@koine/react 2.0.0-beta.2 → 2.0.0-beta.5
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/Alert/Alert.js +27 -12
- package/Alert/Alert.mjs +16 -8
- package/Alert/Alert.stories.js +36 -0
- package/Alert/Alert.stories.mjs +15 -0
- package/Alert/index.js +5 -3
- package/Animations/Reveal.js +48 -18
- package/Animations/Reveal.mjs +38 -14
- package/Animations/Underline.js +25 -7
- package/Animations/Underline.mjs +14 -4
- package/Animations/index.js +7 -5
- package/Animations/useReveal.js +51 -43
- package/Animations/useReveal.mjs +42 -40
- package/Autocomplete/AutocompleteDownshift.js +166 -160
- package/Autocomplete/AutocompleteDownshift.mjs +156 -157
- package/Autocomplete/AutocompleteDownshiftMultiselect.js +361 -355
- package/Autocomplete/AutocompleteDownshiftMultiselect.mjs +351 -352
- package/Autocomplete/AutocompleteMui.d.ts +1 -1
- package/Autocomplete/AutocompleteMui.js +111 -137
- package/Autocomplete/AutocompleteMui.mjs +98 -90
- package/Autocomplete/AutocompleteReach.js +120 -114
- package/Autocomplete/AutocompleteReach.mjs +110 -111
- package/Autocomplete/components.js +129 -34
- package/Autocomplete/components.mjs +76 -23
- package/Autocomplete/helpers.js +25 -25
- package/Autocomplete/helpers.mjs +11 -5
- package/Autocomplete/index.js +14 -6
- package/Autocomplete/index.mjs +4 -3
- package/Bg/BgColor.js +55 -21
- package/Bg/BgColor.mjs +32 -16
- package/Bg/BgPhoto.js +78 -18
- package/Bg/BgPhoto.mjs +65 -12
- package/Bg/BgSvg.js +27 -14
- package/Bg/BgSvg.mjs +16 -8
- package/Bg/index.js +7 -5
- package/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/Breadcrumbs/Breadcrumbs.js +85 -26
- package/Breadcrumbs/Breadcrumbs.mjs +70 -19
- package/Breadcrumbs/index.js +5 -3
- package/Buttons/Button.js +105 -16
- package/Buttons/Button.mjs +73 -9
- package/Buttons/ButtonComposite.d.ts +1 -1
- package/Buttons/ButtonComposite.js +76 -25
- package/Buttons/ButtonComposite.mjs +66 -22
- package/Buttons/ButtonFab.js +26 -8
- package/Buttons/ButtonFab.mjs +6 -4
- package/Buttons/ButtonLink.d.ts +1 -1
- package/Buttons/ButtonLink.js +26 -13
- package/Buttons/ButtonLink.mjs +14 -8
- package/Buttons/IconButton.js +40 -9
- package/Buttons/IconButton.mjs +18 -6
- package/Buttons/index.js +9 -7
- package/Calendar/CalendarDaygridCell.d.ts +2 -2
- package/Calendar/CalendarDaygridCell.js +70 -49
- package/Calendar/CalendarDaygridCell.mjs +58 -43
- package/Calendar/CalendarDaygridNav.d.ts +1 -1
- package/Calendar/CalendarDaygridNav.js +41 -20
- package/Calendar/CalendarDaygridNav.mjs +28 -13
- package/Calendar/CalendarDaygridTable.d.ts +3 -3
- package/Calendar/CalendarDaygridTable.js +88 -39
- package/Calendar/CalendarDaygridTable.mjs +73 -31
- package/Calendar/CalendarLegend.d.ts +1 -1
- package/Calendar/CalendarLegend.js +17 -10
- package/Calendar/CalendarLegend.mjs +8 -7
- package/Calendar/calendar-api-google.d.ts +1 -1
- package/Calendar/calendar-api-google.js +90 -113
- package/Calendar/calendar-api-google.mjs +75 -105
- package/Calendar/index.js +10 -8
- package/Calendar/types.js +3 -1
- package/Calendar/types.mjs +1 -1
- package/Calendar/useCalendar.d.ts +2 -2
- package/Calendar/useCalendar.js +196 -148
- package/Calendar/useCalendar.mjs +184 -142
- package/Calendar/utils.js +152 -115
- package/Calendar/utils.mjs +101 -94
- package/Carousel/Carousel.js +386 -380
- package/Carousel/Carousel.mjs +377 -378
- package/Carousel/CarouselCss.d.ts +1 -1
- package/Carousel/CarouselCss.js +59 -23
- package/Carousel/CarouselCss.mjs +37 -17
- package/Carousel/index.js +5 -3
- package/Collapsable/Collapsable.js +10 -3
- package/Collapsable/Collapsable.mjs +1 -1
- package/Collapsable/CollapsableReach.js +2 -3
- package/Collapsable/CollapsableReach.mjs +1 -3
- package/Collapsable/index.js +6 -4
- package/Collapsable/index.mjs +1 -2
- package/Debug/Debug.js +29 -11
- package/Debug/Debug.mjs +18 -7
- package/Debug/index.js +5 -3
- package/Details/Details.d.ts +5 -5
- package/Details/Details.js +87 -44
- package/Details/Details.mjs +60 -41
- package/Details/Details.stories.js +38 -0
- package/Details/Details.stories.mjs +20 -0
- package/Details/index.js +5 -3
- package/Dialog/DialogMui.d.ts +7 -7
- package/Dialog/DialogMui.js +78 -31
- package/Dialog/DialogMui.mjs +38 -26
- package/Dialog/DialogMui.stories.js +37 -0
- package/Dialog/DialogMui.stories.mjs +19 -0
- package/Dialog/css/bare.d.ts +6 -6
- package/Dialog/css/bare.js +53 -22
- package/Dialog/css/bare.mjs +15 -17
- package/Dialog/css/index.stories.js +85 -0
- package/Dialog/css/index.stories.mjs +67 -0
- package/Dialog/index.js +10 -4
- package/Dialog/m/bare.d.ts +6 -6
- package/Dialog/m/bare.js +55 -30
- package/Dialog/m/bare.mjs +40 -22
- package/Dialog/m/basic.js +29 -14
- package/Dialog/m/basic.mjs +10 -10
- package/Dialog/m/index.js +13 -7
- package/Dialog/m/index.mjs +4 -4
- package/Dialog/sc/bare.d.ts +6 -6
- package/Dialog/sc/bare.js +79 -42
- package/Dialog/sc/bare.mjs +40 -29
- package/Dialog/sc/framer.d.ts +6 -6
- package/Dialog/sc/framer.js +24 -17
- package/Dialog/sc/framer.mjs +9 -9
- package/Dialog/sc/framerMaterial.d.ts +6 -6
- package/Dialog/sc/framerMaterial.js +24 -17
- package/Dialog/sc/framerMaterial.mjs +9 -9
- package/Dialog/sc/index.stories.js +74 -0
- package/Dialog/sc/index.stories.mjs +47 -0
- package/Dialog/sc/material.d.ts +6 -6
- package/Dialog/sc/material.js +76 -22
- package/Dialog/sc/material.mjs +37 -17
- package/Dialog/tw/bare.d.ts +6 -6
- package/Dialog/tw/bare.js +51 -41
- package/Dialog/tw/bare.mjs +15 -28
- package/Dialog/tw/elegant.d.ts +6 -6
- package/Dialog/tw/elegant.js +52 -21
- package/Dialog/tw/elegant.mjs +15 -17
- package/Dialog/tw/framer.d.ts +6 -6
- package/Dialog/tw/framer.js +24 -17
- package/Dialog/tw/framer.mjs +9 -9
- package/Dialog/tw/framerMaterial.d.ts +6 -6
- package/Dialog/tw/framerMaterial.js +24 -17
- package/Dialog/tw/framerMaterial.mjs +9 -9
- package/Dialog/tw/index.stories.js +112 -0
- package/Dialog/tw/index.stories.mjs +82 -0
- package/Dialog/tw/material.d.ts +6 -6
- package/Dialog/tw/material.js +52 -21
- package/Dialog/tw/material.mjs +15 -17
- package/Editor/Editor--tiptap.d.ts +1 -1
- package/Editor/Editor--tiptap.js +50 -24
- package/Editor/Editor--tiptap.mjs +31 -19
- package/Editor/components.js +58 -14
- package/Editor/components.mjs +26 -8
- package/Editor/index.js +5 -3
- package/FaviconTags.js +59 -0
- package/FaviconTags.mjs +50 -0
- package/Form/Form.js +100 -52
- package/Form/Form.mjs +64 -47
- package/Form/index.js +5 -3
- package/Form/sc/bare.js +53 -21
- package/Form/sc/bare.mjs +21 -12
- package/Forms/Checkbox/Checkbox.js +46 -19
- package/Forms/Checkbox/Checkbox.mjs +16 -12
- package/Forms/Checkbox/index.js +5 -3
- package/Forms/Feedback/Feedback.js +21 -11
- package/Forms/Feedback/Feedback.mjs +10 -7
- package/Forms/Feedback/index.js +5 -3
- package/Forms/Field/Field.js +55 -21
- package/Forms/Field/Field.mjs +30 -17
- package/Forms/Field/FieldControl.js +41 -37
- package/Forms/Field/FieldControl.mjs +26 -20
- package/Forms/Field/FieldHint.js +16 -6
- package/Forms/Field/FieldHint.mjs +5 -3
- package/Forms/Field/index.js +6 -4
- package/Forms/Input/Input.js +56 -17
- package/Forms/Input/Input.mjs +22 -11
- package/Forms/Input/index.js +5 -3
- package/Forms/InputGroup/InputGroup.js +73 -17
- package/Forms/InputGroup/InputGroup.mjs +43 -11
- package/Forms/InputGroup/index.js +5 -3
- package/Forms/Label/Label.js +45 -8
- package/Forms/Label/Label.mjs +23 -5
- package/Forms/Label/index.js +5 -3
- package/Forms/Password/Password.js +56 -18
- package/Forms/Password/Password.mjs +35 -13
- package/Forms/Password/index.js +5 -3
- package/Forms/Radio/Radio.js +46 -25
- package/Forms/Radio/Radio.mjs +32 -19
- package/Forms/Radio/index.js +5 -3
- package/Forms/Switch/Switch.js +66 -21
- package/Forms/Switch/Switch.mjs +41 -13
- package/Forms/Switch/index.js +5 -3
- package/Forms/Textarea/Textarea.js +35 -13
- package/Forms/Textarea/Textarea.mjs +13 -7
- package/Forms/Textarea/TextareaRich.js +48 -29
- package/Forms/Textarea/TextareaRich.mjs +34 -22
- package/Forms/Textarea/index.js +6 -4
- package/Forms/Toggle/Toggle-tailwind.js +1 -1
- package/Forms/Toggle/Toggle-tailwind.mjs +0 -1
- package/Forms/Toggle/Toggle.js +149 -29
- package/Forms/Toggle/Toggle.mjs +95 -22
- package/Forms/Toggle/index.js +5 -3
- package/Forms/Toggle/useToggle-tailwind.js +1 -1
- package/Forms/Toggle/useToggle-tailwind.mjs +0 -1
- package/Forms/Toggle/useToggle.js +91 -101
- package/Forms/Toggle/useToggle.mjs +80 -68
- package/Forms/antispam.js +38 -45
- package/Forms/antispam.mjs +19 -21
- package/Forms/helpers.js +49 -31
- package/Forms/helpers.mjs +25 -19
- package/Forms/index.js +18 -18
- package/Forms/styles.js +90 -29
- package/Forms/styles.mjs +50 -19
- package/Gauge/Gauge.js +109 -104
- package/Gauge/Gauge.mjs +99 -100
- package/Grid/Grid.d.ts +4 -3
- package/Grid/Grid.js +84 -34
- package/Grid/Grid.mjs +54 -32
- package/Grid/index.js +5 -3
- package/Hamburger/Hamburger.js +68 -41
- package/Hamburger/Hamburger.mjs +58 -38
- package/Hamburger/index.js +5 -3
- package/Header/index.js +5 -3
- package/Header/useHeader.js +44 -25
- package/Header/useHeader.mjs +23 -18
- package/Hidden/Hidden.js +19 -11
- package/Hidden/Hidden.mjs +9 -9
- package/Hidden/index.js +5 -3
- package/Img/index.js +5 -3
- package/Img/sc/bare.js +42 -41
- package/Img/sc/bare.mjs +31 -34
- package/Img/types.js +5 -1
- package/Img/types.mjs +1 -1
- package/Link/Link.js +12 -6
- package/Link/Link.mjs +1 -3
- package/Link/LinkBlank.js +42 -18
- package/Link/LinkBlank.mjs +19 -11
- package/Link/index.js +6 -4
- package/Menu/Menu.js +21 -6
- package/Menu/Menu.mjs +10 -3
- package/Menu/MenuMui.js +2 -2
- package/Menu/MenuMui.mjs +1 -2
- package/Menu/index.js +5 -3
- package/MenuItem/MenuItem.js +30 -6
- package/MenuItem/MenuItem.mjs +19 -3
- package/MenuItem/MenuItemMui.js +1 -1
- package/MenuItem/MenuItemMui.mjs +0 -1
- package/MenuItem/index.js +5 -3
- package/MenuItem/useMenuItem.js +65 -33
- package/MenuItem/useMenuItem.mjs +45 -27
- package/Meta/Meta.js +23 -8
- package/Meta/Meta.mjs +5 -4
- package/Meta/index.js +11 -6
- package/NoJs/NoJs.js +25 -9
- package/NoJs/NoJs.mjs +7 -5
- package/NoJs/index.js +11 -6
- package/Pagination/PaginationNav.d.ts +1 -1
- package/Pagination/PaginationNav.js +86 -44
- package/Pagination/PaginationNav.mjs +72 -30
- package/Pagination/PaginationResults.js +38 -13
- package/Pagination/PaginationResults.mjs +27 -9
- package/Pagination/index.js +6 -4
- package/Pill/Pill.js +61 -9
- package/Pill/Pill.mjs +36 -6
- package/Pill/index.js +5 -3
- package/Progress/ProgressCircular.js +58 -17
- package/Progress/ProgressCircular.mjs +47 -11
- package/Progress/ProgressLinear.js +49 -26
- package/Progress/ProgressLinear.mjs +38 -20
- package/Progress/ProgressOverlay.js +65 -24
- package/Progress/ProgressOverlay.mjs +51 -17
- package/Progress/index.js +7 -5
- package/Rating/Rating.js +128 -41
- package/Rating/Rating.mjs +93 -35
- package/Rating/index.js +61 -33
- package/Rating/index.mjs +37 -24
- package/Select/SelectDownshift.js +46 -40
- package/Select/SelectDownshift.mjs +37 -38
- package/Select/components.js +40 -13
- package/Select/components.mjs +20 -9
- package/Select/index.js +12 -6
- package/Select/index.mjs +2 -3
- package/Sidebar/Sidebar.js +61 -23
- package/Sidebar/Sidebar.mjs +48 -17
- package/Sidebar/index.js +5 -3
- package/Spacing/Spacing.d.ts +1 -1
- package/Spacing/Spacing.js +36 -33
- package/Spacing/Spacing.mjs +24 -17
- package/Spacing/index.js +5 -3
- package/Sticky/Sticky.js +227 -221
- package/Sticky/Sticky.mjs +218 -219
- package/Sticky/StickyCss.js +17 -8
- package/Sticky/StickyCss.mjs +8 -5
- package/Sticky/index.js +18 -4
- package/Sticky/index.mjs +1 -1
- package/Tabs/TabsMui.d.ts +8 -8
- package/Tabs/TabsMui.js +64 -34
- package/Tabs/TabsMui.mjs +31 -28
- package/Tabs/TabsMui.stories.js +37 -0
- package/Tabs/TabsMui.stories.mjs +19 -0
- package/Tabs/index.js +5 -3
- package/Tabs/sc/bare.js +2 -3
- package/Tabs/sc/bare.mjs +1 -3
- package/Tabs/sc/index.stories.js +1 -0
- package/Tabs/sc/index.stories.mjs +0 -0
- package/Tabs/tw/bare.d.ts +6 -6
- package/Tabs/tw/bare.js +43 -18
- package/Tabs/tw/bare.mjs +11 -13
- package/Tabs/tw/index.stories.js +45 -0
- package/Tabs/tw/index.stories.mjs +24 -0
- package/Tabs/tw/material.d.ts +6 -6
- package/Tabs/tw/material.js +41 -18
- package/Tabs/tw/material.mjs +11 -15
- package/Tabs/useTabs.js +44 -25
- package/Tabs/useTabs.mjs +24 -21
- package/Typography/CopyPasteVisible.js +16 -6
- package/Typography/CopyPasteVisible.mjs +5 -3
- package/Typography/Native.js +89 -16
- package/Typography/Native.mjs +45 -12
- package/Typography/ReadMore.js +99 -36
- package/Typography/ReadMore.mjs +86 -30
- package/Typography/TextLoop.js +94 -45
- package/Typography/TextLoop.mjs +76 -40
- package/Typography/TypeStairs.js +43 -32
- package/Typography/TypeStairs.mjs +33 -29
- package/Typography/index.js +9 -7
- package/css/index.js +32 -35
- package/css/index.mjs +20 -21
- package/helpers/classed.js +39 -51
- package/helpers/classed.mjs +21 -30
- package/helpers/classed.stories.js +122 -0
- package/helpers/classed.stories.mjs +103 -0
- package/helpers/createUseMediaQueryWidth.js +163 -153
- package/helpers/createUseMediaQueryWidth.mjs +140 -140
- package/helpers/extend-component.js +26 -11
- package/helpers/extend-component.mjs +7 -7
- package/helpers/index.js +8 -6
- package/helpers/mergeRefs.js +21 -8
- package/helpers/mergeRefs.mjs +3 -4
- package/hooks/index.js +91 -43
- package/hooks/index.mjs +3 -3
- package/hooks/types.js +6 -2
- package/hooks/types.mjs +3 -1
- package/hooks/useAsyncFn.js +48 -33
- package/hooks/useAsyncFn.mjs +28 -26
- package/hooks/useDateLocale.js +42 -32
- package/hooks/useDateLocale.mjs +22 -22
- package/hooks/useFirstMountState.js +20 -9
- package/hooks/useFirstMountState.mjs +2 -3
- package/hooks/useFixedOffset.js +45 -40
- package/hooks/useFixedOffset.mjs +23 -24
- package/hooks/useFocus.js +26 -12
- package/hooks/useFocus.mjs +7 -5
- package/hooks/useInterval.js +37 -25
- package/hooks/useInterval.mjs +15 -14
- package/hooks/useIsomorphicLayoutEffect.js +22 -12
- package/hooks/useIsomorphicLayoutEffect.mjs +1 -4
- package/hooks/useKeyUp.js +30 -17
- package/hooks/useKeyUp.mjs +9 -11
- package/hooks/useMeasure.js +98 -80
- package/hooks/useMeasure.mjs +74 -67
- package/hooks/useMountedState.js +23 -12
- package/hooks/useMountedState.mjs +5 -6
- package/hooks/useNavigateAway.js +47 -51
- package/hooks/useNavigateAway.mjs +26 -25
- package/hooks/usePrevious.js +27 -10
- package/hooks/usePrevious.mjs +9 -4
- package/hooks/usePreviousRef.js +21 -7
- package/hooks/usePreviousRef.mjs +2 -2
- package/hooks/useScrollPosition.js +53 -43
- package/hooks/useScrollPosition.mjs +28 -26
- package/hooks/useScrollThreshold.js +41 -22
- package/hooks/useScrollThreshold.mjs +18 -13
- package/hooks/useScrollTo.js +28 -16
- package/hooks/useScrollTo.mjs +6 -8
- package/hooks/useSmoothScroll.js +39 -34
- package/hooks/useSmoothScroll.mjs +12 -16
- package/hooks/useSpinDelay.js +42 -37
- package/hooks/useSpinDelay.mjs +24 -22
- package/hooks/useTraceUpdate.js +26 -13
- package/hooks/useTraceUpdate.mjs +8 -7
- package/hooks/useUpdateEffect.js +24 -13
- package/hooks/useUpdateEffect.mjs +4 -5
- package/hooks/useWindowSize.js +34 -25
- package/hooks/useWindowSize.mjs +13 -10
- package/index.js +9 -7
- package/index.mjs +4 -5
- package/m/MotionProvider.js +23 -41
- package/m/MotionProvider.mjs +4 -5
- package/m/index.js +6 -5
- package/m/index.mjs +1 -2
- package/m/lite.js +11 -3
- package/m/max.js +11 -3
- package/package.json +16 -13
- package/sc/index.js +48 -36
- package/scm/index.js +39 -35
- package/shared/index.js +12 -10
- package/shared/index.mjs +35 -0
- package/styles/Body.js +27 -15
- package/styles/Body.mjs +8 -5
- package/styles/Global.js +54 -20
- package/styles/Global.mjs +36 -5
- package/styles/index.js +141 -40
- package/styles/index.mjs +5 -5
- package/styles/media.js +98 -120
- package/styles/media.mjs +63 -68
- package/styles/spacing.js +49 -31
- package/styles/spacing.mjs +26 -25
- package/styles/styled.js +56 -15
- package/styles/styled.mjs +23 -10
- package/styles/theme--vanilla.js +58 -42
- package/styles/theme--vanilla.mjs +25 -20
- package/styles/theme.js +38 -34
- package/styles/theme.mjs +16 -19
- package/tw/index.js +32 -35
- package/tw/index.mjs +20 -21
- package/twm/index.js +32 -35
- package/twm/index.mjs +20 -21
- package/types.js +3 -1
- package/types.mjs +1 -1
- package/typings.d.ts +1 -0
- package/Alert/package.json +0 -6
- package/Animations/package.json +0 -6
- package/Autocomplete/package.json +0 -6
- package/Bg/package.json +0 -6
- package/Breadcrumbs/package.json +0 -6
- package/Buttons/package.json +0 -6
- package/Calendar/package.json +0 -6
- package/Carousel/package.json +0 -6
- package/Collapsable/package.json +0 -6
- package/Debug/package.json +0 -6
- package/Details/package.json +0 -6
- package/Dialog/m/package.json +0 -6
- package/Dialog/package.json +0 -6
- package/Editor/package.json +0 -6
- package/FaviconTags/FaviconTags.js +0 -20
- package/FaviconTags/FaviconTags.mjs +0 -16
- package/FaviconTags/index.d.ts +0 -2
- package/FaviconTags/index.js +0 -7
- package/FaviconTags/index.mjs +0 -2
- package/FaviconTags/package.json +0 -6
- package/Form/package.json +0 -6
- package/Forms/Checkbox/package.json +0 -6
- package/Forms/Feedback/package.json +0 -6
- package/Forms/Field/package.json +0 -6
- package/Forms/Input/package.json +0 -6
- package/Forms/InputGroup/package.json +0 -6
- package/Forms/Label/package.json +0 -6
- package/Forms/Password/package.json +0 -6
- package/Forms/Radio/package.json +0 -6
- package/Forms/Switch/package.json +0 -6
- package/Forms/Textarea/package.json +0 -6
- package/Forms/Toggle/package.json +0 -6
- package/Forms/package.json +0 -6
- package/Grid/package.json +0 -6
- package/Hamburger/package.json +0 -6
- package/Header/package.json +0 -6
- package/Hidden/package.json +0 -6
- package/Img/package.json +0 -6
- package/Link/package.json +0 -6
- package/Menu/package.json +0 -6
- package/MenuItem/package.json +0 -6
- package/Meta/package.json +0 -6
- package/NoJs/package.json +0 -6
- package/Pagination/package.json +0 -6
- package/Pill/package.json +0 -6
- package/Progress/package.json +0 -6
- package/Rating/package.json +0 -6
- package/Select/package.json +0 -6
- package/Sidebar/package.json +0 -6
- package/Spacing/package.json +0 -6
- package/Sticky/package.json +0 -6
- package/Tabs/package.json +0 -6
- package/Typography/package.json +0 -6
- package/css/package.json +0 -6
- package/helpers/package.json +0 -6
- package/hooks/package.json +0 -6
- package/m/package.json +0 -6
- package/sc/package.json +0 -6
- package/scm/package.json +0 -6
- package/shared/package.json +0 -6
- package/styles/package.json +0 -6
- package/tw/package.json +0 -6
- package/twm/package.json +0 -6
- /package/{FaviconTags/FaviconTags.d.ts → FaviconTags.d.ts} +0 -0
package/hooks/useMeasure.mjs
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect, useState, useRef, useMemo } from "react";
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
2
|
import debounce from "@koine/utils/debounce";
|
|
4
3
|
import noop from "@koine/utils/noop";
|
|
5
4
|
import listenResizeDebounced from "@koine/dom/listenResizeDebounced";
|
|
6
5
|
import listenScrollDebounced from "@koine/dom/listenScrollDebounced";
|
|
7
|
-
import on from "@koine/dom/on";
|
|
8
6
|
import off from "@koine/dom/off";
|
|
9
|
-
|
|
7
|
+
import on from "@koine/dom/on";
|
|
8
|
+
let observer;
|
|
10
9
|
// Returns a list of scroll offsets
|
|
11
10
|
function findScrollContainers(element) {
|
|
12
|
-
|
|
13
|
-
if (!element || element === document.body)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const result = [];
|
|
12
|
+
if (!element || element === document.body) return result;
|
|
13
|
+
const { overflow, overflowX, overflowY } = window.getComputedStyle(element);
|
|
14
|
+
if ([
|
|
15
|
+
overflow,
|
|
16
|
+
overflowX,
|
|
17
|
+
overflowY
|
|
18
|
+
].some((prop)=>prop === "auto" || prop === "scroll")) result.push(element);
|
|
19
|
+
return [
|
|
20
|
+
...result,
|
|
21
|
+
...findScrollContainers(element.parentElement)
|
|
22
|
+
];
|
|
19
23
|
}
|
|
20
|
-
|
|
24
|
+
const keys = [
|
|
21
25
|
"x",
|
|
22
26
|
"y",
|
|
23
27
|
"top",
|
|
@@ -25,19 +29,16 @@ var keys = [
|
|
|
25
29
|
"left",
|
|
26
30
|
"right",
|
|
27
31
|
"width",
|
|
28
|
-
"height"
|
|
32
|
+
"height"
|
|
29
33
|
];
|
|
30
|
-
|
|
31
|
-
return keys.every(function (key) { return a[key] === b[key]; });
|
|
32
|
-
};
|
|
34
|
+
const areBoundsEqual = (a, b)=>keys.every((key)=>a[key] === b[key]);
|
|
33
35
|
/**
|
|
34
36
|
* Use measure hook
|
|
35
37
|
*
|
|
36
38
|
* @borrows [pmndrs/react-use-measure](https://github.com/pmndrs/react-use-measure)
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var _b = useState({
|
|
39
|
+
*/ export function useMeasure(options) {
|
|
40
|
+
const { scroll = false } = options || {};
|
|
41
|
+
const [bounds, setBounds] = useState({
|
|
41
42
|
left: 0,
|
|
42
43
|
top: 0,
|
|
43
44
|
width: 0,
|
|
@@ -45,10 +46,10 @@ export function useMeasure(options) {
|
|
|
45
46
|
bottom: 0,
|
|
46
47
|
right: 0,
|
|
47
48
|
x: 0,
|
|
48
|
-
y: 0
|
|
49
|
-
})
|
|
49
|
+
y: 0
|
|
50
|
+
});
|
|
50
51
|
// keep all state in a ref
|
|
51
|
-
|
|
52
|
+
const state = useRef([
|
|
52
53
|
// element
|
|
53
54
|
null,
|
|
54
55
|
// scrollContainers
|
|
@@ -56,25 +57,20 @@ export function useMeasure(options) {
|
|
|
56
57
|
// resizeObserver
|
|
57
58
|
null,
|
|
58
59
|
// lastBounds
|
|
59
|
-
bounds
|
|
60
|
+
bounds
|
|
60
61
|
]);
|
|
61
62
|
// make sure to update state only as long as the component is truly mounted
|
|
62
|
-
|
|
63
|
-
useEffect(
|
|
63
|
+
const mounted = useRef(false);
|
|
64
|
+
useEffect(()=>{
|
|
64
65
|
mounted.current = true;
|
|
65
|
-
return
|
|
66
|
+
return ()=>void (mounted.current = false);
|
|
66
67
|
}, []);
|
|
67
68
|
// memoize handlers, so event-listeners know when they should update
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
var _a = state.current, element = _a[0], lastBounds = _a[3];
|
|
75
|
-
if (!element)
|
|
76
|
-
return;
|
|
77
|
-
var size = element.getBoundingClientRect();
|
|
69
|
+
const [forceRefresh /* resizeChange */ , , scrollChange] = useMemo(()=>{
|
|
70
|
+
const callback = (..._args)=>{
|
|
71
|
+
const [element, , , lastBounds] = state.current;
|
|
72
|
+
if (!element) return;
|
|
73
|
+
const size = element.getBoundingClientRect();
|
|
78
74
|
// if (element instanceof HTMLElement && offsetSize) {
|
|
79
75
|
// size.height = element.offsetHeight;
|
|
80
76
|
// size.width = element.offsetWidth;
|
|
@@ -85,16 +81,20 @@ export function useMeasure(options) {
|
|
|
85
81
|
setBounds(size);
|
|
86
82
|
}
|
|
87
83
|
};
|
|
88
|
-
|
|
89
|
-
return [
|
|
90
|
-
|
|
84
|
+
const debouncedCallback = debounce(callback);
|
|
85
|
+
return [
|
|
86
|
+
callback,
|
|
87
|
+
debouncedCallback,
|
|
88
|
+
debouncedCallback
|
|
89
|
+
];
|
|
90
|
+
}, [
|
|
91
|
+
setBounds /* , offsetSize */
|
|
92
|
+
]);
|
|
91
93
|
// cleanup current scroll-listeners / observers
|
|
92
94
|
function removeListeners() {
|
|
93
|
-
|
|
95
|
+
const [, scrollContainers, resizeObserver] = state.current;
|
|
94
96
|
if (scrollContainers) {
|
|
95
|
-
scrollContainers.forEach(
|
|
96
|
-
return off(element, "scroll", scrollChange);
|
|
97
|
-
});
|
|
97
|
+
scrollContainers.forEach((element)=>off(element, "scroll", scrollChange));
|
|
98
98
|
state.current[1] = null;
|
|
99
99
|
}
|
|
100
100
|
if (resizeObserver) {
|
|
@@ -104,27 +104,23 @@ export function useMeasure(options) {
|
|
|
104
104
|
}
|
|
105
105
|
// add scroll-listeners / observers
|
|
106
106
|
function addListeners() {
|
|
107
|
-
|
|
108
|
-
if (!element)
|
|
109
|
-
return;
|
|
107
|
+
const [element, scrollContainers] = state.current;
|
|
108
|
+
if (!element) return;
|
|
110
109
|
if (!observer && ResizeObserver) {
|
|
111
110
|
observer = new ResizeObserver(scrollChange);
|
|
112
111
|
state.current[2] = observer;
|
|
113
112
|
observer.observe(element);
|
|
114
113
|
if (scroll && scrollContainers) {
|
|
115
|
-
scrollContainers.forEach(
|
|
116
|
-
return on(scrollContainer, "scroll", scrollChange, {
|
|
114
|
+
scrollContainers.forEach((scrollContainer)=>on(scrollContainer, "scroll", scrollChange, {
|
|
117
115
|
capture: true,
|
|
118
|
-
passive: true
|
|
119
|
-
});
|
|
120
|
-
});
|
|
116
|
+
passive: true
|
|
117
|
+
}));
|
|
121
118
|
}
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
121
|
// the ref we expose to the user
|
|
125
|
-
|
|
126
|
-
if (!node || node === state.current[0])
|
|
127
|
-
return;
|
|
122
|
+
const ref = (node)=>{
|
|
123
|
+
if (!node || node === state.current[0]) return;
|
|
128
124
|
removeListeners();
|
|
129
125
|
state.current[0] = node;
|
|
130
126
|
state.current[1] = findScrollContainers(node);
|
|
@@ -136,32 +132,43 @@ export function useMeasure(options) {
|
|
|
136
132
|
// debugger;
|
|
137
133
|
// forceRefresh();
|
|
138
134
|
// });
|
|
139
|
-
useEffect(
|
|
135
|
+
useEffect(()=>{
|
|
140
136
|
if (scroll) {
|
|
141
|
-
|
|
137
|
+
const listener = listenScrollDebounced(0, forceRefresh, 100);
|
|
142
138
|
return listener;
|
|
143
139
|
}
|
|
144
140
|
return noop;
|
|
145
|
-
}, [
|
|
146
|
-
|
|
141
|
+
}, [
|
|
142
|
+
scroll,
|
|
143
|
+
forceRefresh
|
|
144
|
+
]);
|
|
145
|
+
useEffect(()=>{
|
|
147
146
|
// const listener = listenResizeDebounced(onWindowResize);
|
|
148
147
|
// return listener;
|
|
149
|
-
|
|
148
|
+
const listener = listenResizeDebounced(0, forceRefresh, 100);
|
|
150
149
|
return listener;
|
|
151
|
-
}, [
|
|
150
|
+
}, [
|
|
151
|
+
forceRefresh
|
|
152
|
+
]);
|
|
152
153
|
// respond to changes that are relevant for the listeners
|
|
153
|
-
useEffect(
|
|
154
|
+
useEffect(()=>{
|
|
154
155
|
removeListeners();
|
|
155
156
|
addListeners();
|
|
156
|
-
|
|
157
|
-
}, [
|
|
158
|
-
|
|
157
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
158
|
+
}, [
|
|
159
|
+
scroll /* , scrollChange, resizeChange */
|
|
160
|
+
]);
|
|
161
|
+
useEffect(()=>{
|
|
159
162
|
// operate on mount, @kuus on the original version there is no call on mount?
|
|
160
163
|
forceRefresh();
|
|
161
164
|
// remove all listeners when the components unmounts
|
|
162
165
|
return removeListeners;
|
|
163
|
-
|
|
166
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
164
167
|
}, []);
|
|
165
|
-
return [
|
|
168
|
+
return [
|
|
169
|
+
ref,
|
|
170
|
+
bounds,
|
|
171
|
+
forceRefresh
|
|
172
|
+
];
|
|
166
173
|
}
|
|
167
174
|
export default useMeasure;
|
package/hooks/useMountedState.js
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
useMountedState: function() {
|
|
13
|
+
return useMountedState;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _react = require("react");
|
|
8
20
|
function useMountedState() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
(0,
|
|
21
|
+
const mountedRef = (0, _react.useRef)(false);
|
|
22
|
+
const get = (0, _react.useCallback)(()=>mountedRef.current, []);
|
|
23
|
+
(0, _react.useEffect)(()=>{
|
|
12
24
|
mountedRef.current = true;
|
|
13
|
-
return
|
|
25
|
+
return ()=>{
|
|
14
26
|
mountedRef.current = false;
|
|
15
27
|
};
|
|
16
28
|
}, []);
|
|
17
29
|
return get;
|
|
18
30
|
}
|
|
19
|
-
|
|
20
|
-
exports.default = useMountedState;
|
|
31
|
+
const _default = useMountedState;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useMountedState.ts)
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
useEffect(function () {
|
|
4
|
+
*/ export function useMountedState() {
|
|
5
|
+
const mountedRef = useRef(false);
|
|
6
|
+
const get = useCallback(()=>mountedRef.current, []);
|
|
7
|
+
useEffect(()=>{
|
|
9
8
|
mountedRef.current = true;
|
|
10
|
-
return
|
|
9
|
+
return ()=>{
|
|
11
10
|
mountedRef.current = false;
|
|
12
11
|
};
|
|
13
12
|
}, []);
|
package/hooks/useNavigateAway.js
CHANGED
|
@@ -1,73 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* For the callback technique see:
|
|
25
|
-
* - https://stackoverflow.com/a/11835394/1938970
|
|
26
|
-
*/
|
|
27
|
-
var useNavigateAway = function (handler) {
|
|
28
|
-
var beforeUnloadHandlerRef = (0, react_1.useRef)();
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
useNavigateAway: function() {
|
|
13
|
+
return useNavigateAway;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _react = require("react");
|
|
21
|
+
const _on = /*#__PURE__*/ _interop_require_default._(require("@koine/dom/on"));
|
|
22
|
+
const useNavigateAway = (handler)=>{
|
|
23
|
+
const beforeUnloadHandlerRef = (0, _react.useRef)();
|
|
29
24
|
// const pagehideHandlerRef = useRef<UseNavigateAwayPagehideHandler | undefined>();
|
|
30
|
-
(0,
|
|
31
|
-
beforeUnloadHandlerRef.current =
|
|
32
|
-
|
|
25
|
+
(0, _react.useEffect)(()=>{
|
|
26
|
+
beforeUnloadHandlerRef.current = (event)=>{
|
|
27
|
+
const customMessageOrCondition = handler(event);
|
|
33
28
|
if (customMessageOrCondition) {
|
|
34
29
|
event.preventDefault();
|
|
35
30
|
}
|
|
36
31
|
// Handle legacy `event.returnValue` property
|
|
37
32
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
|
|
38
33
|
if (typeof customMessageOrCondition === "string") {
|
|
39
|
-
return
|
|
34
|
+
return event.returnValue = customMessageOrCondition;
|
|
40
35
|
}
|
|
41
36
|
// Chrome doesn't support `event.preventDefault()` on `BeforeUnloadEvent`,
|
|
42
37
|
// instead it requires `event.returnValue` to be set
|
|
43
38
|
// https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#browser_compatibility
|
|
44
39
|
if (event.defaultPrevented) {
|
|
45
|
-
return
|
|
40
|
+
return event.returnValue = "";
|
|
46
41
|
}
|
|
47
42
|
return;
|
|
48
43
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, [
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
// pagehideHandlerRef.current = (event) => {
|
|
45
|
+
// const returnValue = handler?.(event);
|
|
46
|
+
// if (event.persisted) {
|
|
47
|
+
// // If the event's persisted property is `true` the page is about
|
|
48
|
+
// // to enter the Back-Forward Cache, which is also in the frozen state.
|
|
49
|
+
// } else {
|
|
50
|
+
// // If the event's persisted property is not `true` the page is
|
|
51
|
+
// // about to be unloaded.
|
|
52
|
+
// }
|
|
53
|
+
// };
|
|
54
|
+
}, [
|
|
55
|
+
handler
|
|
56
|
+
]);
|
|
57
|
+
(0, _react.useEffect)(()=>{
|
|
58
|
+
const listenerBeforeunload = (0, _on.default)(window, "beforeunload", (event)=>beforeUnloadHandlerRef.current?.(event));
|
|
62
59
|
// const listenerPagehide = on(window, "pagehide", (event) =>
|
|
63
60
|
// pagehideHandlerRef.current?.(event)
|
|
64
61
|
// );
|
|
65
62
|
return listenerBeforeunload;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
// return () => {
|
|
64
|
+
// listenerBeforeunload();
|
|
65
|
+
// // listenerPagehide();
|
|
66
|
+
// };
|
|
70
67
|
}, []);
|
|
71
68
|
};
|
|
72
|
-
|
|
73
|
-
exports.default = exports.useNavigateAway;
|
|
69
|
+
const _default = useNavigateAway;
|
|
@@ -19,50 +19,51 @@ import on from "@koine/dom/on";
|
|
|
19
19
|
*
|
|
20
20
|
* For the callback technique see:
|
|
21
21
|
* - https://stackoverflow.com/a/11835394/1938970
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
var beforeUnloadHandlerRef = useRef();
|
|
22
|
+
*/ export const useNavigateAway = (handler)=>{
|
|
23
|
+
const beforeUnloadHandlerRef = useRef();
|
|
25
24
|
// const pagehideHandlerRef = useRef<UseNavigateAwayPagehideHandler | undefined>();
|
|
26
|
-
useEffect(
|
|
27
|
-
beforeUnloadHandlerRef.current =
|
|
28
|
-
|
|
25
|
+
useEffect(()=>{
|
|
26
|
+
beforeUnloadHandlerRef.current = (event)=>{
|
|
27
|
+
const customMessageOrCondition = handler(event);
|
|
29
28
|
if (customMessageOrCondition) {
|
|
30
29
|
event.preventDefault();
|
|
31
30
|
}
|
|
32
31
|
// Handle legacy `event.returnValue` property
|
|
33
32
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
|
|
34
33
|
if (typeof customMessageOrCondition === "string") {
|
|
35
|
-
return
|
|
34
|
+
return event.returnValue = customMessageOrCondition;
|
|
36
35
|
}
|
|
37
36
|
// Chrome doesn't support `event.preventDefault()` on `BeforeUnloadEvent`,
|
|
38
37
|
// instead it requires `event.returnValue` to be set
|
|
39
38
|
// https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#browser_compatibility
|
|
40
39
|
if (event.defaultPrevented) {
|
|
41
|
-
return
|
|
40
|
+
return event.returnValue = "";
|
|
42
41
|
}
|
|
43
42
|
return;
|
|
44
43
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}, [
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
// pagehideHandlerRef.current = (event) => {
|
|
45
|
+
// const returnValue = handler?.(event);
|
|
46
|
+
// if (event.persisted) {
|
|
47
|
+
// // If the event's persisted property is `true` the page is about
|
|
48
|
+
// // to enter the Back-Forward Cache, which is also in the frozen state.
|
|
49
|
+
// } else {
|
|
50
|
+
// // If the event's persisted property is not `true` the page is
|
|
51
|
+
// // about to be unloaded.
|
|
52
|
+
// }
|
|
53
|
+
// };
|
|
54
|
+
}, [
|
|
55
|
+
handler
|
|
56
|
+
]);
|
|
57
|
+
useEffect(()=>{
|
|
58
|
+
const listenerBeforeunload = on(window, "beforeunload", (event)=>beforeUnloadHandlerRef.current?.(event));
|
|
58
59
|
// const listenerPagehide = on(window, "pagehide", (event) =>
|
|
59
60
|
// pagehideHandlerRef.current?.(event)
|
|
60
61
|
// );
|
|
61
62
|
return listenerBeforeunload;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
// return () => {
|
|
64
|
+
// listenerBeforeunload();
|
|
65
|
+
// // listenerPagehide();
|
|
66
|
+
// };
|
|
66
67
|
}, []);
|
|
67
68
|
};
|
|
68
69
|
export default useNavigateAway;
|
package/hooks/usePrevious.js
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
usePrevious: function() {
|
|
13
|
+
return usePrevious;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _react = require("react");
|
|
8
20
|
function usePrevious(state, defaulValue) {
|
|
9
|
-
|
|
21
|
+
const [tuple, setTuple] = (0, _react.useState)([
|
|
22
|
+
state,
|
|
23
|
+
defaulValue
|
|
24
|
+
]);
|
|
10
25
|
if (tuple[1] !== state) {
|
|
11
|
-
setTuple([
|
|
26
|
+
setTuple([
|
|
27
|
+
tuple[1],
|
|
28
|
+
state
|
|
29
|
+
]);
|
|
12
30
|
}
|
|
13
31
|
return tuple[0];
|
|
14
32
|
}
|
|
15
|
-
|
|
16
|
-
exports.default = usePrevious;
|
|
33
|
+
const _default = usePrevious;
|
package/hooks/usePrevious.mjs
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* @borrows [samselikoff/animated-carousel](https://github.com/samselikoff/2022-06-02-animated-carousel/blob/main/pages/final.jsx)
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
*/ export function usePrevious(state, defaulValue) {
|
|
5
|
+
const [tuple, setTuple] = useState([
|
|
6
|
+
state,
|
|
7
|
+
defaulValue
|
|
8
|
+
]);
|
|
7
9
|
if (tuple[1] !== state) {
|
|
8
|
-
setTuple([
|
|
10
|
+
setTuple([
|
|
11
|
+
tuple[1],
|
|
12
|
+
state
|
|
13
|
+
]);
|
|
9
14
|
}
|
|
10
15
|
return tuple[0];
|
|
11
16
|
}
|
package/hooks/usePreviousRef.js
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
usePreviousRef: function() {
|
|
13
|
+
return usePreviousRef;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _react = require("react");
|
|
5
20
|
function usePreviousRef(value) {
|
|
6
|
-
|
|
7
|
-
(0,
|
|
21
|
+
const ref = (0, _react.useRef)();
|
|
22
|
+
(0, _react.useEffect)(()=>{
|
|
8
23
|
ref.current = value;
|
|
9
24
|
});
|
|
10
25
|
return ref.current;
|
|
11
26
|
}
|
|
12
|
-
|
|
13
|
-
exports.default = usePreviousRef;
|
|
27
|
+
const _default = usePreviousRef;
|
package/hooks/usePreviousRef.mjs
CHANGED