grommet 2.32.0 → 2.32.2

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 (79) hide show
  1. package/components/Chart/Chart.js +113 -57
  2. package/components/Chart/index.d.ts +3 -0
  3. package/components/Chart/propTypes.js +1 -0
  4. package/components/Chart/stories/Layout.js +6 -3
  5. package/components/Chart/stories/Pattern.js +1 -0
  6. package/components/Chart/stories/Vertical.js +41 -0
  7. package/components/Chart/utils.js +57 -10
  8. package/components/CheckBox/StyledCheckBox.js +2 -2
  9. package/components/Data/Data.js +2 -1
  10. package/components/Data/filter.js +10 -7
  11. package/components/DataFilter/DataFilter.js +26 -21
  12. package/components/DataTable/GroupedBody.js +1 -1
  13. package/components/DataTable/buildState.js +1 -1
  14. package/components/Drop/DropContainer.js +3 -2
  15. package/components/Layer/LayerContainer.js +1 -1
  16. package/components/Meter/Bar.js +5 -2
  17. package/components/Meter/Meter.js +11 -3
  18. package/components/Meter/StyledMeter.js +3 -1
  19. package/components/Meter/index.d.ts +1 -0
  20. package/components/Meter/propTypes.js +1 -0
  21. package/components/Meter/stories/ReverseBar.js +29 -0
  22. package/components/Pagination/Pagination.js +3 -1
  23. package/components/RadioButtonGroup/RadioButtonGroup.js +19 -4
  24. package/components/RadioButtonGroup/stories/typescript/Simple.tsx +6 -4
  25. package/components/Select/EmptySearchOption.js +3 -9
  26. package/components/Select/SelectContainer.js +4 -4
  27. package/components/Select/index.d.ts +1 -1
  28. package/components/Select/propTypes.js +1 -1
  29. package/components/SelectMultiple/SelectMultipleContainer.js +4 -4
  30. package/components/Text/Text.js +3 -1
  31. package/components/index.d.ts +2 -1
  32. package/contexts/DataContext.js +2 -1
  33. package/es6/components/Chart/Chart.js +113 -57
  34. package/es6/components/Chart/index.d.ts +3 -0
  35. package/es6/components/Chart/propTypes.js +1 -0
  36. package/es6/components/Chart/stories/Layout.js +6 -3
  37. package/es6/components/Chart/stories/Pattern.js +1 -0
  38. package/es6/components/Chart/stories/Vertical.js +35 -0
  39. package/es6/components/Chart/utils.js +57 -10
  40. package/es6/components/CheckBox/StyledCheckBox.js +2 -2
  41. package/es6/components/Data/Data.js +2 -1
  42. package/es6/components/Data/filter.js +10 -7
  43. package/es6/components/DataFilter/DataFilter.js +26 -21
  44. package/es6/components/DataTable/GroupedBody.js +1 -1
  45. package/es6/components/DataTable/buildState.js +1 -1
  46. package/es6/components/Drop/DropContainer.js +3 -2
  47. package/es6/components/Layer/LayerContainer.js +1 -1
  48. package/es6/components/Meter/Bar.js +5 -2
  49. package/es6/components/Meter/Meter.js +12 -4
  50. package/es6/components/Meter/StyledMeter.js +3 -1
  51. package/es6/components/Meter/index.d.ts +1 -0
  52. package/es6/components/Meter/propTypes.js +1 -0
  53. package/es6/components/Meter/stories/ReverseBar.js +23 -0
  54. package/es6/components/Pagination/Pagination.js +3 -1
  55. package/es6/components/RadioButtonGroup/RadioButtonGroup.js +19 -4
  56. package/es6/components/RadioButtonGroup/stories/typescript/Simple.tsx +6 -4
  57. package/es6/components/Select/EmptySearchOption.js +3 -9
  58. package/es6/components/Select/SelectContainer.js +4 -4
  59. package/es6/components/Select/index.d.ts +1 -1
  60. package/es6/components/Select/propTypes.js +1 -1
  61. package/es6/components/SelectMultiple/SelectMultipleContainer.js +4 -4
  62. package/es6/components/Text/Text.js +3 -1
  63. package/es6/components/index.d.ts +2 -1
  64. package/es6/contexts/DataContext.js +2 -1
  65. package/es6/index.d.ts +11 -0
  66. package/es6/index.js +2 -0
  67. package/es6/themes/base.d.ts +4 -0
  68. package/es6/themes/base.js +4 -0
  69. package/es6/utils/index.d.ts +1 -1
  70. package/es6/utils/refs.js +1 -1
  71. package/grommet.min.js +1 -1
  72. package/grommet.min.js.map +1 -1
  73. package/index.d.ts +11 -0
  74. package/index.js +1 -0
  75. package/package.json +36 -36
  76. package/themes/base.d.ts +4 -0
  77. package/themes/base.js +4 -0
  78. package/utils/index.d.ts +1 -1
  79. package/utils/refs.js +1 -1
