@pie-lib/config-ui 11.30.0-mui-update.0 → 11.30.1-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 (105) hide show
  1. package/CHANGELOG.md +12 -9
  2. package/lib/__tests__/choice-utils.test.js +16 -0
  3. package/lib/__tests__/langs.test.js +55 -0
  4. package/lib/__tests__/number-text-field.test.js +128 -0
  5. package/lib/__tests__/settings-panel.test.js +201 -0
  6. package/lib/__tests__/two-choice.test.js +33 -0
  7. package/lib/alert-dialog.js +42 -23
  8. package/lib/alert-dialog.js.map +1 -1
  9. package/lib/checkbox.js +71 -56
  10. package/lib/checkbox.js.map +1 -1
  11. package/lib/choice-configuration/__tests__/feedback-menu.test.js +20 -0
  12. package/lib/choice-configuration/__tests__/index.test.js +119 -0
  13. package/lib/choice-configuration/feedback-menu.js +63 -24
  14. package/lib/choice-configuration/feedback-menu.js.map +1 -1
  15. package/lib/choice-configuration/index.js +257 -201
  16. package/lib/choice-configuration/index.js.map +1 -1
  17. package/lib/choice-utils.js +18 -6
  18. package/lib/choice-utils.js.map +1 -1
  19. package/lib/feedback-config/__tests__/feedback-config.test.js +78 -0
  20. package/lib/feedback-config/__tests__/feedback-selector.test.js +71 -0
  21. package/lib/feedback-config/feedback-selector.js +114 -77
  22. package/lib/feedback-config/feedback-selector.js.map +1 -1
  23. package/lib/feedback-config/group.js +40 -26
  24. package/lib/feedback-config/group.js.map +1 -1
  25. package/lib/feedback-config/index.js +90 -38
  26. package/lib/feedback-config/index.js.map +1 -1
  27. package/lib/form-section.js +33 -24
  28. package/lib/form-section.js.map +1 -1
  29. package/lib/help.js +80 -39
  30. package/lib/help.js.map +1 -1
  31. package/lib/index.js +31 -1
  32. package/lib/index.js.map +1 -1
  33. package/lib/input.js +54 -21
  34. package/lib/input.js.map +1 -1
  35. package/lib/inputs.js +95 -61
  36. package/lib/inputs.js.map +1 -1
  37. package/lib/langs.js +100 -56
  38. package/lib/langs.js.map +1 -1
  39. package/lib/layout/__tests__/config.layout.test.js +33 -0
  40. package/lib/layout/__tests__/layout-content.test.js +6 -0
  41. package/lib/layout/config-layout.js +99 -48
  42. package/lib/layout/config-layout.js.map +1 -1
  43. package/lib/layout/index.js +3 -0
  44. package/lib/layout/index.js.map +1 -1
  45. package/lib/layout/layout-contents.js +101 -72
  46. package/lib/layout/layout-contents.js.map +1 -1
  47. package/lib/layout/settings-box.js +56 -27
  48. package/lib/layout/settings-box.js.map +1 -1
  49. package/lib/mui-box/index.js +57 -41
  50. package/lib/mui-box/index.js.map +1 -1
  51. package/lib/number-text-field-custom.js +161 -79
  52. package/lib/number-text-field-custom.js.map +1 -1
  53. package/lib/number-text-field.js +115 -57
  54. package/lib/number-text-field.js.map +1 -1
  55. package/lib/radio-with-label.js +31 -23
  56. package/lib/radio-with-label.js.map +1 -1
  57. package/lib/settings/display-size.js +32 -16
  58. package/lib/settings/display-size.js.map +1 -1
  59. package/lib/settings/index.js +47 -14
  60. package/lib/settings/index.js.map +1 -1
  61. package/lib/settings/panel.js +228 -142
  62. package/lib/settings/panel.js.map +1 -1
  63. package/lib/settings/settings-radio-label.js +30 -21
  64. package/lib/settings/settings-radio-label.js.map +1 -1
  65. package/lib/settings/toggle.js +46 -34
  66. package/lib/settings/toggle.js.map +1 -1
  67. package/lib/tabs/index.js +57 -22
  68. package/lib/tabs/index.js.map +1 -1
  69. package/lib/tags-input/__tests__/index.test.js +88 -0
  70. package/lib/tags-input/index.js +99 -50
  71. package/lib/tags-input/index.js.map +1 -1
  72. package/lib/two-choice.js +90 -46
  73. package/lib/two-choice.js.map +1 -1
  74. package/lib/with-stateful-model.js +31 -8
  75. package/lib/with-stateful-model.js.map +1 -1
  76. package/package.json +10 -12
  77. package/src/__tests__/number-text-field.test.jsx +1 -1
  78. package/src/alert-dialog.jsx +18 -14
  79. package/src/checkbox.jsx +46 -42
  80. package/src/choice-configuration/feedback-menu.jsx +5 -5
  81. package/src/choice-configuration/index.jsx +193 -205
  82. package/src/feedback-config/feedback-selector.jsx +53 -51
  83. package/src/feedback-config/group.jsx +22 -21
  84. package/src/feedback-config/index.jsx +29 -27
  85. package/src/form-section.jsx +18 -18
  86. package/src/help.jsx +28 -20
  87. package/src/input.jsx +1 -1
  88. package/src/inputs.jsx +50 -34
  89. package/src/langs.jsx +46 -40
  90. package/src/layout/config-layout.jsx +36 -25
  91. package/src/layout/layout-contents.jsx +34 -34
  92. package/src/layout/settings-box.jsx +19 -16
  93. package/src/mui-box/index.jsx +43 -35
  94. package/src/number-text-field-custom.jsx +36 -30
  95. package/src/number-text-field.jsx +30 -22
  96. package/src/radio-with-label.jsx +13 -17
  97. package/src/settings/display-size.jsx +11 -12
  98. package/src/settings/panel.jsx +89 -83
  99. package/src/settings/settings-radio-label.jsx +13 -17
  100. package/src/settings/toggle.jsx +29 -29
  101. package/src/tabs/index.jsx +8 -8
  102. package/src/tags-input/index.jsx +38 -35
  103. package/src/two-choice.jsx +19 -15
  104. package/LICENSE.md +0 -5
  105. package/NEXT.CHANGELOG.json +0 -1
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { styled } from '@mui/material/styles';
3
+ import { withStyles } from '@material-ui/core/styles';
4
4
  import get from 'lodash/get';
