@codeleap/web 7.0.0 → 7.0.2
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/dist/components/ActivityIndicator/index.js +46 -0
- package/dist/components/ActivityIndicator/index.js.map +1 -0
- package/dist/components/ActivityIndicator/styles.js +3 -0
- package/dist/components/ActivityIndicator/styles.js.map +1 -0
- package/dist/components/ActivityIndicator/types.js +3 -0
- package/dist/components/ActivityIndicator/types.js.map +1 -0
- package/dist/components/Badge/index.js +86 -0
- package/dist/components/Badge/index.js.map +1 -0
- package/dist/components/Badge/styles.js +3 -0
- package/dist/components/Badge/styles.js.map +1 -0
- package/dist/components/Badge/types.js +3 -0
- package/dist/components/Badge/types.js.map +1 -0
- package/dist/components/Button/index.js +69 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/styles.js +3 -0
- package/dist/components/Button/styles.js.map +1 -0
- package/dist/components/Button/types.js +3 -0
- package/dist/components/Button/types.js.map +1 -0
- package/dist/components/Calendar/index.js +67 -0
- package/dist/components/Calendar/index.js.map +1 -0
- package/dist/components/Calendar/styles.js +3 -0
- package/dist/components/Calendar/styles.js.map +1 -0
- package/dist/components/Calendar/types.js +3 -0
- package/dist/components/Calendar/types.js.map +1 -0
- package/dist/components/Carousel/index.js +171 -0
- package/dist/components/Carousel/index.js.map +1 -0
- package/dist/components/Carousel/styles.js +3 -0
- package/dist/components/Carousel/styles.js.map +1 -0
- package/dist/components/Carousel/types.js +3 -0
- package/dist/components/Carousel/types.js.map +1 -0
- package/dist/components/Checkbox/index.js +62 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/Checkbox/styles.js +3 -0
- package/dist/components/Checkbox/styles.js.map +1 -0
- package/dist/components/Checkbox/types.js +3 -0
- package/dist/components/Checkbox/types.js.map +1 -0
- package/dist/components/Collapse/index.js +45 -0
- package/dist/components/Collapse/index.js.map +1 -0
- package/dist/components/Collapse/styles.js +3 -0
- package/dist/components/Collapse/styles.js.map +1 -0
- package/dist/components/Collapse/types.js +3 -0
- package/dist/components/Collapse/types.js.map +1 -0
- package/dist/components/ColorPicker/index.js +83 -0
- package/dist/components/ColorPicker/index.js.map +1 -0
- package/dist/components/ColorPicker/styles.js +3 -0
- package/dist/components/ColorPicker/styles.js.map +1 -0
- package/dist/components/ColorPicker/types.js +3 -0
- package/dist/components/ColorPicker/types.js.map +1 -0
- package/dist/components/CropPicker/hooks.d.ts +2 -2
- package/dist/components/CropPicker/hooks.js +133 -0
- package/dist/components/CropPicker/hooks.js.map +1 -0
- package/dist/components/CropPicker/index.js +56 -0
- package/dist/components/CropPicker/index.js.map +1 -0
- package/dist/components/CropPicker/styles.js +3 -0
- package/dist/components/CropPicker/styles.js.map +1 -0
- package/dist/components/CropPicker/types.js +3 -0
- package/dist/components/CropPicker/types.js.map +1 -0
- package/dist/components/CropPicker/utils.js +76 -0
- package/dist/components/CropPicker/utils.js.map +1 -0
- package/dist/components/DatePicker/index.js +87 -0
- package/dist/components/DatePicker/index.js.map +1 -0
- package/dist/components/DatePicker/styles.js +3 -0
- package/dist/components/DatePicker/styles.js.map +1 -0
- package/dist/components/DatePicker/types.js +3 -0
- package/dist/components/DatePicker/types.js.map +1 -0
- package/dist/components/Drawer/index.js +68 -0
- package/dist/components/Drawer/index.js.map +1 -0
- package/dist/components/Drawer/styles.js +3 -0
- package/dist/components/Drawer/styles.js.map +1 -0
- package/dist/components/Drawer/types.js +3 -0
- package/dist/components/Drawer/types.js.map +1 -0
- package/dist/components/Dropzone/context.js +44 -0
- package/dist/components/Dropzone/context.js.map +1 -0
- package/dist/components/Dropzone/elements.js +57 -0
- package/dist/components/Dropzone/elements.js.map +1 -0
- package/dist/components/Dropzone/index.js +89 -0
- package/dist/components/Dropzone/index.js.map +1 -0
- package/dist/components/Dropzone/styles.js +3 -0
- package/dist/components/Dropzone/styles.js.map +1 -0
- package/dist/components/Dropzone/types.js +3 -0
- package/dist/components/Dropzone/types.js.map +1 -0
- package/dist/components/Dropzone/useDropzone.js +20 -0
- package/dist/components/Dropzone/useDropzone.js.map +1 -0
- package/dist/components/EmptyPlaceholder/index.js +86 -0
- package/dist/components/EmptyPlaceholder/index.js.map +1 -0
- package/dist/components/EmptyPlaceholder/styles.js +3 -0
- package/dist/components/EmptyPlaceholder/styles.js.map +1 -0
- package/dist/components/EmptyPlaceholder/types.js +3 -0
- package/dist/components/EmptyPlaceholder/types.js.map +1 -0
- package/dist/components/Field/context.js +58 -0
- package/dist/components/Field/context.js.map +1 -0
- package/dist/components/Field/elements.js +92 -0
- package/dist/components/Field/elements.js.map +1 -0
- package/dist/components/Field/index.js +55 -0
- package/dist/components/Field/index.js.map +1 -0
- package/dist/components/Field/styles.js +3 -0
- package/dist/components/Field/styles.js.map +1 -0
- package/dist/components/Field/types.js +3 -0
- package/dist/components/Field/types.js.map +1 -0
- package/dist/components/Field/useFieldInput.d.ts +1 -1
- package/dist/components/Field/useFieldInput.js +50 -0
- package/dist/components/Field/useFieldInput.js.map +1 -0
- package/dist/components/FileInput/index.js +73 -0
- package/dist/components/FileInput/index.js.map +1 -0
- package/dist/components/FileInput/types.js +3 -0
- package/dist/components/FileInput/types.js.map +1 -0
- package/dist/components/Icon/index.js +69 -0
- package/dist/components/Icon/index.js.map +1 -0
- package/dist/components/Icon/styles.js +3 -0
- package/dist/components/Icon/styles.js.map +1 -0
- package/dist/components/Icon/types.js +3 -0
- package/dist/components/Icon/types.js.map +1 -0
- package/dist/components/List/context.js +81 -0
- package/dist/components/List/context.js.map +1 -0
- package/dist/components/List/elements.js +164 -0
- package/dist/components/List/elements.js.map +1 -0
- package/dist/components/List/index.js +52 -0
- package/dist/components/List/index.js.map +1 -0
- package/dist/components/List/scroll.js +80 -0
- package/dist/components/List/scroll.js.map +1 -0
- package/dist/components/List/styles.js +3 -0
- package/dist/components/List/styles.js.map +1 -0
- package/dist/components/List/types.js +3 -0
- package/dist/components/List/types.js.map +1 -0
- package/dist/components/LoadingOverlay/index.js +50 -0
- package/dist/components/LoadingOverlay/index.js.map +1 -0
- package/dist/components/LoadingOverlay/styles.js +3 -0
- package/dist/components/LoadingOverlay/styles.js.map +1 -0
- package/dist/components/LoadingOverlay/types.js +3 -0
- package/dist/components/LoadingOverlay/types.js.map +1 -0
- package/dist/components/MaskedTextInput/index.js +52 -0
- package/dist/components/MaskedTextInput/index.js.map +1 -0
- package/dist/components/MaskedTextInput/mask.js +37 -0
- package/dist/components/MaskedTextInput/mask.js.map +1 -0
- package/dist/components/MaskedTextInput/types.js +3 -0
- package/dist/components/MaskedTextInput/types.js.map +1 -0
- package/dist/components/Modal/context.js +41 -0
- package/dist/components/Modal/context.js.map +1 -0
- package/dist/components/Modal/elements.js +74 -0
- package/dist/components/Modal/elements.js.map +1 -0
- package/dist/components/Modal/index.js +52 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/styles.js +3 -0
- package/dist/components/Modal/styles.js.map +1 -0
- package/dist/components/Modal/types.js +3 -0
- package/dist/components/Modal/types.js.map +1 -0
- package/dist/components/NumberIncrement/index.js +83 -0
- package/dist/components/NumberIncrement/index.js.map +1 -0
- package/dist/components/NumberIncrement/styles.js +3 -0
- package/dist/components/NumberIncrement/styles.js.map +1 -0
- package/dist/components/NumberIncrement/types.js +3 -0
- package/dist/components/NumberIncrement/types.js.map +1 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js +116 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -0
- package/dist/components/Overlay/index.js +62 -0
- package/dist/components/Overlay/index.js.map +1 -0
- package/dist/components/Overlay/styles.js +3 -0
- package/dist/components/Overlay/styles.js.map +1 -0
- package/dist/components/Overlay/types.js +3 -0
- package/dist/components/Overlay/types.js.map +1 -0
- package/dist/components/PaginationButtons/index.js +118 -0
- package/dist/components/PaginationButtons/index.js.map +1 -0
- package/dist/components/PaginationButtons/styles.js +3 -0
- package/dist/components/PaginationButtons/styles.js.map +1 -0
- package/dist/components/PaginationButtons/types.js +3 -0
- package/dist/components/PaginationButtons/types.js.map +1 -0
- package/dist/components/PaginationIndicator/index.js +59 -0
- package/dist/components/PaginationIndicator/index.js.map +1 -0
- package/dist/components/PaginationIndicator/styles.js +3 -0
- package/dist/components/PaginationIndicator/styles.js.map +1 -0
- package/dist/components/PaginationIndicator/types.js +3 -0
- package/dist/components/PaginationIndicator/types.js.map +1 -0
- package/dist/components/Progress/Bar/Segmented.js +41 -0
- package/dist/components/Progress/Bar/Segmented.js.map +1 -0
- package/dist/components/Progress/Bar/index.js +62 -0
- package/dist/components/Progress/Bar/index.js.map +1 -0
- package/dist/components/Progress/Bar/styles.js +3 -0
- package/dist/components/Progress/Bar/styles.js.map +1 -0
- package/dist/components/Progress/Bar/types.js +3 -0
- package/dist/components/Progress/Bar/types.js.map +1 -0
- package/dist/components/Progress/Circle/Segmented.js +64 -0
- package/dist/components/Progress/Circle/Segmented.js.map +1 -0
- package/dist/components/Progress/Circle/index.js +83 -0
- package/dist/components/Progress/Circle/index.js.map +1 -0
- package/dist/components/Progress/Circle/styles.js +3 -0
- package/dist/components/Progress/Circle/styles.js.map +1 -0
- package/dist/components/Progress/Circle/types.js +3 -0
- package/dist/components/Progress/Circle/types.js.map +1 -0
- package/dist/components/Progress/index.js +19 -0
- package/dist/components/Progress/index.js.map +1 -0
- package/dist/components/Progress/utils.js +7 -0
- package/dist/components/Progress/utils.js.map +1 -0
- package/dist/components/RadioInput/index.js +68 -0
- package/dist/components/RadioInput/index.js.map +1 -0
- package/dist/components/RadioInput/styles.js +3 -0
- package/dist/components/RadioInput/styles.js.map +1 -0
- package/dist/components/RadioInput/types.js +3 -0
- package/dist/components/RadioInput/types.js.map +1 -0
- package/dist/components/SearchInput/index.js +98 -0
- package/dist/components/SearchInput/index.js.map +1 -0
- package/dist/components/SectionFilters/index.js +166 -0
- package/dist/components/SectionFilters/index.js.map +1 -0
- package/dist/components/SectionFilters/styles.js +3 -0
- package/dist/components/SectionFilters/styles.js.map +1 -0
- package/dist/components/SectionFilters/types.js +3 -0
- package/dist/components/SectionFilters/types.js.map +1 -0
- package/dist/components/Select/context.js +162 -0
- package/dist/components/Select/context.js.map +1 -0
- package/dist/components/Select/elements.js +53 -0
- package/dist/components/Select/elements.js.map +1 -0
- package/dist/components/Select/index.js +70 -0
- package/dist/components/Select/index.js.map +1 -0
- package/dist/components/Select/styles.js +3 -0
- package/dist/components/Select/styles.js.map +1 -0
- package/dist/components/Select/types.js +3 -0
- package/dist/components/Select/types.js.map +1 -0
- package/dist/components/Select/useTriggerWidth.js +30 -0
- package/dist/components/Select/useTriggerWidth.js.map +1 -0
- package/dist/components/Slider/index.js +160 -0
- package/dist/components/Slider/index.js.map +1 -0
- package/dist/components/Slider/styles.js +3 -0
- package/dist/components/Slider/styles.js.map +1 -0
- package/dist/components/Slider/types.js +3 -0
- package/dist/components/Slider/types.js.map +1 -0
- package/dist/components/Switch/index.js +66 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Switch/styles.js +3 -0
- package/dist/components/Switch/styles.js.map +1 -0
- package/dist/components/Switch/types.js +3 -0
- package/dist/components/Switch/types.js.map +1 -0
- package/dist/components/Tag/index.js +74 -0
- package/dist/components/Tag/index.js.map +1 -0
- package/dist/components/Tag/styles.js +3 -0
- package/dist/components/Tag/styles.js.map +1 -0
- package/dist/components/Tag/types.js +3 -0
- package/dist/components/Tag/types.js.map +1 -0
- package/dist/components/Text/index.js +115 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/Text/styles.js +3 -0
- package/dist/components/Text/styles.js.map +1 -0
- package/dist/components/Text/types.js +3 -0
- package/dist/components/Text/types.js.map +1 -0
- package/dist/components/TextEditor/index.js +111 -0
- package/dist/components/TextEditor/index.js.map +1 -0
- package/dist/components/TextEditor/styles.js +3 -0
- package/dist/components/TextEditor/styles.js.map +1 -0
- package/dist/components/TextEditor/types.js +3 -0
- package/dist/components/TextEditor/types.js.map +1 -0
- package/dist/components/TextInput/index.js +86 -0
- package/dist/components/TextInput/index.js.map +1 -0
- package/dist/components/TextInput/styles.js +3 -0
- package/dist/components/TextInput/styles.js.map +1 -0
- package/dist/components/TextInput/types.js +3 -0
- package/dist/components/TextInput/types.js.map +1 -0
- package/dist/components/TextInput/useTextInput.d.ts +2 -2
- package/dist/components/TextInput/useTextInput.js +67 -0
- package/dist/components/TextInput/useTextInput.js.map +1 -0
- package/dist/components/Tooltip/index.js +115 -0
- package/dist/components/Tooltip/index.js.map +1 -0
- package/dist/components/Tooltip/styles.js +3 -0
- package/dist/components/Tooltip/styles.js.map +1 -0
- package/dist/components/Tooltip/types.js +3 -0
- package/dist/components/Tooltip/types.js.map +1 -0
- package/dist/components/Touchable/index.js +100 -0
- package/dist/components/Touchable/index.js.map +1 -0
- package/dist/components/Touchable/styles.js +3 -0
- package/dist/components/Touchable/styles.js.map +1 -0
- package/dist/components/Touchable/types.js +3 -0
- package/dist/components/Touchable/types.js.map +1 -0
- package/dist/components/View/index.js +56 -0
- package/dist/components/View/index.js.map +1 -0
- package/dist/components/View/styles.js +3 -0
- package/dist/components/View/styles.js.map +1 -0
- package/dist/components/View/types.js +3 -0
- package/dist/components/View/types.js.map +1 -0
- package/dist/components/components.js +58 -0
- package/dist/components/components.js.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/ListMasonry.js +95 -0
- package/dist/lib/ListMasonry.js.map +1 -0
- package/dist/lib/ThemeVariables.js +27 -0
- package/dist/lib/ThemeVariables.js.map +1 -0
- package/dist/lib/WebStyleRegistry.js +73 -0
- package/dist/lib/WebStyleRegistry.js.map +1 -0
- package/dist/lib/hooks/index.js +39 -0
- package/dist/lib/hooks/index.js.map +1 -0
- package/dist/lib/hooks/useAnimatedStyle.js +27 -0
- package/dist/lib/hooks/useAnimatedStyle.js.map +1 -0
- package/dist/lib/hooks/useAnimatedVariantStyles.js +23 -0
- package/dist/lib/hooks/useAnimatedVariantStyles.js.map +1 -0
- package/dist/lib/hooks/useAsyncSelect.js +60 -0
- package/dist/lib/hooks/useAsyncSelect.js.map +1 -0
- package/dist/lib/hooks/useBreakpointMatch.js +111 -0
- package/dist/lib/hooks/useBreakpointMatch.js.map +1 -0
- package/dist/lib/hooks/useClick.js +41 -0
- package/dist/lib/hooks/useClick.js.map +1 -0
- package/dist/lib/hooks/useClickOutside.js +34 -0
- package/dist/lib/hooks/useClickOutside.js.map +1 -0
- package/dist/lib/hooks/useFileInput.js +21 -0
- package/dist/lib/hooks/useFileInput.js.map +1 -0
- package/dist/lib/hooks/useIsomorphicEffect.js +10 -0
- package/dist/lib/hooks/useIsomorphicEffect.js.map +1 -0
- package/dist/lib/hooks/useKeydown.js +43 -0
- package/dist/lib/hooks/useKeydown.js.map +1 -0
- package/dist/lib/hooks/useListFocus.js +49 -0
- package/dist/lib/hooks/useListFocus.js.map +1 -0
- package/dist/lib/hooks/useMediaQuery.js +28 -0
- package/dist/lib/hooks/useMediaQuery.js.map +1 -0
- package/dist/lib/hooks/usePageExitBlocker.js +48 -0
- package/dist/lib/hooks/usePageExitBlocker.js.map +1 -0
- package/dist/lib/hooks/usePagination.js +93 -0
- package/dist/lib/hooks/usePagination.js.map +1 -0
- package/dist/lib/hooks/usePopState.js +35 -0
- package/dist/lib/hooks/usePopState.js.map +1 -0
- package/dist/lib/hooks/usePopoverDismiss.js +35 -0
- package/dist/lib/hooks/usePopoverDismiss.js.map +1 -0
- package/dist/lib/hooks/useRefresh.js +74 -0
- package/dist/lib/hooks/useRefresh.js.map +1 -0
- package/dist/lib/hooks/useScrollEffect.js +22 -0
- package/dist/lib/hooks/useScrollEffect.js.map +1 -0
- package/dist/lib/hooks/useSearchParams.js +51 -0
- package/dist/lib/hooks/useSearchParams.js.map +1 -0
- package/dist/lib/hooks/useStaticAnimationStyles.js +19 -0
- package/dist/lib/hooks/useStaticAnimationStyles.js.map +1 -0
- package/dist/lib/hooks/useStylesFor.js +40 -0
- package/dist/lib/hooks/useStylesFor.js.map +1 -0
- package/dist/lib/hooks/useTouchableEvents.js +37 -0
- package/dist/lib/hooks/useTouchableEvents.js.map +1 -0
- package/dist/lib/hooks/useWindowFocus.js +34 -0
- package/dist/lib/hooks/useWindowFocus.js.map +1 -0
- package/dist/lib/hooks/useWindowSize.js +32 -0
- package/dist/lib/hooks/useWindowSize.js.map +1 -0
- package/dist/lib/index.js +23 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/tools/index.js +20 -0
- package/dist/lib/tools/index.js.map +1 -0
- package/dist/lib/tools/localStorage.js +159 -0
- package/dist/lib/tools/localStorage.js.map +1 -0
- package/dist/lib/tools/mediaQuery.js +38 -0
- package/dist/lib/tools/mediaQuery.js.map +1 -0
- package/dist/lib/tools/modal.js +60 -0
- package/dist/lib/tools/modal.js.map +1 -0
- package/dist/lib/utils/attributes.js +26 -0
- package/dist/lib/utils/attributes.js.map +1 -0
- package/dist/lib/utils/cache.d.ts +2 -2
- package/dist/lib/utils/cache.js +17 -0
- package/dist/lib/utils/cache.js.map +1 -0
- package/dist/lib/utils/index.js +22 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/utils/pollyfils/scroll.js +70 -0
- package/dist/lib/utils/pollyfils/scroll.js.map +1 -0
- package/dist/lib/utils/stopPropagation.js +22 -0
- package/dist/lib/utils/stopPropagation.js.map +1 -0
- package/dist/lib/utils/test.js +18 -0
- package/dist/lib/utils/test.js.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/utility.js +3 -0
- package/dist/types/utility.js.map +1 -0
- package/package.json +18 -18
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePagination = usePagination;
|
|
4
|
+
const hooks_1 = require("@codeleap/hooks");
|
|
5
|
+
const utils_1 = require("@codeleap/utils");
|
|
6
|
+
/**
|
|
7
|
+
* Manages pagination state and computes the visible page range for a
|
|
8
|
+
* `PaginationButtons` component.
|
|
9
|
+
*
|
|
10
|
+
* Supports controlled (`page` + `onChangePage`) and uncontrolled modes. When
|
|
11
|
+
* `shouldAbbreviate` is true (default) and `total` exceeds
|
|
12
|
+
* `abbreviationMinimumAmount`, the range collapses middle pages into
|
|
13
|
+
* `abbreviationSymbol` entries. Mobile mode reduces the boundary count and
|
|
14
|
+
* forces abbreviation.
|
|
15
|
+
*
|
|
16
|
+
* Arrow buttons at positions `0` and `total + 1` are reserved for the
|
|
17
|
+
* previous/next controls and are not selectable as page numbers.
|
|
18
|
+
*/
|
|
19
|
+
function usePagination(props) {
|
|
20
|
+
const { isMobile } = props;
|
|
21
|
+
const { total, boundaries = 2, initialPage = 1, page, onChangePage, shouldAbbreviate = true, abbreviationMinimumAmount = isMobile ? 5 : 10, displayLeftArrow = true, displayRightArrow = true, abbreviationSymbol, } = props;
|
|
22
|
+
const [activePage, setActivePage] = (0, hooks_1.useUncontrolled)({
|
|
23
|
+
value: page,
|
|
24
|
+
onChange: onChangePage,
|
|
25
|
+
defaultValue: initialPage,
|
|
26
|
+
finalValue: initialPage,
|
|
27
|
+
rule: (_page) => typeof _page === 'number' && _page <= total,
|
|
28
|
+
});
|
|
29
|
+
const _boundaries = isMobile ? 2 : boundaries;
|
|
30
|
+
const canAbreviateItems = (shouldAbbreviate || isMobile) && total > abbreviationMinimumAmount;
|
|
31
|
+
const displayLastNumbers = activePage + _boundaries + (isMobile ? 0 : 2) >= total;
|
|
32
|
+
const isCenterSelected = canAbreviateItems && activePage > _boundaries && !displayLastNumbers;
|
|
33
|
+
const dotsDisplay = isCenterSelected ? abbreviationSymbol : null;
|
|
34
|
+
const setPage = (pageNumber) => {
|
|
35
|
+
const isPreviousArrow = pageNumber === 0;
|
|
36
|
+
const isNextArrow = pageNumber === total + 1;
|
|
37
|
+
const nonSelectableItems = [
|
|
38
|
+
displayLeftArrow && isPreviousArrow,
|
|
39
|
+
displayRightArrow && isNextArrow,
|
|
40
|
+
].some(x => x);
|
|
41
|
+
if (nonSelectableItems)
|
|
42
|
+
return activePage;
|
|
43
|
+
setActivePage(pageNumber);
|
|
44
|
+
};
|
|
45
|
+
const next = () => setPage(activePage + 1);
|
|
46
|
+
const previous = () => setPage(activePage - 1);
|
|
47
|
+
const first = () => setPage(1);
|
|
48
|
+
const last = () => setPage(total);
|
|
49
|
+
const status = (0, hooks_1.useMemo)(() => {
|
|
50
|
+
if (isCenterSelected) {
|
|
51
|
+
return 'abreviated';
|
|
52
|
+
}
|
|
53
|
+
if (displayLastNumbers) {
|
|
54
|
+
return 'end';
|
|
55
|
+
}
|
|
56
|
+
return 'initial';
|
|
57
|
+
}, [isCenterSelected, displayLastNumbers]);
|
|
58
|
+
const paginationRange = (0, hooks_1.useMemo)(() => {
|
|
59
|
+
if (!canAbreviateItems) {
|
|
60
|
+
return [
|
|
61
|
+
...(0, utils_1.range)(1, total),
|
|
62
|
+
].filter(Boolean);
|
|
63
|
+
}
|
|
64
|
+
if (displayLastNumbers) {
|
|
65
|
+
const extraItems = [
|
|
66
|
+
1,
|
|
67
|
+
abbreviationSymbol,
|
|
68
|
+
];
|
|
69
|
+
return [
|
|
70
|
+
...extraItems,
|
|
71
|
+
...(0, utils_1.range)(total - (_boundaries + extraItems?.length - (isMobile ? 2 : 0)), total),
|
|
72
|
+
].filter(Boolean);
|
|
73
|
+
}
|
|
74
|
+
return [
|
|
75
|
+
...(0, utils_1.range)(1, isCenterSelected ? _boundaries - 1 : _boundaries),
|
|
76
|
+
dotsDisplay,
|
|
77
|
+
isCenterSelected ? activePage : abbreviationSymbol,
|
|
78
|
+
dotsDisplay,
|
|
79
|
+
...(0, utils_1.range)(total - _boundaries + (isCenterSelected ? 2 : 1), total),
|
|
80
|
+
].filter(Boolean);
|
|
81
|
+
}, [total, activePage, displayLastNumbers, isCenterSelected, canAbreviateItems]);
|
|
82
|
+
return {
|
|
83
|
+
range: paginationRange,
|
|
84
|
+
page: Number(activePage),
|
|
85
|
+
setPage,
|
|
86
|
+
status,
|
|
87
|
+
next,
|
|
88
|
+
previous,
|
|
89
|
+
first,
|
|
90
|
+
last,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=usePagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePagination.js","sourceRoot":"","sources":["../../../src/lib/hooks/usePagination.ts"],"names":[],"mappings":";;AA+BA,sCA0GC;AAzID,2CAA0D;AAC1D,2CAAuC;AAiBvC;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAAC,KAAuB;IAEnD,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAE1B,MAAM,EACJ,KAAK,EACL,UAAU,GAAG,CAAC,EACd,WAAW,GAAG,CAAC,EACf,IAAI,EACJ,YAAY,EACZ,gBAAgB,GAAG,IAAI,EACvB,yBAAyB,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAC7C,gBAAgB,GAAG,IAAI,EACvB,iBAAiB,GAAG,IAAI,EACxB,kBAAkB,GACnB,GAAG,KAAK,CAAA;IAET,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,uBAAe,EAAC;QAClD,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,YAAY;QACtB,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,WAAW;QACvB,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,KAAK;KAC7D,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAE7C,MAAM,iBAAiB,GAAG,CAAC,gBAAgB,IAAI,QAAQ,CAAC,IAAI,KAAK,GAAG,yBAAyB,CAAA;IAC7F,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAA;IACjF,MA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2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePopState = void 0;
|
|
4
|
+
const hooks_1 = require("@codeleap/hooks");
|
|
5
|
+
const useIsomorphicEffect_1 = require("./useIsomorphicEffect");
|
|
6
|
+
/**
|
|
7
|
+
* Conditionally attaches a `popstate` listener while `dependence` is `true`.
|
|
8
|
+
*
|
|
9
|
+
* When `dependence` becomes `true`, pushes the current URL onto the history
|
|
10
|
+
* stack so the browser back button triggers `popstate` rather than navigating
|
|
11
|
+
* away. When `dependence` becomes `false` (or the component unmounts), the
|
|
12
|
+
* listener is removed.
|
|
13
|
+
*
|
|
14
|
+
* Useful for keeping overlays (modals, drawers) dismissable via the browser
|
|
15
|
+
* back button.
|
|
16
|
+
*/
|
|
17
|
+
const usePopState = (dependence, handler) => {
|
|
18
|
+
(0, useIsomorphicEffect_1.useIsomorphicEffect)(() => {
|
|
19
|
+
if (dependence) {
|
|
20
|
+
const pathname = location.pathname;
|
|
21
|
+
const searchParams = location.search;
|
|
22
|
+
const newUrl = pathname + searchParams;
|
|
23
|
+
window.history.pushState(null, null, newUrl);
|
|
24
|
+
window.addEventListener('popstate', handler);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
window.removeEventListener('popstate', handler);
|
|
28
|
+
}
|
|
29
|
+
}, [dependence]);
|
|
30
|
+
(0, hooks_1.useUnmount)(() => {
|
|
31
|
+
window.removeEventListener('popstate', handler);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
exports.usePopState = usePopState;
|
|
35
|
+
//# sourceMappingURL=usePopState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePopState.js","sourceRoot":"","sources":["../../../src/lib/hooks/usePopState.ts"],"names":[],"mappings":";;;AACA,2CAA4C;AAC5C,+DAA2D;AAE3D;;;;;;;;;;GAUG;AACI,MAAM,WAAW,GAAG,CAAC,UAAmB,EAAE,OAAoB,EAAE,EAAE;IACvE,IAAA,yCAAmB,EAAC,GAAG,EAAE;QACvB,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA;YAClC,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAA;YACpC,MAAM,MAAM,GAAG,QAAQ,GAAG,YAAY,CAAA;YAEtC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;YAC5C,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QAC9C,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QACjD,CAAC;IACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;IAEhB,IAAA,kBAAU,EAAC,GAAG,EAAE;QACd,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAjBY,QAAA,WAAW,eAiBvB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePopoverDismiss = usePopoverDismiss;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Restores outside-click dismissal for a Popover rendered with isNonModal=true.
|
|
7
|
+
*
|
|
8
|
+
* react-aria's usePopover sets isDismissable=!isNonModal, which disables its own
|
|
9
|
+
* useInteractOutside listener. This hook adds an equivalent pointerdown capture
|
|
10
|
+
* listener directly on the document.
|
|
11
|
+
*
|
|
12
|
+
* The trigger element is excluded so its own press handler can handle the toggle.
|
|
13
|
+
* The blur-based close (shouldCloseOnBlur=true in useOverlay) still handles the
|
|
14
|
+
* case where focus is inside the popover and moves elsewhere, so this hook only
|
|
15
|
+
* needs to cover the unfocused-popover scenario.
|
|
16
|
+
*/
|
|
17
|
+
function usePopoverDismiss({ popoverRef, triggerRef, isOpen, onClose, }) {
|
|
18
|
+
const onCloseRef = (0, react_1.useRef)(onClose);
|
|
19
|
+
(0, react_1.useEffect)(() => { onCloseRef.current = onClose; });
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
if (!isOpen)
|
|
22
|
+
return;
|
|
23
|
+
const handle = (e) => {
|
|
24
|
+
const target = e.target;
|
|
25
|
+
if (popoverRef.current?.contains(target))
|
|
26
|
+
return;
|
|
27
|
+
if (triggerRef.current?.contains(target))
|
|
28
|
+
return;
|
|
29
|
+
onCloseRef.current();
|
|
30
|
+
};
|
|
31
|
+
document.addEventListener('pointerdown', handle, { capture: true });
|
|
32
|
+
return () => document.removeEventListener('pointerdown', handle, { capture: true });
|
|
33
|
+
}, [isOpen, popoverRef, triggerRef]);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=usePopoverDismiss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePopoverDismiss.js","sourceRoot":"","sources":["../../../src/lib/hooks/usePopoverDismiss.ts"],"names":[],"mappings":";;AAcA,8CA2BC;AAzCD,iCAAyD;AAEzD;;;;;;;;;;;GAWG;AACH,SAAgB,iBAAiB,CAAC,EAChC,UAAU,EACV,UAAU,EACV,MAAM,EACN,OAAO,GAMR;IACC,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,OAAO,CAAC,CAAA;IAClC,IAAA,iBAAS,EAAC,GAAG,EAAE,GAAG,UAAU,CAAC,OAAO,GAAG,OAAO,CAAA,CAAC,CAAC,CAAC,CAAA;IAEjD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM;YAAE,OAAM;QAEnB,MAAM,MAAM,GAAG,CAAC,CAAe,EAAE,EAAE;YACjC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAc,CAAA;YAC/B,IAAI,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAAE,OAAM;YAChD,IAAI,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAAE,OAAM;YAChD,UAAU,CAAC,OAAO,EAAE,CAAA;QACtB,CAAC,CAAA;QAED,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;QACnE,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IACrF,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useRefresh = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const hooks_1 = require("@codeleap/hooks");
|
|
9
|
+
const scrollDebounce = (func, delay) => {
|
|
10
|
+
const timerRef = react_1.default.useRef(null);
|
|
11
|
+
const scrollDebounce = (...args) => {
|
|
12
|
+
clearTimeout(timerRef.current);
|
|
13
|
+
timerRef.current = setTimeout(() => {
|
|
14
|
+
func(...args);
|
|
15
|
+
}, delay);
|
|
16
|
+
};
|
|
17
|
+
return scrollDebounce;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Implements a pull-to-refresh pattern for web scroll containers.
|
|
21
|
+
*
|
|
22
|
+
* Monitors the window `scroll` event and fires `onRefresh` when the container
|
|
23
|
+
* has been scrolled above `threshold` (percentage) twice in quick succession.
|
|
24
|
+
* After `onRefresh` resolves, the refresh state is reset after 2.5 s. Set
|
|
25
|
+
* `enabled: false` to disable the listener entirely (e.g. while a request is
|
|
26
|
+
* already in flight). Attach `scrollableRef` to the scrollable container element.
|
|
27
|
+
*/
|
|
28
|
+
const useRefresh = (onRefresh = () => null, options) => {
|
|
29
|
+
const { threshold, debounce, enabled, } = options;
|
|
30
|
+
const [refresh, setRefresh] = react_1.default.useState(false);
|
|
31
|
+
const pushToTopRef = react_1.default.useRef(0);
|
|
32
|
+
const refresher = react_1.default.useCallback(async (_onRefresh) => {
|
|
33
|
+
setRefresh(true);
|
|
34
|
+
await _onRefresh?.();
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
setRefresh(false);
|
|
37
|
+
pushToTopRef.current = 0;
|
|
38
|
+
}, 2500);
|
|
39
|
+
}, []);
|
|
40
|
+
const containerRef = react_1.default.useRef(null);
|
|
41
|
+
const onScroll = scrollDebounce(() => {
|
|
42
|
+
if (containerRef.current) {
|
|
43
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
44
|
+
const scrollTop = window?.pageYOffset || document?.documentElement?.scrollTop;
|
|
45
|
+
const containerTop = rect.top + scrollTop;
|
|
46
|
+
const containerHeight = rect.height;
|
|
47
|
+
const distanceFromTop = Math.max(0, scrollTop - containerTop);
|
|
48
|
+
const distanceFromBottom = Math.max(0, containerTop + containerHeight - scrollTop);
|
|
49
|
+
const totalDistance = containerHeight + distanceFromTop + distanceFromBottom;
|
|
50
|
+
const percentage = (distanceFromTop / totalDistance) * 100;
|
|
51
|
+
if (percentage < threshold) {
|
|
52
|
+
if (pushToTopRef.current === 2) {
|
|
53
|
+
refresher(onRefresh);
|
|
54
|
+
}
|
|
55
|
+
pushToTopRef.current = pushToTopRef.current + 1;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, debounce);
|
|
59
|
+
(0, hooks_1.useEffect)(() => {
|
|
60
|
+
if (enabled) {
|
|
61
|
+
window.addEventListener('scroll', onScroll);
|
|
62
|
+
return () => {
|
|
63
|
+
window.removeEventListener('scroll', onScroll);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}, [enabled]);
|
|
67
|
+
return {
|
|
68
|
+
refresh,
|
|
69
|
+
scrollableRef: containerRef,
|
|
70
|
+
refresher,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
exports.useRefresh = useRefresh;
|
|
74
|
+
//# sourceMappingURL=useRefresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRefresh.js","sourceRoot":"","sources":["../../../src/lib/hooks/useRefresh.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAEzB,2CAA2C;AAQ3C,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IACrC,MAAM,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAEnC,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;QACjC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC9B,QAAQ,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YACjC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;QACf,CAAC,EAAE,KAAK,CAAC,CAAA;IACX,CAAC,CAAA;IAED,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED;;;;;;;;GAQG;AACI,MAAM,UAAU,GAAG,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,EAAE,OAA0B,EAAE,EAAE;IAE/E,MAAM,EACJ,SAAS,EACT,QAAQ,EACR,OAAO,GACR,GAAG,OAAO,CAAA;IAEX,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEnD,MAAM,YAAY,GAAG,eAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAEpC,MAAM,SAAS,GAAG,eAAK,CAAC,WAAW,CAAC,KAAK,EAAE,UAAuB,EAAE,EAAE;QACpE,UAAU,CAAC,IAAI,CAAC,CAAA;QAChB,M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AAC,CAAA;IAEZ,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;YAE3C,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;YAChD,CAAC,CAAA;QACH,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAEb,OAAO;QACL,OAAO;QACP,aAAa,EAAE,YAAY;QAC3B,SAAS;KACV,CAAA;AACH,CAAC,CAAA;AA/DY,QAAA,UAAU,cA+DtB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useScrollEffect = useScrollEffect;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Calls `effect` on every window scroll event, passing whether `window.scrollY`
|
|
7
|
+
* has passed `breakpoint` and the current scroll position. The listener is
|
|
8
|
+
* re-registered when `breakpoint` or any `extraDependencies` change.
|
|
9
|
+
*/
|
|
10
|
+
function useScrollEffect(effect, breakpoint, extraDependencies = []) {
|
|
11
|
+
function handleScroll() {
|
|
12
|
+
const passed = window.scrollY > breakpoint;
|
|
13
|
+
effect(passed, window.scrollY);
|
|
14
|
+
}
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
document.addEventListener('scroll', handleScroll);
|
|
17
|
+
return () => {
|
|
18
|
+
document.removeEventListener('scroll', handleScroll);
|
|
19
|
+
};
|
|
20
|
+
}, [breakpoint, ...extraDependencies]);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=useScrollEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollEffect.js","sourceRoot":"","sources":["../../../src/lib/hooks/useScrollEffect.ts"],"names":[],"mappings":";;AAOA,0CAgBC;AAvBD,iCAAiC;AAEjC;;;;GAIG;AACH,SAAgB,eAAe,CAC7B,MAAiD,EACjD,UAAkB,EAClB,iBAAiB,GAAG,EAAE;IAEtB,SAAS,YAAY;QACnB,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,GAAG,UAAU,CAAA;QAC1C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QACjD,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QACtD,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,iBAAiB,CAAC,CAAC,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSearchParams = useSearchParams;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const hooks_1 = require("@codeleap/hooks");
|
|
6
|
+
/**
|
|
7
|
+
* Syncs a typed record of string params with the URL query string via
|
|
8
|
+
* `window.history.replaceState`. On mount, reads the current URL params and
|
|
9
|
+
* merges them with `initial` defaults (initial values are only applied when the
|
|
10
|
+
* URL param is absent or empty). Call `reset()` to restore `initial`.
|
|
11
|
+
*
|
|
12
|
+
* Not a router integration — changes do not trigger a navigation event, and the
|
|
13
|
+
* hook does not react to external URL changes after mount.
|
|
14
|
+
*/
|
|
15
|
+
function useSearchParams(initial) {
|
|
16
|
+
const searchParams = (0, react_1.useRef)(new URLSearchParams(typeof window === 'undefined' ? '' : location.search));
|
|
17
|
+
const [params, setParams] = (0, react_1.useState)(() => {
|
|
18
|
+
const initialParams = Object.fromEntries(searchParams.current);
|
|
19
|
+
for (const key in initial) {
|
|
20
|
+
if (initialParams[key] === '' || typeof initialParams[key] === 'undefined') {
|
|
21
|
+
initialParams[key] = initial[key];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return initialParams;
|
|
25
|
+
});
|
|
26
|
+
const previousParams = (0, hooks_1.usePrevious)(params);
|
|
27
|
+
(0, react_1.useEffect)(() => {
|
|
28
|
+
if (window.history) {
|
|
29
|
+
Object.entries({ ...previousParams, ...params }).forEach(([k, v]) => {
|
|
30
|
+
if (!!previousParams?.[k] && !params?.[k]) {
|
|
31
|
+
searchParams.current.delete(k);
|
|
32
|
+
}
|
|
33
|
+
else if (v) {
|
|
34
|
+
searchParams.current.set(k, v);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
searchParams.current.delete(k);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const url = window.location.origin +
|
|
41
|
+
window.location.pathname +
|
|
42
|
+
`?${searchParams.current?.toString()}`;
|
|
43
|
+
window.history.replaceState({ path: url }, '', url);
|
|
44
|
+
}
|
|
45
|
+
}, [params]);
|
|
46
|
+
function reset() {
|
|
47
|
+
setParams(initial);
|
|
48
|
+
}
|
|
49
|
+
return [params, setParams, reset, searchParams.current];
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=useSearchParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSearchParams.js","sourceRoot":"","sources":["../../../src/lib/hooks/useSearchParams.ts"],"names":[],"mappings":";;AAuBA,0CA2CC;AAlED,iCAAmD;AACnD,2CAA6C;AAa7C;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAE7B,OAAW;IACX,MAAM,YAAY,GAAG,IAAA,cAAM,EAAC,IAAI,eAAe,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IACtG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ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AAE,EAAE,CAAA;YACxC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;QACrD,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IAEZ,SAAS,KAAK;QACZ,SAAS,CAAC,OAAO,CAAC,CAAA;IACpB,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStaticAnimationStyles = useStaticAnimationStyles;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Captures a frozen snapshot of the selected `keys` from `obj` on the first
|
|
7
|
+
* render and never updates it. Used by `useAnimatedVariantStyles` to keep the
|
|
8
|
+
* non-animated style values stable across re-renders so Framer Motion does not
|
|
9
|
+
* re-create animation targets unnecessarily.
|
|
10
|
+
*/
|
|
11
|
+
function useStaticAnimationStyles(obj, keys) {
|
|
12
|
+
const styles = (0, react_1.useRef)({});
|
|
13
|
+
if (Object.keys(styles.current).length === 0) {
|
|
14
|
+
const mappedStyles = keys.map((k) => [k, { ...obj[k] }]);
|
|
15
|
+
styles.current = Object.fromEntries(mappedStyles);
|
|
16
|
+
}
|
|
17
|
+
return styles.current;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=useStaticAnimationStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStaticAnimationStyles.js","sourceRoot":"","sources":["../../../src/lib/hooks/useStaticAnimationStyles.ts"],"names":[],"mappings":";;AASA,4DAUC;AAnBD,iCAA8B;AAG9B;;;;;GAKG;AACH,SAAgB,wBAAwB,CAAqE,GAAM,EAAE,IAAS;IAC5H,MAAM,MAAM,GAAG,IAAA,cAAM,EAAC,EAAE,CAAC,CAAA;IAEzB,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAExD,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;IACnD,CAAC;IAED,OAAO,MAAM,CAAC,OAAiC,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStylesFor = void 0;
|
|
4
|
+
const styles_1 = require("@codeleap/styles");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const WebStyleRegistry_1 = require("../WebStyleRegistry");
|
|
7
|
+
const hooks_1 = require("@codeleap/hooks");
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a component's style parts from `WebStyleRegistry` and re-evaluates
|
|
10
|
+
* whenever the `style` prop or `context` changes.
|
|
11
|
+
*
|
|
12
|
+
* Must be called inside a component that has a `WebStyleRegistry` instance
|
|
13
|
+
* available (created once per app via `new WebStyleRegistry()`). Pass the
|
|
14
|
+
* component's registered name as `componentName` — it must match the name used
|
|
15
|
+
* in `WebStyleRegistry.registerComponent`.
|
|
16
|
+
*/
|
|
17
|
+
const useStylesFor = (componentName, style, context) => {
|
|
18
|
+
const styleObserver = (0, styles_1.useStyleObserver)(style);
|
|
19
|
+
// const isMounted = useIsMounted()
|
|
20
|
+
const stableContext = (0, hooks_1.useStableReference)(context ?? {});
|
|
21
|
+
const styles = (0, react_1.useMemo)(() => {
|
|
22
|
+
return WebStyleRegistry_1.WebStyleRegistry.current.styleFor(componentName, style, true, stableContext);
|
|
23
|
+
}, [styleObserver, stableContext]);
|
|
24
|
+
// const processedStyles = useMemo(() => {
|
|
25
|
+
// // this is strange, but necessary to recalculate the pre-set styles from SSR
|
|
26
|
+
// return Object.entries(styles).reduce((acc, [key, styleValue]) => {
|
|
27
|
+
// const isServer = typeof window === 'undefined'
|
|
28
|
+
// const inEnvTransition = isServer ? false : !isMounted
|
|
29
|
+
// acc[key] = inEnvTransition ? {
|
|
30
|
+
// // Despite what it may look like, this is not (just) a joke. The "orphans" property is almost completely useless,
|
|
31
|
+
// // so we set it just to force the styles to recompute after hydration. Also picked for comedic impact.
|
|
32
|
+
// orphans: 1,
|
|
33
|
+
// ...styleValue } : styleValue
|
|
34
|
+
// return acc
|
|
35
|
+
// }, {} as Record<C, ICSS>)
|
|
36
|
+
// }, [styles, isMounted])
|
|
37
|
+
return styles;
|
|
38
|
+
};
|
|
39
|
+
exports.useStylesFor = useStylesFor;
|
|
40
|
+
//# sourceMappingURL=useStylesFor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStylesFor.js","sourceRoot":"","sources":["../../../src/lib/hooks/useStylesFor.ts"],"names":[],"mappings":";;;AAAA,6CAAsF;AACtF,iCAA+B;AAC/B,0DAAsD;AACtD,2CAAkE;AAElE;;;;;;;;GAQG;AACI,MAAM,YAAY,GAAG,CAAmB,aAAqB,EAAE,KAA2B,EAAE,OAA0B,EAAmB,EAAE;IAChJ,MAAM,aAAa,GAAG,IAAA,yBAAgB,EAAC,KAAK,CAAC,CAAA;IAE7C,mCAAmC;IAEnC,MAAM,aAAa,GAAG,IAAA,0BAAkB,EAAC,OAAO,IAAI,EAAE,CAAC,CAAA;IAEvD,MAAM,MAAM,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC1B,OAAO,mCAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,CAAC,CAAA;IACrF,CAAC,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAA;IAElC,0CAA0C;IAC1C,iFAAiF;IACjF,uEAAuE;IACvE,qDAAqD;IACrD,4DAA4D;IAE5D,qCAAqC;IACrC,0HAA0H;IAC1H,+GAA+G;IAC/G,oBAAoB;IAEpB,qCAAqC;IAErC,iBAAiB;IACjB,8BAA8B;IAC9B,0BAA0B;IAE1B,OAAO,MAAyB,CAAA;AAElC,CAAC,CAAA;AA9BY,QAAA,YAAY,gBA8BxB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTouchableInteraction = useTouchableInteraction;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Tracks hover and pressed interaction states for a `Touchable`-like element
|
|
7
|
+
* using pointer events. Uses `setPointerCapture` / `releasePointerCapture` so
|
|
8
|
+
* that `isPressed` stays accurate even when the pointer leaves the element
|
|
9
|
+
* while held down. Both states are forced to `false` when `disabled` is `true`.
|
|
10
|
+
*/
|
|
11
|
+
function useTouchableInteraction(disabled = false) {
|
|
12
|
+
const [isHovering, setIsHovering] = (0, react_1.useState)(false);
|
|
13
|
+
const [isPressed, setIsPressed] = (0, react_1.useState)(false);
|
|
14
|
+
return {
|
|
15
|
+
eventHandlers: {
|
|
16
|
+
onPointerEnter: () => setIsHovering(true),
|
|
17
|
+
onPointerLeave: () => {
|
|
18
|
+
setIsHovering(false);
|
|
19
|
+
setIsPressed(false);
|
|
20
|
+
},
|
|
21
|
+
onPointerDown: (e) => {
|
|
22
|
+
setIsPressed(true);
|
|
23
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
24
|
+
},
|
|
25
|
+
onPointerUp: (e) => {
|
|
26
|
+
setIsPressed(false);
|
|
27
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
28
|
+
},
|
|
29
|
+
onPointerCancel: () => {
|
|
30
|
+
setIsPressed(false);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
isHovering: isHovering && !disabled,
|
|
34
|
+
isPressed: isPressed && !disabled,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=useTouchableEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTouchableEvents.js","sourceRoot":"","sources":["../../../src/lib/hooks/useTouchableEvents.ts"],"names":[],"mappings":";;AAQA,0DA8BC;AAtCD,iCAAgC;AAEhC;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,QAAQ,GAAG,KAAK;IACtD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IACnD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAEjD,OAAO;QACL,aAAa,EAAE;YACb,cAAc,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC;YAEzC,cAAc,EAAE,GAAG,EAAE;gBACnB,aAAa,CAAC,KAAK,CAAC,CAAA;gBACpB,YAAY,CAAC,KAAK,CAAC,CAAA;YACrB,CAAC;YAED,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE;gBACnB,YAAY,CAAC,IAAI,CAAC,CAAA;gBAClB,CAAC,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;YAChD,CAAC;YAED,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE;gBACjB,YAAY,CAAC,KAAK,CAAC,CAAA;gBACnB,CAAC,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;YACpD,CAAC;YAED,eAAe,EAAE,GAAG,EAAE;gBACpB,YAAY,CAAC,KAAK,CAAC,CAAA;YACrB,CAAC;SACF;QACD,UAAU,EAAE,UAAU,IAAI,CAAC,QAAQ;QACnC,SAAS,EAAE,SAAS,IAAI,CAAC,QAAQ;KAClC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWindowFocus = void 0;
|
|
4
|
+
const types_1 = require("@codeleap/types");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
/**
|
|
7
|
+
* Returns `true` when the browser window has focus, `false` when it is blurred.
|
|
8
|
+
* Calls `options.onFocus` and `options.onBlur` side-effect callbacks as needed.
|
|
9
|
+
* The listeners are re-registered when `deps` change.
|
|
10
|
+
*/
|
|
11
|
+
const useWindowFocus = (options = {}, deps = []) => {
|
|
12
|
+
const [focused, setFocused] = (0, react_1.useState)(true);
|
|
13
|
+
const onFocus = () => {
|
|
14
|
+
setFocused(true);
|
|
15
|
+
if (types_1.TypeGuards.isFunction(options?.onFocus))
|
|
16
|
+
options?.onFocus();
|
|
17
|
+
};
|
|
18
|
+
const onBlur = () => {
|
|
19
|
+
setFocused(false);
|
|
20
|
+
if (types_1.TypeGuards.isFunction(options?.onBlur))
|
|
21
|
+
options?.onBlur();
|
|
22
|
+
};
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
window.addEventListener('focus', onFocus);
|
|
25
|
+
window.addEventListener('blur', onBlur);
|
|
26
|
+
return () => {
|
|
27
|
+
window.removeEventListener('focus', onFocus);
|
|
28
|
+
window.removeEventListener('blur', onBlur);
|
|
29
|
+
};
|
|
30
|
+
}, deps);
|
|
31
|
+
return focused;
|
|
32
|
+
};
|
|
33
|
+
exports.useWindowFocus = useWindowFocus;
|
|
34
|
+
//# sourceMappingURL=useWindowFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowFocus.js","sourceRoot":"","sources":["../../../src/lib/hooks/useWindowFocus.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AACzD,iCAA2C;AAO3C;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAC,UAAiC,EAAE,EAAE,OAAmB,EAAE,EAAW,EAAE;IACpG,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAA;IAE5C,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,UAAU,CAAC,IAAI,CAAC,CAAA;QAChB,IAAI,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IACjE,CAAC,CAAA;IAED,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,UAAU,CAAC,KAAK,CAAC,CAAA;QACjB,IAAI,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC;YAAE,OAAO,EAAE,MAAM,EAAE,CAAA;IAC/D,CAAC,CAAA;IAED,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACzC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAEvC,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC5C,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC5C,CAAC,CAAA;IACH,CAAC,EAAE,IAAI,CAAC,CAAA;IAER,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAxBY,QAAA,cAAc,kBAwB1B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWindowSize = useWindowSize;
|
|
4
|
+
const hooks_1 = require("@codeleap/hooks");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
/**
|
|
7
|
+
* Returns `[innerWidth, innerHeight]` and keeps the value in sync with window
|
|
8
|
+
* resize events. When `live` is `false` (default), resize updates are debounced
|
|
9
|
+
* by 300 ms to avoid flooding renders. Pass `live: true` for immediate updates.
|
|
10
|
+
* SSR returns `[1920, 1080]` as a placeholder.
|
|
11
|
+
*/
|
|
12
|
+
function useWindowSize(live = false) {
|
|
13
|
+
const [size, setSize] = (0, react_1.useState)(() => {
|
|
14
|
+
if (typeof window === 'undefined')
|
|
15
|
+
return [1920, 1080];
|
|
16
|
+
return [window.innerWidth, window.innerHeight];
|
|
17
|
+
});
|
|
18
|
+
const handler = (0, react_1.useCallback)(() => {
|
|
19
|
+
setSize([window.innerWidth, window.innerHeight]);
|
|
20
|
+
}, [setSize]);
|
|
21
|
+
const debouncedHandleResize = (0, hooks_1.useDebounceCallback)(handler, 300);
|
|
22
|
+
const handleResize = live ? handler : debouncedHandleResize.debounce;
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
handleResize();
|
|
25
|
+
window.addEventListener('resize', handleResize);
|
|
26
|
+
return () => {
|
|
27
|
+
window.removeEventListener('resize', handleResize);
|
|
28
|
+
};
|
|
29
|
+
}, [handleResize]);
|
|
30
|
+
return size;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=useWindowSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowSize.js","sourceRoot":"","sources":["../../../src/lib/hooks/useWindowSize.ts"],"names":[],"mappings":";;AAUA,sCAyBC;AAnCD,2CAAqD;AACrD,iCAAwD;AAGxD;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,IAAI,GAAC,KAAK;IACtC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE;QACpC,IAAG,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,CAAC,IAAI,EAAC,IAAI,CAAC,CAAA;QACpD,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC/B,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAA;IAClD,CAAC,EAAC,CAAC,OAAO,CAAC,CAAC,CAAA;IAEZ,MAAM,qBAAqB,GAAG,IAAA,2BAAmB,EAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAE/D,MAAM,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAA;IAEpE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,YAAY,EAAE,CAAA;QAEd,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QAE/C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QACpD,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAA;IAElB,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./hooks"), exports);
|
|
18
|
+
__exportStar(require("./tools"), exports);
|
|
19
|
+
__exportStar(require("./utils"), exports);
|
|
20
|
+
__exportStar(require("./ListMasonry"), exports);
|
|
21
|
+
__exportStar(require("./WebStyleRegistry"), exports);
|
|
22
|
+
__exportStar(require("./ThemeVariables"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,0CAAuB;AACvB,0CAAuB;AACvB,gDAA6B;AAC7B,qDAAkC;AAClC,mDAAgC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./localStorage"), exports);
|
|
18
|
+
__exportStar(require("./mediaQuery"), exports);
|
|
19
|
+
__exportStar(require("./modal"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/tools/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,+CAA4B;AAC5B,0CAAuB"}
|