@@ -1,4 +1,4 @@
1
- var _excluded = ["a11yTitle", "bounds", "color", "dash", "gap", "id", "onClick", "onHover", "opacity", "overflow", "pad", "pattern", "point", "round", "size", "thickness", "type", "values"],
1
+ var _excluded = ["a11yTitle", "bounds", "color", "dash", "direction", "gap", "id", "onClick", "onHover", "opacity", "overflow", "pad", "pattern", "point", "round", "size", "thickness", "type", "values"],
2
2
  _excluded2 = ["color", "label", "onHover", "opacity", "thickness", "value"],
3
3
  _excluded3 = ["color", "label", "onHover", "opacity", "thickness", "value"];
4
4
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -21,14 +21,15 @@ var defaultSize = {
21
21
  var defaultValues = [];
22
22
  var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
23
23
  var a11yTitle = _ref.a11yTitle,
24
- propsBounds = _ref.bounds,
24
+ boundsProp = _ref.bounds,
25
25
  color = _ref.color,
26
26
  dash = _ref.dash,
27
+ direction = _ref.direction,
27
28
  gap = _ref.gap,
28
29
  id = _ref.id,
29
30
  onClick = _ref.onClick,
30
31
  onHover = _ref.onHover,
31
- propsOpacity = _ref.opacity,
32
+ opacityProp = _ref.opacity,
32
33
  _ref$overflow = _ref.overflow,
33
34
  overflow = _ref$overflow === void 0 ? false : _ref$overflow,
34
35
  pad = _ref.pad,
@@ -36,50 +37,62 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
36
37
  point = _ref.point,
37
38
  round = _ref.round,
38
39
  _ref$size = _ref.size,
39
- propsSize = _ref$size === void 0 ? defaultSize : _ref$size,
40
+ sizeProp = _ref$size === void 0 ? defaultSize : _ref$size,
40
41
  _ref$thickness = _ref.thickness,
41
42
  thickness = _ref$thickness === void 0 ? 'medium' : _ref$thickness,
42
43
  _ref$type = _ref.type,
43
44
  type = _ref$type === void 0 ? 'bar' : _ref$type,
44
45
  _ref$values = _ref.values,
45
- propsValues = _ref$values === void 0 ? defaultValues : _ref$values,
46
+ valuesProp = _ref$values === void 0 ? defaultValues : _ref$values,
46
47
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
47
48
  var containerRef = useForwardedRef(ref);
48
49
  var theme = useContext(ThemeContext) || defaultProps.theme;
49
-
50
- // normalize variables
51
-
52
50
  var values = useMemo(function () {
53
- return normalizeValues(propsValues);
54
- }, [propsValues]);
51
+ return normalizeValues(valuesProp);
52
+ }, [valuesProp]);
53
+ var vertical = useMemo(function () {
54
+ return direction === 'vertical';
55
+ }, [direction]);
56
+
57
+ // bounds is { x: { min, max }, y: { min, max } }, accounting for direction
55
58
  var bounds = useMemo(function () {
56
- return normalizeBounds(propsBounds, values);
57
- }, [propsBounds, values]);
59
+ return normalizeBounds(boundsProp, values, direction);
60
+ }, [direction, boundsProp, values]);
58
61
  var strokeWidth = useMemo(function () {
59
62
  return parseMetricToNum(theme.global.edgeSize[thickness] || thickness);
60
63
  }, [theme.global.edgeSize, thickness]);
