grommet 2.32.1 → 2.33.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 (89) hide show
  1. package/all/stories/CustomThemed/ExtendTheme.tsx +2 -4
  2. package/components/Chart/Chart.js +20 -20
  3. package/components/Chart/calcs.js +163 -92
  4. package/components/Chart/index.d.ts +10 -4
  5. package/components/Chart/propTypes.js +10 -1
  6. package/components/Chart/stories/{Vertical.js → Horizontal.js} +34 -6
  7. package/components/Chart/utils.js +68 -64
  8. package/components/CheckBox/StyledCheckBox.js +2 -2
  9. package/components/DataChart/DataChart.js +114 -68
  10. package/components/DataChart/Detail.js +55 -21
  11. package/components/DataChart/XAxis.js +33 -6
  12. package/components/DataChart/XGuide.js +14 -1
  13. package/components/DataChart/YAxis.js +58 -39
  14. package/components/DataChart/YGuide.js +13 -10
  15. package/components/DataChart/index.d.ts +2 -0
  16. package/components/DataChart/propTypes.js +3 -1
  17. package/components/DataChart/stories/Horizontal.js +63 -0
  18. package/components/DataChart/utils.js +27 -2
  19. package/components/DataFilter/DataFilter.js +25 -2
  20. package/components/DataSort/DataSort.js +1 -1
  21. package/components/DataTable/buildState.js +6 -1
  22. package/components/DateInput/DateInput.js +22 -2
  23. package/components/Footer/stories/DoubleFooter.js +6 -2
  24. package/components/Footer/stories/Sitemap.js +0 -2
  25. package/components/Footer/stories/Social.js +2 -2
  26. package/components/Layer/LayerContainer.js +1 -1
  27. package/components/Menu/Menu.js +9 -6
  28. package/components/Meter/Bar.js +5 -2
  29. package/components/Meter/Meter.js +11 -3
  30. package/components/Meter/StyledMeter.js +3 -1
  31. package/components/Meter/index.d.ts +1 -0
  32. package/components/Meter/propTypes.js +1 -0
  33. package/components/Meter/stories/ReverseBar.js +29 -0
  34. package/components/Pagination/Pagination.js +3 -1
  35. package/components/Select/EmptySearchOption.js +3 -9
  36. package/components/Select/Select.js +1 -1
  37. package/components/Select/SelectContainer.js +4 -4
  38. package/components/Select/index.d.ts +1 -1
  39. package/components/Select/propTypes.js +1 -1
  40. package/components/SelectMultiple/SelectMultipleContainer.js +4 -4
  41. package/components/Text/Text.js +3 -1
  42. package/es6/all/stories/CustomThemed/ExtendTheme.tsx +2 -4
  43. package/es6/components/Chart/Chart.js +20 -20
  44. package/es6/components/Chart/calcs.js +164 -93
  45. package/es6/components/Chart/index.d.ts +10 -4
  46. package/es6/components/Chart/propTypes.js +10 -1
  47. package/es6/components/Chart/stories/{Vertical.js → Horizontal.js} +32 -4
  48. package/es6/components/Chart/utils.js +66 -63
  49. package/es6/components/CheckBox/StyledCheckBox.js +2 -2
  50. package/es6/components/DataChart/DataChart.js +115 -69
  51. package/es6/components/DataChart/Detail.js +55 -21
  52. package/es6/components/DataChart/XAxis.js +33 -6
  53. package/es6/components/DataChart/XGuide.js +14 -1
  54. package/es6/components/DataChart/YAxis.js +59 -40
  55. package/es6/components/DataChart/YGuide.js +13 -10
  56. package/es6/components/DataChart/index.d.ts +2 -0
  57. package/es6/components/DataChart/propTypes.js +3 -1
  58. package/es6/components/DataChart/stories/Horizontal.js +57 -0
  59. package/es6/components/DataChart/utils.js +22 -0
  60. package/es6/components/DataFilter/DataFilter.js +27 -3
  61. package/es6/components/DataSort/DataSort.js +1 -1
  62. package/es6/components/DataTable/buildState.js +6 -1
  63. package/es6/components/DateInput/DateInput.js +22 -2
  64. package/es6/components/Footer/stories/DoubleFooter.js +6 -2
  65. package/es6/components/Footer/stories/Sitemap.js +0 -2
  66. package/es6/components/Footer/stories/Social.js +2 -2
  67. package/es6/components/Layer/LayerContainer.js +1 -1
  68. package/es6/components/Menu/Menu.js +9 -6
  69. package/es6/components/Meter/Bar.js +5 -2
  70. package/es6/components/Meter/Meter.js +12 -4
  71. package/es6/components/Meter/StyledMeter.js +3 -1
  72. package/es6/components/Meter/index.d.ts +1 -0
  73. package/es6/components/Meter/propTypes.js +1 -0
  74. package/es6/components/Meter/stories/ReverseBar.js +23 -0
  75. package/es6/components/Pagination/Pagination.js +3 -1
  76. package/es6/components/Select/EmptySearchOption.js +3 -9
  77. package/es6/components/Select/Select.js +1 -1
  78. package/es6/components/Select/SelectContainer.js +4 -4
  79. package/es6/components/Select/index.d.ts +1 -1
  80. package/es6/components/Select/propTypes.js +1 -1
  81. package/es6/components/SelectMultiple/SelectMultipleContainer.js +4 -4
  82. package/es6/components/Text/Text.js +3 -1
  83. package/es6/themes/base.d.ts +9 -1
  84. package/es6/themes/base.js +4 -0
  85. package/grommet.min.js +1 -1
  86. package/grommet.min.js.map +1 -1
  87. package/package.json +39 -39
  88. package/themes/base.d.ts +9 -1
  89. package/themes/base.js +4 -0
