@pie-lib/config-ui 11.9.25-next.0 → 11.9.25-next.1595

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 (64) hide show
  1. package/CHANGELOG.json +8 -1653
  2. package/CHANGELOG.md +131 -39
  3. package/NEXT.CHANGELOG.json +1 -0
  4. package/lib/alert-dialog.js +38 -7
  5. package/lib/alert-dialog.js.map +1 -1
  6. package/lib/checkbox.js +6 -1
  7. package/lib/checkbox.js.map +1 -1
  8. package/lib/choice-configuration/index.js +19 -8
  9. package/lib/choice-configuration/index.js.map +1 -1
  10. package/lib/feedback-config/feedback-selector.js +0 -0
  11. package/lib/inputs.js +8 -2
  12. package/lib/inputs.js.map +1 -1
  13. package/lib/layout/config-layout.js +27 -10
  14. package/lib/layout/config-layout.js.map +1 -1
  15. package/lib/number-text-field-custom.js +134 -43
  16. package/lib/number-text-field-custom.js.map +1 -1
  17. package/lib/number-text-field.js +17 -18
  18. package/lib/number-text-field.js.map +1 -1
  19. package/lib/radio-with-label.js +9 -1
  20. package/lib/radio-with-label.js.map +1 -1
  21. package/lib/settings/index.js +3 -1
  22. package/lib/settings/index.js.map +1 -1
  23. package/lib/settings/panel.js +7 -4
  24. package/lib/settings/panel.js.map +1 -1
  25. package/lib/settings/settings-radio-label.js +9 -1
  26. package/lib/settings/settings-radio-label.js.map +1 -1
  27. package/lib/settings/toggle.js +18 -0
  28. package/lib/settings/toggle.js.map +1 -1
  29. package/package.json +8 -5
  30. package/src/__tests__/__snapshots__/langs.test.jsx.snap +32 -0
  31. package/src/__tests__/__snapshots__/settings-panel.test.js.snap +115 -0
  32. package/src/__tests__/__snapshots__/two-choice.test.js.snap +171 -0
  33. package/src/__tests__/choice-utils.test.js +12 -0
  34. package/src/__tests__/langs.test.jsx +37 -0
  35. package/src/__tests__/number-text-field.test.jsx +148 -0
  36. package/src/__tests__/settings-panel.test.js +204 -0
  37. package/src/__tests__/two-choice.test.js +24 -0
  38. package/src/alert-dialog.jsx +27 -7
  39. package/src/checkbox.jsx +8 -1
  40. package/src/choice-configuration/__tests__/__snapshots__/feedback-menu.test.jsx.snap +51 -0
  41. package/src/choice-configuration/__tests__/__snapshots__/index.test.jsx.snap +519 -0
  42. package/src/choice-configuration/__tests__/feedback-menu.test.jsx +10 -0
  43. package/src/choice-configuration/__tests__/index.test.jsx +92 -0
  44. package/src/choice-configuration/index.jsx +14 -3
  45. package/src/feedback-config/__tests__/__snapshots__/feedback-config.test.jsx.snap +27 -0
  46. package/src/feedback-config/__tests__/__snapshots__/feedback-selector.test.jsx.snap +38 -0
  47. package/src/feedback-config/__tests__/feedback-config.test.jsx +71 -0
  48. package/src/feedback-config/__tests__/feedback-selector.test.jsx +60 -0
  49. package/src/feedback-config/feedback-selector.jsx +0 -0
  50. package/src/inputs.jsx +9 -2
  51. package/src/layout/__tests__/__snapshots__/config.layout.test.jsx.snap +59 -0
  52. package/src/layout/__tests__/config.layout.test.jsx +42 -0
  53. package/src/layout/__tests__/layout-content.test.jsx +3 -0
  54. package/src/layout/config-layout.jsx +16 -8
  55. package/src/number-text-field-custom.jsx +86 -28
  56. package/src/number-text-field.jsx +6 -5
  57. package/src/radio-with-label.jsx +6 -2
  58. package/src/settings/index.js +2 -1
  59. package/src/settings/panel.jsx +5 -2
  60. package/src/settings/settings-radio-label.jsx +6 -2
  61. package/src/settings/toggle.jsx +20 -2
  62. package/src/tags-input/__tests__/__snapshots__/index.test.jsx.snap +170 -0
  63. package/src/tags-input/__tests__/index.test.jsx +62 -0
  64. package/README.md +0 -12
@@ -2,17 +2,21 @@ import FormControlLabel from '@material-ui/core/FormControlLabel';
2
2
  import Radio from '@material-ui/core/Radio';
3
3
  import React from 'react';
4
4
  import { withStyles } from '@material-ui/core/styles';
5
+ import { color } from '@pie-lib/render-ui';
5
6
 