64
+
65
+ // inset is { top, left, bottom, right }
61
66
  var inset = useMemo(function () {
62
- var result = [0, 0, 0, 0];
67
+ var result = {
68
+ top: 0,
69
+ left: 0,
70
+ bottom: 0,
71
+ right: 0
72
+ };
63
73
  if (pad) {
64
74
  if (pad.horizontal) {
65
75
  var padSize = parseMetricToNum(theme.global.edgeSize[pad.horizontal] || pad.horizontal);
66
- result[0] = padSize;
67
- result[2] = padSize;
76
+ result.left = padSize;
77
+ result.right = padSize;
68
78
  }
69
79
  if (pad.vertical) {
70
80
  var _padSize = parseMetricToNum(theme.global.edgeSize[pad.vertical] || pad.vertical);
71
- result[1] = _padSize;
72
- result[3] = _padSize;
81
+ result.top = _padSize;
82
+ result.bottom = _padSize;
73
83
  }
74
84
  if (pad.start) {
75
- result[0] = parseMetricToNum(theme.global.edgeSize[pad.start] || pad.start);
85
+ result.left = parseMetricToNum(theme.global.edgeSize[pad.start] || pad.start);
76
86
  }
77
87
  if (pad.end) {
78
- result[2] = parseMetricToNum(theme.global.edgeSize[pad.end] || pad.end);
88
+ result.right = parseMetricToNum(theme.global.edgeSize[pad.end] || pad.end);
79
89
  }
80
90
  if (typeof pad === 'string') {
81
91
  var _padSize2 = parseMetricToNum(theme.global.edgeSize[pad]);
82
- result = [_padSize2, _padSize2, _padSize2, _padSize2];
92
+ result.top = _padSize2;
93
+ result.left = _padSize2;
94
+ result.bottom = _padSize2;
95
+ result.right = _padSize2;
83
96
  }
84
97
  }
85
98
  return result;
@@ -98,36 +111,51 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
98
111
  containerSize = _useState[0],
99
112
  setContainerSize = _useState[1];
100
113
  var needContainerSize = useMemo(function () {
101
- return propsSize && (propsSize === 'full' || propsSize === 'fill' || propsSize.height === 'full' || propsSize.height === 'fill' || propsSize.width === 'full' || propsSize.width === 'fill');
102
- }, [propsSize]);
114
+ return sizeProp && (sizeProp === 'full' || sizeProp === 'fill' || sizeProp.height === 'full' || sizeProp.height === 'fill' || sizeProp.width === 'full' || sizeProp.width === 'fill');
115
+ }, [sizeProp]);
116
+
117
+ // size is { width, height }
103
118
  var size = useMemo(function () {
104
119
  var gapWidth = gap ? parseMetricToNum(theme.global.edgeSize[gap] || gap) : strokeWidth;
105
120
 
106
- // autoWidth is how wide we'd pefer
107
- var autoWidth = strokeWidth * values.length + (values.length - 1) * gapWidth;
108
- var sizeWidth = typeof propsSize === 'string' ? propsSize : propsSize.width || defaultSize.width;
121
+ // autoSize is how wide or tall we'd pefer based on the number of values
122
+ var autoSize = strokeWidth * values.length + (values.length - 1) * gapWidth;
123
+ var sizeWidth = typeof sizeProp === 'string' ? sizeProp : sizeProp.width || defaultSize.width;
109
124
  var width;
110
125
  if (sizeWidth === 'full' || sizeWidth === 'fill') {
111
126
  width = containerSize[0];
112
127
  } else if (sizeWidth === 'auto') {
113
- width = autoWidth;
128
+ width = autoSize;
114
129
  } else {
115
130
  width = parseMetricToNum(theme.global.size[sizeWidth] || sizeWidth);
116
131
  }
117
- var sizeHeight = typeof propsSize === 'string' ? propsSize : propsSize.height || defaultSize.height;
132
+ var sizeHeight = typeof sizeProp === 'string' ? sizeProp : sizeProp.height || defaultSize.height;
118
133
  var height;
119
134
  if (sizeHeight === 'full' || sizeHeight === 'fill') {
120
135
  height = containerSize[1];
136
+ } else if (sizeHeight === 'auto') {
137
+ height = autoSize;
121
138
  } else {
122
139
  height = parseMetricToNum(theme.global.size[sizeHeight] || sizeHeight);
123
140
  }
124
- return [width, height];
125
- }, [containerSize, gap, propsSize, strokeWidth, theme.global.edgeSize, theme.global.size, values]);
141
+ return {
142
+ width: width,
143
+ height: height
144
+ };
145
+ }, [containerSize, gap, sizeProp, strokeWidth, theme.global.edgeSize, theme.global.size, values]);
146
+
147
+ // scale is { x, y }
126
148
  var scale = useMemo(function () {
127
- return [(size[0] - (inset[0] + inset[2])) / (bounds[0][1] - bounds[0][0]), (size[1] - (inset[1] + inset[3])) / (bounds[1][1] - bounds[1][0])];
149
+ return {
150
+ x: (size.width - (inset.left + inset.right)) / (bounds.x.max - bounds.x.min),
151
+ y: (size.height - (inset.top + inset.bottom)) / (bounds.y.max - bounds.y.min)
152
+ };
128
153
  }, [bounds, inset, size]);
