@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,17 @@
1
+ import React from 'react';
2
+ import { ValidationSchema } from '@fovestta2/validation-engine';
3
+ export interface FvTimeFieldProps {
4
+ label?: string;
5
+ value: string;
6
+ schema?: ValidationSchema;
7
+ disabled?: boolean;
8
+ readonly?: boolean;
9
+ placeholder?: string;
10
+ className?: string;
11
+ labelClassName?: string;
12
+ errorClassName?: string;
13
+ onChange: (value: string) => void;
14
+ onBlur?: () => void;
15
+ onFocus?: () => void;
16
+ }
17
+ export declare const FvTimeField: React.FC<FvTimeFieldProps>;
@@ -0,0 +1,190 @@
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.FvTimeField = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const validation_engine_1 = require("@fovestta2/validation-engine");
29
+ const FvTimeField = ({ label = '', value, schema, disabled = false, readonly = false, placeholder = '--:--', className = '', labelClassName = '', errorClassName = '', onChange, onBlur, onFocus, }) => {
30
+ const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
31
+ const [showPicker, setShowPicker] = (0, react_1.useState)(false);
32
+ const [selectedHour, setSelectedHour] = (0, react_1.useState)(null);
33
+ const [selectedMinute, setSelectedMinute] = (0, react_1.useState)(null);
34
+ const containerRef = (0, react_1.useRef)(null);
35
+ const hours = Array.from({ length: 24 }, (_, i) => i);
36
+ const minutes = Array.from({ length: 60 }, (_, i) => i);
37
+ (0, react_1.useEffect)(() => {
38
+ validateValue(value);
39
+ parseTimeValue(value);
40
+ }, [value, schema]);
41
+ (0, react_1.useEffect)(() => {
42
+ const handleClickOutside = (event) => {
43
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
44
+ if (showPicker) {
45
+ setShowPicker(false);
46
+ validateValue(value);
47
+ if (onBlur)
48
+ onBlur();
49
+ }
50
+ }
51
+ };
52
+ document.addEventListener('mousedown', handleClickOutside);
53
+ return () => {
54
+ document.removeEventListener('mousedown', handleClickOutside);
55
+ };
56
+ }, [showPicker, value]);
57
+ const parseTimeValue = (val) => {
58
+ if (!val || typeof val !== 'string') {
59
+ setSelectedHour(null);
60
+ setSelectedMinute(null);
61
+ return;
62
+ }
63
+ const parts = val.split(':');
64
+ if (parts.length === 2) {
65
+ const h = parseInt(parts[0], 10);
66
+ const m = parseInt(parts[1], 10);
67
+ if (!isNaN(h) && h >= 0 && h <= 23)
68
+ setSelectedHour(h);
69
+ if (!isNaN(m) && m >= 0 && m <= 59)
70
+ setSelectedMinute(m);
71
+ }
72
+ };
73
+ const validateValue = (val) => {
74
+ if (!schema)
75
+ return;
76
+ const result = validation_engine_1.Validator.validate(val, schema);
77
+ if (!result.isValid && result.errorKey) {
78
+ setErrorMessage(result.errorKey);
79
+ }
80
+ else {
81
+ setErrorMessage(null);
82
+ }
83
+ };
84
+ const padZero = (num) => num.toString().padStart(2, '0');
85
+ const updateTimeValue = (hour, minute) => {
86
+ if (hour !== null && minute !== null) {
87
+ const timeVal = `${padZero(hour)}:${padZero(minute)}`;
88
+ onChange(timeVal);
89
+ setShowPicker(false);
90
+ }
91
+ };
92
+ const handleSelectHour = (h) => {
93
+ setSelectedHour(h);
94
+ updateTimeValue(h, selectedMinute);
95
+ };
96
+ const handleSelectMinute = (m) => {
97
+ setSelectedMinute(m);
98
+ updateTimeValue(selectedHour, m);
99
+ };
100
+ const togglePicker = () => {
101
+ if (!disabled && !readonly) {
102
+ if (!showPicker) {
103
+ if (onFocus)
104
+ onFocus();
105
+ }
106
+ setShowPicker(!showPicker);
107
+ }
108
+ };
109
+ const isRequired = () => {
110
+ var _a;
111
+ 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;
112
+ };
113
+ const getDisplayValue = () => {
114
+ if (selectedHour !== null && selectedMinute !== null) {
115
+ return `${padZero(selectedHour)}:${padZero(selectedMinute)}`;
116
+ }
117
+ return placeholder;
118
+ };
119
+ const getErrorMessage = () => {
120
+ if (!errorMessage)
121
+ return '';
122
+ const errorMessages = {
123
+ ERR_REQUIRED: 'Time is required',
124
+ ERR_INVALID_TIME: 'Invalid time format',
125
+ };
126
+ return errorMessages[errorMessage] || errorMessage;
127
+ };
128
+ return (react_1.default.createElement("div", { ref: containerRef, className: `fv-field-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column', position: 'relative' } },
129
+ label && (react_1.default.createElement("label", { className: `fv-label ${labelClassName}`, style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
130
+ label,
131
+ isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
132
+ react_1.default.createElement("div", { className: `time-input ${errorMessage ? 'error' : ''}`, onClick: togglePicker, style: {
133
+ display: 'flex',
134
+ alignItems: 'center',
135
+ justifyContent: 'space-between',
136
+ padding: '10px',
137
+ border: errorMessage ? '1px solid #dc3545' : '1px solid #ccc',
138
+ borderRadius: '4px',
139
+ fontSize: '14px',
140
+ backgroundColor: disabled ? '#f5f5f5' : '#fff',
141
+ cursor: disabled || readonly ? 'not-allowed' : 'pointer',
142
+ ...((disabled || readonly) ? { opacity: 0.6 } : {})
143
+ } },
144
+ react_1.default.createElement("span", { style: { color: (selectedHour !== null && selectedMinute !== null) ? '#333' : '#999' } }, getDisplayValue()),
145
+ react_1.default.createElement("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "currentColor", style: { color: '#666' } },
146
+ react_1.default.createElement("path", { d: "M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" }))),
147
+ showPicker && (react_1.default.createElement("div", { className: "time-picker-dropdown", style: {
148
+ position: 'absolute',
149
+ top: '100%',
150
+ left: 0,
151
+ marginTop: '4px',
152
+ backgroundColor: '#fff',
153
+ border: '1px solid #ccc',
154
+ borderRadius: '4px',
155
+ boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
156
+ zIndex: 1000,
157
+ width: '200px',
158
+ display: 'flex',
159
+ flexDirection: 'column'
160
+ } },
161
+ react_1.default.createElement("div", { style: { padding: '10px', display: 'flex', justifyContent: 'space-between', borderBottom: '1px solid #eee', fontWeight: 'bold' } },
162
+ react_1.default.createElement("span", null,
163
+ selectedHour !== null ? padZero(selectedHour) : '--',
164
+ ":",
165
+ selectedMinute !== null ? padZero(selectedMinute) : '--'),
166
+ react_1.default.createElement("button", { type: "button", onClick: () => setShowPicker(false), style: { background: 'none', border: 'none', cursor: 'pointer', fontSize: '18px', lineHeight: 1 } }, "\u00D7")),
167
+ react_1.default.createElement("div", { style: { display: 'flex', height: '200px' } },
168
+ react_1.default.createElement("div", { style: { flex: 1, overflowY: 'auto', borderRight: '1px solid #eee' } },
169
+ react_1.default.createElement("div", { style: { padding: '5px', textAlign: 'center', fontWeight: 'bold', fontSize: '12px', color: '#666', borderBottom: '1px solid #eee' } }, "Hour"),
170
+ hours.map((h) => (react_1.default.createElement("div", { key: `h-${h}`, onClick: () => handleSelectHour(h), style: {
171
+ padding: '8px',
172
+ textAlign: 'center',
173
+ cursor: 'pointer',
174
+ backgroundColor: selectedHour === h ? '#007bff' : 'transparent',
175
+ color: selectedHour === h ? '#fff' : '#333'
176
+ } }, padZero(h))))),
177
+ react_1.default.createElement("div", { style: { flex: 1, overflowY: 'auto' } },
178
+ react_1.default.createElement("div", { style: { padding: '5px', textAlign: 'center', fontWeight: 'bold', fontSize: '12px', color: '#666', borderBottom: '1px solid #eee' } }, "Minute"),
179
+ minutes.map((m) => (react_1.default.createElement("div", { key: `m-${m}`, onClick: () => handleSelectMinute(m), style: {
180
+ padding: '8px',
181
+ textAlign: 'center',
182
+ cursor: 'pointer',
183
+ backgroundColor: selectedMinute === m ? '#007bff' : 'transparent',
184
+ color: selectedMinute === m ? '#fff' : '#333'
185
+ } }, padZero(m)))))))),
186
+ errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
187
+ "\u26A0 ",
188
+ getErrorMessage()))));
189
+ };
190
+ exports.FvTimeField = FvTimeField;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export interface FvToggleProps {
3
+ label?: string;
4
+ value: boolean;
5
+ disabled?: boolean;
6
+ required?: boolean;
7
+ className?: string;
8
+ labelClassName?: string;
9
+ toggleClassName?: string;
10
+ onChange: (value: boolean) => void;
11
+ }
12
+ export declare const FvToggle: React.FC<FvToggleProps>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FvToggle = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const FvToggle = ({ label = '', value, disabled = false, required = false, className = '', labelClassName = '', toggleClassName = '', onChange, }) => {
9
+ const handleChange = (e) => {
10
+ onChange(e.target.checked);
11
+ };
12
+ return (react_1.default.createElement("div", { className: `fv-toggle-container ${className}`, style: { marginBottom: '16px', display: 'flex', alignItems: 'center' } },
13
+ react_1.default.createElement("label", { className: `fv-toggle-label ${labelClassName}`, style: { display: 'flex', alignItems: 'center', cursor: disabled ? 'not-allowed' : 'pointer', fontSize: '14px', color: disabled ? '#999' : '#333' } },
14
+ react_1.default.createElement("span", { className: "fv-toggle-text", style: { marginRight: '10px' } },
15
+ label,
16
+ required && react_1.default.createElement("span", { className: "fv-required-asterisk", style: { color: '#dc3545', fontWeight: 'bold' } }, " *")),
17
+ react_1.default.createElement("div", { className: `fv-toggle-switch ${toggleClassName}`, style: { position: 'relative', display: 'inline-block', width: '40px', height: '20px' } },
18
+ react_1.default.createElement("input", { type: "checkbox", checked: value, onChange: handleChange, disabled: disabled, className: "fv-toggle-input", style: { opacity: 0, width: 0, height: 0 } }),
19
+ react_1.default.createElement("span", { className: "fv-toggle-slider", style: {
20
+ position: 'absolute',
21
+ cursor: disabled ? 'not-allowed' : 'pointer',
22
+ top: 0, left: 0, right: 0, bottom: 0,
23
+ backgroundColor: value ? '#007bff' : (disabled ? '#e0e0e0' : '#ccc'),
24
+ transition: '0.4s',
25
+ borderRadius: '34px'
26
+ } },
27
+ react_1.default.createElement("span", { style: {
28
+ position: 'absolute',
29
+ content: '""',
30
+ height: '16px',
31
+ width: '16px',
32
+ left: value ? '22px' : '2px',
33
+ bottom: '2px',
34
+ backgroundColor: 'white',
35
+ transition: '0.4s',
36
+ borderRadius: '50%'
37
+ } }))))));
38
+ };
39
+ exports.FvToggle = FvToggle;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { ValidationSchema } from '@fovestta2/validation-engine';
3
+ export interface FvUanFieldProps {
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 FvUanField: React.FC<FvUanFieldProps>;
@@ -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.FvUanField = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const validation_engine_1 = require("@fovestta2/validation-engine");
29
+ const FvUanField = ({ label = 'UAN 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, 12);
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.FvUanField = FvUanField;
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ export interface QueryFormColumn {
3
+ label: string;
4
+ key: string;
5
+ type: 'dropdown' | 'text' | 'number' | 'date' | 'month' | 'file' | 'name-code' | 'phone' | 'uan' | 'pf' | 'esi' | 'ifsc' | 'micr' | 'iban' | 'email' | 'password' | 'toggle';
6
+ options?: any[];
7
+ placeholder?: string;
8
+ onChange?: (value: any) => void;
9
+ accept?: string;
10
+ required?: boolean;
11
+ readonly?: boolean;
12
+ }
13
+ export interface QueryFormRow {
14
+ columns: QueryFormColumn[];
15
+ }
16
+ export interface QueryFormConfig {
17
+ title: string;
18
+ rows: QueryFormRow[];
19
+ buttonText?: string;
20
+ showExportButton?: boolean;
21
+ exportFormats?: string[];
22
+ showBackButton?: boolean;
23
+ backButtonText?: string;
24
+ }
25
+ export interface QueryFormProps {
26
+ config: QueryFormConfig;
27
+ onSubmit: (data: Record<string, any>) => void;
28
+ onExport?: (format: string) => void;
29
+ onBack?: () => void;
30
+ }
31
+ export declare const QueryForm: React.FC<QueryFormProps>;
@@ -0,0 +1,214 @@
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.QueryForm = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ // Import all Fv controls
29
+ const FvEntryField_1 = require("./FvEntryField");
30
+ const FvDropdown_1 = require("./FvDropdown");
31
+ const FvNumberField_1 = require("./FvNumberField");
32
+ const FvDateField_1 = require("./FvDateField");
33
+ const FvMonthYearField_1 = require("./FvMonthYearField");
34
+ const FvFileSelector_1 = require("./FvFileSelector");
35
+ const FvNameCode_1 = require("./FvNameCode");
36
+ const FvPhoneField_1 = require("./FvPhoneField");
37
+ const FvUanField_1 = require("./FvUanField");
38
+ const FvPfField_1 = require("./FvPfField");
39
+ const FvEsiField_1 = require("./FvEsiField");
40
+ const FvIfscField_1 = require("./FvIfscField");
41
+ const FvMicrField_1 = require("./FvMicrField");
42
+ const FvIbanField_1 = require("./FvIbanField");
43
+ const FvEmailField_1 = require("./FvEmailField");
44
+ const FvPasswordField_1 = require("./FvPasswordField");
45
+ const FvToggle_1 = require("./FvToggle");
46
+ const QueryForm = ({ config, onSubmit, onExport, onBack, }) => {
47
+ const [formData, setFormData] = (0, react_1.useState)({});
48
+ const [showExportMenu, setShowExportMenu] = (0, react_1.useState)(false);
49
+ const [showValidationError, setShowValidationError] = (0, react_1.useState)(false);
50
+ // Initialize form data
51
+ (0, react_1.useEffect)(() => {
52
+ const initialData = {};
53
+ config.rows.forEach(row => {
54
+ row.columns.forEach(col => {
55
+ initialData[col.key] = col.type === 'toggle' ? false : '';
56
+ });
57
+ });
58
+ setFormData(initialData);
59
+ }, [config]);
60
+ (0, react_1.useEffect)(() => {
61
+ const handleClickOutside = () => setShowExportMenu(false);
62
+ document.addEventListener('click', handleClickOutside);
63
+ return () => document.removeEventListener('click', handleClickOutside);
64
+ }, []);
65
+ const handleFieldChange = (key, value, column) => {
66
+ setFormData(prev => ({ ...prev, [key]: value }));
67
+ if (column.onChange) {
68
+ column.onChange(value);
69
+ }
70
+ };
71
+ const mapSearchOptions = (options) => {
72
+ return options.map(opt => ({
73
+ code: opt.code || opt.value,
74
+ name: opt.name || opt.label || opt.value,
75
+ value: opt.value
76
+ }));
77
+ };
78
+ const mapType = (type) => {
79
+ switch (type) {
80
+ case 'text': return 'EntryField';
81
+ case 'number': return 'NumberField';
82
+ case 'date': return 'DateField';
83
+ case 'dropdown': return 'Dropdown';
84
+ case 'month': return 'MonthYearField';
85
+ case 'file': return 'FileSelector';
86
+ case 'name-code': return 'Dropdown';
87
+ case 'phone': return 'PhoneField';
88
+ case 'uan': return 'UanField';
89
+ case 'pf': return 'PfField';
90
+ case 'esi': return 'EsiField';
91
+ case 'ifsc': return 'IfscField';
92
+ case 'micr': return 'MicrField';
93
+ case 'iban': return 'IbanField';
94
+ case 'email': return 'EmailField';
95
+ case 'password': return 'PasswordField';
96
+ case 'toggle': return 'Toggle';
97
+ default: return 'EntryField';
98
+ }
99
+ };
100
+ const getSchema = (column) => {
101
+ const rules = [];
102
+ const errorPriority = [];
103
+ if (column.required) {
104
+ rules.push({ name: 'required', params: { enabled: true }, errorKey: 'ERR_REQUIRED' });
105
+ errorPriority.push('required');
106
+ }
107
+ if (column.type === 'email') {
108
+ rules.push({ name: 'regex', params: { pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$' }, errorKey: 'ERR_EMAIL_INVALID' });
109
+ errorPriority.push('regex');
110
+ }
111
+ if (column.type === 'pf') {
112
+ rules.push({ name: 'regex', params: { pattern: '^[A-Z]{2}/[A-Z]{3}/[0-9]{7}/[0-9]{3}/[0-9]{7}$' }, errorKey: 'ERR_PF_INVALID' });
113
+ errorPriority.push('regex');
114
+ }
115
+ if (column.type === 'password') {
116
+ rules.push({
117
+ name: 'passwordComplexity',
118
+ params: { minLength: 8, requireUppercase: true, requireLowercase: true, requireNumber: true, requireSpecialChar: true }
119
+ });
120
+ errorPriority.push('passwordComplexity');
121
+ }
122
+ return {
123
+ controlType: mapType(column.type),
124
+ rules: rules,
125
+ errorPriority: errorPriority
126
+ };
127
+ };
128
+ const validateForm = () => {
129
+ let isValid = true;
130
+ config.rows.forEach(row => {
131
+ row.columns.forEach(col => {
132
+ if (col.required && (!formData[col.key] || formData[col.key] === '')) {
133
+ isValid = false;
134
+ }
135
+ });
136
+ });
137
+ return isValid;
138
+ };
139
+ const handleButtonClick = () => {
140
+ if (validateForm()) {
141
+ setShowValidationError(false);
142
+ onSubmit(formData);
143
+ }
144
+ else {
145
+ setShowValidationError(true);
146
+ }
147
+ };
148
+ const exportToFormat = (format, e) => {
149
+ e.stopPropagation();
150
+ if (onExport)
151
+ onExport(format);
152
+ setShowExportMenu(false);
153
+ };
154
+ const renderField = (column) => {
155
+ const value = formData[column.key];
156
+ const schema = getSchema(column);
157
+ const disabled = column.readonly || false;
158
+ const onChange = (val) => handleFieldChange(column.key, val, column);
159
+ switch (column.type) {
160
+ case 'dropdown':
161
+ return react_1.default.createElement(FvDropdown_1.FvDropdown, { label: column.label, placeholder: column.placeholder || 'Select option', options: column.options || [], value: value || '', schema: schema, disabled: disabled, onChange: onChange });
162
+ case 'text':
163
+ return react_1.default.createElement(FvEntryField_1.FvEntryField, { label: column.label, placeholder: column.placeholder, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
164
+ case 'number':
165
+ return react_1.default.createElement(FvNumberField_1.FvNumberField, { label: column.label, placeholder: column.placeholder, value: value || null, schema: schema, disabled: disabled, onChange: onChange });
166
+ case 'date':
167
+ return react_1.default.createElement(FvDateField_1.FvDateField, { label: column.label, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
168
+ case 'month':
169
+ return react_1.default.createElement(FvMonthYearField_1.FvMonthYearField, { label: column.label, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
170
+ case 'file':
171
+ return react_1.default.createElement(FvFileSelector_1.FvFileSelector, { label: column.label, placeholder: column.placeholder, accept: column.accept, value: value || null, schema: schema, disabled: disabled, onChange: onChange });
172
+ case 'name-code':
173
+ return react_1.default.createElement(FvNameCode_1.FvNameCode, { label: column.label, placeholder: column.placeholder, options: mapSearchOptions(column.options || []), value: value || '', schema: schema, disabled: disabled, onChange: onChange });
174
+ case 'phone':
175
+ return react_1.default.createElement(FvPhoneField_1.FvPhoneField, { label: column.label, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
176
+ case 'uan':
177
+ return react_1.default.createElement(FvUanField_1.FvUanField, { label: column.label, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
178
+ case 'pf':
179
+ return react_1.default.createElement(FvPfField_1.FvPfField, { label: column.label, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
180
+ case 'esi':
181
+ return react_1.default.createElement(FvEsiField_1.FvEsiField, { label: column.label, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
182
+ case 'ifsc':
183
+ return react_1.default.createElement(FvIfscField_1.FvIfscField, { label: column.label, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
184
+ case 'micr':
185
+ return react_1.default.createElement(FvMicrField_1.FvMicrField, { label: column.label, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
186
+ case 'iban':
187
+ return react_1.default.createElement(FvIbanField_1.FvIbanField, { label: column.label, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
188
+ case 'email':
189
+ return react_1.default.createElement(FvEmailField_1.FvEmailField, { label: column.label, placeholder: column.placeholder, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
190
+ case 'password':
191
+ return react_1.default.createElement(FvPasswordField_1.FvPasswordField, { label: column.label, placeholder: column.placeholder, value: value || '', schema: schema, disabled: disabled, onChange: onChange });
192
+ case 'toggle':
193
+ return react_1.default.createElement(FvToggle_1.FvToggle, { label: column.label, value: value || false, disabled: disabled, onChange: onChange });
194
+ default:
195
+ return null;
196
+ }
197
+ };
198
+ return (react_1.default.createElement("div", { className: "query-form-container", style: { background: '#f2f2f2', border: '1px solid #e0e0e0', borderRadius: '8px', padding: '16px', marginBottom: '16px' } },
199
+ react_1.default.createElement("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '16px' } },
200
+ react_1.default.createElement("h2", { style: { fontSize: '20px', fontWeight: 700, margin: 0, color: '#303030' } }, config.title),
201
+ config.showExportButton && config.exportFormats && config.exportFormats.length > 0 && (react_1.default.createElement("div", { style: { position: 'relative' } },
202
+ react_1.default.createElement("button", { type: "button", onClick: (e) => { e.stopPropagation(); setShowExportMenu(!showExportMenu); }, style: { display: 'flex', alignItems: 'center', gap: '5px', padding: '8px 16px', background: '#006aff', color: '#fff', border: 'none', borderRadius: '7px', cursor: 'pointer' } }, "Export \u25BC"),
203
+ showExportMenu && (react_1.default.createElement("div", { style: { position: 'absolute', top: '100%', right: 0, background: '#fff', borderRadius: '4px', boxShadow: '0 4px 12px rgba(0,0,0,0.15)', marginTop: '5px', minWidth: '150px', zIndex: 1000 } }, config.exportFormats.map(format => (react_1.default.createElement("button", { key: format, onClick: (e) => exportToFormat(format, e), style: { width: '100%', padding: '10px 16px', background: 'none', border: 'none', textAlign: 'left', cursor: 'pointer', fontSize: '14px', borderBottom: '1px solid #f0f0f0' } },
204
+ "Export as ",
205
+ format.toUpperCase())))))))),
206
+ showValidationError && (react_1.default.createElement("div", { style: { background: '#fee', color: '#c33', padding: '12px 16px', borderRadius: '8px', marginBottom: '16px', border: '1px solid #fcc', fontSize: '14px', fontWeight: 500 } }, "\u26A0 Please fill all required fields correctly.")),
207
+ react_1.default.createElement("div", { style: { background: '#fff', padding: '16px', borderRadius: '12px', border: '1px solid #cfcfcf' } },
208
+ react_1.default.createElement("form", { onSubmit: (e) => e.preventDefault() },
209
+ config.rows.map((row, rowIndex) => (react_1.default.createElement("div", { key: rowIndex, style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '16px', marginBottom: '16px' } }, row.columns.map((col, colIndex) => (react_1.default.createElement("div", { key: `${rowIndex}-${colIndex}`, style: { minWidth: 0 } }, renderField(col))))))),
210
+ react_1.default.createElement("div", { style: { display: 'flex', justifyContent: 'space-between', gap: '12px', marginTop: '16px' } },
211
+ react_1.default.createElement("button", { type: "button", onClick: handleButtonClick, style: { padding: '8px 24px', background: '#006aff', color: '#fff', border: 'none', borderRadius: '7px', fontWeight: 600, cursor: 'pointer' } }, config.buttonText || 'View'),
212
+ config.showBackButton && (react_1.default.createElement("button", { type: "button", onClick: onBack, style: { padding: '8px 24px', background: '#303030', color: '#fff', border: 'none', borderRadius: '7px', fontWeight: 600, cursor: 'pointer' } }, config.backButtonText || 'Back')))))));
213
+ };
214
+ exports.QueryForm = QueryForm;
@@ -0,0 +1,28 @@
1
+ export * from './components/FvEntryField';
2
+ export * from './components/FvEmailField';
3
+ export * from './components/FvPasswordField';
4
+ export * from './components/FvNumberField';
5
+ export * from './components/FvCheckbox';
6
+ export * from './components/FvToggle';
7
+ export * from './components/FvDropdown';
8
+ export * from './components/FvRadioGroup';
9
+ export * from './components/FvDateField';
10
+ export * from './components/FvTimeField';
11
+ export * from './components/FvMonthYearField';
12
+ export * from './components/FvServicePeriod';
13
+ export * from './components/FvEsiField';
14
+ export * from './components/FvIbanField';
15
+ export * from './components/FvIfscField';
16
+ export * from './components/FvMicrField';
17
+ export * from './components/FvPfField';
18
+ export * from './components/FvPhoneField';
19
+ export * from './components/FvUanField';
20
+ export * from './components/FvNameCode';
21
+ export { FileInfo as FvFileInfo, FvFileSelector } from './components/FvFileSelector';
22
+ export type { FvFileSelectorProps } from './components/FvFileSelector';
23
+ export * from './components/FvImageSelector';
24
+ export { FvDocumentField } from './components/FvDocumentField';
25
+ export type { FvDocumentFieldProps } from './components/FvDocumentField';
26
+ export * from './components/FvRichTextEditor';
27
+ export * from './components/AddUpdateForm';
28
+ export * from './components/QueryForm';