@bytebrand/fe-ui-core 4.2.34 → 4.2.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.2.34",
3
+ "version": "4.2.35",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -5,6 +5,7 @@ import MaterialAutocomplete from '../../../_common/MaterialAutocomplete/Material
5
5
  import MaterialSelect from '../../../_common/MaterialSelect/MaterialSelect';
6
6
  import MaterialField from '../../../_common/MaterialField/MaterialField';
7
7
  import IconSVG from '../../../_common/IconSVG/IconSVG';
8
+ import _debounce from 'lodash/debounce';
8
9
 
9
10
  import styles from './MakeModel.styl';
10
11
 
@@ -17,6 +18,8 @@ export interface IMakeModelProps {
17
18
  t?: any;
18
19
  }
19
20
 
21
+ const DEBOUNCE_TIME: number = 700;
22
+
20
23
  class MakeModel extends React.Component<IMakeModelProps> {
21
24
  renderLabel = (option: any): React.ReactNode => {
22
25
  const { t } = this.props;
@@ -54,6 +57,13 @@ class MakeModel extends React.Component<IMakeModelProps> {
54
57
  return bodyType ? <MaterialSelect {...ddProps} /> : <MaterialAutocomplete {...ddProps} />;
55
58
  };
56
59
 
60
+ debaunceOnFilterChange = _debounce( // is used for the text field to add a delay and not make a search request for each key stroke
61
+ (name: string, value: string, index: number) => {
62
+ this.props.onChange(name, value, index)
63
+ },
64
+ DEBOUNCE_TIME
65
+ );
66
+
57
67
  renderTextField = (props: any) => {
58
68
  const { name, values, index, placeholder } = props;
59
69
 
@@ -62,7 +72,7 @@ class MakeModel extends React.Component<IMakeModelProps> {
62
72
  placeholder,
63
73
  size: 'custom',
64
74
  value: values,
65
- onChange: (value: string, name: string) => this.props.onChange(name, value, index)
75
+ onChange: (value: string, name: string) => this.debaunceOnFilterChange(name, value, index)
66
76
  };
67
77
 
68
78
  return (<MaterialField {...textFieldProps} />);
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { TextField, IconButton } from '@mui/material';
3
3
  import { ThemeProvider } from '@mui/material/styles';
4
4
  import { Theme } from './MaterialField.styled';
@@ -43,11 +43,13 @@ const MaterialField: React.FC<IVehicleModalProps> = ({
43
43
  placeholder
44
44
  }: IVehicleModalProps) => {
45
45
  const [showPassword, setShowPassword] = React.useState(false);
46
+ const [enteredValue, setEnteredValue] = useState(value);
46
47
 
47
48
  const onHandleChange = (event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
48
49
  const value = event.currentTarget.value;
49
50
  const name = event.currentTarget.name;
50
51
 
52
+ setEnteredValue(event.target.value);
51
53
  onChange(value, name, event);
52
54
  };
53
55
 
@@ -67,7 +69,7 @@ const MaterialField: React.FC<IVehicleModalProps> = ({
67
69
  fullWidth={true}
68
70
  autoComplete={autoComplete}
69
71
  label={label}
70
- value={value}
72
+ value={enteredValue}
71
73
  name={name}
72
74
  sx={sx}
73
75
  error={!!error}
@@ -60,8 +60,6 @@ interface IFiltersContainerProps extends IRouteComponentProps<PathParamsType> {
60
60
  Link?: any;
61
61
  }
62
62
 
63
- const DEBOUNCE_TIME: number = 500;
64
-
65
63
  @observer
66
64
  class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
67
65
  componentDidMount() {
@@ -103,13 +101,6 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
103
101
  resetFiltersToDefault();
104
102
  }
105
103
 
106
- debaunceOnFilterChange = _debounce( // is used for the text field to add a delay and not make a search request for each key stroke
107
- () => {
108
- this.props.onFilterChange();
109
- },
110
- DEBOUNCE_TIME
111
- );
112
-
113
104
  onFilterChange = (field: string, value: any, index?: number, isSeries?: boolean) => {
114
105
  const { addModelsToFilters, changeFilterValue, changeSeries, getModelsInfoByMaker } = this.props;
115
106
  let newValue = _get(value, 'value') || value;
@@ -147,12 +138,7 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
147
138
  }
148
139
 
149
140
  changeFilterValue(field, newValue, index);
150
-
151
- if (field === SUB_MODEL_KEY) {
152
- this.debaunceOnFilterChange();
153
- } else {
154
- this.props.onFilterChange();
155
- }
141
+ this.props.onFilterChange();
156
142
  };
157
143
 
158
144
  onChangeFilterControls = (field: string, value: any) => {