baseui 10.9.0 → 10.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/data-table/column-numerical.js +355 -307
  2. package/data-table/column-numerical.js.flow +287 -273
  3. package/data-table/constants.js +11 -17
  4. package/data-table/constants.js.flow +8 -11
  5. package/data-table/data-table.js +50 -53
  6. package/data-table/data-table.js.flow +13 -18
  7. package/data-table/filter-shell.js +4 -27
  8. package/data-table/filter-shell.js.flow +9 -33
  9. package/data-table/locale.js +2 -4
  10. package/data-table/locale.js.flow +2 -6
  11. package/data-table/measure-column-widths.js +121 -83
  12. package/data-table/measure-column-widths.js.flow +109 -87
  13. package/es/data-table/column-numerical.js +317 -245
  14. package/es/data-table/constants.js +8 -12
  15. package/es/data-table/data-table.js +16 -18
  16. package/es/data-table/filter-shell.js +4 -26
  17. package/es/data-table/locale.js +2 -4
  18. package/es/data-table/measure-column-widths.js +86 -75
  19. package/es/form-control/form-control.js +58 -7
  20. package/es/form-control/styled-components.js +27 -6
  21. package/es/popover/popover.js +1 -1
  22. package/esm/data-table/column-numerical.js +353 -304
  23. package/esm/data-table/constants.js +8 -12
  24. package/esm/data-table/data-table.js +50 -53
  25. package/esm/data-table/filter-shell.js +4 -26
  26. package/esm/data-table/locale.js +2 -4
  27. package/esm/data-table/measure-column-widths.js +121 -83
  28. package/esm/form-control/form-control.js +60 -9
  29. package/esm/form-control/styled-components.js +23 -3
  30. package/esm/popover/popover.js +1 -1
  31. package/form-control/form-control.js +61 -8
  32. package/form-control/form-control.js.flow +82 -10
  33. package/form-control/index.d.ts +1 -0
  34. package/form-control/styled-components.js +27 -5
  35. package/form-control/styled-components.js.flow +25 -3
  36. package/form-control/types.js.flow +20 -8
  37. package/package.json +1 -2
  38. package/popover/popover.js +1 -1
  39. package/popover/popover.js.flow +1 -1
@@ -17,17 +17,15 @@ var _index3 = require("../input/index.js");
17
17
 
18
18
  var _index4 = require("../styles/index.js");
19
19
 
20
+ var _index5 = require("../typography/index.js");
21
+
20
22
  var _column = _interopRequireDefault(require("./column.js"));
21
23
 
22
24
  var _constants = require("./constants.js");
23
25
 
24
26
  var _filterShell = _interopRequireDefault(require("./filter-shell.js"));
25
27
 
26
- var _index5 = require("../locale/index.js");
27
-
28
- var _d2 = require("d3");
29
-
30
- var _index6 = require("../slider/index.js");
28
+ var _index6 = require("../locale/index.js");
31
29
 
32
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
31
 
@@ -43,6 +41,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
43
41
 
44
42
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
45
43
 
44
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
45
+
46
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
47
+
48
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
49
+
50
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
51
+
46
52
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
47
53
 
48
54
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -100,226 +106,291 @@ function validateInput(input) {
100
106
  return Boolean(parseFloat(input)) || input === '' || input === '-';
101
107
  }
102
108
 
