@pie-lib/config-ui 11.3.12 → 12.0.0-beta.1

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +0 -332
  2. package/lib/alert-dialog.js +1 -1
  3. package/lib/alert-dialog.js.map +1 -1
  4. package/lib/checkbox.js +3 -3
  5. package/lib/checkbox.js.map +1 -1
  6. package/lib/choice-configuration/feedback-menu.js +1 -1
  7. package/lib/choice-configuration/feedback-menu.js.map +1 -1
  8. package/lib/choice-configuration/index.js +10 -24
  9. package/lib/choice-configuration/index.js.map +1 -1
  10. package/lib/choice-utils.js +1 -1
  11. package/lib/choice-utils.js.map +1 -1
  12. package/lib/feedback-config/feedback-selector.js +6 -12
  13. package/lib/feedback-config/feedback-selector.js.map +1 -1
  14. package/lib/feedback-config/group.js +3 -3
  15. package/lib/feedback-config/group.js.map +1 -1
  16. package/lib/feedback-config/index.js +1 -1
  17. package/lib/feedback-config/index.js.map +1 -1
  18. package/lib/form-section.js +1 -1
  19. package/lib/form-section.js.map +1 -1
  20. package/lib/help.js +6 -8
  21. package/lib/help.js.map +1 -1
  22. package/lib/index.js +1 -1
  23. package/lib/index.js.map +1 -1
  24. package/lib/input.js +1 -1
  25. package/lib/input.js.map +1 -1
  26. package/lib/inputs.js +10 -12
  27. package/lib/inputs.js.map +1 -1
  28. package/lib/langs.js +1 -1
  29. package/lib/langs.js.map +1 -1
  30. package/lib/layout/config-layout.js +16 -28
  31. package/lib/layout/config-layout.js.map +1 -1
  32. package/lib/layout/index.js +1 -1
  33. package/lib/layout/index.js.map +1 -1
  34. package/lib/layout/layout-contents.js +16 -85
  35. package/lib/layout/layout-contents.js.map +1 -1
  36. package/lib/layout/settings-box.js +6 -5
  37. package/lib/layout/settings-box.js.map +1 -1
  38. package/lib/mui-box/index.js +1 -1
  39. package/lib/mui-box/index.js.map +1 -1
  40. package/lib/number-text-field-custom.js +1 -1
  41. package/lib/number-text-field-custom.js.map +1 -1
  42. package/lib/number-text-field.js +1 -1
  43. package/lib/number-text-field.js.map +1 -1
  44. package/lib/radio-with-label.js +1 -1
  45. package/lib/radio-with-label.js.map +1 -1
  46. package/lib/settings/display-size.js +1 -1
  47. package/lib/settings/display-size.js.map +1 -1
  48. package/lib/settings/index.js +1 -1
  49. package/lib/settings/index.js.map +1 -1
  50. package/lib/settings/panel.js +58 -78
  51. package/lib/settings/panel.js.map +1 -1
  52. package/lib/settings/settings-radio-label.js +8 -10
  53. package/lib/settings/settings-radio-label.js.map +1 -1
  54. package/lib/settings/toggle.js +2 -2
  55. package/lib/settings/toggle.js.map +1 -1
  56. package/lib/tabs/index.js +2 -6
  57. package/lib/tabs/index.js.map +1 -1
  58. package/lib/tags-input/index.js +3 -3
  59. package/lib/tags-input/index.js.map +1 -1
  60. package/lib/two-choice.js +1 -1
  61. package/lib/two-choice.js.map +1 -1
  62. package/lib/with-stateful-model.js +1 -1
  63. package/lib/with-stateful-model.js.map +1 -1
  64. package/package.json +5 -5
  65. package/src/alert-dialog.jsx +9 -2
  66. package/src/checkbox.jsx +10 -10
  67. package/src/choice-configuration/feedback-menu.jsx +23 -10
  68. package/src/choice-configuration/index.jsx +49 -66
  69. package/src/choice-utils.js +1 -1
  70. package/src/feedback-config/feedback-selector.jsx +22 -26
  71. package/src/feedback-config/group.jsx +12 -10
  72. package/src/feedback-config/index.jsx +8 -14
  73. package/src/form-section.jsx +4 -4
  74. package/src/help.jsx +15 -14
  75. package/src/index.js +5 -2
  76. package/src/input.jsx +7 -7
  77. package/src/inputs.jsx +20 -15
  78. package/src/langs.jsx +39 -28
  79. package/src/layout/config-layout.jsx +20 -17
  80. package/src/layout/layout-contents.jsx +19 -65
  81. package/src/layout/settings-box.jsx +8 -12
  82. package/src/mui-box/index.jsx +9 -9
  83. package/src/number-text-field-custom.jsx +25 -25
  84. package/src/number-text-field.jsx +12 -12
  85. package/src/radio-with-label.jsx +2 -2
  86. package/src/settings/display-size.jsx +5 -5
  87. package/src/settings/index.js +11 -12
  88. package/src/settings/panel.jsx +59 -64
  89. package/src/settings/settings-radio-label.jsx +5 -5
  90. package/src/settings/toggle.jsx +7 -7
  91. package/src/tabs/index.jsx +15 -11
  92. package/src/tags-input/index.jsx +19 -17
  93. package/src/two-choice.jsx +8 -8
  94. package/src/with-stateful-model.jsx +4 -4
  95. package/LICENSE.md +0 -5