129
- var viewBounds = useMemo(function () {
130
- return overflow ? [0, 0, size[0], size[1]] : [-(strokeWidth / 2), -(strokeWidth / 2), size[0] + strokeWidth, size[1] + strokeWidth];
154
+ var viewBoxBounds = useMemo(function () {
155
+ if (overflow) {
156
+ return [0, 0, size.width, size.height];
157
+ }
158
+ return [-(strokeWidth / 2), -(strokeWidth / 2), size.width + strokeWidth, size.height + strokeWidth];
131
159
  }, [overflow, size, strokeWidth]);
132
160
 
133
161
  // set container size when we get ref or when size changes
@@ -162,10 +190,19 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
162
190
  return undefined;
163
191
  }, [containerRef, needContainerSize]);
164
192
 
193
+ // rendering helpers, to make rendering code easier to understand
194
+
195
+ var valueCoords = function valueCoords(x, y) {
196
+ return vertical ? [y, x] : [x, y];
197
+ };
198
+
165
199
  // Converts values to drawing coordinates.
166
200
  // Takes into account the bounds, any inset, and the scale.
167
201
  var valueToCoordinate = function valueToCoordinate(xValue, yValue) {
168
- return [(xValue - bounds[0][0]) * scale[0] + inset[0], size[1] - ((yValue - bounds[1][0]) * scale[1] + inset[1])];
202
+ var y = (yValue - bounds.y.min) * scale.y + inset.top;
203
+ return [(xValue - bounds.x.min) * scale.x + inset.left,
204
+ // vertical grows y top down, horizontal grows y bottom up
205
+ vertical ? y : size.height - y];
169
206
  };
170
207
  var useGradient = color && Array.isArray(color);
171
208
  var patternId;
@@ -188,9 +225,13 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
188
225
  valueRest = _objectWithoutPropertiesLoose(valueArg, _excluded2);
189
226
  var key = "p-" + index;
190
227
  // Math.min/max are to handle negative values
191
- var bottom = value.length === 2 ? Math.min(Math.max(0, bounds[1][0]), value[1]) : Math.min(value[1], value[2]);
192
- var top = value.length === 2 ? Math.max(Math.min(0, bounds[1][1]), value[1]) : Math.max(value[1], value[2]);
193
- var d = "M " + valueToCoordinate(value[0], bottom).join(',') + (" L " + valueToCoordinate(value[0], top).join(','));
228
+ var _valueCoords = valueCoords(value[0], value.length === 2 ? Math.min(Math.max(0, vertical ? bounds.x.min : bounds.y.min), value[1]) : Math.min(value[1], value[2])),
229
+ startX = _valueCoords[0],
230
+ startY = _valueCoords[1];
231
+ var _valueCoords2 = valueCoords(value[0], value.length === 2 ? Math.max(Math.min(0, vertical ? bounds.x.max : bounds.y.max), value[1]) : Math.max(value[1], value[2])),
232
+ endX = _valueCoords2[0],
233
+ endY = _valueCoords2[1];
234
+ var d = "M " + valueToCoordinate(startX, startY).join(',') + (" L " + valueToCoordinate(endX, endY).join(','));
194
235
  var hoverProps;
