@fovestta2/web-react 1.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.
Files changed (55) hide show
  1. package/dist/components/AddUpdateForm.d.ts +64 -0
  2. package/dist/components/AddUpdateForm.js +244 -0
  3. package/dist/components/FvCheckbox.d.ts +12 -0
  4. package/dist/components/FvCheckbox.js +19 -0
  5. package/dist/components/FvDateField.d.ts +19 -0
  6. package/dist/components/FvDateField.js +123 -0
  7. package/dist/components/FvDocumentField.d.ts +22 -0
  8. package/dist/components/FvDocumentField.js +242 -0
  9. package/dist/components/FvDropdown.d.ts +33 -0
  10. package/dist/components/FvDropdown.js +346 -0
  11. package/dist/components/FvEmailField.d.ts +18 -0
  12. package/dist/components/FvEmailField.js +103 -0
  13. package/dist/components/FvEntryField.d.ts +21 -0
  14. package/dist/components/FvEntryField.js +101 -0
  15. package/dist/components/FvEsiField.d.ts +16 -0
  16. package/dist/components/FvEsiField.js +92 -0
  17. package/dist/components/FvFileSelector.d.ts +22 -0
  18. package/dist/components/FvFileSelector.js +153 -0
  19. package/dist/components/FvIbanField.d.ts +16 -0
  20. package/dist/components/FvIbanField.js +92 -0
  21. package/dist/components/FvIfscField.d.ts +16 -0
  22. package/dist/components/FvIfscField.js +92 -0
  23. package/dist/components/FvImageSelector.d.ts +22 -0
  24. package/dist/components/FvImageSelector.js +317 -0
  25. package/dist/components/FvMicrField.d.ts +16 -0
  26. package/dist/components/FvMicrField.js +92 -0
  27. package/dist/components/FvMonthYearField.d.ts +19 -0
  28. package/dist/components/FvMonthYearField.js +139 -0
  29. package/dist/components/FvNameCode.d.ts +23 -0
  30. package/dist/components/FvNameCode.js +239 -0
  31. package/dist/components/FvNumberField.d.ts +21 -0
  32. package/dist/components/FvNumberField.js +98 -0
  33. package/dist/components/FvPasswordField.d.ts +18 -0
  34. package/dist/components/FvPasswordField.js +114 -0
  35. package/dist/components/FvPfField.d.ts +16 -0
  36. package/dist/components/FvPfField.js +106 -0
  37. package/dist/components/FvPhoneField.d.ts +16 -0
  38. package/dist/components/FvPhoneField.js +95 -0
  39. package/dist/components/FvRadioGroup.d.ts +20 -0
  40. package/dist/components/FvRadioGroup.js +64 -0
  41. package/dist/components/FvRichTextEditor.d.ts +20 -0
  42. package/dist/components/FvRichTextEditor.js +199 -0
  43. package/dist/components/FvServicePeriod.d.ts +10 -0
  44. package/dist/components/FvServicePeriod.js +122 -0
  45. package/dist/components/FvTimeField.d.ts +17 -0
  46. package/dist/components/FvTimeField.js +190 -0
  47. package/dist/components/FvToggle.d.ts +12 -0
  48. package/dist/components/FvToggle.js +39 -0
  49. package/dist/components/FvUanField.d.ts +16 -0
  50. package/dist/components/FvUanField.js +92 -0
  51. package/dist/components/QueryForm.d.ts +31 -0
  52. package/dist/components/QueryForm.js +214 -0
  53. package/dist/index.d.ts +28 -0
  54. package/dist/index.js +47 -0
  55. package/package.json +39 -0
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.FvEmailField = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const validation_engine_1 = require("@fovestta2/validation-engine");
29
+ const FvEmailField = ({ label = 'Email Address', placeholder = 'e.g. john@example.com', value, schema, disabled = false, readonly = false, className = '', inputClassName = '', labelClassName = '', errorClassName = '', onChange, onBlur, onFocus, }) => {
30
+ const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
31
+ const defaultSchema = schema || {
32
+ controlType: 'EntryField',
33
+ errorPriority: ['required', 'regex'],
34
+ rules: [
35
+ {
36
+ name: 'regex',
37
+ params: {
38
+ pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$',
39
+ },
40
+ errorKey: 'ERR_EMAIL_INVALID',
41
+ },
42
+ ],
43
+ };
44
+ (0, react_1.useEffect)(() => {
45
+ validateValue(value);
46
+ }, [value, schema]);
47
+ const validateValue = (val) => {
48
+ const result = validation_engine_1.Validator.validate(val, schema || defaultSchema);
49
+ if (!result.isValid && result.errorKey) {
50
+ setErrorMessage(result.errorKey);
51
+ }
52
+ else {
53
+ setErrorMessage(null);
54
+ }
55
+ };
56
+ const handleInput = (e) => {
57
+ onChange(e.target.value);
58
+ };
59
+ const handleBlur = (e) => {
60
+ validateValue(value);
61
+ if (onBlur)
62
+ onBlur();
63
+ };
64
+ const handleFocus = (e) => {
65
+ if (onFocus)
66
+ onFocus();
67
+ };
68
+ const isRequired = () => {
69
+ var _a;
70
+ return ((_a = (schema || defaultSchema).rules) === null || _a === void 0 ? void 0 : _a.some((r) => { var _a; return r.name === 'required' && ((_a = r.params) === null || _a === void 0 ? void 0 : _a['enabled']); })) || false;
71
+ };
72
+ const getErrorMessage = () => {
73
+ if (!errorMessage)
74
+ return '';
75
+ const errorMessages = {
76
+ ERR_REQUIRED: 'Email is required',
77
+ ERR_EMAIL_INVALID: 'Invalid email format',
78
+ ERR_REGEX_MISMATCH: 'Invalid email format',
79
+ ERR_DUPLICATE: 'Email already exists',
80
+ };
81
+ return errorMessages[errorMessage] || errorMessage;
82
+ };
83
+ return (react_1.default.createElement("div", { className: `fv-field-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column' } },
84
+ label && (react_1.default.createElement("label", { className: `fv-label ${labelClassName}`, style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
85
+ label,
86
+ isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
87
+ react_1.default.createElement("input", { type: "email", value: value, onChange: handleInput, onBlur: handleBlur, onFocus: handleFocus, disabled: disabled, readOnly: readonly, placeholder: placeholder, className: `fv-input ${errorMessage ? 'fv-input-error' : ''} ${inputClassName}`, style: {
88
+ padding: '10px',
89
+ border: errorMessage ? '1px solid #dc3545' : '1px solid #ccc',
90
+ borderRadius: '4px',
91
+ fontSize: '14px',
92
+ backgroundColor: disabled ? '#f5f5f5' : '#fff',
93
+ cursor: disabled ? 'not-allowed' : 'text',
94
+ outline: 'none',
95
+ boxSizing: 'border-box',
96
+ width: '100%',
97
+ ...((disabled || readonly) ? { opacity: 0.6 } : {})
98
+ } }),
99
+ errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
100
+ "\u26A0 ",
101
+ getErrorMessage()))));
102
+ };
103
+ exports.FvEmailField = FvEmailField;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { ValidationSchema } from '@fovestta2/validation-engine';
3
+ export interface FvEntryFieldProps {
4
+ label?: string;
5
+ placeholder?: string;
6
+ value: string;
7
+ schema?: ValidationSchema;
8
+ disabled?: boolean;
9
+ readonly?: boolean;
10
+ type?: 'text' | 'password' | 'email';
11
+ allowAlphabetsOnly?: boolean;
12
+ maxLength?: number;
13
+ className?: string;
14
+ inputClassName?: string;
15
+ labelClassName?: string;
16
+ errorClassName?: string;
17
+ onChange: (value: string) => void;
18
+ onBlur?: () => void;
19
+ onFocus?: () => void;
20
+ }
21
+ export declare const FvEntryField: React.FC<FvEntryFieldProps>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.FvEntryField = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const validation_engine_1 = require("@fovestta2/validation-engine");
29
+ const FvEntryField = ({ label = '', placeholder = '', value, schema, disabled = false, readonly = false, type = 'text', allowAlphabetsOnly = false, maxLength, className = '', inputClassName = '', labelClassName = '', errorClassName = '', onChange, onBlur, onFocus, }) => {
30
+ const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
31
+ (0, react_1.useEffect)(() => {
32
+ validateValue(value);
33
+ }, [value, schema]);
34
+ const validateValue = (val) => {
35
+ if (!schema)
36
+ return;
37
+ const result = validation_engine_1.Validator.validate(val, schema);
38
+ // In React this is fully controlled by state, without formControl injection
39
+ if (!result.isValid && result.errorKey) {
40
+ setErrorMessage(result.errorKey);
41
+ }
42
+ else {
43
+ setErrorMessage(null);
44
+ }
45
+ };
46
+ const handleInput = (e) => {
47
+ let newValue = e.target.value;
48
+ if (allowAlphabetsOnly) {
49
+ newValue = newValue.replace(/[^a-zA-Z ]/g, '');
50
+ }
51
+ if (maxLength && newValue.length > maxLength) {
52
+ newValue = newValue.substring(0, maxLength);
53
+ }
54
+ onChange(newValue);
55
+ };
56
+ const handleBlur = (e) => {
57
+ validateValue(value);
58
+ if (onBlur)
59
+ onBlur();
60
+ };
61
+ const handleFocus = (e) => {
62
+ if (onFocus)
63
+ onFocus();
64
+ };
65
+ const isRequired = () => {
66
+ var _a;
67
+ return ((_a = schema === null || schema === void 0 ? void 0 : schema.rules) === null || _a === void 0 ? void 0 : _a.some((r) => { var _a; return r.name === 'required' && ((_a = r.params) === null || _a === void 0 ? void 0 : _a['enabled']); })) || false;
68
+ };
69
+ const getErrorMessage = () => {
70
+ if (!errorMessage)
71
+ return '';
72
+ const errorMessages = {
73
+ ERR_REQUIRED: 'This field is required',
74
+ ERR_MIN_LENGTH: 'Value is too short',
75
+ ERR_MAX_LENGTH: 'Value is too long',
76
+ ERR_REGEX_MISMATCH: 'Invalid format',
77
+ ERR_DUPLICATE: 'This value already exists',
78
+ };
79
+ return errorMessages[errorMessage] || errorMessage;
80
+ };
81
+ return (react_1.default.createElement("div", { className: `fv-field-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column' } },
82
+ label && (react_1.default.createElement("label", { className: `fv-label ${labelClassName}`, style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
83
+ label,
84
+ isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
85
+ react_1.default.createElement("input", { type: type, value: value, onChange: handleInput, onBlur: handleBlur, onFocus: handleFocus, disabled: disabled, readOnly: readonly, placeholder: placeholder, maxLength: maxLength, className: `fv-input ${errorMessage ? 'fv-input-error' : ''} ${inputClassName}`, style: {
86
+ padding: '10px',
87
+ border: errorMessage ? '1px solid #dc3545' : '1px solid #ccc',
88
+ borderRadius: '4px',
89
+ fontSize: '14px',
90
+ backgroundColor: disabled ? '#f5f5f5' : '#fff',
91
+ cursor: disabled ? 'not-allowed' : 'text',
92
+ outline: 'none',
93
+ boxSizing: 'border-box',
94
+ width: '100%',
95
+ ...((disabled || readonly) ? { opacity: 0.6 } : {})
96
+ } }),
97
+ errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
98
+ "\u26A0 ",
99
+ getErrorMessage()))));
100
+ };
101
+ exports.FvEntryField = FvEntryField;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { ValidationSchema } from '@fovestta2/validation-engine';
3
+ export interface FvEsiFieldProps {
4
+ label?: string;
5
+ value: string;
6
+ schema?: ValidationSchema;
7
+ disabled?: boolean;
8
+ className?: string;
9
+ inputClassName?: string;
10
+ labelClassName?: string;
11
+ errorClassName?: string;
12
+ onChange: (value: string) => void;
13
+ onBlur?: () => void;
14
+ onFocus?: () => void;
15
+ }
16
+ export declare const FvEsiField: React.FC<FvEsiFieldProps>;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.FvEsiField = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const validation_engine_1 = require("@fovestta2/validation-engine");
29
+ const FvEsiField = ({ label = 'ESI Number', value, schema, disabled = false, className = '', inputClassName = '', labelClassName = '', errorClassName = '', onChange, onBlur, onFocus, }) => {
30
+ const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
31
+ (0, react_1.useEffect)(() => {
32
+ validateValue(value);
33
+ }, [value, schema]);
34
+ const validateValue = (val) => {
35
+ if (!schema)
36
+ return;
37
+ const result = validation_engine_1.Validator.validate(val, schema);
38
+ if (!result.isValid && result.errorKey) {
39
+ setErrorMessage(result.errorKey);
40
+ }
41
+ else {
42
+ setErrorMessage(null);
43
+ }
44
+ };
45
+ const handleInput = (e) => {
46
+ let rawVal = e.target.value;
47
+ const numericValue = rawVal.replace(/[^0-9]/g, '');
48
+ const truncatedValue = numericValue.substring(0, 17);
49
+ onChange(truncatedValue);
50
+ };
51
+ const handleBlur = (e) => {
52
+ validateValue(value);
53
+ if (onBlur)
54
+ onBlur();
55
+ };
56
+ const handleFocus = (e) => {
57
+ if (onFocus)
58
+ onFocus();
59
+ };
60
+ const isRequired = () => {
61
+ var _a;
62
+ return ((_a = schema === null || schema === void 0 ? void 0 : schema.rules) === null || _a === void 0 ? void 0 : _a.some((r) => { var _a; return r.name === 'required' && ((_a = r.params) === null || _a === void 0 ? void 0 : _a['enabled']); })) || false;
63
+ };
64
+ const getErrorMessage = () => {
65
+ if (!errorMessage)
66
+ return '';
67
+ const errorMessages = {
68
+ ERR_REQUIRED: 'This field is required',
69
+ };
70
+ return errorMessages[errorMessage] || errorMessage;
71
+ };
72
+ return (react_1.default.createElement("div", { className: `fv-field-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column' } },
73
+ label && (react_1.default.createElement("label", { className: `fv-label ${labelClassName}`, style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
74
+ label,
75
+ isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
76
+ react_1.default.createElement("input", { type: "text", value: value, onChange: handleInput, onBlur: handleBlur, onFocus: handleFocus, disabled: disabled, className: `fv-input ${errorMessage ? 'fv-input-error' : ''} ${inputClassName}`, style: {
77
+ padding: '10px',
78
+ border: errorMessage ? '1px solid #dc3545' : '1px solid #ccc',
79
+ borderRadius: '4px',
80
+ fontSize: '14px',
81
+ backgroundColor: disabled ? '#f5f5f5' : '#fff',
82
+ cursor: disabled ? 'not-allowed' : 'text',
83
+ outline: 'none',
84
+ boxSizing: 'border-box',
85
+ width: '100%',
86
+ ...(disabled ? { opacity: 0.6 } : {})
87
+ } }),
88
+ errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
89
+ "\u26A0 ",
90
+ getErrorMessage()))));
91
+ };
92
+ exports.FvEsiField = FvEsiField;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { ValidationSchema } from '@fovestta2/validation-engine';
3
+ export interface FileInfo {
4
+ file: File | string;
5
+ name: string;
6
+ size: number;
7
+ type: string;
8
+ }
9
+ export interface FvFileSelectorProps {
10
+ label?: string;
11
+ placeholder?: string;
12
+ value: FileInfo | null;
13
+ schema?: ValidationSchema;
14
+ disabled?: boolean;
15
+ accept?: string;
16
+ maxSize?: number;
17
+ className?: string;
18
+ errorClassName?: string;
19
+ onChange: (value: FileInfo | null) => void;
20
+ onBlur?: () => void;
21
+ }
22
+ export declare const FvFileSelector: React.FC<FvFileSelectorProps>;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.FvFileSelector = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const validation_engine_1 = require("@fovestta2/validation-engine");
29
+ const FvFileSelector = ({ label = '', placeholder = 'Upload', value, schema, disabled = false, accept = '*/*', maxSize, className = '', errorClassName = '', onChange, onBlur, }) => {
30
+ const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
31
+ const fileInputRef = (0, react_1.useRef)(null);
32
+ (0, react_1.useEffect)(() => {
33
+ validateValue(value);
34
+ }, [value, schema]);
35
+ const validateValue = (val) => {
36
+ if (!schema)
37
+ return;
38
+ const result = validation_engine_1.Validator.validate(val, schema);
39
+ if (!result.isValid && result.errorKey) {
40
+ setErrorMessage(result.errorKey);
41
+ }
42
+ else {
43
+ setErrorMessage(null);
44
+ }
45
+ };
46
+ const handleFileChange = (e) => {
47
+ const files = e.target.files;
48
+ if (files && files.length > 0) {
49
+ const file = files[0];
50
+ if (maxSize && file.size > maxSize) {
51
+ alert(`File size exceeds the maximum allowed size of ${formatFileSize(maxSize)}`);
52
+ if (fileInputRef.current)
53
+ fileInputRef.current.value = '';
54
+ return;
55
+ }
56
+ const fileInfo = {
57
+ file: file,
58
+ name: file.name,
59
+ size: file.size,
60
+ type: file.type,
61
+ };
62
+ onChange(fileInfo);
63
+ if (onBlur)
64
+ onBlur();
65
+ }
66
+ };
67
+ const openFileDialog = () => {
68
+ if (!disabled && fileInputRef.current) {
69
+ fileInputRef.current.click();
70
+ }
71
+ };
72
+ const removeFile = (e) => {
73
+ e.stopPropagation();
74
+ onChange(null);
75
+ if (fileInputRef.current) {
76
+ fileInputRef.current.value = '';
77
+ }
78
+ if (onBlur)
79
+ onBlur();
80
+ };
81
+ const formatFileSize = (bytes) => {
82
+ if (bytes === 0)
83
+ return '0 Bytes';
84
+ const k = 1024;
85
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
86
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
87
+ return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i];
88
+ };
89
+ const getFileIcon = () => {
90
+ if (!value)
91
+ return 'description';
92
+ const type = value.type || '';
93
+ const name = value.name || '';
94
+ if (type.includes('pdf') || name.toLowerCase().endsWith('.pdf'))
95
+ return 'picture_as_pdf';
96
+ if (type.includes('image'))
97
+ return 'image';
98
+ if (type.includes('excel') || type.includes('spreadsheet') || name.toLowerCase().endsWith('.xls') || name.toLowerCase().endsWith('.xlsx'))
99
+ return 'table_view';
100
+ if (type.includes('word') || name.toLowerCase().endsWith('.doc') || name.toLowerCase().endsWith('.docx'))
101
+ return 'description';
102
+ return 'description';
103
+ };
104
+ const isRequired = () => {
105
+ var _a;
106
+ return ((_a = schema === null || schema === void 0 ? void 0 : schema.rules) === null || _a === void 0 ? void 0 : _a.some((r) => { var _a; return r.name === 'required' && ((_a = r.params) === null || _a === void 0 ? void 0 : _a['enabled']); })) || false;
107
+ };
108
+ const getErrorMessage = () => {
109
+ if (!errorMessage)
110
+ return '';
111
+ const errorMessages = {
112
+ ERR_REQUIRED: 'This field is required',
113
+ ERR_INVALID_FILE: 'Invalid file',
114
+ };
115
+ return errorMessages[errorMessage] || errorMessage;
116
+ };
117
+ return (react_1.default.createElement("div", { className: `fv-field-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column' } },
118
+ label && (react_1.default.createElement("label", { className: "fv-label", style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
119
+ label,
120
+ isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
121
+ react_1.default.createElement("div", { className: `fv-file-upload-box ${errorMessage ? 'error' : ''} ${disabled ? 'disabled' : ''}`, onClick: openFileDialog, style: {
122
+ display: 'flex',
123
+ alignItems: 'center',
124
+ justifyContent: 'space-between',
125
+ padding: '12px 16px',
126
+ border: errorMessage ? '1px dashed #dc3545' : '1px dashed #ccc',
127
+ borderRadius: '8px',
128
+ backgroundColor: disabled ? '#f9f9f9' : '#fafafa',
129
+ cursor: disabled ? 'not-allowed' : 'pointer',
130
+ transition: 'all 0.2sease',
131
+ opacity: disabled ? 0.6 : 1
132
+ } },
133
+ react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center', flex: 1, overflow: 'hidden' } },
134
+ react_1.default.createElement("span", { className: "material-icons-outlined", style: { color: '#007bff', marginRight: '12px', fontSize: '24px' } }, "\uD83D\uDCC1"),
135
+ react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', overflow: 'hidden' } }, value ? (react_1.default.createElement(react_1.default.Fragment, null,
136
+ react_1.default.createElement("span", { style: { fontSize: '14px', fontWeight: 500, color: '#333', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } }, value.name),
137
+ value.size > 0 && (react_1.default.createElement("span", { style: { fontSize: '12px', color: '#666' } }, formatFileSize(value.size))))) : (react_1.default.createElement("span", { style: { fontSize: '14px', color: '#666' } }, placeholder)))),
138
+ value && !disabled && (react_1.default.createElement("button", { type: "button", onClick: removeFile, style: {
139
+ background: 'none',
140
+ border: 'none',
141
+ cursor: 'pointer',
142
+ color: '#dc3545',
143
+ display: 'flex',
144
+ alignItems: 'center',
145
+ justifyContent: 'center',
146
+ padding: '4px'
147
+ } }, "\u2715"))),
148
+ react_1.default.createElement("input", { type: "file", ref: fileInputRef, onChange: handleFileChange, accept: accept, disabled: disabled, style: { display: 'none' } }),
149
+ errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
150
+ "\u26A0 ",
151
+ getErrorMessage()))));
152
+ };
153
+ exports.FvFileSelector = FvFileSelector;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { ValidationSchema } from '@fovestta2/validation-engine';
3
+ export interface FvIbanFieldProps {
4
+ label?: string;
5
+ value: string;
6
+ schema?: ValidationSchema;
7
+ disabled?: boolean;
8
+ className?: string;
9
+ inputClassName?: string;
10
+ labelClassName?: string;
11
+ errorClassName?: string;
12
+ onChange: (value: string) => void;
13
+ onBlur?: () => void;
14
+ onFocus?: () => void;
15
+ }
16
+ export declare const FvIbanField: React.FC<FvIbanFieldProps>;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.FvIbanField = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const validation_engine_1 = require("@fovestta2/validation-engine");
29
+ const FvIbanField = ({ label = 'IBAN Number', value, schema, disabled = false, className = '', inputClassName = '', labelClassName = '', errorClassName = '', onChange, onBlur, onFocus, }) => {
30
+ const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
31
+ (0, react_1.useEffect)(() => {
32
+ validateValue(value);
33
+ }, [value, schema]);
34
+ const validateValue = (val) => {
35
+ if (!schema)
36
+ return;
37
+ const result = validation_engine_1.Validator.validate(val, schema);
38
+ if (!result.isValid && result.errorKey) {
39
+ setErrorMessage(result.errorKey);
40
+ }
41
+ else {
42
+ setErrorMessage(null);
43
+ }
44
+ };
45
+ const handleInput = (e) => {
46
+ let rawVal = e.target.value;
47
+ const formatted = rawVal.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
48
+ const truncated = formatted.substring(0, 34);
49
+ onChange(truncated);
50
+ };
51
+ const handleBlur = (e) => {
52
+ validateValue(value);
53
+ if (onBlur)
54
+ onBlur();
55
+ };
56
+ const handleFocus = (e) => {
57
+ if (onFocus)
58
+ onFocus();
59
+ };
60
+ const isRequired = () => {
61
+ var _a;
62
+ return ((_a = schema === null || schema === void 0 ? void 0 : schema.rules) === null || _a === void 0 ? void 0 : _a.some((r) => { var _a; return r.name === 'required' && ((_a = r.params) === null || _a === void 0 ? void 0 : _a['enabled']); })) || false;
63
+ };
64
+ const getErrorMessage = () => {
65
+ if (!errorMessage)
66
+ return '';
67
+ const errorMessages = {
68
+ ERR_REQUIRED: 'This field is required',
69
+ };
70
+ return errorMessages[errorMessage] || errorMessage;
71
+ };
72
+ return (react_1.default.createElement("div", { className: `fv-field-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column' } },
73
+ label && (react_1.default.createElement("label", { className: `fv-label ${labelClassName}`, style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
74
+ label,
75
+ isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
76
+ react_1.default.createElement("input", { type: "text", value: value, onChange: handleInput, onBlur: handleBlur, onFocus: handleFocus, disabled: disabled, className: `fv-input ${errorMessage ? 'fv-input-error' : ''} ${inputClassName}`, style: {
77
+ padding: '10px',
78
+ border: errorMessage ? '1px solid #dc3545' : '1px solid #ccc',
79
+ borderRadius: '4px',
80
+ fontSize: '14px',
81
+ backgroundColor: disabled ? '#f5f5f5' : '#fff',
82
+ cursor: disabled ? 'not-allowed' : 'text',
83
+ outline: 'none',
84
+ boxSizing: 'border-box',
85
+ width: '100%',
86
+ ...(disabled ? { opacity: 0.6 } : {})
87
+ } }),
88
+ errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
89
+ "\u26A0 ",
90
+ getErrorMessage()))));
91
+ };
92
+ exports.FvIbanField = FvIbanField;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { ValidationSchema } from '@fovestta2/validation-engine';
3
+ export interface FvIfscFieldProps {
4
+ label?: string;
5
+ value: string;
6
+ schema?: ValidationSchema;
7
+ disabled?: boolean;
8
+ className?: string;
9
+ inputClassName?: string;
10
+ labelClassName?: string;
11
+ errorClassName?: string;
12
+ onChange: (value: string) => void;
13
+ onBlur?: () => void;
14
+ onFocus?: () => void;
15
+ }
16
+ export declare const FvIfscField: React.FC<FvIfscFieldProps>;