grommet 2.30.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 (162) 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/Anchor/Anchor.js +3 -2
  6. package/components/Box/Box.js +14 -4
  7. package/components/Box/stories/Border.js +15 -1
  8. package/components/Button/Badge.js +42 -43
  9. package/components/Button/BusyAnimation.js +51 -0
  10. package/components/Button/Button.js +78 -15
  11. package/components/Button/StyledButton.js +7 -3
  12. package/components/Button/StyledButtonKind.js +12 -6
  13. package/components/Button/index.d.ts +9 -0
  14. package/components/Button/propTypes.js +7 -0
  15. package/components/Button/stories/Busy.js +45 -0
  16. package/components/Calendar/stories/Dual.js +4 -6
  17. package/components/CheckBox/index.d.ts +1 -1
  18. package/components/Data/DataForm.js +45 -35
  19. package/components/Data/filter.js +9 -1
  20. package/components/Data/stories/Complex.js +63 -6
  21. package/components/Data/stories/Inline.js +19 -2
  22. package/components/DataFilter/DataFilter.js +11 -1
  23. package/components/DataFilters/DataFilters.js +13 -10
  24. package/components/DataTable/Body.js +16 -13
  25. package/components/DataTable/DataTable.js +4 -1
  26. package/components/DataTable/GroupedBody.js +1 -0
  27. package/components/DataTable/Header.js +1 -0
  28. package/components/DataTable/buildState.js +12 -10
  29. package/components/DataTable/stories/Controlled.js +2 -1
  30. package/components/DataTable/stories/ControlledGrouped.js +2 -1
  31. package/components/DataTable/stories/CustomThemed/Custom.js +0 -1
  32. package/components/DataTable/stories/CustomThemed/Fill.js +2 -1
  33. package/components/DataTable/stories/GroupedOnSelect.js +2 -1
  34. package/components/DataTable/stories/NoPrimary.js +0 -1
  35. package/components/DataTable/stories/OnUpdate.js +2 -1
  36. package/components/DataTable/stories/Served.js +2 -1
  37. package/components/DataTable/stories/Tunable.js +2 -1
  38. package/components/DataTable/stories/rowDetails.js +2 -1
  39. package/components/DataTableColumns/DataTableColumns.js +5 -0
  40. package/components/DataTableColumns/stories/Simple.js +4 -3
  41. package/components/DataTableGroupBy/DataTableGroupBy.js +67 -0
  42. package/components/DataTableGroupBy/README.md +2 -0
  43. package/components/DataTableGroupBy/index.d.ts +20 -0
  44. package/components/DataTableGroupBy/index.js +6 -0
  45. package/components/DataTableGroupBy/propTypes.js +17 -0
  46. package/components/DataTableGroupBy/stories/Simple.js +50 -0
  47. package/components/DataView/DataView.js +1 -1
  48. package/components/DateInput/DateInput.js +3 -2
  49. package/components/Drop/DropContainer.js +2 -2
  50. package/components/DropButton/DropButton.js +2 -2
  51. package/components/FileInput/FileInput.js +82 -53
  52. package/components/Form/Form.js +95 -44
  53. package/components/Form/stories/TriggerValidationUsingFormField.js +109 -0
  54. package/components/FormField/FormField.js +4 -3
  55. package/components/FormField/index.d.ts +1 -0
  56. package/components/FormField/propTypes.js +2 -1
  57. package/components/Grid/stories/CustomThemed/Responsive.js +0 -1
  58. package/components/InfiniteScroll/InfiniteScroll.js +1 -0
  59. package/components/Layer/Layer.js +1 -1
  60. package/components/Layer/LayerContainer.js +2 -2
  61. package/components/List/index.d.ts +2 -2
  62. package/components/MaskedInput/MaskedInput.js +3 -2
  63. package/components/MaskedInput/StyledMaskedInput.js +2 -1
  64. package/components/NameValueList/NameValueList.js +1 -1
  65. package/components/Notification/Notification.js +7 -3
  66. package/components/PageHeader/PageHeader.js +6 -4
  67. package/components/Pagination/StyledPageControl.js +3 -1
  68. package/components/Paragraph/Paragraph.js +2 -2
  69. package/components/Paragraph/stories/All.js +5 -1
  70. package/components/SelectMultiple/SelectMultiple.js +24 -20
  71. package/components/SelectMultiple/SelectMultipleContainer.js +16 -13
  72. package/components/SelectMultiple/SelectMultipleValue.js +1 -1
  73. package/components/SelectMultiple/stories/Help.js +49 -0
  74. package/components/Text/Text.js +2 -2
  75. package/components/TextInput/StyledTextInput.js +2 -1
  76. package/components/TextInput/TextInput.js +3 -2
  77. package/components/Tip/stories/HeaderActions.js +0 -1
  78. package/components/index.d.ts +1 -0
  79. package/components/index.js +6 -0
  80. package/es6/components/Accordion/Accordion.js +4 -2
  81. package/es6/components/Accordion/index.d.ts +1 -0
  82. package/es6/components/Accordion/propTypes.js +1 -0
  83. package/es6/components/AccordionPanel/AccordionPanel.js +2 -1
  84. package/es6/components/Anchor/Anchor.js +4 -3
  85. package/es6/components/Box/Box.js +14 -4
  86. package/es6/components/Box/stories/Border.js +15 -1
  87. package/es6/components/Button/Badge.js +43 -44
  88. package/es6/components/Button/BusyAnimation.js +41 -0
  89. package/es6/components/Button/Button.js +79 -17
  90. package/es6/components/Button/StyledButton.js +8 -4
  91. package/es6/components/Button/StyledButtonKind.js +13 -7
  92. package/es6/components/Button/index.d.ts +9 -0
  93. package/es6/components/Button/propTypes.js +8 -1
  94. package/es6/components/Button/stories/Busy.js +37 -0
  95. package/es6/components/Calendar/stories/Dual.js +4 -6
  96. package/es6/components/CheckBox/index.d.ts +1 -1
  97. package/es6/components/Data/DataForm.js +43 -34
  98. package/es6/components/Data/filter.js +9 -1
  99. package/es6/components/Data/stories/Complex.js +64 -7
  100. package/es6/components/Data/stories/Inline.js +20 -3
  101. package/es6/components/DataFilter/DataFilter.js +11 -1
  102. package/es6/components/DataFilters/DataFilters.js +13 -10
  103. package/es6/components/DataTable/Body.js +15 -13
  104. package/es6/components/DataTable/DataTable.js +4 -1
  105. package/es6/components/DataTable/GroupedBody.js +1 -0
  106. package/es6/components/DataTable/buildState.js +12 -10
  107. package/es6/components/DataTableColumns/DataTableColumns.js +5 -0
  108. package/es6/components/DataTableColumns/stories/Simple.js +5 -4
  109. package/es6/components/DataTableGroupBy/DataTableGroupBy.js +60 -0
  110. package/es6/components/DataTableGroupBy/README.md +2 -0
  111. package/es6/components/DataTableGroupBy/index.d.ts +20 -0
  112. package/es6/components/DataTableGroupBy/index.js +1 -0
  113. package/es6/components/DataTableGroupBy/propTypes.js +11 -0
  114. package/es6/components/DataTableGroupBy/stories/Simple.js +45 -0
  115. package/es6/components/DataView/DataView.js +1 -1
  116. package/es6/components/DateInput/DateInput.js +3 -2
  117. package/es6/components/Drop/DropContainer.js +2 -2
  118. package/es6/components/DropButton/DropButton.js +2 -2
  119. package/es6/components/FileInput/FileInput.js +83 -53
  120. package/es6/components/Form/Form.js +95 -44
  121. package/es6/components/Form/stories/TriggerValidationUsingFormField.js +102 -0
  122. package/es6/components/FormField/FormField.js +4 -3
  123. package/es6/components/FormField/index.d.ts +1 -0
  124. package/es6/components/FormField/propTypes.js +2 -1
  125. package/es6/components/InfiniteScroll/InfiniteScroll.js +1 -0
  126. package/es6/components/Layer/Layer.js +1 -1
  127. package/es6/components/Layer/LayerContainer.js +2 -2
  128. package/es6/components/List/index.d.ts +2 -2
  129. package/es6/components/MaskedInput/MaskedInput.js +4 -3
  130. package/es6/components/MaskedInput/StyledMaskedInput.js +2 -1
  131. package/es6/components/NameValueList/NameValueList.js +1 -1
  132. package/es6/components/Notification/Notification.js +7 -3
  133. package/es6/components/PageHeader/PageHeader.js +6 -4
  134. package/es6/components/Pagination/StyledPageControl.js +3 -1
  135. package/es6/components/Paragraph/Paragraph.js +2 -2
  136. package/es6/components/Paragraph/stories/All.js +5 -1
  137. package/es6/components/SelectMultiple/SelectMultiple.js +24 -20
  138. package/es6/components/SelectMultiple/SelectMultipleContainer.js +16 -13
  139. package/es6/components/SelectMultiple/SelectMultipleValue.js +1 -1
  140. package/es6/components/SelectMultiple/stories/Help.js +42 -0
  141. package/es6/components/Text/Text.js +2 -2
  142. package/es6/components/TextInput/StyledTextInput.js +2 -1
  143. package/es6/components/TextInput/TextInput.js +4 -3
  144. package/es6/components/index.d.ts +1 -0
  145. package/es6/components/index.js +1 -0
  146. package/es6/index.d.ts +1 -0
  147. package/es6/languages/default.json +15 -2
  148. package/es6/themes/base.d.ts +3 -0
  149. package/es6/themes/base.js +7 -1
  150. package/es6/utils/icon.js +7 -0
  151. package/es6/utils/index.js +1 -0
  152. package/es6/utils/styles.js +10 -0
  153. package/grommet.min.js +1 -1
  154. package/grommet.min.js.map +1 -1
  155. package/index.d.ts +1 -0
  156. package/languages/default.json +15 -2
  157. package/package.json +49 -48
  158. package/themes/base.d.ts +3 -0
  159. package/themes/base.js +7 -1
  160. package/utils/icon.js +12 -0
  161. package/utils/index.js +6 -0
  162. package/utils/styles.js +12 -1