6
7
  export default withStyles({
7
8
  label: {
8
9
  left: '-5px',
9
10
  position: 'relative',
10
11
  },
12
+ customColor: {
13
+ color: `${color.tertiary()} !important`,
14
+ },
11
15
  })(({ label, value, checked, onChange, classes }) => (
12
16
  <FormControlLabel
13
17
  value={value}
14
- classes={classes}
15
- control={<Radio checked={checked} onChange={onChange} />}
18
+ classes={{ label: classes.label }}
19
+ control={<Radio className={classes.customColor} checked={checked} onChange={onChange} />}
16
20
  label={label}
17
21
  />
18
22
  ));
@@ -8,10 +8,11 @@ export const textField = (label, isConfigProperty = true) => ({
8
8
  isConfigProperty,
9
9
  });
10
10
 
11
- export const toggle = (label, isConfigProperty = false) => ({
11
+ export const toggle = (label, isConfigProperty = false, disabled = false) => ({
12
12
  type: 'toggle',
13
13
  label,
14
14
  isConfigProperty,
15
+ disabled,
15
16
  });
16
17
 
17
18
  const toChoice = (opt) => {
@@ -11,7 +11,7 @@ import debug from 'debug';
11
11
  import Toggle from './toggle';
12
12
  import { NChoice } from '../two-choice';
13
13
  import SettingsRadioLabel from './settings-radio-label';
14
- import { NumberTextField } from '../index';
14
+ import NumberTextField from '../number-text-field';
15
15
  import Checkbox from '../checkbox';
16
16
  import Typography from '@material-ui/core/Typography';
17
17
 
@@ -151,6 +151,7 @@ const NumberField = withStyles((theme) => ({
151
151
  showErrorWhenOutsideRange
152
152
  inputClassName={classes.wrapper}
153
153
  disableUnderline
154
+ classes={classes}
154
155
  />
155
156
  );
156
157
  });
@@ -168,7 +169,9 @@ TextField.propTypes = {
168
169
  ...baseTypes,
169
170
  };
170
171
 
171
- const ToggleWrapper = ({ label, value, onChange }) => <Toggle label={label} checked={!!value} toggle={onChange} />;
172
+ const ToggleWrapper = ({ disabled, label, value, onChange }) => (
173
+ <Toggle label={label} checked={!!value} disabled={!!disabled} toggle={onChange} />
174
+ );
172
175
 
173
176
  ToggleWrapper.propTypes = { ...baseTypes, value: PropTypes.bool };
174
177
 
@@ -2,6 +2,7 @@ import FormControlLabel from '@material-ui/core/FormControlLabel';
2
2
  import Radio from '@material-ui/core/Radio';
3
3
  import React from 'react';
4
4
  import { withStyles } from '@material-ui/core/styles';
5
+ import { color } from '@pie-lib/render-ui';
5
6
 
6
7
  export default withStyles((theme) => ({
7
8
  label: {
@@ -10,11 +11,14 @@ export default withStyles((theme) => ({
10
11
  left: '-5px',
11
12
  position: 'relative',
12
13
  },
14
+ customColor: {
15
+ color: `${color.tertiary()} !important`,
16
+ },
13
17
  }))(({ label, value, checked, onChange, classes }) => (
14
18
  <FormControlLabel
15
19
  value={value}
16
- classes={classes}
17
- control={<Radio checked={checked} onChange={onChange} />}
20
+ classes={{ label: classes.label }}
21
+ control={<Radio className={classes.customColor} checked={checked} onChange={onChange} />}
18
22
  label={label}
19
23
  />
20
24
  ));
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
3
3
  import InputLabel from '@material-ui/core/InputLabel';
4
4
  import { withStyles } from '@material-ui/core/styles';
5
5
  import Switch from '@material-ui/core/Switch';
6
+ import classNames from 'classnames';
7
+ import { color } from '@pie-lib/render-ui';
6
8
 
7
9
  const Toggle = withStyles((theme) => ({
8
10
  toggle: {
@@ -15,10 +17,26 @@ const Toggle = withStyles((theme) => ({
15
17
  fontSize: theme.typography.fontSize,
16
18
  paddingTop: theme.spacing.unit * 2,
17
19
  },
18
- }))(({ checked, label, toggle, classes }) => (
20
+ checkedThumb: {
21
+ color: `${color.tertiary()} !important`,
22
+ },
23
+ checkedBar: {
24
+ backgroundColor: `${color.tertiaryLight()} !important`,
25
+ },
26
+ }))(({ checked, disabled, label, toggle, classes }) => (
19
27
  <div className={classes.toggle}>
20
28
  <InputLabel className={classes.label}>{label}</InputLabel>
21
- <Switch checked={checked} onChange={(e) => toggle(e.target.checked)} />
29
+ <Switch
30
+ classes={{
31
+ checked: classNames(classes.checkedThumb),
32
+ bar: classNames({
33
+ [classes.checkedBar]: checked,
34
+ }),
35
+ }}
36
+ checked={checked}
37
+ disabled={disabled}
38
+ onChange={(e) => toggle(e.target.checked)}
39
+ />
22
40
  </div>
23
41
  ));
24
42
 
@@ -0,0 +1,170 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TagsInput snapshots renders 1`] = `
4
+ <TagsInput
5
+ classes={
6
+ Object {
7
+ "tagsInput": "tagsInput",
8
+ }
9
+ }
10
+ onChange={[MockFunction]}
11
+ tags={
12
+ Array [
13
+ "foo",
14
+ ]
15
+ }
16
+ >
17
+ <WithStyles(Component)
18
+ focused={false}
19
+ >
20
+ <Component
21
+ classes={
22
+ Object {
23
+ "focused": "Component-focused-2",
24
+ "muiBox": "Component-muiBox-1",
25
+ }
26
+ }
27
+ focused={false}
28
+ >
29
+ <div
30
+ className="Component-muiBox-1"
31
+ >
32
+ <div
33
+ className="tagsInput"
34
+ >
35
+ <WithStyles(Component)
36
+ key="0"
37
+ label="foo"
38
+ onDelete={[Function]}
39
+ >
40
+ <Component
41
+ classes={
42
+ Object {
43
+ "tag": "Component-tag-3",
44
+ }
45
+ }
46
+ label="foo"
47
+ onDelete={[Function]}
48
+ >
49
+ <WithStyles(Chip)
50
+ className="Component-tag-3"
51
+ label="foo"
52
+ onDelete={[Function]}
53
+ >
54
+ <Chip
55
+ className="Component-tag-3"
56
+ classes={
57
+ Object {
58
+ "avatar": "MuiChip-avatar-16",
59
+ "avatarChildren": "MuiChip-avatarChildren-19",
60
+ "avatarColorPrimary": "MuiChip-avatarColorPrimary-17",
61
+ "avatarColorSecondary": "MuiChip-avatarColorSecondary-18",
62
+ "clickable": "MuiChip-clickable-7",
63
+ "clickableColorPrimary": "MuiChip-clickableColorPrimary-8",
64
+ "clickableColorSecondary": "MuiChip-clickableColorSecondary-9",
65
+ "colorPrimary": "MuiChip-colorPrimary-5",
66
+ "colorSecondary": "MuiChip-colorSecondary-6",
67
+ "deletable": "MuiChip-deletable-10",
68
+ "deletableColorPrimary": "MuiChip-deletableColorPrimary-11",
69
+ "deletableColorSecondary": "MuiChip-deletableColorSecondary-12",
70
+ "deleteIcon": "MuiChip-deleteIcon-24",
71
+ "deleteIconColorPrimary": "MuiChip-deleteIconColorPrimary-25",
72
+ "deleteIconColorSecondary": "MuiChip-deleteIconColorSecondary-26",
73
+ "deleteIconOutlinedColorPrimary": "MuiChip-deleteIconOutlinedColorPrimary-27",
74
+ "deleteIconOutlinedColorSecondary": "MuiChip-deleteIconOutlinedColorSecondary-28",
75
+ "icon": "MuiChip-icon-20",
76
+ "iconColorPrimary": "MuiChip-iconColorPrimary-21",
77
+ "iconColorSecondary": "MuiChip-iconColorSecondary-22",
78
+ "label": "MuiChip-label-23",
79
+ "outlined": "MuiChip-outlined-13",
80
+ "outlinedPrimary": "MuiChip-outlinedPrimary-14",
81
+ "outlinedSecondary": "MuiChip-outlinedSecondary-15",
82
+ "root": "MuiChip-root-4",
83
+ }
84
+ }
85
+ color="default"
86
+ component="div"
87
+ label="foo"
88
+ onDelete={[Function]}
89
+ variant="default"
90
+ >
91
+ <div
92
+ className="MuiChip-root-4 MuiChip-deletable-10 Component-tag-3"
93
+ onKeyDown={[Function]}
94
+ onKeyUp={[Function]}
95
+ role="button"
96
+ tabIndex={0}
97
+ >
98
+ <span
99
+ className="MuiChip-label-23"
100
+ >
101
+ foo
102
+ </span>
103
+ <pure(Cancel)
104
+ className="MuiChip-deleteIcon-24"
105
+ onClick={[Function]}
106
+ >
107
+ <Cancel
108
+ className="MuiChip-deleteIcon-24"
109
+ onClick={[Function]}
110
+ >
111
+ <WithStyles(SvgIcon)
112
+ className="MuiChip-deleteIcon-24"
113
+ onClick={[Function]}
114
+ >
115
+ <SvgIcon
116
+ className="MuiChip-deleteIcon-24"
117
+ classes={
118
+ Object {
119
+ "colorAction": "MuiSvgIcon-colorAction-32",
120
+ "colorDisabled": "MuiSvgIcon-colorDisabled-34",
121
+ "colorError": "MuiSvgIcon-colorError-33",
122
+ "colorPrimary": "MuiSvgIcon-colorPrimary-30",
123
+ "colorSecondary": "MuiSvgIcon-colorSecondary-31",
124
+ "fontSizeInherit": "MuiSvgIcon-fontSizeInherit-35",
125
+ "fontSizeLarge": "MuiSvgIcon-fontSizeLarge-37",
126
+ "fontSizeSmall": "MuiSvgIcon-fontSizeSmall-36",
127
+ "root": "MuiSvgIcon-root-29",
128
+ }
129
+ }
130
+ color="inherit"
131
+ component="svg"
132
+ fontSize="default"
133
+ onClick={[Function]}
134
+ viewBox="0 0 24 24"
135
+ >
136
+ <svg
137
+ aria-hidden="true"
138
+ className="MuiSvgIcon-root-29 MuiChip-deleteIcon-24"
139
+ focusable="false"
140
+ onClick={[Function]}
141
+ role="presentation"
142
+ viewBox="0 0 24 24"
143
+ >
144
+ <path
145
+ d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"
146
+ />
147
+ </svg>
148
+ </SvgIcon>
149
+ </WithStyles(SvgIcon)>
150
+ </Cancel>
151
+ </pure(Cancel)>
152
+ </div>
153
+ </Chip>
154
+ </WithStyles(Chip)>
155
+ </Component>
156
+ </WithStyles(Component)>
157
+ <input
158
+ onBlur={[Function]}
159
+ onChange={[Function]}
160
+ onFocus={[Function]}
161
+ onKeyDown={[Function]}
162
+ type="text"
163
+ value=""
164
+ />
165
+ </div>
166
+ </div>
167
+ </Component>
168
+ </WithStyles(Component)>
169
+ </TagsInput>
170
+ `;
@@ -0,0 +1,62 @@
1
+ import { TagsInput } from '../index';
2
+ import toJson from 'enzyme-to-json';
3
+ import { shallow, mount } from 'enzyme';
4
+ import React from 'react';
5
+
6
+ describe('TagsInput', () => {
7
+ describe('snapshots', () => {
8
+ it('renders', () => {
9
+ const wrapper = mount(<TagsInput classes={{ tagsInput: 'tagsInput' }} tags={['foo']} onChange={jest.fn()} />);
10
+ expect(toJson(wrapper)).toMatchSnapshot();
11
+ });
12
+ });
13
+
14
+ describe('logic', () => {
15
+ let onChange;
16
+ const mkWrapper = () => {
17
+ onChange = jest.fn();
18
+ return shallow(<TagsInput onChange={onChange} classes={{}} tags={['foo']} />);
19
+ };
20
+
21
+ describe('onFocus', () => {
22
+ it('sets state.focused = true', () => {
23
+ const wrapper = mkWrapper();
24
+ wrapper.instance().onFocus();
25
+ expect(wrapper.state('focused')).toEqual(true);
26
+ });
27
+ });
28
+
29
+ describe('onBlur', () => {
30
+ it('sets state.focused = false', () => {
31
+ const wrapper = mkWrapper();
32
+ wrapper.instance().onFocus();
33
+ wrapper.instance().onBlur();
34
+ expect(wrapper.state('focused')).toEqual(false);
35
+ });
36
+ });
37
+
38
+ describe('onChange', () => {
39
+ it('sets state.value ', () => {
40
+ const wrapper = mkWrapper();
41
+ wrapper.instance().onChange({ target: { value: 'boo' } });
42
+ expect(wrapper.state('value')).toEqual('boo');
43
+ });
44
+ });
45
+
46
+ describe('onKeyDown', () => {
47
+ it('calls onChange on enter', () => {
48
+ const wrapper = mkWrapper();
49
+ wrapper.setState({ value: 'banana' });
50
+ wrapper.instance().onKeyDown({ keyCode: 13 });
51
+ expect(onChange).toBeCalledWith(['foo', 'banana']);
52
+ });
53
+
54
+ it('doesnt calls onChange on enter if the value is the same as a value in tags', () => {
55
+ const wrapper = mkWrapper();
56
+ wrapper.setState({ value: 'foo' });
57
+ wrapper.instance().onKeyDown({ keyCode: 13 });
58
+ expect(onChange).not.toBeCalled();
59
+ });
60
+ });
61
+ });
62
+ });
package/README.md DELETED
@@ -1,12 +0,0 @@
1
- # install
2
-
3
- ```
4
- npm install
5
- ```
6
-
7
- # demo
8
-
9
- ```
10
- cd demo
11
- ../node_modules/.bin/webpack-dev-server --hot --inline
12
- ```