grommet 2.29.0 → 2.30.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.
- package/components/Anchor/Anchor.js +9 -3
- package/components/Anchor/StyledAnchor.js +6 -3
- package/components/Button/Button.js +10 -14
- package/components/Button/StyledButtonKind.js +21 -9
- package/components/Calendar/Calendar.js +80 -71
- package/components/Data/Data.js +48 -26
- package/components/Data/DataForm.js +203 -48
- package/components/Data/filter.js +17 -6
- package/components/Data/index.d.ts +12 -7
- package/components/Data/index.js +6 -2
- package/components/Data/propTypes.js +3 -2
- package/components/Data/stories/Cards.js +1 -1
- package/components/Data/stories/Complex.js +84 -0
- package/components/Data/stories/Controlled.js +1 -1
- package/components/Data/stories/DataTable.js +11 -4
- package/components/Data/stories/Infinite.js +53 -57
- package/components/Data/stories/Inline.js +7 -2
- package/components/Data/stories/List.js +1 -1
- package/components/Data/stories/Simple.js +1 -1
- package/components/Data/stories/SpaceX.js +114 -140
- package/components/Data/stories/StarWars.js +127 -0
- package/components/Data/stories/Views.js +56 -0
- package/components/DataFilter/DataFilter.js +33 -42
- package/components/DataFilter/stories/Simple.js +7 -4
- package/components/DataFilters/DataFilters.js +117 -40
- package/components/DataFilters/index.d.ts +1 -0
- package/components/DataFilters/propTypes.js +2 -1
- package/components/DataFilters/stories/Drop.js +7 -4
- package/components/DataFilters/stories/Inline.js +24 -6
- package/components/DataFilters/stories/Layer.js +46 -0
- package/components/DataFilters/stories/Simple.js +7 -4
- package/components/DataSearch/DataSearch.js +70 -13
- package/components/DataSearch/index.d.ts +10 -1
- package/components/DataSearch/propTypes.js +6 -1
- package/components/DataSearch/stories/Drop.js +42 -0
- package/components/DataSearch/stories/Responsive.js +42 -0
- package/components/DataSearch/stories/Simple.js +5 -2
- package/components/DataSort/DataSort.js +67 -18
- package/components/DataSort/index.d.ts +4 -8
- package/components/DataSort/propTypes.js +9 -2
- package/components/DataSort/stories/Drop.js +41 -0
- package/components/DataSort/stories/Simple.js +9 -5
- package/components/DataSummary/DataSummary.js +4 -4
- package/components/DataSummary/index.d.ts +1 -1
- package/components/DataSummary/propTypes.js +2 -2
- package/components/DataSummary/stories/Simple.js +7 -4
- package/components/DataTable/Cell.js +1 -1
- package/components/DataTable/DataTable.js +23 -9
- package/components/DataTable/GroupedBody.js +1 -0
- package/components/DataTable/Resizer.js +1 -3
- package/components/DataTable/StyledDataTable.js +2 -2
- package/components/DataTable/index.d.ts +23 -6
- package/components/DataTable/stories/SpaceX.js +72 -76
- package/components/DataTable/stories/SpaceXUngrouped.js +33 -35
- package/components/DataTableColumns/DataTableColumns.js +226 -0
- package/components/DataTableColumns/README.md +2 -0
- package/components/DataTableColumns/index.d.ts +10 -0
- package/components/DataTableColumns/index.js +6 -0
- package/components/DataTableColumns/propTypes.js +18 -0
- package/components/DataTableColumns/stories/Simple.js +51 -0
- package/components/DataView/DataView.js +73 -0
- package/components/DataView/README.md +2 -0
- package/components/DataView/index.d.ts +15 -0
- package/components/DataView/index.js +6 -0
- package/components/DataView/propTypes.js +10 -0
- package/components/DataView/stories/Simple.js +51 -0
- package/components/DateInput/utils.js +1 -3
- package/components/Distribution/Distribution.js +1 -1
- package/components/Drop/DropContainer.js +56 -100
- package/components/Drop/stories/Overflow.js +1 -0
- package/components/DropButton/DropButton.js +1 -1
- package/components/Form/stories/Controlled.js +11 -2
- package/components/Form/stories/ControlledInput.js +13 -2
- package/components/Form/stories/ControlledInputLazy.js +13 -2
- package/components/Form/stories/ControlledLazy.js +13 -2
- package/components/Form/stories/FieldWithChildren.js +13 -2
- package/components/Form/stories/FieldWithComponentProp.js +17 -1
- package/components/Form/stories/Uncontrolled.js +15 -2
- package/components/Form/stories/ValidateOnBlur.js +18 -0
- package/components/Form/stories/ValidateOnChange.js +6 -0
- package/components/Form/stories/ValidateOnMount.js +4 -0
- package/components/Form/stories/typescript/TypedForm.tsx +25 -3
- package/components/FormField/FormField.js +15 -4
- package/components/Layer/LayerContainer.js +2 -3
- package/components/Layer/PortalContext.js +1 -1
- package/components/Layer/StyledLayer.js +3 -1
- package/components/Layer/stories/Form.js +54 -28
- package/components/List/List.js +1 -8
- package/components/Pagination/Pagination.js +27 -8
- package/components/Paragraph/Paragraph.js +18 -6
- package/components/Select/utils.js +1 -1
- package/components/Skeleton/stories/GridContainer.js +1 -3
- package/components/Tabs/Tabs.js +2 -1
- package/components/Text/Text.js +9 -1
- package/components/Text/TextContext.js +8 -0
- package/components/TextInput/StyledTextInput.js +3 -1
- package/components/TextInput/TextInput.js +4 -2
- package/components/TextInput/index.d.ts +3 -1
- package/components/TextInput/propTypes.js +3 -1
- package/components/Toolbar/stories/Simple.js +1 -1
- package/components/Video/Video.js +4 -8
- package/components/WorldMap/WorldMap.js +18 -17
- package/components/index.d.ts +2 -0
- package/components/index.js +18 -6
- package/es6/components/Anchor/Anchor.js +9 -3
- package/es6/components/Anchor/StyledAnchor.js +6 -3
- package/es6/components/Button/Button.js +10 -14
- package/es6/components/Button/StyledButtonKind.js +21 -9
- package/es6/components/Calendar/Calendar.js +80 -71
- package/es6/components/Data/Data.js +48 -26
- package/es6/components/Data/DataForm.js +199 -51
- package/es6/components/Data/filter.js +17 -6
- package/es6/components/Data/index.d.ts +12 -7
- package/es6/components/Data/index.js +1 -1
- package/es6/components/Data/propTypes.js +3 -2
- package/es6/components/Data/stories/Cards.js +1 -1
- package/es6/components/Data/stories/Complex.js +78 -0
- package/es6/components/Data/stories/Controlled.js +1 -1
- package/es6/components/Data/stories/DataTable.js +12 -5
- package/es6/components/Data/stories/Infinite.js +53 -57
- package/es6/components/Data/stories/Inline.js +7 -2
- package/es6/components/Data/stories/List.js +1 -1
- package/es6/components/Data/stories/Simple.js +1 -1
- package/es6/components/Data/stories/SpaceX.js +114 -140
- package/es6/components/Data/stories/StarWars.js +121 -0
- package/es6/components/Data/stories/Views.js +50 -0
- package/es6/components/DataFilter/DataFilter.js +33 -42
- package/es6/components/DataFilter/stories/Simple.js +8 -5
- package/es6/components/DataFilters/DataFilters.js +118 -41
- package/es6/components/DataFilters/index.d.ts +1 -0
- package/es6/components/DataFilters/propTypes.js +2 -1
- package/es6/components/DataFilters/stories/Drop.js +8 -5
- package/es6/components/DataFilters/stories/Inline.js +25 -7
- package/es6/components/DataFilters/stories/Layer.js +40 -0
- package/es6/components/DataFilters/stories/Simple.js +8 -5
- package/es6/components/DataSearch/DataSearch.js +71 -14
- package/es6/components/DataSearch/index.d.ts +10 -1
- package/es6/components/DataSearch/propTypes.js +5 -1
- package/es6/components/DataSearch/stories/Drop.js +36 -0
- package/es6/components/DataSearch/stories/Responsive.js +36 -0
- package/es6/components/DataSearch/stories/Simple.js +6 -3
- package/es6/components/DataSort/DataSort.js +67 -18
- package/es6/components/DataSort/index.d.ts +4 -8
- package/es6/components/DataSort/propTypes.js +8 -2
- package/es6/components/DataSort/stories/Drop.js +35 -0
- package/es6/components/DataSort/stories/Simple.js +10 -6
- package/es6/components/DataSummary/DataSummary.js +4 -4
- package/es6/components/DataSummary/index.d.ts +1 -1
- package/es6/components/DataSummary/propTypes.js +2 -2
- package/es6/components/DataSummary/stories/Simple.js +8 -5
- package/es6/components/DataTable/Cell.js +2 -2
- package/es6/components/DataTable/DataTable.js +23 -9
- package/es6/components/DataTable/GroupedBody.js +1 -0
- package/es6/components/DataTable/Resizer.js +1 -3
- package/es6/components/DataTable/StyledDataTable.js +2 -2
- package/es6/components/DataTable/index.d.ts +23 -6
- package/es6/components/DataTable/stories/SpaceX.js +72 -76
- package/es6/components/DataTable/stories/SpaceXUngrouped.js +33 -35
- package/es6/components/DataTableColumns/DataTableColumns.js +219 -0
- package/es6/components/DataTableColumns/README.md +2 -0
- package/es6/components/DataTableColumns/index.d.ts +10 -0
- package/es6/components/DataTableColumns/index.js +1 -0
- package/es6/components/DataTableColumns/propTypes.js +12 -0
- package/es6/components/DataTableColumns/stories/Simple.js +46 -0
- package/es6/components/DataView/DataView.js +66 -0
- package/es6/components/DataView/README.md +2 -0
- package/es6/components/DataView/index.d.ts +15 -0
- package/es6/components/DataView/index.js +1 -0
- package/es6/components/DataView/propTypes.js +5 -0
- package/es6/components/DataView/stories/Simple.js +45 -0
- package/es6/components/DateInput/utils.js +1 -3
- package/es6/components/Distribution/Distribution.js +1 -1
- package/es6/components/Drop/DropContainer.js +58 -102
- package/es6/components/Drop/stories/Overflow.js +1 -0
- package/es6/components/DropButton/DropButton.js +1 -1
- package/es6/components/Form/stories/Controlled.js +11 -2
- package/es6/components/Form/stories/ControlledInput.js +13 -2
- package/es6/components/Form/stories/ControlledInputLazy.js +13 -2
- package/es6/components/Form/stories/ControlledLazy.js +13 -2
- package/es6/components/Form/stories/FieldWithChildren.js +13 -2
- package/es6/components/Form/stories/FieldWithComponentProp.js +17 -1
- package/es6/components/Form/stories/Uncontrolled.js +15 -2
- package/es6/components/Form/stories/ValidateOnBlur.js +19 -1
- package/es6/components/Form/stories/ValidateOnChange.js +6 -0
- package/es6/components/Form/stories/ValidateOnMount.js +4 -0
- package/es6/components/Form/stories/typescript/TypedForm.tsx +25 -3
- package/es6/components/FormField/FormField.js +15 -4
- package/es6/components/Layer/LayerContainer.js +2 -3
- package/es6/components/Layer/PortalContext.js +1 -1
- package/es6/components/Layer/StyledLayer.js +3 -1
- package/es6/components/Layer/stories/Form.js +56 -29
- package/es6/components/List/List.js +1 -8
- package/es6/components/Pagination/Pagination.js +27 -8
- package/es6/components/Paragraph/Paragraph.js +19 -7
- package/es6/components/Select/utils.js +1 -1
- package/es6/components/Skeleton/stories/GridContainer.js +1 -3
- package/es6/components/Tabs/Tabs.js +2 -1
- package/es6/components/Text/Text.js +10 -2
- package/es6/components/Text/TextContext.js +2 -0
- package/es6/components/TextInput/StyledTextInput.js +4 -2
- package/es6/components/TextInput/TextInput.js +4 -2
- package/es6/components/TextInput/index.d.ts +3 -1
- package/es6/components/TextInput/propTypes.js +3 -1
- package/es6/components/Toolbar/stories/Simple.js +1 -1
- package/es6/components/Video/Video.js +4 -8
- package/es6/components/WorldMap/WorldMap.js +18 -17
- package/es6/components/index.d.ts +2 -0
- package/es6/components/index.js +3 -1
- package/es6/languages/default.json +14 -4
- package/es6/themes/base.d.ts +31 -0
- package/es6/themes/base.js +31 -1
- package/es6/utils/DOM.js +17 -0
- package/es6/utils/PortalContext.js +1 -1
- package/es6/utils/background.js +9 -1
- package/es6/utils/colors.js +2 -2
- package/es6/utils/general-prop-types.js +1 -1
- package/es6/utils/index.d.ts +7 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +14 -4
- package/package.json +42 -40
- package/themes/base.d.ts +31 -0
- package/themes/base.js +31 -1
- package/utils/DOM.js +20 -2
- package/utils/PortalContext.js +1 -1
- package/utils/background.js +8 -0
- package/utils/colors.js +3 -1
- package/utils/general-prop-types.js +1 -1
- package/utils/index.d.ts +7 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Data, DataSummary, DataTable, Grid, Notification, Paragraph } from 'grommet';
|
|
3
|
+
import { DataSearch } from '../DataSearch';
|
|
4
|
+
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
|
+
export var Drop = function Drop() {
|
|
6
|
+
return (
|
|
7
|
+
/*#__PURE__*/
|
|
8
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
|
+
// <Grommet theme={...}>
|
|
10
|
+
React.createElement(Grid, {
|
|
11
|
+
pad: "large",
|
|
12
|
+
columns: ['large'],
|
|
13
|
+
justifyContent: "center"
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
15
|
+
status: "info",
|
|
16
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Paragraph, {
|
|
18
|
+
color: "text-weak"
|
|
19
|
+
}, "Note: Results are filtered as you type, checking all fields."), /*#__PURE__*/React.createElement(Data, {
|
|
20
|
+
data: DATA,
|
|
21
|
+
updateOn: "change"
|
|
22
|
+
}, /*#__PURE__*/React.createElement(DataSearch, {
|
|
23
|
+
drop: true
|
|
24
|
+
}), /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(DataTable, {
|
|
25
|
+
columns: columns
|
|
26
|
+
})))
|
|
27
|
+
// </Grommet>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Drop.args = {
|
|
32
|
+
full: true
|
|
33
|
+
};
|
|
34
|
+
export default {
|
|
35
|
+
title: 'Data/DataSearch/Drop'
|
|
36
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Data, DataSummary, DataTable, Grid, Notification, Paragraph } from 'grommet';
|
|
3
|
+
import { DataSearch } from '../DataSearch';
|
|
4
|
+
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
|
+
export var Responsive = function Responsive() {
|
|
6
|
+
return (
|
|
7
|
+
/*#__PURE__*/
|
|
8
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
|
+
// <Grommet theme={...}>
|
|
10
|
+
React.createElement(Grid, {
|
|
11
|
+
pad: "large",
|
|
12
|
+
columns: [['medium', 'large']],
|
|
13
|
+
justifyContent: "center"
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
15
|
+
status: "info",
|
|
16
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Paragraph, {
|
|
18
|
+
color: "text-weak"
|
|
19
|
+
}, "Note: Results are filtered as you type, checking all fields."), /*#__PURE__*/React.createElement(Data, {
|
|
20
|
+
data: DATA,
|
|
21
|
+
updateOn: "change"
|
|
22
|
+
}, /*#__PURE__*/React.createElement(DataSearch, {
|
|
23
|
+
responsive: true
|
|
24
|
+
}), /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(DataTable, {
|
|
25
|
+
columns: columns
|
|
26
|
+
})))
|
|
27
|
+
// </Grommet>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Responsive.args = {
|
|
32
|
+
full: true
|
|
33
|
+
};
|
|
34
|
+
export default {
|
|
35
|
+
title: 'Data/DataSearch/Responsive'
|
|
36
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Data, DataSummary, DataTable, Grid, Paragraph } from 'grommet';
|
|
2
|
+
import { Data, DataSummary, DataTable, Grid, Notification, Paragraph } from 'grommet';
|
|
3
3
|
import { DataSearch } from '../DataSearch';
|
|
4
4
|
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
5
|
export var Simple = function Simple() {
|
|
@@ -11,7 +11,10 @@ export var Simple = function Simple() {
|
|
|
11
11
|
pad: "large",
|
|
12
12
|
columns: ['large'],
|
|
13
13
|
justifyContent: "center"
|
|
14
|
-
}, /*#__PURE__*/React.createElement(
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
15
|
+
status: "info",
|
|
16
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Paragraph, {
|
|
15
18
|
color: "text-weak"
|
|
16
19
|
}, "Note: Results are filtered as you type, checking all fields."), /*#__PURE__*/React.createElement(Data, {
|
|
17
20
|
data: DATA,
|
|
@@ -27,5 +30,5 @@ Simple.args = {
|
|
|
27
30
|
full: true
|
|
28
31
|
};
|
|
29
32
|
export default {
|
|
30
|
-
title: '
|
|
33
|
+
title: 'Data/DataSearch/Simple'
|
|
31
34
|
};
|
|
@@ -1,47 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["drop", "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, useMemo, useState } from 'react';
|
|
5
|
+
import { Descend } from 'grommet-icons/icons/Descend';
|
|
2
6
|
import { DataContext } from '../../contexts/DataContext';
|
|
3
|
-
import {
|
|
4
|
-
import { DataForm } from '../Data';
|
|
7
|
+
import { Box } from '../Box';
|
|
8
|
+
import { DataForm } from '../Data/DataForm';
|
|
9
|
+
import { DropButton } from '../DropButton';
|
|
5
10
|
import { FormContext } from '../Form/FormContext';
|
|
6
11
|
import { FormField } from '../FormField';
|
|
12
|
+
import { RadioButtonGroup } from '../RadioButtonGroup';
|
|
7
13
|
import { Select } from '../Select';
|
|
8
14
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
9
15
|
import { DataSortPropTypes } from './propTypes';
|
|
10
|
-
|
|
16
|
+
var dropProps = {
|
|
17
|
+
align: {
|
|
18
|
+
top: 'bottom',
|
|
19
|
+
left: 'left'
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var Content = function Content(_ref) {
|
|
11
23
|
var optionsArg = _ref.options;
|
|
12
24
|
var _useContext = useContext(DataContext),
|
|
25
|
+
data = _useContext.data,
|
|
13
26
|
dataId = _useContext.id,
|
|
14
27
|
messages = _useContext.messages,
|
|
15
|
-
properties = _useContext.properties
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
noForm = _useContext2.noForm;
|
|
19
|
-
var _useContext3 = useContext(MessageContext),
|
|
20
|
-
format = _useContext3.format;
|
|
28
|
+
properties = _useContext.properties;
|
|
29
|
+
var _useContext2 = useContext(MessageContext),
|
|
30
|
+
format = _useContext2.format;
|
|
21
31
|
var options = useMemo(function () {
|
|
22
|
-
return optionsArg || properties && Object.keys(properties).sort() || Object.keys(
|
|
23
|
-
}, [optionsArg, properties
|
|
32
|
+
return optionsArg || properties && Object.keys(properties).sort() || Object.keys(data[0]).sort();
|
|
33
|
+
}, [data, optionsArg, properties]);
|
|
24
34
|
var directionOptions = [{
|
|
25
35
|
label: format({
|
|
26
36
|
id: 'dataSort.ascending',
|
|
27
|
-
messages: messages == null ? void 0 : messages.
|
|
37
|
+
messages: messages == null ? void 0 : messages.dataSort
|
|
28
38
|
}),
|
|
29
39
|
value: 'asc'
|
|
30
40
|
}, {
|
|
31
41
|
label: format({
|
|
32
42
|
id: 'dataSort.descending',
|
|
33
|
-
messages: messages == null ? void 0 : messages.
|
|
43
|
+
messages: messages == null ? void 0 : messages.dataSort
|
|
34
44
|
}),
|
|
35
45
|
value: 'desc'
|
|
36
46
|
}];
|
|
37
47
|
var sortPropertyId = dataId + "--sort-property";
|
|
38
48
|
var sortDirectionId = dataId + "--sort-direction";
|
|
39
|
-
|
|
49
|
+
return [/*#__PURE__*/React.createElement(FormField, {
|
|
40
50
|
key: "by",
|
|
41
51
|
htmlFor: sortPropertyId,
|
|
42
52
|
label: format({
|
|
43
53
|
id: 'dataSort.by',
|
|
44
|
-
messages: messages == null ? void 0 : messages.
|
|
54
|
+
messages: messages == null ? void 0 : messages.dataSort
|
|
45
55
|
})
|
|
46
56
|
}, /*#__PURE__*/React.createElement(Select, {
|
|
47
57
|
id: sortPropertyId,
|
|
@@ -52,16 +62,55 @@ export var DataSort = function DataSort(_ref) {
|
|
|
52
62
|
htmlFor: sortDirectionId,
|
|
53
63
|
label: format({
|
|
54
64
|
id: 'dataSort.direction',
|
|
55
|
-
messages: messages == null ? void 0 : messages.
|
|
65
|
+
messages: messages == null ? void 0 : messages.dataSort
|
|
56
66
|
})
|
|
57
67
|
}, /*#__PURE__*/React.createElement(RadioButtonGroup, {
|
|
58
68
|
id: sortDirectionId,
|
|
59
69
|
name: "_sort.direction",
|
|
60
70
|
options: directionOptions
|
|
61
71
|
}))];
|
|
72
|
+
};
|
|
73
|
+
export var DataSort = function DataSort(_ref2) {
|
|
74
|
+
var drop = _ref2.drop,
|
|
75
|
+
options = _ref2.options,
|
|
76
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
77
|
+
var _useContext3 = useContext(DataContext),
|
|
78
|
+
dataId = _useContext3.id,
|
|
79
|
+
messages = _useContext3.messages;
|
|
80
|
+
var _useContext4 = useContext(FormContext),
|
|
81
|
+
noForm = _useContext4.noForm;
|
|
82
|
+
var _useContext5 = useContext(MessageContext),
|
|
83
|
+
format = _useContext5.format;
|
|
84
|
+
var _useState = useState(),
|
|
85
|
+
showContent = _useState[0],
|
|
86
|
+
setShowContent = _useState[1];
|
|
87
|
+
var content = /*#__PURE__*/React.createElement(Content, {
|
|
88
|
+
options: options
|
|
89
|
+
});
|
|
62
90
|
if (noForm) content = /*#__PURE__*/React.createElement(DataForm, {
|
|
63
91
|
footer: false
|
|
64
92
|
}, content);
|
|
65
|
-
return content;
|
|
93
|
+
if (!drop) return content;
|
|
94
|
+
var control = /*#__PURE__*/React.createElement(DropButton, _extends({
|
|
95
|
+
id: dataId + "--sort-control",
|
|
96
|
+
"aria-label": format({
|
|
97
|
+
id: 'dataSort.open',
|
|
98
|
+
messages: messages == null ? void 0 : messages.dataSort
|
|
99
|
+
}),
|
|
100
|
+
kind: "toolbar",
|
|
101
|
+
icon: /*#__PURE__*/React.createElement(Descend, null),
|
|
102
|
+
dropProps: dropProps,
|
|
103
|
+
dropContent: /*#__PURE__*/React.createElement(Box, {
|
|
104
|
+
pad: "small"
|
|
105
|
+
}, content),
|
|
106
|
+
open: showContent,
|
|
107
|
+
onOpen: function onOpen() {
|
|
108
|
+
return setShowContent(undefined);
|
|
109
|
+
},
|
|
110
|
+
onClose: function onClose() {
|
|
111
|
+
return setShowContent(undefined);
|
|
112
|
+
}
|
|
113
|
+
}, rest));
|
|
114
|
+
return control;
|
|
66
115
|
};
|
|
67
116
|
DataSort.propTypes = DataSortPropTypes;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { BoxProps } from '../Box/index';
|
|
3
2
|
|
|
4
|
-
export interface DataSortProps {
|
|
3
|
+
export interface DataSortProps {
|
|
4
|
+
drop?: boolean;
|
|
5
|
+
}
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export interface DataSortExtendedProps
|
|
9
|
-
extends BoxProps,
|
|
10
|
-
DataSortProps,
|
|
11
|
-
divProps {}
|
|
7
|
+
export interface DataSortExtendedProps extends DataSortProps {}
|
|
12
8
|
|
|
13
9
|
declare const DataSort: React.FC<DataSortExtendedProps>;
|
|
14
10
|
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
var PropType = {};
|
|
3
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4
|
+
PropType = {
|
|
5
|
+
drop: PropTypes.bool
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export var DataSortPropTypes = PropType;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, Data, DataTable, Notification, Toolbar } from 'grommet';
|
|
3
|
+
import { DataSort } from '../DataSort';
|
|
4
|
+
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
|
+
export var Drop = function Drop() {
|
|
6
|
+
return (
|
|
7
|
+
/*#__PURE__*/
|
|
8
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
|
+
// <Grommet theme={...}>
|
|
10
|
+
React.createElement(Box, {
|
|
11
|
+
align: "center",
|
|
12
|
+
justify: "start",
|
|
13
|
+
pad: "large",
|
|
14
|
+
gap: "medium"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
16
|
+
status: "info",
|
|
17
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
18
|
+
}), /*#__PURE__*/React.createElement(Data, {
|
|
19
|
+
data: DATA,
|
|
20
|
+
updateOn: "change"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(DataSort, {
|
|
22
|
+
drop: true
|
|
23
|
+
})), /*#__PURE__*/React.createElement(DataTable, {
|
|
24
|
+
columns: columns
|
|
25
|
+
})))
|
|
26
|
+
// </Grommet>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Drop.args = {
|
|
31
|
+
full: true
|
|
32
|
+
};
|
|
33
|
+
export default {
|
|
34
|
+
title: 'Data/DataSort/Drop'
|
|
35
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Data, DataTable,
|
|
2
|
+
import { Box, Data, DataTable, Notification } from 'grommet';
|
|
3
3
|
import { DataSort } from '../DataSort';
|
|
4
4
|
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
5
|
export var Simple = function Simple() {
|
|
@@ -7,11 +7,15 @@ export var Simple = function Simple() {
|
|
|
7
7
|
/*#__PURE__*/
|
|
8
8
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
9
|
// <Grommet theme={...}>
|
|
10
|
-
React.createElement(
|
|
10
|
+
React.createElement(Box, {
|
|
11
|
+
align: "center",
|
|
12
|
+
justify: "start",
|
|
11
13
|
pad: "large",
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
gap: "medium"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
16
|
+
status: "info",
|
|
17
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
18
|
+
}), /*#__PURE__*/React.createElement(Data, {
|
|
15
19
|
data: DATA,
|
|
16
20
|
updateOn: "change"
|
|
17
21
|
}, /*#__PURE__*/React.createElement(DataSort, null), /*#__PURE__*/React.createElement(DataTable, {
|
|
@@ -25,5 +29,5 @@ Simple.args = {
|
|
|
25
29
|
full: true
|
|
26
30
|
};
|
|
27
31
|
export default {
|
|
28
|
-
title: '
|
|
32
|
+
title: 'Data/DataSort/Simple'
|
|
29
33
|
};
|
|
@@ -12,12 +12,12 @@ export var DataSummary = function DataSummary(_ref) {
|
|
|
12
12
|
var _useContext = useContext(MessageContext),
|
|
13
13
|
format = _useContext.format;
|
|
14
14
|
var _useContext2 = useContext(DataContext),
|
|
15
|
-
|
|
15
|
+
filteredTotal = _useContext2.filteredTotal,
|
|
16
16
|
dataMessages = _useContext2.messages,
|
|
17
17
|
total = _useContext2.total;
|
|
18
18
|
var messageId;
|
|
19
|
-
if (total !==
|
|
20
|
-
if (
|
|
19
|
+
if (total !== filteredTotal) {
|
|
20
|
+
if (filteredTotal === 1) messageId = 'dataSummary.filteredSingle';else messageId = 'dataSummary.filtered';
|
|
21
21
|
} else messageId = 'dataSummary.total';
|
|
22
22
|
return /*#__PURE__*/React.createElement(Text, _extends({
|
|
23
23
|
margin: {
|
|
@@ -27,7 +27,7 @@ export var DataSummary = function DataSummary(_ref) {
|
|
|
27
27
|
id: messageId,
|
|
28
28
|
messages: messages || (dataMessages == null ? void 0 : dataMessages.dataSummary),
|
|
29
29
|
values: {
|
|
30
|
-
|
|
30
|
+
filteredTotal: filteredTotal,
|
|
31
31
|
total: total
|
|
32
32
|
}
|
|
33
33
|
}));
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { TextProps } from '../Text/index';
|
|
3
3
|
|
|
4
4
|
export interface DataSummaryProps {
|
|
5
|
-
messages?: {
|
|
5
|
+
messages?: { filteredTotal?: string; total?: string };
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface DataSummaryExtendedProps extends TextProps, DataSummaryProps {}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Box, Data, DataTable } from 'grommet';
|
|
2
|
+
import { Box, Data, DataTable, Notification } from 'grommet';
|
|
3
3
|
import { DataSummary } from '../DataSummary';
|
|
4
4
|
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
5
|
export var Simple = function Simple() {
|
|
@@ -8,11 +8,14 @@ export var Simple = function Simple() {
|
|
|
8
8
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
9
|
// <Grommet theme={...}>
|
|
10
10
|
React.createElement(Box, {
|
|
11
|
-
fill: true,
|
|
12
11
|
align: "center",
|
|
13
12
|
justify: "start",
|
|
14
|
-
pad: "large"
|
|
15
|
-
|
|
13
|
+
pad: "large",
|
|
14
|
+
gap: "medium"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
16
|
+
status: "info",
|
|
17
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
18
|
+
}), /*#__PURE__*/React.createElement(Data, {
|
|
16
19
|
data: DATA
|
|
17
20
|
}, /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(DataTable, {
|
|
18
21
|
columns: columns
|
|
@@ -25,5 +28,5 @@ Simple.args = {
|
|
|
25
28
|
full: true
|
|
26
29
|
};
|
|
27
30
|
export default {
|
|
28
|
-
title: '
|
|
31
|
+
title: 'Data/DataSummary/Simple'
|
|
29
32
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _excluded = ["background", "border", "column", "datum", "pad", "pin", "pinnedOffset", "primaryProperty", "scope", "verticalAlign"];
|
|
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, { memo, useContext } from 'react';
|
|
4
|
+
import React, { isValidElement, memo, useContext } from 'react';
|
|
5
5
|
import { ThemeContext } from 'styled-components';
|
|
6
6
|
import { defaultProps } from '../../default-props';
|
|
7
7
|
import { Text } from '../Text';
|
|
@@ -36,7 +36,7 @@ var Cell = /*#__PURE__*/memo(function (_ref) {
|
|
|
36
36
|
if (render && renderContexts) {
|
|
37
37
|
content = render(datum);
|
|
38
38
|
} else if (value !== undefined) {
|
|
39
|
-
content = value;
|
|
39
|
+
if (typeof value === 'string' || typeof value === 'number' || /*#__PURE__*/isValidElement(value)) content = value;
|
|
40
40
|
}
|
|
41
41
|
if (typeof content === 'string' || typeof content === 'number') {
|
|
42
42
|
var textProps = property === primaryProperty ? theme.dataTable.primary : {};
|
|
@@ -78,23 +78,29 @@ var DataTable = function DataTable(_ref) {
|
|
|
78
78
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
79
79
|
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
80
80
|
var _useContext = useContext(DataContext),
|
|
81
|
+
view = _useContext.view,
|
|
81
82
|
contextData = _useContext.data,
|
|
82
|
-
properties = _useContext.properties
|
|
83
|
+
properties = _useContext.properties,
|
|
84
|
+
onView = _useContext.onView;
|
|
83
85
|
var data = dataProp || contextData || emptyData;
|
|
84
86
|
var columns = useMemo(function () {
|
|
85
|
-
|
|
86
|
-
if (properties)
|
|
87
|
+
var result = [];
|
|
88
|
+
if (columnsProp) result = columnsProp;else if (properties) result = Object.keys(properties).map(function (p) {
|
|
87
89
|
return _extends({
|
|
88
90
|
property: p
|
|
89
91
|
}, properties[p]);
|
|
90
|
-
});
|
|
91
|
-
if (data.length) return Object.keys(data[0]).map(function (p) {
|
|
92
|
+
});else if (data.length) result = Object.keys(data[0]).map(function (p) {
|
|
92
93
|
return {
|
|
93
94
|
property: p
|
|
94
95
|
};
|
|
95
96
|
});
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
if (view != null && view.columns) result = result.filter(function (c) {
|
|
98
|
+
return view.columns.includes(c.property);
|
|
99
|
+
}).sort(function (c1, c2) {
|
|
100
|
+
return view.columns.indexOf(c1.property) - view.columns.indexOf(c2.property);
|
|
101
|
+
});
|
|
102
|
+
return result;
|
|
103
|
+
}, [columnsProp, data, properties, view]);
|
|
98
104
|
|
|
99
105
|
// property name of the primary property
|
|
100
106
|
var primaryProperty = useMemo(function () {
|
|
@@ -123,8 +129,8 @@ var DataTable = function DataTable(_ref) {
|
|
|
123
129
|
sort = _useState5[0],
|
|
124
130
|
setSort = _useState5[1];
|
|
125
131
|
useEffect(function () {
|
|
126
|
-
if (sortProp) setSort(sortProp);
|
|
127
|
-
}, [sortProp]);
|
|
132
|
+
if (sortProp) setSort(sortProp);else if (view != null && view.sort) setSort(view.sort);
|
|
133
|
+
}, [sortProp, view]);
|
|
128
134
|
|
|
129
135
|
// the data filtered and sorted, if needed
|
|
130
136
|
// Note: onUpdate mode expects the data to be passed
|
|
@@ -267,6 +273,14 @@ var DataTable = function DataTable(_ref) {
|
|
|
267
273
|
external: external
|
|
268
274
|
};
|
|
269
275
|
setSort(nextSort);
|
|
276
|
+
if (onView) {
|
|
277
|
+
onView(_extends({}, view, {
|
|
278
|
+
sort: {
|
|
279
|
+
property: property,
|
|
280
|
+
direction: direction
|
|
281
|
+
}
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
270
284
|
if (onUpdate) {
|
|
271
285
|
var opts = {
|
|
272
286
|
count: limit,
|
|
@@ -28,9 +28,7 @@ var Resizer = function Resizer(_ref) {
|
|
|
28
28
|
if (ref.current) {
|
|
29
29
|
var element = ref.current;
|
|
30
30
|
// find TH parent
|
|
31
|
-
while (element && element.nodeName !== 'TH')
|
|
32
|
-
element = element.parentNode;
|
|
33
|
-
}
|
|
31
|
+
while (element && element.nodeName !== 'TH') element = element.parentNode;
|
|
34
32
|
var rect = element.getBoundingClientRect();
|
|
35
33
|
setStart(event.clientX);
|
|
36
34
|
setWidth(rect.width);
|
|
@@ -13,7 +13,7 @@ import { TableFooter } from '../TableFooter';
|
|
|
13
13
|
var StyledDataTable = styled(Table).withConfig({
|
|
14
14
|
displayName: "StyledDataTable",
|
|
15
15
|
componentId: "sc-xrlyjm-0"
|
|
16
|
-
})(["position:relative;border-spacing:0;border-collapse:separate;
|
|
16
|
+
})(["position:relative;border-spacing:0;border-collapse:separate;", " ", " ", ";"], genericStyles, function (props) {
|
|
17
17
|
return props.fillProp && fillStyle(props.fillProp);
|
|
18
18
|
}, function (props) {
|
|
19
19
|
return props.theme.dataTable && props.theme.dataTable.body && props.theme.dataTable.body.extend;
|
|
@@ -53,7 +53,7 @@ var StyledDataTableBody = styled(TableBody).withConfig({
|
|
|
53
53
|
displayName: "StyledDataTable__StyledDataTableBody",
|
|
54
54
|
componentId: "sc-xrlyjm-3"
|
|
55
55
|
})(["", " &:focus{", "}&:focus:not(:focus-visible){", "}"], function (props) {
|
|
56
|
-
return props.size && "\n display: block;\n width: 100%;\n max-height: " + props.theme.global.size[props.size] + ";\n overflow: auto;\n ";
|
|
56
|
+
return props.size && "\n display: block;\n width: 100%;\n max-height: " + (props.theme.global.size[props.size] || props.size) + ";\n overflow: auto;\n ";
|
|
57
57
|
}, focusStyle({
|
|
58
58
|
skipSvgChildren: true,
|
|
59
59
|
forceOutline: true
|
|
@@ -8,9 +8,15 @@ import {
|
|
|
8
8
|
PadType,
|
|
9
9
|
BorderType,
|
|
10
10
|
} from '../../utils';
|
|
11
|
+
import { BoxProps } from '../Box';
|
|
11
12
|
import { PaginationType } from '../Pagination';
|
|
12
13
|
|
|
13
|
-
type Sections<
|
|
14
|
+
export type Sections<
|
|
15
|
+
TBody,
|
|
16
|
+
THeader = TBody,
|
|
17
|
+
TFooter = TBody,
|
|
18
|
+
TPinned = TBody,
|
|
19
|
+
> = {
|
|
14
20
|
header?: THeader;
|
|
15
21
|
body?: TBody;
|
|
16
22
|
footer?: TFooter;
|
|
@@ -56,6 +62,15 @@ export interface ColumnConfig<TRowType> {
|
|
|
56
62
|
verticalAlign?: VerticalAlignType;
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
interface SortDefinition {
|
|
66
|
+
property: string;
|
|
67
|
+
direction: 'asc' | 'desc';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface SortType extends SortDefinition {
|
|
71
|
+
external?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
59
74
|
export interface DataTableProps<TRowType = any> {
|
|
60
75
|
a11yTitle?: A11yTitleType;
|
|
61
76
|
|
|
@@ -63,6 +78,7 @@ export interface DataTableProps<TRowType = any> {
|
|
|
63
78
|
alignSelf?: AlignSelfType;
|
|
64
79
|
background?:
|
|
65
80
|
| BackgroundType
|
|
81
|
+
| BackgroundType[]
|
|
66
82
|
| Sections<BackgroundType | string[], BackgroundType, BackgroundType>;
|
|
67
83
|
border?: BorderType | Sections<BorderType>;
|
|
68
84
|
columns?: ColumnConfig<TRowType>[];
|
|
@@ -70,7 +86,7 @@ export interface DataTableProps<TRowType = any> {
|
|
|
70
86
|
gridArea?: GridAreaType;
|
|
71
87
|
margin?: MarginType;
|
|
72
88
|
pad?: PadType | Sections<PadType>;
|
|
73
|
-
paginate?: boolean | PaginationType;
|
|
89
|
+
paginate?: boolean | PaginationType | BoxProps;
|
|
74
90
|
pin?: boolean | 'header' | 'footer';
|
|
75
91
|
placeholder?: string | React.ReactNode;
|
|
76
92
|
resizeable?: boolean;
|
|
@@ -83,6 +99,7 @@ export interface DataTableProps<TRowType = any> {
|
|
|
83
99
|
};
|
|
84
100
|
};
|
|
85
101
|
rowDetails?: (row: TRowType) => React.ReactNode;
|
|
102
|
+
show?: number | { page?: number };
|
|
86
103
|
size?: 'small' | 'medium' | 'large' | 'xlarge' | string;
|
|
87
104
|
|
|
88
105
|
// Data
|
|
@@ -100,7 +117,7 @@ export interface DataTableProps<TRowType = any> {
|
|
|
100
117
|
};
|
|
101
118
|
primaryKey?: string | boolean;
|
|
102
119
|
select?: (string | number)[];
|
|
103
|
-
sort?:
|
|
120
|
+
sort?: SortType;
|
|
104
121
|
sortable?: boolean;
|
|
105
122
|
step?: number;
|
|
106
123
|
|
|
@@ -109,11 +126,11 @@ export interface DataTableProps<TRowType = any> {
|
|
|
109
126
|
| 'select'
|
|
110
127
|
| ((event: MouseClick<TRowType> | KeyPress<TRowType>) => void);
|
|
111
128
|
onMore?: () => void;
|
|
112
|
-
onSearch?: (search:
|
|
129
|
+
onSearch?: (search: object) => void;
|
|
113
130
|
onSelect?: (select: (string | number)[], datum: TRowType) => void;
|
|
114
|
-
onSort?: (sort:
|
|
131
|
+
onSort?: (sort: SortDefinition) => void;
|
|
115
132
|
onUpdate?: (datatableState: {
|
|
116
|
-
sort?:
|
|
133
|
+
sort?: SortDefinition;
|
|
117
134
|
expanded?: Array<string>;
|
|
118
135
|
show: number;
|
|
119
136
|
count: number;
|