@@ -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,
@@ -4,7 +4,7 @@ import { A11yTitleType, PadType } from '../../utils';
4
4
  export interface CheckBoxProps {
5
5
  a11yTitle?: A11yTitleType;
6
6
  checked?: boolean;
7
- children?: Function;
7
+ children?: React.ReactNode | Function;
8
8
  disabled?: boolean;
9
9
  fill?: boolean;
10
10
  id?: string;
@@ -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
 
@@ -252,42 +255,48 @@ export var DataForm = function DataForm(_ref) {
252
255
  useEffect(function () {
253
256
  return setFormValue(viewToFormValue(view));
254
257
  }, [view]);
258
+ var content = children;
259
+ if (footer !== false && updateOn === 'submit' || pad) {
260
+ content = /*#__PURE__*/React.createElement(Box, {
261
+ fill: "vertical"
262
+ }, /*#__PURE__*/React.createElement(Box, {
263
+ flex: true,
264
+ overflow: "auto",
265
+ pad: {
266
+ horizontal: pad,
267
+ top: pad
268
+ }
269
+ }, /*#__PURE__*/React.createElement(Box, {
270
+ flex: false
271
+ }, content)), footer !== false && updateOn === 'submit' && /*#__PURE__*/React.createElement(Footer, {
272
+ flex: false,
273
+ margin: {
274
+ top: 'small'
275
+ },
276
+ pad: {
277
+ horizontal: pad,
278
+ bottom: pad
279
+ },
280
+ gap: "small"
281
+ }, /*#__PURE__*/React.createElement(Button, {
282
+ label: format({
283
+ id: 'dataForm.submit',
284
+ messages: messages == null ? void 0 : messages.dataForm
285
+ }),
286
+ type: "submit",
287
+ primary: true
288
+ }), /*#__PURE__*/React.createElement(HideableButton, _extends({
289
+ label: format({
290
+ id: 'dataForm.reset',
291
+ messages: messages == null ? void 0 : messages.dataForm
292
+ }),
293
+ type: "reset",
294
+ onClick: onReset
295
+ }, !changed ? hideButtonProps : {}))));
296
+ }
255
297
  return /*#__PURE__*/React.createElement(MaxForm, _extends({}, rest, {
256
298
  value: formValue,
257
299
  onSubmit: updateOn === 'submit' ? onSubmit : undefined,
258
300
  onChange: onChange
259
- }), /*#__PURE__*/React.createElement(Box, {
260
- fill: "vertical"
261
- }, /*#__PURE__*/React.createElement(Box, {
262
- flex: true,
263
- overflow: "auto",
264
- pad: {
265
- horizontal: pad,
266
- top: pad
267
- }
268
- }, children), footer !== false && updateOn === 'submit' && /*#__PURE__*/React.createElement(Footer, {
269
- flex: false,
270
- margin: {
271
- top: 'small'
272
- },
273
- pad: {
274
- horizontal: pad,
275
- bottom: pad
276
- },
277
- gap: "small"
278
- }, /*#__PURE__*/React.createElement(Button, {
279
- label: format({
280
- id: 'dataForm.submit',
281
- messages: messages == null ? void 0 : messages.dataForm
282
- }),
283
- type: "submit",
284
- primary: true
285
- }), /*#__PURE__*/React.createElement(HideableButton, _extends({
286
- label: format({
287
- id: 'dataForm.reset',
288
- messages: messages == null ? void 0 : messages.dataForm
289
- }),
290
- type: "reset",
291
- onClick: onReset
292
- }, !changed ? hideButtonProps : {})))));
301
+ }), content);
293
302
  };
