@peak-ai/canvas 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
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{useEffect,useState,Fragment,useMemo,useRef}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{formatValue}from"../../helpers";import{SEMANTIC_CHIP_STYLES_MAP,RANDOM_CHIP_COLOR_PALETTE}from"../../constants";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";/**
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{useEffect,useState,Fragment,useMemo,useRef}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{formatValue}from"../../helpers";import{SEMANTIC_CHIP_STYLES_MAP,RANDOM_CHIP_COLOR_PALETTE}from"../../constants";import{useButtonForm}from"./button-form";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * Normalizes a value to a consistent string key for color mapping.
3
3
  * Handles all value types: null/undefined, numbers, booleans, objects, arrays, dates.
4
4
  * Ensures consistent color assignment for all variations of the same logical value.
@@ -7,9 +7,9 @@ if(value===null||value===undefined){return""}var str=String(value);return str.tr
7
7
  * Generates a stable hash based on unique value sets per column.
8
8
  * This hash is order-independent - it only changes when the set of unique values changes,
9
9
  * not when rows are reordered (e.g., during sorting).
10
- */function getUniqueValuesHash(data,columnWithChipClass){if(!Array.isArray(data)||data.length===0){return""}var availableKeys=Object.keys(data[0]||{});var hashParts={};Object.keys(columnWithChipClass).forEach(function(columnKey){if(!availableKeys.includes(columnKey)){return}var chipMode=getChipMode(columnWithChipClass,columnKey);if(chipMode==="useRandom"){var uniqueNormalizedValues=new Set;data.forEach(function(row){var value=row[columnKey];var normalizedKey=normalizeValue(value);if(normalizedKey){uniqueNormalizedValues.add(normalizedKey)}});var sortedUniqueValues=Array.from(uniqueNormalizedValues).sort();hashParts[columnKey]=sortedUniqueValues}});return JSON.stringify(hashParts)}export function DataTable(_ref){var _ref2,_pagination$values$pa,_pagination$values,_ref3,_pagination$values$pa2,_pagination$values2;var _ref$data=_ref.data,data=_ref$data===void 0?[]:_ref$data,_ref$headerMapper=_ref.headerMapper,headerMapper=_ref$headerMapper===void 0?{}:_ref$headerMapper,_ref$className=_ref.className,className=_ref$className===void 0?"":_ref$className,_ref$actions=_ref.actions,actions=_ref$actions===void 0?[]:_ref$actions,_ref$isEditable=_ref.isEditable,isEditable=_ref$isEditable===void 0?false:_ref$isEditable,pagination=_ref.pagination,_ref$isLoading=_ref.isLoading,isLoading=_ref$isLoading===void 0?false:_ref$isLoading,onRowAction=_ref.onRowAction,onPageChange=_ref.onPageChange,onSort=_ref.onSort,sortConfig=_ref.sortConfig,_ref$otherProps=_ref.otherProps,otherProps=_ref$otherProps===void 0?{}:_ref$otherProps,height=_ref.height,_ref$decimalPrecision=_ref.decimalPrecision,decimalPrecision=_ref$decimalPrecision===void 0?2:_ref$decimalPrecision,_ref$columnWithChipCl=_ref.columnWithChipClass,columnWithChipClass=_ref$columnWithChipCl===void 0?{}:_ref$columnWithChipCl,_ref$chipStylesMappin=_ref.chipStylesMapping,chipStylesMapping=_ref$chipStylesMappin===void 0?{}:_ref$chipStylesMappin;if(!data||data.length===0){return/*#__PURE__*/_jsx(Fragment,{children:/*#__PURE__*/_jsx("div",{className:"flex flex-col overflow-hidden",children:/*#__PURE__*/_jsx("div",{"data-slot":"table-container",className:"aspect-auto w-full",style:{height:"auto",minHeight:"180px"},children:isLoading?/*#__PURE__*/_jsx(TableLoader,{}):renderNoDataFallback()})})})}var _useState=useState(null),activeSortColumn=_useState[0],setActiveSortColumn=_useState[1];var _useState2=useState({}),sortDirections=_useState2[0],setSortDirections=_useState2[1];var _useState3=useState(Number((_ref2=(_pagination$values$pa=pagination==null||(_pagination$values=pagination.values)==null?void 0:_pagination$values.pageNumber)!=null?_pagination$values$pa:pagination==null?void 0:pagination.initialPage)!=null?_ref2:1)),pageNumber=_useState3[0],setPageNumber=_useState3[1];var _useState4=useState(Number((_ref3=(_pagination$values$pa2=pagination==null||(_pagination$values2=pagination.values)==null?void 0:_pagination$values2.pageSize)!=null?_pagination$values$pa2:pagination==null?void 0:pagination.initialPageSize)!=null?_ref3:10)),pageSize=_useState4[0],setPageSize=_useState4[1];var _useState5=useState(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1),totalPages=_useState5[0],setTotalPages=_useState5[1];var _useState6=useState({}),chipColorMap=_useState6[0],setChipColorMap=_useState6[1];var prevDataHashRef=useRef("");useEffect(function(){var _ref4,_pagination$values$pa3,_pagination$values3,_ref5,_pagination$values$pa4,_pagination$values4;setPageNumber(Number((_ref4=(_pagination$values$pa3=pagination==null||(_pagination$values3=pagination.values)==null?void 0:_pagination$values3.pageNumber)!=null?_pagination$values$pa3:pagination==null?void 0:pagination.initialPage)!=null?_ref4:1));setPageSize(Number((_ref5=(_pagination$values$pa4=pagination==null||(_pagination$values4=pagination.values)==null?void 0:_pagination$values4.pageSize)!=null?_pagination$values$pa4:pagination==null?void 0:pagination.initialPageSize)!=null?_ref5:25))},[pagination]);useEffect(function(){setTotalPages(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1)},[pagination==null?void 0:pagination.totalCount,pageSize]);useEffect(function(){if(sortConfig){setSortDirections(sortConfig);var first=Object.keys(sortConfig)[0];if(first){setActiveSortColumn(first)}}},[sortConfig]);useEffect(function(){if(sortConfig!=null&&sortConfig.sortColumn||sortConfig!=null&&sortConfig.sortDirection){sortConfig.sortColumn=null;sortConfig.sortDirection=null}setActiveSortColumn(null);setSortDirections({})},[]);var computedColorMap=useMemo(function(){if(!Array.isArray(data)||data.length===0){return{}}// Get available column keys from first row
10
+ */function getUniqueValuesHash(data,columnWithChipClass){if(!Array.isArray(data)||data.length===0){return""}var availableKeys=Object.keys(data[0]||{});var hashParts={};Object.keys(columnWithChipClass).forEach(function(columnKey){if(!availableKeys.includes(columnKey)){return}var chipMode=getChipMode(columnWithChipClass,columnKey);if(chipMode==="useRandom"){var uniqueNormalizedValues=new Set;data.forEach(function(row){var value=row[columnKey];var normalizedKey=normalizeValue(value);if(normalizedKey){uniqueNormalizedValues.add(normalizedKey)}});var sortedUniqueValues=Array.from(uniqueNormalizedValues).sort();hashParts[columnKey]=sortedUniqueValues}});return JSON.stringify(hashParts)}export function DataTable(_ref){var _ref2,_pagination$values$pa,_pagination$values,_ref3,_pagination$values$pa2,_pagination$values2;var _ref$data=_ref.data,data=_ref$data===void 0?[]:_ref$data,_ref$headerMapper=_ref.headerMapper,headerMapper=_ref$headerMapper===void 0?{}:_ref$headerMapper,_ref$className=_ref.className,className=_ref$className===void 0?"":_ref$className,_ref$actions=_ref.actions,actions=_ref$actions===void 0?[]:_ref$actions,_ref$isEditable=_ref.isEditable,isEditable=_ref$isEditable===void 0?false:_ref$isEditable,pagination=_ref.pagination,_ref$isLoading=_ref.isLoading,isLoading=_ref$isLoading===void 0?false:_ref$isLoading,onRowAction=_ref.onRowAction,onPageChange=_ref.onPageChange,onSort=_ref.onSort,sortConfig=_ref.sortConfig,_ref$otherProps=_ref.otherProps,otherProps=_ref$otherProps===void 0?{}:_ref$otherProps,height=_ref.height,_ref$decimalPrecision=_ref.decimalPrecision,decimalPrecision=_ref$decimalPrecision===void 0?2:_ref$decimalPrecision,_ref$columnWithChipCl=_ref.columnWithChipClass,columnWithChipClass=_ref$columnWithChipCl===void 0?{}:_ref$columnWithChipCl,_ref$chipStylesMappin=_ref.chipStylesMapping,chipStylesMapping=_ref$chipStylesMappin===void 0?{}:_ref$chipStylesMappin;if(!data||data.length===0){return/*#__PURE__*/_jsx(Fragment,{children:/*#__PURE__*/_jsx("div",{className:"flex flex-col overflow-hidden",children:/*#__PURE__*/_jsx("div",{"data-slot":"table-container",className:"aspect-auto w-full",style:{height:"auto",minHeight:"180px"},children:isLoading?/*#__PURE__*/_jsx(TableLoader,{}):renderNoDataFallback()})})})}var _useState=useState(null),activeSortColumn=_useState[0],setActiveSortColumn=_useState[1];var _useState2=useState({}),sortDirections=_useState2[0],setSortDirections=_useState2[1];var _useState3=useState(null),activeRowIndex=_useState3[0],setActiveRowIndex=_useState3[1];var _useState4=useState(null),activeAction=_useState4[0],setActiveAction=_useState4[1];var _useState5=useState(false),isFormSubmitting=_useState5[0],setIsFormSubmitting=_useState5[1];var _useState6=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=_useState6[0],setPageNumber=_useState6[1];var _useState7=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=_useState7[0],setPageSize=_useState7[1];var _useState8=useState(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1),totalPages=_useState8[0],setTotalPages=_useState8[1];var _useState9=useState({}),chipColorMap=_useState9[0],setChipColorMap=_useState9[1];var prevDataHashRef=useRef("");useEffect(function(){var _ref4,_pagination$values$pa3,_pagination$values3,_ref5,_pagination$values$pa4,_pagination$values4;setPageNumber(Number((_ref4=(_pagination$values$pa3=pagination==null||(_pagination$values3=pagination.values)==null?void 0:_pagination$values3.pageNumber)!=null?_pagination$values$pa3:pagination==null?void 0:pagination.initialPage)!=null?_ref4:1));setPageSize(Number((_ref5=(_pagination$values$pa4=pagination==null||(_pagination$values4=pagination.values)==null?void 0:_pagination$values4.pageSize)!=null?_pagination$values$pa4:pagination==null?void 0:pagination.initialPageSize)!=null?_ref5:25))},[pagination]);useEffect(function(){setTotalPages(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1)},[pagination==null?void 0:pagination.totalCount,pageSize]);useEffect(function(){if(sortConfig){setSortDirections(sortConfig);var first=Object.keys(sortConfig)[0];if(first){setActiveSortColumn(first)}}},[sortConfig]);useEffect(function(){if(sortConfig!=null&&sortConfig.sortColumn||sortConfig!=null&&sortConfig.sortDirection){sortConfig.sortColumn=null;sortConfig.sortDirection=null}setActiveSortColumn(null);setSortDirections({})},[]);var computedColorMap=useMemo(function(){if(!Array.isArray(data)||data.length===0){return{}}// Get available column keys from first row
11
11
  var availableKeys=Object.keys(data[0]||{});var newColorMap={};// Process each column that uses random chips
12
12
  Object.keys(columnWithChipClass).forEach(function(columnKey){// Validate column key exists in data
13
13
  if(!availableKeys.includes(columnKey)){return}var chipMode=getChipMode(columnWithChipClass,columnKey);if(chipMode==="useRandom"){if(!newColorMap[columnKey]){newColorMap[columnKey]={}}var uniqueNormalizedValues=new Set;data.forEach(function(row){var value=row[columnKey];var normalizedKey=normalizeValue(value);if(normalizedKey){uniqueNormalizedValues.add(normalizedKey)}});var sortedUniqueValues=Array.from(uniqueNormalizedValues).sort();sortedUniqueValues.forEach(function(normalizedKey,index){if(!newColorMap[columnKey][normalizedKey]){var colorIndex=index%RANDOM_CHIP_COLOR_PALETTE.length;newColorMap[columnKey][normalizedKey]=RANDOM_CHIP_COLOR_PALETTE[colorIndex]}})}});return newColorMap},[data,columnWithChipClass]);useEffect(function(){var uniqueValuesHash=getUniqueValuesHash(data,columnWithChipClass);// Only update if the set of unique values actually changed
14
- if(uniqueValuesHash!==prevDataHashRef.current){prevDataHashRef.current=uniqueValuesHash;setChipColorMap(function(prevMap){var merged=_extends({},prevMap);Object.keys(computedColorMap).forEach(function(columnKey){merged[columnKey]=_extends({},computedColorMap[columnKey],merged[columnKey])});return merged})}},[computedColorMap,data,columnWithChipClass]);useEffect(function(){setChipColorMap(function(prevMap){var cleaned=_extends({},prevMap);var hasChanges=false;Object.keys(cleaned).forEach(function(columnKey){var chipMode=getChipMode(columnWithChipClass,columnKey);if(!chipMode){delete cleaned[columnKey];hasChanges=true}});return hasChanges?cleaned:prevMap})},[columnWithChipClass]);var originalKeys=Object.keys(data[0]||{}).filter(function(key){return key in headerMapper});var headers=originalKeys.map(function(key){return headerMapper[key]});if(actions.length>0){headers.push("")}var rows=data.map(function(datum){return originalKeys.map(function(key){return datum[key]})});function handlePageChange(_x,_x2){return _handlePageChange.apply(this,arguments)}function _handlePageChange(){_handlePageChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(newPage,newSize){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(newPage===void 0){newPage=pageNumber}if(newSize===void 0){newSize=pageSize}setPageNumber(newPage);setPageSize(newSize);onPageChange==null||onPageChange(newPage,newSize);case 5:case"end":return _context.stop()}},_callee)}));return _handlePageChange.apply(this,arguments)}function handleSortClick(column,direction){setActiveSortColumn(direction?column:null);setSortDirections(function(prev){var _extends2;return _extends({},prev,(_extends2={},_extends2[column]=direction,_extends2))});onSort==null||onSort(column,direction)}function renderActions(rowIndex,rowActions){if(!actions.length){return null}return/*#__PURE__*/_jsx(TableCell,{className:"sticky right-0 bg-white",children:rowActions.map(function(action){return/*#__PURE__*/_jsx(TableButton,{className:action.className,isEditable:isEditable,onClick:function onClick(){return onRowAction==null?void 0:onRowAction(rowIndex,action.id)},variant:action.variant,text:action.text,tooltipContent:action.tooltipContent,disabled:isLoading},action.id)})})}var defaultClasses="aspect-auto w-full";var mergedClasses=className?cn(defaultClasses,className):defaultClasses;function getRandomColorForValue(columnKey,value){var _chipColorMap$columnK;var normalizedKey=normalizeValue(value);if((_chipColorMap$columnK=chipColorMap[columnKey])!=null&&_chipColorMap$columnK[normalizedKey]){return chipColorMap[columnKey][normalizedKey]}return"bg-gray-50 text-gray-900 shadow-sm"}function renderChip(columnKey,value){var chipMode=getChipMode(columnWithChipClass,columnKey);var formattedValue=formatValue(value,decimalPrecision);if(!chipMode){return/*#__PURE__*/_jsx(_Fragment,{children:formattedValue})}var chipClassName="";if(chipMode==="useMap"){var _chipStylesMapping$co;var valueStr=String(value);chipClassName=(_chipStylesMapping$co=chipStylesMapping[columnKey])==null?void 0:_chipStylesMapping$co[valueStr];if(!chipClassName){var valueLower=valueStr.toLowerCase().trim();chipClassName=SEMANTIC_CHIP_STYLES_MAP[valueLower]}if(!chipClassName){chipClassName="bg-gray-50 text-gray-900 shadow-sm"}}else if(chipMode==="useRandom"){chipClassName=getRandomColorForValue(columnKey,value)}return/*#__PURE__*/_jsx("span",{className:cn("inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-gray-500/10",chipClassName),children:formattedValue})}function renderTableComponent(){if(isLoading||!data||data.length===0){return/*#__PURE__*/_jsx(TableLoader,{})}return/*#__PURE__*/_jsxs(Table,_extends({},otherProps,{className:"caption-bottom text-sm relative "+mergedClasses,"data-slot":"table",children:[/*#__PURE__*/_jsx(TableHeader,{"data-slot":"table-header",className:"sticky top-0 z-2",children:/*#__PURE__*/_jsx(TableRow,{children:headers.map(function(head,idx){var isActionColumn=actions.length>0&&idx===headers.length-1;var originalKey=originalKeys[idx];if(isActionColumn){return/*#__PURE__*/_jsx(TableHead,{"data-slot":"table-header-"+idx,contentEditable:isEditable,className:"sticky right-0 bg-slate-100",children:head},idx)}return/*#__PURE__*/_jsx(TableHeadSortable,{"data-slot":"table-header-"+idx,sortDirection:sortDirections[originalKey]||"asc",isActive:activeSortColumn===originalKey,onSort:function onSort(direction){return handleSortClick(originalKey,direction)},sortable:!isLoading,isEditable:isEditable,children:head},idx)})})}),/*#__PURE__*/_jsx(TableBody,{"data-slot":"table-body",children:rows.map(function(row,rIdx){return/*#__PURE__*/_jsxs(TableRow,{"data-slot":"row-"+rIdx,className:"hover:bg-muted/50 border-b transition-colors",children:[row.map(function(cell,cIdx){var columnKey=originalKeys[cIdx];var chipMode=columnKey?getChipMode(columnWithChipClass,columnKey):undefined;var shouldRenderChip=!!chipMode;return/*#__PURE__*/_jsx(TableCell,{"data-slot":"cell-"+rIdx+"-"+cIdx,className:"p-2 align-middle whitespace-nowrap",contentEditable:false,children:shouldRenderChip?renderChip(columnKey,cell):formatValue(cell,decimalPrecision)},cIdx)}),renderActions(rIdx,actions)]},rIdx)})})]}))}return/*#__PURE__*/_jsxs(Fragment,{children:[/*#__PURE__*/_jsx("div",{className:"flex flex-col h-full overflow-hidden",children:/*#__PURE__*/_jsxs(ScrollArea,_extends({"data-slot":"table-container",className:mergedClasses},height!==undefined&&{style:{height:height}},{children:[renderTableComponent(),/*#__PURE__*/_jsx(ScrollBar,{orientation:"horizontal"})]}))}),pagination&&pagination.totalCount>0&&/*#__PURE__*/_jsxs("div",{className:"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[/*#__PURE__*/_jsx("label",{htmlFor:"page-size-select",className:"text-sm whitespace-nowrap",children:"Rows per page:"}),/*#__PURE__*/_jsx("select",{id:"page-size-select",value:pageSize,onChange:function onChange(e){return handlePageChange(1,Number(e.target.value))},className:"border rounded px-2 py-1 text-sm cursor-pointer",disabled:isLoading,children:pagination.pageSizeOptions.map(function(size){return/*#__PURE__*/_jsx("option",{value:size,children:size},size)})})]}),/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[/*#__PURE__*/_jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap ml-1.5",children:[(pageNumber-1)*pageSize+1,"\u2013",Math.min(pageNumber*pageSize,pagination.totalCount)," of ",pagination.totalCount]}),/*#__PURE__*/_jsx(Pagination,{children:/*#__PURE__*/_jsx(PaginationContent,{className:"gap-0.2 flex-shrink-0",children:renderPaginationArrows(pageNumber,totalPages,isLoading,handlePageChange)})})]})]})]})}
14
+ if(uniqueValuesHash!==prevDataHashRef.current){prevDataHashRef.current=uniqueValuesHash;setChipColorMap(function(prevMap){var merged=_extends({},prevMap);Object.keys(computedColorMap).forEach(function(columnKey){merged[columnKey]=_extends({},computedColorMap[columnKey],merged[columnKey])});return merged})}},[computedColorMap,data,columnWithChipClass]);useEffect(function(){setChipColorMap(function(prevMap){var cleaned=_extends({},prevMap);var hasChanges=false;Object.keys(cleaned).forEach(function(columnKey){var chipMode=getChipMode(columnWithChipClass,columnKey);if(!chipMode){delete cleaned[columnKey];hasChanges=true}});return hasChanges?cleaned:prevMap})},[columnWithChipClass]);var _useButtonForm=useButtonForm({formMapper:activeAction==null?void 0:activeAction.action.formMapper,formTitle:activeAction==null?void 0:activeAction.action.formTitle,formDescription:activeAction==null?void 0:activeAction.action.formDescription,formButtonText:activeAction==null?void 0:activeAction.action.formButtonText,isSubmitting:isFormSubmitting||isLoading,onClose:function onClose(){setActiveRowIndex(null);setActiveAction(null)},onSubmit:function(){var _onSubmit=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(formData){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!(activeRowIndex!==null&&activeAction)){_context.next=10;break}setIsFormSubmitting(true);_context.prev=2;_context.next=5;return onRowAction==null?void 0:onRowAction(activeRowIndex,activeAction.id,formData);case 5:_context.prev=5;setIsFormSubmitting(false);return _context.finish(5);case 8:setActiveAction(null);setActiveRowIndex(null);case 10:case"end":return _context.stop()}},_callee,null,[[2,,5,8]])}));function onSubmit(_x){return _onSubmit.apply(this,arguments)}return onSubmit}()}),FormDialog=_useButtonForm.FormDialog,openForm=_useButtonForm.openForm;function handleButtonClick(rowIndex,action){if(action.action.formMapper&&Object.keys(action.action.formMapper).length>0){setActiveRowIndex(rowIndex);setActiveAction(action)}else{onRowAction==null||onRowAction(rowIndex,action.id)}}useEffect(function(){if(activeAction!=null&&activeAction.action.formMapper&&Object.keys(activeAction.action.formMapper).length>0){openForm()}},[activeAction]);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(_x2,_x3){return _handlePageChange.apply(this,arguments)}function _handlePageChange(){_handlePageChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(newPage,newSize){return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.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 _context2.stop()}},_callee2)}));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 handleButtonClick(rowIndex,action)},variant:action.variant,text:action.text,tooltipContent:action.tooltipContent,disabled:isLoading},action.id)})})}var defaultClasses="aspect-auto w-full";var mergedClasses=className?cn(defaultClasses,className):defaultClasses;function getRandomColorForValue(columnKey,value){var _chipColorMap$columnK;var normalizedKey=normalizeValue(value);if((_chipColorMap$columnK=chipColorMap[columnKey])!=null&&_chipColorMap$columnK[normalizedKey]){return chipColorMap[columnKey][normalizedKey]}return"bg-gray-50 text-gray-900 shadow-sm"}function renderChip(columnKey,value){var chipMode=getChipMode(columnWithChipClass,columnKey);var formattedValue=formatValue(value,decimalPrecision);if(!chipMode){return/*#__PURE__*/_jsx(_Fragment,{children:formattedValue})}var chipClassName="";if(chipMode==="useMap"){var _chipStylesMapping$co;var valueStr=String(value);chipClassName=(_chipStylesMapping$co=chipStylesMapping[columnKey])==null?void 0:_chipStylesMapping$co[valueStr];if(!chipClassName){var valueLower=valueStr.toLowerCase().trim();chipClassName=SEMANTIC_CHIP_STYLES_MAP[valueLower]}if(!chipClassName){chipClassName="bg-gray-50 text-gray-900 shadow-sm"}}else if(chipMode==="useRandom"){chipClassName=getRandomColorForValue(columnKey,value)}return/*#__PURE__*/_jsx("span",{className:cn("inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-gray-500/10",chipClassName),children:formattedValue})}function renderTableComponent(){if(isLoading||!data||data.length===0){return/*#__PURE__*/_jsx(TableLoader,{})}return/*#__PURE__*/_jsxs(Table,_extends({},otherProps,{className:"caption-bottom text-sm relative "+mergedClasses,"data-slot":"table",children:[/*#__PURE__*/_jsx(TableHeader,{"data-slot":"table-header",className:"sticky top-0 z-2",children:/*#__PURE__*/_jsx(TableRow,{children:headers.map(function(head,idx){var isActionColumn=actions.length>0&&idx===headers.length-1;var originalKey=originalKeys[idx];if(isActionColumn){return/*#__PURE__*/_jsx(TableHead,{"data-slot":"table-header-"+idx,contentEditable:isEditable,className:"sticky right-0 bg-slate-100",children:head},idx)}return/*#__PURE__*/_jsx(TableHeadSortable,{"data-slot":"table-header-"+idx,sortDirection:sortDirections[originalKey]||"asc",isActive:activeSortColumn===originalKey,onSort:function onSort(direction){return handleSortClick(originalKey,direction)},sortable:!isLoading,isEditable:isEditable,children:head},idx)})})}),/*#__PURE__*/_jsx(TableBody,{"data-slot":"table-body",children:rows.map(function(row,rIdx){return/*#__PURE__*/_jsxs(TableRow,{"data-slot":"row-"+rIdx,className:"hover:bg-muted/50 border-b transition-colors",children:[row.map(function(cell,cIdx){var columnKey=originalKeys[cIdx];var chipMode=columnKey?getChipMode(columnWithChipClass,columnKey):undefined;var shouldRenderChip=!!chipMode;return/*#__PURE__*/_jsx(TableCell,{"data-slot":"cell-"+rIdx+"-"+cIdx,className:"p-2 align-middle whitespace-nowrap",contentEditable:false,children:shouldRenderChip?renderChip(columnKey,cell):formatValue(cell,decimalPrecision)},cIdx)}),renderActions(rIdx,actions)]},rIdx)})})]}))}return/*#__PURE__*/_jsxs(Fragment,{children:[/*#__PURE__*/_jsx("div",{className:"flex flex-col h-full overflow-hidden",children:/*#__PURE__*/_jsxs(ScrollArea,_extends({"data-slot":"table-container",className:mergedClasses},height!==undefined&&{style:{height:height}},{children:[renderTableComponent(),/*#__PURE__*/_jsx(ScrollBar,{orientation:"horizontal"})]}))}),pagination&&pagination.totalCount>0&&/*#__PURE__*/_jsxs("div",{className:"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[/*#__PURE__*/_jsx("label",{htmlFor:"page-size-select",className:"text-sm whitespace-nowrap",children:"Rows per page:"}),/*#__PURE__*/_jsx("select",{id:"page-size-select",value:pageSize,onChange:function onChange(e){return handlePageChange(1,Number(e.target.value))},className:"border rounded px-2 py-1 text-sm cursor-pointer",disabled:isLoading,children:pagination.pageSizeOptions.map(function(size){return/*#__PURE__*/_jsx("option",{value:size,children:size},size)})})]}),/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[/*#__PURE__*/_jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap ml-1.5",children:[(pageNumber-1)*pageSize+1,"\u2013",Math.min(pageNumber*pageSize,pagination.totalCount)," of ",pagination.totalCount]}),/*#__PURE__*/_jsx(Pagination,{children:/*#__PURE__*/_jsx(PaginationContent,{className:"gap-0.2 flex-shrink-0",children:renderPaginationArrows(pageNumber,totalPages,isLoading,handlePageChange)})})]})]}),FormDialog]})}
15
15
  //# sourceMappingURL=data-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-table.js","names":["useEffect","useState","Fragment","useMemo","useRef","Table","TableHeader","TableRow","TableHead","TableBody","TableCell","TableHeadSortable","TableLoader","ScrollArea","ScrollBar","Pagination","PaginationContent","renderPaginationArrows","TableButton","cn","renderNoDataFallback","formatValue","SEMANTIC_CHIP_STYLES_MAP","RANDOM_CHIP_COLOR_PALETTE","jsx","_jsx","_Fragment","jsxs","_jsxs","normalizeValue","value","undefined","str","String","trim","toLowerCase","getChipMode","columnWithChipClass","columnKey","mode","getUniqueValuesHash","data","Array","isArray","length","availableKeys","Object","keys","hashParts","forEach","includes","chipMode","uniqueNormalizedValues","Set","row","normalizedKey","add","sortedUniqueValues","from","sort","JSON","stringify","DataTable","_ref","_ref2","_pagination$values$pa","_pagination$values","_ref3","_pagination$values$pa2","_pagination$values2","_ref$data","_ref$headerMapper","headerMapper","_ref$className","className","_ref$actions","actions","_ref$isEditable","isEditable","pagination","_ref$isLoading","isLoading","onRowAction","onPageChange","onSort","sortConfig","_ref$otherProps","otherProps","height","_ref$decimalPrecision","decimalPrecision","_ref$columnWithChipCl","_ref$chipStylesMappin","chipStylesMapping","children","style","minHeight","_useState","activeSortColumn","setActiveSortColumn","_useState2","sortDirections","setSortDirections","_useState3","Number","values","pageNumber","initialPage","setPageNumber","_useState4","pageSize","initialPageSize","setPageSize","_useState5","Math","ceil","totalCount","totalPages","setTotalPages","_useState6","chipColorMap","setChipColorMap","prevDataHashRef","_ref4","_pagination$values$pa3","_pagination$values3","_ref5","_pagination$values$pa4","_pagination$values4","first","sortColumn","sortDirection","computedColorMap","newColorMap","index","colorIndex","uniqueValuesHash","current","prevMap","merged","_extends","cleaned","hasChanges","originalKeys","filter","key","headers","map","push","rows","datum","handlePageChange","_x","_x2","_handlePageChange","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","newPage","newSize","wrap","_callee$","_context","prev","next","stop","handleSortClick","column","direction","_extends2","renderActions","rowIndex","rowActions","action","onClick","id","variant","text","tooltipContent","disabled","defaultClasses","mergedClasses","getRandomColorForValue","_chipColorMap$columnK","renderChip","formattedValue","chipClassName","_chipStylesMapping$co","valueStr","valueLower","renderTableComponent","head","idx","isActionColumn","originalKey","contentEditable","isActive","sortable","rIdx","cell","cIdx","shouldRenderChip","orientation","htmlFor","onChange","e","target","pageSizeOptions","size","min"],"sources":["../../../src/plugins/helpers/data-table.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useEffect, useState, Fragment, useMemo, useRef } 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';\nimport { formatValue } from '../../helpers';\nimport { SEMANTIC_CHIP_STYLES_MAP, RANDOM_CHIP_COLOR_PALETTE } from '../../constants';\n\ntype RowAction = {\n id: string;\n text: string;\n variant?: string;\n tooltipContent?: string;\n className?: string;\n};\n\nexport type DataTableProps = {\n data: Record<string, any>[];\n headerMapper?: Record<string, string>;\n className?: string;\n isEditable?: boolean;\n actions?: RowAction[];\n pagination?: {\n values?: {\n pageNumber: number;\n pageSize: number;\n };\n initialPage?: number;\n initialPageSize?: number;\n totalCount: number;\n pageSizeOptions: number[];\n };\n isLoading?: boolean;\n onRowAction?: (rowIndex: number, actionId: string) => void;\n onPageChange?: (pageNumber: number, pageSize: number) => void;\n onSort?: (column: string, direction: SortDirection) => void;\n sortConfig?: Record<string, SortDirection>;\n otherProps?: Record<string, any>;\n height?: string | number;\n decimalPrecision?: number;\n columnWithChipClass?: Record<string, 'useMap' | 'useRandom'>;\n chipStylesMapping?: Record<string, Record<string, string>>;\n};\n\n/**\n * Normalizes a value to a consistent string key for color mapping.\n * Handles all value types: null/undefined, numbers, booleans, objects, arrays, dates.\n * Ensures consistent color assignment for all variations of the same logical value.\n */\nfunction normalizeValue(value: any): string {\n // Handle null/undefined\n if (value === null || value === undefined) {\n return '';\n }\n\n const str = String(value);\n \n return str.trim().toLowerCase();\n}\n\nfunction getChipMode(\n columnWithChipClass: Record<string, 'useMap' | 'useRandom'>,\n columnKey: string\n): 'useMap' | 'useRandom' | undefined {\n if (!(columnKey in columnWithChipClass)) {\n return undefined;\n }\n \n const mode = columnWithChipClass[columnKey];\n\n if (mode !== 'useMap' && mode !== 'useRandom') {\n return 'useRandom';\n }\n \n return mode;\n}\n\n/**\n * Generates a stable hash based on unique value sets per column.\n * This hash is order-independent - it only changes when the set of unique values changes,\n * not when rows are reordered (e.g., during sorting).\n */\nfunction getUniqueValuesHash(\n data: Record<string, any>[],\n columnWithChipClass: Record<string, 'useMap' | 'useRandom'>\n): string {\n if (!Array.isArray(data) || data.length === 0) {\n return '';\n }\n\n const availableKeys = Object.keys(data[0] || {});\n const hashParts: Record<string, string[]> = {};\n\n Object.keys(columnWithChipClass).forEach((columnKey) => {\n if (!availableKeys.includes(columnKey)) {\n return;\n }\n\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n if (chipMode === 'useRandom') {\n const uniqueNormalizedValues = new Set<string>();\n data.forEach((row) => {\n const value = row[columnKey];\n const normalizedKey = normalizeValue(value);\n\n if (normalizedKey) {\n uniqueNormalizedValues.add(normalizedKey);\n }\n });\n const sortedUniqueValues = Array.from(uniqueNormalizedValues).sort();\n hashParts[columnKey] = sortedUniqueValues;\n }\n });\n\n return JSON.stringify(hashParts);\n}\n\nexport function DataTable({\n data = [],\n headerMapper = {},\n className = '',\n actions = [],\n isEditable = false,\n pagination,\n isLoading = false,\n onRowAction,\n onPageChange,\n onSort,\n sortConfig,\n otherProps = {},\n height,\n decimalPrecision = 2,\n columnWithChipClass = {},\n chipStylesMapping = {},\n}: DataTableProps) {\n\n if (!data || data.length === 0) {\n return (\n <Fragment>\n <div className=\"flex flex-col overflow-hidden\">\n <div\n data-slot=\"table-container\"\n className=\"aspect-auto w-full\"\n style={{ height: 'auto', minHeight: '180px' }}\n >\n {isLoading ? <TableLoader /> : renderNoDataFallback()}\n </div>\n </div>\n </Fragment>\n );\n }\n\n const [activeSortColumn, setActiveSortColumn] = useState<string | null>(null);\n const [sortDirections, setSortDirections] = useState<Record<string, SortDirection>>({});\n\n const [pageNumber, setPageNumber] = useState(\n Number(pagination?.values?.pageNumber ?? pagination?.initialPage ?? 1),\n );\n const [pageSize, setPageSize] = useState(\n Number(pagination?.values?.pageSize ?? pagination?.initialPageSize ?? 10),\n );\n const [totalPages, setTotalPages] = useState(\n Math.ceil((pagination?.totalCount || 0) / pageSize) || 1,\n );\n\n const [chipColorMap, setChipColorMap] = useState<Record<string, Record<string, string>>>({});\n\n const prevDataHashRef = useRef<string>('');\n\n useEffect(() => {\n setPageNumber(Number(pagination?.values?.pageNumber ?? pagination?.initialPage ?? 1));\n setPageSize(Number(pagination?.values?.pageSize ?? pagination?.initialPageSize ?? 25));\n }, [pagination]);\n\n useEffect(() => {\n setTotalPages(Math.ceil((pagination?.totalCount || 0) / pageSize) || 1);\n }, [pagination?.totalCount, pageSize]);\n\n useEffect(() => {\n if (sortConfig) {\n setSortDirections(sortConfig);\n const first = Object.keys(sortConfig)[0];\n\n if (first) {\n setActiveSortColumn(first);\n }\n }\n }, [sortConfig]);\n\n useEffect(() => {\n if (sortConfig?.sortColumn || sortConfig?.sortDirection) {\n sortConfig.sortColumn = null;\n sortConfig.sortDirection = null;\n }\n \n setActiveSortColumn(null);\n setSortDirections({});\n }, []);\n\n const computedColorMap = useMemo(() => {\n if (!Array.isArray(data) || data.length === 0) {\n return {};\n }\n\n // Get available column keys from first row\n const availableKeys = Object.keys(data[0] || {});\n \n const newColorMap: Record<string, Record<string, string>> = {};\n\n // Process each column that uses random chips\n Object.keys(columnWithChipClass).forEach((columnKey) => {\n // Validate column key exists in data\n if (!availableKeys.includes(columnKey)) {\n return;\n }\n\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n if (chipMode === 'useRandom') {\n if (!newColorMap[columnKey]) {\n newColorMap[columnKey] = {};\n }\n\n const uniqueNormalizedValues = new Set<string>();\n data.forEach((row) => {\n const value = row[columnKey];\n const normalizedKey = normalizeValue(value);\n\n if (normalizedKey) {\n uniqueNormalizedValues.add(normalizedKey);\n }\n });\n\n const sortedUniqueValues = Array.from(uniqueNormalizedValues).sort();\n\n sortedUniqueValues.forEach((normalizedKey, index) => {\n if (!newColorMap[columnKey][normalizedKey]) {\n const colorIndex = index % RANDOM_CHIP_COLOR_PALETTE.length;\n newColorMap[columnKey][normalizedKey] = RANDOM_CHIP_COLOR_PALETTE[colorIndex];\n }\n });\n }\n });\n\n return newColorMap;\n }, [data, columnWithChipClass]);\n\n useEffect(() => {\n const uniqueValuesHash = getUniqueValuesHash(data, columnWithChipClass);\n \n // Only update if the set of unique values actually changed\n if (uniqueValuesHash !== prevDataHashRef.current) {\n prevDataHashRef.current = uniqueValuesHash;\n \n setChipColorMap((prevMap) => {\n const merged = { ...prevMap };\n Object.keys(computedColorMap).forEach((columnKey) => {\n merged[columnKey] = { ...computedColorMap[columnKey], ...merged[columnKey] };\n });\n return merged;\n });\n }\n }, [computedColorMap, data, columnWithChipClass]);\n\n useEffect(() => {\n setChipColorMap((prevMap) => {\n const cleaned = { ...prevMap };\n let hasChanges = false;\n\n Object.keys(cleaned).forEach((columnKey) => {\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n if (!chipMode) {\n delete cleaned[columnKey];\n hasChanges = true;\n }\n });\n \n return hasChanges ? cleaned : prevMap;\n });\n }, [columnWithChipClass]);\n \n const originalKeys = Object.keys(data[0] || {}).filter((key) => key in headerMapper);\n const headers = originalKeys.map((key) => headerMapper[key]);\n\n if (actions.length > 0) {\n headers.push('');\n }\n\n const rows = data.map((datum: any) => originalKeys.map((key) => datum[key]));\n\n async function handlePageChange(newPage = pageNumber, newSize = pageSize) {\n setPageNumber(newPage);\n setPageSize(newSize);\n onPageChange?.(newPage, newSize);\n }\n\n function handleSortClick(column: string, direction: SortDirection) {\n setActiveSortColumn(direction ? column : null);\n setSortDirections((prev) => ({\n ...prev,\n [column]: direction,\n }));\n onSort?.(column, direction);\n }\n\n function renderActions(rowIndex: number, rowActions: RowAction[]) {\n if (!actions.length) {\n return null;\n }\n\n return (\n <TableCell className=\"sticky right-0 bg-white\">\n {rowActions.map((action) => (\n <TableButton\n key={action.id}\n className={action.className}\n isEditable={isEditable}\n onClick={() => onRowAction?.(rowIndex, action.id)}\n variant={action.variant}\n text={action.text}\n tooltipContent={action.tooltipContent}\n disabled={isLoading}\n />\n ))}\n </TableCell>\n );\n }\n\n const defaultClasses = `aspect-auto w-full`;\n const mergedClasses = className ? cn(defaultClasses, className) : defaultClasses;\n\n function getRandomColorForValue(columnKey: string, value: any): string {\n const normalizedKey = normalizeValue(value);\n\n if (chipColorMap[columnKey]?.[normalizedKey]) {\n return chipColorMap[columnKey][normalizedKey];\n }\n \n return 'bg-gray-50 text-gray-900 shadow-sm';\n }\n\n function renderChip(columnKey: string, value: any) {\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n const formattedValue = formatValue(value, decimalPrecision);\n \n if (!chipMode) {\n return <>{formattedValue}</>;\n }\n\n let chipClassName = '';\n \n if (chipMode === 'useMap') {\n const valueStr = String(value);\n chipClassName = chipStylesMapping[columnKey]?.[valueStr];\n \n if (!chipClassName) {\n const valueLower = valueStr.toLowerCase().trim();\n chipClassName = SEMANTIC_CHIP_STYLES_MAP[valueLower];\n }\n\n if (!chipClassName) {\n chipClassName = 'bg-gray-50 text-gray-900 shadow-sm';\n }\n } else if (chipMode === 'useRandom') {\n chipClassName = getRandomColorForValue(columnKey, value);\n }\n\n return (\n <span\n className={cn(\n 'inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-gray-500/10',\n chipClassName\n )}\n >\n {formattedValue}\n </span>\n );\n }\n\n function renderTableComponent() {\n if (isLoading || (!data || data.length === 0)) {\n return <TableLoader />;\n }\n\n return (\n <Table\n {...otherProps}\n className={`caption-bottom text-sm relative ${mergedClasses}`}\n data-slot=\"table\"\n >\n <TableHeader data-slot=\"table-header\" className=\"sticky top-0 z-2\">\n <TableRow>\n {headers.map((head: string, idx: number) => {\n const isActionColumn = actions.length > 0 && idx === headers.length - 1;\n const originalKey = originalKeys[idx];\n\n if (isActionColumn) {\n return (\n <TableHead\n key={idx}\n data-slot={`table-header-${idx}`}\n contentEditable={isEditable}\n className=\"sticky right-0 bg-slate-100\"\n >\n {head}\n </TableHead>\n );\n }\n\n return (\n <TableHeadSortable\n key={idx}\n data-slot={`table-header-${idx}`}\n sortDirection={sortDirections[originalKey] || 'asc'}\n isActive={activeSortColumn === originalKey}\n onSort={(direction) => handleSortClick(originalKey, direction)}\n sortable={!isLoading}\n isEditable={isEditable}\n >\n {head}\n </TableHeadSortable>\n );\n })}\n </TableRow>\n </TableHeader>\n <TableBody data-slot=\"table-body\">\n {rows.map((row: any[], rIdx: number) => (\n <TableRow\n key={rIdx}\n data-slot={`row-${rIdx}`}\n className=\"hover:bg-muted/50 border-b transition-colors\"\n >\n {row.map((cell: string, cIdx: number) => {\n const columnKey = originalKeys[cIdx];\n const chipMode = columnKey ? getChipMode(columnWithChipClass, columnKey) : undefined;\n const shouldRenderChip = !!chipMode;\n \n return (\n <TableCell\n key={cIdx}\n data-slot={`cell-${rIdx}-${cIdx}`}\n className=\"p-2 align-middle whitespace-nowrap\"\n contentEditable={false}\n >\n {shouldRenderChip ? renderChip(columnKey, cell) : formatValue(cell, decimalPrecision)}\n </TableCell>\n );\n })}\n {renderActions(rIdx, actions)}\n </TableRow>\n ))}\n </TableBody>\n </Table>\n );\n }\n\n return (\n <Fragment>\n <div className=\"flex flex-col h-full overflow-hidden\">\n <ScrollArea\n data-slot=\"table-container\"\n className={mergedClasses}\n {...(height !== undefined && { style: { height } })}\n >\n {renderTableComponent()}\n <ScrollBar orientation=\"horizontal\" />\n </ScrollArea>\n </div>\n {pagination && pagination.totalCount > 0 && (\n <div className=\"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2\">\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n <label htmlFor=\"page-size-select\" className=\"text-sm whitespace-nowrap\">\n Rows per page:\n </label>\n <select\n id=\"page-size-select\"\n value={pageSize}\n onChange={(e) => handlePageChange(1, Number(e.target.value))}\n className=\"border rounded px-2 py-1 text-sm cursor-pointer\"\n disabled={isLoading}\n >\n {pagination.pageSizeOptions.map((size: number) => (\n <option key={size} value={size}>\n {size}\n </option>\n ))}\n </select>\n </div>\n <div className=\"flex items-center gap-1 flex-shrink-0\">\n <span className=\"text-xs text-muted-foreground whitespace-nowrap ml-1.5\">\n {(pageNumber - 1) * pageSize + 1}–\n {Math.min(pageNumber * pageSize, pagination.totalCount)} of {pagination.totalCount}\n </span>\n <Pagination>\n <PaginationContent className=\"gap-0.2 flex-shrink-0\">\n {renderPaginationArrows(pageNumber, totalPages, isLoading, handlePageChange)}\n </PaginationContent>\n </Pagination>\n </div>\n </div>\n )}\n </Fragment>\n );\n}\n"],"mappings":"wLAAA,uDACA,OAASA,SAAS,CAAEC,QAAQ,CAAEC,QAAQ,CAAEC,OAAO,CAAEC,MAAM,KAAQ,OAAO,CACtE,OACEC,KAAK,CACLC,WAAW,CACXC,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js","names":["useEffect","useState","Fragment","useMemo","useRef","Table","TableHeader","TableRow","TableHead","TableBody","TableCell","TableHeadSortable","TableLoader","ScrollArea","ScrollBar","Pagination","PaginationContent","renderPaginationArrows","TableButton","cn","renderNoDataFallback","formatValue","SEMANTIC_CHIP_STYLES_MAP","RANDOM_CHIP_COLOR_PALETTE","useButtonForm","jsx","_jsx","_Fragment","jsxs","_jsxs","normalizeValue","value","undefined","str","String","trim","toLowerCase","getChipMode","columnWithChipClass","columnKey","mode","getUniqueValuesHash","data","Array","isArray","length","availableKeys","Object","keys","hashParts","forEach","includes","chipMode","uniqueNormalizedValues","Set","row","normalizedKey","add","sortedUniqueValues","from","sort","JSON","stringify","DataTable","_ref","_ref2","_pagination$values$pa","_pagination$values","_ref3","_pagination$values$pa2","_pagination$values2","_ref$data","_ref$headerMapper","headerMapper","_ref$className","className","_ref$actions","actions","_ref$isEditable","isEditable","pagination","_ref$isLoading","isLoading","onRowAction","onPageChange","onSort","sortConfig","_ref$otherProps","otherProps","height","_ref$decimalPrecision","decimalPrecision","_ref$columnWithChipCl","_ref$chipStylesMappin","chipStylesMapping","children","style","minHeight","_useState","activeSortColumn","setActiveSortColumn","_useState2","sortDirections","setSortDirections","_useState3","activeRowIndex","setActiveRowIndex","_useState4","activeAction","setActiveAction","_useState5","isFormSubmitting","setIsFormSubmitting","_useState6","Number","values","pageNumber","initialPage","setPageNumber","_useState7","pageSize","initialPageSize","setPageSize","_useState8","Math","ceil","totalCount","totalPages","setTotalPages","_useState9","chipColorMap","setChipColorMap","prevDataHashRef","_ref4","_pagination$values$pa3","_pagination$values3","_ref5","_pagination$values$pa4","_pagination$values4","first","sortColumn","sortDirection","computedColorMap","newColorMap","index","colorIndex","uniqueValuesHash","current","prevMap","merged","_extends","cleaned","hasChanges","_useButtonForm","formMapper","action","formTitle","formDescription","formButtonText","isSubmitting","onClose","onSubmit","_onSubmit","_asyncToGenerator","_regeneratorRuntime","mark","_callee","formData","wrap","_callee$","_context","prev","next","id","finish","stop","_x","apply","arguments","FormDialog","openForm","handleButtonClick","rowIndex","originalKeys","filter","key","headers","map","push","rows","datum","handlePageChange","_x2","_x3","_handlePageChange","_callee2","newPage","newSize","_callee2$","_context2","handleSortClick","column","direction","_extends2","renderActions","rowActions","onClick","variant","text","tooltipContent","disabled","defaultClasses","mergedClasses","getRandomColorForValue","_chipColorMap$columnK","renderChip","formattedValue","chipClassName","_chipStylesMapping$co","valueStr","valueLower","renderTableComponent","head","idx","isActionColumn","originalKey","contentEditable","isActive","sortable","rIdx","cell","cIdx","shouldRenderChip","orientation","htmlFor","onChange","e","target","pageSizeOptions","size","min"],"sources":["../../../src/plugins/helpers/data-table.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useEffect, useState, Fragment, useMemo, useRef } 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';\nimport { formatValue } from '../../helpers';\nimport { SEMANTIC_CHIP_STYLES_MAP, RANDOM_CHIP_COLOR_PALETTE } from '../../constants';\nimport { useButtonForm } from './button-form';\n\ntype RowAction = {\n id: string;\n text: string;\n variant?: string;\n tooltipContent?: string;\n className?: string;\n action: any;\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, formData?: Record<string, any>) => void;\n onPageChange?: (pageNumber: number, pageSize: number) => void;\n onSort?: (column: string, direction: SortDirection) => void;\n sortConfig?: Record<string, SortDirection>;\n otherProps?: Record<string, any>;\n height?: string | number;\n decimalPrecision?: number;\n columnWithChipClass?: Record<string, 'useMap' | 'useRandom'>;\n chipStylesMapping?: Record<string, Record<string, string>>;\n};\n\n/**\n * Normalizes a value to a consistent string key for color mapping.\n * Handles all value types: null/undefined, numbers, booleans, objects, arrays, dates.\n * Ensures consistent color assignment for all variations of the same logical value.\n */\nfunction normalizeValue(value: any): string {\n // Handle null/undefined\n if (value === null || value === undefined) {\n return '';\n }\n\n const str = String(value);\n \n return str.trim().toLowerCase();\n}\n\nfunction getChipMode(\n columnWithChipClass: Record<string, 'useMap' | 'useRandom'>,\n columnKey: string\n): 'useMap' | 'useRandom' | undefined {\n if (!(columnKey in columnWithChipClass)) {\n return undefined;\n }\n \n const mode = columnWithChipClass[columnKey];\n\n if (mode !== 'useMap' && mode !== 'useRandom') {\n return 'useRandom';\n }\n \n return mode;\n}\n\n/**\n * Generates a stable hash based on unique value sets per column.\n * This hash is order-independent - it only changes when the set of unique values changes,\n * not when rows are reordered (e.g., during sorting).\n */\nfunction getUniqueValuesHash(\n data: Record<string, any>[],\n columnWithChipClass: Record<string, 'useMap' | 'useRandom'>\n): string {\n if (!Array.isArray(data) || data.length === 0) {\n return '';\n }\n\n const availableKeys = Object.keys(data[0] || {});\n const hashParts: Record<string, string[]> = {};\n\n Object.keys(columnWithChipClass).forEach((columnKey) => {\n if (!availableKeys.includes(columnKey)) {\n return;\n }\n\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n if (chipMode === 'useRandom') {\n const uniqueNormalizedValues = new Set<string>();\n data.forEach((row) => {\n const value = row[columnKey];\n const normalizedKey = normalizeValue(value);\n\n if (normalizedKey) {\n uniqueNormalizedValues.add(normalizedKey);\n }\n });\n const sortedUniqueValues = Array.from(uniqueNormalizedValues).sort();\n hashParts[columnKey] = sortedUniqueValues;\n }\n });\n\n return JSON.stringify(hashParts);\n}\n\nexport function DataTable({\n data = [],\n headerMapper = {},\n className = '',\n actions = [],\n isEditable = false,\n pagination,\n isLoading = false,\n onRowAction,\n onPageChange,\n onSort,\n sortConfig,\n otherProps = {},\n height,\n decimalPrecision = 2,\n columnWithChipClass = {},\n chipStylesMapping = {},\n}: DataTableProps) {\n\n if (!data || data.length === 0) {\n return (\n <Fragment>\n <div className=\"flex flex-col overflow-hidden\">\n <div\n data-slot=\"table-container\"\n className=\"aspect-auto w-full\"\n style={{ height: 'auto', minHeight: '180px' }}\n >\n {isLoading ? <TableLoader /> : renderNoDataFallback()}\n </div>\n </div>\n </Fragment>\n );\n }\n\n const [activeSortColumn, setActiveSortColumn] = useState<string | null>(null);\n const [sortDirections, setSortDirections] = useState<Record<string, SortDirection>>({});\n const [activeRowIndex, setActiveRowIndex] = useState<number | null>(null);\n const [activeAction, setActiveAction] = useState<RowAction | null>(null);\n const [isFormSubmitting, setIsFormSubmitting] = useState(false);\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 const [chipColorMap, setChipColorMap] = useState<Record<string, Record<string, string>>>({});\n\n const prevDataHashRef = useRef<string>('');\n\n useEffect(() => {\n setPageNumber(Number(pagination?.values?.pageNumber ?? pagination?.initialPage ?? 1));\n setPageSize(Number(pagination?.values?.pageSize ?? pagination?.initialPageSize ?? 25));\n }, [pagination]);\n\n useEffect(() => {\n setTotalPages(Math.ceil((pagination?.totalCount || 0) / pageSize) || 1);\n }, [pagination?.totalCount, pageSize]);\n\n useEffect(() => {\n if (sortConfig) {\n setSortDirections(sortConfig);\n const first = Object.keys(sortConfig)[0];\n\n if (first) {\n setActiveSortColumn(first);\n }\n }\n }, [sortConfig]);\n\n useEffect(() => {\n if (sortConfig?.sortColumn || sortConfig?.sortDirection) {\n sortConfig.sortColumn = null;\n sortConfig.sortDirection = null;\n }\n \n setActiveSortColumn(null);\n setSortDirections({});\n }, []);\n\n const computedColorMap = useMemo(() => {\n if (!Array.isArray(data) || data.length === 0) {\n return {};\n }\n\n // Get available column keys from first row\n const availableKeys = Object.keys(data[0] || {});\n \n const newColorMap: Record<string, Record<string, string>> = {};\n\n // Process each column that uses random chips\n Object.keys(columnWithChipClass).forEach((columnKey) => {\n // Validate column key exists in data\n if (!availableKeys.includes(columnKey)) {\n return;\n }\n\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n if (chipMode === 'useRandom') {\n if (!newColorMap[columnKey]) {\n newColorMap[columnKey] = {};\n }\n\n const uniqueNormalizedValues = new Set<string>();\n data.forEach((row) => {\n const value = row[columnKey];\n const normalizedKey = normalizeValue(value);\n\n if (normalizedKey) {\n uniqueNormalizedValues.add(normalizedKey);\n }\n });\n\n const sortedUniqueValues = Array.from(uniqueNormalizedValues).sort();\n\n sortedUniqueValues.forEach((normalizedKey, index) => {\n if (!newColorMap[columnKey][normalizedKey]) {\n const colorIndex = index % RANDOM_CHIP_COLOR_PALETTE.length;\n newColorMap[columnKey][normalizedKey] = RANDOM_CHIP_COLOR_PALETTE[colorIndex];\n }\n });\n }\n });\n\n return newColorMap;\n }, [data, columnWithChipClass]);\n\n useEffect(() => {\n const uniqueValuesHash = getUniqueValuesHash(data, columnWithChipClass);\n \n // Only update if the set of unique values actually changed\n if (uniqueValuesHash !== prevDataHashRef.current) {\n prevDataHashRef.current = uniqueValuesHash;\n \n setChipColorMap((prevMap) => {\n const merged = { ...prevMap };\n Object.keys(computedColorMap).forEach((columnKey) => {\n merged[columnKey] = { ...computedColorMap[columnKey], ...merged[columnKey] };\n });\n return merged;\n });\n }\n }, [computedColorMap, data, columnWithChipClass]);\n\n useEffect(() => {\n setChipColorMap((prevMap) => {\n const cleaned = { ...prevMap };\n let hasChanges = false;\n\n Object.keys(cleaned).forEach((columnKey) => {\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n if (!chipMode) {\n delete cleaned[columnKey];\n hasChanges = true;\n }\n });\n \n return hasChanges ? cleaned : prevMap;\n });\n }, [columnWithChipClass]);\n\n const { FormDialog, openForm } = useButtonForm({\n formMapper: activeAction?.action.formMapper,\n formTitle: activeAction?.action.formTitle,\n formDescription: activeAction?.action.formDescription,\n formButtonText: activeAction?.action.formButtonText,\n isSubmitting: isFormSubmitting || isLoading,\n onClose: () => {\n setActiveRowIndex(null);\n setActiveAction(null);\n },\n onSubmit: async (formData) => {\n if (activeRowIndex !== null && activeAction) {\n setIsFormSubmitting(true);\n try {\n await onRowAction?.(activeRowIndex, activeAction.id, formData);\n } finally {\n setIsFormSubmitting(false);\n }\n\n setActiveAction(null);\n setActiveRowIndex(null);\n }\n },\n });\n\n function handleButtonClick(rowIndex: number, action: RowAction) {\n if (action.action.formMapper && Object.keys(action.action.formMapper).length > 0) {\n setActiveRowIndex(rowIndex);\n setActiveAction(action);\n } else {\n onRowAction?.(rowIndex, action.id);\n }\n}\n\n useEffect(() => {\n if (activeAction?.action.formMapper && Object.keys(activeAction.action.formMapper).length > 0) {\n openForm();\n }\n }, [activeAction]); \n\n\n const originalKeys = Object.keys(data[0] || {}).filter((key) => key in headerMapper);\n const headers = originalKeys.map((key) => headerMapper[key]);\n\n if (actions.length > 0) {\n headers.push('');\n }\n\n const rows = data.map((datum: any) => originalKeys.map((key) => datum[key]));\n\n async function handlePageChange(newPage = pageNumber, newSize = pageSize) {\n setPageNumber(newPage);\n setPageSize(newSize);\n onPageChange?.(newPage, newSize);\n }\n\n function handleSortClick(column: string, direction: SortDirection) {\n setActiveSortColumn(direction ? column : null);\n setSortDirections((prev) => ({\n ...prev,\n [column]: direction,\n }));\n onSort?.(column, direction);\n }\n\n function renderActions(rowIndex: number, rowActions: RowAction[]) {\n if (!actions.length) {\n return null;\n }\n\n return (\n <TableCell className=\"sticky right-0 bg-white\">\n {rowActions.map((action) => (\n <TableButton\n key={action.id}\n className={action.className}\n isEditable={isEditable}\n onClick={() => handleButtonClick(rowIndex, action)}\n variant={action.variant}\n text={action.text}\n tooltipContent={action.tooltipContent}\n disabled={isLoading}\n />\n ))}\n </TableCell>\n );\n }\n\n const defaultClasses = `aspect-auto w-full`;\n const mergedClasses = className ? cn(defaultClasses, className) : defaultClasses;\n\n function getRandomColorForValue(columnKey: string, value: any): string {\n const normalizedKey = normalizeValue(value);\n\n if (chipColorMap[columnKey]?.[normalizedKey]) {\n return chipColorMap[columnKey][normalizedKey];\n }\n \n return 'bg-gray-50 text-gray-900 shadow-sm';\n }\n\n function renderChip(columnKey: string, value: any) {\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n const formattedValue = formatValue(value, decimalPrecision);\n \n if (!chipMode) {\n return <>{formattedValue}</>;\n }\n\n let chipClassName = '';\n \n if (chipMode === 'useMap') {\n const valueStr = String(value);\n chipClassName = chipStylesMapping[columnKey]?.[valueStr];\n \n if (!chipClassName) {\n const valueLower = valueStr.toLowerCase().trim();\n chipClassName = SEMANTIC_CHIP_STYLES_MAP[valueLower];\n }\n\n if (!chipClassName) {\n chipClassName = 'bg-gray-50 text-gray-900 shadow-sm';\n }\n } else if (chipMode === 'useRandom') {\n chipClassName = getRandomColorForValue(columnKey, value);\n }\n\n return (\n <span\n className={cn(\n 'inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-gray-500/10',\n chipClassName\n )}\n >\n {formattedValue}\n </span>\n );\n }\n\n function renderTableComponent() {\n if (isLoading || (!data || data.length === 0)) {\n return <TableLoader />;\n }\n\n return (\n <Table\n {...otherProps}\n className={`caption-bottom text-sm relative ${mergedClasses}`}\n data-slot=\"table\"\n >\n <TableHeader data-slot=\"table-header\" className=\"sticky top-0 z-2\">\n <TableRow>\n {headers.map((head: string, idx: number) => {\n const isActionColumn = actions.length > 0 && idx === headers.length - 1;\n const originalKey = originalKeys[idx];\n\n if (isActionColumn) {\n return (\n <TableHead\n key={idx}\n data-slot={`table-header-${idx}`}\n contentEditable={isEditable}\n className=\"sticky right-0 bg-slate-100\"\n >\n {head}\n </TableHead>\n );\n }\n\n return (\n <TableHeadSortable\n key={idx}\n data-slot={`table-header-${idx}`}\n sortDirection={sortDirections[originalKey] || 'asc'}\n isActive={activeSortColumn === originalKey}\n onSort={(direction) => handleSortClick(originalKey, direction)}\n sortable={!isLoading}\n isEditable={isEditable}\n >\n {head}\n </TableHeadSortable>\n );\n })}\n </TableRow>\n </TableHeader>\n <TableBody data-slot=\"table-body\">\n {rows.map((row: any[], rIdx: number) => (\n <TableRow\n key={rIdx}\n data-slot={`row-${rIdx}`}\n className=\"hover:bg-muted/50 border-b transition-colors\"\n >\n {row.map((cell: string, cIdx: number) => {\n const columnKey = originalKeys[cIdx];\n const chipMode = columnKey ? getChipMode(columnWithChipClass, columnKey) : undefined;\n const shouldRenderChip = !!chipMode;\n \n return (\n <TableCell\n key={cIdx}\n data-slot={`cell-${rIdx}-${cIdx}`}\n className=\"p-2 align-middle whitespace-nowrap\"\n contentEditable={false}\n >\n {shouldRenderChip ? renderChip(columnKey, cell) : formatValue(cell, decimalPrecision)}\n </TableCell>\n );\n })}\n {renderActions(rIdx, actions)}\n </TableRow>\n ))}\n </TableBody>\n </Table>\n );\n }\n\n return (\n <Fragment>\n <div className=\"flex flex-col h-full overflow-hidden\">\n <ScrollArea\n data-slot=\"table-container\"\n className={mergedClasses}\n {...(height !== undefined && { style: { height } })}\n >\n {renderTableComponent()}\n <ScrollBar orientation=\"horizontal\" />\n </ScrollArea>\n </div>\n {pagination && pagination.totalCount > 0 && (\n <div className=\"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2\">\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n <label htmlFor=\"page-size-select\" className=\"text-sm whitespace-nowrap\">\n Rows per page:\n </label>\n <select\n id=\"page-size-select\"\n value={pageSize}\n onChange={(e) => handlePageChange(1, Number(e.target.value))}\n className=\"border rounded px-2 py-1 text-sm cursor-pointer\"\n disabled={isLoading}\n >\n {pagination.pageSizeOptions.map((size: number) => (\n <option key={size} value={size}>\n {size}\n </option>\n ))}\n </select>\n </div>\n <div className=\"flex items-center gap-1 flex-shrink-0\">\n <span className=\"text-xs text-muted-foreground whitespace-nowrap ml-1.5\">\n {(pageNumber - 1) * pageSize + 1}–\n {Math.min(pageNumber * pageSize, pagination.totalCount)} of {pagination.totalCount}\n </span>\n <Pagination>\n <PaginationContent className=\"gap-0.2 flex-shrink-0\">\n {renderPaginationArrows(pageNumber, totalPages, isLoading, handlePageChange)}\n </PaginationContent>\n </Pagination>\n </div>\n </div>\n )}\n {FormDialog}\n </Fragment>\n );\n}\n"],"mappings":"wLAAA,uDACA,OAASA,SAAS,CAAEC,QAAQ,CAAEC,QAAQ,CAAEC,OAAO,CAAEC,MAAM,KAAQ,OAAO,CACtE,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,CAC9C,OAASC,WAAW,KAAQ,eAAe,CAC3C,OAASC,wBAAwB,CAAEC,yBAAyB,KAAQ,iBAAiB,CACrF,OAASC,aAAa,KAAQ,eAAe,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAxB,QAAA,IAAAyB,SAAA,CAAAC,IAAA,IAAAC,KAAA,yBAuC9C;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,cAAcA,CAACC,KAAU,CAAU,CAC1C;AACA,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lE,KAAA,SAAM8C,SAAS,CAAC,wDAAwD,CAAAoB,QAAA,EACrE,CAACqB,UAAU,CAAG,CAAC,EAAII,QAAQ,CAAG,CAAC,CAAC,QACjC,CAACI,IAAI,CAACoH,GAAG,CAAC5H,UAAU,CAAGI,QAAQ,CAAExC,UAAU,CAAC8C,UAAU,CAAC,CAAC,MAAI,CAAC9C,UAAU,CAAC8C,UAAU,EAC9E,CAAC,cACPpG,IAAA,CAACX,UAAU,EAAAgF,QAAA,cACTrE,IAAA,CAACV,iBAAiB,EAAC2D,SAAS,CAAC,uBAAuB,CAAAoB,QAAA,CACjD9E,sBAAsB,CAACmG,UAAU,CAAEW,UAAU,CAAE7C,SAAS,CAAE6G,gBAAgB,CAAC,CAC3D,CAAC,CACV,CAAC,EACV,CAAC,EACH,CACN,CACAZ,UAAU,EACH,CAEd","ignoreList":[]}
