@ramesesinc/app-forms 0.1.0
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/dist/components/AppContactForm.d.ts +2 -0
- package/dist/components/AppContactForm.js +13 -0
- package/dist/components/AppContactForm.tsx +80 -0
- package/dist/components/AppInitForm.d.ts +0 -0
- package/dist/components/AppInitForm.js +74 -0
- package/dist/components/AppInitForm.tsx +80 -0
- package/dist/components/AppOtpForm.d.ts +2 -0
- package/dist/components/AppOtpForm.js +25 -0
- package/dist/components/AppOtpForm.tsx +71 -0
- package/dist/components/AppSaveForm.d.ts +2 -0
- package/dist/components/AppSaveForm.js +8 -0
- package/dist/components/AppSaveForm.tsx +29 -0
- package/dist/components/ApplicantInfo.d.ts +2 -0
- package/dist/components/ApplicantInfo.js +29 -0
- package/dist/components/ApplicantInfo.tsx +125 -0
- package/dist/components/HtmlTemplate.d.ts +8 -0
- package/dist/components/HtmlTemplate.js +28 -0
- package/dist/components/HtmlTemplate.tsx +46 -0
- package/dist/components/NewPermitAppCodeForm.d.ts +2 -0
- package/dist/components/NewPermitAppCodeForm.js +6 -0
- package/dist/components/NewPermitAppCodeForm.tsx +22 -0
- package/dist/components/NewPermitAppForm.d.ts +2 -0
- package/dist/components/NewPermitAppForm.js +8 -0
- package/dist/components/NewPermitAppForm.tsx +26 -0
- package/dist/components/NewPermitAppTermForm.d.ts +2 -0
- package/dist/components/NewPermitAppTermForm.js +8 -0
- package/dist/components/NewPermitAppTermForm.tsx +33 -0
- package/dist/components/NewPermitAppTypeForm.d.ts +2 -0
- package/dist/components/NewPermitAppTypeForm.js +8 -0
- package/dist/components/NewPermitAppTypeForm.tsx +28 -0
- package/dist/components/PrivacyStatementForm.d.ts +0 -0
- package/dist/components/PrivacyStatementForm.js +49 -0
- package/dist/components/PrivacyStatementForm.tsx +55 -0
- package/dist/components/common/InputValidator.d.ts +13 -0
- package/dist/components/common/InputValidator.js +118 -0
- package/dist/components/common/InputValidator.tsx +252 -0
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.js +12 -0
- package/dist/components/index.ts +14 -0
- package/dist/components/test.d.ts +2 -0
- package/dist/components/test.js +5 -0
- package/dist/components/test.tsx +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styles/index.css +47 -0
- package/package.json +51 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { localAPI } from "@ramesesinc/lib/local-api";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
type HtmlTemplateProps = {
|
|
5
|
+
id: string;
|
|
6
|
+
module: string;
|
|
7
|
+
tenant: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const HtmlTemplate: React.FC<HtmlTemplateProps> = ({ id, module, tenant }) => {
|
|
11
|
+
const [html, setHtml] = useState<string>("");
|
|
12
|
+
const [error, setError] = useState<string | null>(null);
|
|
13
|
+
|
|
14
|
+
console.log("HtmlTemplate props:", { id, module, tenant });
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const fetchHtml = async () => {
|
|
17
|
+
try {
|
|
18
|
+
const mgmt = localAPI.useMgmt(tenant, module);
|
|
19
|
+
const data = await mgmt.get("html_templates", id);
|
|
20
|
+
|
|
21
|
+
console.log("Fetched HTML Template:", data);
|
|
22
|
+
setHtml(data?.htmlCode ?? "");
|
|
23
|
+
} catch (e: any) {
|
|
24
|
+
setHtml("");
|
|
25
|
+
setError(e.message || "Unknown error");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
fetchHtml();
|
|
29
|
+
}, [id]);
|
|
30
|
+
|
|
31
|
+
if (error)
|
|
32
|
+
return (
|
|
33
|
+
<div id={id} style={{ color: "red" }}>
|
|
34
|
+
Error: {error}
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div id={id}>
|
|
40
|
+
{/* Render fetched HTML content safely */}
|
|
41
|
+
<div dangerouslySetInnerHTML={{ __html: html }} />
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default HtmlTemplate;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
const NewPermitAppCodeForm = (props) => {
|
|
3
|
+
const { trackingNumber = "154-30TWQLEP" } = props !== null && props !== void 0 ? props : {};
|
|
4
|
+
return (_jsxs("div", { className: "px-4", children: [_jsx("h2", { className: "text-2xl font-bold text-green-600 mb-12", children: "New Permit Application" }), _jsxs("div", { className: "mb-12", children: [_jsx("h3", { className: "text-xl font-bold text-gray-900 mb-6", children: "Application created" }), _jsx("p", { className: "text-gray-700 leading-relaxed mb-6", children: "Please take note of the tracking number for this application. This will be your tracking reference for completing and follow up for this application." }), _jsx("h4", { className: "text-xl font-bold text-gray-900 mb-8", children: trackingNumber })] })] }));
|
|
5
|
+
};
|
|
6
|
+
export default NewPermitAppCodeForm;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const NewPermitAppCodeForm = (props: any) => {
|
|
2
|
+
const { trackingNumber = "154-30TWQLEP" } = props ?? {};
|
|
3
|
+
|
|
4
|
+
return (
|
|
5
|
+
<div className="px-4">
|
|
6
|
+
<h2 className="text-2xl font-bold text-green-600 mb-12">New Permit Application</h2>
|
|
7
|
+
|
|
8
|
+
<div className="mb-12">
|
|
9
|
+
<h3 className="text-xl font-bold text-gray-900 mb-6">Application created</h3>
|
|
10
|
+
|
|
11
|
+
<p className="text-gray-700 leading-relaxed mb-6">
|
|
12
|
+
Please take note of the tracking number for this application. This will be your tracking reference for completing and follow up for this
|
|
13
|
+
application.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<h4 className="text-xl font-bold text-gray-900 mb-8">{trackingNumber}</h4>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default NewPermitAppCodeForm;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import InputValidator from "./common/InputValidator";
|
|
4
|
+
const NewPermitAppForm = () => {
|
|
5
|
+
const [radioValue, setRadioValue] = useState("");
|
|
6
|
+
return (_jsxs("div", { className: "px-4", children: [_jsx("h1", { className: "text-lg font-bold text-green-600 mb-8", children: "Select Application Type" }), _jsx("div", { className: "space-y-6 mb-12", children: _jsx("label", { className: "flex items-center space-x-4 cursor-pointer group", children: _jsx(InputValidator, { datatype: "radio", options: ["New Construction", "Renovation", "Amendment"], value: radioValue, onChange: setRadioValue, className: "gap-2 my-4" }) }) })] }));
|
|
7
|
+
};
|
|
8
|
+
export default NewPermitAppForm;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import InputValidator from "./common/InputValidator";
|
|
3
|
+
|
|
4
|
+
const NewPermitAppForm = () => {
|
|
5
|
+
const [radioValue, setRadioValue] = useState("");
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<div className="px-4">
|
|
9
|
+
<h1 className="text-lg font-bold text-green-600 mb-8">Select Application Type</h1>
|
|
10
|
+
|
|
11
|
+
<div className="space-y-6 mb-12">
|
|
12
|
+
<label className="flex items-center space-x-4 cursor-pointer group">
|
|
13
|
+
<InputValidator
|
|
14
|
+
datatype="radio"
|
|
15
|
+
options={["New Construction", "Renovation", "Amendment"]}
|
|
16
|
+
value={radioValue}
|
|
17
|
+
onChange={setRadioValue}
|
|
18
|
+
className="gap-2 my-4"
|
|
19
|
+
/>
|
|
20
|
+
</label>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default NewPermitAppForm;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import InputValidator from "./common/InputValidator";
|
|
4
|
+
const NewPermitTermForm = () => {
|
|
5
|
+
const [agreed, setAgreed] = useState(false);
|
|
6
|
+
return (_jsxs("div", { className: "px-4", children: [_jsx("h2", { className: "text-2xl font-bold text-green-600 mb-12", children: "New Permit Application" }), _jsxs("div", { className: "mb-8", children: [_jsx("h3", { className: "text-xl font-bold text-gray-900 mb-6", children: "Please read thoroughly before proceeding" }), _jsx("p", { className: "text-gray-700 leading-relaxed mb-4", children: "This online service will require personal information from the applicant, lot owner(s) and professionals involved in this transaction. In compliance with the Data Privacy Act, we are securing your consent that you have been authorized by the aforementioned parties to act on their behalf. The data collected will be stored, processed and used for effectively carrying out legitimate transactions with the local government of Tagbilaran City. If you do not agree to these terms, you can cancel out by click on the Cancel button. If you agree to these terms, tick on the checkbox and click Continue." }), _jsx(InputValidator, { datatype: "boolean", value: agreed, onChange: (val) => setAgreed(val), label: "Yes, I have read and agree to the terms and conditions" })] })] }));
|
|
7
|
+
};
|
|
8
|
+
export default NewPermitTermForm;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import InputValidator from "./common/InputValidator";
|
|
3
|
+
|
|
4
|
+
const NewPermitTermForm = () => {
|
|
5
|
+
const [agreed, setAgreed] = useState(false);
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<div className="px-4">
|
|
9
|
+
<h2 className="text-2xl font-bold text-green-600 mb-12">New Permit Application</h2>
|
|
10
|
+
|
|
11
|
+
<div className="mb-8">
|
|
12
|
+
<h3 className="text-xl font-bold text-gray-900 mb-6">Please read thoroughly before proceeding</h3>
|
|
13
|
+
|
|
14
|
+
<p className="text-gray-700 leading-relaxed mb-4">
|
|
15
|
+
This online service will require personal information from the applicant, lot owner(s) and professionals involved in this transaction. In
|
|
16
|
+
compliance with the Data Privacy Act, we are securing your consent that you have been authorized by the aforementioned parties to act on
|
|
17
|
+
their behalf. The data collected will be stored, processed and used for effectively carrying out legitimate transactions with the local
|
|
18
|
+
government of Tagbilaran City. If you do not agree to these terms, you can cancel out by click on the Cancel button. If you agree to these
|
|
19
|
+
terms, tick on the checkbox and click Continue.
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
<InputValidator
|
|
23
|
+
datatype="boolean"
|
|
24
|
+
value={agreed}
|
|
25
|
+
onChange={(val) => setAgreed(val)}
|
|
26
|
+
label="Yes, I have read and agree to the terms and conditions"
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default NewPermitTermForm;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import InputValidator from "./common/InputValidator";
|
|
4
|
+
const ApplicationTypeForm = () => {
|
|
5
|
+
const [projectName, setProjectName] = useState("");
|
|
6
|
+
return (_jsxs("div", { className: "px-4", children: [_jsx("h2", { className: "text-lg font-bold text-green-600 mb-12", children: "New Building Permit Application" }), _jsxs("div", { className: "mb-12", children: [_jsx("h3", { className: "text-xl font-bold text-gray-900 mb-6", children: "Project Information" }), _jsxs("div", { children: [_jsx("label", { className: "block text-gray-600 text-sm mb-3", children: "Project Name *" }), _jsx(InputValidator, { datatype: "string", value: projectName, onChange: (val) => setProjectName(val), className: "w-full border-b-2 border-gray-800 text-gray-900" })] })] })] }));
|
|
7
|
+
};
|
|
8
|
+
export default ApplicationTypeForm;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import InputValidator from "./common/InputValidator";
|
|
3
|
+
|
|
4
|
+
const ApplicationTypeForm = () => {
|
|
5
|
+
const [projectName, setProjectName] = useState("");
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<div className="px-4">
|
|
9
|
+
<h2 className="text-lg font-bold text-green-600 mb-12">New Building Permit Application</h2>
|
|
10
|
+
|
|
11
|
+
<div className="mb-12">
|
|
12
|
+
<h3 className="text-xl font-bold text-gray-900 mb-6">Project Information</h3>
|
|
13
|
+
|
|
14
|
+
<div>
|
|
15
|
+
<label className="block text-gray-600 text-sm mb-3">Project Name *</label>
|
|
16
|
+
<InputValidator
|
|
17
|
+
datatype="string"
|
|
18
|
+
value={projectName}
|
|
19
|
+
onChange={(val) => setProjectName(val)}
|
|
20
|
+
className="w-full border-b-2 border-gray-800 text-gray-900"
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default ApplicationTypeForm;
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { Button } from "@ramesesinc/client";
|
|
3
|
+
// import { usePageContext } from "@ramesesinc/platform-core";
|
|
4
|
+
// import HtmlTemplate from "./HtmlTemplate";
|
|
5
|
+
// type PrivacyStatementFormProps = {
|
|
6
|
+
// attr?: {
|
|
7
|
+
// html_template_id?: string;
|
|
8
|
+
// module?: string;
|
|
9
|
+
// tenant?: string;
|
|
10
|
+
// [key: string]: any;
|
|
11
|
+
// };
|
|
12
|
+
// html_template_id?: string;
|
|
13
|
+
// module?: string;
|
|
14
|
+
// tenant?: string;
|
|
15
|
+
// params?: any;
|
|
16
|
+
// };
|
|
17
|
+
// const PrivacyStatementForm = (props: PrivacyStatementFormProps) => {
|
|
18
|
+
// const pageContext = usePageContext();
|
|
19
|
+
// const attr = props.attr || {};
|
|
20
|
+
// const { wizard } = props.params ?? {};
|
|
21
|
+
// console.log("PageContext in PrivacyStatementForm:", pageContext);
|
|
22
|
+
// console.log("PrivacyStatementForm props:", {
|
|
23
|
+
// html_template_id: props.html_template_id ?? attr.html_template_id,
|
|
24
|
+
// module: props.module ?? attr.module ?? pageContext.module ?? "",
|
|
25
|
+
// tenant: props.tenant ?? attr.tenant ?? pageContext.tenant ?? "",
|
|
26
|
+
// });
|
|
27
|
+
// return (
|
|
28
|
+
// <div className="mx-auto px-4 bg-white">
|
|
29
|
+
// <HtmlTemplate
|
|
30
|
+
// id={props.html_template_id ?? attr.html_template_id ?? ""}
|
|
31
|
+
// module={props.module ?? pageContext.module ?? ""}
|
|
32
|
+
// tenant={props.tenant ?? pageContext.tenant ?? ""}
|
|
33
|
+
// />
|
|
34
|
+
// <div className="flex flex-row justify-between gap-4 py-4 border-t border-slate-200">
|
|
35
|
+
// <div className="w-[120px]">
|
|
36
|
+
// <Button variant="text" size="lg" type="button" onClick={wizard.onBack}>
|
|
37
|
+
// Prev
|
|
38
|
+
// </Button>
|
|
39
|
+
// </div>
|
|
40
|
+
// <div className="w-[120px] flex justify-end">
|
|
41
|
+
// <Button variant="text" size="lg" type="button" onClick={wizard.onNext}>
|
|
42
|
+
// Next
|
|
43
|
+
// </Button>
|
|
44
|
+
// </div>
|
|
45
|
+
// </div>
|
|
46
|
+
// </div>
|
|
47
|
+
// );
|
|
48
|
+
// };
|
|
49
|
+
// export default PrivacyStatementForm;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// import { Button } from "@ramesesinc/client";
|
|
2
|
+
// import { usePageContext } from "@ramesesinc/platform-core";
|
|
3
|
+
// import HtmlTemplate from "./HtmlTemplate";
|
|
4
|
+
|
|
5
|
+
// type PrivacyStatementFormProps = {
|
|
6
|
+
// attr?: {
|
|
7
|
+
// html_template_id?: string;
|
|
8
|
+
// module?: string;
|
|
9
|
+
// tenant?: string;
|
|
10
|
+
// [key: string]: any;
|
|
11
|
+
// };
|
|
12
|
+
// html_template_id?: string;
|
|
13
|
+
// module?: string;
|
|
14
|
+
// tenant?: string;
|
|
15
|
+
// params?: any;
|
|
16
|
+
// };
|
|
17
|
+
|
|
18
|
+
// const PrivacyStatementForm = (props: PrivacyStatementFormProps) => {
|
|
19
|
+
// const pageContext = usePageContext();
|
|
20
|
+
// const attr = props.attr || {};
|
|
21
|
+
// const { wizard } = props.params ?? {};
|
|
22
|
+
|
|
23
|
+
// console.log("PageContext in PrivacyStatementForm:", pageContext);
|
|
24
|
+
// console.log("PrivacyStatementForm props:", {
|
|
25
|
+
// html_template_id: props.html_template_id ?? attr.html_template_id,
|
|
26
|
+
// module: props.module ?? attr.module ?? pageContext.module ?? "",
|
|
27
|
+
// tenant: props.tenant ?? attr.tenant ?? pageContext.tenant ?? "",
|
|
28
|
+
// });
|
|
29
|
+
|
|
30
|
+
// return (
|
|
31
|
+
// <div className="mx-auto px-4 bg-white">
|
|
32
|
+
// <HtmlTemplate
|
|
33
|
+
// id={props.html_template_id ?? attr.html_template_id ?? ""}
|
|
34
|
+
// module={props.module ?? pageContext.module ?? ""}
|
|
35
|
+
// tenant={props.tenant ?? pageContext.tenant ?? ""}
|
|
36
|
+
// />
|
|
37
|
+
|
|
38
|
+
// <div className="flex flex-row justify-between gap-4 py-4 border-t border-slate-200">
|
|
39
|
+
// <div className="w-[120px]">
|
|
40
|
+
// <Button variant="text" size="lg" type="button" onClick={wizard.onBack}>
|
|
41
|
+
// Prev
|
|
42
|
+
// </Button>
|
|
43
|
+
// </div>
|
|
44
|
+
|
|
45
|
+
// <div className="w-[120px] flex justify-end">
|
|
46
|
+
// <Button variant="text" size="lg" type="button" onClick={wizard.onNext}>
|
|
47
|
+
// Next
|
|
48
|
+
// </Button>
|
|
49
|
+
// </div>
|
|
50
|
+
// </div>
|
|
51
|
+
// </div>
|
|
52
|
+
// );
|
|
53
|
+
// };
|
|
54
|
+
|
|
55
|
+
// export default PrivacyStatementForm;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type InputValidatorProps = {
|
|
3
|
+
datatype: "number" | "decimal" | "string" | "boolean" | "list" | "complexlist" | any;
|
|
4
|
+
value?: any;
|
|
5
|
+
onChange?: (value: any) => void;
|
|
6
|
+
options?: string[];
|
|
7
|
+
className?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
activeFirst?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare const InputValidator: React.FC<InputValidatorProps>;
|
|
13
|
+
export default InputValidator;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
const InputValidator = ({ datatype, value, onChange, options = [], className = "", label = "", placeholder = "", activeFirst = true }) => {
|
|
4
|
+
const [inputValue, setInputValue] = useState(value !== null && value !== void 0 ? value : "");
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
setInputValue(value !== null && value !== void 0 ? value : "");
|
|
7
|
+
}, [value]);
|
|
8
|
+
const handleChange = (val) => {
|
|
9
|
+
setInputValue(val);
|
|
10
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(val);
|
|
11
|
+
};
|
|
12
|
+
switch (datatype) {
|
|
13
|
+
case "number":
|
|
14
|
+
return (_jsx("input", { type: "text", value: inputValue, placeholder: placeholder, className: `outline-none ${className}`, onChange: (e) => {
|
|
15
|
+
const val = e.target.value;
|
|
16
|
+
if (/^-?\d*$/.test(val)) {
|
|
17
|
+
handleChange(val);
|
|
18
|
+
}
|
|
19
|
+
} }));
|
|
20
|
+
case "decimal":
|
|
21
|
+
return (_jsx("input", { type: "text", value: inputValue, placeholder: placeholder, className: `outline-none ${className}`, onChange: (e) => {
|
|
22
|
+
const val = e.target.value;
|
|
23
|
+
if (/^-?\d*\.?\d*$/.test(val)) {
|
|
24
|
+
handleChange(val);
|
|
25
|
+
}
|
|
26
|
+
} }));
|
|
27
|
+
case "string":
|
|
28
|
+
return (_jsx("input", { type: "text", value: inputValue, placeholder: placeholder, className: `
|
|
29
|
+
focus:ring-0
|
|
30
|
+
focus:border-transparent
|
|
31
|
+
bg-transparent
|
|
32
|
+
focus:bg-transparent
|
|
33
|
+
shadow-none
|
|
34
|
+
focus:shadow-none
|
|
35
|
+
appearance-none ${className}`, onChange: (e) => {
|
|
36
|
+
const val = e.target.value;
|
|
37
|
+
// allow empty value
|
|
38
|
+
if (val === "") {
|
|
39
|
+
handleChange(val);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// allow alphanumeric + space
|
|
43
|
+
if (/^[a-zA-Z0-9 ]+$/.test(val)) {
|
|
44
|
+
handleChange(val);
|
|
45
|
+
}
|
|
46
|
+
} }));
|
|
47
|
+
case "mobilenumber":
|
|
48
|
+
return (_jsx("input", { type: "text", value: inputValue, placeholder: placeholder, className: `focus:ring-0
|
|
49
|
+
focus:border-transparent
|
|
50
|
+
bg-transparent
|
|
51
|
+
focus:bg-transparent
|
|
52
|
+
shadow-none
|
|
53
|
+
focus:shadow-none
|
|
54
|
+
appearance-none ${className}`, onChange: (e) => {
|
|
55
|
+
const val = e.target.value;
|
|
56
|
+
// allow empty, digits, or + at start
|
|
57
|
+
if (/^\+?\d*$/.test(val)) {
|
|
58
|
+
handleChange(val);
|
|
59
|
+
}
|
|
60
|
+
} }));
|
|
61
|
+
case "email":
|
|
62
|
+
return (_jsx("input", { type: "text", value: inputValue, placeholder: placeholder, className: `focus:ring-0
|
|
63
|
+
focus:border-transparent
|
|
64
|
+
bg-transparent
|
|
65
|
+
focus:bg-transparent
|
|
66
|
+
shadow-none
|
|
67
|
+
focus:shadow-none
|
|
68
|
+
appearance-none ${className}`, onChange: (e) => {
|
|
69
|
+
const val = e.target.value;
|
|
70
|
+
// allow empty value
|
|
71
|
+
if (val === "") {
|
|
72
|
+
handleChange(val);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// allow email-safe characters while typing
|
|
76
|
+
if (/^[a-zA-Z0-9@._-]*$/.test(val)) {
|
|
77
|
+
handleChange(val);
|
|
78
|
+
}
|
|
79
|
+
} }));
|
|
80
|
+
case "boolean":
|
|
81
|
+
if (options.length > 0) {
|
|
82
|
+
// Multiple checkboxes
|
|
83
|
+
return (_jsx("div", { className: `flex flex-col space-y-1 ${className}`, children: options.map((opt, i) => (_jsxs("label", { className: "inline-flex items-center space-x-2 cursor-pointer", children: [_jsx("input", { type: "checkbox", value: opt, checked: Array.isArray(inputValue) ? inputValue.includes(opt) : false, className: "w-4 h-4 accent-blue-500", onChange: (e) => {
|
|
84
|
+
let newValue = Array.isArray(inputValue) ? [...inputValue] : [];
|
|
85
|
+
if (e.target.checked) {
|
|
86
|
+
newValue.push(opt);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
newValue = newValue.filter((v) => v !== opt);
|
|
90
|
+
}
|
|
91
|
+
handleChange(newValue);
|
|
92
|
+
} }), _jsx("span", { children: opt })] }, i))) }));
|
|
93
|
+
}
|
|
94
|
+
// Single checkbox (default)
|
|
95
|
+
return (_jsxs("label", { className: `inline-flex items-center space-x-2 cursor-pointer ${className}`, children: [_jsx("input", { type: "checkbox", checked: !!inputValue, className: "w-4 h-4 accent-blue-500", onChange: (e) => handleChange(e.target.checked) }), label && _jsx("span", { children: label })] }));
|
|
96
|
+
case "radio":
|
|
97
|
+
if (options.length === 0) {
|
|
98
|
+
return _jsx("span", { className: className, children: "No options provided" });
|
|
99
|
+
}
|
|
100
|
+
// Initialize first option as active if inputValue is empty and activeFirst is true
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if ((inputValue === "" || inputValue === undefined) && activeFirst) {
|
|
103
|
+
handleChange(options[0]);
|
|
104
|
+
}
|
|
105
|
+
}, [options, activeFirst]);
|
|
106
|
+
return (_jsx("div", { className: `flex flex-col space-y-1 ${className}`, children: options.map((opt, i) => (_jsxs("label", { className: "inline-flex items-center space-x-2 cursor-pointer", children: [_jsx("input", { type: "radio", name: `radio-${label || Math.random()}`, value: opt, checked: inputValue === opt, className: "w-4 h-4 accent-blue-500", onChange: () => handleChange(opt) }), _jsx("span", { children: opt })] }, i))) }));
|
|
107
|
+
case "list":
|
|
108
|
+
return (_jsxs("select", { value: inputValue, className: `bg-transparent ${className}`, onChange: (e) => handleChange(e.target.value), children: [_jsx("option", { value: "", children: "Select an option" }), options.map((opt, i) => (_jsx("option", { value: opt, children: opt }, i)))] }));
|
|
109
|
+
case "complexlist":
|
|
110
|
+
return (_jsx("select", { multiple: true, value: inputValue || [], className: `${className}`, onChange: (e) => {
|
|
111
|
+
const selected = Array.from(e.target.selectedOptions).map((opt) => opt.value);
|
|
112
|
+
handleChange(selected);
|
|
113
|
+
}, children: options.map((opt, i) => (_jsxs("option", { value: opt, children: [" ", opt, " "] }, i))) }));
|
|
114
|
+
default:
|
|
115
|
+
return _jsx("span", { className: className, children: "Unsupported datatype" });
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
export default InputValidator;
|