@usereactify/search 4.4.1 → 5.0.0-beta.10
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 +93 -0
- package/dist/package.json +11 -8
- package/dist/src/components/Example/ExampleFilterList.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterList.js +21 -0
- package/dist/src/components/Example/ExampleFilterList.js.map +1 -0
- package/dist/src/components/Example/ExampleFilterRange.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterRange.js +22 -0
- package/dist/src/components/Example/ExampleFilterRange.js.map +1 -0
- package/dist/src/components/Example/ExampleFilterSlider.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterSlider.js +21 -0
- package/dist/src/components/Example/ExampleFilterSlider.js.map +1 -0
- package/dist/src/components/Example/ExampleFilterStack.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterStack.js +13 -0
- package/dist/src/components/Example/ExampleFilterStack.js.map +1 -0
- package/dist/src/components/Example/ExampleResultCardCallout.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultCardCallout.js +22 -0
- package/dist/src/components/Example/ExampleResultCardCallout.js.map +1 -0
- package/dist/src/components/Example/ExampleResultCardProduct.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultCardProduct.js +19 -0
- package/dist/src/components/Example/ExampleResultCardProduct.js.map +1 -0
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.js +12 -0
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.js.map +1 -0
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.js +14 -0
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.js.map +1 -0
- package/dist/src/components/Example/ExampleResultPaginationNumbered.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationNumbered.js +27 -0
- package/dist/src/components/Example/ExampleResultPaginationNumbered.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/index.d.ts +10 -0
- package/dist/src/components/Example/index.js +23 -0
- package/dist/src/components/Example/index.js.map +1 -0
- package/dist/src/components/Filter/Filter.d.ts +20 -0
- package/dist/src/components/Filter/Filter.js +90 -0
- package/dist/src/components/Filter/Filter.js.map +1 -0
- package/dist/src/components/Filter/FilterStack.d.ts +7 -0
- package/dist/src/components/Filter/FilterStack.js +17 -0
- package/dist/src/components/Filter/FilterStack.js.map +1 -0
- package/dist/src/{filter → components/Filter}/index.d.ts +0 -1
- package/dist/src/{filter → components/Filter}/index.js +1 -1
- package/dist/src/components/Filter/index.js.map +1 -0
- package/dist/src/components/ReactifySearchBase/ReactifySearchBase.d.ts +42 -0
- package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js +128 -0
- package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js.map +1 -0
- package/dist/src/components/ReactifySearchBase/index.d.ts +1 -0
- package/dist/src/components/ReactifySearchBase/index.js +14 -0
- package/dist/src/components/ReactifySearchBase/index.js.map +1 -0
- package/dist/src/components/Result/ResultCardCallout.d.ts +12 -0
- package/dist/src/{result → components/Result}/ResultCardCallout.js +14 -22
- package/dist/src/components/Result/ResultCardCallout.js.map +1 -0
- package/dist/src/components/Result/ResultCardProduct.d.ts +13 -0
- package/dist/src/components/Result/ResultCardProduct.js +50 -0
- package/dist/src/components/Result/ResultCardProduct.js.map +1 -0
- package/dist/src/components/Result/ResultPaginationLoadMore.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationLoadMore.js +17 -0
- package/dist/src/components/Result/ResultPaginationLoadMore.js.map +1 -0
- package/dist/src/components/Result/ResultPaginationNextPrev.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationNextPrev.js +17 -0
- package/dist/src/components/Result/ResultPaginationNextPrev.js.map +1 -0
- package/dist/src/components/Result/ResultPaginationNumbered.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationNumbered.js +20 -0
- package/dist/src/components/Result/ResultPaginationNumbered.js.map +1 -0
- package/dist/src/components/Result/ResultStack.d.ts +40 -0
- package/dist/src/components/Result/ResultStack.js +108 -0
- package/dist/src/components/Result/ResultStack.js.map +1 -0
- package/dist/src/components/Result/ResultStateProvider.d.ts +6 -0
- package/dist/src/{result → components/Result}/ResultStateProvider.js +5 -1
- package/dist/src/components/Result/ResultStateProvider.js.map +1 -0
- package/dist/src/components/Result/index.d.ts +7 -0
- package/dist/src/{result → components/Result}/index.js +6 -4
- package/dist/src/components/Result/index.js.map +1 -0
- package/dist/src/components/Search/SearchInput.d.ts +8 -0
- package/dist/src/{search → components/Search}/SearchInput.js +3 -2
- package/dist/src/components/Search/SearchInput.js.map +1 -0
- package/dist/src/{search → components/Search}/index.d.ts +0 -0
- package/dist/src/{search → components/Search}/index.js +1 -0
- package/dist/src/components/Search/index.js.map +1 -0
- package/dist/src/{sensor → components/Sensor}/SensorCollection.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorCollection.js +9 -5
- package/dist/src/components/Sensor/SensorCollection.js.map +1 -0
- package/dist/src/{sensor → components/Sensor}/SensorInventoryAvailable.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorInventoryAvailable.js +3 -2
- package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -0
- package/dist/src/{sensor → components/Sensor}/SensorPublished.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorPublished.js +1 -0
- package/dist/src/components/Sensor/SensorPublished.js.map +1 -0
- package/dist/src/{sensor → components/Sensor}/SensorSearch.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorSearch.js +4 -3
- package/dist/src/components/Sensor/SensorSearch.js.map +1 -0
- package/dist/src/{sensor → components/Sensor}/SensorSort.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorSort.js +6 -24
- package/dist/src/components/Sensor/SensorSort.js.map +1 -0
- package/dist/src/{sensor → components/Sensor}/SensorSortScore.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorSortScore.js +1 -0
- package/dist/src/components/Sensor/SensorSortScore.js.map +1 -0
- package/dist/src/components/Sensor/SensorStack.d.ts +3 -0
- package/dist/src/{sensor → components/Sensor}/SensorStack.js +4 -3
- package/dist/src/components/Sensor/SensorStack.js.map +1 -0
- package/dist/src/{sensor → components/Sensor}/index.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/index.js +1 -0
- package/dist/src/components/Sensor/index.js.map +1 -0
- 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/index.js +14 -0
- package/dist/src/components/Sortby/index.js.map +1 -0
- package/dist/src/{utility → components/Utility}/UtilityAuthenticatedReactiveBase.d.ts +0 -0
- package/dist/src/{utility → components/Utility}/UtilityAuthenticatedReactiveBase.js +5 -4
- package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.js.map +1 -0
- package/dist/src/components/Utility/index.d.ts +1 -0
- package/dist/src/components/Utility/index.js +14 -0
- package/dist/src/components/Utility/index.js.map +1 -0
- package/dist/src/components/index.d.ts +8 -0
- package/dist/src/components/index.js +21 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/hooks/index.d.ts +6 -5
- package/dist/src/hooks/index.js +7 -5
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/reactivesearch/index.d.ts +4 -1
- package/dist/src/hooks/reactivesearch/index.js +5 -1
- package/dist/src/hooks/reactivesearch/index.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.d.ts +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +8 -7
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +6 -8
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +30 -31
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +9 -4
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +10 -94
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +70 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +22 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.d.ts +67 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +106 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +68 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +22 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +9 -8
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js.map +1 -0
- package/dist/src/hooks/reactivesearch/{useReactiveResultListProps.d.ts → useReactiveResultStackProps.d.ts} +2 -4
- package/dist/src/hooks/reactivesearch/{useReactiveResultListProps.js → useReactiveResultStackProps.js} +9 -9
- package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.js.map +1 -0
- package/dist/src/hooks/useAnalytics.js +7 -4
- package/dist/src/hooks/useAnalytics.js.map +1 -0
- package/dist/src/hooks/useConfig.d.ts +4 -1
- package/dist/src/hooks/useConfig.js +79 -2
- package/dist/src/hooks/useConfig.js.map +1 -0
- package/dist/src/hooks/useCuration.d.ts +2 -1
- package/dist/src/hooks/useCuration.js +62 -2
- package/dist/src/hooks/useCuration.js.map +1 -0
- package/dist/src/hooks/useDebugger.d.ts +1 -0
- package/dist/src/hooks/useDebugger.js +15 -0
- package/dist/src/hooks/useDebugger.js.map +1 -0
- package/dist/src/hooks/useFilterCollapsedState.js +1 -0
- package/dist/src/hooks/useFilterCollapsedState.js.map +1 -0
- package/dist/src/hooks/useFilterListProps.d.ts +4 -14
- package/dist/src/hooks/useFilterListProps.js +1 -0
- package/dist/src/hooks/useFilterListProps.js.map +1 -0
- package/dist/src/hooks/useFilterStack.d.ts +4 -1
- package/dist/src/hooks/useFilterStack.js +48 -2
- package/dist/src/hooks/useFilterStack.js.map +1 -0
- package/dist/src/hooks/useFilters.d.ts +4 -1
- package/dist/src/hooks/useFilters.js +16 -6
- package/dist/src/hooks/useFilters.js.map +1 -0
- package/dist/src/hooks/usePagination.d.ts +14 -0
- package/dist/src/hooks/{usePages.js → usePagination.js} +41 -29
- package/dist/src/hooks/usePagination.js.map +1 -0
- package/dist/src/hooks/usePaginationLoadMore.d.ts +15 -0
- package/dist/src/hooks/usePaginationLoadMore.js +38 -0
- package/dist/src/hooks/usePaginationLoadMore.js.map +1 -0
- package/dist/src/hooks/useProductPrice.d.ts +3 -5
- package/dist/src/hooks/useProductPrice.js +43 -40
- package/dist/src/hooks/useProductPrice.js.map +1 -0
- package/dist/src/hooks/useReactifySearchContext.d.ts +78 -0
- package/dist/src/hooks/useReactifySearchContext.js +11 -0
- package/dist/src/hooks/useReactifySearchContext.js.map +1 -0
- package/dist/src/hooks/useSearch.d.ts +5 -5
- package/dist/src/hooks/useSearch.js +42 -8
- package/dist/src/hooks/useSearch.js.map +1 -0
- package/dist/src/hooks/useSortby.d.ts +6 -0
- package/dist/src/hooks/useSortby.js +58 -0
- package/dist/src/hooks/useSortby.js.map +1 -0
- package/dist/src/index.d.ts +2 -8
- package/dist/src/index.js +48 -11
- package/dist/src/index.js.map +1 -0
- package/dist/src/types/config.d.ts +1 -0
- package/dist/src/types/config.js +1 -0
- package/dist/src/types/config.js.map +1 -0
- package/dist/src/types/elastic.js +1 -0
- package/dist/src/types/elastic.js.map +1 -0
- package/dist/src/types/firestore.js +1 -0
- package/dist/src/types/firestore.js.map +1 -0
- package/dist/src/types/graphql.js +1 -0
- package/dist/src/types/graphql.js.map +1 -0
- package/dist/src/types/index.d.ts +3 -0
- package/dist/src/types/index.js +16 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/reactivesearch.js +1 -0
- package/dist/src/types/reactivesearch.js.map +1 -0
- package/dist/src/types/shopify.js +1 -0
- package/dist/src/types/shopify.js.map +1 -0
- package/dist/src/utility/debug.d.ts +10 -0
- package/dist/src/utility/debug.js +39 -0
- package/dist/src/utility/debug.js.map +1 -0
- package/dist/src/utility/index.d.ts +1 -0
- package/dist/src/utility/index.js +14 -0
- package/dist/src/utility/index.js.map +1 -0
- package/package.json +11 -8
- package/dist/src/filter/Filter.d.ts +0 -12
- package/dist/src/filter/Filter.js +0 -71
- package/dist/src/filter/FilterList.d.ts +0 -4
- package/dist/src/filter/FilterList.js +0 -15
- package/dist/src/filter/FilterStack.d.ts +0 -11
- package/dist/src/filter/FilterStack.js +0 -25
- package/dist/src/hooks/useCollection.d.ts +0 -1
- package/dist/src/hooks/useCollection.js +0 -6
- package/dist/src/hooks/useLiveConfig.d.ts +0 -4
- package/dist/src/hooks/useLiveConfig.js +0 -74
- package/dist/src/hooks/usePages.d.ts +0 -10
- package/dist/src/hooks/useSort.d.ts +0 -5
- package/dist/src/hooks/useSort.js +0 -24
- package/dist/src/provider.d.ts +0 -78
- package/dist/src/provider.js +0 -287
- package/dist/src/result/ResultCard.d.ts +0 -14
- package/dist/src/result/ResultCard.js +0 -66
- package/dist/src/result/ResultCardCallout.d.ts +0 -13
- package/dist/src/result/ResultList.d.ts +0 -34
- package/dist/src/result/ResultList.js +0 -93
- package/dist/src/result/ResultLoadMoreButton.d.ts +0 -10
- package/dist/src/result/ResultLoadMoreButton.js +0 -61
- package/dist/src/result/ResultPagination.d.ts +0 -10
- package/dist/src/result/ResultPagination.js +0 -60
- package/dist/src/result/ResultPaginationNextPrev.d.ts +0 -8
- package/dist/src/result/ResultPaginationNextPrev.js +0 -30
- package/dist/src/result/ResultStateProvider.d.ts +0 -7
- package/dist/src/result/index.d.ts +0 -6
- package/dist/src/search/SearchInput.d.ts +0 -9
- package/dist/src/sensor/SensorStack.d.ts +0 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./config"), exports);
|
|
14
|
+
__exportStar(require("./elastic"), exports);
|
|
15
|
+
__exportStar(require("./reactivesearch"), exports);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,mDAAiC","sourcesContent":["export * from \"./config\";\nexport * from \"./elastic\";\nexport * from \"./reactivesearch\";"]}
|
|
@@ -0,0 +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 ReactivesearchFilterProps {\n loading: boolean;\n error: Error | null;\n handleChange: (value: 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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shopify.js","sourceRoot":"","sources":["../../../src/types/shopify.ts"],"names":[],"mappings":";;;AAoCA,SAAgB,SAAS,CACvB,UAA6B;IAE7B,OAAO,SAAS,KAAK,UAAU,CAAC,UAAU,CAAC;AAC7C,CAAC;AAJD,8BAIC;AAED,SAAgB,gBAAgB,CAC9B,UAA6B;IAE7B,OAAO,gBAAgB,KAAK,UAAU,CAAC,UAAU,CAAC;AACpD,CAAC;AAJD,4CAIC;AAED,SAAgB,kBAAkB,CAChC,UAA6B;IAE7B,OAAO,yBAAyB,KAAK,UAAU,CAAC,UAAU,CAAC;AAC7D,CAAC;AAJD,gDAIC;AAED,SAAgB,OAAO,CACrB,UAA6B;IAE7B,OAAO,OAAO,KAAK,UAAU,CAAC,UAAU,CAAC;AAC3C,CAAC;AAJD,0BAIC;AAED,SAAgB,OAAO,CACrB,UAA6B;IAE7B,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC,QAAQ,CACjE,UAAU,CAAC,UAAU,CACtB,CAAC;AACJ,CAAC;AAND,0BAMC;AAED,SAAgB,WAAW,CACzB,UAA6B;IAE7B,OAAO,WAAW,KAAK,UAAU,CAAC,UAAU,CAAC;AAC/C,CAAC;AAJD,kCAIC","sourcesContent":["import { ProductQuery, BulkQueryProductsQuery } from \"./graphql\";\n\n// these are the types from the single \"product\" query, and is what we store in firestore\nexport type ShopifyProduct = NonNullable<ProductQuery[\"product\"]>;\nexport type ShopifyVariant = ShopifyProduct[\"variants\"][\"edges\"][0][\"node\"];\n\n// these are the types from the bulk \"product\" query, which should match the above, but we\n// always type on the single query in firestore\nexport type BulkShopifyProduct =\n BulkQueryProductsQuery[\"products\"][\"edges\"][0][\"node\"];\nexport type BulkShopifyVariant =\n BulkShopifyProduct[\"variants\"][\"edges\"][0][\"node\"];\n\n// these are types for the individual \"export lines\" which shopify exports in the bulk export file\nexport type ShopifyExportProduct = Omit<\n BulkShopifyProduct,\n \"variants\" | \"images\" | \"media\" | \"metafields\"\n>;\nexport type ShopifyExportProductVariant = Omit<\n BulkShopifyVariant,\n \"presentmentPrices\"\n>;\nexport type ShopifyExportPresentmentPrice =\n BulkShopifyVariant[\"presentmentPrices\"][\"edges\"][0][\"node\"];\nexport type ShopifyExportImage =\n BulkShopifyProduct[\"images\"][\"edges\"][0][\"node\"];\nexport type ShopifyExportMedia =\n BulkShopifyProduct[\"media\"][\"edges\"][0][\"node\"];\nexport type ShopifyExportMetafield =\n BulkShopifyProduct[\"metafields\"][\"edges\"][0][\"node\"];\n\nexport interface ShopifyExportLine {\n __parentId?: string;\n __typename: string;\n}\n\nexport function isProduct(\n exportLine: ShopifyExportLine\n): exportLine is ShopifyExportProduct {\n return \"Product\" === exportLine.__typename;\n}\n\nexport function isProductVariant(\n exportLine: ShopifyExportLine\n): exportLine is ShopifyExportProductVariant {\n return \"ProductVariant\" === exportLine.__typename;\n}\n\nexport function isPresentmentPrice(\n exportLine: ShopifyExportLine\n): exportLine is ShopifyExportPresentmentPrice {\n return \"ProductVariantPricePair\" === exportLine.__typename;\n}\n\nexport function isImage(\n exportLine: ShopifyExportLine\n): exportLine is ShopifyExportImage {\n return \"Image\" === exportLine.__typename;\n}\n\nexport function isMedia(\n exportLine: ShopifyExportLine\n): exportLine is ShopifyExportMedia {\n return [\"Video\", \"Model3d\", \"MediaImage\", \"ExternalVideo\"].includes(\n exportLine.__typename\n );\n}\n\nexport function isMetafield(\n exportLine: ShopifyExportLine\n): exportLine is ShopifyExportMetafield {\n return \"Metafield\" === exportLine.__typename;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Sentry from "@sentry/react";
|
|
2
|
+
export declare const debug: {
|
|
3
|
+
namespace: string;
|
|
4
|
+
log: (namespace: string, formatter?: string | undefined, ...args: Array<any>) => void;
|
|
5
|
+
breadcrumb: (breadcrumb: Partial<Sentry.Breadcrumb> & {
|
|
6
|
+
message: string;
|
|
7
|
+
category: "search" | "sort" | "pagination" | "filter" | "curation";
|
|
8
|
+
}) => void;
|
|
9
|
+
hook: (namespace: string, message: string, value: unknown) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.debug = void 0;
|
|
26
|
+
const debug_1 = __importDefault(require("debug"));
|
|
27
|
+
const Sentry = __importStar(require("@sentry/react"));
|
|
28
|
+
const hooks_1 = require("../hooks");
|
|
29
|
+
exports.debug = {
|
|
30
|
+
namespace: "reactify-search",
|
|
31
|
+
log: (namespace, formatter, ...args) => {
|
|
32
|
+
(0, debug_1.default)(`${exports.debug.namespace}:${namespace}`)(formatter, ...args);
|
|
33
|
+
},
|
|
34
|
+
breadcrumb: (breadcrumb) => {
|
|
35
|
+
Sentry.addBreadcrumb(Object.assign(Object.assign({ level: "debug", type: "query" }, breadcrumb), { category: `${exports.debug.namespace}:${breadcrumb.category}` }));
|
|
36
|
+
},
|
|
37
|
+
hook: hooks_1.useDebugger,
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +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;IAC/D,CAAC;IACD,UAAU,EAAE,CACV,UAGC,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 debug = {\n namespace: \"reactify-search\",\n log: (namespace: string, formatter?: string, ...args: Array<any>) => {\n Debug(`${debug.namespace}:${namespace}`)(formatter, ...args);\n },\n breadcrumb: (\n breadcrumb: Partial<Sentry.Breadcrumb> & {\n message: string;\n category: \"search\" | \"sort\" | \"pagination\" | \"filter\" | \"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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./debug";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./debug"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utility/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB","sourcesContent":["export * from \"./debug\";"]}
|
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": "
|
|
4
|
+
"version": "5.0.0-beta.10",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"types": "dist/src/index.d.ts",
|
|
@@ -12,14 +12,15 @@
|
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"watch": "tsc --watch",
|
|
15
|
-
"release": "standard-version",
|
|
16
|
-
"release:
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"build": "rimraf dist && tsc",
|
|
15
|
+
"release": "standard-version --prerelease rc",
|
|
16
|
+
"release:beta": "standard-version --prerelease beta",
|
|
17
|
+
"prebuild": "rimraf dist",
|
|
18
|
+
"build": "tsc",
|
|
20
19
|
"prettier": "prettier --write .",
|
|
21
20
|
"storybook": "start-storybook -p 6006",
|
|
22
|
-
"
|
|
21
|
+
"sentry:release:new": "sentry-cli releases new $npm_package_version",
|
|
22
|
+
"sentry:release:upload": "sentry-cli releases files $npm_package_version upload-sourcemaps dist",
|
|
23
|
+
"sentry:release:finalize": "sentry-cli releases finalize $npm_package_version"
|
|
23
24
|
},
|
|
24
25
|
"husky": {
|
|
25
26
|
"hooks": {
|
|
@@ -33,7 +34,8 @@
|
|
|
33
34
|
]
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@sentry/react": "7.
|
|
37
|
+
"@sentry/react": "7.7.0",
|
|
38
|
+
"@sentry/tracing": "7.7.0",
|
|
37
39
|
"ahooks": "2.10.11",
|
|
38
40
|
"axios": "0.26.1",
|
|
39
41
|
"currency.js": "2.0.4",
|
|
@@ -48,6 +50,7 @@
|
|
|
48
50
|
"@appbaseio/reactivesearch": "^3.14.0",
|
|
49
51
|
"@commitlint/cli": "13.2.0",
|
|
50
52
|
"@commitlint/config-conventional": "13.2.0",
|
|
53
|
+
"@sentry/cli": "2.5.0",
|
|
51
54
|
"@storybook/addon-actions": "6.3.10",
|
|
52
55
|
"@storybook/addon-essentials": "6.3.10",
|
|
53
56
|
"@storybook/addon-links": "6.3.10",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ConfigFilterOption } from "../types/config";
|
|
3
|
-
import { useFilterListProps, useFilterCollapsedState } from "../hooks";
|
|
4
|
-
declare type Props = {
|
|
5
|
-
noWrapper?: boolean;
|
|
6
|
-
filter: ConfigFilterOption;
|
|
7
|
-
renderFilterList?: (props: Omit<Props, "renderFilterList"> & {
|
|
8
|
-
filterListProps: ReturnType<typeof useFilterListProps>;
|
|
9
|
-
}) => JSX.Element;
|
|
10
|
-
} & Partial<ReturnType<typeof useFilterCollapsedState>>;
|
|
11
|
-
export declare const Filter: React.FC<Props>;
|
|
12
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Filter = void 0;
|
|
18
|
-
const react_1 = __importDefault(require("react"));
|
|
19
|
-
const MultiList_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/list/MultiList"));
|
|
20
|
-
const SingleList_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/list/SingleList"));
|
|
21
|
-
const hooks_1 = require("../hooks");
|
|
22
|
-
const FilterList_1 = require("./FilterList");
|
|
23
|
-
const hooks_2 = require("../hooks");
|
|
24
|
-
const Filter = (props) => {
|
|
25
|
-
const { filter } = props;
|
|
26
|
-
const reactiveFilterListProps = (0, hooks_2.useReactiveFilterListProps)(filter);
|
|
27
|
-
if ("single" === filter.displayType) {
|
|
28
|
-
return (react_1.default.createElement(SingleList_1.default, Object.assign({}, reactiveFilterListProps, { render: (reactivesearchFilterProps) => (react_1.default.createElement(FilterListInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps }))) })));
|
|
29
|
-
}
|
|
30
|
-
if ("multi" === filter.displayType) {
|
|
31
|
-
return (react_1.default.createElement(MultiList_1.default, Object.assign({ showCheckbox: false }, reactiveFilterListProps, { render: (reactivesearchFilterProps) => (react_1.default.createElement(FilterListInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps }))) })));
|
|
32
|
-
}
|
|
33
|
-
console.log(`filter with display type "${filter.displayType}" not yet supported`);
|
|
34
|
-
return null;
|
|
35
|
-
};
|
|
36
|
-
exports.Filter = Filter;
|
|
37
|
-
// inner component exists only so we can use memos in reactivesearch render functions
|
|
38
|
-
const FilterListInner = (props) => {
|
|
39
|
-
const { filter, noWrapper, renderFilterList, reactivesearchFilterProps } = props, otherProps = __rest(props, ["filter", "noWrapper", "renderFilterList", "reactivesearchFilterProps"]);
|
|
40
|
-
const { track } = (0, hooks_1.useAnalytics)();
|
|
41
|
-
const _a = (0, hooks_2.useFilterListProps)(filter, reactivesearchFilterProps), { handleChange } = _a, filterListProps = __rest(_a, ["handleChange"]);
|
|
42
|
-
const handleFilterChange = react_1.default.useCallback((value) => {
|
|
43
|
-
handleChange(value);
|
|
44
|
-
track({
|
|
45
|
-
eventName: "filterChange",
|
|
46
|
-
payload: {
|
|
47
|
-
name: filter.name,
|
|
48
|
-
value: value,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}, [filterListProps]);
|
|
52
|
-
const updatedFilterListProps = Object.assign(Object.assign({}, filterListProps), { handleChange: handleFilterChange });
|
|
53
|
-
// hide entire filter when no options available
|
|
54
|
-
if (0 === filterListProps.options.length)
|
|
55
|
-
return null;
|
|
56
|
-
if (renderFilterList) {
|
|
57
|
-
return renderFilterList(Object.assign({ filterListProps: updatedFilterListProps, filter }, otherProps));
|
|
58
|
-
}
|
|
59
|
-
if (noWrapper) {
|
|
60
|
-
return react_1.default.createElement(FilterList_1.FilterList, Object.assign({}, updatedFilterListProps));
|
|
61
|
-
}
|
|
62
|
-
return (react_1.default.createElement(FilterWrapper, Object.assign({}, props),
|
|
63
|
-
react_1.default.createElement(FilterList_1.FilterList, Object.assign({}, updatedFilterListProps))));
|
|
64
|
-
};
|
|
65
|
-
// wrap the filter with a clickable title
|
|
66
|
-
const FilterWrapper = ({ filter, children, collapsed, shouldRender, collapsedToggle }) => {
|
|
67
|
-
return (react_1.default.createElement("div", null,
|
|
68
|
-
react_1.default.createElement("h1", { onClick: () => collapsedToggle && collapsedToggle() }, filter.name),
|
|
69
|
-
("undefined" === typeof shouldRender || !!shouldRender) && (react_1.default.createElement("div", { style: { display: collapsed ? "none" : "block" } }, children)),
|
|
70
|
-
"undefined" !== typeof collapsed && !!collapsed && (react_1.default.createElement("div", null, "Filter is collapsed."))));
|
|
71
|
-
};
|
|
@@ -1,15 +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.FilterList = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const FilterList = ({ options, handleChange }) => (react_1.default.createElement("ul", null, options.map(({ key, doc_count, checked }) => (react_1.default.createElement("li", { key: key },
|
|
9
|
-
react_1.default.createElement("label", null,
|
|
10
|
-
react_1.default.createElement("input", { value: key, type: "checkbox", checked: checked, onChange: ({ target: { value } }) => handleChange(value) }),
|
|
11
|
-
key,
|
|
12
|
-
" (",
|
|
13
|
-
doc_count,
|
|
14
|
-
")"))))));
|
|
15
|
-
exports.FilterList = FilterList;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ConfigFilterOption } from "../types/config";
|
|
3
|
-
import { useFilterCollapsedState } from "../hooks";
|
|
4
|
-
declare type Props = {
|
|
5
|
-
render?: (filters: ConfigFilterOption[]) => JSX.Element;
|
|
6
|
-
renderFilter?: (props: {
|
|
7
|
-
filter: ConfigFilterOption;
|
|
8
|
-
} & ReturnType<typeof useFilterCollapsedState>) => JSX.Element;
|
|
9
|
-
};
|
|
10
|
-
export declare const FilterStack: React.FC<Props>;
|
|
11
|
-
export {};
|
|
@@ -1,25 +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 Filter_1 = require("./Filter");
|
|
9
|
-
const hooks_1 = require("../hooks");
|
|
10
|
-
const FilterStack = (props) => {
|
|
11
|
-
const { render } = props;
|
|
12
|
-
const filters = (0, hooks_1.useFilters)();
|
|
13
|
-
if (0 === filters.length)
|
|
14
|
-
return null;
|
|
15
|
-
if (render)
|
|
16
|
-
return render(filters);
|
|
17
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, filters.map((filter) => (react_1.default.createElement(FilterWithState, Object.assign({ key: filter.id, filter: filter }, props))))));
|
|
18
|
-
};
|
|
19
|
-
exports.FilterStack = FilterStack;
|
|
20
|
-
const FilterWithState = ({ filter, renderFilter, }) => {
|
|
21
|
-
const collapsedProps = (0, hooks_1.useFilterCollapsedState)(filter);
|
|
22
|
-
if (renderFilter)
|
|
23
|
-
return renderFilter(Object.assign({ filter }, collapsedProps));
|
|
24
|
-
return react_1.default.createElement(Filter_1.Filter, Object.assign({ filter: filter }, collapsedProps));
|
|
25
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useCollection: () => import("../provider").Collection | undefined;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.useLiveConfig = void 0;
|
|
16
|
-
const react_1 = __importDefault(require("react"));
|
|
17
|
-
const debug = require("debug")("reactify-search:useLiveConfig");
|
|
18
|
-
// 5 minute cache expiry
|
|
19
|
-
const CACHE_EXPIRY = 5 * 60 * 1000;
|
|
20
|
-
// synchronously returns cached and non-expired config from session storage
|
|
21
|
-
function getCachedConfig() {
|
|
22
|
-
var _a;
|
|
23
|
-
if (typeof window === "undefined") {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// skip checking cache if url search param "nocache" is set
|
|
27
|
-
const skipCache = new URLSearchParams(window.location.href.split("?")[1]).get("nocache") !==
|
|
28
|
-
null;
|
|
29
|
-
if (skipCache) {
|
|
30
|
-
debug("skipping cache");
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const sessionConfig = JSON.parse((_a = window.sessionStorage.getItem("reactify-search:config")) !== null && _a !== void 0 ? _a : "null");
|
|
34
|
-
if (sessionConfig) {
|
|
35
|
-
const sessionConfigTtl = sessionConfig.expiresAt - Date.now();
|
|
36
|
-
debug(`found ${sessionConfigTtl > 0 ? "cached" : "expired"} config`);
|
|
37
|
-
if (sessionConfigTtl > 0) {
|
|
38
|
-
debug(`config expires in ${(sessionConfigTtl / 1000).toFixed()} seconds`);
|
|
39
|
-
return sessionConfig.config;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const useLiveConfig = (shopifyPermanentDomain, configId) => {
|
|
45
|
-
const [config, setConfig] = react_1.default.useState(getCachedConfig());
|
|
46
|
-
react_1.default.useEffect(() => {
|
|
47
|
-
const cachedConfig = getCachedConfig();
|
|
48
|
-
if (cachedConfig)
|
|
49
|
-
return;
|
|
50
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
-
debug("fetching fresh config");
|
|
52
|
-
const searchParams = new URLSearchParams();
|
|
53
|
-
searchParams.set("shop", shopifyPermanentDomain);
|
|
54
|
-
if (configId) {
|
|
55
|
-
searchParams.set("id", configId);
|
|
56
|
-
}
|
|
57
|
-
const skipCache = new URLSearchParams(window.location.href.split("?")[1]).get("nocache") !== null;
|
|
58
|
-
if (skipCache) {
|
|
59
|
-
searchParams.set("nocache", "true");
|
|
60
|
-
}
|
|
61
|
-
const json = yield fetch(`https://config.search.reactify.app/?${searchParams.toString()}`).then((response) => response.json());
|
|
62
|
-
setConfig(json.body);
|
|
63
|
-
window.sessionStorage.setItem("reactify-search:config", JSON.stringify({
|
|
64
|
-
expiresAt: new Date().getTime() + CACHE_EXPIRY,
|
|
65
|
-
noCache: skipCache,
|
|
66
|
-
config: json.body,
|
|
67
|
-
}));
|
|
68
|
-
}))();
|
|
69
|
-
}, [shopifyPermanentDomain, configId]);
|
|
70
|
-
return {
|
|
71
|
-
config,
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
exports.useLiveConfig = useLiveConfig;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ReactivesearchPaginationProps } from "../types/reactivesearch";
|
|
2
|
-
export declare const usePages: (props: ReactivesearchPaginationProps) => {
|
|
3
|
-
pagesToShow: number[];
|
|
4
|
-
hasNextPage: boolean;
|
|
5
|
-
buildPagePath: (page: number) => string;
|
|
6
|
-
handleNextPage: (event?: any) => void;
|
|
7
|
-
hasPreviousPage: boolean;
|
|
8
|
-
actualCurrentPage: number;
|
|
9
|
-
handlePreviousPage: (event?: any) => void;
|
|
10
|
-
};
|
|
@@ -1,24 +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.useSort = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const provider_1 = require("../provider");
|
|
9
|
-
const hooks_1 = require("../hooks");
|
|
10
|
-
const useSort = () => {
|
|
11
|
-
const { track } = (0, hooks_1.useAnalytics)();
|
|
12
|
-
const { sortOption, sortOptions, setSortOption } = (0, provider_1.useContext)();
|
|
13
|
-
const handleSortChange = react_1.default.useCallback((sortOptionHandle) => {
|
|
14
|
-
setSortOption(sortOptionHandle);
|
|
15
|
-
track({
|
|
16
|
-
eventName: "sortChange",
|
|
17
|
-
payload: {
|
|
18
|
-
type: sortOptionHandle,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
}, [track, setSortOption]);
|
|
22
|
-
return { sortOption, sortOptions, setSortOption: handleSortChange };
|
|
23
|
-
};
|
|
24
|
-
exports.useSort = useSort;
|
package/dist/src/provider.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { Config, ConfigSort, ConfigFilter, ConfigCuration } from "./types/config";
|
|
3
|
-
declare type Context = {
|
|
4
|
-
index: string;
|
|
5
|
-
config: Config;
|
|
6
|
-
shopifyPermanentDomain: string;
|
|
7
|
-
sortOption: ConfigSort | undefined;
|
|
8
|
-
sortOptions: ConfigSort[];
|
|
9
|
-
searchQuery?: string;
|
|
10
|
-
filterStack?: ConfigFilter;
|
|
11
|
-
collection?: Collection;
|
|
12
|
-
instantSearch: boolean;
|
|
13
|
-
credentials: Credentials;
|
|
14
|
-
onRedirect?: (type: "redirect" | "search", url: string) => void;
|
|
15
|
-
submitSearch: (localSearchQuery?: string) => void;
|
|
16
|
-
setSearchQuery: (searchQuery: string) => void;
|
|
17
|
-
setSortOption: (sortOptionHandle: string) => void;
|
|
18
|
-
showInstantSearchResults: boolean;
|
|
19
|
-
setShowInstantSearchResults: (showInstantSearchResults: boolean) => void;
|
|
20
|
-
theme?: Theme;
|
|
21
|
-
curation?: ConfigCuration;
|
|
22
|
-
/** Array of additional component IDs managed outside of Reactify Search */
|
|
23
|
-
additionalComponentHandles?: string[];
|
|
24
|
-
};
|
|
25
|
-
declare const Context: React.Context<Context | undefined>;
|
|
26
|
-
declare type Props = {
|
|
27
|
-
index: string;
|
|
28
|
-
shopifyPermanentDomain: string;
|
|
29
|
-
configId?: string;
|
|
30
|
-
filterStackHandle?: string;
|
|
31
|
-
collection?: Collection;
|
|
32
|
-
noReactiveBase?: boolean;
|
|
33
|
-
instantSearch?: boolean;
|
|
34
|
-
onRedirect?: (type: "redirect" | "search", url: string) => void;
|
|
35
|
-
credentials?: Credentials;
|
|
36
|
-
theme?: Theme;
|
|
37
|
-
/** Array of additional component IDs managed outside of Reactify Search */
|
|
38
|
-
additionalComponentHandles?: string[];
|
|
39
|
-
/**
|
|
40
|
-
* Optional render function to display a component when the config is loading.
|
|
41
|
-
*/
|
|
42
|
-
renderBooting?: () => JSX.Element | null;
|
|
43
|
-
};
|
|
44
|
-
export declare const Provider: React.FC<Props>;
|
|
45
|
-
export declare const ConfiguredProvider: React.FC<Omit<Props, "renderBooting"> & {
|
|
46
|
-
config: Config;
|
|
47
|
-
}>;
|
|
48
|
-
export declare const useContext: () => Context;
|
|
49
|
-
export interface Collection {
|
|
50
|
-
id: number;
|
|
51
|
-
handle: string;
|
|
52
|
-
title: string;
|
|
53
|
-
}
|
|
54
|
-
export interface Credentials {
|
|
55
|
-
username: string;
|
|
56
|
-
password: string;
|
|
57
|
-
endpoint: string;
|
|
58
|
-
}
|
|
59
|
-
export interface Theme {
|
|
60
|
-
component?: any;
|
|
61
|
-
colors?: ThemeColors;
|
|
62
|
-
typography?: ThemeTypography;
|
|
63
|
-
}
|
|
64
|
-
export interface ThemeTypography {
|
|
65
|
-
fontFamily?: string;
|
|
66
|
-
fontSize?: string;
|
|
67
|
-
}
|
|
68
|
-
export interface ThemeColors {
|
|
69
|
-
alertColor?: string;
|
|
70
|
-
backgroundColor?: string;
|
|
71
|
-
borderColor?: string;
|
|
72
|
-
extColor?: string;
|
|
73
|
-
primaryTextColor?: string;
|
|
74
|
-
primaryColor?: string;
|
|
75
|
-
textColor?: string;
|
|
76
|
-
titleColor?: string;
|
|
77
|
-
}
|
|
78
|
-
export {};
|