195
236
  if (valueOnHover) {
196
237
  hoverProps = {
@@ -229,9 +270,15 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
229
270
  return value[1] !== undefined;
230
271
  }).forEach(function (_ref4) {
231
272
  var value = _ref4.value;
232
- d += (d ? ' L' : 'M') + " " + valueToCoordinate(value[0], value[1]).join(',');
273
+ var _valueCoords3 = valueCoords(value[0], value[1]),
274
+ x = _valueCoords3[0],
275
+ y = _valueCoords3[1];
276
+ d += (d ? ' L' : 'M') + " " + valueToCoordinate(x, y).join(',');
233
277
  if (value[2] !== undefined) {
234
- d2 += (d2 ? ' L' : 'M') + " " + valueToCoordinate(value[0], value[2]).join(',');
278
+ var _valueCoords4 = valueCoords(value[0], value[2]),
279
+ x2 = _valueCoords4[0],
280
+ y2 = _valueCoords4[1];
281
+ d2 += (d2 ? ' L' : 'M') + " " + valueToCoordinate(x2, y2).join(',');
235
282
  }
236
283
  });
237
284
  var hoverProps;
@@ -270,16 +317,24 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
270
317
  return value[1] !== undefined;
271
318
  }).forEach(function (_ref6, index) {
272
319
  var value = _ref6.value;
273
- d += (!index ? 'M' : ' L') + " " + valueToCoordinate(value[0], value[value.length === 2 ? 1 : 2]).join(',');
320
+ var _valueCoords5 = valueCoords(value[0],
321
+ // when a range, second value is on top
322
+ value[value.length === 2 ? 1 : 2]),
323
+ x = _valueCoords5[0],
324
+ y = _valueCoords5[1];
325
+ d += (!index ? 'M' : ' L') + " " + valueToCoordinate(x, y).join(',');
274
326
  });
275
327
  (values || []).filter(function (_ref7) {
276
328
  var value = _ref7.value;
277
329
  return value[1] !== undefined;
278
330
  }).reverse().forEach(function (_ref8) {
279
331
  var value = _ref8.value;
280
- d += " L " + valueToCoordinate(value[0],
281
- // Math.max() is to account for value[1] being negative
282
- value.length === 2 ? Math.max(0, bounds[1][0]) : value[1]).join(',');
332
+ var _valueCoords6 = valueCoords(value[0],
333
+ // Math.max() is to account for value[1] being negative
334
+ value.length === 2 ? Math.max(0, vertical ? bounds.x.min : bounds.y.min) : value[1]),
335
+ x = _valueCoords6[0],
336
+ y = _valueCoords6[1];
337
+ d += " L " + valueToCoordinate(x, y).join(',');
283
338
  });
284
339
  if (d.length > 0) {
285
340
  d += ' Z';
@@ -340,7 +395,10 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
340
395
  var width = valueThickness ? parseMetricToNum(theme.global.edgeSize[valueThickness] || valueThickness) : strokeWidth;
341
396
  var renderPoint = function renderPoint(valueX, valueY) {
342
397
  var props = _extends({}, hoverProps, clickProps, valueRest);
343
- var _valueToCoordinate = valueToCoordinate(valueX, valueY),
398
+ var _valueCoords7 = valueCoords(valueX, valueY),
399
+ x = _valueCoords7[0],
400
+ y = _valueCoords7[1];
401
+ var _valueToCoordinate = valueToCoordinate(x, y),
344
402
  cx = _valueToCoordinate[0],
345
403
  cy = _valueToCoordinate[1];
346
404
  var off = width / 2;
@@ -379,16 +437,16 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
379
437
  } else if (type === 'point') {
380
438
  contents = renderPoints();
381
439
  }
382
- var viewBox = viewBounds.join(' ');
440
+ var viewBox = viewBoxBounds.join(' ');
383
441
  var colorName;
384
442
  if (!useGradient) {
385
443
  if (color && color.color) colorName = color.color;else if (color) colorName = color;else if (theme.chart && theme.chart.color) colorName = theme.chart.color;
386
444
  }
387
445
  var opacity;
388
- if (propsOpacity === true) {
446
+ if (opacityProp === true) {
389
447
  opacity = theme.global.opacity.medium;
390
- } else if (propsOpacity) {
391
- opacity = theme.global.opacity[propsOpacity] ? theme.global.opacity[propsOpacity] : propsOpacity;
448
+ } else if (opacityProp) {
449
+ opacity = theme.global.opacity[opacityProp] ? theme.global.opacity[opacityProp] : opacityProp;
392
450
  } else if (color && color.opacity) {
393
451
  opacity = theme.global.opacity[color.opacity] ? theme.global.opacity[color.opacity] : color.opacity;
394
452
  } else opacity = undefined;
@@ -410,7 +468,7 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
410
468
  }, contents);
