@bytebrand/fe-ui-core 4.2.70 → 4.2.72

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/common.ts CHANGED
@@ -3,7 +3,6 @@ export { default as Accordion } from './source/components/_common/Accordion/Acco
3
3
  export { default as Button } from './source/components/_common/Button/Button';
4
4
  export { default as ButtonOld } from './source/components/_common/ButtonOld/Button';
5
5
  export { default as PSGroup } from './source/components/_common/PropertySelector/PSGroup';
6
- export { default as FormPSGroup } from './source/components/_common/PropertySelector/FormPSGroup';
7
6
  export { default as PropertySelector } from './source/components/_common/PropertySelector/PropertySelector';
8
7
 
9
8
  export { default as FormRadioGroup } from './source/components/_common/Radio/FormRadioGroup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.2.70",
3
+ "version": "4.2.72",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -1,7 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import classnames from 'classnames';
3
- import { observer } from 'mobx-react';
4
-
5
3
  import Checkbox from './Checkbox';
6
4
  import styles from './FormCheckbox.styl';
7
5
 
@@ -9,8 +7,6 @@ interface IFormCheckboxProps {
9
7
  className?: string;
10
8
  errorClassName?: string;
11
9
  label?: JSX.Element | string | null;
12
-
13
- // mobx form field instance
14
10
  field: any;
15
11
  checkboxClassName?: string;
16
12
  labelClassName?: string;
@@ -18,34 +14,70 @@ interface IFormCheckboxProps {
18
14
  helperText?: string;
19
15
  }
20
16
 
21
- @observer
22
- class FormCheckbox extends React.Component<IFormCheckboxProps> {
17
+ interface IFormCheckboxState {
18
+ field: {
19
+ name?: string;
20
+ value?: boolean;
21
+ checked?: boolean;
22
+ error?: boolean;
23
+ disabled?: boolean
24
+ }
25
+ }
26
+
27
+ class FormCheckbox extends React.Component<IFormCheckboxProps, IFormCheckboxState> {
28
+ constructor(props: IFormCheckboxProps) {
29
+ super(props);
30
+
31
+ this.state = {
32
+ field: {
33
+ value: this.props.field.value,
34
+ error: this.props.field.error,
35
+ checked: this.props.field.checked,
36
+ disabled: this.props.field.disabled,
37
+ name: this.props.field.name
38
+ }
39
+ };
40
+ }
23
41
  static defaultProps = {
24
42
  className: '',
25
43
  label: false
26
44
  };
27
45
 
28
- render() {
29
- const { field, label, className, checkboxClassName, labelClassName, customError } = this.props;
46
+ handleChange = (event: React.ChangeEvent<HTMLInputElement>, checked?: boolean, value?: any) => {
47
+ const { name, disabled, onChange, rules } = this.props.field;
48
+ const customError = (rules.includes('accepted') && !checked);
49
+ this.setState(() => ({
50
+ field: {
51
+ value,
52
+ name,
53
+ disabled,
54
+ checked,
55
+ error: customError
56
+ }
57
+ }));
58
+ onChange(event, checked, value);
59
+ }
30
60
 
31
- // const customHasError = customError;
32
- // const hasError = field.hasError;
33
- const error = customError ? customError : field.error;
61
+ render() {
62
+ const { label, className, checkboxClassName, labelClassName } = this.props;
63
+ const { name, value, checked, disabled, error } = this.state.field;
64
+ const customError = error || (this.props.field.error && !checked);
34
65
 
35
66
  const _props = {
36
- ...field.bind(),
37
- error, label,
67
+ value,
68
+ checked,
69
+ name,
70
+ disabled,
71
+ onChange: this.handleChange,
72
+ error: customError,
73
+ label,
38
74
  checkboxClassName,
39
75
  labelClassName
40
76
  };
41
77
 
42
- // const errorClassNames = classnames(styles.errorText, errorClassName);
43
-
44
78
  return (
45
79
  <div className={classnames(styles.field, className)}>
46
80
  <Checkbox {..._props} />
47
- {/* {hasError && error ? (<span className={errorClassNames}>{error}</span>) : false} */}
48
- {/* {customHasError ? (<span className={errorClassNames}>{helperText}</span>) : false} */}
49
81
  </div>
50
82
  );
51
83
  }
@@ -4,7 +4,6 @@ import { action } from '@storybook/addon-actions';
4
4
 
5
5
  import { ROW_STYLES } from '../../../framework/constants';
6
6
  import CheckboxMaterial from './CheckboxMaterial';
7
- import FormCheckboxMaterial from './FormCheckboxMaterial';
8
7
 
9
8
  import styles from './CheckboxMaterial.story.styl';
10
9
 
@@ -124,13 +123,4 @@ const CheckboxWrap = () => {
124
123
 
125
124
  storiesOf('_Common_UI', module)
126
125
  .add('CheckboxMaterial', () => <CheckboxWrap />)
127
- .add('FormCheckboxMaterial', () => (
128
- <div>
129
- <div style={ROW_STYLES}>
130
- <FormCheckboxMaterial {...basePropsForm} />
131
- </div>
132
- <div style={ROW_STYLES}>
133
- <FormCheckboxMaterial {...withErrorForm} />
134
- </div>
135
- </div>
136
- ));
126
+
@@ -3,8 +3,6 @@ import _get from 'lodash/get';
3
3
  import _startsWith from 'lodash/startsWith';
4
4
  import _debounce from 'lodash/debounce';
5
5
  import qs from 'qs';
6
- import { observer } from 'mobx-react';
7
- import { toJS } from 'mobx';
8
6
  import { checkRangeValuesOnEqual, getGroupValuesForQuery } from '../../../../framework/utils/CommonUtils';
9
7
  import { FilterBlockFactory } from '../../../SearchFilters/common/FilterBlock/FilterBlockFactory';
10
8
  import { FilterGroups, IFilters } from '../../../SearchFilters/FiltersFactory';
@@ -60,7 +58,6 @@ interface IFiltersContainerProps extends IRouteComponentProps<PathParamsType> {
60
58
  Link?: any;
61
59
  }
62
60
 
63
- @observer
64
61
  class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
65
62
  componentDidMount() {
66
63
  this.getFiltersFromQuery();
@@ -89,7 +86,7 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
89
86
  }
90
87
 
91
88
  clearSearchState(!activeSort);
92
- search(toJS(filters), pageNumber || 1, true);
89
+ search(filters, pageNumber || 1, true);
93
90
  }
94
91
 
95
92
  this.updateFinancingSearchConfig();
@@ -97,7 +94,7 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
97
94
 
98
95
  componentWillUnmount(): void {
99
96
  const { location, filters, setLastSearchString, resetFiltersToDefault } = this.props;
100
- setLastSearchString(toJS(filters), location.search);
97
+ setLastSearchString(filters, location.search);
101
98
  resetFiltersToDefault();
102
99
  }
103
100
 
@@ -163,7 +160,7 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
163
160
  if (needToRefreshPage) {
164
161
  onFilterChange();
165
162
  clearSearchState();
166
- search(toJS(filters), 1, true);
163
+ search(filters, 1, true);
167
164
  }
168
165
  };
169
166
 
@@ -243,12 +240,11 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
243
240
 
244
241
  getQueryFromFilters = () => {
245
242
  const { filters } = this.props;
246
- const filtersList = toJS(filters);
247
- const filtersKeys = Object.keys(filtersList);
243
+ const filtersKeys = Object.keys(filters);
248
244
  const query: { [key: string]: any } = {};
249
245
 
250
246
  filtersKeys.forEach((filter: string) => {
251
- const filterObj = filtersList[filter];
247
+ const filterObj = filters[filter];
252
248
  const filterValue = filter === MMS_GROUPS_KEY ? getGroupValuesForQuery(filterObj) : filterObj.value;
253
249
  const isRangeFilter = typeof filterValue === 'object' && filterObj.isRange;
254
250
  const isRateFilter = typeof filterValue === 'object' && filterObj.isRate;
@@ -272,8 +268,7 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
272
268
 
273
269
  getMmsGroupsProps = (filter: string) => {
274
270
  const { filters } = this.props;
275
- const allFilters = toJS(filters);
276
- const mmsGroups = allFilters[filter];
271
+ const mmsGroups = filters[filter];
277
272
 
278
273
  return mmsGroups.map((filterGroup: any, index: number) => {
279
274
  const group: any = {};
@@ -281,8 +276,8 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
281
276
  Object.keys(filterGroup).forEach((fl: string) => {
282
277
 
283
278
  group[fl] = {
284
- values: toJS(allFilters[filter][index][fl].value),
285
- options: toJS(allFilters[filter][index][fl].options)
279
+ values: filters[filter][index][fl].value,
280
+ options: filters[filter][index][fl].options
286
281
  };
287
282
  });
288
283
 
@@ -292,15 +287,14 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
292
287
 
293
288
  getDefaultFilterProps = (filter: string) => {
294
289
  const { filters, aggregation } = this.props;
295
- const allFilters = toJS(filters);
296
- const agg: any = toJS(aggregation);
297
- const controls = allFilters[filter].controls;
290
+ const agg: any = aggregation;
291
+ const controls = filters[filter].controls;
298
292
  const controlsType = _get(controls, 'type', '');
299
- const filterField = `${allFilters[filter].field}${controlsType}`;
293
+ const filterField = `${filters[filter].field}${controlsType}`;
300
294
  const histograms = agg['HISTOGRAM'] || {};
301
295
  const isHistogram = Object.keys(histograms).indexOf(filterField) !== -1;
302
296
 
303
- const typeOptions = allFilters[filter].typeOptions;
297
+ const typeOptions = filters[filter].typeOptions;
304
298
  let filterProps = {
305
299
  ...(controls && Object.keys(controls).length && { controls }),
306
300
  ...(typeOptions && Object.keys(typeOptions).length && { typeOptions })
@@ -318,8 +312,8 @@ class FiltersContainer extends React.Component<IFiltersContainerProps, {}> {
318
312
  options: histogramData
319
313
  });
320
314
  } else {
321
- const values = toJS(allFilters[filter].value);
322
- const options = toJS(allFilters[filter].options);
315
+ const values = filters[filter].value;
316
+ const options = filters[filter].options;
323
317
  const optionsWithoutUnknown = removeUnknownOptions(options);
324
318
 
325
319
  filterProps = Object.assign({}, filterProps, {
@@ -1,22 +0,0 @@
1
- @import '../../../theme/theme.styl'
2
-
3
- .field
4
- position: relative
5
- flex: 1 0 100%
6
-
7
- .errorText
8
- position: absolute
9
- left: 0
10
- bottom: -15px
11
- display: block
12
- width: 100%
13
- z-index: 1
14
- font-family: "Arial Standard", Arial
15
- font-weight: 400;
16
- font-style: normal
17
- font-size: 10px
18
- line-height: 15px
19
- color: $darkRed
20
- overflow: hidden
21
- text-overflow: ellipsis
22
- white-space: nowrap
@@ -1,50 +0,0 @@
1
- import * as React from 'react';
2
- import classnames from 'classnames';
3
- import { observer } from 'mobx-react';
4
-
5
- import CheckboxMaterial from './CheckboxMaterial';
6
- import styles from './FormCheckboxMaterial.styl';
7
-
8
- interface IFormCheckboxProps {
9
- className?: string;
10
- errorClassName?: string;
11
- label?: JSX.Element | string | null;
12
-
13
- // mobx form field instance
14
- field: any;
15
- checkboxClassName?: string;
16
- labelClassName?: string;
17
- }
18
-
19
- @observer
20
- class FormCheckboxMaterial extends React.Component<IFormCheckboxProps> {
21
- static defaultProps = {
22
- className: '',
23
- label: false
24
- };
25
-
26
- render() {
27
- const { field, label, className, checkboxClassName, labelClassName, errorClassName } = this.props;
28
-
29
- const hasError = field.hasError;
30
- const error = field.error;
31
-
32
- const _props = {
33
- ...field.bind(),
34
- error, label,
35
- checkboxClassName,
36
- labelClassName
37
- };
38
-
39
- const errorClassNames = classnames(styles.errorText, errorClassName);
40
-
41
- return (
42
- <div className={classnames(styles.field, className)}>
43
- <CheckboxMaterial {..._props} />
44
- {hasError && error ? (<span className={errorClassNames}>{error}</span>) : false}
45
- </div>
46
- );
47
- }
48
- }
49
-
50
- export default FormCheckboxMaterial;
@@ -1,36 +0,0 @@
1
- import React from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import { action } from '@storybook/addon-actions';
4
-
5
- import PropertySelector from './PropertySelector';
6
- import FormPSGroup from './FormPSGroup';
7
- import styles from './FormPSGroup.story.styl';
8
-
9
- const mockField = {
10
- name: 'availability',
11
- value: ['always'],
12
- error: 'Something went wrong',
13
- hasError: true,
14
- onChange: action('FormRadioGroup change'),
15
- bind: () => {
16
- const { bind, ...rest } = mockField;
17
- return rest;
18
- }
19
- };
20
-
21
- storiesOf('_Common_UI', module)
22
- .add('FormPSGroup', () => (
23
- <div>
24
- <FormPSGroup field={mockField} childClassName={styles.child}>
25
- <PropertySelector label='Available always' value='always'/>
26
- <PropertySelector label='Available from' value='fromDate'/>
27
- <PropertySelector label='Unknown' value='unknown' disabled={true} />
28
- </FormPSGroup>
29
-
30
- <FormPSGroup field={mockField} containerClassName={styles.vertical}>
31
- <PropertySelector label='Available always' value='always'/>
32
- <PropertySelector label='Available from' value='fromDate'/>
33
- <PropertySelector label='Unknown' value='unknown' disabled={true} />
34
- </FormPSGroup>
35
- </div>
36
- ));
@@ -1,5 +0,0 @@
1
- .vertical
2
- display: flex
3
- flex-direction: row
4
- align-items: center
5
-
@@ -1,22 +0,0 @@
1
- @import '../../../theme/theme.styl'
2
-
3
- .field
4
- position: relative
5
- display: inline-block
6
-
7
- .errorText
8
- position: absolute
9
- left: 0
10
- bottom: -15px
11
- display: block
12
- width: 100%
13
- z-index: 1
14
- font-family: $font-style-arial
15
- font-weight: $font-weight-default
16
- font-style: normal
17
- font-size: 10px
18
- line-height: 15px
19
- color: $darkRed
20
- overflow: hidden
21
- text-overflow: ellipsis
22
- white-space: nowrap
@@ -1,54 +0,0 @@
1
- import * as React from 'react';
2
- import classnames from 'classnames';
3
- import { observer } from 'mobx-react';
4
-
5
- import PSGroup from './PSGroup';
6
- import styles from './FormPSGroup.styl';
7
-
8
- interface IFormRadioGroupProps {
9
- children: any;
10
- className?: string;
11
- behavior?: string;
12
-
13
- // mobx form field instance
14
- field: any;
15
-
16
- containerClassName?: string;
17
- childClassName?: string;
18
- }
19
-
20
- @observer
21
- class FormPSGroup extends React.Component<IFormRadioGroupProps> {
22
- static defaultProps = {
23
- className: '',
24
- label: false,
25
- containerClassName: '',
26
- childClassName: ''
27
- };
28
-
29
- render() {
30
- const { field, className, behavior, containerClassName, childClassName } = this.props;
31
-
32
- const hasError = field.hasError;
33
- const error = field.error;
34
-
35
- const _props = {
36
- ...field.bind(),
37
- behavior,
38
- containerClassName,
39
- childClassName,
40
- error: hasError
41
- };
42
-
43
- return (
44
- <div className={classnames(styles.field, className)}>
45
- <PSGroup {..._props} >
46
- {this.props.children}
47
- </PSGroup>
48
- {hasError && error ? (<span className={styles.errorText}>{error}</span>) : false}
49
- </div>
50
- );
51
- }
52
- }
53
-
54
- export default FormPSGroup;