@peak-ai/canvas 1.4.0 → 1.4.2-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/.babelrc +14 -0
  2. package/.eslintignore +5 -0
  3. package/.eslintrc.js +29 -0
  4. package/{GrapesjsCanvas.d.ts → dist/GrapesjsCanvas.d.ts} +7 -1
  5. package/{GrapesjsCanvas.js → dist/GrapesjsCanvas.js} +1 -1
  6. package/dist/GrapesjsCanvas.js.map +1 -0
  7. package/dist/package.json +58 -0
  8. package/dist/plugins/helpers/data-table.js +2 -0
  9. package/dist/plugins/helpers/data-table.js.map +1 -0
  10. package/dist/plugins/helpers/render-components.js +10 -0
  11. package/dist/plugins/helpers/render-components.js.map +1 -0
  12. package/dist/shadcn/components/ui/filter.js +3 -0
  13. package/dist/shadcn/components/ui/filter.js.map +1 -0
  14. package/{shadcn → dist/shadcn}/components/ui/search.js +1 -1
  15. package/dist/shadcn/components/ui/search.js.map +1 -0
  16. package/package.json +45 -7
  17. package/scripts/build.ts +88 -0
  18. package/src/GrapesjsCanvas.tsx +332 -0
  19. package/src/constants/index.ts +27 -0
  20. package/src/helpers/compiled-table.css +2429 -0
  21. package/src/helpers/css.ts +2375 -0
  22. package/src/helpers/date-picker.ts +807 -0
  23. package/src/helpers/index.ts +13 -0
  24. package/src/helpers/merge-json.ts +106 -0
  25. package/src/index.styles.ts +58 -0
  26. package/src/index.ts +4 -0
  27. package/src/plugins/grapejs-plugin.tsx +139 -0
  28. package/src/plugins/helpers/data-table.tsx +282 -0
  29. package/src/plugins/helpers/extra.tsx +164 -0
  30. package/src/plugins/helpers/render-components.tsx +911 -0
  31. package/src/public/canvas.css +42 -0
  32. package/src/public/components-css/table/table-output.css +2436 -0
  33. package/src/public/components-css/table/table.css +30 -0
  34. package/src/public/output.css +2199 -0
  35. package/src/public/table.css +135 -0
  36. package/src/shadcn/components/ui/button.tsx +132 -0
  37. package/src/shadcn/components/ui/card.tsx +92 -0
  38. package/src/shadcn/components/ui/chart.tsx +324 -0
  39. package/src/shadcn/components/ui/checkbox.tsx +27 -0
  40. package/src/shadcn/components/ui/date-filter.tsx +816 -0
  41. package/src/shadcn/components/ui/filter.tsx +355 -0
  42. package/src/shadcn/components/ui/hover-card.tsx +36 -0
  43. package/src/shadcn/components/ui/input.tsx +20 -0
  44. package/src/shadcn/components/ui/label.tsx +24 -0
  45. package/src/shadcn/components/ui/pagination.tsx +213 -0
  46. package/src/shadcn/components/ui/scroll-area.tsx +59 -0
  47. package/src/shadcn/components/ui/search.tsx +164 -0
  48. package/src/shadcn/components/ui/separator.tsx +26 -0
  49. package/src/shadcn/components/ui/skeleton.tsx +69 -0
  50. package/src/shadcn/components/ui/table.tsx +196 -0
  51. package/src/shadcn/components/ui/tabs.tsx +55 -0
  52. package/src/shadcn/components/ui/textarea.tsx +18 -0
  53. package/src/shadcn/components/ui/tooltip.tsx +87 -0
  54. package/src/shadcn/utils.ts +6 -0
  55. package/src/types/grapesjs-tailwind.d.ts +50 -0
  56. package/tailwind.config.js +5 -0
  57. package/tooling/tailwind-compiler/index.js +99 -0
  58. package/tooling/tailwind-compiler/package.json +11 -0
  59. package/tooling/tailwind-compiler/yarn.lock +123 -0
  60. package/tsconfig.build.json +15 -0
  61. package/tsconfig.json +8 -0
  62. package/GrapesjsCanvas.js.map +0 -1
  63. package/plugins/helpers/data-table.js +0 -2
  64. package/plugins/helpers/data-table.js.map +0 -1
  65. package/plugins/helpers/render-components.js +0 -10
  66. package/plugins/helpers/render-components.js.map +0 -1
  67. package/shadcn/components/ui/filter.js +0 -3
  68. package/shadcn/components/ui/filter.js.map +0 -1
  69. package/shadcn/components/ui/search.js.map +0 -1
  70. /package/{constants → dist/constants}/index.d.ts +0 -0
  71. /package/{constants → dist/constants}/index.js +0 -0
  72. /package/{constants → dist/constants}/index.js.map +0 -0
  73. /package/{helpers → dist/helpers}/compiled-table.css +0 -0
  74. /package/{helpers → dist/helpers}/css.d.ts +0 -0
  75. /package/{helpers → dist/helpers}/css.js +0 -0
  76. /package/{helpers → dist/helpers}/css.js.map +0 -0
  77. /package/{helpers → dist/helpers}/date-picker.d.ts +0 -0
  78. /package/{helpers → dist/helpers}/date-picker.js +0 -0
  79. /package/{helpers → dist/helpers}/date-picker.js.map +0 -0
  80. /package/{helpers → dist/helpers}/index.d.ts +0 -0
  81. /package/{helpers → dist/helpers}/index.js +0 -0
  82. /package/{helpers → dist/helpers}/index.js.map +0 -0
  83. /package/{helpers → dist/helpers}/merge-json.d.ts +0 -0
  84. /package/{helpers → dist/helpers}/merge-json.js +0 -0
  85. /package/{helpers → dist/helpers}/merge-json.js.map +0 -0
  86. /package/{index.d.ts → dist/index.d.ts} +0 -0
  87. /package/{index.js → dist/index.js} +0 -0
  88. /package/{index.js.map → dist/index.js.map} +0 -0
  89. /package/{index.styles.d.ts → dist/index.styles.d.ts} +0 -0
  90. /package/{index.styles.js → dist/index.styles.js} +0 -0
  91. /package/{index.styles.js.map → dist/index.styles.js.map} +0 -0
  92. /package/{plugins → dist/plugins}/grapejs-plugin.d.ts +0 -0
  93. /package/{plugins → dist/plugins}/grapejs-plugin.js +0 -0
  94. /package/{plugins → dist/plugins}/grapejs-plugin.js.map +0 -0
  95. /package/{plugins → dist/plugins}/helpers/data-table.d.ts +0 -0
  96. /package/{plugins → dist/plugins}/helpers/extra.d.ts +0 -0
  97. /package/{plugins → dist/plugins}/helpers/extra.js +0 -0
  98. /package/{plugins → dist/plugins}/helpers/extra.js.map +0 -0
  99. /package/{plugins → dist/plugins}/helpers/render-components.d.ts +0 -0
  100. /package/{shadcn → dist/shadcn}/components/ui/button.d.ts +0 -0
  101. /package/{shadcn → dist/shadcn}/components/ui/button.js +0 -0
  102. /package/{shadcn → dist/shadcn}/components/ui/button.js.map +0 -0
  103. /package/{shadcn → dist/shadcn}/components/ui/card.d.ts +0 -0
  104. /package/{shadcn → dist/shadcn}/components/ui/card.js +0 -0
  105. /package/{shadcn → dist/shadcn}/components/ui/card.js.map +0 -0
  106. /package/{shadcn → dist/shadcn}/components/ui/chart.d.ts +0 -0
  107. /package/{shadcn → dist/shadcn}/components/ui/chart.js +0 -0
  108. /package/{shadcn → dist/shadcn}/components/ui/chart.js.map +0 -0
  109. /package/{shadcn → dist/shadcn}/components/ui/checkbox.d.ts +0 -0
  110. /package/{shadcn → dist/shadcn}/components/ui/checkbox.js +0 -0
  111. /package/{shadcn → dist/shadcn}/components/ui/checkbox.js.map +0 -0
  112. /package/{shadcn → dist/shadcn}/components/ui/date-filter.d.ts +0 -0
  113. /package/{shadcn → dist/shadcn}/components/ui/date-filter.js +0 -0
  114. /package/{shadcn → dist/shadcn}/components/ui/date-filter.js.map +0 -0
  115. /package/{shadcn → dist/shadcn}/components/ui/filter.d.ts +0 -0
  116. /package/{shadcn → dist/shadcn}/components/ui/hover-card.d.ts +0 -0
  117. /package/{shadcn → dist/shadcn}/components/ui/hover-card.js +0 -0
  118. /package/{shadcn → dist/shadcn}/components/ui/hover-card.js.map +0 -0
  119. /package/{shadcn → dist/shadcn}/components/ui/input.d.ts +0 -0
  120. /package/{shadcn → dist/shadcn}/components/ui/input.js +0 -0
  121. /package/{shadcn → dist/shadcn}/components/ui/input.js.map +0 -0
  122. /package/{shadcn → dist/shadcn}/components/ui/label.d.ts +0 -0
  123. /package/{shadcn → dist/shadcn}/components/ui/label.js +0 -0
  124. /package/{shadcn → dist/shadcn}/components/ui/label.js.map +0 -0
  125. /package/{shadcn → dist/shadcn}/components/ui/pagination.d.ts +0 -0
  126. /package/{shadcn → dist/shadcn}/components/ui/pagination.js +0 -0
  127. /package/{shadcn → dist/shadcn}/components/ui/pagination.js.map +0 -0
  128. /package/{shadcn → dist/shadcn}/components/ui/scroll-area.d.ts +0 -0
  129. /package/{shadcn → dist/shadcn}/components/ui/scroll-area.js +0 -0
  130. /package/{shadcn → dist/shadcn}/components/ui/scroll-area.js.map +0 -0
  131. /package/{shadcn → dist/shadcn}/components/ui/search.d.ts +0 -0
  132. /package/{shadcn → dist/shadcn}/components/ui/separator.d.ts +0 -0
  133. /package/{shadcn → dist/shadcn}/components/ui/separator.js +0 -0
  134. /package/{shadcn → dist/shadcn}/components/ui/separator.js.map +0 -0
  135. /package/{shadcn → dist/shadcn}/components/ui/skeleton.d.ts +0 -0
  136. /package/{shadcn → dist/shadcn}/components/ui/skeleton.js +0 -0
  137. /package/{shadcn → dist/shadcn}/components/ui/skeleton.js.map +0 -0
  138. /package/{shadcn → dist/shadcn}/components/ui/table.d.ts +0 -0
  139. /package/{shadcn → dist/shadcn}/components/ui/table.js +0 -0
  140. /package/{shadcn → dist/shadcn}/components/ui/table.js.map +0 -0
  141. /package/{shadcn → dist/shadcn}/components/ui/tabs.d.ts +0 -0
  142. /package/{shadcn → dist/shadcn}/components/ui/tabs.js +0 -0
  143. /package/{shadcn → dist/shadcn}/components/ui/tabs.js.map +0 -0
  144. /package/{shadcn → dist/shadcn}/components/ui/textarea.d.ts +0 -0
  145. /package/{shadcn → dist/shadcn}/components/ui/textarea.js +0 -0
  146. /package/{shadcn → dist/shadcn}/components/ui/textarea.js.map +0 -0
  147. /package/{shadcn → dist/shadcn}/components/ui/tooltip.d.ts +0 -0
  148. /package/{shadcn → dist/shadcn}/components/ui/tooltip.js +0 -0
  149. /package/{shadcn → dist/shadcn}/components/ui/tooltip.js.map +0 -0
  150. /package/{shadcn → dist/shadcn}/utils.d.ts +0 -0
  151. /package/{shadcn → dist/shadcn}/utils.js +0 -0
  152. /package/{shadcn → dist/shadcn}/utils.js.map +0 -0
  153. /package/{types → dist/types}/grapesjs-tailwind.d.js +0 -0
  154. /package/{types → dist/types}/grapesjs-tailwind.d.js.map +0 -0
package/.babelrc ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "presets": [
3
+ "@babel/preset-typescript",
4
+ ["@babel/preset-react", { "runtime": "automatic" }],
5
+ ["@babel/preset-env", { "modules": false, "loose": true }]
6
+ ],
7
+ "plugins": [
8
+ "babel-plugin-styled-components",
9
+ ["@babel/plugin-transform-class-properties", { "loose": true }],
10
+ ["@babel/plugin-transform-private-methods", { "loose": true }],
11
+ ["@babel/plugin-transform-private-property-in-object", { "loose": true }],
12
+ "@babel/plugin-transform-runtime"
13
+ ]
14
+ }
package/.eslintignore ADDED
@@ -0,0 +1,5 @@
1
+ node_modules/
2
+ dist/
3
+ commitlint.config.js
4
+ jest.config.ts
5
+ .eslintrc.js
package/.eslintrc.js ADDED
@@ -0,0 +1,29 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ root: true,
5
+ parserOptions: {
6
+ project: path.resolve(__dirname, 'tsconfig.json'),
7
+ tsconfigRootDir: __dirname,
8
+ },
9
+ settings: {
10
+ 'import/resolver': {
11
+ typescript: {
12
+ project: path.resolve(__dirname, 'tsconfig.json'),
13
+ },
14
+ },
15
+ },
16
+ extends: [
17
+ '@peak-ai/eslint-config-peak-api',
18
+ '@peak-ai/eslint-config-peak-base',
19
+ '@peak-ai/eslint-config-peak-typescript',
20
+ ],
21
+ overrides: [
22
+ {
23
+ files: ['**/*.test.ts', '**/*.test.tsx'],
24
+ env: {
25
+ jest: true,
26
+ },
27
+ },
28
+ ],
29
+ };
@@ -1,10 +1,16 @@
1
1
  import { Editor } from 'grapesjs';
2
2
  import 'grapesjs/dist/css/grapes.min.css';
3
+ type NotificationHandler = (newData: {
4
+ componentId: string;
5
+ newProps: Record<string, any>;
6
+ newAttributes: Record<string, any>;
7
+ }) => boolean;
3
8
  type GrapesjsCanvasProps = {
4
9
  json: any;
5
10
  mode?: 'editor' | 'preview';
6
11
  setEditor: (editor: Editor) => void;
7
12
  performInteraction: (payload: Record<string, any>) => Promise<Record<string, any> | undefined>;
13
+ newDataNotifier: (notifHandler: NotificationHandler) => void;
8
14
  };
9
- declare function GrapesjsCanvas({ json, mode, setEditor, performInteraction, }: GrapesjsCanvasProps): import("react/jsx-runtime").JSX.Element;
15
+ declare function GrapesjsCanvas({ json, mode, setEditor, performInteraction, newDataNotifier, }: GrapesjsCanvasProps): import("react/jsx-runtime").JSX.Element;
10
16
  export default GrapesjsCanvas;