5
5
  import set from 'lodash/set';
6
- import Select from '@mui/material/Select';
7
- import Input from '@mui/material/Input';
8
- import MenuItem from '@mui/material/MenuItem';
6
+ import Select from '@material-ui/core/Select';
7
+ import Input from '@material-ui/core/Input';
8
+ import MenuItem from '@material-ui/core/MenuItem';
9
9
  import debug from 'debug';
10
10
 
11
11
  import Toggle from './toggle';
@@ -13,7 +13,7 @@ import { NChoice } from '../two-choice';
13
13
  import SettingsRadioLabel from './settings-radio-label';
14
14
  import NumberTextField from '../number-text-field';
15
15
  import Checkbox from '../checkbox';
16
- import Typography from '@mui/material/Typography';
16
+ import Typography from '@material-ui/core/Typography';
17
17
 
18
18
  const log = debug('pie-lib:config-ui:settings:panel');
19
19
 
@@ -46,23 +46,10 @@ CheckboxChoice.propTypes = {
46
46
  onChange: PropTypes.func,
47
47
  };
48
48
 
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: '14px',
57
- },
58
- '& > div': {
59
- marginTop: theme.spacing(2.5),
60
- },
61
- }));
62
-
63
- const Radio = ({ label, value, onChange, choices }) => {
49
+ const Radio = ({ classes, label, value, onChange, choices }) => {
64
50
  return (
65
- <StyledNChoice
51
+ <NChoice
52
+ className={classes.radioSettings}
66
53
  direction="horizontal"
67
54
  customLabel={SettingsRadioLabel}
68
55
  value={value}
@@ -75,27 +62,44 @@ const Radio = ({ label, value, onChange, choices }) => {
75
62
 
76
63
  Radio.propTypes = { ...baseTypes, choices: PropTypes.arrayOf(PropTypes.shape(labelValue)) };
77
64
 
78
- const StyledRadio = Radio;
79
-
80
- const StyledLabel = styled('p')(({ theme }) => ({
81
- margin: 0,
82
- fontSize: theme.typography.fontSize,
83
- }));
84
-
85
- const StyledSelect = styled(Select)(({ theme }) => ({
86
- marginTop: theme.spacing(0.5),
87
- border: '2px solid lightgrey',
88
- borderRadius: '4px',
89
- padding: `0 ${theme.spacing(1)}px`,
90
- }));
65
+ const StyledRadio = withStyles((theme) => ({
66
+ radioSettings: {
67
+ marginTop: theme.spacing.unit / 2,
68
+ paddingBottom: theme.spacing.unit / 2,
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: theme.spacing.unit * 2.5,
77
+ },
78
+ },
79
+ label: {
80
+ display: 'none',
81
+ },
82
+ }))(Radio);
91
83
 
92
- const Dropdown = ({ label, value, onChange, choices = [] }) => {
84
+ const Dropdown = withStyles((theme) => ({
85
+ label: {
86
+ margin: 0,
87
+ fontSize: theme.typography.fontSize,
88
+ },
89
+ wrapper: {
90
+ marginTop: theme.spacing.unit / 2,
91
+ border: '2px solid lightgrey',
92
+ borderRadius: '4px',
93
+ padding: `0 ${theme.spacing.unit}px`,
94
+ },
95
+ }))(({ classes, label, value, onChange, choices = [] }) => {
93
96
  const getItemLabel = (l) => (typeof l === 'string' ? l : l.label);
94
97
  const getItemValue = (l) => (typeof l === 'string' ? l : l.value);
95
98
  return (
96
99
  <div>
97
- {label && <StyledLabel>{label}</StyledLabel>}
98
- <StyledSelect
100
+ {label && <p className={classes.label}>{label}</p>}
101
+ <Select
102
+ className={classes.wrapper}
99
103
  value={value || (choices && choices[0])}
100
104
  onChange={({ target }) => onChange(target.value)}
101
105
  input={<Input id={`dropdown-${label}`} />}
@@ -106,51 +110,55 @@ const Dropdown = ({ label, value, onChange, choices = [] }) => {
106
110
  {getItemLabel(l)}
107
111
  </MenuItem>
108
112
  ))}
109
- </StyledSelect>
113
+ </Select>
110
114
  </div>
111
115
  );
112
- };
116
+ });
113
117
 
114
118
  Dropdown.propTypes = { ...baseTypes, choices: PropTypes.arrayOf(PropTypes.string) };
115
119
 
116
- const StyledTypography = styled(Typography)(({ theme }) => ({
117
- marginRight: theme.spacing(3),
118
- marginTop: theme.spacing(1),
119
- }));
120
-
121
- const TextField = ({ label }) => {
122
- return <StyledTypography>{label}</StyledTypography>;
123
- };
124
-
125
- const StyledNumberTextField = styled(NumberTextField)(({ theme }) => ({
126
- width: '35%',
127
- marginRight: theme.spacing(3),
128
- marginTop: theme.spacing(1),
129
- '& .MuiInputBase-root': {
130
- marginTop: theme.spacing(0.5),
120
+ const TextField = withStyles((theme) => ({
121
+ field: {
122
+ marginRight: theme.spacing.unit * 3,
123
+ marginTop: theme.spacing.unit,
124
+ },
125
+ }))(({ classes, label }) => {
126
+ return <Typography className={classes.field}>{label}</Typography>;
127
+ });
128
+
129
+ const NumberField = withStyles((theme) => ({
130
+ field: {
131
+ width: '35%',
132
+ marginRight: theme.spacing.unit * 3,
133
+ marginTop: theme.spacing.unit,
134
+ },
135
+ wrapper: {
136
+ marginTop: theme.spacing.unit / 2,
131
137
  border: '2px solid lightgrey',
132
138
  borderRadius: '4px',
133
- padding: `0 ${theme.spacing(1)}px`,
139
+ padding: `0 ${theme.spacing.unit}px`,
134
140
  },
135
- }));
136
-
137
- const NumberField = ({ label, value, onChange = () => {}, suffix, min, max }) => {
141
+ }))(({ classes, label, value, onChange = () => {}, suffix, min, max }) => {
138
142
  return (
139
- <StyledNumberTextField
143
+ <NumberTextField
140
144
  label={label || 'Label'}
141
145
  value={value}
142
146
  max={max}
143
147
  min={min}
144
148
  onChange={(ev, value) => onChange(value)}
145
149
  suffix={suffix}
150
+ className={classes.field}
146
151
  showErrorWhenOutsideRange
152
+ inputClassName={classes.wrapper}
147
153
  disableUnderline
154
+ classes={classes}
148
155
  />
149
156
  );
150
- };
157
+ });
151
158
 
152
159
  NumberField.propTypes = {
153
160
  ...baseTypes,
161
+ classes: PropTypes.object,
154
162
  suffix: PropTypes.string,
155
163
  min: PropTypes.number,
156
164
  max: PropTypes.number,
@@ -176,24 +184,22 @@ const tagMap = {
176
184
  textField: TextField,
177
185
  };
178
186
 
179
- const StyledGroup = styled('div')(({ theme }) => ({
180
- margin: `0 0 ${theme.spacing(2)}px 0`,
181
- }));
182
-
183
- const StyledGroupHeader = styled('div')(({ theme }) => ({
184
- color: '#495B8F',
185
- fontSize: theme.typography.fontSize + 2,
186
- fontWeight: 600,
187
- marginBottom: theme.spacing(1),
188
- }));
189
-
190
- const StyledNumberFields = styled('p')(({ theme }) => ({
191
- fontSize: theme.typography.fontSize,
192
- marginBottom: 0,
193
- }));
194
-
195
- const Group = (props) => {
196
- const { model, label, group, configuration, onChange } = props;
187
+ const Group = withStyles((theme) => ({
188
+ group: {
189
+ margin: `0 0 ${theme.spacing.unit * 2}px 0`,
190
+ },
191
+ groupHeader: {
192
+ color: '#495B8F',
193
+ fontSize: theme.typography.fontSize + 2,
194
+ fontWeight: 600,
195
+ marginBottom: theme.spacing.unit,
196
+ },
197
+ numberFields: {
198
+ fontSize: theme.typography.fontSize,
199
+ marginBottom: 0,
200
+ },
201
+ }))((props) => {
202
+ const { classes, model, label, group, configuration, onChange } = props;
197
203
 
198
204
  /**
199
205
  * @param group - the group of settings
@@ -221,7 +227,7 @@ const Group = (props) => {
221
227
  if (type === 'numberFields') {
222
228
  return (
223
229
  <div key={`numberField-${label}`}>
224
- <StyledNumberFields>{label}</StyledNumberFields>
230
+ <p className={classes.numberFields}>{label}</p>
225
231
  {Object.keys(fields).map((fieldKey) => {
226
232
  return getTag(group, `${key}.${fieldKey}`, `${key}.fields.${fieldKey}`);
227
233
  })}
@@ -245,15 +251,15 @@ const Group = (props) => {
245
251
  };
246
252
 
247
253
  return (
248
- <StyledGroup>
249
- <StyledGroupHeader>{label}</StyledGroupHeader>
254
+ <div className={classes.group}>
255
+ <div className={classes.groupHeader}>{label}</div>
250
256
 
251
257
  {Object.keys(group).map((key) => {
252
258
  return content(group, key);
253
259
  })}
254
- </StyledGroup>
260
+ </div>
255
261
  );
256
- };
262
+ });
257
263
 
258
264
  export class Panel extends React.Component {
259
265
  static propTypes = {
@@ -1,28 +1,24 @@
1
- import FormControlLabel from '@mui/material/FormControlLabel';
2
- import Radio from '@mui/material/Radio';
1
+ import FormControlLabel from '@material-ui/core/FormControlLabel';
2
+ import Radio from '@material-ui/core/Radio';
3
3
  import React from 'react';
4
- import { styled } from '@mui/material/styles';
4
+ import { withStyles } from '@material-ui/core/styles';
5
5
  import { color } from '@pie-lib/render-ui';
6
6
 
7
- const StyledFormControlLabel = styled(FormControlLabel)(({ theme }) => ({
8
- '& .MuiFormControlLabel-label': {
7
+ export default withStyles((theme) => ({
8
+ label: {
9
9
  color: 'rgba(0, 0, 0, 0.89)',
10
10
  fontSize: theme.typography.fontSize - 2,
11
11
  left: '-5px',
12
12
  position: 'relative',
13
13
  },
14
- }));
15
-
16
- const StyledRadio = styled(Radio)(() => ({
17
- color: `${color.tertiary()} !important`,
18
- }));
19
-
20
- const SettingsRadioLabel = ({ label, value, checked, onChange }) => (
21
- <StyledFormControlLabel
14
+ customColor: {
15
+ color: `${color.tertiary()} !important`,
16
+ },
17
+ }))(({ label, value, checked, onChange, classes }) => (
18
+ <FormControlLabel
22
19
  value={value}
23
- control={<StyledRadio checked={checked} onChange={onChange} />}
20
+ classes={{ label: classes.label }}
21
+ control={<Radio className={classes.customColor} checked={checked} onChange={onChange} />}
24
22
  label={label}
25
23
  />
26
- );
27
-
28
- export default SettingsRadioLabel;
24
+ ));
@@ -1,44 +1,44 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import InputLabel from '@mui/material/InputLabel';
4
- import { styled } from '@mui/material/styles';
5
- import Switch from '@mui/material/Switch';
3
+ import InputLabel from '@material-ui/core/InputLabel';
4
+ import { withStyles } from '@material-ui/core/styles';
5
+ import Switch from '@material-ui/core/Switch';
6
+ import classNames from 'classnames';
6
7
  import { color } from '@pie-lib/render-ui';
7
8
 
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': {
9
+ const Toggle = withStyles((theme) => ({
10
+ toggle: {
11
+ display: 'flex',
12
+ width: '100%',
13
+ justifyContent: 'space-between',
14
+ },
15
+ label: {
16
+ color: 'rgba(0, 0, 0, 0.89)',
17
+ fontSize: theme.typography.fontSize,
18
+ paddingTop: theme.spacing.unit * 2,
19
+ },
20
+ checkedThumb: {
22
21
  color: `${color.tertiary()} !important`,
23
22
  },
24
- '&.Mui-checked .MuiSwitch-track': {
23
+ checkedBar: {
25
24
  backgroundColor: `${color.tertiaryLight()} !important`,
26
25
  },
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
26
+ }))(({ checked, disabled, label, toggle, classes }) => (
27
+ <div className={classes.toggle}>
28
+ <InputLabel className={classes.label}>{label}</InputLabel>
29
+ <Switch
30
+ classes={{
31
+ checked: classNames(classes.checkedThumb),
32
+ bar: classNames({
33
+ [classes.checkedBar]: checked,
34
+ }),
35
+ }}
36
36
  checked={checked}
37
37
  disabled={disabled}
38
38
  onChange={(e) => toggle(e.target.checked)}
39
39
  />
40
- </StyledToggle>
41
- );
40
+ </div>
41
+ ));
42
42
 
43
43
  Toggle.propTypes = {
44
44
  checked: PropTypes.bool,
@@ -1,14 +1,13 @@
1
1
  import React from 'react';
2
2
 
3
- import MuiTabs from '@mui/material/Tabs';
4
- import MuiTab from '@mui/material/Tab';
3
+ import MuiTabs from '@material-ui/core/Tabs';
4
+ import MuiTab from '@material-ui/core/Tab';
5
5
  import PropTypes from 'prop-types';
6
- import { styled } from '@mui/material/styles';
7
-
8
- const StyledMuiTab = styled(MuiTab)(() => ({}));
6
+ import { withStyles } from '@material-ui/core';
9
7
 
10
8
  export class Tabs extends React.Component {
11
9
  static propTypes = {
10
+ classes: PropTypes.object,
12
11
  className: PropTypes.string,
13
12
  contentClassName: PropTypes.string,
14
13
  contentStyle: PropTypes.object,
@@ -26,13 +25,14 @@ export class Tabs extends React.Component {
26
25
 
27
26
  render() {
28
27
  const { value } = this.state;
29
- const { children, className, contentClassName, contentStyle = {} } = this.props;
28
+ const { children, className, contentClassName, contentStyle = {}, classes } = this.props;
29
+ const tabClasses = { root: classes.tabRoot };
30
30
 
31
31
  return (
32
32
  <div className={className}>
33
33
  <MuiTabs indicatorColor="primary" value={value} onChange={this.handleChange}>
34
34
  {React.Children.map(children, (c, index) =>
35
- c && c.props.title ? <StyledMuiTab key={index} label={c.props.title} /> : null,
35
+ c && c.props.title ? <MuiTab classes={tabClasses} key={index} label={c.props.title} /> : null,
36
36
  )}
37
37
  </MuiTabs>
38
38
 
@@ -44,4 +44,4 @@ export class Tabs extends React.Component {
44
44
  }
45
45
  }
46
46
 
47
- export default Tabs;
47
+ export default withStyles(() => ({ tabRoot: {} }))(Tabs);
@@ -1,48 +1,27 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { styled } from '@mui/material/styles';
3
+ import { withStyles } from '@material-ui/core/styles';
4
4
  import uniq from 'lodash/uniq';
5
- import Chip from '@mui/material/Chip';
5
+ import Chip from '@material-ui/core/Chip';
6
6
  import MuiBox from '../mui-box';
7
7
 
8
8
  const ENTER = 13;
9
9
 
10
- const StyledChip = styled(Chip)(() => ({
11
- padding: '0px',
12
- margin: '1px',
13
- }));
14
-
15
- const Tag = ({ label, onDelete }) => <StyledChip label={label} onDelete={onDelete} />;
10
+ const Tag = withStyles(() => ({
11
+ tag: {
12
+ padding: '0px',
13
+ margin: '1px',
14
+ },
15
+ }))(({ classes, label, onDelete }) => <Chip className={classes.tag} label={label} onDelete={onDelete} />);
16
16
 
17
17
  Tag.propTypes = {
18
18
  label: PropTypes.string.isRequired,
19
19
  onDelete: PropTypes.func.isRequired,
20
20
  };
21
21
 
22
- const StyledTagsInput = styled('div')(({ theme }) => ({
23
- border: `0px solid ${theme.palette.background.paper}`,
24
- display: 'flex',
25
- flexWrap: 'wrap',
26
- }));
27
-
28
- const StyledInput = styled('input')(({ theme }) => ({
29
- padding: '2px',
30
- margin: '1px',
31
- minWidth: '30px',
32
- width: '100%',
33
- flex: '1',
34
- border: `0px solid ${theme.palette.background.paper}`,
35
- height: '28px',
36
- fontSize: theme.typography.fontSize,
37
- fontFamily: theme.typography.fontFamily,
38
- outline: 'none',
39
- '&:focus': {
40
- outline: 'none',
41
- },
42
- }));
43
-
44
22
  export class TagsInput extends React.Component {
45
23
  static propTypes = {
24
+ classes: PropTypes.object.isRequired,
46
25
  tags: PropTypes.arrayOf(PropTypes.string).isRequired,
47
26
  onChange: PropTypes.func.isRequired,
48
27
  };
@@ -91,26 +70,50 @@ export class TagsInput extends React.Component {
91
70
  };
92
71
 
93
72
  render() {
94
- const { tags } = this.props;
73
+ const { classes, tags } = this.props;
95
74
  return (
96
75
  <MuiBox focused={this.state.focused}>
97
- <StyledTagsInput>
76
+ <div className={classes.tagsInput}>
98
77
  {(tags || []).map((t, index) => (
99
78
  <Tag key={index} label={t} onDelete={() => this.deleteTag(t)} />
100
79
  ))}
101
- <StyledInput
80
+ <input
102
81
  ref={(r) => (this.input = r)}
103
82
  onKeyDown={this.onKeyDown}
104
83
  onChange={this.onChange}
84
+ className={classes.input}
105
85
  value={this.state.value}
106
86
  onFocus={this.onFocus}
107
87
  onBlur={this.onBlur}
108
88
  type="text"
109
89
  />
110
- </StyledTagsInput>
90
+ </div>
111
91
  </MuiBox>
112
92
  );
113
93
  }
114
94
  }
115
95
 
116
- export default TagsInput;
96
+ const styles = (theme) => ({
97
+ tagsInput: {
98
+ border: `0px solid ${theme.palette.background.paper}`,
99
+ display: 'flex',
100
+ flexWrap: 'wrap',
101
+ },
102
+ input: {
103
+ padding: '2px',
104
+ margin: '1px',
105
+ minWidth: '30px',
106
+ width: '100%',
107
+ flex: '1',
108
+ border: `0px solid ${theme.palette.background.paper}`,
109
+ height: '28px',
110
+ fontSize: theme.typography.fontSize,
111
+ fontFamily: theme.typography.fontFamily,
112
+ outline: 'none',
113
+ '&:focus': {
114
+ outline: 'none',
115
+ },
116
+ },
117
+ });
118
+
119
+ export default withStyles(styles)(TagsInput);
@@ -2,19 +2,22 @@ import { InputContainer } from '@pie-lib/render-ui';
2
2
  import PropTypes from 'prop-types';
3
3
  import RadioWithLabel from './radio-with-label';
4
4
  import React from 'react';
5
- import { styled } from '@mui/material/styles';
5
+ import classNames from 'classnames';
6
+ import { withStyles } from '@material-ui/core/styles';
6
7
 
7
- const StyledGroup = styled('div')(({ theme, direction }) => ({
8
- display: 'flex',
9
- flexWrap: 'wrap',
10
- paddingLeft: 0,
11
- marginTop: theme.spacing(1),
12
- ...(direction === 'vertical' && {
8
+ const styles = (theme) => ({
9
+ group: {
10
+ display: 'flex',
11
+ flexWrap: 'wrap',
12
+ paddingLeft: 0,
13
+ marginTop: theme.spacing.unit,
14
+ },
15
+ vertical: {
13
16
  flexDirection: 'column',
14
- }),
15
- }));
17
+ },
18
+ });
16
19
 
17
- class NChoice extends React.Component {
20
+ class RawNChoice extends React.Component {
18
21
  static propTypes = {
19
22
  header: PropTypes.string.isRequired,
20
23
  className: PropTypes.string,
@@ -23,6 +26,7 @@ class NChoice extends React.Component {
23
26
  value: PropTypes.string,
24
27
  onChange: PropTypes.func.isRequired,
25
28
  direction: PropTypes.oneOf(['horizontal', 'vertical']),
29
+ classes: PropTypes.object.isRequired,
26
30
  };
27
31
 
28
32
  handleChange = (event) => {
@@ -30,7 +34,7 @@ class NChoice extends React.Component {
30
34
  };
31
35
 
32
36
  render() {
33
- const { header, className, customLabel, opts, value, direction } = this.props;
37
+ const { header, className, classes, customLabel, opts, value, direction } = this.props;
34
38
 
35
39
  const preppedOpts = opts.map((o) => {
36
40
  return typeof o === 'string' ? { label: o, value: o } : o;
@@ -39,7 +43,7 @@ class NChoice extends React.Component {
39
43
 
40
44
  return (
41
45
  <InputContainer label={header} className={className}>
42
- <StyledGroup direction={direction}>
46
+ <div className={classNames(classes.group, classes[direction])}>
43
47
  {preppedOpts.map((o, index) => (
44
48
  <LabelComponent
45
49
  value={o.value}
@@ -49,13 +53,13 @@ class NChoice extends React.Component {
49
53
  label={o.label}
50
54
  />
51
55
  ))}
52
- </StyledGroup>
56
+ </div>
53
57
  </InputContainer>
54
58
  );
55
59
  }
56
60
  }
57
61
 
58
- export { NChoice };
62
+ export const NChoice = withStyles(styles)(RawNChoice);
59
63
 
60
64
  const labelValue = PropTypes.shape({ label: PropTypes.string, value: PropTypes.string });
61
65
 
@@ -87,4 +91,4 @@ class TwoChoice extends React.Component {
87
91
  }
88
92
  }
89
93
 
90
- export default TwoChoice;
94
+ export default withStyles(styles)(TwoChoice);
package/LICENSE.md DELETED
@@ -1,5 +0,0 @@
1
- Copyright 2019 CoreSpring Inc
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
-
5
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -1 +0,0 @@
1
- []