@pie-lib/config-ui 12.0.0-beta.4 → 12.0.0-next.0

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 (120) hide show
  1. package/CHANGELOG.json +8 -1653
  2. package/CHANGELOG.md +540 -58
  3. package/LICENSE.md +5 -0
  4. package/NEXT.CHANGELOG.json +1 -0
  5. package/lib/alert-dialog.js +44 -20
  6. package/lib/alert-dialog.js.map +1 -1
  7. package/lib/checkbox.js +59 -61
  8. package/lib/checkbox.js.map +1 -1
  9. package/lib/choice-configuration/feedback-menu.js +30 -65
  10. package/lib/choice-configuration/feedback-menu.js.map +1 -1
  11. package/lib/choice-configuration/index.js +231 -244
  12. package/lib/choice-configuration/index.js.map +1 -1
  13. package/lib/choice-utils.js +7 -19
  14. package/lib/choice-utils.js.map +1 -1
  15. package/lib/feedback-config/feedback-selector.js +89 -115
  16. package/lib/feedback-config/feedback-selector.js.map +1 -1
  17. package/lib/feedback-config/group.js +28 -42
  18. package/lib/feedback-config/group.js.map +1 -1
  19. package/lib/feedback-config/index.js +55 -87
  20. package/lib/feedback-config/index.js.map +1 -1
  21. package/lib/form-section.js +32 -34
  22. package/lib/form-section.js.map +1 -1
  23. package/lib/help.js +41 -80
  24. package/lib/help.js.map +1 -1
  25. package/lib/index.js +2 -32
  26. package/lib/index.js.map +1 -1
  27. package/lib/input.js +24 -57
  28. package/lib/input.js.map +1 -1
  29. package/lib/inputs.js +62 -88
  30. package/lib/inputs.js.map +1 -1
  31. package/lib/langs.js +59 -102
  32. package/lib/langs.js.map +1 -1
  33. package/lib/layout/config-layout.js +95 -67
  34. package/lib/layout/config-layout.js.map +1 -1
  35. package/lib/layout/index.js +1 -4
  36. package/lib/layout/index.js.map +1 -1
  37. package/lib/layout/layout-contents.js +130 -75
  38. package/lib/layout/layout-contents.js.map +1 -1
  39. package/lib/layout/settings-box.js +28 -58
  40. package/lib/layout/settings-box.js.map +1 -1
  41. package/lib/mui-box/index.js +42 -58
  42. package/lib/mui-box/index.js.map +1 -1
  43. package/lib/number-text-field-custom.js +164 -152
  44. package/lib/number-text-field-custom.js.map +1 -1
  45. package/lib/number-text-field.js +87 -119
  46. package/lib/number-text-field.js.map +1 -1
  47. package/lib/radio-with-label.js +33 -26
  48. package/lib/radio-with-label.js.map +1 -1
  49. package/lib/settings/display-size.js +17 -33
  50. package/lib/settings/display-size.js.map +1 -1
  51. package/lib/settings/index.js +26 -46
  52. package/lib/settings/index.js.map +1 -1
  53. package/lib/settings/panel.js +202 -221
  54. package/lib/settings/panel.js.map +1 -1
  55. package/lib/settings/settings-radio-label.js +37 -29
  56. package/lib/settings/settings-radio-label.js.map +1 -1
  57. package/lib/settings/toggle.js +40 -33
  58. package/lib/settings/toggle.js.map +1 -1
  59. package/lib/tabs/index.js +26 -57
  60. package/lib/tabs/index.js.map +1 -1
  61. package/lib/tags-input/index.js +51 -100
  62. package/lib/tags-input/index.js.map +1 -1
  63. package/lib/two-choice.js +47 -91
  64. package/lib/two-choice.js.map +1 -1
  65. package/lib/with-stateful-model.js +11 -34
  66. package/lib/with-stateful-model.js.map +1 -1
  67. package/package.json +22 -11
  68. package/src/__tests__/alert-dialog.test.jsx +283 -0
  69. package/src/__tests__/checkbox.test.jsx +249 -0
  70. package/src/__tests__/choice-utils.test.js +12 -0
  71. package/src/__tests__/form-section.test.jsx +334 -0
  72. package/src/__tests__/help.test.jsx +184 -0
  73. package/src/__tests__/input.test.jsx +192 -0
  74. package/src/__tests__/langs.test.jsx +457 -0
  75. package/src/__tests__/number-text-field-custom.test.jsx +438 -0
  76. package/src/__tests__/number-text-field.test.jsx +341 -0
  77. package/src/__tests__/radio-with-label.test.jsx +259 -0
  78. package/src/__tests__/settings-panel.test.js +187 -0
  79. package/src/__tests__/settings.test.jsx +515 -0
  80. package/src/__tests__/tabs.test.jsx +193 -0
  81. package/src/__tests__/two-choice.test.js +110 -0
  82. package/src/__tests__/with-stateful-model.test.jsx +145 -0
  83. package/src/alert-dialog.jsx +31 -16
  84. package/src/checkbox.jsx +45 -39
  85. package/src/choice-configuration/__tests__/feedback-menu.test.jsx +163 -0
  86. package/src/choice-configuration/__tests__/index.test.jsx +234 -0
  87. package/src/choice-configuration/feedback-menu.jsx +15 -28
  88. package/src/choice-configuration/index.jsx +233 -182
  89. package/src/choice-utils.js +1 -1
  90. package/src/feedback-config/__tests__/feedback-config.test.jsx +141 -0
  91. package/src/feedback-config/__tests__/feedback-selector.test.jsx +107 -0
  92. package/src/feedback-config/feedback-selector.jsx +65 -60
  93. package/src/feedback-config/group.jsx +26 -29
  94. package/src/feedback-config/index.jsx +59 -47
  95. package/src/form-section.jsx +26 -18
  96. package/src/help.jsx +27 -36
  97. package/src/index.js +2 -5
  98. package/src/input.jsx +9 -9
  99. package/src/inputs.jsx +36 -50
  100. package/src/langs.jsx +57 -73
  101. package/src/layout/__tests__/config.layout.test.jsx +59 -0
  102. package/src/layout/__tests__/layout-content.test.jsx +3 -0
  103. package/src/layout/config-layout.jsx +70 -37
  104. package/src/layout/layout-contents.jsx +96 -39
  105. package/src/layout/settings-box.jsx +22 -21
  106. package/src/mui-box/index.jsx +37 -45
  107. package/src/number-text-field-custom.jsx +136 -81
  108. package/src/number-text-field.jsx +59 -37
  109. package/src/radio-with-label.jsx +28 -12
  110. package/src/settings/display-size.jsx +14 -13
  111. package/src/settings/index.js +20 -12
  112. package/src/settings/panel.jsx +147 -110
  113. package/src/settings/settings-radio-label.jsx +29 -13
  114. package/src/settings/toggle.jsx +39 -20
  115. package/src/tabs/index.jsx +15 -19
  116. package/src/tags-input/__tests__/index.test.jsx +113 -0
  117. package/src/tags-input/index.jsx +42 -47
  118. package/src/two-choice.jsx +19 -23
  119. package/src/with-stateful-model.jsx +5 -5
  120. package/README.md +0 -12
