@peak-ai/canvas 1.6.9-rc.1 → 1.6.9-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -7,10 +7,10 @@ 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,_pagination$totalCoun
|
|
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,_pagination$totalCoun;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$sortable=_ref.sortable,sortableGlobal=_ref$sortable===void 0?true:_ref$sortable,_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,navigateToPage=_ref.navigateToPage,_ref$isBulkSelectionE=_ref.isBulkSelectionEnabled,isBulkSelectionEnabled=_ref$isBulkSelectionE===void 0?false:_ref$isBulkSelectionE,_ref$selectedIndices=_ref.selectedIndices,selectedIndices=_ref$selectedIndices===void 0?[]:_ref$selectedIndices,setSelectedIndices=_ref.setSelectedIndices,title=_ref.title,onDownload=_ref.onDownload;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(null),loadingActionKey=_useState6[0],setLoadingActionKey=_useState6[1];var _useState7=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=_useState7[0],setPageNumber=_useState7[1];var _useState8=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=_useState8[0],setPageSize=_useState8[1];var _useState9=useState(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1),totalPages=_useState9[0],setTotalPages=_useState9[1];var _useState10=useState({}),chipColorMap=_useState10[0],setChipColorMap=_useState10[1];var _useState11=useState(null),openDropdownIndex=_useState11[0],setOpenDropdownIndex=_useState11[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
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.action==="navigateToPage"&&action.action.targetPageId){var rowContext=resolveRowContext(action.action.rowContext,data[rowIndex]);navigateToPage==null||navigateToPage(action.action.targetPageId,rowContext);return}if(action.action.type==="navigation"){var onClick=action.action.onClick;if((onClick==null?void 0:onClick.action)==="navigateToPage"&&onClick.targetPageId){var _rowContext=resolveRowContext(action.action.rowContext,data[rowIndex]);navigateToPage==null||navigateToPage(onClick.targetPageId,_rowContext);return}}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 _callee3(newPage,newSize){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.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 _context3.stop()}},_callee3)}));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 handleCheckboxClick(rowIndex){if(setSelectedIndices){if(selectedIndices.includes(rowIndex)){setSelectedIndices(selectedIndices.filter(function(idx){return idx!==rowIndex}))}else{setSelectedIndices([].concat(selectedIndices,[rowIndex]))}}}function ActionsDropdown(_ref6){var rowIndex=_ref6.rowIndex,rowActions=_ref6.rowActions;var isOpen=openDropdownIndex===rowIndex;var totalRows=rows.length;var isNearBottom=rowIndex>=totalRows-3;function handleActionClick(_x4){return _handleActionClick.apply(this,arguments)}function _handleActionClick(){_handleActionClick=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(action){var rowContext,onClick,_rowContext2,actionKey;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(action.action.action==="navigateToPage"&&action.action.targetPageId)){_context2.next=5;break}rowContext=resolveRowContext(action.action.rowContext,data[rowIndex]);navigateToPage==null||navigateToPage(action.action.targetPageId,rowContext);setOpenDropdownIndex(null);return _context2.abrupt("return");case 5:if(!(action.action.type==="navigation")){_context2.next=12;break}onClick=action.action.onClick;if(!((onClick==null?void 0:onClick.action)==="navigateToPage"&&onClick.targetPageId)){_context2.next=12;break}_rowContext2=resolveRowContext(action.action.rowContext,data[rowIndex]);navigateToPage==null||navigateToPage(onClick.targetPageId,_rowContext2);setOpenDropdownIndex(null);return _context2.abrupt("return");case 12:// Handle form-based and API actions
|
|
15
|
-
actionKey=rowIndex+"-"+action.id;if(!(action.action.formMapper&&Object.keys(action.action.formMapper).length>0)){_context2.next=19;break}setActiveRowIndex(rowIndex);setActiveAction(action);setOpenDropdownIndex(null);_context2.next=27;break;case 19:_context2.prev=19;setLoadingActionKey(actionKey);_context2.next=23;return onRowAction==null?void 0:onRowAction(rowIndex,action.id);case 23:_context2.prev=23;setLoadingActionKey(null);setOpenDropdownIndex(null);return _context2.finish(23);case 27:case"end":return _context2.stop()}},_callee2,null,[[19,,23,27]])}));return _handleActionClick.apply(this,arguments)}function toggleDropdown(){setOpenDropdownIndex(isOpen?null:rowIndex)}function handleBackdropClick(){if(!loadingActionKey){setOpenDropdownIndex(null)}}return/*#__PURE__*/_jsxs(_Fragment,{children:[isOpen&&/*#__PURE__*/_jsx("div",{className:"fixed inset-0 z-40",onClick:handleBackdropClick,style:{background:"transparent",cursor:"default"}}),/*#__PURE__*/_jsxs("div",{className:"relative",children:[/*#__PURE__*/_jsx(Button,{variant:"ghost",size:"icon",onClick:function onClick(e){e.stopPropagation();toggleDropdown()},disabled:isLoading,className:"h-8 w-8 relative z-50","data-dropdown-button":"true",children:/*#__PURE__*/_jsx(MoreVertical,{className:"h-4 w-4"})}),isOpen&&/*#__PURE__*/_jsx("div",{className:cn("absolute right-full mr-2 w-48 rounded-md shadow-lg bg-white ring-gray-400 ring-opacity-5 z-50",isNearBottom?"bottom-0":"top-0"),children:/*#__PURE__*/_jsx("div",{className:"py-1",role:"menu",children:rowActions.map(function(action){var actionKey=rowIndex+"-"+action.id;var isActionLoading=loadingActionKey===actionKey;return/*#__PURE__*/_jsxs("button",{onClick:function onClick(){return handleActionClick(action)},className:"block w-full text-left px-4 py-2 text-sm hover:bg-accent transition-colors font-semibold disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 focus:outline-none focus:bg-accent",disabled:isLoading||isActionLoading,role:"menuitem",children:[isActionLoading&&/*#__PURE__*/_jsx(Loader2,{className:"h-3 w-3 animate-spin"}),action.text]},action.id)})})})]})]})}function renderActions(rowIndex,rowActions){if(!actions.length){return null}return/*#__PURE__*/_jsx(TableCell,{className:"sticky right-0 bg-white overflow-visible",children:/*#__PURE__*/_jsx(ActionsDropdown,{rowIndex:rowIndex,rowActions:rowActions})})}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__*/_jsxs(TableRow,{children:[isBulkSelectionEnabled&&/*#__PURE__*/_jsx(TableCell,{className:"p-2 w-10",children:/*#__PURE__*/_jsx(Checkbox,{checked:(selectedIndices==null?void 0:selectedIndices.length)===data.length,onCheckedChange:function onCheckedChange(){if(setSelectedIndices){if((selectedIndices==null?void 0:selectedIndices.length)===data.length){setSelectedIndices([])}else{setSelectedIndices(data.map(function(_,idx){return idx}))}}}})}),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:sortableGlobal&&!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:[isBulkSelectionEnabled&&/*#__PURE__*/_jsx(TableCell,{className:"p-2 align-middle",children:/*#__PURE__*/_jsx(Checkbox,{checked:selectedIndices==null?void 0:selectedIndices.includes(rIdx),onCheckedChange:function onCheckedChange(){return handleCheckboxClick(rIdx)}})}),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$totalCoun=pagination==null?void 0:pagination.totalCount)!=null?_pagination$totalCoun:0)>0||title&&!isEditable&&onDownload)&&/*#__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__*/_jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:pagination&&pagination.totalCount>0&&/*#__PURE__*/_jsxs(_Fragment,{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||[10,20,50,100]).map(function(size){return/*#__PURE__*/_jsx("option",{value:size,children:size},size)})})]})}),/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[title&&!isEditable&&onDownload&&/*#__PURE__*/_jsx(DownloadButton,{component:"table",title:title,onDownload:onDownload,dataCount:(
|
|
15
|
+
actionKey=rowIndex+"-"+action.id;if(!(action.action.formMapper&&Object.keys(action.action.formMapper).length>0)){_context2.next=19;break}setActiveRowIndex(rowIndex);setActiveAction(action);setOpenDropdownIndex(null);_context2.next=27;break;case 19:_context2.prev=19;setLoadingActionKey(actionKey);_context2.next=23;return onRowAction==null?void 0:onRowAction(rowIndex,action.id);case 23:_context2.prev=23;setLoadingActionKey(null);setOpenDropdownIndex(null);return _context2.finish(23);case 27:case"end":return _context2.stop()}},_callee2,null,[[19,,23,27]])}));return _handleActionClick.apply(this,arguments)}function toggleDropdown(){setOpenDropdownIndex(isOpen?null:rowIndex)}function handleBackdropClick(){if(!loadingActionKey){setOpenDropdownIndex(null)}}return/*#__PURE__*/_jsxs(_Fragment,{children:[isOpen&&/*#__PURE__*/_jsx("div",{className:"fixed inset-0 z-40",onClick:handleBackdropClick,style:{background:"transparent",cursor:"default"}}),/*#__PURE__*/_jsxs("div",{className:"relative",children:[/*#__PURE__*/_jsx(Button,{variant:"ghost",size:"icon",onClick:function onClick(e){e.stopPropagation();toggleDropdown()},disabled:isLoading,className:"h-8 w-8 relative z-50","data-dropdown-button":"true",children:/*#__PURE__*/_jsx(MoreVertical,{className:"h-4 w-4"})}),isOpen&&/*#__PURE__*/_jsx("div",{className:cn("absolute right-full mr-2 w-48 rounded-md shadow-lg bg-white ring-gray-400 ring-opacity-5 z-50",isNearBottom?"bottom-0":"top-0"),children:/*#__PURE__*/_jsx("div",{className:"py-1",role:"menu",children:rowActions.map(function(action){var actionKey=rowIndex+"-"+action.id;var isActionLoading=loadingActionKey===actionKey;return/*#__PURE__*/_jsxs("button",{onClick:function onClick(){return handleActionClick(action)},className:"block w-full text-left px-4 py-2 text-sm hover:bg-accent transition-colors font-semibold disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 focus:outline-none focus:bg-accent",disabled:isLoading||isActionLoading,role:"menuitem",children:[isActionLoading&&/*#__PURE__*/_jsx(Loader2,{className:"h-3 w-3 animate-spin"}),action.text]},action.id)})})})]})]})}function renderActions(rowIndex,rowActions){if(!actions.length){return null}return/*#__PURE__*/_jsx(TableCell,{className:"sticky right-0 bg-white overflow-visible",children:/*#__PURE__*/_jsx(ActionsDropdown,{rowIndex:rowIndex,rowActions:rowActions})})}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__*/_jsxs(TableRow,{children:[isBulkSelectionEnabled&&/*#__PURE__*/_jsx(TableCell,{className:"p-2 w-10",children:/*#__PURE__*/_jsx(Checkbox,{checked:(selectedIndices==null?void 0:selectedIndices.length)===data.length,onCheckedChange:function onCheckedChange(){if(setSelectedIndices){if((selectedIndices==null?void 0:selectedIndices.length)===data.length){setSelectedIndices([])}else{setSelectedIndices(data.map(function(_,idx){return idx}))}}}})}),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:sortableGlobal&&!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:[isBulkSelectionEnabled&&/*#__PURE__*/_jsx(TableCell,{className:"p-2 align-middle",children:/*#__PURE__*/_jsx(Checkbox,{checked:selectedIndices==null?void 0:selectedIndices.includes(rIdx),onCheckedChange:function onCheckedChange(){return handleCheckboxClick(rIdx)}})}),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$totalCoun=pagination==null?void 0:pagination.totalCount)!=null?_pagination$totalCoun:0)>0||title&&!isEditable&&onDownload)&&/*#__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__*/_jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:pagination&&pagination.totalCount>0&&/*#__PURE__*/_jsxs(_Fragment,{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||[10,20,50,100]).map(function(size){return/*#__PURE__*/_jsx("option",{value:size,children:size},size)})})]})}),/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[title&&!isEditable&&onDownload&&/*#__PURE__*/_jsx(DownloadButton,{component:"table",title:title,onDownload:onDownload,dataCount:typeof(pagination==null?void 0:pagination.totalCount)==="number"?pagination.totalCount:data.length}),pagination&&pagination.totalCount>0&&/*#__PURE__*/_jsxs(_Fragment,{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]})}
|
|
16
16
|
//# 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","Button","cn","renderNoDataFallback","formatValue","SEMANTIC_CHIP_STYLES_MAP","RANDOM_CHIP_COLOR_PALETTE","Checkbox","MoreVertical","Loader2","useButtonForm","DownloadButton","jsx","_jsx","jsxs","_jsxs","_Fragment","resolveRowContext","rowContext","row","Object","keys","length","undefined","resolved","_i","_Object$entries","entries","_Object$entries$_i","key","ref","startsWith","_row$fieldName","fieldName","includes","split","slice","join","normalizeValue","value","str","String","trim","toLowerCase","getChipMode","columnWithChipClass","columnKey","mode","getUniqueValuesHash","data","Array","isArray","availableKeys","hashParts","forEach","chipMode","uniqueNormalizedValues","Set","normalizedKey","add","sortedUniqueValues","from","sort","JSON","stringify","DataTable","_ref","_ref2","_pagination$values$pa","_pagination$values","_ref3","_pagination$values$pa2","_pagination$values2","_pagination$totalCoun","_pagination$totalCoun2","_ref$data","_ref$headerMapper","headerMapper","_ref$className","className","_ref$actions","actions","_ref$isEditable","isEditable","pagination","_ref$isLoading","isLoading","onRowAction","onPageChange","onSort","sortConfig","_ref$sortable","sortable","sortableGlobal","_ref$otherProps","otherProps","height","_ref$decimalPrecision","decimalPrecision","_ref$columnWithChipCl","_ref$chipStylesMappin","chipStylesMapping","navigateToPage","_ref$isBulkSelectionE","isBulkSelectionEnabled","_ref$selectedIndices","selectedIndices","setSelectedIndices","title","onDownload","children","style","minHeight","_useState","activeSortColumn","setActiveSortColumn","_useState2","sortDirections","setSortDirections","_useState3","activeRowIndex","setActiveRowIndex","_useState4","activeAction","setActiveAction","_useState5","isFormSubmitting","setIsFormSubmitting","_useState6","loadingActionKey","setLoadingActionKey","_useState7","Number","values","pageNumber","initialPage","setPageNumber","_useState8","pageSize","initialPageSize","setPageSize","_useState9","Math","ceil","totalCount","totalPages","setTotalPages","_useState10","chipColorMap","setChipColorMap","_useState11","openDropdownIndex","setOpenDropdownIndex","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","targetPageId","type","onClick","originalKeys","filter","headers","map","push","rows","datum","handlePageChange","_x2","_x3","_handlePageChange","_callee3","newPage","newSize","_callee3$","_context3","handleSortClick","column","direction","_extends2","handleCheckboxClick","idx","concat","ActionsDropdown","_ref6","rowActions","isOpen","totalRows","isNearBottom","handleActionClick","_x4","_handleActionClick","_callee2","_rowContext2","actionKey","_callee2$","_context2","abrupt","toggleDropdown","handleBackdropClick","background","cursor","variant","size","e","stopPropagation","disabled","role","isActionLoading","text","renderActions","defaultClasses","mergedClasses","getRandomColorForValue","_chipColorMap$columnK","renderChip","formattedValue","chipClassName","_chipStylesMapping$co","valueStr","valueLower","renderTableComponent","checked","onCheckedChange","_","head","isActionColumn","originalKey","contentEditable","isActive","rIdx","cell","cIdx","shouldRenderChip","orientation","htmlFor","onChange","target","pageSizeOptions","component","dataCount","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 { Button } 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 { Checkbox } from '../../shadcn/components/ui/checkbox';\nimport { MoreVertical, Loader2 } from 'lucide-react';\nimport { useButtonForm } from './button-form';\nimport { DownloadButton } from './download-data-button';\n\nfunction resolveRowContext(\n rowContext: Record<string, string> | undefined,\n row: Record<string, any>,\n): Record<string, any> | undefined {\n if (!rowContext || Object.keys(rowContext).length === 0) {\n return undefined;\n }\n\n const resolved: Record<string, any> = {};\n\n for (const [key, ref] of Object.entries(rowContext)) {\n if (typeof ref === 'string' && ref.startsWith('@')) {\n const fieldName = ref.includes('.') ? ref.split('.').slice(1).join('.') : ref.slice(1);\n resolved[key] = row[fieldName] ?? row[ref.slice(1)];\n } else {\n resolved[key] = ref;\n }\n }\n\n return resolved;\n}\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 sortable?: boolean;\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 navigateToPage?: (pageId: string, rowContext?: Record<string, any>) => void;\n isBulkSelectionEnabled?: boolean;\n selectedIndices?: number[];\n setSelectedIndices?: (indices: number[]) => void;\n title?: string;\n onDownload?: (limit: number) => Promise<void>;\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\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 sortable: sortableGlobal = true,\n otherProps = {},\n height,\n decimalPrecision = 2,\n columnWithChipClass = {},\n chipStylesMapping = {},\n navigateToPage,\n isBulkSelectionEnabled = false,\n selectedIndices = [],\n setSelectedIndices,\n title,\n onDownload,\n}: DataTableProps) {\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 const [loadingActionKey, setLoadingActionKey] = useState<string | null>(null);\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 [openDropdownIndex, setOpenDropdownIndex] = useState<number | null>(null);\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\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\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\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\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.action === 'navigateToPage' && action.action.targetPageId) {\n const rowContext = resolveRowContext(action.action.rowContext, data[rowIndex]);\n navigateToPage?.(action.action.targetPageId, rowContext);\n\n return;\n }\n\n if (action.action.type === 'navigation') {\n const onClick = action.action.onClick;\n\n if (onClick?.action === 'navigateToPage' && onClick.targetPageId) {\n const rowContext = resolveRowContext(action.action.rowContext, data[rowIndex]);\n navigateToPage?.(onClick.targetPageId, rowContext);\n\n return;\n }\n }\n\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 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 handleCheckboxClick(rowIndex: number) {\n if (setSelectedIndices) {\n if (selectedIndices.includes(rowIndex)) {\n setSelectedIndices(selectedIndices.filter((idx) => idx !== rowIndex));\n } else {\n setSelectedIndices([...selectedIndices, rowIndex]);\n }\n }\n }\n\n function ActionsDropdown({\n rowIndex,\n rowActions,\n }: {\n rowIndex: number;\n rowActions: RowAction[];\n }) {\n const isOpen = openDropdownIndex === rowIndex;\n\n const totalRows = rows.length;\n const isNearBottom = rowIndex >= totalRows - 3;\n\n async function handleActionClick(action: RowAction) {\n if (action.action.action === 'navigateToPage' && action.action.targetPageId) {\n const rowContext = resolveRowContext(action.action.rowContext, data[rowIndex]);\n navigateToPage?.(action.action.targetPageId, rowContext);\n setOpenDropdownIndex(null);\n\n return;\n }\n\n if (action.action.type === 'navigation') {\n const onClick = action.action.onClick;\n\n if (onClick?.action === 'navigateToPage' && onClick.targetPageId) {\n const rowContext = resolveRowContext(action.action.rowContext, data[rowIndex]);\n navigateToPage?.(onClick.targetPageId, rowContext);\n setOpenDropdownIndex(null);\n\n return;\n }\n }\n\n // Handle form-based and API actions\n const actionKey = `${rowIndex}-${action.id}`;\n\n if (action.action.formMapper && Object.keys(action.action.formMapper).length > 0) {\n setActiveRowIndex(rowIndex);\n setActiveAction(action);\n setOpenDropdownIndex(null);\n } else {\n try {\n setLoadingActionKey(actionKey);\n await onRowAction?.(rowIndex, action.id);\n } finally {\n setLoadingActionKey(null);\n setOpenDropdownIndex(null);\n }\n }\n }\n\n function toggleDropdown() {\n setOpenDropdownIndex(isOpen ? null : rowIndex);\n }\n\n function handleBackdropClick() {\n if (!loadingActionKey) {\n setOpenDropdownIndex(null);\n }\n }\n\n return (\n <>\n {isOpen && (\n <div\n className=\"fixed inset-0 z-40\"\n onClick={handleBackdropClick}\n style={{ background: 'transparent', cursor: 'default' }}\n />\n )}\n <div className=\"relative\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={(e) => {\n e.stopPropagation();\n toggleDropdown();\n }}\n disabled={isLoading}\n className=\"h-8 w-8 relative z-50\"\n data-dropdown-button=\"true\"\n >\n <MoreVertical className=\"h-4 w-4\" />\n </Button>\n {isOpen && (\n <div\n className={cn(\n 'absolute right-full mr-2 w-48 rounded-md shadow-lg bg-white ring-gray-400 ring-opacity-5 z-50',\n isNearBottom ? 'bottom-0' : 'top-0',\n )}\n >\n <div className=\"py-1\" role=\"menu\">\n {rowActions.map((action) => {\n const actionKey = `${rowIndex}-${action.id}`;\n const isActionLoading = loadingActionKey === actionKey;\n\n return (\n <button\n key={action.id}\n onClick={() => handleActionClick(action)}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-accent transition-colors font-semibold disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 focus:outline-none focus:bg-accent\"\n disabled={isLoading || isActionLoading}\n role=\"menuitem\"\n >\n {isActionLoading && <Loader2 className=\"h-3 w-3 animate-spin\" />}\n {action.text}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n </>\n );\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 overflow-visible\">\n <ActionsDropdown rowIndex={rowIndex} rowActions={rowActions} />\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 {isBulkSelectionEnabled && (\n <TableCell className=\"p-2 w-10\">\n <Checkbox\n checked={selectedIndices?.length === data.length}\n onCheckedChange={() => {\n if (setSelectedIndices) {\n if (selectedIndices?.length === data.length) {\n setSelectedIndices([]);\n } else {\n setSelectedIndices(data.map((_, idx) => idx));\n }\n }\n }}\n />\n </TableCell>\n )}\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={sortableGlobal && !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 {isBulkSelectionEnabled && (\n <TableCell className=\"p-2 align-middle\">\n <Checkbox\n checked={selectedIndices?.includes(rIdx)}\n onCheckedChange={() => handleCheckboxClick(rIdx)}\n />\n </TableCell>\n )}\n {row.map((cell: string, cIdx: number) => {\n const columnKey = originalKeys[cIdx];\n const chipMode = columnKey\n ? getChipMode(columnWithChipClass, columnKey)\n : 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\n ? renderChip(columnKey, cell)\n : 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?.totalCount ?? 0) > 0 || (title && !isEditable && onDownload)) && (\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 {pagination && pagination.totalCount > 0 && (\n <>\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 || [10, 20, 50, 100]).map((size: number) => (\n <option key={size} value={size}>\n {size}\n </option>\n ))}\n </select>\n </>\n )}\n </div>\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n {title && !isEditable && onDownload && (\n <DownloadButton\n component=\"table\"\n title={title}\n onDownload={onDownload}\n dataCount={pagination?.totalCount ?? data.length}\n />\n )}\n {pagination && pagination.totalCount > 0 && (\n <>\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 </>\n )}\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,MAAM,KAAQ,mCAAmC,CAC1D,OAASC,EAAE,KAAQ,oBAAoB,CACvC,OAASC,oBAAoB,KAAQ,SAAS,CAC9C,OAASC,WAAW,KAAQ,eAAe,CAC3C,OAASC,wBAAwB,CAAEC,yBAAyB,KAAQ,iBAAiB,CACrF,OAASC,QAAQ,KAAQ,qCAAqC,CAC9D,OAASC,YAAY,CAAEC,OAAO,KAAQ,cAAc,CACpD,OAASC,aAAa,KAAQ,eAAe,CAC7C,OAASC,cAAc,KAAQ,wBAAwB,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,CAAA9B,QAAA,IAAA+B,SAAA,yBAExD,QAAS,CAAAC,iBAAiBA,CACxBC,UAA8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BAAsB,CAACsI,UAAU,CAAEW,UAAU,CAAE3D,SAAS,CAAEgI,gBAAgB,CAAC,CAC3D,CAAC,CACV,CAAC,EACb,CACH,EACE,CAAC,EACH,CACN,CACAd,UAAU,EACH,CAEd","ignoreList":[]}
|
|
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","Button","cn","renderNoDataFallback","formatValue","SEMANTIC_CHIP_STYLES_MAP","RANDOM_CHIP_COLOR_PALETTE","Checkbox","MoreVertical","Loader2","useButtonForm","DownloadButton","jsx","_jsx","jsxs","_jsxs","_Fragment","resolveRowContext","rowContext","row","Object","keys","length","undefined","resolved","_i","_Object$entries","entries","_Object$entries$_i","key","ref","startsWith","_row$fieldName","fieldName","includes","split","slice","join","normalizeValue","value","str","String","trim","toLowerCase","getChipMode","columnWithChipClass","columnKey","mode","getUniqueValuesHash","data","Array","isArray","availableKeys","hashParts","forEach","chipMode","uniqueNormalizedValues","Set","normalizedKey","add","sortedUniqueValues","from","sort","JSON","stringify","DataTable","_ref","_ref2","_pagination$values$pa","_pagination$values","_ref3","_pagination$values$pa2","_pagination$values2","_pagination$totalCoun","_ref$data","_ref$headerMapper","headerMapper","_ref$className","className","_ref$actions","actions","_ref$isEditable","isEditable","pagination","_ref$isLoading","isLoading","onRowAction","onPageChange","onSort","sortConfig","_ref$sortable","sortable","sortableGlobal","_ref$otherProps","otherProps","height","_ref$decimalPrecision","decimalPrecision","_ref$columnWithChipCl","_ref$chipStylesMappin","chipStylesMapping","navigateToPage","_ref$isBulkSelectionE","isBulkSelectionEnabled","_ref$selectedIndices","selectedIndices","setSelectedIndices","title","onDownload","children","style","minHeight","_useState","activeSortColumn","setActiveSortColumn","_useState2","sortDirections","setSortDirections","_useState3","activeRowIndex","setActiveRowIndex","_useState4","activeAction","setActiveAction","_useState5","isFormSubmitting","setIsFormSubmitting","_useState6","loadingActionKey","setLoadingActionKey","_useState7","Number","values","pageNumber","initialPage","setPageNumber","_useState8","pageSize","initialPageSize","setPageSize","_useState9","Math","ceil","totalCount","totalPages","setTotalPages","_useState10","chipColorMap","setChipColorMap","_useState11","openDropdownIndex","setOpenDropdownIndex","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","targetPageId","type","onClick","originalKeys","filter","headers","map","push","rows","datum","handlePageChange","_x2","_x3","_handlePageChange","_callee3","newPage","newSize","_callee3$","_context3","handleSortClick","column","direction","_extends2","handleCheckboxClick","idx","concat","ActionsDropdown","_ref6","rowActions","isOpen","totalRows","isNearBottom","handleActionClick","_x4","_handleActionClick","_callee2","_rowContext2","actionKey","_callee2$","_context2","abrupt","toggleDropdown","handleBackdropClick","background","cursor","variant","size","e","stopPropagation","disabled","role","isActionLoading","text","renderActions","defaultClasses","mergedClasses","getRandomColorForValue","_chipColorMap$columnK","renderChip","formattedValue","chipClassName","_chipStylesMapping$co","valueStr","valueLower","renderTableComponent","checked","onCheckedChange","_","head","isActionColumn","originalKey","contentEditable","isActive","rIdx","cell","cIdx","shouldRenderChip","orientation","htmlFor","onChange","target","pageSizeOptions","component","dataCount","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 { Button } 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 { Checkbox } from '../../shadcn/components/ui/checkbox';\nimport { MoreVertical, Loader2 } from 'lucide-react';\nimport { useButtonForm } from './button-form';\nimport { DownloadButton } from './download-data-button';\n\nfunction resolveRowContext(\n rowContext: Record<string, string> | undefined,\n row: Record<string, any>,\n): Record<string, any> | undefined {\n if (!rowContext || Object.keys(rowContext).length === 0) {\n return undefined;\n }\n\n const resolved: Record<string, any> = {};\n\n for (const [key, ref] of Object.entries(rowContext)) {\n if (typeof ref === 'string' && ref.startsWith('@')) {\n const fieldName = ref.includes('.') ? ref.split('.').slice(1).join('.') : ref.slice(1);\n resolved[key] = row[fieldName] ?? row[ref.slice(1)];\n } else {\n resolved[key] = ref;\n }\n }\n\n return resolved;\n}\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 sortable?: boolean;\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 navigateToPage?: (pageId: string, rowContext?: Record<string, any>) => void;\n isBulkSelectionEnabled?: boolean;\n selectedIndices?: number[];\n setSelectedIndices?: (indices: number[]) => void;\n title?: string;\n onDownload?: (limit: number) => Promise<void>;\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\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 sortable: sortableGlobal = true,\n otherProps = {},\n height,\n decimalPrecision = 2,\n columnWithChipClass = {},\n chipStylesMapping = {},\n navigateToPage,\n isBulkSelectionEnabled = false,\n selectedIndices = [],\n setSelectedIndices,\n title,\n onDownload,\n}: DataTableProps) {\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 const [loadingActionKey, setLoadingActionKey] = useState<string | null>(null);\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 [openDropdownIndex, setOpenDropdownIndex] = useState<number | null>(null);\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\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\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\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\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.action === 'navigateToPage' && action.action.targetPageId) {\n const rowContext = resolveRowContext(action.action.rowContext, data[rowIndex]);\n navigateToPage?.(action.action.targetPageId, rowContext);\n\n return;\n }\n\n if (action.action.type === 'navigation') {\n const onClick = action.action.onClick;\n\n if (onClick?.action === 'navigateToPage' && onClick.targetPageId) {\n const rowContext = resolveRowContext(action.action.rowContext, data[rowIndex]);\n navigateToPage?.(onClick.targetPageId, rowContext);\n\n return;\n }\n }\n\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 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 handleCheckboxClick(rowIndex: number) {\n if (setSelectedIndices) {\n if (selectedIndices.includes(rowIndex)) {\n setSelectedIndices(selectedIndices.filter((idx) => idx !== rowIndex));\n } else {\n setSelectedIndices([...selectedIndices, rowIndex]);\n }\n }\n }\n\n function ActionsDropdown({\n rowIndex,\n rowActions,\n }: {\n rowIndex: number;\n rowActions: RowAction[];\n }) {\n const isOpen = openDropdownIndex === rowIndex;\n\n const totalRows = rows.length;\n const isNearBottom = rowIndex >= totalRows - 3;\n\n async function handleActionClick(action: RowAction) {\n if (action.action.action === 'navigateToPage' && action.action.targetPageId) {\n const rowContext = resolveRowContext(action.action.rowContext, data[rowIndex]);\n navigateToPage?.(action.action.targetPageId, rowContext);\n setOpenDropdownIndex(null);\n\n return;\n }\n\n if (action.action.type === 'navigation') {\n const onClick = action.action.onClick;\n\n if (onClick?.action === 'navigateToPage' && onClick.targetPageId) {\n const rowContext = resolveRowContext(action.action.rowContext, data[rowIndex]);\n navigateToPage?.(onClick.targetPageId, rowContext);\n setOpenDropdownIndex(null);\n\n return;\n }\n }\n\n // Handle form-based and API actions\n const actionKey = `${rowIndex}-${action.id}`;\n\n if (action.action.formMapper && Object.keys(action.action.formMapper).length > 0) {\n setActiveRowIndex(rowIndex);\n setActiveAction(action);\n setOpenDropdownIndex(null);\n } else {\n try {\n setLoadingActionKey(actionKey);\n await onRowAction?.(rowIndex, action.id);\n } finally {\n setLoadingActionKey(null);\n setOpenDropdownIndex(null);\n }\n }\n }\n\n function toggleDropdown() {\n setOpenDropdownIndex(isOpen ? null : rowIndex);\n }\n\n function handleBackdropClick() {\n if (!loadingActionKey) {\n setOpenDropdownIndex(null);\n }\n }\n\n return (\n <>\n {isOpen && (\n <div\n className=\"fixed inset-0 z-40\"\n onClick={handleBackdropClick}\n style={{ background: 'transparent', cursor: 'default' }}\n />\n )}\n <div className=\"relative\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={(e) => {\n e.stopPropagation();\n toggleDropdown();\n }}\n disabled={isLoading}\n className=\"h-8 w-8 relative z-50\"\n data-dropdown-button=\"true\"\n >\n <MoreVertical className=\"h-4 w-4\" />\n </Button>\n {isOpen && (\n <div\n className={cn(\n 'absolute right-full mr-2 w-48 rounded-md shadow-lg bg-white ring-gray-400 ring-opacity-5 z-50',\n isNearBottom ? 'bottom-0' : 'top-0',\n )}\n >\n <div className=\"py-1\" role=\"menu\">\n {rowActions.map((action) => {\n const actionKey = `${rowIndex}-${action.id}`;\n const isActionLoading = loadingActionKey === actionKey;\n\n return (\n <button\n key={action.id}\n onClick={() => handleActionClick(action)}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-accent transition-colors font-semibold disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 focus:outline-none focus:bg-accent\"\n disabled={isLoading || isActionLoading}\n role=\"menuitem\"\n >\n {isActionLoading && <Loader2 className=\"h-3 w-3 animate-spin\" />}\n {action.text}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n </>\n );\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 overflow-visible\">\n <ActionsDropdown rowIndex={rowIndex} rowActions={rowActions} />\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 {isBulkSelectionEnabled && (\n <TableCell className=\"p-2 w-10\">\n <Checkbox\n checked={selectedIndices?.length === data.length}\n onCheckedChange={() => {\n if (setSelectedIndices) {\n if (selectedIndices?.length === data.length) {\n setSelectedIndices([]);\n } else {\n setSelectedIndices(data.map((_, idx) => idx));\n }\n }\n }}\n />\n </TableCell>\n )}\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={sortableGlobal && !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 {isBulkSelectionEnabled && (\n <TableCell className=\"p-2 align-middle\">\n <Checkbox\n checked={selectedIndices?.includes(rIdx)}\n onCheckedChange={() => handleCheckboxClick(rIdx)}\n />\n </TableCell>\n )}\n {row.map((cell: string, cIdx: number) => {\n const columnKey = originalKeys[cIdx];\n const chipMode = columnKey\n ? getChipMode(columnWithChipClass, columnKey)\n : 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\n ? renderChip(columnKey, cell)\n : 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?.totalCount ?? 0) > 0 || (title && !isEditable && onDownload)) && (\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 {pagination && pagination.totalCount > 0 && (\n <>\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 || [10, 20, 50, 100]).map((size: number) => (\n <option key={size} value={size}>\n {size}\n </option>\n ))}\n </select>\n </>\n )}\n </div>\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n {title && !isEditable && onDownload && (\n <DownloadButton\n component=\"table\"\n title={title}\n onDownload={onDownload}\n dataCount={typeof pagination?.totalCount === 'number' ? pagination.totalCount : data.length}\n />\n )}\n {pagination && pagination.totalCount > 0 && (\n <>\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 </>\n )}\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,MAAM,KA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G,CAAC,eACtChI,KAAA,CAAAC,SAAA,EAAA6F,QAAA,eACE9F,KAAA,SAAM+D,SAAS,CAAC,wDAAwD,CAAA+B,QAAA,EACrE,CAACwB,UAAU,CAAG,CAAC,EAAII,QAAQ,CAAG,CAAC,CAAC,QACjC,CAACI,IAAI,CAACkJ,GAAG,CAAC1J,UAAU,CAAGI,QAAQ,CAAEtD,UAAU,CAAC4D,UAAU,CAAC,CAAC,MAAI,CAAC5D,UAAU,CAAC4D,UAAU,EAC9E,CAAC,cACPlI,IAAA,CAACf,UAAU,EAAA+G,QAAA,cACThG,IAAA,CAACd,iBAAiB,EAAC+E,SAAS,CAAC,uBAAuB,CAAA+B,QAAA,CACjD7G,sBAAsB,CAACqI,UAAU,CAAEW,UAAU,CAAE3D,SAAS,CAAEgI,gBAAgB,CAAC,CAC3D,CAAC,CACV,CAAC,EACb,CACH,EACE,CAAC,EACH,CACN,CACAd,UAAU,EACH,CAEd","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";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}import{useState}from"react";import{Button}from"../../shadcn/components/ui/button";import{Download,Loader2}from"lucide-react";import{Dialog,DialogContent,DialogDescription,DialogFooter,DialogHeader,DialogTitle}from"../../shadcn/components/ui/dialog";import{RadioOption}from"../../shadcn/components/ui/styled-elements";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";function getLegendItems(container){var legendItems=[];var legendWrapper=container.querySelector("[class*=\"recharts-legend-wrapper\"]");if(!legendWrapper)return legendItems;legendWrapper.querySelectorAll("[class*=\"recharts-legend-item\"]").forEach(function(item){var _item$textContent;var text=(_item$textContent=item.textContent)==null?void 0:_item$textContent.trim();var color="#666666";var colorElements=item.querySelectorAll("path, rect, circle, line");for(var _i=0,_Array$from=Array.from(colorElements);_i<_Array$from.length;_i++){var elem=_Array$from[_i];var computedStyle=window.getComputedStyle(elem);var computedFill=computedStyle.fill;var computedStroke=computedStyle.stroke;if(computedFill&&computedFill!=="none"&&computedFill!=="transparent"&&computedFill!=="rgb(0, 0, 0)"){color=computedFill;break}if(computedStroke&&computedStroke!=="none"&&computedStroke!=="transparent"&&computedStroke!=="rgb(0, 0, 0)"){color=computedStroke;break}var fill=elem.getAttribute("fill");var stroke=elem.getAttribute("stroke");if(fill&&fill!=="none"&&fill!=="transparent"){color=fill;break}if(stroke&&stroke!=="none"&&stroke!=="transparent"){color=stroke;break}}if(text&&!legendItems.some(function(existing){return existing.text===text})){legendItems.push({text:text,color:color})}});return legendItems}var SVG_INLINE_PROPS=["fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","font-size","font-family","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","opacity","visibility"];function inlineSvgStyles(original,clone){var computed=window.getComputedStyle(original);var style="";for(var _iterator=_createForOfIteratorHelperLoose(SVG_INLINE_PROPS),_step;!(_step=_iterator()).done;){var prop=_step.value;var val=computed.getPropertyValue(prop);if(val)style+=prop+":"+val+";"}clone.setAttribute("style",style);for(var i=0;i<original.children.length;i++){inlineSvgStyles(original.children[i],clone.children[i])}}function escapeXml(str){return str.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function getSvgDimensions(svgElement){var width=parseFloat(svgElement.getAttribute("width")||"0")||svgElement.scrollWidth||800;var height=parseFloat(svgElement.getAttribute("height")||"0")||svgElement.scrollHeight||400;return{width:width,height:height}}function buildCompositeSvg(svgElement,title,subtitle,legendItems,inlineStyles){var cloned=svgElement.cloneNode(true);if(inlineStyles)inlineSvgStyles(svgElement,cloned);var _getSvgDimensions=getSvgDimensions(svgElement),chartWidth=_getSvgDimensions.width,chartHeight=_getSvgDimensions.height;var padding=20;var titleHeight=28;var subtitleHeight=subtitle?36:0;var legendHeight=legendItems.length>0?30:0;var headerHeight=padding+titleHeight+subtitleHeight;var totalWidth=chartWidth+padding*2;var totalHeight=chartHeight+headerHeight+legendHeight+padding;var serializer=new XMLSerializer;cloned.setAttribute("x",String(padding));cloned.setAttribute("y",String(headerHeight));cloned.setAttribute("overflow","visible");return"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\""+totalWidth+"\" height=\""+totalHeight+"\">\n <rect width=\""+totalWidth+"\" height=\""+totalHeight+"\" fill=\"white\"/>\n <text x=\""+padding+"\" y=\""+(padding+20)+"\" font-family=\"Arial,sans-serif\" font-size=\"18\" font-weight=\"600\" fill=\"#000000\">"+escapeXml(title)+"</text>\n "+(subtitle?"<text x=\""+padding+"\" y=\""+(padding+44)+"\" font-family=\"Arial,sans-serif\" font-size=\"14\" fill=\"#666666\">"+escapeXml(subtitle)+"</text>":"")+"\n "+serializer.serializeToString(cloned)+"\n "+(legendItems.length>0?"<g transform=\"translate("+padding+", "+(totalHeight-25)+")\">\n "+legendItems.map(function(item,index){var x=index*200;return"<rect x=\""+x+"\" y=\"0\" width=\"12\" height=\"12\" fill=\""+item.color+"\"/>"+("<text x=\""+(x+18)+"\" y=\"10\" font-family=\"Arial,sans-serif\" font-size=\"12\" fill=\"#666666\">"+escapeXml(item.text)+"</text>")}).join("")+"\n </g>":"")+"\n </svg>"}function downloadChartSVG(title,containerRef,subtitle){if(!containerRef.current)return;var svgElement=containerRef.current.querySelector("svg");if(!svgElement)return;var legendItems=getLegendItems(containerRef.current);var compositeSvg=buildCompositeSvg(svgElement,title,subtitle,legendItems,false);var blob=new Blob([compositeSvg],{type:"image/svg+xml;charset=utf-8"});var url=URL.createObjectURL(blob);var link=document.createElement("a");link.href=url;link.download=title.replace(/\s+/g,"_")+".svg";link.click();URL.revokeObjectURL(url)}function downloadChartPNG(_x,_x2,_x3){return _downloadChartPNG.apply(this,arguments)}function _downloadChartPNG(){_downloadChartPNG=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(title,containerRef,subtitle){var svgElement,legendItems,compositeSvg,_getSvgDimensions2,chartWidth,chartHeight,padding,subtitleHeight,legendHeight,totalWidth,totalHeight;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(containerRef.current){_context3.next=2;break}return _context3.abrupt("return");case 2:svgElement=containerRef.current.querySelector("svg");if(svgElement){_context3.next=5;break}return _context3.abrupt("return");case 5:legendItems=getLegendItems(containerRef.current);compositeSvg=buildCompositeSvg(svgElement,title,subtitle,legendItems,true);_getSvgDimensions2=getSvgDimensions(svgElement),chartWidth=_getSvgDimensions2.width,chartHeight=_getSvgDimensions2.height;padding=20;subtitleHeight=subtitle?36:0;legendHeight=legendItems.length>0?30:0;totalWidth=chartWidth+padding*2;totalHeight=chartHeight+padding+28+subtitleHeight+legendHeight+padding;return _context3.abrupt("return",new Promise(function(resolve,reject){var img=new Image;var blob=new Blob([compositeSvg],{type:"image/svg+xml;charset=utf-8"});var url=URL.createObjectURL(blob);img.onload=function(){var scale=2;var canvas=document.createElement("canvas");canvas.width=totalWidth*scale;canvas.height=totalHeight*scale;var ctx=canvas.getContext("2d");ctx.scale(scale,scale);ctx.fillStyle="white";ctx.fillRect(0,0,totalWidth,totalHeight);ctx.drawImage(img,0,0,totalWidth,totalHeight);URL.revokeObjectURL(url);var link=document.createElement("a");link.download=title.replace(/\s+/g,"_")+".png";link.href=canvas.toDataURL("image/png");link.click();resolve()};img.onerror=function(){URL.revokeObjectURL(url);reject(new Error("SVG render failed"))};img.src=url}));case 14:case"end":return _context3.stop()}},_callee3)}));return _downloadChartPNG.apply(this,arguments)}var ROW_LIMITS=[100,500,1000];export function DownloadButton(_ref){var _ref$component=_ref.component,component=_ref$component===void 0?"chart":_ref$component,containerRef=_ref.containerRef,title=_ref.title,subtitle=_ref.subtitle,onDownload=_ref.onDownload,onDownloadCSV=_ref.onDownloadCSV,dataCount=_ref.dataCount;var defaultRowCount=dataCount!==undefined&&dataCount<100?"all":100;var _useState=useState(false),isModalOpen=_useState[0],setIsModalOpen=_useState[1];var _useState2=useState("svg"),selectedFormat=_useState2[0],setSelectedFormat=_useState2[1];var _useState3=useState(defaultRowCount),selectedRowCount=_useState3[0],setSelectedRowCount=_useState3[1];var _useState4=useState(false),isDownloading=_useState4[0],setIsDownloading=_useState4[1];var rowOptions=[].concat(ROW_LIMITS.filter(function(limit){return dataCount===undefined||dataCount>limit}).map(function(limit){return{value:limit,label:limit+" rows"}}),[{value:"all",label:dataCount!==undefined&&dataCount<=10000?"All ("+dataCount+" rows)":"All (max 10,000 rows)"}]);var handleChartDownload=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!(selectedFormat==="csv")){_context.next=10;break}setIsDownloading(true);_context.prev=2;_context.next=5;return onDownloadCSV==null?void 0:onDownloadCSV();case 5:_context.prev=5;setIsDownloading(false);return _context.finish(5);case 8:_context.next=21;break;case 10:if(!(selectedFormat==="png")){_context.next=20;break}setIsDownloading(true);_context.prev=12;_context.next=15;return downloadChartPNG(title,containerRef,subtitle);case 15:_context.prev=15;setIsDownloading(false);return _context.finish(15);case 18:_context.next=21;break;case 20:downloadChartSVG(title,containerRef,subtitle);case 21:setIsModalOpen(false);case 22:case"end":return _context.stop()}},_callee,null,[[2,,5,8],[12,,15,18]])}));return function handleChartDownload(){return _ref2.apply(this,arguments)}}();var handleTableDownload=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){var limit;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:limit=selectedRowCount==="all"?10000:selectedRowCount;setIsDownloading(true);_context2.prev=2;_context2.next=5;return onDownload==null?void 0:onDownload(limit);case 5:_context2.prev=5;setIsDownloading(false);return _context2.finish(5);case 8:setIsModalOpen(false);case 9:case"end":return _context2.stop()}},_callee2,null,[[2,,5,8]])}));return function handleTableDownload(){return _ref3.apply(this,arguments)}}();var handleCancel=function handleCancel(){setIsModalOpen(false);if(component==="chart"){setSelectedFormat("svg")}else{setSelectedRowCount(defaultRowCount)}};if(component==="table"){return/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Button,{variant:"outline",size:"sm",className:"h-8 w-8 bg-white text-muted-foreground border-none hover:text-black transition-all flex items-center justify-center",title:"Download table as CSV",onClick:function onClick(){setSelectedRowCount(defaultRowCount);setIsModalOpen(true)},children:/*#__PURE__*/_jsx(Download,{className:"h-3 w-3"})}),/*#__PURE__*/_jsx(Dialog,{open:isModalOpen,onOpenChange:setIsModalOpen,children:/*#__PURE__*/_jsxs(DialogContent,{children:[/*#__PURE__*/_jsxs(DialogHeader,{children:[/*#__PURE__*/_jsx(DialogTitle,{children:"Download Table"}),/*#__PURE__*/_jsx(DialogDescription,{children:"Max 10,000 rows can be downloaded at a time."})]}),/*#__PURE__*/_jsxs("div",{className:"py-4 flex items-center gap-3",children:[/*#__PURE__*/_jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Number of rows to download"}),/*#__PURE__*/_jsx("select",{value:String(selectedRowCount),onChange:function onChange(e){var val=e.target.value;setSelectedRowCount(val==="all"?"all":Number(val))},className:"border border-gray-200 rounded-md px-3 py-2 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-[#2A44D4] cursor-pointer",children:rowOptions.map(function(opt){return/*#__PURE__*/_jsx("option",{value:String(opt.value),children:opt.label},String(opt.value))})})]}),/*#__PURE__*/_jsx(DialogFooter,{className:"mt-6 block",children:/*#__PURE__*/_jsxs("div",{className:"flex items-center justify-end gap-2",children:[/*#__PURE__*/_jsx(Button,{type:"button",variant:"outline",onClick:handleCancel,disabled:isDownloading,className:"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]",children:"Cancel"}),/*#__PURE__*/_jsx(Button,{type:"button",variant:"default",onClick:handleTableDownload,disabled:isDownloading,className:"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white disabled:opacity-70",children:isDownloading?/*#__PURE__*/_jsx(Loader2,{className:"h-4 w-4 animate-spin"}):"Download"})]})})]})})]})}return/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Button,{variant:"outline",size:"sm",className:"h-8 w-8 bg-white text-muted-foreground border-none hover:text-black transition-all flex items-center justify-center",title:"Download chart",onClick:function onClick(){return setIsModalOpen(true)},children:/*#__PURE__*/_jsx(Download,{className:"h-3 w-3"})}),/*#__PURE__*/_jsx(Dialog,{open:isModalOpen,onOpenChange:setIsModalOpen,children:/*#__PURE__*/_jsxs(DialogContent,{children:[/*#__PURE__*/_jsxs(DialogHeader,{children:[/*#__PURE__*/_jsx(DialogTitle,{children:"Download Chart"}),/*#__PURE__*/_jsx(DialogDescription,{children:"Choose the format you'd like to download the chart in."})]}),/*#__PURE__*/_jsxs("div",{className:"space-y-3 py-4",children:[/*#__PURE__*/_jsx(RadioOption,{label:"SVG",selected:selectedFormat==="svg",onClick:function onClick(){return setSelectedFormat("svg")}}),/*#__PURE__*/_jsx(RadioOption,{label:"PNG",selected:selectedFormat==="png",onClick:function onClick(){return setSelectedFormat("png")}}),onDownloadCSV&&/*#__PURE__*/_jsx(RadioOption,{label:"CSV",selected:selectedFormat==="csv",onClick:function onClick(){return setSelectedFormat("csv")}})]}),/*#__PURE__*/_jsx(DialogFooter,{className:"mt-6 block",children:/*#__PURE__*/_jsxs("div",{className:"flex items-center justify-end gap-2",children:[/*#__PURE__*/_jsx(Button,{type:"button",variant:"outline",onClick:handleCancel,disabled:isDownloading,className:"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]",children:"Cancel"}),/*#__PURE__*/_jsx(Button,{type:"button",variant:"default",onClick:handleChartDownload,disabled:isDownloading,className:"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white disabled:opacity-70",children:isDownloading?/*#__PURE__*/_jsx(Loader2,{className:"h-4 w-4 animate-spin"}):"Download"})]})})]})})]})}
|
|
1
|
+
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";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}import{useState}from"react";import{Button}from"../../shadcn/components/ui/button";import{Download,Loader2}from"lucide-react";import{Dialog,DialogContent,DialogDescription,DialogFooter,DialogHeader,DialogTitle}from"../../shadcn/components/ui/dialog";import{RadioOption}from"../../shadcn/components/ui/styled-elements";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";function getLegendItems(container){var legendItems=[];var legendWrapper=container.querySelector("[class*=\"recharts-legend-wrapper\"]");if(!legendWrapper)return legendItems;legendWrapper.querySelectorAll("[class*=\"recharts-legend-item\"]").forEach(function(item){var _item$textContent;var text=(_item$textContent=item.textContent)==null?void 0:_item$textContent.trim();var color="#666666";var colorElements=item.querySelectorAll("path, rect, circle, line");for(var _i=0,_Array$from=Array.from(colorElements);_i<_Array$from.length;_i++){var elem=_Array$from[_i];var computedStyle=window.getComputedStyle(elem);var computedFill=computedStyle.fill;var computedStroke=computedStyle.stroke;if(computedFill&&computedFill!=="none"&&computedFill!=="transparent"&&computedFill!=="rgb(0, 0, 0)"){color=computedFill;break}if(computedStroke&&computedStroke!=="none"&&computedStroke!=="transparent"&&computedStroke!=="rgb(0, 0, 0)"){color=computedStroke;break}var fill=elem.getAttribute("fill");var stroke=elem.getAttribute("stroke");if(fill&&fill!=="none"&&fill!=="transparent"){color=fill;break}if(stroke&&stroke!=="none"&&stroke!=="transparent"){color=stroke;break}}if(text&&!legendItems.some(function(existing){return existing.text===text})){legendItems.push({text:text,color:color})}});return legendItems}var SVG_INLINE_PROPS=["fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","font-size","font-family","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","opacity","visibility"];function inlineSvgStyles(original,clone){var computed=window.getComputedStyle(original);var style="";for(var _iterator=_createForOfIteratorHelperLoose(SVG_INLINE_PROPS),_step;!(_step=_iterator()).done;){var prop=_step.value;var val=computed.getPropertyValue(prop);if(val)style+=prop+":"+val+";"}clone.setAttribute("style",style);for(var i=0;i<original.children.length;i++){inlineSvgStyles(original.children[i],clone.children[i])}}function escapeXml(str){return str.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function getSvgDimensions(svgElement){var width=parseFloat(svgElement.getAttribute("width")||"0")||svgElement.scrollWidth||800;var height=parseFloat(svgElement.getAttribute("height")||"0")||svgElement.scrollHeight||400;return{width:width,height:height}}function buildCompositeSvg(svgElement,title,subtitle,legendItems,inlineStyles){var cloned=svgElement.cloneNode(true);if(inlineStyles)inlineSvgStyles(svgElement,cloned);var _getSvgDimensions=getSvgDimensions(svgElement),chartWidth=_getSvgDimensions.width,chartHeight=_getSvgDimensions.height;var padding=20;var titleHeight=28;var subtitleHeight=subtitle?36:0;var legendHeight=legendItems.length>0?30:0;var headerHeight=padding+titleHeight+subtitleHeight;var totalWidth=chartWidth+padding*2;var totalHeight=chartHeight+headerHeight+legendHeight+padding;var serializer=new XMLSerializer;cloned.setAttribute("x",String(padding));cloned.setAttribute("y",String(headerHeight));cloned.setAttribute("overflow","visible");return"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\""+totalWidth+"\" height=\""+totalHeight+"\">\n <rect width=\""+totalWidth+"\" height=\""+totalHeight+"\" fill=\"white\"/>\n <text x=\""+padding+"\" y=\""+(padding+20)+"\" font-family=\"Arial,sans-serif\" font-size=\"18\" font-weight=\"600\" fill=\"#000000\">"+escapeXml(title)+"</text>\n "+(subtitle?"<text x=\""+padding+"\" y=\""+(padding+44)+"\" font-family=\"Arial,sans-serif\" font-size=\"14\" fill=\"#666666\">"+escapeXml(subtitle)+"</text>":"")+"\n "+serializer.serializeToString(cloned)+"\n "+(legendItems.length>0?"<g transform=\"translate("+padding+", "+(totalHeight-25)+")\">\n "+legendItems.map(function(item,index){var x=index*200;return"<rect x=\""+x+"\" y=\"0\" width=\"12\" height=\"12\" fill=\""+item.color+"\"/>"+("<text x=\""+(x+18)+"\" y=\"10\" font-family=\"Arial,sans-serif\" font-size=\"12\" fill=\"#666666\">"+escapeXml(item.text)+"</text>")}).join("")+"\n </g>":"")+"\n </svg>"}function downloadChartSVG(title,containerRef,subtitle){if(!containerRef.current)return;var svgElement=containerRef.current.querySelector("svg");if(!svgElement)return;var legendItems=getLegendItems(containerRef.current);var compositeSvg=buildCompositeSvg(svgElement,title,subtitle,legendItems,false);var blob=new Blob([compositeSvg],{type:"image/svg+xml;charset=utf-8"});var url=URL.createObjectURL(blob);var link=document.createElement("a");link.href=url;link.download=title.replace(/\s+/g,"_")+".svg";link.click();URL.revokeObjectURL(url)}function downloadChartPNG(_x,_x2,_x3){return _downloadChartPNG.apply(this,arguments)}function _downloadChartPNG(){_downloadChartPNG=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(title,containerRef,subtitle){var svgElement,legendItems,compositeSvg,_getSvgDimensions2,chartWidth,chartHeight,padding,subtitleHeight,legendHeight,totalWidth,totalHeight;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(containerRef.current){_context3.next=2;break}return _context3.abrupt("return");case 2:svgElement=containerRef.current.querySelector("svg");if(svgElement){_context3.next=5;break}return _context3.abrupt("return");case 5:legendItems=getLegendItems(containerRef.current);compositeSvg=buildCompositeSvg(svgElement,title,subtitle,legendItems,true);_getSvgDimensions2=getSvgDimensions(svgElement),chartWidth=_getSvgDimensions2.width,chartHeight=_getSvgDimensions2.height;padding=20;subtitleHeight=subtitle?36:0;legendHeight=legendItems.length>0?30:0;totalWidth=chartWidth+padding*2;totalHeight=chartHeight+padding+28+subtitleHeight+legendHeight+padding;return _context3.abrupt("return",new Promise(function(resolve,reject){var img=new Image;var blob=new Blob([compositeSvg],{type:"image/svg+xml;charset=utf-8"});var url=URL.createObjectURL(blob);img.onload=function(){var scale=2;var canvas=document.createElement("canvas");canvas.width=totalWidth*scale;canvas.height=totalHeight*scale;var ctx=canvas.getContext("2d");ctx.scale(scale,scale);ctx.fillStyle="white";ctx.fillRect(0,0,totalWidth,totalHeight);ctx.drawImage(img,0,0,totalWidth,totalHeight);URL.revokeObjectURL(url);var link=document.createElement("a");link.download=title.replace(/\s+/g,"_")+".png";link.href=canvas.toDataURL("image/png");link.click();resolve()};img.onerror=function(){URL.revokeObjectURL(url);reject(new Error("SVG render failed"))};img.src=url}));case 14:case"end":return _context3.stop()}},_callee3)}));return _downloadChartPNG.apply(this,arguments)}var ROW_LIMITS=[100,500,1000];export function DownloadButton(_ref){var _ref$component=_ref.component,component=_ref$component===void 0?"chart":_ref$component,containerRef=_ref.containerRef,title=_ref.title,subtitle=_ref.subtitle,onDownload=_ref.onDownload,onDownloadCSV=_ref.onDownloadCSV,dataCount=_ref.dataCount;var defaultRowCount=dataCount!==undefined&&dataCount<100?"all":100;var _useState=useState(false),isModalOpen=_useState[0],setIsModalOpen=_useState[1];var _useState2=useState("svg"),selectedFormat=_useState2[0],setSelectedFormat=_useState2[1];var _useState3=useState(defaultRowCount),selectedRowCount=_useState3[0],setSelectedRowCount=_useState3[1];var _useState4=useState(false),isDownloading=_useState4[0],setIsDownloading=_useState4[1];var rowOptions=[].concat(ROW_LIMITS.filter(function(limit){return dataCount===undefined||dataCount>limit}).map(function(limit){return{value:limit,label:limit+" rows"}}),[{value:"all",label:dataCount!==undefined&&dataCount<=10000?"All ("+dataCount+" rows)":"All (max 10,000 rows)"}]);var handleChartDownload=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!(selectedFormat==="csv")){_context.next=10;break}setIsDownloading(true);_context.prev=2;_context.next=5;return onDownloadCSV==null?void 0:onDownloadCSV();case 5:_context.prev=5;setIsDownloading(false);return _context.finish(5);case 8:_context.next=21;break;case 10:if(!(selectedFormat==="png")){_context.next=20;break}setIsDownloading(true);_context.prev=12;_context.next=15;return downloadChartPNG(title,containerRef,subtitle);case 15:_context.prev=15;setIsDownloading(false);return _context.finish(15);case 18:_context.next=21;break;case 20:downloadChartSVG(title,containerRef,subtitle);case 21:setIsModalOpen(false);case 22:case"end":return _context.stop()}},_callee,null,[[2,,5,8],[12,,15,18]])}));return function handleChartDownload(){return _ref2.apply(this,arguments)}}();var handleTableDownload=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){var limit;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:limit=selectedRowCount==="all"?typeof dataCount==="number"&&dataCount<10000?dataCount:10000:selectedRowCount;setIsDownloading(true);_context2.prev=2;_context2.next=5;return onDownload==null?void 0:onDownload(limit);case 5:_context2.prev=5;setIsDownloading(false);return _context2.finish(5);case 8:setIsModalOpen(false);case 9:case"end":return _context2.stop()}},_callee2,null,[[2,,5,8]])}));return function handleTableDownload(){return _ref3.apply(this,arguments)}}();var handleCancel=function handleCancel(){setIsModalOpen(false);if(component==="chart"){setSelectedFormat("svg")}else{setSelectedRowCount(defaultRowCount)}};if(component==="table"){return/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Button,{variant:"outline",size:"sm",className:"h-8 w-8 bg-white text-muted-foreground border-none hover:text-black transition-all flex items-center justify-center",title:"Download table as CSV",onClick:function onClick(){setSelectedRowCount(defaultRowCount);setIsModalOpen(true)},children:/*#__PURE__*/_jsx(Download,{className:"h-3 w-3"})}),/*#__PURE__*/_jsx(Dialog,{open:isModalOpen,onOpenChange:setIsModalOpen,children:/*#__PURE__*/_jsxs(DialogContent,{children:[/*#__PURE__*/_jsxs(DialogHeader,{children:[/*#__PURE__*/_jsx(DialogTitle,{children:"Download Table"}),/*#__PURE__*/_jsx(DialogDescription,{children:"Max 10,000 rows can be downloaded at a time."})]}),/*#__PURE__*/_jsxs("div",{className:"py-4 flex items-center gap-3",children:[/*#__PURE__*/_jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Number of rows to download"}),/*#__PURE__*/_jsx("select",{value:String(selectedRowCount),onChange:function onChange(e){var val=e.target.value;setSelectedRowCount(val==="all"?"all":Number(val))},className:"border border-gray-200 rounded-md px-3 py-2 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-[#2A44D4] cursor-pointer",children:rowOptions.map(function(opt){return/*#__PURE__*/_jsx("option",{value:String(opt.value),children:opt.label},String(opt.value))})})]}),/*#__PURE__*/_jsx(DialogFooter,{className:"mt-6 block",children:/*#__PURE__*/_jsxs("div",{className:"flex items-center justify-end gap-2",children:[/*#__PURE__*/_jsx(Button,{type:"button",variant:"outline",onClick:handleCancel,disabled:isDownloading,className:"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]",children:"Cancel"}),/*#__PURE__*/_jsx(Button,{type:"button",variant:"default",onClick:handleTableDownload,disabled:isDownloading,className:"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white disabled:opacity-70",children:isDownloading?/*#__PURE__*/_jsx(Loader2,{className:"h-4 w-4 animate-spin"}):"Download"})]})})]})})]})}return/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Button,{variant:"outline",size:"sm",className:"h-8 w-8 bg-white text-muted-foreground border-none hover:text-black transition-all flex items-center justify-center",title:"Download chart",onClick:function onClick(){return setIsModalOpen(true)},children:/*#__PURE__*/_jsx(Download,{className:"h-3 w-3"})}),/*#__PURE__*/_jsx(Dialog,{open:isModalOpen,onOpenChange:setIsModalOpen,children:/*#__PURE__*/_jsxs(DialogContent,{children:[/*#__PURE__*/_jsxs(DialogHeader,{children:[/*#__PURE__*/_jsx(DialogTitle,{children:"Download Chart"}),/*#__PURE__*/_jsx(DialogDescription,{children:"Choose the format you'd like to download the chart in."})]}),/*#__PURE__*/_jsxs("div",{className:"space-y-3 py-4",children:[/*#__PURE__*/_jsx(RadioOption,{label:"SVG",selected:selectedFormat==="svg",onClick:function onClick(){return setSelectedFormat("svg")}}),/*#__PURE__*/_jsx(RadioOption,{label:"PNG",selected:selectedFormat==="png",onClick:function onClick(){return setSelectedFormat("png")}}),onDownloadCSV&&/*#__PURE__*/_jsx(RadioOption,{label:"CSV",selected:selectedFormat==="csv",onClick:function onClick(){return setSelectedFormat("csv")}})]}),/*#__PURE__*/_jsx(DialogFooter,{className:"mt-6 block",children:/*#__PURE__*/_jsxs("div",{className:"flex items-center justify-end gap-2",children:[/*#__PURE__*/_jsx(Button,{type:"button",variant:"outline",onClick:handleCancel,disabled:isDownloading,className:"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]",children:"Cancel"}),/*#__PURE__*/_jsx(Button,{type:"button",variant:"default",onClick:handleChartDownload,disabled:isDownloading,className:"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white disabled:opacity-70",children:isDownloading?/*#__PURE__*/_jsx(Loader2,{className:"h-4 w-4 animate-spin"}):"Download"})]})})]})})]})}
|
|
2
2
|
//# sourceMappingURL=download-data-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-data-button.js","names":["useState","Button","Download","Loader2","Dialog","DialogContent","DialogDescription","DialogFooter","DialogHeader","DialogTitle","RadioOption","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","getLegendItems","container","legendItems","legendWrapper","querySelector","querySelectorAll","forEach","item","_item$textContent","text","textContent","trim","color","colorElements","_i","_Array$from","Array","from","length","elem","computedStyle","window","getComputedStyle","computedFill","fill","computedStroke","stroke","getAttribute","some","existing","push","SVG_INLINE_PROPS","inlineSvgStyles","original","clone","computed","style","_iterator","_createForOfIteratorHelperLoose","_step","done","prop","value","val","getPropertyValue","setAttribute","i","children","escapeXml","str","replace","getSvgDimensions","svgElement","width","parseFloat","scrollWidth","height","scrollHeight","buildCompositeSvg","title","subtitle","inlineStyles","cloned","cloneNode","_getSvgDimensions","chartWidth","chartHeight","padding","titleHeight","subtitleHeight","legendHeight","headerHeight","totalWidth","totalHeight","serializer","XMLSerializer","String","serializeToString","map","index","x","join","downloadChartSVG","containerRef","current","compositeSvg","blob","Blob","type","url","URL","createObjectURL","link","document","createElement","href","download","click","revokeObjectURL","downloadChartPNG","_x","_x2","_x3","_downloadChartPNG","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee3","_getSvgDimensions2","wrap","_callee3$","_context3","prev","next","abrupt","Promise","resolve","reject","img","Image","onload","scale","canvas","ctx","getContext","fillStyle","fillRect","drawImage","toDataURL","onerror","Error","src","stop","ROW_LIMITS","DownloadButton","_ref","_ref$component","component","onDownload","onDownloadCSV","dataCount","defaultRowCount","undefined","_useState","isModalOpen","setIsModalOpen","_useState2","selectedFormat","setSelectedFormat","_useState3","selectedRowCount","setSelectedRowCount","_useState4","isDownloading","setIsDownloading","rowOptions","concat","filter","limit","label","handleChartDownload","_ref2","_callee","_callee$","_context","finish","handleTableDownload","_ref3","_callee2","_callee2$","_context2","handleCancel","variant","size","className","onClick","open","onOpenChange","onChange","e","target","Number","opt","disabled","selected"],"sources":["../../../src/plugins/helpers/download-data-button.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { Button } from \"../../shadcn/components/ui/button\";\nimport { Download, Loader2 } from \"lucide-react\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"../../shadcn/components/ui/dialog\";\nimport { RadioOption } from \"../../shadcn/components/ui/styled-elements\";\n\ntype LegendItem = { text: string; color: string };\n\nfunction getLegendItems(container: Element): LegendItem[] {\n const legendItems: LegendItem[] = [];\n const legendWrapper = container.querySelector('[class*=\"recharts-legend-wrapper\"]');\n if (!legendWrapper) return legendItems;\n\n legendWrapper.querySelectorAll('[class*=\"recharts-legend-item\"]').forEach((item) => {\n const text = item.textContent?.trim();\n let color = '#666666';\n const colorElements = item.querySelectorAll('path, rect, circle, line');\n\n for (const elem of Array.from(colorElements)) {\n const computedStyle = window.getComputedStyle(elem);\n const computedFill = computedStyle.fill;\n const computedStroke = computedStyle.stroke;\n\n if (computedFill && computedFill !== 'none' && computedFill !== 'transparent' && computedFill !== 'rgb(0, 0, 0)') {\n color = computedFill;\n break;\n }\n if (computedStroke && computedStroke !== 'none' && computedStroke !== 'transparent' && computedStroke !== 'rgb(0, 0, 0)') {\n color = computedStroke;\n break;\n }\n\n const fill = elem.getAttribute('fill');\n const stroke = elem.getAttribute('stroke');\n\n if (fill && fill !== 'none' && fill !== 'transparent') {\n color = fill;\n break;\n }\n if (stroke && stroke !== 'none' && stroke !== 'transparent') {\n color = stroke;\n break;\n }\n }\n\n if (text && !legendItems.some((existing) => existing.text === text)) {\n legendItems.push({ text, color });\n }\n });\n\n return legendItems;\n}\n\nconst SVG_INLINE_PROPS = [\n 'fill', 'stroke', 'stroke-width', 'stroke-dasharray', 'stroke-linecap', 'stroke-linejoin',\n 'font-size', 'font-family', 'font-weight', 'font-style',\n 'text-anchor', 'dominant-baseline', 'alignment-baseline', 'opacity', 'visibility',\n];\n\nfunction inlineSvgStyles(original: Element, clone: Element) {\n const computed = window.getComputedStyle(original);\n let style = '';\n for (const prop of SVG_INLINE_PROPS) {\n const val = computed.getPropertyValue(prop);\n if (val) style += `${prop}:${val};`;\n }\n (clone as SVGElement).setAttribute('style', style);\n for (let i = 0; i < original.children.length; i++) {\n inlineSvgStyles(original.children[i], clone.children[i]);\n }\n}\n\nfunction escapeXml(str: string): string {\n return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n}\n\nfunction getSvgDimensions(svgElement: SVGSVGElement): { width: number; height: number } {\n const width = parseFloat(svgElement.getAttribute('width') || '0') || svgElement.scrollWidth || 800;\n const height = parseFloat(svgElement.getAttribute('height') || '0') || svgElement.scrollHeight || 400;\n return { width, height };\n}\n\nfunction buildCompositeSvg(\n svgElement: SVGSVGElement,\n title: string,\n subtitle: string | undefined,\n legendItems: LegendItem[],\n inlineStyles: boolean,\n): string {\n const cloned = svgElement.cloneNode(true) as SVGSVGElement;\n if (inlineStyles) inlineSvgStyles(svgElement, cloned);\n\n const { width: chartWidth, height: chartHeight } = getSvgDimensions(svgElement);\n\n const padding = 20;\n const titleHeight = 28;\n const subtitleHeight = subtitle ? 36 : 0;\n const legendHeight = legendItems.length > 0 ? 30 : 0;\n const headerHeight = padding + titleHeight + subtitleHeight;\n const totalWidth = chartWidth + padding * 2;\n const totalHeight = chartHeight + headerHeight + legendHeight + padding;\n\n const serializer = new XMLSerializer();\n cloned.setAttribute('x', String(padding));\n cloned.setAttribute('y', String(headerHeight));\n cloned.setAttribute('overflow', 'visible');\n\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${totalWidth}\" height=\"${totalHeight}\">\n <rect width=\"${totalWidth}\" height=\"${totalHeight}\" fill=\"white\"/>\n <text x=\"${padding}\" y=\"${padding + 20}\" font-family=\"Arial,sans-serif\" font-size=\"18\" font-weight=\"600\" fill=\"#000000\">${escapeXml(title)}</text>\n ${subtitle ? `<text x=\"${padding}\" y=\"${padding + 44}\" font-family=\"Arial,sans-serif\" font-size=\"14\" fill=\"#666666\">${escapeXml(subtitle)}</text>` : ''}\n ${serializer.serializeToString(cloned)}\n ${legendItems.length > 0 ? `<g transform=\"translate(${padding}, ${totalHeight - 25})\">\n ${legendItems.map((item, index) => {\n const x = index * 200;\n return `<rect x=\"${x}\" y=\"0\" width=\"12\" height=\"12\" fill=\"${item.color}\"/>` +\n `<text x=\"${x + 18}\" y=\"10\" font-family=\"Arial,sans-serif\" font-size=\"12\" fill=\"#666666\">${escapeXml(item.text)}</text>`;\n }).join('')}\n </g>` : ''}\n </svg>`;\n}\n\nfunction downloadChartSVG(title: string, containerRef: any, subtitle?: string) {\n if (!containerRef.current) return;\n\n const svgElement = containerRef.current.querySelector('svg') as SVGSVGElement | null;\n if (!svgElement) return;\n\n const legendItems = getLegendItems(containerRef.current);\n const compositeSvg = buildCompositeSvg(svgElement, title, subtitle, legendItems, false);\n\n const blob = new Blob([compositeSvg], { type: 'image/svg+xml;charset=utf-8' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = `${title.replace(/\\s+/g, '_')}.svg`;\n link.click();\n URL.revokeObjectURL(url);\n}\n\nasync function downloadChartPNG(title: string, containerRef: any, subtitle?: string): Promise<void> {\n if (!containerRef.current) return;\n\n const svgElement = containerRef.current.querySelector('svg') as SVGSVGElement | null;\n if (!svgElement) return;\n\n const legendItems = getLegendItems(containerRef.current);\n const compositeSvg = buildCompositeSvg(svgElement, title, subtitle, legendItems, true);\n\n const { width: chartWidth, height: chartHeight } = getSvgDimensions(svgElement);\n const padding = 20;\n const subtitleHeight = subtitle ? 36 : 0;\n const legendHeight = legendItems.length > 0 ? 30 : 0;\n const totalWidth = chartWidth + padding * 2;\n const totalHeight = chartHeight + padding + 28 + subtitleHeight + legendHeight + padding;\n\n return new Promise((resolve, reject) => {\n const img = new Image();\n const blob = new Blob([compositeSvg], { type: 'image/svg+xml;charset=utf-8' });\n const url = URL.createObjectURL(blob);\n\n img.onload = () => {\n const scale = 2;\n const canvas = document.createElement('canvas');\n canvas.width = totalWidth * scale;\n canvas.height = totalHeight * scale;\n const ctx = canvas.getContext('2d')!;\n ctx.scale(scale, scale);\n ctx.fillStyle = 'white';\n ctx.fillRect(0, 0, totalWidth, totalHeight);\n ctx.drawImage(img, 0, 0, totalWidth, totalHeight);\n URL.revokeObjectURL(url);\n\n const link = document.createElement('a');\n link.download = `${title.replace(/\\s+/g, '_')}.png`;\n link.href = canvas.toDataURL('image/png');\n link.click();\n resolve();\n };\n\n img.onerror = () => { URL.revokeObjectURL(url); reject(new Error('SVG render failed')); };\n img.src = url;\n });\n}\n\nconst ROW_LIMITS = [100, 500, 1000] as const;\n\ntype DownloadButtonProps = {\n component: \"chart\" | \"table\";\n containerRef?: any;\n title: string;\n subtitle?: string;\n onDownload?: (limit: number) => Promise<void>;\n onDownloadCSV?: () => Promise<void>;\n dataCount?: number;\n};\n\nexport function DownloadButton({\n component = \"chart\",\n containerRef,\n title,\n subtitle,\n onDownload,\n onDownloadCSV,\n dataCount,\n}: DownloadButtonProps) {\n const defaultRowCount = dataCount !== undefined && dataCount < 100 ? \"all\" : 100;\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [selectedFormat, setSelectedFormat] = useState<\"svg\" | \"png\" | \"csv\">(\"svg\");\n const [selectedRowCount, setSelectedRowCount] = useState<100 | 500 | 1000 | \"all\">(defaultRowCount);\n const [isDownloading, setIsDownloading] = useState(false);\n\n const rowOptions = [\n ...ROW_LIMITS\n .filter((limit) => dataCount === undefined || dataCount > limit)\n .map((limit) => ({ value: limit as number, label: `${limit} rows` })),\n {\n value: \"all\" as const,\n label: dataCount !== undefined && dataCount <= 10000\n ? `All (${dataCount} rows)`\n : \"All (max 10,000 rows)\",\n },\n ];\n\n const handleChartDownload = async () => {\n if (selectedFormat === \"csv\") {\n setIsDownloading(true);\n try {\n await onDownloadCSV?.();\n } finally {\n setIsDownloading(false);\n }\n } else if (selectedFormat === \"png\") {\n setIsDownloading(true);\n try {\n await downloadChartPNG(title, containerRef, subtitle);\n } finally {\n setIsDownloading(false);\n }\n } else {\n downloadChartSVG(title, containerRef, subtitle);\n }\n setIsModalOpen(false);\n };\n\n const handleTableDownload = async () => {\n const limit = selectedRowCount === \"all\" ? 10000 : selectedRowCount;\n setIsDownloading(true);\n try {\n await onDownload?.(limit);\n } finally {\n setIsDownloading(false);\n }\n setIsModalOpen(false);\n };\n\n const handleCancel = () => {\n setIsModalOpen(false);\n if (component === \"chart\") {\n setSelectedFormat(\"svg\");\n } else {\n setSelectedRowCount(defaultRowCount);\n }\n };\n\n if (component === \"table\") {\n return (\n <>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"h-8 w-8 bg-white text-muted-foreground border-none hover:text-black transition-all flex items-center justify-center\"\n title=\"Download table as CSV\"\n onClick={() => {\n setSelectedRowCount(defaultRowCount);\n setIsModalOpen(true);\n }}\n >\n <Download className=\"h-3 w-3\" />\n </Button>\n\n <Dialog open={isModalOpen} onOpenChange={setIsModalOpen}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Download Table</DialogTitle>\n <DialogDescription>\n Max 10,000 rows can be downloaded at a time.\n </DialogDescription>\n </DialogHeader>\n\n <div className=\"py-4 flex items-center gap-3\">\n <span className=\"text-sm text-muted-foreground whitespace-nowrap\">Number of rows to download</span>\n <select\n value={String(selectedRowCount)}\n onChange={(e) => {\n const val = e.target.value;\n setSelectedRowCount(val === \"all\" ? \"all\" : Number(val) as 100 | 500 | 1000);\n }}\n className=\"border border-gray-200 rounded-md px-3 py-2 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-[#2A44D4] cursor-pointer\"\n >\n {rowOptions.map((opt) => (\n <option key={String(opt.value)} value={String(opt.value)}>\n {opt.label}\n </option>\n ))}\n </select>\n </div>\n\n <DialogFooter className=\"mt-6 block\">\n <div className=\"flex items-center justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleCancel}\n disabled={isDownloading}\n className=\"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]\"\n >\n Cancel\n </Button>\n <Button\n type=\"button\"\n variant=\"default\"\n onClick={handleTableDownload}\n disabled={isDownloading}\n className=\"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white disabled:opacity-70\"\n >\n {isDownloading ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : 'Download'}\n </Button>\n </div>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </>\n );\n }\n\n return (\n <>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"h-8 w-8 bg-white text-muted-foreground border-none hover:text-black transition-all flex items-center justify-center\"\n title=\"Download chart\"\n onClick={() => setIsModalOpen(true)}\n >\n <Download className=\"h-3 w-3\" />\n </Button>\n\n <Dialog open={isModalOpen} onOpenChange={setIsModalOpen}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Download Chart</DialogTitle>\n <DialogDescription>\n Choose the format you'd like to download the chart in.\n </DialogDescription>\n </DialogHeader>\n\n <div className=\"space-y-3 py-4\">\n <RadioOption label=\"SVG\" selected={selectedFormat === \"svg\"} onClick={() => setSelectedFormat(\"svg\")} />\n <RadioOption label=\"PNG\" selected={selectedFormat === \"png\"} onClick={() => setSelectedFormat(\"png\")} />\n {onDownloadCSV && (\n <RadioOption label=\"CSV\" selected={selectedFormat === \"csv\"} onClick={() => setSelectedFormat(\"csv\")} />\n )}\n </div>\n\n <DialogFooter className=\"mt-6 block\">\n <div className=\"flex items-center justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleCancel}\n disabled={isDownloading}\n className=\"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]\"\n >\n Cancel\n </Button>\n <Button\n type=\"button\"\n variant=\"default\"\n onClick={handleChartDownload}\n disabled={isDownloading}\n className=\"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white disabled:opacity-70\"\n >\n {isDownloading ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : 'Download'}\n </Button>\n </div>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </>\n );\n}\n"],"mappings":"4iCAAA,OAASA,QAAQ,KAAQ,OAAO,CAChC,OAASC,MAAM,KAAQ,mCAAmC,CAC1D,OAASC,QAAQ,CAAEC,OAAO,KAAQ,cAAc,CAChD,OACIC,MAAM,CACNC,aAAa,CACbC,iBAAiB,CACjBC,YAAY,CACZC,YAAY,CACZC,WAAW,KACR,mCAAmC,CAC1C,OAASC,WAAW,KAAQ,4CAA4C,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,CAAAC,QAAA,IAAAC,SAAA,yBAIzE,QAAS,CAAAC,cAAcA,CAACC,SAAkB,CAAgB,CACtD,GAAM,CAAAC,WAAyB,CAAG,EAAE,CACpC,GAAM,CAAAC,aAAa,CAAGF,SAAS,CAACG,aAAa,CAAC,sCAAoC,CAAC,CACnF,GAAI,CAACD,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AAS,CACjBG,OAAO,CAAEJ,YAAa,CACtBY,QAAQ,CAAE9B,aAAc,CACxBqB,SAAS,CAAC,6FAA6F,CAAAjI,QAAA,CAC1G,QAED,CAAQ,CAAC,cACTpD,IAAA,CAACX,MAAM,EACHwG,IAAI,CAAC,QAAQ,CACbsF,OAAO,CAAC,SAAS,CACjBG,OAAO,CAAEf,mBAAoB,CAC7BuB,QAAQ,CAAE9B,aAAc,CACxBqB,SAAS,CAAC,iFAAiF,CAAAjI,QAAA,CAE1F4G,aAAa,cAAGhK,IAAA,CAACT,OAAO,EAAC8L,SAAS,CAAC,sBAAsB,CAAE,CAAC,CAAG,UAAU,CACtE,CAAC,EACR,CAAC,CACI,CAAC,EACJ,CAAC,CACZ,CAAC,EACX,CAEV","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"download-data-button.js","names":["useState","Button","Download","Loader2","Dialog","DialogContent","DialogDescription","DialogFooter","DialogHeader","DialogTitle","RadioOption","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","getLegendItems","container","legendItems","legendWrapper","querySelector","querySelectorAll","forEach","item","_item$textContent","text","textContent","trim","color","colorElements","_i","_Array$from","Array","from","length","elem","computedStyle","window","getComputedStyle","computedFill","fill","computedStroke","stroke","getAttribute","some","existing","push","SVG_INLINE_PROPS","inlineSvgStyles","original","clone","computed","style","_iterator","_createForOfIteratorHelperLoose","_step","done","prop","value","val","getPropertyValue","setAttribute","i","children","escapeXml","str","replace","getSvgDimensions","svgElement","width","parseFloat","scrollWidth","height","scrollHeight","buildCompositeSvg","title","subtitle","inlineStyles","cloned","cloneNode","_getSvgDimensions","chartWidth","chartHeight","padding","titleHeight","subtitleHeight","legendHeight","headerHeight","totalWidth","totalHeight","serializer","XMLSerializer","String","serializeToString","map","index","x","join","downloadChartSVG","containerRef","current","compositeSvg","blob","Blob","type","url","URL","createObjectURL","link","document","createElement","href","download","click","revokeObjectURL","downloadChartPNG","_x","_x2","_x3","_downloadChartPNG","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee3","_getSvgDimensions2","wrap","_callee3$","_context3","prev","next","abrupt","Promise","resolve","reject","img","Image","onload","scale","canvas","ctx","getContext","fillStyle","fillRect","drawImage","toDataURL","onerror","Error","src","stop","ROW_LIMITS","DownloadButton","_ref","_ref$component","component","onDownload","onDownloadCSV","dataCount","defaultRowCount","undefined","_useState","isModalOpen","setIsModalOpen","_useState2","selectedFormat","setSelectedFormat","_useState3","selectedRowCount","setSelectedRowCount","_useState4","isDownloading","setIsDownloading","rowOptions","concat","filter","limit","label","handleChartDownload","_ref2","_callee","_callee$","_context","finish","handleTableDownload","_ref3","_callee2","_callee2$","_context2","handleCancel","variant","size","className","onClick","open","onOpenChange","onChange","e","target","Number","opt","disabled","selected"],"sources":["../../../src/plugins/helpers/download-data-button.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { Button } from \"../../shadcn/components/ui/button\";\nimport { Download, Loader2 } from \"lucide-react\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"../../shadcn/components/ui/dialog\";\nimport { RadioOption } from \"../../shadcn/components/ui/styled-elements\";\n\ntype LegendItem = { text: string; color: string };\n\nfunction getLegendItems(container: Element): LegendItem[] {\n const legendItems: LegendItem[] = [];\n const legendWrapper = container.querySelector('[class*=\"recharts-legend-wrapper\"]');\n if (!legendWrapper) return legendItems;\n\n legendWrapper.querySelectorAll('[class*=\"recharts-legend-item\"]').forEach((item) => {\n const text = item.textContent?.trim();\n let color = '#666666';\n const colorElements = item.querySelectorAll('path, rect, circle, line');\n\n for (const elem of Array.from(colorElements)) {\n const computedStyle = window.getComputedStyle(elem);\n const computedFill = computedStyle.fill;\n const computedStroke = computedStyle.stroke;\n\n if (computedFill && computedFill !== 'none' && computedFill !== 'transparent' && computedFill !== 'rgb(0, 0, 0)') {\n color = computedFill;\n break;\n }\n if (computedStroke && computedStroke !== 'none' && computedStroke !== 'transparent' && computedStroke !== 'rgb(0, 0, 0)') {\n color = computedStroke;\n break;\n }\n\n const fill = elem.getAttribute('fill');\n const stroke = elem.getAttribute('stroke');\n\n if (fill && fill !== 'none' && fill !== 'transparent') {\n color = fill;\n break;\n }\n if (stroke && stroke !== 'none' && stroke !== 'transparent') {\n color = stroke;\n break;\n }\n }\n\n if (text && !legendItems.some((existing) => existing.text === text)) {\n legendItems.push({ text, color });\n }\n });\n\n return legendItems;\n}\n\nconst SVG_INLINE_PROPS = [\n 'fill', 'stroke', 'stroke-width', 'stroke-dasharray', 'stroke-linecap', 'stroke-linejoin',\n 'font-size', 'font-family', 'font-weight', 'font-style',\n 'text-anchor', 'dominant-baseline', 'alignment-baseline', 'opacity', 'visibility',\n];\n\nfunction inlineSvgStyles(original: Element, clone: Element) {\n const computed = window.getComputedStyle(original);\n let style = '';\n for (const prop of SVG_INLINE_PROPS) {\n const val = computed.getPropertyValue(prop);\n if (val) style += `${prop}:${val};`;\n }\n (clone as SVGElement).setAttribute('style', style);\n for (let i = 0; i < original.children.length; i++) {\n inlineSvgStyles(original.children[i], clone.children[i]);\n }\n}\n\nfunction escapeXml(str: string): string {\n return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n}\n\nfunction getSvgDimensions(svgElement: SVGSVGElement): { width: number; height: number } {\n const width = parseFloat(svgElement.getAttribute('width') || '0') || svgElement.scrollWidth || 800;\n const height = parseFloat(svgElement.getAttribute('height') || '0') || svgElement.scrollHeight || 400;\n return { width, height };\n}\n\nfunction buildCompositeSvg(\n svgElement: SVGSVGElement,\n title: string,\n subtitle: string | undefined,\n legendItems: LegendItem[],\n inlineStyles: boolean,\n): string {\n const cloned = svgElement.cloneNode(true) as SVGSVGElement;\n if (inlineStyles) inlineSvgStyles(svgElement, cloned);\n\n const { width: chartWidth, height: chartHeight } = getSvgDimensions(svgElement);\n\n const padding = 20;\n const titleHeight = 28;\n const subtitleHeight = subtitle ? 36 : 0;\n const legendHeight = legendItems.length > 0 ? 30 : 0;\n const headerHeight = padding + titleHeight + subtitleHeight;\n const totalWidth = chartWidth + padding * 2;\n const totalHeight = chartHeight + headerHeight + legendHeight + padding;\n\n const serializer = new XMLSerializer();\n cloned.setAttribute('x', String(padding));\n cloned.setAttribute('y', String(headerHeight));\n cloned.setAttribute('overflow', 'visible');\n\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${totalWidth}\" height=\"${totalHeight}\">\n <rect width=\"${totalWidth}\" height=\"${totalHeight}\" fill=\"white\"/>\n <text x=\"${padding}\" y=\"${padding + 20}\" font-family=\"Arial,sans-serif\" font-size=\"18\" font-weight=\"600\" fill=\"#000000\">${escapeXml(title)}</text>\n ${subtitle ? `<text x=\"${padding}\" y=\"${padding + 44}\" font-family=\"Arial,sans-serif\" font-size=\"14\" fill=\"#666666\">${escapeXml(subtitle)}</text>` : ''}\n ${serializer.serializeToString(cloned)}\n ${legendItems.length > 0 ? `<g transform=\"translate(${padding}, ${totalHeight - 25})\">\n ${legendItems.map((item, index) => {\n const x = index * 200;\n return `<rect x=\"${x}\" y=\"0\" width=\"12\" height=\"12\" fill=\"${item.color}\"/>` +\n `<text x=\"${x + 18}\" y=\"10\" font-family=\"Arial,sans-serif\" font-size=\"12\" fill=\"#666666\">${escapeXml(item.text)}</text>`;\n }).join('')}\n </g>` : ''}\n </svg>`;\n}\n\nfunction downloadChartSVG(title: string, containerRef: any, subtitle?: string) {\n if (!containerRef.current) return;\n\n const svgElement = containerRef.current.querySelector('svg') as SVGSVGElement | null;\n if (!svgElement) return;\n\n const legendItems = getLegendItems(containerRef.current);\n const compositeSvg = buildCompositeSvg(svgElement, title, subtitle, legendItems, false);\n\n const blob = new Blob([compositeSvg], { type: 'image/svg+xml;charset=utf-8' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = `${title.replace(/\\s+/g, '_')}.svg`;\n link.click();\n URL.revokeObjectURL(url);\n}\n\nasync function downloadChartPNG(title: string, containerRef: any, subtitle?: string): Promise<void> {\n if (!containerRef.current) return;\n\n const svgElement = containerRef.current.querySelector('svg') as SVGSVGElement | null;\n if (!svgElement) return;\n\n const legendItems = getLegendItems(containerRef.current);\n const compositeSvg = buildCompositeSvg(svgElement, title, subtitle, legendItems, true);\n\n const { width: chartWidth, height: chartHeight } = getSvgDimensions(svgElement);\n const padding = 20;\n const subtitleHeight = subtitle ? 36 : 0;\n const legendHeight = legendItems.length > 0 ? 30 : 0;\n const totalWidth = chartWidth + padding * 2;\n const totalHeight = chartHeight + padding + 28 + subtitleHeight + legendHeight + padding;\n\n return new Promise((resolve, reject) => {\n const img = new Image();\n const blob = new Blob([compositeSvg], { type: 'image/svg+xml;charset=utf-8' });\n const url = URL.createObjectURL(blob);\n\n img.onload = () => {\n const scale = 2;\n const canvas = document.createElement('canvas');\n canvas.width = totalWidth * scale;\n canvas.height = totalHeight * scale;\n const ctx = canvas.getContext('2d')!;\n ctx.scale(scale, scale);\n ctx.fillStyle = 'white';\n ctx.fillRect(0, 0, totalWidth, totalHeight);\n ctx.drawImage(img, 0, 0, totalWidth, totalHeight);\n URL.revokeObjectURL(url);\n\n const link = document.createElement('a');\n link.download = `${title.replace(/\\s+/g, '_')}.png`;\n link.href = canvas.toDataURL('image/png');\n link.click();\n resolve();\n };\n\n img.onerror = () => { URL.revokeObjectURL(url); reject(new Error('SVG render failed')); };\n img.src = url;\n });\n}\n\nconst ROW_LIMITS = [100, 500, 1000] as const;\n\ntype DownloadButtonProps = {\n component: \"chart\" | \"table\";\n containerRef?: any;\n title: string;\n subtitle?: string;\n onDownload?: (limit: number) => Promise<void>;\n onDownloadCSV?: () => Promise<void>;\n dataCount?: number;\n};\n\nexport function DownloadButton({\n component = \"chart\",\n containerRef,\n title,\n subtitle,\n onDownload,\n onDownloadCSV,\n dataCount,\n}: DownloadButtonProps) {\n const defaultRowCount = dataCount !== undefined && dataCount < 100 ? \"all\" : 100;\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [selectedFormat, setSelectedFormat] = useState<\"svg\" | \"png\" | \"csv\">(\"svg\");\n const [selectedRowCount, setSelectedRowCount] = useState<100 | 500 | 1000 | \"all\">(defaultRowCount);\n const [isDownloading, setIsDownloading] = useState(false);\n\n const rowOptions = [\n ...ROW_LIMITS\n .filter((limit) => dataCount === undefined || dataCount > limit)\n .map((limit) => ({ value: limit as number, label: `${limit} rows` })),\n {\n value: \"all\" as const,\n label: dataCount !== undefined && dataCount <= 10000\n ? `All (${dataCount} rows)`\n : \"All (max 10,000 rows)\",\n },\n ];\n const handleChartDownload = async () => {\n if (selectedFormat === \"csv\") {\n setIsDownloading(true);\n try {\n await onDownloadCSV?.();\n } finally {\n setIsDownloading(false);\n }\n } else if (selectedFormat === \"png\") {\n setIsDownloading(true);\n try {\n await downloadChartPNG(title, containerRef, subtitle);\n } finally {\n setIsDownloading(false);\n }\n } else {\n downloadChartSVG(title, containerRef, subtitle);\n }\n setIsModalOpen(false);\n };\n\n const handleTableDownload = async () => {\n const limit = selectedRowCount === \"all\"\n ? (typeof dataCount === 'number' && dataCount < 10000 ? dataCount : 10000)\n : selectedRowCount;\n setIsDownloading(true);\n try {\n await onDownload?.(limit);\n } finally {\n setIsDownloading(false);\n }\n setIsModalOpen(false);\n };\n\n const handleCancel = () => {\n setIsModalOpen(false);\n if (component === \"chart\") {\n setSelectedFormat(\"svg\");\n } else {\n setSelectedRowCount(defaultRowCount);\n }\n };\n\n if (component === \"table\") {\n return (\n <>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"h-8 w-8 bg-white text-muted-foreground border-none hover:text-black transition-all flex items-center justify-center\"\n title=\"Download table as CSV\"\n onClick={() => {\n setSelectedRowCount(defaultRowCount);\n setIsModalOpen(true);\n }}\n >\n <Download className=\"h-3 w-3\" />\n </Button>\n\n <Dialog open={isModalOpen} onOpenChange={setIsModalOpen}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Download Table</DialogTitle>\n <DialogDescription>\n Max 10,000 rows can be downloaded at a time.\n </DialogDescription>\n </DialogHeader>\n\n <div className=\"py-4 flex items-center gap-3\">\n <span className=\"text-sm text-muted-foreground whitespace-nowrap\">Number of rows to download</span>\n <select\n value={String(selectedRowCount)}\n onChange={(e) => {\n const val = e.target.value;\n setSelectedRowCount(val === \"all\" ? \"all\" : Number(val) as 100 | 500 | 1000);\n }}\n className=\"border border-gray-200 rounded-md px-3 py-2 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-[#2A44D4] cursor-pointer\"\n >\n {rowOptions.map((opt) => (\n <option key={String(opt.value)} value={String(opt.value)}>\n {opt.label}\n </option>\n ))}\n </select>\n </div>\n\n <DialogFooter className=\"mt-6 block\">\n <div className=\"flex items-center justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleCancel}\n disabled={isDownloading}\n className=\"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]\"\n >\n Cancel\n </Button>\n <Button\n type=\"button\"\n variant=\"default\"\n onClick={handleTableDownload}\n disabled={isDownloading}\n className=\"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white disabled:opacity-70\"\n >\n {isDownloading ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : 'Download'}\n </Button>\n </div>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </>\n );\n }\n\n return (\n <>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"h-8 w-8 bg-white text-muted-foreground border-none hover:text-black transition-all flex items-center justify-center\"\n title=\"Download chart\"\n onClick={() => setIsModalOpen(true)}\n >\n <Download className=\"h-3 w-3\" />\n </Button>\n\n <Dialog open={isModalOpen} onOpenChange={setIsModalOpen}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Download Chart</DialogTitle>\n <DialogDescription>\n Choose the format you'd like to download the chart in.\n </DialogDescription>\n </DialogHeader>\n\n <div className=\"space-y-3 py-4\">\n <RadioOption label=\"SVG\" selected={selectedFormat === \"svg\"} onClick={() => setSelectedFormat(\"svg\")} />\n <RadioOption label=\"PNG\" selected={selectedFormat === \"png\"} onClick={() => setSelectedFormat(\"png\")} />\n {onDownloadCSV && (\n <RadioOption label=\"CSV\" selected={selectedFormat === \"csv\"} onClick={() => setSelectedFormat(\"csv\")} />\n )}\n </div>\n\n <DialogFooter className=\"mt-6 block\">\n <div className=\"flex items-center justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleCancel}\n disabled={isDownloading}\n className=\"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]\"\n >\n Cancel\n </Button>\n <Button\n type=\"button\"\n variant=\"default\"\n onClick={handleChartDownload}\n disabled={isDownloading}\n className=\"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white disabled:opacity-70\"\n >\n {isDownloading ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : 'Download'}\n </Button>\n </div>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </>\n );\n}\n"],"mappings":"4iCAAA,OAASA,QAAQ,KAAQ,OAAO,CAChC,OAASC,MAAM,KAAQ,mCAAmC,CAC1D,OAASC,QAAQ,CAAEC,OAAO,KAAQ,cAAc,CAChD,OACIC,MAAM,CACNC,aAAa,CACbC,iBAAiB,CACjBC,YAAY,CACZC,YAAY,CACZC,WAAW,KACR,mCAAmC,CAC1C,OAASC,WAAW,KAAQ,4CAA4C,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,CAAAC,QAAA,IAAAC,SAAA,yBAIzE,QAAS,CAAAC,cAAcA,CAACC,SAAkB,CAAgB,CACtD,GAAM,CAAAC,WAAyB,CAAG,EAAE,CACpC,GAAM,CAAAC,aAAa,CAAGF,SAAS,CAACG,aAAa,CAAC,sCAAoC,CAAC,CACnF,GAAI,CAACD,aAAa,CAAE,MAAO,CAAAD,WAAW,CAEtCC,aAAa,CAACE,gBAAgB,CAAC,mCAAiC,CAAC,CAACC,OAAO,CAAC,SAACC,IAAI,CAAK,KAA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