@usereactify/search 5.0.0-beta.8 → 5.0.1
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/CHANGELOG.md +713 -0
- package/README.md +3 -21
- package/dist/package.json +3 -3
- package/dist/src/components/ClearAll/ClearAll.d.ts +8 -0
- package/dist/src/components/ClearAll/ClearAll.js +29 -0
- package/dist/src/components/ClearAll/ClearAll.js.map +1 -0
- package/dist/src/components/ClearAll/index.d.ts +1 -0
- package/dist/src/components/{ReactifySearchBase → ClearAll}/index.js +1 -1
- package/dist/src/components/ClearAll/index.js.map +1 -0
- package/dist/src/components/CustomComponent/CustomComponent.d.ts +4 -0
- package/dist/src/components/CustomComponent/CustomComponent.js +13 -0
- package/dist/src/components/CustomComponent/CustomComponent.js.map +1 -0
- package/dist/src/components/CustomComponent/index.d.ts +1 -0
- package/dist/src/components/CustomComponent/index.js +14 -0
- package/dist/src/components/CustomComponent/index.js.map +1 -0
- package/dist/src/components/Example/ExampleClearAll.d.ts +4 -0
- package/dist/src/components/Example/ExampleClearAll.js +12 -0
- package/dist/src/components/Example/ExampleClearAll.js.map +1 -0
- package/dist/src/components/Example/ExampleCustomComponent.d.ts +2 -0
- package/dist/src/components/Example/ExampleCustomComponent.js +36 -0
- package/dist/src/components/Example/ExampleCustomComponent.js.map +1 -0
- package/dist/src/components/Example/ExampleFilterList.d.ts +5 -0
- package/dist/src/components/Example/ExampleFilterList.js +81 -9
- package/dist/src/components/Example/ExampleFilterList.js.map +1 -1
- package/dist/src/components/Example/ExampleFilterRange.js +6 -11
- package/dist/src/components/Example/ExampleFilterRange.js.map +1 -1
- package/dist/src/components/Example/ExampleFilterSlider.js +8 -9
- package/dist/src/components/Example/ExampleFilterSlider.js.map +1 -1
- package/dist/src/components/Example/ExampleFilters.d.ts +4 -0
- package/dist/src/components/Example/{ExampleFilterStack.js → ExampleFilters.js} +6 -5
- package/dist/src/components/Example/ExampleFilters.js.map +1 -0
- package/dist/src/components/Example/ExampleFiltersActive.d.ts +4 -0
- package/dist/src/components/Example/ExampleFiltersActive.js +23 -0
- package/dist/src/components/Example/ExampleFiltersActive.js.map +1 -0
- package/dist/src/components/Example/ExampleHookUseFilters.d.ts +2 -0
- package/dist/src/components/Example/ExampleHookUseFilters.js +20 -0
- package/dist/src/components/Example/ExampleHookUseFilters.js.map +1 -0
- package/dist/src/components/Example/ExampleHookUseSearch.d.ts +2 -0
- package/dist/src/components/Example/ExampleHookUseSearch.js +22 -0
- package/dist/src/components/Example/ExampleHookUseSearch.js.map +1 -0
- package/dist/src/components/Example/ExampleHookUseSortBy.d.ts +2 -0
- package/dist/src/components/Example/ExampleHookUseSortBy.js +18 -0
- package/dist/src/components/Example/ExampleHookUseSortBy.js.map +1 -0
- package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.d.ts +2 -0
- package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.js +27 -0
- package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.js.map +1 -0
- package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.d.ts +2 -0
- package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.js +27 -0
- package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.js.map +1 -0
- package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.d.ts +2 -0
- package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.js +27 -0
- package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.js.map +1 -0
- package/dist/src/components/Example/ExampleResultCardCallout.js +4 -4
- package/dist/src/components/Example/ExampleResultCardCallout.js.map +1 -1
- package/dist/src/components/Example/ExampleResultCardProduct.js +6 -6
- package/dist/src/components/Example/ExampleResultCardProduct.js.map +1 -1
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.js +1 -1
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.js.map +1 -1
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.js +3 -3
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.js.map +1 -1
- package/dist/src/components/Example/ExampleResultPaginationNumbered.js +6 -6
- package/dist/src/components/Example/ExampleResultPaginationNumbered.js.map +1 -1
- package/dist/src/components/Example/ExampleResults.d.ts +2 -0
- package/dist/src/components/Example/ExampleResults.js +38 -0
- package/dist/src/components/Example/ExampleResults.js.map +1 -0
- package/dist/src/components/Example/ExampleSearch.d.ts +4 -0
- package/dist/src/components/Example/ExampleSearch.js +20 -0
- package/dist/src/components/Example/ExampleSearch.js.map +1 -0
- package/dist/src/components/Example/ExampleSortBy.d.ts +4 -0
- package/dist/src/components/Example/ExampleSortBy.js +13 -0
- package/dist/src/components/Example/ExampleSortBy.js.map +1 -0
- package/dist/src/components/Example/ExampleStats.d.ts +4 -0
- package/dist/src/components/Example/ExampleStats.js +15 -0
- package/dist/src/components/Example/ExampleStats.js.map +1 -0
- package/dist/src/components/Example/index.d.ts +12 -2
- package/dist/src/components/Example/index.js +12 -2
- package/dist/src/components/Example/index.js.map +1 -1
- package/dist/src/components/Filter/Filter.d.ts +9 -6
- package/dist/src/components/Filter/Filter.js +29 -29
- package/dist/src/components/Filter/Filter.js.map +1 -1
- package/dist/src/components/Filter/Filters.d.ts +7 -0
- package/dist/src/components/Filter/Filters.js +17 -0
- package/dist/src/components/Filter/Filters.js.map +1 -0
- package/dist/src/components/Filter/FiltersActive.d.ts +16 -0
- package/dist/src/components/Filter/FiltersActive.js +36 -0
- package/dist/src/components/Filter/FiltersActive.js.map +1 -0
- package/dist/src/components/Filter/index.d.ts +2 -1
- package/dist/src/components/Filter/index.js +2 -1
- package/dist/src/components/Filter/index.js.map +1 -1
- package/dist/src/components/{ReactifySearchBase/ReactifySearchBase.d.ts → ReactifySearchProvider/ReactifySearchProvider.d.ts} +6 -10
- package/dist/src/components/{ReactifySearchBase/ReactifySearchBase.js → ReactifySearchProvider/ReactifySearchProvider.js} +33 -29
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -0
- package/dist/src/components/ReactifySearchProvider/index.d.ts +1 -0
- package/dist/src/components/ReactifySearchProvider/index.js +14 -0
- package/dist/src/components/ReactifySearchProvider/index.js.map +1 -0
- package/dist/src/components/Result/ResultCardCallout.d.ts +2 -4
- package/dist/src/components/Result/ResultCardCallout.js.map +1 -1
- package/dist/src/components/Result/ResultCardProduct.d.ts +2 -5
- package/dist/src/components/Result/ResultCardProduct.js.map +1 -1
- package/dist/src/components/Result/ResultPaginationLoadMore.d.ts +2 -2
- package/dist/src/components/Result/ResultPaginationLoadMore.js +1 -1
- package/dist/src/components/Result/ResultPaginationLoadMore.js.map +1 -1
- package/dist/src/components/Result/ResultPaginationNextPrev.d.ts +2 -2
- package/dist/src/components/Result/ResultPaginationNextPrev.js +1 -1
- package/dist/src/components/Result/ResultPaginationNextPrev.js.map +1 -1
- package/dist/src/components/Result/ResultPaginationNumbered.d.ts +2 -2
- package/dist/src/components/Result/ResultPaginationNumbered.js +1 -1
- package/dist/src/components/Result/ResultPaginationNumbered.js.map +1 -1
- package/dist/src/components/Result/{ResultStack.d.ts → Results.d.ts} +21 -13
- package/dist/src/components/Result/{ResultStack.js → Results.js} +45 -28
- package/dist/src/components/Result/Results.js.map +1 -0
- package/dist/src/components/Result/index.d.ts +1 -1
- package/dist/src/components/Result/index.js +1 -1
- package/dist/src/components/Result/index.js.map +1 -1
- package/dist/src/components/Search/Search.d.ts +7 -0
- package/dist/src/components/Search/Search.js +17 -0
- package/dist/src/components/Search/Search.js.map +1 -0
- package/dist/src/components/Search/index.d.ts +1 -1
- package/dist/src/components/Search/index.js +1 -1
- package/dist/src/components/Search/index.js.map +1 -1
- package/dist/src/components/Sensor/SensorCollection.js +2 -2
- package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
- package/dist/src/components/Sensor/SensorInventoryAvailable.js +1 -1
- package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -1
- package/dist/src/components/Sensor/SensorSearch.js +3 -3
- package/dist/src/components/Sensor/SensorSearch.js.map +1 -1
- package/dist/src/components/Sensor/SensorSort.js +13 -13
- package/dist/src/components/Sensor/SensorSort.js.map +1 -1
- package/dist/src/components/Sensor/Sensors.d.ts +3 -0
- package/dist/src/components/Sensor/{SensorStack.js → Sensors.js} +4 -4
- package/dist/src/components/Sensor/Sensors.js.map +1 -0
- package/dist/src/components/Sensor/index.d.ts +1 -1
- package/dist/src/components/Sensor/index.js +1 -1
- package/dist/src/components/Sensor/index.js.map +1 -1
- package/dist/src/components/SortBy/SortBy.d.ts +7 -0
- package/dist/src/components/SortBy/SortBy.js +17 -0
- package/dist/src/components/SortBy/SortBy.js.map +1 -0
- package/dist/src/components/SortBy/index.d.ts +1 -0
- package/dist/src/components/{Sortby → SortBy}/index.js +1 -1
- package/dist/src/components/{Sortby → SortBy}/index.js.map +1 -1
- package/dist/src/components/Stats/Stats.d.ts +22 -0
- package/dist/src/components/Stats/Stats.js +15 -0
- package/dist/src/components/Stats/Stats.js.map +1 -0
- package/dist/src/components/Stats/index.d.ts +1 -0
- package/dist/src/components/Stats/index.js +14 -0
- package/dist/src/components/Stats/index.js.map +1 -0
- package/dist/src/components/index.d.ts +5 -2
- package/dist/src/components/index.js +5 -2
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/hooks/index.d.ts +4 -3
- package/dist/src/hooks/index.js +4 -3
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/reactivesearch/index.d.ts +3 -3
- package/dist/src/hooks/reactivesearch/index.js +3 -3
- package/dist/src/hooks/reactivesearch/index.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +2 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +12 -11
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +2 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +6 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +14 -2
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +2 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +5 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +11 -3
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +4 -4
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.d.ts +5 -0
- package/dist/src/hooks/reactivesearch/{useReactiveResultStackProps.js → useReactiveReactiveListProps.js} +7 -6
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js.map +1 -0
- package/dist/src/hooks/useConfig.js +1 -1
- package/dist/src/hooks/useConfig.js.map +1 -1
- package/dist/src/hooks/useCuration.js +4 -8
- package/dist/src/hooks/useCuration.js.map +1 -1
- package/dist/src/hooks/useFilterListProps.d.ts +3 -2
- package/dist/src/hooks/useFilterListProps.js +67 -10
- package/dist/src/hooks/useFilterListProps.js.map +1 -1
- package/dist/src/hooks/useFilterRangeProps.d.ts +11 -0
- package/dist/src/hooks/useFilterRangeProps.js +53 -0
- package/dist/src/hooks/useFilterRangeProps.js.map +1 -0
- package/dist/src/hooks/useFilterSliderProps.d.ts +12 -0
- package/dist/src/hooks/useFilterSliderProps.js +49 -0
- package/dist/src/hooks/useFilterSliderProps.js.map +1 -0
- package/dist/src/hooks/useFilters.d.ts +5 -2
- package/dist/src/hooks/useFilters.js +45 -11
- package/dist/src/hooks/useFilters.js.map +1 -1
- package/dist/src/hooks/usePagination.d.ts +10 -0
- package/dist/src/hooks/usePagination.js.map +1 -1
- package/dist/src/hooks/usePaginationLoadMore.js +1 -1
- package/dist/src/hooks/usePaginationLoadMore.js.map +1 -1
- package/dist/src/hooks/useReactifySearchContext.d.ts +12 -20
- package/dist/src/hooks/useReactifySearchContext.js.map +1 -1
- package/dist/src/hooks/useSearch.d.ts +8 -3
- package/dist/src/hooks/useSearch.js +39 -17
- package/dist/src/hooks/useSearch.js.map +1 -1
- package/dist/src/hooks/useSortBy.d.ts +9 -0
- package/dist/src/hooks/{useSortby.js → useSortBy.js} +5 -5
- package/dist/src/hooks/useSortBy.js.map +1 -0
- package/dist/src/types/firestore.d.ts +3 -0
- package/dist/src/types/firestore.js.map +1 -1
- package/dist/src/types/reactivesearch.d.ts +2 -2
- package/dist/src/types/reactivesearch.js.map +1 -1
- package/dist/src/utility/debug.d.ts +3 -1
- package/dist/src/utility/debug.js +6 -2
- package/dist/src/utility/debug.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/components/Example/ExampleFilterStack.d.ts +0 -4
- package/dist/src/components/Example/ExampleFilterStack.js.map +0 -1
- package/dist/src/components/Example/ExampleSortby.d.ts +0 -4
- package/dist/src/components/Example/ExampleSortby.js +0 -13
- package/dist/src/components/Example/ExampleSortby.js.map +0 -1
- package/dist/src/components/Filter/FilterStack.d.ts +0 -7
- package/dist/src/components/Filter/FilterStack.js +0 -17
- package/dist/src/components/Filter/FilterStack.js.map +0 -1
- package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js.map +0 -1
- package/dist/src/components/ReactifySearchBase/index.d.ts +0 -1
- package/dist/src/components/ReactifySearchBase/index.js.map +0 -1
- package/dist/src/components/Result/ResultStack.js.map +0 -1
- package/dist/src/components/Search/SearchInput.d.ts +0 -8
- package/dist/src/components/Search/SearchInput.js +0 -18
- package/dist/src/components/Search/SearchInput.js.map +0 -1
- package/dist/src/components/Sensor/SensorStack.d.ts +0 -3
- package/dist/src/components/Sensor/SensorStack.js.map +0 -1
- package/dist/src/components/Sortby/Sortby.d.ts +0 -7
- package/dist/src/components/Sortby/Sortby.js +0 -17
- package/dist/src/components/Sortby/Sortby.js.map +0 -1
- package/dist/src/components/Sortby/index.d.ts +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.d.ts +0 -17
- package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.js.map +0 -1
- package/dist/src/hooks/useFilterStack.d.ts +0 -4
- package/dist/src/hooks/useFilterStack.js +0 -52
- package/dist/src/hooks/useFilterStack.js.map +0 -1
- package/dist/src/hooks/useSortby.d.ts +0 -6
- package/dist/src/hooks/useSortby.js.map +0 -1
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ReactivesearchPaginationProps } from "../types";
|
|
3
3
|
export declare const usePagination: (input: ReactivesearchPaginationProps) => {
|
|
4
|
+
/** The current page number, indexed from 0 */
|
|
4
5
|
currentPage: number;
|
|
6
|
+
/** The total amount of pages */
|
|
5
7
|
totalPages: number;
|
|
8
|
+
/** The total amount of pages to show within pagination components */
|
|
6
9
|
pagesToShow: Array<number>;
|
|
10
|
+
/** If there is a next page */
|
|
7
11
|
hasNextPage: boolean;
|
|
12
|
+
/** If there is a previous page */
|
|
8
13
|
hasPreviousPage: boolean;
|
|
14
|
+
/** The _actual_ current page number, indexed from 1 */
|
|
9
15
|
actualCurrentPage: number;
|
|
16
|
+
/** Function to build a URL for a specific page number, useful for Href links */
|
|
10
17
|
buildPagePath: (page: number) => string;
|
|
18
|
+
/** Function to change to the next page, if an event is provided the preventDefault() method will be called */
|
|
11
19
|
handleNextPage: (event?: React.SyntheticEvent<Element, Event> | undefined) => void;
|
|
20
|
+
/** Function to change to the previous page, if an event is provided the preventDefault() method will be called */
|
|
12
21
|
handlePreviousPage: (event?: React.SyntheticEvent<Element, Event> | undefined) => void;
|
|
22
|
+
/** Function to change to any page, if an event is provided the preventDefault() method will be called */
|
|
13
23
|
handlePageChange: (pageNumber: number, event?: React.SyntheticEvent<Element, Event> | undefined) => void;
|
|
14
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePagination.js","sourceRoot":"","sources":["../../../src/hooks/usePagination.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAAwC;AACxC,wCAAmC;AAE5B,MAAM,aAAa,GAAG,CAC3B,KAAoC,
|
|
1
|
+
{"version":3,"file":"usePagination.js","sourceRoot":"","sources":["../../../src/hooks/usePagination.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAAwC;AACxC,wCAAmC;AAE5B,MAAM,aAAa,GAAG,CAC3B,KAAoC,EAsBpC,EAAE;IACF,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IAEjC,MAAM,aAAa,GAAG,eAAK,CAAC,WAAW,CAAC,CAAC,IAAY,EAAE,EAAE;QACvD,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAE7C,OAAO,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC;YAClC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,IAAI,EAAE,CAAC;YAClD,CAAC,CAAC,GAAG,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,EAAE,CAAC;IAC3E,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,eAAK,CAAC,OAAO,CAC/B,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,EAChE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,CACnD,CAAC;IAEF,8EAA8E;IAC9E,MAAM,iBAAiB,GA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ClB,gBAAgB;KACjB,CACF,CAAC;AACJ,CAAC,CAAC;AA1IW,QAAA,aAAa,iBA0IxB;AAEF,6CAA6C;AAC7C,uDAAuD;AACvD,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,UAAkB,EAAE,WAAmB,EAAE,EAAE;IAC1E,MAAM,WAAW,GAAG,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;IAC3C,IAAI,IAAI,GAAa,EAAE,CAAC;IACxB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,UAAU,IAAI,CAAC,IAAI,WAAW,GAAG,MAAM,GAAG,CAAC,EAAE;QAC/C,KAAK,GAAG,CAAC,CAAC;KACX;SAAM;QACL,IAAI,UAAU,GAAG,MAAM,IAAI,WAAW,EAAE;YACtC,KAAK;gBACH,WAAW,GAAG,CAAC,KAAK,UAAU;oBAC5B,CAAC,CAAC,WAAW,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC;oBACjC,CAAC,CAAC,WAAW,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC;SAC3C;aAAM;YACL,KAAK,GAAG,WAAW,GAAG,MAAM,CAAC;SAC9B;KACF;IACD,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACxD,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchPaginationProps } from \"../types\";\nimport { useAnalytics } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const usePagination = (\n input: ReactivesearchPaginationProps\n): {\n /** The current page number, indexed from 0 */\n currentPage: number;\n /** The total amount of pages */\n totalPages: number;\n /** The total amount of pages to show within pagination components */\n pagesToShow: Array<number>;\n /** If there is a next page */\n hasNextPage: boolean;\n /** If there is a previous page */\n hasPreviousPage: boolean;\n /** The _actual_ current page number, indexed from 1 */\n actualCurrentPage: number;\n /** Function to build a URL for a specific page number, useful for Href links */\n buildPagePath: (page: number) => string;\n /** Function to change to the next page, if an event is provided the preventDefault() method will be called */\n handleNextPage: (event?: React.SyntheticEvent) => void;\n /** Function to change to the previous page, if an event is provided the preventDefault() method will be called */\n handlePreviousPage: (event?: React.SyntheticEvent) => void;\n /** Function to change to any page, if an event is provided the preventDefault() method will be called */\n handlePageChange: (pageNumber: number, event?: React.SyntheticEvent) => void;\n} => {\n const { track } = useAnalytics();\n\n const buildPagePath = React.useCallback((page: number) => {\n const currentPath = window.location.pathname;\n\n return currentPath.includes(\"page=\")\n ? currentPath.replace(/page=\\d+/g, `page=${page}`)\n : `${currentPath}${currentPath.includes(\"?\") ? \"&\" : \"?\"}page=${page}`;\n }, []);\n\n const pagesToShow = React.useMemo(\n () => getPages(input.pages, input.totalPages, input.currentPage),\n [input.pages, input.totalPages, input.currentPage]\n );\n\n // default input.currentPage is zero-indexed, actualCurrentPage is one-indexed\n const actualCurrentPage = React.useMemo(\n () => input.currentPage + 1,\n [input.currentPage]\n );\n\n const hasNextPage = React.useMemo(\n () => actualCurrentPage < input.totalPages,\n [actualCurrentPage, input.totalPages]\n );\n\n const hasPreviousPage = React.useMemo(\n () => actualCurrentPage > 1,\n [actualCurrentPage]\n );\n\n const hasPage = React.useCallback(\n (pageNumber: number) => {\n return pageNumber >= 0 && pageNumber < input.totalPages;\n },\n [input.totalPages]\n );\n\n const handlePageChange = React.useCallback<\n ReturnType<typeof usePagination>[\"handlePageChange\"]\n >(\n (pageNumber, event) => {\n debug.log(\"usePagination\", \"handlePageChange[pageNumber]\", pageNumber);\n debug.breadcrumb({\n category: \"pagination\",\n message: \"change page number\",\n data: {\n pageNumber: pageNumber,\n },\n });\n event?.preventDefault();\n if (!hasPage(pageNumber)) {\n return;\n }\n input.setPage(pageNumber);\n track({\n eventName: \"paginationChange\",\n payload: {\n page: pageNumber,\n source: window.location.pathname.includes(\"/search\")\n ? \"search\"\n : \"collection\",\n },\n });\n },\n [input.setPage, track]\n );\n\n const handleNextPage = React.useCallback<\n ReturnType<typeof usePagination>[\"handleNextPage\"]\n >(\n (event) => {\n debug.log(\"usePagination\", \"handleNextPage\", input.currentPage + 1);\n handlePageChange(input.currentPage + 1, event);\n },\n [hasNextPage, input.currentPage, handlePageChange]\n );\n\n const handlePreviousPage = React.useCallback<\n ReturnType<typeof usePagination>[\"handlePreviousPage\"]\n >(\n (event) => {\n debug.log(\"usePagination\", \"handlePreviousPage\", input.currentPage - 1);\n handlePageChange(input.currentPage - 1, event);\n },\n [hasPreviousPage, input.currentPage, handlePageChange]\n );\n\n return React.useMemo(\n () => ({\n currentPage: input.currentPage,\n totalPages: input.totalPages,\n pagesToShow,\n hasNextPage,\n buildPagePath,\n hasPreviousPage,\n actualCurrentPage,\n handleNextPage,\n handlePreviousPage,\n handlePageChange,\n }),\n [\n input.currentPage,\n input.totalPages,\n pagesToShow,\n hasNextPage,\n buildPagePath,\n hasPreviousPage,\n actualCurrentPage,\n handleNextPage,\n handlePreviousPage,\n handlePageChange,\n ]\n );\n};\n\n// get a list of pages to display buttons for\n// @todo this is super hacky and needs to be cleaned up\nconst getPages = (pages: number, totalPages: number, currentPage: number) => {\n const pagesToShow = pages > totalPages ? totalPages : pages;\n const buffer = Math.floor(pagesToShow / 2);\n let list: number[] = [];\n let start = 0;\n if (totalPages <= 5 || currentPage < buffer + 1) {\n start = 0;\n } else {\n if (totalPages - buffer <= currentPage) {\n start =\n currentPage + 1 === totalPages\n ? currentPage - (pagesToShow - 1)\n : currentPage - (buffer + buffer / 2);\n } else {\n start = currentPage - buffer;\n }\n }\n Array.apply(null, Array(pagesToShow)).map((item, index) => {\n list.push(start + index);\n });\n return list;\n};\n"]}
|
|
@@ -9,7 +9,7 @@ const hooks_1 = require("../hooks");
|
|
|
9
9
|
const utility_1 = require("../utility");
|
|
10
10
|
const usePaginationLoadMore = (input) => {
|
|
11
11
|
const analyticsHook = (0, hooks_1.useAnalytics)();
|
|
12
|
-
const { filterStack } = (0, hooks_1.
|
|
12
|
+
const { filterStack } = (0, hooks_1.useFilters)();
|
|
13
13
|
const hasMore = input.resultStats.displayedResults !== input.resultStats.numberOfResults;
|
|
14
14
|
const handleLoadMore = react_1.default.useCallback(() => {
|
|
15
15
|
utility_1.debug.log("usePaginationLoadMore", "handleLoadMore");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaginationLoadMore.js","sourceRoot":"","sources":["../../../src/hooks/usePaginationLoadMore.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,
|
|
1
|
+
{"version":3,"file":"usePaginationLoadMore.js","sourceRoot":"","sources":["../../../src/hooks/usePaginationLoadMore.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAAoD;AACpD,wCAAmC;AAE5B,MAAM,qBAAqB,GAAG,CACnC,KAAgC,EAchC,EAAE;IACF,MAAM,aAAa,GAAG,IAAA,oBAAY,GAAE,CAAC;IACrC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,MAAM,OAAO,GACX,KAAK,CAAC,WAAW,CAAC,gBAAgB,KAAK,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC;IAE3E,MAAM,cAAc,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC5C,eAAK,CAAC,GAAG,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;QAErD,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QAED,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,aAAa,CAAC,KAAK,CAAC;YAClB,SAAS,EAAE,kBAAkB;YAC7B,OAAO,EAAE;gBACP,IAAI,EACF,IAAI,CAAC,IAAI,CACP,KAAK,CAAC,WAAW,CAAC,gBAAgB,GAAG,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,KAAI,EAAE,CAAC,CACnE,GAAG,CAAC;gBACP,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;oBAClD,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,YAAY;aACjB;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;IAE1E,OAAO,eAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO;QACP,cAAc;QACd,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC,EACF,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC,CAC5D,CAAC;AACJ,CAAC,CAAC;AArDW,QAAA,qBAAqB,yBAqDhC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../types\";\nimport { useAnalytics, useFilters } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const usePaginationLoadMore = (\n input: ReactivesearchResultProps\n): {\n loading: boolean;\n hasMore: boolean;\n handleLoadMore: () => void;\n resultStats: {\n time: number;\n hidden: number;\n promoted: number;\n currentPage: number;\n numberOfPages: number;\n numberOfResults?: number;\n displayedResults: number;\n };\n} => {\n const analyticsHook = useAnalytics();\n const { filterStack } = useFilters();\n\n const hasMore =\n input.resultStats.displayedResults !== input.resultStats.numberOfResults;\n\n const handleLoadMore = React.useCallback(() => {\n debug.log(\"usePaginationLoadMore\", \"handleLoadMore\");\n\n if (!hasMore) {\n return;\n }\n\n input.loadMore();\n analyticsHook.track({\n eventName: \"paginationChange\",\n payload: {\n page:\n Math.ceil(\n input.resultStats.displayedResults / (filterStack?.pageSize || 20)\n ) + 1,\n source: window.location.pathname.includes(\"/search\")\n ? \"search\"\n : \"collection\",\n },\n });\n }, [input.loadMore, analyticsHook.track, input.resultStats, filterStack]);\n\n return React.useMemo(\n () => ({\n loading: input.loading,\n hasMore,\n handleLoadMore,\n resultStats: input.resultStats,\n }),\n [input.loading, hasMore, handleLoadMore, input.resultStats]\n );\n};\n"]}
|
|
@@ -6,7 +6,7 @@ export declare const ReactifySearchContext: React.Context<{
|
|
|
6
6
|
mode: "search" | "collection" | "instant-search";
|
|
7
7
|
index: string;
|
|
8
8
|
shopifyPermanentDomain: string;
|
|
9
|
-
|
|
9
|
+
filtersHandle?: string | undefined;
|
|
10
10
|
credentials: {
|
|
11
11
|
username: string;
|
|
12
12
|
password: string;
|
|
@@ -19,19 +19,15 @@ export declare const ReactifySearchContext: React.Context<{
|
|
|
19
19
|
mode: "search";
|
|
20
20
|
} | {
|
|
21
21
|
mode: "collection";
|
|
22
|
-
|
|
23
|
-
id: number;
|
|
24
|
-
handle: string;
|
|
25
|
-
title: string;
|
|
26
|
-
};
|
|
22
|
+
collectionHandle: string;
|
|
27
23
|
} | {
|
|
28
24
|
mode: "instant-search";
|
|
29
25
|
});
|
|
30
26
|
search: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
searchTerm: string;
|
|
28
|
+
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
29
|
+
showInstantSearchResults: boolean;
|
|
30
|
+
setShowInstantSearchResults: React.Dispatch<React.SetStateAction<boolean>>;
|
|
35
31
|
};
|
|
36
32
|
sortby: {
|
|
37
33
|
sortOption: string;
|
|
@@ -44,7 +40,7 @@ export declare const useReactifySearchContext: () => {
|
|
|
44
40
|
mode: "search" | "collection" | "instant-search";
|
|
45
41
|
index: string;
|
|
46
42
|
shopifyPermanentDomain: string;
|
|
47
|
-
|
|
43
|
+
filtersHandle?: string | undefined;
|
|
48
44
|
credentials: {
|
|
49
45
|
username: string;
|
|
50
46
|
password: string;
|
|
@@ -57,19 +53,15 @@ export declare const useReactifySearchContext: () => {
|
|
|
57
53
|
mode: "search";
|
|
58
54
|
} | {
|
|
59
55
|
mode: "collection";
|
|
60
|
-
|
|
61
|
-
id: number;
|
|
62
|
-
handle: string;
|
|
63
|
-
title: string;
|
|
64
|
-
};
|
|
56
|
+
collectionHandle: string;
|
|
65
57
|
} | {
|
|
66
58
|
mode: "instant-search";
|
|
67
59
|
});
|
|
68
60
|
search: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
searchTerm: string;
|
|
62
|
+
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
63
|
+
showInstantSearchResults: boolean;
|
|
64
|
+
setShowInstantSearchResults: React.Dispatch<React.SetStateAction<boolean>>;
|
|
73
65
|
};
|
|
74
66
|
sortby: {
|
|
75
67
|
sortOption: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAIb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAIb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,CA0CtD,SAAS,CAAC,CAAC;AAEN,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAC3C,eAAK,CAAC,UAAU,CAAC,6BAAqB,CAAE,CAAC;AAD9B,QAAA,wBAAwB,4BACM","sourcesContent":["import React from \"react\";\n\nimport { Config } from \"../types\";\n\nexport const ReactifySearchContext = React.createContext<\n | {\n config: Config;\n options: {\n mode: \"search\" | \"collection\" | \"instant-search\";\n index: string;\n shopifyPermanentDomain: string;\n filtersHandle?: string;\n credentials: {\n username: string;\n password: string;\n endpoint: string;\n };\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n theme: Record<string, unknown>;\n additionalComponentHandles?: Array<string>;\n } & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n );\n search: {\n searchTerm: string;\n setSearchTerm: React.Dispatch<React.SetStateAction<string>>;\n showInstantSearchResults: boolean;\n setShowInstantSearchResults: React.Dispatch<\n React.SetStateAction<boolean>\n >;\n };\n sortby: {\n sortOption: string;\n setSortOption: React.Dispatch<React.SetStateAction<string>>;\n };\n }\n | undefined\n>(undefined);\n\nexport const useReactifySearchContext = () =>\n React.useContext(ReactifySearchContext)!;\n"]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export declare const useSearch: () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/** The current search term */
|
|
4
|
+
searchTerm: string;
|
|
5
|
+
/** Function for changing the current search term */
|
|
6
|
+
setSearchTerm: (searchTerm?: string | undefined) => void;
|
|
7
|
+
/** Function for navigating to the search page, includes logic for redirects */
|
|
8
|
+
submitSearchTerm: (searchTerm?: string | undefined) => void;
|
|
9
|
+
/** Used to determine if instant search results should be displayed */
|
|
6
10
|
showInstantSearchResults: boolean;
|
|
11
|
+
/** Used to manually set the "showInstantSearchResults" value */
|
|
7
12
|
setShowInstantSearchResults: React.Dispatch<React.SetStateAction<boolean>>;
|
|
8
13
|
};
|
|
@@ -4,46 +4,68 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useSearch = void 0;
|
|
7
|
+
const ahooks_1 = require("ahooks");
|
|
7
8
|
const react_1 = __importDefault(require("react"));
|
|
8
9
|
const hooks_1 = require("../hooks");
|
|
9
10
|
const utility_1 = require("../utility");
|
|
10
11
|
const useSearch = () => {
|
|
11
12
|
const { options, config, search } = (0, hooks_1.useReactifySearchContext)();
|
|
12
|
-
const
|
|
13
|
+
const handleSubmitSearchTerm = react_1.default.useCallback((searchTerm = search.searchTerm) => {
|
|
13
14
|
utility_1.debug.breadcrumb({
|
|
14
15
|
category: "search",
|
|
15
|
-
message: "search
|
|
16
|
+
message: "search submit",
|
|
16
17
|
data: {
|
|
17
|
-
|
|
18
|
+
searchTerm: searchTerm,
|
|
18
19
|
},
|
|
19
20
|
});
|
|
20
|
-
utility_1.debug.log("useSearch", "
|
|
21
|
-
if (!
|
|
21
|
+
utility_1.debug.log("useSearch", "submitSearchTerm[query]", searchTerm);
|
|
22
|
+
if (!searchTerm) {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
const redirect = config.redirects.find((redirect) => redirect.query.trim().toLowerCase() ===
|
|
25
|
-
|
|
26
|
+
searchTerm.trim().toLowerCase());
|
|
26
27
|
if (redirect) {
|
|
27
|
-
utility_1.debug.log("useSearch", "
|
|
28
|
+
utility_1.debug.log("useSearch", "submitSearchTerm[redirect]", redirect);
|
|
28
29
|
}
|
|
29
|
-
search.
|
|
30
|
+
search.setShowInstantSearchResults(false);
|
|
30
31
|
if (options.onRedirect) {
|
|
31
|
-
options.onRedirect(redirect ? "redirect" : "search", redirect ? redirect.url : `/search?q=${
|
|
32
|
+
options.onRedirect(redirect ? "redirect" : "search", redirect ? redirect.url : `/search?q=${searchTerm}`);
|
|
32
33
|
}
|
|
33
34
|
else if (redirect) {
|
|
34
35
|
window.location.href = redirect.url;
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
|
-
window.location.href = `/search?q=${
|
|
38
|
+
window.location.href = `/search?q=${searchTerm}`;
|
|
38
39
|
}
|
|
39
|
-
}, [search.
|
|
40
|
-
|
|
40
|
+
}, [search.searchTerm]);
|
|
41
|
+
const { run: runDebouncedBreadcrumb, cancel: cancelDebouncedBreadcrumb } = (0, ahooks_1.useDebounceFn)((searchTerm = search.searchTerm) => {
|
|
42
|
+
utility_1.debug.log("useSearch", "setSearchTerm[searchTerm]", searchTerm);
|
|
43
|
+
utility_1.debug.breadcrumb({
|
|
44
|
+
category: "search",
|
|
45
|
+
message: "search query",
|
|
46
|
+
data: {
|
|
47
|
+
searchTerm: searchTerm,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}, {
|
|
51
|
+
wait: 300,
|
|
52
|
+
});
|
|
53
|
+
const handleSetSearchTerm = react_1.default.useCallback((searchTerm = "") => {
|
|
54
|
+
utility_1.debug.log("useSearch", "setSearchTerm[searchTerm]", searchTerm);
|
|
55
|
+
if (searchTerm) {
|
|
56
|
+
runDebouncedBreadcrumb(searchTerm);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
cancelDebouncedBreadcrumb();
|
|
60
|
+
}
|
|
61
|
+
search.setSearchTerm(searchTerm);
|
|
62
|
+
}, [search.searchTerm]);
|
|
41
63
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
showInstantSearchResults: !!search.
|
|
46
|
-
setShowInstantSearchResults: search.
|
|
64
|
+
searchTerm: search.searchTerm,
|
|
65
|
+
setSearchTerm: handleSetSearchTerm,
|
|
66
|
+
submitSearchTerm: handleSubmitSearchTerm,
|
|
67
|
+
showInstantSearchResults: !!search.showInstantSearchResults && !!search.searchTerm,
|
|
68
|
+
setShowInstantSearchResults: search.setShowInstantSearchResults,
|
|
47
69
|
};
|
|
48
70
|
};
|
|
49
71
|
exports.useSearch = useSearch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearch.js","sourceRoot":"","sources":["../../../src/hooks/useSearch.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,oCAAoD;AACpD,wCAAmC;AAE5B,MAAM,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"useSearch.js","sourceRoot":"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AC;AA/FW,QAAA,SAAS,aA+FpB","sourcesContent":["import { useDebounceFn } from \"ahooks\";\nimport React from \"react\";\n\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useSearch = (): {\n /** The current search term */\n searchTerm: string;\n /** Function for changing the current search term */\n setSearchTerm: (searchTerm?: string) => void;\n /** Function for navigating to the search page, includes logic for redirects */\n submitSearchTerm: (searchTerm?: string) => void;\n /** Used to determine if instant search results should be displayed */\n showInstantSearchResults: boolean;\n /** Used to manually set the \"showInstantSearchResults\" value */\n setShowInstantSearchResults: React.Dispatch<React.SetStateAction<boolean>>;\n} => {\n const { options, config, search } = useReactifySearchContext();\n\n const handleSubmitSearchTerm = React.useCallback(\n (searchTerm: string = search.searchTerm) => {\n debug.breadcrumb({\n category: \"search\",\n message: \"search submit\",\n data: {\n searchTerm: searchTerm,\n },\n });\n\n debug.log(\"useSearch\", \"submitSearchTerm[query]\", searchTerm);\n\n if (!searchTerm) {\n return;\n }\n\n const redirect = config.redirects.find(\n (redirect) =>\n redirect.query.trim().toLowerCase() ===\n searchTerm.trim().toLowerCase()\n );\n\n if (redirect) {\n debug.log(\"useSearch\", \"submitSearchTerm[redirect]\", redirect);\n }\n\n search.setShowInstantSearchResults(false);\n\n if (options.onRedirect) {\n options.onRedirect(\n redirect ? \"redirect\" : \"search\",\n redirect ? redirect.url : `/search?q=${searchTerm}`\n );\n } else if (redirect) {\n window.location.href = redirect.url;\n } else {\n window.location.href = `/search?q=${searchTerm}`;\n }\n },\n [search.searchTerm]\n );\n\n const { run: runDebouncedBreadcrumb, cancel: cancelDebouncedBreadcrumb } =\n useDebounceFn(\n (searchTerm: string = search.searchTerm) => {\n debug.log(\"useSearch\", \"setSearchTerm[searchTerm]\", searchTerm);\n debug.breadcrumb({\n category: \"search\",\n message: \"search query\",\n data: {\n searchTerm: searchTerm,\n },\n });\n },\n {\n wait: 300,\n }\n );\n\n const handleSetSearchTerm = React.useCallback(\n (searchTerm: string = \"\") => {\n debug.log(\"useSearch\", \"setSearchTerm[searchTerm]\", searchTerm);\n if (searchTerm) {\n runDebouncedBreadcrumb(searchTerm);\n } else {\n cancelDebouncedBreadcrumb();\n }\n\n search.setSearchTerm(searchTerm);\n },\n [search.searchTerm]\n );\n\n return {\n searchTerm: search.searchTerm,\n setSearchTerm: handleSetSearchTerm,\n submitSearchTerm: handleSubmitSearchTerm,\n showInstantSearchResults:\n !!search.showInstantSearchResults && !!search.searchTerm,\n setShowInstantSearchResults: search.setShowInstantSearchResults,\n };\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConfigSort } from "../types";
|
|
2
|
+
export declare const useSortBy: () => {
|
|
3
|
+
/** The currently selected sort option */
|
|
4
|
+
sortOption?: ConfigSort | undefined;
|
|
5
|
+
/** All of the available sort options */
|
|
6
|
+
sortOptions: Array<ConfigSort>;
|
|
7
|
+
/** Function for changing the current sort option */
|
|
8
|
+
setSortOption: (sortOptionHandle: string, ignoreHistoryState?: boolean | undefined) => void;
|
|
9
|
+
};
|
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.useSortBy = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const hooks_1 = require("../hooks");
|
|
9
9
|
const utility_1 = require("../utility");
|
|
10
|
-
const
|
|
10
|
+
const useSortBy = () => {
|
|
11
11
|
const { options, config, sortby } = (0, hooks_1.useReactifySearchContext)();
|
|
12
12
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
13
13
|
const sortOptions = react_1.default.useMemo(() => {
|
|
@@ -27,7 +27,7 @@ const useSortby = () => {
|
|
|
27
27
|
sortOptionHandle: sortOptionHandle,
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
|
-
utility_1.debug.log("
|
|
30
|
+
utility_1.debug.log("useSortBy", "setSortOption[sortOptionHandle]", sortOptionHandle);
|
|
31
31
|
sortby.setSortOption(sortOptionHandle);
|
|
32
32
|
if (!ignoreHistoryState) {
|
|
33
33
|
const url = new URL(window.location.href);
|
|
@@ -54,5 +54,5 @@ const useSortby = () => {
|
|
|
54
54
|
setSortOption,
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
|
-
exports.
|
|
58
|
-
//# sourceMappingURL=
|
|
57
|
+
exports.useSortBy = useSortBy;
|
|
58
|
+
//# sourceMappingURL=useSortBy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSortBy.js","sourceRoot":"","sources":["../../../src/hooks/useSortBy.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAAkE;AAClE,wCAAmC;AAE5B,MAAM,SAAS,GAAG,GAUvB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/D,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IAEjC,MAAM,WAAW,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACrC,OAAO,MAAM,CAAC,IAAI;aACf,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;aAC9D,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5E,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAE3B,MAAM,UAAU,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,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CAAC,IAAI,CAAC,CACvB,CAAC;IAEF,eAAK,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IAClD,eAAK,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IAEpD,OAAO;QACL,WAAW;QACX,UAAU;QACV,aAAa;KACd,CAAC;AACJ,CAAC,CAAC;AAzEW,QAAA,SAAS,aAyEpB","sourcesContent":["import React from \"react\";\n\nimport { ConfigSort } from \"../types\";\nimport { useAnalytics, useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useSortBy = (): {\n /** The currently selected sort option */\n sortOption?: ConfigSort;\n /** All of the available sort options */\n sortOptions: Array<ConfigSort>;\n /** Function for changing the current sort option */\n setSortOption: (\n sortOptionHandle: string,\n ignoreHistoryState?: boolean\n ) => void;\n} => {\n const { options, config, sortby } = useReactifySearchContext();\n const { track } = useAnalytics();\n\n const sortOptions = React.useMemo(() => {\n return config.sort\n .sort((a, b) => `${a.position}`.localeCompare(`${b.position}`))\n .filter(({ visibility }) => [\"all\", options.mode].includes(visibility));\n }, [options.mode, config]);\n\n const sortOption = React.useMemo(() => {\n return (\n sortOptions.find(({ handle }) => handle === sortby.sortOption) ||\n sortOptions[0]\n );\n }, [sortOptions, sortby.sortOption]);\n\n const setSortOption = React.useCallback(\n (sortOptionHandle: string, ignoreHistoryState = false) => {\n debug.breadcrumb({\n category: \"sort\",\n message: \"sort option changed\",\n data: {\n sortOptionHandle: sortOptionHandle,\n },\n });\n\n debug.log(\n \"useSortBy\",\n \"setSortOption[sortOptionHandle]\",\n sortOptionHandle\n );\n\n sortby.setSortOption(sortOptionHandle);\n\n if (!ignoreHistoryState) {\n const url = new URL(window.location.href);\n if (url.searchParams.has(\"sort\")) {\n url.searchParams.set(\"sort\", sortOptionHandle);\n } else {\n url.searchParams.append(\"sort\", sortOptionHandle);\n }\n window.history.pushState({}, \"\", url.toString());\n }\n\n track({\n eventName: \"sortChange\",\n payload: {\n type: sortOptionHandle,\n },\n });\n },\n [window.location.href]\n );\n\n debug.hook(\"useSortBy\", \"sortOption\", sortOption);\n debug.hook(\"useSortBy\", \"sortOptions\", sortOptions);\n\n return {\n sortOptions,\n sortOption,\n setSortOption,\n };\n};\n"]}
|
|
@@ -131,6 +131,9 @@ export interface FilterOption {
|
|
|
131
131
|
displaySize: string;
|
|
132
132
|
displaySliderInterval: string;
|
|
133
133
|
displaySliderStep: string;
|
|
134
|
+
displaySliderPrefix?: string;
|
|
135
|
+
displaySliderSuffix?: string;
|
|
136
|
+
displayRangeOptions?: Array<string>;
|
|
134
137
|
displayType: "multi" | "single" | "range" | "slider";
|
|
135
138
|
displayView: "list" | "check" | "swatch" | "box";
|
|
136
139
|
enabled: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firestore.js","sourceRoot":"","sources":["../../../src/types/firestore.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"firestore.js","sourceRoot":"","sources":["../../../src/types/firestore.ts"],"names":[],"mappings":";;;AAkOA,IAAY,cAQX;AARD,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,2CAAyB,CAAA;IACzB,yCAAuB,CAAA;IACvB,+CAA6B,CAAA;IAC7B,yCAAuB,CAAA;IACvB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;AACrB,CAAC,EARW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAQzB;AAyBD,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,8BAAmB,CAAA;IACnB,8BAAmB,CAAA;AACrB,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB","sourcesContent":["// @todo this is so we don't need to import firebase\ntype Timestamp = string;\n\nimport { ShopifyProduct } from \"./shopify\";\nimport { ElasticDataType } from \"./elastic\";\n\nexport interface Log {\n id: string;\n keywords: string[];\n message: string;\n platform: \"reactify\" | \"shopify\" | \"elastic\";\n percentCompleted: number;\n action?: {\n type: \"retry\";\n label: string;\n task: Task[\"taskId\"];\n };\n step:\n | \"download\"\n | \"transform\"\n | \"merge\"\n | \"upload\"\n | \"cleanup\"\n | \"complete\"\n | \"sync\";\n title: string;\n type: \"bulk\";\n data?: string; // JSON sringified data\n progress: \"new\" | \"error\" | \"complete\" | \"partiallyComplete\";\n status: \"success\" | \"info\" | \"warning\" | \"critical\"; // polaris banner status\n createdAt: Timestamp;\n updatedAt?: Timestamp;\n finishedAt?: Timestamp;\n}\n\nexport interface Task {\n logId: string;\n taskId:\n | \"download\"\n | \"transform\"\n | \"merge\"\n | \"upload\"\n | \"cleanup\"\n | \"refreshDefinedFields\"\n | \"install\";\n firstRun: boolean;\n createdAt: Timestamp;\n updatedAt?: Timestamp;\n}\n\nexport interface TaskDownload extends Task {\n taskId: \"download\";\n type: \"collection\" | \"product\";\n productUrl?: string;\n collectionUrl?: string;\n}\n\nexport interface TaskTransform extends Task {\n taskId: \"transform\";\n productUrl: string;\n collectionUrl: string;\n}\n\nexport interface TaskMerge extends Task {\n taskId: \"merge\";\n productCount: number;\n collectionCount: number;\n startAfterId?: string;\n}\n\nexport interface TaskUpload extends Task {\n taskId: \"upload\";\n productCount: number;\n collectionCount: number;\n startAfterId?: string;\n}\n\nexport interface TaskCleanup extends Task {\n taskId: \"cleanup\";\n}\n\nexport interface TaskRefreshDefinedFields extends Task {\n taskId: \"refreshDefinedFields\";\n}\n\nexport interface TaskInstall extends Task {\n taskId: \"install\";\n}\n\nexport interface Lock {\n logId: string;\n taskType: \"sync\";\n createdAt: Timestamp;\n}\n\nexport interface SettingsInstance {\n index: string;\n cloudId: string;\n endpoint: string;\n password: string;\n username: string;\n syncFrequency: string;\n syncThreshold: number;\n provider: \"elastic\" | \"aws\";\n storefrontAccessToken: string;\n customMappings: string; // JSON sringified data\n}\n\nexport interface SettingsProduct {\n tagChild?: string;\n tagKeys?: string[];\n tagParent?: string;\n syncObjects: string[];\n tagExclude?: string[];\n tagSeparator?: string;\n metafieldWhitelist?: string[];\n}\n\nexport interface SettingsCurations {\n moreInfo?: boolean;\n pageSize?: number;\n gridColumns?: number;\n}\n\nexport interface Field {\n id: string;\n field: string;\n enabled: boolean;\n importance: number;\n searchType: \"always_search\" | \"search_page\" | \"instant_search\";\n}\n\nexport interface DefinedField {\n label: string;\n value: string;\n type: ElasticDataType;\n}\n\nexport interface Sort {\n id: string;\n name: string;\n handle: string;\n field: string;\n position: number;\n enabled: boolean;\n direction: \"desc\" | \"asc\";\n visibility: \"all\" | \"search\" | \"collection\";\n}\n\nexport interface Filter {\n id: string;\n name: string;\n handle: string;\n enabled: boolean;\n pageSize: number;\n keywords: string[];\n defaultSort: string;\n collections: string[];\n type: \"search\" | \"collection\";\n paginationType: \"pagination\" | \"load_more\" | \"next_prev\" | \"infinite_scroll\";\n inventoryVisibility:\n | \"show_all\"\n | \"hide_products\"\n | \"hide_variants\"\n | \"hide_all\";\n}\n\nexport interface FilterOption {\n displaySize: string;\n displaySliderInterval: string;\n displaySliderStep: string;\n displaySliderPrefix?: string;\n displaySliderSuffix?: string;\n displayRangeOptions?: Array<string>; // formatted like \"<label>:<start>:<end>\"\n displayType: \"multi\" | \"single\" | \"range\" | \"slider\";\n displayView: \"list\" | \"check\" | \"swatch\" | \"box\";\n enabled: boolean;\n field: string;\n id: string;\n name: string;\n handle: string;\n position: number;\n settingsCollapsedDesktop: boolean;\n settingsCollapsedMobile: boolean;\n settingsShowFilter: boolean;\n settingsShowMore: boolean;\n settingsShowSearch: boolean;\n settingsUppercase: boolean;\n settingsHideUnavailable: boolean;\n valuesExclude: Array<string>;\n valuesManual: Array<string>;\n valuesShow: \"all\" | \"manual\";\n}\n\nexport interface Redirect {\n id: string;\n url: string;\n query: string;\n enabled: boolean;\n keywords: string[];\n}\n\nexport interface Curation {\n id: string;\n title: string;\n status: CurationStatus;\n published: boolean;\n keywords: string[];\n searchTerm?: string;\n longRunningTask?: boolean;\n collectionHandle?: string;\n type: \"collection\" | \"search\";\n boosting?: {\n groupings?: BoostGrouping[];\n sortings?: BoostSorting[];\n };\n sort?: CurationSort;\n}\n\nexport interface CurationSort {\n sortTag?: string;\n sortOption: string;\n sortDirection: \"asc\" | \"desc\";\n sortVariantOption?: \"option1\" | \"option2\" | \"option3\";\n}\n\nexport enum CurationStatus {\n Draft = \"draft\",\n Publishing = \"publishing\",\n Published = \"published\",\n Unpublishing = \"unpublishing\",\n Resetting = \"resetting\",\n Pinning = \"pinning\",\n Sorting = \"sorting\",\n}\n\nexport interface CurationHiding {\n productId: number;\n productHandle: string;\n}\n\nexport interface BoostGrouping {\n key: string;\n value: string;\n field: string;\n position: number;\n operation: string;\n}\n\nexport interface BoostSorting {\n key: string;\n field: string;\n query?: string;\n position: number;\n direction: \"asc\" | \"desc\";\n}\n\nexport type Pin = PinProduct | PinCallout;\n\nexport enum PinType {\n Product = \"product\",\n Callout = \"callout\",\n}\n\nexport interface PinProduct {\n key: string;\n type: PinType.Product;\n position: number;\n productId: number;\n productHandle: string;\n}\n\nexport interface PinCallout {\n key: string;\n type: PinType.Callout;\n position: number;\n calloutId: string;\n}\n\nexport interface Callout {\n id: string;\n link: string;\n title: string;\n content: string;\n enabled: boolean;\n textColor: string;\n keywords: string[];\n mobileImage: string;\n mobileVideo: string;\n desktopVideo: string;\n desktopImage: string;\n backgroundColor: string;\n visibility: \"desktop\" | \"mobile\" | \"all\";\n displayColumns: string; // @todo this should be a number\n displayRows: string; // @todo this should be a number\n selectedDates?: {\n end: Timestamp;\n start: Timestamp;\n };\n}\n\nexport interface Synonym {\n id: string;\n name: string;\n enabled: boolean;\n keywords: string[];\n synonyms: string[];\n type: \"group\" | \"oneway\";\n}\n\nexport interface MergedValue {\n id: string;\n name: string;\n field: string;\n keywords: string[];\n values: string[];\n}\n\nexport interface Collection {\n title: string;\n handle: string;\n shopifyId: string;\n productIds: string[];\n storefrontId: string;\n legacyResourceId: number;\n}\n\n// product is the shopify product with edges and nodes normalised\nexport type Product = Omit<\n ShopifyProduct,\n \"variants\" | \"images\" | \"media\" | \"metafields\"\n> & {\n variants: (Omit<\n ShopifyProduct[\"variants\"][\"edges\"][0][\"node\"],\n \"presentmentPrices\"\n > & {\n images?: ShopifyProduct[\"images\"][\"edges\"][0][\"node\"][]; // from child product if this variant is from a child\n presentmentPrices: ShopifyProduct[\"variants\"][\"edges\"][0][\"node\"][\"presentmentPrices\"][\"edges\"][0][\"node\"][];\n })[];\n images: ShopifyProduct[\"images\"][\"edges\"][0][\"node\"][];\n media: ShopifyProduct[\"media\"][\"edges\"][0][\"node\"][];\n metafields: ShopifyProduct[\"metafields\"][\"edges\"][0][\"node\"][];\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ElasticDocument, ElasticHit } from "./elastic";
|
|
2
|
-
export interface
|
|
2
|
+
export interface ReactivesearchFilterListProps {
|
|
3
3
|
loading: boolean;
|
|
4
4
|
error: Error | null;
|
|
5
|
-
handleChange: (
|
|
5
|
+
handleChange: (key: string) => void;
|
|
6
6
|
data: {
|
|
7
7
|
doc_count: number;
|
|
8
8
|
key: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactivesearch.js","sourceRoot":"","sources":["../../../src/types/reactivesearch.ts"],"names":[],"mappings":"","sourcesContent":["import { ElasticDocument, ElasticHit } from \"./elastic\";\n\n// props passed to SingleList/MultiList.render\nexport interface
|
|
1
|
+
{"version":3,"file":"reactivesearch.js","sourceRoot":"","sources":["../../../src/types/reactivesearch.ts"],"names":[],"mappings":"","sourcesContent":["import { ElasticDocument, ElasticHit } from \"./elastic\";\n\n// props passed to SingleList/MultiList.render\nexport interface ReactivesearchFilterListProps {\n loading: boolean;\n error: Error | null;\n handleChange: (key: string) => void;\n data: { doc_count: number; key: string }[];\n value: string | { [key: string]: boolean };\n}\n\n// props passed to ReactiveList.renderPagination\nexport interface ReactivesearchPaginationProps {\n pages: number;\n showEndPage: false;\n totalPages: number;\n currentPage: number;\n setPage: (page: number) => void;\n}\n\n// props passed to ReactiveList.render\n// @todo complete missing types\nexport interface ReactivesearchResultProps {\n error?: ReactivesearchError;\n loading: boolean;\n data: (Omit<ElasticHit, \"_source\"> & ElasticDocument)[];\n loadMore: () => void;\n customData: unknown;\n promotedData: unknown;\n aggregationData: unknown;\n rawData?: {\n _shards: {\n failed: number;\n skipped: number;\n successful: number;\n total: number;\n };\n took: number;\n status: number;\n timed_out: boolean;\n hits: ElasticHit[];\n };\n resultStats: {\n time: number;\n hidden: number;\n promoted: number;\n currentPage: number;\n numberOfPages: number;\n numberOfResults?: number;\n displayedResults: number;\n };\n streamData: unknown;\n triggerAnalytics: unknown;\n triggerClickAnalytics: unknown;\n}\n\n// state for the \"page\" component returned by StateProvider when given the keys: [\"isLoading\", \"hits\", \"resultStats\", \"error\"]\nexport interface ReactivesearchSearchStatePage {\n isLoading: boolean;\n hits: {\n hidden: number;\n time: number;\n total: number;\n hits: ElasticHit[];\n };\n resultStats: {\n hidden: number;\n numberOfResults?: number;\n promoted: number;\n time: number;\n };\n error?: ReactivesearchError;\n}\n\nexport interface ReactivesearchError {\n status: number;\n statusText: string;\n}\n"]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import Debug from "debug";
|
|
1
2
|
import * as Sentry from "@sentry/react";
|
|
3
|
+
export declare const debuggers: Record<string, Debug.Debugger>;
|
|
2
4
|
export declare const debug: {
|
|
3
5
|
namespace: string;
|
|
4
6
|
log: (namespace: string, formatter?: string | undefined, ...args: Array<any>) => void;
|
|
5
7
|
breadcrumb: (breadcrumb: Partial<Sentry.Breadcrumb> & {
|
|
6
8
|
message: string;
|
|
7
|
-
category: "search" | "sort" | "pagination" | "filter" | "curation";
|
|
9
|
+
category: "result" | "search" | "sort" | "pagination" | "filter" | "curation";
|
|
8
10
|
}) => void;
|
|
9
11
|
hook: (namespace: string, message: string, value: unknown) => void;
|
|
10
12
|
};
|
|
@@ -22,14 +22,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.debug = void 0;
|
|
25
|
+
exports.debug = exports.debuggers = void 0;
|
|
26
26
|
const debug_1 = __importDefault(require("debug"));
|
|
27
27
|
const Sentry = __importStar(require("@sentry/react"));
|
|
28
28
|
const hooks_1 = require("../hooks");
|
|
29
|
+
exports.debuggers = {};
|
|
29
30
|
exports.debug = {
|
|
30
31
|
namespace: "reactify-search",
|
|
31
32
|
log: (namespace, formatter, ...args) => {
|
|
32
|
-
|
|
33
|
+
if (!exports.debuggers[namespace]) {
|
|
34
|
+
exports.debuggers[namespace] = (0, debug_1.default)(`${exports.debug.namespace}:${namespace}`);
|
|
35
|
+
}
|
|
36
|
+
exports.debuggers[namespace](formatter, ...args);
|
|
33
37
|
},
|
|
34
38
|
breadcrumb: (breadcrumb) => {
|
|
35
39
|
Sentry.addBreadcrumb(Object.assign(Object.assign({ level: "debug", type: "query" }, breadcrumb), { category: `${exports.debug.namespace}:${breadcrumb.category}` }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/utility/debug.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,sDAAwC;AAExC,oCAAuC;AAE1B,QAAA,KAAK,GAAG;IACnB,SAAS,EAAE,iBAAiB;IAC5B,GAAG,EAAE,CAAC,SAAiB,EAAE,SAAkB,EAAE,GAAG,IAAgB,EAAE,EAAE;QAClE,IAAA,eAAK,EAAC,GAAG,aAAK,CAAC,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/utility/debug.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,sDAAwC;AAExC,oCAAuC;AAE1B,QAAA,SAAS,GAAmC,EAAE,CAAC;AAE/C,QAAA,KAAK,GAAG;IACnB,SAAS,EAAE,iBAAiB;IAC5B,GAAG,EAAE,CAAC,SAAiB,EAAE,SAAkB,EAAE,GAAG,IAAgB,EAAE,EAAE;QAClE,IAAI,CAAC,iBAAS,CAAC,SAAS,CAAC,EAAE;YACzB,iBAAS,CAAC,SAAS,CAAC,GAAG,IAAA,eAAK,EAAC,GAAG,aAAK,CAAC,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC;SACjE;QAED,iBAAS,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3C,CAAC;IACD,UAAU,EAAE,CACV,UASC,EACD,EAAE;QACF,MAAM,CAAC,aAAa,+BAClB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,OAAO,IACV,UAAU,KACb,QAAQ,EAAE,GAAG,aAAK,CAAC,SAAS,IAAI,UAAU,CAAC,QAAQ,EAAE,IACrD,CAAC;IACL,CAAC;IACD,IAAI,EAAE,mBAAW;CAClB,CAAC","sourcesContent":["import Debug from \"debug\";\nimport * as Sentry from \"@sentry/react\";\n\nimport { useDebugger } from \"../hooks\";\n\nexport const debuggers: Record<string, Debug.Debugger> = {};\n\nexport const debug = {\n namespace: \"reactify-search\",\n log: (namespace: string, formatter?: string, ...args: Array<any>) => {\n if (!debuggers[namespace]) {\n debuggers[namespace] = Debug(`${debug.namespace}:${namespace}`);\n }\n\n debuggers[namespace](formatter, ...args);\n },\n breadcrumb: (\n breadcrumb: Partial<Sentry.Breadcrumb> & {\n message: string;\n category:\n | \"result\"\n | \"search\"\n | \"sort\"\n | \"pagination\"\n | \"filter\"\n | \"curation\";\n }\n ) => {\n Sentry.addBreadcrumb({\n level: \"debug\",\n type: \"query\",\n ...breadcrumb,\n category: `${debug.namespace}:${breadcrumb.category}`,\n });\n },\n hook: useDebugger,\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usereactify/search",
|
|
3
3
|
"description": "React UI library for Reactify Search",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"types": "dist/src/index.d.ts",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"watch": "tsc --watch",
|
|
15
|
-
"release": "standard-version --
|
|
16
|
-
"release:beta": "standard-version --prerelease beta",
|
|
15
|
+
"release": "standard-version --tag-prefix release-v",
|
|
16
|
+
"release:beta": "standard-version --tag-prefix beta-v --prerelease beta",
|
|
17
17
|
"prebuild": "rimraf dist",
|
|
18
18
|
"build": "tsc",
|
|
19
19
|
"prettier": "prettier --write .",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { FilterStackProps } from "../../components";
|
|
3
|
-
export declare type ExampleFilterStackProps = React.ComponentProps<NonNullable<FilterStackProps["renderFilters"]>>;
|
|
4
|
-
export declare const ExampleFilterStack: React.FC<ExampleFilterStackProps>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleFilterStack.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleFilterStack.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAA4D;AAMrD,MAAM,kBAAkB,GAAsC,CACnE,KAAK,EACL,EAAE;IACF,OAAO,CACL,8DACG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC7B,8BAAC,mBAAM,kBAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,IAAM,KAAK,EAAI,CACtD,CAAC,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,kBAAkB,sBAU7B","sourcesContent":["import React from \"react\";\n\nimport { Filter, FilterStackProps } from \"../../components\";\n\nexport type ExampleFilterStackProps = React.ComponentProps<\n NonNullable<FilterStackProps[\"renderFilters\"]>\n>;\n\nexport const ExampleFilterStack: React.FC<ExampleFilterStackProps> = (\n props\n) => {\n return (\n <>\n {props.filters.map((filter) => (\n <Filter key={filter.id} filter={filter} {...props} />\n ))}\n </>\n );\n};\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
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.ExampleSortby = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const ExampleSortby = (props) => {
|
|
9
|
-
var _a;
|
|
10
|
-
return (react_1.default.createElement("select", { value: (_a = props.sortOption) === null || _a === void 0 ? void 0 : _a.handle, onChange: (event) => props.setSortOption(event.target.value) }, props.sortOptions.map((sortOption) => (react_1.default.createElement("option", { key: sortOption.handle, value: sortOption.handle }, sortOption.name)))));
|
|
11
|
-
};
|
|
12
|
-
exports.ExampleSortby = ExampleSortby;
|
|
13
|
-
//# sourceMappingURL=ExampleSortby.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleSortby.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleSortby.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAQnB,MAAM,aAAa,GAAiC,CAAC,KAAK,EAAE,EAAE;;IACnE,OAAO,CACL,0CACE,KAAK,EAAE,MAAA,KAAK,CAAC,UAAU,0CAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAE3D,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CACrC,0CAAQ,GAAG,EAAE,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,IACrD,UAAU,CAAC,IAAI,CACT,CACV,CAAC,CACK,CACV,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB","sourcesContent":["import React from \"react\";\n\nimport { SortbyProps } from \"../../components\";\n\nexport type ExampleSortbyProps = React.ComponentProps<\n NonNullable<SortbyProps[\"renderSortOptions\"]>\n>;\n\nexport const ExampleSortby: React.FC<ExampleSortbyProps> = (props) => {\n return (\n <select\n value={props.sortOption?.handle}\n onChange={(event) => props.setSortOption(event.target.value)}\n >\n {props.sortOptions.map((sortOption) => (\n <option key={sortOption.handle} value={sortOption.handle}>\n {sortOption.name}\n </option>\n ))}\n </select>\n );\n};\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useFilters } from "../../hooks";
|
|
3
|
-
export declare type FilterStackProps = {
|
|
4
|
-
/** Render method called once for all filters */
|
|
5
|
-
renderFilters?: React.FC<ReturnType<typeof useFilters>>;
|
|
6
|
-
};
|
|
7
|
-
export declare const FilterStack: React.FC<FilterStackProps>;
|
|
@@ -1,17 +0,0 @@
|
|
|
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.FilterStack = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const hooks_1 = require("../../hooks");
|
|
9
|
-
const components_1 = require("../../components");
|
|
10
|
-
const FilterStack = (props) => {
|
|
11
|
-
var _a;
|
|
12
|
-
const filtersHook = (0, hooks_1.useFilters)();
|
|
13
|
-
const RenderFiltersComponent = (_a = props.renderFilters) !== null && _a !== void 0 ? _a : components_1.ExampleFilterStack;
|
|
14
|
-
return (react_1.default.createElement(RenderFiltersComponent, Object.assign({}, filtersHook)));
|
|
15
|
-
};
|
|
16
|
-
exports.FilterStack = FilterStack;
|
|
17
|
-
//# sourceMappingURL=FilterStack.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FilterStack.js","sourceRoot":"","sources":["../../../../src/components/Filter/FilterStack.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAAyC;AACzC,iDAAsD;AAO/C,MAAM,WAAW,GAA+B,CAAC,KAAK,EAAE,EAAE;;IAC/D,MAAM,WAAW,GAAG,IAAA,kBAAU,GAAE,CAAC;IAEjC,MAAM,sBAAsB,GAAG,MAAA,KAAK,CAAC,aAAa,mCAAI,+BAAkB,CAAC;IAEzE,OAAO,CACL,8BAAC,sBAAsB,oBACjB,WAAW,EACf,CACH,CAAA;AACH,CAAC,CAAC;AAVW,QAAA,WAAW,eAUtB","sourcesContent":["import React from \"react\";\n\nimport { useFilters } from \"../../hooks\";\nimport { ExampleFilterStack } from \"../../components\";\n\nexport type FilterStackProps = {\n /** Render method called once for all filters */\n renderFilters?: React.FC<ReturnType<typeof useFilters>>\n};\n\nexport const FilterStack: React.FC<FilterStackProps> = (props) => {\n const filtersHook = useFilters();\n\n const RenderFiltersComponent = props.renderFilters ?? ExampleFilterStack;\n\n return (\n <RenderFiltersComponent\n {...filtersHook}\n />\n )\n};\n"]}
|