@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.
- package/dist/components/AddUpdateForm.d.ts +64 -0
- package/dist/components/AddUpdateForm.js +244 -0
- package/dist/components/FvCheckbox.d.ts +12 -0
- package/dist/components/FvCheckbox.js +19 -0
- package/dist/components/FvDateField.d.ts +19 -0
- package/dist/components/FvDateField.js +123 -0
- package/dist/components/FvDocumentField.d.ts +22 -0
- package/dist/components/FvDocumentField.js +242 -0
- package/dist/components/FvDropdown.d.ts +33 -0
- package/dist/components/FvDropdown.js +346 -0
- package/dist/components/FvEmailField.d.ts +18 -0
- package/dist/components/FvEmailField.js +103 -0
- package/dist/components/FvEntryField.d.ts +21 -0
- package/dist/components/FvEntryField.js +101 -0
- package/dist/components/FvEsiField.d.ts +16 -0
- package/dist/components/FvEsiField.js +92 -0
- package/dist/components/FvFileSelector.d.ts +22 -0
- package/dist/components/FvFileSelector.js +153 -0
- package/dist/components/FvIbanField.d.ts +16 -0
- package/dist/components/FvIbanField.js +92 -0
- package/dist/components/FvIfscField.d.ts +16 -0
- package/dist/components/FvIfscField.js +92 -0
- package/dist/components/FvImageSelector.d.ts +22 -0
- package/dist/components/FvImageSelector.js +317 -0
- package/dist/components/FvMicrField.d.ts +16 -0
- package/dist/components/FvMicrField.js +92 -0
- package/dist/components/FvMonthYearField.d.ts +19 -0
- package/dist/components/FvMonthYearField.js +139 -0
- package/dist/components/FvNameCode.d.ts +23 -0
- package/dist/components/FvNameCode.js +239 -0
- package/dist/components/FvNumberField.d.ts +21 -0
- package/dist/components/FvNumberField.js +98 -0
- package/dist/components/FvPasswordField.d.ts +18 -0
- package/dist/components/FvPasswordField.js +114 -0
- package/dist/components/FvPfField.d.ts +16 -0
- package/dist/components/FvPfField.js +106 -0
- package/dist/components/FvPhoneField.d.ts +16 -0
- package/dist/components/FvPhoneField.js +95 -0
- package/dist/components/FvRadioGroup.d.ts +20 -0
- package/dist/components/FvRadioGroup.js +64 -0
- package/dist/components/FvRichTextEditor.d.ts +20 -0
- package/dist/components/FvRichTextEditor.js +199 -0
- package/dist/components/FvServicePeriod.d.ts +10 -0
- package/dist/components/FvServicePeriod.js +122 -0
- package/dist/components/FvTimeField.d.ts +17 -0
- package/dist/components/FvTimeField.js +190 -0
- package/dist/components/FvToggle.d.ts +12 -0
- package/dist/components/FvToggle.js +39 -0
- package/dist/components/FvUanField.d.ts +16 -0
- package/dist/components/FvUanField.js +92 -0
- package/dist/components/QueryForm.d.ts +31 -0
- package/dist/components/QueryForm.js +214 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +47 -0
- package/package.json +39 -0
|
@@ -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.FvIfscField = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const validation_engine_1 = require("@fovestta2/validation-engine");
|
|
29
|
+
const FvIfscField = ({ label = 'IFSC Code', 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, 11);
|
|
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.FvIfscField = FvIfscField;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ValidationSchema } from '@fovestta2/validation-engine';
|
|
3
|
+
export interface ImageInfo {
|
|
4
|
+
file: File | Blob;
|
|
5
|
+
url: string;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
size: number;
|
|
9
|
+
}
|
|
10
|
+
export interface FvImageSelectorProps {
|
|
11
|
+
label?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
value: ImageInfo | null;
|
|
14
|
+
schema?: ValidationSchema;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
maxSize?: number;
|
|
17
|
+
className?: string;
|
|
18
|
+
errorClassName?: string;
|
|
19
|
+
onChange: (value: ImageInfo | null) => void;
|
|
20
|
+
onBlur?: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const FvImageSelector: React.FC<FvImageSelectorProps>;
|
|
@@ -0,0 +1,317 @@
|
|
|
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.FvImageSelector = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const validation_engine_1 = require("@fovestta2/validation-engine");
|
|
29
|
+
const FvImageSelector = ({ label = '', placeholder = 'Select an image', value, schema, disabled = false, maxSize, className = '', errorClassName = '', onChange, onBlur, }) => {
|
|
30
|
+
const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
|
|
31
|
+
const [isEditorOpen, setIsEditorOpen] = (0, react_1.useState)(false);
|
|
32
|
+
const [editImageSrc, setEditImageSrc] = (0, react_1.useState)(null);
|
|
33
|
+
const [editImageName, setEditImageName] = (0, react_1.useState)('');
|
|
34
|
+
const [scale, setScale] = (0, react_1.useState)(1);
|
|
35
|
+
const minScale = 0.5;
|
|
36
|
+
const maxScale = 3;
|
|
37
|
+
const step = 0.1;
|
|
38
|
+
const [panX, setPanX] = (0, react_1.useState)(0);
|
|
39
|
+
const [panY, setPanY] = (0, react_1.useState)(0);
|
|
40
|
+
const [isDragging, setIsDragging] = (0, react_1.useState)(false);
|
|
41
|
+
// Storing start coords in refs instead of state to avoid unnecessary re-renders during drag
|
|
42
|
+
const dragStartRef = (0, react_1.useRef)({ x: 0, y: 0 });
|
|
43
|
+
const imageInputRef = (0, react_1.useRef)(null);
|
|
44
|
+
const editorImageRef = (0, react_1.useRef)(null);
|
|
45
|
+
(0, react_1.useEffect)(() => {
|
|
46
|
+
validateValue(value);
|
|
47
|
+
}, [value, schema]);
|
|
48
|
+
(0, react_1.useEffect)(() => {
|
|
49
|
+
const handleMouseMove = (e) => {
|
|
50
|
+
if (!isDragging)
|
|
51
|
+
return;
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
setPanX(e.clientX - dragStartRef.current.x);
|
|
54
|
+
setPanY(e.clientY - dragStartRef.current.y);
|
|
55
|
+
};
|
|
56
|
+
const handleMouseUp = () => {
|
|
57
|
+
if (isDragging)
|
|
58
|
+
setIsDragging(false);
|
|
59
|
+
};
|
|
60
|
+
if (isDragging) {
|
|
61
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
62
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
63
|
+
}
|
|
64
|
+
return () => {
|
|
65
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
66
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
67
|
+
};
|
|
68
|
+
}, [isDragging]);
|
|
69
|
+
const validateValue = (val) => {
|
|
70
|
+
if (!schema)
|
|
71
|
+
return;
|
|
72
|
+
const result = validation_engine_1.Validator.validate(val, schema);
|
|
73
|
+
if (!result.isValid && result.errorKey) {
|
|
74
|
+
setErrorMessage(result.errorKey);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
setErrorMessage(null);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const handleImageSelected = (e) => {
|
|
81
|
+
const files = e.target.files;
|
|
82
|
+
if (files && files.length > 0) {
|
|
83
|
+
const file = files[0];
|
|
84
|
+
if (!file.type.startsWith('image/')) {
|
|
85
|
+
alert('Please select an image file');
|
|
86
|
+
if (imageInputRef.current)
|
|
87
|
+
imageInputRef.current.value = '';
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (maxSize && file.size > maxSize) {
|
|
91
|
+
alert(`Image size exceeds ${formatFileSize(maxSize)}`);
|
|
92
|
+
if (imageInputRef.current)
|
|
93
|
+
imageInputRef.current.value = '';
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const reader = new FileReader();
|
|
97
|
+
reader.onload = (ev) => {
|
|
98
|
+
if (ev.target && typeof ev.target.result === 'string') {
|
|
99
|
+
setEditImageSrc(ev.target.result);
|
|
100
|
+
setEditImageName(file.name);
|
|
101
|
+
openEditor();
|
|
102
|
+
if (imageInputRef.current)
|
|
103
|
+
imageInputRef.current.value = '';
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
reader.readAsDataURL(file);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const openEditor = () => {
|
|
110
|
+
setIsEditorOpen(true);
|
|
111
|
+
setScale(1);
|
|
112
|
+
setPanX(0);
|
|
113
|
+
setPanY(0);
|
|
114
|
+
};
|
|
115
|
+
const closeEditor = () => {
|
|
116
|
+
setIsEditorOpen(false);
|
|
117
|
+
setEditImageSrc(null);
|
|
118
|
+
};
|
|
119
|
+
const startDrag = (e) => {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
setIsDragging(true);
|
|
122
|
+
dragStartRef.current = {
|
|
123
|
+
x: e.clientX - panX,
|
|
124
|
+
y: e.clientY - panY,
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const handleSliderChange = (e) => {
|
|
128
|
+
setScale(parseFloat(e.target.value));
|
|
129
|
+
};
|
|
130
|
+
const zoomIn = () => {
|
|
131
|
+
setScale((prev) => Math.min(prev + step, maxScale));
|
|
132
|
+
};
|
|
133
|
+
const zoomOut = () => {
|
|
134
|
+
setScale((prev) => Math.max(prev - step, minScale));
|
|
135
|
+
};
|
|
136
|
+
const resetEditor = () => {
|
|
137
|
+
setScale(1);
|
|
138
|
+
setPanX(0);
|
|
139
|
+
setPanY(0);
|
|
140
|
+
};
|
|
141
|
+
const dataURLtoBlob = (dataurl) => {
|
|
142
|
+
const arr = dataurl.split(',');
|
|
143
|
+
const match = arr[0].match(/:(.*?);/);
|
|
144
|
+
const mime = match ? match[1] : 'image/png';
|
|
145
|
+
const bstr = atob(arr[1]);
|
|
146
|
+
let n = bstr.length;
|
|
147
|
+
const u8arr = new Uint8Array(n);
|
|
148
|
+
while (n--) {
|
|
149
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
150
|
+
}
|
|
151
|
+
return new Blob([u8arr], { type: mime });
|
|
152
|
+
};
|
|
153
|
+
const applyCrop = () => {
|
|
154
|
+
if (!editorImageRef.current)
|
|
155
|
+
return;
|
|
156
|
+
const img = editorImageRef.current;
|
|
157
|
+
const canvas = document.createElement('canvas');
|
|
158
|
+
const ctx = canvas.getContext('2d');
|
|
159
|
+
if (!ctx)
|
|
160
|
+
return;
|
|
161
|
+
const size = 300; // Output size
|
|
162
|
+
canvas.width = size;
|
|
163
|
+
canvas.height = size;
|
|
164
|
+
ctx.fillStyle = '#ffffff';
|
|
165
|
+
ctx.fillRect(0, 0, size, size);
|
|
166
|
+
ctx.translate(size / 2, size / 2);
|
|
167
|
+
ctx.translate(panX, panY);
|
|
168
|
+
ctx.scale(scale, scale);
|
|
169
|
+
ctx.translate(-img.naturalWidth / 2, -img.naturalHeight / 2);
|
|
170
|
+
ctx.drawImage(img, 0, 0);
|
|
171
|
+
const dataUrl = canvas.toDataURL('image/png');
|
|
172
|
+
const blob = dataURLtoBlob(dataUrl);
|
|
173
|
+
// Approximate size, in real app would use blob size
|
|
174
|
+
const finalSize = blob.size;
|
|
175
|
+
const imageInfo = {
|
|
176
|
+
file: new File([blob], editImageName, { type: 'image/png' }),
|
|
177
|
+
url: dataUrl,
|
|
178
|
+
width: size,
|
|
179
|
+
height: size,
|
|
180
|
+
size: finalSize,
|
|
181
|
+
};
|
|
182
|
+
onChange(imageInfo);
|
|
183
|
+
if (onBlur)
|
|
184
|
+
onBlur();
|
|
185
|
+
closeEditor();
|
|
186
|
+
};
|
|
187
|
+
const openImageDialog = () => {
|
|
188
|
+
if (!disabled && imageInputRef.current) {
|
|
189
|
+
imageInputRef.current.click();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const removeImage = (e) => {
|
|
193
|
+
e.stopPropagation();
|
|
194
|
+
if (disabled)
|
|
195
|
+
return;
|
|
196
|
+
onChange(null);
|
|
197
|
+
if (imageInputRef.current) {
|
|
198
|
+
imageInputRef.current.value = '';
|
|
199
|
+
}
|
|
200
|
+
if (onBlur)
|
|
201
|
+
onBlur();
|
|
202
|
+
};
|
|
203
|
+
const formatFileSize = (bytes) => {
|
|
204
|
+
if (bytes === undefined || bytes === 0)
|
|
205
|
+
return '0 Bytes';
|
|
206
|
+
const k = 1024;
|
|
207
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
208
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
209
|
+
return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i];
|
|
210
|
+
};
|
|
211
|
+
const isRequired = () => {
|
|
212
|
+
var _a;
|
|
213
|
+
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;
|
|
214
|
+
};
|
|
215
|
+
const getErrorMessage = () => {
|
|
216
|
+
if (!errorMessage)
|
|
217
|
+
return '';
|
|
218
|
+
const errorMessages = {
|
|
219
|
+
ERR_REQUIRED: 'This field is required',
|
|
220
|
+
ERR_INVALID_IMAGE: 'Invalid image',
|
|
221
|
+
};
|
|
222
|
+
return errorMessages[errorMessage] || errorMessage;
|
|
223
|
+
};
|
|
224
|
+
return (react_1.default.createElement("div", { className: `fv-image-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column' } },
|
|
225
|
+
label && (react_1.default.createElement("label", { className: "fv-label", style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
|
|
226
|
+
label,
|
|
227
|
+
isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
|
|
228
|
+
react_1.default.createElement("div", { className: `image-upload-box ${errorMessage ? 'error' : ''} ${disabled ? 'disabled' : ''}`, onClick: openImageDialog, style: {
|
|
229
|
+
display: 'flex',
|
|
230
|
+
alignItems: 'center',
|
|
231
|
+
justifyContent: 'center',
|
|
232
|
+
flexDirection: 'column',
|
|
233
|
+
minHeight: '120px',
|
|
234
|
+
border: errorMessage ? '2px dashed #dc3545' : '2px dashed #8CBBA8',
|
|
235
|
+
borderRadius: '8px',
|
|
236
|
+
backgroundColor: disabled ? '#f9f9f9' : '#F6F9F8',
|
|
237
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
238
|
+
transition: 'all 0.2sease',
|
|
239
|
+
position: 'relative',
|
|
240
|
+
overflow: 'hidden',
|
|
241
|
+
opacity: disabled ? 0.6 : 1
|
|
242
|
+
} }, value ? (react_1.default.createElement("div", { style: { position: 'relative', width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' } },
|
|
243
|
+
react_1.default.createElement("img", { src: value.url, alt: value.file instanceof File ? value.file.name : 'Image preview', style: { maxHeight: '150px', maxWidth: '100%', objectFit: 'contain' } }),
|
|
244
|
+
!disabled && (react_1.default.createElement("button", { type: "button", className: "remove-image-btn", onClick: removeImage, style: {
|
|
245
|
+
position: 'absolute',
|
|
246
|
+
top: '8px',
|
|
247
|
+
right: '8px',
|
|
248
|
+
background: 'rgba(255, 255, 255, 0.8)',
|
|
249
|
+
border: 'none',
|
|
250
|
+
borderRadius: '50%',
|
|
251
|
+
width: '28px',
|
|
252
|
+
height: '28px',
|
|
253
|
+
display: 'flex',
|
|
254
|
+
alignItems: 'center',
|
|
255
|
+
justifyContent: 'center',
|
|
256
|
+
cursor: 'pointer',
|
|
257
|
+
color: '#e74c3c',
|
|
258
|
+
boxShadow: '0 2px 4px rgba(0,0,0,0.1)'
|
|
259
|
+
}, title: "Remove Image" }, "\u2715")))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
260
|
+
react_1.default.createElement("span", { style: { fontSize: '32px', color: '#8CBBA8', marginBottom: '8px' } }, "\uD83D\uDCF8"),
|
|
261
|
+
react_1.default.createElement("span", { style: { fontSize: '14px', color: '#666', fontWeight: 500 } }, placeholder),
|
|
262
|
+
react_1.default.createElement("span", { style: { fontSize: '12px', color: '#999', marginTop: '4px' } }, maxSize ? `Max size: ${formatFileSize(maxSize)}` : 'Click to browse')))),
|
|
263
|
+
react_1.default.createElement("input", { type: "file", ref: imageInputRef, onChange: handleImageSelected, accept: "image/*", disabled: disabled, onClick: (e) => { e.stopPropagation(); }, style: { display: 'none' } }),
|
|
264
|
+
errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
|
|
265
|
+
"\u26A0 ",
|
|
266
|
+
getErrorMessage())),
|
|
267
|
+
isEditorOpen && editImageSrc && (react_1.default.createElement("div", { className: "editor-modal-overlay", style: {
|
|
268
|
+
position: 'fixed',
|
|
269
|
+
top: 0, left: 0, right: 0, bottom: 0,
|
|
270
|
+
backgroundColor: 'rgba(0,0,0,0.8)',
|
|
271
|
+
display: 'flex',
|
|
272
|
+
alignItems: 'center',
|
|
273
|
+
justifyContent: 'center',
|
|
274
|
+
zIndex: 9999
|
|
275
|
+
} },
|
|
276
|
+
react_1.default.createElement("div", { className: "editor-modal-content", style: {
|
|
277
|
+
backgroundColor: '#fff',
|
|
278
|
+
borderRadius: '12px',
|
|
279
|
+
padding: '20px',
|
|
280
|
+
width: '400px',
|
|
281
|
+
maxWidth: '90%',
|
|
282
|
+
display: 'flex',
|
|
283
|
+
flexDirection: 'column',
|
|
284
|
+
boxShadow: '0 10px 25px rgba(0,0,0,0.2)'
|
|
285
|
+
} },
|
|
286
|
+
react_1.default.createElement("h3", { style: { margin: '0 0 16px', fontSize: '18px', color: '#151D48', fontWeight: 600 } }, "Adjust Image"),
|
|
287
|
+
react_1.default.createElement("div", { className: "crop-area-wrapper", style: {
|
|
288
|
+
width: '300px',
|
|
289
|
+
height: '300px',
|
|
290
|
+
margin: '0 auto',
|
|
291
|
+
borderRadius: '50%', // optional: circle crop mask
|
|
292
|
+
overflow: 'hidden',
|
|
293
|
+
backgroundColor: '#f0f0f0',
|
|
294
|
+
position: 'relative',
|
|
295
|
+
cursor: isDragging ? 'grabbing' : 'grab',
|
|
296
|
+
border: '1px solid #ddd'
|
|
297
|
+
}, onMouseDown: startDrag },
|
|
298
|
+
react_1.default.createElement("img", { ref: editorImageRef, src: editImageSrc, alt: "Edit Preview", draggable: false, style: {
|
|
299
|
+
position: 'absolute',
|
|
300
|
+
left: '50%',
|
|
301
|
+
top: '50%',
|
|
302
|
+
transform: `translate(-50%, -50%) translate(${panX}px, ${panY}px) scale(${scale})`,
|
|
303
|
+
transformOrigin: 'center center',
|
|
304
|
+
pointerEvents: 'none', // let wrapper handle mouse events
|
|
305
|
+
} })),
|
|
306
|
+
react_1.default.createElement("div", { className: "editor-controls", style: { marginTop: '20px', display: 'flex', flexDirection: 'column', gap: '16px' } },
|
|
307
|
+
react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center', gap: '12px' } },
|
|
308
|
+
react_1.default.createElement("button", { type: "button", onClick: zoomOut, style: { background: 'none', border: 'none', cursor: 'pointer', fontSize: '18px', color: '#555' } }, "-"),
|
|
309
|
+
react_1.default.createElement("input", { type: "range", min: minScale, max: maxScale, step: step, value: scale, onChange: handleSliderChange, style: { flex: 1 } }),
|
|
310
|
+
react_1.default.createElement("button", { type: "button", onClick: zoomIn, style: { background: 'none', border: 'none', cursor: 'pointer', fontSize: '18px', color: '#555' } }, "+")),
|
|
311
|
+
react_1.default.createElement("div", { style: { display: 'flex', justifyContent: 'space-between', marginTop: '8px' } },
|
|
312
|
+
react_1.default.createElement("button", { type: "button", onClick: resetEditor, style: { padding: '8px 16px', background: '#f5f5f5', border: '1px solid #ddd', borderRadius: '4px', cursor: 'pointer', color: '#555', fontSize: '14px' } }, "Reset"),
|
|
313
|
+
react_1.default.createElement("div", { style: { display: 'flex', gap: '8px' } },
|
|
314
|
+
react_1.default.createElement("button", { type: "button", onClick: closeEditor, style: { padding: '8px 16px', background: 'none', border: 'none', cursor: 'pointer', color: '#666', fontSize: '14px', fontWeight: 500 } }, "Cancel"),
|
|
315
|
+
react_1.default.createElement("button", { type: "button", onClick: applyCrop, style: { padding: '8px 24px', background: '#4CAF50', color: '#fff', border: 'none', borderRadius: '4px', cursor: 'pointer', fontSize: '14px', fontWeight: 500 } }, "Apply")))))))));
|
|
316
|
+
};
|
|
317
|
+
exports.FvImageSelector = FvImageSelector;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ValidationSchema } from '@fovestta2/validation-engine';
|
|
3
|
+
export interface FvMicrFieldProps {
|
|
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 FvMicrField: React.FC<FvMicrFieldProps>;
|
|
@@ -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.FvMicrField = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const validation_engine_1 = require("@fovestta2/validation-engine");
|
|
29
|
+
const FvMicrField = ({ label = 'MICR Code', 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, 9);
|
|
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.FvMicrField = FvMicrField;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ValidationSchema } from '@fovestta2/validation-engine';
|
|
3
|
+
export interface FvMonthYearFieldProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
value: string;
|
|
6
|
+
schema?: ValidationSchema;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
readonly?: boolean;
|
|
9
|
+
min?: string;
|
|
10
|
+
max?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
inputClassName?: string;
|
|
13
|
+
labelClassName?: string;
|
|
14
|
+
errorClassName?: string;
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
onBlur?: () => void;
|
|
17
|
+
onFocus?: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const FvMonthYearField: React.FC<FvMonthYearFieldProps>;
|