@beyondcorp/beyond-ui 1.0.95 → 1.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import { Modal } from '../Modal/Modal.js';
|
|
3
4
|
import { Button } from '../Button/Button.js';
|
|
4
5
|
import { Input } from '../Input/Input.js';
|
|
@@ -12,11 +13,13 @@ const EditModal = ({ open, title, description, fields, onChange, onSave, onClose
|
|
|
12
13
|
if (field.type === "custom") {
|
|
13
14
|
return jsx("div", { children: field.render() }, field.name);
|
|
14
15
|
}
|
|
16
|
+
// Title above every input/textarea
|
|
17
|
+
const title = (jsx("div", { className: "mb-1 font-medium text-gray-700", children: field.label }, field.name + "-title"));
|
|
15
18
|
if (field.type === "textarea") {
|
|
16
|
-
return (jsx(Textarea, { name: field.name, value: field.value, placeholder: field.placeholder
|
|
19
|
+
return (jsxs(React.Fragment, { children: [title, jsx(Textarea, { name: field.name, value: field.value, placeholder: field.placeholder, rows: field.rows || 3, required: field.required, onChange: e => field.onChange ? field.onChange(e) : onChange(field.name, e.target.value), className: "w-full" })] }, field.name));
|
|
17
20
|
}
|
|
18
21
|
// Default: Input
|
|
19
|
-
return (jsx(Input, { type: field.type, name: field.name, value: field.value, placeholder: field.placeholder
|
|
22
|
+
return (jsxs(React.Fragment, { children: [title, jsx(Input, { type: field.type, name: field.name, value: field.value, placeholder: field.placeholder, required: field.required, autoFocus: field.autoFocus, onChange: e => field.onChange ? field.onChange(e) : onChange(field.name, e.target.value), className: "w-full" })] }, field.name));
|
|
20
23
|
}) }), jsxs("div", { className: "flex justify-end space-x-2 mt-8", children: [jsx(Button, { type: "button", variant: "secondary", onClick: onClose, children: closeLabel }), jsx(Button, { type: "submit", variant: "primary", disabled: saving, children: saveLabel })] })] })] }) }));
|
|
21
24
|
EditModal.displayName = "EditModal";
|
|
22
25
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditModal.js","sources":["../../../src/components/ProfileManagement/EditModal.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport { Modal } from \"../Modal/Modal\";\r\nimport { Button } from \"../Button\";\r\nimport { Input } from \"../Input\";\r\nimport { Textarea } from \"../Textarea\";\r\nimport { cn } from \"../../utils/cn\";\r\n\r\nexport type EditModalField =\r\n | {\r\n type: \"text\" | \"email\" | \"tel\" | \"url\" | \"password\";\r\n label: string;\r\n name: string;\r\n value?: string;\r\n placeholder?: string;\r\n required?: boolean;\r\n autoFocus?: boolean;\r\n onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;\r\n }\r\n | {\r\n type: \"textarea\";\r\n label: string;\r\n name: string;\r\n value?: string;\r\n placeholder?: string;\r\n required?: boolean;\r\n rows?: number;\r\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\r\n }\r\n | {\r\n type: \"custom\";\r\n name: string;\r\n render: () => React.ReactNode;\r\n };\r\n\r\nexport interface EditModalProps {\r\n open: boolean;\r\n title?: string;\r\n description?: string;\r\n fields: EditModalField[];\r\n onChange: (name: string, value: string) => void;\r\n onSave: () => void;\r\n onClose: () => void;\r\n saving?: boolean;\r\n saveLabel?: string;\r\n closeLabel?: string;\r\n className?: string;\r\n}\r\n\r\nexport const EditModal: React.FC<EditModalProps> = ({\r\n open,\r\n title,\r\n description,\r\n fields,\r\n onChange,\r\n onSave,\r\n onClose,\r\n saving,\r\n saveLabel = \"Save Changes\",\r\n closeLabel = \"Close\",\r\n className,\r\n}) => (\r\n <Modal open={open}>\r\n <div className={cn(\"max-w-2xl rounded-2xl p-0 p-8 mx-auto bg-white\", className)}>\r\n {title && <h2 className=\"text-2xl font-bold mb-1 text-gray-900\">{title}</h2>}\r\n {description && <p className=\"text-gray-500 mb-6\">{description}</p>}\r\n <form\r\n className=\"space-y-6\"\r\n onSubmit={e => {\r\n e.preventDefault();\r\n onSave();\r\n }}\r\n >\r\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\r\n {fields.map((field, idx) => {\r\n if (field.type === \"custom\") {\r\n return <div key={field.name}>{field.render()}</div>;\r\n }\r\n if (field.type === \"textarea\") {\r\n return (\r\n <
|
|
1
|
+
{"version":3,"file":"EditModal.js","sources":["../../../src/components/ProfileManagement/EditModal.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport { Modal } from \"../Modal/Modal\";\r\nimport { Button } from \"../Button\";\r\nimport { Input } from \"../Input\";\r\nimport { Textarea } from \"../Textarea\";\r\nimport { cn } from \"../../utils/cn\";\r\n\r\nexport type EditModalField =\r\n | {\r\n type: \"text\" | \"email\" | \"tel\" | \"url\" | \"password\";\r\n label: string;\r\n name: string;\r\n value?: string;\r\n placeholder?: string;\r\n required?: boolean;\r\n autoFocus?: boolean;\r\n onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;\r\n }\r\n | {\r\n type: \"textarea\";\r\n label: string;\r\n name: string;\r\n value?: string;\r\n placeholder?: string;\r\n required?: boolean;\r\n rows?: number;\r\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\r\n }\r\n | {\r\n type: \"custom\";\r\n name: string;\r\n render: () => React.ReactNode;\r\n };\r\n\r\nexport interface EditModalProps {\r\n open: boolean;\r\n title?: string;\r\n description?: string;\r\n fields: EditModalField[];\r\n onChange: (name: string, value: string) => void;\r\n onSave: () => void;\r\n onClose: () => void;\r\n saving?: boolean;\r\n saveLabel?: string;\r\n closeLabel?: string;\r\n className?: string;\r\n}\r\n\r\nexport const EditModal: React.FC<EditModalProps> = ({\r\n open,\r\n title,\r\n description,\r\n fields,\r\n onChange,\r\n onSave,\r\n onClose,\r\n saving,\r\n saveLabel = \"Save Changes\",\r\n closeLabel = \"Close\",\r\n className,\r\n}) => (\r\n <Modal open={open}>\r\n <div className={cn(\"max-w-2xl rounded-2xl p-0 p-8 mx-auto bg-white\", className)}>\r\n {title && <h2 className=\"text-2xl font-bold mb-1 text-gray-900\">{title}</h2>}\r\n {description && <p className=\"text-gray-500 mb-6\">{description}</p>}\r\n <form\r\n className=\"space-y-6\"\r\n onSubmit={e => {\r\n e.preventDefault();\r\n onSave();\r\n }}\r\n >\r\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\r\n {fields.map((field, idx) => {\r\n if (field.type === \"custom\") {\r\n return <div key={field.name}>{field.render()}</div>;\r\n }\r\n // Title above every input/textarea\r\n const title = (\r\n <div key={field.name + \"-title\"} className=\"mb-1 font-medium text-gray-700\">\r\n {field.label}\r\n </div>\r\n );\r\n if (field.type === \"textarea\") {\r\n return (\r\n <React.Fragment key={field.name}>\r\n {title}\r\n <Textarea\r\n name={field.name}\r\n value={field.value}\r\n placeholder={field.placeholder}\r\n rows={field.rows || 3}\r\n required={field.required}\r\n onChange={e => field.onChange ? field.onChange(e) : onChange(field.name, e.target.value)}\r\n className=\"w-full\"\r\n />\r\n </React.Fragment>\r\n );\r\n }\r\n // Default: Input\r\n return (\r\n <React.Fragment key={field.name}>\r\n {title}\r\n <Input\r\n type={field.type}\r\n name={field.name}\r\n value={field.value}\r\n placeholder={field.placeholder}\r\n required={field.required}\r\n autoFocus={field.autoFocus}\r\n onChange={e => field.onChange ? field.onChange(e) : onChange(field.name, e.target.value)}\r\n className=\"w-full\"\r\n />\r\n </React.Fragment>\r\n );\r\n })}\r\n </div>\r\n <div className=\"flex justify-end space-x-2 mt-8\">\r\n <Button type=\"button\" variant=\"secondary\" onClick={onClose}>\r\n {closeLabel}\r\n </Button>\r\n <Button type=\"submit\" variant=\"primary\" disabled={saving}>\r\n {saveLabel}\r\n </Button>\r\n </div>\r\n </form>\r\n </div>\r\n </Modal>\r\n);\r\n\r\nEditModal.displayName = \"EditModal\";"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AAgDO,MAAM,SAAS,GAA6B,CAAC,EAClD,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,QAAQ,EACR,MAA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