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,16 +1,17 @@
|
|
|
1
|
-
var _excluded = ["buttonProps", "calendarProps", "defaultValue", "disabled", "dropProps", "format", "id", "inline", "inputProps", "name", "onChange", "onFocus", "value", "messages"];
|
|
1
|
+
var _excluded = ["buttonProps", "calendarProps", "defaultValue", "disabled", "dropProps", "format", "id", "inline", "inputProps", "name", "onChange", "onFocus", "plain", "value", "messages"];
|
|
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, { forwardRef, useContext, useEffect, useMemo, useState, useCallback } from 'react';
|
|
7
|
+
import React, { useRef, forwardRef, useContext, useEffect, useMemo, useState, useCallback } from 'react';
|
|
8
8
|
import { ThemeContext } from 'styled-components';
|
|
9
9
|
import { Calendar as CalendarIcon } from 'grommet-icons/icons/Calendar';
|
|
10
10
|
import { defaultProps } from '../../default-props';
|
|
11
11
|
import { AnnounceContext } from '../../contexts/AnnounceContext';
|
|
12
12
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
13
13
|
import { Box } from '../Box';
|
|
14
|
+
import { Button } from '../Button';
|
|
14
15
|
import { Calendar } from '../Calendar';
|
|
15
16
|
import { Drop } from '../Drop';
|
|
16
17
|
import { DropButton } from '../DropButton';
|
|
@@ -18,6 +19,7 @@ import { FormContext } from '../Form';
|
|
|
18
19
|
import { Keyboard } from '../Keyboard';
|
|
19
20
|
import { MaskedInput } from '../MaskedInput';
|
|
20
21
|
import { useForwardedRef } from '../../utils';
|
|
22
|
+
import { getTimestamp, normalizeForTimezone } from '../Calendar/utils';
|
|
21
23
|
import { formatToSchema, schemaToMask, valuesAreEqual, valueToText, textToValue } from './utils';
|
|
22
24
|
import { DateInputPropTypes } from './propTypes';
|
|
23
25
|
var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
@@ -34,6 +36,7 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
34
36
|
name = _ref.name,
|
|
35
37
|
_onChange = _ref.onChange,
|
|
36
38
|
_onFocus = _ref.onFocus,
|
|
39
|
+
plain = _ref.plain,
|
|
37
40
|
valueArg = _ref.value,
|
|
38
41
|
messages = _ref.messages,
|
|
39
42
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -50,6 +53,7 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
50
53
|
useFormInput = _useContext2.useFormInput;
|
|
51
54
|
|
|
52
55
|
var ref = useForwardedRef(refArg);
|
|
56
|
+
var containerRef = useRef();
|
|
53
57
|
|
|
54
58
|
var _useFormInput = useFormInput({
|
|
55
59
|
name: name,
|
|
@@ -57,8 +61,23 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
57
61
|
initialValue: defaultValue
|
|
58
62
|
}),
|
|
59
63
|
value = _useFormInput[0],
|
|
60
|
-
setValue = _useFormInput[1];
|
|
64
|
+
setValue = _useFormInput[1];
|
|
61
65
|
|
|
66
|
+
var timestamp;
|
|
67
|
+
|
|
68
|
+
if (Array.isArray(defaultValue) && defaultValue.length) {
|
|
69
|
+
timestamp = getTimestamp(defaultValue[0]);
|
|
70
|
+
} else if (typeof defaultValue === 'string') {
|
|
71
|
+
timestamp = getTimestamp(defaultValue);
|
|
72
|
+
} else if (Array.isArray(value) && value.length) {
|
|
73
|
+
timestamp = getTimestamp(value[0]); // check to see if value is not an empty string
|
|
74
|
+
// empty string should behave like undefined
|
|
75
|
+
} else if (typeof value === 'string' && value.length) {
|
|
76
|
+
timestamp = getTimestamp(value);
|
|
77
|
+
} // normalize value based on timestamp vs user's local timezone
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
var normalizedDate = normalizeForTimezone(value, timestamp); // do we expect multiple dates?
|
|
62
81
|
|
|
63
82
|
var range = Array.isArray(value) || format && format.includes('-'); // parse format and build a formal schema we can use elsewhere
|
|
64
83
|
|
|
@@ -70,7 +89,7 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
70
89
|
return schemaToMask(schema);
|
|
71
90
|
}, [schema]); // textValue is only used when a format is provided
|
|
72
91
|
|
|
73
|
-
var _useState = useState(schema ? valueToText(
|
|
92
|
+
var _useState = useState(schema ? valueToText(normalizedDate, schema) : undefined),
|
|
74
93
|
textValue = _useState[0],
|
|
75
94
|
setTextValue = _useState[1]; // We need to distinguish between the caller changing a Form value
|
|
76
95
|
// and the user typing a date that he isn't finished with yet.
|
|
@@ -82,13 +101,13 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
82
101
|
|
|
83
102
|
useEffect(function () {
|
|
84
103
|
if (schema && value !== undefined) {
|
|
85
|
-
var nextTextValue = valueToText(
|
|
104
|
+
var nextTextValue = valueToText(normalizedDate, schema);
|
|
86
105
|
|
|
87
|
-
if (!valuesAreEqual(textToValue(textValue, schema,
|
|
106
|
+
if (!valuesAreEqual(textToValue(textValue, schema, range, timestamp), textToValue(nextTextValue, schema, range, timestamp)) || textValue === '' && nextTextValue !== '') {
|
|
88
107
|
setTextValue(nextTextValue);
|
|
89
108
|
}
|
|
90
109
|
}
|
|
91
|
-
}, [range, schema, textValue, value]); // when format and not inline, whether to show the Calendar in a Drop
|
|
110
|
+
}, [range, schema, textValue, value, normalizedDate, timestamp]); // when format and not inline, whether to show the Calendar in a Drop
|
|
92
111
|
|
|
93
112
|
var _useState2 = useState(),
|
|
94
113
|
open = _useState2[0],
|
|
@@ -112,10 +131,10 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
112
131
|
ref: inline ? ref : undefined,
|
|
113
132
|
id: inline && !format ? id : undefined,
|
|
114
133
|
range: range,
|
|
115
|
-
date: range ? undefined :
|
|
134
|
+
date: range ? undefined : normalizedDate // when caller initializes with empty array, dates should be undefined
|
|
116
135
|
// allowing the user to select both begin and end of the range
|
|
117
136
|
,
|
|
118
|
-
dates: range && value.length ? [
|
|
137
|
+
dates: range && value.length ? [normalizedDate] : undefined // places focus on days grid when Calendar opens
|
|
119
138
|
,
|
|
120
139
|
initialFocus: open ? 'days' : undefined,
|
|
121
140
|
onSelect: disabled ? undefined : function (nextValue) {
|
|
@@ -126,7 +145,7 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
126
145
|
} // clicking an edge date removes it
|
|
127
146
|
else if (range) normalizedValue = [nextValue, nextValue];else normalizedValue = nextValue;
|
|
128
147
|
|
|
129
|
-
if (schema) setTextValue(valueToText(normalizedValue, schema));
|
|
148
|
+
if (schema) setTextValue(valueToText(normalizeForTimezone(normalizedValue), schema));
|
|
130
149
|
setValue(normalizedValue);
|
|
131
150
|
if (_onChange) _onChange({
|
|
132
151
|
value: normalizedValue
|
|
@@ -139,7 +158,17 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
139
158
|
}, 1);
|
|
140
159
|
}
|
|
141
160
|
}
|
|
142
|
-
}, calendarProps
|
|
161
|
+
}, _extends({}, calendarProps, {
|
|
162
|
+
timestamp: timestamp
|
|
163
|
+
})));
|
|
164
|
+
var formContextValue = useMemo(function () {
|
|
165
|
+
return {
|
|
166
|
+
useFormInput: function useFormInput(_ref2) {
|
|
167
|
+
var valueProp = _ref2.value;
|
|
168
|
+
return [valueProp, function () {}];
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}, []);
|
|
143
172
|
|
|
144
173
|
if (!format) {
|
|
145
174
|
// When no format is specified, we don't give the user a way to type
|
|
@@ -163,33 +192,32 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
163
192
|
var input = /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
164
193
|
key: "input" // don't let MaskedInput drive the Form
|
|
165
194
|
,
|
|
166
|
-
value:
|
|
167
|
-
useFormInput: function useFormInput(_ref2) {
|
|
168
|
-
var valueProp = _ref2.value;
|
|
169
|
-
return [valueProp, function () {}];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
195
|
+
value: formContextValue
|
|
172
196
|
}, /*#__PURE__*/React.createElement(Keyboard, {
|
|
173
197
|
onEsc: open ? function () {
|
|
174
198
|
return closeCalendar();
|
|
175
199
|
} : undefined,
|
|
176
200
|
onSpace: openCalendar
|
|
201
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
202
|
+
ref: containerRef,
|
|
203
|
+
border: !plain,
|
|
204
|
+
round: "xxsmall",
|
|
205
|
+
direction: "row",
|
|
206
|
+
fill: true
|
|
177
207
|
}, /*#__PURE__*/React.createElement(MaskedInput, _extends({
|
|
178
208
|
ref: ref,
|
|
179
209
|
id: id,
|
|
180
210
|
name: name,
|
|
181
|
-
icon: /*#__PURE__*/React.createElement(CalendarIcon, {
|
|
182
|
-
size: iconSize
|
|
183
|
-
}),
|
|
184
211
|
reverse: true,
|
|
185
212
|
disabled: disabled,
|
|
186
|
-
mask: mask
|
|
213
|
+
mask: mask,
|
|
214
|
+
plain: true
|
|
187
215
|
}, inputProps, rest, {
|
|
188
216
|
value: textValue,
|
|
189
217
|
onChange: function onChange(event) {
|
|
190
218
|
var nextTextValue = event.target.value;
|
|
191
219
|
setTextValue(nextTextValue);
|
|
192
|
-
var nextValue = textToValue(nextTextValue, schema,
|
|
220
|
+
var nextValue = textToValue(nextTextValue, schema, range, timestamp); // update value even when undefined
|
|
193
221
|
|
|
194
222
|
setValue(nextValue);
|
|
195
223
|
|
|
@@ -209,6 +237,15 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
209
237
|
}));
|
|
210
238
|
if (_onFocus) _onFocus(event);
|
|
211
239
|
}
|
|
240
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
|
241
|
+
onClick: open ? closeCalendar : openCalendar,
|
|
242
|
+
plain: true,
|
|
243
|
+
icon: /*#__PURE__*/React.createElement(CalendarIcon, {
|
|
244
|
+
size: iconSize
|
|
245
|
+
}),
|
|
246
|
+
margin: {
|
|
247
|
+
right: 'small'
|
|
248
|
+
}
|
|
212
249
|
}))));
|
|
213
250
|
|
|
214
251
|
if (inline) {
|
|
@@ -232,7 +269,10 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
232
269
|
onEsc: closeCalendar,
|
|
233
270
|
onClickOutside: function onClickOutside(_ref3) {
|
|
234
271
|
var target = _ref3.target;
|
|
235
|
-
|
|
272
|
+
|
|
273
|
+
if (target !== containerRef.current && !containerRef.current.contains(target)) {
|
|
274
|
+
closeCalendar();
|
|
275
|
+
}
|
|
236
276
|
}
|
|
237
277
|
}, dropProps), calendar))];
|
|
238
278
|
}
|
|
@@ -1,31 +1,184 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box,
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, DateInput, Text } from 'grommet';
|
|
3
|
+
var DATE = '2020-07-02';
|
|
4
|
+
var DATETZ = '2020-07-02T00:00:00-08:00';
|
|
5
|
+
var DATE_RANGE = ['2020-07-02', '2020-07-05'];
|
|
6
|
+
var DATE_RANGETZ = ['2020-07-02T00:00:00-08:00', '2020-07-05T00:00:00-08:00'];
|
|
3
7
|
export var FormatInline = function FormatInline() {
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
var _useState = useState(),
|
|
9
|
+
date = _useState[0],
|
|
10
|
+
setDate = _useState[1];
|
|
7
11
|
|
|
8
|
-
var
|
|
12
|
+
var _useState2 = useState(),
|
|
13
|
+
emptyDate = _useState2[0],
|
|
14
|
+
setEmptyDate = _useState2[1];
|
|
15
|
+
|
|
16
|
+
var _useState3 = useState(),
|
|
17
|
+
dateRange = _useState3[0],
|
|
18
|
+
setDateRange = _useState3[1];
|
|
19
|
+
|
|
20
|
+
var _useState4 = useState(),
|
|
21
|
+
dateNoTZ = _useState4[0],
|
|
22
|
+
setDateNoTZ = _useState4[1];
|
|
23
|
+
|
|
24
|
+
var _useState5 = useState(),
|
|
25
|
+
dateRangeNoTZ = _useState5[0],
|
|
26
|
+
setDateRangeNoTZ = _useState5[1];
|
|
27
|
+
|
|
28
|
+
var _useState6 = useState(),
|
|
29
|
+
dateNoDefault = _useState6[0],
|
|
30
|
+
setDateNoDefault = _useState6[1];
|
|
31
|
+
|
|
32
|
+
var _useState7 = useState(DATETZ),
|
|
33
|
+
dateStateDefault = _useState7[0],
|
|
34
|
+
setDateStateDefault = _useState7[1];
|
|
35
|
+
|
|
36
|
+
var _useState8 = useState(DATE),
|
|
37
|
+
dateStateDefaultNoTZ = _useState8[0],
|
|
38
|
+
setDateStateDefaultNoTZ = _useState8[1];
|
|
39
|
+
|
|
40
|
+
var onChangeEmpty = function onChangeEmpty(event) {
|
|
41
|
+
var nextValue = event.value;
|
|
42
|
+
console.log('onChange', nextValue);
|
|
43
|
+
setEmptyDate(nextValue);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var onChangeTZ = function onChangeTZ(event) {
|
|
47
|
+
var nextValue = event.value;
|
|
48
|
+
console.log('onChange', nextValue);
|
|
49
|
+
setDate(nextValue);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var onChangeNoTZ = function onChangeNoTZ(event) {
|
|
53
|
+
var nextValue = event.value;
|
|
54
|
+
console.log('onChange', nextValue);
|
|
55
|
+
setDateNoTZ(nextValue);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var onChangeRange = function onChangeRange(event) {
|
|
59
|
+
var nextValue = event.value;
|
|
60
|
+
console.log('onChange', nextValue);
|
|
61
|
+
setDateRange(nextValue);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var onChangeRangeNoTZ = function onChangeRangeNoTZ(event) {
|
|
9
65
|
var nextValue = event.value;
|
|
10
66
|
console.log('onChange', nextValue);
|
|
11
|
-
|
|
67
|
+
setDateRangeNoTZ(nextValue);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var onChangeNoDefault = function onChangeNoDefault(event) {
|
|
71
|
+
var nextValue = event.value;
|
|
72
|
+
console.log('onChange', nextValue);
|
|
73
|
+
setDateNoDefault(nextValue);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
var onChangeStateDefault = function onChangeStateDefault(event) {
|
|
77
|
+
var nextValue = event.value;
|
|
78
|
+
console.log('onChange', nextValue);
|
|
79
|
+
setDateStateDefault(nextValue);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
var onChangeStateDefaultNoTZ = function onChangeStateDefaultNoTZ(event) {
|
|
83
|
+
var nextValue = event.value;
|
|
84
|
+
console.log('onChange', nextValue);
|
|
85
|
+
setDateStateDefaultNoTZ(nextValue);
|
|
12
86
|
};
|
|
13
87
|
|
|
14
88
|
return /*#__PURE__*/React.createElement(Box, {
|
|
15
|
-
align: "center",
|
|
16
89
|
pad: "large",
|
|
17
90
|
gap: "medium"
|
|
18
|
-
}, /*#__PURE__*/React.createElement(
|
|
91
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
92
|
+
gap: "small",
|
|
93
|
+
align: "start"
|
|
94
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
95
|
+
weight: "bold"
|
|
96
|
+
}, "1) When defaultValue is [], everything should be local"), /*#__PURE__*/React.createElement(Text, null, "defaultValue: []"), /*#__PURE__*/React.createElement(Text, null, "Current value:", ' ', emptyDate ? emptyDate[0] + " \u2014 " + emptyDate[1] : '--'), /*#__PURE__*/React.createElement(DateInput, {
|
|
97
|
+
id: "item",
|
|
98
|
+
name: "item",
|
|
99
|
+
defaultValue: [],
|
|
100
|
+
format: "mm/dd/yyyy-mm/dd/yyyy",
|
|
101
|
+
inline: true,
|
|
102
|
+
value: emptyDate,
|
|
103
|
+
onChange: onChangeEmpty
|
|
104
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
105
|
+
gap: "small",
|
|
106
|
+
align: "start"
|
|
107
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
108
|
+
weight: "bold"
|
|
109
|
+
}, "2) When defaultValue has a timezone, everything stays in that timezone"), /*#__PURE__*/React.createElement(Text, null, "defaultValue: ", DATETZ), /*#__PURE__*/React.createElement(Text, null, "Current value: ", date || '--'), /*#__PURE__*/React.createElement(DateInput, {
|
|
19
110
|
format: "mm/dd/yyyy",
|
|
20
111
|
inline: true,
|
|
21
|
-
value:
|
|
22
|
-
onChange:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return setValue(new Date().toISOString());
|
|
112
|
+
value: date,
|
|
113
|
+
onChange: onChangeTZ,
|
|
114
|
+
defaultValue: DATETZ,
|
|
115
|
+
calendarProps: {
|
|
116
|
+
bounds: ['2020-07-01', '2020-07-31']
|
|
27
117
|
}
|
|
28
|
-
}))
|
|
118
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
119
|
+
gap: "small",
|
|
120
|
+
align: "start"
|
|
121
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
122
|
+
weight: "bold"
|
|
123
|
+
}, "3) When defaultValue has no timezone, everything is returned without a timezone and is assumed to be local time"), /*#__PURE__*/React.createElement(Text, null, "defaultValue: ", DATE), /*#__PURE__*/React.createElement(Text, null, "Current value: ", dateNoTZ || '--'), /*#__PURE__*/React.createElement(DateInput, {
|
|
124
|
+
format: "mm/dd/yyyy",
|
|
125
|
+
inline: true,
|
|
126
|
+
value: dateNoTZ,
|
|
127
|
+
onChange: onChangeNoTZ,
|
|
128
|
+
defaultValue: DATE
|
|
129
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
130
|
+
gap: "small",
|
|
131
|
+
align: "start"
|
|
132
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
133
|
+
weight: "bold"
|
|
134
|
+
}, "4) When defaultValue is a range and has a timezone, everything stays in that timezone"), /*#__PURE__*/React.createElement(Text, null, "defaultValue: ", DATE_RANGETZ[0] + " \u2014 " + DATE_RANGETZ[1]), /*#__PURE__*/React.createElement(Text, null, "Current value:", ' ', dateRange ? dateRange[0] + " \u2014 " + dateRange[1] : '--'), /*#__PURE__*/React.createElement(DateInput, {
|
|
135
|
+
format: "mm/dd/yyyy-mm/dd/yyyy",
|
|
136
|
+
inline: true,
|
|
137
|
+
value: dateRange,
|
|
138
|
+
onChange: onChangeRange,
|
|
139
|
+
defaultValue: DATE_RANGETZ
|
|
140
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
141
|
+
gap: "small",
|
|
142
|
+
align: "start"
|
|
143
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
144
|
+
weight: "bold"
|
|
145
|
+
}, "5) When defaultValue is a range and has no timezone, everything is returned without a timezone and is assumed to be local time"), /*#__PURE__*/React.createElement(Text, null, "defaultValue: ", DATE_RANGE[0] + " \u2014 " + DATE_RANGE[1]), /*#__PURE__*/React.createElement(Text, null, "Current value:", ' ', dateRangeNoTZ ? dateRangeNoTZ[0] + " \u2014 " + dateRangeNoTZ[1] : '--'), /*#__PURE__*/React.createElement(DateInput, {
|
|
146
|
+
format: "mm/dd/yyyy-mm/dd/yyyy",
|
|
147
|
+
inline: true,
|
|
148
|
+
value: dateRangeNoTZ,
|
|
149
|
+
onChange: onChangeRangeNoTZ,
|
|
150
|
+
defaultValue: DATE_RANGE
|
|
151
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
152
|
+
gap: "small",
|
|
153
|
+
align: "start"
|
|
154
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
155
|
+
weight: "bold"
|
|
156
|
+
}, "6) When no defaultValue, everything is in UTC relative to local"), /*#__PURE__*/React.createElement(Text, null, "defaultValue: undefined"), /*#__PURE__*/React.createElement(Text, null, "Current value: ", dateNoDefault || '--'), /*#__PURE__*/React.createElement(DateInput, {
|
|
157
|
+
format: "mm/dd/yyyy",
|
|
158
|
+
inline: true,
|
|
159
|
+
value: dateNoDefault,
|
|
160
|
+
onChange: onChangeNoDefault
|
|
161
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
162
|
+
gap: "small",
|
|
163
|
+
align: "start"
|
|
164
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
165
|
+
weight: "bold"
|
|
166
|
+
}, "7) When state has default value with TZ, everything everything stays in that timezone"), /*#__PURE__*/React.createElement(Text, null, "defaultValue: ", DATETZ), /*#__PURE__*/React.createElement(Text, null, "Current value: ", dateStateDefault || '--'), /*#__PURE__*/React.createElement(DateInput, {
|
|
167
|
+
format: "mm/dd/yyyy",
|
|
168
|
+
inline: true,
|
|
169
|
+
value: dateStateDefault,
|
|
170
|
+
onChange: onChangeStateDefault
|
|
171
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
172
|
+
gap: "small",
|
|
173
|
+
align: "start"
|
|
174
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
175
|
+
weight: "bold"
|
|
176
|
+
}, "8) When state has default value w/o TZ, everything is returned without a timezone and is assumed to be local time"), /*#__PURE__*/React.createElement(Text, null, "defaultValue: ", DATE), /*#__PURE__*/React.createElement(Text, null, "Current value: ", dateStateDefaultNoTZ || '--'), /*#__PURE__*/React.createElement(DateInput, {
|
|
177
|
+
format: "mm/dd/yyyy",
|
|
178
|
+
inline: true,
|
|
179
|
+
value: dateStateDefaultNoTZ,
|
|
180
|
+
onChange: onChangeStateDefaultNoTZ
|
|
181
|
+
})));
|
|
29
182
|
};
|
|
30
183
|
FormatInline.storyName = 'Format inline';
|
|
31
184
|
export default {
|
|
@@ -3,6 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
// Converting between Date and String types is handled via a "schema".
|
|
4
4
|
// The schema is an array of strings, split into strings with identical
|
|
5
5
|
// characters. So, 'mm/dd/yyyy' will be ['mm', '/', 'dd', '/', 'yyyyy'].
|
|
6
|
+
import { formatToLocalYYYYMMDD } from '../Calendar/utils';
|
|
6
7
|
export var formatToSchema = function formatToSchema(format) {
|
|
7
8
|
if (!format) return undefined;
|
|
8
9
|
var result = [];
|
|
@@ -26,27 +27,27 @@ export var formatToSchema = function formatToSchema(format) {
|
|
|
26
27
|
var masks = {
|
|
27
28
|
m: {
|
|
28
29
|
length: [1, 2],
|
|
29
|
-
regexp:
|
|
30
|
+
regexp: /^[1-9]$|^1[0-2]$/
|
|
30
31
|
},
|
|
31
32
|
mm: {
|
|
32
33
|
length: [1, 2],
|
|
33
|
-
regexp:
|
|
34
|
+
regexp: /^[0-1]$|^0[1-9]$|^1[0-2]$/
|
|
34
35
|
},
|
|
35
36
|
d: {
|
|
36
37
|
length: [1, 2],
|
|
37
|
-
regexp:
|
|
38
|
+
regexp: /^[1-9]$|^[1-2][0-9]$|^3[0-1]$/
|
|
38
39
|
},
|
|
39
40
|
dd: {
|
|
40
41
|
length: [1, 2],
|
|
41
|
-
regexp:
|
|
42
|
+
regexp: /^[0-3]$|^0[1-9]$|^[1-2][0-9]$|^3[0-1]$/
|
|
42
43
|
},
|
|
43
44
|
yy: {
|
|
44
45
|
length: [1, 2],
|
|
45
|
-
regexp:
|
|
46
|
+
regexp: /^[0-9]{1,2}$/
|
|
46
47
|
},
|
|
47
48
|
yyyy: {
|
|
48
49
|
length: [1, 4],
|
|
49
|
-
regexp:
|
|
50
|
+
regexp: /^[0-9]{1,4}$/
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
export var schemaToMask = function schemaToMask(schema) {
|
|
@@ -125,7 +126,7 @@ var pullDigits = function pullDigits(text, index) {
|
|
|
125
126
|
return text.slice(index, end);
|
|
126
127
|
};
|
|
127
128
|
|
|
128
|
-
export var textToValue = function textToValue(text, schema,
|
|
129
|
+
export var textToValue = function textToValue(text, schema, range, timestamp) {
|
|
129
130
|
if (!text) return range ? [] : undefined;
|
|
130
131
|
var result;
|
|
131
132
|
|
|
@@ -136,10 +137,7 @@ export var textToValue = function textToValue(text, schema, valueProp, range) {
|
|
|
136
137
|
if (!parts.m || !parts.d || !parts.y || parts.y.length < 4 || parts.m.length > 2 || parts.d.length > 2 || parts.m > 12 || parts.d > 31 || (parts.m === "02" || parts.m === "2") && parts.d > (leapYear ? 29 : 28)) return parts;
|
|
137
138
|
var date = new Date(parts.y, parts.m - 1, parts.d).toISOString(); // match time and timezone of any supplied valueProp
|
|
138
139
|
|
|
139
|
-
if (
|
|
140
|
-
var valueDate = new Date(Array.isArray(valueProp) && valueProp.length ? valueProp[0] : valueProp).toISOString();
|
|
141
|
-
date = date.split('T')[0] + "T" + valueDate.split('T')[1];
|
|
142
|
-
}
|
|
140
|
+
if (timestamp) date = formatToLocalYYYYMMDD(date).split('T')[0] + "T" + timestamp;else date = "" + formatToLocalYYYYMMDD(date).split('T')[0];
|
|
143
141
|
|
|
144
142
|
if (!range) {
|
|
145
143
|
if (!result) result = date;
|
|
@@ -311,17 +311,23 @@ var DropContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
311
311
|
overflow: overflow,
|
|
312
312
|
"data-g-portal-id": portalId
|
|
313
313
|
}, rest), children);
|
|
314
|
+
var themeContextValue = useMemo(function () {
|
|
315
|
+
var dark;
|
|
314
316
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if (dark !== undefined && dark !== theme.dark) {
|
|
319
|
-
content = /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
|
320
|
-
value: _extends({}, theme, {
|
|
321
|
-
dark: dark
|
|
322
|
-
})
|
|
323
|
-
}, content);
|
|
317
|
+
if (background || theme.global.drop.background) {
|
|
318
|
+
dark = backgroundIsDark(background || theme.global.drop.background, theme);
|
|
324
319
|
}
|
|
320
|
+
|
|
321
|
+
return _extends({}, theme, {
|
|
322
|
+
dark: dark
|
|
323
|
+
});
|
|
324
|
+
}, [background, theme]);
|
|
325
|
+
var dark = themeContextValue.dark;
|
|
326
|
+
|
|
327
|
+
if (dark !== undefined && dark !== theme.dark) {
|
|
328
|
+
content = /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
|
329
|
+
value: themeContextValue
|
|
330
|
+
}, content);
|
|
325
331
|
}
|
|
326
332
|
|
|
327
333
|
return /*#__PURE__*/React.createElement(PortalContext.Provider, {
|