grommet 2.31.0 → 2.32.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 (122) hide show
  1. package/components/Accordion/Accordion.js +4 -2
  2. package/components/Accordion/index.d.ts +1 -0
  3. package/components/Accordion/propTypes.js +1 -0
  4. package/components/AccordionPanel/AccordionPanel.js +2 -1
  5. package/components/Box/Box.js +14 -4
  6. package/components/Box/stories/Border.js +15 -1
  7. package/components/Button/BusyAnimation.js +51 -0
  8. package/components/Button/Button.js +64 -4
  9. package/components/Button/StyledButton.js +4 -2
  10. package/components/Button/StyledButtonKind.js +8 -4
  11. package/components/Button/index.d.ts +7 -0
  12. package/components/Button/propTypes.js +6 -0
  13. package/components/Button/stories/Busy.js +45 -0
  14. package/components/Calendar/stories/Dual.js +4 -6
  15. package/components/Data/DataForm.js +6 -2
  16. package/components/Data/filter.js +9 -1
  17. package/components/Data/stories/Complex.js +63 -6
  18. package/components/Data/stories/Inline.js +19 -2
  19. package/components/DataFilter/DataFilter.js +11 -1
  20. package/components/DataFilters/DataFilters.js +13 -10
  21. package/components/DataTable/Body.js +16 -13
  22. package/components/DataTable/DataTable.js +4 -1
  23. package/components/DataTable/GroupedBody.js +1 -0
  24. package/components/DataTable/Header.js +1 -0
  25. package/components/DataTable/buildState.js +12 -10
  26. package/components/DataTable/stories/Controlled.js +2 -1
  27. package/components/DataTable/stories/ControlledGrouped.js +2 -1
  28. package/components/DataTable/stories/CustomThemed/Custom.js +0 -1
  29. package/components/DataTable/stories/CustomThemed/Fill.js +2 -1
  30. package/components/DataTable/stories/GroupedOnSelect.js +2 -1
  31. package/components/DataTable/stories/NoPrimary.js +0 -1
  32. package/components/DataTable/stories/OnUpdate.js +2 -1
  33. package/components/DataTable/stories/Served.js +2 -1
  34. package/components/DataTable/stories/Tunable.js +2 -1
  35. package/components/DataTable/stories/rowDetails.js +2 -1
  36. package/components/DataTableColumns/DataTableColumns.js +5 -0
  37. package/components/DataTableColumns/stories/Simple.js +4 -3
  38. package/components/DataTableGroupBy/DataTableGroupBy.js +67 -0
  39. package/components/DataTableGroupBy/README.md +2 -0
  40. package/components/DataTableGroupBy/index.d.ts +20 -0
  41. package/components/DataTableGroupBy/index.js +6 -0
  42. package/components/DataTableGroupBy/propTypes.js +17 -0
  43. package/components/DataTableGroupBy/stories/Simple.js +50 -0
  44. package/components/DateInput/DateInput.js +1 -1
  45. package/components/Drop/DropContainer.js +2 -2
  46. package/components/DropButton/DropButton.js +2 -2
  47. package/components/FileInput/FileInput.js +82 -53
  48. package/components/Form/Form.js +95 -44
  49. package/components/Form/stories/TriggerValidationUsingFormField.js +109 -0
  50. package/components/FormField/FormField.js +4 -2
  51. package/components/FormField/index.d.ts +1 -0
  52. package/components/FormField/propTypes.js +2 -1
  53. package/components/Grid/stories/CustomThemed/Responsive.js +0 -1
  54. package/components/InfiniteScroll/InfiniteScroll.js +1 -0
  55. package/components/Layer/Layer.js +1 -1
  56. package/components/Layer/LayerContainer.js +2 -2
  57. package/components/List/index.d.ts +2 -2
  58. package/components/NameValueList/NameValueList.js +1 -1
  59. package/components/SelectMultiple/SelectMultiple.js +13 -10
  60. package/components/SelectMultiple/SelectMultipleValue.js +1 -1
  61. package/components/Tip/stories/HeaderActions.js +0 -1
  62. package/components/index.d.ts +1 -0
  63. package/components/index.js +6 -0
  64. package/es6/components/Accordion/Accordion.js +4 -2
  65. package/es6/components/Accordion/index.d.ts +1 -0
  66. package/es6/components/Accordion/propTypes.js +1 -0
  67. package/es6/components/AccordionPanel/AccordionPanel.js +2 -1
  68. package/es6/components/Box/Box.js +14 -4
  69. package/es6/components/Box/stories/Border.js +15 -1
  70. package/es6/components/Button/BusyAnimation.js +41 -0
  71. package/es6/components/Button/Button.js +64 -5
  72. package/es6/components/Button/StyledButton.js +4 -2
  73. package/es6/components/Button/StyledButtonKind.js +8 -4
  74. package/es6/components/Button/index.d.ts +7 -0
  75. package/es6/components/Button/propTypes.js +6 -0
  76. package/es6/components/Button/stories/Busy.js +37 -0
  77. package/es6/components/Calendar/stories/Dual.js +4 -6
  78. package/es6/components/Data/DataForm.js +4 -1
  79. package/es6/components/Data/filter.js +9 -1
  80. package/es6/components/Data/stories/Complex.js +64 -7
  81. package/es6/components/Data/stories/Inline.js +20 -3
  82. package/es6/components/DataFilter/DataFilter.js +11 -1
  83. package/es6/components/DataFilters/DataFilters.js +13 -10
  84. package/es6/components/DataTable/Body.js +15 -13
  85. package/es6/components/DataTable/DataTable.js +4 -1
  86. package/es6/components/DataTable/GroupedBody.js +1 -0
  87. package/es6/components/DataTable/buildState.js +12 -10
  88. package/es6/components/DataTableColumns/DataTableColumns.js +5 -0
  89. package/es6/components/DataTableColumns/stories/Simple.js +5 -4
  90. package/es6/components/DataTableGroupBy/DataTableGroupBy.js +60 -0
  91. package/es6/components/DataTableGroupBy/README.md +2 -0
  92. package/es6/components/DataTableGroupBy/index.d.ts +20 -0
  93. package/es6/components/DataTableGroupBy/index.js +1 -0
  94. package/es6/components/DataTableGroupBy/propTypes.js +11 -0
  95. package/es6/components/DataTableGroupBy/stories/Simple.js +45 -0
  96. package/es6/components/DateInput/DateInput.js +1 -1
  97. package/es6/components/Drop/DropContainer.js +2 -2
  98. package/es6/components/DropButton/DropButton.js +2 -2
  99. package/es6/components/FileInput/FileInput.js +83 -53
  100. package/es6/components/Form/Form.js +95 -44
  101. package/es6/components/Form/stories/TriggerValidationUsingFormField.js +102 -0
  102. package/es6/components/FormField/FormField.js +4 -2
  103. package/es6/components/FormField/index.d.ts +1 -0
  104. package/es6/components/FormField/propTypes.js +2 -1
  105. package/es6/components/InfiniteScroll/InfiniteScroll.js +1 -0
  106. package/es6/components/Layer/Layer.js +1 -1
  107. package/es6/components/Layer/LayerContainer.js +2 -2
  108. package/es6/components/List/index.d.ts +2 -2
  109. package/es6/components/NameValueList/NameValueList.js +1 -1
  110. package/es6/components/SelectMultiple/SelectMultiple.js +13 -10
  111. package/es6/components/SelectMultiple/SelectMultipleValue.js +1 -1
  112. package/es6/components/index.d.ts +1 -0
  113. package/es6/components/index.js +1 -0
  114. package/es6/index.d.ts +1 -0
  115. package/es6/languages/default.json +15 -2
  116. package/es6/themes/base.js +1 -1
  117. package/grommet.min.js +1 -1
  118. package/grommet.min.js.map +1 -1
  119. package/index.d.ts +1 -0
  120. package/languages/default.json +15 -2
  121. package/package.json +37 -36
  122. package/themes/base.js +1 -1
