@irontec/ivoz-ui 1.3.10 → 1.3.11

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.
@@ -28,6 +28,39 @@ const FastSearchField = (props, ref) => {
28
28
  const foreignEntities = useStoreState((state) => state.list.fkChoices);
29
29
  const fkChoices = foreignEntities[firstColumnName] || [];
30
30
  const [value, setValue] = useState((firstColumnCriteria === null || firstColumnCriteria === void 0 ? void 0 : firstColumnCriteria.value) || '');
31
+ const isDatetime = !isFk && firstColumnSpec.format === 'date-time';
32
+ const triggerSearchIfChanged = () => {
33
+ if (!firstColumnCriteria) {
34
+ return;
35
+ }
36
+ if (firstColumnCriteria.value == value) {
37
+ return;
38
+ }
39
+ if (value !== '') {
40
+ firstColumnCriteria.value = encodeURIComponent(value);
41
+ }
42
+ let match = false;
43
+ let matchIdx;
44
+ for (const idx in queryStringCriteria) {
45
+ if (queryStringCriteria[idx].name !== firstColumnCriteria.name) {
46
+ continue;
47
+ }
48
+ if (queryStringCriteria[idx].type !== firstColumnCriteria.type) {
49
+ continue;
50
+ }
51
+ queryStringCriteria[idx] = firstColumnCriteria;
52
+ matchIdx = idx;
53
+ match = true;
54
+ break;
55
+ }
56
+ if (!match) {
57
+ queryStringCriteria.push(firstColumnCriteria);
58
+ }
59
+ else if (value === '' && matchIdx) {
60
+ queryStringCriteria.splice(parseInt(matchIdx, 10), 1);
61
+ }
62
+ setQueryStringCriteria(queryStringCriteria);
63
+ };
31
64
  const changeHandler = ({ target, }) => {
32
65
  const { value } = target;
33
66
  setValue(value);
@@ -37,38 +70,13 @@ const FastSearchField = (props, ref) => {
37
70
  setValue((firstColumnCriteria === null || firstColumnCriteria === void 0 ? void 0 : firstColumnCriteria.value) || '');
38
71
  }, [firstColumnCriteria]);
39
72
  useEffect(() => {
73
+ if (isDatetime) {
74
+ return;
75
+ }
40
76
  const timeOutId = setTimeout(() => {
41
- if (firstColumnCriteria) {
42
- if (firstColumnCriteria.value == value) {
43
- return;
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);
77
+ triggerSearchIfChanged();
78
+ return;
79
+ }, 2000);
72
80
  return () => clearTimeout(timeOutId);
73
81
  }, [value, firstColumnCriteria]);
74
82
  if (isFk) {
@@ -80,12 +88,22 @@ const FastSearchField = (props, ref) => {
80
88
  }
81
89
  let type = 'text';
82
90
  const inputProps = {};
83
- if (firstColumnSpec.format === 'date-time') {
91
+ if (isDatetime) {
84
92
  type = 'datetime-local';
85
93
  inputProps.step = 1;
86
94
  }
87
95
  return (_jsx(StyledSearchTextField, { name: 'fast_search', type: type, error: false, value: value, errorMsg: '', inputProps: inputProps, InputProps: {
88
96
  startAdornment: _jsx(SearchIcon, {}),
97
+ }, onBlur: () => {
98
+ if (!isDatetime) {
99
+ return;
100
+ }
101
+ triggerSearchIfChanged();
102
+ }, onKeyDown: (event) => {
103
+ if (event.code !== 'Enter') {
104
+ return;
105
+ }
106
+ triggerSearchIfChanged();
89
107
  }, placeholder: 'Search', hasChanged: false, onChange: changeHandler, ref: ref }));
90
108
  };
91
109
  export default forwardRef(FastSearchField);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irontec/ivoz-ui",
3
- "version": "1.3.10",
3
+ "version": "1.3.11",
4
4
  "description": "UI library used in ivozprovider",
5
5
  "license": "GPL-3.0",
6
6
  "main": "index.js",
@@ -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
- 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, { 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 })))] })));
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
  };