@@ -9,23 +9,23 @@ import InputAdornment from '@material-ui/core/InputAdornment';
9
9
  import Remove from '@material-ui/icons/Remove';
10
10
  import Add from '@material-ui/icons/Add';
11
11
 
12
- const styles = (theme) => ({
12
+ const styles = theme => ({
13
13
  input: {
14
14
  '& input[type=number]': {
15
- '-moz-appearance': 'textfield',
15
+ '-moz-appearance': 'textfield'
16
16
  },
17
17
  '& input[type=number]::-webkit-outer-spin-button': {
18
18
  '-webkit-appearance': 'none',
19
- margin: 0,
19
+ margin: 0
20
20
  },
21
21
  '& input[type=number]::-webkit-inner-spin-button': {
22
22
  '-webkit-appearance': 'none',
23
- margin: 0,
24
- },
23
+ margin: 0
24
+ }
25
25
  },
26
26
  iconButton: {
27
- padding: '2px',
28
- },
27
+ padding: '2px'
28
+ }
29
29
  });
30
30
 
31
31
  const fallbackNumber = (min, max) => {
@@ -58,7 +58,7 @@ export class NumberTextFieldCustom extends React.Component {
58
58
  step: PropTypes.number,
59
59
  label: PropTypes.string,
60
60
  disableUnderline: PropTypes.bool,
61
- variant: PropTypes.string,
61
+ variant: PropTypes.string
62
62
  };
63
63
 
64
64
  static defaultProps = {
@@ -66,7 +66,7 @@ export class NumberTextFieldCustom extends React.Component {
66
66
  customValues: [],
67
67
  textAlign: 'center',
68
68
  variant: 'standard',
69
- onlyIntegersAllowed: false,
69
+ onlyIntegersAllowed: false
70
70
  };
71
71
 
72
72
  constructor(props) {
@@ -76,7 +76,7 @@ export class NumberTextFieldCustom extends React.Component {
76
76
 
77
77
  this.state = {
78
78
  value,
79
- currentIndex,
79
+ currentIndex
80
80
  };
81
81
 
82
82
  if (value !== props.value) {
@@ -116,7 +116,7 @@ export class NumberTextFieldCustom extends React.Component {
116
116
 
117
117
  normalizeValueAndIndex = (customValues, number) => {
118
118
  const value = this.clamp(number);
119
- const currentIndex = (customValues || []).findIndex((val) => val === value);
119
+ const currentIndex = (customValues || []).findIndex(val => val === value);
120
120
 
121
121
  if ((customValues || []).length > 0 && currentIndex === -1) {
122
122
  const closestValue = this.getClosestValue(customValues, value);
@@ -131,10 +131,10 @@ export class NumberTextFieldCustom extends React.Component {
131
131
  customValues.reduce(
132
132
  (closest, value, index) =>
133
133
  Math.abs(value - number) < Math.abs(closest.value - number) ? { value, index } : closest,
134
- { value: customValues[0], index: 0 },
134
+ { value: customValues[0], index: 0 }
135
135
  );
136
136
 
137
- onBlur = (event) => {
137
+ onBlur = event => {
138
138
  const { customValues, onlyIntegersAllowed } = this.props;
139
139
  const { value } = event.target;
140
140
  const rawNumber = onlyIntegersAllowed ? parseInt(value) : parseFloat(value);
@@ -145,9 +145,9 @@ export class NumberTextFieldCustom extends React.Component {
145
145
  this.setState(
146
146
  {
147
147
  value: number.toString(),
148
- currentIndex,
148
+ currentIndex
149
149
  },
150
- () => this.props.onChange(event, number),
150
+ () => this.props.onChange(event, number)
151
151
  );
152
152
  }
153
153
  };
@@ -181,13 +181,13 @@ export class NumberTextFieldCustom extends React.Component {
181
181
  this.setState(
182
182
  {
183
183
  value: number.toString(),
184
- currentIndex: updatedIndex,
184
+ currentIndex: updatedIndex
185
185
  },
186
186
  () => {
187
187
  if (shouldUpdate) {
188
188
  onChange(event, number);
189
189
  }
190
- },
190
+ }
191
191
  );
192
192
  }
193
193
 
@@ -204,7 +204,7 @@ export class NumberTextFieldCustom extends React.Component {
204
204
  disableUnderline,
205
205
  helperText,
206
206
  variant,
207
- textAlign,
207
+ textAlign
208
208
  } = this.props;
209
209
  const { value } = this.state;
210
210
  const names = classNames(className, classes.input);
@@ -212,7 +212,7 @@ export class NumberTextFieldCustom extends React.Component {
212
212
  return (
213
213
  <TextField
214
214
  variant={variant}
215
- inputRef={(ref) => (this.inputRef = ref)}
215
+ inputRef={ref => (this.inputRef = ref)}
216
216
  disabled={disabled}
217
217
  label={label}
218
218
  value={value}
@@ -220,13 +220,13 @@ export class NumberTextFieldCustom extends React.Component {
220
220
  helperText={helperText}
221
221
  onChange={this.onChange}
222
222
  onBlur={this.onBlur}
223
- onKeyPress={(e) => {
223
+ onKeyPress={e => {
224
224
  // once the Enter key is pressed, we force input blur
225
225
  if (e.key === 'Enter' && this.inputRef) {
226
226
  this.inputRef.blur();
227
227
  }
228
228
  }}
229
- onKeyDown={(e) => {
229
+ onKeyDown={e => {
230
230
  if (e.key === 'ArrowUp') {
231
231
  this.changeValue(e);
232
232
  }
@@ -245,7 +245,7 @@ export class NumberTextFieldCustom extends React.Component {
245
245
  <IconButton
246
246
  className={classes.iconButton}
247
247
  disabled={disabled}
248
- onClick={(e) => this.changeValue(e, -1, true)}
248
+ onClick={e => this.changeValue(e, -1, true)}
249
249
  >
250
250
  <Remove fontSize="small" />
251
251
  </IconButton>
@@ -256,17 +256,17 @@ export class NumberTextFieldCustom extends React.Component {
256
256
  <IconButton
257
257
  className={classes.iconButton}
258
258
  disabled={disabled}
259
- onClick={(e) => this.changeValue(e, 1, true)}
259
+ onClick={e => this.changeValue(e, 1, true)}
260
260
  >
261
261
  <Add fontSize="small" />
262
262
  </IconButton>
263
263
  </InputAdornment>
264
- ),
264
+ )
265
265
  }}
266
266
  inputProps={{
267
267
  style: { textAlign },
268
268
  min,
269
- max,
269
+ max
270
270
  }}
271
271
  />
272
272
  );
@@ -8,8 +8,8 @@ import isFinite from 'lodash/isFinite';
8
8
  import InputAdornment from '@material-ui/core/InputAdornment';
9
9
  const log = debug('@pie-lib:config-ui:number-text-field');
10
10
 
11
- const styles = (theme) => ({
12
- root: { marginRight: theme.spacing.unit },
11
+ const styles = theme => ({
12
+ root: { marginRight: theme.spacing.unit }
13
13
  });
14
14
 
15
15
  const fallbackNumber = (min, max) => {
@@ -39,11 +39,11 @@ export class NumberTextField extends React.Component {
39
39
  suffix: PropTypes.string,
40
40
  showErrorWhenOutsideRange: PropTypes.bool,
41
41
  disableUnderline: PropTypes.bool,
42
- variant: PropTypes.string,
42
+ variant: PropTypes.string
43
43
  };
44
44
 
45
45
  static defaultProps = {
46
- showErrorWhenOutsideRange: false,
46
+ showErrorWhenOutsideRange: false
47
47
  };
48
48
 
49
49
  constructor(props) {
@@ -52,7 +52,7 @@ export class NumberTextField extends React.Component {
52
52
  const value = this.clamp(props.value);
53
53
 
54
54
  this.state = {
55
- value,
55
+ value
56
56
  };
57
57
 
58
58
  if (value !== props.value) {
@@ -87,7 +87,7 @@ export class NumberTextField extends React.Component {
87
87
  * on Blur (this can be triggered by pressing Enter, see below)
88
88
  * we check the entered value and reset it if needed
89
89
  */
90
- onBlur = (event) => {
90
+ onBlur = event => {
91
91
  const value = event.target.value;
92
92
 
93
93
  const rawNumber = parseFloat(value);
@@ -149,7 +149,7 @@ export class NumberTextField extends React.Component {
149
149
  inputClassName,
150
150
  disableUnderline,
151
151
  showErrorWhenOutsideRange,
152
- variant,
152
+ variant
153
153
  } = this.props;
154
154
  const names = classNames(classes.root, className);
155
155
 
@@ -157,7 +157,7 @@ export class NumberTextField extends React.Component {
157
157
  return (
158
158
  <TextField
159
159
  variant={variant || 'standard'}
160
- inputRef={(ref) => {
160
+ inputRef={ref => {
161
161
  this.inputRef = ref;
162
162
  }}
163
163
  disabled={disabled}
@@ -167,7 +167,7 @@ export class NumberTextField extends React.Component {
167
167
  helperText={error}
168
168
  onChange={this.onChange}
169
169
  onBlur={this.onBlur}
170
- onKeyPress={(e) => {
170
+ onKeyPress={e => {
171
171
  // once the Enter key is pressed, we force input blur
172
172
  if (e.key === 'Enter' && this.inputRef) {
173
173
  this.inputRef.blur();
@@ -176,16 +176,16 @@ export class NumberTextField extends React.Component {
176
176
  type="number"
177
177
  className={names}
178
178
  InputLabelProps={{
179
- shrink: true,
179
+ shrink: true
180
180
  }}
181
181
  InputProps={{
182
182
  endAdornment: suffix && <InputAdornment position="end">{suffix}</InputAdornment>,
183
183
  className: inputClassName,
184
- disableUnderline: disableUnderline,
184
+ disableUnderline: disableUnderline
185
185
  }}
186
186
  inputProps={{
187
187
  min,
188
- max,
188
+ max
189
189
  }}
190
190
  margin="normal"
191
191
  />
@@ -6,8 +6,8 @@ import { withStyles } from '@material-ui/core/styles';
6
6
  export default withStyles({
7
7
  label: {
8
8
  left: '-5px',
9
- position: 'relative',
10
- },
9
+ position: 'relative'
10
+ }
11
11
  })(({ label, value, checked, onChange, classes }) => (
12
12
  <FormControlLabel
13
13
  value={value}
@@ -4,11 +4,11 @@ import Typography from '@material-ui/core/Typography';
4
4
  import { withStyles } from '@material-ui/core/styles';
5
5
  import NumberTextField from '../number-text-field';
6
6
 
7
- const DisplaySize = withStyles((theme) => ({
7
+ const DisplaySize = withStyles(theme => ({
8
8
  displaySize: {
9
9
  display: 'flex',
10
- paddingTop: theme.spacing.unit,
11
- },
10
+ paddingTop: theme.spacing.unit
11
+ }
12
12
  }))(({ size, label, classes, onChange }) => {
13
13
  const updateSize = (key, v) => {
14
14
  onChange({ ...size, [key]: v });
@@ -43,10 +43,10 @@ const DisplaySize = withStyles((theme) => ({
43
43
  DisplaySize.propTypes = {
44
44
  size: PropTypes.shape({
45
45
  width: PropTypes.number.isRequired,
46
- height: PropTypes.number.isRequired,
46
+ height: PropTypes.number.isRequired
47
47
  }).isRequired,
48
48
  label: PropTypes.string.isRequired,
49
- onChange: PropTypes.func,
49
+ onChange: PropTypes.func
50
50
  };
51
51
 
52
52
  export default DisplaySize;
@@ -5,10 +5,10 @@ export { Panel };
5
5
  export const toggle = (label, isConfigProperty = false) => ({
6
6
  type: 'toggle',
7
7
  label,
8
- isConfigProperty,
8
+ isConfigProperty
9
9
  });
10
10
 
11
- const toChoice = (opt) => {
11
+ const toChoice = opt => {
12
12
  if (typeof opt === 'string') {
13
13
  return { label: opt, value: opt };
14
14
  } else {
@@ -19,12 +19,11 @@ const toChoice = (opt) => {
19
19
  export const radio = function() {
20
20
  const args = Array.prototype.slice.call(arguments);
21
21
  const [label, choices, isConfigProperty = false] = args;
22
-
23
22
  return {
24
23
  type: 'radio',
25
24
  label,
26
- choices: choices && choices.map((o) => toChoice(o)),
27
- isConfigProperty,
25
+ choices: choices && choices.map(o => toChoice(o)),
26
+ isConfigProperty
28
27
  };
29
28
  };
30
29
 
@@ -33,7 +32,7 @@ export const dropdown = (label, choices, isConfigProperty = false) => {
33
32
  type: 'dropdown',
34
33
  label,
35
34
  choices,
36
- isConfigProperty,
35
+ isConfigProperty
37
36
  };
38
37
  };
39
38
 
@@ -41,18 +40,18 @@ export const numberField = (label, options, isConfigProperty = false) => ({
41
40
  ...options,
42
41
  label,
43
42
  type: 'numberField',
44
- isConfigProperty,
43
+ isConfigProperty
45
44
  });
46
45
 
47
46
  export const numberFields = (label, fields, isConfigProperty = false) => {
48
- Object.keys(fields).map((key) => {
47
+ Object.keys(fields).map(key => {
49
48
  fields[key] = numberField(fields[key].label, fields[key], isConfigProperty);
50
49
  });
51
50
 
52
51
  return {
53
52
  type: 'numberFields',
54
53
  label,
55
- fields,
54
+ fields
56
55
  };
57
56
  };
58
57
 
@@ -60,17 +59,17 @@ export const checkbox = (label, settings, isConfigProperty = false) => ({
60
59
  ...settings,
61
60
  label,
62
61
  type: 'checkbox',
63
- isConfigProperty,
62
+ isConfigProperty
64
63
  });
65
64
 
66
65
  export const checkboxes = (label, choices, isConfigProperty = false) => {
67
- Object.keys(choices).map((key) => {
66
+ Object.keys(choices).map(key => {
68
67
  choices[key] = checkbox(choices[key].label, choices[key], isConfigProperty);
69
68
  });
70
69
 
71
70
  return {
72
71
  type: 'checkboxes',
73
72
  label,
74
- choices,
73
+ choices
75
74
  };
76
75
  };
@@ -9,7 +9,7 @@ import MenuItem from '@material-ui/core/MenuItem';
9
9
  import debug from 'debug';
10
10
 
11
11
  import Toggle from './toggle';
12
- import { NChoice } from '../two-choice';
12
+ import TwoChoice from '../two-choice';
13
13
  import SettingsRadioLabel from './settings-radio-label';
14
14
  import { NumberTextField } from '../index';
15
15
  import Checkbox from '../checkbox';
@@ -18,13 +18,13 @@ const log = debug('pie-lib:config-ui:settings:panel');
18
18
 
19
19
  const labelValue = {
20
20
  label: PropTypes.string,
21
- value: PropTypes.string,
21
+ value: PropTypes.string
22
22
  };
23
23
 
24
24
  const baseTypes = {
25
25
  label: PropTypes.string,
26
26
  value: PropTypes.string,
27
- onChange: PropTypes.func,
27
+ onChange: PropTypes.func
28
28
  };
29
29
 
30
30
  const CheckboxChoice = ({ label, value, onChange }) => {
@@ -32,7 +32,7 @@ const CheckboxChoice = ({ label, value, onChange }) => {
32
32
  <Checkbox
33
33
  checked={value}
34
34
  label={label}
35
- onChange={(event) => {
35
+ onChange={event => {
36
36
  onChange(event.target.checked);
37
37
  }}
38
38
  />
@@ -42,18 +42,19 @@ const CheckboxChoice = ({ label, value, onChange }) => {
42
42
  CheckboxChoice.propTypes = {
43
43
  label: PropTypes.string,
44
44
  value: PropTypes.bool,
45
- onChange: PropTypes.func,
45
+ onChange: PropTypes.func
46
46
  };
47
47
 
48
48
  const Radio = ({ classes, label, value, onChange, choices }) => {
49
49
  return (
50
- <NChoice
50
+ <TwoChoice
51
51
  className={classes.radioSettings}
52
- direction="horizontal"
52
+ direction="vertical"
53
53
  customLabel={SettingsRadioLabel}
54
54
  value={value}
55
55
  header={label}
56
- opts={choices}
56
+ one={choices[0]}
57
+ two={choices[1]}
57
58
  onChange={onChange}
58
59
  />
59
60
  );
@@ -61,37 +62,37 @@ const Radio = ({ classes, label, value, onChange, choices }) => {
61
62
 
62
63
  Radio.propTypes = { ...baseTypes, choices: PropTypes.arrayOf(PropTypes.shape(labelValue)) };
63
64
 
64
- const StyledRadio = withStyles((theme) => ({
65
+ const StyledRadio = withStyles({
65
66
  radioSettings: {
66
- marginTop: theme.spacing.unit / 2,
67
- paddingBottom: theme.spacing.unit / 2,
67
+ marginTop: '4px',
68
+ paddingBottom: '4px',
68
69
  width: '100%',
69
70
  '& > label': {
70
71
  color: 'rgba(0, 0, 0, 0.89)',
71
72
  transform: 'translate(0, 10px) scale(1)',
72
- fontSize: '14px',
73
+ fontSize: '14px'
73
74
  },
74
75
  '& > div': {
75
- marginTop: theme.spacing.unit * 2.5,
76
- },
76
+ marginTop: '20px'
77
+ }
77
78
  },
78
79
  label: {
79
- display: 'none',
80
- },
81
- }))(Radio);
80
+ display: 'none'
81
+ }
82
+ })(Radio);
82
83
 
83
- const Dropdown = withStyles((theme) => ({
84
+ const Dropdown = withStyles({
84
85
  label: {
85
86
  margin: 0,
86
- fontSize: theme.typography.fontSize,
87
+ fontSize: '14px'
87
88
  },
88
89
  wrapper: {
89
- marginTop: theme.spacing.unit / 2,
90
+ marginTop: '4px',
90
91
  border: '2px solid lightgrey',
91
92
  borderRadius: '4px',
92
- padding: `0 ${theme.spacing.unit}px`,
93
- },
94
- }))(({ classes, label, value, onChange, choices = [] }) => {
93
+ padding: '0 8px'
94
+ }
95
+ })(({ classes, label, value, onChange, choices = [] }) => {
95
96
  return (
96
97
  <div>
97
98
  {label && <p className={classes.label}>{label}</p>}
@@ -114,19 +115,19 @@ const Dropdown = withStyles((theme) => ({
114
115
 
115
116
  Dropdown.propTypes = { ...baseTypes, choices: PropTypes.arrayOf(PropTypes.string) };
116
117
 
117
- const NumberField = withStyles((theme) => ({
118
+ const NumberField = withStyles({
118
119
  field: {
119
120
  width: '35%',
120
- marginRight: theme.spacing.unit * 3,
121
- marginTop: theme.spacing.unit,
121
+ marginRight: '24px',
122
+ marginTop: '8px'
122
123
  },
123
124
  wrapper: {
124
- marginTop: theme.spacing.unit / 2,
125
+ marginTop: '4px',
125
126
  border: '2px solid lightgrey',
126
127
  borderRadius: '4px',
127
- padding: `0 ${theme.spacing.unit}px`,
128
- },
129
- }))(({ classes, label, value, onChange = () => {}, suffix, min, max }) => {
128
+ padding: '0 8px'
129
+ }
130
+ })(({ classes, label, value, onChange = () => {}, suffix, min, max }) => {
130
131
  return (
131
132
  <NumberTextField
132
133
  label={label || 'Label'}
@@ -149,10 +150,12 @@ NumberField.propTypes = {
149
150
  suffix: PropTypes.string,
150
151
  min: PropTypes.number,
151
152
  max: PropTypes.number,
152
- value: PropTypes.number,
153
+ value: PropTypes.number
153
154
  };
154
155
 
155
- const ToggleWrapper = ({ label, value, onChange }) => <Toggle label={label} checked={!!value} toggle={onChange} />;
156
+ const ToggleWrapper = ({ label, value, onChange }) => (
157
+ <Toggle label={label} checked={!!value} toggle={onChange} />
158
+ );
156
159
 
157
160
  ToggleWrapper.propTypes = { ...baseTypes, value: PropTypes.bool };
158
161
 
@@ -161,24 +164,24 @@ const tagMap = {
161
164
  radio: StyledRadio,
162
165
  dropdown: Dropdown,
163
166
  numberField: NumberField,
164
- checkbox: CheckboxChoice,
167
+ checkbox: CheckboxChoice
165
168
  };
166
169
 
167
- const Group = withStyles((theme) => ({
170
+ const Group = withStyles(() => ({
168
171
  group: {
169
- margin: `0 0 ${theme.spacing.unit * 2}px 0`,
172
+ margin: '0 0 25px 0'
170
173
  },
171
174
  groupHeader: {
172
175
  color: '#495B8F',
173
- fontSize: theme.typography.fontSize + 2,
176
+ fontSize: '16px',
174
177
  fontWeight: 600,
175
- marginBottom: theme.spacing.unit,
178
+ marginBottom: '8px'
176
179
  },
177
180
  numberFields: {
178
- fontSize: theme.typography.fontSize,
179
- marginBottom: 0,
180
- },
181
- }))((props) => {
181
+ fontSize: '0.85rem',
182
+ marginBottom: 0
183
+ }
184
+ }))(props => {
182
185
  const { classes, model, label, group, configuration, onChange } = props;
183
186
 
184
187
  /**
@@ -192,7 +195,7 @@ const Group = withStyles((theme) => ({
192
195
  const tagProps = { ...properties, key, value };
193
196
  const Tag = tagMap[tagProps.type];
194
197
 
195
- return <Tag key={key} {...tagProps} onChange={(v) => onChange(key, v, isConfigProperty)} />;
198
+ return <Tag key={key} {...tagProps} onChange={v => onChange(key, v, isConfigProperty)} />;
196
199
  };
197
200
 
198
201
  const content = (group, key) => {
@@ -208,7 +211,7 @@ const Group = withStyles((theme) => ({
208
211
  return (
209
212
  <div key={`numberField-${label}`}>
210
213
  <p className={classes.numberFields}>{label}</p>
211
- {Object.keys(fields).map((fieldKey) => {
214
+ {Object.keys(fields).map(fieldKey => {
212
215
  return getTag(group, `${key}.${fieldKey}`, `${key}.fields.${fieldKey}`);
213
216
  })}
214
217
  </div>
@@ -219,7 +222,7 @@ const Group = withStyles((theme) => ({
219
222
  return (
220
223
  <div key={`checkbox-${label}`}>
221
224
  <p>{label}</p>
222
- {Object.keys(choices).map((choiceKey) => {
225
+ {Object.keys(choices).map(choiceKey => {
223
226
  return getTag(group, `${key}.${choiceKey}`, `${key}.choices.${choiceKey}`);
224
227
  })}
225
228
  </div>
@@ -234,7 +237,7 @@ const Group = withStyles((theme) => ({
234
237
  <div className={classes.group}>
235
238
  <div className={classes.groupHeader}>{label}</div>
236
239
 
237
- {Object.keys(group).map((key) => {
240
+ {Object.keys(group).map(key => {
238
241
  return content(group, key);
239
242
  })}
240
243
  </div>
@@ -247,17 +250,16 @@ export class Panel extends React.Component {
247
250
  configuration: PropTypes.object,
248
251
  groups: PropTypes.object,
249
252
  onChangeModel: PropTypes.func,
250
- onChangeConfiguration: PropTypes.func,
253
+ onChangeConfiguration: PropTypes.func
251
254
  };
252
255
 
253
256
  static defaultProps = {
254
257
  onChangeModel: () => {},
255
- onChangeConfiguration: () => {},
258
+ onChangeConfiguration: () => {}
256
259
  };
257
260
 
258
261
  change = (key, value, isConfigProperty = false) => {
259
262
  log('[changeModel]', key, value);
260
-
261
263
  const { onChangeModel, onChangeConfiguration } = this.props;
262
264
  const model = { ...this.props.model };
263
265
  const configuration = { ...this.props.configuration };
@@ -273,29 +275,22 @@ export class Panel extends React.Component {
273
275
 
274
276
  render() {
275
277
  const { groups, model, configuration } = this.props;
276
-
277
278
  log('render:', model);
278
279
 
279
- const renderedGroups = Object.keys(groups || {}).map((group) => {
280
- const showGroup = Object.entries(groups[group]).some(([propName, propVal]) => !!propVal);
281
-
282
- if (showGroup) {
283
- return (
280
+ return (
281
+ <div>
282
+ {Object.keys(groups).map(g => (
284
283
  <Group
285
- label={group}
286
- key={group}
284
+ label={g}
285
+ key={g}
287
286
  model={model}
288
287
  configuration={configuration}
289
- group={groups[group]}
288
+ group={groups[g]}
290
289
  onChange={this.change}
291
290
  />
292
- );
293
- }
294
-
295
- return null;
296
- });
297
-
298
- return <div>{renderedGroups}</div>;
291
+ ))}
292
+ </div>
293
+ );
299
294
  }
300
295
  }
301
296
 
@@ -3,14 +3,14 @@ import Radio from '@material-ui/core/Radio';
3
3
  import React from 'react';
4
4
  import { withStyles } from '@material-ui/core/styles';
5
5
 
6
- export default withStyles((theme) => ({
6
+ export default withStyles({
7
7
  label: {
8
8
  color: 'rgba(0, 0, 0, 0.89)',
9
- fontSize: theme.typography.fontSize - 2,
9
+ fontSize: '12px',
10
10
  left: '-5px',
11
- position: 'relative',
12
- },
13
- }))(({ label, value, checked, onChange, classes }) => (
11
+ position: 'relative'
12
+ }
13
+ })(({ label, value, checked, onChange, classes }) => (
14
14
  <FormControlLabel
15
15
  value={value}
16
16
  classes={classes}