@@ -2,13 +2,20 @@ import Panel from './panel';
2
2
 
3
3
  export { Panel };
4
4
 
5
- export const toggle = (label, isConfigProperty = false) => ({
5
+ export const textField = (label, isConfigProperty = true) => ({
6
+ label,
7
+ type: 'textField',
8
+ isConfigProperty,
9
+ });
10
+
11
+ export const toggle = (label, isConfigProperty = false, disabled = false) => ({
6
12
  type: 'toggle',
7
13
  label,
8
- isConfigProperty
14
+ isConfigProperty,
15
+ disabled,
9
16
  });
10
17
 
11
- const toChoice = opt => {
18
+ const toChoice = (opt) => {
12
19
  if (typeof opt === 'string') {
13
20
  return { label: opt, value: opt };
14
21
  } else {
@@ -19,11 +26,12 @@ const toChoice = opt => {
19
26
  export const radio = function() {
20
27
  const args = Array.prototype.slice.call(arguments);
21
28
  const [label, choices, isConfigProperty = false] = args;
29
+
22
30
  return {
23
31
  type: 'radio',
24
32
  label,
25
- choices: choices && choices.map(o => toChoice(o)),
26
- isConfigProperty
33
+ choices: choices && choices.map((o) => toChoice(o)),
34
+ isConfigProperty,
27
35
  };
28
36
  };
29
37
 
@@ -32,7 +40,7 @@ export const dropdown = (label, choices, isConfigProperty = false) => {
32
40
  type: 'dropdown',
33
41
  label,
34
42
  choices,
35
- isConfigProperty
43
+ isConfigProperty,
36
44
  };
37
45
  };
38
46
 
@@ -40,18 +48,18 @@ export const numberField = (label, options, isConfigProperty = false) => ({
40
48
  ...options,
41
49
  label,
42
50
  type: 'numberField',
43
- isConfigProperty
51
+ isConfigProperty,
44
52
  });
45
53
 
46
54
  export const numberFields = (label, fields, isConfigProperty = false) => {
47
- Object.keys(fields).map(key => {
55
+ Object.keys(fields).map((key) => {
48
56
  fields[key] = numberField(fields[key].label, fields[key], isConfigProperty);
49
57
  });
50
58
 
51
59
  return {
52
60
  type: 'numberFields',
53
61
  label,
54
- fields
62
+ fields,
55
63
  };
56
64
  };
57
65
 
@@ -59,17 +67,17 @@ export const checkbox = (label, settings, isConfigProperty = false) => ({
59
67
  ...settings,
60
68
  label,
61
69
  type: 'checkbox',
62
- isConfigProperty
70
+ isConfigProperty,
63
71
  });
64
72
 
65
73
  export const checkboxes = (label, choices, isConfigProperty = false) => {
66
- Object.keys(choices).map(key => {
74
+ Object.keys(choices).map((key) => {
67
75
  choices[key] = checkbox(choices[key].label, choices[key], isConfigProperty);
68
76
  });
69
77
 
70
78
  return {
71
79
  type: 'checkboxes',
72
80
  label,
73
- choices
81
+ choices,
74
82
  };
75
83
  };
@@ -1,30 +1,31 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@material-ui/core/styles';
4
3
  import get from 'lodash/get';
5
4
  import set from 'lodash/set';
6
- import Select from '@material-ui/core/Select';
7
- import Input from '@material-ui/core/Input';
8
- import MenuItem from '@material-ui/core/MenuItem';
5
+ import { styled } from '@mui/material/styles';
6
+ import Select from '@mui/material/Select';
7
+ import Input from '@mui/material/Input';
8
+ import MenuItem from '@mui/material/MenuItem';
9
+ import Typography from '@mui/material/Typography';
9
10
  import debug from 'debug';
10
11
 
11
12
  import Toggle from './toggle';
12
- import TwoChoice from '../two-choice';
13
+ import { NChoice } from '../two-choice';
13
14
  import SettingsRadioLabel from './settings-radio-label';
14
- import { NumberTextField } from '../index';
15
+ import NumberTextField from '../number-text-field';
15
16
  import Checkbox from '../checkbox';
16
17
 
17
18
  const log = debug('pie-lib:config-ui:settings:panel');
18
19
 
19
20
  const labelValue = {
20
21
  label: PropTypes.string,
21
- value: PropTypes.string
22
+ value: PropTypes.string,
22
23
  };
23
24
 
24
25
  const baseTypes = {
25
26
  label: PropTypes.string,
26
27
  value: PropTypes.string,
27
- onChange: PropTypes.func
28
+ onChange: PropTypes.func,
28
29
  };
29
30
 
30
31
  const CheckboxChoice = ({ label, value, onChange }) => {
@@ -32,7 +33,7 @@ const CheckboxChoice = ({ label, value, onChange }) => {
32
33
  <Checkbox
33
34
  checked={value}
34
35
  label={label}
35
- onChange={event => {
36
+ onChange={(event) => {
36
37
  onChange(event.target.checked);
37
38
  }}
38
39
  />
@@ -42,19 +43,32 @@ const CheckboxChoice = ({ label, value, onChange }) => {
42
43
  CheckboxChoice.propTypes = {
43
44
  label: PropTypes.string,
44
45
  value: PropTypes.bool,
45
- onChange: PropTypes.func
46
+ onChange: PropTypes.func,
46
47
  };
47
48
 
48
- const Radio = ({ classes, label, value, onChange, choices }) => {
49
+ const StyledNChoice = styled(NChoice)(({ theme }) => ({
50
+ marginTop: theme.spacing(0.5),
51
+ paddingBottom: theme.spacing(0.5),
52
+ width: '100%',
53
+ '& > label': {
54
+ color: 'rgba(0, 0, 0, 0.89)',
55
+ transform: 'translate(0, 10px) scale(1)',
56
+ fontSize: '18px',
57
+ marginTop: theme.spacing(2.5),
58
+ },
59
+ '& > div': {
60
+ marginTop: theme.spacing(2.5),
61
+ },
62
+ }));
63
+
64
+ const Radio = ({ label, value, onChange, choices }) => {
49
65
  return (
50
- <TwoChoice
51
- className={classes.radioSettings}
52
- direction="vertical"
66
+ <StyledNChoice
67
+ direction="horizontal"
53
68
  customLabel={SettingsRadioLabel}
54
69
  value={value}
55
70
  header={label}
56
- one={choices[0]}
57
- two={choices[1]}
71
+ opts={choices}
58
72
  onChange={onChange}
59
73
  />
60
74
  );
@@ -62,99 +76,97 @@ const Radio = ({ classes, label, value, onChange, choices }) => {
62
76
 
63
77
  Radio.propTypes = { ...baseTypes, choices: PropTypes.arrayOf(PropTypes.shape(labelValue)) };
64
78
 
65
- const StyledRadio = withStyles({
66
- radioSettings: {
67
- marginTop: '4px',
68
- paddingBottom: '4px',
69
- width: '100%',
70
- '& > label': {
71
- color: 'rgba(0, 0, 0, 0.89)',
72
- transform: 'translate(0, 10px) scale(1)',
73
- fontSize: '14px'
74
- },
75
- '& > div': {
76
- marginTop: '20px'
77
- }
78
- },
79
- label: {
80
- display: 'none'
81
- }
82
- })(Radio);
79
+ const StyledRadio = Radio;
83
80
 
84
- const Dropdown = withStyles({
85
- label: {
86
- margin: 0,
87
- fontSize: '14px'
88
- },
89
- wrapper: {
90
- marginTop: '4px',
91
- border: '2px solid lightgrey',
92
- borderRadius: '4px',
93
- padding: '0 8px'
94
- }
95
- })(({ classes, label, value, onChange, choices = [] }) => {
81
+ const StyledLabel = styled('p')(({ theme }) => ({
82
+ margin: 0,
83
+ fontSize: theme.typography.fontSize,
84
+ }));
85
+
86
+ const StyledSelect = styled(Select)(({ theme }) => ({
87
+ marginTop: theme.spacing(0.5),
88
+ border: '2px solid lightgrey',
89
+ padding: `0 ${theme.spacing(1)}`,
90
+ borderRadius: '4px',
91
+ }));
92
+
93
+ const Dropdown = ({ label, value, onChange, choices = [] }) => {
94
+ const getItemLabel = (l) => (typeof l === 'string' ? l : l.label);
95
+ const getItemValue = (l) => (typeof l === 'string' ? l : l.value);
96
96
  return (
97
97
  <div>
98
- {label && <p className={classes.label}>{label}</p>}
99
- <Select
100
- className={classes.wrapper}
98
+ {label && <StyledLabel>{label}</StyledLabel>}
99
+ <StyledSelect
101
100
  value={value || (choices && choices[0])}
102
101
  onChange={({ target }) => onChange(target.value)}
103
102
  input={<Input id={`dropdown-${label}`} />}
104
103
  disableUnderline
104
+ MenuProps={{ transitionDuration: { enter: 225, exit: 195 } }}
105
105
  >
106
106
  {choices.map((l, index) => (
107
- <MenuItem key={index} value={l}>
108
- {l}
107
+ <MenuItem key={index} value={getItemValue(l)}>
108
+ {getItemLabel(l)}
109
109
  </MenuItem>
110
110
  ))}
111
- </Select>
111
+ </StyledSelect>
112
112
  </div>
113
113
  );
114
- });
114
+ };
115
115
 
116
116
  Dropdown.propTypes = { ...baseTypes, choices: PropTypes.arrayOf(PropTypes.string) };
117
117
 
118
- const NumberField = withStyles({
119
- field: {
120
- width: '35%',
121
- marginRight: '24px',
122
- marginTop: '8px'
123
- },
124
- wrapper: {
125
- marginTop: '4px',
118
+ const StyledTypography = styled(Typography)(({ theme }) => ({
119
+ marginRight: theme.spacing(3),
120
+ marginTop: theme.spacing(1),
121
+ }));
122
+
123
+ const TextField = ({ label }) => {
124
+ return <StyledTypography>{label}</StyledTypography>;
125
+ };
126
+
127
+ const StyledNumberTextField = styled(NumberTextField)(({ theme }) => ({
128
+ width: '35%',
129
+ marginRight: theme.spacing(3),
130
+ marginTop: theme.spacing(1),
131
+ '& .MuiInputBase-root': {
132
+ marginTop: theme.spacing(0.5),
126
133
  border: '2px solid lightgrey',
127
134
  borderRadius: '4px',
128
- padding: '0 8px'
129
- }
130
- })(({ classes, label, value, onChange = () => {}, suffix, min, max }) => {
135
+ padding: `0 ${theme.spacing(1)}`,
136
+ backgroundColor: 'transparent',
137
+ },
138
+ }));
139
+
140
+ const NumberField = ({ label, value, onChange = () => { }, suffix, min, max }) => {
131
141
  return (
132
- <NumberTextField
142
+ <StyledNumberTextField
143
+ variant={'standard'}
133
144
  label={label || 'Label'}
134
145
  value={value}
135
146
  max={max}
136
147
  min={min}
137
148
  onChange={(ev, value) => onChange(value)}
138
149
  suffix={suffix}
139
- className={classes.field}
140
150
  showErrorWhenOutsideRange
141
- inputClassName={classes.wrapper}
142
151
  disableUnderline
143
152
  />
144
153
  );
145
- });
154
+ };
146
155
 
147
156
  NumberField.propTypes = {
148
157
  ...baseTypes,
149
- classes: PropTypes.object,
150
158
  suffix: PropTypes.string,
151
159
  min: PropTypes.number,
152
160
  max: PropTypes.number,
153
- value: PropTypes.number
161
+ value: PropTypes.number,
154
162
  };
155
163
 
156
- const ToggleWrapper = ({ label, value, onChange }) => (
157
- <Toggle label={label} checked={!!value} toggle={onChange} />
164
+ TextField.propTypes = {
165
+ ...baseTypes,
166
+ };
167
+
168
+ const ToggleWrapper = ({ disabled, label, value, onChange }) => (
169
+ <Toggle label={label} checked={!!value} disabled={!!disabled} toggle={onChange} />
158
170
  );
159
171
 
160
172
  ToggleWrapper.propTypes = { ...baseTypes, value: PropTypes.bool };
@@ -164,25 +176,28 @@ const tagMap = {
164
176
  radio: StyledRadio,
165
177
  dropdown: Dropdown,
166
178
  numberField: NumberField,
167
- checkbox: CheckboxChoice
179
+ checkbox: CheckboxChoice,
180
+ textField: TextField,
168
181
  };
169
182
 
170
- const Group = withStyles(() => ({
171
- group: {
172
- margin: '0 0 25px 0'
173
- },
174
- groupHeader: {
175
- color: '#495B8F',
176
- fontSize: '16px',
177
- fontWeight: 600,
178
- marginBottom: '8px'
179
- },
180
- numberFields: {
181
- fontSize: '0.85rem',
182
- marginBottom: 0
183
- }
184
- }))(props => {
185
- const { classes, model, label, group, configuration, onChange } = props;
183
+ const StyledGroup = styled('div')(({ theme }) => ({
184
+ margin: `0 0 ${theme.spacing(2)} 0`,
185
+ }));
186
+
187
+ const StyledGroupHeader = styled('div')(({ theme }) => ({
188
+ color: '#495B8F',
189
+ fontSize: theme.typography.fontSize + 2,
190
+ fontWeight: 600,
191
+ marginBottom: theme.spacing(1),
192
+ }));
193
+
194
+ const StyledNumberFields = styled('p')(({ theme }) => ({
195
+ fontSize: theme.typography.fontSize,
196
+ marginBottom: 0,
197
+ }));
198
+
199
+ const Group = (props) => {
200
+ const { model, label, group, configuration, onChange } = props;
186
201
 
187
202
  /**
188
203
  * @param group - the group of settings
@@ -195,7 +210,7 @@ const Group = withStyles(() => ({
195
210
  const tagProps = { ...properties, key, value };
196
211
  const Tag = tagMap[tagProps.type];
197
212
 
198
- return <Tag key={key} {...tagProps} onChange={v => onChange(key, v, isConfigProperty)} />;
213
+ return <Tag key={key} {...tagProps} onChange={(v) => onChange(key, v, isConfigProperty)} />;
199
214
  };
200
215
 
201
216
  const content = (group, key) => {
@@ -210,8 +225,8 @@ const Group = withStyles(() => ({
210
225
  if (type === 'numberFields') {
211
226
  return (
212
227
  <div key={`numberField-${label}`}>
213
- <p className={classes.numberFields}>{label}</p>
214
- {Object.keys(fields).map(fieldKey => {
228
+ <StyledNumberFields>{label}</StyledNumberFields>
229
+ {Object.keys(fields).map((fieldKey) => {
215
230
  return getTag(group, `${key}.${fieldKey}`, `${key}.fields.${fieldKey}`);
216
231
  })}
217
232
  </div>
@@ -222,27 +237,35 @@ const Group = withStyles(() => ({
222
237
  return (
223
238
  <div key={`checkbox-${label}`}>
224
239
  <p>{label}</p>
225
- {Object.keys(choices).map(choiceKey => {
240
+ {Object.keys(choices).map((choiceKey) => {
226
241
  return getTag(group, `${key}.${choiceKey}`, `${key}.choices.${choiceKey}`);
227
242
  })}
228
243
  </div>
229
244
  );
230
245
  }
231
246
 
232
- // if type is toggle, radio, dropdown or numberField
247
+ // if type is toggle, radio, dropdown, numberField or numberText
233
248
  return getTag(group, key);
234
249
  };
235
250
 
236
251
  return (
237
- <div className={classes.group}>
238
- <div className={classes.groupHeader}>{label}</div>
252
+ <StyledGroup>
253
+ <StyledGroupHeader>{label}</StyledGroupHeader>
239
254
 
240
- {Object.keys(group).map(key => {
255
+ {Object.keys(group).map((key) => {
241
256
  return content(group, key);
242
257
  })}
243
- </div>
258
+ </StyledGroup>
244
259
  );
245
- });
260
+ };
261
+
262
+ Group.propTypes = {
263
+ model: PropTypes.object,
264
+ label: PropTypes.string,
265
+ group: PropTypes.object,
266
+ configuration: PropTypes.object,
267
+ onChange: PropTypes.func,
268
+ };
246
269
 
247
270
  export class Panel extends React.Component {
248
271
  static propTypes = {
@@ -250,16 +273,18 @@ export class Panel extends React.Component {
250
273
  configuration: PropTypes.object,
251
274
  groups: PropTypes.object,
252
275
  onChangeModel: PropTypes.func,
253
- onChangeConfiguration: PropTypes.func
276
+ onChangeConfiguration: PropTypes.func,
277
+ modal: PropTypes.object,
254
278
  };
255
279
 
256
280
  static defaultProps = {
257
- onChangeModel: () => {},
258
- onChangeConfiguration: () => {}
281
+ onChangeModel: () => { },
282
+ onChangeConfiguration: () => { },
259
283
  };
260
284
 
261
285
  change = (key, value, isConfigProperty = false) => {
262
286
  log('[changeModel]', key, value);
287
+
263
288
  const { onChangeModel, onChangeConfiguration } = this.props;
264
289
  const model = { ...this.props.model };
265
290
  const configuration = { ...this.props.configuration };
@@ -274,21 +299,33 @@ export class Panel extends React.Component {
274
299
  };
275
300
 
276
301
  render() {
277
- const { groups, model, configuration } = this.props;
302
+ const { groups, model, configuration, modal } = this.props;
303
+
278
304
  log('render:', model);
279
305
 
280
- return (
281
- <div>
282
- {Object.keys(groups).map(g => (
306
+ const renderedGroups = Object.keys(groups || {}).map((group) => {
307
+ const showGroup = Object.entries(groups[group]).some(([, propVal]) => !!propVal);
308
+
309
+ if (showGroup) {
310
+ return (
283
311
  <Group
284
- label={g}
285
- key={g}
312
+ label={group}
313
+ key={group}
286
314
  model={model}
287
315
  configuration={configuration}
288
- group={groups[g]}
316
+ group={groups[group]}
289
317
  onChange={this.change}
290
318
  />
291
- ))}
319
+ );
320
+ }
321
+
322
+ return null;
323
+ });
324
+
325
+ return (
326
+ <div>
327
+ {renderedGroups}
328
+ {modal}
292
329
  </div>
293
330
  );
294
331
  }
@@ -1,20 +1,36 @@
1
- import FormControlLabel from '@material-ui/core/FormControlLabel';
2
- import Radio from '@material-ui/core/Radio';
1
+ import FormControlLabel from '@mui/material/FormControlLabel';
2
+ import Radio from '@mui/material/Radio';
3
3
  import React from 'react';
4
- import { withStyles } from '@material-ui/core/styles';
4
+ import PropTypes from 'prop-types';
5
+ import { styled } from '@mui/material/styles';
6
+ import { color } from '@pie-lib/render-ui';
5
7
 
6
- export default withStyles({
7
- label: {
8
+ const StyledFormControlLabel = styled(FormControlLabel)(({ theme }) => ({
9
+ '& .MuiFormControlLabel-label': {
8
10
  color: 'rgba(0, 0, 0, 0.89)',
9
- fontSize: '12px',
11
+ fontSize: theme.typography.fontSize - 2,
10
12
  left: '-5px',
11
- position: 'relative'
12
- }
13
- })(({ label, value, checked, onChange, classes }) => (
14
- <FormControlLabel
13
+ position: 'relative',
14
+ },
15
+ }));
16
+
17
+ const StyledRadio = styled(Radio)(() => ({
18
+ color: `${color.tertiary()} !important`,
19
+ }));
20
+
21
+ const SettingsRadioLabel = ({ label, value, checked, onChange }) => (
22
+ <StyledFormControlLabel
15
23
  value={value}
16
- classes={classes}
17
- control={<Radio checked={checked} onChange={onChange} />}
24
+ control={<StyledRadio checked={checked} onChange={onChange} />}
18
25
  label={label}
19
26
  />
20
- ));
27
+ );
28
+
29
+ SettingsRadioLabel.propTypes = {
30
+ label: PropTypes.string,
31
+ value: PropTypes.string,
32
+ checked: PropTypes.bool,
33
+ onChange: PropTypes.func,
34
+ };
35
+
36
+ export default SettingsRadioLabel;
@@ -1,31 +1,50 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import InputLabel from '@material-ui/core/InputLabel';
4
- import { withStyles } from '@material-ui/core/styles';
5
- import Switch from '@material-ui/core/Switch';
3
+ import InputLabel from '@mui/material/InputLabel';
4
+ import { styled } from '@mui/material/styles';
5
+ import Switch from '@mui/material/Switch';
6
+ import { color } from '@pie-lib/render-ui';
6
7
 
7
- const Toggle = withStyles(theme => ({
8
- toggle: {
9
- display: 'flex',
10
- width: '100%',
11
- justifyContent: 'space-between'
8
+ const StyledToggle = styled('div')(() => ({
9
+ display: 'flex',
10
+ width: '100%',
11
+ justifyContent: 'space-between',
12
+ }));
13
+
14
+ const StyledInputLabel = styled(InputLabel)(({ theme }) => ({
15
+ color: 'rgba(0, 0, 0, 0.89)',
16
+ fontSize: theme.typography.fontSize,
17
+ paddingTop: theme.spacing(2),
18
+ }));
19
+
20
+ const StyledSwitch = styled(Switch)(({ checked }) => ({
21
+ '&.Mui-checked .MuiSwitch-thumb': {
22
+ color: `${color.tertiary()} !important`,
23
+ },
24
+ '&.Mui-checked .MuiSwitch-track': {
25
+ backgroundColor: `${color.tertiaryLight()} !important`,
12
26
  },
13
- label: {
14
- color: 'rgba(0, 0, 0, 0.89)',
15
- fontSize: '14px',
16
- paddingTop: theme.spacing.unit * 2
17
- }
18
- }))(({ checked, label, toggle, classes }) => (
19
- <div className={classes.toggle}>
20
- <InputLabel className={classes.label}>{label}</InputLabel>
21
- <Switch checked={checked} onChange={e => toggle(e.target.checked)} />
22
- </div>
23
- ));
27
+ '& .MuiSwitch-track': {
28
+ backgroundColor: checked ? `${color.tertiaryLight()} !important` : undefined,
29
+ },
30
+ }));
31
+
32
+ const Toggle = ({ checked, disabled, label, toggle }) => (
33
+ <StyledToggle>
34
+ <StyledInputLabel>{label}</StyledInputLabel>
35
+ <StyledSwitch
36
+ checked={checked}
37
+ disabled={disabled}
38
+ onChange={(e) => toggle(e.target.checked)}
39
+ />
40
+ </StyledToggle>
41
+ );
24
42
 
25
43
  Toggle.propTypes = {
26
44
  checked: PropTypes.bool,
45
+ disabled: PropTypes.bool,
27
46
  label: PropTypes.string.isRequired,
28
- toggle: PropTypes.func.isRequired
47
+ toggle: PropTypes.func.isRequired,
29
48
  };
30
49
 
31
50
  export default Toggle;