@@ -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),
@@ -56,8 +56,8 @@ var Row = /*#__PURE__*/memo(function (_ref) {
56
56
  if (isSelected) {
57
57
  onSelect(selected.filter(function (s) {
58
58
  return s !== primaryValue;
59
- }));
60
- } else onSelect([].concat(selected, [primaryValue]));
59
+ }), datum);
60
+ } else onSelect([].concat(selected, [primaryValue]), datum);
61
61
  }
62
62
  }
63
63
  } : undefined,
@@ -69,6 +69,7 @@ var Row = /*#__PURE__*/memo(function (_ref) {
69
69
  } : undefined
70
70
  }, (selected || onSelect) && /*#__PURE__*/React.createElement(Cell, {
71
71
  background: (pinnedOffset == null ? void 0 : pinnedOffset._grommetDataTableSelect) && cellProps.pinned.background || cellProps.background,
72
+ border: cellProps.pinned.border || cellProps.border,
72
73
  pinnedOffset: pinnedOffset == null ? void 0 : pinnedOffset._grommetDataTableSelect,
73
74
  "aria-disabled": isDisabled || !onSelect || undefined,
74
75
  column: {
@@ -85,8 +86,8 @@ var Row = /*#__PURE__*/memo(function (_ref) {
85
86
  if (isSelected) {
86
87
  onSelect(selected.filter(function (s) {
87
88
  return s !== primaryValue;
88
- }));
89
- } else onSelect([].concat(selected, [primaryValue]));
89
+ }), datum);
90
+ } else onSelect([].concat(selected, [primaryValue]), datum);
90
91
  },
