@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,139 @@
|
|
|
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.FvMonthYearField = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const validation_engine_1 = require("@fovestta2/validation-engine");
|
|
29
|
+
const FvMonthYearField = ({ label = '', value, schema, disabled = false, readonly = false, min, max, className = '', inputClassName = '', labelClassName = '', errorClassName = '', onChange, onBlur, onFocus, }) => {
|
|
30
|
+
const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
|
|
31
|
+
const [derivedMin, setDerivedMin] = (0, react_1.useState)(min);
|
|
32
|
+
const [derivedMax, setDerivedMax] = (0, react_1.useState)(max);
|
|
33
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
extractConstraintsFromSchema();
|
|
36
|
+
}, [schema, min, max]);
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
validateValue(value);
|
|
39
|
+
}, [value, schema]);
|
|
40
|
+
const formatMonth = (date) => {
|
|
41
|
+
if (!date)
|
|
42
|
+
return undefined;
|
|
43
|
+
const d = new Date(date);
|
|
44
|
+
if (isNaN(d.getTime()))
|
|
45
|
+
return undefined;
|
|
46
|
+
return d.toISOString().slice(0, 7);
|
|
47
|
+
};
|
|
48
|
+
const extractConstraintsFromSchema = () => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
let newMin = min;
|
|
51
|
+
let newMax = max;
|
|
52
|
+
if (schema === null || schema === void 0 ? void 0 : schema.rules) {
|
|
53
|
+
for (const rule of schema.rules) {
|
|
54
|
+
if (rule.name === 'minDate' && !newMin) {
|
|
55
|
+
newMin = formatMonth((_a = rule.params) === null || _a === void 0 ? void 0 : _a['value']);
|
|
56
|
+
}
|
|
57
|
+
if (rule.name === 'maxDate' && !newMax) {
|
|
58
|
+
newMax = formatMonth((_b = rule.params) === null || _b === void 0 ? void 0 : _b['value']);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
setDerivedMin(newMin);
|
|
63
|
+
setDerivedMax(newMax);
|
|
64
|
+
};
|
|
65
|
+
const validateValue = (val) => {
|
|
66
|
+
if (!schema)
|
|
67
|
+
return;
|
|
68
|
+
const result = validation_engine_1.Validator.validate(val, schema);
|
|
69
|
+
if (!result.isValid && result.errorKey) {
|
|
70
|
+
setErrorMessage(result.errorKey);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
setErrorMessage(null);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const handleInput = (e) => {
|
|
77
|
+
onChange(e.target.value);
|
|
78
|
+
};
|
|
79
|
+
const handleBlur = (e) => {
|
|
80
|
+
validateValue(value);
|
|
81
|
+
if (onBlur)
|
|
82
|
+
onBlur();
|
|
83
|
+
};
|
|
84
|
+
const handleFocus = (e) => {
|
|
85
|
+
if (onFocus)
|
|
86
|
+
onFocus();
|
|
87
|
+
};
|
|
88
|
+
const openPicker = () => {
|
|
89
|
+
if (disabled || readonly)
|
|
90
|
+
return;
|
|
91
|
+
if (inputRef.current) {
|
|
92
|
+
if ('showPicker' in HTMLInputElement.prototype) {
|
|
93
|
+
try {
|
|
94
|
+
inputRef.current.showPicker();
|
|
95
|
+
}
|
|
96
|
+
catch (_a) {
|
|
97
|
+
inputRef.current.click();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
inputRef.current.click();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const isRequired = () => {
|
|
106
|
+
var _a;
|
|
107
|
+
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;
|
|
108
|
+
};
|
|
109
|
+
const getErrorMessage = () => {
|
|
110
|
+
if (!errorMessage)
|
|
111
|
+
return '';
|
|
112
|
+
const errorMessages = {
|
|
113
|
+
ERR_REQUIRED: 'This field is required',
|
|
114
|
+
ERR_MIN_DATE: `Date must be after ${derivedMin}`,
|
|
115
|
+
ERR_MAX_DATE: `Date must be before ${derivedMax}`,
|
|
116
|
+
};
|
|
117
|
+
return errorMessages[errorMessage] || errorMessage;
|
|
118
|
+
};
|
|
119
|
+
return (react_1.default.createElement("div", { className: `fv-field-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column' } },
|
|
120
|
+
label && (react_1.default.createElement("label", { className: `fv-label ${labelClassName}`, style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
|
|
121
|
+
label,
|
|
122
|
+
isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
|
|
123
|
+
react_1.default.createElement("input", { ref: inputRef, type: "month", onClick: openPicker, value: value, onChange: handleInput, onBlur: handleBlur, onFocus: handleFocus, disabled: disabled, readOnly: readonly, min: derivedMin, max: derivedMax, className: `fv-input ${errorMessage ? 'fv-input-error' : ''} ${inputClassName}`, style: {
|
|
124
|
+
padding: '10px',
|
|
125
|
+
border: errorMessage ? '1px solid #dc3545' : '1px solid #ccc',
|
|
126
|
+
borderRadius: '4px',
|
|
127
|
+
fontSize: '14px',
|
|
128
|
+
backgroundColor: disabled ? '#f5f5f5' : '#fff',
|
|
129
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
130
|
+
outline: 'none',
|
|
131
|
+
boxSizing: 'border-box',
|
|
132
|
+
width: '100%',
|
|
133
|
+
...((disabled || readonly) ? { opacity: 0.6 } : {})
|
|
134
|
+
} }),
|
|
135
|
+
errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
|
|
136
|
+
"\u26A0 ",
|
|
137
|
+
getErrorMessage()))));
|
|
138
|
+
};
|
|
139
|
+
exports.FvMonthYearField = FvMonthYearField;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ValidationSchema } from '@fovestta2/validation-engine';
|
|
3
|
+
export interface SearchSelectOption {
|
|
4
|
+
code: string;
|
|
5
|
+
name: string;
|
|
6
|
+
value: any;
|
|
7
|
+
}
|
|
8
|
+
export interface FvNameCodeProps {
|
|
9
|
+
label?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
options: SearchSelectOption[];
|
|
12
|
+
value: any;
|
|
13
|
+
schema?: ValidationSchema;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
inputClassName?: string;
|
|
17
|
+
labelClassName?: string;
|
|
18
|
+
errorClassName?: string;
|
|
19
|
+
onChange: (value: any) => void;
|
|
20
|
+
onBlur?: () => void;
|
|
21
|
+
onFocus?: () => void;
|
|
22
|
+
}
|
|
23
|
+
export declare const FvNameCode: React.FC<FvNameCodeProps>;
|
|
@@ -0,0 +1,239 @@
|
|
|
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.FvNameCode = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const validation_engine_1 = require("@fovestta2/validation-engine");
|
|
29
|
+
const FvNameCode = ({ label = '', placeholder = 'Search by Code or Name', options = [], value, schema, disabled = false, className = '', inputClassName = '', labelClassName = '', errorClassName = '', onChange, onBlur, onFocus, }) => {
|
|
30
|
+
const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
|
|
31
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
32
|
+
const [searchText, setSearchText] = (0, react_1.useState)('');
|
|
33
|
+
const [filteredOptions, setFilteredOptions] = (0, react_1.useState)(options);
|
|
34
|
+
const [highlightedIndex, setHighlightedIndex] = (0, react_1.useState)(-1);
|
|
35
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
36
|
+
const listRef = (0, react_1.useRef)(null);
|
|
37
|
+
// Sync initial and prop changes
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
validateValue(value);
|
|
40
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
41
|
+
if (selectedOption) {
|
|
42
|
+
setSearchText(`${selectedOption.code} - ${selectedOption.name}`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
if (value === null || value === undefined) {
|
|
46
|
+
setSearchText('');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
setFilteredOptions(options);
|
|
50
|
+
}, [value, options, schema]);
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
const handleClickOutside = (event) => {
|
|
53
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
54
|
+
if (isOpen) {
|
|
55
|
+
closeDropdown();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
60
|
+
return () => {
|
|
61
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
62
|
+
};
|
|
63
|
+
}, [isOpen, value, options]);
|
|
64
|
+
const validateValue = (val) => {
|
|
65
|
+
if (!schema)
|
|
66
|
+
return;
|
|
67
|
+
const result = validation_engine_1.Validator.validate(val, schema);
|
|
68
|
+
if (!result.isValid && result.errorKey) {
|
|
69
|
+
setErrorMessage(result.errorKey);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
setErrorMessage(null);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const filterOptions = (term) => {
|
|
76
|
+
if (!term) {
|
|
77
|
+
setFilteredOptions(options);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const lowerTerm = term.toLowerCase();
|
|
81
|
+
const filtered = options.filter((opt) => opt.code.toLowerCase().includes(lowerTerm) || opt.name.toLowerCase().includes(lowerTerm));
|
|
82
|
+
setFilteredOptions(filtered);
|
|
83
|
+
};
|
|
84
|
+
const handleSearchChange = (e) => {
|
|
85
|
+
const term = e.target.value;
|
|
86
|
+
setSearchText(term);
|
|
87
|
+
filterOptions(term);
|
|
88
|
+
if (!isOpen)
|
|
89
|
+
setIsOpen(true);
|
|
90
|
+
};
|
|
91
|
+
const openDropdown = () => {
|
|
92
|
+
if (disabled)
|
|
93
|
+
return;
|
|
94
|
+
setIsOpen(true);
|
|
95
|
+
filterOptions(searchText);
|
|
96
|
+
setHighlightedIndex(filteredOptions.length === 1 ? 0 : -1);
|
|
97
|
+
if (onFocus)
|
|
98
|
+
onFocus();
|
|
99
|
+
};
|
|
100
|
+
const closeDropdown = () => {
|
|
101
|
+
setIsOpen(false);
|
|
102
|
+
setHighlightedIndex(-1);
|
|
103
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
104
|
+
if (selectedOption) {
|
|
105
|
+
setSearchText(`${selectedOption.code} - ${selectedOption.name}`);
|
|
106
|
+
}
|
|
107
|
+
else if (!value) {
|
|
108
|
+
setSearchText('');
|
|
109
|
+
}
|
|
110
|
+
validateValue(value);
|
|
111
|
+
if (onBlur)
|
|
112
|
+
onBlur();
|
|
113
|
+
};
|
|
114
|
+
const selectOption = (option) => {
|
|
115
|
+
onChange(option.value);
|
|
116
|
+
setSearchText(`${option.code} - ${option.name}`);
|
|
117
|
+
setIsOpen(false);
|
|
118
|
+
setHighlightedIndex(-1);
|
|
119
|
+
validateValue(option.value);
|
|
120
|
+
};
|
|
121
|
+
const scrollToHighlighted = (index) => {
|
|
122
|
+
const list = listRef.current;
|
|
123
|
+
if (!list)
|
|
124
|
+
return;
|
|
125
|
+
const items = list.querySelectorAll('.fv-name-code-dropdown-item');
|
|
126
|
+
const item = items[index];
|
|
127
|
+
if (item) {
|
|
128
|
+
const listRect = list.getBoundingClientRect();
|
|
129
|
+
const itemRect = item.getBoundingClientRect();
|
|
130
|
+
if (itemRect.bottom > listRect.bottom) {
|
|
131
|
+
list.scrollTop += itemRect.bottom - listRect.bottom;
|
|
132
|
+
}
|
|
133
|
+
else if (itemRect.top < listRect.top) {
|
|
134
|
+
list.scrollTop -= listRect.top - itemRect.top;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const handleKeyDown = (e) => {
|
|
139
|
+
if (!isOpen && (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Enter')) {
|
|
140
|
+
openDropdown();
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (!isOpen)
|
|
145
|
+
return;
|
|
146
|
+
switch (e.key) {
|
|
147
|
+
case 'ArrowDown':
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
setHighlightedIndex((prev) => {
|
|
150
|
+
const next = (prev + 1) % filteredOptions.length;
|
|
151
|
+
scrollToHighlighted(next);
|
|
152
|
+
return next;
|
|
153
|
+
});
|
|
154
|
+
break;
|
|
155
|
+
case 'ArrowUp':
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
setHighlightedIndex((prev) => {
|
|
158
|
+
const next = (prev - 1 + filteredOptions.length) % filteredOptions.length;
|
|
159
|
+
scrollToHighlighted(next);
|
|
160
|
+
return next;
|
|
161
|
+
});
|
|
162
|
+
break;
|
|
163
|
+
case 'Enter':
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
if (filteredOptions.length === 1) {
|
|
166
|
+
selectOption(filteredOptions[0]);
|
|
167
|
+
}
|
|
168
|
+
else if (highlightedIndex >= 0 && highlightedIndex < filteredOptions.length) {
|
|
169
|
+
selectOption(filteredOptions[highlightedIndex]);
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
case 'Escape':
|
|
173
|
+
case 'Tab':
|
|
174
|
+
closeDropdown();
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const isRequired = () => {
|
|
179
|
+
var _a;
|
|
180
|
+
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;
|
|
181
|
+
};
|
|
182
|
+
const getErrorMessage = () => {
|
|
183
|
+
if (!errorMessage)
|
|
184
|
+
return '';
|
|
185
|
+
const errorMessages = {
|
|
186
|
+
ERR_REQUIRED: 'This field is required',
|
|
187
|
+
ERR_MIN_LENGTH: 'Value is too short',
|
|
188
|
+
ERR_DUPLICATE: 'This value already exists',
|
|
189
|
+
};
|
|
190
|
+
return errorMessages[errorMessage] || errorMessage;
|
|
191
|
+
};
|
|
192
|
+
return (react_1.default.createElement("div", { ref: containerRef, className: `fv-name-code-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column', position: 'relative' }, onKeyDown: handleKeyDown },
|
|
193
|
+
label && (react_1.default.createElement("label", { className: `fv-label ${labelClassName}`, style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
|
|
194
|
+
label,
|
|
195
|
+
isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
|
|
196
|
+
react_1.default.createElement("input", { type: "text", value: searchText, onChange: handleSearchChange, onFocus: openDropdown, disabled: disabled, placeholder: (searchText || isOpen) ? '' : placeholder, className: `fv-input ${errorMessage ? 'fv-input-error' : ''} ${inputClassName}`, style: {
|
|
197
|
+
padding: '10px',
|
|
198
|
+
border: errorMessage ? '1px solid #dc3545' : '1px solid #ccc',
|
|
199
|
+
borderRadius: '4px',
|
|
200
|
+
fontSize: '14px',
|
|
201
|
+
backgroundColor: disabled ? '#f5f5f5' : '#fff',
|
|
202
|
+
cursor: disabled ? 'not-allowed' : 'text',
|
|
203
|
+
outline: 'none',
|
|
204
|
+
boxSizing: 'border-box',
|
|
205
|
+
width: '100%',
|
|
206
|
+
...(disabled ? { opacity: 0.6 } : {})
|
|
207
|
+
} }),
|
|
208
|
+
isOpen && !disabled && (react_1.default.createElement("div", { ref: listRef, className: "fv-name-code-dropdown-list", style: {
|
|
209
|
+
position: 'absolute',
|
|
210
|
+
top: '100%',
|
|
211
|
+
left: 0,
|
|
212
|
+
right: 0,
|
|
213
|
+
marginTop: '4px',
|
|
214
|
+
backgroundColor: '#fff',
|
|
215
|
+
border: '1px solid #ccc',
|
|
216
|
+
borderRadius: '4px',
|
|
217
|
+
boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
|
|
218
|
+
maxHeight: '200px',
|
|
219
|
+
overflowY: 'auto',
|
|
220
|
+
zIndex: 1000
|
|
221
|
+
} }, filteredOptions.length === 0 ? (react_1.default.createElement("div", { style: { padding: '10px', textAlign: 'center', color: '#999', fontSize: '13px' } }, "No results found")) : (filteredOptions.map((option, index) => {
|
|
222
|
+
const isHighlighted = index === highlightedIndex;
|
|
223
|
+
return (react_1.default.createElement("div", { key: index, className: "fv-name-code-dropdown-item", onClick: () => selectOption(option), onMouseEnter: () => setHighlightedIndex(index), style: {
|
|
224
|
+
padding: '10px 12px',
|
|
225
|
+
display: 'flex',
|
|
226
|
+
justifyContent: 'space-between',
|
|
227
|
+
alignItems: 'center',
|
|
228
|
+
cursor: 'pointer',
|
|
229
|
+
borderBottom: '1px solid #f0f0f0',
|
|
230
|
+
backgroundColor: isHighlighted ? '#f0f7ff' : '#fff'
|
|
231
|
+
} },
|
|
232
|
+
react_1.default.createElement("span", { style: { color: '#0056b3', fontWeight: 600, fontSize: '14px', whiteSpace: 'nowrap' } }, option.code),
|
|
233
|
+
react_1.default.createElement("span", { style: { color: '#333', fontSize: '14px', overflow: 'hidden', textOverflow: 'ellipsis', textAlign: 'right' } }, option.name)));
|
|
234
|
+
})))),
|
|
235
|
+
errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
|
|
236
|
+
"\u26A0 ",
|
|
237
|
+
getErrorMessage()))));
|
|
238
|
+
};
|
|
239
|
+
exports.FvNameCode = FvNameCode;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ValidationSchema } from '@fovestta2/validation-engine';
|
|
3
|
+
export interface FvNumberFieldProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
value: number | '';
|
|
7
|
+
schema?: ValidationSchema;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
min?: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
step?: number;
|
|
13
|
+
className?: string;
|
|
14
|
+
inputClassName?: string;
|
|
15
|
+
labelClassName?: string;
|
|
16
|
+
errorClassName?: string;
|
|
17
|
+
onChange: (value: number | '') => void;
|
|
18
|
+
onBlur?: () => void;
|
|
19
|
+
onFocus?: () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const FvNumberField: React.FC<FvNumberFieldProps>;
|
|
@@ -0,0 +1,98 @@
|
|
|
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.FvNumberField = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const validation_engine_1 = require("@fovestta2/validation-engine");
|
|
29
|
+
const FvNumberField = ({ label = '', placeholder = '', value, schema, disabled = false, readonly = false, min, max, step = 1, 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
|
+
const val = e.target.value;
|
|
47
|
+
onChange(val === '' ? '' : Number(val));
|
|
48
|
+
};
|
|
49
|
+
const handleBlur = (e) => {
|
|
50
|
+
validateValue(value);
|
|
51
|
+
if (onBlur)
|
|
52
|
+
onBlur();
|
|
53
|
+
};
|
|
54
|
+
const handleFocus = (e) => {
|
|
55
|
+
if (onFocus)
|
|
56
|
+
onFocus();
|
|
57
|
+
};
|
|
58
|
+
const handleKeyDown = (e) => {
|
|
59
|
+
if (e.key === '-') {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const isRequired = () => {
|
|
64
|
+
var _a;
|
|
65
|
+
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;
|
|
66
|
+
};
|
|
67
|
+
const getErrorMessage = () => {
|
|
68
|
+
if (!errorMessage)
|
|
69
|
+
return '';
|
|
70
|
+
const errorMessages = {
|
|
71
|
+
ERR_REQUIRED: 'This field is required',
|
|
72
|
+
ERR_NUMERIC_INVALID: 'Please enter a valid number',
|
|
73
|
+
ERR_RANGE_INVALID: 'Number is out of range',
|
|
74
|
+
ERR_DUPLICATE: 'This value already exists',
|
|
75
|
+
};
|
|
76
|
+
return errorMessages[errorMessage] || errorMessage;
|
|
77
|
+
};
|
|
78
|
+
return (react_1.default.createElement("div", { className: `fv-field-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column' } },
|
|
79
|
+
label && (react_1.default.createElement("label", { className: `fv-label ${labelClassName}`, style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
|
|
80
|
+
label,
|
|
81
|
+
isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
|
|
82
|
+
react_1.default.createElement("input", { type: "number", value: value, onChange: handleInput, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, disabled: disabled, readOnly: readonly, placeholder: placeholder, min: min, max: max, step: step, className: `fv-input ${errorMessage ? 'fv-input-error' : ''} ${inputClassName}`, style: {
|
|
83
|
+
padding: '10px',
|
|
84
|
+
border: errorMessage ? '1px solid #dc3545' : '1px solid #ccc',
|
|
85
|
+
borderRadius: '4px',
|
|
86
|
+
fontSize: '14px',
|
|
87
|
+
backgroundColor: disabled ? '#f5f5f5' : '#fff',
|
|
88
|
+
cursor: disabled ? 'not-allowed' : 'text',
|
|
89
|
+
outline: 'none',
|
|
90
|
+
boxSizing: 'border-box',
|
|
91
|
+
width: '100%',
|
|
92
|
+
...((disabled || readonly) ? { opacity: 0.6 } : {})
|
|
93
|
+
} }),
|
|
94
|
+
errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
|
|
95
|
+
"\u26A0 ",
|
|
96
|
+
getErrorMessage()))));
|
|
97
|
+
};
|
|
98
|
+
exports.FvNumberField = FvNumberField;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ValidationSchema } from '@fovestta2/validation-engine';
|
|
3
|
+
export interface FvPasswordFieldProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
value: string;
|
|
7
|
+
schema?: ValidationSchema;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
inputClassName?: string;
|
|
12
|
+
labelClassName?: string;
|
|
13
|
+
errorClassName?: string;
|
|
14
|
+
onChange: (value: string) => void;
|
|
15
|
+
onBlur?: () => void;
|
|
16
|
+
onFocus?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const FvPasswordField: React.FC<FvPasswordFieldProps>;
|
|
@@ -0,0 +1,114 @@
|
|
|
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.FvPasswordField = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const validation_engine_1 = require("@fovestta2/validation-engine");
|
|
29
|
+
const FvPasswordField = ({ label = 'Password', placeholder = '••••••••', value, schema, disabled = false, readonly = false, className = '', inputClassName = '', labelClassName = '', errorClassName = '', onChange, onBlur, onFocus, }) => {
|
|
30
|
+
const [errorMessage, setErrorMessage] = (0, react_1.useState)(null);
|
|
31
|
+
const [showPassword, setShowPassword] = (0, react_1.useState)(false);
|
|
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 handleInput = (e) => {
|
|
47
|
+
onChange(e.target.value);
|
|
48
|
+
};
|
|
49
|
+
const handleBlur = (e) => {
|
|
50
|
+
validateValue(value);
|
|
51
|
+
if (onBlur)
|
|
52
|
+
onBlur();
|
|
53
|
+
};
|
|
54
|
+
const handleFocus = (e) => {
|
|
55
|
+
if (onFocus)
|
|
56
|
+
onFocus();
|
|
57
|
+
};
|
|
58
|
+
const toggleVisibility = () => {
|
|
59
|
+
if (disabled)
|
|
60
|
+
return;
|
|
61
|
+
setShowPassword(!showPassword);
|
|
62
|
+
};
|
|
63
|
+
const isRequired = () => {
|
|
64
|
+
var _a;
|
|
65
|
+
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;
|
|
66
|
+
};
|
|
67
|
+
const getErrorMessage = () => {
|
|
68
|
+
if (!errorMessage)
|
|
69
|
+
return '';
|
|
70
|
+
const errorMessages = {
|
|
71
|
+
ERR_REQUIRED: 'Password is required',
|
|
72
|
+
ERR_MIN_LENGTH: 'Password is too short',
|
|
73
|
+
ERR_REGEX_MISMATCH: 'Invalid password format',
|
|
74
|
+
ERR_PASSWORD_TOO_SHORT: 'Password must be at least 8 characters',
|
|
75
|
+
ERR_PASSWORD_MISSING_UPPERCASE: 'Uppercase letter missing',
|
|
76
|
+
ERR_PASSWORD_MISSING_LOWERCASE: 'Lowercase letter missing',
|
|
77
|
+
ERR_PASSWORD_MISSING_NUMBER: 'At least one number missing',
|
|
78
|
+
ERR_PASSWORD_MISSING_SPECIAL_CHAR: 'Special character missing',
|
|
79
|
+
};
|
|
80
|
+
return errorMessages[errorMessage] || errorMessage;
|
|
81
|
+
};
|
|
82
|
+
return (react_1.default.createElement("div", { className: `fv-field-container ${className}`, style: { marginBottom: '16px', display: 'flex', flexDirection: 'column' } },
|
|
83
|
+
label && (react_1.default.createElement("label", { className: `fv-label ${labelClassName}`, style: { marginBottom: '6px', fontSize: '14px', fontWeight: 500, color: disabled ? '#999' : '#333' } },
|
|
84
|
+
label,
|
|
85
|
+
isRequired() && react_1.default.createElement("span", { className: "fv-required", style: { color: '#dc3545', fontWeight: 'bold' } }, " *"))),
|
|
86
|
+
react_1.default.createElement("div", { style: { position: 'relative', display: 'flex', alignItems: 'center', width: '100%' } },
|
|
87
|
+
react_1.default.createElement("input", { type: showPassword ? 'text' : 'password', 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
|
+
paddingRight: '40px',
|
|
90
|
+
border: errorMessage ? '1px solid #dc3545' : '1px solid #ccc',
|
|
91
|
+
borderRadius: '4px',
|
|
92
|
+
fontSize: '14px',
|
|
93
|
+
backgroundColor: disabled ? '#f5f5f5' : '#fff',
|
|
94
|
+
cursor: disabled ? 'not-allowed' : 'text',
|
|
95
|
+
outline: 'none',
|
|
96
|
+
boxSizing: 'border-box',
|
|
97
|
+
width: '100%',
|
|
98
|
+
...((disabled || readonly) ? { opacity: 0.6 } : {})
|
|
99
|
+
} }),
|
|
100
|
+
react_1.default.createElement("button", { type: "button", onClick: toggleVisibility, disabled: disabled, style: {
|
|
101
|
+
position: 'absolute',
|
|
102
|
+
right: '10px',
|
|
103
|
+
background: 'none',
|
|
104
|
+
border: 'none',
|
|
105
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
106
|
+
padding: '0',
|
|
107
|
+
fontSize: '14px',
|
|
108
|
+
color: '#666'
|
|
109
|
+
} }, showPassword ? 'Hide' : 'Show')),
|
|
110
|
+
errorMessage && (react_1.default.createElement("span", { className: `fv-error-text ${errorClassName}`, style: { marginTop: '4px', fontSize: '12px', color: '#dc3545' } },
|
|
111
|
+
"\u26A0 ",
|
|
112
|
+
getErrorMessage()))));
|
|
113
|
+
};
|
|
114
|
+
exports.FvPasswordField = FvPasswordField;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ValidationSchema } from '@fovestta2/validation-engine';
|
|
3
|
+
export interface FvPfFieldProps {
|
|
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 FvPfField: React.FC<FvPfFieldProps>;
|