@@ -1,16 +1,16 @@
1
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","isTemplateView"],_excluded2=["gjsModel","performInteraction","isTemplateView"],_excluded3=["gjsModel","performInteraction","isTemplateView"],_excluded4=["gjsModel","performInteraction","isTemplateView"],_excluded5=["gjsModel","isTemplateView"];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,useMemo,useCallback,useRef}from"react";import{renderNoDataFallback}from"./extra";import{CircleAlert,TrendingDown,TrendingUp,ShoppingCart,ChartBarBig,Tag,MapPin}from"lucide-react";import{StyledInfoButton}from"./styled-info-button";import{filterPlaceholders}from"../../helpers/filter-placeholder";import{theme}from"@peak-ai/ais-components/theme";import Markdown from"markdown-to-jsx";import{Bar,BarChart,CartesianGrid,Legend,Line,LineChart,Pie,PieChart,Scatter,ScatterChart,XAxis,YAxis,Cell}from"recharts/lib";// @ts-ignore
2
- import*as domutil from"recharts/lib/util/DOMUtils";import{Group}from"@visx/group";import{scaleBand,scaleLinear}from"@visx/scale";import{AxisBottom,AxisLeft}from"@visx/axis";import{GridRows}from"@visx/grid";import{Circle}from"@visx/shape";import{useTooltip,TooltipWithBounds,defaultStyles}from"@visx/tooltip";import{forceSimulation,forceX,forceY,forceCollide}from"d3-force";import{TooltipButton}from"../../shadcn/components/ui/button";import{Card,CardContent,CardDescription,CardFooter,CardHeader,CardTitle}from"../../shadcn/components/ui/card";import{ChartContainer,ChartTooltip,ChartTooltipContent}from"../../shadcn/components/ui/chart";import{renderFilter}from"../../shadcn/components/ui/filter";import{renderUnifiedFilter}from"../../shadcn/components/ui/unified-filter";import{renderSearch}from"../../shadcn/components/ui/search";import{CardLoader,ChartLoader,MarkdownLoader}from"../../shadcn/components/ui/skeleton";import{Tabs,TabsContent,TabsList,TabsTrigger}from"../../shadcn/components/ui/tabs";import{cn}from"../../shadcn/utils";import{getAffectedComponentsWithLoader,formatValue}from"../../helpers";import{DataTable}from"./data-table";import{ComponentWrapper}from"../../shadcn/components/ui/error-wrapper";// Monkey-patching the getOffset function to use iframe's window instead of global one
2
+ import*as domutil from"recharts/lib/util/DOMUtils";import{Group}from"@visx/group";import{scaleBand,scaleLinear}from"@visx/scale";import{AxisBottom,AxisLeft}from"@visx/axis";import{GridRows}from"@visx/grid";import{Circle}from"@visx/shape";import{useTooltip,TooltipWithBounds,defaultStyles}from"@visx/tooltip";import{forceSimulation,forceX,forceY,forceCollide}from"d3-force";import{TooltipButton}from"../../shadcn/components/ui/button";import{Card,CardContent,CardDescription,CardFooter,CardHeader,CardTitle}from"../../shadcn/components/ui/card";import{ChartContainer,ChartTooltip,ChartTooltipContent}from"../../shadcn/components/ui/chart";import{renderFilter}from"../../shadcn/components/ui/filter";import{renderUnifiedFilter}from"../../shadcn/components/ui/unified-filter";import{renderSearch}from"../../shadcn/components/ui/search";import{CardLoader,ChartLoader,MarkdownLoader}from"../../shadcn/components/ui/skeleton";import{Tabs,TabsContent,TabsList,TabsTrigger}from"../../shadcn/components/ui/tabs";import{cn}from"../../shadcn/utils";import{getAffectedComponentsWithLoader,formatValue}from"../../helpers";import{DataTable}from"./data-table";import{ComponentWrapper}from"../../shadcn/components/ui/error-wrapper";import{useButtonForm}from"./button-form";// Monkey-patching the getOffset function to use iframe's window instead of global one
3
3
  // REMEMBER TO UDPATE THIS WHEN recharts IS UPGRADED