@@ -1,11 +1,13 @@
1
- var _excluded = ["active", "align", "aria-label", "badge", "color", "children", "disabled", "icon", "focusIndicator", "gap", "fill", "href", "justify", "kind", "label", "onBlur", "onClick", "onFocus", "onMouseOut", "onMouseOver", "pad", "plain", "primary", "reverse", "secondary", "selected", "size", "tip", "type", "a11yTitle", "as"];
1
+ var _excluded = ["active", "align", "aria-label", "badge", "busy", "color", "children", "disabled", "icon", "focusIndicator", "gap", "fill", "href", "justify", "kind", "label", "messages", "onBlur", "onClick", "onFocus", "onMouseOut", "onMouseOver", "pad", "plain", "primary", "reverse", "secondary", "selected", "size", "success", "tip", "type", "a11yTitle", "as"];
2
2
  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); }
3
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
- import React, { cloneElement, Children, forwardRef, useContext, useMemo, useState, useCallback } from 'react';
5
- import { ThemeContext } from 'styled-components';
4
+ import React, { cloneElement, Children, forwardRef, useContext, useMemo, useState, useCallback, useEffect } from 'react';
5
+ import styled, { ThemeContext } from 'styled-components';
6
6
  import { backgroundAndTextColors, colorIsDark, findButtonParent, useSizedIcon, normalizeBackground, normalizeColor } from '../../utils';
7
7
  import { defaultProps } from '../../default-props';
8
8
  import { ButtonPropTypes } from './propTypes';