@@ -1,4 +1,4 @@
1
- import { normalizeValues } from './utils';
1
+ import { calcMinMax, normalizeValues } from './utils';
2
2
  var thicknessPad = {
3
3
  xlarge: 'large',
4
4
  large: 'medium',
@@ -9,6 +9,37 @@ var thicknessPad = {
9
9
  export var round = function round(value, decimals) {
10
10
  return Number(Math.round(value + "e" + decimals) + "e-" + decimals);
11
11
  };
12
+
13
+ // Normalize coarseness to an object.
14
+ // Backwards compatible has no coarseness for x-axis.
15
+ var normalizeCoarseness = function normalizeCoarseness(coarseness, direction) {
16
+ var result;
17
+ if (Array.isArray(coarseness)) result = {
18
+ x: coarseness[0],
19
+ y: coarseness[1]
20
+ };else if (typeof coarseness === 'object') result = coarseness;else if (coarseness) result = {
21
+ x: undefined,
22
+ y: coarseness
23
+ };else result = direction === 'horizontal' ? {
24
+ x: 5,
25
+ y: undefined
26
+ } : {
27
+ x: undefined,
28
+ y: 5
29
+ };
30
+ return result;
31
+ };
32
+ var normalizeSteps = function normalizeSteps(steps) {
33
+ var result;
34
+ if (Array.isArray(steps)) result = {
35
+ x: steps[0],
36
+ y: steps[1]
37
+ };else if (typeof steps === 'object') result = steps;else result = {
38
+ x: 1,
39
+ y: 1
40
+ };
41
+ return result;
42
+ };
12
43
  var alignMax = function alignMax(value, interval) {
13
44
  if (value > 0) return value - value % interval + interval;
14
45
  if (value < 0) return value + value % interval;
@@ -19,56 +50,60 @@ var alignMin = function alignMin(value, interval) {
19
50
  if (value < 0) return value - value % interval - interval;
20
51
  return value;
21
52
  };
22
- export var calcBounds = function calcBounds(values, options) {
53
+ var adjustToShowZero = function adjustToShowZero(minArg, maxArg, steps) {
54
+ var min = minArg;
55
+ var max = maxArg;
56
+ if (min < 0 && max > 0 && Math.abs(min) !== Math.abs(max)) {
57
+ // Adjust min and max when crossing 0 to ensure 0 will be shown on
58
+ // the axis based on the number of steps.
59
+ if (steps === 1) {
60
+ var largest = Math.max(Math.abs(min), Math.abs(max));
61
+ min = -largest;
62
+ max = largest;
63
+ } else {
64
+ var stepInterval = (max - min) / steps;
65
+ var minSteps = min / stepInterval;
66
+ var maxSteps = max / stepInterval;
67
+ if (Math.abs(minSteps) < Math.abs(maxSteps)) {
68
+ // more above than below
69
+ stepInterval = max / Math.floor(maxSteps);
70
+ max = stepInterval * Math.floor(maxSteps);
71
+ min = stepInterval * Math.floor(minSteps);
72
+ } else {
73
+ // more below than above
74
+ stepInterval = Math.abs(min / Math.ceil(minSteps));
75
+ min = stepInterval * Math.ceil(minSteps);
76
+ max = stepInterval * Math.ceil(maxSteps);
77
+ }
78
+ }
79
+ }
80
+ return [min, max];
81
+ };
82
+ export var calcBounds = function calcBounds(valuesArg, options) {
23
83
  if (options === void 0) {
24
84
  options = {};
25
85
  }
26
86
  // coarseness influences the rounding of the bounds, the smaller the
27
- // number, the more the bounds will be rounded. e.g. 111 -> 110 -> 100
28
- // Normalize to an array. Backwards compatible has no coarseness for x-axis
29
- var coarseness = Array.isArray(options.coarseness) && options.coarseness || options.coarseness && [undefined, options.coarseness] || [undefined, 5];
30
- var coarseX = coarseness[0],
31
- coarseY = coarseness[1];
32
- // the number of steps is one less than the number of labels
33
- var steps = options.steps || [1, 1];
34
- var stepsY = steps[1];
35
- var calcValues = normalizeValues(values || []);
36
-
37
- // min and max values
38
- var minX;
39
- var maxX;
40
- var minY;
41
- var maxY;
42
- if (calcValues.length) {
43
- // Calculate the max and min values.
44
- calcValues.filter(function (value) {
45
- return value !== undefined;
46
- }).forEach(function (value) {
47
- var x = value.value[0];
48
- if (x !== undefined) {
49
- minX = minX === undefined ? x : Math.min(minX, x);
50
- maxX = maxX === undefined ? x : Math.max(maxX, x);
51
- }
52
- var y = value.value[1];
53
- if (y !== undefined) {
54
- minY = minY === undefined ? y : Math.min(minY, y);
55
- maxY = maxY === undefined ? y : Math.max(maxY, y);
56
- }
57
- // handle ranges of values
58
- var y2 = value.value[2];
59
- if (y2 !== undefined) {
60
- minY = Math.min(minY, y2);
61
- maxY = Math.max(maxY, y2);
62
- }
63
- });
87
+ // number, the more the bounds will be rounded. e.g. 111 -> 110 -> 100.
88
+ var _normalizeCoarseness = normalizeCoarseness(options.coarseness, options.direction),
89
+ coarseX = _normalizeCoarseness.x,
90
+ coarseY = _normalizeCoarseness.y;
64
91
 
65
- // when max === min, offset them so we can show something
66
- if (maxX === minX) {
67
- if (maxX > 0) minX = maxX - 1;else maxX = minX + 1;
68
- }
69
- if (maxY === minY) {
70
- if (maxY > 0) minY = maxY - 1;else maxY = minY + 1;
71
- }
92
+ // the number of steps is one less than the number of labels
93
+ var _normalizeSteps = normalizeSteps(options.steps),
94
+ stepsX = _normalizeSteps.x,
95
+ stepsY = _normalizeSteps.y;
96
+ var values = normalizeValues(valuesArg || []);
97
+ var result;
98
+ if (values.length) {
99
+ // min and max values
100
+ var _calcMinMax = calcMinMax(values, options.direction),
101
+ _calcMinMax$x = _calcMinMax.x,
102
+ minX = _calcMinMax$x.min,
103
+ maxX = _calcMinMax$x.max,
104
+ _calcMinMax$y = _calcMinMax.y,
105
+ minY = _calcMinMax$y.min,
106
+ maxY = _calcMinMax$y.max;
72
107
 
73
108
  // Calculate some reasonable bounds based on the max and min values.
74
109
  // This is so values like 87342.12 don't end up being displayed as the
@@ -85,35 +120,41 @@ export var calcBounds = function calcBounds(values, options) {
85
120
  minY = alignMin(minY, intervalY);
86
121
  maxY = alignMax(maxY, intervalY);
87
122
  }
88
- if (minY < 0 && maxY > 0 && Math.abs(minY) !== Math.abs(maxY)) {
89
- // Adjust min and max when crossing 0 to ensure 0 will be shown on
90
- // the Y axis based on the number of steps.
91
- if (stepsY === 1) {
92
- var largest = Math.max(Math.abs(minY), Math.abs(maxY));
93
- minY = -largest;
94
- maxY = largest;
95
- } else {
96
- var stepInterval = (maxY - minY) / stepsY;
97
- var minSteps = minY / stepInterval;
98
- var maxSteps = maxY / stepInterval;
99
- if (Math.abs(minSteps) < Math.abs(maxSteps)) {
100
- // more above than below
101
- stepInterval = maxY / Math.floor(maxSteps);
102
- maxY = stepInterval * Math.floor(maxSteps);
103
- minY = stepInterval * Math.floor(minSteps);
104
- } else {
105
- // more below than above
106
- stepInterval = Math.abs(minY / Math.ceil(minSteps));
107
- minY = stepInterval * Math.ceil(minSteps);
108
- maxY = stepInterval * Math.ceil(maxSteps);
109
- }
110
- }
123
+ if (options.direction === 'horizontal') {
124
+ var _adjustToShowZero = adjustToShowZero(minX, maxX, stepsX);
125
+ minX = _adjustToShowZero[0];
126
+ maxX = _adjustToShowZero[1];
127
+ } else {
128
+ var _adjustToShowZero2 = adjustToShowZero(minY, maxY, stepsY);
129
+ minY = _adjustToShowZero2[0];
130
+ maxY = _adjustToShowZero2[1];
111
131
  }
132
+
133
+ // if options.direction is present, the results are delivered in { x, y }
134
+ // object structure. If options.direction is not present, the results are
135
+ // delivered in [x, y] array structure, for backwards compatibility
136
+ result = options.direction ? {
137
+ x: {
138
+ min: minX,
139
+ max: maxX
140
+ },
141
+ y: {
142
+ min: minY,
143
+ max: maxY
144
+ }
145
+ } : [[minX, maxX], [minY, maxY]];
146
+ } else {
147
+ result = options.direction ? {
148
+ x: {},
149
+ y: {}
150
+ } : [[], []];
112
151
  }
113
- var bounds;
114
- if (calcValues.length) bounds = [[minX, maxX], [minY, maxY]];else bounds = [[], []];
115
- return bounds;
152
+ return result;
116
153
  };
154
+
155
+ // if options.direction is present, the results are delivered in { x, y }
156
+ // object structure. If options.direction is not present, the results are
157
+ // delivered in [x, y] array structure, for backwards compatibility
117
158
  export var calcs = function calcs(values, options) {
118
159
  if (values === void 0) {
119
160
  values = [];
@@ -121,37 +162,64 @@ export var calcs = function calcs(values, options) {
121
162
  if (options === void 0) {
122
163
  options = {};
123
164
  }
165
+ var horizontal = options.direction === 'horizontal';
166
+
124
167
  // the number of steps is one less than the number of labels
125
- var steps = options.steps || [1, 1];
126
- var stepsX = steps[0],
127
- stepsY = steps[1];
168
+ var _normalizeSteps2 = normalizeSteps(options.steps),
169
+ stepsX = _normalizeSteps2.x,
170
+ stepsY = _normalizeSteps2.y;
171
+
172
+ // bounds is { x: { min, max }, y: { min, max } } when options.direction is
173
+ // present and [[min, max], [min, max]] if not, for backwards compatibility
128
174
  var bounds = options.bounds || calcBounds(values, options);
129
- if (options.min !== undefined) bounds[1][0] = options.min;
130
- if (options.max !== undefined) bounds[1][1] = options.max;
131
- var boundsX = bounds[0],
132
- boundsY = bounds[1];
133
- var boundsXmin = boundsX[0],
134
- boundsXmax = boundsX[1];
135
- var boundsYmin = boundsY[0],
136
- boundsYmax = boundsY[1];
137
- var dimensions = [round(boundsXmax - boundsXmin, 2), round(boundsYmax - boundsYmin, 2)];
138
- var dimensionsX = dimensions[0],
139
- dimensionsY = dimensions[1];
175
+ if (options.min !== undefined) {
176
+ if (options.direction) {
177
+ if (horizontal) bounds.x.min = options.min;else bounds.y.min = options.min;
178
+ } else bounds[1][0] = options.min;
179
+ }
180
+ if (options.max !== undefined) {
181
+ if (options.direction) {
182
+ if (horizontal) bounds.y.max = options.max;else bounds.x.max = options.max;
183
+ } else bounds[1][1] = options.max;
184
+ }
185
+ var _ref = options.direction ? bounds : {
186
+ x: {
187
+ min: bounds[0][0],
188
+ max: bounds[0][1]
189
+ },
190
+ y: {
191
+ min: bounds[1][0],
192
+ max: bounds[1][1]
193
+ }
194
+ },
195
+ _ref$x = _ref.x,
196
+ minX = _ref$x.min,
197
+ maxX = _ref$x.max,
198
+ _ref$y = _ref.y,
199
+ minY = _ref$y.min,
200
+ maxY = _ref$y.max;
201
+ var width = round(maxX - minX, 2);
202
+ var height = round(maxY - minY, 2);
203
+ var dimensions = options.direction ? {
204
+ width: width,
205
+ height: height
206
+ } : [width, height];
140
207
 
141
208
  // Calculate x and y axis values across the specfied number of steps.
142
209
  var yAxis = [];
143
- var y = boundsYmax;
210
+ var y = maxY;
144
211
  // To deal with javascript math limitations, round the step with 4 decimal
145
212
  // places and then push the values with 2 decimal places
146
- var yStepInterval = round(dimensionsY / stepsY, 4);
147
- while (round(y, 2) >= boundsYmin) {
213
+ var yStepInterval = round(height / stepsY, 4);
214
+ while (round(y, 2) >= minY) {
148
215
  yAxis.push(round(y, 2));
149
216
  y -= yStepInterval;
150
217
  }
218
+ if (horizontal) yAxis.reverse();
151
219
  var xAxis = [];
152
- var x = boundsXmin;
153
- var xStepInterval = round(dimensionsX / stepsX, 4);
154
- while (round(x, 2) <= boundsXmax) {
220
+ var x = minX;
221
+ var xStepInterval = round(width / stepsX, 4);
222
+ while (round(x, 2) <= maxX) {
155
223
  xAxis.push(round(x, 2));
156
224
  x += xStepInterval;
157
225
  }
@@ -178,7 +246,10 @@ export var calcs = function calcs(values, options) {
178
246
  }
179
247
  var pad = thicknessPad[thickness];
180
248
  return {
181
- axis: [xAxis, yAxis],
249
+ axis: options.direction ? {
250
+ x: xAxis,
251
+ y: yAxis
252
+ } : [xAxis, yAxis],
182
253
  bounds: bounds,
183
254
  dimensions: dimensions,
184
255
  pad: pad,
@@ -16,7 +16,10 @@ export interface ChartProps {
16
16
  animate?: boolean;
17
17
  gridArea?: GridAreaType;
18
18
  margin?: MarginType;
19
- bounds?: number[][];
19
+ // caller must align with direction
20
+ bounds?:
21
+ | { x: { min: number; max: number }; y: { min: number; max: number } }
22
+ | number[][];
20
23
  color?:
21
24
  | ColorType
22
25
  | { color: ColorType; value: number | number[] }[]
@@ -105,12 +108,15 @@ export interface ChartExtendedProps
105
108
 
106
109
  declare const Chart: React.FC<ChartExtendedProps>;
107
110
 
108
- type Bounds = [[number, number], [number, number]] | [[], []];
111
+ type Bounds =
112
+ | { x: { min: number; max: number }; y: { min: number; max: number } }
113
+ | [[number, number], [number, number]]
114
+ | [[], []];
109
115
 
110
116
  interface CalcsResult {
111
- axis: [number[], number[]];
117
+ axis: { x: number[]; y: number[] } | [number[], number[]];
112
118
  bounds: Bounds;
113
- dimensions: [number, number];
119
+ dimensions: { width: number; height: number } | [number, number];
114
120
  pad: string;
115
121
  thickness: string;
116
122
  }
@@ -6,7 +6,16 @@ var PropType = {};
6
6
  if (process.env.NODE_ENV !== 'production') {
7
7
  PropType = _extends({}, genericProps, {
8
8
  animate: PropTypes.bool,
9
- bounds: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
9
+ bounds: PropTypes.oneOfType([PropTypes.shape({
10
+ x: PropTypes.shape({
11
+ min: PropTypes.number,
12
+ max: PropTypes.number
13
+ }),
14
+ y: PropTypes.shape({
15
+ min: PropTypes.number,
16
+ max: PropTypes.number
17
+ })
18
+ }), PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number))]),
10
19
  color: PropTypes.oneOfType([colorPropType, PropTypes.shape({
11
20
  color: colorPropType,
12
21
  // deprecated, use top level 'opacity'
@@ -1,6 +1,19 @@
1
1
  import React from 'react';
2
2
  import { Box, Chart } from 'grommet';
3
- export var Vertical = function Vertical() {
3
+ var gradient = [{
4
+ value: 0,
5
+ color: 'status-ok'
6
+ }, {
7
+ value: 25,
8
+ color: 'status-ok'
9
+ }, {
10
+ value: 27,
11
+ color: 'status-warning'
12
+ }, {
13
+ value: 30,
14
+ color: 'status-critical'
15
+ }];
16
+ export var Horizontal = function Horizontal() {
4
17
  return (
5
18
  /*#__PURE__*/
6
19
  // Uncomment <Grommet> lines when using outside of storybook
@@ -14,7 +27,7 @@ export var Vertical = function Vertical() {
14
27
  key: type,
15
28
  direction: "row",
16
29
  gap: "medium"
17
- }, ['horizontal', 'vertical'].map(function (direction) {
30
+ }, ['vertical', 'horizontal'].map(function (direction) {
18
31
  return /*#__PURE__*/React.createElement(Box, {
19
32
  key: direction,
20
33
  border: true
@@ -25,11 +38,26 @@ export var Vertical = function Vertical() {
25
38
  values: [[10, 20], [20, 30], [30, 15]]
26
39
  }));
27
40
  }));
28
- }))
41
+ }), /*#__PURE__*/React.createElement(Box, {
42
+ direction: "row",
43
+ gap: "medium"
44
+ }, ['vertical', 'horizontal'].map(function (direction) {
45
+ return /*#__PURE__*/React.createElement(Box, {
46
+ key: direction,
47
+ border: true
48
+ }, /*#__PURE__*/React.createElement(Chart, {
49
+ id: direction,
50
+ type: "line",
51
+ direction: direction,
52
+ color: gradient,
53
+ values: [20, 30, 15],
54
+ size: "small"
55
+ }));
56
+ })))
29
57
  // </Grommet>
30
58
  );
31
59
  };
32
60
 
33
61
  export default {
34
- title: 'Visualizations/Chart/Vertical'
62
+ title: 'Visualizations/Chart/Horizontal'
35
63
  };
@@ -12,72 +12,75 @@ export var normalizeValues = function normalizeValues(values) {
12
12
  };
13
13
  });
14
14
  };
15
+ export var calcMinMax = function calcMinMax(values, direction) {
16
+ var _ref, _ref2, _ref3, _ref4;
17
+ if (values === void 0) {
18
+ values = [];
19
+ }
20
+ // We default to 0 minimum as that's typically what's wanted.
21
+ // If callers want a narrower band, they can pass bounds explicitly.
22
+ var min0 = (_ref = direction && 0) != null ? _ref : undefined;
23
+ var max0 = (_ref2 = direction && 1) != null ? _ref2 : undefined;
24
+ var min1 = (_ref3 = direction && 0) != null ? _ref3 : undefined;
25
+ var max1 = (_ref4 = direction && 1) != null ? _ref4 : undefined;
26
+ values.forEach(function (value) {
27
+ var _value$value = value.value,
28
+ val0 = _value$value[0],
29
+ val1 = _value$value[1],
30
+ val2 = _value$value[2];
31
+ if (val0 !== undefined) {
32
+ min0 = min0 === undefined ? val0 : Math.min(min0, val0);
33
+ max0 = max0 === undefined ? val0 : Math.max(max0, val0);
34
+ }
35
+ if (val1 !== undefined) {
36
+ min1 = min1 === undefined ? val1 : Math.min(min1, val1);
37
+ max1 = max1 === undefined ? val1 : Math.max(max1, val1);
38
+ }
39
+ if (val2 !== undefined) {
40
+ min1 = min1 === undefined ? val2 : Math.min(min1, val2);
41
+ max1 = max1 === undefined ? val2 : Math.max(max1, val2);
42
+ }
43
+ });
44
+
45
+ // when max === min, offset them so we can show something
46
+ if (max0 === min0) {
47
+ if (max0 > 0) min0 = max0 - 1;else max0 = min0 + 1;
48
+ }
49
+ if (max1 === min1) {
50
+ if (max1 > 0) min1 = max1 - 1;else max1 = min1 + 1;
51
+ }
52
+ return direction === 'horizontal' ? {
53
+ x: {
54
+ min: min1,
55
+ max: max1
56
+ },
57
+ y: {
58
+ min: min0,
59
+ max: max0
60
+ }
61
+ } : {
62
+ x: {
63
+ min: min0,
64
+ max: max0
65
+ },
66
+ y: {
67
+ min: min1,
68
+ max: max1
69
+ }
70
+ };
71
+ };
15
72
  export var normalizeBounds = function normalizeBounds(boundsProp, values, direction) {
16
- var vertical = direction === 'vertical';
17
73
  var result;
18
- if (boundsProp) {
19
- if (vertical) result = {
20
- x: {
21
- min: boundsProp[1][0],
22
- max: boundsProp[1][1]
23
- },
24
- y: {
25
- min: boundsProp[0][0],
26
- max: boundsProp[0][1]
27
- }
28
- };else result = {
29
- x: {
30
- min: boundsProp[0][0],
31
- max: boundsProp[0][1]
32
- },
33
- y: {
34
- min: boundsProp[1][0],
35
- max: boundsProp[1][1]
36
- }
37
- };
38
- } else {
39
- var min0 = 0;
40
- var max0 = 1;
41
- var min1 = 0;
42
- var max1 = 1;
43
- (values || []).forEach(function (value) {
44
- if (value.value[0] !== undefined) {
45
- min0 = Math.min(min0, value.value[0]);
46
- max0 = Math.max(max0, value.value[0]);
47
- }
48
- if (value.value[1] !== undefined) {
49
- min1 = Math.min(min1, value.value[1]);
50
- max1 = Math.max(max1, value.value[1]);
51
- }
52
- if (value.value[2] !== undefined) {
53
- min1 = Math.min(min1, value.value[2]);
54
- max1 = Math.max(max1, value.value[2]);
55
- }
56
- });
57
- if (vertical) {
58
- result = {
59
- x: {
60
- min: min1,
61
- max: max1
62
- },
63
- y: {
64
- min: min0,
65
- max: max0
66
- }
67
- };
68
- } else {
69
- result = {
70
- x: {
71
- min: min0,
72
- max: max0
73
- },
74
- y: {
75
- min: min1,
76
- max: max1
77
- }
78
- };
74
+ if (Array.isArray(boundsProp)) result = {
75
+ x: {
76
+ min: boundsProp[0][0],
77
+ max: boundsProp[0][1]
78
+ },
79
+ y: {
80
+ min: boundsProp[1][0],
81
+ max: boundsProp[1][1]
79
82
  }
80
- }
83
+ };else if (typeof boundsProp === 'object') result = boundsProp;else result = calcMinMax(values, direction);
81
84
  return result;
82
85
  };
83
86
  export var areNormalizedValuesEquals = function areNormalizedValuesEquals(valuesX, valuesY) {
@@ -6,7 +6,7 @@ import { defaultProps } from '../../default-props';
6
6
  // added to it to simplify its logic. If this is ever reused somewhere else,
7
7
  // consider the need of separating those once again.
8
8
  var fillStyle = function fillStyle() {
9
- return "\n width: 100%;\n height: 100%;\n max-width: none;\n flex: 1 0 auto;\n justify-content: space-between;\n ";
9
+ return "\n width: auto;\n height: 100%;\n max-width: none;\n flex: 1 0 auto;\n justify-content: space-between;\n ";
10
10
  };
11
11
  var disabledStyle = "\n opacity: 0.5;\n cursor: default;\n";
12
12
  var hoverStyle = css([":hover input:not([disabled]) + div,:hover input:not([disabled]) + span{border-color:", ";", "}:hover{background-color:", ";}"], function (props) {
@@ -50,7 +50,7 @@ var StyledCheckBoxContainer = styled.label.withConfig({
50
50
  return !props.disabled && 'cursor: pointer;';
51
51
  }, hoverStyle, function (props) {
52
52
  var _props$theme$checkBox6, _props$theme$checkBox7, _props$theme$checkBox8, _props$theme$checkBox9;
53
- return props.focus && !props.focusIndicator && "\n input:not([disabled]) + div,\n input:not([disabled]) + span {\n border-color: " + normalizeColor((_props$theme$checkBox6 = props.theme.checkBox.hover) == null ? void 0 : (_props$theme$checkBox7 = _props$theme$checkBox6.border) == null ? void 0 : _props$theme$checkBox7.color, props.theme) + ";\n }\n \n background-color: " + normalizeColor(!props.disabled && ((_props$theme$checkBox8 = props.theme.checkBox.hover) == null ? void 0 : (_props$theme$checkBox9 = _props$theme$checkBox8.background) == null ? void 0 : _props$theme$checkBox9.color), props.theme) + ";";
53
+ return props.focus && !props.focusIndicator && "\n input:not([disabled]) + div,\n input:not([disabled]) + span {\n border-color: " + normalizeColor((_props$theme$checkBox6 = props.theme.checkBox.hover) == null ? void 0 : (_props$theme$checkBox7 = _props$theme$checkBox6.border) == null ? void 0 : _props$theme$checkBox7.color, props.theme) + ";\n }\n\n background-color: " + normalizeColor(!props.disabled && ((_props$theme$checkBox8 = props.theme.checkBox.hover) == null ? void 0 : (_props$theme$checkBox9 = _props$theme$checkBox8.background) == null ? void 0 : _props$theme$checkBox9.color), props.theme) + ";";
54
54
  }, function (props) {
55
55
  return props.theme.checkBox.extend;
56
56
  });