grommet 2.46.1 → 2.47.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/Accordion/index.d.ts +7 -1
- package/components/AccordionPanel/index.d.ts +4 -1
- package/components/Anchor/index.d.ts +7 -1
- package/components/Avatar/Avatar.js +4 -3
- package/components/Avatar/index.d.ts +9 -1
- package/components/Avatar/propTypes.js +2 -1
- package/components/Box/StyledBox.js +9 -1
- package/components/Box/index.d.ts +9 -2
- package/components/Button/index.d.ts +14 -2
- package/components/Calendar/Calendar.js +43 -32
- package/components/Calendar/StyledCalendar.js +86 -32
- package/components/Calendar/index.d.ts +15 -2
- package/components/Calendar/propTypes.js +1 -0
- package/components/Cards/index.d.ts +7 -1
- package/components/Carousel/index.d.ts +4 -1
- package/components/Chart/index.d.ts +7 -1
- package/components/CheckBox/index.d.ts +7 -1
- package/components/CheckBoxGroup/index.d.ts +15 -2
- package/components/Clock/index.d.ts +14 -2
- package/components/Collapsible/index.d.ts +4 -1
- package/components/Data/index.d.ts +4 -1
- package/components/DataFilter/index.d.ts +4 -1
- package/components/DataFilters/index.d.ts +4 -1
- package/components/DataTable/Body.js +13 -7
- package/components/DataTable/DataTable.js +6 -1
- package/components/DataTable/index.d.ts +11 -2
- package/components/DataTable/propTypes.js +5 -1
- package/components/DataTable/stories/rowDetails.stories.js +174 -66
- package/components/DataTable/stories/typescript/OnSelect.stories.tsx +3 -3
- package/components/DataTableGroupBy/index.d.ts +4 -1
- package/components/DataView/index.d.ts +4 -1
- package/components/DateInput/index.d.ts +4 -1
- package/components/Diagram/index.d.ts +4 -1
- package/components/Distribution/index.d.ts +4 -1
- package/components/Drop/StyledDrop.js +3 -1
- package/components/Drop/index.d.ts +6 -2
- package/components/DropButton/index.d.ts +8 -1
- package/components/FileInput/index.d.ts +8 -2
- package/components/Form/index.d.ts +7 -1
- package/components/FormField/index.d.ts +4 -1
- package/components/Grid/index.d.ts +4 -1
- package/components/Grommet/index.d.ts +18 -1
- package/components/Grommet/propTypes.js +11 -0
- package/components/Header/stories/typescript/Ref.stories.tsx +1 -1
- package/components/Heading/index.d.ts +7 -7
- package/components/Image/index.d.ts +4 -1
- package/components/InfiniteScroll/index.d.ts +2 -2
- package/components/Layer/index.d.ts +4 -1
- package/components/List/index.d.ts +9 -3
- package/components/Markdown/index.d.ts +5 -1
- package/components/MaskedInput/MaskedInput.js +49 -4
- package/components/MaskedInput/index.d.ts +7 -1
- package/components/MaskedInput/stories/CustomBox.stories.js +1 -0
- package/components/MaskedInput/stories/Date.stories.js +1 -0
- package/components/MaskedInput/stories/DateRange.stories.js +1 -0
- package/components/MaskedInput/stories/DateTimeDrop.stories.js +1 -0
- package/components/MaskedInput/stories/Filtered.stories.js +1 -0
- package/components/MaskedInput/stories/SizeUnits.stories.js +1 -0
- package/components/MaskedInput/stories/Time.stories.js +1 -0
- package/components/NameValueList/index.d.ts +8 -1
- package/components/Notification/index.d.ts +1 -0
- package/components/PageHeader/index.d.ts +5 -1
- package/components/Pagination/PaginationStep.js +4 -0
- package/components/Pagination/index.d.ts +5 -0
- package/components/Pagination/propTypes.js +6 -1
- package/components/Paragraph/index.d.ts +7 -1
- package/components/RadioButton/index.d.ts +7 -1
- package/components/RadioButtonGroup/index.d.ts +7 -1
- package/components/RangeInput/index.d.ts +7 -1
- package/components/RangeSelector/index.d.ts +15 -2
- package/components/RoutedAnchor/index.d.ts +3 -2
- package/components/RoutedButton/index.d.ts +3 -2
- package/components/Select/Select.js +2 -4
- package/components/Select/index.d.ts +7 -1
- package/components/Select/utils.js +12 -3
- package/components/SelectMultiple/SelectMultiple.js +5 -10
- package/components/SelectMultiple/SelectMultipleContainer.js +2 -4
- package/components/SelectMultiple/SelectMultipleValue.js +1 -2
- package/components/SelectMultiple/index.d.ts +7 -1
- package/components/Sidebar/index.d.ts +4 -1
- package/components/Stack/index.d.ts +4 -1
- package/components/Tab/index.d.ts +7 -1
- package/components/Table/index.d.ts +4 -1
- package/components/TableBody/index.d.ts +4 -1
- package/components/TableCell/index.d.ts +10 -3
- package/components/TableFooter/index.d.ts +4 -1
- package/components/TableHeader/index.d.ts +4 -1
- package/components/TableRow/index.d.ts +4 -1
- package/components/Tabs/index.d.ts +4 -1
- package/components/Tag/Tag.js +15 -1
- package/components/Tag/index.d.ts +6 -0
- package/components/Tag/propTypes.js +6 -0
- package/components/Text/Text.js +3 -2
- package/components/Text/index.d.ts +7 -1
- package/components/TextArea/index.d.ts +7 -1
- package/components/TextInput/TextInput.js +6 -2
- package/components/TextInput/index.d.ts +6 -3
- package/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +2 -1
- package/components/TextInput/stories/CustomThemed/Themed.stories.js +1 -0
- package/components/TextInput/stories/OnSelect.stories.js +1 -0
- package/components/TextInput/stories/WithTags.stories.js +1 -0
- package/components/Tip/Tip.js +16 -1
- package/components/ToggleGroup/index.d.ts +7 -1
- package/components/Toolbar/index.d.ts +5 -2
- package/components/Video/index.d.ts +7 -1
- package/components/WorldMap/index.d.ts +7 -1
- package/es6/components/Accordion/index.d.ts +7 -1
- package/es6/components/AccordionPanel/index.d.ts +4 -1
- package/es6/components/Anchor/index.d.ts +7 -1
- package/es6/components/Avatar/Avatar.js +4 -3
- package/es6/components/Avatar/index.d.ts +9 -1
- package/es6/components/Avatar/propTypes.js +2 -1
- package/es6/components/Box/StyledBox.js +8 -1
- package/es6/components/Box/index.d.ts +9 -2
- package/es6/components/Button/index.d.ts +14 -2
- package/es6/components/Calendar/Calendar.js +44 -32
- package/es6/components/Calendar/StyledCalendar.js +86 -32
- package/es6/components/Calendar/index.d.ts +15 -2
- package/es6/components/Calendar/propTypes.js +1 -0
- package/es6/components/Cards/index.d.ts +7 -1
- package/es6/components/Carousel/index.d.ts +4 -1
- package/es6/components/Chart/index.d.ts +7 -1
- package/es6/components/CheckBox/index.d.ts +7 -1
- package/es6/components/CheckBoxGroup/index.d.ts +15 -2
- package/es6/components/Clock/index.d.ts +14 -2
- package/es6/components/Collapsible/index.d.ts +4 -1
- package/es6/components/Data/index.d.ts +4 -1
- package/es6/components/DataFilter/index.d.ts +4 -1
- package/es6/components/DataFilters/index.d.ts +4 -1
- package/es6/components/DataTable/Body.js +13 -7
- package/es6/components/DataTable/DataTable.js +6 -1
- package/es6/components/DataTable/index.d.ts +11 -2
- package/es6/components/DataTable/propTypes.js +5 -1
- package/es6/components/DataTable/stories/rowDetails.stories.js +172 -66
- package/es6/components/DataTable/stories/typescript/OnSelect.stories.tsx +3 -3
- package/es6/components/DataTableGroupBy/index.d.ts +4 -1
- package/es6/components/DataView/index.d.ts +4 -1
- package/es6/components/DateInput/index.d.ts +4 -1
- package/es6/components/Diagram/index.d.ts +4 -1
- package/es6/components/Distribution/index.d.ts +4 -1
- package/es6/components/Drop/StyledDrop.js +3 -1
- package/es6/components/Drop/index.d.ts +6 -2
- package/es6/components/DropButton/index.d.ts +8 -1
- package/es6/components/FileInput/index.d.ts +8 -2
- package/es6/components/Form/index.d.ts +7 -1
- package/es6/components/FormField/index.d.ts +4 -1
- package/es6/components/Grid/index.d.ts +4 -1
- package/es6/components/Grommet/index.d.ts +18 -1
- package/es6/components/Grommet/propTypes.js +11 -0
- package/es6/components/Header/stories/typescript/Ref.stories.tsx +1 -1
- package/es6/components/Heading/index.d.ts +7 -7
- package/es6/components/Image/index.d.ts +4 -1
- package/es6/components/InfiniteScroll/index.d.ts +2 -2
- package/es6/components/Layer/index.d.ts +4 -1
- package/es6/components/List/index.d.ts +9 -3
- package/es6/components/Markdown/index.d.ts +5 -1
- package/es6/components/MaskedInput/MaskedInput.js +49 -4
- package/es6/components/MaskedInput/index.d.ts +7 -1
- package/es6/components/MaskedInput/stories/CustomBox.stories.js +1 -0
- package/es6/components/MaskedInput/stories/Date.stories.js +1 -0
- package/es6/components/MaskedInput/stories/DateRange.stories.js +1 -0
- package/es6/components/MaskedInput/stories/DateTimeDrop.stories.js +1 -0
- package/es6/components/MaskedInput/stories/Filtered.stories.js +1 -0
- package/es6/components/MaskedInput/stories/SizeUnits.stories.js +1 -0
- package/es6/components/MaskedInput/stories/Time.stories.js +1 -0
- package/es6/components/NameValueList/index.d.ts +8 -1
- package/es6/components/Notification/index.d.ts +1 -0
- package/es6/components/PageHeader/index.d.ts +5 -1
- package/es6/components/Pagination/PaginationStep.js +4 -0
- package/es6/components/Pagination/index.d.ts +5 -0
- package/es6/components/Pagination/propTypes.js +6 -1
- package/es6/components/Paragraph/index.d.ts +7 -1
- package/es6/components/RadioButton/index.d.ts +7 -1
- package/es6/components/RadioButtonGroup/index.d.ts +7 -1
- package/es6/components/RangeInput/index.d.ts +7 -1
- package/es6/components/RangeSelector/index.d.ts +15 -2
- package/es6/components/RoutedAnchor/index.d.ts +3 -2
- package/es6/components/RoutedButton/index.d.ts +3 -2
- package/es6/components/Select/Select.js +3 -5
- package/es6/components/Select/index.d.ts +7 -1
- package/es6/components/Select/utils.js +9 -2
- package/es6/components/SelectMultiple/SelectMultiple.js +6 -11
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +3 -5
- package/es6/components/SelectMultiple/SelectMultipleValue.js +2 -3
- package/es6/components/SelectMultiple/index.d.ts +7 -1
- package/es6/components/Sidebar/index.d.ts +4 -1
- package/es6/components/Stack/index.d.ts +4 -1
- package/es6/components/Tab/index.d.ts +7 -1
- package/es6/components/Table/index.d.ts +4 -1
- package/es6/components/TableBody/index.d.ts +4 -1
- package/es6/components/TableCell/index.d.ts +10 -3
- package/es6/components/TableFooter/index.d.ts +4 -1
- package/es6/components/TableHeader/index.d.ts +4 -1
- package/es6/components/TableRow/index.d.ts +4 -1
- package/es6/components/Tabs/index.d.ts +4 -1
- package/es6/components/Tag/Tag.js +16 -2
- package/es6/components/Tag/index.d.ts +6 -0
- package/es6/components/Tag/propTypes.js +6 -0
- package/es6/components/Text/Text.js +3 -2
- package/es6/components/Text/index.d.ts +7 -1
- package/es6/components/TextArea/index.d.ts +7 -1
- package/es6/components/TextInput/TextInput.js +6 -2
- package/es6/components/TextInput/index.d.ts +6 -3
- package/es6/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +2 -1
- package/es6/components/TextInput/stories/CustomThemed/Themed.stories.js +1 -0
- package/es6/components/TextInput/stories/OnSelect.stories.js +1 -0
- package/es6/components/TextInput/stories/WithTags.stories.js +1 -0
- package/es6/components/Tip/Tip.js +17 -1
- package/es6/components/ToggleGroup/index.d.ts +7 -1
- package/es6/components/Toolbar/index.d.ts +5 -2
- package/es6/components/Video/index.d.ts +7 -1
- package/es6/components/WorldMap/index.d.ts +7 -1
- package/es6/languages/default.json +6 -0
- package/es6/utils/mixins.js +2 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +6 -0
- package/package.json +9 -9
- package/utils/mixins.js +2 -1
- package/components/Drop/stories/TrapFocus.stories.js +0 -86
- package/es6/components/Drop/stories/TrapFocus.stories.js +0 -82
|
@@ -49,17 +49,30 @@ export interface CalendarProps {
|
|
|
49
49
|
onSelect?: (select: string | string[]) => any;
|
|
50
50
|
range?: boolean | 'array';
|
|
51
51
|
reference?: string;
|
|
52
|
+
responsive?: boolean;
|
|
52
53
|
showAdjacentDays?: boolean | 'trim';
|
|
53
54
|
size?: 'small' | 'medium' | 'large' | string;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export interface CalendarExtendedProps
|
|
57
58
|
extends CalendarProps,
|
|
58
|
-
Omit<
|
|
59
|
+
Omit<
|
|
60
|
+
React.DetailedHTMLProps<
|
|
61
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
62
|
+
HTMLDivElement
|
|
63
|
+
>,
|
|
64
|
+
keyof CalendarProps
|
|
65
|
+
> {}
|
|
59
66
|
|
|
60
67
|
// Keep type alias for backwards compatibility.
|
|
61
68
|
export type CalendarType = CalendarProps &
|
|
62
|
-
Omit<
|
|
69
|
+
Omit<
|
|
70
|
+
React.DetailedHTMLProps<
|
|
71
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
72
|
+
HTMLDivElement
|
|
73
|
+
>,
|
|
74
|
+
'onSelect'
|
|
75
|
+
>;
|
|
63
76
|
|
|
64
77
|
declare const Calendar: React.ComponentClass<CalendarExtendedProps>;
|
|
65
78
|
|
|
@@ -30,6 +30,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
30
30
|
onSelect: _propTypes["default"].func,
|
|
31
31
|
range: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].oneOf(['array'])]),
|
|
32
32
|
reference: _propTypes["default"].string,
|
|
33
|
+
responsive: _propTypes["default"].bool,
|
|
33
34
|
showAdjacentDays: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].oneOf(['trim'])]),
|
|
34
35
|
size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['small', 'medium', 'large']), _propTypes["default"].string])
|
|
35
36
|
});
|
|
@@ -25,7 +25,13 @@ export interface CardsProps<CardType = any> {
|
|
|
25
25
|
step?: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
type ulProps = Omit<
|
|
28
|
+
type ulProps = Omit<
|
|
29
|
+
React.DetailedHTMLProps<
|
|
30
|
+
React.HTMLAttributes<HTMLUListElement>,
|
|
31
|
+
HTMLUListElement
|
|
32
|
+
>,
|
|
33
|
+
'children'
|
|
34
|
+
>;
|
|
29
35
|
|
|
30
36
|
export interface CardsExtendedProps<CardType>
|
|
31
37
|
extends CardsProps<CardType>,
|
|
@@ -24,7 +24,10 @@ export interface CarouselProps {
|
|
|
24
24
|
onChild?: (...args: any[]) => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
type divType =
|
|
27
|
+
type divType = React.DetailedHTMLProps<
|
|
28
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
29
|
+
HTMLDivElement
|
|
30
|
+
>;
|
|
28
31
|
|
|
29
32
|
export interface CarouselExtendedProps extends CarouselProps, divType {}
|
|
30
33
|
|
|
@@ -104,7 +104,13 @@ export interface ChartProps {
|
|
|
104
104
|
|
|
105
105
|
export interface ChartExtendedProps
|
|
106
106
|
extends ChartProps,
|
|
107
|
-
Omit<
|
|
107
|
+
Omit<
|
|
108
|
+
React.DetailedHTMLProps<
|
|
109
|
+
React.SVGAttributes<SVGSVGElement>,
|
|
110
|
+
SVGSVGElement
|
|
111
|
+
>,
|
|
112
|
+
keyof ChartProps
|
|
113
|
+
> {}
|
|
108
114
|
|
|
109
115
|
declare const Chart: React.FC<ChartExtendedProps>;
|
|
110
116
|
|
|
@@ -16,7 +16,13 @@ export interface CheckBoxProps {
|
|
|
16
16
|
indeterminate?: boolean;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
type inputType = Omit<
|
|
19
|
+
type inputType = Omit<
|
|
20
|
+
React.DetailedHTMLProps<
|
|
21
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
22
|
+
HTMLInputElement
|
|
23
|
+
>,
|
|
24
|
+
'children'
|
|
25
|
+
>;
|
|
20
26
|
|
|
21
27
|
export interface CheckBoxExtendedProps extends CheckBoxProps, inputType {}
|
|
22
28
|
|
|
@@ -9,7 +9,14 @@ interface OnChangeEvent {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface CheckBoxType
|
|
12
|
-
extends Omit<
|
|
12
|
+
extends Omit<
|
|
13
|
+
CheckBoxProps &
|
|
14
|
+
React.DetailedHTMLProps<
|
|
15
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
16
|
+
HTMLInputElement
|
|
17
|
+
>,
|
|
18
|
+
'checked'
|
|
19
|
+
> {
|
|
13
20
|
[key: string]: any;
|
|
14
21
|
}
|
|
15
22
|
|
|
@@ -27,7 +34,13 @@ export interface CheckBoxGroupProps {
|
|
|
27
34
|
export interface CheckBoxGroupExtendedProps
|
|
28
35
|
extends CheckBoxGroupProps,
|
|
29
36
|
BoxProps,
|
|
30
|
-
Omit<
|
|
37
|
+
Omit<
|
|
38
|
+
React.DetailedHTMLProps<
|
|
39
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
40
|
+
HTMLDivElement
|
|
41
|
+
>,
|
|
42
|
+
keyof CheckBoxGroupProps
|
|
43
|
+
> {}
|
|
31
44
|
|
|
32
45
|
declare const CheckBoxGroup: React.FC<CheckBoxGroupExtendedProps>;
|
|
33
46
|
|
|
@@ -35,8 +35,20 @@ export interface ClockProps {
|
|
|
35
35
|
*/
|
|
36
36
|
export type ClockExtendedProps = ClockProps &
|
|
37
37
|
(
|
|
38
|
-
| Omit<
|
|
39
|
-
|
|
38
|
+
| Omit<
|
|
39
|
+
React.DetailedHTMLProps<
|
|
40
|
+
React.SVGAttributes<SVGSVGElement>,
|
|
41
|
+
SVGSVGElement
|
|
42
|
+
>,
|
|
43
|
+
'onChange' | 'type'
|
|
44
|
+
>
|
|
45
|
+
| Omit<
|
|
46
|
+
React.DetailedHTMLProps<
|
|
47
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
48
|
+
HTMLDivElement
|
|
49
|
+
>,
|
|
50
|
+
'onChange'
|
|
51
|
+
>
|
|
40
52
|
);
|
|
41
53
|
|
|
42
54
|
declare const Clock: React.FC<ClockExtendedProps>;
|
|
@@ -5,7 +5,10 @@ export interface CollapsibleProps {
|
|
|
5
5
|
direction?: 'horizontal' | 'vertical';
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
type divProps =
|
|
8
|
+
type divProps = React.DetailedHTMLProps<
|
|
9
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
10
|
+
HTMLDivElement
|
|
11
|
+
>;
|
|
9
12
|
|
|
10
13
|
export interface CollapsibleExtendedProps extends CollapsibleProps, divProps {}
|
|
11
14
|
|
|
@@ -125,7 +125,10 @@ export interface DataProps {
|
|
|
125
125
|
// onDeleteView?: (string) => void;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
type divProps = Omit<
|
|
128
|
+
type divProps = Omit<
|
|
129
|
+
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>,
|
|
130
|
+
'onClick'
|
|
131
|
+
>;
|
|
129
132
|
|
|
130
133
|
export interface DataExtendedProps extends BoxProps, DataProps, divProps {}
|
|
131
134
|
|
|
@@ -18,7 +18,10 @@ export interface DataFilterProps {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
type divProps = Omit<
|
|
21
|
+
type divProps = Omit<
|
|
22
|
+
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>,
|
|
23
|
+
'onClick' | 'property'
|
|
24
|
+
>;
|
|
22
25
|
|
|
23
26
|
export interface DataFilterExtendedProps
|
|
24
27
|
extends BoxProps,
|
|
@@ -10,7 +10,10 @@ export interface DataFiltersProps {
|
|
|
10
10
|
updateOn?: 'change' | 'submit';
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
type divProps = Omit<
|
|
13
|
+
type divProps = Omit<
|
|
14
|
+
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>,
|
|
15
|
+
'onClick'
|
|
16
|
+
>;
|
|
14
17
|
|
|
15
18
|
export interface DataFiltersExtendedProps
|
|
16
19
|
extends BoxProps,
|
|
@@ -41,7 +41,6 @@ var Row = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
41
41
|
columns = _ref.columns,
|
|
42
42
|
pinnedOffset = _ref.pinnedOffset,
|
|
43
43
|
primaryProperty = _ref.primaryProperty,
|
|
44
|
-
data = _ref.data,
|
|
45
44
|
verticalAlign = _ref.verticalAlign;
|
|
46
45
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_StyledDataTable.StyledDataTableRow, {
|
|
47
46
|
ref: rowRef,
|
|
@@ -104,12 +103,19 @@ var Row = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
104
103
|
context: isRowExpanded ? 'groupHeader' : 'body',
|
|
105
104
|
expanded: isRowExpanded,
|
|
106
105
|
onToggle: function onToggle() {
|
|
106
|
+
var nextRowExpand;
|
|
107
|
+
var rowKey = primaryValue || index;
|
|
107
108
|
if (isRowExpanded) {
|
|
108
|
-
|
|
109
|
-
return s !==
|
|
110
|
-
})
|
|
109
|
+
nextRowExpand = rowExpand.filter(function (s) {
|
|
110
|
+
return s !== rowKey;
|
|
111
|
+
});
|
|
112
|
+
} else {
|
|
113
|
+
nextRowExpand = [].concat(rowExpand, [rowKey]);
|
|
114
|
+
}
|
|
115
|
+
if (rowDetails.onExpand) {
|
|
116
|
+
rowDetails.onExpand(nextRowExpand, datum);
|
|
111
117
|
} else {
|
|
112
|
-
setRowExpand(
|
|
118
|
+
setRowExpand(nextRowExpand);
|
|
113
119
|
}
|
|
114
120
|
},
|
|
115
121
|
pad: cellProps.pad,
|
|
@@ -133,7 +139,7 @@ var Row = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
133
139
|
key: index.toString() + "_expand"
|
|
134
140
|
}, (selected || onSelect) && /*#__PURE__*/_react["default"].createElement(_TableCell.TableCell, null), /*#__PURE__*/_react["default"].createElement(_TableCell.TableCell, {
|
|
135
141
|
colSpan: columns.length + 1
|
|
136
|
-
}, rowDetails(
|
|
142
|
+
}, rowDetails.render ? rowDetails.render(datum) : rowDetails(datum))));
|
|
137
143
|
});
|
|
138
144
|
var Body = exports.Body = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
139
145
|
var _ref3;
|
|
@@ -251,7 +257,7 @@ var Body = exports.Body = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, r
|
|
|
251
257
|
var primaryValue = primaryProperty ? (0, _buildState.datumValue)(datum, primaryProperty) : undefined;
|
|
252
258
|
var isSelected = selected && selected.includes(primaryValue);
|
|
253
259
|
var isDisabled = disabled && disabled.includes(primaryValue);
|
|
254
|
-
var isRowExpanded = rowExpand && rowExpand.includes(index);
|
|
260
|
+
var isRowExpanded = rowExpand && rowExpand.includes(primaryValue || index);
|
|
255
261
|
var cellProps = (0, _buildState.normalizeRowCellProps)(rowProps, cellPropsProp, primaryValue, index);
|
|
256
262
|
return /*#__PURE__*/_react["default"].createElement(Row, {
|
|
257
263
|
key: primaryValue != null ? primaryValue : index,
|
|
@@ -190,9 +190,14 @@ var DataTable = exports.DataTable = function DataTable(_ref) {
|
|
|
190
190
|
setSelectedDataContext(select.length);
|
|
191
191
|
}
|
|
192
192
|
}, [select, setSelectedDataContext]);
|
|
193
|
-
var _useState8 = (0, _react.useState)([]),
|
|
193
|
+
var _useState8 = (0, _react.useState)((rowDetails == null ? void 0 : rowDetails.expand) || []),
|
|
194
194
|
rowExpand = _useState8[0],
|
|
195
195
|
setRowExpand = _useState8[1];
|
|
196
|
+
(0, _react.useEffect)(function () {
|
|
197
|
+
if (rowDetails != null && rowDetails.expand) {
|
|
198
|
+
setRowExpand(rowDetails.expand);
|
|
199
|
+
}
|
|
200
|
+
}, [rowDetails == null ? void 0 : rowDetails.expand]);
|
|
196
201
|
|
|
197
202
|
// any customized column widths
|
|
198
203
|
var _useState9 = (0, _react.useState)({}),
|
|
@@ -99,7 +99,13 @@ export interface DataTableProps<TRowType = any> {
|
|
|
99
99
|
pad?: PadType;
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
-
rowDetails?:
|
|
102
|
+
rowDetails?:
|
|
103
|
+
| ((row: TRowType) => React.ReactNode)
|
|
104
|
+
| {
|
|
105
|
+
render: (row: TRowType) => React.ReactNode;
|
|
106
|
+
expand?: (string | number)[];
|
|
107
|
+
onExpand?: (expandedKeys: (string | number)[], datum: TRowType) => void;
|
|
108
|
+
};
|
|
103
109
|
show?: number | { page?: number };
|
|
104
110
|
size?: 'small' | 'medium' | 'large' | 'xlarge' | string;
|
|
105
111
|
|
|
@@ -152,7 +158,10 @@ export interface DataTableProps<TRowType = any> {
|
|
|
152
158
|
export interface DataTableExtendedProps<TRowType = any>
|
|
153
159
|
extends DataTableProps<TRowType>,
|
|
154
160
|
Omit<
|
|
155
|
-
|
|
161
|
+
React.DetailedHTMLProps<
|
|
162
|
+
React.HTMLAttributes<HTMLTableElement>,
|
|
163
|
+
HTMLTableElement
|
|
164
|
+
>,
|
|
156
165
|
'onSelect' | 'placeholder' | 'border'
|
|
157
166
|
> {}
|
|
158
167
|
|
|
@@ -78,7 +78,11 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
78
78
|
onSelect: _propTypes["default"].func
|
|
79
79
|
})]),
|
|
80
80
|
onClickRow: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].oneOf(['select'])]),
|
|
81
|
-
rowDetails: _propTypes["default"].func,
|
|
81
|
+
rowDetails: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].shape({
|
|
82
|
+
render: _propTypes["default"].func.isRequired,
|
|
83
|
+
expand: _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number])),
|
|
84
|
+
onExpand: _propTypes["default"].func
|
|
85
|
+
})]),
|
|
82
86
|
onMore: _propTypes["default"].func,
|
|
83
87
|
onSearch: _propTypes["default"].func,
|
|
84
88
|
onSelect: _propTypes["default"].func,
|
|
@@ -1,83 +1,191 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports["default"] = exports.
|
|
5
|
-
var _react =
|
|
4
|
+
exports["default"] = exports.RowDetails = void 0;
|
|
5
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _grommet = require("grommet");
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
7
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
8
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
11
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
12
|
+
// Uses the StarWars API for starships, see https://swapi.dev
|
|
13
|
+
|
|
14
|
+
var step = 10; // default for https://swapi.dev
|
|
15
|
+
|
|
16
|
+
var fetchData = /*#__PURE__*/function () {
|
|
17
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(view, signal) {
|
|
18
|
+
var params, url;
|
|
19
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
20
|
+
while (1) switch (_context.prev = _context.next) {
|
|
21
|
+
case 0:
|
|
22
|
+
params = {};
|
|
23
|
+
if (view.search) params.search = view.search;
|
|
24
|
+
if (view.page) params.page = view.page;
|
|
25
|
+
url = "https://swapi.dev/api/starships?" + Object.keys(params).map(function (k) {
|
|
26
|
+
return k + "=" + params[k];
|
|
27
|
+
}).join('&');
|
|
28
|
+
return _context.abrupt("return", fetch(url, {
|
|
29
|
+
method: 'GET',
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'application/json'
|
|
32
|
+
},
|
|
33
|
+
signal: signal
|
|
34
|
+
}).then(function (response) {
|
|
35
|
+
return response.json();
|
|
36
|
+
})["catch"](function (err) {
|
|
37
|
+
if (err.name !== 'AbortError') throw err;
|
|
38
|
+
return {};
|
|
39
|
+
}));
|
|
40
|
+
case 5:
|
|
41
|
+
case "end":
|
|
42
|
+
return _context.stop();
|
|
43
|
+
}
|
|
44
|
+
}, _callee);
|
|
45
|
+
}));
|
|
46
|
+
return function fetchData(_x, _x2) {
|
|
47
|
+
return _ref.apply(this, arguments);
|
|
35
48
|
};
|
|
49
|
+
}();
|
|
50
|
+
var ShipProperties = function ShipProperties(_ref2) {
|
|
51
|
+
var ship = _ref2.ship;
|
|
52
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.NameValueList, {
|
|
53
|
+
pairProps: {
|
|
54
|
+
direction: 'column'
|
|
55
|
+
},
|
|
56
|
+
valueProps: {
|
|
57
|
+
width: 'xsmall'
|
|
58
|
+
},
|
|
59
|
+
layout: "grid",
|
|
60
|
+
pad: {
|
|
61
|
+
left: 'large',
|
|
62
|
+
bottom: 'small'
|
|
63
|
+
},
|
|
64
|
+
gap: {
|
|
65
|
+
row: 'xsmall',
|
|
66
|
+
column: 'large'
|
|
67
|
+
}
|
|
68
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.NameValuePair, {
|
|
69
|
+
name: /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
70
|
+
size: "small",
|
|
71
|
+
weight: "bold"
|
|
72
|
+
}, "Name")
|
|
73
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
74
|
+
size: "xsmall"
|
|
75
|
+
}, ship.name)), /*#__PURE__*/_react["default"].createElement(_grommet.NameValuePair, {
|
|
76
|
+
name: /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
77
|
+
size: "small",
|
|
78
|
+
weight: "bold"
|
|
79
|
+
}, "Model")
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
81
|
+
size: "xsmall"
|
|
82
|
+
}, ship.model)), /*#__PURE__*/_react["default"].createElement(_grommet.NameValuePair, {
|
|
83
|
+
name: /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
84
|
+
size: "small",
|
|
85
|
+
weight: "bold"
|
|
86
|
+
}, "Manufacturer")
|
|
87
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
88
|
+
size: "xsmall"
|
|
89
|
+
}, ship.manufacturer)), /*#__PURE__*/_react["default"].createElement(_grommet.NameValuePair, {
|
|
90
|
+
name: /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
91
|
+
size: "small",
|
|
92
|
+
weight: "bold"
|
|
93
|
+
}, "Passengers")
|
|
94
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
95
|
+
size: "xsmall"
|
|
96
|
+
}, ship.passengers)));
|
|
97
|
+
};
|
|
98
|
+
var RowDetails = exports.RowDetails = function RowDetails() {
|
|
99
|
+
var _useState = (0, _react.useState)({}),
|
|
100
|
+
result = _useState[0],
|
|
101
|
+
setResult = _useState[1];
|
|
102
|
+
var _useState2 = (0, _react.useState)(0),
|
|
103
|
+
total = _useState2[0],
|
|
104
|
+
setTotal = _useState2[1];
|
|
105
|
+
var _useState3 = (0, _react.useState)({
|
|
106
|
+
search: '',
|
|
107
|
+
step: step
|
|
108
|
+
}),
|
|
109
|
+
view = _useState3[0],
|
|
110
|
+
setView = _useState3[1];
|
|
111
|
+
var abortRef = (0, _react.useRef)();
|
|
112
|
+
var _useState4 = (0, _react.useState)(['Y-wing']),
|
|
113
|
+
expand = _useState4[0],
|
|
114
|
+
setExpand = _useState4[1];
|
|
115
|
+
(0, _react.useEffect)(function () {
|
|
116
|
+
var _abortRef$current;
|
|
117
|
+
// This API is a bit slow, abort any uncompleted requests.
|
|
118
|
+
abortRef == null || (_abortRef$current = abortRef.current) == null || _abortRef$current.abort();
|
|
119
|
+
abortRef.current = new AbortController();
|
|
120
|
+
fetchData(view, abortRef.current.signal).then(function (_ref3) {
|
|
121
|
+
var count = _ref3.count,
|
|
122
|
+
results = _ref3.results;
|
|
123
|
+
if (results) {
|
|
124
|
+
// The API doesn't provide a non-filtered total, so we rely on the
|
|
125
|
+
// first call having no filtering telling us the total.
|
|
126
|
+
setTotal(function (prevTotal) {
|
|
127
|
+
return Math.max(prevTotal, count);
|
|
128
|
+
});
|
|
129
|
+
setResult({
|
|
130
|
+
data: results,
|
|
131
|
+
filteredTotal: count
|
|
132
|
+
});
|
|
133
|
+
abortRef.current = undefined;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}, [view]);
|
|
137
|
+
var rowDetails = (0, _react.useMemo)(function () {
|
|
138
|
+
return {
|
|
139
|
+
render: function render(row) {
|
|
140
|
+
return /*#__PURE__*/_react["default"].createElement(ShipProperties, {
|
|
141
|
+
ship: row
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
expand: expand,
|
|
145
|
+
onExpand: function onExpand(nextExpand /* , datum */) {
|
|
146
|
+
return setExpand(nextExpand);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}, [expand]);
|
|
36
150
|
return (
|
|
37
151
|
/*#__PURE__*/
|
|
38
152
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
39
|
-
// <Grommet theme={
|
|
153
|
+
// <Grommet theme={...}>
|
|
40
154
|
_react["default"].createElement(_grommet.Box, {
|
|
41
|
-
|
|
42
|
-
|
|
155
|
+
skeleton: !result.data,
|
|
156
|
+
width: "large",
|
|
157
|
+
pad: "large"
|
|
158
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Data, {
|
|
159
|
+
data: result.data,
|
|
160
|
+
total: total,
|
|
161
|
+
filteredTotal: result.filteredTotal,
|
|
162
|
+
view: view,
|
|
163
|
+
onView: setView,
|
|
164
|
+
toolbar: "search"
|
|
43
165
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.DataTable, {
|
|
44
166
|
columns: [{
|
|
45
|
-
property: '
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
header: /*#__PURE__*/_react["default"].createElement(_grommet.CheckBox, {
|
|
58
|
-
checked: checked.length === _data.DATA.length,
|
|
59
|
-
indeterminate: checked.length > 0 && checked.length < _data.DATA.length,
|
|
60
|
-
onChange: onCheckAll,
|
|
61
|
-
"aria-label": "header checkbox"
|
|
62
|
-
}),
|
|
63
|
-
sortable: false
|
|
64
|
-
}].concat(controlledColumns).map(function (col) {
|
|
65
|
-
return _extends({}, col);
|
|
66
|
-
}),
|
|
67
|
-
data: _data.DATA,
|
|
68
|
-
sortable: true,
|
|
69
|
-
rowDetails: function rowDetails(row) {
|
|
70
|
-
if (row.name === 'Alan') {
|
|
71
|
-
return /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, " ", row.name, " ");
|
|
72
|
-
}
|
|
73
|
-
return /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, "Blah ", row.name, " ");
|
|
74
|
-
},
|
|
75
|
-
size: "medium"
|
|
76
|
-
}))
|
|
167
|
+
property: 'name',
|
|
168
|
+
header: 'Name',
|
|
169
|
+
primary: true
|
|
170
|
+
}, {
|
|
171
|
+
property: 'starship_class',
|
|
172
|
+
header: 'Class'
|
|
173
|
+
}],
|
|
174
|
+
rowDetails: rowDetails
|
|
175
|
+
}), /*#__PURE__*/_react["default"].createElement(_grommet.Pagination, null)))
|
|
176
|
+
|
|
77
177
|
// </Grommet>
|
|
78
178
|
);
|
|
79
179
|
};
|
|
80
|
-
|
|
180
|
+
RowDetails.storyName = 'rowDetails';
|
|
181
|
+
RowDetails.parameters = {
|
|
182
|
+
chromatic: {
|
|
183
|
+
disable: true
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
RowDetails.args = {
|
|
187
|
+
full: true
|
|
188
|
+
};
|
|
81
189
|
var _default = exports["default"] = {
|
|
82
190
|
title: 'Visualizations/DataTable/rowDetails'
|
|
83
191
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { Box, DataTable, Meter, Text } from 'grommet';
|
|
4
4
|
|
|
@@ -148,8 +148,8 @@ const DATA: RowType[] = [
|
|
|
148
148
|
|
|
149
149
|
export const OnSelectDataTable = () => {
|
|
150
150
|
// Type arguments can only be used in TypeScript files.
|
|
151
|
-
// Remove <
|
|
152
|
-
const [select, setSelect] = useState<
|
|
151
|
+
// Remove <(number | string)[]> if you are not using Typescript.
|
|
152
|
+
const [select, setSelect] = useState<(number | string)[]>([]);
|
|
153
153
|
|
|
154
154
|
return (
|
|
155
155
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
@@ -3,7 +3,10 @@ import { BoxProps } from '../Box/index';
|
|
|
3
3
|
|
|
4
4
|
export interface DataViewProps {}
|
|
5
5
|
|
|
6
|
-
type divProps = Omit<
|
|
6
|
+
type divProps = Omit<
|
|
7
|
+
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>,
|
|
8
|
+
'onClick' | 'property'
|
|
9
|
+
>;
|
|
7
10
|
|
|
8
11
|
export interface DataViewExtendedProps
|
|
9
12
|
extends BoxProps,
|