411
469
  var defs = [];
412
470
  var gradientRect;
413
- if (useGradient && size[1]) {
471
+ if (useGradient && size.height) {
414
472
  var uniqueGradientId = color.map(function (element) {
415
473
  return element.color;
416
474
  }).join('-');
@@ -430,9 +488,7 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
430
488
  gradientColor = _ref10.color;
431
489
  return /*#__PURE__*/React.createElement("stop", {
432
490
  key: value,
433
- offset:
434
- // TODO:
435
- (size[1] - (value - bounds[1][0]) * scale[1]) / size[1],
491
+ offset: (size.height - (value - bounds.y.min) * scale.y) / size.height,
436
492
  stopColor: normalizeColor(gradientColor, theme)
437
493
  });
438
494
  })));
@@ -441,10 +497,10 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
441
497
  id: maskId
442
498
  }, drawing));
443
499
  gradientRect = /*#__PURE__*/React.createElement("rect", {
444
- x: viewBounds[0],
445
- y: viewBounds[1],
446
- width: viewBounds[2],
447
- height: viewBounds[3],
500
+ x: viewBoxBounds[0],
501
+ y: viewBoxBounds[1],
502
+ width: viewBoxBounds[2],
503
+ height: viewBoxBounds[3],
448
504
  fill: "url(#" + gradientId + ")",
449
505
  mask: "url(#" + maskId + ")"
450
506
  });
@@ -509,8 +565,8 @@ var Chart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
509
565
  "aria-label": a11yTitle,
510
566
  viewBox: viewBox,
511
567
  preserveAspectRatio: "none",
512
- width: size === 'full' ? '100%' : size[0],
513
- height: size === 'full' ? '100%' : size[1],
568
+ width: size === 'full' ? '100%' : size.width,
569
+ height: size === 'full' ? '100%' : size.height,
514
570
  typeProp: type // prevent adding to DOM
515
571
  }, rest), defs.length && /*#__PURE__*/React.createElement("defs", null, defs), useGradient ? gradientRect : drawing);
516
572
  });
@@ -26,6 +26,7 @@ export interface ChartProps {
26
26
  opacity?: 'weak' | 'medium' | 'strong' | boolean | number;
27
27
  };
28
28
  dash?: boolean;
29
+ direction?: 'horizontal' | 'vertical';
29
30
  gap?: GapType;
30
31
  onClick?: (...args: any[]) => any;
31
32
  onHover?: (...args: any[]) => any;
@@ -66,6 +67,7 @@ export interface ChartProps {
66
67
  | 'xlarge'
67
68
  | 'fill'
68
69
  | 'full'
70
+ | 'auto'
69
71
  | string;
70
72
  width?:
71
73
  | 'xxsmall'
@@ -76,6 +78,7 @@ export interface ChartProps {
76
78
  | 'xlarge'
77
79
  | 'fill'
78
80
  | 'full'
81
+ | 'auto'
79
82
  | string;
80
83
  }
81
84
  | string;
@@ -17,6 +17,7 @@ if (process.env.NODE_ENV !== 'production') {
17
17
  }))]),
18
18
  id: PropTypes.string,
19
19
  dash: PropTypes.bool,
20
+ direction: PropTypes.oneOf(['horizontal', 'vertical']),
20
21
  gap: PropTypes.oneOfType([PropTypes.oneOf(['none', 'xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge']), PropTypes.string]),
21
22
  onClick: PropTypes.func,
22
23
  onHover: PropTypes.func,
