@pie-lib/graphing 2.34.3-next.2 → 2.34.3-next.203

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 (218) hide show
  1. package/CHANGELOG.md +13 -67
  2. package/lib/axis/arrow.js +19 -55
  3. package/lib/axis/arrow.js.map +1 -1
  4. package/lib/axis/axes.js +106 -194
  5. package/lib/axis/axes.js.map +1 -1
  6. package/lib/axis/index.js +1 -6
  7. package/lib/axis/index.js.map +1 -1
  8. package/lib/bg.js +21 -49
  9. package/lib/bg.js.map +1 -1
  10. package/lib/container/actions.js +2 -8
  11. package/lib/container/actions.js.map +1 -1
  12. package/lib/container/index.js +14 -59
  13. package/lib/container/index.js.map +1 -1
  14. package/lib/container/marks.js +1 -6
  15. package/lib/container/marks.js.map +1 -1
  16. package/lib/container/middleware.js +2 -8
  17. package/lib/container/middleware.js.map +1 -1
  18. package/lib/container/reducer.js +1 -8
  19. package/lib/container/reducer.js.map +1 -1
  20. package/lib/coordinates-label.js +24 -54
  21. package/lib/coordinates-label.js.map +1 -1
  22. package/lib/graph-with-controls.js +120 -184
  23. package/lib/graph-with-controls.js.map +1 -1
  24. package/lib/graph.js +59 -116
  25. package/lib/graph.js.map +1 -1
  26. package/lib/grid-setup.js +169 -225
  27. package/lib/grid-setup.js.map +1 -1
  28. package/lib/grid.js +29 -74
  29. package/lib/grid.js.map +1 -1
  30. package/lib/index.js +1 -13
  31. package/lib/index.js.map +1 -1
  32. package/lib/key-legend.js +40 -85
  33. package/lib/key-legend.js.map +1 -1
  34. package/lib/label-svg-icon.js +1 -7
  35. package/lib/label-svg-icon.js.map +1 -1
  36. package/lib/labels.js +66 -122
  37. package/lib/labels.js.map +1 -1
  38. package/lib/mark-label.js +120 -163
  39. package/lib/mark-label.js.map +1 -1
  40. package/lib/toggle-bar.js +155 -243
  41. package/lib/toggle-bar.js.map +1 -1
  42. package/lib/tool-menu.js +16 -50
  43. package/lib/tool-menu.js.map +1 -1
  44. package/lib/tools/absolute/component.js +4 -10
  45. package/lib/tools/absolute/component.js.map +1 -1
  46. package/lib/tools/absolute/index.js +3 -16
  47. package/lib/tools/absolute/index.js.map +1 -1
  48. package/lib/tools/circle/bg-circle.js +42 -92
  49. package/lib/tools/circle/bg-circle.js.map +1 -1
  50. package/lib/tools/circle/component.js +78 -165
  51. package/lib/tools/circle/component.js.map +1 -1
  52. package/lib/tools/circle/index.js +3 -13
  53. package/lib/tools/circle/index.js.map +1 -1
  54. package/lib/tools/exponential/component.js +4 -10
  55. package/lib/tools/exponential/component.js.map +1 -1
  56. package/lib/tools/exponential/index.js +3 -18
  57. package/lib/tools/exponential/index.js.map +1 -1
  58. package/lib/tools/index.js +3 -16
  59. package/lib/tools/index.js.map +1 -1
  60. package/lib/tools/line/component.js +27 -48
  61. package/lib/tools/line/component.js.map +1 -1
  62. package/lib/tools/line/index.js +1 -6
  63. package/lib/tools/line/index.js.map +1 -1
  64. package/lib/tools/parabola/component.js +4 -10
  65. package/lib/tools/parabola/component.js.map +1 -1
  66. package/lib/tools/parabola/index.js +3 -16
  67. package/lib/tools/parabola/index.js.map +1 -1
  68. package/lib/tools/point/component.js +24 -71
  69. package/lib/tools/point/component.js.map +1 -1
  70. package/lib/tools/point/index.js +3 -11
  71. package/lib/tools/point/index.js.map +1 -1
  72. package/lib/tools/polygon/component.js +83 -184
  73. package/lib/tools/polygon/component.js.map +1 -1
  74. package/lib/tools/polygon/index.js +6 -23
  75. package/lib/tools/polygon/index.js.map +1 -1
  76. package/lib/tools/polygon/line.js +48 -91
  77. package/lib/tools/polygon/line.js.map +1 -1
  78. package/lib/tools/polygon/polygon.js +65 -98
  79. package/lib/tools/polygon/polygon.js.map +1 -1
  80. package/lib/tools/ray/component.js +41 -60
  81. package/lib/tools/ray/component.js.map +1 -1
  82. package/lib/tools/ray/index.js +1 -6
  83. package/lib/tools/ray/index.js.map +1 -1
  84. package/lib/tools/segment/component.js +25 -43
  85. package/lib/tools/segment/component.js.map +1 -1
  86. package/lib/tools/segment/index.js +1 -6
  87. package/lib/tools/segment/index.js.map +1 -1
  88. package/lib/tools/shared/arrow-head.js +69 -28
  89. package/lib/tools/shared/arrow-head.js.map +1 -1
  90. package/lib/tools/shared/icons/CorrectSVG.js +12 -8
  91. package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
  92. package/lib/tools/shared/icons/IncorrectSVG.js +12 -8
  93. package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
  94. package/lib/tools/shared/icons/MissingSVG.js +12 -8
  95. package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
  96. package/lib/tools/shared/line/index.js +140 -193
  97. package/lib/tools/shared/line/index.js.map +1 -1
  98. package/lib/tools/shared/line/line-path.js +70 -101
  99. package/lib/tools/shared/line/line-path.js.map +1 -1
  100. package/lib/tools/shared/line/with-root-edge.js +22 -56
  101. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  102. package/lib/tools/shared/point/arrow-point.js +21 -62
  103. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  104. package/lib/tools/shared/point/arrow.js +23 -52
  105. package/lib/tools/shared/point/arrow.js.map +1 -1
  106. package/lib/tools/shared/point/base-point.js +54 -72
  107. package/lib/tools/shared/point/base-point.js.map +1 -1
  108. package/lib/tools/shared/point/index.js +22 -57
  109. package/lib/tools/shared/point/index.js.map +1 -1
  110. package/lib/tools/shared/styles.js +10 -38
  111. package/lib/tools/shared/styles.js.map +1 -1
  112. package/lib/tools/shared/types.js +2 -9
  113. package/lib/tools/shared/types.js.map +1 -1
  114. package/lib/tools/sine/component.js +8 -19
  115. package/lib/tools/sine/component.js.map +1 -1
  116. package/lib/tools/sine/index.js +3 -16
  117. package/lib/tools/sine/index.js.map +1 -1
  118. package/lib/tools/vector/component.js +24 -44
  119. package/lib/tools/vector/component.js.map +1 -1
  120. package/lib/tools/vector/index.js +1 -6
  121. package/lib/tools/vector/index.js.map +1 -1
  122. package/lib/undo-redo.js +29 -69
  123. package/lib/undo-redo.js.map +1 -1
  124. package/lib/use-debounce.js +4 -11
  125. package/lib/use-debounce.js.map +1 -1
  126. package/lib/utils.js +51 -128
  127. package/lib/utils.js.map +1 -1
  128. package/package.json +25 -29
  129. package/src/__tests__/graph-with-controls.test.jsx +28 -11
  130. package/src/__tests__/graph.test.jsx +104 -168
  131. package/src/__tests__/grid.test.jsx +8 -6
  132. package/src/__tests__/labels.test.jsx +25 -8
  133. package/src/__tests__/mark-label.test.jsx +12 -17
  134. package/src/__tests__/toggle-bar.test.jsx +92 -17
  135. package/src/__tests__/tool-menu.test.jsx +61 -12
  136. package/src/__tests__/undo-redo.test.jsx +7 -8
  137. package/src/__tests__/utils.js +3 -0
  138. package/src/axis/__tests__/arrow.test.jsx +16 -17
  139. package/src/axis/__tests__/axes.test.jsx +118 -122
  140. package/src/axis/arrow.jsx +7 -12
  141. package/src/axis/axes.jsx +45 -55
  142. package/src/coordinates-label.jsx +14 -18
  143. package/src/graph-with-controls.jsx +52 -59
  144. package/src/grid-setup.jsx +203 -205
  145. package/src/grid.jsx +2 -4
  146. package/src/key-legend.jsx +52 -56
  147. package/src/labels.jsx +24 -31
  148. package/src/mark-label.jsx +92 -81
  149. package/src/toggle-bar.jsx +135 -164
  150. package/src/tool-menu.jsx +1 -1
  151. package/src/tools/circle/__tests__/bg-circle.test.jsx +7 -9
  152. package/src/tools/circle/__tests__/component.test.jsx +17 -189
  153. package/src/tools/circle/bg-circle.jsx +20 -28
  154. package/src/tools/circle/component.jsx +28 -63
  155. package/src/tools/line/__tests__/component.test.jsx +7 -7
  156. package/src/tools/line/component.jsx +22 -15
  157. package/src/tools/point/__tests__/component.test.jsx +18 -43
  158. package/src/tools/point/component.jsx +1 -1
  159. package/src/tools/polygon/__tests__/component.test.jsx +18 -162
  160. package/src/tools/polygon/__tests__/line.test.jsx +7 -10
  161. package/src/tools/polygon/__tests__/polygon.test.jsx +7 -8
  162. package/src/tools/polygon/component.jsx +3 -4
  163. package/src/tools/polygon/line.jsx +30 -33
  164. package/src/tools/polygon/polygon.jsx +52 -45
  165. package/src/tools/ray/__tests__/component.test.jsx +7 -8
  166. package/src/tools/ray/component.jsx +38 -25
  167. package/src/tools/segment/__tests__/component.test.jsx +7 -8
  168. package/src/tools/segment/component.jsx +19 -18
  169. package/src/tools/shared/__tests__/arrow-head.test.jsx +14 -17
  170. package/src/tools/shared/arrow-head.jsx +60 -7
  171. package/src/tools/shared/icons/CorrectSVG.jsx +10 -0
  172. package/src/tools/shared/icons/IncorrectSVG.jsx +10 -0
  173. package/src/tools/shared/icons/MissingSVG.jsx +10 -0
  174. package/src/tools/shared/line/__tests__/index.test.jsx +19 -165
  175. package/src/tools/shared/line/__tests__/line-path.test.jsx +8 -8
  176. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +22 -22
  177. package/src/tools/shared/line/index.jsx +52 -7
  178. package/src/tools/shared/line/line-path.jsx +55 -59
  179. package/src/tools/shared/line/with-root-edge.jsx +1 -1
  180. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +15 -11
  181. package/src/tools/shared/point/__tests__/base-point.test.jsx +14 -11
  182. package/src/tools/shared/point/arrow-point.jsx +10 -24
  183. package/src/tools/shared/point/arrow.jsx +5 -11
  184. package/src/tools/shared/point/base-point.jsx +42 -19
  185. package/src/tools/shared/point/index.jsx +27 -44
  186. package/src/tools/vector/__tests__/component.test.jsx +7 -8
  187. package/src/tools/vector/component.jsx +11 -16
  188. package/src/undo-redo.jsx +19 -21
  189. package/esm/index.css +0 -847
  190. package/esm/index.js +0 -239949
  191. package/esm/index.js.map +0 -1
  192. package/esm/package.json +0 -3
  193. package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +0 -237
  194. package/src/__tests__/__snapshots__/graph.test.jsx.snap +0 -211
  195. package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -54
  196. package/src/__tests__/__snapshots__/labels.test.jsx.snap +0 -30
  197. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -45
  198. package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +0 -7
  199. package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +0 -13
  200. package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +0 -14
  201. package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +0 -33
  202. package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +0 -122
  203. package/src/tools/circle/__tests__/__snapshots__/bg-circle.test.jsx.snap +0 -46
  204. package/src/tools/circle/__tests__/__snapshots__/component.test.jsx.snap +0 -293
  205. package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +0 -20
  206. package/src/tools/point/__tests__/__snapshots__/component.test.jsx.snap +0 -40
  207. package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +0 -415
  208. package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +0 -45
  209. package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +0 -52
  210. package/src/tools/ray/__tests__/__snapshots__/component.test.jsx.snap +0 -23
  211. package/src/tools/segment/__tests__/__snapshots__/component.test.jsx.snap +0 -14
  212. package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +0 -27
  213. package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +0 -360
  214. package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +0 -58
  215. package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +0 -63
  216. package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +0 -56
  217. package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +0 -44
  218. package/src/tools/vector/__tests__/__snapshots__/component.test.jsx.snap +0 -12