9
+ import { AnnounceContext } from '../../contexts/AnnounceContext';
10
+ import { MessageContext } from '../../contexts/MessageContext';
9
11
  import { Box } from '../Box';
10
12
  import { Tip } from '../Tip';
11
13
  import { Badge } from './Badge';
@@ -13,6 +15,11 @@ import { StyledButton } from './StyledButton';
13
15
  import { StyledButtonKind } from './StyledButtonKind';
14
16
  import { useAnalytics } from '../../contexts/AnalyticsContext';
15
17
  import { Skeleton, useSkeleton } from '../Skeleton';
18
+ import { EllipsisAnimation, GrowCheckmark, StyledBusyContents } from './BusyAnimation';
19
+ var RelativeBox = styled(Box).withConfig({
20
+ displayName: "Button__RelativeBox",
21
+ componentId: "sc-zuqsuw-0"
22
+ })(["position:relative;"]);
16
23
 
17
24
  // We have two Styled* components to separate
18
25
  // the newer default|primary|secondary approach,
@@ -138,6 +145,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
138
145
  align = _ref$align === void 0 ? 'center' : _ref$align,
139
146
  ariaLabel = _ref['aria-label'],
140
147
  badgeProp = _ref.badge,
148
+ busy = _ref.busy,
141
149
  color = _ref.color,
142
150
  children = _ref.children,
143
151
  disabled = _ref.disabled,
@@ -150,6 +158,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
150
158
  justify = _ref.justify,
151
159
  kindArg = _ref.kind,
152
160
  label = _ref.label,
161
+ messages = _ref.messages,
153
162
  _onBlur = _ref.onBlur,
154
163
  onClickProp = _ref.onClick,
155
164
  _onFocus = _ref.onFocus,
@@ -162,6 +171,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
162
171
  secondary = _ref.secondary,
163
172
  selected = _ref.selected,
164
173
  sizeProp = _ref.size,
174
+ success = _ref.success,
165
175
  tip = _ref.tip,
166
176
  _ref$type = _ref.type,
167
177
  type = _ref$type === void 0 ? 'button' : _ref$type,
@@ -176,6 +186,21 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
176
186
  var _useState2 = useState(false),
177
187
  hover = _useState2[0],
178
188
  setHover = _useState2[1];
189
+ var announce = useContext(AnnounceContext);
190
+ var _useContext = useContext(MessageContext),
191
+ format = _useContext.format;
192
+ if (busy && success) {
193
+ console.warn('Button cannot have both busy and success set to true.');
194
+ }
195
+ useEffect(function () {
196
+ if (busy) announce(format({
197
+ id: 'button.busy',
198
+ messages: messages
199
+ }));else if (success) announce(format({
200
+ id: 'button.success',
201
+ messages: messages
202
+ }));
203
+ }, [announce, busy, format, messages, success]);
179
204
  if ((icon || label) && children) {
180
205
  console.warn('Button should not have children if icon or label is provided');
181
206
  }
@@ -332,6 +357,36 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
332
357
  content: badgeProp
333
358
  }, contents);
334
359
  }
360
+ if (busy || success) {
361
+ // match what the label will use
362
+ var animationColor;
363
+ if (kind) {
364
+ if (!plain) {
365
+ animationColor = hover && getIconColor(themePaths.hover, theme) || getIconColor(themePaths.base, theme, color, kind);
366
+ }
367
+ } else if (primary) {
368
+ animationColor = theme.global.colors.text[isDarkBackground() ? 'dark' : 'light'];
369
+ }
370
+ contents =
371
+ /*#__PURE__*/
372
+ // position relative is necessary to have the animation
373
+ // display over the button content
374
+ React.createElement(RelativeBox, {
375
+ flex: false
376
+ }, busy && /*#__PURE__*/React.createElement(EllipsisAnimation, null), success && /*#__PURE__*/React.createElement(Box, {
377
+ style: {
378
+ position: 'absolute'
379
+ },
380
+ fill: true,
381
+ alignContent: "center",
382
+ justify: "center"
383
+ }, /*#__PURE__*/React.createElement(GrowCheckmark, {
384
+ color: animationColor,
385
+ "aria-hidden": true
386
+ })), /*#__PURE__*/React.createElement(StyledBusyContents, {
387
+ animating: busy || success
388
+ }, contents));
389
+ }
335
390
  var styledButtonResult;
