grommet 2.19.1 → 2.20.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/Accordion.js +26 -23
- package/components/Accordion/stories/CustomHeader.js +36 -34
- package/components/Accordion/stories/CustomThemed/Custom.js +2 -9
- package/components/Accordion/stories/{typescript → CustomThemed}/Rich.tsx +2 -2
- package/components/Accordion/stories/DarkNoAnimation.js +34 -32
- package/components/Accordion/stories/Multiple.js +32 -30
- package/components/Accordion/stories/Simple.js +33 -31
- package/components/Anchor/propTypes.js +1 -1
- package/components/Anchor/stories/Color.js +1 -5
- package/components/Anchor/stories/Default.js +2 -6
- package/components/Anchor/stories/Disabled.js +2 -6
- package/components/Anchor/stories/Gap.js +2 -6
- package/components/Anchor/stories/Inline.js +2 -6
- package/components/Anchor/stories/Size.js +2 -6
- package/components/Anchor/stories/Weight.js +2 -6
- package/components/Avatar/Avatar.js +12 -11
- package/components/Avatar/stories/Basic.js +23 -21
- package/components/Avatar/stories/{Themed.js → CustomThemed/Themed.js} +1 -1
- package/components/Avatar/stories/Round.js +35 -33
- package/components/Avatar/stories/Sizes.js +80 -78
- package/components/Avatar/stories/typescript/Stacked.tsx +10 -11
- package/components/Button/Button.js +1 -0
- package/components/Button/StyledButton.js +3 -1
- package/components/Button/StyledButtonKind.js +5 -11
- package/components/Calendar/Calendar.js +113 -87
- package/components/Calendar/StyledCalendar.js +1 -1
- package/components/Calendar/index.d.ts +4 -0
- package/components/Calendar/stories/ActiveDate.js +35 -34
- package/components/Calendar/stories/CustomDay.js +69 -67
- package/components/Calendar/stories/CustomHeader.js +39 -37
- package/{es6/components/Calendar/stories/typescript → components/Calendar/stories/CustomThemed}/CustomDate.tsx +1 -1
- package/components/Calendar/stories/{CustomSizeHeading.js → CustomThemed/CustomSizeHeading.js} +1 -1
- package/components/Calendar/stories/DaylightSavings.js +55 -53
- package/components/Calendar/stories/Dual.js +86 -84
- package/components/Calendar/stories/Fill.js +16 -14
- package/components/Calendar/stories/Multiple.js +26 -24
- package/components/Calendar/stories/Range.js +13 -11
- package/components/Calendar/stories/ShowAdjacentDays.js +36 -34
- package/components/Calendar/stories/Simple.js +24 -22
- package/components/Calendar/stories/SundayFirstDay.js +13 -11
- package/components/Calendar/utils.js +60 -10
- package/components/Card/stories/{Clickable.js → CustomThemed/Clickable.js} +2 -2
- package/components/Card/stories/{Stacked.js → CustomThemed/Stacked.js} +2 -2
- package/components/Card/stories/{Themed.js → CustomThemed/Themed.js} +2 -2
- package/components/Card/stories/Simple.js +26 -23
- package/components/Carousel/Carousel.js +145 -93
- package/components/Carousel/CarouselChild.js +17 -27
- package/components/Carousel/StyledCarousel.js +44 -0
- package/components/Carousel/index.d.ts +5 -0
- package/components/Carousel/propTypes.js +13 -9
- package/components/Carousel/stories/Autoplay.js +52 -0
- package/components/Carousel/stories/ControlVariations.js +170 -0
- package/components/Carousel/stories/Controlled.js +43 -37
- package/components/Carousel/stories/{Custom.js → CustomThemed/Custom.js} +1 -1
- package/components/Carousel/stories/CustomThemed/Icons.tsx +50 -0
- package/components/Carousel/stories/InteractiveChild.js +73 -0
- package/components/Carousel/stories/Multiple.js +7 -1
- package/components/Carousel/stories/Simple.js +25 -19
- package/components/Chart/Chart.js +2 -1
- package/components/Chart/calcs.js +1 -1
- package/components/Chart/utils.js +1 -1
- package/components/CheckBox/StyledCheckBox.js +1 -1
- package/components/Clock/Clock.js +1 -1
- package/components/Clock/StyledClock.js +1 -1
- package/components/Collapsible/stories/Horizontal.js +54 -50
- package/components/Collapsible/stories/Nested.js +78 -76
- package/components/Collapsible/stories/Simple.js +24 -22
- package/components/DataChart/utils.js +1 -1
- package/components/DataTable/DataTable.js +1 -1
- package/components/DataTable/StyledDataTable.js +1 -1
- package/components/DataTable/buildState.js +3 -2
- package/components/DataTable/index.d.ts +3 -3
- package/components/DataTable/stories/ColumnSize.js +63 -61
- package/components/DataTable/stories/Controlled.js +34 -32
- package/components/DataTable/stories/ControlledGrouped.js +16 -14
- package/components/DataTable/stories/{Fill.js → CustomThemed/Fill.js} +2 -2
- package/components/DataTable/stories/Grouped.js +15 -13
- package/components/DataTable/stories/GroupedOnSelect.js +16 -14
- package/components/DataTable/stories/InfiniteScrollDataTable.js +22 -20
- package/components/DataTable/stories/MultiplePin.js +48 -44
- package/components/DataTable/stories/NoPrimary.js +15 -13
- package/components/DataTable/stories/OnUpdate.js +24 -22
- package/components/DataTable/stories/Placeholder.js +27 -25
- package/components/DataTable/stories/ResizableColumns.js +17 -15
- package/components/DataTable/stories/Served.js +18 -16
- package/components/DataTable/stories/Show.js +29 -23
- package/components/DataTable/stories/Simple.js +14 -12
- package/components/DataTable/stories/Sized.js +14 -12
- package/components/DataTable/stories/Sort.js +20 -18
- package/components/DataTable/stories/SpaceX.js +36 -34
- package/components/DataTable/stories/SpaceXUngrouped.js +26 -24
- package/components/DataTable/stories/Styled.js +43 -41
- package/components/DataTable/stories/Tunable.js +19 -17
- package/components/DataTable/stories/Units.js +16 -14
- package/components/DataTable/stories/data.js +1 -1
- package/components/DataTable/stories/rowDetails.js +40 -38
- package/components/DataTable/stories/typescript/Clickable.tsx +30 -29
- package/components/DataTable/stories/typescript/OnSelect.tsx +13 -13
- package/components/DataTable/stories/typescript/Paginated.tsx +15 -15
- package/components/DateInput/DateInput.js +68 -25
- package/components/DateInput/stories/FormatInline.js +172 -16
- package/components/DateInput/stories/ResetDate.js +1 -1
- package/components/DateInput/utils.js +11 -15
- package/components/Drop/DropContainer.js +16 -9
- package/components/Drop/stories/AllNotStretched.js +166 -164
- package/components/Drop/stories/{Lazy.js → CustomThemed/Lazy.js} +1 -1
- package/components/Drop/stories/{Themed.js → CustomThemed/Themed.js} +1 -1
- package/components/Drop/stories/Meter.js +35 -30
- package/components/Drop/stories/Multiple.js +56 -52
- package/components/Drop/stories/Overflow.js +54 -50
- package/components/Drop/stories/Plain.js +30 -26
- package/components/Drop/stories/Progressive.js +52 -48
- package/components/Drop/stories/Simple.js +28 -24
- package/components/Drop/stories/Styled.js +45 -41
- package/components/Drop/stories/TrapFocus.js +21 -16
- package/components/DropButton/stories/Menu.js +5 -7
- package/components/DropButton/stories/Simple.js +2 -6
- package/components/DropButton/stories/typescript/Calendar.tsx +17 -20
- package/components/FileInput/stories/CustomThemed/Custom.js +5 -7
- package/components/Footer/stories/data.js +1 -1
- package/components/Form/Form.js +240 -183
- package/components/Form/stories/ArrayOfFormFields.js +161 -0
- package/components/Form/stories/FieldWithChildren.js +4 -4
- package/components/FormField/FormField.js +1 -1
- package/components/Grommet/Grommet.js +8 -1
- package/components/Layer/LayerContainer.js +9 -4
- package/components/Layer/StyledLayer.js +1 -1
- package/components/MaskedInput/StyledMaskedInput.js +1 -1
- package/components/Menu/stories/BottomControlButton.js +2 -6
- package/components/Menu/stories/{typescript → CustomThemed}/Themed.tsx +1 -1
- package/components/Menu/stories/ItemWithIcon.js +2 -6
- package/components/Menu/stories/Justify.js +2 -6
- package/components/Menu/stories/Reverse.js +2 -6
- package/components/Menu/stories/Simple.js +2 -6
- package/components/Menu/stories/typescript/Children.tsx +10 -13
- package/components/Meter/utils.js +1 -1
- package/components/NameValueList/NameValueList.js +8 -5
- package/components/NameValueList/stories/CustomValue.js +1 -1
- package/components/NameValueList/stories/data.js +1 -1
- package/components/NameValuePair/NameValuePair.js +1 -4
- package/components/Nav/stories/Collapsable.js +39 -37
- package/components/Nav/stories/{CustomAnchor.js → CustomThemed/CustomAnchor.js} +2 -2
- package/components/Nav/stories/{JustifySidebar.js → CustomThemed/JustifySidebar.js} +1 -1
- package/components/Nav/stories/OnHeader.js +29 -27
- package/components/Nav/stories/Sidebar.js +24 -18
- package/components/Nav/stories/Simple.js +15 -13
- package/components/Notification/Notification.js +2 -2
- package/components/Pagination/StyledPageControl.js +2 -2
- package/components/RadioButton/StyledRadioButton.js +1 -1
- package/components/RadioButtonGroup/RadioButtonGroup.js +3 -1
- package/components/Select/Select.js +1 -0
- package/components/Stack/stories/Fill.js +15 -11
- package/components/Stack/stories/Simple.js +15 -9
- package/components/Table/StyledTable.js +1 -1
- package/components/Table/stories/data.js +1 -1
- package/components/Tabs/StyledTabs.js +1 -1
- package/components/Tabs/Tabs.js +23 -19
- package/components/Tabs/stories/{AlignControls.js → CustomThemed/AlignControls.js} +1 -1
- package/components/Tabs/stories/{Custom.js → CustomThemed/Custom.js} +3 -3
- package/components/Tabs/stories/{Icon.js → CustomThemed/Icon.js} +1 -1
- package/components/Tabs/stories/{States.js → CustomThemed/States.js} +1 -1
- package/components/Tabs/stories/Plain.js +45 -41
- package/components/Tabs/stories/Responsive.js +191 -189
- package/components/Tabs/stories/Rich.js +30 -28
- package/components/Tabs/stories/Scrollable.js +32 -28
- package/components/Tabs/stories/Uncontrolled.js +45 -41
- package/components/Tabs/stories/typescript/Controlled.tsx +21 -21
- package/components/Tag/README.md +2 -0
- package/components/Tag/StyledTag.js +35 -0
- package/components/Tag/Tag.js +83 -0
- package/components/Tag/index.d.ts +27 -0
- package/components/Tag/index.js +8 -0
- package/components/Tag/propTypes.js +27 -0
- package/components/Tag/stories/OnClick.js +34 -0
- package/components/Tag/stories/OnRemove.js +38 -0
- package/components/Tag/stories/Simple.js +32 -0
- package/components/Text/Text.js +23 -9
- package/components/TextInput/StyledTextInput.js +1 -1
- package/components/TextInput/TextInput.js +14 -2
- package/components/TextInput/index.d.ts +6 -1
- package/components/Video/Video.js +98 -38
- package/components/Video/index.d.ts +15 -2
- package/components/Video/propTypes.js +8 -1
- package/components/Video/stories/typescript/TheaterMode.tsx +46 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +8 -0
- package/contexts/MessageContext/MessageContext.js +3 -2
- package/contexts/MessageContext/index.js +1 -1
- package/es6/components/Accordion/Accordion.js +26 -23
- package/es6/components/Accordion/stories/CustomHeader.js +37 -34
- package/es6/components/Accordion/stories/CustomThemed/Custom.js +2 -9
- package/es6/components/Accordion/stories/{typescript → CustomThemed}/Rich.tsx +2 -2
- package/es6/components/Accordion/stories/DarkNoAnimation.js +35 -32
- package/es6/components/Accordion/stories/Multiple.js +33 -30
- package/es6/components/Accordion/stories/Simple.js +34 -31
- package/es6/components/Anchor/propTypes.js +1 -1
- package/es6/components/Anchor/stories/Color.js +2 -5
- package/es6/components/Anchor/stories/Default.js +3 -6
- package/es6/components/Anchor/stories/Disabled.js +3 -6
- package/es6/components/Anchor/stories/Gap.js +3 -6
- package/es6/components/Anchor/stories/Inline.js +3 -6
- package/es6/components/Anchor/stories/Size.js +3 -6
- package/es6/components/Anchor/stories/Weight.js +3 -6
- package/es6/components/Avatar/Avatar.js +13 -12
- package/es6/components/Avatar/stories/Basic.js +24 -21
- package/es6/components/Avatar/stories/{Themed.js → CustomThemed/Themed.js} +1 -1
- package/es6/components/Avatar/stories/Round.js +36 -33
- package/es6/components/Avatar/stories/Sizes.js +81 -78
- package/es6/components/Avatar/stories/typescript/Stacked.tsx +10 -11
- package/es6/components/Button/Button.js +1 -0
- package/es6/components/Button/StyledButton.js +3 -1
- package/es6/components/Button/StyledButtonKind.js +4 -11
- package/es6/components/Calendar/Calendar.js +114 -88
- package/es6/components/Calendar/index.d.ts +4 -0
- package/es6/components/Calendar/stories/ActiveDate.js +36 -34
- package/es6/components/Calendar/stories/CustomDay.js +70 -67
- package/es6/components/Calendar/stories/CustomHeader.js +40 -37
- package/{components/Calendar/stories/typescript → es6/components/Calendar/stories/CustomThemed}/CustomDate.tsx +1 -1
- package/es6/components/Calendar/stories/{CustomSizeHeading.js → CustomThemed/CustomSizeHeading.js} +1 -1
- package/es6/components/Calendar/stories/DaylightSavings.js +56 -53
- package/es6/components/Calendar/stories/Dual.js +87 -84
- package/es6/components/Calendar/stories/Fill.js +17 -14
- package/es6/components/Calendar/stories/Multiple.js +25 -22
- package/es6/components/Calendar/stories/Range.js +14 -11
- package/es6/components/Calendar/stories/ShowAdjacentDays.js +37 -34
- package/es6/components/Calendar/stories/Simple.js +25 -22
- package/es6/components/Calendar/stories/SundayFirstDay.js +14 -11
- package/es6/components/Calendar/utils.js +48 -4
- package/es6/components/Card/stories/{Clickable.js → CustomThemed/Clickable.js} +2 -2
- package/es6/components/Card/stories/{Stacked.js → CustomThemed/Stacked.js} +2 -2
- package/es6/components/Card/stories/{Themed.js → CustomThemed/Themed.js} +2 -2
- package/es6/components/Card/stories/Simple.js +27 -24
- package/es6/components/Carousel/Carousel.js +145 -94
- package/es6/components/Carousel/CarouselChild.js +17 -25
- package/es6/components/Carousel/StyledCarousel.js +31 -0
- package/es6/components/Carousel/index.d.ts +5 -0
- package/es6/components/Carousel/propTypes.js +13 -9
- package/es6/components/Carousel/stories/Autoplay.js +41 -0
- package/es6/components/Carousel/stories/ControlVariations.js +161 -0
- package/es6/components/Carousel/stories/Controlled.js +44 -38
- package/es6/components/Carousel/stories/{Custom.js → CustomThemed/Custom.js} +1 -1
- package/es6/components/Carousel/stories/CustomThemed/Icons.tsx +50 -0
- package/es6/components/Carousel/stories/InteractiveChild.js +61 -0
- package/es6/components/Carousel/stories/Multiple.js +8 -2
- package/es6/components/Carousel/stories/Simple.js +26 -20
- package/es6/components/Chart/Chart.js +2 -1
- package/es6/components/Clock/Clock.js +1 -1
- package/es6/components/Collapsible/stories/Horizontal.js +55 -50
- package/es6/components/Collapsible/stories/Nested.js +79 -76
- package/es6/components/Collapsible/stories/Simple.js +25 -22
- package/es6/components/DataTable/DataTable.js +1 -1
- package/es6/components/DataTable/buildState.js +2 -1
- package/es6/components/DataTable/index.d.ts +3 -3
- package/es6/components/DataTable/stories/ColumnSize.js +64 -61
- package/es6/components/DataTable/stories/Controlled.js +35 -32
- package/es6/components/DataTable/stories/ControlledGrouped.js +17 -14
- package/es6/components/DataTable/stories/{Fill.js → CustomThemed/Fill.js} +2 -2
- package/es6/components/DataTable/stories/Grouped.js +16 -13
- package/es6/components/DataTable/stories/GroupedOnSelect.js +17 -14
- package/es6/components/DataTable/stories/InfiniteScrollDataTable.js +23 -20
- package/es6/components/DataTable/stories/MultiplePin.js +49 -45
- package/es6/components/DataTable/stories/NoPrimary.js +16 -13
- package/es6/components/DataTable/stories/OnUpdate.js +25 -22
- package/es6/components/DataTable/stories/Placeholder.js +28 -25
- package/es6/components/DataTable/stories/ResizableColumns.js +18 -15
- package/es6/components/DataTable/stories/Served.js +19 -16
- package/es6/components/DataTable/stories/Show.js +27 -21
- package/es6/components/DataTable/stories/Simple.js +15 -12
- package/es6/components/DataTable/stories/Sized.js +15 -12
- package/es6/components/DataTable/stories/Sort.js +21 -18
- package/es6/components/DataTable/stories/SpaceX.js +37 -34
- package/es6/components/DataTable/stories/SpaceXUngrouped.js +27 -24
- package/es6/components/DataTable/stories/Styled.js +44 -41
- package/es6/components/DataTable/stories/Tunable.js +20 -17
- package/es6/components/DataTable/stories/Units.js +17 -14
- package/es6/components/DataTable/stories/rowDetails.js +41 -38
- package/es6/components/DataTable/stories/typescript/Clickable.tsx +30 -29
- package/es6/components/DataTable/stories/typescript/OnSelect.tsx +13 -13
- package/es6/components/DataTable/stories/typescript/Paginated.tsx +15 -15
- package/es6/components/DateInput/DateInput.js +63 -23
- package/es6/components/DateInput/stories/FormatInline.js +169 -16
- package/es6/components/DateInput/utils.js +9 -11
- package/es6/components/Drop/DropContainer.js +15 -9
- package/es6/components/Drop/stories/AllNotStretched.js +167 -164
- package/es6/components/Drop/stories/{Lazy.js → CustomThemed/Lazy.js} +1 -1
- package/es6/components/Drop/stories/{Themed.js → CustomThemed/Themed.js} +1 -1
- package/es6/components/Drop/stories/Meter.js +36 -30
- package/es6/components/Drop/stories/Multiple.js +57 -52
- package/es6/components/Drop/stories/Overflow.js +55 -50
- package/es6/components/Drop/stories/Plain.js +31 -26
- package/es6/components/Drop/stories/Progressive.js +53 -48
- package/es6/components/Drop/stories/Simple.js +29 -24
- package/es6/components/Drop/stories/Styled.js +46 -41
- package/es6/components/Drop/stories/TrapFocus.js +22 -17
- package/es6/components/DropButton/stories/Menu.js +6 -7
- package/es6/components/DropButton/stories/Simple.js +3 -6
- package/es6/components/DropButton/stories/typescript/Calendar.tsx +17 -20
- package/es6/components/FileInput/stories/CustomThemed/Custom.js +5 -7
- package/es6/components/Form/Form.js +240 -183
- package/es6/components/Form/stories/ArrayOfFormFields.js +147 -0
- package/es6/components/Form/stories/FieldWithChildren.js +4 -4
- package/es6/components/FormField/FormField.js +2 -2
- package/es6/components/Grommet/Grommet.js +8 -1
- package/es6/components/Layer/LayerContainer.js +9 -4
- package/es6/components/Menu/stories/BottomControlButton.js +3 -6
- package/es6/components/Menu/stories/{typescript → CustomThemed}/Themed.tsx +1 -1
- package/es6/components/Menu/stories/ItemWithIcon.js +3 -6
- package/es6/components/Menu/stories/Justify.js +3 -6
- package/es6/components/Menu/stories/Reverse.js +3 -6
- package/es6/components/Menu/stories/Simple.js +3 -6
- package/es6/components/Menu/stories/typescript/Children.tsx +10 -13
- package/es6/components/NameValueList/NameValueList.js +9 -6
- package/es6/components/NameValueList/stories/CustomValue.js +1 -1
- package/es6/components/NameValuePair/NameValuePair.js +1 -4
- package/es6/components/Nav/stories/Collapsable.js +40 -37
- package/es6/components/Nav/stories/{CustomAnchor.js → CustomThemed/CustomAnchor.js} +2 -2
- package/es6/components/Nav/stories/{JustifySidebar.js → CustomThemed/JustifySidebar.js} +1 -1
- package/es6/components/Nav/stories/OnHeader.js +30 -27
- package/es6/components/Nav/stories/Sidebar.js +25 -19
- package/es6/components/Nav/stories/Simple.js +16 -13
- package/es6/components/Notification/Notification.js +2 -2
- package/es6/components/Pagination/StyledPageControl.js +1 -1
- package/es6/components/RadioButtonGroup/RadioButtonGroup.js +3 -1
- package/es6/components/Select/Select.js +1 -0
- package/es6/components/Stack/stories/Fill.js +16 -11
- package/es6/components/Stack/stories/Simple.js +16 -10
- package/es6/components/Tabs/Tabs.js +23 -20
- package/es6/components/Tabs/stories/{AlignControls.js → CustomThemed/AlignControls.js} +1 -1
- package/es6/components/Tabs/stories/{Custom.js → CustomThemed/Custom.js} +3 -3
- package/es6/components/Tabs/stories/{Icon.js → CustomThemed/Icon.js} +1 -1
- package/es6/components/Tabs/stories/{States.js → CustomThemed/States.js} +1 -1
- package/es6/components/Tabs/stories/Plain.js +45 -40
- package/es6/components/Tabs/stories/Responsive.js +191 -188
- package/es6/components/Tabs/stories/Rich.js +30 -27
- package/es6/components/Tabs/stories/Scrollable.js +32 -27
- package/es6/components/Tabs/stories/Uncontrolled.js +45 -40
- package/es6/components/Tabs/stories/typescript/Controlled.tsx +21 -21
- package/es6/components/Tag/README.md +2 -0
- package/es6/components/Tag/StyledTag.js +22 -0
- package/es6/components/Tag/Tag.js +66 -0
- package/es6/components/Tag/index.d.ts +27 -0
- package/es6/components/Tag/index.js +1 -0
- package/es6/components/Tag/propTypes.js +17 -0
- package/es6/components/Tag/stories/OnClick.js +22 -0
- package/es6/components/Tag/stories/OnRemove.js +26 -0
- package/es6/components/Tag/stories/Simple.js +20 -0
- package/es6/components/Text/Text.js +23 -10
- package/es6/components/TextInput/TextInput.js +14 -2
- package/es6/components/TextInput/index.d.ts +6 -1
- package/es6/components/Video/Video.js +99 -39
- package/es6/components/Video/index.d.ts +15 -2
- package/es6/components/Video/propTypes.js +8 -1
- package/es6/components/Video/stories/typescript/TheaterMode.tsx +46 -0
- package/es6/components/index.d.ts +1 -0
- package/es6/components/index.js +1 -0
- package/es6/contexts/MessageContext/MessageContext.js +2 -1
- package/es6/index.d.ts +1 -0
- package/es6/languages/default.json +9 -2
- package/es6/themes/base.d.ts +25 -11
- package/es6/themes/base.js +21 -2
- package/es6/utils/DOM.js +13 -3
- package/es6/utils/background.js +2 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +1 -0
- package/languages/default.json +9 -2
- package/package.json +53 -52
- package/themes/base.d.ts +25 -11
- package/themes/base.js +22 -3
- package/themes/index.js +1 -1
- package/utils/DOM.js +20 -4
- package/utils/animation.js +1 -1
- package/utils/background.js +3 -2
- package/utils/border.js +1 -1
- package/utils/colors.js +1 -1
- package/utils/general-prop-types.js +1 -1
- package/utils/graphics.js +1 -1
- package/utils/mixins.js +1 -1
- package/utils/object.js +1 -1
- package/utils/responsive.js +1 -1
- package/utils/styles.js +1 -1
- package/utils/use-isomorphic-layout-effect.js +1 -1
- package/components/Carousel/stories/InitialChild.js +0 -43
- package/components/Carousel/stories/WithClickableChild.js +0 -51
- package/components/Carousel/stories/WithoutControls.js +0 -44
- package/es6/components/Carousel/stories/InitialChild.js +0 -32
- package/es6/components/Carousel/stories/WithClickableChild.js +0 -40
- package/es6/components/Carousel/stories/WithoutControls.js +0 -33
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Box, Card, CardBody, CardFooter, CardHeader, Text } from 'grommet';
|
|
3
3
|
export var Simple = function Simple() {
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
4
|
+
return (
|
|
5
|
+
/*#__PURE__*/
|
|
6
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
7
|
+
// <Grommet theme={...}>
|
|
8
|
+
React.createElement(Box, {
|
|
9
|
+
pad: "large",
|
|
10
|
+
gap: "medium",
|
|
11
|
+
width: "medium"
|
|
12
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
13
|
+
pad: "small",
|
|
14
|
+
background: "dark-1",
|
|
15
|
+
gap: "medium"
|
|
16
|
+
}, /*#__PURE__*/React.createElement(CardHeader, null, "header"), /*#__PURE__*/React.createElement(CardBody, null, "body"), /*#__PURE__*/React.createElement(CardFooter, null, "footer")), /*#__PURE__*/React.createElement(Card, {
|
|
17
|
+
pad: "small",
|
|
18
|
+
gap: "medium",
|
|
19
|
+
background: "light-4"
|
|
20
|
+
}, /*#__PURE__*/React.createElement(CardBody, null, "body"), /*#__PURE__*/React.createElement(Box, null, "box - random component")), /*#__PURE__*/React.createElement(Card, {
|
|
21
|
+
pad: "small",
|
|
22
|
+
gap: "medium"
|
|
23
|
+
}, /*#__PURE__*/React.createElement(CardBody, null, "body"), /*#__PURE__*/React.createElement(CardHeader, null, "header"), /*#__PURE__*/React.createElement(CardFooter, null, "footer")), /*#__PURE__*/React.createElement(Card, {
|
|
24
|
+
pad: "small",
|
|
25
|
+
gap: "medium",
|
|
26
|
+
background: "light-1"
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Text, null, "text - random component"), /*#__PURE__*/React.createElement(Box, null, "box - random component"))) // </Grommet>
|
|
28
|
+
|
|
29
|
+
);
|
|
27
30
|
};
|
|
28
31
|
export default {
|
|
29
32
|
title: 'Layout/Card/Simple'
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
var _excluded = ["activeChild", "initialChild", "onChild", "play", "children", "controls", "fill", "onFocus", "onBlur"];
|
|
1
|
+
var _excluded = ["activeChild", "initialChild", "onChild", "play", "children", "controls", "height", "fill", "width", "onFocus", "onBlur", "wrap"];
|
|
2
2
|
|
|
3
3
|
function _extends() { _extends = Object.assign || 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); }
|
|
4
4
|
|
|
5
5
|
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; }
|
|
6
6
|
|
|
7
|
-
import React, { Children, useCallback, useContext, useEffect, useState, useRef } from 'react';
|
|
7
|
+
import React, { Children, useCallback, useContext, useEffect, useMemo, useState, useRef } from 'react';
|
|
8
8
|
import { normalizeColor } from '../../utils';
|
|
9
9
|
import { defaultProps } from '../../default-props';
|
|
10
10
|
import { ThemeContext } from '../../contexts';
|
|
11
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
11
12
|
import { Box } from '../Box';
|
|
12
13
|
import { Button } from '../Button';
|
|
13
14
|
import { Keyboard } from '../Keyboard';
|
|
14
|
-
import {
|
|
15
|
+
import { StyledCarouselContainer, StyledControl } from './StyledCarousel';
|
|
15
16
|
import { CarouselChild } from './CarouselChild';
|
|
16
17
|
import { CarouselPropTypes } from './propTypes';
|
|
17
18
|
|
|
@@ -22,108 +23,144 @@ var Carousel = function Carousel(_ref) {
|
|
|
22
23
|
play = _ref.play,
|
|
23
24
|
children = _ref.children,
|
|
24
25
|
controls = _ref.controls,
|
|
26
|
+
height = _ref.height,
|
|
25
27
|
fill = _ref.fill,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
width = _ref.width,
|
|
29
|
+
onFocus = _ref.onFocus,
|
|
30
|
+
onBlur = _ref.onBlur,
|
|
31
|
+
wrap = _ref.wrap,
|
|
28
32
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
29
33
|
|
|
30
34
|
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
31
35
|
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
setFocus = _useState[1];
|
|
36
|
+
var _useContext = useContext(MessageContext),
|
|
37
|
+
format = _useContext.format;
|
|
35
38
|
|
|
36
39
|
var timerRef = useRef();
|
|
40
|
+
var animationDuration = useMemo(function () {
|
|
41
|
+
return play && play < theme.carousel.animation.duration ? play : theme.carousel.animation.duration;
|
|
42
|
+
}, [play, theme.carousel.animation.duration]);
|
|
37
43
|
|
|
38
|
-
var
|
|
44
|
+
var _useState = useState({
|
|
39
45
|
activeIndex: activeChild !== undefined ? activeChild : initialChild
|
|
40
46
|
}),
|
|
41
|
-
indexes =
|
|
42
|
-
setIndexes =
|
|
47
|
+
indexes = _useState[0],
|
|
48
|
+
setIndexes = _useState[1];
|
|
49
|
+
|
|
50
|
+
var _useState2 = useState(activeChild),
|
|
51
|
+
activeChildState = _useState2[0],
|
|
52
|
+
setActiveChildState = _useState2[1];
|
|
53
|
+
|
|
54
|
+
var _useState3 = useState(),
|
|
55
|
+
direction = _useState3[0],
|
|
56
|
+
setDirection = _useState3[1];
|
|
57
|
+
|
|
58
|
+
var _useState4 = useState(false),
|
|
59
|
+
inTransition = _useState4[0],
|
|
60
|
+
setInTransition = _useState4[1];
|
|
43
61
|
|
|
44
62
|
var activeIndex = indexes.activeIndex,
|
|
45
63
|
priorActiveIndex = indexes.priorActiveIndex;
|
|
46
64
|
var lastIndex = Children.count(children) - 1;
|
|
47
|
-
|
|
48
|
-
if (activeIndex !== activeChild && activeChild !== undefined) {
|
|
49
|
-
if (activeChild >= 0 && activeChild <= lastIndex) {
|
|
50
|
-
setIndexes({
|
|
51
|
-
activeIndex: activeChild,
|
|
52
|
-
priorActiveIndex: activeIndex
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
65
|
var onChildChange = useCallback(function (index) {
|
|
58
66
|
if (onChild) {
|
|
59
67
|
onChild(index);
|
|
60
68
|
}
|
|
61
69
|
}, [onChild]);
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
var timer = setInterval(function () {
|
|
65
|
-
if (activeIndex < lastIndex) {
|
|
66
|
-
setIndexes({
|
|
67
|
-
activeIndex: activeIndex + 1,
|
|
68
|
-
priorActiveIndex: activeIndex
|
|
69
|
-
});
|
|
70
|
-
onChildChange(activeIndex + 1);
|
|
71
|
-
} else {
|
|
72
|
-
setIndexes({
|
|
73
|
-
activeIndex: 0,
|
|
74
|
-
priorActiveIndex: activeIndex
|
|
75
|
-
});
|
|
76
|
-
onChildChange(0);
|
|
77
|
-
}
|
|
78
|
-
}, play);
|
|
79
|
-
timerRef.current = timer;
|
|
80
|
-
return function () {
|
|
81
|
-
clearTimeout(timer);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return function () {};
|
|
86
|
-
}, [activeIndex, play, children, lastIndex, onChildChange]);
|
|
87
|
-
|
|
88
|
-
var onRight = function onRight() {
|
|
89
|
-
if (activeIndex >= lastIndex) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
70
|
+
var onRight = useCallback(function () {
|
|
71
|
+
if (inTransition) return;
|
|
93
72
|
clearInterval(timerRef.current);
|
|
73
|
+
var nextActiveIndex = activeIndex < lastIndex ? activeIndex + 1 : 0;
|
|
94
74
|
setIndexes({
|
|
95
|
-
activeIndex:
|
|
75
|
+
activeIndex: nextActiveIndex,
|
|
96
76
|
priorActiveIndex: activeIndex
|
|
97
77
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
78
|
+
setInTransition(true);
|
|
79
|
+
setDirection('left');
|
|
80
|
+
onChildChange(nextActiveIndex);
|
|
81
|
+
}, [activeIndex, inTransition, lastIndex, onChildChange]);
|
|
82
|
+
var onLeft = useCallback(function () {
|
|
83
|
+
if (inTransition) return;
|
|
106
84
|
clearInterval(timerRef.current);
|
|
85
|
+
var nextActiveIndex = activeIndex === 0 ? lastIndex : activeIndex - 1;
|
|
107
86
|
setIndexes({
|
|
108
|
-
activeIndex:
|
|
87
|
+
activeIndex: nextActiveIndex,
|
|
109
88
|
priorActiveIndex: activeIndex
|
|
110
89
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
90
|
+
setInTransition(true);
|
|
91
|
+
setDirection('right');
|
|
92
|
+
onChildChange(nextActiveIndex);
|
|
93
|
+
}, [activeIndex, inTransition, lastIndex, onChildChange]);
|
|
94
|
+
var onSelect = useCallback(function (index) {
|
|
115
95
|
return function () {
|
|
116
|
-
if (activeIndex !== index) {
|
|
96
|
+
if (!inTransition && activeIndex !== index) {
|
|
117
97
|
clearInterval(timerRef.current);
|
|
118
98
|
setIndexes({
|
|
119
99
|
activeIndex: index,
|
|
120
100
|
priorActiveIndex: activeIndex
|
|
121
101
|
});
|
|
102
|
+
setInTransition(true);
|
|
103
|
+
setDirection(index > activeIndex ? 'left' : 'right');
|
|
122
104
|
onChildChange(index);
|
|
123
105
|
}
|
|
124
106
|
};
|
|
125
|
-
};
|
|
107
|
+
}, [activeIndex, inTransition, onChildChange]);
|
|
108
|
+
var onControlledNavigation = useCallback(function () {
|
|
109
|
+
if (inTransition || activeChild === activeChildState || activeChild === activeIndex || activeChild === undefined || activeChild < 0 || activeChild > lastIndex) return;
|
|
110
|
+
setDirection(activeChild > activeIndex ? 'left' : 'right');
|
|
111
|
+
setInTransition(true);
|
|
112
|
+
setIndexes({
|
|
113
|
+
activeIndex: activeChild,
|
|
114
|
+
priorActiveIndex: activeIndex
|
|
115
|
+
});
|
|
116
|
+
setActiveChildState(activeChild);
|
|
117
|
+
onChildChange(activeChild);
|
|
118
|
+
}, [activeChild, activeChildState, activeIndex, inTransition, lastIndex, onChildChange]);
|
|
119
|
+
/**
|
|
120
|
+
* Delays the transitions between Carousel slides. This is needed to
|
|
121
|
+
* avoid users "spamming" the controls which results in jarring animations
|
|
122
|
+
* and a bad user experience.
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
useEffect(function () {
|
|
126
|
+
var transitionTimer;
|
|
127
|
+
|
|
128
|
+
if (inTransition) {
|
|
129
|
+
transitionTimer = setTimeout(function () {
|
|
130
|
+
setInTransition(false);
|
|
131
|
+
}, animationDuration);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return function () {
|
|
135
|
+
return clearTimeout(transitionTimer);
|
|
136
|
+
};
|
|
137
|
+
}, [inTransition, setInTransition, animationDuration]); // Handles auto-playing Carousel slides
|
|
138
|
+
|
|
139
|
+
useEffect(function () {
|
|
140
|
+
// stop playing if wrap is explicitly false and we're at the end
|
|
141
|
+
if (play && (wrap !== false || activeIndex < lastIndex)) {
|
|
142
|
+
var timer = setInterval(function () {
|
|
143
|
+
var nextActiveIndex = activeIndex < lastIndex ? activeIndex + 1 : 0;
|
|
144
|
+
setIndexes({
|
|
145
|
+
activeIndex: nextActiveIndex,
|
|
146
|
+
priorActiveIndex: activeIndex
|
|
147
|
+
});
|
|
148
|
+
setInTransition(true);
|
|
149
|
+
setDirection('left');
|
|
150
|
+
onChildChange(nextActiveIndex);
|
|
151
|
+
}, play);
|
|
152
|
+
timerRef.current = timer;
|
|
153
|
+
return function () {
|
|
154
|
+
clearTimeout(timer);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
126
157
|
|
|
158
|
+
return function () {};
|
|
159
|
+
}, [activeIndex, play, children, lastIndex, onChildChange, wrap]); // Allow Carousel slides to be controlled outside the component
|
|
160
|
+
|
|
161
|
+
useEffect(function () {
|
|
162
|
+
onControlledNavigation(activeIndex, activeChild, activeChildState, inTransition);
|
|
163
|
+
}, [onControlledNavigation, activeIndex, activeChild, activeChildState, inTransition]);
|
|
127
164
|
var showArrows = controls && controls !== 'selectors';
|
|
128
165
|
var showSelectors = controls && controls !== 'arrows';
|
|
129
166
|
var CurrentIcon = theme.carousel.icons.current;
|
|
@@ -131,7 +168,12 @@ var Carousel = function Carousel(_ref) {
|
|
|
131
168
|
var selectors = [];
|
|
132
169
|
var wrappedChildren = Children.map(children, function (child, index) {
|
|
133
170
|
selectors.push( /*#__PURE__*/React.createElement(Button, {
|
|
134
|
-
a11yTitle:
|
|
171
|
+
a11yTitle: format({
|
|
172
|
+
id: 'carousel.jump',
|
|
173
|
+
values: {
|
|
174
|
+
slide: index + 1
|
|
175
|
+
}
|
|
176
|
+
}) // eslint-disable-next-line react/no-array-index-key
|
|
135
177
|
,
|
|
136
178
|
key: index,
|
|
137
179
|
icon: /*#__PURE__*/React.createElement(CurrentIcon, {
|
|
@@ -140,57 +182,66 @@ var Carousel = function Carousel(_ref) {
|
|
|
140
182
|
onClick: onSelect(index)
|
|
141
183
|
}));
|
|
142
184
|
return /*#__PURE__*/React.createElement(CarouselChild, {
|
|
143
|
-
|
|
144
|
-
|
|
185
|
+
animationDuration: animationDuration,
|
|
186
|
+
fill: fill || !!height || !!width,
|
|
145
187
|
index: index,
|
|
146
188
|
activeIndex: activeIndex,
|
|
147
|
-
priorActiveIndex: priorActiveIndex
|
|
189
|
+
priorActiveIndex: priorActiveIndex,
|
|
190
|
+
direction: direction
|
|
148
191
|
}, child);
|
|
149
192
|
});
|
|
150
193
|
var NextIcon = theme.carousel.icons.next;
|
|
151
194
|
var PreviousIcon = theme.carousel.icons.previous;
|
|
152
|
-
var nextIconDisabled = activeIndex >= lastIndex;
|
|
153
|
-
var previousIconDisabled = activeIndex <= 0;
|
|
195
|
+
var nextIconDisabled = !wrap && activeIndex >= lastIndex;
|
|
196
|
+
var previousIconDisabled = !wrap && activeIndex <= 0;
|
|
154
197
|
return /*#__PURE__*/React.createElement(Keyboard, {
|
|
155
198
|
onLeft: onLeft,
|
|
156
199
|
onRight: onRight
|
|
157
|
-
}, /*#__PURE__*/React.createElement(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (_onFocus) _onFocus(event);
|
|
166
|
-
},
|
|
167
|
-
onBlur: function onBlur(event) {
|
|
168
|
-
setFocus(false);
|
|
169
|
-
if (_onBlur) _onBlur(event);
|
|
170
|
-
},
|
|
171
|
-
fill: true,
|
|
172
|
-
direction: "row",
|
|
173
|
-
justify: "between"
|
|
174
|
-
}, showArrows && /*#__PURE__*/React.createElement(Button, {
|
|
200
|
+
}, /*#__PURE__*/React.createElement(StyledCarouselContainer, _extends({
|
|
201
|
+
fill: fill,
|
|
202
|
+
height: height,
|
|
203
|
+
width: width
|
|
204
|
+
}, rest), showArrows && /*#__PURE__*/React.createElement(StyledControl, {
|
|
205
|
+
offsetProp: "left",
|
|
206
|
+
fill: "vertical"
|
|
207
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
175
208
|
fill: "vertical",
|
|
176
209
|
icon: /*#__PURE__*/React.createElement(PreviousIcon, {
|
|
177
210
|
color: normalizeColor(previousIconDisabled ? theme.carousel.disabled.icons.color : theme.carousel.icons.color, theme)
|
|
178
211
|
}),
|
|
212
|
+
a11yTitle: format({
|
|
213
|
+
id: 'carousel.previous',
|
|
214
|
+
values: {
|
|
215
|
+
slide: activeIndex
|
|
216
|
+
}
|
|
217
|
+
}),
|
|
179
218
|
plain: true,
|
|
180
219
|
disabled: previousIconDisabled,
|
|
181
220
|
onClick: onLeft,
|
|
182
221
|
hoverIndicator: true
|
|
183
|
-
}), showSelectors && /*#__PURE__*/React.createElement(
|
|
222
|
+
})), wrappedChildren, showSelectors && /*#__PURE__*/React.createElement(StyledControl, {
|
|
223
|
+
offsetProp: "bottom",
|
|
224
|
+
fill: "horizontal"
|
|
225
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
184
226
|
justify: "end",
|
|
185
227
|
fill: !showArrows && 'horizontal'
|
|
186
228
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
187
229
|
direction: "row",
|
|
188
230
|
justify: "center"
|
|
189
|
-
}, selectors)), showArrows && /*#__PURE__*/React.createElement(
|
|
231
|
+
}, selectors))), showArrows && /*#__PURE__*/React.createElement(StyledControl, {
|
|
232
|
+
offsetProp: "right",
|
|
233
|
+
fill: "vertical"
|
|
234
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
190
235
|
fill: "vertical",
|
|
191
236
|
icon: /*#__PURE__*/React.createElement(NextIcon, {
|
|
192
237
|
color: normalizeColor(nextIconDisabled ? theme.carousel.disabled.icons.color : theme.carousel.icons.color, theme)
|
|
193
238
|
}),
|
|
239
|
+
a11yTitle: format({
|
|
240
|
+
id: 'carousel.next',
|
|
241
|
+
values: {
|
|
242
|
+
slide: activeIndex + 2
|
|
243
|
+
}
|
|
244
|
+
}),
|
|
194
245
|
plain: true,
|
|
195
246
|
disabled: nextIconDisabled,
|
|
196
247
|
onClick: onRight,
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { CarouselChildPropTypes } from './propTypes';
|
|
3
|
+
import { StyledCarouselChild } from './StyledCarousel';
|
|
3
4
|
import { Box } from '../Box';
|
|
4
|
-
import { ThemeContext } from '../../contexts';
|
|
5
|
-
import { defaultProps } from '../../default-props';
|
|
6
5
|
|
|
7
6
|
var CarouselChild = function CarouselChild(_ref) {
|
|
8
|
-
var
|
|
9
|
-
|
|
7
|
+
var animationDuration = _ref.animationDuration,
|
|
8
|
+
fill = _ref.fill,
|
|
10
9
|
index = _ref.index,
|
|
11
10
|
activeIndex = _ref.activeIndex,
|
|
12
11
|
priorActiveIndex = _ref.priorActiveIndex,
|
|
12
|
+
direction = _ref.direction,
|
|
13
13
|
children = _ref.children;
|
|
14
|
-
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
15
14
|
|
|
16
15
|
var _useState = useState(undefined),
|
|
17
16
|
animation = _useState[0],
|
|
18
17
|
setAnimation = _useState[1];
|
|
19
18
|
|
|
20
|
-
var _useState2 = useState('hidden'),
|
|
19
|
+
var _useState2 = useState(index === activeIndex ? 'visible' : 'hidden'),
|
|
21
20
|
visibility = _useState2[0],
|
|
22
21
|
setVisibility = _useState2[1];
|
|
23
22
|
|
|
@@ -30,37 +29,30 @@ var CarouselChild = function CarouselChild(_ref) {
|
|
|
30
29
|
* This check will only be false onMount of the component. It ensures
|
|
31
30
|
* the initial active slide of the Carousel renders with no animation.
|
|
32
31
|
*/
|
|
33
|
-
setAnimation(
|
|
34
|
-
type: play || priorActiveIndex < activeIndex ? 'slideLeft' : 'slideRight',
|
|
35
|
-
size: 'xlarge',
|
|
36
|
-
duration: theme.carousel.animation.duration
|
|
37
|
-
});
|
|
32
|
+
setAnimation(direction === 'left' ? 'slideLeftCurrent' : 'slideRightCurrent');
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
setVisibility('visible');
|
|
41
36
|
} else if (index === priorActiveIndex) {
|
|
42
|
-
setAnimation(
|
|
43
|
-
type: 'fadeOut',
|
|
44
|
-
duration: theme.carousel.animation.duration
|
|
45
|
-
});
|
|
37
|
+
setAnimation(direction === 'left' ? 'slideLeftPrevious' : 'slideRightPrevious');
|
|
46
38
|
timer = setTimeout(function () {
|
|
47
39
|
return setVisibility('hidden');
|
|
48
|
-
},
|
|
40
|
+
}, animationDuration);
|
|
49
41
|
}
|
|
50
42
|
|
|
51
43
|
return function () {
|
|
52
44
|
return clearTimeout(timer);
|
|
53
45
|
};
|
|
54
|
-
}, [activeIndex, priorActiveIndex, index,
|
|
55
|
-
|
|
46
|
+
}, [activeIndex, priorActiveIndex, index, direction, animationDuration]);
|
|
47
|
+
var position = index === 0 ? 'relative' : 'absolute';
|
|
48
|
+
return /*#__PURE__*/React.createElement(StyledCarouselChild, {
|
|
56
49
|
fill: fill,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
visibilityProp: visibility,
|
|
51
|
+
positionProp: position,
|
|
52
|
+
animationType: animation,
|
|
53
|
+
animationDuration: animationDuration
|
|
61
54
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
62
|
-
fill: fill
|
|
63
|
-
animation: animation
|
|
55
|
+
fill: fill
|
|
64
56
|
}, children));
|
|
65
57
|
};
|
|
66
58
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import styled, { css, keyframes } from 'styled-components';
|
|
2
|
+
import { Box } from '../Box';
|
|
3
|
+
var StyledCarouselContainer = styled(Box).withConfig({
|
|
4
|
+
displayName: "StyledCarousel__StyledCarouselContainer",
|
|
5
|
+
componentId: "sc-c2hjel-0"
|
|
6
|
+
})(["position:relative;overflow:hidden;"]);
|
|
7
|
+
var animationKeyframes = {
|
|
8
|
+
// Slide Right = Previous or Backward
|
|
9
|
+
slideRightPrevious: keyframes(["0%{transform:translateX(0%)}100%{transform:translateX(100%)}"]),
|
|
10
|
+
slideRightCurrent: keyframes(["0%{transform:translateX(-100%)}100%{transform:translateX(0%)}"]),
|
|
11
|
+
// Slide Left = Next or Forward
|
|
12
|
+
slideLeftPrevious: keyframes(["0%{transform:translateX(0%)}100%{transform:translateX(-100%)}"]),
|
|
13
|
+
slideLeftCurrent: keyframes(["0%{transform:translateX(100%)}100%{transform:translateX(0%)}"])
|
|
14
|
+
};
|
|
15
|
+
var StyledCarouselChild = styled(Box).withConfig({
|
|
16
|
+
displayName: "StyledCarousel__StyledCarouselChild",
|
|
17
|
+
componentId: "sc-c2hjel-1"
|
|
18
|
+
})(["visibility:", ";position:", ";width:100%;height:100%;overflow:hidden;", ";animation-fill-mode:both;"], function (props) {
|
|
19
|
+
return props.visibilityProp;
|
|
20
|
+
}, function (props) {
|
|
21
|
+
return props.positionProp;
|
|
22
|
+
}, function (props) {
|
|
23
|
+
return props.animationType ? css(["animation:", " ", "s ease-in-out;"], animationKeyframes[props.animationType], props.animationDuration / 1000) : "";
|
|
24
|
+
});
|
|
25
|
+
var StyledControl = styled(Box).withConfig({
|
|
26
|
+
displayName: "StyledCarousel__StyledControl",
|
|
27
|
+
componentId: "sc-c2hjel-2"
|
|
28
|
+
})(["position:absolute;z-index:1;", " align-items:center;justify-content:center;"], function (props) {
|
|
29
|
+
return props.offsetProp + ": 0;";
|
|
30
|
+
});
|
|
31
|
+
export { StyledCarouselContainer, StyledCarouselChild, StyledControl };
|
|
@@ -3,19 +3,24 @@ import {
|
|
|
3
3
|
A11yTitleType,
|
|
4
4
|
AlignSelfType,
|
|
5
5
|
GridAreaType,
|
|
6
|
+
HeightType,
|
|
6
7
|
MarginType,
|
|
8
|
+
WidthType,
|
|
7
9
|
} from '../../utils';
|
|
8
10
|
|
|
9
11
|
export interface CarouselProps {
|
|
10
12
|
a11yTitle?: A11yTitleType;
|
|
11
13
|
activeChild?: number;
|
|
12
14
|
alignSelf?: AlignSelfType;
|
|
15
|
+
wrap?: boolean;
|
|
13
16
|
controls?: boolean | 'arrows' | 'selectors';
|
|
14
17
|
gridArea?: GridAreaType;
|
|
15
18
|
margin?: MarginType;
|
|
16
19
|
fill?: boolean;
|
|
17
20
|
play?: number;
|
|
18
21
|
initialChild?: number;
|
|
22
|
+
height?: HeightType;
|
|
23
|
+
width?: WidthType;
|
|
19
24
|
onChild?: (...args: any[]) => void;
|
|
20
25
|
}
|
|
21
26
|
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || 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
2
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { genericProps } from '../../utils/general-prop-types';
|
|
5
|
-
var
|
|
4
|
+
import { genericProps, widthPropType, heightPropType } from '../../utils/general-prop-types';
|
|
5
|
+
var CarouselPropType;
|
|
6
6
|
|
|
7
7
|
if (process.env.NODE_ENV !== 'production') {
|
|
8
|
-
|
|
8
|
+
CarouselPropType = _extends({}, genericProps, {
|
|
9
9
|
activeChild: PropTypes.number,
|
|
10
|
-
fill: PropTypes.bool,
|
|
11
|
-
play: PropTypes.number,
|
|
12
10
|
initialChild: PropTypes.number,
|
|
11
|
+
fill: PropTypes.bool,
|
|
12
|
+
wrap: PropTypes.bool,
|
|
13
|
+
controls: PropTypes.oneOfType([PropTypes.oneOf(['arrows', 'selectors']), PropTypes.bool]),
|
|
13
14
|
onChild: PropTypes.func,
|
|
14
|
-
|
|
15
|
+
width: widthPropType,
|
|
16
|
+
height: heightPropType,
|
|
17
|
+
play: PropTypes.number
|
|
15
18
|
});
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
export var CarouselPropTypes =
|
|
21
|
+
export var CarouselPropTypes = CarouselPropType;
|
|
19
22
|
var CarouselChildPropType;
|
|
20
23
|
|
|
21
24
|
if (process.env.NODE_ENV !== 'production') {
|
|
22
25
|
CarouselChildPropType = {
|
|
26
|
+
animationDuration: PropTypes.number.isRequired,
|
|
23
27
|
fill: PropTypes.bool,
|
|
24
|
-
play: PropTypes.number,
|
|
25
28
|
index: PropTypes.number.isRequired,
|
|
26
29
|
activeIndex: PropTypes.number.isRequired,
|
|
27
|
-
priorActiveIndex: PropTypes.number
|
|
30
|
+
priorActiveIndex: PropTypes.number,
|
|
31
|
+
direction: PropTypes.oneOf(['left', 'right'])
|
|
28
32
|
};
|
|
29
33
|
}
|
|
30
34
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Attraction } from "grommet-icons/es6/icons/Attraction";
|
|
3
|
+
import { Car } from "grommet-icons/es6/icons/Car";
|
|
4
|
+
import { TreeOption } from "grommet-icons/es6/icons/TreeOption";
|
|
5
|
+
import { Box, Carousel, Text } from 'grommet';
|
|
6
|
+
export var Autoplay = function Autoplay() {
|
|
7
|
+
return (
|
|
8
|
+
/*#__PURE__*/
|
|
9
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
10
|
+
// <Grommet theme={grommet}>
|
|
11
|
+
React.createElement(Box, {
|
|
12
|
+
gap: "medium",
|
|
13
|
+
align: "center",
|
|
14
|
+
pad: "large"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
16
|
+
size: "small"
|
|
17
|
+
}, "The Carousel slides will transition every 3 seconds"), /*#__PURE__*/React.createElement(Carousel, {
|
|
18
|
+
controls: false,
|
|
19
|
+
play: 3000
|
|
20
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
21
|
+
pad: "xlarge",
|
|
22
|
+
background: "accent-1"
|
|
23
|
+
}, /*#__PURE__*/React.createElement(Attraction, {
|
|
24
|
+
size: "xlarge"
|
|
25
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
26
|
+
pad: "xlarge",
|
|
27
|
+
background: "accent-2"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(TreeOption, {
|
|
29
|
+
size: "xlarge"
|
|
30
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
31
|
+
pad: "xlarge",
|
|
32
|
+
background: "accent-3"
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Car, {
|
|
34
|
+
size: "xlarge"
|
|
35
|
+
})))) // </Grommet>
|
|
36
|
+
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
export default {
|
|
40
|
+
title: 'Media/Carousel/Autoplay'
|
|
41
|
+
};
|