@@ -1,49 +1,109 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { color, InputContainer } from '@pie-lib/render-ui';
4
- import { withStyles } from '@material-ui/core/styles';
5
- import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
6
- import Typography from '@material-ui/core/Typography';
7
- import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
8
- import ExpansionPanel from '@material-ui/core/ExpansionPanel';
9
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
4
+ import { Accordion, AccordionSummary, AccordionDetails, Typography } from '@mui/material';
5
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
10
6
  import { NumberTextFieldCustom, Toggle } from '@pie-lib/config-ui';
11
- import EditableHTML from '@pie-lib/editable-html';
7
+ import EditableHTML from '@pie-lib/editable-html-tip-tap';
8
+ import { styled } from '@mui/material/styles';
9
+
10
+ const Wrapper = styled('div')(() => ({
11
+ width: '450px',
12
+ }));
13
+
14
+ const Content = styled('div')(() => ({
15
+ display: 'flex',
16
+ flexDirection: 'column',
17
+ width: '100%',
18
+ }));
19
+
20
+ const ColumnView = styled('div')(() => ({
21
+ display: 'flex',
22
+ flexDirection: 'column',
23
+ alignItems: 'center',
24
+ }));
25
+
26
+ const RowView = styled('div')(() => ({
27
+ display: 'flex',
28
+ justifyContent: 'space-around',
29
+ alignItems: 'center',
30
+ }));
31
+
32
+ const TextFieldSmall = styled('div')(({ theme }) => ({
33
+ width: '130px',
34
+ margin: `${theme.spacing(1)} ${theme.spacing(0.5)}`,
35
+ }));
36
+
37
+ const TextFieldMedium = styled('div')(({ theme }) => ({
38
+ width: '160px',
39
+ margin: `${theme.spacing(1)} ${theme.spacing(0.5)}`,
40
+ '& .MuiFormControl-root': {
41
+ width: '100%',
42
+ },
43
+ }));
44
+
45
+ const TextFieldLarge = styled('div')(({ theme }) => ({
46
+ width: '230px',
47
+ margin: `${theme.spacing(1)} ${theme.spacing(0.5)}`,
48
+ '& .MuiFormControl-root': {
49
+ width: '100%',
50
+ },
51
+ }));
52
+
53
+ const ItalicText = styled(Typography)(({ theme }) => ({
54
+ fontStyle: 'italic',
55
+ margin: `${theme.spacing(1)} 0`,
56
+ }));
57
+
58
+ const Dimensions = styled('div')(() => ({
59
+ display: 'flex',
60
+ justifyContent: 'space-between',
61
+ alignItems: 'center',
62
+ }));
63
+
64
+ const DisabledText = styled(Typography)(() => ({
65
+ color: color.disabled(),
66
+ }));
67
+
68
+ const AxisLabel = styled('div')(({ theme }) => ({
69
+ paddingTop: theme.spacing(2),
70
+ }));
12
71
 