4
4
  // @ts-ignore
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 BEESWARM_CONFIG={RADIUS:4,SPREAD_FACTOR:0.45,RANDOM_FACTOR:2,SIMULATION_ITERATIONS:300,COLLISION_PADDING:3};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"]];var iconMap={TrendingUp:/*#__PURE__*/_jsx(TrendingUp,{}),TrendingDown:/*#__PURE__*/_jsx(TrendingDown,{}),ShoppingCart:/*#__PURE__*/_jsx(ShoppingCart,{}),Equalizer:/*#__PURE__*/_jsx(ChartBarBig,{}),Style:/*#__PURE__*/_jsx(Tag,{}),Place:/*#__PURE__*/_jsx(MapPin,{})};function getIconFromString(iconString){if(!iconString){return null}if(iconMap[iconString]){return iconMap[iconString]}var lowerIconString=iconString.toLowerCase();var matchingKey=Object.keys(iconMap).find(function(key){return key.toLowerCase()===lowerIconString});if(matchingKey){return iconMap[matchingKey]}return null}function getNColors(n){var colors=[];var safeBaseColors=Array.isArray(baseColors)?baseColors:[];for(var _iterator=_createForOfIteratorHelperLoose(safeBaseColors),_step;!(_step=_iterator()).done;){var baseColor=_step.value;// eslint-disable-next-line import/no-named-as-default-member
5
+ import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}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 BEESWARM_CONFIG={RADIUS:4,SPREAD_FACTOR:0.45,RANDOM_FACTOR:2,SIMULATION_ITERATIONS:300,COLLISION_PADDING:3};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"]];var iconMap={TrendingUp:/*#__PURE__*/_jsx(TrendingUp,{}),TrendingDown:/*#__PURE__*/_jsx(TrendingDown,{}),ShoppingCart:/*#__PURE__*/_jsx(ShoppingCart,{}),Equalizer:/*#__PURE__*/_jsx(ChartBarBig,{}),Style:/*#__PURE__*/_jsx(Tag,{}),Place:/*#__PURE__*/_jsx(MapPin,{})};function getIconFromString(iconString){if(!iconString){return null}if(iconMap[iconString]){return iconMap[iconString]}var lowerIconString=iconString.toLowerCase();var matchingKey=Object.keys(iconMap).find(function(key){return key.toLowerCase()===lowerIconString});if(matchingKey){return iconMap[matchingKey]}return null}function getNColors(n){var colors=[];var safeBaseColors=Array.isArray(baseColors)?baseColors:[];for(var _iterator=_createForOfIteratorHelperLoose(safeBaseColors),_step;!(_step=_iterator()).done;){var baseColor=_step.value;// eslint-disable-next-line import/no-named-as-default-member
6
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,_props$isTemplateView=props.isTemplateView,isTemplateView=_props$isTemplateView===void 0?false:_props$isTemplateView,rest=_objectWithoutPropertiesLoose(props,_excluded);// Memoize filtered props to avoid re-filtering on every render
7
7
  var initialData=useMemo(function(){return filterPlaceholders(props)},[]);var _useState=useState(initialData),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,sampleData=allData.sampleData;var effectiveBodyContent=isTemplateView&&sampleData!==undefined?sampleData:bodyContent;var _useState2=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState2[0],setAttributes=_useState2[1];useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var defaultClasses="text-black p-4 rounded-lg shadow border flex flex-col h-full";return/*#__PURE__*/_jsx(Card,_extends({className:defaultClasses+" relative",style:{backgroundColor:"#f9f9fe"},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 flex-col",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center justify-between w-full",children:[/*#__PURE__*/_jsx("div",{className:"text-xl font-semibold",children:headerContent}),/*#__PURE__*/_jsx("div",{className:"text-5xl ml-2 flex items-center","aria-hidden":"true",children:getIconFromString(icon)})]}),/*#__PURE__*/_jsx("div",{className:"w-full mt-1",children:attributes.error||allData.error||attributes.isMissing||allData.isMissing||!effectiveBodyContent?/*#__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",children:effectiveBodyContent})})]})})})}))}export function renderCard(props){var _attributes$isEditabl,_attributes$error,_attributes$isMissing;var gjsModel=props.gjsModel,_props$performInterac=props.performInteraction,performInteraction=_props$performInterac===void 0?function(){return Promise.resolve({})}:_props$performInterac,_props$isTemplateView2=props.isTemplateView,isTemplateView=_props$isTemplateView2===void 0?false:_props$isTemplateView2,rest=_objectWithoutPropertiesLoose(props,_excluded2);// Memoize filtered props to avoid re-filtering on every render
8
8
  var initialData=useMemo(function(){return filterPlaceholders(props)},[]);var _useState3=useState(initialData),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,dataClassName=allData.className,dataError=allData.error,dataIsMissing=allData.isMissing,sampleData=allData.sampleData;function toSafeText(value){if(value===null||value===undefined){return""}return typeof value==="string"?value:JSON.stringify(value)}var safeHeaderContent=toSafeText(headerContent);var safeHeaderDescription=toSafeText(headerDescription);var effectiveBodyContent=isTemplateView&&sampleData!==undefined?sampleData.bodyContent:bodyContent;var safeBodyContent=toSafeText(effectiveBodyContent);var effectiveFooterContent=isTemplateView&&sampleData!==undefined?sampleData.footerContent:footerContent;var safeFooterContent=toSafeText(effectiveFooterContent);var safeContentMetadata=toSafeText(contentMetadata);var _useState4=useState((safeFooterContent==null?void 0:safeFooterContent.length)>0),footerHasContent=_useState4[0],setFooterHasContent=_useState4[1];var _useState5=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState5[0],setAttributes=_useState5[1];var isEditable=(_attributes$isEditabl=attributes.isEditable)!=null?_attributes$isEditabl:false;useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);useEffect(function(){setFooterHasContent((safeFooterContent==null?void 0:safeFooterContent.length)>0)},[safeFooterContent]);var defaultClasses="bg-white text-black p-4 rounded-lg border flex flex-col h-full shadow-none";var defaultFooterClasses=footerHasContent?"text-sm bg-pink-50 text-pink-900 shadow-sm":"text-sm";var defaultContentMetadataClasses="text-xs";var mergedCardClassName=dataClassName?cn(defaultClasses,dataClassName):defaultClasses;var effectiveFooterClass=isTemplateView&&sampleData!==undefined?sampleData.footerClass:footerClass;var mergedFooterClassName=effectiveFooterClass?cn(defaultFooterClasses,effectiveFooterClass):defaultFooterClasses;var mergedContentMetadataClassName=contentMetadataClass?cn(defaultContentMetadataClasses,contentMetadataClass):defaultContentMetadataClasses;var hasError=Boolean((_attributes$error=attributes==null?void 0:attributes.error)!=null?_attributes$error:dataError);var hasMissing=Boolean((_attributes$isMissing=attributes==null?void 0:attributes.isMissing)!=null?_attributes$isMissing:dataIsMissing);var isLoading=Boolean(((attributes==null?void 0:attributes.interactionApiInProgress)||(attributes==null?void 0:attributes.loading))&&!hasError&&!hasMissing);var footerIconText=typeof footerIcon==="string"?footerIcon:footerIcon&&typeof footerIcon==="object"&&"icon"in footerIcon?String(footerIcon.icon):"";function getCardContent(){if(isLoading){return/*#__PURE__*/_jsx(CardContent,{children:/*#__PURE__*/_jsx(CardLoader,{})})}var showEmpty=hasError||hasMissing||!safeBodyContent;function handleFooterInput(event){var target=event.target;var content=target.textContent||"";var hasContent=content.trim().length>0;setFooterHasContent(hasContent);if(!hasContent){var currentProps=gjsModel.get("componentProps");gjsModel.set("componentProps",_extends({},currentProps,{footerContent:null,footerIcon:null,footerClass:null,isEmptied:true}))}}return/*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"headerContent",contentEditable:isEditable,className:"text-lg",children:safeHeaderContent}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"headerDescription",contentEditable:isEditable,className:"text-sm",children:safeHeaderDescription})]})})}),showEmpty?/*#__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:safeBodyContent}),safeContentMetadata&&/*#__PURE__*/_jsx("div",{className:mergedContentMetadataClassName,style:{color:"#2A44D4"},children:safeContentMetadata})]}),/*#__PURE__*/_jsxs(CardFooter,{"data-slot":"footerContent",contentEditable:isEditable,className:mergedFooterClassName,onInput:handleFooterInput,children:[(footerIconText||"").trim()?/*#__PURE__*/_jsx("span",{className:"mr-2","aria-hidden":"true",children:footerIconText}):null,safeFooterContent||""]})]})}return/*#__PURE__*/_jsxs(Card,_extends({},rest,{isEditable:false,className:mergedCardClassName+" relative",children:[getCardContent(),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}function transformDataForScatter(data,xAxis,yAxis,dataKeys){if(!data||data.length===0){return[]}var scatterData=data.filter(function(item){return item[xAxis]!==null&&item[xAxis]!==undefined&&item[yAxis]!==null&&item[yAxis]!==undefined}).map(function(item){var _result;var result=(_result={},_result[xAxis]=Number(item[xAxis]),_result[yAxis]=Number(item[yAxis]),_result);if(dataKeys&&dataKeys.length>0){dataKeys.forEach(function(_ref){var key=_ref.key;if(item[key]!==null&&item[key]!==undefined){result[key]=Number(item[key])}})}return result});return scatterData}function binDataForHistogram(data,valueKey,bins){if(bins===void 0){bins=10}if(!data||data.length===0){return[]}var values=data.map(function(item){return Number(item[valueKey])}).filter(function(val){return!isNaN(val)});if(values.length===0){return[]}var min=Math.min.apply(Math,values);var max=Math.max.apply(Math,values);var binWidth=(max-min)/bins;var binsArray=new Array(bins).fill(0);var binLabels=[];for(var i=0;i<bins;i++){var binStart=min+i*binWidth;var binEnd=binStart+binWidth;binLabels.push(binStart.toFixed(1)+"-"+binEnd.toFixed(1))}values.forEach(function(value){var binIndex=Math.floor((value-min)/binWidth);if(binIndex>=bins){binIndex=bins-1}if(binIndex<0){binIndex=0}binsArray[binIndex]+=1});return binLabels.map(function(label,index){return{bin:label,frequency:binsArray[index]}})}function transformDataForBeeswarm(data,groupBy,valueKey){if(!data||data.length===0){return{nodes:[],groups:[]}}var grouped={};data.forEach(function(item){if(item[groupBy]!==null&&item[groupBy]!==undefined&&item[valueKey]!==null&&item[valueKey]!==undefined){var group=String(item[groupBy]);var value=Number(item[valueKey]);if(!isNaN(value)){if(!grouped[group]){grouped[group]=[]}grouped[group].push(value)}}});var groups=Object.keys(grouped).sort();var nodes=[];groups.forEach(function(group,groupIndex){var values=grouped[group];values.forEach(function(value){nodes.push({group:group,groupIndex:groupIndex,value:value,x:groupIndex,y:value,radius:4})})});return{nodes:nodes,groups:groups}}function BeeswarmChart(_ref2){var data=_ref2.data,groups=_ref2.groups,color=_ref2.color,groupBy=_ref2.groupBy,valueKey=_ref2.valueKey,_ref2$decimalPrecisio=_ref2.decimalPrecision,decimalPrecision=_ref2$decimalPrecisio===void 0?2:_ref2$decimalPrecisio;var containerRef=useRef(null);var svgRef=useRef(null);var _useState6=useState({width:800,height:250}),dimensions=_useState6[0],setDimensions=_useState6[1];var _useState7=useState([]),simulatedNodes=_useState7[0],setSimulatedNodes=_useState7[1];var _useTooltip=useTooltip(),tooltipData=_useTooltip.tooltipData,tooltipLeft=_useTooltip.tooltipLeft,tooltipTop=_useTooltip.tooltipTop,tooltipOpen=_useTooltip.tooltipOpen,showTooltip=_useTooltip.showTooltip,hideTooltip=_useTooltip.hideTooltip;useEffect(function(){var updateDimensions=function updateDimensions(){if(containerRef.current){setDimensions({width:containerRef.current.offsetWidth||800,height:250})}};updateDimensions();var resizeObserver=new ResizeObserver(function(entries){for(var _iterator2=_createForOfIteratorHelperLoose(entries),_step2;!(_step2=_iterator2()).done;){var entry=_step2.value;setDimensions({width:entry.contentRect.width||800,height:250})}});if(containerRef.current){resizeObserver.observe(containerRef.current)}window.addEventListener("resize",updateDimensions);return function(){resizeObserver.disconnect();window.removeEventListener("resize",updateDimensions)}},[]);var createXScale=useCallback(function(innerWidth,groupDomain){var minBandwidth=60;var totalMinWidth=groupDomain.length*minBandwidth;var paddingRatio=0.3;var xScale=scaleBand({domain:groupDomain,range:[0,innerWidth],padding:paddingRatio});if(totalMinWidth>innerWidth){xScale=scaleBand({domain:groupDomain,range:[0,groupDomain.length*minBandwidth],padding:paddingRatio})}else{xScale=scaleBand({domain:groupDomain,range:[0,innerWidth],padding:paddingRatio});var currentBandwidth=xScale.bandwidth();if(currentBandwidth<minBandwidth){xScale=scaleBand({domain:groupDomain,range:[0,groupDomain.length*minBandwidth],padding:paddingRatio})}}return xScale},[]);var scales=useMemo(function(){if(data.length===0||dimensions.width===0){return null}var margin={top:20,right:20,bottom:60,left:60};var innerWidth=dimensions.width-margin.left-margin.right;var innerHeight=dimensions.height-margin.top-margin.bottom;var values=data.map(function(d){return d.value});var minValue=Math.min.apply(Math,values);var maxValue=Math.max.apply(Math,values);var xScale=createXScale(innerWidth,groups);var yScale=scaleLinear({domain:[minValue,maxValue],range:[innerHeight,0]});return{xScale:xScale,yScale:yScale,minValue:minValue,maxValue:maxValue,innerWidth:innerWidth,innerHeight:innerHeight}},[data,groups,dimensions,createXScale]);useEffect(function(){if(!scales){return}var xScale=scales.xScale,minValue=scales.minValue,maxValue=scales.maxValue,innerWidth=scales.innerWidth,innerHeight=scales.innerHeight;var valueRange=maxValue-minValue;var padding=valueRange*0.1;var yScaleWithPadding=scaleLinear({domain:[minValue-padding,maxValue+padding],range:[innerHeight,0]});// Use the actual chart width from xScale range, not just innerWidth
9
9
  var actualChartWidth=Math.max(innerWidth,xScale.range()[1]||0);var bounds={minY:BEESWARM_CONFIG.RADIUS,maxY:innerHeight-BEESWARM_CONFIG.RADIUS,minX:0,maxX:actualChartWidth};var nodes=data.map(function(d){var initialY=yScaleWithPadding(d.value);var clampedY=Math.max(bounds.minY,Math.min(bounds.maxY,initialY));var groupCenterX=(xScale(d.group)||0)+(xScale.bandwidth()||0)/2;var bandwidth=xScale.bandwidth()||0;var maxSpread=bandwidth*BEESWARM_CONFIG.SPREAD_FACTOR;var randomOffset=(Math.random()-0.5)*maxSpread*BEESWARM_CONFIG.RANDOM_FACTOR;return _extends({},d,{groupCenterX:groupCenterX,x:groupCenterX+randomOffset,y:clampedY,radius:BEESWARM_CONFIG.RADIUS,maxSpread:maxSpread})});var simulation=null;try{simulation=forceSimulation(nodes).force("x",forceX(function(d){return d.groupCenterX}).strength(0.15)).force("y",forceY(function(d){var targetY=yScaleWithPadding(d.value);return Math.max(bounds.minY,Math.min(bounds.maxY,targetY))}).strength(1)).force("collide",forceCollide().radius(function(d){return d.radius+BEESWARM_CONFIG.COLLISION_PADDING}).strength(0.9).iterations(3));if(simulation&&typeof simulation.stop==="function"){simulation.stop()}}catch(error){setSimulatedNodes([].concat(nodes));return}var constrainNode=function constrainNode(node,isFinal){if(isFinal===void 0){isFinal=false}var correctY=yScaleWithPadding(node.value);node.y=Math.max(bounds.minY,Math.min(bounds.maxY,correctY));node.vy=0;var nodeMinX=node.groupCenterX-node.maxSpread;var nodeMaxX=node.groupCenterX+node.maxSpread;var constrainedMinX=Math.max(bounds.minX,nodeMinX);var constrainedMaxX=Math.min(bounds.maxX,nodeMaxX);if(isFinal){if(node.x<constrainedMinX){node.x=constrainedMinX}else if(node.x>constrainedMaxX){node.x=constrainedMaxX}}else{var overflowMargin=node.maxSpread*0.1;if(node.x<constrainedMinX-overflowMargin){node.x=constrainedMinX-overflowMargin;node.vx*=0.7}else if(node.x>constrainedMaxX+overflowMargin){node.x=constrainedMaxX+overflowMargin;node.vx*=0.7}}};if(simulation&&typeof simulation.tick==="function"){for(var i=0;i<BEESWARM_CONFIG.SIMULATION_ITERATIONS;i++){try{simulation.tick();nodes.forEach(function(node){return constrainNode(node,false)})}catch(error){break}}}// Final constraint pass
10
10
  nodes.forEach(function(node){constrainNode(node,true);node.vx=0});setSimulatedNodes([].concat(nodes))},[scales,data]);if(simulatedNodes.length===0||dimensions.width===0||!scales){return/*#__PURE__*/_jsx("div",{ref:containerRef,style:{width:"100%",height:"250px"}})}var margin={top:20,right:20,bottom:60,left:60};var xScale=scales.xScale,yScale=scales.yScale,innerWidth=scales.innerWidth,innerHeight=scales.innerHeight;var handleMouseOver=function handleMouseOver(event,node){if(containerRef.current){var containerRect=containerRef.current.getBoundingClientRect();var x=event.clientX-containerRect.left+10;var y=event.clientY-containerRect.top-10;showTooltip({tooltipLeft:x,tooltipTop:y,tooltipData:node})}};var actualChartWidth=Math.max(innerWidth,xScale.range()[1]||0);var actualSvgWidth=actualChartWidth+margin.left+margin.right;return/*#__PURE__*/_jsxs("div",{ref:containerRef,style:{width:"100%",height:"250px",position:"relative"},children:[/*#__PURE__*/_jsx("svg",{ref:svgRef,width:Math.max(dimensions.width,actualSvgWidth),height:dimensions.height,onMouseLeave:hideTooltip,children:/*#__PURE__*/_jsxs(Group,{left:margin.left,top:margin.top,children:[/*#__PURE__*/_jsx(GridRows,{scale:yScale,width:actualChartWidth,strokeDasharray:"3,3",stroke:"#e0e0e0",strokeOpacity:0.5}),/*#__PURE__*/_jsx(AxisLeft,{scale:yScale,tickStroke:"#666",stroke:"#666",tickLabelProps:function tickLabelProps(){return{fill:"#666",fontSize:12,textAnchor:"end",dy:"0.33em"}}}),/*#__PURE__*/_jsx(AxisBottom,{top:innerHeight,scale:xScale,tickStroke:"#666",stroke:"#666",tickLabelProps:function tickLabelProps(){return{fill:"#666",fontSize:12,textAnchor:"middle"}}}),simulatedNodes.map(function(node,i){return/*#__PURE__*/_jsx(Circle,{cx:node.x||0,cy:node.y||0,r:node.radius,fill:color,opacity:0.8,stroke:color,strokeWidth:1,onMouseOver:function onMouseOver(e){return handleMouseOver(e,node)},style:{cursor:"pointer"}},i)})]})}),tooltipOpen&&tooltipData&&tooltipLeft!==null&&tooltipLeft!==undefined&&tooltipTop!==null&&tooltipTop!==undefined&&/*#__PURE__*/_jsx(TooltipWithBounds,{left:tooltipLeft,top:tooltipTop,style:_extends({},defaultStyles,{backgroundColor:"white",border:"1px solid #e0e0e0",borderRadius:"4px",padding:"8px 12px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)",fontSize:"12px",position:"absolute",zIndex:1000,pointerEvents:"none"}),children:/*#__PURE__*/_jsxs("div",{children:[/*#__PURE__*/_jsxs("div",{style:{marginBottom:"4px",fontWeight:600},children:[groupBy,": ",tooltipData.group]}),/*#__PURE__*/_jsxs("div",{children:[valueKey,": ",formatValue(tooltipData.value,decimalPrecision)]})]})})]})}function renderChartComponent(chartType,data,config,decimalPrecision){if(decimalPrecision===void 0){decimalPrecision=2}var safeData=Array.isArray(data)?data:[];if(safeData.length===0){return renderNoDataFallback()}switch(chartType){case"pie":return/*#__PURE__*/_jsxs(PieChart,{children:[safeData.length>=20&&/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{hideLabel:true,decimalPrecision:decimalPrecision})}),/*#__PURE__*/_jsx(Pie,{data:safeData,dataKey:config.dataKey,nameKey:config.nameKey,innerRadius:60,strokeWidth:10,label:safeData.length<20?function(_ref3){var name=_ref3.name,percent=_ref3.percent;return name+": "+formatValue(percent*100,decimalPrecision)+"%"}:undefined,labelLine:false})]});case"bar":{config.dataKeys=config.dataKeys||[];var barDataKeys=Array.isArray(config.dataKeys)?config.dataKeys:[];var angle=config.angle?config.angle:0;var radian=Math.abs(angle)*(Math.PI/180);var maxLabelLength=safeData.reduce(function(max,item){var label=String(item[config.xAxis]||"");return Math.max(max,Math.min(label.length,28))},0);var multiplier=Math.floor(Math.max(Math.sin(radian),0.3)*6);var axisHeight=40+maxLabelLength*multiplier;return/*#__PURE__*/_jsxs(BarChart,_extends({data:safeData},config.chartUi,barDataKeys.length>1&&{barGap:0},{children:[/*#__PURE__*/_jsx(CartesianGrid,{vertical:false}),/*#__PURE__*/_jsx(XAxis,_extends({dataKey:config.xAxis},config.angle&&{interval:0,angle:angle,height:axisHeight,textAnchor:"end"},{tickFormatter:function tickFormatter(value){return value.length>25?value.slice(0,25)+"...":value}})),/*#__PURE__*/_jsx(YAxis,{}),/*#__PURE__*/_jsx(Legend,{align:"left",wrapperStyle:{marginLeft:20}}),barDataKeys.map(function(_ref4){var key=_ref4.key,name=_ref4.name,color=_ref4.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",decimalPrecision:decimalPrecision})})]}))}case"line":{config.dataKeys=config.dataKeys||[];var safeDataKeysLine=Array.isArray(config.dataKeys)?config.dataKeys:[];return/*#__PURE__*/_jsxs(LineChart,_extends({data:safeData},config.chartUi,{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",decimalPrecision:decimalPrecision})}),safeDataKeysLine.map(function(_ref5){var key=_ref5.key,name=_ref5.name,color=_ref5.color;return/*#__PURE__*/_jsx(Line,{type:"monotone",dataKey:key,stroke:color!=null?color:"#4caf50",name:name},key)}),/*#__PURE__*/_jsx(Legend,{align:"left"})]}))}case"scatter":{config.dataKeys=config.dataKeys||[];var safeDataKeys=Array.isArray(config.dataKeys)?config.dataKeys:[];var scatterData=transformDataForScatter(safeData,config.xAxis,config.yAxis,safeDataKeys);if(scatterData.length===0){return renderNoDataFallback()}var colors=safeDataKeys.length>0?safeDataKeys.map(function(_ref6){var color=_ref6.color;return color!=null?color:"#2A44D4"}):["#2A44D4"];return/*#__PURE__*/_jsxs(ScatterChart,_extends({data:scatterData},config.chartUi,{children:[/*#__PURE__*/_jsx(CartesianGrid,{vertical:false}),/*#__PURE__*/_jsx(XAxis,{type:"number",dataKey:config.xAxis,name:config.xAxis||"X Axis",domain:["auto","auto"]}),/*#__PURE__*/_jsx(YAxis,{type:"number",dataKey:config.yAxis,name:config.yAxis||"Y Axis",domain:["auto","auto"]}),/*#__PURE__*/_jsx(ChartTooltip,{cursor:{strokeDasharray:"3 3"},content:/*#__PURE__*/_jsx(ChartTooltipContent,{decimalPrecision:decimalPrecision})}),safeDataKeys.length>0?safeDataKeys.map(function(_ref7,index){var key=_ref7.key,name=_ref7.name,color=_ref7.color;return/*#__PURE__*/_jsx(Scatter,{name:name||key,dataKey:key||config.yAxis,fill:color!=null?color:colors[index%colors.length]},key)}):/*#__PURE__*/_jsx(Scatter,{name:"Data",dataKey:config.yAxis,fill:colors[0]}),/*#__PURE__*/_jsx(Legend,{align:"left"})]}))}case"histogram":{config.dataKeys=config.dataKeys||[];var _safeDataKeys=Array.isArray(config.dataKeys)?config.dataKeys:[];var valueKey=_safeDataKeys.length>0?_safeDataKeys[0].key:config.xAxis;var bins=config.bins||10;var binnedData=binDataForHistogram(safeData,valueKey,bins);if(binnedData.length===0){return renderNoDataFallback()}var color=_safeDataKeys.length>0?_safeDataKeys[0].color:"#2A44D4";return/*#__PURE__*/_jsxs(BarChart,_extends({data:binnedData},config.chartUi,{children:[/*#__PURE__*/_jsx(CartesianGrid,{vertical:false}),/*#__PURE__*/_jsx(XAxis,{dataKey:"bin",angle:-45,textAnchor:"end",height:80}),/*#__PURE__*/_jsx(YAxis,{}),/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{indicator:"dashed",decimalPrecision:decimalPrecision})}),/*#__PURE__*/_jsx(Bar,{dataKey:"frequency",fill:color,radius:2,children:binnedData.map(function(entry,index){return/*#__PURE__*/_jsx(Cell,{fill:color},"cell-"+index)})}),/*#__PURE__*/_jsx(Legend,{align:"left"})]}))}case"beeswarm":{var _config$dataKeys$,_config$dataKeys$2;var groupBy=config.groupBy||config.xAxis;var _valueKey=config.valueKey||config.dataKeys&&((_config$dataKeys$=config.dataKeys[0])==null?void 0:_config$dataKeys$.key)||"value";var _transformDataForBees=transformDataForBeeswarm(safeData,groupBy,_valueKey),nodes=_transformDataForBees.nodes,groups=_transformDataForBees.groups;if(nodes.length===0||groups.length===0){return renderNoDataFallback()}var _color=config.dataKeys&&(_config$dataKeys$2=config.dataKeys[0])!=null&&_config$dataKeys$2.color?config.dataKeys[0].color:"#2A44D4";return/*#__PURE__*/_jsx(BeeswarmChart,{data:nodes,groups:groups,color:_color,groupBy:groupBy,valueKey:_valueKey,decimalPrecision:decimalPrecision})}default:return/*#__PURE__*/_jsxs(PieChart,{children:[safeData.length>=20&&/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{hideLabel:true,decimalPrecision:decimalPrecision})}),/*#__PURE__*/_jsx(Pie,{data:safeData,dataKey:config.dataKey,nameKey:config.nameKey,innerRadius:60,strokeWidth:10,label:safeData.length<20?function(_ref8){var name=_ref8.name,percent=_ref8.percent;return name+": "+formatValue(percent*100,decimalPrecision)+"%"}:undefined,labelLine:false})]})}}export function renderChart(props){var _attributes$isEditabl2;var gjsModel=props.gjsModel,_props$performInterac2=props.performInteraction,performInteraction=_props$performInterac2===void 0?function(){return Promise.resolve({})}:_props$performInterac2,_props$isTemplateView3=props.isTemplateView,isTemplateView=_props$isTemplateView3===void 0?false:_props$isTemplateView3,rest=_objectWithoutPropertiesLoose(props,_excluded3);// Memoize filtered props to avoid re-filtering on every render
11
11
  var initialData=useMemo(function(){return filterPlaceholders(props)},[]);var _useState8=useState(initialData),allData=_useState8[0],setAllData=_useState8[1];var _useState9=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState9[0],setAttributes=_useState9[1];var isEditable=(_attributes$isEditabl2=attributes.isEditable)!=null?_attributes$isEditabl2:false;var containerRef=useRef(null);var _useState10=useState(0),containerWidth=_useState10[0],setContainerWidth=_useState10[1];useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){var handleAttributesChange=function handleAttributesChange(){var newAttributes=gjsModel.get("attributes");setAttributes(_extends({},newAttributes))};gjsModel.on("change:attributes",handleAttributesChange);return function(){gjsModel.off("change:attributes",handleAttributesChange)}},[gjsModel]);useEffect(function(){var updateContainerWidth=function updateContainerWidth(){if(containerRef.current){setContainerWidth(containerRef.current.offsetWidth||0)}};var resizeObserver=new ResizeObserver(function(entries){for(var _iterator3=_createForOfIteratorHelperLoose(entries),_step3;!(_step3=_iterator3()).done;){var entry=_step3.value;setContainerWidth(entry.contentRect.width||0)}});updateContainerWidth();var timeoutId=setTimeout(updateContainerWidth,50);if(containerRef.current){resizeObserver.observe(containerRef.current)}window.addEventListener("resize",updateContainerWidth);return function(){clearTimeout(timeoutId);resizeObserver.disconnect();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,sampleData=allData.sampleData,decimalPrecision=allData.decimalPrecision;var effectiveChartData=isTemplateView&&sampleData!==undefined?sampleData:chartData;var defaultClasses="aspect-auto w-full min-w-[200px] min-h-[200px]";var mergedClasses=className?cn(defaultClasses,className):defaultClasses;if(chartType==="pie"){var safeChartData=Array.isArray(effectiveChartData)?effectiveChartData:[];var colors=getNColors(safeChartData.length);safeChartData.forEach(function(data,i){if(!data.fill){data.fill=colors[i]}})}else if(!config.color){var safeBaseColors=Array.isArray(baseColors)?baseColors:[];if(safeBaseColors.length>0){config.color=safeBaseColors[Math.floor(Math.random()*safeBaseColors.length)]}}var totalDataPoints=0;if(chartType==="bar"||chartType==="line"||chartType==="scatter"||chartType==="histogram"||chartType==="beeswarm"){var _safeChartData=Array.isArray(effectiveChartData)?effectiveChartData:[];var safeDataKeys=Array.isArray(config.dataKeys)?config.dataKeys:[];if(chartType==="bar"){totalDataPoints=_safeChartData.length*Math.max(1,safeDataKeys.length)}else{totalDataPoints=_safeChartData.length}}var getScrollableWidth=function getScrollableWidth(){if(chartType==="line"){return totalDataPoints*20}if(chartType==="bar"){return totalDataPoints*20+(Array.isArray(config.dataKeys)?config.dataKeys.length:0)*8*(Array.isArray(chartData)?chartData.length:0)+(Array.isArray(chartData)?chartData.length:0)*15}return 800};var scrollWidth=getScrollableWidth();var shouldScroll=(chartType==="bar"||chartType==="line"||chartType==="beeswarm"||chartType==="histogram"||chartType==="scatter")&&totalDataPoints>15&&scrollWidth>containerWidth;var adjustedHeight=250;var angle=config.angle?config.angle:0;var radian=Math.abs(angle)*(Math.PI/180);if(chartType==="bar"&&chartData&&Array.isArray(chartData)&&config.angle){var maxLabelLength=chartData.reduce(function(max,item){var label=String(item[config.xAxis]||"");return Math.max(max,Math.min(label.length,28))},0);var multiplier=Math.floor(Math.max(Math.sin(radian),0.3)*5);var axisHeight=40+maxLabelLength*multiplier;adjustedHeight=250+axisHeight}var hasError=attributes.error||allData.error;var hasMissing=attributes.isMissing||allData.isMissing;var isLoading=(attributes.interactionApiInProgress||attributes.loading)&&!hasError&&!hasMissing;var ChartWrapper=function ChartWrapper(_ref9){var children=_ref9.children;if(shouldScroll){return/*#__PURE__*/_jsx("div",{className:"w-full overflow-x-auto",children:/*#__PURE__*/_jsx("div",{style:{minWidth:scrollWidth+"px",height:adjustedHeight+"px"},children:children})})}return/*#__PURE__*/_jsx("div",{className:"w-full",style:{height:adjustedHeight+"px"},children:children})};var chartUi=isLoading?/*#__PURE__*/_jsx(ChartLoader,{}):hasError||hasMissing||!effectiveChartData?renderNoDataFallback():/*#__PURE__*/_jsx(ChartWrapper,{children:/*#__PURE__*/_jsx(ChartContainer,_extends({},rest,{config:config,className:mergedClasses,style:{height:adjustedHeight+"px"},children:renderChartComponent(chartType,effectiveChartData,config,decimalPrecision!=null?decimalPrecision:2)}))});return/*#__PURE__*/_jsxs(Card,{className:"shadow border mt-2 mb-2 relative",children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",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",className:"px-6",style:{minHeight:"250px"},children:chartUi}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]})}export function renderTable(props){var _attributes$isEditabl3;var gjsModel=props.gjsModel,_props$performInterac3=props.performInteraction,performInteraction=_props$performInterac3===void 0?function(){}:_props$performInterac3,_props$isTemplateView4=props.isTemplateView,isTemplateView=_props$isTemplateView4===void 0?false:_props$isTemplateView4,rest=_objectWithoutPropertiesLoose(props,_excluded4);// Memoize filtered props to avoid re-filtering on every render
12
- var initialData=useMemo(function(){return filterPlaceholders(props)},[]);var _useState11=useState(initialData),allData=_useState11[0],setAllData=_useState11[1];var cardRef=useRef(null);var _useState12=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState12[0],setAttributes=_useState12[1];var isEditable=(_attributes$isEditabl3=attributes.isEditable)!=null?_attributes$isEditabl3:false;var rawData=allData.data,_allData$headerMapper=allData.headerMapper,rawHeaderMapper=_allData$headerMapper===void 0?{}:_allData$headerMapper,className=allData.className,_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,sampleData=allData.sampleData,decimalPrecision=allData.decimalPrecision,columnWithChipClass=allData.columnWithChipClass,chipStylesMapping=allData.chipStylesMapping;var effectiveRawData=isTemplateView&&sampleData!==undefined?sampleData:rawData;var data=Array.isArray(effectiveRawData)?effectiveRawData:[];var headerMapper=function(){var cleaned=_extends({},rawHeaderMapper);if("id"in cleaned){delete cleaned.id}if(data.length>0){var dataKeys=Object.keys(data[0]||{});return Object.fromEntries(Object.entries(cleaned).filter(function(_ref10){var key=_ref10[0];return dataKeys.includes(key)}))}return cleaned}();var sortConfig=function(_gjsModel$get,_ref12){var _ref11=(_gjsModel$get=gjsModel.get("componentProps"))!=null?_gjsModel$get:{},sortColumn=_ref11.sortColumn,sortDirection=_ref11.sortDirection;return sortColumn&&sortDirection?(_ref12={},_ref12[sortColumn]=sortDirection,_ref12):{}}();var _useState13=useState(0),viewportWidth=_useState13[0],setViewportWidth=_useState13[1];var _useState14=useState(250),scrollAreaHeight=_useState14[0],setScrollAreaHeight=_useState14[1];var calculateTableHeight=function calculateTableHeight(tableWidth,rowCount){if(viewportWidth>0){var _gjsModel$collection;var widthRatio=tableWidth/viewportWidth;var baseTableHeight=250;var targetScrollAreaHeight=baseTableHeight;if(widthRatio>=0.8){var headerHeight=48;var rowHeight=40;var calculatedHeight=headerHeight+rowCount*rowHeight;targetScrollAreaHeight=Math.min(calculatedHeight,baseTableHeight)}var tableId=gjsModel.get("id");var editor=gjsModel.em||((_gjsModel$collection=gjsModel.collection)==null?void 0:_gjsModel$collection.em);var canvasDocument=editor.Canvas.getDocument()||document;var tableElement=canvasDocument.querySelector("[data-table-id=\""+tableId+"\"]");if(tableElement){var headerElement=tableElement.querySelector("[data-slot=\"card-header\"]");if(headerElement&&headerElement.offsetHeight>0){var actualHeaderHeight=headerElement.offsetHeight;var standardHeaderHeight=58;var heightDifference=actualHeaderHeight-standardHeaderHeight;if(heightDifference>0){targetScrollAreaHeight=targetScrollAreaHeight-heightDifference}}}setScrollAreaHeight(targetScrollAreaHeight)}};useEffect(function(){var updateViewportWidth=function updateViewportWidth(){var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;var iframeDocument=iframeWindow==null?void 0:iframeWindow.document;if(iframeDocument){var dashboardRoot=iframeDocument.getElementById("dashboard-root");var effectiveViewportWidth=(dashboardRoot==null?void 0:dashboardRoot.clientWidth)||iframeDocument.documentElement.clientWidth;setViewportWidth(effectiveViewportWidth)}};updateViewportWidth();window.addEventListener("resize",updateViewportWidth);var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;if(iframeWindow){iframeWindow.addEventListener("resize",updateViewportWidth)}return function(){window.removeEventListener("resize",updateViewportWidth);if(iframeWindow){iframeWindow.removeEventListener("resize",updateViewportWidth)}}},[]);useEffect(function(){var updateTableWidthAndApplyCSS=function updateTableWidthAndApplyCSS(){var _gjsModel$collection2;var tableId=gjsModel.get("id");var editor=gjsModel.em||((_gjsModel$collection2=gjsModel.collection)==null?void 0:_gjsModel$collection2.em);var canvasDocument=editor.Canvas.getDocument()||document;var tableElement=canvasDocument.querySelector("[data-table-id=\""+tableId+"\"]");if(!tableElement&&window.parent!==window){tableElement=window.parent.document.querySelector("[data-table-id=\""+tableId+"\"]")}if(!tableElement){return}var tableActualWidth=tableElement.getBoundingClientRect().width;if(tableActualWidth>0){calculateTableHeight(tableActualWidth,Array.isArray(data)?data.length:0)}};var timeoutId=setTimeout(updateTableWidthAndApplyCSS,150);window.addEventListener("resize",updateTableWidthAndApplyCSS);return function(){clearTimeout(timeoutId);window.removeEventListener("resize",updateTableWidthAndApplyCSS)}},[allData,gjsModel,viewportWidth,data,calculateTableHeight]);useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){var handleAttributesChange=function handleAttributesChange(){setAttributes(_extends({},gjsModel.get("attributes")))};gjsModel.on("change:attributes",handleAttributesChange);return function(){gjsModel.off("change:attributes",handleAttributesChange)}},[gjsModel]);var parsedData=function(){if(typeof data==="object"&&data!==null&&!Array.isArray(data)&&data.name==="__peak_placeholder"){return[]}if(!Array.isArray(data)){return[]}return 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,_ref13,sortColumn,sortDirection;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:id=gjsModel.get("id");_ref13=(_gjsModel$get2=gjsModel.get("componentProps"))!=null?_gjsModel$get2:{},sortColumn=_ref13.sortColumn,sortDirection=_ref13.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 relative flex flex-col h-fit overflow-hidden","data-component-type":"table","data-table-id":gjsModel.get("id"),children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",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,className:"flex-1 flex flex-col overflow-hidden",children:attributes.error||allData.error||attributes.isMissing||allData.isMissing?renderNoDataFallback():/*#__PURE__*/_jsx(DataTable,{data:parsedData,headerMapper:headerMapper,className:className,isEditable:isEditable,actions:actions,pagination:pagination,isLoading:attributes.interactionApiInProgress||attributes.loading,onRowAction:onRowAction,onPageChange:onPageChange,onSort:handleSort,sortConfig:sortConfig,otherProps:rest,height:scrollAreaHeight,decimalPrecision:decimalPrecision,columnWithChipClass:columnWithChipClass,chipStylesMapping:chipStylesMapping})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",tableActions:actions,firstRowData:Array.isArray(data)&&data.length>0?data[0]:{},isVisible:isEditable,componentProps:allData})]})}export function renderTab(props){var tabsWidth=157;var safeTabs=Array.isArray(props.tabs)?props.tabs:[];var showFallback=safeTabs.length===0;if(safeTabs.length>4){tabsWidth=157}var defaultValue=props.defaultValue||(safeTabs.length>0?safeTabs[0]:undefined);useEffect(function(){if(props.gjsModel){var componentId=props.gjsModel.get("id");var childrenCount=props.gjsModel.components().length;if(safeTabs.length>0&&childrenCount===0){// eslint-disable-next-line no-console
12
+ var initialData=useMemo(function(){return filterPlaceholders(props)},[]);var _useState11=useState(initialData),allData=_useState11[0],setAllData=_useState11[1];var cardRef=useRef(null);var _useState12=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState12[0],setAttributes=_useState12[1];var isEditable=(_attributes$isEditabl3=attributes.isEditable)!=null?_attributes$isEditabl3:false;var rawData=allData.data,_allData$headerMapper=allData.headerMapper,rawHeaderMapper=_allData$headerMapper===void 0?{}:_allData$headerMapper,className=allData.className,_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,sampleData=allData.sampleData,decimalPrecision=allData.decimalPrecision,columnWithChipClass=allData.columnWithChipClass,chipStylesMapping=allData.chipStylesMapping;var effectiveRawData=isTemplateView&&sampleData!==undefined?sampleData:rawData;var data=Array.isArray(effectiveRawData)?effectiveRawData:[];var headerMapper=function(){var cleaned=_extends({},rawHeaderMapper);if("id"in cleaned){delete cleaned.id}if(data.length>0){var dataKeys=Object.keys(data[0]||{});return Object.fromEntries(Object.entries(cleaned).filter(function(_ref10){var key=_ref10[0];return dataKeys.includes(key)}))}return cleaned}();var sortConfig=function(_gjsModel$get,_ref12){var _ref11=(_gjsModel$get=gjsModel.get("componentProps"))!=null?_gjsModel$get:{},sortColumn=_ref11.sortColumn,sortDirection=_ref11.sortDirection;return sortColumn&&sortDirection?(_ref12={},_ref12[sortColumn]=sortDirection,_ref12):{}}();var _useState13=useState(0),viewportWidth=_useState13[0],setViewportWidth=_useState13[1];var _useState14=useState(250),scrollAreaHeight=_useState14[0],setScrollAreaHeight=_useState14[1];var calculateTableHeight=function calculateTableHeight(tableWidth,rowCount){if(viewportWidth>0){var _gjsModel$collection;var widthRatio=tableWidth/viewportWidth;var baseTableHeight=250;var targetScrollAreaHeight=baseTableHeight;if(widthRatio>=0.8){var headerHeight=48;var rowHeight=40;var calculatedHeight=headerHeight+rowCount*rowHeight;targetScrollAreaHeight=Math.min(calculatedHeight,baseTableHeight)}var tableId=gjsModel.get("id");var editor=gjsModel.em||((_gjsModel$collection=gjsModel.collection)==null?void 0:_gjsModel$collection.em);var canvasDocument=editor.Canvas.getDocument()||document;var tableElement=canvasDocument.querySelector("[data-table-id=\""+tableId+"\"]");if(tableElement){var headerElement=tableElement.querySelector("[data-slot=\"card-header\"]");if(headerElement&&headerElement.offsetHeight>0){var actualHeaderHeight=headerElement.offsetHeight;var standardHeaderHeight=58;var heightDifference=actualHeaderHeight-standardHeaderHeight;if(heightDifference>0){targetScrollAreaHeight=targetScrollAreaHeight-heightDifference}}}setScrollAreaHeight(targetScrollAreaHeight)}};useEffect(function(){var updateViewportWidth=function updateViewportWidth(){var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;var iframeDocument=iframeWindow==null?void 0:iframeWindow.document;if(iframeDocument){var dashboardRoot=iframeDocument.getElementById("dashboard-root");var effectiveViewportWidth=(dashboardRoot==null?void 0:dashboardRoot.clientWidth)||iframeDocument.documentElement.clientWidth;setViewportWidth(effectiveViewportWidth)}};updateViewportWidth();window.addEventListener("resize",updateViewportWidth);var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;if(iframeWindow){iframeWindow.addEventListener("resize",updateViewportWidth)}return function(){window.removeEventListener("resize",updateViewportWidth);if(iframeWindow){iframeWindow.removeEventListener("resize",updateViewportWidth)}}},[]);useEffect(function(){var updateTableWidthAndApplyCSS=function updateTableWidthAndApplyCSS(){var _gjsModel$collection2;var tableId=gjsModel.get("id");var editor=gjsModel.em||((_gjsModel$collection2=gjsModel.collection)==null?void 0:_gjsModel$collection2.em);var canvasDocument=editor.Canvas.getDocument()||document;var tableElement=canvasDocument.querySelector("[data-table-id=\""+tableId+"\"]");if(!tableElement&&window.parent!==window){tableElement=window.parent.document.querySelector("[data-table-id=\""+tableId+"\"]")}if(!tableElement){return}var tableActualWidth=tableElement.getBoundingClientRect().width;if(tableActualWidth>0){calculateTableHeight(tableActualWidth,Array.isArray(data)?data.length:0)}};var timeoutId=setTimeout(updateTableWidthAndApplyCSS,150);window.addEventListener("resize",updateTableWidthAndApplyCSS);return function(){clearTimeout(timeoutId);window.removeEventListener("resize",updateTableWidthAndApplyCSS)}},[allData,gjsModel,viewportWidth,data,calculateTableHeight]);useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){var handleAttributesChange=function handleAttributesChange(){setAttributes(_extends({},gjsModel.get("attributes")))};gjsModel.on("change:attributes",handleAttributesChange);return function(){gjsModel.off("change:attributes",handleAttributesChange)}},[gjsModel]);var parsedData=function(){if(typeof data==="object"&&data!==null&&!Array.isArray(data)&&data.name==="__peak_placeholder"){return[]}if(!Array.isArray(data)){return[]}return data.map(function(datum){var newData=_extends({},datum);delete newData.id;return newData})}();function onRowAction(_x,_x2,_x3){return _onRowAction.apply(this,arguments)}function _onRowAction(){_onRowAction=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(rowIndex,actionId,formData){var id,result;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:_extends({row:data[rowIndex],tableId:id},formData&&{formData:formData}),affectedComponents:[]});case 3:result=_context.sent;if(!(result&&result.errors)){_context.next=6;break}throw{detail:result.errorMsg};case 6:case"end":return _context.stop()}},_callee)}));return _onRowAction.apply(this,arguments)}function onPageChange(_x4,_x5){return _onPageChange.apply(this,arguments)}function _onPageChange(){_onPageChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(pageNumber,pageSize){var _gjsModel$get2;var id,_ref13,sortColumn,sortDirection;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:id=gjsModel.get("id");_ref13=(_gjsModel$get2=gjsModel.get("componentProps"))!=null?_gjsModel$get2:{},sortColumn=_ref13.sortColumn,sortDirection=_ref13.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(_x6,_x7){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 relative flex flex-col h-fit overflow-hidden","data-component-type":"table","data-table-id":gjsModel.get("id"),children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",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,className:"flex-1 flex flex-col overflow-hidden",children:attributes.error||allData.error||attributes.isMissing||allData.isMissing?renderNoDataFallback():/*#__PURE__*/_jsx(DataTable,{data:parsedData,headerMapper:headerMapper,className:className,isEditable:isEditable,actions:actions,pagination:pagination,isLoading:attributes.interactionApiInProgress||attributes.loading,onRowAction:onRowAction,onPageChange:onPageChange,onSort:handleSort,sortConfig:sortConfig,otherProps:rest,height:scrollAreaHeight,decimalPrecision:decimalPrecision,columnWithChipClass:columnWithChipClass,chipStylesMapping:chipStylesMapping})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",tableActions:actions,firstRowData:Array.isArray(data)&&data.length>0?data[0]:{},isVisible:isEditable,componentProps:allData})]})}export function renderTab(props){var tabsWidth=157;var safeTabs=Array.isArray(props.tabs)?props.tabs:[];var showFallback=safeTabs.length===0;if(safeTabs.length>4){tabsWidth=157}var defaultValue=props.defaultValue||(safeTabs.length>0?safeTabs[0]:undefined);useEffect(function(){if(props.gjsModel){var componentId=props.gjsModel.get("id");var childrenCount=props.gjsModel.components().length;if(safeTabs.length>0&&childrenCount===0){// eslint-disable-next-line no-console
13
13
  console.warn("Tab component "+componentId+" has "+safeTabs.length+" tabs but no child components. This may indicate lost tab content.")}}},[safeTabs.length,props.gjsModel]);return/*#__PURE__*/_jsxs(Tabs,{defaultValue:defaultValue,children:[/*#__PURE__*/_jsx("div",{className:"text-center mb-4",children:/*#__PURE__*/_jsx(TabsList,{className:"bg-[#F9F9FE] border border-[#D4D5DE] p-1 rounded-lg h-auto",children:safeTabs.length>0?safeTabs.map(function(tab){return/*#__PURE__*/_jsx(TabsTrigger,{value:tab,className:"\n w-["+tabsWidth+"px] h-[38px] gap-1 px-3 py-[11px]\n font-medium text-sm leading-4\n border-0 bg-[#F9F9FE] text-[#687387] rounded-none\n data-[state=active]:border data-[state=active]:border-solid data-[state=active]:border-[#2A44D4] data-[state=active]:bg-[#EAECFB] data-[state=active]:text-[#263DBF] data-[state=active]:shadow-none data-[state=active]:rounded-md\n transition-all duration-200\n ",style:{fontFamily:"Helvetica Neue",fontWeight:500,fontSize:"14px",lineHeight:"16px",letterSpacing:"0%"},children:tab},tab)}):/*#__PURE__*/_jsx(TabsTrigger,{value:"no-data",className:"\n w-["+tabsWidth+"px] h-[38px] gap-1 px-3 py-[11px]\n font-medium text-sm leading-4\n border-0 bg-[#F9F9FE] text-[#687387] rounded-none\n data-[state=active]:border data-[state=active]:border-solid data-[state=active]:border-[#2A44D4] data-[state=active]:bg-[#EAECFB] data-[state=active]:text-[#263DBF] data-[state=active]:shadow-none data-[state=active]:rounded-md\n transition-all duration-200\n ",style:{fontFamily:"Helvetica Neue",fontWeight:500,fontSize:"14px",lineHeight:"16px",letterSpacing:"0%"},disabled:true,children:"No tabs"})})}),showFallback?/*#__PURE__*/_jsx(TabsContent,{value:defaultValue||"no-data",className:"tabs-content","data-fallback":"true",children:renderNoDataFallback()}):safeTabs.map(function(tab){return/*#__PURE__*/_jsx(TabsContent,{value:tab,className:"tabs-content"},tab)})]})}export function renderMarkdown(props){var _attributes$isEditabl4;var gjsModel=props.gjsModel,_props$isTemplateView5=props.isTemplateView,isTemplateView=_props$isTemplateView5===void 0?false:_props$isTemplateView5,rest=_objectWithoutPropertiesLoose(props,_excluded5);// Memoize filtered props to avoid re-filtering on every render
14
14
  var initialData=useMemo(function(){return filterPlaceholders(props)},[]);var _useState15=useState(initialData),allData=_useState15[0],setAllData=_useState15[1];var _useState16=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState16[0],setAttributes=_useState16[1];var isEditable=(_attributes$isEditabl4=attributes.isEditable)!=null?_attributes$isEditabl4:false;useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){var handleAttributesChange=function handleAttributesChange(){setAttributes(_extends({},gjsModel.get("attributes")))};gjsModel.on("change:attributes",handleAttributesChange);return function(){gjsModel.off("change:attributes",handleAttributesChange)}},[gjsModel]);var _useState17=useState(false),isEditing=_useState17[0],setIsEditing=_useState17[1];var _useState18=useState(false),isEditingHeading=_useState18[0],setIsEditingHeading=_useState18[1];var editRef=useRef(null);var headingEditRef=useRef(null);var startEditing=function startEditing(){setIsEditing(true);setTimeout(function(){setupEditor()},0)};var startEditingHeading=function startEditingHeading(){setIsEditingHeading(true);setTimeout(function(){setupHeadingEditor()},0)};var setupEditor=function setupEditor(){if(!editRef.current){return}var editor=editRef.current;editor.innerHTML="";var effectiveText=isTemplateView&&allData.sampleData!==undefined?allData.sampleData:allData.summaryText;editor.textContent=effectiveText;editor.focus()};var setupHeadingEditor=function setupHeadingEditor(){if(!headingEditRef.current){return}var editor=headingEditRef.current;editor.innerHTML="";editor.textContent=allData.summaryHeading||"Insights";editor.focus()};// Save changes and exit editing mode
