grommet 2.28.0 → 2.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Accordion/Accordion.js +1 -2
- package/components/AccordionPanel/AccordionPanel.js +1 -2
- package/components/Box/Box.js +11 -2
- package/components/Box/StyledBox.js +30 -5
- package/components/Button/Button.js +4 -12
- package/components/Button/StyledButtonKind.js +1 -3
- package/components/Calendar/Calendar.js +66 -65
- package/components/Cards/Cards.js +83 -0
- package/components/Cards/README.md +2 -0
- package/components/Cards/index.d.ts +38 -0
- package/components/Cards/index.js +6 -0
- package/components/Cards/propTypes.js +24 -0
- package/components/Cards/stories/Children.js +49 -0
- package/components/Cards/stories/Paginated.js +31 -0
- package/components/Cards/stories/Simple.js +28 -0
- package/components/Collapsible/Collapsible.js +1 -1
- package/components/Data/Data.js +113 -0
- package/components/Data/DataForm.js +243 -0
- package/components/Data/README.md +2 -0
- package/components/Data/filter.js +102 -0
- package/components/Data/index.d.ts +111 -0
- package/components/Data/index.js +12 -0
- package/components/Data/propTypes.js +29 -0
- package/components/Data/stories/Cards.js +51 -0
- package/components/Data/stories/Controlled.js +94 -0
- package/components/Data/stories/DataTable.js +44 -0
- package/components/Data/stories/Infinite.js +263 -0
- package/components/Data/stories/Inline.js +94 -0
- package/components/Data/stories/List.js +45 -0
- package/components/Data/stories/Simple.js +40 -0
- package/components/Data/stories/SpaceX.js +257 -0
- package/components/Data/stories/StarWars.js +133 -0
- package/components/Data/stories/Views.js +56 -0
- package/components/DataFilter/DataFilter.js +138 -0
- package/components/DataFilter/README.md +2 -0
- package/components/DataFilter/index.d.ts +29 -0
- package/components/DataFilter/index.js +6 -0
- package/components/DataFilter/propTypes.js +18 -0
- package/components/DataFilter/stories/Simple.js +35 -0
- package/components/DataFilters/DataFilters.js +145 -0
- package/components/DataFilters/README.md +2 -0
- package/components/DataFilters/index.d.ts +18 -0
- package/components/DataFilters/index.js +6 -0
- package/components/DataFilters/propTypes.js +15 -0
- package/components/DataFilters/stories/Drop.js +37 -0
- package/components/DataFilters/stories/Inline.js +37 -0
- package/components/DataFilters/stories/Simple.js +33 -0
- package/components/DataSearch/DataSearch.js +49 -0
- package/components/DataSearch/README.md +2 -0
- package/components/DataSearch/index.d.ts +6 -0
- package/components/DataSearch/index.js +6 -0
- package/components/DataSearch/propTypes.js +10 -0
- package/components/DataSearch/stories/Simple.js +37 -0
- package/components/DataSort/DataSort.js +74 -0
- package/components/DataSort/README.md +2 -0
- package/components/DataSort/index.d.ts +15 -0
- package/components/DataSort/index.js +6 -0
- package/components/DataSort/propTypes.js +7 -0
- package/components/DataSort/stories/Simple.js +35 -0
- package/components/DataSummary/DataSummary.js +42 -0
- package/components/DataSummary/README.md +2 -0
- package/components/DataSummary/index.d.ts +12 -0
- package/components/DataSummary/index.js +6 -0
- package/components/DataSummary/propTypes.js +17 -0
- package/components/DataSummary/stories/Simple.js +35 -0
- package/components/DataTable/Cell.js +1 -1
- package/components/DataTable/DataTable.js +38 -6
- package/components/DataTable/Header.js +2 -1
- package/components/DataTable/Resizer.js +1 -3
- package/components/DataTable/buildState.js +2 -6
- 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 +225 -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 +47 -0
- package/components/DataView/DataView.js +58 -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 +48 -0
- package/components/DateInput/DateInput.js +2 -1
- package/components/DateInput/utils.js +1 -3
- package/components/Distribution/stories/typescript/Simple.tsx +1 -1
- package/components/Drop/DropContainer.js +25 -22
- package/components/Footer/stories/Sitemap.js +5 -2
- package/components/Form/Form.js +22 -5
- package/components/Form/FormContext.js +2 -1
- package/components/Form/index.d.ts +1 -0
- package/components/Form/propTypes.js +1 -0
- package/components/Form/stories/Controlled.js +2 -0
- package/components/Form/stories/SolicitedFeedback.js +79 -0
- package/components/Form/stories/UnsolicitedFeedback.js +145 -0
- package/components/Form/stories/ValidateOnBlur.js +18 -0
- package/components/FormField/FormField.js +32 -11
- package/components/Grommet/index.d.ts +3 -0
- package/components/Header/stories/Sticky.js +3 -1
- package/components/Image/stories/Fallback.js +2 -1
- package/components/Layer/LayerContainer.js +1 -2
- package/components/Layer/PortalContext.js +1 -1
- package/components/Layer/stories/Form.js +54 -28
- package/components/List/List.js +8 -10
- package/components/NameValueList/stories/Align.js +5 -4
- package/components/NameValueList/stories/CustomName.js +2 -2
- package/components/NameValueList/stories/CustomValue.js +4 -4
- package/components/NameValueList/stories/Layout.js +4 -4
- package/components/NameValueList/stories/PairProps.js +3 -3
- package/components/NameValueList/stories/Width.js +5 -5
- package/components/Pagination/Pagination.js +19 -8
- package/components/Pagination/stories/Size.js +5 -5
- package/components/RangeSelector/RangeSelector.js +87 -30
- package/components/RangeSelector/index.d.ts +3 -1
- package/components/RangeSelector/propTypes.js +3 -1
- package/components/RangeSelector/stories/Label.js +62 -0
- package/components/RangeSelector/stories/Simple.js +35 -0
- package/components/Select/index.d.ts +2 -2
- package/components/Select/utils.js +1 -1
- package/components/Skeleton/stories/GridContainer.js +1 -3
- package/components/StarRating/README.MD +2 -0
- package/components/StarRating/StarRating.js +40 -0
- package/components/StarRating/index.d.ts +7 -0
- package/components/StarRating/index.js +6 -0
- package/components/StarRating/stories/simple.js +22 -0
- package/components/Tabs/Tabs.js +1 -1
- package/components/ThumbsRating/README.md +2 -0
- package/components/ThumbsRating/ThumbsRating.js +41 -0
- package/components/ThumbsRating/index.d.ts +7 -0
- package/components/ThumbsRating/index.js +6 -0
- package/components/ThumbsRating/stories/simple.js +22 -0
- package/components/Toolbar/README.md +2 -0
- package/components/Toolbar/Toolbar.js +37 -0
- package/components/Toolbar/index.d.ts +15 -0
- package/components/Toolbar/index.js +6 -0
- package/components/Toolbar/propTypes.js +10 -0
- package/components/Toolbar/stories/Simple.js +52 -0
- package/components/Video/Video.js +4 -8
- package/components/WorldMap/WorldMap.js +1 -3
- package/components/index.d.ts +11 -0
- package/components/index.js +72 -0
- package/contexts/DataContext.js +10 -0
- package/contexts/index.js +6 -0
- package/es6/components/Accordion/Accordion.js +1 -2
- package/es6/components/AccordionPanel/AccordionPanel.js +1 -2
- package/es6/components/Box/Box.js +11 -2
- package/es6/components/Box/StyledBox.js +30 -5
- package/es6/components/Button/Button.js +4 -12
- package/es6/components/Button/StyledButtonKind.js +1 -3
- package/es6/components/Calendar/Calendar.js +66 -65
- package/es6/components/Cards/Cards.js +77 -0
- package/es6/components/Cards/README.md +2 -0
- package/es6/components/Cards/index.d.ts +38 -0
- package/es6/components/Cards/index.js +1 -0
- package/es6/components/Cards/propTypes.js +18 -0
- package/es6/components/Cards/stories/Children.js +42 -0
- package/es6/components/Cards/stories/Paginated.js +24 -0
- package/es6/components/Cards/stories/Simple.js +21 -0
- package/es6/components/Collapsible/Collapsible.js +1 -1
- package/es6/components/Data/Data.js +106 -0
- package/es6/components/Data/DataForm.js +228 -0
- package/es6/components/Data/README.md +2 -0
- package/es6/components/Data/filter.js +97 -0
- package/es6/components/Data/index.d.ts +111 -0
- package/es6/components/Data/index.js +2 -0
- package/es6/components/Data/propTypes.js +23 -0
- package/es6/components/Data/stories/Cards.js +45 -0
- package/es6/components/Data/stories/Controlled.js +87 -0
- package/es6/components/Data/stories/DataTable.js +38 -0
- package/es6/components/Data/stories/Infinite.js +256 -0
- package/es6/components/Data/stories/Inline.js +87 -0
- package/es6/components/Data/stories/List.js +39 -0
- package/es6/components/Data/stories/Simple.js +34 -0
- package/es6/components/Data/stories/SpaceX.js +250 -0
- package/es6/components/Data/stories/StarWars.js +127 -0
- package/es6/components/Data/stories/Views.js +50 -0
- package/es6/components/DataFilter/DataFilter.js +131 -0
- package/es6/components/DataFilter/README.md +2 -0
- package/es6/components/DataFilter/index.d.ts +29 -0
- package/es6/components/DataFilter/index.js +1 -0
- package/es6/components/DataFilter/propTypes.js +12 -0
- package/es6/components/DataFilter/stories/Simple.js +29 -0
- package/es6/components/DataFilters/DataFilters.js +138 -0
- package/es6/components/DataFilters/README.md +2 -0
- package/es6/components/DataFilters/index.d.ts +18 -0
- package/es6/components/DataFilters/index.js +1 -0
- package/es6/components/DataFilters/propTypes.js +9 -0
- package/es6/components/DataFilters/stories/Drop.js +31 -0
- package/es6/components/DataFilters/stories/Inline.js +31 -0
- package/es6/components/DataFilters/stories/Simple.js +27 -0
- package/es6/components/DataSearch/DataSearch.js +42 -0
- package/es6/components/DataSearch/README.md +2 -0
- package/es6/components/DataSearch/index.d.ts +6 -0
- package/es6/components/DataSearch/index.js +1 -0
- package/es6/components/DataSearch/propTypes.js +5 -0
- package/es6/components/DataSearch/stories/Simple.js +31 -0
- package/es6/components/DataSort/DataSort.js +67 -0
- package/es6/components/DataSort/README.md +2 -0
- package/es6/components/DataSort/index.d.ts +15 -0
- package/es6/components/DataSort/index.js +1 -0
- package/es6/components/DataSort/propTypes.js +2 -0
- package/es6/components/DataSort/stories/Simple.js +29 -0
- package/es6/components/DataSummary/DataSummary.js +35 -0
- package/es6/components/DataSummary/README.md +2 -0
- package/es6/components/DataSummary/index.d.ts +12 -0
- package/es6/components/DataSummary/index.js +1 -0
- package/es6/components/DataSummary/propTypes.js +11 -0
- package/es6/components/DataSummary/stories/Simple.js +29 -0
- package/es6/components/DataTable/Cell.js +2 -2
- package/es6/components/DataTable/DataTable.js +38 -6
- package/es6/components/DataTable/Header.js +2 -1
- package/es6/components/DataTable/Resizer.js +1 -3
- package/es6/components/DataTable/buildState.js +2 -6
- 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 +218 -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 +42 -0
- package/es6/components/DataView/DataView.js +51 -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 +42 -0
- package/es6/components/DateInput/DateInput.js +2 -1
- package/es6/components/DateInput/utils.js +1 -3
- package/es6/components/Distribution/stories/typescript/Simple.tsx +1 -1
- package/es6/components/Drop/DropContainer.js +25 -22
- package/es6/components/Footer/stories/Sitemap.js +5 -2
- package/es6/components/Form/Form.js +22 -5
- package/es6/components/Form/FormContext.js +2 -1
- package/es6/components/Form/index.d.ts +1 -0
- package/es6/components/Form/propTypes.js +1 -0
- package/es6/components/Form/stories/Controlled.js +2 -0
- package/es6/components/Form/stories/SolicitedFeedback.js +73 -0
- package/es6/components/Form/stories/UnsolicitedFeedback.js +138 -0
- package/es6/components/Form/stories/ValidateOnBlur.js +19 -1
- package/es6/components/FormField/FormField.js +32 -11
- package/es6/components/Grommet/index.d.ts +3 -0
- package/es6/components/Header/stories/Sticky.js +3 -1
- package/es6/components/Image/stories/Fallback.js +2 -1
- package/es6/components/Layer/LayerContainer.js +1 -2
- package/es6/components/Layer/PortalContext.js +1 -1
- package/es6/components/Layer/stories/Form.js +56 -29
- package/es6/components/List/List.js +8 -10
- package/es6/components/NameValueList/stories/Align.js +5 -4
- package/es6/components/NameValueList/stories/CustomName.js +2 -2
- package/es6/components/NameValueList/stories/CustomValue.js +4 -4
- package/es6/components/NameValueList/stories/Layout.js +4 -4
- package/es6/components/NameValueList/stories/PairProps.js +3 -3
- package/es6/components/NameValueList/stories/Width.js +5 -5
- package/es6/components/Pagination/Pagination.js +19 -8
- package/es6/components/Pagination/stories/Size.js +5 -5
- package/es6/components/RangeSelector/RangeSelector.js +87 -30
- package/es6/components/RangeSelector/index.d.ts +3 -1
- package/es6/components/RangeSelector/propTypes.js +3 -1
- package/es6/components/RangeSelector/stories/Label.js +55 -0
- package/es6/components/RangeSelector/stories/Simple.js +28 -0
- package/es6/components/Select/index.d.ts +2 -2
- package/es6/components/Select/utils.js +1 -1
- package/es6/components/Skeleton/stories/GridContainer.js +1 -3
- package/es6/components/StarRating/README.MD +2 -0
- package/es6/components/StarRating/StarRating.js +34 -0
- package/es6/components/StarRating/index.d.ts +7 -0
- package/es6/components/StarRating/index.js +1 -0
- package/es6/components/StarRating/stories/simple.js +15 -0
- package/es6/components/Tabs/Tabs.js +1 -1
- package/es6/components/ThumbsRating/README.md +2 -0
- package/es6/components/ThumbsRating/ThumbsRating.js +35 -0
- package/es6/components/ThumbsRating/index.d.ts +7 -0
- package/es6/components/ThumbsRating/index.js +1 -0
- package/es6/components/ThumbsRating/stories/simple.js +15 -0
- package/es6/components/Toolbar/README.md +2 -0
- package/es6/components/Toolbar/Toolbar.js +30 -0
- package/es6/components/Toolbar/index.d.ts +15 -0
- package/es6/components/Toolbar/index.js +1 -0
- package/es6/components/Toolbar/propTypes.js +5 -0
- package/es6/components/Toolbar/stories/Simple.js +46 -0
- package/es6/components/Video/Video.js +4 -8
- package/es6/components/WorldMap/WorldMap.js +1 -3
- package/es6/components/index.d.ts +11 -0
- package/es6/components/index.js +12 -0
- package/es6/contexts/DataContext.js +4 -0
- package/es6/contexts/index.js +1 -0
- package/es6/index.d.ts +2 -0
- package/es6/languages/default.json +28 -0
- package/es6/themes/base.d.ts +14 -0
- package/es6/themes/base.js +29 -2
- package/es6/utils/DOM.js +21 -3
- package/es6/utils/PortalContext.js +1 -1
- package/es6/utils/refs.js +3 -19
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +2 -0
- package/languages/default.json +28 -0
- package/package.json +46 -46
- package/themes/base.d.ts +14 -0
- package/themes/base.js +29 -2
- package/utils/DOM.js +24 -5
- package/utils/PortalContext.js +1 -1
- package/utils/refs.js +2 -18
|
@@ -583,7 +583,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
583
583
|
var days;
|
|
584
584
|
var firstDayInMonth;
|
|
585
585
|
var blankWeek = false;
|
|
586
|
-
|
|
586
|
+
var _loop = function _loop() {
|
|
587
587
|
if (day.getDay() === firstDayOfWeek) {
|
|
588
588
|
if (days) {
|
|
589
589
|
weeks.push( /*#__PURE__*/React.createElement(StyledWeek, {
|
|
@@ -627,73 +627,74 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
627
627
|
fillContainer: fill
|
|
628
628
|
})));
|
|
629
629
|
} else {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
return _onClick(dateObject);
|
|
654
|
-
},
|
|
655
|
-
onMouseOver: function onMouseOver() {
|
|
656
|
-
return setActive(dateObject);
|
|
657
|
-
},
|
|
658
|
-
onMouseOut: function onMouseOut() {
|
|
659
|
-
return setActive(undefined);
|
|
660
|
-
}
|
|
630
|
+
var dateObject = day;
|
|
631
|
+
// this.dayRefs[dateObject] = React.createRef();
|
|
632
|
+
var selected = false;
|
|
633
|
+
var inRange = false;
|
|
634
|
+
var selectedState = withinDates(day, range ? normalizeRange(value, activeDate) : value);
|
|
635
|
+
if (selectedState === 2) {
|
|
636
|
+
selected = true;
|
|
637
|
+
} else if (selectedState === 1) {
|
|
638
|
+
inRange = true;
|
|
639
|
+
}
|
|
640
|
+
var dayDisabled = withinDates(day, normalizeInput(disabled)) || bounds && !betweenDates(day, normalizeInput(bounds));
|
|
641
|
+
if (!firstDayInMonth && !dayDisabled && day.getMonth() === reference.getMonth()) {
|
|
642
|
+
firstDayInMonth = dateObject;
|
|
643
|
+
}
|
|
644
|
+
if (!children) {
|
|
645
|
+
days.push( /*#__PURE__*/React.createElement(CalendarDay, {
|
|
646
|
+
key: day.getTime(),
|
|
647
|
+
buttonProps: {
|
|
648
|
+
a11yTitle: day.toDateString(),
|
|
649
|
+
active: active && active.getTime() === day.getTime(),
|
|
650
|
+
disabled: dayDisabled && !!dayDisabled,
|
|
651
|
+
onClick: function onClick() {
|
|
652
|
+
return _onClick(dateObject);
|
|
661
653
|
},
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
654
|
+
onMouseOver: function onMouseOver() {
|
|
655
|
+
return setActive(dateObject);
|
|
656
|
+
},
|
|
657
|
+
onMouseOut: function onMouseOut() {
|
|
658
|
+
return setActive(undefined);
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
isInRange: inRange,
|
|
662
|
+
isSelected: selected,
|
|
663
|
+
otherMonth: day.getMonth() !== reference.getMonth(),
|
|
664
|
+
size: size,
|
|
665
|
+
fill: fill
|
|
666
|
+
}, day.getDate()));
|
|
667
|
+
} else {
|
|
668
|
+
days.push( /*#__PURE__*/React.createElement(CalendarCustomDay, {
|
|
669
|
+
key: day.getTime(),
|
|
670
|
+
buttonProps: onSelect ? {
|
|
671
|
+
a11yTitle: day.toDateString(),
|
|
672
|
+
active: active && active.getTime() === day.getTime(),
|
|
673
|
+
disabled: dayDisabled && !!dayDisabled,
|
|
674
|
+
onClick: function onClick() {
|
|
675
|
+
return _onClick(dateObject);
|
|
676
|
+
},
|
|
677
|
+
onMouseOver: function onMouseOver() {
|
|
678
|
+
return setActive(dateObject);
|
|
679
|
+
},
|
|
680
|
+
onMouseOut: function onMouseOut() {
|
|
681
|
+
return setActive(undefined);
|
|
682
|
+
}
|
|
683
|
+
} : null,
|
|
684
|
+
size: size,
|
|
685
|
+
fill: fill
|
|
686
|
+
}, children({
|
|
687
|
+
date: day,
|
|
688
|
+
day: day.getDate(),
|
|
689
|
+
isInRange: inRange,
|
|
690
|
+
isSelected: selected
|
|
691
|
+
})));
|
|
692
|
+
}
|
|
695
693
|
}
|
|
696
694
|
day = addDays(day, 1);
|
|
695
|
+
};
|
|
696
|
+
while (day.getTime() < displayBounds[1].getTime()) {
|
|
697
|
+
_loop();
|
|
697
698
|
}
|
|
698
699
|
weeks.push( /*#__PURE__*/React.createElement(StyledWeek
|
|
699
700
|
// if a week contains only blank days, for screen reader accessibility
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var _excluded = ["as", "children", "data", "margin", "onMore", "pad", "paginate", "show", "size", "step"];
|
|
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, { Fragment, useContext } from 'react';
|
|
5
|
+
import { ThemeContext } from 'styled-components';
|
|
6
|
+
import { DataContext } from '../../contexts/DataContext';
|
|
7
|
+
import { Box } from '../Box';
|
|
8
|
+
import { Card } from '../Card';
|
|
9
|
+
import { CardBody } from '../CardBody';
|
|
10
|
+
import { Grid } from '../Grid';
|
|
11
|
+
import { InfiniteScroll } from '../InfiniteScroll';
|
|
12
|
+
import { Pagination } from '../Pagination';
|
|
13
|
+
import { normalizeShow, usePagination } from '../../utils';
|
|
14
|
+
import { CardsPropTypes } from './propTypes';
|
|
15
|
+
var emptyData = [];
|
|
16
|
+
var Cards = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
17
|
+
var _ref$as = _ref.as,
|
|
18
|
+
as = _ref$as === void 0 ? 'ul' : _ref$as,
|
|
19
|
+
children = _ref.children,
|
|
20
|
+
dataProp = _ref.data,
|
|
21
|
+
margin = _ref.margin,
|
|
22
|
+
onMore = _ref.onMore,
|
|
23
|
+
pad = _ref.pad,
|
|
24
|
+
paginate = _ref.paginate,
|
|
25
|
+
showProp = _ref.show,
|
|
26
|
+
_ref$size = _ref.size,
|
|
27
|
+
size = _ref$size === void 0 ? 'small' : _ref$size,
|
|
28
|
+
_ref$step = _ref.step,
|
|
29
|
+
step = _ref$step === void 0 ? paginate ? 50 : undefined : _ref$step,
|
|
30
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
31
|
+
var theme = useContext(ThemeContext);
|
|
32
|
+
var _useContext = useContext(DataContext),
|
|
33
|
+
contextData = _useContext.data;
|
|
34
|
+
var data = dataProp || contextData || emptyData;
|
|
35
|
+
var _usePagination = usePagination(_extends({
|
|
36
|
+
data: data,
|
|
37
|
+
page: normalizeShow(showProp, step),
|
|
38
|
+
step: step
|
|
39
|
+
}, paginate)),
|
|
40
|
+
items = _usePagination[0],
|
|
41
|
+
paginationProps = _usePagination[1];
|
|
42
|
+
var Container = paginate ? Box : Fragment;
|
|
43
|
+
var containerProps = paginate ? _extends({}, theme.cards.container, {
|
|
44
|
+
pad: pad,
|
|
45
|
+
margin: margin
|
|
46
|
+
}) : undefined;
|
|
47
|
+
return /*#__PURE__*/React.createElement(Container, containerProps, /*#__PURE__*/React.createElement(Grid, _extends({
|
|
48
|
+
ref: ref,
|
|
49
|
+
as: as,
|
|
50
|
+
columns: size,
|
|
51
|
+
gap: "medium",
|
|
52
|
+
margin: !paginate && margin || 'none',
|
|
53
|
+
pad: !paginate && pad || 'none'
|
|
54
|
+
}, rest), /*#__PURE__*/React.createElement(InfiniteScroll, {
|
|
55
|
+
items: !paginate ? data : items,
|
|
56
|
+
onMore: onMore,
|
|
57
|
+
show: !paginate ? showProp : undefined,
|
|
58
|
+
step: step,
|
|
59
|
+
renderMarker: function renderMarker(marker) {
|
|
60
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
61
|
+
as: "li",
|
|
62
|
+
flex: false
|
|
63
|
+
}, marker);
|
|
64
|
+
}
|
|
65
|
+
}, function (item, index) {
|
|
66
|
+
var _ref2, _ref3;
|
|
67
|
+
return children ? children(item, index) : /*#__PURE__*/React.createElement(Card, {
|
|
68
|
+
key: index.toString(),
|
|
69
|
+
as: as === 'ul' ? 'li' : undefined
|
|
70
|
+
}, /*#__PURE__*/React.createElement(CardBody, null, (_ref2 = (_ref3 = typeof item === 'string' && item) != null ? _ref3 : typeof item === 'object' && Object.values(item)[0]) != null ? _ref2 : index));
|
|
71
|
+
})), paginate && data.length > step && items && items.length ? /*#__PURE__*/React.createElement(Pagination, _extends({
|
|
72
|
+
alignSelf: "end"
|
|
73
|
+
}, paginationProps)) : null);
|
|
74
|
+
});
|
|
75
|
+
Cards.displayName = 'Cards';
|
|
76
|
+
Cards.propTypes = CardsPropTypes;
|
|
77
|
+
export { Cards };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
A11yTitleType,
|
|
4
|
+
AlignSelfType,
|
|
5
|
+
GridAreaType,
|
|
6
|
+
MarginType,
|
|
7
|
+
PadType,
|
|
8
|
+
} from '../../utils';
|
|
9
|
+
import { GridSizeType } from '../Grid';
|
|
10
|
+
import { PaginationType } from '../Pagination';
|
|
11
|
+
|
|
12
|
+
export interface CardsProps<CardType = any> {
|
|
13
|
+
a11yTitle?: A11yTitleType;
|
|
14
|
+
alignSelf?: AlignSelfType;
|
|
15
|
+
as?: string;
|
|
16
|
+
children?: (item: CardType, index: number) => JSX.Element;
|
|
17
|
+
data?: CardType[];
|
|
18
|
+
gridArea?: GridAreaType;
|
|
19
|
+
margin?: MarginType;
|
|
20
|
+
onMore?: () => void;
|
|
21
|
+
pad?: PadType;
|
|
22
|
+
paginate?: boolean | PaginationType;
|
|
23
|
+
show?: number | { page?: number };
|
|
24
|
+
size?: GridSizeType;
|
|
25
|
+
step?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type ulProps = Omit<JSX.IntrinsicElements['ul'], 'children'>;
|
|
29
|
+
|
|
30
|
+
export interface CardsExtendedProps<CardType>
|
|
31
|
+
extends CardsProps<CardType>,
|
|
32
|
+
ulProps {}
|
|
33
|
+
|
|
34
|
+
declare class Cards<CardType = any> extends React.Component<
|
|
35
|
+
CardsExtendedProps<CardType>
|
|
36
|
+
> {}
|
|
37
|
+
|
|
38
|
+
export { Cards };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Cards } from './Cards';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { genericProps } from '../../utils/general-prop-types';
|
|
4
|
+
var PropType = {};
|
|
5
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6
|
+
PropType = _extends({}, genericProps, {
|
|
7
|
+
as: PropTypes.string,
|
|
8
|
+
data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.shape({})])),
|
|
9
|
+
children: PropTypes.func,
|
|
10
|
+
onMore: PropTypes.func,
|
|
11
|
+
paginate: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
12
|
+
show: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
13
|
+
page: PropTypes.number
|
|
14
|
+
})]),
|
|
15
|
+
step: PropTypes.number
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export var CardsPropTypes = PropType;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Card, CardBody, CardFooter, Grid, Heading } from 'grommet';
|
|
3
|
+
import { Cards } from '../Cards';
|
|
4
|
+
var data = [{
|
|
5
|
+
city: 'Boise',
|
|
6
|
+
state: 'Idaho'
|
|
7
|
+
}, {
|
|
8
|
+
city: 'Fort Collins',
|
|
9
|
+
state: 'Colorado'
|
|
10
|
+
}, {
|
|
11
|
+
city: 'Bay Area',
|
|
12
|
+
state: 'California'
|
|
13
|
+
}, {
|
|
14
|
+
city: 'San Diego',
|
|
15
|
+
state: 'California'
|
|
16
|
+
}, {
|
|
17
|
+
city: 'San Francisco',
|
|
18
|
+
state: 'California'
|
|
19
|
+
}];
|
|
20
|
+
export var Children = function Children() {
|
|
21
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
22
|
+
pad: "large",
|
|
23
|
+
columns: [['medium', 'large']],
|
|
24
|
+
justifyContent: "center"
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Cards, {
|
|
26
|
+
data: data,
|
|
27
|
+
pad: "medium",
|
|
28
|
+
border: false
|
|
29
|
+
}, function (datum) {
|
|
30
|
+
return /*#__PURE__*/React.createElement(Card, {
|
|
31
|
+
key: datum.city,
|
|
32
|
+
as: "li"
|
|
33
|
+
}, /*#__PURE__*/React.createElement(CardBody, null, /*#__PURE__*/React.createElement(Heading, {
|
|
34
|
+
level: 2,
|
|
35
|
+
size: "small",
|
|
36
|
+
margin: "none"
|
|
37
|
+
}, datum.city)), /*#__PURE__*/React.createElement(CardFooter, null, datum.state));
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
export default {
|
|
41
|
+
title: 'Visualizations/Cards/Children'
|
|
42
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from 'grommet';
|
|
3
|
+
import { Cards } from '../Cards';
|
|
4
|
+
var data = [];
|
|
5
|
+
for (var i = 0; i < 95; i += 1) {
|
|
6
|
+
data.push("item " + (i + 1));
|
|
7
|
+
}
|
|
8
|
+
export var Paginated = function Paginated() {
|
|
9
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
10
|
+
pad: "large",
|
|
11
|
+
columns: [['medium', 'large']],
|
|
12
|
+
justifyContent: "center"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(Cards, {
|
|
14
|
+
data: data,
|
|
15
|
+
step: 9,
|
|
16
|
+
show: {
|
|
17
|
+
page: 7
|
|
18
|
+
},
|
|
19
|
+
paginate: true
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
export default {
|
|
23
|
+
title: 'Visualizations/Cards/Paginated'
|
|
24
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid, Notification } from 'grommet';
|
|
3
|
+
import { Cards } from '../Cards';
|
|
4
|
+
var locations = ['Boise', 'Fort Collins', 'Los Gatos', 'Palo Alto', 'San Francisco'];
|
|
5
|
+
export var Simple = function Simple() {
|
|
6
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
7
|
+
pad: "large",
|
|
8
|
+
columns: [['medium', 'large']],
|
|
9
|
+
justifyContent: "center",
|
|
10
|
+
gap: "large"
|
|
11
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
12
|
+
status: "info",
|
|
13
|
+
message: "Cards is in 'beta'. The API surface is subject to change."
|
|
14
|
+
}), /*#__PURE__*/React.createElement(Cards, {
|
|
15
|
+
a11yTitle: "Locations",
|
|
16
|
+
data: locations
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
19
|
+
export default {
|
|
20
|
+
title: 'Visualizations/Cards/Simple'
|
|
21
|
+
};
|
|
@@ -30,7 +30,7 @@ var Collapsible = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
30
30
|
return direction === 'horizontal' ? 'width' : 'height';
|
|
31
31
|
}, [direction]);
|
|
32
32
|
var containerRef = useForwardedRef(ref);
|
|
33
|
-
var sizeRef = useRef();
|
|
33
|
+
var sizeRef = useRef(0);
|
|
34
34
|
var shouldOpen = !open && openArg;
|
|
35
35
|
var shouldClose = open && !openArg;
|
|
36
36
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var _excluded = ["children", "data", "defaultView", "filteredTotal", "id", "messages", "onView", "properties", "toolbar", "total", "updateOn", "view", "views"];
|
|
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, { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { Box } from '../Box';
|
|
6
|
+
import { DataFilters } from '../DataFilters';
|
|
7
|
+
import { DataSearch } from '../DataSearch';
|
|
8
|
+
import { DataSummary } from '../DataSummary';
|
|
9
|
+
import { DataView } from '../DataView';
|
|
10
|
+
import { Toolbar } from '../Toolbar';
|
|
11
|
+
import { DataContext } from '../../contexts/DataContext';
|
|
12
|
+
import { DataPropTypes } from './propTypes';
|
|
13
|
+
import { filter } from './filter';
|
|
14
|
+
var defaultDefaultView = {
|
|
15
|
+
search: ''
|
|
16
|
+
};
|
|
17
|
+
var normalizeView = function normalizeView(viewProp, views) {
|
|
18
|
+
return typeof viewProp === 'string' && (views == null ? void 0 : views.find(function (v) {
|
|
19
|
+
return v.name === viewProp;
|
|
20
|
+
})) || typeof viewProp === 'object' && viewProp;
|
|
21
|
+
};
|
|
22
|
+
export var Data = function Data(_ref) {
|
|
23
|
+
var children = _ref.children,
|
|
24
|
+
dataProp = _ref.data,
|
|
25
|
+
_ref$defaultView = _ref.defaultView,
|
|
26
|
+
defaultView = _ref$defaultView === void 0 ? defaultDefaultView : _ref$defaultView,
|
|
27
|
+
filteredTotal = _ref.filteredTotal,
|
|
28
|
+
_ref$id = _ref.id,
|
|
29
|
+
id = _ref$id === void 0 ? 'data' : _ref$id,
|
|
30
|
+
messages = _ref.messages,
|
|
31
|
+
onView = _ref.onView,
|
|
32
|
+
properties = _ref.properties,
|
|
33
|
+
toolbar = _ref.toolbar,
|
|
34
|
+
total = _ref.total,
|
|
35
|
+
_ref$updateOn = _ref.updateOn,
|
|
36
|
+
updateOn = _ref$updateOn === void 0 ? 'submit' : _ref$updateOn,
|
|
37
|
+
viewProp = _ref.view,
|
|
38
|
+
views = _ref.views,
|
|
39
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
40
|
+
var _useState = useState(normalizeView(viewProp || defaultView, views)),
|
|
41
|
+
view = _useState[0],
|
|
42
|
+
setView = _useState[1];
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
return setView(normalizeView(viewProp || defaultView, views));
|
|
45
|
+
}, [defaultView, viewProp, views]);
|
|
46
|
+
var _useState2 = useState([]),
|
|
47
|
+
toolbarKeys = _useState2[0],
|
|
48
|
+
setToolbarKeys = _useState2[1];
|
|
49
|
+
var result = useMemo(function () {
|
|
50
|
+
var _ref2;
|
|
51
|
+
if (onView)
|
|
52
|
+
// caller is filtering
|
|
53
|
+
return {
|
|
54
|
+
data: dataProp,
|
|
55
|
+
total: total,
|
|
56
|
+
filteredTotal: (_ref2 = filteredTotal != null ? filteredTotal : dataProp == null ? void 0 : dataProp.length) != null ? _ref2 : 0
|
|
57
|
+
};
|
|
58
|
+
return filter(dataProp, view, properties);
|
|
59
|
+
}, [dataProp, filteredTotal, onView, properties, total, view]);
|
|
60
|
+
|
|
61
|
+
// what we use for DataContext value
|
|
62
|
+
var contextValue = useMemo(function () {
|
|
63
|
+
var value = _extends({
|
|
64
|
+
id: id,
|
|
65
|
+
messages: messages,
|
|
66
|
+
properties: properties,
|
|
67
|
+
updateOn: updateOn,
|
|
68
|
+
view: view,
|
|
69
|
+
views: views
|
|
70
|
+
}, result);
|
|
71
|
+
value.clearFilters = function () {
|
|
72
|
+
var nextView = defaultView;
|
|
73
|
+
setView(nextView);
|
|
74
|
+
if (onView) onView(nextView);
|
|
75
|
+
};
|
|
76
|
+
value.onView = function (nextView) {
|
|
77
|
+
setView(nextView);
|
|
78
|
+
if (onView) onView(nextView);
|
|
79
|
+
};
|
|
80
|
+
value.addToolbarKey = function (key) {
|
|
81
|
+
setToolbarKeys(function (prevKeys) {
|
|
82
|
+
if (prevKeys.includes(key)) return prevKeys;
|
|
83
|
+
return [].concat(prevKeys, [key]);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
value.toolbarKeys = toolbarKeys;
|
|
87
|
+
return value;
|
|
88
|
+
}, [defaultView, id, messages, onView, properties, result, toolbarKeys, updateOn, view, views]);
|
|
89
|
+
var toolbarContent;
|
|
90
|
+
if (toolbar) {
|
|
91
|
+
toolbarContent = [/*#__PURE__*/React.createElement(Toolbar, {
|
|
92
|
+
key: "toolbar"
|
|
93
|
+
}, (toolbar === true || toolbar === 'search') && /*#__PURE__*/React.createElement(DataSearch, null), (toolbar === true || toolbar === 'view') && /*#__PURE__*/React.createElement(DataView, null), (toolbar === true || toolbar === 'filters') && /*#__PURE__*/React.createElement(DataFilters, {
|
|
94
|
+
drop: true
|
|
95
|
+
})), /*#__PURE__*/React.createElement(DataSummary, {
|
|
96
|
+
key: "summary"
|
|
97
|
+
})];
|
|
98
|
+
}
|
|
99
|
+
return /*#__PURE__*/React.createElement(DataContext.Provider, {
|
|
100
|
+
value: contextValue
|
|
101
|
+
}, /*#__PURE__*/React.createElement(Box, _extends({
|
|
102
|
+
id: id,
|
|
103
|
+
flex: false
|
|
104
|
+
}, rest), toolbarContent, children));
|
|
105
|
+
};
|
|
106
|
+
Data.propTypes = DataPropTypes;
|