@@ -18,7 +18,8 @@ export var Layout = function Layout() {
18
18
  level: 2
19
19
  }, "full"), /*#__PURE__*/React.createElement(Box, {
20
20
  pad: "medium",
21
- border: true
21
+ border: true,
22
+ alignSelf: "stretch"
22
23
  }, /*#__PURE__*/React.createElement(Chart, {
23
24
  type: type,
24
25
  values: values,
@@ -30,7 +31,8 @@ export var Layout = function Layout() {
30
31
  level: 2
31
32
  }, "auto, gap"), /*#__PURE__*/React.createElement(Box, {
32
33
  pad: "medium",
33
- border: true
34
+ border: true,
35
+ alignSelf: "start"
34
36
  }, /*#__PURE__*/React.createElement(Chart, {
35
37
  type: type,
36
38
  values: values,
@@ -43,7 +45,8 @@ export var Layout = function Layout() {
43
45
  level: 2
44
46
  }, "default"), /*#__PURE__*/React.createElement(Box, {
45
47
  pad: "medium",
46
- border: true
48
+ borde: true,
49
+ alignSelf: "start"
47
50
  }, /*#__PURE__*/React.createElement(Chart, {
48
51
  type: type,
49
52
  values: values,
@@ -11,6 +11,7 @@ export var Pattern = function Pattern() {
11
11
  gap: "medium"
12
12
  }, ['squares', 'circles', 'stripesHorizontal', 'stripesVertical', 'stripesDiagonalDown', 'stripesDiagonalUp'].map(function (pattern) {
13
13
  return /*#__PURE__*/React.createElement(Chart, {
14
+ key: pattern,
14
15
  id: "area-" + pattern,
15
16
  type: "area",
16
17
  pattern: pattern,
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { Box, Chart } from 'grommet';
3
+ export var Vertical = function Vertical() {
4
+ return (
5
+ /*#__PURE__*/
6
+ // Uncomment <Grommet> lines when using outside of storybook
7
+ // <Grommet theme={grommet}>
8
+ React.createElement(Box, {
9
+ align: "center",
10
+ pad: "large",
11
+ gap: "large"
12
+ }, ['bar', 'line', 'area', 'point'].map(function (type) {
13
+ return /*#__PURE__*/React.createElement(Box, {
14
+ key: type,
15
+ direction: "row",
16
+ gap: "medium"
17
+ }, ['horizontal', 'vertical'].map(function (direction) {
18
+ return /*#__PURE__*/React.createElement(Box, {
19
+ key: direction,
20
+ border: true
21
+ }, /*#__PURE__*/React.createElement(Chart, {
22
+ type: type,
23
+ direction: direction,
24
+ size: "small",
25
+ values: [[10, 20], [20, 30], [30, 15]]
26
+ }));
27
+ }));
28
+ }))
29
+ // </Grommet>
30
+ );
31
+ };
32
+
33
+ export default {
34
+ title: 'Visualizations/Chart/Vertical'
35
+ };
@@ -12,24 +12,71 @@ export var normalizeValues = function normalizeValues(values) {
12
12
  };
13
13
  });
14
14
  };
15
- export var normalizeBounds = function normalizeBounds(bounds, values) {
16
- var result = bounds;
17
- if (!result) {
18
- result = [[0, 1], [0, 1]];
15
+ export var normalizeBounds = function normalizeBounds(boundsProp, values, direction) {
16
+ var vertical = direction === 'vertical';
17
+ 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;
19
43
  (values || []).forEach(function (value) {
20
44
  if (value.value[0] !== undefined) {
21
- result[0][0] = Math.min(result[0][0], value.value[0]);
22
- result[0][1] = Math.max(result[0][1], value.value[0]);
45
+ min0 = Math.min(min0, value.value[0]);
46
+ max0 = Math.max(max0, value.value[0]);
23
47
  }
24
48
  if (value.value[1] !== undefined) {
25
- result[1][0] = Math.min(result[1][0], value.value[1]);
26
- result[1][1] = Math.max(result[1][1], value.value[1]);
49
+ min1 = Math.min(min1, value.value[1]);
50
+ max1 = Math.max(max1, value.value[1]);
27
51
  }
28
52
  if (value.value[2] !== undefined) {
29
- result[1][0] = Math.min(result[1][0], value.value[2]);
30
- result[1][1] = Math.max(result[1][1], value.value[2]);
53
+ min1 = Math.min(min1, value.value[2]);
54
+ max1 = Math.max(max1, value.value[2]);
31
55
  }
32
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
+ };
79
+ }
33
80
  }
34
81
  return result;
35
82
  };
@@ -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
  });
@@ -21,7 +21,8 @@ var normalizeView = function normalizeView(viewProp, views) {
21
21
  };
22
22
  export var Data = function Data(_ref) {
23
23
  var children = _ref.children,
24
- dataProp = _ref.data,
24
+ _ref$data = _ref.data,
25
+ dataProp = _ref$data === void 0 ? [] : _ref$data,
25
26
  _ref$defaultView = _ref.defaultView,
26
27
  defaultView = _ref$defaultView === void 0 ? defaultDefaultView : _ref$defaultView,
27
28
  filteredTotal = _ref.filteredTotal,
@@ -48,13 +48,16 @@ export var filter = function filter(data, view, properties) {
48
48
 
49
49
  // options case
50
50
  if (Array.isArray(filterValue)) {
51
- if (Array.isArray(value)) {
52
- return !filterValue.some(function (f) {
53
- return typeof f === 'object' ? value.includes(f == null ? void 0 : f.value) // from {label: ___, value: ___}
54
- : value.includes(f);
55
- });
56
- }
57
- return !filterValue.includes(value);
51
+ return !filterValue.some(function (f) {
52
+ // f may be an object with form {label: __, value: __}
53
+ var isObject = typeof f === 'object';
54
+ // match f within data value array using .includes()
55
+ if (Array.isArray(value)) {
56
+ return isObject ? value.includes(f == null ? void 0 : f.value) : value.includes(f);
57
+ }
58
+ // match f with data value using ===
59
+ return isObject ? (f == null ? void 0 : f.value) === value : f === value;
60
+ });
58
61
  }
59
62
 
60
63
  // presence case
@@ -65,9 +65,11 @@ export var DataFilter = function DataFilter(_ref) {
65
65
 
66
66
  // generate options from all values for property
67
67
  var uniqueValues = generateOptions(unfilteredData || data, property);
68
+ // if less than two values, nothing to filter
69
+ if (uniqueValues.length < 2) return [undefined, undefined];
68
70
  // if any values aren't numeric, treat as options
69
71
  if (uniqueValues.some(function (v) {
70
- return v && typeof v !== 'number';
72
+ return v !== undefined && typeof v !== 'number';
71
73
  })) return [uniqueValues, undefined];
72
74
  // all values are numeric, treat as range
73
75
  // normalize to make it friendler, so [1.3, 4.895] becomes [1, 5]
@@ -94,28 +96,31 @@ export var DataFilter = function DataFilter(_ref) {
94
96
  size: "full",
95
97
  round: "small"
96
98
  });
97
- } else if (options.length === 2 && options[1] === true && options[0] === false) {
98
- // special case boolean properties
99
- content = /*#__PURE__*/React.createElement(CheckBoxGroup, {
100
- id: id,
101
- name: property,
102
- options: booleanOptions
103
- });
104
- } else if (options.length < 7) {
105
- content = /*#__PURE__*/React.createElement(CheckBoxGroup, {
106
- id: id,
107
- name: property,
108
- options: options
109
- });
110
- } else {
111
- content = /*#__PURE__*/React.createElement(SelectMultiple, {
112
- id: id,
113
- name: property,
114
- showSelectedInline: true,
115
- options: options
116
- });
99
+ } else if (options) {
100
+ if (options.length === 2 && options[1] === true && options[0] === false) {
101
+ // special case boolean properties
102
+ content = /*#__PURE__*/React.createElement(CheckBoxGroup, {
103
+ id: id,
104
+ name: property,
105
+ options: booleanOptions
106
+ });
107
+ } else if (options.length < 7) {
108
+ content = /*#__PURE__*/React.createElement(CheckBoxGroup, {
109
+ id: id,
110
+ name: property,
111
+ options: options
112
+ });
113
+ } else {
114
+ content = /*#__PURE__*/React.createElement(SelectMultiple, {
115
+ id: id,
116
+ name: property,
117
+ showSelectedInline: true,
118
+ options: options
119
+ });
120
+ }
117
121
  }
118
122
  }
123
+ if (!content) return null;
119
124
  if (noForm)
120
125
  // likely in Toolbar
121
126
  content = /*#__PURE__*/React.createElement(DataForm, {
@@ -43,7 +43,7 @@ export var GroupedBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
43
43
  var isGroupSelected = false;
44
44
  var groupDisabled = [];
45
45
  var isGroupDisabled = false;
46
- if (memberCount > 1 || onUpdate && group.key) {
46
+ if (memberCount > 1 || onUpdate && group.key !== undefined) {
47
47
  // need a header
48
48
  var primaryKeys = group.data.map(function (datum) {
49
49
  return datum[primaryProperty];