13
72
  const GridConfig = (props) => {
14
- const { classes, disabled, displayedFields, labelValue, labelValues, gridValue, gridValues, onChange } = props;
73
+ const { disabled, displayedFields, labelValue, labelValues, gridValue, gridValues, onChange } = props;
15
74
  const { labelStep = {}, step = {} } = displayedFields;
16
75
 
17
76
  return (
18
- <div className={classes.columnView}>
77
+ <ColumnView>
19
78
  {step && step.enabled && (
20
- <NumberTextFieldCustom
21
- className={classes.mediumTextField}
22
- label={step.label || ''}
23
- value={gridValue}
24
- customValues={gridValues}
25
- variant="outlined"
26
- disabled={disabled}
27
- onChange={(e, v) => onChange('step', v)}
28
- />
79
+ <TextFieldMedium>
80
+ <NumberTextFieldCustom
81
+ label={step.label || ''}
82
+ value={gridValue}
83
+ customValues={gridValues}
84
+ variant="outlined"
85
+ disabled={disabled}
86
+ onChange={(e, v) => onChange('step', v)}
87
+ />
88
+ </TextFieldMedium>
29
89
  )}
30
90
  {labelStep && labelStep.enabled && (
31
- <NumberTextFieldCustom
32
- className={classes.mediumTextField}
33
- label={labelStep.label || ''}
34
- value={labelValue}
35
- customValues={labelValues}
36
- variant="outlined"
37
- disabled={disabled}
38
- onChange={(e, v) => onChange('labelStep', v)}
39
- />
91
+ <TextFieldMedium>
92
+ <NumberTextFieldCustom
93
+ label={labelStep.label || ''}
94
+ value={labelValue}
95
+ customValues={labelValues}
96
+ variant="outlined"
97
+ disabled={disabled}
98
+ onChange={(e, v) => onChange('labelStep', v)}
99
+ />
100
+ </TextFieldMedium>
40
101
  )}
41
- </div>
102
+ </ColumnView>
42
103
  );
43
104
  };
