@koine/react 1.0.11 → 1.0.14
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 +7 -13
- package/Animations/Reveal.js +12 -10
- package/Animations/Underline.js +3 -13
- package/Animations/useReveal.js +18 -17
- package/Autocomplete/AutocompleteDownshift.js +1 -1
- package/Autocomplete/AutocompleteDownshiftMultiselect.js +1 -1
- package/Autocomplete/AutocompleteMui.js +61 -56
- package/Autocomplete/AutocompleteReach.js +1 -1
- package/Autocomplete/components.js +17 -72
- package/Autocomplete/helpers.js +1 -1
- package/Bg/BgColor.js +14 -24
- package/Bg/BgPhoto.js +11 -54
- package/Bg/BgSvg.js +6 -9
- package/Breadcrumbs/Breadcrumbs.js +14 -54
- package/Buttons/Button.js +8 -73
- package/Buttons/ButtonComposite.js +20 -41
- package/Buttons/ButtonFab.js +4 -6
- package/Buttons/ButtonLink.js +7 -6
- package/Buttons/IconButton.js +5 -17
- package/Calendar/CalendarDaygridCell.js +20 -14
- package/Calendar/CalendarDaygridNav.js +10 -9
- package/Calendar/CalendarDaygridTable.js +32 -30
- package/Calendar/CalendarLegend.js +7 -2
- package/Calendar/calendar-api-google.js +101 -68
- package/Calendar/useCalendar.js +114 -113
- package/Calendar/utils.js +73 -74
- package/Carousel/Carousel.js +1 -1
- package/Carousel/CarouselCss.js +12 -26
- package/Collapsable/Collapsable.js +1 -1
- package/Debug/Debug.js +5 -17
- package/Details/Details.js +30 -27
- package/Dialog/DialogMui.js +22 -20
- package/Dialog/css/bare.js +17 -15
- package/Dialog/m/bare.js +17 -13
- package/Dialog/m/basic.js +2 -2
- package/Dialog/m/index.js +4 -4
- package/Dialog/sc/bare.js +25 -43
- package/Dialog/sc/framer.js +6 -6
- package/Dialog/sc/framerMaterial.js +6 -6
- package/Dialog/sc/material.js +17 -37
- package/Dialog/tw/bare.js +25 -19
- package/Dialog/tw/elegant.js +17 -15
- package/Dialog/tw/framer.js +6 -6
- package/Dialog/tw/framerMaterial.js +6 -6
- package/Dialog/tw/material.js +17 -15
- package/Editor/Editor--tiptap.js +14 -11
- package/Editor/components.js +6 -24
- package/Favicon/FaviconTags.js +2 -1
- package/Form/Form.js +30 -28
- package/Form/sc/bare.js +9 -18
- package/Forms/Checkbox/Checkbox.js +9 -15
- package/Forms/Feedback/Feedback.js +6 -7
- package/Forms/Field/Field.js +15 -26
- package/Forms/Field/FieldControl.js +19 -15
- package/Forms/Field/FieldHint.js +3 -5
- package/Forms/Input/Input.js +10 -16
- package/Forms/InputGroup/InputGroup.js +9 -36
- package/Forms/Label/Label.js +5 -23
- package/Forms/Password/Password.js +10 -23
- package/Forms/Radio/Radio.js +15 -18
- package/Forms/Switch/Switch.js +9 -39
- package/Forms/Textarea/Textarea.js +6 -7
- package/Forms/Textarea/TextareaRich.js +10 -24
- package/Forms/Toggle/Toggle.js +19 -67
- package/Forms/Toggle/useToggle.d.ts +1 -1
- package/Forms/Toggle/useToggle.js +30 -30
- package/Forms/antispam.js +12 -12
- package/Forms/helpers.js +7 -6
- package/Forms/styles.js +12 -43
- package/Gauge/Gauge.js +1 -1
- package/Grid/Grid.js +25 -51
- package/Hamburger/Hamburger.js +35 -47
- package/Header/useHeader.js +12 -12
- package/Hidden/Hidden.js +9 -13
- package/Img/sc/bare.js +3 -1
- package/Link/Link.js +3 -1
- package/Link/LinkBlank.js +8 -17
- package/Menu/Menu.js +3 -10
- package/MenuItem/MenuItem.js +3 -19
- package/Meta/Meta.js +3 -2
- package/NoJs/NoJs.js +2 -2
- package/Pagination/PaginationNav.js +26 -48
- package/Pagination/PaginationResults.js +7 -6
- package/Pill/Pill.js +6 -36
- package/Progress/ProgressCircular.js +9 -30
- package/Progress/ProgressLinear.js +8 -16
- package/Progress/ProgressOverlay.js +11 -27
- package/Rating/Rating.js +24 -44
- package/Rating/index.js +19 -15
- package/Select/SelectDownshift.js +1 -1
- package/Select/components.js +6 -12
- package/Sidebar/Sidebar.js +13 -38
- package/Spacing/Spacing.js +12 -12
- package/Sticky/Sticky.js +1 -1
- package/Sticky/StickyCss.js +4 -2
- package/Tabs/TabsMui.js +19 -16
- package/Tabs/tw/bare.js +13 -11
- package/Tabs/tw/material.js +15 -11
- package/Tabs/useTabs.js +16 -16
- package/Typography/CopyPasteVisible.js +3 -5
- package/Typography/Native.js +12 -45
- package/Typography/ReadMore.js +25 -51
- package/Typography/TextLoop.js +19 -22
- package/Typography/TypeStairs.js +20 -16
- package/helpers/classed.js +21 -18
- package/helpers/extend-component.js +6 -6
- package/hooks/useAsyncFn.js +18 -11
- package/hooks/useDateLocale.js +22 -13
- package/hooks/useEffectOnce.js +1 -1
- package/hooks/useFirstMountState.js +1 -1
- package/hooks/useFocus.js +3 -3
- package/hooks/useId.js +3 -2
- package/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/hooks/useMount.js +2 -2
- package/hooks/useMountedState.js +4 -4
- package/hooks/usePrevious.js +2 -2
- package/hooks/useScrollPosition.js +20 -15
- package/hooks/useScrollTo.js +7 -5
- package/hooks/useTraceUpdate.js +4 -3
- package/hooks/useUpdateEffect.js +3 -3
- package/hooks/useWindowSize.js +3 -3
- package/m/MotionProvider.js +4 -2
- package/package.json +8 -7
- package/styles/Body.js +4 -8
- package/styles/Global.js +4 -36
- package/styles/media.js +41 -36
- package/styles/spacing.js +15 -16
- package/styles/styled.js +7 -21
- package/styles/theme--vanilla.js +20 -18
- package/styles/theme.js +11 -11
- package/node/Alert/Alert.js +0 -21
- package/node/Alert/index.js +0 -4
- package/node/Animations/Reveal.js +0 -19
- package/node/Animations/Underline.js +0 -19
- package/node/Animations/index.js +0 -6
- package/node/Animations/useReveal.js +0 -74
- package/node/Autocomplete/AutocompleteDownshift.js +0 -161
- package/node/Autocomplete/AutocompleteDownshiftMultiselect.js +0 -356
- package/node/Autocomplete/AutocompleteMui.js +0 -175
- package/node/Autocomplete/AutocompleteReach.js +0 -115
- package/node/Autocomplete/components.js +0 -93
- package/node/Autocomplete/helpers.js +0 -32
- package/node/Autocomplete/index.js +0 -7
- package/node/Bg/BgColor.js +0 -36
- package/node/Bg/BgPhoto.js +0 -64
- package/node/Bg/BgSvg.js +0 -20
- package/node/Bg/index.js +0 -6
- package/node/Breadcrumbs/Breadcrumbs.js +0 -72
- package/node/Breadcrumbs/index.js +0 -4
- package/node/Buttons/Button.js +0 -83
- package/node/Buttons/ButtonComposite.js +0 -54
- package/node/Buttons/ButtonFab.js +0 -12
- package/node/Buttons/ButtonLink.js +0 -15
- package/node/Buttons/IconButton.js +0 -23
- package/node/Buttons/index.js +0 -8
- package/node/Calendar/CalendarDaygridCell.js +0 -55
- package/node/Calendar/CalendarDaygridNav.js +0 -27
- package/node/Calendar/CalendarDaygridTable.js +0 -60
- package/node/Calendar/CalendarLegend.js +0 -15
- package/node/Calendar/calendar-api-google.js +0 -99
- package/node/Calendar/index.js +0 -9
- package/node/Calendar/types.js +0 -2
- package/node/Calendar/useCalendar.js +0 -186
- package/node/Calendar/utils.js +0 -217
- package/node/Carousel/Carousel.js +0 -381
- package/node/Carousel/CarouselCss.js +0 -42
- package/node/Carousel/index.js +0 -4
- package/node/Collapsable/Collapsable.js +0 -4
- package/node/Collapsable/CollapsableReach.js +0 -253
- package/node/Collapsable/index.js +0 -5
- package/node/Debug/Debug.js +0 -26
- package/node/Debug/index.js +0 -4
- package/node/Details/Details.js +0 -65
- package/node/Details/index.js +0 -4
- package/node/Dialog/DialogMui.js +0 -82
- package/node/Dialog/css/bare.js +0 -23
- package/node/Dialog/index.js +0 -5
- package/node/Dialog/m/bare.js +0 -51
- package/node/Dialog/m/basic.js +0 -35
- package/node/Dialog/m/index.js +0 -8
- package/node/Dialog/sc/bare.js +0 -65
- package/node/Dialog/sc/framer.js +0 -19
- package/node/Dialog/sc/framerMaterial.js +0 -19
- package/node/Dialog/sc/material.js +0 -45
- package/node/Dialog/tw/bare.js +0 -40
- package/node/Dialog/tw/elegant.js +0 -21
- package/node/Dialog/tw/framer.js +0 -19
- package/node/Dialog/tw/framerMaterial.js +0 -19
- package/node/Dialog/tw/material.js +0 -21
- package/node/Editor/Editor--tiptap.js +0 -29
- package/node/Editor/components.js +0 -34
- package/node/Editor/index.js +0 -4
- package/node/Favicon/FaviconTags.js +0 -18
- package/node/Favicon/index.js +0 -4
- package/node/Form/Form.js +0 -63
- package/node/Form/index.js +0 -4
- package/node/Form/sc/bare.js +0 -33
- package/node/Forms/Checkbox/Checkbox.js +0 -28
- package/node/Forms/Checkbox/index.js +0 -4
- package/node/Forms/Feedback/Feedback.js +0 -15
- package/node/Forms/Feedback/index.js +0 -4
- package/node/Forms/Field/Field.js +0 -64
- package/node/Forms/Field/FieldControl.js +0 -47
- package/node/Forms/Field/FieldHint.js +0 -10
- package/node/Forms/Field/index.js +0 -5
- package/node/Forms/Input/Input.js +0 -27
- package/node/Forms/Input/index.js +0 -4
- package/node/Forms/InputGroup/InputGroup.js +0 -47
- package/node/Forms/InputGroup/index.js +0 -4
- package/node/Forms/Label/Label.js +0 -28
- package/node/Forms/Label/index.js +0 -4
- package/node/Forms/Password/Password.js +0 -34
- package/node/Forms/Password/index.js +0 -4
- package/node/Forms/Radio/Radio.js +0 -32
- package/node/Forms/Radio/index.js +0 -4
- package/node/Forms/Switch/Switch.js +0 -54
- package/node/Forms/Switch/index.js +0 -4
- package/node/Forms/Textarea/Textarea.js +0 -17
- package/node/Forms/Textarea/TextareaRich.js +0 -46
- package/node/Forms/Textarea/index.js +0 -5
- package/node/Forms/Toggle/Toggle.js +0 -86
- package/node/Forms/Toggle/index.js +0 -4
- package/node/Forms/Toggle/useToggle.js +0 -149
- package/node/Forms/antispam.js +0 -61
- package/node/Forms/helpers.js +0 -51
- package/node/Forms/index.js +0 -19
- package/node/Forms/styles.js +0 -64
- package/node/Gauge/Gauge.js +0 -106
- package/node/Grid/Grid.js +0 -83
- package/node/Grid/index.js +0 -4
- package/node/Hamburger/Hamburger.js +0 -69
- package/node/Hamburger/index.js +0 -4
- package/node/Header/index.js +0 -4
- package/node/Header/useHeader.js +0 -34
- package/node/Hidden/Hidden.js +0 -18
- package/node/Hidden/index.js +0 -4
- package/node/Img/index.js +0 -4
- package/node/Img/sc/bare.js +0 -41
- package/node/Img/types.js +0 -2
- package/node/Link/Link.js +0 -6
- package/node/Link/LinkBlank.js +0 -31
- package/node/Link/index.js +0 -5
- package/node/Menu/Menu.js +0 -15
- package/node/Menu/index.js +0 -4
- package/node/MenuItem/MenuItem.js +0 -24
- package/node/MenuItem/index.js +0 -4
- package/node/Meta/Meta.js +0 -8
- package/node/Meta/index.js +0 -4
- package/node/NoJs/NoJs.js +0 -10
- package/node/NoJs/index.js +0 -4
- package/node/Pagination/PaginationNav.js +0 -88
- package/node/Pagination/PaginationResults.js +0 -15
- package/node/Pagination/index.js +0 -5
- package/node/Pill/Pill.js +0 -41
- package/node/Pill/index.js +0 -4
- package/node/Progress/ProgressCircular.js +0 -41
- package/node/Progress/ProgressLinear.js +0 -37
- package/node/Progress/ProgressOverlay.js +0 -45
- package/node/Progress/index.js +0 -6
- package/node/Rating/Rating.js +0 -97
- package/node/Rating/index.js +0 -53
- package/node/Select/SelectDownshift.js +0 -41
- package/node/Select/components.js +0 -22
- package/node/Select/index.js +0 -7
- package/node/Sidebar/Sidebar.js +0 -53
- package/node/Sidebar/index.js +0 -4
- package/node/Spacing/Spacing.js +0 -50
- package/node/Spacing/index.js +0 -4
- package/node/Sticky/Sticky.js +0 -222
- package/node/Sticky/StickyCss.js +0 -8
- package/node/Sticky/index.js +0 -4
- package/node/Tabs/TabsMui.js +0 -47
- package/node/Tabs/index.js +0 -4
- package/node/Tabs/sc/bare.js +0 -87
- package/node/Tabs/tw/bare.js +0 -19
- package/node/Tabs/tw/material.js +0 -17
- package/node/Tabs/useTabs.js +0 -48
- package/node/Typography/CopyPasteVisible.js +0 -10
- package/node/Typography/Native.js +0 -51
- package/node/Typography/ReadMore.js +0 -74
- package/node/Typography/TextLoop.js +0 -54
- package/node/Typography/TypeStairs.js +0 -49
- package/node/Typography/index.js +0 -8
- package/node/css/index.js +0 -36
- package/node/helpers/classed.js +0 -69
- package/node/helpers/extend-component.js +0 -16
- package/node/helpers/index.js +0 -5
- package/node/hooks/index.js +0 -18
- package/node/hooks/types.js +0 -2
- package/node/hooks/useAsyncFn.js +0 -33
- package/node/hooks/useDateLocale.js +0 -56
- package/node/hooks/useEffectOnce.js +0 -12
- package/node/hooks/useFirstMountState.js +0 -16
- package/node/hooks/useFocus.js +0 -15
- package/node/hooks/useId.js +0 -11
- package/node/hooks/useIsomorphicLayoutEffect.js +0 -11
- package/node/hooks/useMount.js +0 -13
- package/node/hooks/useMountedState.js +0 -19
- package/node/hooks/usePrevious.js +0 -12
- package/node/hooks/useScrollPosition.js +0 -79
- package/node/hooks/useScrollTo.js +0 -23
- package/node/hooks/useTraceUpdate.js +0 -24
- package/node/hooks/useUpdateEffect.js +0 -18
- package/node/hooks/useWindowSize.js +0 -17
- package/node/index.js +0 -8
- package/node/m/MotionProvider.js +0 -41
- package/node/m/index.js +0 -9
- package/node/m/lite.js +0 -4
- package/node/m/max.js +0 -4
- package/node/sc/index.js +0 -37
- package/node/scm/index.js +0 -36
- package/node/shared/index.js +0 -11
- package/node/styles/Body.js +0 -21
- package/node/styles/Global.js +0 -53
- package/node/styles/index.js +0 -10
- package/node/styles/media.js +0 -156
- package/node/styles/spacing.js +0 -53
- package/node/styles/styled.js +0 -31
- package/node/styles/theme--vanilla.js +0 -59
- package/node/styles/theme.js +0 -45
- package/node/tw/index.js +0 -36
- package/node/twm/index.js +0 -36
- package/node/types.js +0 -2
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KoineCarousel = void 0;
|
|
4
|
-
exports.KoineCarousel = null;
|
|
5
|
-
// import React, { useEffect, useState, useRef } from 'react';
|
|
6
|
-
// import Slide from './slide';
|
|
7
|
-
// import { getSliderListStyles } from './slider-list';
|
|
8
|
-
// import { CarouselProps, KeyCodeFunction } from './types';
|
|
9
|
-
// import renderControls from './controls';
|
|
10
|
-
// import defaultProps from './default-carousel-props';
|
|
11
|
-
// import { getIndexes, addEvent, removeEvent } from './utils';
|
|
12
|
-
// import AnnounceSlide from './announce-slide';
|
|
13
|
-
// export const Carousel = (props: CarouselProps): React.ReactElement => {
|
|
14
|
-
// const count = React.Children.count(props.children);
|
|
15
|
-
// const [currentSlide, setCurrentSlide] = useState<number>(
|
|
16
|
-
// props.autoplayReverse ? count - props.slidesToShow : props.slideIndex
|
|
17
|
-
// );
|
|
18
|
-
// const [animation, setAnimation] = useState<boolean>(false);
|
|
19
|
-
// const [pause, setPause] = useState<boolean>(false);
|
|
20
|
-
// const [dragging, setDragging] = useState<boolean>(false);
|
|
21
|
-
// const [move, setMove] = useState<number>(0);
|
|
22
|
-
// const [keyboardMove, setKeyboardMove] = useState<KeyCodeFunction>(null);
|
|
23
|
-
// const carouselWidth = useRef<number | null>(null);
|
|
24
|
-
// const focus = useRef<boolean>(false);
|
|
25
|
-
// const prevMove = useRef<number>(0);
|
|
26
|
-
// const carouselEl = useRef<HTMLDivElement>(null);
|
|
27
|
-
// const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
28
|
-
// const isMounted = useRef<boolean>(true);
|
|
29
|
-
// useEffect(
|
|
30
|
-
// () => () => {
|
|
31
|
-
// isMounted.current = false;
|
|
32
|
-
// },
|
|
33
|
-
// []
|
|
34
|
-
// );
|
|
35
|
-
// const slidesToScroll =
|
|
36
|
-
// props.animation === 'fade' ? props.slidesToShow : props.slidesToScroll;
|
|
37
|
-
// const dragThreshold = (carouselWidth.current || 0) / props.slidesToShow / 2;
|
|
38
|
-
// const carouselRef = props.innerRef || carouselEl;
|
|
39
|
-
// const moveSlide = (to?: number) => {
|
|
40
|
-
// const [slide, endSlide] = getIndexes(
|
|
41
|
-
// currentSlide,
|
|
42
|
-
// currentSlide - slidesToScroll,
|
|
43
|
-
// count
|
|
44
|
-
// );
|
|
45
|
-
// to && props.beforeSlide(slide, endSlide);
|
|
46
|
-
// !props.disableAnimation && setAnimation(true);
|
|
47
|
-
// setCurrentSlide(to ?? currentSlide);
|
|
48
|
-
// setTimeout(
|
|
49
|
-
// () => {
|
|
50
|
-
// if (!isMounted.current) return;
|
|
51
|
-
// to && props.afterSlide(currentSlide);
|
|
52
|
-
// !props.disableAnimation && setAnimation(false);
|
|
53
|
-
// },
|
|
54
|
-
// !props.disableAnimation ? props.speed || 500 : 40
|
|
55
|
-
// ); // if animation is disabled decrease the speed to 40
|
|
56
|
-
// };
|
|
57
|
-
// const nextSlide = () => {
|
|
58
|
-
// if (props.wrapAround || currentSlide <= count) {
|
|
59
|
-
// moveSlide(currentSlide + slidesToScroll);
|
|
60
|
-
// } else {
|
|
61
|
-
// moveSlide();
|
|
62
|
-
// }
|
|
63
|
-
// };
|
|
64
|
-
// const prevSlide = () => {
|
|
65
|
-
// // boundary
|
|
66
|
-
// if (props.wrapAround || currentSlide > 0) {
|
|
67
|
-
// moveSlide(currentSlide - slidesToScroll);
|
|
68
|
-
// } else {
|
|
69
|
-
// moveSlide();
|
|
70
|
-
// }
|
|
71
|
-
// };
|
|
72
|
-
// useEffect(() => {
|
|
73
|
-
// if (props.autoplay && !animation && props.wrapAround) {
|
|
74
|
-
// if (currentSlide > count) {
|
|
75
|
-
// setCurrentSlide(currentSlide - count);
|
|
76
|
-
// if (timer?.current) {
|
|
77
|
-
// clearTimeout(timer.current);
|
|
78
|
-
// }
|
|
79
|
-
// } else if (currentSlide < 0) {
|
|
80
|
-
// setCurrentSlide(count - -currentSlide);
|
|
81
|
-
// if (timer?.current) {
|
|
82
|
-
// clearTimeout(timer.current);
|
|
83
|
-
// }
|
|
84
|
-
// }
|
|
85
|
-
// }
|
|
86
|
-
// }, [animation, currentSlide]);
|
|
87
|
-
// useEffect(() => {
|
|
88
|
-
// if (props.autoplay && !pause) {
|
|
89
|
-
// timer.current = setTimeout(() => {
|
|
90
|
-
// if (props.autoplayReverse) {
|
|
91
|
-
// if (!props.wrapAround && currentSlide > 0) {
|
|
92
|
-
// prevSlide();
|
|
93
|
-
// } else if (props.wrapAround) {
|
|
94
|
-
// prevSlide();
|
|
95
|
-
// }
|
|
96
|
-
// } else if (
|
|
97
|
-
// !props.wrapAround &&
|
|
98
|
-
// currentSlide < count - props.slidesToShow
|
|
99
|
-
// ) {
|
|
100
|
-
// nextSlide();
|
|
101
|
-
// } else if (props.wrapAround) {
|
|
102
|
-
// nextSlide();
|
|
103
|
-
// }
|
|
104
|
-
// }, props.autoplayInterval);
|
|
105
|
-
// }
|
|
106
|
-
// // Clear the timeout if user hover on carousel
|
|
107
|
-
// if (props.autoplay && pause && timer?.current) {
|
|
108
|
-
// clearTimeout(timer.current);
|
|
109
|
-
// }
|
|
110
|
-
// return () => {
|
|
111
|
-
// if (timer.current) {
|
|
112
|
-
// clearTimeout(timer.current);
|
|
113
|
-
// }
|
|
114
|
-
// };
|
|
115
|
-
// }, [currentSlide, pause]);
|
|
116
|
-
// useEffect(() => {
|
|
117
|
-
// // makes the loop infinity
|
|
118
|
-
// if (props.wrapAround && !props.autoplay) {
|
|
119
|
-
// // if animation is disabled decrease the speed to 0
|
|
120
|
-
// const speed = !props.disableAnimation ? props.speed || 500 : 0;
|
|
121
|
-
// if (currentSlide <= -props.slidesToShow) {
|
|
122
|
-
// // prev
|
|
123
|
-
// setTimeout(() => {
|
|
124
|
-
// if (!isMounted.current) return;
|
|
125
|
-
// setCurrentSlide(count - -currentSlide);
|
|
126
|
-
// }, speed + 10);
|
|
127
|
-
// } else if (currentSlide >= count) {
|
|
128
|
-
// // next
|
|
129
|
-
// setTimeout(() => {
|
|
130
|
-
// if (!isMounted.current) return;
|
|
131
|
-
// setCurrentSlide(currentSlide - count);
|
|
132
|
-
// }, speed + 10);
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
// }, [currentSlide]);
|
|
136
|
-
// useEffect(() => {
|
|
137
|
-
// if (props.enableKeyboardControls && keyboardMove && focus.current) {
|
|
138
|
-
// switch (keyboardMove) {
|
|
139
|
-
// case 'nextSlide':
|
|
140
|
-
// nextSlide(); // set boundaries for !wrapAround
|
|
141
|
-
// break;
|
|
142
|
-
// case 'previousSlide':
|
|
143
|
-
// prevSlide(); // set boundaries for !wrapAround
|
|
144
|
-
// break;
|
|
145
|
-
// case 'firstSlide':
|
|
146
|
-
// setCurrentSlide(0);
|
|
147
|
-
// break;
|
|
148
|
-
// case 'lastSlide':
|
|
149
|
-
// setCurrentSlide(count - props.slidesToShow);
|
|
150
|
-
// break;
|
|
151
|
-
// case 'pause':
|
|
152
|
-
// if (pause && props.autoplay) {
|
|
153
|
-
// setPause(false);
|
|
154
|
-
// break;
|
|
155
|
-
// } else if (props.autoplay) {
|
|
156
|
-
// setPause(true);
|
|
157
|
-
// break;
|
|
158
|
-
// }
|
|
159
|
-
// break;
|
|
160
|
-
// }
|
|
161
|
-
// setKeyboardMove(null);
|
|
162
|
-
// }
|
|
163
|
-
// }, [keyboardMove]);
|
|
164
|
-
// const onKeyPress = (e: Event) => {
|
|
165
|
-
// if (
|
|
166
|
-
// props.enableKeyboardControls &&
|
|
167
|
-
// focus.current &&
|
|
168
|
-
// (e as KeyboardEvent).keyCode
|
|
169
|
-
// ) {
|
|
170
|
-
// const keyConfig = props.keyCodeConfig;
|
|
171
|
-
// for (const func in keyConfig) {
|
|
172
|
-
// if (
|
|
173
|
-
// keyConfig[func as keyof typeof keyConfig]?.includes(
|
|
174
|
-
// (e as KeyboardEvent).keyCode
|
|
175
|
-
// )
|
|
176
|
-
// ) {
|
|
177
|
-
// setKeyboardMove(func as KeyCodeFunction);
|
|
178
|
-
// }
|
|
179
|
-
// }
|
|
180
|
-
// }
|
|
181
|
-
// };
|
|
182
|
-
// useEffect(() => {
|
|
183
|
-
// if (carouselEl && carouselEl.current) {
|
|
184
|
-
// carouselWidth.current = carouselEl.current.offsetWidth;
|
|
185
|
-
// } else if (props.innerRef) {
|
|
186
|
-
// carouselWidth.current = props.innerRef.current.offsetWidth;
|
|
187
|
-
// }
|
|
188
|
-
// if (props.enableKeyboardControls) {
|
|
189
|
-
// addEvent(document, 'keydown', onKeyPress);
|
|
190
|
-
// }
|
|
191
|
-
// return () => {
|
|
192
|
-
// removeEvent(document, 'keydown', onKeyPress);
|
|
193
|
-
// };
|
|
194
|
-
// }, []);
|
|
195
|
-
// const handleDragEnd = () => {
|
|
196
|
-
// if (!props.dragging || !dragging) return;
|
|
197
|
-
// setDragging(false);
|
|
198
|
-
// if (Math.abs(move) <= dragThreshold) {
|
|
199
|
-
// moveSlide();
|
|
200
|
-
// setMove(0);
|
|
201
|
-
// prevMove.current = 0;
|
|
202
|
-
// return;
|
|
203
|
-
// }
|
|
204
|
-
// if (move > 0) {
|
|
205
|
-
// nextSlide();
|
|
206
|
-
// } else {
|
|
207
|
-
// prevSlide();
|
|
208
|
-
// }
|
|
209
|
-
// setMove(0);
|
|
210
|
-
// prevMove.current = 0;
|
|
211
|
-
// };
|
|
212
|
-
// const onTouchStart = () => {
|
|
213
|
-
// if (!props.swiping) {
|
|
214
|
-
// return;
|
|
215
|
-
// }
|
|
216
|
-
// setDragging(true);
|
|
217
|
-
// };
|
|
218
|
-
// const handlePointerMove = (m: number) => {
|
|
219
|
-
// if (!props.dragging || !dragging) return;
|
|
220
|
-
// const moveValue = m * 0.75; // Friction
|
|
221
|
-
// const moveState = move + (moveValue - prevMove.current);
|
|
222
|
-
// // Exit drag early if passed threshold
|
|
223
|
-
// if (Math.abs(move) > dragThreshold) {
|
|
224
|
-
// handleDragEnd();
|
|
225
|
-
// return;
|
|
226
|
-
// }
|
|
227
|
-
// if (
|
|
228
|
-
// !props.wrapAround &&
|
|
229
|
-
// props.disableEdgeSwiping &&
|
|
230
|
-
// ((currentSlide <= 0 && moveState <= 0) ||
|
|
231
|
-
// (moveState > 0 && currentSlide >= count - props.slidesToShow))
|
|
232
|
-
// ) {
|
|
233
|
-
// prevMove.current = moveValue;
|
|
234
|
-
// return;
|
|
235
|
-
// }
|
|
236
|
-
// if (prevMove.current !== 0) {
|
|
237
|
-
// setMove(moveState);
|
|
238
|
-
// }
|
|
239
|
-
// prevMove.current = moveValue;
|
|
240
|
-
// };
|
|
241
|
-
// const onTouchMove = (e: React.TouchEvent<HTMLDivElement>) => {
|
|
242
|
-
// if (!props.dragging || !dragging) return;
|
|
243
|
-
// props.onDragStart(e);
|
|
244
|
-
// const moveValue = (carouselWidth?.current || 0) - e.touches[0].pageX;
|
|
245
|
-
// handlePointerMove(moveValue);
|
|
246
|
-
// };
|
|
247
|
-
// const onMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
248
|
-
// e?.preventDefault();
|
|
249
|
-
// carouselRef?.current?.focus();
|
|
250
|
-
// if (!props.dragging) return;
|
|
251
|
-
// setDragging(true);
|
|
252
|
-
// };
|
|
253
|
-
// const onMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
254
|
-
// if (!props.dragging || !dragging) return;
|
|
255
|
-
// props.onDragStart(e);
|
|
256
|
-
// const offsetX =
|
|
257
|
-
// e.clientX - (carouselRef.current?.getBoundingClientRect().left || 0);
|
|
258
|
-
// const moveValue = (carouselWidth?.current || 0) - offsetX;
|
|
259
|
-
// handlePointerMove(moveValue);
|
|
260
|
-
// };
|
|
261
|
-
// const onMouseUp = (e?: React.MouseEvent<HTMLDivElement>) => {
|
|
262
|
-
// e?.preventDefault();
|
|
263
|
-
// handleDragEnd();
|
|
264
|
-
// };
|
|
265
|
-
// const onMouseEnter = () => {
|
|
266
|
-
// if (props.pauseOnHover) {
|
|
267
|
-
// setPause(true);
|
|
268
|
-
// }
|
|
269
|
-
// };
|
|
270
|
-
// const onMouseLeave = () => {
|
|
271
|
-
// if (props.pauseOnHover) {
|
|
272
|
-
// setPause(false);
|
|
273
|
-
// }
|
|
274
|
-
// };
|
|
275
|
-
// const renderSlides = (typeOfSlide?: 'prev-cloned' | 'next-cloned') => {
|
|
276
|
-
// const slides = React.Children.map(props.children, (child, index) => {
|
|
277
|
-
// const isCurrentSlide = props.wrapAround
|
|
278
|
-
// ? currentSlide === index ||
|
|
279
|
-
// currentSlide === index + count ||
|
|
280
|
-
// currentSlide === index - count
|
|
281
|
-
// : currentSlide === index;
|
|
282
|
-
// return (
|
|
283
|
-
// <Slide
|
|
284
|
-
// key={`${typeOfSlide}-${index}`}
|
|
285
|
-
// count={count}
|
|
286
|
-
// currentSlide={currentSlide}
|
|
287
|
-
// index={index}
|
|
288
|
-
// isCurrentSlide={isCurrentSlide}
|
|
289
|
-
// typeOfSlide={typeOfSlide}
|
|
290
|
-
// wrapAround={props.wrapAround}
|
|
291
|
-
// cellSpacing={props.cellSpacing}
|
|
292
|
-
// animation={props.animation}
|
|
293
|
-
// slidesToShow={props.slidesToShow}
|
|
294
|
-
// speed={props.speed}
|
|
295
|
-
// zoomScale={props.zoomScale}
|
|
296
|
-
// cellAlign={props.cellAlign}
|
|
297
|
-
// >
|
|
298
|
-
// {child}
|
|
299
|
-
// </Slide>
|
|
300
|
-
// );
|
|
301
|
-
// });
|
|
302
|
-
// return slides;
|
|
303
|
-
// };
|
|
304
|
-
// const [slide] = getIndexes(
|
|
305
|
-
// currentSlide,
|
|
306
|
-
// currentSlide - slidesToScroll,
|
|
307
|
-
// count
|
|
308
|
-
// );
|
|
309
|
-
// return (
|
|
310
|
-
// <div
|
|
311
|
-
// className={'slider-container'}
|
|
312
|
-
// style={{
|
|
313
|
-
// position: 'relative',
|
|
314
|
-
// padding: props.withoutControls ? 0 : '0 60px 50px'
|
|
315
|
-
// }}
|
|
316
|
-
// onMouseEnter={onMouseEnter}
|
|
317
|
-
// onMouseLeave={onMouseLeave}
|
|
318
|
-
// >
|
|
319
|
-
// <AnnounceSlide
|
|
320
|
-
// ariaLive={props.autoplay && !pause ? 'off' : 'polite'}
|
|
321
|
-
// message={props.renderAnnounceSlideMessage({
|
|
322
|
-
// currentSlide: slide,
|
|
323
|
-
// count
|
|
324
|
-
// })}
|
|
325
|
-
// />
|
|
326
|
-
// <div
|
|
327
|
-
// className={['slider-frame', props.className || ''].join(' ').trim()}
|
|
328
|
-
// style={{
|
|
329
|
-
// overflow: 'hidden',
|
|
330
|
-
// width: '100%',
|
|
331
|
-
// position: 'relative',
|
|
332
|
-
// outline: 'none',
|
|
333
|
-
// ...props.style
|
|
334
|
-
// }}
|
|
335
|
-
// aria-label="carousel-slider"
|
|
336
|
-
// role="region"
|
|
337
|
-
// tabIndex={0}
|
|
338
|
-
// onFocus={() => (focus.current = true)}
|
|
339
|
-
// onBlur={() => (focus.current = false)}
|
|
340
|
-
// ref={props.innerRef || carouselEl}
|
|
341
|
-
// onMouseUp={onMouseUp}
|
|
342
|
-
// onMouseDown={onMouseDown}
|
|
343
|
-
// onMouseMove={onMouseMove}
|
|
344
|
-
// onMouseLeave={onMouseUp}
|
|
345
|
-
// onTouchStart={onTouchStart}
|
|
346
|
-
// onTouchEnd={handleDragEnd}
|
|
347
|
-
// onTouchMove={onTouchMove}
|
|
348
|
-
// >
|
|
349
|
-
// <div
|
|
350
|
-
// className="slider-list"
|
|
351
|
-
// style={getSliderListStyles(
|
|
352
|
-
// props.children,
|
|
353
|
-
// currentSlide,
|
|
354
|
-
// animation,
|
|
355
|
-
// props.slidesToShow,
|
|
356
|
-
// props.cellAlign,
|
|
357
|
-
// props.wrapAround,
|
|
358
|
-
// props.speed,
|
|
359
|
-
// move,
|
|
360
|
-
// props.animation
|
|
361
|
-
// )}
|
|
362
|
-
// >
|
|
363
|
-
// {props.wrapAround ? renderSlides('prev-cloned') : null}
|
|
364
|
-
// {renderSlides()}
|
|
365
|
-
// {props.wrapAround ? renderSlides('next-cloned') : null}
|
|
366
|
-
// </div>
|
|
367
|
-
// </div>
|
|
368
|
-
// {renderControls(
|
|
369
|
-
// props,
|
|
370
|
-
// count,
|
|
371
|
-
// currentSlide,
|
|
372
|
-
// moveSlide,
|
|
373
|
-
// nextSlide,
|
|
374
|
-
// prevSlide,
|
|
375
|
-
// slidesToScroll
|
|
376
|
-
// )}
|
|
377
|
-
// </div>
|
|
378
|
-
// );
|
|
379
|
-
// };
|
|
380
|
-
// Carousel.defaultProps = defaultProps;
|
|
381
|
-
// export default Carousel;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KoineCarouselCss = exports.CarouselCssCol = exports.CarouselCssRow = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const styled_components_1 = tslib_1.__importDefault(require("styled-components"));
|
|
8
|
-
const Grid_1 = require("../Grid");
|
|
9
|
-
const useId_1 = require("../hooks/useId");
|
|
10
|
-
exports.CarouselCssRow = (0, styled_components_1.default)(Grid_1.Row) `
|
|
11
|
-
${({ $gutter: cs, theme: { gutter } }) => `
|
|
12
|
-
margin-left: -${cs === Grid_1.GRID_GUTTER_DEFAULT ? gutter[Grid_1.GRID_GUTTER_DEFAULT] : (gutter[Grid_1.GRID_GUTTER_DEFAULT] - gutter[cs]) * 2}px;
|
|
13
|
-
margin-right: -${cs === Grid_1.GRID_GUTTER_DEFAULT ? gutter[Grid_1.GRID_GUTTER_DEFAULT] : (gutter[Grid_1.GRID_GUTTER_DEFAULT] - gutter[cs]) * 2}px;
|
|
14
|
-
padding-left: ${cs === Grid_1.GRID_GUTTER_DEFAULT ? gutter[Grid_1.GRID_GUTTER_DEFAULT] : gutter[Grid_1.GRID_GUTTER_DEFAULT] - gutter[cs]}px;
|
|
15
|
-
padding-right: ${cs === Grid_1.GRID_GUTTER_DEFAULT ? gutter[Grid_1.GRID_GUTTER_DEFAULT] : gutter[Grid_1.GRID_GUTTER_DEFAULT] - gutter[cs]}px;
|
|
16
|
-
`}
|
|
17
|
-
|
|
18
|
-
scroll-behavior: smooth;
|
|
19
|
-
scroll-snap-type: x;
|
|
20
|
-
-ms-overflow-style: none;
|
|
21
|
-
scrollbar-width: none;
|
|
22
|
-
|
|
23
|
-
&::-webkit-scrollbar {
|
|
24
|
-
display: none;
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
27
|
-
exports.CarouselCssCol = (0, styled_components_1.default)(Grid_1.Col) `
|
|
28
|
-
${(p) => p.$width && `flex-basis: ${p.$width}px; min-width: ${p.$width}px;`}
|
|
29
|
-
position: relative;
|
|
30
|
-
scroll-snap-align: ${(p) => p.$snap};
|
|
31
|
-
`;
|
|
32
|
-
/**
|
|
33
|
-
* For programmatic usage an example here @see https://stackoverflow.com/a/65902068/9122820
|
|
34
|
-
*/
|
|
35
|
-
const KoineCarouselCss = ({ items, $gutterRow, $gutterCol, $gutter = "quarter", $proportion, $snap = "center", width, children, ...colProps }) => {
|
|
36
|
-
const slides = children ? react_1.Children.toArray(children) : items;
|
|
37
|
-
const id = (0, useId_1.useId)();
|
|
38
|
-
if (!slides)
|
|
39
|
-
return null;
|
|
40
|
-
return ((0, jsx_runtime_1.jsx)(exports.CarouselCssRow, { "$noWrap": true, "$gutter": $gutterRow || $gutter, children: slides.map((_slide, idx) => ((0, jsx_runtime_1.jsx)(exports.CarouselCssCol, { ...colProps, "$gutter": $gutterCol || $gutter, "$width": width, children: slides[idx] }, `CarouselCssCol-${id}-${idx}`))) }));
|
|
41
|
-
};
|
|
42
|
-
exports.KoineCarouselCss = KoineCarouselCss;
|
package/node/Carousel/index.js
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file
|
|
4
|
-
*
|
|
5
|
-
* Maybe do a simplified version following this example:
|
|
6
|
-
* https://codesandbox.io/s/framer-motion-accordion-qx958?file=/src/Example.tsx
|
|
7
|
-
*/
|
|
8
|
-
// import { forwardRef, useCallback, useEffect, /* useId, */ useRef, useState } from "react";
|
|
9
|
-
// import styled from "styled-components";
|
|
10
|
-
// import { MotionProps, m } from "framer-motion";
|
|
11
|
-
// import {
|
|
12
|
-
// Disclosure,
|
|
13
|
-
// DisclosureButton,
|
|
14
|
-
// DisclosurePanel,
|
|
15
|
-
// } from "@reach/disclosure";
|
|
16
|
-
// import { BsBoxArrowInDown as IconCollapse } from "react-icons/bs";
|
|
17
|
-
// import { btnStyleReset } from "../Buttons";
|
|
18
|
-
// import { useWindowSize } from "../hooks/useWindowSize";
|
|
19
|
-
// import { InputInvisible } from "../Forms/styles";
|
|
20
|
-
// import { useId } from "../hooks/useId";
|
|
21
|
-
// export type CollapsableStyledProps = {
|
|
22
|
-
// $expanded?: boolean;
|
|
23
|
-
// };
|
|
24
|
-
// /**
|
|
25
|
-
// * `overflow-anchor: none;` keeps the same scrolling position
|
|
26
|
-
// * @see https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Accordion/Accordion.js#L54
|
|
27
|
-
// */
|
|
28
|
-
// export const CollapsableRoot = styled(Disclosure)`
|
|
29
|
-
// overflow-anchor: none;
|
|
30
|
-
// `;
|
|
31
|
-
// export const CollapsableHeadRoot = styled(m.label).attrs(
|
|
32
|
-
// (props: Pick<CollapsableHeadProps, "id">) => ({
|
|
33
|
-
// htmlFor: `${props.id}-input`,
|
|
34
|
-
// })
|
|
35
|
-
// )<Pick<CollapsableStyledProps, "$expanded">>`
|
|
36
|
-
// ${btnStyleReset}
|
|
37
|
-
// width: 100%;
|
|
38
|
-
// padding: 0;
|
|
39
|
-
// text-align: left;
|
|
40
|
-
// display: flex;
|
|
41
|
-
// justify-content: space-between;
|
|
42
|
-
// align-items: center;
|
|
43
|
-
// cursor: pointer;
|
|
44
|
-
// `;
|
|
45
|
-
// export const CollapsableHeadSpace = styled.div`
|
|
46
|
-
// flex: 1;
|
|
47
|
-
// padding-left: 20px;
|
|
48
|
-
// `;
|
|
49
|
-
// export const CollapsableHeadAction = styled.div`
|
|
50
|
-
// padding-left: 20px;
|
|
51
|
-
// `;
|
|
52
|
-
// export const CollaspableHeadLine = styled(m.div)`
|
|
53
|
-
// width: 0%;
|
|
54
|
-
// height: 1px;
|
|
55
|
-
// background: #bbb;
|
|
56
|
-
// `;
|
|
57
|
-
// export const collapsableHeadLineMotion = {
|
|
58
|
-
// hover: {
|
|
59
|
-
// width: "100%",
|
|
60
|
-
// transition: {
|
|
61
|
-
// duration: 0.4,
|
|
62
|
-
// },
|
|
63
|
-
// },
|
|
64
|
-
// };
|
|
65
|
-
// export const CollapsableHeadText = styled.div``;
|
|
66
|
-
// export const CollapsableHeadIcon = styled(m.div)``;
|
|
67
|
-
// export type CollapsableHeadProps = React.PropsWithChildren<
|
|
68
|
-
// Pick<CollapsableStyledProps, "$expanded"> &
|
|
69
|
-
// CollapsableComponents & {
|
|
70
|
-
// id: CollapsableProps["id"];
|
|
71
|
-
// onClick: (...args: any) => any;
|
|
72
|
-
// }
|
|
73
|
-
// >;
|
|
74
|
-
// export const CollapsableHead = ({
|
|
75
|
-
// $expanded,
|
|
76
|
-
// id,
|
|
77
|
-
// onClick,
|
|
78
|
-
// HeadRoot = CollapsableHeadRoot,
|
|
79
|
-
// HeadAction = CollapsableHeadAction,
|
|
80
|
-
// HeadIcon = CollapsableHeadIcon,
|
|
81
|
-
// children,
|
|
82
|
-
// }: CollapsableHeadProps) => {
|
|
83
|
-
// return (
|
|
84
|
-
// <DisclosureButton
|
|
85
|
-
// onClick={onClick}
|
|
86
|
-
// // tabIndex={0}
|
|
87
|
-
// // role="tab"
|
|
88
|
-
// initial="rest"
|
|
89
|
-
// whileHover="hover"
|
|
90
|
-
// $expanded={$expanded}
|
|
91
|
-
// as={HeadRoot}
|
|
92
|
-
// id={id}
|
|
93
|
-
// >
|
|
94
|
-
// <CollapsableHeadText>{children}</CollapsableHeadText>
|
|
95
|
-
// <CollapsableHeadSpace>
|
|
96
|
-
// <CollaspableHeadLine
|
|
97
|
-
// variants={collapsableHeadLineMotion}
|
|
98
|
-
// animate={$expanded ? "hover" : ""}
|
|
99
|
-
// />
|
|
100
|
-
// </CollapsableHeadSpace>
|
|
101
|
-
// {HeadAction && (
|
|
102
|
-
// <HeadAction>
|
|
103
|
-
// {HeadIcon && (
|
|
104
|
-
// <HeadIcon animate={{ rotate: $expanded ? 180 : 0 }}>
|
|
105
|
-
// <IconCollapse />
|
|
106
|
-
// </HeadIcon>
|
|
107
|
-
// )}
|
|
108
|
-
// </HeadAction>
|
|
109
|
-
// )}
|
|
110
|
-
// </DisclosureButton>
|
|
111
|
-
// );
|
|
112
|
-
// };
|
|
113
|
-
// export const CollapsableInput = styled(InputInvisible).attrs({
|
|
114
|
-
// type: "checkbox",
|
|
115
|
-
// })``;
|
|
116
|
-
// export const CollasableBodyWrap = styled(
|
|
117
|
-
// DisclosurePanel
|
|
118
|
-
// )<CollapsableStyledProps>`
|
|
119
|
-
// /* this is because @reach adds the "hidden" attribute */
|
|
120
|
-
// &[hidden] {
|
|
121
|
-
// display: block;
|
|
122
|
-
// }
|
|
123
|
-
// `;
|
|
124
|
-
// export const CollapsableBodyRoot = styled(m.div)`
|
|
125
|
-
// .no-js & {
|
|
126
|
-
// transition: margin-top 0.2s ease;
|
|
127
|
-
// }
|
|
128
|
-
// .no-js ${CollapsableInput}:checked + ${CollasableBodyWrap} & {
|
|
129
|
-
// margin-top: 0 !important;
|
|
130
|
-
// opacity: 1 !important;
|
|
131
|
-
// }
|
|
132
|
-
// `;
|
|
133
|
-
// export type CollapsableBodyProps = MotionProps &
|
|
134
|
-
// Pick<CollapsableStyledProps, "$expanded"> & {
|
|
135
|
-
// children?: React.ReactNode;
|
|
136
|
-
// style?: React.CSSProperties;
|
|
137
|
-
// };
|
|
138
|
-
// export const CollapsableBody = forwardRef<HTMLDivElement, CollapsableBodyProps>(
|
|
139
|
-
// function CollapsableBody(props, ref) {
|
|
140
|
-
// return <CollapsableBodyRoot ref={ref} {...props} />;
|
|
141
|
-
// }
|
|
142
|
-
// );
|
|
143
|
-
// export type CollapsableComponents = {
|
|
144
|
-
// HeadRoot?: typeof CollapsableHeadRoot;
|
|
145
|
-
// HeadAction?: null | typeof CollapsableHeadAction | React.FC<any>;
|
|
146
|
-
// HeadIcon?: null | typeof CollapsableHeadIcon | React.FC<any>;
|
|
147
|
-
// };
|
|
148
|
-
// export type CollapsableProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
149
|
-
// id?: string;
|
|
150
|
-
// expanded?: boolean;
|
|
151
|
-
// /** Used to trigger a recalculation effect */
|
|
152
|
-
// recalc?: any;
|
|
153
|
-
// onChange?: () => any;
|
|
154
|
-
// head: null | React.ReactNode;
|
|
155
|
-
// body: React.ReactNode;
|
|
156
|
-
// /** Amount of milliseconds after which the component collapses */
|
|
157
|
-
// // autoCollapse?: number;
|
|
158
|
-
// components?: CollapsableComponents;
|
|
159
|
-
// /** @default "Expand" */
|
|
160
|
-
// ariaExpand?: string;
|
|
161
|
-
// /** @default "Collapse" */
|
|
162
|
-
// ariaCollapse?: string;
|
|
163
|
-
// };
|
|
164
|
-
// export const Collapsable = ({
|
|
165
|
-
// expanded: propExpanded,
|
|
166
|
-
// recalc,
|
|
167
|
-
// onChange,
|
|
168
|
-
// id,
|
|
169
|
-
// head,
|
|
170
|
-
// body,
|
|
171
|
-
// // autoCollapse,
|
|
172
|
-
// components = {},
|
|
173
|
-
// ariaExpand = "Expand",
|
|
174
|
-
// ariaCollapse = "Collapse",
|
|
175
|
-
// ...props
|
|
176
|
-
// }: CollapsableProps) => {
|
|
177
|
-
// const isControlled = typeof propExpanded !== "undefined";
|
|
178
|
-
// const [stateExpanded, setStateExpanded] = useState(propExpanded);
|
|
179
|
-
// const [height, setHeight] = useState(0);
|
|
180
|
-
// const hash = id ? `#${id}` : "";
|
|
181
|
-
// const winSize = useWindowSize();
|
|
182
|
-
// const expanded = isControlled ? propExpanded : stateExpanded;
|
|
183
|
-
// const [overflow, setOverflow] = useState(expanded ? "unset" : "hidden");
|
|
184
|
-
// const content = useRef<HTMLDivElement>(null);
|
|
185
|
-
// const defaultId = useId();
|
|
186
|
-
// id = id || defaultId;
|
|
187
|
-
// const handleClick = useCallback(() => {
|
|
188
|
-
// if (hash) {
|
|
189
|
-
// window.history.replaceState(
|
|
190
|
-
// null,
|
|
191
|
-
// "",
|
|
192
|
-
// expanded ? window.location.pathname + window.location.search : hash
|
|
193
|
-
// );
|
|
194
|
-
// }
|
|
195
|
-
// if (onChange) {
|
|
196
|
-
// onChange();
|
|
197
|
-
// }
|
|
198
|
-
// if (!isControlled) {
|
|
199
|
-
// setStateExpanded((prevExpanded) => !prevExpanded);
|
|
200
|
-
// }
|
|
201
|
-
// }, [expanded, hash, onChange, isControlled]);
|
|
202
|
-
// const handleAnimationStart = useCallback(() => {
|
|
203
|
-
// setOverflow("hidden");
|
|
204
|
-
// }, []);
|
|
205
|
-
// const handleAnimationComplete = useCallback(() => {
|
|
206
|
-
// setOverflow(expanded ? "unset" : "hidden");
|
|
207
|
-
// }, [expanded]);
|
|
208
|
-
// useEffect(() => {
|
|
209
|
-
// if (content.current) {
|
|
210
|
-
// setHeight(Math.ceil(content.current.offsetHeight));
|
|
211
|
-
// }
|
|
212
|
-
// }, [winSize, recalc]);
|
|
213
|
-
// // deeplink on mount
|
|
214
|
-
// useEffect(() => {
|
|
215
|
-
// if (!isControlled && hash && window.location.hash === hash) {
|
|
216
|
-
// setStateExpanded(true);
|
|
217
|
-
// }
|
|
218
|
-
// }, [hash, isControlled]);
|
|
219
|
-
// return (
|
|
220
|
-
// <CollapsableRoot id={id} {...props} open={expanded || false}>
|
|
221
|
-
// {head !== null && (
|
|
222
|
-
// <CollapsableHead
|
|
223
|
-
// id={id}
|
|
224
|
-
// $expanded={expanded}
|
|
225
|
-
// onClick={handleClick}
|
|
226
|
-
// {...components}
|
|
227
|
-
// >
|
|
228
|
-
// {head}
|
|
229
|
-
// </CollapsableHead>
|
|
230
|
-
// )}
|
|
231
|
-
// <CollapsableInput id={`${id}-input`} />
|
|
232
|
-
// <CollasableBodyWrap $expanded={expanded} style={{ overflow }}>
|
|
233
|
-
// <CollapsableBody
|
|
234
|
-
// ref={content}
|
|
235
|
-
// $expanded={expanded}
|
|
236
|
-
// // aria-expanded={expanded}
|
|
237
|
-
// // aria-label={expanded ? ariaCollapse : ariaExpand}
|
|
238
|
-
// style={{
|
|
239
|
-
// pointerEvents: expanded ? "all" : "none",
|
|
240
|
-
// }}
|
|
241
|
-
// onAnimationStart={handleAnimationStart}
|
|
242
|
-
// onAnimationComplete={handleAnimationComplete}
|
|
243
|
-
// animate={{
|
|
244
|
-
// marginTop: expanded ? 0 : height ? `-${height}px` : "-100vh",
|
|
245
|
-
// opacity: expanded ? 1 : 0.4,
|
|
246
|
-
// }}
|
|
247
|
-
// >
|
|
248
|
-
// {body}
|
|
249
|
-
// </CollapsableBody>
|
|
250
|
-
// </CollasableBodyWrap>
|
|
251
|
-
// </CollapsableRoot>
|
|
252
|
-
// );
|
|
253
|
-
// };
|