@peak-ai/canvas 1.6.5 → 1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -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";/* eslint-disable @typescript-eslint/no-explicit-any */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}),formDescription&&/*#__PURE__*/_jsx(DialogDescription,{children:formDescription})]}),/*#__PURE__*/_jsxs("form",{onSubmit:handleFormSubmit,children:[/*#__PURE__*/_jsx(FieldGroup,{children:formMapper&&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}),
|
|
1
|
+
import _extends from"@babel/runtime/helpers/extends";import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _regeneratorRuntime from"@babel/runtime/regenerator";/* eslint-disable @typescript-eslint/no-explicit-any */import{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}),formDescription&&/*#__PURE__*/_jsx(DialogDescription,{children:formDescription})]}),/*#__PURE__*/_jsxs("form",{onSubmit:handleFormSubmit,children:[/*#__PURE__*/_jsx(FieldGroup,{children:formMapper&&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&&/*#__PURE__*/_jsx(Input,{id:fieldName,name:fieldName,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":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useState } from 'react';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogFooterError,\n DialogHeader,\n DialogTitle,\n} from '../../shadcn/components/ui/dialog';\nimport {\n Field,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n} 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\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\n setFormErrors(errors);\n\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\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\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 =\n 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\n return true;\n }\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\n return newErrors;\n });\n }\n }\n\n const FormDialog =\n hasForm && isFormOpen ? (\n <Dialog open={isFormOpen} onOpenChange={handleOpenChange}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{formTitle}</DialogTitle>\n {formDescription && <DialogDescription>{formDescription}</DialogDescription>}\n </DialogHeader>\n\n <form onSubmit={handleFormSubmit}>\n <FieldGroup>\n {formMapper &&\n Object.entries(formMapper).map(([fieldName, fieldConfig]) => {\n const hasError = showErrors && formErrors[fieldName];\n\n if (typeof fieldConfig !== 'object') {\n return null;\n }\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' ||\n fieldConfig.type === 'string' ||\n 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={\n hasError ? 'border-destructive focus-visible:ring-destructive' : ''\n }\n aria-invalid={hasError ? 'true' : 'false'}\n aria-describedby={hasError ? `${fieldName}-error` : undefined}\n />\n )}\n {hasError && (\n <FieldError id={`${fieldName}-error`}>{formErrors[fieldName]}</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 <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}\n"],"mappings":"wLAAA,uDACA,OAASA,QAAQ,KAAQ,OAAO,CAChC,OACEC,MAAM,CACNC,aAAa,CACbC,iBAAiB,CACjBC,YAAY,CACZC,iBAAiB,CACjBC,YAAY,CACZC,WAAW,KACN,mCAAmC,CAC1C,OACEC,KAAK,CACLC,gBAAgB,CAChBC,UAAU,CACVC,UAAU,CACVC,UAAU,KACL,kCAAkC,CACzC,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,CACD,GACE,CAAAC,UAAU,CAORD,MAAM,CAPRC,UAAU,CACVC,QAAQ,CAMNF,MAAM,CANRE,QAAQ,CAAAC,oBAAA,CAMNH,MAAM,CALRI,YAAY,CAAZA,YAAY,CAAAD,oBAAA,UAAG,KAAK,CAAAA,oBAAA,CAAAE,iBAAA,CAKlBL,MAAM,CAJRM,SAAS,CAATA,SAAS,CAAAD,iBAAA,UAAG,YAAY,CAAAA,iBAAA,CAAAE,qBAAA,CAItBP,MAAM,CAHRQ,eAAe,CAAfA,eAAe,CAAAD,qBAAA,UAAG,uCAAuC,CAAAA,qBAAA,CAAAE,qBAAA,CAGvDT,MAAM,CAFRU,cAAc,CAAdA,cAAc,CAAAD,qBAAA,UAAG,QAAQ,CAAAA,qBAAA,CACzBE,OAA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
{"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":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useState } from 'react';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogFooterError,\n DialogHeader,\n DialogTitle,\n} from '../../shadcn/components/ui/dialog';\nimport {\n Field,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n} 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\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\n setFormErrors(errors);\n\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\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\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 =\n 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\n return true;\n }\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\n return newErrors;\n });\n }\n }\n\n const FormDialog =\n hasForm && isFormOpen ? (\n <Dialog open={isFormOpen} onOpenChange={handleOpenChange}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{formTitle}</DialogTitle>\n {formDescription && <DialogDescription>{formDescription}</DialogDescription>}\n </DialogHeader>\n\n <form onSubmit={handleFormSubmit}>\n <FieldGroup>\n {formMapper &&\n Object.entries(formMapper).map(([fieldName, fieldConfig]) => {\n const hasError = showErrors && formErrors[fieldName];\n\n if (typeof fieldConfig !== 'object') {\n return null;\n }\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 && (\n <Input\n id={fieldName}\n name={fieldName}\n 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={\n hasError ? 'border-destructive focus-visible:ring-destructive' : ''\n }\n aria-invalid={hasError ? 'true' : 'false'}\n aria-describedby={hasError ? `${fieldName}-error` : undefined}\n />\n )}\n {hasError && (\n <FieldError id={`${fieldName}-error`}>{formErrors[fieldName]}</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 <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}\n"],"mappings":"wLAAA,uDACA,OAASA,QAAQ,KAAQ,OAAO,CAChC,OACEC,MAAM,CACNC,aAAa,CACbC,iBAAiB,CACjBC,YAAY,CACZC,iBAAiB,CACjBC,YAAY,CACZC,WAAW,KACN,mCAAmC,CAC1C,OACEC,KAAK,CACLC,gBAAgB,CAChBC,UAAU,CACVC,UAAU,CACVC,UAAU,KACL,kCAAkC,CACzC,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,CACD,GACE,CAAAC,UAAU,CAORD,MAAM,CAPRC,UAAU,CACVC,QAAQ,CAMNF,MAAM,CANRE,QAAQ,CAAAC,oBAAA,CAMNH,MAAM,CALRI,YAAY,CAAZA,YAAY,CAAAD,oBAAA,UAAG,KAAK,CAAAA,oBAAA,CAAAE,iBAAA,CAKlBL,MAAM,CAJRM,SAAS,CAATA,SAAS,CAAAD,iBAAA,UAAG,YAAY,CAAAA,iBAAA,CAAAE,qBAAA,CAItBP,MAAM,CAHRQ,eAAe,CAAfA,eAAe,CAAAD,qBAAA,UAAG,uCAAuC,CAAAA,qBAAA,CAAAE,qBAAA,CAGvDT,MAAM,CAFRU,cAAc,CAAdA,cAAc,CAAAD,qBAAA,UAAG,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