@@ -1,5 +1,5 @@
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{createGrapesjsShadcnGenericPlugin}from"./plugins/grapejs-plugin";import{StyledEditor}from"./index.styles";import{tailwindCompiledCss}from"./helpers/css";import{datePickerCss}from"./helpers/date-picker";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 expandActions(node){var _node$componentProps;if(node.type==="shadcn-generic"&&node.componentName==="Actions"&&Array.isArray((_node$componentProps=node.componentProps)==null?void 0:_node$componentProps.actions)){var actions=node.componentProps.actions;return _extends({},node,{type:"div",classes:["dashboard-cards"].concat(node.classes||[]),componentName:undefined,componentProps:undefined,components:actions.map(function(action,i){var icon=action.icon,title=action.title,description=action.description;return{id:node.id+"--action-card-"+i,type:"shadcn-generic",componentName:"ActionCard",badgable:false,copyable:false,componentProps:{icon:icon,headerContent:title,bodyContent:description}}})})}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 GrapesjsCanvas(_ref2){var json=_ref2.json,_ref2$mode=_ref2.mode,mode=_ref2$mode===void 0?"preview":_ref2$mode,setEditor=_ref2.setEditor,performInteraction=_ref2.performInteraction;var editorRef=useRef(null);var editorInstance=useRef(null);var renderedComponents={};function performInteractionWrapper(_x){return _performInteractionWrapper.apply(this,arguments)}function _performInteractionWrapper(){_performInteractionWrapper=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload){var _editorInstance$curre;var updatedJson,result;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return(_editorInstance$curre=editorInstance.current)==null?void 0:_editorInstance$curre.store();case 2:updatedJson=_context.sent;setInteracting(renderedComponents,payload.affectedComponents,true);_context.prev=4;_context.next=7;return performInteraction(_extends({},payload,{json:updatedJson}));case 7:result=_context.sent;Object.entries(result||{}).forEach(function(_ref4){var key=_ref4[0],value=_ref4[1];var model=renderedComponents[key];if(model){model.set("componentProps",_extends({},model.get("componentProps"),value))}});return _context.abrupt("return",result);case 10:_context.prev=10;setInteracting(renderedComponents,payload.affectedComponents,false);return _context.finish(10);case 13:case"end":return _context.stop()}},_callee,null,[[4,,10,13]])}));return _performInteractionWrapper.apply(this,arguments)}useEffect(function(){var _json$pages,_json$pages$0$frames;if(!editorRef.current){return function(){// Cleanup if editorRef is not available
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{createGrapesjsShadcnGenericPlugin}from"./plugins/grapejs-plugin";import{StyledEditor}from"./index.styles";import{tailwindCompiledCss}from"./helpers/css";import{datePickerCss}from"./helpers/date-picker";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 expandActions(node){var _node$componentProps;if(node.type==="shadcn-generic"&&node.componentName==="Actions"&&Array.isArray((_node$componentProps=node.componentProps)==null?void 0:_node$componentProps.actions)){var actions=node.componentProps.actions;return _extends({},node,{type:"div",classes:["dashboard-cards"].concat(node.classes||[]),componentName:undefined,componentProps:undefined,components:actions.map(function(action,i){var icon=action.icon,title=action.title,description=action.description;return{id:node.id+"--action-card-"+i,type:"shadcn-generic",componentName:"ActionCard",badgable:false,copyable:false,componentProps:{icon:icon,headerContent:title,bodyContent:description}}})})}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 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(){}:_ref2$newDataNotifier;var editorRef=useRef(null);var editorInstance=useRef(null);var renderedComponents={};function notificationHandler(props){if(!props){return true}var componentId=props.componentId,newProps=props.newProps,newAttributes=props.newAttributes;var model=renderedComponents[componentId];if(!model){return false}var parsedNewProps=_extends({},newProps);if(newProps.pagination){parsedNewProps.pagination=_extends({},model.get("componentProps").pagination||{},newProps.pagination)}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 _callee(payload){var _editorInstance$curre;var updatedJson,result;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return(_editorInstance$curre=editorInstance.current)==null?void 0:_editorInstance$curre.store();case 2:updatedJson=_context.sent;setInteracting(renderedComponents,payload.affectedComponents,true);_context.prev=4;_context.next=7;return performInteraction(_extends({},payload,{json:updatedJson}));case 7:result=_context.sent;Object.entries(result||{}).forEach(function(_ref4){var key=_ref4[0],value=_ref4[1];var model=renderedComponents[key];if(model){model.set("componentProps",_extends({},model.get("componentProps"),value))}});return _context.abrupt("return",result);case 10:_context.prev=10;setInteracting(renderedComponents,payload.affectedComponents,false);return _context.finish(10);case 13:case"end":return _context.stop()}},_callee,null,[[4,,10,13]])}));return _performInteractionWrapper.apply(this,arguments)}useEffect(function(){var _json$pages,_json$pages$0$frames;if(!editorRef.current){return function(){// Cleanup if editorRef is not available
3
3
  }}if(editorInstance.current){editorInstance.current.destroy();editorInstance.current=null}var currentMode=mode;var editor=grapesjs.init({container:editorRef.current,height:"100%",plugins:[tailwind,createGrapesjsShadcnGenericPlugin(currentMode,performInteractionWrapper,renderedComponents)],storageManager:{type:"none"},richTextEditor:{actions:["bold","italic","underline","strikethrough"]},canvas:{customBadgeLabel:function customBadgeLabel(component){var tagName=component.get("tagName");return tagName==="body"?"":tagName||""}}});// Tailwind CSS rules aren't fully added to our component
4
4
  // So, adding them from here!
5
5
  editor.on("load",function(){var canvasHead=editor.Canvas.getDocument().head;var style=document.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 \n ";style.innerHTML=fullCss;style.setAttribute("type","text/css");canvasHead.appendChild(style)});editorInstance.current=editor;if(setEditor){setEditor(editor)}TypesToRegister.forEach(function(_ref3){var type=_ref3.type,tagName=_ref3.tagName;if(!editor.DomComponents.getType(type)){editor.DomComponents.addType(type,{model:{defaults:{tagName:tagName}},view:{}})}});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 raw=json.pages[0].frames[0].component;var processed=expandActions(raw);editor.setComponents(processed);var cssText=convertStyles(json.styles||[]);editor.setStyle(cssText)}editor.on("load",function(){setComponentProperties(editor,mode==="preview")});return function(){editor.destroy()};// eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GrapesjsCanvas.js","names":["React","useEffect","useRef","grapesjs","tailwind","TypesToRegister","toKebabCase","createGrapesjsShadcnGenericPlugin","StyledEditor","tailwindCompiledCss","datePickerCss","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","expandActions","node","_node$componentProps","type","componentName","componentProps","actions","_extends","classes","concat","undefined","action","i","icon","title","description","id","headerContent","bodyContent","setInteracting","renderedComponents","inProgress","component","componentId","showLoader","gjsModel","get","interactionApiInProgress","GrapesjsCanvas","_ref2","json","_ref2$mode","mode","setEditor","performInteraction","_ref2$newDataNotifier","newDataNotifier","editorRef","editorInstance","notificationHandler","props","newProps","newAttributes","model","parsedNewProps","pagination","performInteractionWrapper","_x","_performInteractionWrapper","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","payload","_editorInstance$curre","updatedJson","result","wrap","_callee$","_context","prev","next","current","store","sent","affectedComponents","_ref4","key","abrupt","finish","stop","_json$pages","_json$pages$0$frames","destroy","currentMode","init","container","height","plugins","storageManager","richTextEditor","canvas","customBadgeLabel","tagName","on","canvasHead","Canvas","getDocument","head","document","createElement","fullCss","innerHTML","setAttribute","appendChild","_ref3","DomComponents","getType","addType","defaults","view","pages","length","frames","raw","processed","setComponents","cssText","styles","setStyle","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';\nimport { TypesToRegister } from './constants';\nimport { toKebabCase } from './helpers';\nimport { createGrapesjsShadcnGenericPlugin } from './plugins/grapejs-plugin';\nimport { StyledEditor } from './index.styles';\nimport { tailwindCompiledCss } from './helpers/css';\nimport { datePickerCss } from './helpers/date-picker';\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};\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 expandActions(node: any): any {\n if (\n node.type === 'shadcn-generic' &&\n node.componentName === 'Actions' &&\n Array.isArray(node.componentProps?.actions)\n ) {\n const { actions } = node.componentProps;\n\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 const { icon, title, description } = action;\n\n return {\n id: `${node.id}--action-card-${i}`,\n type: 'shadcn-generic',\n componentName: 'ActionCard',\n badgable: false,\n copyable: false,\n componentProps: {\n icon,\n headerContent: title,\n bodyContent: description,\n },\n };\n }),\n };\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 GrapesjsCanvas({\n json,\n mode = 'preview',\n setEditor,\n performInteraction,\n newDataNotifier = () => {},\n}: GrapesjsCanvasProps) {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<any>(null);\n const renderedComponents: Record<string, Component> = {};\n\n function notificationHandler(props: Parameters<NotificationHandler>[0]): ReturnType<NotificationHandler> {\n if (!props) {\n return true;\n }\n\n const {\n componentId,\n newProps,\n newAttributes,\n } = props;\n const model = renderedComponents[componentId];\n\n if (!model) {\n return false;\n }\n\n const parsedNewProps = {\n ...newProps,\n };\n\n if (newProps.pagination) {\n parsedNewProps.pagination = {\n ...(model.get('componentProps').pagination || {}),\n ...newProps.pagination,\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, payload.affectedComponents, true);\n\n try {\n const result = await performInteraction({\n ...payload,\n json: updatedJson,\n });\n\n Object.entries(result || {}).forEach(([key, value]) => {\n const model = renderedComponents[key];\n\n if (model) {\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...value,\n });\n }\n });\n\n return result;\n } finally {\n setInteracting(renderedComponents, payload.affectedComponents, false);\n }\n }\n\n useEffect(() => {\n if (!editorRef.current) {\n return () => {\n // Cleanup if editorRef is not available\n };\n }\n\n if (editorInstance.current) {\n editorInstance.current.destroy();\n editorInstance.current = null;\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,\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 // Tailwind CSS rules aren't fully added to our component\n // So, adding them from here!\n editor.on('load', () => {\n const canvasHead = editor.Canvas.getDocument().head;\n const style = document.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 `;\n style.innerHTML = fullCss;\n style.setAttribute('type', 'text/css');\n canvasHead.appendChild(style);\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 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\n editor.on('load', () => {\n setComponentProperties(editor, mode === 'preview');\n });\n\n return () => {\n editor.destroy();\n };\n // eslint-disable-next-line @typescript-eslint/no-empty-function\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,CACxC,OAASC,eAAe,KAAQ,aAAa,CAC7C,OAASC,WAAW,KAAQ,WAAW,CACvC,OAASC,iCAAiC,KAAQ,0BAA0B,CAC5E,OAASC,YAAY,KAAQ,gBAAgB,CAC7C,OAASC,mBAAmB,KAAQ,eAAe,CACnD,OAASC,aAAa,KAAQ,uBAAuB,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAgBtD,QAAS,CAAAC,sBAAsBA,CAACC,MAAc,CAAEC,SAAkB,CAAE,CAClE,QAAS,CAAAC,wBAAwBA,CAACC,IAAe,CAAE,CACjDA,IAAI,CAACC,GAAG,CAAC,CACPC,QAAQ,CAAE,CAACJ,SAAS,CACpBK,SAAS,CAAE,CAACL,SAAS,CACrBM,SAAS,CAAE,CAACN,SAAS,EAAIE,IAAI,CAACK,OAAO,CAAC,CAAC,GAAK,gBAAgB,CAC5DC,UAAU,CAAE,CAACR,SAAS,CACtBS,SAAS,CAAE,CAACT,SAAS,CACrBU,aAAa,CAAE,CAACV,SAAS,CACzBW,QAAQ,CAAE,KAAK,CACfC,SAAS,CAAE,KAAK,CAChBC,SAAS,CAAE,CAACb,SAAS,CACrBc,QAAQ,CAAE,KACZ,CAAC,CAAC,CAEF,GAAI,CAACd,SAAS,CAAE,CACdE,IAAI,CAACC,GAAG,CAAC,SAA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,QAAQ,EAAAC,QAAA,eACb7J,IAAA,CAACJ,YAAY,GAAE,CAAC,cAChBI,IAAA,QAAK8J,GAAG,CAAE7E,SAAU,CAACrB,EAAE,CAAC,iBAAiB,CAAE,CAAC,EAC9B,CAEpB,CAEA,cAAe,CAAAY,cAAc","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@peak-ai/canvas",
3
+ "author": "squad-builder-experience",
4
+ "license": "UNLICENSED",
5
+ "version": "1.4.2-rc.0",
6
+ "description": "",
7
+ "dependencies": {
8
+ "@peak-ai/ais-components": "6.41.0",
9
+ "@radix-ui/react-checkbox": "^1.3.2",
10
+ "@radix-ui/react-hover-card": "^1.1.7",
11
+ "@radix-ui/react-label": "^2.1.3",
12
+ "@radix-ui/react-scroll-area": "^1.2.5",
13
+ "@radix-ui/react-separator": "^1.1.3",
14
+ "@radix-ui/react-slot": "^1.2.0",
15
+ "@radix-ui/react-tabs": "1.0.0",
16
+ "@radix-ui/react-tooltip": "^1.2.7",
17
+ "@tailwindcss/cli": "^4.1.3",
18
+ "@types/chroma-js": "^3.1.1",
19
+ "@types/react-datepicker": "^7.0.0",
20
+ "chroma-js": "^3.1.2",
21
+ "class-variance-authority": "^0.7.1",
22
+ "clsx": "^2.1.1",
23
+ "date-fns": "^4.1.0",
24
+ "grapesjs": "0.22.6",
25
+ "grapesjs-tailwind": "1.0.7",
26
+ "lodash": "^4.17.21",
27
+ "lucide-react": "^0.525.0",
28
+ "markdown": "^0.5.0",
29
+ "markdown-to-jsx": "7.4.1",
30
+ "plotly.js": "2.34.0",
31
+ "react": "^17.0.2",
32
+ "react-datepicker": "^8.4.0",
33
+ "react-dom": "^17.0.2",
34
+ "react-plotly.js": "^2.6.0",
35
+ "react-resizable-panels": "^2.1.9",
36
+ "styled-components": "^5.0.0",
37
+ "tailwind-merge": "^3.2.0",
38
+ "tailwindcss": "^4.1.3",
39
+ "tailwindcss-animate": "^1.0.7",
40
+ "tslib": "^2.7.0",
41
+ "tw-animate-css": "^1.2.5",
42
+ "sherlockjs": "^1.4.2",
43
+ "date-fns-tz": "^2.0.0"
44
+ },
45
+ "peerDependencies": {
46
+ "react": "^17.0.2",
47
+ "react-dom": "^17.0.2"
48
+ },
49
+ "resolutions": {
50
+ "@babel/traverse": "7.25.7",
51
+ "minimist": "1.2.6",
52
+ "tar": "^6.1.11"
53
+ },
54
+ "main": "index.js",
55
+ "types": "index.d.ts",
56
+ "module": "index.js",
57
+ "sideEffects": false
58
+ }
@@ -0,0 +1,2 @@
1
+ import _extends from"@babel/runtime/helpers/extends";import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _regeneratorRuntime from"@babel/runtime/regenerator";/* eslint-disable @typescript-eslint/no-explicit-any */import{useEffect,useState,Fragment}from"react";import{Table,TableHeader,TableRow,TableHead,TableBody,TableCell,TableHeadSortable}from"../../shadcn/components/ui/table";import{TableLoader}from"../../shadcn/components/ui/skeleton";import{ScrollArea,ScrollBar}from"../../shadcn/components/ui/scroll-area";import{Pagination,PaginationContent,renderPaginationArrows}from"../../shadcn/components/ui/pagination";import{TableButton}from"../../shadcn/components/ui/button";import{cn}from"../../shadcn/utils";import{renderNoDataFallback}from"./extra";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function DataTable(_ref){var _ref2,_pagination$values$pa,_pagination$values,_ref3,_pagination$values$pa2,_pagination$values2;var _ref$data=_ref.data,data=_ref$data===void 0?[]:_ref$data,_ref$headerMapper=_ref.headerMapper,headerMapper=_ref$headerMapper===void 0?{}:_ref$headerMapper,_ref$className=_ref.className,className=_ref$className===void 0?"":_ref$className,_ref$actions=_ref.actions,actions=_ref$actions===void 0?[]:_ref$actions,_ref$isEditable=_ref.isEditable,isEditable=_ref$isEditable===void 0?false:_ref$isEditable,pagination=_ref.pagination,_ref$isLoading=_ref.isLoading,isLoading=_ref$isLoading===void 0?false:_ref$isLoading,onRowAction=_ref.onRowAction,onPageChange=_ref.onPageChange,onSort=_ref.onSort,sortConfig=_ref.sortConfig,_ref$otherProps=_ref.otherProps,otherProps=_ref$otherProps===void 0?{}:_ref$otherProps;var _useState=useState(null),activeSortColumn=_useState[0],setActiveSortColumn=_useState[1];var _useState2=useState({}),sortDirections=_useState2[0],setSortDirections=_useState2[1];var _useState3=useState(Number((_ref2=(_pagination$values$pa=pagination==null||(_pagination$values=pagination.values)==null?void 0:_pagination$values.pageNumber)!=null?_pagination$values$pa:pagination==null?void 0:pagination.initialPage)!=null?_ref2:1)),pageNumber=_useState3[0],setPageNumber=_useState3[1];var _useState4=useState(Number((_ref3=(_pagination$values$pa2=pagination==null||(_pagination$values2=pagination.values)==null?void 0:_pagination$values2.pageSize)!=null?_pagination$values$pa2:pagination==null?void 0:pagination.initialPageSize)!=null?_ref3:10)),pageSize=_useState4[0],setPageSize=_useState4[1];var _useState5=useState(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1),totalPages=_useState5[0],setTotalPages=_useState5[1];useEffect(function(){var _ref4,_pagination$values$pa3,_pagination$values3,_ref5,_pagination$values$pa4,_pagination$values4;setPageNumber(Number((_ref4=(_pagination$values$pa3=pagination==null||(_pagination$values3=pagination.values)==null?void 0:_pagination$values3.pageNumber)!=null?_pagination$values$pa3:pagination==null?void 0:pagination.initialPage)!=null?_ref4:1));setPageSize(Number((_ref5=(_pagination$values$pa4=pagination==null||(_pagination$values4=pagination.values)==null?void 0:_pagination$values4.pageSize)!=null?_pagination$values$pa4:pagination==null?void 0:pagination.initialPageSize)!=null?_ref5:25))},[pagination]);useEffect(function(){setTotalPages(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1)},[pagination==null?void 0:pagination.totalCount,pageSize]);useEffect(function(){if(sortConfig){setSortDirections(sortConfig);var first=Object.keys(sortConfig)[0];if(first){setActiveSortColumn(first)}}},[sortConfig]);var originalKeys=Object.keys(data[0]||{}).filter(function(key){return key in headerMapper});var headers=originalKeys.map(function(key){return headerMapper[key]});if(actions.length>0){headers.push("")}var rows=data.map(function(datum){return originalKeys.map(function(key){return datum[key]})});function handlePageChange(_x,_x2){return _handlePageChange.apply(this,arguments)}function _handlePageChange(){_handlePageChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(newPage,newSize){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(newPage===void 0){newPage=pageNumber}if(newSize===void 0){newSize=pageSize}setPageNumber(newPage);setPageSize(newSize);onPageChange==null||onPageChange(newPage,newSize);case 5:case"end":return _context.stop()}},_callee)}));return _handlePageChange.apply(this,arguments)}function handleSortClick(column,direction){setActiveSortColumn(direction?column:null);setSortDirections(function(prev){var _extends2;return _extends({},prev,(_extends2={},_extends2[column]=direction,_extends2))});onSort==null||onSort(column,direction)}function renderActions(rowIndex,rowActions){if(!actions.length){return null}return/*#__PURE__*/_jsx(TableCell,{className:"sticky right-0 bg-white",children:rowActions.map(function(action){return/*#__PURE__*/_jsx(TableButton,{className:action.className,isEditable:isEditable,onClick:function onClick(){return onRowAction==null?void 0:onRowAction(rowIndex,action.id)},variant:action.variant,text:action.text,tooltipContent:action.tooltipContent},action.id)})})}var actualRowCount=rows.length;var headerHeight=48;var rowHeight=40;var maxHeight=250;var calculatedHeight=headerHeight+actualRowCount*rowHeight;var tableHeight=Math.min(calculatedHeight,maxHeight);var defaultClasses="aspect-auto w-full";var mergedClasses=className?cn(defaultClasses,className):defaultClasses;function renderTableComponent(){if(isLoading){return/*#__PURE__*/_jsx(TableLoader,{})}if(!(data!=null&&data.length)&&!isLoading){renderNoDataFallback()}return/*#__PURE__*/_jsxs(Table,_extends({},otherProps,{className:"caption-bottom text-sm relative "+mergedClasses,"data-slot":"table",children:[/*#__PURE__*/_jsx(TableHeader,{"data-slot":"table-header",className:"sticky top-0 z-2",children:/*#__PURE__*/_jsx(TableRow,{children:headers.map(function(head,idx){var isActionColumn=actions.length>0&&idx===headers.length-1;var originalKey=originalKeys[idx];if(isActionColumn){return/*#__PURE__*/_jsx(TableHead,{"data-slot":"table-header-"+idx,contentEditable:isEditable,className:"sticky right-0 bg-slate-100",children:head},idx)}return/*#__PURE__*/_jsx(TableHeadSortable,{"data-slot":"table-header-"+idx,sortDirection:sortDirections[originalKey]||"asc",isActive:activeSortColumn===originalKey,onSort:function onSort(direction){return handleSortClick(originalKey,direction)},sortable:true,isEditable:isEditable,children:head},idx)})})}),/*#__PURE__*/_jsx(TableBody,{"data-slot":"table-body",children:rows.map(function(row,rIdx){return/*#__PURE__*/_jsxs(TableRow,{"data-slot":"row-"+rIdx,className:"hover:bg-muted/50 border-b transition-colors",children:[row.map(function(cell,cIdx){return/*#__PURE__*/_jsx(TableCell,{"data-slot":"cell-"+rIdx+"-"+cIdx,className:"p-2 align-middle whitespace-nowrap",contentEditable:false,children:cell},cIdx)}),renderActions(rIdx,actions)]},rIdx)})})]}))}return/*#__PURE__*/_jsxs(Fragment,{children:[/*#__PURE__*/_jsxs(ScrollArea,{"data-slot":"table-container",className:mergedClasses,style:{height:tableHeight+"px"},children:[renderTableComponent(),/*#__PURE__*/_jsx(ScrollBar,{orientation:"horizontal"})]}),pagination&&pagination.totalCount>0&&/*#__PURE__*/_jsxs("div",{className:"flex items-center justify-between mt-2 w-full overflow-x-auto",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[/*#__PURE__*/_jsx("label",{htmlFor:"page-size-select",className:"text-sm whitespace-nowrap",children:"Rows per page:"}),/*#__PURE__*/_jsx("select",{id:"page-size-select",value:pageSize,onChange:function onChange(e){return handlePageChange(1,Number(e.target.value))},className:"border rounded px-2 py-1 text-sm cursor-pointer",disabled:isLoading,children:pagination.pageSizeOptions.map(function(size){return/*#__PURE__*/_jsx("option",{value:size,children:size},size)})})]}),/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[/*#__PURE__*/_jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[(pageNumber-1)*pageSize+1,"\u2013",Math.min(pageNumber*pageSize,pagination.totalCount)," of ",pagination.totalCount]}),/*#__PURE__*/_jsx(Pagination,{children:/*#__PURE__*/_jsx(PaginationContent,{className:"gap-0.2 flex-shrink-0",children:renderPaginationArrows(pageNumber,totalPages,isLoading,handlePageChange)})})]})]})]})}
2
+ //# sourceMappingURL=data-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-table.js","names":["useEffect","useState","Fragment","Table","TableHeader","TableRow","TableHead","TableBody","TableCell","TableHeadSortable","TableLoader","ScrollArea","ScrollBar","Pagination","PaginationContent","renderPaginationArrows","TableButton","cn","renderNoDataFallback","jsx","_jsx","jsxs","_jsxs","DataTable","_ref","_ref2","_pagination$values$pa","_pagination$values","_ref3","_pagination$values$pa2","_pagination$values2","_ref$data","data","_ref$headerMapper","headerMapper","_ref$className","className","_ref$actions","actions","_ref$isEditable","isEditable","pagination","_ref$isLoading","isLoading","onRowAction","onPageChange","onSort","sortConfig","_ref$otherProps","otherProps","_useState","activeSortColumn","setActiveSortColumn","_useState2","sortDirections","setSortDirections","_useState3","Number","values","pageNumber","initialPage","setPageNumber","_useState4","pageSize","initialPageSize","setPageSize","_useState5","Math","ceil","totalCount","totalPages","setTotalPages","_ref4","_pagination$values$pa3","_pagination$values3","_ref5","_pagination$values$pa4","_pagination$values4","first","Object","keys","originalKeys","filter","key","headers","map","length","push","rows","datum","handlePageChange","_x","_x2","_handlePageChange","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","newPage","newSize","wrap","_callee$","_context","prev","next","stop","handleSortClick","column","direction","_extends2","_extends","renderActions","rowIndex","rowActions","children","action","onClick","id","variant","text","tooltipContent","actualRowCount","headerHeight","rowHeight","maxHeight","calculatedHeight","tableHeight","min","defaultClasses","mergedClasses","renderTableComponent","head","idx","isActionColumn","originalKey","contentEditable","sortDirection","isActive","sortable","row","rIdx","cell","cIdx","style","height","orientation","htmlFor","value","onChange","e","target","disabled","pageSizeOptions","size"],"sources":["../../../src/plugins/helpers/data-table.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useEffect, useState, Fragment } from 'react';\nimport {\n Table,\n TableHeader,\n TableRow,\n TableHead,\n TableBody,\n TableCell,\n TableHeadSortable,\n SortDirection,\n} from '../../shadcn/components/ui/table';\nimport { TableLoader } from '../../shadcn/components/ui/skeleton';\nimport { ScrollArea, ScrollBar } from '../../shadcn/components/ui/scroll-area';\nimport {\n Pagination,\n PaginationContent,\n renderPaginationArrows,\n} from '../../shadcn/components/ui/pagination';\nimport { TableButton } from '../../shadcn/components/ui/button';\nimport { cn } from '../../shadcn/utils';\nimport { renderNoDataFallback } from './extra'\n\ntype RowAction = {\n id: string;\n text: string;\n variant?: string;\n tooltipContent?: string;\n className?: string;\n};\n\nexport type DataTableProps = {\n data: Record<string, any>[];\n headerMapper?: Record<string, string>;\n className?: string;\n isEditable?: boolean;\n actions?: RowAction[];\n pagination?: {\n values?: {\n pageNumber: number;\n pageSize: number;\n };\n initialPage?: number;\n initialPageSize?: number;\n totalCount: number;\n pageSizeOptions: number[];\n };\n isLoading?: boolean;\n onRowAction?: (rowIndex: number, actionId: string) => void;\n onPageChange?: (pageNumber: number, pageSize: number) => void;\n onSort?: (column: string, direction: SortDirection) => void;\n sortConfig?: Record<string, SortDirection>;\n otherProps?: Record<string, any>;\n};\n\nexport function DataTable({\n data = [],\n headerMapper = {},\n className = '',\n actions = [],\n isEditable = false,\n pagination,\n isLoading = false,\n onRowAction,\n onPageChange,\n onSort,\n sortConfig,\n otherProps = {},\n}: DataTableProps) {\n\n const [activeSortColumn, setActiveSortColumn] = useState<string | null>(null);\n const [sortDirections, setSortDirections] = useState<Record<string, SortDirection>>({});\n\n const [pageNumber, setPageNumber] = useState(\n Number(pagination?.values?.pageNumber ?? pagination?.initialPage ?? 1),\n );\n const [pageSize, setPageSize] = useState(\n Number(pagination?.values?.pageSize ?? pagination?.initialPageSize ?? 10),\n );\n const [totalPages, setTotalPages] = useState(\n Math.ceil((pagination?.totalCount || 0) / pageSize) || 1,\n );\n\n useEffect(() => {\n setPageNumber(Number(pagination?.values?.pageNumber ?? pagination?.initialPage ?? 1));\n setPageSize(Number(pagination?.values?.pageSize ?? pagination?.initialPageSize ?? 25));\n }, [pagination]);\n\n useEffect(() => {\n setTotalPages(Math.ceil((pagination?.totalCount || 0) / pageSize) || 1);\n }, [pagination?.totalCount, pageSize]);\n\n useEffect(() => {\n if (sortConfig) {\n setSortDirections(sortConfig);\n const first = Object.keys(sortConfig)[0];\n\n if (first) {\n setActiveSortColumn(first);\n }\n }\n }, [sortConfig]);\n\n const originalKeys = Object.keys(data[0] || {}).filter((key) => key in headerMapper);\n const headers = originalKeys.map((key) => headerMapper[key]);\n\n if (actions.length > 0) {\n headers.push('');\n }\n\n const rows = data.map((datum: any) => originalKeys.map((key) => datum[key]));\n\n async function handlePageChange(newPage = pageNumber, newSize = pageSize) {\n setPageNumber(newPage);\n setPageSize(newSize);\n onPageChange?.(newPage, newSize);\n }\n\n function handleSortClick(column: string, direction: SortDirection) {\n setActiveSortColumn(direction ? column : null);\n setSortDirections((prev) => ({\n ...prev,\n [column]: direction,\n }));\n onSort?.(column, direction);\n }\n\n function renderActions(rowIndex: number, rowActions: RowAction[]) {\n if (!actions.length) {\n return null;\n }\n\n return (\n <TableCell className=\"sticky right-0 bg-white\">\n {rowActions.map((action) => (\n <TableButton\n key={action.id}\n className={action.className}\n isEditable={isEditable}\n onClick={() => onRowAction?.(rowIndex, action.id)}\n variant={action.variant}\n text={action.text}\n tooltipContent={action.tooltipContent}\n />\n ))}\n </TableCell>\n );\n }\n\n const actualRowCount = rows.length;\n const headerHeight = 48;\n const rowHeight = 40;\n const maxHeight = 250;\n const calculatedHeight = headerHeight + actualRowCount * rowHeight;\n const tableHeight = Math.min(calculatedHeight, maxHeight);\n\n const defaultClasses = `aspect-auto w-full`;\n const mergedClasses = className ? cn(defaultClasses, className) : defaultClasses;\n\n function renderTableComponent() {\n if (isLoading) {\n return <TableLoader />;\n }\n\n if(!data?.length && !isLoading ) {\n renderNoDataFallback()\n }\n\n return (\n <Table\n {...otherProps}\n className={`caption-bottom text-sm relative ${mergedClasses}`}\n data-slot=\"table\"\n >\n <TableHeader data-slot=\"table-header\" className=\"sticky top-0 z-2\">\n <TableRow>\n {headers.map((head: string, idx: number) => {\n const isActionColumn = actions.length > 0 && idx === headers.length - 1;\n const originalKey = originalKeys[idx];\n\n if (isActionColumn) {\n return (\n <TableHead\n key={idx}\n data-slot={`table-header-${idx}`}\n contentEditable={isEditable}\n className=\"sticky right-0 bg-slate-100\"\n >\n {head}\n </TableHead>\n );\n }\n\n return (\n <TableHeadSortable\n key={idx}\n data-slot={`table-header-${idx}`}\n sortDirection={sortDirections[originalKey] || 'asc'}\n isActive={activeSortColumn === originalKey}\n onSort={(direction) => handleSortClick(originalKey, direction)}\n sortable={true}\n isEditable={isEditable}\n >\n {head}\n </TableHeadSortable>\n );\n })}\n </TableRow>\n </TableHeader>\n <TableBody data-slot=\"table-body\">\n {rows.map((row: any[], rIdx: number) => (\n <TableRow\n key={rIdx}\n data-slot={`row-${rIdx}`}\n className=\"hover:bg-muted/50 border-b transition-colors\"\n >\n {row.map((cell: string, cIdx: number) => (\n <TableCell\n key={cIdx}\n data-slot={`cell-${rIdx}-${cIdx}`}\n className=\"p-2 align-middle whitespace-nowrap\"\n contentEditable={false}\n >\n {cell}\n </TableCell>\n ))}\n {renderActions(rIdx, actions)}\n </TableRow>\n ))}\n </TableBody>\n </Table>\n );\n }\n\n return (\n <Fragment>\n <ScrollArea\n data-slot=\"table-container\"\n className={mergedClasses}\n style={{\n height: `${tableHeight}px`,\n }}\n >\n {renderTableComponent()}\n <ScrollBar orientation=\"horizontal\" />\n </ScrollArea>\n {pagination && pagination.totalCount > 0 && (\n <div className=\"flex items-center justify-between mt-2 w-full overflow-x-auto\">\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n <label htmlFor=\"page-size-select\" className=\"text-sm whitespace-nowrap\">\n Rows per page:\n </label>\n <select\n id=\"page-size-select\"\n value={pageSize}\n onChange={(e) => handlePageChange(1, Number(e.target.value))}\n className=\"border rounded px-2 py-1 text-sm cursor-pointer\"\n disabled={isLoading}\n >\n {pagination.pageSizeOptions.map((size: number) => (\n <option key={size} value={size}>\n {size}\n </option>\n ))}\n </select>\n </div>\n <div className=\"flex items-center gap-1 flex-shrink-0\">\n <span className=\"text-xs text-muted-foreground whitespace-nowrap\">\n {(pageNumber - 1) * pageSize + 1}–\n {Math.min(pageNumber * pageSize, pagination.totalCount)} of {pagination.totalCount}\n </span>\n <Pagination>\n <PaginationContent className=\"gap-0.2 flex-shrink-0\">\n {renderPaginationArrows(pageNumber, totalPages, isLoading, handlePageChange)}\n </PaginationContent>\n </Pagination>\n </div>\n </div>\n )}\n </Fragment>\n );\n}\n"],"mappings":"wLAAA,uDACA,OAASA,SAAS,CAAEC,QAAQ,CAAEC,QAAQ,KAAQ,OAAO,CACrD,OACEC,KAAK,CACLC,WAAW,CACXC,QAAQ,CACRC,SAAS,CACTC,SAAS,CACTC,SAAS,CACTC,iBAAiB,KAEZ,kCAAkC,CACzC,OAASC,WAAW,KAAQ,qCAAqC,CACjE,OAASC,UAAU,CAAEC,SAAS,KAAQ,wCAAwC,CAC9E,OACEC,UAAU,CACVC,iBAAiB,CACjBC,sBAAsB,KACjB,uCAAuC,CAC9C,OAASC,WAAW,KAAQ,mCAAmC,CAC/D,OAASC,EAAE,KAAQ,oBAAoB,CACvC,OAASC,oBAAoB,KAAQ,SAAS,QAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAkC9C,MAAO,SAAS,CAAAC,SAASA,CAAAC,IAAA,CAaN,KAAAC,KAAA,CAAAC,qBAAA,CAAAC,kBAAA,CAAAC,KAAA,CAAAC,sBAAA,CAAAC,mBAAA,KAAAC,SAAA,CAAAP,IAAA,CAZjBQ,IAAI,CAAJA,IAAI,CAAAD,SAAA,UAAG,EAAE,CAAAA,SAAA,CAAAE,iBAAA,CAAAT,IAAA,CACTU,YA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D9F,KAAA,SAAMc,SAAS,CAAC,iDAAiD,CAAAgF,QAAA,EAC9D,CAACzD,UAAU,CAAG,CAAC,EAAII,QAAQ,CAAG,CAAC,CAAC,QACjC,CAACI,IAAI,CAAC8D,GAAG,CAACtE,UAAU,CAAGI,QAAQ,CAAEtB,UAAU,CAAC4B,UAAU,CAAC,CAAC,MAAI,CAAC5B,UAAU,CAAC4B,UAAU,EAC9E,CAAC,cACPjD,IAAA,CAACP,UAAU,EAAAuG,QAAA,cACThG,IAAA,CAACN,iBAAiB,EAACsB,SAAS,CAAC,uBAAuB,CAAAgF,QAAA,CACjDrG,sBAAsB,CAAC4C,UAAU,CAAEW,UAAU,CAAE3B,SAAS,CAAE+C,gBAAgB,CAAC,CAC3D,CAAC,CACV,CAAC,EACV,CAAC,EACH,CACN,EACO,CAEd","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _extends from"@babel/runtime/helpers/extends";import _objectWithoutPropertiesLoose from"@babel/runtime/helpers/objectWithoutPropertiesLoose";var _excluded=["gjsModel"],_excluded2=["isEditable","gjsModel"],_excluded3=["isEditable","gjsModel"],_excluded4=["gjsModel","performInteraction"],_excluded5=["gjsModel"];import _regeneratorRuntime from"@babel/runtime/regenerator";function _createForOfIteratorHelperLoose(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}/* eslint-disable no-nested-ternary *//* eslint-disable @typescript-eslint/ban-ts-comment *//* eslint-disable func-style *//* eslint-disable @typescript-eslint/no-empty-function *//* eslint-disable func-names *//* eslint-disable @typescript-eslint/no-explicit-any */import chroma from"chroma-js";import React,{useEffect,useState,useRef}from"react";import{renderNoDataFallback}from"./extra";import{CircleAlert}from"lucide-react";import{theme}from"@peak-ai/ais-components/theme";import Markdown from"markdown-to-jsx";import{PieChart,Pie,BarChart,Bar,LineChart,Line,XAxis,YAxis,ResponsiveContainer,CartesianGrid,Legend// @ts-ignore
2
+ }from"recharts/lib";// @ts-ignore
3
+ import*as domutil from"recharts/lib/util/DOMUtils";import{TooltipButton}from"../../shadcn/components/ui/button";import{Card,CardHeader,CardTitle,CardDescription,CardContent,CardFooter}from"../../shadcn/components/ui/card";import{ChartContainer,ChartTooltip,ChartTooltipContent}from"../../shadcn/components/ui/chart";import{renderFilter}from"../../shadcn/components/ui/filter";import{ScrollArea,ScrollBar}from"../../shadcn/components/ui/scroll-area";import{renderSearch}from"../../shadcn/components/ui/search";import{ChartLoader,CardLoader,MarkdownLoader}from"../../shadcn/components/ui/skeleton";import{Tabs,TabsList,TabsTrigger,TabsContent}from"../../shadcn/components/ui/tabs";import{cn}from"../../shadcn/utils";import{getAffectedComponentsWithLoader}from"../../helpers";import{DataTable}from"./data-table";// Monkey-patching the getOffset function to use iframe's window instead of global one
4
+ // REMEMBER TO UDPATE THIS WHEN recharts IS UPGRADED
5
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";domutil.getOffset=function(el){var html=el.ownerDocument.documentElement;var box={top:0,left:0};if(typeof el.getBoundingClientRect!=="undefined"){box=el.getBoundingClientRect()}var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;return{top:box.top+iframeWindow.pageYOffset-html.clientTop,left:box.left+iframeWindow.pageXOffset-html.clientLeft}};var baseColors=[[theme.colors.Blue_100,theme.colors.Blue_30],[theme.colors.Purpley_100,theme.colors.Purpley_30],[theme.colors.Light_Bluish_Green,"#06601b"],[theme.colors.Wild_Strawberry,"#4d001c"]];function getNColors(n){var colors=[];for(var _iterator=_createForOfIteratorHelperLoose(baseColors),_step;!(_step=_iterator()).done;){var baseColor=_step.value;// eslint-disable-next-line import/no-named-as-default-member
6
+ colors.push(chroma.scale(baseColor).mode("lab").colors(n))}function getOneColor(existing){var color=null;do{var base=colors[Math.floor(Math.random()*colors.length)];var selectedColorIndex=Math.floor(Math.random()*base.length);color=base[selectedColorIndex]}while(existing.includes(color));return color}var selectedColors=[];for(var i=0;i<n;i++){selectedColors.push(getOneColor(selectedColors))}return selectedColors}/* TODO: Loader remains */export function renderActionCard(props){var gjsModel=props.gjsModel,rest=_objectWithoutPropertiesLoose(props,_excluded);var _useState=useState(_extends({},props)),allData=_useState[0],setAllData=_useState[1];var _allData$headerConten=allData.headerContent,headerContent=_allData$headerConten===void 0?"Default Action Card Title":_allData$headerConten,icon=allData.icon,_allData$bodyContent=allData.bodyContent,bodyContent=_allData$bodyContent===void 0?"Default body content. Click to edit.":_allData$bodyContent;var _useState2=useState(_extends({},gjsModel.get("attributes"))),setAttributes=_useState2[1];useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(_extends({},gjsModel.get("componentProps")))})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var defaultClasses="bg-white text-black p-4 rounded-lg shadow border flex flex-col h-full";return/*#__PURE__*/_jsx(Card,_extends({className:defaultClasses,isEditable:false,contentEditable:false},rest,{children:/*#__PURE__*/_jsx(CardContent,{className:"p-0",isEditable:false,contentEditable:false,children:/*#__PURE__*/_jsx("div",{className:"px-4 py-3",children:/*#__PURE__*/_jsxs("div",{className:"flex items-start",children:[/*#__PURE__*/_jsx("span",{className:"text-5xl mr-2","aria-hidden":"true",children:icon}),/*#__PURE__*/_jsxs("div",{className:"flex-1",children:[/*#__PURE__*/_jsx("div",{className:"text-xl font-semibold",children:headerContent}),!bodyContent?/*#__PURE__*/_jsxs("span",{className:"flex flex-row items-center px-3 py-2",children:[/*#__PURE__*/_jsx(CircleAlert,{className:"w-3 h-3 text-gray-400 mr-1"}),/*#__PURE__*/_jsx("p",{className:"text-sm text-gray-500 max-w-md text-center",children:"No data available for given filters"})]}):/*#__PURE__*/_jsx("div",{className:"text-base leading-relaxed mt-1",children:bodyContent})]})]})})})}))}export function renderCard(props){var _props$isEditable=props.isEditable,isEditable=_props$isEditable===void 0?false:_props$isEditable,gjsModel=props.gjsModel,rest=_objectWithoutPropertiesLoose(props,_excluded2);var _useState3=useState(_extends({},props)),allData=_useState3[0],setAllData=_useState3[1];var headerContent=allData.headerContent,headerDescription=allData.headerDescription,bodyContent=allData.bodyContent,footerContent=allData.footerContent,footerClass=allData.footerClass,footerIcon=allData.footerIcon,contentMetadata=allData.contentMetadata,contentMetadataClass=allData.contentMetadataClass,className=allData.className;var _useState4=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState4[0],setAttributes=_useState4[1];useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(_extends({},gjsModel.get("componentProps")))})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var defaultClasses="bg-white text-black p-4 rounded-lg shadow border flex flex-col h-full";var defaultFooterClasses="text-sm";var defaultContentMetadataClasses="text-xs";var mergedCardClassName=className?cn(defaultClasses,className):defaultClasses;var mergedFooterClassName=footerClass?cn(defaultFooterClasses,footerClass):defaultFooterClasses;var mergedContentMetadataClassName=contentMetadataClass?cn(defaultContentMetadataClasses,contentMetadataClass):defaultContentMetadataClasses;function getCardContent(){if(attributes.interactionApiInProgress||attributes.loading){return/*#__PURE__*/_jsx(CardContent,{children:/*#__PURE__*/_jsx(CardLoader,{})})}return/*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsxs(CardHeader,{children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"headerContent",contentEditable:isEditable,className:"text-lg",children:headerContent}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"headerDescription",contentEditable:isEditable,className:"text-sm",children:headerDescription})]}),!bodyContent?/*#__PURE__*/_jsxs("span",{className:"flex flex-row items-center px-3 py-2",children:[/*#__PURE__*/_jsx(CircleAlert,{className:"w-3 h-3 text-gray-400 mr-1"}),/*#__PURE__*/_jsx("p",{className:"text-sm text-gray-500 max-w-md text-center",children:"No data available for given filters"})]}):/*#__PURE__*/_jsxs(CardContent,{"data-slot":"bodyContent",contentEditable:false,className:"flex-grow",children:[/*#__PURE__*/_jsx("div",{className:"text-3xl font-semibold truncate",children:bodyContent}),contentMetadata&&/*#__PURE__*/_jsx("div",{className:mergedContentMetadataClassName,style:{color:"#2A44D4"},children:contentMetadata})]}),/*#__PURE__*/_jsxs(CardFooter,{"data-slot":"footerContent",contentEditable:isEditable,className:cn(mergedFooterClassName),children:[footerIcon&&/*#__PURE__*/_jsx("span",{className:"mr-2","aria-hidden":"true",children:footerIcon}),footerContent]})]})}return/*#__PURE__*/_jsx(Card,_extends({},rest,{className:mergedCardClassName,children:getCardContent()}))}function renderChartComponent(chartType,data,config){if(!data||data.length===0){return renderNoDataFallback()}switch(chartType){case"pie":return/*#__PURE__*/_jsxs(PieChart,{children:[data.length>=20&&/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{hideLabel:true})}),/*#__PURE__*/_jsx(Pie,{data:data,dataKey:config.dataKey,nameKey:config.nameKey,innerRadius:60,strokeWidth:10,label:data.length<20?function(_ref){var name=_ref.name,percent=_ref.percent;return name+": "+(percent*100).toFixed(0)+"%"}:undefined,labelLine:false})]});case"bar":config.dataKeys=config.dataKeys||[];return/*#__PURE__*/_jsxs(BarChart,_extends({data:data},config.chartUi,{children:[/*#__PURE__*/_jsx(CartesianGrid,{vertical:false}),/*#__PURE__*/_jsx(XAxis,{dataKey:config.xAxis}),/*#__PURE__*/_jsx(YAxis,{}),/*#__PURE__*/_jsx(Legend,{align:"left",wrapperStyle:{marginLeft:20}}),config.dataKeys.map(function(_ref2){var key=_ref2.key,name=_ref2.name,color=_ref2.color;return/*#__PURE__*/_jsx(Bar,{dataKey:key,fill:color!=null?color:"#4caf50",name:name,radius:2},key)}),/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{indicator:"dashed"})})]}));case"line":config.dataKeys=config.dataKeys||[];return/*#__PURE__*/_jsxs(LineChart,{data:data,children:[/*#__PURE__*/_jsx(CartesianGrid,{vertical:false}),/*#__PURE__*/_jsx(XAxis,{dataKey:config.xAxis}),/*#__PURE__*/_jsx(YAxis,{}),/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{indicator:"dashed"})}),config.dataKeys.map(function(_ref3){var key=_ref3.key,name=_ref3.name,color=_ref3.color;return/*#__PURE__*/_jsx(Line,{type:"monotone",dataKey:key,stroke:color!=null?color:"#4caf50",name:name},key)}),/*#__PURE__*/_jsx(Legend,{align:"left"})]});default:return/*#__PURE__*/_jsxs(PieChart,{children:[data.length>=20&&/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{hideLabel:true})}),/*#__PURE__*/_jsx(Pie,{data:data,dataKey:config.dataKey,nameKey:config.nameKey,innerRadius:60,strokeWidth:10,label:data.length<20?function(_ref4){var name=_ref4.name,percent=_ref4.percent;return name+": "+(percent*100).toFixed(0)+"%"}:undefined,labelLine:false})]})}}export function renderChart(props){var _props$isEditable2=props.isEditable,isEditable=_props$isEditable2===void 0?false:_props$isEditable2,gjsModel=props.gjsModel,rest=_objectWithoutPropertiesLoose(props,_excluded3);var _useState5=useState(_extends({},props)),allData=_useState5[0],setAllData=_useState5[1];var _useState6=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState6[0],setAttributes=_useState6[1];var containerRef=useRef(null);var _useState7=useState(0),containerWidth=_useState7[0],setContainerWidth=_useState7[1];useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(_extends({},gjsModel.get("componentProps")))})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);useEffect(function(){var updateContainerWidth=function updateContainerWidth(){if(containerRef.current){setContainerWidth(containerRef.current.offsetWidth)}};updateContainerWidth();window.addEventListener("resize",updateContainerWidth);return function(){return window.removeEventListener("resize",updateContainerWidth)}},[]);var _allData$config=allData.config,config=_allData$config===void 0?{}:_allData$config,_allData$chartType=allData.chartType,chartType=_allData$chartType===void 0?"pie":_allData$chartType,_allData$chartData=allData.chartData,chartData=_allData$chartData===void 0?[]:_allData$chartData,className=allData.className,_allData$title=allData.title,title=_allData$title===void 0?"Title":_allData$title,_allData$subTitle=allData.subTitle,subTitle=_allData$subTitle===void 0?"Subtitle":_allData$subTitle;var defaultClasses="aspect-auto h-[250px] w-full";var mergedClasses=className?cn(defaultClasses,className):defaultClasses;if(chartType==="pie"){var colors=getNColors(chartData.length);for(var i=0;i<chartData.length;i++){var data=chartData[i];if(!data.fill){data.fill=colors[i]}}}else if(!config.color){config.color=baseColors[Math.floor(Math.random()*baseColors.length)]}var width=undefined;var totalDataPoints=0;// Helper function to get responsive config
7
+ var getResponsiveConfig=function getResponsiveConfig(){if(chartType==="bar"&&totalDataPoints>15&&containerWidth>0&&width&&width<=containerWidth){// If chart fits in container, use responsive behavior
8
+ return _extends({},config,{chartUi:{}})}return config};if(chartType==="bar"){totalDataPoints=chartData.length*config.dataKeys.length;if(totalDataPoints>15){width=totalDataPoints*20+config.dataKeys.length*8*chartData.length+chartData.length*15;config.chartUi={barCategoryGap:"10%",width:width}}else{config.chartUi={}}}var chartUi=attributes.interactionApiInProgress||attributes.loading?/*#__PURE__*/_jsx(ChartLoader,{}):!chartData?renderNoDataFallback():/*#__PURE__*/_jsx(React.Fragment,{children:chartType==="bar"&&totalDataPoints>15&&config.chartUi&&width&&(containerWidth===0||width>containerWidth)?/*#__PURE__*/_jsx("div",{className:"w-full",children:/*#__PURE__*/_jsxs(ScrollArea,{className:"w-full",children:[/*#__PURE__*/_jsx("div",{style:{minWidth:width+"px",width:"max-content"},children:/*#__PURE__*/_jsx(ResponsiveContainer,{width:width,height:250,children:/*#__PURE__*/_jsx(ChartContainer,_extends({},rest,{config:config,className:mergedClasses,children:renderChartComponent(chartType,chartData,config)}))})}),/*#__PURE__*/_jsx(ScrollBar,{orientation:"horizontal"})]})}):/*#__PURE__*/_jsx(ResponsiveContainer,{width:"100%",height:250,children:/*#__PURE__*/_jsx(ChartContainer,_extends({},rest,{config:getResponsiveConfig(),className:mergedClasses,children:renderChartComponent(chartType,chartData,getResponsiveConfig())}))})});return/*#__PURE__*/_jsxs(Card,{className:"shadow border mt-2 mb-2",children:[/*#__PURE__*/_jsxs(CardHeader,{children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"title",contentEditable:isEditable,className:"text-2xl",children:title}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"subTitle",contentEditable:isEditable,className:"text-sm",children:subTitle})]}),/*#__PURE__*/_jsx(CardContent,{ref:containerRef,"data-slot":"bodyContent",contentEditable:false,className:"px-6",children:chartUi})]})}export function renderTable(props){var gjsModel=props.gjsModel,_props$performInterac=props.performInteraction,performInteraction=_props$performInterac===void 0?function(){}:_props$performInterac,rest=_objectWithoutPropertiesLoose(props,_excluded4);var _useState8=useState(_extends({},props)),allData=_useState8[0],setAllData=_useState8[1];var cardRef=useRef(null);var _useState9=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState9[0],setAttributes=_useState9[1];var _allData$data=allData.data,data=_allData$data===void 0?[]:_allData$data,_allData$headerMapper=allData.headerMapper,headerMapper=_allData$headerMapper===void 0?{}:_allData$headerMapper,className=allData.className,_allData$isEditable=allData.isEditable,isEditable=_allData$isEditable===void 0?false:_allData$isEditable,_allData$title2=allData.title,title=_allData$title2===void 0?"Title":_allData$title2,_allData$subTitle2=allData.subTitle,subTitle=_allData$subTitle2===void 0?"Subtitle":_allData$subTitle2,_allData$actions=allData.actions,actions=_allData$actions===void 0?[]:_allData$actions,pagination=allData.pagination;var sortConfig=function(_gjsModel$get,_ref6){var _ref5=(_gjsModel$get=gjsModel.get("componentProps"))!=null?_gjsModel$get:{},sortColumn=_ref5.sortColumn,sortDirection=_ref5.sortDirection;return sortColumn&&sortDirection?(_ref6={},_ref6[sortColumn]=sortDirection,_ref6):{}}();useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(_extends({},gjsModel.get("componentProps")))})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var parsedData=data.map(function(datum){var newData=_extends({},datum);delete newData.id;return newData});function onRowAction(_x,_x2){return _onRowAction.apply(this,arguments)}function _onRowAction(){_onRowAction=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(rowIndex,actionId){var id;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:id=gjsModel.get("id");_context.next=3;return performInteraction({id:actionId,interactionType:"tableButton",payload:{row:data[rowIndex],tableId:id},affectedComponents:[]});case 3:case"end":return _context.stop()}},_callee)}));return _onRowAction.apply(this,arguments)}function onPageChange(_x3,_x4){return _onPageChange.apply(this,arguments)}function _onPageChange(){_onPageChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(pageNumber,pageSize){var _gjsModel$get2;var id,_ref7,sortColumn,sortDirection;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:id=gjsModel.get("id");_ref7=(_gjsModel$get2=gjsModel.get("componentProps"))!=null?_gjsModel$get2:{},sortColumn=_ref7.sortColumn,sortDirection=_ref7.sortDirection;_context2.next=4;return performInteraction({id:id,interactionType:"pagination",payload:_extends({pageNumber:pageNumber,pageSize:pageSize},sortColumn&&sortDirection&&{sortColumn:sortColumn,sortDirection:sortDirection}),affectedComponents:getAffectedComponentsWithLoader([id],true)});case 4:case"end":return _context2.stop()}},_callee2)}));return _onPageChange.apply(this,arguments)}function handleSort(_x5,_x6){return _handleSort.apply(this,arguments)}function _handleSort(){_handleSort=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(column,direction){var currentProps,id;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:currentProps=gjsModel.get("componentProps");id=gjsModel.get("id");gjsModel.set("componentProps",_extends({},currentProps,{sortColumn:direction?column:null,sortDirection:direction}));_context3.next=5;return performInteraction({id:id,interactionType:"tableSort",payload:{sortColumn:direction?column:null,sortDirection:direction,tableId:id},affectedComponents:getAffectedComponentsWithLoader([id],true)});case 5:case"end":return _context3.stop()}},_callee3)}));return _handleSort.apply(this,arguments)}return/*#__PURE__*/_jsxs(Card,{ref:cardRef,className:"shadow border","data-component-type":"table",children:[/*#__PURE__*/_jsxs(CardHeader,{children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"title",contentEditable:isEditable,className:"text-2xl",children:title}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"subTitle",contentEditable:isEditable,className:"text-sm",children:subTitle})]}),/*#__PURE__*/_jsx(CardContent,{"data-slot":"bodyContent",contentEditable:false,children:/*#__PURE__*/_jsx(DataTable,{data:parsedData,headerMapper:headerMapper,className:className,isEditable:isEditable,actions:actions,pagination:pagination,isLoading:attributes.interactionApiInProgress,onRowAction:onRowAction,onPageChange:onPageChange,onSort:handleSort,sortConfig:sortConfig,otherProps:rest})})]})}export function renderTab(props){var tabsWidth=200;if(props.tabs.length>4){tabsWidth=150}return/*#__PURE__*/_jsxs(Tabs,{defaultValue:props.defaultValue,children:[/*#__PURE__*/_jsx("div",{className:"text-center mb-4",children:/*#__PURE__*/_jsx(TabsList,{className:"bg-gray-300",children:props.tabs.map(function(tab){return/*#__PURE__*/_jsx(TabsTrigger,{value:tab,className:"text-md w-["+tabsWidth+"px]",children:tab},tab)})})}),props.tabs.map(function(tab){return/*#__PURE__*/_jsx(TabsContent,{value:tab,className:"tabs-content"},tab)})]})}export function renderMarkdown(props){var gjsModel=props.gjsModel,rest=_objectWithoutPropertiesLoose(props,_excluded5);var _useState10=useState(_extends({},props)),allData=_useState10[0],setAllData=_useState10[1];var _useState11=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState11[0],setAttributes=_useState11[1];useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(_extends({},gjsModel.get("componentProps")))})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var _useState12=useState(false),isEditing=_useState12[0],setIsEditing=_useState12[1];var editRef=useRef(null);var startEditing=function startEditing(){setIsEditing(true);setTimeout(function(){setupEditor()},0)};var setupEditor=function setupEditor(){if(!editRef.current){return}var editor=editRef.current;editor.innerHTML="";editor.textContent=allData.summaryText;editor.focus()};// Save changes and exit editing mode
9
+ var saveChanges=function saveChanges(){if(!editRef.current){return}var content=editRef.current.innerText||"";setAllData(function(prev){return _extends({},prev,{summaryText:content})});setIsEditing(false);editRef.current.innerHTML=""};var markdownStyles={ul:{props:{className:"list-disc"}},h1:{props:{className:"text-4xl font-bold leading-[4rem]"}},h2:{props:{className:"text-3xl font-bold leading-[3rem]"}},h3:{props:{className:"text-2xl font-bold leading-[2rem]"}},h4:{props:{className:"text-xl font-bold leading-[2.5rem]"}},h5:{props:{className:"text-lg font-bold leading-[2.5rem]"}},h6:{props:{className:"text-base font-bold leading-[2rem]"}}};if(attributes.loading){return/*#__PURE__*/_jsx(MarkdownLoader,{})}if(!allData.isEditable){return/*#__PURE__*/_jsx("div",_extends({className:"px-[1em]"},rest,{children:/*#__PURE__*/_jsx("div",{"data-slot":"summaryText",children:/*#__PURE__*/_jsx(Markdown,{options:{overrides:markdownStyles},children:allData.summaryText})})}))}return/*#__PURE__*/_jsx("div",_extends({className:"p-[1em]"},rest,{children:isEditing?/*#__PURE__*/_jsx("div",{ref:editRef,contentEditable:true,onBlur:saveChanges,"data-slot":"summaryText",className:"p-2 min-h-[100px] whitespace-pre-wrap",suppressContentEditableWarning:true,style:{whiteSpace:"pre-wrap",wordWrap:"break-word"}}):/*#__PURE__*/_jsx("div",{onClick:startEditing,"data-slot":"summaryText",style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:/*#__PURE__*/_jsx(Markdown,{options:{overrides:markdownStyles},children:allData.summaryText})})}))}export function renderButton(props){var _props$isEditable3=props.isEditable,isEditable=_props$isEditable3===void 0?false:_props$isEditable3,gjsModel=props.gjsModel,_props$performInterac2=props.performInteraction,performInteraction=_props$performInterac2===void 0?function(){}:_props$performInterac2;var _useState13=useState(_extends({},props)),allData=_useState13[0],setAllData=_useState13[1];var _useState14=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState14[0],setAttributes=_useState14[1];useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(_extends({},gjsModel.get("componentProps")))})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var text=allData.text,className=allData.className,payload=allData.payload,_allData$variant=allData.variant,variant=_allData$variant===void 0?"default":_allData$variant,_allData$size=allData.size,size=_allData$size===void 0?"sm":_allData$size,affectedComponents=allData.affectedComponents,tooltipContent=allData.tooltipContent;function interact(){var id=gjsModel.get("id");performInteraction({id:id,interactionType:"button",affectedComponents:getAffectedComponentsWithLoader([id].concat(affectedComponents),true),payload:payload})}return/*#__PURE__*/_jsx(TooltipButton,{className:className,isEditable:isEditable,interact:interact,attributes:attributes,variant:variant,size:size,text:text,tooltipContent:tooltipContent})}export function getRenderers(){return{ActionCard:renderActionCard,Button:renderButton,Card:renderCard,Chart:renderChart,Filter:renderFilter,Markdown:renderMarkdown,Search:renderSearch,Table:renderTable,Tabs:renderTab}}
10
+ //# sourceMappingURL=render-components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-components.js","names":["chroma","React","useEffect","useState","useRef","renderNoDataFallback","CircleAlert","theme","Markdown","PieChart","Pie","BarChart","Bar","LineChart","Line","XAxis","YAxis","ResponsiveContainer","CartesianGrid","Legend","domutil","TooltipButton","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter","ChartContainer","ChartTooltip","ChartTooltipContent","renderFilter","ScrollArea","ScrollBar","renderSearch","ChartLoader","CardLoader","MarkdownLoader","Tabs","TabsList","TabsTrigger","TabsContent","cn","getAffectedComponentsWithLoader","DataTable","jsx","_jsx","jsxs","_jsxs","getOffset","el","html","ownerDocument","documentElement","box","top","left","getBoundingClientRect","iframe","document","querySelector","iframeWindow","contentWindow","pageYOffset","clientTop","pageXOffset","clientLeft","baseColors","colors","Blue_100","Blue_30","Purpley_100","Purpley_30","Light_Bluish_Green","Wild_Strawberry","getNColors","n","_iterator","_createForOfIteratorHelperLoose","_step","done","baseColor","value","push","scale","mode","getOneColor","existing","color","base","Math","floor","random","length","selectedColorIndex","includes","selectedColors","i","renderActionCard","props","gjsModel","rest","_objectWithoutPropertiesLoose","_excluded","_useState","_extends","allData","setAllData","_allData$headerConten","headerContent","icon","_allData$bodyContent","bodyContent","_useState2","get","setAttributes","on","defaultClasses","className","isEditable","contentEditable","children","renderCard","_props$isEditable","_excluded2","_useState3","headerDescription","footerContent","footerClass","footerIcon","contentMetadata","contentMetadataClass","_useState4","attributes","defaultFooterClasses","defaultContentMetadataClasses","mergedCardClassName","mergedFooterClassName","mergedContentMetadataClassName","getCardContent","interactionApiInProgress","loading","Fragment","style","renderChartComponent","chartType","data","config","cursor","content","hideLabel","dataKey","nameKey","innerRadius","strokeWidth","label","_ref","name","percent","toFixed","undefined","labelLine","dataKeys","chartUi","vertical","xAxis","align","wrapperStyle","marginLeft","map","_ref2","key","fill","radius","indicator","_ref3","type","stroke","_ref4","renderChart","_props$isEditable2","_excluded3","_useState5","_useState6","containerRef","_useState7","containerWidth","setContainerWidth","updateContainerWidth","current","offsetWidth","window","addEventListener","removeEventListener","_allData$config","_allData$chartType","_allData$chartData","chartData","_allData$title","title","_allData$subTitle","subTitle","mergedClasses","width","totalDataPoints","getResponsiveConfig","barCategoryGap","minWidth","height","orientation","ref","renderTable","_props$performInterac","performInteraction","_excluded4","_useState8","cardRef","_useState9","_allData$data","_allData$headerMapper","headerMapper","_allData$isEditable","_allData$title2","_allData$subTitle2","_allData$actions","actions","pagination","sortConfig","_gjsModel$get","_ref6","_ref5","sortColumn","sortDirection","parsedData","datum","newData","id","onRowAction","_x","_x2","_onRowAction","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","rowIndex","actionId","wrap","_callee$","_context","prev","next","interactionType","payload","row","tableId","affectedComponents","stop","onPageChange","_x3","_x4","_onPageChange","_callee2","pageNumber","pageSize","_gjsModel$get2","_ref7","_callee2$","_context2","handleSort","_x5","_x6","_handleSort","_callee3","column","direction","currentProps","_callee3$","_context3","set","isLoading","onSort","otherProps","renderTab","tabsWidth","tabs","defaultValue","tab","renderMarkdown","_excluded5","_useState10","_useState11","_useState12","isEditing","setIsEditing","editRef","startEditing","setTimeout","setupEditor","editor","innerHTML","textContent","summaryText","focus","saveChanges","innerText","markdownStyles","ul","h1","h2","h3","h4","h5","h6","options","overrides","onBlur","suppressContentEditableWarning","whiteSpace","wordWrap","onClick","renderButton","_props$isEditable3","_props$performInterac2","_useState13","_useState14","text","_allData$variant","variant","_allData$size","size","tooltipContent","interact","concat","getRenderers","ActionCard","Button","Chart","Filter","Search","Table"],"sources":["../../../src/plugins/helpers/render-components.tsx"],"sourcesContent":["/* eslint-disable no-nested-ternary */\n/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable func-style */\n/* eslint-disable @typescript-eslint/no-empty-function */\n/* eslint-disable func-names */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport chroma from 'chroma-js';\nimport React, { useEffect, useState, JSX, useRef } from 'react';\nimport { renderNoDataFallback } from './extra'\nimport { CircleAlert } from 'lucide-react';\n\nimport { theme } from '@peak-ai/ais-components/theme';\n\nimport Markdown from 'markdown-to-jsx';\n\nimport {\n PieChart,\n Pie,\n BarChart,\n Bar,\n LineChart,\n Line,\n XAxis,\n YAxis,\n ResponsiveContainer,\n CartesianGrid,\n Legend,\n // @ts-ignore\n} from 'recharts/lib';\n\n// @ts-ignore\nimport * as domutil from 'recharts/lib/util/DOMUtils';\n\nimport { TooltipButton } from '../../shadcn/components/ui/button';\nimport {\n Card,\n CardHeader,\n CardTitle,\n CardDescription,\n CardContent,\n CardFooter,\n} from '../../shadcn/components/ui/card';\nimport {\n ChartContainer,\n ChartTooltip,\n ChartTooltipContent,\n} from '../../shadcn/components/ui/chart';\nimport { renderFilter } from '../../shadcn/components/ui/filter';\nimport { ScrollArea, ScrollBar } from '../../shadcn/components/ui/scroll-area';\nimport { renderSearch } from '../../shadcn/components/ui/search';\nimport { TableLoader, ChartLoader, CardLoader, MarkdownLoader } from '../../shadcn/components/ui/skeleton';\nimport { SortDirection } from '../../shadcn/components/ui/table';\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from '../../shadcn/components/ui/tabs';\n\nimport { cn } from '../../shadcn/utils';\nimport { getAffectedComponentsWithLoader } from '../../helpers';\nimport { DataTable } from './data-table';\n\n// Monkey-patching the getOffset function to use iframe's window instead of global one\n// REMEMBER TO UDPATE THIS WHEN recharts IS UPGRADED\ndomutil.getOffset = (el: HTMLElement): {\n top: number;\n left: number;\n} => {\n const html = el.ownerDocument.documentElement;\n let box = { top: 0, left: 0 };\n\n if (typeof el.getBoundingClientRect !== 'undefined') {\n box = el.getBoundingClientRect();\n }\n\n const iframe = document.querySelector('.gjs-frame');\n const iframeWindow = (iframe as any)?.contentWindow;\n\n return {\n top: box.top + iframeWindow.pageYOffset - html.clientTop,\n left: box.left + iframeWindow.pageXOffset - html.clientLeft,\n };\n};\n\n\nconst baseColors = [\n [theme.colors.Blue_100, theme.colors.Blue_30],\n [theme.colors.Purpley_100, theme.colors.Purpley_30],\n [theme.colors.Light_Bluish_Green, '#06601b'],\n [theme.colors.Wild_Strawberry, '#4d001c'],\n];\n\nfunction getNColors(n: number) {\n const colors: Array<string[]> = [];\n\n for (const baseColor of baseColors) {\n // eslint-disable-next-line import/no-named-as-default-member\n colors.push(chroma.scale(baseColor).mode('lab').colors(n));\n }\n\n function getOneColor(existing: Array<string>) {\n let color: null | string = null;\n\n do {\n const base = colors[Math.floor(Math.random() * colors.length)];\n const selectedColorIndex = Math.floor(Math.random() * base.length);\n color = base[selectedColorIndex];\n } while (existing.includes(color));\n\n return color as string;\n }\n\n const selectedColors: Array<string> = [];\n\n for (let i = 0; i < n; i++) {\n selectedColors.push(getOneColor(selectedColors));\n }\n\n return selectedColors;\n}\n\n/* TODO: Loader remains */\nexport function renderActionCard(props: any): JSX.Element {\n const { gjsModel, ...rest } = props;\n\n const [allData, setAllData] = useState({\n ...props,\n });\n\n const {\n headerContent = 'Default Action Card Title',\n icon,\n bodyContent = 'Default body content. Click to edit.',\n } = allData;\n\n const [, setAttributes] = useState({\n ...gjsModel.get('attributes'),\n });\n\n useEffect(() => {\n gjsModel.on('change:componentProps', () => {\n setAllData({\n ...gjsModel.get('componentProps'),\n });\n });\n }, []);\n\n useEffect(() => {\n gjsModel.on('change:attributes', () => {\n setAttributes({\n ...gjsModel.get('attributes'),\n });\n });\n }, []);\n\n const defaultClasses = 'bg-white text-black p-4 rounded-lg shadow border flex flex-col h-full';\n\n return (\n <Card className={defaultClasses} isEditable={false} contentEditable={false} {...rest}>\n <CardContent className=\"p-0\" isEditable={false} contentEditable={false}>\n <div className=\"px-4 py-3\">\n <div className=\"flex items-start\">\n <span className=\"text-5xl mr-2\" aria-hidden=\"true\">\n {icon}\n </span>\n <div className=\"flex-1\">\n <div className=\"text-xl font-semibold\">{headerContent}</div>\n {!bodyContent ? (\n <span className=\"flex flex-row items-center px-3 py-2\">\n <CircleAlert className=\"w-3 h-3 text-gray-400 mr-1\" />\n <p className=\"text-sm text-gray-500 max-w-md text-center\">\n No data available for given filters\n </p>\n </span>\n ) : (\n <div className=\"text-base leading-relaxed mt-1\">{bodyContent}</div>\n )}\n </div>\n </div>\n </div>\n </CardContent>\n </Card>\n );\n}\n\nexport function renderCard(props: any): JSX.Element {\n const { isEditable = false, gjsModel, ...rest } = props;\n\n const [allData, setAllData] = useState({\n ...props,\n });\n\n const {\n headerContent,\n headerDescription,\n bodyContent,\n footerContent,\n footerClass,\n footerIcon,\n contentMetadata,\n contentMetadataClass,\n className,\n } = allData;\n\n const [attributes, setAttributes] = useState({\n ...gjsModel.get('attributes'),\n });\n\n useEffect(() => {\n gjsModel.on('change:componentProps', () => {\n setAllData({\n ...gjsModel.get('componentProps'),\n });\n });\n }, []);\n\n useEffect(() => {\n gjsModel.on('change:attributes', () => {\n setAttributes({\n ...gjsModel.get('attributes'),\n });\n });\n }, []);\n\n const defaultClasses = 'bg-white text-black p-4 rounded-lg shadow border flex flex-col h-full';\n const defaultFooterClasses = 'text-sm';\n const defaultContentMetadataClasses = 'text-xs';\n const mergedCardClassName = className ? cn(defaultClasses, className) : defaultClasses;\n const mergedFooterClassName = footerClass\n ? cn(defaultFooterClasses, footerClass)\n : defaultFooterClasses;\n const mergedContentMetadataClassName = contentMetadataClass\n ? cn(defaultContentMetadataClasses, contentMetadataClass)\n : defaultContentMetadataClasses;\n\n function getCardContent() {\n if (attributes.interactionApiInProgress || attributes.loading) {\n return (\n <CardContent>\n <CardLoader />\n </CardContent>\n );\n }\n\n return (\n <React.Fragment>\n <CardHeader>\n <CardTitle data-slot=\"headerContent\" contentEditable={isEditable} className=\"text-lg\">\n {headerContent}\n </CardTitle>\n <CardDescription\n data-slot=\"headerDescription\"\n contentEditable={isEditable}\n className=\"text-sm\"\n >\n {headerDescription}\n </CardDescription>\n </CardHeader>\n\n {!bodyContent ? (\n <span className=\"flex flex-row items-center px-3 py-2\">\n <CircleAlert className=\"w-3 h-3 text-gray-400 mr-1\" />\n <p className=\"text-sm text-gray-500 max-w-md text-center\">\n No data available for given filters\n </p>\n </span>\n ) : (\n <CardContent data-slot=\"bodyContent\" contentEditable={false} className=\"flex-grow\">\n <div className=\"text-3xl font-semibold truncate\">{bodyContent}</div>\n {contentMetadata && (\n <div className={mergedContentMetadataClassName} style={{ color: '#2A44D4' }}>\n {contentMetadata}\n </div>\n )}\n </CardContent>\n )}\n\n <CardFooter\n data-slot=\"footerContent\"\n contentEditable={isEditable}\n className={cn(mergedFooterClassName)}\n >\n {footerIcon && (\n <span className=\"mr-2\" aria-hidden=\"true\">\n {footerIcon}\n </span>\n )}\n {footerContent}\n </CardFooter>\n </React.Fragment>\n );\n }\n\n return (\n <Card {...rest} className={mergedCardClassName}>\n {getCardContent()}\n </Card>\n );\n}\n\nfunction renderChartComponent(chartType: string, data: any, config: any): JSX.Element {\n if (!data || data.length === 0) {\n return renderNoDataFallback();\n }\n\n switch (chartType) {\n case 'pie':\n return (\n <PieChart>\n {data.length >= 20 && (\n <ChartTooltip cursor={false} content={<ChartTooltipContent hideLabel />} />\n )}\n <Pie\n data={data}\n dataKey={config.dataKey}\n nameKey={config.nameKey}\n innerRadius={60}\n strokeWidth={10}\n label={\n data.length < 20\n ? ({ name, percent }: { name: string; percent: number; }) => `${name}: ${(percent * 100).toFixed(0)}%`\n : undefined\n }\n labelLine={false}\n />\n </PieChart>\n );\n case 'bar':\n config.dataKeys = config.dataKeys || [];\n\n return (\n <BarChart data={data} {...config.chartUi}>\n <CartesianGrid vertical={false} />\n <XAxis dataKey={config.xAxis} />\n <YAxis />\n <Legend align=\"left\" wrapperStyle={{ marginLeft: 20 }} />\n {config.dataKeys.map(\n ({ key, name, color }: { key: string; name: string; color: string }) => {\n return (\n <Bar dataKey={key} fill={color ?? '#4caf50'} name={name} key={key} radius={2} />\n );\n },\n )}\n <ChartTooltip cursor={false} content={<ChartTooltipContent indicator=\"dashed\" />} />\n </BarChart>\n );\n case 'line':\n config.dataKeys = config.dataKeys || [];\n\n return (\n <LineChart data={data}>\n <CartesianGrid vertical={false} />\n <XAxis dataKey={config.xAxis} />\n <YAxis />\n <ChartTooltip cursor={false} content={<ChartTooltipContent indicator=\"dashed\" />} />\n {config.dataKeys.map(\n ({ key, name, color }: { key: string; name: string; color: string }) => {\n return (\n <Line\n type=\"monotone\"\n dataKey={key}\n stroke={color ?? '#4caf50'}\n name={name}\n key={key}\n />\n );\n },\n )}\n <Legend align=\"left\" />\n </LineChart>\n );\n default:\n return (\n <PieChart>\n {data.length >= 20 && (\n <ChartTooltip cursor={false} content={<ChartTooltipContent hideLabel />} />\n )}\n <Pie\n data={data}\n dataKey={config.dataKey}\n nameKey={config.nameKey}\n innerRadius={60}\n strokeWidth={10}\n label={\n data.length < 20\n ? ({ name, percent }: { name: string; percent: number; }) => `${name}: ${(percent * 100).toFixed(0)}%`\n : undefined\n }\n labelLine={false}\n />\n </PieChart>\n );\n }\n}\n\nexport function renderChart(props: any): JSX.Element {\n const { isEditable = false, gjsModel, ...rest } = props;\n\n const [allData, setAllData] = useState({\n ...props,\n });\n\n const [attributes, setAttributes] = useState({\n ...gjsModel.get('attributes'),\n });\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [containerWidth, setContainerWidth] = useState<number>(0);\n\n useEffect(() => {\n gjsModel.on('change:componentProps', () => {\n setAllData({\n ...gjsModel.get('componentProps'),\n });\n });\n }, []);\n\n useEffect(() => {\n gjsModel.on('change:attributes', () => {\n setAttributes({\n ...gjsModel.get('attributes'),\n });\n });\n }, []);\n\n useEffect(() => {\n const updateContainerWidth = () => {\n if (containerRef.current) {\n setContainerWidth(containerRef.current.offsetWidth);\n }\n };\n\n updateContainerWidth();\n window.addEventListener('resize', updateContainerWidth);\n\n return () => window.removeEventListener('resize', updateContainerWidth);\n }, []);\n\n const {\n config = {},\n chartType = 'pie',\n chartData = [],\n className,\n title = 'Title',\n subTitle = 'Subtitle',\n } = allData;\n\n const defaultClasses = 'aspect-auto h-[250px] w-full';\n const mergedClasses = className ? cn(defaultClasses, className) : defaultClasses;\n\n if (chartType === 'pie') {\n const colors = getNColors(chartData.length);\n\n for (let i = 0; i < chartData.length; i++) {\n const data = chartData[i];\n\n if (!data.fill) {\n data.fill = colors[i];\n }\n }\n } else if (!config.color) {\n config.color = baseColors[Math.floor(Math.random() * baseColors.length)];\n }\n\n let width: number | undefined = undefined;\n let totalDataPoints = 0;\n\n // Helper function to get responsive config\n const getResponsiveConfig = () => {\n if (\n chartType === 'bar' &&\n totalDataPoints > 15 &&\n containerWidth > 0 &&\n width &&\n width <= containerWidth\n ) {\n // If chart fits in container, use responsive behavior\n return { ...config, chartUi: {} };\n }\n\n return config;\n };\n\n if (chartType === 'bar') {\n totalDataPoints = chartData.length * config.dataKeys.length;\n\n if (totalDataPoints > 15) {\n width =\n totalDataPoints * 20 +\n config.dataKeys.length * 8 * chartData.length +\n chartData.length * 15;\n config.chartUi = {\n barCategoryGap: '10%',\n width,\n };\n } else {\n config.chartUi = {};\n }\n }\n\n const chartUi = (attributes.interactionApiInProgress || attributes.loading) ? (\n <ChartLoader />\n ) : !chartData ? (\n renderNoDataFallback()\n ) : (\n <React.Fragment>\n {chartType === 'bar' &&\n totalDataPoints > 15 &&\n config.chartUi &&\n width &&\n (containerWidth === 0 || width > containerWidth) ? (\n <div className=\"w-full\">\n <ScrollArea className=\"w-full\">\n <div style={{ minWidth: `${width}px`, width: 'max-content' }}>\n <ResponsiveContainer width={width} height={250}>\n <ChartContainer {...rest} config={config} className={mergedClasses}>\n {renderChartComponent(chartType, chartData, config)}\n </ChartContainer>\n </ResponsiveContainer>\n </div>\n <ScrollBar orientation=\"horizontal\" />\n </ScrollArea>\n </div>\n ) : (\n <ResponsiveContainer width=\"100%\" height={250}>\n <ChartContainer {...rest} config={getResponsiveConfig()} className={mergedClasses}>\n {renderChartComponent(chartType, chartData, getResponsiveConfig())}\n </ChartContainer>\n </ResponsiveContainer>\n )}\n </React.Fragment>\n );\n\n return (\n <Card className=\"shadow border mt-2 mb-2\">\n <CardHeader>\n <CardTitle data-slot=\"title\" contentEditable={isEditable} className=\"text-2xl\">\n {title}\n </CardTitle>\n <CardDescription data-slot=\"subTitle\" contentEditable={isEditable} className=\"text-sm\">\n {subTitle}\n </CardDescription>\n </CardHeader>\n <CardContent\n ref={containerRef}\n data-slot=\"bodyContent\"\n contentEditable={false}\n className=\"px-6\"\n >\n {chartUi}\n </CardContent>\n </Card>\n );\n}\n\nexport function renderTable(props: any): JSX.Element {\n const { gjsModel, performInteraction = () => {}, ...rest } = props;\n\n const [allData, setAllData] = useState({\n ...props,\n });\n\n const cardRef = useRef<HTMLDivElement>(null);\n\n const [attributes, setAttributes] = useState({\n ...gjsModel.get('attributes'),\n });\n\n const {\n data = [],\n headerMapper = {},\n className,\n isEditable = false,\n title = 'Title',\n subTitle = 'Subtitle',\n actions = [],\n pagination,\n } = allData;\n\n const sortConfig = (() => {\n const { sortColumn, sortDirection } = gjsModel.get('componentProps') ?? {};\n\n return sortColumn && sortDirection ? { [sortColumn]: sortDirection } : {};\n })();\n\n useEffect(() => {\n gjsModel.on('change:componentProps', () => {\n setAllData({\n ...gjsModel.get('componentProps'),\n });\n });\n }, []);\n\n useEffect(() => {\n gjsModel.on('change:attributes', () => {\n setAttributes({\n ...gjsModel.get('attributes'),\n });\n });\n }, []);\n\n\n const parsedData = data.map((datum: any) => {\n const newData = {\n ...datum,\n };\n\n delete newData.id;\n\n return newData;\n });\n\n async function onRowAction(rowIndex: number, actionId: string) {\n const id = gjsModel.get('id');\n\n await performInteraction({\n id: actionId,\n interactionType: 'tableButton',\n payload: {\n row: data[rowIndex],\n tableId: id,\n },\n affectedComponents: [],\n });\n }\n\n async function onPageChange(pageNumber: number, pageSize: number) {\n const id = gjsModel.get('id');\n const { sortColumn, sortDirection } = gjsModel.get('componentProps') ?? {};\n\n await performInteraction({\n id,\n interactionType: 'pagination',\n payload: {\n pageNumber,\n pageSize,\n ...(sortColumn && sortDirection && { sortColumn, sortDirection }),\n },\n affectedComponents: getAffectedComponentsWithLoader([id], true),\n });\n }\n\n async function handleSort(column: string, direction: SortDirection) {\n const currentProps = gjsModel.get('componentProps');\n const id = gjsModel.get('id');\n\n gjsModel.set('componentProps', {\n ...currentProps,\n sortColumn: direction ? column : null,\n sortDirection: direction,\n });\n\n await performInteraction({\n id,\n interactionType: 'tableSort',\n payload: {\n sortColumn: direction ? column : null,\n sortDirection: direction,\n tableId: id,\n },\n affectedComponents: getAffectedComponentsWithLoader([id], true),\n });\n }\n\n return (\n <Card \n ref={cardRef}\n className=\"shadow border\"\n data-component-type=\"table\"\n >\n <CardHeader>\n <CardTitle data-slot=\"title\" contentEditable={isEditable} className=\"text-2xl\">\n {title}\n </CardTitle>\n <CardDescription data-slot=\"subTitle\" contentEditable={isEditable} className=\"text-sm\">\n {subTitle}\n </CardDescription>\n </CardHeader>\n <CardContent data-slot=\"bodyContent\" contentEditable={false}>\n <DataTable\n data={parsedData}\n headerMapper={headerMapper}\n className={className}\n isEditable={isEditable}\n actions={actions}\n pagination={pagination}\n isLoading={attributes.interactionApiInProgress}\n onRowAction={onRowAction}\n onPageChange={onPageChange}\n onSort={handleSort}\n sortConfig={sortConfig}\n otherProps={rest}\n />\n </CardContent>\n </Card>\n );\n}\n\nexport function renderTab(props: any): JSX.Element {\n let tabsWidth = 200;\n\n if (props.tabs.length > 4) {\n tabsWidth = 150;\n }\n\n return (\n <Tabs defaultValue={props.defaultValue}>\n <div className=\"text-center mb-4\">\n <TabsList className=\"bg-gray-300\">\n {props.tabs.map((tab: string) => (\n <TabsTrigger value={tab} key={tab} className={`text-md w-[${tabsWidth}px]`}>\n {tab}\n </TabsTrigger>\n ))}\n </TabsList>\n </div>\n {props.tabs.map((tab: string) => (\n <TabsContent value={tab} className=\"tabs-content\" key={tab} />\n ))}\n </Tabs>\n );\n}\n\nexport function renderMarkdown(props: any): JSX.Element {\n const { gjsModel, ...rest } = props;\n\n const [allData, setAllData] = useState({\n ...props,\n });\n\n const [attributes, setAttributes] = useState({\n ...gjsModel.get('attributes'),\n });\n\n useEffect(() => {\n gjsModel.on('change:componentProps', () => {\n setAllData({\n ...gjsModel.get('componentProps'),\n });\n });\n }, []);\n\n useEffect(() => {\n gjsModel.on('change:attributes', () => {\n setAttributes({\n ...gjsModel.get('attributes'),\n });\n });\n }, []);\n\n const [isEditing, setIsEditing] = useState(false);\n const editRef = useRef<HTMLDivElement>(null);\n\n const startEditing = () => {\n setIsEditing(true);\n setTimeout(() => {\n setupEditor();\n }, 0);\n };\n\n const setupEditor = () => {\n if (!editRef.current) {\n return;\n }\n\n const editor = editRef.current;\n editor.innerHTML = '';\n editor.textContent = allData.summaryText;\n editor.focus();\n };\n\n // Save changes and exit editing mode\n const saveChanges = () => {\n if (!editRef.current) {\n return;\n }\n\n const content = editRef.current.innerText || '';\n setAllData((prev: Record<string, any>) => ({\n ...prev,\n summaryText: content,\n }));\n setIsEditing(false);\n editRef.current.innerHTML = '';\n };\n\n const markdownStyles = {\n ul: { props: { className: 'list-disc' } },\n h1: { props: { className: 'text-4xl font-bold leading-[4rem]' } },\n h2: { props: { className: 'text-3xl font-bold leading-[3rem]' } },\n h3: { props: { className: 'text-2xl font-bold leading-[2rem]' } },\n h4: { props: { className: 'text-xl font-bold leading-[2.5rem]' } },\n h5: { props: { className: 'text-lg font-bold leading-[2.5rem]' } },\n h6: { props: { className: 'text-base font-bold leading-[2rem]' } },\n };\n\n if (attributes.loading) {\n return <MarkdownLoader />\n }\n\n if (!allData.isEditable) {\n return (\n <div className=\"px-[1em]\" {...rest}>\n <div data-slot=\"summaryText\">\n <Markdown options={{ overrides: markdownStyles }}>{allData.summaryText}</Markdown>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"p-[1em]\" {...rest}>\n {isEditing ? (\n <div\n ref={editRef}\n contentEditable\n onBlur={saveChanges}\n data-slot=\"summaryText\"\n className=\"p-2 min-h-[100px] whitespace-pre-wrap\"\n suppressContentEditableWarning={true}\n style={{\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n />\n ) : (\n <div\n onClick={startEditing}\n data-slot=\"summaryText\"\n style={{\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n <Markdown options={{ overrides: markdownStyles }}>{allData.summaryText}</Markdown>\n </div>\n )}\n </div>\n );\n}\n\nexport function renderButton(props: any): JSX.Element {\n const { isEditable = false, gjsModel, performInteraction = () => {} } = props;\n\n const [allData, setAllData] = useState({\n ...props,\n });\n\n const [attributes, setAttributes] = useState({\n ...gjsModel.get('attributes'),\n });\n\n useEffect(() => {\n gjsModel.on('change:componentProps', () => {\n setAllData({\n ...gjsModel.get('componentProps'),\n });\n });\n }, []);\n\n useEffect(() => {\n gjsModel.on('change:attributes', () => {\n setAttributes({\n ...gjsModel.get('attributes'),\n });\n });\n }, []);\n\n const {\n text,\n className,\n payload,\n variant = 'default',\n size = 'sm',\n affectedComponents,\n tooltipContent,\n } = allData;\n\n function interact() {\n const id = gjsModel.get('id');\n performInteraction({\n id,\n interactionType: 'button',\n affectedComponents: getAffectedComponentsWithLoader([id, ...affectedComponents], true),\n payload,\n });\n }\n\n return (\n <TooltipButton\n className={className}\n isEditable={isEditable}\n interact={interact}\n attributes={attributes}\n variant={variant}\n size={size}\n text={text}\n tooltipContent={tooltipContent}\n />\n );\n}\n\nexport function getRenderers(): Record<string, (props: any) => JSX.Element> {\n return {\n ActionCard: renderActionCard,\n Button: renderButton,\n Card: renderCard,\n Chart: renderChart,\n Filter: renderFilter,\n Markdown: renderMarkdown,\n Search: renderSearch,\n Table: renderTable,\n Tabs: renderTab,\n };\n}\n"],"mappings":"02CAAA,sCACA,sDACA,+BACA,yDACA,+BACA,uDACA,MAAO,CAAAA,MAAM,KAAM,WAAW,CAC9B,MAAO,CAAAC,KAAK,EAAIC,SAAS,CAAEC,QAAQ,CAAOC,MAAM,KAAQ,OAAO,CAC/D,OAASC,oBAAoB,KAAQ,SAAS,CAC9C,OAASC,WAAW,KAAQ,cAAc,CA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,CAAAA,gBAAA,CAAAE,aAAA,CAIjBjO,OAAO,CAHTkO,IAAI,CAAJA,IAAI,CAAAD,aAAA,UAAG,IAAI,CAAAA,aAAA,CACXzE,kBAAkB,CAEhBxJ,OAAO,CAFTwJ,kBAAkB,CAClB2E,cAAc,CACZnO,OAAO,CADTmO,cAAc,CAGhB,QAAS,CAAAC,QAAQA,CAAA,CAAG,CAClB,GAAM,CAAAlG,EAAE,CAAGxI,QAAQ,CAACc,GAAG,CAAC,IAAI,CAAC,CAC7BmG,kBAAkB,CAAC,CACjBuB,EAAE,CAAFA,EAAE,CACFkB,eAAe,CAAE,QAAQ,CACzBI,kBAAkB,CAAEvN,+BAA+B,EAAEiM,EAAE,EAAAmG,MAAA,CAAK7E,kBAAkB,EAAG,IAAI,CAAC,CACtFH,OAAO,CAAPA,OACF,CAAC,CACH,CAEA,mBACEjN,IAAA,CAACzB,aAAa,EACZiG,SAAS,CAAEA,SAAU,CACrBC,UAAU,CAAEA,UAAW,CACvBuN,QAAQ,CAAEA,QAAS,CACnBzM,UAAU,CAAEA,UAAW,CACvBqM,OAAO,CAAEA,OAAQ,CACjBE,IAAI,CAAEA,IAAK,CACXJ,IAAI,CAAEA,IAAK,CACXK,cAAc,CAAEA,cAAe,CAChC,CAEL,CAEA,MAAO,SAAS,CAAAG,YAAYA,CAAA,CAAgD,CAC1E,MAAO,CACLC,UAAU,CAAE/O,gBAAgB,CAC5BgP,MAAM,CAAEf,YAAY,CACpB7S,IAAI,CAAEoG,UAAU,CAChByN,KAAK,CAAEhK,WAAW,CAClBiK,MAAM,CAAErT,YAAY,CACpBvB,QAAQ,CAAE0R,cAAc,CACxBmD,MAAM,CAAEnT,YAAY,CACpBoT,KAAK,CAAEnI,WAAW,CAClB7K,IAAI,CAAEuP,SACR,CACF","ignoreList":[]}
@@ -0,0 +1,3 @@
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{useCallback,useEffect,useRef,useState}from"react";import{ChevronDown,ChevronUp,ListFilter as FilterIcon,Loader2Icon}from"lucide-react";import{Button}from"./button";import{Checkbox}from"./checkbox";import{ScrollArea}from"./scroll-area";import{getAffectedComponentsWithLoader}from"../../../helpers";import{renderDateFilter}from"./date-filter";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function FilterHeader(_ref){var label=_ref.label,count=_ref.count,isDisabled=_ref.isDisabled,isDropdownOpen=_ref.isDropdownOpen,isLoading=_ref.isLoading,toggleOpen=_ref.toggleOpen;var ChevronIcon=isDropdownOpen?ChevronUp:ChevronDown;return/*#__PURE__*/_jsxs(Button,{variant:"outline",size:"sm",disabled:isDisabled,onClick:toggleOpen,className:"px-2",children:[/*#__PURE__*/_jsx(FilterIcon,{size:16}),count>0?label+" ("+count+")":label,isLoading?/*#__PURE__*/_jsx(Loader2Icon,{className:"ml-2 animate-spin",size:16}):/*#__PURE__*/_jsx(ChevronIcon,{size:16,className:"ml-1"})]})}function FilterActions(_ref2){var selected=_ref2.selected,allSelected=_ref2.allSelected,onClear=_ref2.onClear,onSelectAll=_ref2.onSelectAll,isDisabled=_ref2.isDisabled;return/*#__PURE__*/_jsxs("div",{className:"flex items-center mb-3",children:[/*#__PURE__*/_jsx(Checkbox,{checked:allSelected,onCheckedChange:function onCheckedChange(){return allSelected?onClear():onSelectAll()},disabled:isDisabled}),/*#__PURE__*/_jsx("span",{className:"ml-2 text-sm text-gray-900",children:"Select All"}),selected.length>0&&/*#__PURE__*/_jsx("button",{type:"button",className:"ml-auto text-sm text-blue-600 hover:underline",onMouseDown:function onMouseDown(e){e.stopPropagation();e.preventDefault()},onClick:onClear,disabled:isDisabled,children:"Clear All"})]})}function FilterOptionList(_ref3){var options=_ref3.options,selected=_ref3.selected,onToggle=_ref3.onToggle,isDisabled=_ref3.isDisabled;return/*#__PURE__*/_jsx(ScrollArea,{viewportClassName:"max-h-48 overflow-y-auto mb-4 space-y-2",children:options.length>0?options.map(function(opt){return/*#__PURE__*/_jsxs("label",{className:"flex items-center space-x-2 hover:bg-gray-100 rounded p-1 transition hover:cursor-pointer",onClick:function onClick(e){e.preventDefault();e.stopPropagation();if(!isDisabled){onToggle(opt.value)}},children:[/*#__PURE__*/_jsx(Checkbox,{checked:selected.includes(opt.value),onChange:function onChange(){// Prevent checkbox from toggling when clicking label
2
+ },disabled:isDisabled}),/*#__PURE__*/_jsx("span",{className:"text-sm text-gray-900",children:opt.label})]},opt.value)}):/*#__PURE__*/_jsx("div",{className:"text-sm text-gray-500",children:"No results found"})})}export function renderFilter(_ref4){var gjsModel=_ref4.gjsModel,performInteraction=_ref4.performInteraction;var _useState=useState(_extends({},gjsModel.get("componentProps"))),componentData=_useState[0],setComponentData=_useState[1];var _componentData$option=componentData.options,options=_componentData$option===void 0?[]:_componentData$option,_componentData$value=componentData.value,value=_componentData$value===void 0?[]:_componentData$value,_componentData$classN=componentData.className,className=_componentData$classN===void 0?"":_componentData$classN,_componentData$affect=componentData.affectedComponents,affectedComponents=_componentData$affect===void 0?[]:_componentData$affect,_componentData$text=componentData.text,label=_componentData$text===void 0?"Filter":_componentData$text,_componentData$filter=componentData.filterType,filterType=_componentData$filter===void 0?"multiselect":_componentData$filter;if(filterType==="date"){return renderDateFilter({gjsModel:gjsModel,performInteraction:performInteraction})}var wrapperRef=useRef(null);var _useState2=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState2[0],setAttributes=_useState2[1];var _useState3=useState(false),isDropdownOpen=_useState3[0],setIsDropdownOpen=_useState3[1];var _useState4=useState(""),searchQuery=_useState4[0],setSearchQuery=_useState4[1];var _useState5=useState(false),isApplying=_useState5[0],setIsApplying=_useState5[1];var _useState6=useState({left:"auto",right:"0"}),dropdownPosition=_useState6[0],setDropdownPosition=_useState6[1];var defaultValue=componentData["default"]||[];var _useState7=useState(function(){return Array.isArray(value)&&value.length>0?value:defaultValue}),selectedValues=_useState7[0],setSelectedValues=_useState7[1];var isMultiSelect=filterType==="multiselect";var isBusy=attributes.interactionApiInProgress||isApplying||attributes.loading;var allOptionsSelected=selectedValues.length===options.length&&options.length>0;useEffect(function(){var _document$getElementB;if(!isDropdownOpen||!wrapperRef.current){return}var filterRect=wrapperRef.current.getBoundingClientRect();var dropdownWidth=256;var iframeViewportWidth=document.documentElement.clientWidth;var iframeBodyWidth=((_document$getElementB=document.getElementById("dashboard-root"))==null?void 0:_document$getElementB.clientWidth)||iframeViewportWidth;var spaceToRight=iframeBodyWidth-filterRect.right;var spaceToLeft=filterRect.left;if(spaceToLeft>=dropdownWidth){setDropdownPosition({left:"auto",right:"0px"})}else if(spaceToRight<dropdownWidth&&spaceToLeft<dropdownWidth){var shiftLeft=dropdownWidth-spaceToRight+16;setDropdownPosition({left:"-"+shiftLeft+"px",right:"auto"})}else if(spaceToRight>=dropdownWidth){setDropdownPosition({left:"0px",right:"auto"})}},[isDropdownOpen]);useEffect(function(){function updateComponentData(){setComponentData(_extends({},gjsModel.get("componentProps")))}function updateAttributes(){setAttributes(_extends({},gjsModel.get("attributes")))}gjsModel.on("change:componentProps",updateComponentData);gjsModel.on("change:attributes",updateAttributes);return function(){gjsModel.off("change:componentProps",updateComponentData);gjsModel.off("change:attributes",updateAttributes)}},[gjsModel]);useEffect(function(){var _wrapperRef$current$o,_wrapperRef$current;var doc=(_wrapperRef$current$o=(_wrapperRef$current=wrapperRef.current)==null?void 0:_wrapperRef$current.ownerDocument)!=null?_wrapperRef$current$o:document;function handleOutsideClick(e){if(isDropdownOpen&&wrapperRef.current&&!wrapperRef.current.contains(e.target)){setIsDropdownOpen(false)}}function handleEscape(e){if(e.key==="Escape"){setIsDropdownOpen(false)}}doc.addEventListener("pointerdown",handleOutsideClick);doc.addEventListener("keydown",handleEscape);return function(){doc.removeEventListener("pointerdown",handleOutsideClick);doc.removeEventListener("keydown",handleEscape)}},[isDropdownOpen]);var filteredOptions=options.filter(function(opt){return String(opt.label).toLowerCase().includes(searchQuery.toLowerCase())});function updateAndApply(_x){return _updateAndApply.apply(this,arguments)}function _updateAndApply(){_updateAndApply=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(newValues){var id;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(newValues===void 0){newValues=selectedValues}setIsApplying(true);_context.prev=2;gjsModel.set("componentProps",_extends({},gjsModel.get("componentProps"),{value:newValues}));id=gjsModel.get("id");_context.next=7;return performInteraction({interactionType:"filter",id:id,affectedComponents:getAffectedComponentsWithLoader([id].concat(affectedComponents),true)});case 7:_context.prev=7;setIsApplying(false);setIsDropdownOpen(false);return _context.finish(7);case 11:case"end":return _context.stop()}},_callee,null,[[2,,7,11]])}));return _updateAndApply.apply(this,arguments)}var handleOptionToggle=useCallback(function(val){if(isMultiSelect){setSelectedValues(function(prev){return prev.includes(val)?prev.filter(function(v){return v!==val}):[].concat(prev,[val])})}else{if(selectedValues.includes(val)){setSelectedValues([]);updateAndApply([])}else{var singleValue=[val];setSelectedValues(singleValue);updateAndApply(singleValue)}}},[isMultiSelect,selectedValues]);function handleClearAll(){setSelectedValues([])}function handleSelectAll(){setSelectedValues(options.map(function(o){return o.value}))}return/*#__PURE__*/_jsxs("div",{ref:wrapperRef,className:"relative inline-block "+className,style:{color:"#2A44D4",backgroundColor:"rgb(255 255 255)"},children:[/*#__PURE__*/_jsx(FilterHeader,{label:label,count:selectedValues.length,isDisabled:isBusy,isDropdownOpen:isDropdownOpen,isLoading:isBusy,toggleOpen:function toggleOpen(){return setIsDropdownOpen(function(prev){return!prev})}}),isDropdownOpen&&/*#__PURE__*/_jsxs("div",{className:"absolute top-full mt-2 w-64 bg-white border rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 p-4 z-50",style:dropdownPosition,children:[/*#__PURE__*/_jsx("input",{type:"text",placeholder:"Search...",value:searchQuery,onChange:function onChange(e){return setSearchQuery(e.target.value)},className:"w-full mb-3 px-2 py-1 border rounded focus:outline-none",disabled:isBusy}),isMultiSelect&&/*#__PURE__*/_jsx(FilterActions,{selected:selectedValues,allSelected:allOptionsSelected,onClear:handleClearAll,onSelectAll:handleSelectAll,isDisabled:isBusy}),/*#__PURE__*/_jsx(FilterOptionList,{options:filteredOptions,selected:selectedValues,onToggle:handleOptionToggle,isDisabled:isBusy}),isMultiSelect&&/*#__PURE__*/_jsxs("div",{className:"flex justify-end space-x-2",children:[/*#__PURE__*/_jsx(Button,{variant:"ghost",size:"sm",onClick:function onClick(){return setIsDropdownOpen(false)},disabled:isApplying,children:"Cancel"}),/*#__PURE__*/_jsxs(Button,{variant:"default",size:"sm",onClick:function onClick(){return updateAndApply(selectedValues)},disabled:isBusy,children:[isApplying&&/*#__PURE__*/_jsx(Loader2Icon,{className:"animate-spin mr-2",size:16}),"Apply"]})]})]})]})}
3
+ //# sourceMappingURL=filter.js.map