@bytebrand/fe-ui-core 4.2.72 → 4.2.74

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,6 +3,7 @@ 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';
6
7
  export { default as PropertySelector } from './source/components/_common/PropertySelector/PropertySelector';
7
8
 
8
9
  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.72",
3
+ "version": "4.2.74",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -19,6 +19,10 @@
19
19
  width: 1px;
20
20
  height: 100%
21
21
  background-color $grey-5f;
22
+
23
+ [class^='OfferCheckboxGroup__labelContent']
24
+ @media (min-width: 990px) and (max-width: 1073px)
25
+ max-width: 230px
22
26
 
23
27
  .wrapConfigDetails
24
28
  box-sizing: border-box
@@ -73,9 +73,6 @@
73
73
  .labelContent
74
74
  flex: 1 1 auto
75
75
  color: $grey-3;
76
- @media (min-width: 990px) and (max-width: 1112px)
77
- max-width: 230px
78
- padding-right: 10px !important;
79
76
 
80
77
  .icon
81
78
  display: block
@@ -120,4 +117,4 @@
120
117
  font-size: 12px;
121
118
 
122
119
  .hidePlus
123
- display: inline-block
120
+ display: inline-block
@@ -167,14 +167,13 @@
167
167
  [class*='MuiFormControlLabel-root']
168
168
  height: 20px
169
169
  min-height: 0
170
+ margin-left:0
170
171
  .labelText
171
172
  font-size: 12px;
172
173
  font-weight: normal;
173
174
 
174
175
  [class*='labelContent']
175
176
  font-size: 12px
176
- +media-phone-up()
177
- padding-right: 62px;
178
177
 
179
178
 
180
179
  .checkBoxGroup
@@ -190,3 +189,6 @@
190
189
  margin: 0
191
190
  justify-content: space-between
192
191
  width: 100%
192
+
193
+ [class*='MuiIconButton-root']
194
+ padding:5px!important
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import classnames from 'classnames';
3
+ import { observer } from 'mobx-react';
4
+
3
5
  import Checkbox from './Checkbox';
4
6
  import styles from './FormCheckbox.styl';
5
7
 
@@ -7,6 +9,8 @@ interface IFormCheckboxProps {
7
9
  className?: string;
8
10
  errorClassName?: string;
9
11
  label?: JSX.Element | string | null;
12
+
13
+ // mobx form field instance
10
14
  field: any;
11
15
  checkboxClassName?: string;
12
16
  labelClassName?: string;
@@ -14,70 +18,34 @@ interface IFormCheckboxProps {
14
18
  helperText?: string;
15
19
  }
16
20
 
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
- }
21
+ @observer
22
+ class FormCheckbox extends React.Component<IFormCheckboxProps> {
41
23
  static defaultProps = {
42
24
  className: '',
43
25
  label: false
44
26
  };
45
27
 
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
- }
60
-
61
28
  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);
29
+ const { field, label, className, checkboxClassName, labelClassName, customError } = this.props;
30
+
31
+ // const customHasError = customError;
32
+ // const hasError = field.hasError;
33
+ const error = customError ? customError : field.error;
65
34
 
66
35
  const _props = {
67
- value,
68
- checked,
69
- name,
70
- disabled,
71
- onChange: this.handleChange,
72
- error: customError,
73
- label,
36
+ ...field.bind(),
37
+ error, label,
74
38
  checkboxClassName,
75
39
  labelClassName
76
40
  };
77
41
 
42
+ // const errorClassNames = classnames(styles.errorText, errorClassName);
43
+
78
44
  return (
79
45
  <div className={classnames(styles.field, className)}>
80
46
  <Checkbox {..._props} />
47
+ {/* {hasError && error ? (<span className={errorClassNames}>{error}</span>) : false} */}
48
+ {/* {customHasError ? (<span className={errorClassNames}>{helperText}</span>) : false} */}
81
49
  </div>
82
50
  );
83
51
  }
@@ -4,6 +4,7 @@ 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';
7
8
 
8
9
  import styles from './CheckboxMaterial.story.styl';
9
10
 
@@ -123,4 +124,13 @@ const CheckboxWrap = () => {
123
124
 
124
125
  storiesOf('_Common_UI', module)
125
126
  .add('CheckboxMaterial', () => <CheckboxWrap />)
126
-
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
+ ));
@@ -0,0 +1,22 @@
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
@@ -0,0 +1,50 @@
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;
@@ -0,0 +1,36 @@
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
+ ));
@@ -0,0 +1,5 @@
1
+ .vertical
2
+ display: flex
3
+ flex-direction: row
4
+ align-items: center
5
+
@@ -0,0 +1,22 @@
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
@@ -0,0 +1,54 @@
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;