44
105
 
45
106
  GridConfig.propTypes = {
46
- classes: PropTypes.object,
47
107
  disabled: PropTypes.bool,
48
108
  displayedFields: PropTypes.object,
49
109
  labelValue: PropTypes.number,
@@ -54,65 +114,62 @@ GridConfig.propTypes = {
54
114
  };
55
115
 
56
116
  const AxisConfig = (props) => {
57
- const { classes, disabled, displayedFields, displayHeader, label, maxValue, minValue, onChange, type } = props;
117
+ const { disabled, displayedFields, displayHeader, label, maxValue, minValue, onChange, type } = props;
58
118
  const { axisLabel = {}, min = {}, max = {} } = displayedFields;
59
- const activePlugins = [
60
- 'bold',
61
- 'italic',
62
- 'underline',
63
- 'strikethrough',
64
- // 'languageCharacters'
65
- ];
119
+ const activePlugins = ['bold', 'italic', 'underline', 'strikethrough'];
66
120
 
67
121
  return (
68
- <div className={classes.columnView}>
122
+ <ColumnView>
69
123
  {displayHeader && (
70
124
  <Typography variant="subtitle2">
71
- <i>{type === 'domain' ? 'x' : 'y'}</i>
72
- -axis
125
+ <i>{type === 'domain' ? 'x' : 'y'}</i>-axis
73
126
  </Typography>
74
127
  )}
75
128
  {min && min.enabled && (
76
- <NumberTextFieldCustom
77
- className={classes.mediumTextField}
78
- label={min.label || ''}
79
- value={minValue}
80
- min={-10000}
81
- max={maxValue - 0.05}
82
- variant="outlined"
83
- disabled={disabled}
84
- onChange={(e, v) => onChange('min', v)}
85
- />
129
+ <TextFieldMedium>
130
+ <NumberTextFieldCustom
131
+ label={min.label || ''}
132
+ value={minValue}
133
+ min={-10000}
134
+ max={maxValue - 0.05}
135
+ variant="outlined"
136
+ disabled={disabled}
137
+ onChange={(e, v) => onChange('min', v)}
138
+ />
139
+ </TextFieldMedium>
86
140
  )}
87
141
  {max && max.enabled && (
88
- <NumberTextFieldCustom
89
- className={classes.mediumTextField}
90
- label={max.label || ''}
91
- value={maxValue}
92
- min={minValue + 0.05}
93
- max={10000}
94
- variant="outlined"
95
- disabled={disabled}
96
- onChange={(e, v) => onChange('max', v)}
97
- />
142
+ <TextFieldMedium>
143
+ <NumberTextFieldCustom
144
+ label={max.label || ''}
145
+ value={maxValue}
146
+ min={minValue + 0.05}
147
+ max={10000}
148
+ variant="outlined"
149
+ disabled={disabled}
150
+ onChange={(e, v) => onChange('max', v)}
151
+ />
152
+ </TextFieldMedium>
98
153
  )}
99
154
  {axisLabel && axisLabel.enabled && (
100
- <InputContainer label={axisLabel.label || ''} className={classes.mediumTextField}>
101
- <EditableHTML
102
- className={classes.axisLabel}
103
- onChange={(value) => onChange('axisLabel', value)}
104
- markup={label || ''}
105
- charactersLimit={5}
106
- activePlugins={activePlugins}
107
- />
108
- </InputContainer>
155
+ <TextFieldMedium>
156
+ <InputContainer label={axisLabel.label || ''}>
157
+ <AxisLabel>
158
+ <EditableHTML
159
+ onChange={(value) => onChange('axisLabel', value)}
160
+ markup={label || ''}
161
+ charactersLimit={5}
162
+ activePlugins={activePlugins}
163
+ />
164
+ </AxisLabel>
165
+ </InputContainer>
166
+ </TextFieldMedium>
109
167
  )}
110
- </div>
168
+ </ColumnView>
111
169
  );
112
170
  };
113
171
 
114
172
  AxisConfig.propTypes = {
115
- classes: PropTypes.object,
116
173
  disabled: PropTypes.bool,
117
174
  displayedFields: PropTypes.object,
118
175
  displayHeader: PropTypes.bool,
@@ -122,9 +179,9 @@ AxisConfig.propTypes = {
122
179
  type: PropTypes.string,
123
180
  onChange: PropTypes.func,
124
181
  };
182
+
125
183
  const GridSetup = (props) => {
126
184
  const {
127
- classes,
128
185
  domain,
129
186
  displayedFields = {},
130
187
  gridValues = {},
@@ -137,6 +194,7 @@ const GridSetup = (props) => {
137
194
  sizeConstraints,
138
195
  standardGrid,
139
196
  } = props;
197
+
140
198
  const gridProps = { min: 2, max: 41 };
141
199
  const {
142
200
  axisLabel = {},
@@ -148,6 +206,7 @@ const GridSetup = (props) => {
148
206
  standardGridEnabled,
149
207
  step = {},
150
208
  } = displayedFields || {};
209
+
151
210
  const displayAxisType = min.enabled || max.enabled || axisLabel.enabled || step.enabled || labelStep.enabled;
152
211
  const gridConfigFields = { step, labelStep };
153
212
  const axisConfigFields = { min, max, axisLabel };
@@ -155,7 +214,6 @@ const GridSetup = (props) => {
155
214
  const onIncludeAxes = (includeAxes) => {
156
215
  const noAxesConfig = (type) => {
157
216
  const axis = type === 'domain' ? domain : range;
158
-
159
217
  return {
160
218
  min: 1,
161
219
  max: axis.max < gridProps.min || axis.max > gridProps.max ? 16 : axis.max,
@@ -192,35 +250,25 @@ const GridSetup = (props) => {
192
250
 
193
251
  const onSizeChanged = (key, value) => {
194
252
  const graph = { ...size, [key]: value };
195
-
196
- if (standardGrid) {
197
- graph.height = value;
198
- }
199
-
253
+ if (standardGrid) graph.height = value;
200
254
  onChange({ graph });
201
255
  };
202
256
 
203
257
  const onDomainChanged = (key, value) => {
204
258
  domain[key] = value;
205
-
206
- if (standardGrid && key !== 'axisLabel') {
207
- range[key] = value;
208
- }
209
-
259
+ if (standardGrid && key !== 'axisLabel') range[key] = value;
210
260
  onChange({ domain, range });
211
261
  };
212
262
 
213
263
  const onRangeChanged = (key, value) => {
214
264
  range[key] = value;
215
-
216
265
  onChange({ range });
217
266
  };
218
267
 
219
268
  const axesConfig = (
220
- <React.Fragment>
221
- <div className={classes.rowView}>
269
+ <>
270
+ <RowView>
222
271
  <AxisConfig
223
- classes={classes}
224
272
  displayedFields={axisConfigFields}
225
273
  displayHeader={displayAxisType}
226
274
  type="domain"
@@ -231,7 +279,6 @@ const GridSetup = (props) => {
231
279
  onChange={onDomainChanged}
232
280
  />
233
281
  <AxisConfig
234
- classes={classes}
235
282
  displayedFields={axisConfigFields}
236
283
  displayHeader={displayAxisType}
237
284
  type="range"
@@ -242,16 +289,15 @@ const GridSetup = (props) => {
242
289
  includeAxes={includeAxes}
243
290
  onChange={onRangeChanged}
244
291
  />
245
- </div>
292
+ </RowView>
246
293
  {(min.enabled || max.enabled) && (
247
- <Typography className={classes.text}>
294
+ <ItalicText>
248
295
  If you want the axis to be visible, use a zero or negative Min Value, and a positive Max Value
249
- </Typography>
296
+ </ItalicText>
250
297
  )}
251
298
  {(step.enabled || labelStep.enabled) && (
252
- <div className={classes.rowView}>
299
+ <RowView>
253
300
  <GridConfig
254
- classes={classes}
255
301
  displayedFields={gridConfigFields}
256
302
  gridValue={domain.step}
257
303
  labelValue={domain.labelStep}
@@ -260,7 +306,6 @@ const GridSetup = (props) => {
260
306
  onChange={onDomainChanged}
261
307
  />
262
308
  <GridConfig
263
- classes={classes}
264
309
  disabled={standardGrid}
265
310
  displayedFields={gridConfigFields}
266
311
  gridValue={range.step}
@@ -269,46 +314,46 @@ const GridSetup = (props) => {
269
314
  labelValues={labelValues.range || []}
270
315
  onChange={onRangeChanged}
271
316
  />
272
- </div>
273
- )}
274
- {labelStep.enabled && (
275
- <Typography className={classes.text}>For unnumbered gridlines, enter a label interval of 0</Typography>
317
+ </RowView>
276
318
  )}
277
- </React.Fragment>
319
+ {labelStep.enabled && <ItalicText>For unnumbered gridlines, enter a label interval of 0</ItalicText>}
320
+ </>
278
321
  );
279
322
 
280
323
  const gridlinesConfig = max.enabled ? (
281
- <div className={classes.columnView}>
282
- <NumberTextFieldCustom
283
- className={classes.largeTextField}
284
- label="Number of Vertical Gridlines"
285
- value={domain.max}
286
- min={!includeAxes && gridProps.min}
287
- max={!includeAxes && gridProps.max}
288
- variant="outlined"
289
- onChange={(e, v) => onDomainChanged('max', v)}
290
- />
291
- <NumberTextFieldCustom
292
- className={classes.largeTextField}
293
- label="Number of Horizontal Gridlines"
294
- value={range.max}
295
- min={!includeAxes && gridProps.min}
296
- max={!includeAxes && gridProps.max}
297
- variant="outlined"
298
- disabled={standardGrid}
299
- onChange={(e, v) => onRangeChanged('max', v)}
300
- />
301
- </div>
324
+ <ColumnView>
325
+ <TextFieldLarge>
326
+ <NumberTextFieldCustom
327
+ label="Number of Vertical Gridlines"
328
+ value={domain.max}
329
+ min={!includeAxes && gridProps.min}
330
+ max={!includeAxes && gridProps.max}
331
+ variant="outlined"
332
+ onChange={(e, v) => onDomainChanged('max', v)}
333
+ />
334
+ </TextFieldLarge>
335
+ <TextFieldLarge>
336
+ <NumberTextFieldCustom
337
+ label="Number of Horizontal Gridlines"
338
+ value={range.max}
339
+ min={!includeAxes && gridProps.min}
340
+ max={!includeAxes && gridProps.max}
341
+ variant="outlined"
342
+ disabled={standardGrid}
343
+ onChange={(e, v) => onRangeChanged('max', v)}
344
+ />
345
+ </TextFieldLarge>
346
+ </ColumnView>
302
347
  ) : null;
303
348
 
304
349
  return (
305
- <div className={classes.wrapper}>
306
- <ExpansionPanel onChange={onChangeView}>
307
- <ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
350
+ <Wrapper>
351
+ <Accordion onChange={onChangeView} TransitionProps={{ timeout: { enter: 225, exit: 195 } }}>
352
+ <AccordionSummary expandIcon={<ExpandMoreIcon />}>
308
353
  <Typography variant="subtitle1">Customize Grid Setup</Typography>
309
- </ExpansionPanelSummary>
310
- <ExpansionPanelDetails>
311
- <div className={classes.content}>
354
+ </AccordionSummary>
355
+ <AccordionDetails>
356
+ <Content>
312
357
  {includeAxesEnabled && (
313
358
  <Toggle label="Include axes and labels?" toggle={onIncludeAxes} checked={includeAxes} />
314
359
  )}
@@ -321,45 +366,46 @@ const GridSetup = (props) => {
321
366
  )}
322
367
  {includeAxes ? axesConfig : gridlinesConfig}
323
368
  {dimensionsEnabled && (
324
- <div className={classes.dimensions}>
369
+ <Dimensions>
325
370
  <div>
326
371
  <Typography>Dimensions(px)</Typography>
327
- <Typography className={classes.disabled}>
372
+ <DisabledText>
328
373
  Min {sizeConstraints.min}, Max {sizeConstraints.max}
329
- </Typography>
374
+ </DisabledText>
330
375
  </div>
331
- <NumberTextFieldCustom
332
- className={classes.textField}
333
- label="Width"
334
- value={size.width}
335
- min={sizeConstraints.min}
336
- max={sizeConstraints.max}
337
- step={sizeConstraints.step}
338
- variant="outlined"
339
- onChange={(e, v) => onSizeChanged('width', v)}
340
- />
341
- <NumberTextFieldCustom
342
- className={classes.textField}
343
- label="Height"
344
- value={size.height}
345
- min={sizeConstraints.min}
346
- max={sizeConstraints.max}
347
- step={sizeConstraints.step}
348
- variant="outlined"
349
- disabled={standardGrid}
350
- onChange={(e, v) => onSizeChanged('height', v)}
351
- />
352
- </div>
376
+ <TextFieldSmall>
377
+ <NumberTextFieldCustom
378
+ label="Width"
379
+ value={size.width}
380
+ min={sizeConstraints.min}
381
+ max={sizeConstraints.max}
382
+ step={sizeConstraints.step}
383
+ variant="outlined"
384
+ onChange={(e, v) => onSizeChanged('width', v)}
385
+ />
386
+ </TextFieldSmall>
387
+ <TextFieldSmall>
388
+ <NumberTextFieldCustom
389
+ label="Height"
390
+ value={size.height}
391
+ min={sizeConstraints.min}
392
+ max={sizeConstraints.max}
393
+ step={sizeConstraints.step}
394
+ variant="outlined"
395
+ disabled={standardGrid}
396
+ onChange={(e, v) => onSizeChanged('height', v)}
397
+ />
398
+ </TextFieldSmall>
399
+ </Dimensions>
353
400
  )}
354
- </div>
355
- </ExpansionPanelDetails>
356
- </ExpansionPanel>
357
- </div>
401
+ </Content>
402
+ </AccordionDetails>
403
+ </Accordion>
404
+ </Wrapper>
358
405
  );
359
406
  };
360
407
 
361
408
  GridSetup.propTypes = {
362
- classes: PropTypes.object,
363
409
  domain: PropTypes.object,
364
410
  displayedFields: PropTypes.object,
365
411
  gridValues: PropTypes.object,
@@ -373,52 +419,4 @@ GridSetup.propTypes = {
373
419
  standardGrid: PropTypes.bool,
374
420
  };
375
421
 
376
- const styles = (theme) => ({
377
- wrapper: {
378
- width: '450px',
379
- },
380
- content: {
381
- display: 'flex',
382
- flexDirection: 'column',
383
- width: '100%',
384
- },
385
- columnView: {
386
- display: 'flex',
387
- flexDirection: 'column',
388
- alignItems: 'center',
389
- },
390
- rowView: {
391
- display: 'flex',
392
- justifyContent: 'space-around',
393
- alignItems: 'center',
394
- },
395
- textField: {
396
- width: '130px',
397
- margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
398
- },
399
- mediumTextField: {
400
- width: '160px',
401
- margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
402
- },
403
- largeTextField: {
404
- width: '230px',
405
- margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
406
- },
407
- text: {
408
- fontStyle: 'italic',
409
- margin: `${theme.spacing.unit}px 0`,
410
- },
411
- dimensions: {
412
- display: 'flex',
413
- justifyContent: 'space-between',
414
- alignItems: 'center',
415
- },
416
- disabled: {
417
- color: color.disabled(),
418
- },
419
- axisLabel: {
420
- paddingTop: theme.spacing.unit * 2,
421
- },
422
- });
423
-
424
- export default withStyles(styles)(GridSetup);
422
+ export default GridSetup;
package/src/grid.jsx CHANGED
@@ -1,15 +1,13 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import * as vx from '@vx/grid';
3
+ import * as vx from '@visx/grid';
4
4
  import { types } from '@pie-lib/plot';
5
- import { withStyles } from '@material-ui/core/styles';
6
5
  import { getTickValues } from './utils';
7
6
 
8
7
  export class Grid extends React.Component {
9
8
  static propTypes = {
10
9
  disabled: PropTypes.bool,
11
10
  disabledAdditionalGrid: PropTypes.bool,
12
- classes: PropTypes.object.isRequired,
13
11
  graphProps: types.GraphPropsType.isRequired,
14
12
  };
15
13
 
@@ -132,4 +130,4 @@ export class Grid extends React.Component {
132
130
  }
133
131
  }
134
132
 
135
- export default withStyles(() => ({}))(Grid);
133
+ export default Grid;