@irontec/ivoz-ui 1.3.10 → 1.3.12
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.
|
@@ -27,7 +27,42 @@ const FastSearchField = (props, ref) => {
|
|
|
27
27
|
const isFk = isPropertyFk(firstColumnSpec);
|
|
28
28
|
const foreignEntities = useStoreState((state) => state.list.fkChoices);
|
|
29
29
|
const fkChoices = foreignEntities[firstColumnName] || [];
|
|
30
|
-
const
|
|
30
|
+
const isDatetime = !isFk && firstColumnSpec.format === 'date-time';
|
|
31
|
+
const initialValue = (firstColumnCriteria === null || firstColumnCriteria === void 0 ? void 0 : firstColumnCriteria.value) || '';
|
|
32
|
+
const [value, setValue] = useState(isDatetime ? initialValue.replace(' ', 'T') : initialValue);
|
|
33
|
+
const triggerSearchIfChanged = () => {
|
|
34
|
+
if (!firstColumnCriteria) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (firstColumnCriteria.value == value) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (value !== '') {
|
|
41
|
+
const val = isDatetime ? value.replace('T', ' ') : value;
|
|
42
|
+
firstColumnCriteria.value = encodeURIComponent(val);
|
|
43
|
+
}
|
|
44
|
+
let match = false;
|
|
45
|
+
let matchIdx;
|
|
46
|
+
for (const idx in queryStringCriteria) {
|
|
47
|
+
if (queryStringCriteria[idx].name !== firstColumnCriteria.name) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (queryStringCriteria[idx].type !== firstColumnCriteria.type) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
queryStringCriteria[idx] = firstColumnCriteria;
|
|
54
|
+
matchIdx = idx;
|
|
55
|
+
match = true;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
if (!match) {
|
|
59
|
+
queryStringCriteria.push(firstColumnCriteria);
|
|
60
|
+
}
|
|
61
|
+
else if (value === '' && matchIdx) {
|
|
62
|
+
queryStringCriteria.splice(parseInt(matchIdx, 10), 1);
|
|
63
|
+
}
|
|
64
|
+
setQueryStringCriteria(queryStringCriteria);
|
|
65
|
+
};
|
|
31
66
|
const changeHandler = ({ target, }) => {
|
|
32
67
|
const { value } = target;
|
|
33
68
|
setValue(value);
|
|
@@ -37,38 +72,13 @@ const FastSearchField = (props, ref) => {
|
|
|
37
72
|
setValue((firstColumnCriteria === null || firstColumnCriteria === void 0 ? void 0 : firstColumnCriteria.value) || '');
|
|
38
73
|
}, [firstColumnCriteria]);
|
|
39
74
|
useEffect(() => {
|
|
75
|
+
if (isDatetime) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
40
78
|
const timeOutId = setTimeout(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
if (value !== '') {
|
|
46
|
-
firstColumnCriteria.value = encodeURIComponent(value);
|
|
47
|
-
}
|
|
48
|
-
let match = false;
|
|
49
|
-
let matchIdx;
|
|
50
|
-
for (const idx in queryStringCriteria) {
|
|
51
|
-
if (queryStringCriteria[idx].name !== firstColumnCriteria.name) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (queryStringCriteria[idx].type !== firstColumnCriteria.type) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
queryStringCriteria[idx] = firstColumnCriteria;
|
|
58
|
-
matchIdx = idx;
|
|
59
|
-
match = true;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
if (!match) {
|
|
63
|
-
queryStringCriteria.push(firstColumnCriteria);
|
|
64
|
-
}
|
|
65
|
-
else if (value === '' && matchIdx) {
|
|
66
|
-
queryStringCriteria.splice(parseInt(matchIdx, 10), 1);
|
|
67
|
-
}
|
|
68
|
-
setQueryStringCriteria(queryStringCriteria);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}, 1000);
|
|
79
|
+
triggerSearchIfChanged();
|
|
80
|
+
return;
|
|
81
|
+
}, 2000);
|
|
72
82
|
return () => clearTimeout(timeOutId);
|
|
73
83
|
}, [value, firstColumnCriteria]);
|
|
74
84
|
if (isFk) {
|
|
@@ -80,12 +90,22 @@ const FastSearchField = (props, ref) => {
|
|
|
80
90
|
}
|
|
81
91
|
let type = 'text';
|
|
82
92
|
const inputProps = {};
|
|
83
|
-
if (
|
|
93
|
+
if (isDatetime) {
|
|
84
94
|
type = 'datetime-local';
|
|
85
95
|
inputProps.step = 1;
|
|
86
96
|
}
|
|
87
97
|
return (_jsx(StyledSearchTextField, { name: 'fast_search', type: type, error: false, value: value, errorMsg: '', inputProps: inputProps, InputProps: {
|
|
88
98
|
startAdornment: _jsx(SearchIcon, {}),
|
|
99
|
+
}, onBlur: () => {
|
|
100
|
+
if (!isDatetime) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
triggerSearchIfChanged();
|
|
104
|
+
}, onKeyDown: (event) => {
|
|
105
|
+
if (event.code !== 'Enter') {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
triggerSearchIfChanged();
|
|
89
109
|
}, placeholder: 'Search', hasChanged: false, onChange: changeHandler, ref: ref }));
|
|
90
110
|
};
|
|
91
111
|
export default forwardRef(FastSearchField);
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { FormControl, FormHelperText, OutlinedInput, } from '@mui/material';
|
|
|
4
4
|
import { StyledHelpTextTooltip } from '../Shared/HelpText.styles';
|
|
5
5
|
export const TextField = (props) => {
|
|
6
6
|
var _a;
|
|
7
|
-
const { name, size, type, defaultValue, value, disabled, label, placeholder, multiline, required, onChange, onBlur, error, errorMsg, helperText, inputProps, InputProps, hasChanged, inputRef, } = props;
|
|
7
|
+
const { name, size, type, defaultValue, value, disabled, label, placeholder, multiline, required, onChange, onBlur, onKeyDown, onClick, error, errorMsg, helperText, inputProps, InputProps, hasChanged, inputRef, } = props;
|
|
8
8
|
const margin = (_a = props.margin) !== null && _a !== void 0 ? _a : undefined;
|
|
9
9
|
let className = props.className;
|
|
10
10
|
if (hasChanged) {
|
|
@@ -12,5 +12,12 @@ export const TextField = (props) => {
|
|
|
12
12
|
}
|
|
13
13
|
const labelId = `${name}-label`;
|
|
14
14
|
const maxRows = multiline ? 6 : undefined;
|
|
15
|
-
|
|
15
|
+
const passThroughProps = {};
|
|
16
|
+
if (onKeyDown) {
|
|
17
|
+
passThroughProps.onKeyDown = onKeyDown;
|
|
18
|
+
}
|
|
19
|
+
if (onClick) {
|
|
20
|
+
passThroughProps.onClick = onClick;
|
|
21
|
+
}
|
|
22
|
+
return (_jsxs(FormControl, Object.assign({ variant: 'standard', fullWidth: true, error: error, className: className }, { children: [label && (_jsxs("label", Object.assign({ htmlFor: name, id: labelId }, { children: [label, required && '*', helperText && (_jsx(StyledHelpTextTooltip, Object.assign({ title: helperText, placement: 'top', arrow: true, className: 'help-tooltip' }, { children: _jsx(HelpOutlineIcon, {}) })))] }))), _jsx(OutlinedInput, Object.assign({}, passThroughProps, { ref: InputProps === null || InputProps === void 0 ? void 0 : InputProps.ref, name: name, type: type, size: size, multiline: multiline, maxRows: maxRows, placeholder: placeholder, defaultValue: defaultValue, value: value, disabled: disabled, onChange: onChange, onBlur: onBlur, error: error, className: 'input-field', margin: margin, inputProps: inputProps, startAdornment: InputProps === null || InputProps === void 0 ? void 0 : InputProps.startAdornment, endAdornment: InputProps === null || InputProps === void 0 ? void 0 : InputProps.endAdornment, inputRef: inputRef })), error && errorMsg && (_jsx(FormHelperText, Object.assign({ className: 'helper-error' }, { children: errorMsg })))] })));
|
|
16
23
|
};
|