336
391
  if (kind) {
337
392
  styledButtonResult = /*#__PURE__*/React.createElement(StyledButtonKind, _extends({}, rest, {
@@ -340,6 +395,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
340
395
  active: active,
341
396
  align: align,
342
397
  "aria-label": ariaLabel || a11yTitle,
398
+ busy: busy,
343
399
  badge: badgeProp,
344
400
  colorValue: color,
345
401
  disabled: disabled,
@@ -353,7 +409,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
353
409
  href: href,
354
410
  kind: kind,
355
411
  themePaths: themePaths,
356
- onClick: onClick,
412
+ onClick: !busy && !success ? onClick : undefined,
357
413
  onFocus: function onFocus(event) {
358
414
  setFocus(true);
359
415
  if (_onFocus) _onFocus(event);
@@ -368,6 +424,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
368
424
  plain: plain || Children.count(children) > 0,
369
425
  primary: primary,
370
426
  sizeProp: size,
427
+ success: success,
371
428
  type: !href ? type : undefined
372
429
  }), contents);
373
430
  } else {
@@ -375,6 +432,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
375
432
  as: domTag,
376
433
  ref: ref,
377
434
  "aria-label": ariaLabel || a11yTitle,
435
+ busy: busy,
378
436
  colorValue: color,
379
437
  active: active,
380
438
  selected: selected,
@@ -388,7 +446,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
388
446
  href: href,
389
447
  kind: kind,
390
448
  themePaths: themePaths,
391
- onClick: onClick,
449
+ onClick: !busy && !success ? onClick : undefined,
392
450
  onFocus: function onFocus(event) {
393
451
  setFocus(true);
394
452
  if (_onFocus) _onFocus(event);
@@ -403,6 +461,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
403
461
  plain: typeof plain !== 'undefined' ? plain : Children.count(children) > 0 || icon && !label,
404
462
  primary: primary,
405
463
  sizeProp: size,
464
+ success: success,
406
465
  type: !href ? type : undefined
407
466
  }), contents);
408
467
  }
