@peak-ai/canvas 1.5.7-rc.2 → 1.5.7-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/plugins/helpers/button-form.js +1 -1
- package/plugins/helpers/button-form.js.map +1 -1
- package/plugins/helpers/data-table.d.ts +4 -1
- package/plugins/helpers/data-table.js +4 -4
- package/plugins/helpers/data-table.js.map +1 -1
- package/plugins/helpers/download-data-button.js +1 -1
- package/plugins/helpers/download-data-button.js.map +1 -1
- package/plugins/helpers/render-components.js +4 -4
- package/plugins/helpers/render-components.js.map +1 -1
- package/shadcn/components/ui/button.js +2 -2
- package/shadcn/components/ui/button.js.map +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@peak-ai/canvas",
|
|
3
3
|
"author": "squad-builder-experience",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
|
-
"version": "1.5.7-rc.
|
|
5
|
+
"version": "1.5.7-rc.4",
|
|
6
6
|
"description": "",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@emotion/react": "^11.11.4",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"date-fns-tz": "^2.0.0",
|
|
39
39
|
"grapesjs": "0.22.6",
|
|
40
40
|
"grapesjs-tailwind": "1.0.7",
|
|
41
|
+
"html-to-image": "^1.11.13",
|
|
41
42
|
"lodash": "^4.17.21",
|
|
42
43
|
"lucide-react": "^0.525.0",
|
|
43
44
|
"markdown": "^0.5.0",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _extends from"@babel/runtime/helpers/extends";import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _regeneratorRuntime from"@babel/runtime/regenerator";import{useState}from"react";import{Dialog,DialogContent,DialogDescription,DialogFooter,DialogFooterError,DialogHeader,DialogTitle}from"../../shadcn/components/ui/dialog";import{Field,FieldDescription,FieldError,FieldGroup,FieldLabel}from"../../shadcn/components/ui/field";import{Input}from"../../shadcn/components/ui/input";import{Button}from"../../shadcn/components/ui/button";import{Loader2Icon}from"lucide-react";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function useButtonForm(config){var formMapper=config.formMapper,onSubmit=config.onSubmit,_config$isSubmitting=config.isSubmitting,isSubmitting=_config$isSubmitting===void 0?false:_config$isSubmitting,_config$formTitle=config.formTitle,formTitle=_config$formTitle===void 0?"Input form":_config$formTitle,_config$formDescripti=config.formDescription,formDescription=_config$formDescripti===void 0?"Please fill in the necessary details.":_config$formDescripti,_config$formButtonTex=config.formButtonText,formButtonText=_config$formButtonTex===void 0?"Submit":_config$formButtonTex,onClose=config.onClose;var _useState=useState(false),isFormOpen=_useState[0],setIsFormOpen=_useState[1];var _useState2=useState({}),formData=_useState2[0],setFormData=_useState2[1];var _useState3=useState({}),formErrors=_useState3[0],setFormErrors=_useState3[1];var _useState4=useState(false),showErrors=_useState4[0],setShowErrors=_useState4[1];var _useState5=useState(null),apiError=_useState5[0],setApiError=_useState5[1];var hasForm=formMapper&&Object.keys(formMapper).length>0;function validateForm(){var errors={};if(formMapper){Object.entries(formMapper).forEach(function(_ref){var fieldName=_ref[0],fieldConfig=_ref[1];if(fieldConfig.required&&!formData[fieldName]){errors[fieldName]="This field is required."}})}setFormErrors(errors);return Object.keys(errors).length===0}function handleFormCancel(){return _handleFormCancel.apply(this,arguments)}function _handleFormCancel(){_handleFormCancel=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:setIsFormOpen(false);setFormData({});setFormErrors({});setShowErrors(false);setApiError(null);if(onClose){onClose()}case 6:case"end":return _context.stop()}},_callee)}));return _handleFormCancel.apply(this,arguments)}function handleOpenChange(_x){return _handleOpenChange.apply(this,arguments)}function _handleOpenChange(){_handleOpenChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(open){return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:setIsFormOpen(open);if(!open){setFormData({});setFormErrors({});setShowErrors(false);setApiError(null);if(onClose){onClose()}}case 2:case"end":return _context2.stop()}},_callee2)}));return _handleOpenChange.apply(this,arguments)}function handleFormSubmit(_x2){return _handleFormSubmit.apply(this,arguments)}function _handleFormSubmit(){_handleFormSubmit=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(e){var errorMessage;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:e.preventDefault();setShowErrors(true);setApiError(null);if(validateForm()){_context3.next=5;break}return _context3.abrupt("return");case 5:_context3.prev=5;_context3.next=8;return onSubmit(formData);case 8:setIsFormOpen(false);setFormData({});setFormErrors({});setShowErrors(false);_context3.next=18;break;case 14:_context3.prev=14;_context3.t0=_context3["catch"](5);errorMessage=(_context3.t0==null?void 0:_context3.t0.detail)||(_context3.t0==null?void 0:_context3.t0.message)||"An error occurred while submitting the details.";setApiError(errorMessage);case 18:case"end":return _context3.stop()}},_callee3,null,[[5,14]])}));return _handleFormSubmit.apply(this,arguments)}function openForm(){if(hasForm){setIsFormOpen(true);setShowErrors(false);return true}return false}function updateFormData(name,value){setFormData(function(prevData){var _extends2;return _extends({},prevData,(_extends2={},_extends2[name]=value,_extends2))});if(apiError){setApiError(null)}if(formErrors[name]){setFormErrors(function(prevErrors){var newErrors=_extends({},prevErrors);delete newErrors[name];return newErrors})}}var FormDialog=hasForm&&isFormOpen?/*#__PURE__*/_jsx(Dialog,{open:isFormOpen,onOpenChange:handleOpenChange,children:/*#__PURE__*/_jsxs(DialogContent,{children:[/*#__PURE__*/_jsxs(DialogHeader,{children:[/*#__PURE__*/_jsx(DialogTitle,{children:formTitle})
|
|
1
|
+
import _extends from"@babel/runtime/helpers/extends";import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _regeneratorRuntime from"@babel/runtime/regenerator";import{useState}from"react";import{Dialog,DialogContent,DialogDescription,DialogFooter,DialogFooterError,DialogHeader,DialogTitle}from"../../shadcn/components/ui/dialog";import{Field,FieldDescription,FieldError,FieldGroup,FieldLabel}from"../../shadcn/components/ui/field";import{Input}from"../../shadcn/components/ui/input";import{Button}from"../../shadcn/components/ui/button";import{Loader2Icon}from"lucide-react";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function useButtonForm(config){var formMapper=config.formMapper,onSubmit=config.onSubmit,_config$isSubmitting=config.isSubmitting,isSubmitting=_config$isSubmitting===void 0?false:_config$isSubmitting,_config$formTitle=config.formTitle,formTitle=_config$formTitle===void 0?"Input form":_config$formTitle,_config$formDescripti=config.formDescription,formDescription=_config$formDescripti===void 0?"Please fill in the necessary details.":_config$formDescripti,_config$formButtonTex=config.formButtonText,formButtonText=_config$formButtonTex===void 0?"Submit":_config$formButtonTex,onClose=config.onClose;var _useState=useState(false),isFormOpen=_useState[0],setIsFormOpen=_useState[1];var _useState2=useState({}),formData=_useState2[0],setFormData=_useState2[1];var _useState3=useState({}),formErrors=_useState3[0],setFormErrors=_useState3[1];var _useState4=useState(false),showErrors=_useState4[0],setShowErrors=_useState4[1];var _useState5=useState(null),apiError=_useState5[0],setApiError=_useState5[1];var hasForm=formMapper&&Object.keys(formMapper).length>0;function validateForm(){var errors={};if(formMapper){Object.entries(formMapper).forEach(function(_ref){var fieldName=_ref[0],fieldConfig=_ref[1];if(fieldConfig.required&&!formData[fieldName]){errors[fieldName]="This field is required."}})}setFormErrors(errors);return Object.keys(errors).length===0}function handleFormCancel(){return _handleFormCancel.apply(this,arguments)}function _handleFormCancel(){_handleFormCancel=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:setIsFormOpen(false);setFormData({});setFormErrors({});setShowErrors(false);setApiError(null);if(onClose){onClose()}case 6:case"end":return _context.stop()}},_callee)}));return _handleFormCancel.apply(this,arguments)}function handleOpenChange(_x){return _handleOpenChange.apply(this,arguments)}function _handleOpenChange(){_handleOpenChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(open){return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:setIsFormOpen(open);if(!open){setFormData({});setFormErrors({});setShowErrors(false);setApiError(null);if(onClose){onClose()}}case 2:case"end":return _context2.stop()}},_callee2)}));return _handleOpenChange.apply(this,arguments)}function handleFormSubmit(_x2){return _handleFormSubmit.apply(this,arguments)}function _handleFormSubmit(){_handleFormSubmit=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(e){var errorMessage;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:e.preventDefault();setShowErrors(true);setApiError(null);if(validateForm()){_context3.next=5;break}return _context3.abrupt("return");case 5:_context3.prev=5;_context3.next=8;return onSubmit(formData);case 8:setIsFormOpen(false);setFormData({});setFormErrors({});setShowErrors(false);_context3.next=18;break;case 14:_context3.prev=14;_context3.t0=_context3["catch"](5);errorMessage=(_context3.t0==null?void 0:_context3.t0.detail)||(_context3.t0==null?void 0:_context3.t0.message)||"An error occurred while submitting the details.";setApiError(errorMessage);case 18:case"end":return _context3.stop()}},_callee3,null,[[5,14]])}));return _handleFormSubmit.apply(this,arguments)}function openForm(){if(hasForm){setIsFormOpen(true);setShowErrors(false);return true}return false}function updateFormData(name,value){setFormData(function(prevData){var _extends2;return _extends({},prevData,(_extends2={},_extends2[name]=value,_extends2))});if(apiError){setApiError(null)}if(formErrors[name]){setFormErrors(function(prevErrors){var newErrors=_extends({},prevErrors);delete newErrors[name];return newErrors})}}var FormDialog=hasForm&&isFormOpen?/*#__PURE__*/_jsx(Dialog,{open:isFormOpen,onOpenChange:handleOpenChange,children:/*#__PURE__*/_jsxs(DialogContent,{children:[/*#__PURE__*/_jsxs(DialogHeader,{children:[/*#__PURE__*/_jsx(DialogTitle,{children:formTitle}),/*#__PURE__*/_jsx(DialogDescription,{children:formDescription})]}),/*#__PURE__*/_jsxs("form",{onSubmit:handleFormSubmit,children:[/*#__PURE__*/_jsx(FieldGroup,{children:Object.entries(formMapper).map(function(_ref2){var fieldName=_ref2[0],fieldConfig=_ref2[1];var hasError=showErrors&&formErrors[fieldName];if(typeof fieldConfig!=="object"){return null}return/*#__PURE__*/_jsxs(Field,{children:[/*#__PURE__*/_jsxs(FieldLabel,{htmlFor:fieldName,children:[fieldConfig.label||fieldName,fieldConfig.required&&/*#__PURE__*/_jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),fieldConfig.description&&/*#__PURE__*/_jsx(FieldDescription,{children:fieldConfig.description}),(fieldConfig.type==="text"||fieldConfig.type==="string"||fieldConfig.type==="number")&&/*#__PURE__*/_jsx(Input,{id:fieldName,name:fieldName,type:fieldConfig.type||"text",placeholder:fieldConfig.placeholder||"",required:fieldConfig.required||false,value:formData[fieldName]||"",onChange:function onChange(e){return updateFormData(fieldName,e.target.value)},className:hasError?"border-destructive focus-visible:ring-destructive":"","aria-invalid":hasError?"true":"false","aria-describedby":hasError?fieldName+"-error":undefined}),hasError&&/*#__PURE__*/_jsx(FieldError,{id:fieldName+"-error",children:formErrors[fieldName]})]},fieldName)})}),/*#__PURE__*/_jsx(DialogFooter,{className:"mt-6 block",children:/*#__PURE__*/_jsxs("div",{className:"flex flex-row items-start justify-between w-full gap-4",children:[/*#__PURE__*/_jsx("div",{className:"flex-1 min-w-0",children:apiError&&/*#__PURE__*/_jsx(DialogFooterError,{className:"text-left leading-normal whitespace-normal break-words",title:apiError,children:apiError})}),/*#__PURE__*/_jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[/*#__PURE__*/_jsx(Button,{type:"button",variant:"outline",onClick:handleFormCancel,className:"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]",children:"Cancel"}),/*#__PURE__*/_jsx(Button,{type:"submit",variant:"default",onClick:handleFormSubmit,disabled:isSubmitting||apiError!==null,className:"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white",children:isSubmitting?/*#__PURE__*/_jsx(Loader2Icon,{className:"h-4 w-4 animate-spin"}):formButtonText})]})]})})]})]})}):null;return{openForm:openForm,FormDialog:FormDialog,hasForm:hasForm}}
|
|
2
2
|
//# sourceMappingURL=button-form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-form.js","names":["useState","Dialog","DialogContent","DialogDescription","DialogFooter","DialogFooterError","DialogHeader","DialogTitle","Field","FieldDescription","FieldError","FieldGroup","FieldLabel","Input","Button","Loader2Icon","jsx","_jsx","jsxs","_jsxs","useButtonForm","config","formMapper","onSubmit","_config$isSubmitting","isSubmitting","_config$formTitle","formTitle","_config$formDescripti","formDescription","_config$formButtonTex","formButtonText","onClose","_useState","isFormOpen","setIsFormOpen","_useState2","formData","setFormData","_useState3","formErrors","setFormErrors","_useState4","showErrors","setShowErrors","_useState5","apiError","setApiError","hasForm","Object","keys","length","validateForm","errors","entries","forEach","_ref","fieldName","fieldConfig","required","handleFormCancel","_handleFormCancel","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_callee$","_context","prev","next","stop","handleOpenChange","_x","_handleOpenChange","_callee2","open","_callee2$","_context2","handleFormSubmit","_x2","_handleFormSubmit","_callee3","e","errorMessage","_callee3$","_context3","preventDefault","abrupt","t0","detail","message","openForm","updateFormData","name","value","prevData","_extends2","_extends","prevErrors","newErrors","FormDialog","onOpenChange","children","map","_ref2","hasError","htmlFor","label","className","description","type","id","placeholder","onChange","target","undefined","title","variant","onClick","disabled"],"sources":["../../../src/plugins/helpers/button-form.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { Dialog, DialogContent, DialogDescription, DialogFooter, DialogFooterError, DialogHeader, DialogTitle } from \"../../shadcn/components/ui/dialog\";\nimport { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from \"../../shadcn/components/ui/field\";\nimport { Input } from \"../../shadcn/components/ui/input\";\nimport { Button } from \"../../shadcn/components/ui/button\";\nimport { Loader2Icon } from \"lucide-react\";\n\nexport function useButtonForm(config: {\n formMapper?: Record<string, any>[];\n onSubmit: (formData: any) => Promise<void>;\n isSubmitting?: boolean;\n formTitle?: string;\n formDescription?: string;\n formButtonText?: string;\n onClose?: () => void;\n}) {\n const {\n formMapper,\n onSubmit,\n isSubmitting = false,\n formTitle = \"Input form\",\n formDescription = \"Please fill in the necessary details.\",\n formButtonText = \"Submit\",\n onClose\n } = config;\n const [isFormOpen, setIsFormOpen] = useState(false);\n const [formData, setFormData] = useState<Record<string, any>>({});\n const [formErrors, setFormErrors] = useState<Record<string, string>>({});\n const [showErrors, setShowErrors] = useState<boolean>(false);\n const [apiError, setApiError] = useState<string | null>(null);\n\n const hasForm = formMapper && Object.keys(formMapper).length > 0;\n\n function validateForm(): boolean {\n const errors: Record<string, string> = {};\n if (formMapper) {\n Object.entries(formMapper).forEach(([fieldName, fieldConfig]) => {\n if (fieldConfig.required && !formData[fieldName]) {\n errors[fieldName] = 'This field is required.';\n }\n });\n }\n setFormErrors(errors);\n return Object.keys(errors).length === 0;\n }\n\n async function handleFormCancel() {\n setIsFormOpen(false);\n setFormData({});\n setFormErrors({});\n setShowErrors(false);\n setApiError(null);\n if (onClose) {\n onClose();\n }\n }\n\n async function handleOpenChange(open: boolean) {\n setIsFormOpen(open);\n\n if (!open) {\n setFormData({});\n setFormErrors({});\n setShowErrors(false);\n setApiError(null);\n if (onClose) {\n onClose();\n }\n }\n }\n\n async function handleFormSubmit(e: React.FormEvent) {\n e.preventDefault();\n\n setShowErrors(true);\n setApiError(null);\n\n if (!validateForm()) {\n return;\n }\n\n try {\n await onSubmit(formData);\n setIsFormOpen(false);\n setFormData({});\n setFormErrors({});\n setShowErrors(false);\n } catch (error: any) {\n const errorMessage = error?.detail || error?.message || 'An error occurred while submitting the details.';\n setApiError(errorMessage);\n }\n }\n\n function openForm() {\n if (hasForm) {\n setIsFormOpen(true);\n setShowErrors(false);\n return true;\n }\n return false;\n }\n\n function updateFormData(name: string, value: any) {\n setFormData(prevData => ({\n ...prevData,\n [name]: value,\n }));\n\n if (apiError) {\n setApiError(null);\n }\n\n if (formErrors[name]) {\n setFormErrors(prevErrors => {\n const newErrors = { ...prevErrors };\n delete newErrors[name];\n return newErrors;\n });\n }\n }\n\n const FormDialog = (hasForm && isFormOpen) ? (\n <Dialog open={isFormOpen} onOpenChange={handleOpenChange}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{formTitle}</DialogTitle>\n {formDescription && (\n <DialogDescription>{formDescription}</DialogDescription>\n )}\n </DialogHeader>\n\n <form onSubmit={handleFormSubmit}>\n <FieldGroup>\n {Object.entries(formMapper!).map(([fieldName, fieldConfig]) => {\n const hasError = showErrors && formErrors[fieldName];\n if (typeof fieldConfig !== \"object\") {\n return null;\n }\n return (\n <Field key={fieldName}>\n <FieldLabel htmlFor={fieldName}>\n {fieldConfig.label || fieldName}\n {fieldConfig.required && <span className=\"text-red-500 ml-1\">*</span>}\n </FieldLabel>\n {fieldConfig.description && (\n <FieldDescription>{fieldConfig.description}</FieldDescription>\n )}\n {(fieldConfig.type === \"text\" || fieldConfig.type === \"string\" || fieldConfig.type === \"number\") && (\n <Input\n id={fieldName}\n name={fieldName}\n type={fieldConfig.type || \"text\"}\n placeholder={fieldConfig.placeholder || \"\"}\n required={fieldConfig.required || false}\n value={formData[fieldName] || \"\"}\n onChange={(e) => updateFormData(fieldName, e.target.value)}\n className={hasError ? \"border-destructive focus-visible:ring-destructive\" : \"\"}\n aria-invalid={hasError ? \"true\" : \"false\"}\n aria-describedby={hasError ? `${fieldName}-error` : undefined}\n />\n\n )}\n {hasError && (\n <FieldError id={`${fieldName}-error`}>\n {formErrors[fieldName]}\n </FieldError>\n )}\n </Field>\n )\n })}\n </FieldGroup>\n <DialogFooter className=\"mt-6 block\">\n <div className=\"flex flex-row items-start justify-between w-full gap-4\">\n\n <div className=\"flex-1 min-w-0\">\n {apiError && (\n <DialogFooterError\n className=\"text-left leading-normal whitespace-normal break-words\"\n title={apiError}\n >\n {apiError}\n </DialogFooterError>\n )}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleFormCancel}\n className=\"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]\"\n >\n Cancel\n </Button>\n <Button\n type=\"submit\"\n variant=\"default\"\n onClick={handleFormSubmit}\n disabled={isSubmitting || apiError !== null}\n className=\"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white\"\n >\n {isSubmitting ? (\n <Loader2Icon className=\"h-4 w-4 animate-spin\" />\n ) : (\n formButtonText\n )}\n </Button>\n </div>\n </div>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n ) : null;\n\n return {\n openForm,\n FormDialog,\n hasForm,\n }\n}"],"mappings":"wLAAA,OAASA,QAAQ,KAAQ,OAAO,CAChC,OAASC,MAAM,CAAEC,aAAa,CAAEC,iBAAiB,CAAEC,YAAY,CAAEC,iBAAiB,CAAEC,YAAY,CAAEC,WAAW,KAAQ,mCAAmC,CACxJ,OAASC,KAAK,CAAEC,gBAAgB,CAAEC,UAAU,CAAEC,UAAU,CAAEC,UAAU,KAAQ,kCAAkC,CAC9G,OAASC,KAAK,KAAQ,kCAAkC,CACxD,OAASC,MAAM,KAAQ,mCAAmC,CAC1D,OAASC,WAAW,KAAQ,cAAc,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAE3C,MAAO,SAAS,CAAAC,aAAaA,CAACC,MAQ7B,CAAE,CACC,GACI,CAAAC,UAAU,CAOVD,MAAM,CAPNC,UAAU,CACVC,QAAQ,CAMRF,MAAM,CANNE,QAAQ,CAAAC,oBAAA,CAMRH,MAAM,CALNI,YAAY,CAAZA,YAAY,CAAAD,oBAAA,UAAG,KAAK,CAAAA,oBAAA,CA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YAAY,cACTR,IAAA,CAACF,WAAW,EAACgG,SAAS,CAAC,sBAAsB,CAAE,CAAC,CAEhDhF,cACH,CACG,CAAC,EACR,CAAC,EACL,CAAC,CACI,CAAC,EACb,CAAC,EACI,CAAC,CACZ,CAAC,CACT,IAAI,CAER,MAAO,CACH+D,QAAQ,CAARA,QAAQ,CACRS,UAAU,CAAVA,UAAU,CACVvD,OAAO,CAAPA,OACJ,CACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"button-form.js","names":["useState","Dialog","DialogContent","DialogDescription","DialogFooter","DialogFooterError","DialogHeader","DialogTitle","Field","FieldDescription","FieldError","FieldGroup","FieldLabel","Input","Button","Loader2Icon","jsx","_jsx","jsxs","_jsxs","useButtonForm","config","formMapper","onSubmit","_config$isSubmitting","isSubmitting","_config$formTitle","formTitle","_config$formDescripti","formDescription","_config$formButtonTex","formButtonText","onClose","_useState","isFormOpen","setIsFormOpen","_useState2","formData","setFormData","_useState3","formErrors","setFormErrors","_useState4","showErrors","setShowErrors","_useState5","apiError","setApiError","hasForm","Object","keys","length","validateForm","errors","entries","forEach","_ref","fieldName","fieldConfig","required","handleFormCancel","_handleFormCancel","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_callee$","_context","prev","next","stop","handleOpenChange","_x","_handleOpenChange","_callee2","open","_callee2$","_context2","handleFormSubmit","_x2","_handleFormSubmit","_callee3","e","errorMessage","_callee3$","_context3","preventDefault","abrupt","t0","detail","message","openForm","updateFormData","name","value","prevData","_extends2","_extends","prevErrors","newErrors","FormDialog","onOpenChange","children","map","_ref2","hasError","htmlFor","label","className","description","type","id","placeholder","onChange","target","undefined","title","variant","onClick","disabled"],"sources":["../../../src/plugins/helpers/button-form.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { Dialog, DialogContent, DialogDescription, DialogFooter, DialogFooterError, DialogHeader, DialogTitle } from \"../../shadcn/components/ui/dialog\";\nimport { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from \"../../shadcn/components/ui/field\";\nimport { Input } from \"../../shadcn/components/ui/input\";\nimport { Button } from \"../../shadcn/components/ui/button\";\nimport { Loader2Icon } from \"lucide-react\";\n\nexport function useButtonForm(config: {\n formMapper?: Record<string, any>[];\n onSubmit: (formData: any) => Promise<void>;\n isSubmitting?: boolean;\n formTitle?: string;\n formDescription?: string;\n formButtonText?: string;\n onClose?: () => void;\n}) {\n const {\n formMapper,\n onSubmit,\n isSubmitting = false,\n formTitle = \"Input form\",\n formDescription = \"Please fill in the necessary details.\",\n formButtonText = \"Submit\",\n onClose\n } = config;\n const [isFormOpen, setIsFormOpen] = useState(false);\n const [formData, setFormData] = useState<Record<string, any>>({});\n const [formErrors, setFormErrors] = useState<Record<string, string>>({});\n const [showErrors, setShowErrors] = useState<boolean>(false);\n const [apiError, setApiError] = useState<string | null>(null);\n\n const hasForm = formMapper && Object.keys(formMapper).length > 0;\n\n function validateForm(): boolean {\n const errors: Record<string, string> = {};\n if (formMapper) {\n Object.entries(formMapper).forEach(([fieldName, fieldConfig]) => {\n if (fieldConfig.required && !formData[fieldName]) {\n errors[fieldName] = 'This field is required.';\n }\n });\n }\n setFormErrors(errors);\n return Object.keys(errors).length === 0;\n }\n\n async function handleFormCancel() {\n setIsFormOpen(false);\n setFormData({});\n setFormErrors({});\n setShowErrors(false);\n setApiError(null);\n if (onClose) {\n onClose();\n }\n }\n\n async function handleOpenChange(open: boolean) {\n setIsFormOpen(open);\n\n if (!open) {\n setFormData({});\n setFormErrors({});\n setShowErrors(false);\n setApiError(null);\n if (onClose) {\n onClose();\n }\n }\n }\n\n async function handleFormSubmit(e: React.FormEvent) {\n e.preventDefault();\n\n setShowErrors(true);\n setApiError(null);\n\n if (!validateForm()) {\n return;\n }\n\n try {\n await onSubmit(formData);\n setIsFormOpen(false);\n setFormData({});\n setFormErrors({});\n setShowErrors(false);\n } catch (error: any) {\n const errorMessage = error?.detail || error?.message || 'An error occurred while submitting the details.';\n setApiError(errorMessage);\n }\n }\n\n function openForm() {\n if (hasForm) {\n setIsFormOpen(true);\n setShowErrors(false);\n return true;\n }\n return false;\n }\n\n function updateFormData(name: string, value: any) {\n setFormData(prevData => ({\n ...prevData,\n [name]: value,\n }));\n\n if (apiError) {\n setApiError(null);\n }\n\n if (formErrors[name]) {\n setFormErrors(prevErrors => {\n const newErrors = { ...prevErrors };\n delete newErrors[name];\n return newErrors;\n });\n }\n }\n\n const FormDialog = (hasForm && isFormOpen) ? (\n <Dialog open={isFormOpen} onOpenChange={handleOpenChange}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{formTitle}</DialogTitle>\n <DialogDescription>{formDescription}</DialogDescription>\n </DialogHeader>\n\n <form onSubmit={handleFormSubmit}>\n <FieldGroup>\n {Object.entries(formMapper!).map(([fieldName, fieldConfig]) => {\n const hasError = showErrors && formErrors[fieldName];\n if (typeof fieldConfig !== \"object\") {\n return null;\n }\n return (\n <Field key={fieldName}>\n <FieldLabel htmlFor={fieldName}>\n {fieldConfig.label || fieldName}\n {fieldConfig.required && <span className=\"text-red-500 ml-1\">*</span>}\n </FieldLabel>\n {fieldConfig.description && (\n <FieldDescription>{fieldConfig.description}</FieldDescription>\n )}\n {(fieldConfig.type === \"text\" || fieldConfig.type === \"string\" || fieldConfig.type === \"number\") && (\n <Input\n id={fieldName}\n name={fieldName}\n type={fieldConfig.type || \"text\"}\n placeholder={fieldConfig.placeholder || \"\"}\n required={fieldConfig.required || false}\n value={formData[fieldName] || \"\"}\n onChange={(e) => updateFormData(fieldName, e.target.value)}\n className={hasError ? \"border-destructive focus-visible:ring-destructive\" : \"\"}\n aria-invalid={hasError ? \"true\" : \"false\"}\n aria-describedby={hasError ? `${fieldName}-error` : undefined}\n />\n\n )}\n {hasError && (\n <FieldError id={`${fieldName}-error`}>\n {formErrors[fieldName]}\n </FieldError>\n )}\n </Field>\n )\n })}\n </FieldGroup>\n <DialogFooter className=\"mt-6 block\">\n <div className=\"flex flex-row items-start justify-between w-full gap-4\">\n\n <div className=\"flex-1 min-w-0\">\n {apiError && (\n <DialogFooterError\n className=\"text-left leading-normal whitespace-normal break-words\"\n title={apiError}\n >\n {apiError}\n </DialogFooterError>\n )}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleFormCancel}\n className=\"bg-[#EAECFB] border border-[#2A44D4] text-[#263DBF] hover:bg-[#EAECFB] hover:text-[#263DBF]\"\n >\n Cancel\n </Button>\n <Button\n type=\"submit\"\n variant=\"default\"\n onClick={handleFormSubmit}\n disabled={isSubmitting || apiError !== null}\n className=\"bg-[#2A44D4] text-white hover:bg-[#2A44D4] hover:text-white\"\n >\n {isSubmitting ? (\n <Loader2Icon className=\"h-4 w-4 animate-spin\" />\n ) : (\n formButtonText\n )}\n </Button>\n </div>\n </div>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n ) : null;\n\n return {\n openForm,\n FormDialog,\n hasForm,\n }\n}"],"mappings":"wLAAA,OAASA,QAAQ,KAAQ,OAAO,CAChC,OAASC,MAAM,CAAEC,aAAa,CAAEC,iBAAiB,CAAEC,YAAY,CAAEC,iBAAiB,CAAEC,YAAY,CAAEC,WAAW,KAAQ,mCAAmC,CACxJ,OAASC,KAAK,CAAEC,gBAAgB,CAAEC,UAAU,CAAEC,UAAU,CAAEC,UAAU,KAAQ,kCAAkC,CAC9G,OAASC,KAAK,KAAQ,kCAAkC,CACxD,OAASC,MAAM,KAAQ,mCAAmC,CAC1D,OAASC,WAAW,KAAQ,cAAc,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAE3C,MAAO,SAAS,CAAAC,aAAaA,CAACC,MAQ7B,CAAE,CACC,GACI,CAAAC,UAAU,CAOVD,MAAM,CAPNC,UAAU,CACVC,QAAQ,CAMRF,MAAM,CANNE,QAAQ,CAAAC,oBAAA,CAMRH,MAAM,CALNI,YAAY,CAAZA,YAAY,CAAAD,oBAAA,UAAG,KAAK,CAAAA,oBAA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ACTR,IAAA,CAACF,WAAW,EAACgG,SAAS,CAAC,sBAAsB,CAAE,CAAC,CAEhDhF,cACH,CACG,CAAC,EACR,CAAC,EACL,CAAC,CACI,CAAC,EACb,CAAC,EACI,CAAC,CACZ,CAAC,CACT,IAAI,CAER,MAAO,CACH+D,QAAQ,CAARA,QAAQ,CACRS,UAAU,CAAVA,UAAU,CACVvD,OAAO,CAAPA,OACJ,CACJ","ignoreList":[]}
|
|
@@ -33,8 +33,11 @@ export type DataTableProps = {
|
|
|
33
33
|
decimalPrecision?: number;
|
|
34
34
|
columnWithChipClass?: Record<string, 'useMap' | 'useRandom'>;
|
|
35
35
|
chipStylesMapping?: Record<string, Record<string, string>>;
|
|
36
|
+
isBulkSelectionEnabled?: boolean;
|
|
37
|
+
selectedIndices?: number[];
|
|
38
|
+
setSelectedIndices?: (indices: number[]) => void;
|
|
36
39
|
title?: string;
|
|
37
40
|
onDownload?: (limit: number) => Promise<void>;
|
|
38
41
|
};
|
|
39
|
-
export declare function DataTable({ data, headerMapper, className, actions, isEditable, pagination, isLoading, onRowAction, onPageChange, onSort, sortConfig, otherProps, height, decimalPrecision, columnWithChipClass, chipStylesMapping, title, onDownload, }: DataTableProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare function DataTable({ data, headerMapper, className, actions, isEditable, pagination, isLoading, onRowAction, onPageChange, onSort, sortConfig, otherProps, height, decimalPrecision, columnWithChipClass, chipStylesMapping, isBulkSelectionEnabled, selectedIndices, setSelectedIndices, title, onDownload, }: DataTableProps): import("react/jsx-runtime").JSX.Element;
|
|
40
43
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _extends from"@babel/runtime/helpers/extends";import _regeneratorRuntime from"@babel/runtime/regenerator";/* eslint-disable @typescript-eslint/no-explicit-any */import{useEffect,useState,Fragment,useMemo,useRef}from"react";import{Table,TableHeader,TableRow,TableHead,TableBody,TableCell,TableHeadSortable}from"../../shadcn/components/ui/table";import{TableLoader}from"../../shadcn/components/ui/skeleton";import{ScrollArea,ScrollBar}from"../../shadcn/components/ui/scroll-area";import{Pagination,PaginationContent,renderPaginationArrows}from"../../shadcn/components/ui/pagination";import{Button}from"../../shadcn/components/ui/button";import{cn}from"../../shadcn/utils";import{renderNoDataFallback}from"./extra";import{formatValue}from"../../helpers";import{SEMANTIC_CHIP_STYLES_MAP,RANDOM_CHIP_COLOR_PALETTE}from"../../constants";import{MoreVertical,Loader2}from"lucide-react";import{useButtonForm}from"./button-form";import{DownloadButton}from"./download-data-button";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";/**
|
|
1
|
+
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _extends from"@babel/runtime/helpers/extends";import _regeneratorRuntime from"@babel/runtime/regenerator";/* eslint-disable @typescript-eslint/no-explicit-any */import{useEffect,useState,Fragment,useMemo,useRef}from"react";import{Table,TableHeader,TableRow,TableHead,TableBody,TableCell,TableHeadSortable}from"../../shadcn/components/ui/table";import{TableLoader}from"../../shadcn/components/ui/skeleton";import{ScrollArea,ScrollBar}from"../../shadcn/components/ui/scroll-area";import{Pagination,PaginationContent,renderPaginationArrows}from"../../shadcn/components/ui/pagination";import{Button}from"../../shadcn/components/ui/button";import{cn}from"../../shadcn/utils";import{renderNoDataFallback}from"./extra";import{formatValue}from"../../helpers";import{SEMANTIC_CHIP_STYLES_MAP,RANDOM_CHIP_COLOR_PALETTE}from"../../constants";import{Checkbox}from"../../shadcn/components/ui/checkbox";import{MoreVertical,Loader2}from"lucide-react";import{useButtonForm}from"./button-form";import{DownloadButton}from"./download-data-button";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";/**
|
|
2
2
|
* Normalizes a value to a consistent string key for color mapping.
|
|
3
3
|
* Handles all value types: null/undefined, numbers, booleans, objects, arrays, dates.
|
|
4
4
|
* Ensures consistent color assignment for all variations of the same logical value.
|
|
@@ -7,12 +7,12 @@ if(value===null||value===undefined){return""}var str=String(value);return str.tr
|
|
|
7
7
|
* Generates a stable hash based on unique value sets per column.
|
|
8
8
|
* This hash is order-independent - it only changes when the set of unique values changes,
|
|
9
9
|
* not when rows are reordered (e.g., during sorting).
|
|
10
|
-
*/function getUniqueValuesHash(data,columnWithChipClass){if(!Array.isArray(data)||data.length===0){return""}var availableKeys=Object.keys(data[0]||{});var hashParts={};Object.keys(columnWithChipClass).forEach(function(columnKey){if(!availableKeys.includes(columnKey)){return}var chipMode=getChipMode(columnWithChipClass,columnKey);if(chipMode==="useRandom"){var uniqueNormalizedValues=new Set;data.forEach(function(row){var value=row[columnKey];var normalizedKey=normalizeValue(value);if(normalizedKey){uniqueNormalizedValues.add(normalizedKey)}});var sortedUniqueValues=Array.from(uniqueNormalizedValues).sort();hashParts[columnKey]=sortedUniqueValues}});return JSON.stringify(hashParts)}export function DataTable(_ref){var _ref2,_pagination$values$pa,_pagination$values,_ref3,_pagination$values$pa2,_pagination$values2;var _ref$data=_ref.data,data=_ref$data===void 0?[]:_ref$data,_ref$headerMapper=_ref.headerMapper,headerMapper=_ref$headerMapper===void 0?{}:_ref$headerMapper,_ref$className=_ref.className,className=_ref$className===void 0?"":_ref$className,_ref$actions=_ref.actions,actions=_ref$actions===void 0?[]:_ref$actions,_ref$isEditable=_ref.isEditable,isEditable=_ref$isEditable===void 0?false:_ref$isEditable,pagination=_ref.pagination,_ref$isLoading=_ref.isLoading,isLoading=_ref$isLoading===void 0?false:_ref$isLoading,onRowAction=_ref.onRowAction,onPageChange=_ref.onPageChange,onSort=_ref.onSort,sortConfig=_ref.sortConfig,_ref$otherProps=_ref.otherProps,otherProps=_ref$otherProps===void 0?{}:_ref$otherProps,height=_ref.height,_ref$decimalPrecision=_ref.decimalPrecision,decimalPrecision=_ref$decimalPrecision===void 0?2:_ref$decimalPrecision,_ref$columnWithChipCl=_ref.columnWithChipClass,columnWithChipClass=_ref$columnWithChipCl===void 0?{}:_ref$columnWithChipCl,_ref$chipStylesMappin=_ref.chipStylesMapping,chipStylesMapping=_ref$chipStylesMappin===void 0?{}:_ref$chipStylesMappin,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];// Track which dropdown is currently open (by row index)
|
|
10
|
+
*/function getUniqueValuesHash(data,columnWithChipClass){if(!Array.isArray(data)||data.length===0){return""}var availableKeys=Object.keys(data[0]||{});var hashParts={};Object.keys(columnWithChipClass).forEach(function(columnKey){if(!availableKeys.includes(columnKey)){return}var chipMode=getChipMode(columnWithChipClass,columnKey);if(chipMode==="useRandom"){var uniqueNormalizedValues=new Set;data.forEach(function(row){var value=row[columnKey];var normalizedKey=normalizeValue(value);if(normalizedKey){uniqueNormalizedValues.add(normalizedKey)}});var sortedUniqueValues=Array.from(uniqueNormalizedValues).sort();hashParts[columnKey]=sortedUniqueValues}});return JSON.stringify(hashParts)}export function DataTable(_ref){var _ref2,_pagination$values$pa,_pagination$values,_ref3,_pagination$values$pa2,_pagination$values2;var _ref$data=_ref.data,data=_ref$data===void 0?[]:_ref$data,_ref$headerMapper=_ref.headerMapper,headerMapper=_ref$headerMapper===void 0?{}:_ref$headerMapper,_ref$className=_ref.className,className=_ref$className===void 0?"":_ref$className,_ref$actions=_ref.actions,actions=_ref$actions===void 0?[]:_ref$actions,_ref$isEditable=_ref.isEditable,isEditable=_ref$isEditable===void 0?false:_ref$isEditable,pagination=_ref.pagination,_ref$isLoading=_ref.isLoading,isLoading=_ref$isLoading===void 0?false:_ref$isLoading,onRowAction=_ref.onRowAction,onPageChange=_ref.onPageChange,onSort=_ref.onSort,sortConfig=_ref.sortConfig,_ref$otherProps=_ref.otherProps,otherProps=_ref$otherProps===void 0?{}:_ref$otherProps,height=_ref.height,_ref$decimalPrecision=_ref.decimalPrecision,decimalPrecision=_ref$decimalPrecision===void 0?2:_ref$decimalPrecision,_ref$columnWithChipCl=_ref.columnWithChipClass,columnWithChipClass=_ref$columnWithChipCl===void 0?{}:_ref$columnWithChipCl,_ref$chipStylesMappin=_ref.chipStylesMapping,chipStylesMapping=_ref$chipStylesMappin===void 0?{}:_ref$chipStylesMappin,_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];// Track which dropdown is currently open (by row index)
|
|
11
11
|
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
|
|
12
12
|
var availableKeys=Object.keys(data[0]||{});var newColorMap={};// Process each column that uses random chips
|
|
13
13
|
Object.keys(columnWithChipClass).forEach(function(columnKey){// Validate column key exists in data
|
|
14
14
|
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
|
|
15
|
-
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;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 ActionsDropdown(_ref6){var rowIndex=_ref6.rowIndex,rowActions=_ref6.rowActions;var isOpen=openDropdownIndex===rowIndex;// Simple check: if it's one of the last 3 rows, position dropdown above
|
|
15
|
+
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;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;// Simple check: if it's one of the last 3 rows, position dropdown above
|
|
16
16
|
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 actionKey;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:actionKey=rowIndex+"-"+action.id;if(!(action.action.formMapper&&Object.keys(action.action.formMapper).length>0)){_context2.next=7;break}setActiveRowIndex(rowIndex);setActiveAction(action);setOpenDropdownIndex(null);_context2.next=15;break;case 7:_context2.prev=7;setLoadingActionKey(actionKey);_context2.next=11;return onRowAction==null?void 0:onRowAction(rowIndex,action.id);case 11:_context2.prev=11;setLoadingActionKey(null);setOpenDropdownIndex(null);return _context2.finish(11);case 15:case"end":return _context2.stop()}},_callee2,null,[[7,,11,15]])}));return _handleActionClick.apply(this,arguments)}function toggleDropdown(){setOpenDropdownIndex(isOpen?null:rowIndex)}function handleBackdropClick(){// Only close if no action is currently running
|
|
17
|
-
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__*/
|
|
17
|
+
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:!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&&pagination.totalCount>0&&/*#__PURE__*/_jsxs("div",{className:"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[/*#__PURE__*/_jsx("label",{htmlFor:"page-size-select",className:"text-sm whitespace-nowrap",children:"Rows per page:"}),/*#__PURE__*/_jsx("select",{id:"page-size-select",value:pageSize,onChange:function onChange(e){return handlePageChange(1,Number(e.target.value))},className:"border rounded px-2 py-1 text-sm cursor-pointer",disabled:isLoading,children:pagination.pageSizeOptions.map(function(size){return/*#__PURE__*/_jsx("option",{value:size,children:size},size)})})]}),/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[title&&!isEditable&&onDownload&&/*#__PURE__*/_jsx(DownloadButton,{component:"table",title:title,onDownload:onDownload,dataCount:pagination==null?void 0:pagination.totalCount}),/*#__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]})}
|
|
18
18
|
//# 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","MoreVertical","Loader2","useButtonForm","DownloadButton","jsx","_jsx","jsxs","_jsxs","_Fragment","normalizeValue","value","undefined","str","String","trim","toLowerCase","getChipMode","columnWithChipClass","columnKey","mode","getUniqueValuesHash","data","Array","isArray","length","availableKeys","Object","keys","hashParts","forEach","includes","chipMode","uniqueNormalizedValues","Set","row","normalizedKey","add","sortedUniqueValues","from","sort","JSON","stringify","DataTable","_ref","_ref2","_pagination$values$pa","_pagination$values","_ref3","_pagination$values$pa2","_pagination$values2","_ref$data","_ref$headerMapper","headerMapper","_ref$className","className","_ref$actions","actions","_ref$isEditable","isEditable","pagination","_ref$isLoading","isLoading","onRowAction","onPageChange","onSort","sortConfig","_ref$otherProps","otherProps","height","_ref$decimalPrecision","decimalPrecision","_ref$columnWithChipCl","_ref$chipStylesMappin","chipStylesMapping","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","originalKeys","filter","key","headers","map","push","rows","datum","handlePageChange","_x2","_x3","_handlePageChange","_callee3","newPage","newSize","_callee3$","_context3","handleSortClick","column","direction","_extends2","ActionsDropdown","_ref6","rowIndex","rowActions","isOpen","totalRows","isNearBottom","handleActionClick","_x4","_handleActionClick","_callee2","actionKey","_callee2$","_context2","toggleDropdown","handleBackdropClick","onClick","background","cursor","variant","size","e","stopPropagation","disabled","role","isActionLoading","text","renderActions","defaultClasses","mergedClasses","getRandomColorForValue","_chipColorMap$columnK","renderChip","formattedValue","chipClassName","_chipStylesMapping$co","valueStr","valueLower","renderTableComponent","head","idx","isActionColumn","originalKey","contentEditable","isActive","sortable","rIdx","cell","cIdx","shouldRenderChip","orientation","htmlFor","onChange","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 { MoreVertical, Loader2 } from 'lucide-react';\nimport { useButtonForm } from './button-form';\nimport { DownloadButton } from './download-data-button';\n\ntype RowAction = {\n id: string;\n text: string;\n variant?: string;\n tooltipContent?: string;\n className?: string;\n action: any;\n};\n\nexport type DataTableProps = {\n data: Record<string, any>[];\n headerMapper?: Record<string, string>;\n className?: string;\n isEditable?: boolean;\n actions?: RowAction[];\n pagination?: {\n values?: {\n pageNumber: number;\n pageSize: number;\n };\n initialPage?: number;\n initialPageSize?: number;\n totalCount: number;\n pageSizeOptions: number[];\n };\n isLoading?: boolean;\n onRowAction?: (rowIndex: number, actionId: string, formData?: Record<string, any>) => void;\n onPageChange?: (pageNumber: number, pageSize: number) => void;\n onSort?: (column: string, direction: SortDirection) => void;\n sortConfig?: Record<string, SortDirection>;\n otherProps?: Record<string, any>;\n height?: string | number;\n decimalPrecision?: number;\n columnWithChipClass?: Record<string, 'useMap' | 'useRandom'>;\n chipStylesMapping?: Record<string, Record<string, string>>;\n 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 if (chipMode === 'useRandom') {\n const uniqueNormalizedValues = new Set<string>();\n data.forEach((row) => {\n const value = row[columnKey];\n const normalizedKey = normalizeValue(value);\n\n if (normalizedKey) {\n uniqueNormalizedValues.add(normalizedKey);\n }\n });\n const sortedUniqueValues = Array.from(uniqueNormalizedValues).sort();\n hashParts[columnKey] = sortedUniqueValues;\n }\n });\n\n return JSON.stringify(hashParts);\n}\n\nexport function DataTable({\n data = [],\n headerMapper = {},\n className = '',\n actions = [],\n isEditable = false,\n pagination,\n isLoading = false,\n onRowAction,\n onPageChange,\n onSort,\n sortConfig,\n otherProps = {},\n height,\n decimalPrecision = 2,\n columnWithChipClass = {},\n chipStylesMapping = {},\n 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 // Track which dropdown is currently open (by row index)\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 if (chipMode === 'useRandom') {\n if (!newColorMap[columnKey]) {\n newColorMap[columnKey] = {};\n }\n\n const uniqueNormalizedValues = new Set<string>();\n data.forEach((row) => {\n const value = row[columnKey];\n const normalizedKey = normalizeValue(value);\n\n if (normalizedKey) {\n uniqueNormalizedValues.add(normalizedKey);\n }\n });\n\n const sortedUniqueValues = Array.from(uniqueNormalizedValues).sort();\n\n sortedUniqueValues.forEach((normalizedKey, index) => {\n if (!newColorMap[columnKey][normalizedKey]) {\n const colorIndex = index % RANDOM_CHIP_COLOR_PALETTE.length;\n newColorMap[columnKey][normalizedKey] = RANDOM_CHIP_COLOR_PALETTE[colorIndex];\n }\n });\n }\n });\n\n return newColorMap;\n }, [data, columnWithChipClass]);\n\n useEffect(() => {\n const uniqueValuesHash = getUniqueValuesHash(data, columnWithChipClass);\n\n // Only update if the set of unique values actually changed\n if (uniqueValuesHash !== prevDataHashRef.current) {\n prevDataHashRef.current = uniqueValuesHash;\n\n setChipColorMap((prevMap) => {\n const merged = { ...prevMap };\n Object.keys(computedColorMap).forEach((columnKey) => {\n merged[columnKey] = { ...computedColorMap[columnKey], ...merged[columnKey] };\n });\n return merged;\n });\n }\n }, [computedColorMap, data, columnWithChipClass]);\n\n useEffect(() => {\n setChipColorMap((prevMap) => {\n const cleaned = { ...prevMap };\n let hasChanges = false;\n\n Object.keys(cleaned).forEach((columnKey) => {\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n if (!chipMode) {\n delete cleaned[columnKey];\n hasChanges = true;\n }\n });\n\n return hasChanges ? cleaned : prevMap;\n });\n }, [columnWithChipClass]);\n\n const { FormDialog, openForm } = useButtonForm({\n formMapper: activeAction?.action.formMapper,\n formTitle: activeAction?.action.formTitle,\n formDescription: activeAction?.action.formDescription,\n formButtonText: activeAction?.action.formButtonText,\n isSubmitting: isFormSubmitting || isLoading,\n onClose: () => {\n setActiveRowIndex(null);\n setActiveAction(null);\n },\n onSubmit: async (formData) => {\n if (activeRowIndex !== null && activeAction) {\n setIsFormSubmitting(true);\n try {\n await onRowAction?.(activeRowIndex, activeAction.id, formData);\n } finally {\n setIsFormSubmitting(false);\n }\n\n setActiveAction(null);\n setActiveRowIndex(null);\n }\n },\n });\n\n 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 ActionsDropdown({\n rowIndex,\n rowActions,\n }: {\n rowIndex: number;\n rowActions: RowAction[];\n }) {\n const isOpen = openDropdownIndex === rowIndex;\n\n // Simple check: if it's one of the last 3 rows, position dropdown above\n const totalRows = rows.length;\n const isNearBottom = rowIndex >= totalRows - 3;\n\n async function handleActionClick(action: RowAction) {\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 // Only close if no action is currently running\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 && (\n <Loader2 className=\"h-3 w-3 animate-spin\" />\n )}\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 {headers.map((head: string, idx: number) => {\n const isActionColumn = actions.length > 0 && idx === headers.length - 1;\n const originalKey = originalKeys[idx];\n\n if (isActionColumn) {\n return (\n <TableHead\n key={idx}\n data-slot={`table-header-${idx}`}\n contentEditable={isEditable}\n className=\"sticky right-0 bg-slate-100\"\n >\n {head}\n </TableHead>\n );\n }\n\n return (\n <TableHeadSortable\n key={idx}\n data-slot={`table-header-${idx}`}\n sortDirection={sortDirections[originalKey] || 'asc'}\n isActive={activeSortColumn === originalKey}\n onSort={(direction) => handleSortClick(originalKey, direction)}\n sortable={!isLoading}\n isEditable={isEditable}\n >\n {head}\n </TableHeadSortable>\n );\n })}\n </TableRow>\n </TableHeader>\n <TableBody data-slot=\"table-body\">\n {rows.map((row: any[], rIdx: number) => (\n <TableRow\n key={rIdx}\n data-slot={`row-${rIdx}`}\n className=\"hover:bg-muted/50 border-b transition-colors\"\n >\n {row.map((cell: string, cIdx: number) => {\n const columnKey = originalKeys[cIdx];\n const chipMode = columnKey\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 && pagination.totalCount > 0 && (\n <div className=\"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2\">\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n <label htmlFor=\"page-size-select\" className=\"text-sm whitespace-nowrap\">\n Rows per page:\n </label>\n <select\n id=\"page-size-select\"\n value={pageSize}\n onChange={(e) => handlePageChange(1, Number(e.target.value))}\n className=\"border rounded px-2 py-1 text-sm cursor-pointer\"\n disabled={isLoading}\n >\n {pagination.pageSizeOptions.map((size: number) => (\n <option key={size} value={size}>\n {size}\n </option>\n ))}\n </select>\n </div>\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n {title && !isEditable && onDownload && (\n <DownloadButton\n component=\"table\"\n title={title}\n onDownload={onDownload}\n dataCount={pagination?.totalCount}\n />\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 </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,YAAY,CAAEC,OAAO,KAAQ,cAAc,CACpD,OAASC,aAAa,KAAQ,eAAe,CAC7C,OAASC,cAAc,KAAQ,wBAAwB,CAAC,OAAA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E,MAAM,CAACgH,CAAC,CAACgC,MAAM,CAACxO,KAAK,CAAC,CAAC,CAAC,CAC7D4C,SAAS,CAAC,iDAAiD,CAC3D8J,QAAQ,CAAEvJ,SAAU,CAAAe,QAAA,CAEnBjB,UAAU,CAACwL,eAAe,CAACvE,GAAG,CAAC,SAACqC,IAAY,qBAC3C5M,IAAA,WAAmBK,KAAK,CAAEuM,IAAK,CAAArI,QAAA,CAC5BqI,IAAI,EADMA,IAEL,CAAC,CACV,CAAC,CACI,CAAC,EACN,CAAC,cACN1M,KAAA,QAAK+C,SAAS,CAAC,uCAAuC,CAAAsB,QAAA,EACnDF,KAAK,EAAI,CAAChB,UAAU,EAAIiB,UAAU,eACjCtE,IAAA,CAACF,cAAc,EACbiP,SAAS,CAAC,OAAO,CACjB1K,KAAK,CAAEA,KAAM,CACbC,UAAU,CAAEA,UAAW,CACvB0K,SAAS,CAAE1L,UAAU,cAAVA,UAAU,CAAEmD,UAAW,CACnC,CACF,cACDvG,KAAA,SAAM+C,SAAS,CAAC,wDAAwD,CAAAsB,QAAA,EACrE,CAACwB,UAAU,CAAG,CAAC,EAAII,QAAQ,CAAG,CAAC,CAAC,QACjC,CAACI,IAAI,CAAC0I,GAAG,CAAClJ,UAAU,CAAGI,QAAQ,CAAE7C,UAAU,CAACmD,UAAU,CAAC,CAAC,MAAI,CAACnD,UAAU,CAACmD,UAAU,EAC9E,CAAC,cACPzG,IAAA,CAACd,UAAU,EAAAqF,QAAA,cACTvE,IAAA,CAACb,iBAAiB,EAAC8D,SAAS,CAAC,uBAAuB,CAAAsB,QAAA,CACjDnF,sBAAsB,CAAC2G,UAAU,CAAEW,UAAU,CAAElD,SAAS,CAAEmH,gBAAgB,CAAC,CAC3D,CAAC,CACV,CAAC,EACV,CAAC,EACH,CACN,CACAV,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","normalizeValue","value","undefined","str","String","trim","toLowerCase","getChipMode","columnWithChipClass","columnKey","mode","getUniqueValuesHash","data","Array","isArray","length","availableKeys","Object","keys","hashParts","forEach","includes","chipMode","uniqueNormalizedValues","Set","row","normalizedKey","add","sortedUniqueValues","from","sort","JSON","stringify","DataTable","_ref","_ref2","_pagination$values$pa","_pagination$values","_ref3","_pagination$values$pa2","_pagination$values2","_ref$data","_ref$headerMapper","headerMapper","_ref$className","className","_ref$actions","actions","_ref$isEditable","isEditable","pagination","_ref$isLoading","isLoading","onRowAction","onPageChange","onSort","sortConfig","_ref$otherProps","otherProps","height","_ref$decimalPrecision","decimalPrecision","_ref$columnWithChipCl","_ref$chipStylesMappin","chipStylesMapping","_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","originalKeys","filter","key","headers","map","push","rows","datum","handlePageChange","_x2","_x3","_handlePageChange","_callee3","newPage","newSize","_callee3$","_context3","handleSortClick","column","direction","_extends2","handleCheckboxClick","rowIndex","idx","concat","ActionsDropdown","_ref6","rowActions","isOpen","totalRows","isNearBottom","handleActionClick","_x4","_handleActionClick","_callee2","actionKey","_callee2$","_context2","toggleDropdown","handleBackdropClick","onClick","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","sortable","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\ntype RowAction = {\n id: string;\n text: string;\n variant?: string;\n tooltipContent?: string;\n className?: string;\n action: any;\n};\n\nexport type DataTableProps = {\n data: Record<string, any>[];\n headerMapper?: Record<string, string>;\n className?: string;\n isEditable?: boolean;\n actions?: RowAction[];\n pagination?: {\n values?: {\n pageNumber: number;\n pageSize: number;\n };\n initialPage?: number;\n initialPageSize?: number;\n totalCount: number;\n pageSizeOptions: number[];\n };\n isLoading?: boolean;\n onRowAction?: (rowIndex: number, actionId: string, formData?: Record<string, any>) => void;\n onPageChange?: (pageNumber: number, pageSize: number) => void;\n onSort?: (column: string, direction: SortDirection) => void;\n sortConfig?: Record<string, SortDirection>;\n otherProps?: Record<string, any>;\n height?: string | number;\n decimalPrecision?: number;\n columnWithChipClass?: Record<string, 'useMap' | 'useRandom'>;\n chipStylesMapping?: Record<string, Record<string, string>>;\n 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 if (chipMode === 'useRandom') {\n const uniqueNormalizedValues = new Set<string>();\n data.forEach((row) => {\n const value = row[columnKey];\n const normalizedKey = normalizeValue(value);\n\n if (normalizedKey) {\n uniqueNormalizedValues.add(normalizedKey);\n }\n });\n const sortedUniqueValues = Array.from(uniqueNormalizedValues).sort();\n hashParts[columnKey] = sortedUniqueValues;\n }\n });\n\n return JSON.stringify(hashParts);\n}\n\nexport function DataTable({\n data = [],\n headerMapper = {},\n className = '',\n actions = [],\n isEditable = false,\n pagination,\n isLoading = false,\n onRowAction,\n onPageChange,\n onSort,\n sortConfig,\n otherProps = {},\n height,\n decimalPrecision = 2,\n columnWithChipClass = {},\n chipStylesMapping = {},\n 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 // Track which dropdown is currently open (by row index)\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 if (chipMode === 'useRandom') {\n if (!newColorMap[columnKey]) {\n newColorMap[columnKey] = {};\n }\n\n const uniqueNormalizedValues = new Set<string>();\n data.forEach((row) => {\n const value = row[columnKey];\n const normalizedKey = normalizeValue(value);\n\n if (normalizedKey) {\n uniqueNormalizedValues.add(normalizedKey);\n }\n });\n\n const sortedUniqueValues = Array.from(uniqueNormalizedValues).sort();\n\n sortedUniqueValues.forEach((normalizedKey, index) => {\n if (!newColorMap[columnKey][normalizedKey]) {\n const colorIndex = index % RANDOM_CHIP_COLOR_PALETTE.length;\n newColorMap[columnKey][normalizedKey] = RANDOM_CHIP_COLOR_PALETTE[colorIndex];\n }\n });\n }\n });\n\n return newColorMap;\n }, [data, columnWithChipClass]);\n\n useEffect(() => {\n const uniqueValuesHash = getUniqueValuesHash(data, columnWithChipClass);\n\n // Only update if the set of unique values actually changed\n if (uniqueValuesHash !== prevDataHashRef.current) {\n prevDataHashRef.current = uniqueValuesHash;\n\n setChipColorMap((prevMap) => {\n const merged = { ...prevMap };\n Object.keys(computedColorMap).forEach((columnKey) => {\n merged[columnKey] = { ...computedColorMap[columnKey], ...merged[columnKey] };\n });\n return merged;\n });\n }\n }, [computedColorMap, data, columnWithChipClass]);\n\n useEffect(() => {\n setChipColorMap((prevMap) => {\n const cleaned = { ...prevMap };\n let hasChanges = false;\n\n Object.keys(cleaned).forEach((columnKey) => {\n const chipMode = getChipMode(columnWithChipClass, columnKey);\n if (!chipMode) {\n delete cleaned[columnKey];\n hasChanges = true;\n }\n });\n\n return hasChanges ? cleaned : prevMap;\n });\n }, [columnWithChipClass]);\n\n const { FormDialog, openForm } = useButtonForm({\n formMapper: activeAction?.action.formMapper,\n formTitle: activeAction?.action.formTitle,\n formDescription: activeAction?.action.formDescription,\n formButtonText: activeAction?.action.formButtonText,\n isSubmitting: isFormSubmitting || isLoading,\n onClose: () => {\n setActiveRowIndex(null);\n setActiveAction(null);\n },\n onSubmit: async (formData) => {\n if (activeRowIndex !== null && activeAction) {\n setIsFormSubmitting(true);\n try {\n await onRowAction?.(activeRowIndex, activeAction.id, formData);\n } finally {\n setIsFormSubmitting(false);\n }\n\n setActiveAction(null);\n setActiveRowIndex(null);\n }\n },\n });\n\n 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 // Simple check: if it's one of the last 3 rows, position dropdown above\n const totalRows = rows.length;\n const isNearBottom = rowIndex >= totalRows - 3;\n\n async function handleActionClick(action: RowAction) {\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 // Only close if no action is currently running\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 && (\n <Loader2 className=\"h-3 w-3 animate-spin\" />\n )}\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={!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 && pagination.totalCount > 0 && (\n <div className=\"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2\">\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n <label htmlFor=\"page-size-select\" className=\"text-sm whitespace-nowrap\">\n Rows per page:\n </label>\n <select\n id=\"page-size-select\"\n value={pageSize}\n onChange={(e) => handlePageChange(1, Number(e.target.value))}\n className=\"border rounded px-2 py-1 text-sm cursor-pointer\"\n disabled={isLoading}\n >\n {pagination.pageSizeOptions.map((size: number) => (\n <option key={size} value={size}>\n {size}\n </option>\n ))}\n </select>\n </div>\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n {title && !isEditable && onDownload && (\n <DownloadButton\n component=\"table\"\n title={title}\n onDownload={onDownload}\n dataCount={pagination?.totalCount}\n />\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 </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,yBA4CxD;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,cAAcA,CAACC,KAAU,C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2 +1,2 @@
|
|
|
1
|
-
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _regeneratorRuntime from"@babel/runtime/regenerator";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}function downloadChartSVG(title,containerRef,subtitle){if(!containerRef.current)return;var cardElement=containerRef.current.closest("[class*=\"shadow\"][class*=\"border\"]");if(!cardElement)return;var chartContainer=containerRef.current;var svgElement=chartContainer.querySelector("svg");if(!svgElement)return;var legendItems=getLegendItems(chartContainer);var svgRect=svgElement.getBoundingClientRect();var chartWidth=svgRect.width;var chartHeight=svgRect.height;var padding=20;var titleHeight=30;var subtitleHeight=subtitle?20:0;var legendHeight=legendItems.length>0?30:0;var headerHeight=titleHeight+subtitleHeight+padding;var totalWidth=chartWidth+padding*2;var totalHeight=chartHeight+headerHeight+legendHeight+padding;var serializer=new XMLSerializer;var chartSvgString=serializer.serializeToString(svgElement);var compositeSvg="<svg xmlns=\"http://www.w3.org/2000/svg\" width=\""+totalWidth+"\" height=\""+totalHeight+"\">\n <!-- White background -->\n <rect width=\""+totalWidth+"\" height=\""+totalHeight+"\" fill=\"white\"/>\n\n <!-- Title -->\n <text x=\""+padding+"\" y=\""+(padding+20)+"\" font-family=\"Arial, sans-serif\" font-size=\"18\" font-weight=\"600\" fill=\"#000000\">"+title+"</text>\n "+(subtitle?"<text x=\""+padding+"\" y=\""+(padding+45)+"\" font-family=\"Arial, sans-serif\" font-size=\"14\" fill=\"#666666\">"+subtitle+"</text>":"")+"\n\n <!-- Chart -->\n <g transform=\"translate("+padding+", "+headerHeight+")\">\n "+chartSvgString.replace(/<svg[^>]*>/,"").replace(/<\/svg>$/,"")+"\n </g>\n\n "+(legendItems.length>0?"<!-- Legend -->\n <g transform=\"translate("+padding+", "+(totalHeight-25)+")\">\n "+legendItems.map(function(item,index){var xOffset=index*200;return"\n <rect x=\""+xOffset+"\" y=\"0\" width=\"12\" height=\"12\" fill=\""+item.color+"\" />\n <text x=\""+(xOffset+18)+"\" y=\"10\" font-family=\"Arial, sans-serif\" font-size=\"12\" fill=\"#666666\">"+item.text+"</text>\n "}).join("")+"\n </g>":"")+"\n </svg>";var svgBlob=new Blob([compositeSvg],{type:"image/svg+xml;charset=utf-8"});var url=URL.createObjectURL(svgBlob);var link=document.createElement("a");link.href=url;link.download=title.replace(/\s+/g,"_")+".svg";link.click();URL.revokeObjectURL(url)}function downloadChartPNG(title,containerRef,subtitle){if(!containerRef.current)return;var cardElement=containerRef.current.closest("[class*=\"shadow\"][class*=\"border\"]");if(!cardElement)return;var downloadBtn=cardElement.querySelector("[title=\"Download chart\"]");if(downloadBtn){var _downloadBtn$parentEl;(_downloadBtn$parentEl=downloadBtn.parentElement)==null||_downloadBtn$parentEl.remove()}var infoBtn=cardElement.querySelector("[class*=\"top-right\"]");if(infoBtn){infoBtn.remove()}var rect=cardElement.getBoundingClientRect();var width=rect.width;var height=rect.height;var canvas=document.createElement("canvas");var scale=2;canvas.width=width*scale;canvas.height=height*scale;var ctx=canvas.getContext("2d");if(!ctx)return;ctx.scale(scale,scale);ctx.fillStyle="white";ctx.fillRect(0,0,width,height);var svgElement=containerRef.current.querySelector("svg");if(!svgElement)return;var svgRect=svgElement.getBoundingClientRect();var cardRect=cardElement.getBoundingClientRect();var svgOffsetX=svgRect.left-cardRect.left;var svgOffsetY=svgRect.top-cardRect.top;var serializer=new XMLSerializer;var svgString=serializer.serializeToString(svgElement);if(!svgString.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)){svgString=svgString.replace(/^<svg/,"<svg xmlns=\"http://www.w3.org/2000/svg\"")}var legendItems=getLegendItems(containerRef.current);ctx.font="600 18px Arial";ctx.fillStyle="#000000";ctx.fillText(title,24,40);if(subtitle){ctx.font="14px Arial";ctx.fillStyle="#666666";ctx.fillText(subtitle,24,62)}if(legendItems.length>0){var legendX=24;var legendY=height-15;legendItems.forEach(function(item){ctx.fillStyle=item.color;ctx.fillRect(legendX,legendY-10,12,12);ctx.font="12px Arial";ctx.fillStyle="#666666";ctx.fillText(item.text,legendX+18,legendY);legendX+=ctx.measureText(item.text).width+50})}var img=new Image;var svgBlob=new Blob([svgString],{type:"image/svg+xml;charset=utf-8"});var url=URL.createObjectURL(svgBlob);img.onload=function(){ctx.drawImage(img,svgOffsetX,svgOffsetY,svgRect.width,svgRect.height);canvas.toBlob(function(blob){if(blob){var pngUrl=URL.createObjectURL(blob);var link=document.createElement("a");link.href=pngUrl;link.download=title.replace(/\s+/g,"_")+".png";link.click();URL.revokeObjectURL(pngUrl)}},"image/png");URL.revokeObjectURL(url)};img.onerror=function(){console.error("Failed to load SVG as image");URL.revokeObjectURL(url)};img.src=url}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=11;break;case 10:if(selectedFormat==="png"){downloadChartPNG(title,containerRef,subtitle)}else{downloadChartSVG(title,containerRef,subtitle)}case 11:setIsModalOpen(false);case 12:case"end":return _context.stop()}},_callee,null,[[2,,5,8]])}));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";import{useState}from"react";import{toPng}from"html-to-image";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}function downloadChartSVG(title,containerRef,subtitle){if(!containerRef.current)return;var cardElement=containerRef.current.closest("[class*=\"shadow\"][class*=\"border\"]");if(!cardElement)return;var chartContainer=containerRef.current;var svgElement=chartContainer.querySelector("svg");if(!svgElement)return;var legendItems=getLegendItems(chartContainer);var svgRect=svgElement.getBoundingClientRect();var chartWidth=svgRect.width;var chartHeight=svgRect.height;var padding=20;var titleHeight=30;var subtitleHeight=subtitle?20:0;var legendHeight=legendItems.length>0?30:0;var headerHeight=titleHeight+subtitleHeight+padding;var totalWidth=chartWidth+padding*2;var totalHeight=chartHeight+headerHeight+legendHeight+padding;var serializer=new XMLSerializer;var chartSvgString=serializer.serializeToString(svgElement);var compositeSvg="<svg xmlns=\"http://www.w3.org/2000/svg\" width=\""+totalWidth+"\" height=\""+totalHeight+"\">\n <!-- White background -->\n <rect width=\""+totalWidth+"\" height=\""+totalHeight+"\" fill=\"white\"/>\n\n <!-- Title -->\n <text x=\""+padding+"\" y=\""+(padding+20)+"\" font-family=\"Arial, sans-serif\" font-size=\"18\" font-weight=\"600\" fill=\"#000000\">"+title+"</text>\n "+(subtitle?"<text x=\""+padding+"\" y=\""+(padding+45)+"\" font-family=\"Arial, sans-serif\" font-size=\"14\" fill=\"#666666\">"+subtitle+"</text>":"")+"\n\n <!-- Chart -->\n <g transform=\"translate("+padding+", "+headerHeight+")\">\n "+chartSvgString.replace(/<svg[^>]*>/,"").replace(/<\/svg>$/,"")+"\n </g>\n\n "+(legendItems.length>0?"<!-- Legend -->\n <g transform=\"translate("+padding+", "+(totalHeight-25)+")\">\n "+legendItems.map(function(item,index){var xOffset=index*200;return"\n <rect x=\""+xOffset+"\" y=\"0\" width=\"12\" height=\"12\" fill=\""+item.color+"\" />\n <text x=\""+(xOffset+18)+"\" y=\"10\" font-family=\"Arial, sans-serif\" font-size=\"12\" fill=\"#666666\">"+item.text+"</text>\n "}).join("")+"\n </g>":"")+"\n </svg>";var svgBlob=new Blob([compositeSvg],{type:"image/svg+xml;charset=utf-8"});var url=URL.createObjectURL(svgBlob);var link=document.createElement("a");link.href=url;link.download=title.replace(/\s+/g,"_")+".svg";link.click();URL.revokeObjectURL(url)}function downloadChartPNG(_x,_x2){return _downloadChartPNG.apply(this,arguments)}function _downloadChartPNG(){_downloadChartPNG=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(title,containerRef){var cardElement,dataUrl,link;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:cardElement=containerRef.current.closest("[class*=\"shadow\"][class*=\"border\"]");if(cardElement){_context3.next=5;break}return _context3.abrupt("return");case 5:_context3.next=7;return toPng(cardElement,{pixelRatio:2,backgroundColor:"white",filter:function filter(node){var _el$className;var el=node;return(el.getAttribute==null?void 0:el.getAttribute("title"))!=="Download chart"&&!((_el$className=el.className)!=null&&_el$className.toString().includes("top-right"))}});case 7:dataUrl=_context3.sent;link=document.createElement("a");link.download=title.replace(/\s+/g,"_")+".png";link.href=dataUrl;link.click();case 12: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=11;break;case 10:if(selectedFormat==="png"){downloadChartPNG(title,containerRef)}else{downloadChartSVG(title,containerRef,subtitle)}case 11:setIsModalOpen(false);case 12:case"end":return _context.stop()}},_callee,null,[[2,,5,8]])}));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"})]})})]})})]})}
|
|
2
2
|
//# sourceMappingURL=download-data-button.js.map
|