103
- var bisect = (0, _d2.bisector)(function (d) {
104
- return d.x0;
105
- });
106
- var Histogram = /*#__PURE__*/React.memo(function Histogram(_ref) {
107
- var data = _ref.data,
108
- lower = _ref.lower,
109
- upper = _ref.upper,
110
- isRange = _ref.isRange,
111
- exclude = _ref.exclude,
112
- precision = _ref.precision;
113
-
114
- var _useStyletron = (0, _index4.useStyletron)(),
115
- _useStyletron2 = _slicedToArray(_useStyletron, 2),
116
- css = _useStyletron2[0],
117
- theme = _useStyletron2[1];
118
-
119
- var _React$useMemo = React.useMemo(function () {
120
- var bins = (0, _d2.bin)().thresholds(Math.min(data.length, _constants.MAX_BIN_COUNT))(data);
121
- var xScale = (0, _d2.scaleLinear)().domain([bins[0].x0, bins[bins.length - 1].x1]).range([0, _constants.HISTOGRAM_SIZE.width]).clamp(true);
122
- var yScale = (0, _d2.scaleLinear)().domain([0, (0, _d2.max)(bins, function (d) {
123
- return d.length;
124
- })]).nice().range([_constants.HISTOGRAM_SIZE.height, 0]);
125
- return {
126
- bins: bins,
127
- xScale: xScale,
128
- yScale: yScale
129
- };
130
- }, [data]),
131
- bins = _React$useMemo.bins,
132
- xScale = _React$useMemo.xScale,
133
- yScale = _React$useMemo.yScale; // We need to find the index of bar which is nearest to the given single value
134
-
135
-
136
- var singleIndexNearest = React.useMemo(function () {
137
- if (isRange) {
138
- return null;
139
- }
140
-
141
- return bisect.center(bins, lower);
142
- }, [isRange, data, lower, upper]);
143
- return /*#__PURE__*/React.createElement("div", {
144
- className: css({
145
- display: 'flex',
146
- marginTop: theme.sizing.scale600,
147
- marginLeft: theme.sizing.scale200,
148
- marginRight: 0,
149
- marginBottom: theme.sizing.scale400,
150
- justifyContent: 'space-between',
151
- overflow: 'visible'
152
- })
153
- }, /*#__PURE__*/React.createElement("svg", _constants.HISTOGRAM_SIZE, bins.map(function (d, index) {
154
- var x = xScale(d.x0) + 1;
155
- var y = yScale(d.length);
156
- var width = Math.max(0, xScale(d.x1) - xScale(d.x0) - 1);
157
- var height = yScale(0) - yScale(d.length);
158
- var included;
159
-
160
- if (singleIndexNearest != null) {
161
- included = index === singleIndexNearest;
109
+ function filterParamsToInitialState(filterParams) {
110
+ if (filterParams) {
111
+ if (filterParams.comparisons.length > 1) {
112
+ if (filterParams.comparisons[0].operation === _constants.NUMERICAL_OPERATIONS.LT && filterParams.comparisons[1].operation === _constants.NUMERICAL_OPERATIONS.GT) {
113
+ return {
114
+ exclude: !filterParams.exclude,
115
+ comparatorIndex: 0,
116
+ operatorIndex: 4,
117
+ right: filterParams.comparisons[1].value.toString(),
118
+ left: filterParams.comparisons[0].value.toString()
119
+ };
120
+ }
162
121
  } else {
163
- var withinLower = d.x1 > lower;
164
- var withinUpper = d.x0 <= upper;
165
- included = withinLower && withinUpper;
166
- }
167
-
168
- if (exclude) {
169
- included = !included;
122
+ var comparison = filterParams.comparisons[0];
123
+
124
+ if (comparison.operation === _constants.NUMERICAL_OPERATIONS.LT) {
125
+ return {
126
+ exclude: filterParams.exclude,
127
+ comparatorIndex: 0,
128
+ operatorIndex: 0,
129
+ left: '',
130
+ right: comparison.value.toString()
131
+ };
132
+ } else if (comparison.operation === _constants.NUMERICAL_OPERATIONS.GT) {
133
+ return {
134
+ exclude: filterParams.exclude,
135
+ comparatorIndex: 0,
136
+ operatorIndex: 1,
137
+ left: comparison.value.toString(),
138
+ right: ''
139
+ };
140
+ } else if (comparison.operation === _constants.NUMERICAL_OPERATIONS.LTE) {
141
+ return {
142
+ exclude: filterParams.exclude,
143
+ comparatorIndex: 0,
144
+ operatorIndex: 2,
145
+ left: '',
146
+ right: comparison.value.toString()
147
+ };
148
+ } else if (comparison.operation === _constants.NUMERICAL_OPERATIONS.GTE) {
149
+ return {
150
+ exclude: filterParams.exclude,
151
+ comparatorIndex: 0,
152
+ operatorIndex: 3,
153
+ left: comparison.value.toString(),
154
+ right: ''
155
+ };
156
+ } else if (comparison.operation === _constants.NUMERICAL_OPERATIONS.EQ) {
157
+ return {
158
+ exclude: filterParams.exclude,
159
+ comparatorIndex: 1,
160
+ operatorIndex: 0,
161
+ left: comparison.value.toString(),
162
+ right: ''
163
+ };
164
+ }
170
165
  }
166
+ }
171
167
 
172
- return /*#__PURE__*/React.createElement("rect", {
173
- key: "bar-".concat(index),
174
- fill: included ? theme.colors.primary : theme.colors.mono400,
175
- x: x,
176
- y: y,
177
- width: width,
178
- height: height
179
- });
180
- })));
181
- });
168
+ return {
169
+ exclude: false,
170
+ comparatorIndex: 0,
171
+ operatorIndex: 0,
172
+ left: '',
173
+ right: ''
174
+ };
175
+ }
182
176
 
183
177
  function NumericalFilter(props) {
184
- var _useStyletron3 = (0, _index4.useStyletron)(),
185
- _useStyletron4 = _slicedToArray(_useStyletron3, 2),
186
- css = _useStyletron4[0],
187
- theme = _useStyletron4[1];
188
-
189
- var locale = React.useContext(_index5.LocaleContext);
190
- var precision = props.options.precision; // The state handling of this component could be refactored and cleaned up if we used useReducer.
178
+ var _useStyletron = (0, _index4.useStyletron)(),
179
+ _useStyletron2 = _slicedToArray(_useStyletron, 2),
180
+ css = _useStyletron2[0],
181
+ theme = _useStyletron2[1];
191
182
 
192
- var initialState = React.useMemo(function () {
193
- return props.filterParams || {
194
- exclude: false,
195
- excludeKind: 'range',
196
- comparatorIndex: 0,
197
- lowerValue: null,
198
- upperValue: null
199
- };
200
- }, [props.filterParams]);
183
+ var locale = React.useContext(_index6.LocaleContext);
184
+ var initialState = filterParamsToInitialState(props.filterParams);
201
185
 
202
186
  var _React$useState = React.useState(initialState.exclude),
203
187
  _React$useState2 = _slicedToArray(_React$useState, 2),
204
188
  exclude = _React$useState2[0],
205
- setExclude = _React$useState2[1]; // the api of our ButtonGroup forces these numerical indexes...
206
- // TODO look into allowing semantic names, similar to the radio component. Tricky part would be backwards compat
207
-
189
+ setExclude = _React$useState2[1];
208
190
 
209
- var _React$useState3 = React.useState(function () {
210
- switch (initialState.excludeKind) {
211
- case 'value':
212
- return 1;
213
-
214
- case 'range':
215
- default:
216
- // fallthrough
217
- return 0;
218
- }
219
- }),
191
+ var _React$useState3 = React.useState(initialState.comparatorIndex),
220
192
  _React$useState4 = _slicedToArray(_React$useState3, 2),
221
193
  comparatorIndex = _React$useState4[0],
222
- setComparatorIndex = _React$useState4[1]; // We use the d3 function to get the extent as it's a little more robust to null, -Infinity, etc.
223
-
224
-
225
- var _React$useMemo2 = React.useMemo(function () {
226
- return (0, _d2.extent)(props.data);
227
- }, [props.data]),
228
- _React$useMemo3 = _slicedToArray(_React$useMemo2, 2),
229
- min = _React$useMemo3[0],
230
- max = _React$useMemo3[1];
194
+ setComparatorIndex = _React$useState4[1];
231
195
 
232
- var _React$useState5 = React.useState(function () {
233
- return roundToFixed(initialState.lowerValue || min, precision);
234
- }),
196
+ var _React$useState5 = React.useState(initialState.operatorIndex),
235
197
  _React$useState6 = _slicedToArray(_React$useState5, 2),
236
- lv = _React$useState6[0],
237
- setLower = _React$useState6[1];
198
+ operatorIndex = _React$useState6[0],
199
+ setOperatorIndex = _React$useState6[1];
238
200
 
239
- var _React$useState7 = React.useState(function () {
240
- return roundToFixed(initialState.upperValue || max, precision);
241
- }),
201
+ var _React$useState7 = React.useState(initialState.left),
242
202
  _React$useState8 = _slicedToArray(_React$useState7, 2),
243
- uv = _React$useState8[0],
244
- setUpper = _React$useState8[1]; // We keep a separate value for the single select, to give a user the ability to toggle between
245
- // the range and single values without losing their previous input.
203
+ left = _React$useState8[0],
204
+ setLeft = _React$useState8[1];
246
205
 
247
-
248
- var _React$useState9 = React.useState(function () {
249
- return roundToFixed(initialState.lowerValue || (0, _d2.median)(props.data), precision);
250
- }),
206
+ var _React$useState9 = React.useState(initialState.right),
251
207
  _React$useState10 = _slicedToArray(_React$useState9, 2),
252
- sv = _React$useState10[0],
253
- setSingle = _React$useState10[1]; // This is the only conditional which we want to use to determine
254
- // if we are in range or single value mode.
255
- // Don't derive it via something else, e.g. lowerValue === upperValue, etc.
256
-
208
+ right = _React$useState10[0],
209
+ setRight = _React$useState10[1];
257
210
 
258
211
  var isRange = comparatorIndex === 0;
259
- var excludeKind = isRange ? 'range' : 'value'; // while the user is inputting values, we take their input at face value,
260
- // if we don't do this, a user can't input partial numbers, e.g. "-", or "3."
212
+ var min = React.useMemo(function () {
213
+ return Math.min.apply(Math, _toConsumableArray(props.data));
214
+ }, [props.data]);
215
+ var max = React.useMemo(function () {
216
+ return Math.max.apply(Math, _toConsumableArray(props.data));
217
+ }, [props.data]);
218
+ React.useEffect(function () {
219
+ if (!left) {
220
+ setLeft(min.toString());
221
+ }
261
222
 
262
- var _React$useState11 = React.useState(false),
263
- _React$useState12 = _slicedToArray(_React$useState11, 2),
264
- focused = _React$useState12[0],
265
- setFocus = _React$useState12[1];
223
+ if (!right) {
224
+ setRight(max.toString());
225
+ }
226
+ }, []);
266
227
 
267
- var _React$useMemo4 = React.useMemo(function () {
268
- if (focused) {
269
- return [isRange ? lv : sv, uv];
270
- } // once the user is done inputting.
271
- // we validate then format to the given precision
228
+ var _React$useMemo = React.useMemo(function () {
229
+ if (!isRange) return [false, false];
272
230
 
231
+ switch (operatorIndex) {
232
+ case 4:
233
+ return [false, false];
273
234
 
274
- var l = isRange ? lv : sv;
275
- l = validateInput(l) ? l : min;
276
- var h = validateInput(uv) ? uv : max;
277
- return [roundToFixed(l, precision), roundToFixed(h, precision)];
278
- }, [isRange, focused, sv, lv, uv, precision]),
279
- _React$useMemo5 = _slicedToArray(_React$useMemo4, 2),
280
- inputValueLower = _React$useMemo5[0],
281
- inputValueUpper = _React$useMemo5[1]; // We bound the values within our min and max even if a user enters a huge number
235
+ case 0:
236
+ case 2:
237
+ return [true, false];
282
238
 
239
+ case 1:
240
+ case 3:
241
+ return [false, true];
283
242
 
284
- var sliderValue = isRange ? [Math.max(inputValueLower, min), Math.min(inputValueUpper, max)] : [Math.min(Math.max(inputValueLower, min), max)]; // keep the slider happy by sorting the two values
243
+ default:
244
+ return [true, true];
245
+ }
246
+ }, [operatorIndex, isRange]),
247
+ _React$useMemo2 = _slicedToArray(_React$useMemo, 2),
248
+ leftDisabled = _React$useMemo2[0],
249
+ rightDisabled = _React$useMemo2[1];
250
+
251
+ var leftInputRef = React.useRef(null);
252
+ var rightInputRef = React.useRef(null);
253
+ React.useEffect(function () {
254
+ if (!leftDisabled && leftInputRef.current) {
255
+ leftInputRef.current.focus({
256
+ preventScroll: true
257
+ });
258
+ } else if (!rightDisabled && rightInputRef.current) {
259
+ rightInputRef.current.focus({
260
+ preventScroll: true
261
+ });
262
+ }
263
+ }, [leftDisabled, rightDisabled, comparatorIndex]);
264
+ React.useEffect(function () {
265
+ switch (operatorIndex) {
266
+ case 4:
267
+ default:
268
+ break;
285
269
 
286
- if (isRange && sliderValue[0] > sliderValue[1]) {
287
- sliderValue = [sliderValue[1], sliderValue[0]];
288
- }
270
+ case 1:
271
+ case 3:
272
+ setRight(max.toString());
273
+ break;
289
274
 
275
+ case 0:
276
+ case 2:
277
+ setLeft(min.toString());
278
+ break;
279
+ }
280
+ }, [operatorIndex]);
290
281
  return /*#__PURE__*/React.createElement(_filterShell.default, {
291
282
  exclude: exclude,
292
283
  onExcludeChange: function onExcludeChange() {
293
284
  return setExclude(!exclude);
294
285
  },
295
- excludeKind: excludeKind,
296
286
  onApply: function onApply() {
297
287
  if (isRange) {
298
- var lowerValue = parseFloat(inputValueLower);
299
- var upperValue = parseFloat(inputValueUpper);
300
- props.setFilter({
301
- description: "\u2265 ".concat(lowerValue, " and \u2264 ").concat(upperValue),
302
- exclude: exclude,
303
- lowerValue: lowerValue,
304
- upperValue: upperValue,
305
- excludeKind: excludeKind
306
- });
288
+ switch (operatorIndex) {
289
+ case 0:
290
+ {
291
+ var _value = parseFloat(right);
292
+
293
+ var operation = _constants.NUMERICAL_OPERATIONS.LT;
294
+ props.setFilter({
295
+ comparisons: [{
296
+ value: _value,
297
+ operation: operation
298
+ }],
299
+ description: "< ".concat(_value),
300
+ exclude: exclude
301
+ });
302
+ break;
303
+ }
304
+
305
+ case 1:
306
+ {
307
+ var _value2 = parseFloat(left);
308
+
309
+ var _operation = _constants.NUMERICAL_OPERATIONS.GT;
310
+ props.setFilter({
311
+ comparisons: [{
312
+ value: _value2,
313
+ operation: _operation
314
+ }],
315
+ description: "> ".concat(_value2),
316
+ exclude: exclude
317
+ });
318
+ break;
319
+ }
320
+
321
+ case 2:
322
+ {
323
+ var _value3 = parseFloat(right);
324
+
325
+ var _operation2 = _constants.NUMERICAL_OPERATIONS.LTE;
326
+ props.setFilter({
327
+ comparisons: [{
328
+ value: _value3,
329
+ operation: _operation2
330
+ }],
331
+ description: "\u2264 ".concat(_value3),
332
+ exclude: exclude
333
+ });
334
+ break;
335
+ }
336
+
337
+ case 3:
338
+ {
339
+ var _value4 = parseFloat(left);
340
+
341
+ var _operation3 = _constants.NUMERICAL_OPERATIONS.GTE;
342
+ props.setFilter({
343
+ comparisons: [{
344
+ value: _value4,
345
+ operation: _operation3
346
+ }],
347
+ description: "\u2265 ".concat(_value4),
348
+ exclude: exclude
349
+ });
350
+ break;
351
+ }
352
+
353
+ case 4:
354
+ {
355
+ // 'between' case is interesting since if we want less than 10 plus greater than 5
356
+ // comparators, the filter will include _all_ numbers.
357
+ var leftValue = parseFloat(left);
358
+ var rightValue = parseFloat(right);
359
+ props.setFilter({
360
+ comparisons: [{
361
+ value: leftValue,
362
+ operation: _constants.NUMERICAL_OPERATIONS.LT
363
+ }, {
364
+ value: rightValue,
365
+ operation: _constants.NUMERICAL_OPERATIONS.GT
366
+ }],
367
+ description: "\u2265 ".concat(leftValue, " & \u2264 ").concat(rightValue),
368
+ exclude: !exclude
369
+ });
370
+ break;
371
+ }
372
+
373
+ default:
374
+ break;
375
+ }
307
376
  } else {
308
- var _value = parseFloat(inputValueLower);
377
+ var _value5 = parseFloat(left);
309
378
 
379
+ var _operation4 = _constants.NUMERICAL_OPERATIONS.EQ;
310
380
  props.setFilter({
311
- description: "= ".concat(_value),
312
- exclude: exclude,
313
- lowerValue: inputValueLower,
314
- upperValue: inputValueLower,
315
- excludeKind: excludeKind
381
+ comparisons: [{
382
+ value: _value5,
383
+ operation: _operation4
384
+ }],
385
+ description: "= ".concat(_value5),
386
+ exclude: exclude
316
387
  });
317
388
  }
318
389
 
319
390
  props.close();
320
391
  }
321
392
  }, /*#__PURE__*/React.createElement(_index2.ButtonGroup, {
322
- size: _index.SIZE.mini,
393
+ size: _index.SIZE.compact,
323
394
  mode: _index2.MODE.radio,
324
395
  selected: comparatorIndex,
325
396
  onClick: function onClick(_, index) {
@@ -327,8 +398,8 @@ function NumericalFilter(props) {
327
398
  },
328
399
  overrides: {
329
400
  Root: {
330
- style: function style(_ref2) {
331
- var $theme = _ref2.$theme;
401
+ style: function style(_ref) {
402
+ var $theme = _ref.$theme;
332
403
  return {
333
404
  marginBottom: $theme.sizing.scale300
334
405
  };
@@ -343,8 +414,7 @@ function NumericalFilter(props) {
343
414
  width: '100%'
344
415
  }
345
416
  }
346
- },
347
- "aria-label": locale.datatable.numericalFilterRange
417
+ }
348
418
  }, locale.datatable.numericalFilterRange), /*#__PURE__*/React.createElement(_index.Button, {
349
419
  type: "button",
350
420
  overrides: {
@@ -353,167 +423,123 @@ function NumericalFilter(props) {
353
423
  width: '100%'
354
424
  }
355
425
  }
356
- },
357
- "aria-label": locale.datatable.numericalFilterSingleValue
358
- }, locale.datatable.numericalFilterSingleValue)), /*#__PURE__*/React.createElement(Histogram, {
359
- data: props.data,
360
- lower: inputValueLower,
361
- upper: inputValueUpper,
362
- isRange: isRange,
363
- exclude: exclude,
364
- precision: props.options.precision
365
- }), /*#__PURE__*/React.createElement("div", {
366
- className: css({
367
- display: 'flex',
368
- justifyContent: 'space-between'
369
- })
370
- }, /*#__PURE__*/React.createElement(_index6.Slider // The slider throws errors when switching between single and two values
371
- // when it tries to read getThumbDistance on a thumb which is not there anymore
372
- // if we create a new instance these errors are prevented.
373
- , {
374
- key: isRange.toString(),
375
- min: min,
376
- max: max,
377
- value: sliderValue,
378
- onChange: function onChange(_ref3) {
379
- var value = _ref3.value;
380
-
381
- if (!value) {
382
- return;
383
- }
384
-
385
- if (isRange) {
386
- var _value2 = _slicedToArray(value, 2),
387
- lowerValue = _value2[0],
388
- upperValue = _value2[1];
389
-
390
- setLower(lowerValue);
391
- setUpper(upperValue);
392
- } else {
393
- var _value3 = _slicedToArray(value, 1),
394
- singleValue = _value3[0];
395
-
396
- setSingle(singleValue);
397
- }
426
+ }
427
+ }, locale.datatable.numericalFilterSingleValue)), isRange && /*#__PURE__*/React.createElement(_index2.ButtonGroup, {
428
+ size: _index.SIZE.compact,
429
+ mode: _index2.MODE.radio,
430
+ selected: operatorIndex,
431
+ onClick: function onClick(_, index) {
432
+ return setOperatorIndex(index);
398
433
  },
399
434
  overrides: {
400
- InnerThumb: function InnerThumb(_ref4) {
401
- var $value = _ref4.$value,
402
- $thumbIndex = _ref4.$thumbIndex;
403
- return /*#__PURE__*/React.createElement(React.Fragment, null, $value[$thumbIndex]);
404
- },
405
- TickBar: function TickBar(_ref5) {
406
- var $min = _ref5.$min,
407
- $max = _ref5.$max;
408
- return null;
409
- },
410
- // we don't want the ticks
411
- ThumbValue: function ThumbValue() {
412
- return null;
413
- },
414
435
  Root: {
415
- style: function style() {
436
+ style: function style(_ref2) {
437
+ var $theme = _ref2.$theme;
416
438
  return {
417
- // Aligns the center of the slider handles with the histogram bars
418
- width: 'calc(100% + 14px)',
419
- margin: '0 -7px'
439
+ marginBottom: $theme.sizing.scale500
420
440
  };
421
441
  }
422
- },
423
- InnerTrack: {
424
- style: function style(_ref6) {
425
- var $theme = _ref6.$theme;
426
-
427
- if (!isRange) {
428
- return {
429
- // For range selection we use the color as is, but when selecting the single value,
430
- // we don't want the track standing out, so mute its color
431
- background: theme.colors.mono400
432
- };
433
- }
442
+ }
443
+ }
444
+ }, /*#__PURE__*/React.createElement(_index.Button, {
445
+ type: "button",
446
+ overrides: {
447
+ BaseButton: {
448
+ style: {
449
+ width: '100%'
434
450
  }
435
- },
436
- Thumb: {
437
- style: function style() {
438
- return {
439
- // Slider handles are small enough to visually be centered within each histogram bar
440
- height: '18px',
441
- width: '18px',
442
- fontSize: '0px'
443
- };
451
+ }
452
+ }
453
+ }, "<"), /*#__PURE__*/React.createElement(_index.Button, {
454
+ type: "button",
455
+ overrides: {
456
+ BaseButton: {
457
+ style: {
458
+ width: '100%'
444
459
  }
445
460
  }
446
461
  }
447
- })), /*#__PURE__*/React.createElement("div", {
462
+ }, ">"), /*#__PURE__*/React.createElement(_index.Button, {
463
+ type: "button",
464
+ overrides: {
465
+ BaseButton: {
466
+ style: {
467
+ width: '100%'
468
+ }
469
+ }
470
+ }
471
+ }, "\u2264"), /*#__PURE__*/React.createElement(_index.Button, {
472
+ type: "button",
473
+ overrides: {
474
+ BaseButton: {
475
+ style: {
476
+ width: '100%'
477
+ }
478
+ }
479
+ }
480
+ }, "\u2265"), /*#__PURE__*/React.createElement(_index.Button, {
481
+ type: "button",
482
+ overrides: {
483
+ BaseButton: {
484
+ style: {
485
+ width: '100%'
486
+ }
487
+ }
488
+ }
489
+ }, "=")), /*#__PURE__*/React.createElement("div", {
490
+ className: css({
491
+ display: 'flex',
492
+ justifyContent: 'space-between',
493
+ marginLeft: theme.sizing.scale300,
494
+ marginRight: theme.sizing.scale300
495
+ })
496
+ }, /*#__PURE__*/React.createElement(_index5.ParagraphXSmall, null, format(min, props.options)), ' ', /*#__PURE__*/React.createElement(_index5.ParagraphXSmall, null, format(max, props.options))), /*#__PURE__*/React.createElement("div", {
448
497
  className: css({
449
498
  display: 'flex',
450
- marginTop: theme.sizing.scale400,
451
- // This % gap is visually appealing given the filter box width
452
- gap: '30%',
453
499
  justifyContent: 'space-between'
454
500
  })
455
501
  }, /*#__PURE__*/React.createElement(_index3.Input, {
456
- min: min,
457
- max: max,
458
- size: _index3.SIZE.mini,
502
+ size: _index3.SIZE.compact,
459
503
  overrides: {
460
504
  Root: {
461
505
  style: {
462
- width: '100%'
506
+ width: isRange ? '152px' : '100%'
463
507
  }
464
508
  }
465
509
  },
466
- value: inputValueLower,
510
+ disabled: leftDisabled,
511
+ inputRef: leftInputRef,
512
+ value: left,
467
513
  onChange: function onChange(event) {
468
514
  if (validateInput(event.target.value)) {
469
- isRange ? // $FlowFixMe - we know it is a number by now
470
- setLower(event.target.value) : // $FlowFixMe - we know it is a number by now
471
- setSingle(event.target.value);
515
+ setLeft(event.target.value);
472
516
  }
473
- },
474
- onFocus: function onFocus() {
475
- return setFocus(true);
476
- },
477
- onBlur: function onBlur() {
478
- return setFocus(false);
479
517
  }
480
518
  }), isRange && /*#__PURE__*/React.createElement(_index3.Input, {
481
- min: min,
482
- max: max,
483
- size: _index3.SIZE.mini,
519
+ size: _index3.SIZE.compact,
484
520
  overrides: {
485
- Input: {
486
- style: {
487
- textAlign: 'right'
488
- }
489
- },
490
521
  Root: {
491
522
  style: {
492
- width: '100%'
523
+ width: '152px'
493
524
  }
494
525
  }
495
526
  },
496
- value: inputValueUpper,
527
+ disabled: rightDisabled,
528
+ inputRef: rightInputRef,
529
+ value: right,
497
530
  onChange: function onChange(event) {
498
531
  if (validateInput(event.target.value)) {
499
- // $FlowFixMe - we know it is a number by now
500
- setUpper(event.target.value);
532
+ setRight(event.target.value);
501
533
  }
502
- },
503
- onFocus: function onFocus() {
504
- return setFocus(true);
505
- },
506
- onBlur: function onBlur() {
507
- return setFocus(false);
508
534
  }
509
535
  })));
510
536
  }
511
537
 
512
538
  function NumericalCell(props) {
513
- var _useStyletron5 = (0, _index4.useStyletron)(),
514
- _useStyletron6 = _slicedToArray(_useStyletron5, 2),
515
- css = _useStyletron6[0],
516
- theme = _useStyletron6[1];
539
+ var _useStyletron3 = (0, _index4.useStyletron)(),
540
+ _useStyletron4 = _slicedToArray(_useStyletron3, 2),
541
+ css = _useStyletron4[0],
542
+ theme = _useStyletron4[1];
517
543
 
518
544
  return /*#__PURE__*/React.createElement("div", {
519
545
  className: css(_objectSpread(_objectSpread({}, theme.typography.MonoParagraphXSmall), {}, {
@@ -556,8 +582,30 @@ function NumericalColumn(options) {
556
582
  kind: _constants.COLUMNS.NUMERICAL,
557
583
  buildFilter: function buildFilter(params) {
558
584
  return function (data) {
559
- var value = roundToFixed(data, normalizedOptions.precision);
560
- var included = value >= params.lowerValue && value <= params.upperValue;
585
+ var included = params.comparisons.some(function (c) {
586
+ var left = roundToFixed(data, normalizedOptions.precision);
587
+ var right = roundToFixed(c.value, normalizedOptions.precision);
588
+
589
+ switch (c.operation) {
590
+ case _constants.NUMERICAL_OPERATIONS.EQ:
591
+ return left === right;
592
+
593
+ case _constants.NUMERICAL_OPERATIONS.GT:
594
+ return left > right;
595
+
596
+ case _constants.NUMERICAL_OPERATIONS.GTE:
597
+ return left >= right;
598
+
599
+ case _constants.NUMERICAL_OPERATIONS.LT:
600
+ return left < right;
601
+
602
+ case _constants.NUMERICAL_OPERATIONS.LTE:
603
+ return left <= right;
604
+
605
+ default:
606
+ return true;
607
+ }
608
+ });
561
609
  return params.exclude ? !included : included;
562
610
  };
563
611
  },