@@ -71,14 +71,14 @@ var disabledButtonStyle = function disabledButtonStyle(props) {
71
71
  var StyledButton = styled.button.withConfig({
72
72
  displayName: "StyledButton",
73
73
  componentId: "sc-323bzc-0"
74
- })(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", " ", " ", " ", ""], genericStyles, function (props) {
74
+ })(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", " ", " ", " ", " ", ""], genericStyles, function (props) {
75
75
  return props.plain && plainStyle(props);
76
76
  }, function (props) {
77
77
  return !props.plain && basicStyle(props);
78
78
  }, function (props) {
79
79
  return props.primary && primaryStyle(props);
80
80
  }, function (props) {
81
- return !props.disabled && !props.selected && !props.focus && hoverStyle;
81
+ return !props.disabled && !props.selected && !props.focus && !props.busy && !props.success && hoverStyle;
82
82
  }, function (props) {
83
83
  return !props.disabled && props.active && activeButtonStyle(props);
84
84
  }, function (props) {
@@ -97,6 +97,8 @@ var StyledButton = styled.button.withConfig({
97
97
  return !props.plain && props.pad && edgeStyle('padding', props.pad, false, undefined, props.theme);
98
98
  }, function (props) {
99
99
  return props.theme.button && props.theme.button.extend;
100
+ }, function (props) {
101
+ return (props.busy || props.success) && "\n cursor: default;\n ";
100
102
  });
101
103
  StyledButton.defaultProps = {};
102
104
  Object.setPrototypeOf(StyledButton.defaultProps, defaultProps);
@@ -77,11 +77,13 @@ var adjustPadStyle = function adjustPadStyle(pad, width) {
77
77
 
78
78
  // build up CSS from basic to specific based on the supplied sub-object paths
79
79
  var kindStyle = function kindStyle(_ref2) {
80
- var colorValue = _ref2.colorValue,
80
+ var busy = _ref2.busy,
81
+ colorValue = _ref2.colorValue,
81
82
  hasIcon = _ref2.hasIcon,
82
83
  hasLabel = _ref2.hasLabel,
83
84
  kind = _ref2.kind,
84
85
  size = _ref2.sizeProp,
86
+ success = _ref2.success,
85
87
  themePaths = _ref2.themePaths,
86
88
  theme = _ref2.theme;
87
89
  var styles = [];
@@ -128,7 +130,7 @@ var kindStyle = function kindStyle(_ref2) {
128
130
  // padding in the hover or hover.kind itself for backward compatibility
129
131
  adjPadStyles = adjustPadStyle(pad, obj.border.width);
130
132
  }
131
- if (partStyles.length > 0) {
133
+ if (partStyles.length > 0 && !busy && !success) {
132
134
  styles.push(css(["&:hover{", " ", "}"], partStyles, adjPadStyles));
133
135
  }
134
136
  }
@@ -171,7 +173,7 @@ var StyledButtonKind = styled.button.withConfig({
171
173
  }).withConfig({
172
174
  displayName: "StyledButtonKind",
173
175
  componentId: "sc-1vhfpnt-0"
174
- })(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", ""], genericStyles, function (props) {
176
+ })(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", " ", ""], genericStyles, function (props) {
175
177
  return props.plain && plainStyle(props);
176
178
  }, function (props) {
177
179
  return !props.disabled && props.active && activeStyle;
@@ -184,7 +186,7 @@ var StyledButtonKind = styled.button.withConfig({
184
186
  }, function (props) {
185
187
  return !props.plain && props.align && "\n text-align: " + props.align + ";\n ";
186
188
  }, function (props) {
187
- return !props.disabled && props.hoverIndicator && hoverIndicatorStyle(props);
189
+ return !props.disabled && props.hoverIndicator && !props.busy && !props.success && hoverIndicatorStyle(props);
188
190
  }, function (props) {
189
191
  return props.disabled && disabledStyle(props.theme.button.disabled.opacity);
190
192
  }, function (props) {
@@ -195,6 +197,8 @@ var StyledButtonKind = styled.button.withConfig({
195
197
  return props.fillContainer && fillStyle(props.fillContainer);
196
198
  }, function (props) {
197
199
  return props.theme.button && props.theme.button.extend;
200
+ }, function (props) {
201
+ return (props.busy || props.success) && "\n cursor: default;\n ";
198
202
  });
199
203
  StyledButtonKind.defaultProps = {};
200
204
  Object.setPrototypeOf(StyledButtonKind.defaultProps, defaultProps);
@@ -1,3 +1,4 @@
1
+ import { string } from 'prop-types';
1
2
  import * as React from 'react';
2
3
  import {
3
4
  A11yTitleType,
@@ -39,6 +40,7 @@ export interface ButtonProps {
39
40
  hover: boolean;
40
41
  focus: boolean;
41
42
  }) => React.ReactNode);
43
+ busy?: boolean;
42
44
  gridArea?: GridAreaType;
43
45
  margin?: MarginType;
44
46
  active?: boolean;
@@ -61,12 +63,17 @@ export interface ButtonProps {
61
63
  icon?: JSX.Element;
62
64
  kind?: string;
63
65
  label?: React.ReactNode;
66
+ messages?: {
67
+ busy?: string;
68
+ success?: string;
69
+ };
64
70
  pad?: PadType;
65
71
  plain?: boolean;
66
72
  primary?: boolean;
67
73
  reverse?: boolean;
68
74
  secondary?: boolean;
69
75
  size?: 'small' | 'medium' | 'large' | string;
76
+ success?: boolean;
70
77
  tip?: TipProps | string;
71
78
  type?: 'button' | 'reset' | 'submit';
72
79
  as?: PolymorphicType;
@@ -12,6 +12,7 @@ if (process.env.NODE_ENV !== 'production') {
12
12
  max: PropTypes.number,
13
13
  value: PropTypes.oneOfType([PropTypes.bool, PropTypes.number])
14
14
  })]),
15
+ busy: PropTypes.bool,
15
16
  color: colorPropType,
16
17
  disabled: PropTypes.bool,
17
18
  fill: PropTypes.oneOfType([PropTypes.oneOf(['horizontal', 'vertical']), PropTypes.bool]),
@@ -22,6 +23,10 @@ if (process.env.NODE_ENV !== 'production') {
22
23
  icon: PropTypes.element,
23
24
  justify: PropTypes.oneOf(['around', 'between', 'center', 'end', 'evenly', 'start', 'stretch']),
24
25
  label: PropTypes.node,
26
+ messages: PropTypes.shape({
27
+ busy: PropTypes.string,
28
+ success: PropTypes.string
29
+ }),
25
30
  onClick: PropTypes.func,
26
31
  pad: padPropType,
27
32
  plain: PropTypes.bool,
@@ -29,6 +34,7 @@ if (process.env.NODE_ENV !== 'production') {
29
34
  reverse: PropTypes.bool,
30
35
  secondary: PropTypes.bool,
31
36
  size: PropTypes.oneOfType([PropTypes.oneOf(['small', 'medium', 'large']), PropTypes.string]),
37
+ success: PropTypes.bool,
32
38
  target: PropTypes.oneOfType([PropTypes.oneOf(['_self', '_blank', '_parent', '_top']), PropTypes.string]),
33
39
  tip: PropTypes.oneOfType([PropTypes.shape({
34
40
  content: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
@@ -0,0 +1,37 @@
1
+ import React, { useState } from 'react';
2
+ import { Box, Button } from 'grommet';
3
+ export var Busy = function Busy() {
4
+ var _useState = useState(),
5
+ busy = _useState[0],
6
+ setBusy = _useState[1];
7
+ var _useState2 = useState(),
8
+ success = _useState2[0],
9
+ setSuccess = _useState2[1];
10
+ return /*#__PURE__*/React.createElement(Box, {
11
+ align: "center",
12
+ pad: "medium"
13
+ }, /*#__PURE__*/React.createElement(Button, {
14
+ primary: true,
15
+ busy: busy,
16
+ success: success,
17
+ label: "Button Busy",
18
+ onClick: function onClick() {
19
+ setBusy(true);
20
+ setTimeout(function () {
21
+ setBusy(false);
22
+ setSuccess(true);
23
+ }, 2000);
24
+ setTimeout(function () {
25
+ setSuccess(false);
26
+ }, 4000);
27
+ }
28
+ }));
29
+ };
30
+ Busy.parameters = {
31
+ chromatic: {
32
+ disable: true
33
+ }
34
+ };
35
+ export default {
36
+ title: 'Controls/Button/Busy'
37
+ };
@@ -45,11 +45,9 @@ export var Dual = function Dual() {
45
45
  onReference: function onReference(reference) {
46
46
  var refDate = new Date(reference);
47
47
  var nextDate = new Date(refDate);
48
- console.log(refDate);
49
- console.log(nextDate);
50
48
  nextDate.setMonth(refDate.getMonth() + 1, 1);
51
- setReference1(refDate.toString());
52
- setReference2(nextDate.toString());
49
+ setReference1(refDate.toISOString());
50
+ setReference2(nextDate.toISOString());
53
51
  },
54
52
  header: function header(_ref) {
55
53
  var currentDate = _ref.date,
@@ -84,8 +82,8 @@ export var Dual = function Dual() {
84
82
  var refDate = new Date(reference);
85
83
  var priorDate = new Date(refDate);
86
84
  priorDate.setMonth(refDate.getMonth() - 1, 1);
87
- setReference1(priorDate.toString());
88
- setReference2(refDate.toString());
85
+ setReference1(priorDate.toISOString());
86
+ setReference2(refDate.toISOString());
89
87
  },
90
88
  header: function header(_ref2) {
91
89
  var currentDate = _ref2.date,
@@ -36,6 +36,7 @@ export var formRangeKey = '_range';
36
36
  export var formStepKey = '_step';
37
37
  export var formPageKey = '_page';
38
38
  export var formColumnsKey = '_columns';
39
+ export var formGroupByKey = '_groupBy';
39
40
  export var formViewNameKey = '_view';
40
41
  var viewFormKeyMap = {
41
42
  search: formSearchKey,
@@ -43,6 +44,7 @@ var viewFormKeyMap = {
43
44
  step: formStepKey,
44
45
  page: formPageKey,
45
46
  columns: formColumnsKey,
47
+ groupBy: formGroupByKey,
46
48
  view: formViewNameKey
47
49
  };
48
50
 
@@ -105,6 +107,7 @@ var viewToFormValue = function viewToFormValue(view) {
105
107
  if (view != null && view.sort) result[formSortKey] = view.sort;
106
108
  if (view != null && view.name) result[formViewNameKey] = view.name;
107
109
  if (view != null && view.columns) result[formColumnsKey] = view.columns;
110
+ if (view != null && view.groupBy) result[formGroupByKey] = view.groupBy;
108
111
  return unflatten(result);
109
112
  };
110
113
 
@@ -253,7 +256,7 @@ export var DataForm = function DataForm(_ref) {
253
256
  return setFormValue(viewToFormValue(view));
254
257
  }, [view]);
255
258
  var content = children;
256
- if (footer !== false || pad) {
259
+ if (footer !== false && updateOn === 'submit' || pad) {
257
260
  content = /*#__PURE__*/React.createElement(Box, {
258
261
  fill: "vertical"
259
262
  }, /*#__PURE__*/React.createElement(Box, {
@@ -47,7 +47,15 @@ export var filter = function filter(data, view, properties) {
47
47
  if (typeof (filterValue == null ? void 0 : filterValue.min) === 'number' || typeof (filterValue == null ? void 0 : filterValue.max) === 'number') return typeof value !== 'number' || value <= filterValue.min || value >= filterValue.max;
48
48
 
49
49
  // options case
50
- if (Array.isArray(filterValue)) return !filterValue.includes(value);
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);
58
+ }
51
59
 
52
60
  // presence case
53
61
  if (typeof filterValue === 'boolean') return filterValue === !value;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Grid, DataTable, Notification } from 'grommet';
2
+ import { Grid, DataTable, DataFilters, DataSearch, DataSummary, Notification, Text, Toolbar } from 'grommet';
3
3
  import { Data } from '../Data';
4
4
  var data = [{
5
5
  id: 1,
@@ -10,7 +10,8 @@ var data = [{
10
10
  },
11
11
  economy: {
12
12
  GDP: 100
13
- }
13
+ },
14
+ colors: ['white', 'blue']
14
15
  }, {
15
16
  id: 2,
16
17
  name: 'Beta',
@@ -20,7 +21,19 @@ var data = [{
20
21
  },
21
22
  economy: {
22
23
  GDP: 150
23
- }
24
+ },
25
+ colors: ['red', 'white', 'blue']
26
+ }, {
27
+ id: 3,
28
+ name: 'Theta',
29
+ location: {
30
+ city: 'Berlin',
31
+ country: 'Germany'
32
+ },
33
+ economy: {
34
+ GDP: 200
35
+ },
36
+ colors: ['red', 'yellow', 'black']
24
37
  }];
25
38
  var properties = {
26
39
  name: {
@@ -32,6 +45,35 @@ var properties = {
32
45
  },
33
46
  'economy.GDP': {
34
47
  label: 'GDP'
48
+ },
49
+ colors: {
50
+ label: 'Flag Colors',
51
+ options: [{
52
+ label: 'Red',
53
+ value: 'red'
54
+ }, {
55
+ label: 'White',
56
+ value: 'white'
57
+ }, {
58
+ label: 'Blue',
59
+ value: 'blue'
60
+ }, {
61
+ label: 'Yellow',
62
+ value: 'yellow'
63
+ }, {
64
+ label: 'Black',
65
+ value: 'black'
66
+ }, {
67
+ label: 'Green',
68
+ value: 'green'
69
+ }, {
70
+ label: 'Orange',
71
+ value: 'orange'
72
+ }, {
73
+ label: 'Gray',
74
+ value: 'gray'
75
+ }],
76
+ search: true
35
77
  }
36
78
  };
37
79
  var columns = [{
@@ -44,6 +86,17 @@ var columns = [{
44
86
  }, {
45
87
  property: 'economy.GDP',
46
88
  header: 'GDP'
89
+ }, {
90
+ property: 'colors',
91
+ header: 'Flag Colors',
92
+ // render using map map
93
+ render: function render(datum) {
94
+ return datum.colors.map(function (item) {
95
+ return /*#__PURE__*/React.createElement(Text, {
96
+ key: item
97
+ }, item);
98
+ });
99
+ }
47
100
  }];
48
101
  export var Complex = function Complex() {
49
102
  return (
@@ -61,10 +114,14 @@ export var Complex = function Complex() {
61
114
  message: "Data is in 'beta'. The API surface is subject to change."
62
115
  }), /*#__PURE__*/React.createElement(Data, {
63
116
  data: data,
64
- properties: properties,
65
- toolbar: true
66
- }, /*#__PURE__*/React.createElement(DataTable, {
67
- columns: columns
117
+ properties: properties
118
+ }, /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(DataSearch, null), /*#__PURE__*/React.createElement(DataFilters, {
119
+ layer: true
120
+ })), /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(DataTable, {
121
+ columns: columns,
122
+ verticalAlign: {
123
+ body: 'top'
124
+ }
68
125
  })))
69
126
  // </Grommet>
70
127
  );
@@ -1,11 +1,11 @@
1
1
  var _excluded = ["search"];
2
2
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
3
3
  import React, { useContext } from 'react';
4
- import { Box, DataFilters, DataFilter, DataSearch, DataSummary, DataTable, Grid, Heading, Notification, ResponsiveContext, Toolbar } from 'grommet';
4
+ import { Box, DataFilters, DataFilter, DataSearch, DataSummary, DataTable, DataTableGroupBy, Grid, Heading, Notification, ResponsiveContext, Toolbar } from 'grommet';
5
5
  import { Data } from '../Data';
6
6
  var sizes = ['small', 'medium', 'large'];
7
7
  var DATA = [];
8
- for (var i = 0; i < 2; i += 1) {
8
+ for (var i = 0; i < 11; i += 1) {
9
9
  DATA.push({
10
10
  id: "x-" + i,
11
11
  sub: {
@@ -15,6 +15,19 @@ for (var i = 0; i < 2; i += 1) {
15
15
  date: "2022-12-" + (i % 30 + 1)
16
16
  });
17
17
  }
18
+ var columns = [{
19
+ property: 'id',
20
+ header: 'ID'
21
+ }, {
22
+ property: 'sub.name',
23
+ header: 'Name'
24
+ }, {
25
+ property: 'size',
26
+ header: 'Size'
27
+ }, {
28
+ property: 'date',
29
+ header: 'Date'
30
+ }];
18
31
  var Filters = function Filters(_ref) {
19
32
  var search = _ref.search,
20
33
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
@@ -22,6 +35,8 @@ var Filters = function Filters(_ref) {
22
35
  property: "sub.name"
23
36
  }), /*#__PURE__*/React.createElement(DataFilter, {
24
37
  property: "size"
38
+ }), /*#__PURE__*/React.createElement(DataTableGroupBy, {
39
+ options: ['size']
25
40
  }));
26
41
  };
27
42
  export var Inline = function Inline() {
@@ -79,7 +94,9 @@ export var Inline = function Inline() {
79
94
  margin: "none"
80
95
  }, "People"), toolbar, /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(Box, {
81
96
  flex: false
82
- }, /*#__PURE__*/React.createElement(DataTable, null)))))
97
+ }, /*#__PURE__*/React.createElement(DataTable, {
98
+ columns: columns
99
+ })))))
83
100
  // </Grommet>
84
101
  );
85
102
  };
@@ -3,6 +3,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
3
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
4
  import React, { useContext, useMemo } from 'react';
5
5
  import { DataContext } from '../../contexts/DataContext';
6
+ import { DataForm } from '../Data/DataForm';
7
+ import { FormContext } from '../Form/FormContext';
6
8
  import { FormField } from '../FormField';
7
9
  import { CheckBoxGroup } from '../CheckBoxGroup';
8
10
  import { RangeSelector } from '../RangeSelector';
@@ -50,6 +52,8 @@ export var DataFilter = function DataFilter(_ref) {
50
52
  dataId = _useContext.id,
51
53
  properties = _useContext.properties,
52
54
  unfilteredData = _useContext.unfilteredData;
55
+ var _useContext2 = useContext(FormContext),
56
+ noForm = _useContext2.noForm;
53
57
  var _useMemo = useMemo(function () {
54
58
  var _properties$property, _properties$property2;
55
59
  if (children) return [undefined, undefined]; // caller driving
@@ -112,10 +116,16 @@ export var DataFilter = function DataFilter(_ref) {
112
116
  });
113
117
  }
114
118
  }
115
- return /*#__PURE__*/React.createElement(FormField, _extends({
119
+ if (noForm)
120
+ // likely in Toolbar
121
+ content = /*#__PURE__*/React.createElement(DataForm, {
122
+ footer: false,
123
+ updateOn: "change"
124
+ }, content);else content = /*#__PURE__*/React.createElement(FormField, _extends({
116
125
  htmlFor: id,
117
126
  name: property,
118
127
  label: (properties == null ? void 0 : (_properties$property3 = properties[property]) == null ? void 0 : _properties$property3.label) || property
119
128
  }, rest), content);
129
+ return content;
120
130
  };
121
131
  DataFilter.propTypes = DataFilterPropTypes;
@@ -112,14 +112,14 @@ export var DataFilters = function DataFilters(_ref) {
112
112
  } : undefined
113
113
  }, !controlled ? rest : {
114
114
  fill: 'vertical'
115
- }), !drop && /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(Heading, {
115
+ }), layer && /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(Heading, {
116
116
  margin: "none",
117
117
  level: 2,
118
118
  size: "small"
119
119
  }, heading || format({
120
120
  id: 'dataFilters.heading',
121
121
  messages: messages == null ? void 0 : messages.dataFilters
122
- })), !controlled && clearControl, layer && /*#__PURE__*/React.createElement(Button, {
122
+ })), !controlled && clearControl, /*#__PURE__*/React.createElement(Button, {
123
123
  icon: /*#__PURE__*/React.createElement(FormClose, null),
124
124
  hoverIndicator: true,
125
125
  onClick: function onClick() {
@@ -127,14 +127,19 @@ export var DataFilters = function DataFilters(_ref) {
127
127
  }
128
128
  })), content);
129
129
  if (!controlled) return content;
130
+ var tip = format({
131
+ id: badge ? "dataFilters.openSet." + (badge === 1 ? 'singular' : 'plural') : 'dataFilters.open',
132
+ messages: messages == null ? void 0 : messages.dataFilters,
133
+ values: {
134
+ number: badge
135
+ }
136
+ });
130
137
  var control;
131
138
  if (drop) {
132
139
  control = /*#__PURE__*/React.createElement(DropButton, {
133
140
  id: dataId + "--filters-control",
134
- "aria-label": format({
135
- id: 'dataFilters.open',
136
- messages: messages == null ? void 0 : messages.dataFilters
137
- }),
141
+ tip: tip,
142
+ "aria-label": tip,
138
143
  kind: "toolbar",
139
144
  icon: /*#__PURE__*/React.createElement(Filter, null),
140
145
  hoverIndicator: true,
@@ -152,10 +157,8 @@ export var DataFilters = function DataFilters(_ref) {
152
157
  } else if (layer) {
153
158
  control = /*#__PURE__*/React.createElement(Button, {
154
159
  id: dataId + "--filters-control",
155
- "aria-label": format({
156
- id: 'dataFilters.open',
157
- messages: messages == null ? void 0 : messages.dataFilters
158
- }),
160
+ tip: tip,
161
+ "aria-label": tip,
159
162
  kind: "toolbar",
160
163
  hoverIndicator: true,
161
164
  icon: /*#__PURE__*/React.createElement(Filter, null),