15
- 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 saveHeadingChanges=function saveHeadingChanges(){if(!headingEditRef.current){return}var content=headingEditRef.current.innerText||"Insights";setAllData(function(prev){return _extends({},prev,{summaryHeading:content})});setIsEditingHeading(false);headingEditRef.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]"}}};var summaryText=allData.summaryText,summaryHeading=allData.summaryHeading,sampleData=allData.sampleData;var rawSummaryText=isTemplateView&&sampleData!==undefined?sampleData:summaryText;var effectiveSummaryText=typeof rawSummaryText==="string"?rawSummaryText:"";var hasError=attributes.error||allData.error;var hasMissing=attributes.isMissing||allData.isMissing;var isLoading=attributes.loading&&!hasError&&!hasMissing||attributes.interactionApiInProgress;if(isLoading){return/*#__PURE__*/_jsx(MarkdownLoader,{})}if(hasError||hasMissing){return/*#__PURE__*/_jsxs("div",_extends({className:"px-[1em] relative"},rest,{children:[/*#__PURE__*/_jsx("h3",{className:"text-xl font-semibold text-left",children:summaryHeading||"Insights"}),/*#__PURE__*/_jsxs("div",{className:"w-full py-8 flex flex-col items-center justify-center px-6 text-center",style:{minHeight:"180px"},children:[/*#__PURE__*/_jsx(CircleAlert,{className:"w-12 h-12 text-gray-400 mb-2"}),/*#__PURE__*/_jsx("h3",{className:"text-lg font-medium text-gray-900",children:"No data available"}),/*#__PURE__*/_jsx("p",{className:"mt-2 text-sm text-gray-500 max-w-md",children:"Check your filters or try a different time range."})]}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:props.performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}if(!isEditable){return/*#__PURE__*/_jsxs("div",_extends({className:"px-[1em] relative"},rest,{children:[/*#__PURE__*/_jsx("h3",{className:"text-xl font-semibold text-left",children:summaryHeading||"Insights"}),/*#__PURE__*/_jsx("div",{"data-slot":"summaryText",children:/*#__PURE__*/_jsx(Markdown,{options:{overrides:markdownStyles},children:effectiveSummaryText})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:props.performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}return/*#__PURE__*/_jsxs("div",_extends({className:"p-[1em] relative"},rest,{children:[isEditingHeading?/*#__PURE__*/_jsx("div",{ref:headingEditRef,contentEditable:true,onBlur:saveHeadingChanges,"data-slot":"summaryHeading",className:"text-xl font-semibold text-left",suppressContentEditableWarning:true}):/*#__PURE__*/_jsx("h3",{className:"text-xl font-semibold text-left",onClick:startEditingHeading,"data-slot":"summaryHeading",children:allData.summaryHeading||"Insights"}),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:effectiveSummaryText})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:props.performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}export function renderButton(props){var _attributes$isEditabl5;var gjsModel=props.gjsModel,_props$performInterac4=props.performInteraction,performInteraction=_props$performInterac4===void 0?function(){}:_props$performInterac4;var _useState19=useState(_extends({},props)),allData=_useState19[0],setAllData=_useState19[1];var _useState20=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState20[0],setAttributes=_useState20[1];var isEditable=(_attributes$isEditabl5=attributes.isEditable)!=null?_attributes$isEditabl5:false;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})}var renderActionCardWithWrapper=function renderActionCardWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"ActionCard"}),children:renderActionCard(props)})};var renderButtonWithWrapper=function renderButtonWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Button"}),children:renderButton(props)})};var renderCardWithWrapper=function renderCardWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Card"}),children:renderCard(props)})};var renderChartWithWrapper=function renderChartWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Chart"}),children:renderChart(props)})};var renderFilterWithWrapper=function renderFilterWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Filter"}),children:renderFilter(props)})};var renderUnifiedFilterWithWrapper=function renderUnifiedFilterWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"UnifiedFilter"}),children:renderUnifiedFilter(props)})};var renderMarkdownWithWrapper=function renderMarkdownWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Markdown"}),children:renderMarkdown(props)})};var renderSearchWithWrapper=function renderSearchWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Search"}),children:renderSearch(props)})};var renderTableWithWrapper=function renderTableWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Table"}),children:renderTable(props)})};var renderTabWithWrapper=function renderTabWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Tabs"}),children:renderTab(props)})};function renderActions(props){var actions=props.actions,_props$isEditable=props.isEditable,isEditable=_props$isEditable===void 0?false:_props$isEditable,gjsModel=props.gjsModel;if(actions===null){return/*#__PURE__*/_jsx("div",{})}if(!Array.isArray(actions)||actions.length===0){return/*#__PURE__*/_jsx("div",{className:"bg-white text-black p-4 rounded-lg border flex flex-col h-full shadow-none relative",children:/*#__PURE__*/_jsx(CardLoader,{})})}return/*#__PURE__*/_jsx("div",{className:"dashboard-cards flex flex-wrap gap-4",children:actions.map(function(action,index){var icon=action.icon,title=action.title,description=action.description;return/*#__PURE__*/_jsx("div",{className:"flex-1 min-w-[200px]",children:renderActionCard({icon:icon,headerContent:title,bodyContent:description,isEditable:isEditable,gjsModel:gjsModel})},index)})})}var renderActionsWithWrapper=function renderActionsWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Actions"}),children:renderActions(props)})};export function getRenderers(){return{ActionCard:renderActionCardWithWrapper,Actions:renderActionsWithWrapper,Button:renderButtonWithWrapper,Card:renderCardWithWrapper,Chart:renderChartWithWrapper,Filter:renderFilterWithWrapper,Markdown:renderMarkdownWithWrapper,Search:renderSearchWithWrapper,Table:renderTableWithWrapper,Tabs:renderTabWithWrapper,UnifiedFilter:renderUnifiedFilterWithWrapper}}
15
+ 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 saveHeadingChanges=function saveHeadingChanges(){if(!headingEditRef.current){return}var content=headingEditRef.current.innerText||"Insights";setAllData(function(prev){return _extends({},prev,{summaryHeading:content})});setIsEditingHeading(false);headingEditRef.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]"}}};var summaryText=allData.summaryText,summaryHeading=allData.summaryHeading,sampleData=allData.sampleData;var rawSummaryText=isTemplateView&&sampleData!==undefined?sampleData:summaryText;var effectiveSummaryText=typeof rawSummaryText==="string"?rawSummaryText:"";var hasError=attributes.error||allData.error;var hasMissing=attributes.isMissing||allData.isMissing;var isLoading=attributes.loading&&!hasError&&!hasMissing||attributes.interactionApiInProgress;if(isLoading){return/*#__PURE__*/_jsx(MarkdownLoader,{})}if(hasError||hasMissing){return/*#__PURE__*/_jsxs("div",_extends({className:"px-[1em] relative"},rest,{children:[/*#__PURE__*/_jsx("h3",{className:"text-xl font-semibold text-left",children:summaryHeading||"Insights"}),/*#__PURE__*/_jsxs("div",{className:"w-full py-8 flex flex-col items-center justify-center px-6 text-center",style:{minHeight:"180px"},children:[/*#__PURE__*/_jsx(CircleAlert,{className:"w-12 h-12 text-gray-400 mb-2"}),/*#__PURE__*/_jsx("h3",{className:"text-lg font-medium text-gray-900",children:"No data available"}),/*#__PURE__*/_jsx("p",{className:"mt-2 text-sm text-gray-500 max-w-md",children:"Check your filters or try a different time range."})]}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:props.performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}if(!isEditable){return/*#__PURE__*/_jsxs("div",_extends({className:"px-[1em] relative"},rest,{children:[/*#__PURE__*/_jsx("h3",{className:"text-xl font-semibold text-left",children:summaryHeading||"Insights"}),/*#__PURE__*/_jsx("div",{"data-slot":"summaryText",children:/*#__PURE__*/_jsx(Markdown,{options:{overrides:markdownStyles},children:effectiveSummaryText})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:props.performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}return/*#__PURE__*/_jsxs("div",_extends({className:"p-[1em] relative"},rest,{children:[isEditingHeading?/*#__PURE__*/_jsx("div",{ref:headingEditRef,contentEditable:true,onBlur:saveHeadingChanges,"data-slot":"summaryHeading",className:"text-xl font-semibold text-left",suppressContentEditableWarning:true}):/*#__PURE__*/_jsx("h3",{className:"text-xl font-semibold text-left",onClick:startEditingHeading,"data-slot":"summaryHeading",children:allData.summaryHeading||"Insights"}),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:effectiveSummaryText})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:props.performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}export function renderButton(props){var _attributes$isEditabl5;var gjsModel=props.gjsModel,_props$performInterac4=props.performInteraction,performInteraction=_props$performInterac4===void 0?function(){}:_props$performInterac4;var _useState19=useState(_extends({},props)),allData=_useState19[0],setAllData=_useState19[1];var _useState20=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState20[0],setAttributes=_useState20[1];var isEditable=(_attributes$isEditabl5=attributes.isEditable)!=null?_attributes$isEditabl5:false;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,action=allData.action;var _ref14=action||{},formMapper=_ref14.formMapper,formButtonText=_ref14.formButtonText;var _useButtonForm=useButtonForm({formMapper:formMapper,isSubmitting:attributes.interactionApiInProgress||false,onSubmit:function(){var _onSubmit=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(formData){var id,result;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:id=gjsModel.get("id");_context4.next=3;return performInteraction({id:id,interactionType:"button",affectedComponents:getAffectedComponentsWithLoader([id].concat(affectedComponents),true),payload:_extends({},payload,{formData:formData})});case 3:result=_context4.sent;if(!(result&&result.errors)){_context4.next=6;break}throw{detail:result.errorMsg};case 6:case"end":return _context4.stop()}},_callee4)}));function onSubmit(_x8){return _onSubmit.apply(this,arguments)}return onSubmit}(),formButtonText:formButtonText}),openForm=_useButtonForm.openForm,FormDialog=_useButtonForm.FormDialog;function interact(){if(!openForm()){var id=gjsModel.get("id");performInteraction({id:id,interactionType:"button",affectedComponents:getAffectedComponentsWithLoader([id].concat(affectedComponents),true),payload:payload})}}return/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(TooltipButton,{className:className,isEditable:isEditable,interact:interact,attributes:attributes,variant:variant,size:size,text:text,tooltipContent:tooltipContent}),FormDialog]})}var renderActionCardWithWrapper=function renderActionCardWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"ActionCard"}),children:renderActionCard(props)})};var renderButtonWithWrapper=function renderButtonWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Button"}),children:renderButton(props)})};var renderCardWithWrapper=function renderCardWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Card"}),children:renderCard(props)})};var renderChartWithWrapper=function renderChartWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Chart"}),children:renderChart(props)})};var renderFilterWithWrapper=function renderFilterWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Filter"}),children:renderFilter(props)})};var renderUnifiedFilterWithWrapper=function renderUnifiedFilterWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"UnifiedFilter"}),children:renderUnifiedFilter(props)})};var renderMarkdownWithWrapper=function renderMarkdownWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Markdown"}),children:renderMarkdown(props)})};var renderSearchWithWrapper=function renderSearchWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Search"}),children:renderSearch(props)})};var renderTableWithWrapper=function renderTableWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Table"}),children:renderTable(props)})};var renderTabWithWrapper=function renderTabWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Tabs"}),children:renderTab(props)})};function renderActions(props){var actions=props.actions,_props$isEditable=props.isEditable,isEditable=_props$isEditable===void 0?false:_props$isEditable,gjsModel=props.gjsModel;if(actions===null){return/*#__PURE__*/_jsx("div",{})}if(!Array.isArray(actions)||actions.length===0){return/*#__PURE__*/_jsx("div",{className:"bg-white text-black p-4 rounded-lg border flex flex-col h-full shadow-none relative",children:/*#__PURE__*/_jsx(CardLoader,{})})}return/*#__PURE__*/_jsx("div",{className:"dashboard-cards flex flex-wrap gap-4",children:actions.map(function(action,index){var icon=action.icon,title=action.title,description=action.description;return/*#__PURE__*/_jsx("div",{className:"flex-1 min-w-[200px]",children:renderActionCard({icon:icon,headerContent:title,bodyContent:description,isEditable:isEditable,gjsModel:gjsModel})},index)})})}var renderActionsWithWrapper=function renderActionsWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Actions"}),children:renderActions(props)})};export function getRenderers(){return{ActionCard:renderActionCardWithWrapper,Actions:renderActionsWithWrapper,Button:renderButtonWithWrapper,Card:renderCardWithWrapper,Chart:renderChartWithWrapper,Filter:renderFilterWithWrapper,Markdown:renderMarkdownWithWrapper,Search:renderSearchWithWrapper,Table:renderTableWithWrapper,Tabs:renderTabWithWrapper,UnifiedFilter:renderUnifiedFilterWithWrapper}}
16
16
  //# sourceMappingURL=render-components.js.map