91
92
  pad: cellProps.pad
92
93
  });
@@ -160,16 +161,17 @@ var Body = /*#__PURE__*/forwardRef(function (_ref2, ref) {
160
161
  // Determine if using a keyboard to cover focus behavior
161
162
  var usingKeyboard = useKeyboard();
162
163
  var onFocusActive = (_ref3 = active != null ? active : lastActive) != null ? _ref3 : usingKeyboard ? 0 : undefined;
164
+ var activePrimaryValue = active >= 0 ? datumValue(data[active], primaryProperty) : undefined;
163
165
  var selectRow = function selectRow() {
164
- var _data$active;
165
- var primaryValue = (_data$active = data[active]) == null ? void 0 : _data$active[primaryProperty];
166
- if (selected && selected.includes(primaryValue)) {
167
- onSelect(selected.filter(function (s) {
168
- return s !== primaryValue;
169
- }));
170
- } else onSelect([].concat(selected, [primaryValue]));
166
+ if (activePrimaryValue !== undefined) {
167
+ if (selected && selected.includes(activePrimaryValue)) {
168
+ onSelect(selected.filter(function (s) {
169
+ return s !== activePrimaryValue;
170
+ }));
171
+ } else onSelect([].concat(selected, [activePrimaryValue]));
172
+ }
171
173
  };
172
- var clickableRow = onClickRow && active >= 0 && (!disabled || !disabled.includes(datumValue(data[active], primaryProperty)));
174
+ var clickableRow = onClickRow && active >= 0 && (!disabled || activePrimaryValue !== undefined && !disabled.includes(activePrimaryValue));
173
175
  return /*#__PURE__*/React.createElement(Keyboard, {
174
176
  onEnter: clickableRow ? function (event) {
175
177
  if (clickableRow) {
@@ -225,7 +227,7 @@ var Body = /*#__PURE__*/forwardRef(function (_ref2, ref) {
225
227
  var isRowExpanded = rowExpand && rowExpand.includes(index);
226
228
  var cellProps = normalizeRowCellProps(rowProps, cellPropsProp, primaryValue, index);
227
229
  return /*#__PURE__*/React.createElement(Row, {
228
- key: index,
230
+ key: primaryValue != null ? primaryValue : index,
229
231
  setActive: setActive,
230
232
  rowRef: rowRef,
231
233
  cellProps: cellProps,
@@ -51,7 +51,7 @@ var DataTable = function DataTable(_ref) {
51
51
  dataProp = _ref.data,
52
52
  disabled = _ref.disabled,
53
53
  fill = _ref.fill,
54
- groupBy = _ref.groupBy,
54
+ groupByProp = _ref.groupBy,
55
55
  onClickRow = _ref.onClickRow,
56
56
  onMore = _ref.onMore,
57
57
  onSearch = _ref.onSearch,
@@ -132,6 +132,9 @@ var DataTable = function DataTable(_ref) {
132
132
  if (sortProp) setSort(sortProp);else if (view != null && view.sort) setSort(view.sort);
133
133
  }, [sortProp, view]);
134
134
 
135
+ // what we are grouping on
136
+ var groupBy = (view == null ? void 0 : view.groupBy) || groupByProp;
137
+
135
138
  // the data filtered and sorted, if needed
136
139
  // Note: onUpdate mode expects the data to be passed
137
140
  // in completely filtered and sorted already.
@@ -139,6 +139,7 @@ export var GroupedBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
139
139
  verticalAlign: verticalAlign
140
140
  }), (selected || onSelect) && /*#__PURE__*/React.createElement(TableCell, {
141
141
  background: cellProps.background,
142
+ border: cellProps.pinned.border || cellProps.border,
142
143
  plain: "noPad",
143
144
  size: "auto",
144
145
  verticalAlign: verticalAlign,
@@ -17,7 +17,7 @@ export var set = function set(obj, path, value) {
17
17
 
18
18
  // get the value for the property in the datum object
19
19
  export var datumValue = function datumValue(datum, property) {
20
- if (!property) return undefined;
20
+ if (!property || !datum) return undefined;
21
21
  var parts = property.split('.');
22
22
  if (parts.length === 1) return datum[property];
23
23
  if (!datum[parts[0]]) return undefined;
@@ -26,15 +26,17 @@ export var datumValue = function datumValue(datum, property) {
26
26
 
27
27
  // get the primary property name
28
28
  export var normalizePrimaryProperty = function normalizePrimaryProperty(columns, primaryKey) {
29
- var result;
30
- columns.forEach(function (column) {
31
- // remember the first key property
32
- if (column.primary && !result) {
33
- result = column.property;
34
- }
35
- });
36
- if (!result) {
37
- if (primaryKey === false) result = undefined;else if (primaryKey) result = primaryKey;else if (columns.length > 0) result = columns[0].property;
29
+ var result = primaryKey;
30
+ if (result === undefined) {
31
+ columns.forEach(function (column) {
32
+ // remember the first key property
33
+ if (column.primary && !result) {
34
+ result = column.property;
35
+ }
36
+ });
37
+ }
38
+ if (result === undefined && columns.length > 0) {
39
+ result = columns[0].property;
38
40
  }
39
41
  return result;
40
42
  };
@@ -187,6 +187,10 @@ export var DataTableColumns = function DataTableColumns(_ref5) {
187
187
  var _useState3 = useState(),
188
188
  showContent = _useState3[0],
189
189
  setShowContent = _useState3[1];
190
+ var tip = format({
191
+ id: 'dataTableColumns.tip',
192
+ messages: messages == null ? void 0 : messages.dataTableColumns
193
+ });
190
194
  var content = /*#__PURE__*/React.createElement(Content, {
191
195
  drop: drop,
192
196
  options: options
@@ -204,6 +208,7 @@ export var DataTableColumns = function DataTableColumns(_ref5) {
204
208
  }),
205
209
  kind: "toolbar",
206
210
  icon: /*#__PURE__*/React.createElement(Splits, null),
211
+ tip: tip,
207
212
  dropProps: dropProps,
208
213
  dropContent: content,
209
214
  open: showContent,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Box, Data, DataTable, Notification, Toolbar } from 'grommet';
2
+ import { Box, Data, DataSearch, DataSummary, DataTable, Notification, Toolbar } from 'grommet';
3
3
  import { DataTableColumns } from '../DataTableColumns';
4
4
  import { columns, DATA } from '../../DataTable/stories/data';
5
5
 
@@ -28,11 +28,12 @@ export var Simple = function Simple() {
28
28
  }), /*#__PURE__*/React.createElement(Data, {
29
29
  data: DATA,
30
30
  updateOn: "change"
31
- }, /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(DataTableColumns, {
31
+ }, /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(DataSearch, null), /*#__PURE__*/React.createElement(DataTableColumns, {
32
32
  drop: true,
33
33
  options: options
34
- })), /*#__PURE__*/React.createElement(DataTable, {
35
- columns: columns
34
+ })), /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(DataTable, {
35
+ columns: columns,
36
+ primaryKey: "name"
36
37
  })))
37
38
  // </Grommet>
38
39
  );
@@ -0,0 +1,60 @@
1
+ var _excluded = ["id", "options"];
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
+ 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, { useContext, useEffect } from 'react';
5
+ import { DataForm } from '../Data/DataForm';
6
+ import { DataContext } from '../../contexts/DataContext';
7
+ import { FormContext } from '../Form/FormContext';
8
+ import { FormField } from '../FormField';
9
+ import { Select } from '../Select';
10
+ import { MessageContext } from '../../contexts/MessageContext';
11
+ import { DataTableGroupByPropTypes } from './propTypes';
12
+ export var DataTableGroupBy = function DataTableGroupBy(_ref) {
13
+ var idProp = _ref.id,
14
+ options = _ref.options,
15
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
16
+ var _useContext = useContext(DataContext),
17
+ dataId = _useContext.id,
18
+ messages = _useContext.messages,
19
+ view = _useContext.view,
20
+ addToolbarKey = _useContext.addToolbarKey;
21
+ var _useContext2 = useContext(FormContext),
22
+ noForm = _useContext2.noForm;
23
+ var _useContext3 = useContext(MessageContext),
24
+ format = _useContext3.format;
25
+ var id = idProp || dataId + "--groupby";
26
+ useEffect(function () {
27
+ if (noForm) addToolbarKey('_groupBy');
28
+ }, [addToolbarKey, noForm]);
29
+ if (!options) return null;
30
+ var content = /*#__PURE__*/React.createElement(Select, _extends({
31
+ id: id,
32
+ name: "_groupBy",
33
+ showSelectedInline: true,
34
+ placeholder: noForm ? 'Group by' : undefined,
35
+ options: options,
36
+ labelKey: "label",
37
+ clear: view != null && view.groupBy ? {
38
+ position: 'top',
39
+ label: format({
40
+ id: 'dataTableGroupBy.clear',
41
+ messages: messages == null ? void 0 : messages.dataTableGroupBy
42
+ })
43
+ } : undefined,
44
+ value: view == null ? void 0 : view.groupBy
45
+ }, rest));
46
+ if (noForm)
47
+ // likely in Toolbar
48
+ content = /*#__PURE__*/React.createElement(DataForm, {
49
+ footer: false,
50
+ updateOn: "change"
51
+ }, content);else content = /*#__PURE__*/React.createElement(FormField, {
52
+ htmlFor: id,
53
+ label: format({
54
+ id: 'dataTableGroupBy.label',
55
+ messages: messages == null ? void 0 : messages.dataTableGroupBy
56
+ })
57
+ }, content);
58
+ return content;
59
+ };
60
+ DataTableGroupBy.propTypes = DataTableGroupByPropTypes;
@@ -0,0 +1,2 @@
1
+ ## DataTableGroupBy
2
+ Documentation for this component: https://v2.grommet.io/datatablegroupby
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import { BoxProps } from '../Box/index';
3
+
4
+ export interface DataTableGroupByProps {
5
+ options: string[] | { label: string; property: string }[];
6
+ }
7
+
8
+ type selectProps = Omit<
9
+ JSX.IntrinsicElements['select'],
10
+ 'onClick' | 'property'
11
+ >;
12
+
13
+ export interface DataTableGroupByExtendedProps
14
+ extends BoxProps,
15
+ DataTableGroupByProps,
16
+ selectProps {}
17
+
18
+ declare const DataTableGroupBy: React.FC<DataTableGroupByExtendedProps>;
19
+
20
+ export { DataTableGroupBy };