@usereactify/search 5.0.0-beta.6 → 5.0.0-beta.7

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.
Files changed (84) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/components/Example/ExampleFilterList.d.ts +1 -1
  4. package/dist/src/components/Example/ExampleFilterList.js.map +1 -1
  5. package/dist/src/components/Example/ExampleFilterRange.d.ts +1 -1
  6. package/dist/src/components/Example/ExampleFilterRange.js.map +1 -1
  7. package/dist/src/components/Example/ExampleFilterSlider.d.ts +1 -1
  8. package/dist/src/components/Example/ExampleFilterSlider.js +1 -1
  9. package/dist/src/components/Example/ExampleFilterSlider.js.map +1 -1
  10. package/dist/src/components/Example/ExampleFilterStack.d.ts +1 -1
  11. package/dist/src/components/Example/ExampleFilterStack.js.map +1 -1
  12. package/dist/src/components/Example/ExampleResultCardCallout.d.ts +1 -1
  13. package/dist/src/components/Example/ExampleResultCardCallout.js.map +1 -1
  14. package/dist/src/components/Example/ExampleResultCardProduct.d.ts +1 -1
  15. package/dist/src/components/Example/ExampleResultCardProduct.js +1 -1
  16. package/dist/src/components/Example/ExampleResultCardProduct.js.map +1 -1
  17. package/dist/src/components/Example/ExampleResultPaginationLoadMore.d.ts +1 -1
  18. package/dist/src/components/Example/ExampleResultPaginationLoadMore.js.map +1 -1
  19. package/dist/src/components/Example/ExampleResultPaginationNextPrev.d.ts +1 -1
  20. package/dist/src/components/Example/ExampleResultPaginationNextPrev.js.map +1 -1
  21. package/dist/src/components/Example/ExampleResultPaginationNumbered.d.ts +1 -1
  22. package/dist/src/components/Example/ExampleResultPaginationNumbered.js +2 -2
  23. package/dist/src/components/Example/ExampleResultPaginationNumbered.js.map +1 -1
  24. package/dist/src/components/Example/ExampleSortby.d.ts +1 -1
  25. package/dist/src/components/Example/ExampleSortby.js.map +1 -1
  26. package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js +7 -20
  27. package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js.map +1 -1
  28. package/dist/src/components/Result/ResultCardCallout.js +3 -5
  29. package/dist/src/components/Result/ResultCardCallout.js.map +1 -1
  30. package/dist/src/components/Result/ResultCardProduct.js +4 -18
  31. package/dist/src/components/Result/ResultCardProduct.js.map +1 -1
  32. package/dist/src/components/Result/ResultStack.js +6 -6
  33. package/dist/src/components/Result/ResultStack.js.map +1 -1
  34. package/dist/src/components/Result/ResultStateProvider.d.ts +1 -1
  35. package/dist/src/components/Result/ResultStateProvider.js +4 -1
  36. package/dist/src/components/Result/ResultStateProvider.js.map +1 -1
  37. package/dist/src/components/Sensor/SensorInventoryAvailable.js +1 -1
  38. package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -1
  39. package/dist/src/components/Sensor/SensorSort.js +1 -19
  40. package/dist/src/components/Sensor/SensorSort.js.map +1 -1
  41. package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.js +3 -3
  42. package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.js.map +1 -1
  43. package/dist/src/hooks/index.d.ts +1 -0
  44. package/dist/src/hooks/index.js +1 -0
  45. package/dist/src/hooks/index.js.map +1 -1
  46. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +1 -1
  47. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +0 -1
  48. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js.map +1 -1
  49. package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.js +1 -1
  50. package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.js.map +1 -1
  51. package/dist/src/hooks/useAnalytics.js +2 -0
  52. package/dist/src/hooks/useAnalytics.js.map +1 -1
  53. package/dist/src/hooks/useConfig.js +9 -8
  54. package/dist/src/hooks/useConfig.js.map +1 -1
  55. package/dist/src/hooks/useCuration.js +16 -3
  56. package/dist/src/hooks/useCuration.js.map +1 -1
  57. package/dist/src/hooks/useDebugger.d.ts +1 -0
  58. package/dist/src/hooks/useDebugger.js +15 -0
  59. package/dist/src/hooks/useDebugger.js.map +1 -0
  60. package/dist/src/hooks/useFilterStack.d.ts +3 -1
  61. package/dist/src/hooks/useFilterStack.js +6 -1
  62. package/dist/src/hooks/useFilterStack.js.map +1 -1
  63. package/dist/src/hooks/useFilters.js +7 -3
  64. package/dist/src/hooks/useFilters.js.map +1 -1
  65. package/dist/src/hooks/usePagination.d.ts +1 -1
  66. package/dist/src/hooks/usePagination.js +11 -0
  67. package/dist/src/hooks/usePagination.js.map +1 -1
  68. package/dist/src/hooks/usePaginationLoadMore.d.ts +1 -1
  69. package/dist/src/hooks/usePaginationLoadMore.js +7 -7
  70. package/dist/src/hooks/usePaginationLoadMore.js.map +1 -1
  71. package/dist/src/hooks/useSearch.d.ts +1 -1
  72. package/dist/src/hooks/useSearch.js +19 -6
  73. package/dist/src/hooks/useSearch.js.map +1 -1
  74. package/dist/src/hooks/useSortby.js +21 -5
  75. package/dist/src/hooks/useSortby.js.map +1 -1
  76. package/dist/src/index.js +45 -3
  77. package/dist/src/index.js.map +1 -1
  78. package/dist/src/utility/debug.d.ts +10 -0
  79. package/dist/src/utility/debug.js +39 -0
  80. package/dist/src/utility/debug.js.map +1 -0
  81. package/dist/src/utility/index.d.ts +1 -0
  82. package/dist/src/utility/index.js +14 -0
  83. package/dist/src/utility/index.js.map +1 -0
  84. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ResultStack.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultStack.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gHAAwF;AAExF,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AAEtE,uCAMqB;AAErB,uCAOqB;AAkCd,MAAM,WAAW,GAA+B,CAAC,KAAK,EAAE,EAAE;IAC/D,MAAM,wBAAwB,GAAG,IAAA,mCAA2B,EAAC;QAC3D,QAAQ,EAAE,KAAK,CAAC,QAAQ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IAC1I,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/C,MAAM,WAAW,GAAG,IAAA,sBAAc,GAAE,CAAC;IAErC,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,WAAW,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QAC/C,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@appbaseio/reactivesearch/lib/components/result/ReactiveList\";\n\nimport { ResultCardCallout } from \"./ResultCardCallout\";\nimport { ResultCardProduct } from \"./ResultCardProduct\";\nimport { ResultPaginationNumbered } from \"./ResultPaginationNumbered\";\nimport { ResultPaginationLoadMore } from \"./ResultPaginationLoadMore\";\nimport { ResultPaginationNextPrev } from \"./ResultPaginationNextPrev\";\n\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilterStack,\n useReactiveResultStackProps,\n} from \"../../hooks\";\n\nimport {\n ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n} from \"../../types\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultStackProps = {\n /** Style prop for the list wrapper */\n listStyle?: React.HTMLAttributes<HTMLElement>[\"style\"];\n /** Classname prop for the list wrapper */\n listClassName?: string;\n /** Render method called when an error occurs */\n renderError?: React.FC<{ error: ReactivesearchError }>;\n /** Render method called while loading for the first time */\n renderLoading?: React.FC;\n /** Render method called when no results are found */\n renderNoResults?: React.FC;\n /** Render method called once for each product result */\n renderResultCardProduct?: React.ComponentProps<typeof ResultCardProduct>[\"render\"];\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.ComponentProps<typeof ResultCardCallout>[\"render\"];\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.ComponentProps<typeof ResultPaginationNumbered>[\"render\"];\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.ComponentProps<typeof ResultPaginationNextPrev>[\"render\"];\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.ComponentProps<typeof ResultPaginationLoadMore>[\"render\"];\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.ComponentProps<typeof ResultPaginationLoadMore>[\"render\"];\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n};\n\nexport const ResultStack: React.FC<ResultStackProps> = (props) => {\n const reactiveResultStackProps = useReactiveResultStackProps({\n pageSize: props.pageSize,\n });\n\n return (\n <ReactiveList\n {...reactiveResultStackProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultStackInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n renderPagination={(\n reactivesearchPaginationProps: ReactivesearchPaginationProps\n ) => (\n <ResultStackPaginationStack\n {...props}\n {...reactivesearchPaginationProps}\n />\n )}\n />\n );\n};\n\nconst ResultStackRenderErrorComponent: ResultStackProps[\"renderError\"] = (props) => {\n return (\n <div>\n {\"Error: \"}{props.error.statusText}\n </div>\n );\n}\n\nconst ResultStackRenderLoadingComponent: ResultStackProps[\"renderLoading\"] = () => {\n return (\n <div>\n {\"Loading\"}\n </div>\n );\n}\n\nconst ResultStackRenderNoResultsComponent: ResultStackProps[\"renderNoResults\"] = () => {\n return (\n <div>\n {\"No results\"}\n </div>\n );\n}\n\nconst ResultStackInner: React.FC<\n ResultStackProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { track } = useAnalytics();\n const { searchQuery } = useSearch();\n\n const initialSearchHasRun = React.useMemo(\n () =>\n \"undefined\" !==\n typeof props.reactivesearchResultProps.resultStats.numberOfResults,\n [props.reactivesearchResultProps]\n );\n\n const listStyle = React.useMemo<React.HTMLAttributes<HTMLElement>[\"style\"]>(\n () =>\n props.listStyle ?? {\n display: \"grid\",\n gap: \"8px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n },\n [props.listStyle]\n );\n\n if (props.reactivesearchResultProps.error) {\n const RenderErrorComponent = props.renderError ?? ResultStackRenderErrorComponent;\n\n return (\n <RenderErrorComponent\n error={props.reactivesearchResultProps.error}\n />\n );\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent = props.renderLoading ?? ResultStackRenderLoadingComponent;\n return (\n <RenderLoadingComponent />\n );\n }\n\n if (!props.reactivesearchResultProps.resultStats.numberOfResults) {\n if (searchQuery) {\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: searchQuery,\n },\n });\n }\n const RenderNoResultsComponent = props.renderNoResults ?? ResultStackRenderNoResultsComponent;\n return (\n <RenderNoResultsComponent />\n );\n }\n\n return (\n <>\n <section\n style={listStyle}\n className={props.listClassName}\n >\n {props.reactivesearchResultProps.data.map((item, key) => {\n // @todo result.type is missing in v1 indexes, this check ensures that they are assumed to be products\n if (ElasticDocumentType.Product === item.type || !item.type) {\n return (\n <ResultCardProduct\n key={item._id}\n product={item}\n document={item}\n pagePosition={key + 1}\n render={props.renderResultCardProduct}\n />\n );\n }\n\n if (ElasticDocumentType.Callout === item.type) {\n return (\n <ResultCardCallout\n key={item._id}\n document={item}\n pagePosition={key + 1}\n callout={item.callout}\n render={props.renderResultCardCallout}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultStackPaginationStackLoadMore\n {...props}\n {...props.reactivesearchResultProps}\n />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultStackPaginationStack: React.FC<ResultStackProps & ReactivesearchPaginationProps> = (props) => {\n const { options } = useReactifySearchContext();\n const filterStack = useFilterStack();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"pagination\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNumbered\n {...props}\n render={props.renderPaginationNumbered}\n />\n );\n }\n\n if (\"next_prev\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNextPrev\n {...props}\n render={props.renderPaginationNextPrev}\n />\n );\n }\n\n return null;\n};\n\n/** Handles rendering pagination for types that use \"result props\" */\nconst ResultStackPaginationStackLoadMore: React.FC<ResultStackProps & { reactivesearchResultProps: ReactivesearchResultProps }> = (props) => {\n const { options } = useReactifySearchContext();\n const filterStack = useFilterStack();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"load_more\" === filterStack?.paginationType) {\n return (\n <ResultPaginationLoadMore\n {...props.reactivesearchResultProps}\n render={props.renderPaginationLoadMore}\n />\n );\n }\n\n return null;\n};\n"]}
1
+ {"version":3,"file":"ResultStack.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultStack.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gHAAwF;AAExF,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AAEtE,uCAMqB;AAErB,uCAOqB;AA8Cd,MAAM,WAAW,GAA+B,CAAC,KAAK,EAAE,EAAE;IAC/D,MAAM,wBAAwB,GAAG,IAAA,mCAA2B,EAAC;QAC3D,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAC;IAEH,OAAO,CACL,8BAAC,sBAAY,oBACP,wBAAwB,IAC5B,MAAM,EAAE,CAAC,yBAAoD,EAAE,EAAE,CAAC,CAChE,8BAAC,gBAAgB,oBACX,KAAK,IACT,yBAAyB,EAAE,yBAAyB,IACpD,CACH,EACD,gBAAgB,EAAE,CAChB,6BAA4D,EAC5D,EAAE,CAAC,CACH,8BAAC,0BAA0B,oBACrB,KAAK,EACL,6BAA6B,EACjC,CACH,IACD,CACH,CAAC;AACJ,CAAC,CAAC;AAxBW,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,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@appbaseio/reactivesearch/lib/components/result/ReactiveList\";\n\nimport { ResultCardCallout } from \"./ResultCardCallout\";\nimport { ResultCardProduct } from \"./ResultCardProduct\";\nimport { ResultPaginationNumbered } from \"./ResultPaginationNumbered\";\nimport { ResultPaginationLoadMore } from \"./ResultPaginationLoadMore\";\nimport { ResultPaginationNextPrev } from \"./ResultPaginationNextPrev\";\n\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilterStack,\n useReactiveResultStackProps,\n} from \"../../hooks\";\n\nimport {\n ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n} from \"../../types\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultStackProps = {\n /** Style prop for the list wrapper */\n listStyle?: React.HTMLAttributes<HTMLElement>[\"style\"];\n /** Classname prop for the list wrapper */\n listClassName?: string;\n /** Render method called when an error occurs */\n renderError?: React.FC<{ error: ReactivesearchError }>;\n /** Render method called while loading for the first time */\n renderLoading?: React.FC;\n /** Render method called when no results are found */\n renderNoResults?: React.FC;\n /** Render method called once for each product result */\n renderResultCardProduct?: React.ComponentProps<\n typeof ResultCardProduct\n >[\"render\"];\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.ComponentProps<\n typeof ResultCardCallout\n >[\"render\"];\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.ComponentProps<\n typeof ResultPaginationNumbered\n >[\"render\"];\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.ComponentProps<\n typeof ResultPaginationNextPrev\n >[\"render\"];\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.ComponentProps<\n typeof ResultPaginationLoadMore\n >[\"render\"];\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.ComponentProps<\n typeof ResultPaginationLoadMore\n >[\"render\"];\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n};\n\nexport const ResultStack: React.FC<ResultStackProps> = (props) => {\n const reactiveResultStackProps = useReactiveResultStackProps({\n pageSize: props.pageSize,\n });\n\n return (\n <ReactiveList\n {...reactiveResultStackProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultStackInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n renderPagination={(\n reactivesearchPaginationProps: ReactivesearchPaginationProps\n ) => (\n <ResultStackPaginationStack\n {...props}\n {...reactivesearchPaginationProps}\n />\n )}\n />\n );\n};\n\nconst ResultStackRenderErrorComponent: ResultStackProps[\"renderError\"] = (\n props\n) => {\n return (\n <div>\n {\"Error: \"}\n {props.error.statusText}\n </div>\n );\n};\n\nconst ResultStackRenderLoadingComponent: ResultStackProps[\"renderLoading\"] =\n () => {\n return <div>{\"Loading\"}</div>;\n };\n\nconst ResultStackRenderNoResultsComponent: ResultStackProps[\"renderNoResults\"] =\n () => {\n return <div>{\"No results\"}</div>;\n };\n\nconst ResultStackInner: React.FC<\n ResultStackProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { track } = useAnalytics();\n const { searchQuery } = useSearch();\n\n const initialSearchHasRun = React.useMemo(\n () =>\n \"undefined\" !==\n typeof props.reactivesearchResultProps.resultStats.numberOfResults,\n [props.reactivesearchResultProps]\n );\n\n const listStyle = React.useMemo<React.HTMLAttributes<HTMLElement>[\"style\"]>(\n () =>\n props.listStyle ?? {\n display: \"grid\",\n gap: \"8px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n },\n [props.listStyle]\n );\n\n if (props.reactivesearchResultProps.error) {\n const RenderErrorComponent =\n props.renderError ?? ResultStackRenderErrorComponent;\n\n return (\n <RenderErrorComponent error={props.reactivesearchResultProps.error} />\n );\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent =\n props.renderLoading ?? ResultStackRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n\n if (!props.reactivesearchResultProps.resultStats.numberOfResults) {\n if (searchQuery) {\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: searchQuery,\n },\n });\n }\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultStackRenderNoResultsComponent;\n return <RenderNoResultsComponent />;\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {props.reactivesearchResultProps.data.map((item, key) => {\n // @todo result.type is missing in v1 indexes, this check ensures that they are assumed to be products\n if (ElasticDocumentType.Product === item.type || !item.type) {\n return (\n <ResultCardProduct\n key={item._id}\n product={item}\n document={item}\n pagePosition={key + 1}\n render={props.renderResultCardProduct}\n />\n );\n }\n\n if (ElasticDocumentType.Callout === item.type) {\n return (\n <ResultCardCallout\n key={item._id}\n document={item}\n pagePosition={key + 1}\n callout={item.callout}\n render={props.renderResultCardCallout}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultStackPaginationStackLoadMore\n {...props}\n {...props.reactivesearchResultProps}\n />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultStackPaginationStack: React.FC<\n ResultStackProps & ReactivesearchPaginationProps\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilterStack();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"pagination\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNumbered\n {...props}\n render={props.renderPaginationNumbered}\n />\n );\n }\n\n if (\"next_prev\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNextPrev\n {...props}\n render={props.renderPaginationNextPrev}\n />\n );\n }\n\n return null;\n};\n\n/** Handles rendering pagination for types that use \"result props\" */\nconst ResultStackPaginationStackLoadMore: React.FC<\n ResultStackProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilterStack();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"load_more\" === filterStack?.paginationType) {\n return (\n <ResultPaginationLoadMore\n {...props.reactivesearchResultProps}\n render={props.renderPaginationLoadMore}\n />\n );\n }\n\n return null;\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { ReactivesearchSearchStatePage } from "../../types";
3
3
  export declare type ResultStateProvidedProps = {
4
- render: (props: ReactivesearchSearchStatePage) => JSX.Element | null;
4
+ render: React.FC<ReactivesearchSearchStatePage>;
5
5
  };
6
6
  export declare const ResultStateProvider: React.FC<ResultStateProvidedProps>;
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ResultStateProvider = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const StateProvider_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/StateProvider"));
9
- const ResultStateProvider = ({ render }) => (react_1.default.createElement(StateProvider_1.default, { componentIds: ["page"], includeKeys: ["isLoading", "hits", "resultStats", "error"], render: (state) => render(state.searchState.page) }));
9
+ const ResultStateProvider = (props) => (react_1.default.createElement(StateProvider_1.default, { componentIds: ["page"], includeKeys: ["isLoading", "hits", "resultStats", "error"], render: (state) => {
10
+ const RenderComponent = props.render;
11
+ return react_1.default.createElement(RenderComponent, Object.assign({}, state.searchState.page));
12
+ } }));
10
13
  exports.ResultStateProvider = ResultStateProvider;
11
14
  //# sourceMappingURL=ResultStateProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ResultStateProvider.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultStateProvider.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iHAAyF;AAQlF,MAAM,mBAAmB,GAAuC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACrF,8BAAC,uBAAa,IACZ,YAAY,EAAE,CAAC,MAAM,CAAC,EACtB,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,EAC1D,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAChB,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,IAAqC,CAAC,GAEjE,CACH,CAAC;AARW,QAAA,mBAAmB,uBAQ9B","sourcesContent":["import React from \"react\";\nimport StateProvider from \"@appbaseio/reactivesearch/lib/components/basic/StateProvider\";\n\nimport { ReactivesearchSearchStatePage } from \"../../types\";\n\nexport type ResultStateProvidedProps = {\n render: (props: ReactivesearchSearchStatePage) => JSX.Element | null;\n};\n\nexport const ResultStateProvider: React.FC<ResultStateProvidedProps> = ({ render }) => (\n <StateProvider\n componentIds={[\"page\"]}\n includeKeys={[\"isLoading\", \"hits\", \"resultStats\", \"error\"]}\n render={(state) =>\n render(state.searchState.page as ReactivesearchSearchStatePage)\n }\n />\n);\n"]}
1
+ {"version":3,"file":"ResultStateProvider.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultStateProvider.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iHAAyF;AAQlF,MAAM,mBAAmB,GAAuC,CACrE,KAAK,EACL,EAAE,CAAC,CACH,8BAAC,uBAAa,IACZ,YAAY,EAAE,CAAC,MAAM,CAAC,EACtB,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,EAC1D,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QAChB,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC;QAErC,OAAO,8BAAC,eAAe,oBAAK,KAAK,CAAC,WAAW,CAAC,IAAI,EAAI,CAAC;IACzD,CAAC,GACD,CACH,CAAC;AAZW,QAAA,mBAAmB,uBAY9B","sourcesContent":["import React from \"react\";\nimport StateProvider from \"@appbaseio/reactivesearch/lib/components/basic/StateProvider\";\n\nimport { ReactivesearchSearchStatePage } from \"../../types\";\n\nexport type ResultStateProvidedProps = {\n render: React.FC<ReactivesearchSearchStatePage>;\n};\n\nexport const ResultStateProvider: React.FC<ResultStateProvidedProps> = (\n props\n) => (\n <StateProvider\n componentIds={[\"page\"]}\n includeKeys={[\"isLoading\", \"hits\", \"resultStats\", \"error\"]}\n render={(state) => {\n const RenderComponent = props.render;\n\n return <RenderComponent {...state.searchState.page} />;\n }}\n />\n);\n"]}
@@ -8,7 +8,7 @@ const react_1 = __importDefault(require("react"));
8
8
  const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
9
9
  const hooks_1 = require("../../hooks");
10
10
  const SensorInventoryAvailable = () => {
11
- const filterStack = (0, hooks_1.useFilterStack)();
11
+ const { filterStack } = (0, hooks_1.useFilterStack)();
12
12
  if (!filterStack || "show_all" === filterStack.inventoryVisibility)
13
13
  return null;
14
14
  return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorInventoryAvailable", customQuery: () => ({
@@ -1 +1 @@
1
- {"version":3,"file":"SensorInventoryAvailable.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorInventoryAvailable.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAA6C;AAEtC,MAAM,wBAAwB,GAAa,GAAG,EAAE;IACrD,MAAM,WAAW,GAAG,IAAA,sBAAc,GAAE,CAAC;IAErC,IAAI,CAAC,WAAW,IAAI,UAAU,KAAK,WAAW,CAAC,mBAAmB;QAChE,OAAO,IAAI,CAAC;IAEd,OAAO,CACL,8BAAC,2BAAiB,IAChB,WAAW,EAAC,0BAA0B,EACtC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;YAClB,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,MAAM,EAAE;wBACN;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ;wCACE,IAAI,EAAE;4CACJ,IAAI,EAAE;gDACJ,KAAK,EAAE,SAAS;6CACjB;yCACF;qCACF;oCACD;wCACE,MAAM,EAAE;4CACN,IAAI,EAAE,UAAU;4CAChB,KAAK,EAAE;gDACL,KAAK,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE;6CACtC;yCACF;qCACF;iCACF;6BACF;yBACF;wBACD;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ,KAAK,EAAE,SAAS;iCACjB;6BACF;yBACF;qBACF;oBACD,oBAAoB,EAAE,GAAG;iBAC1B;aACF;SACF,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AAhDW,QAAA,wBAAwB,4BAgDnC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useFilterStack } from \"../../hooks\";\n\nexport const SensorInventoryAvailable: React.FC = () => {\n const filterStack = useFilterStack();\n\n if (!filterStack || \"show_all\" === filterStack.inventoryVisibility)\n return null;\n\n return (\n <ReactiveComponent\n componentId=\"SensorInventoryAvailable\"\n customQuery={() => ({\n query: {\n bool: {\n should: [\n {\n bool: {\n must: [\n {\n term: {\n type: {\n value: \"product\",\n },\n },\n },\n {\n nested: {\n path: \"variants\",\n query: {\n match: { \"variants.available\": true },\n },\n },\n },\n ],\n },\n },\n {\n term: {\n type: {\n value: \"callout\",\n },\n },\n },\n ],\n minimum_should_match: \"1\",\n },\n },\n })}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"SensorInventoryAvailable.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorInventoryAvailable.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAA6C;AAEtC,MAAM,wBAAwB,GAAa,GAAG,EAAE;IACrD,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,sBAAc,GAAE,CAAC;IAEzC,IAAI,CAAC,WAAW,IAAI,UAAU,KAAK,WAAW,CAAC,mBAAmB;QAChE,OAAO,IAAI,CAAC;IAEd,OAAO,CACL,8BAAC,2BAAiB,IAChB,WAAW,EAAC,0BAA0B,EACtC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;YAClB,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,MAAM,EAAE;wBACN;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ;wCACE,IAAI,EAAE;4CACJ,IAAI,EAAE;gDACJ,KAAK,EAAE,SAAS;6CACjB;yCACF;qCACF;oCACD;wCACE,MAAM,EAAE;4CACN,IAAI,EAAE,UAAU;4CAChB,KAAK,EAAE;gDACL,KAAK,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE;6CACtC;yCACF;qCACF;iCACF;6BACF;yBACF;wBACD;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ,KAAK,EAAE,SAAS;iCACjB;6BACF;yBACF;qBACF;oBACD,oBAAoB,EAAE,GAAG;iBAC1B;aACF;SACF,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AAhDW,QAAA,wBAAwB,4BAgDnC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useFilterStack } from \"../../hooks\";\n\nexport const SensorInventoryAvailable: React.FC = () => {\n const { filterStack } = useFilterStack();\n\n if (!filterStack || \"show_all\" === filterStack.inventoryVisibility)\n return null;\n\n return (\n <ReactiveComponent\n componentId=\"SensorInventoryAvailable\"\n customQuery={() => ({\n query: {\n bool: {\n should: [\n {\n bool: {\n must: [\n {\n term: {\n type: {\n value: \"product\",\n },\n },\n },\n {\n nested: {\n path: \"variants\",\n query: {\n match: { \"variants.available\": true },\n },\n },\n },\n ],\n },\n },\n {\n term: {\n type: {\n value: \"callout\",\n },\n },\n },\n ],\n minimum_should_match: \"1\",\n },\n },\n })}\n />\n );\n};\n"]}
@@ -7,22 +7,14 @@ exports.SensorSort = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
9
9
  const hooks_1 = require("../../hooks");
10
- const debug = require("debug")("reactify-search:SensorSort");
11
10
  const SensorSort = () => {
12
11
  const { options, config } = (0, hooks_1.useReactifySearchContext)();
13
12
  const curation = (0, hooks_1.useCuration)();
14
13
  const globalCuration = (curation === null || curation === void 0 ? void 0 : curation.id) === "global";
15
14
  const { sortOption } = (0, hooks_1.useSortby)();
16
- const searchQuery = react_1.default.useMemo(() => {
17
- if (typeof window === "undefined")
18
- return "";
19
- const urlParams = new URLSearchParams(window.location.search);
20
- return urlParams.get("q") || "";
21
- }, []);
22
15
  const { sort, query } = react_1.default.useMemo(() => {
23
16
  return {
24
17
  sort: buildSort({
25
- config,
26
18
  sortOption,
27
19
  collection: options.mode === "collection" ? options.collection : undefined,
28
20
  curation,
@@ -35,11 +27,6 @@ const SensorSort = () => {
35
27
  }),
36
28
  };
37
29
  }, [config, sortOption, curation]);
38
- react_1.default.useEffect(() => {
39
- debug("searchQuery", searchQuery);
40
- debug("sort", sort);
41
- debug("query", query);
42
- }, [searchQuery, sort]);
43
30
  return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorSort", customQuery: () => ({
44
31
  sort,
45
32
  query,
@@ -48,12 +35,7 @@ const SensorSort = () => {
48
35
  exports.SensorSort = SensorSort;
49
36
  const buildSort = (args) => {
50
37
  var _a;
51
- const { config, curation, sortOption, collection, globalCuration } = args;
52
- debug("buildSortQuery.start", {
53
- config,
54
- curation,
55
- sortOption,
56
- });
38
+ const { curation, sortOption, collection, globalCuration } = args;
57
39
  // return default sort option if unset
58
40
  if (!sortOption) {
59
41
  return collection
@@ -1 +1 @@
1
- {"version":3,"file":"SensorSort.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSort.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAGjG,uCAA+E;AAE/E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4BAA4B,CAAC,CAAC;AAEtD,MAAM,UAAU,GAA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AE;QAC/B,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR;oBACE,MAAM,EAAE;wBACN,IAAI,EAAE,WAAW;wBACjB,KAAK,EAAE;4BACL,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ;wCACE,IAAI,EAAE;4CACJ,CAAC,aACC,YAAY,KAAK,QAAQ,CAAC,IAAI;gDAC5B,CAAC,CAAC,kBAAkB;gDACpB,CAAC,CAAC,YACN,UAAU,CAAC,EACT,YAAY,KAAK,QAAQ,CAAC,IAAI;gDAC5B,CAAC,CAAC,QAAQ,CAAC,gBAAgB;gDAC3B,CAAC,CAAC,MAAA,QAAQ,CAAC,UAAU,0CAAE,WAAW,EAAE;yCACzC;qCACF;oCACD;wCACE,IAAI,EAAE;4CACJ,kBAAkB,EAAE,IAAI;yCACzB;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;gBACD,kEAAkE;gBAClE,GAAG,CAAC,UAAU;oBACd,CAAC,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC;oBAC5D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;6BAChB;yBACF;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport type { Config, ConfigCuration, ConfigSort } from \"../../types\";\nimport { useReactifySearchContext, useSortby, useCuration } from \"../../hooks\";\n\nconst debug = require(\"debug\")(\"reactify-search:SensorSort\");\n\nexport const SensorSort: React.FC = () => {\n const { options, config } = useReactifySearchContext();\n const curation = useCuration();\n const globalCuration = curation?.id === \"global\";\n\n const { sortOption } = useSortby();\n\n const searchQuery = React.useMemo(() => {\n if (typeof window === \"undefined\") return \"\";\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"q\") || \"\";\n }, []);\n\n const { sort, query } = React.useMemo(() => {\n return {\n sort: buildSort({\n config,\n sortOption,\n collection: options.mode === \"collection\" ? options.collection : undefined,\n curation,\n globalCuration,\n }),\n query: buildQuery({\n sortOption,\n curation,\n globalCuration,\n }),\n };\n }, [config, sortOption, curation]);\n\n React.useEffect(() => {\n debug(\"searchQuery\", searchQuery);\n debug(\"sort\", sort);\n debug(\"query\", query);\n }, [searchQuery, sort]);\n\n return (\n <ReactiveComponent\n componentId=\"SensorSort\"\n customQuery={() => ({\n sort,\n query,\n })}\n />\n );\n};\n\nconst buildSort = (args: {\n config: Config;\n globalCuration?: boolean;\n sortOption?: ConfigSort;\n curation?: ConfigCuration;\n collection?: {\n id: number;\n title: string;\n handle: string;\n };\n}): any[] => {\n const { config, curation, sortOption, collection, globalCuration } = args;\n\n debug(\"buildSortQuery.start\", {\n config,\n curation,\n sortOption,\n });\n\n // return default sort option if unset\n if (!sortOption) {\n return collection\n ? mapCollectionPositionSortClause(collection)\n : [\"_score\"];\n }\n\n // curation positions are only applied for the default `collections.position` or `_score` sort\n // if the sort is something else, apply a normal sort which applies what the user has requested\n if (![\"_score\", \"collections.position\"].includes(sortOption.field)) {\n return [{ [sortOption.field]: sortOption.direction }];\n }\n\n // no matching curation, return default sort clause\n if (!curation) {\n return collection\n ? mapCollectionPositionSortClause(collection)\n : [\"_score\"];\n }\n\n const sorts = [];\n\n // show pins first\n if (globalCuration && collection) {\n sorts.push(...mapCollectionPositionSortClause(collection));\n } else {\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n },\n },\n });\n }\n\n if (0 < curation.boosting.groupings.length) {\n const groupings = curation.boosting.groupings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const grouping of groupings) {\n try {\n const query = JSON.parse(grouping.query);\n if (query) sorts.push(query);\n } catch {\n console.error(`query could not be parsed for boost grouping`, grouping);\n }\n }\n }\n\n if (0 < curation.boosting.sortings.length) {\n const sortings = curation.boosting.sortings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const sorting of sortings) {\n try {\n const query = JSON.parse(sorting.query);\n if (query) sorts.push(query);\n } catch {\n console.error(`query could not be parsed for boost sorting`, sorting);\n }\n }\n }\n\n // finally, for collections, if no other sorting is defined, sort by index order to provide\n // a consistent order\n if (\"collection\" === curation.type && sorts.length === 0) {\n sorts.push(\"_doc\");\n }\n\n // finally, for search, sort by score\n if (\"search\" === curation.type) {\n sorts.push(\"_score\");\n }\n\n return sorts;\n};\n\n/**\n * Return a sort clause which sorts by position within the given collection.\n */\nfunction mapCollectionPositionSortClause(\n collection: NonNullable<{\n id: number;\n title: string;\n handle: string;\n }>\n) {\n return [\n {\n \"collections.position\": {\n order: \"asc\",\n nested: {\n path: \"collections\",\n filter: {\n term: {\n \"collections.handle.keyword\": collection.handle,\n },\n },\n },\n },\n },\n ];\n}\n\nconst buildQuery = (args: {\n sortOption?: ConfigSort;\n curation?: ConfigCuration;\n globalCuration?: boolean;\n}): Record<string, any> | undefined => {\n const { curation, sortOption, globalCuration } = args;\n\n if (!curation || globalCuration) {\n return undefined;\n }\n\n return {\n bool: {\n must_not: [\n {\n nested: {\n path: \"curations\",\n query: {\n bool: {\n must: [\n {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n {\n term: {\n \"curations.hidden\": true,\n },\n },\n ],\n },\n },\n },\n },\n // hide callout when not sorting by _score or collections.position\n ...(sortOption &&\n ![\"_score\", \"collections.position\"].includes(sortOption.field)\n ? [\n {\n term: {\n type: \"callout\",\n },\n },\n ]\n : []),\n ],\n },\n };\n};\n"]}
1
+ {"version":3,"file":"SensorSort.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSort.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAGjG,uCAA+E;AAExE,MAAM,UAAU,GAAa,GAAG,EAAE;IACvC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAA,mBAAW,GAAE,CAAC;IAC/B,MAAM,cAAc,GAAG,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,MAAK,QAAQ,CAAC;IAEjD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACzC,OAAO;YACL,IAAI,EAAE,SAAS,CAAC;gBACd,UAAU;gBACV,UAAU,EAAE,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;gBAC1E,QAAQ;gBACR,cAAc;aACf,CAAC;YACF,KAAK,EAAE,UAAU,CAAC;gBAChB,UAAU;gBACV,QAAQ;gBACR,cAAc;aACf,CAAC;SACH,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEnC,OAAO,CACL,8BAAC,2BAAiB,IAChB,WAAW,EAAC,YAAY,EACxB,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;YAClB,IAAI;YACJ,KAAK;SACN,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AAhCW,QAAA,UAAU,cAgCrB;AAEF,MAAM,SAAS,GAAG,CAAC,IASlB,EAAS,EAAE;;IACV,MAAM,EAAE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AAU,0CAAE,WAAW,EAAE;yCACzC;qCACF;oCACD;wCACE,IAAI,EAAE;4CACJ,kBAAkB,EAAE,IAAI;yCACzB;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;gBACD,kEAAkE;gBAClE,GAAG,CAAC,UAAU;oBACd,CAAC,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC;oBAC5D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;6BAChB;yBACF;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { ConfigCuration, ConfigSort } from \"../../types\";\nimport { useReactifySearchContext, useSortby, useCuration } from \"../../hooks\";\n\nexport const SensorSort: React.FC = () => {\n const { options, config } = useReactifySearchContext();\n const curation = useCuration();\n const globalCuration = curation?.id === \"global\";\n\n const { sortOption } = useSortby();\n\n const { sort, query } = React.useMemo(() => {\n return {\n sort: buildSort({\n sortOption,\n collection: options.mode === \"collection\" ? options.collection : undefined,\n curation,\n globalCuration,\n }),\n query: buildQuery({\n sortOption,\n curation,\n globalCuration,\n }),\n };\n }, [config, sortOption, curation]);\n\n return (\n <ReactiveComponent\n componentId=\"SensorSort\"\n customQuery={() => ({\n sort,\n query,\n })}\n />\n );\n};\n\nconst buildSort = (args: {\n globalCuration?: boolean;\n sortOption?: ConfigSort;\n curation?: ConfigCuration;\n collection?: {\n id: number;\n title: string;\n handle: string;\n };\n}): any[] => {\n const { curation, sortOption, collection, globalCuration } = args;\n\n // return default sort option if unset\n if (!sortOption) {\n return collection\n ? mapCollectionPositionSortClause(collection)\n : [\"_score\"];\n }\n\n // curation positions are only applied for the default `collections.position` or `_score` sort\n // if the sort is something else, apply a normal sort which applies what the user has requested\n if (![\"_score\", \"collections.position\"].includes(sortOption.field)) {\n return [{ [sortOption.field]: sortOption.direction }];\n }\n\n // no matching curation, return default sort clause\n if (!curation) {\n return collection\n ? mapCollectionPositionSortClause(collection)\n : [\"_score\"];\n }\n\n const sorts = [];\n\n // show pins first\n if (globalCuration && collection) {\n sorts.push(...mapCollectionPositionSortClause(collection));\n } else {\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n },\n },\n });\n }\n\n if (0 < curation.boosting.groupings.length) {\n const groupings = curation.boosting.groupings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const grouping of groupings) {\n try {\n const query = JSON.parse(grouping.query);\n if (query) sorts.push(query);\n } catch {\n console.error(`query could not be parsed for boost grouping`, grouping);\n }\n }\n }\n\n if (0 < curation.boosting.sortings.length) {\n const sortings = curation.boosting.sortings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const sorting of sortings) {\n try {\n const query = JSON.parse(sorting.query);\n if (query) sorts.push(query);\n } catch {\n console.error(`query could not be parsed for boost sorting`, sorting);\n }\n }\n }\n\n // finally, for collections, if no other sorting is defined, sort by index order to provide\n // a consistent order\n if (\"collection\" === curation.type && sorts.length === 0) {\n sorts.push(\"_doc\");\n }\n\n // finally, for search, sort by score\n if (\"search\" === curation.type) {\n sorts.push(\"_score\");\n }\n\n return sorts;\n};\n\n/**\n * Return a sort clause which sorts by position within the given collection.\n */\nfunction mapCollectionPositionSortClause(\n collection: NonNullable<{\n id: number;\n title: string;\n handle: string;\n }>\n) {\n return [\n {\n \"collections.position\": {\n order: \"asc\",\n nested: {\n path: \"collections\",\n filter: {\n term: {\n \"collections.handle.keyword\": collection.handle,\n },\n },\n },\n },\n },\n ];\n}\n\nconst buildQuery = (args: {\n sortOption?: ConfigSort;\n curation?: ConfigCuration;\n globalCuration?: boolean;\n}): Record<string, any> | undefined => {\n const { curation, sortOption, globalCuration } = args;\n\n if (!curation || globalCuration) {\n return undefined;\n }\n\n return {\n bool: {\n must_not: [\n {\n nested: {\n path: \"curations\",\n query: {\n bool: {\n must: [\n {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n {\n term: {\n \"curations.hidden\": true,\n },\n },\n ],\n },\n },\n },\n },\n // hide callout when not sorting by _score or collections.position\n ...(sortOption &&\n ![\"_score\", \"collections.position\"].includes(sortOption.field)\n ? [\n {\n term: {\n type: \"callout\",\n },\n },\n ]\n : []),\n ],\n },\n };\n};\n"]}
@@ -7,9 +7,9 @@ exports.UtilityAuthenticatedReactiveBase = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const hooks_1 = require("../../hooks");
9
9
  const ReactiveBase_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveBase"));
10
- const UtilityAuthenticatedReactiveBase = ({ children }) => {
11
- const props = (0, hooks_1.useReactiveBaseProps)();
12
- return react_1.default.createElement(ReactiveBase_1.default, Object.assign({}, props), children);
10
+ const UtilityAuthenticatedReactiveBase = (props) => {
11
+ const reactiveBaseProps = (0, hooks_1.useReactiveBaseProps)();
12
+ return (react_1.default.createElement(ReactiveBase_1.default, Object.assign({}, reactiveBaseProps), props.children));
13
13
  };
14
14
  exports.UtilityAuthenticatedReactiveBase = UtilityAuthenticatedReactiveBase;
15
15
  //# sourceMappingURL=UtilityAuthenticatedReactiveBase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UtilityAuthenticatedReactiveBase.js","sourceRoot":"","sources":["../../../../src/components/Utility/UtilityAuthenticatedReactiveBase.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,uCAAmD;AACnD,+GAAuF;AAEhF,MAAM,gCAAgC,GAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACzE,MAAM,KAAK,GAAG,IAAA,4BAAoB,GAAE,CAAC;IACrC,OAAO,8BAAC,sBAAY,oBAAK,KAAK,GAAG,QAAQ,CAAgB,CAAC;AAC5D,CAAC,CAAC;AAHW,QAAA,gCAAgC,oCAG3C","sourcesContent":["import React from \"react\";\nimport { useReactiveBaseProps } from \"../../hooks\";\nimport ReactiveBase from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveBase\";\n\nexport const UtilityAuthenticatedReactiveBase: React.FC = ({ children }) => {\n const props = useReactiveBaseProps();\n return <ReactiveBase {...props}>{children}</ReactiveBase>;\n};\n"]}
1
+ {"version":3,"file":"UtilityAuthenticatedReactiveBase.js","sourceRoot":"","sources":["../../../../src/components/Utility/UtilityAuthenticatedReactiveBase.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,uCAAmD;AACnD,+GAAuF;AAEhF,MAAM,gCAAgC,GAAa,CAAC,KAAK,EAAE,EAAE;IAClE,MAAM,iBAAiB,GAAG,IAAA,4BAAoB,GAAE,CAAC;IAEjD,OAAO,CACL,8BAAC,sBAAY,oBACP,iBAAiB,GAEpB,KAAK,CAAC,QAAQ,CACF,CAChB,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,gCAAgC,oCAU3C","sourcesContent":["import React from \"react\";\nimport { useReactiveBaseProps } from \"../../hooks\";\nimport ReactiveBase from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveBase\";\n\nexport const UtilityAuthenticatedReactiveBase: React.FC = (props) => {\n const reactiveBaseProps = useReactiveBaseProps();\n\n return (\n <ReactiveBase\n {...reactiveBaseProps}\n >\n {props.children}\n </ReactiveBase>\n );\n};\n"]}
@@ -1,4 +1,5 @@
1
1
  export * from "./reactivesearch";
2
+ export * from "./useDebugger";
2
3
  export * from "./useSortby";
3
4
  export * from "./usePagination";
4
5
  export * from "./usePaginationLoadMore";
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./reactivesearch"), exports);
14
+ __exportStar(require("./useDebugger"), exports);
14
15
  __exportStar(require("./useSortby"), exports);
15
16
  __exportStar(require("./usePagination"), exports);
16
17
  __exportStar(require("./usePaginationLoadMore"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC;AAEjC,8CAA4B;AAC5B,kDAAgC;AAChC,0DAAwC;AACxC,8CAA4B;AAC5B,+CAA6B;AAC7B,gDAA8B;AAC9B,iDAA+B;AAC/B,mDAAiC;AACjC,oDAAkC;AAClC,uDAAqC;AACrC,4DAA0C;AAC1C,8CAA4B;AAC5B,6DAA2C","sourcesContent":["export * from \"./reactivesearch\";\n\nexport * from \"./useSortby\";\nexport * from \"./usePagination\";\nexport * from \"./usePaginationLoadMore\";\nexport * from \"./useSearch\";\nexport * from \"./useFilters\";\nexport * from \"./useCuration\";\nexport * from \"./useAnalytics\";\nexport * from \"./useFilterStack\";\nexport * from \"./useProductPrice\";\nexport * from \"./useFilterListProps\";\nexport * from \"./useFilterCollapsedState\";\nexport * from \"./useConfig\";\nexport * from \"./useReactifySearchContext\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC;AAEjC,gDAA8B;AAC9B,8CAA4B;AAC5B,kDAAgC;AAChC,0DAAwC;AACxC,8CAA4B;AAC5B,+CAA6B;AAC7B,gDAA8B;AAC9B,iDAA+B;AAC/B,mDAAiC;AACjC,oDAAkC;AAClC,uDAAqC;AACrC,4DAA0C;AAC1C,8CAA4B;AAC5B,6DAA2C","sourcesContent":["export * from \"./reactivesearch\";\n\nexport * from \"./useDebugger\";\nexport * from \"./useSortby\";\nexport * from \"./usePagination\";\nexport * from \"./usePaginationLoadMore\";\nexport * from \"./useSearch\";\nexport * from \"./useFilters\";\nexport * from \"./useCuration\";\nexport * from \"./useAnalytics\";\nexport * from \"./useFilterStack\";\nexport * from \"./useProductPrice\";\nexport * from \"./useFilterListProps\";\nexport * from \"./useFilterCollapsedState\";\nexport * from \"./useConfig\";\nexport * from \"./useReactifySearchContext\";\n"]}
@@ -9,7 +9,7 @@ export declare const useReactiveDataSearchProps: (options: {
9
9
  inputClassName?: string | undefined;
10
10
  type: string;
11
11
  showIcon: boolean;
12
- fuzziness: 0 | 1 | 2 | "AUTO";
12
+ fuzziness: 0 | 2 | 1 | "AUTO";
13
13
  queryFormat: "and" | "or";
14
14
  autosuggest: boolean;
15
15
  value: string;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useReactiveDataSearchProps = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const ahooks_1 = require("ahooks");
9
- const debug = require("debug")("reactify-search:useReactiveDataSearchProps");
10
9
  const hooks_1 = require("../../hooks");
11
10
  // default field for when zero search fields have been configured in Reactify
12
11
  const defaultSearchField = {
@@ -1 +1 @@
1
- {"version":3,"file":"useReactiveDataSearchProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveDataSearchProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,mCAAuC;AAEvC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4CAA4C,CAAC,CAAC;AAI7E,uCAAgF;AAEhF,6EAA6E;AAC7E,MAAM,kBAAkB,GAAgB;IACtC,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,gBAAgB;CAC7B,CAAC;AAEK,MAAM,0BAA0B,GAAG,CAAC,OAK1C,EAAE,EAAE;;IACH,MAAM,EAAE,MAAM,EAAE,GAA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;QACZ,cAAc;QACd,wBAAwB;QACxB,2BAA2B;KAC5B,CACF,CAAC;AACJ,CAAC,CAAC;AA7FW,QAAA,0BAA0B,8BA6FrC","sourcesContent":["import React from \"react\";\nimport { useDebounceFn } from \"ahooks\";\n\nconst debug = require(\"debug\")(\"reactify-search:useReactiveDataSearchProps\");\n\nimport type { ConfigField } from \"../../types/config\";\n\nimport { useReactifySearchContext, useSearch, useAnalytics } from \"../../hooks\";\n\n// default field for when zero search fields have been configured in Reactify\nconst defaultSearchField: ConfigField = {\n id: \"title\",\n field: \"title\",\n importance: 0,\n searchType: \"instant_search\",\n};\n\nexport const useReactiveDataSearchProps = (options: {\n [key: string]: any;\n debounce?: number;\n placeholder?: string;\n inputClassName?: string;\n}) => {\n const { config } = useReactifySearchContext();\n const {\n searchQuery,\n submitSearch,\n setSearchQuery,\n setShowInstantSearchResults,\n } = useSearch();\n\n const searchFields = React.useMemo(\n () =>\n 0 < config.fields.length\n ? config.fields.filter((field) =>\n [\"always_search\", \"instant_search\"].includes(field.searchType)\n )\n : [defaultSearchField],\n []\n );\n\n const handleKeyPress = React.useCallback(\n (e) => {\n if (\"Enter\" !== e.key) return;\n submitSearch();\n },\n [submitSearch]\n );\n\n const { track } = useAnalytics();\n\n const trackQuery = React.useCallback(() => {\n if (!searchQuery || (searchQuery && searchQuery.length < 3)) return;\n track({ eventName: \"search\", payload: { searchTerm: searchQuery } });\n }, [searchQuery, track]);\n\n const { run: runDebouncedTriggerQuery, cancel: cancelDebouncedTriggerQuery } =\n useDebounceFn(\n (triggerQuery: () => void) => {\n triggerQuery();\n trackQuery();\n },\n {\n wait: options.debounce ?? 300,\n }\n );\n\n return React.useMemo(\n () => ({\n type: \"search\",\n showIcon: false,\n fuzziness: 1 as 0 | 1 | 2 | \"AUTO\",\n queryFormat: \"and\" as \"and\" | \"or\",\n autosuggest: false,\n value: searchQuery ?? \"\",\n onKeyUp: handleKeyPress,\n componentId: \"SearchInput\",\n placeholder: options.placeholder ?? \"Search for a product...\",\n dataField: searchFields.map((field) => field.field),\n fieldWeights: searchFields.map((field) => field.importance),\n onChange: (value: string, triggerQuery: () => {}) => {\n setSearchQuery(value);\n if (!!value) {\n runDebouncedTriggerQuery(triggerQuery);\n } else {\n cancelDebouncedTriggerQuery();\n }\n },\n onBlur: () => {\n // setTimeout ensures that results are still clickable before close\n setTimeout(() => setShowInstantSearchResults(false), 300);\n },\n onFocus: () => {\n setShowInstantSearchResults(true);\n },\n innerClass: {\n input: options.inputClassName,\n },\n ...options,\n }),\n [\n searchQuery,\n handleKeyPress,\n options.placeholder,\n searchFields,\n setSearchQuery,\n runDebouncedTriggerQuery,\n cancelDebouncedTriggerQuery,\n ]\n );\n};\n"]}
1
+ {"version":3,"file":"useReactiveDataSearchProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveDataSearchProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,mCAAuC;AAIvC,uCAAgF;AAEhF,6EAA6E;AAC7E,MAAM,kBAAkB,GAAgB;IACtC,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,gBAAgB;CAC7B,CAAC;AAEK,MAAM,0BAA0B,GAAG,CAAC,OAK1C,EAAE,EAAE;;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC9C,MAAM,EACJ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,2BAA2B,GAC5B,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEhB,MAAM,YAAY,GAAG,eAAK,CAAC,OAAO,CAChC,GAAG,EAAE,CACH,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM;QACtB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAC7B,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC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AA,OAAO,CAAC,WAAW,mCAAI,yBAAyB,EAC7D,SAAS,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EACnD,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,EAC3D,QAAQ,EAAE,CAAC,KAAa,EAAE,YAAsB,EAAE,EAAE;gBAClD,cAAc,CAAC,KAAK,CAAC,CAAC;gBACtB,IAAI,CAAC,CAAC,KAAK,EAAE;oBACX,wBAAwB,CAAC,YAAY,CAAC,CAAC;iBACxC;qBAAM;oBACL,2BAA2B,EAAE,CAAC;iBAC/B;YACH,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;gBACX,mEAAmE;gBACnE,UAAU,CAAC,GAAG,EAAE,CAAC,2BAA2B,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;YAC5D,CAAC,EACD,OAAO,EAAE,GAAG,EAAE;gBACZ,2BAA2B,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC,EACD,UAAU,EAAE;gBACV,KAAK,EAAE,OAAO,CAAC,cAAc;aAC9B,IACE,OAAO,EACV,CAAA;KAAA,EACF;QACE,WAAW;QACX,cAAc;QACd,OAAO,CAAC,WAAW;QACnB,YAAY;QACZ,cAAc;QACd,wBAAwB;QACxB,2BAA2B;KAC5B,CACF,CAAC;AACJ,CAAC,CAAC;AA7FW,QAAA,0BAA0B,8BA6FrC","sourcesContent":["import React from \"react\";\nimport { useDebounceFn } from \"ahooks\";\n\nimport type { ConfigField } from \"../../types/config\";\n\nimport { useReactifySearchContext, useSearch, useAnalytics } from \"../../hooks\";\n\n// default field for when zero search fields have been configured in Reactify\nconst defaultSearchField: ConfigField = {\n id: \"title\",\n field: \"title\",\n importance: 0,\n searchType: \"instant_search\",\n};\n\nexport const useReactiveDataSearchProps = (options: {\n [key: string]: any;\n debounce?: number;\n placeholder?: string;\n inputClassName?: string;\n}) => {\n const { config } = useReactifySearchContext();\n const {\n searchQuery,\n submitSearch,\n setSearchQuery,\n setShowInstantSearchResults,\n } = useSearch();\n\n const searchFields = React.useMemo(\n () =>\n 0 < config.fields.length\n ? config.fields.filter((field) =>\n [\"always_search\", \"instant_search\"].includes(field.searchType)\n )\n : [defaultSearchField],\n []\n );\n\n const handleKeyPress = React.useCallback(\n (e) => {\n if (\"Enter\" !== e.key) return;\n submitSearch();\n },\n [submitSearch]\n );\n\n const { track } = useAnalytics();\n\n const trackQuery = React.useCallback(() => {\n if (!searchQuery || (searchQuery && searchQuery.length < 3)) return;\n track({ eventName: \"search\", payload: { searchTerm: searchQuery } });\n }, [searchQuery, track]);\n\n const { run: runDebouncedTriggerQuery, cancel: cancelDebouncedTriggerQuery } =\n useDebounceFn(\n (triggerQuery: () => void) => {\n triggerQuery();\n trackQuery();\n },\n {\n wait: options.debounce ?? 300,\n }\n );\n\n return React.useMemo(\n () => ({\n type: \"search\",\n showIcon: false,\n fuzziness: 1 as 0 | 1 | 2 | \"AUTO\",\n queryFormat: \"and\" as \"and\" | \"or\",\n autosuggest: false,\n value: searchQuery ?? \"\",\n onKeyUp: handleKeyPress,\n componentId: \"SearchInput\",\n placeholder: options.placeholder ?? \"Search for a product...\",\n dataField: searchFields.map((field) => field.field),\n fieldWeights: searchFields.map((field) => field.importance),\n onChange: (value: string, triggerQuery: () => {}) => {\n setSearchQuery(value);\n if (!!value) {\n runDebouncedTriggerQuery(triggerQuery);\n } else {\n cancelDebouncedTriggerQuery();\n }\n },\n onBlur: () => {\n // setTimeout ensures that results are still clickable before close\n setTimeout(() => setShowInstantSearchResults(false), 300);\n },\n onFocus: () => {\n setShowInstantSearchResults(true);\n },\n innerClass: {\n input: options.inputClassName,\n },\n ...options,\n }),\n [\n searchQuery,\n handleKeyPress,\n options.placeholder,\n searchFields,\n setSearchQuery,\n runDebouncedTriggerQuery,\n cancelDebouncedTriggerQuery,\n ]\n );\n};\n"]}
@@ -8,7 +8,7 @@ const react_1 = __importDefault(require("react"));
8
8
  const hooks_1 = require("../../hooks");
9
9
  const useReactiveReactProp_1 = require("./useReactiveReactProp");
10
10
  const useReactiveResultStackProps = (options) => {
11
- const filterStack = (0, hooks_1.useFilterStack)();
11
+ const { filterStack } = (0, hooks_1.useFilterStack)();
12
12
  const reactiveReactProp = (0, useReactiveReactProp_1.useReactiveReactProp)();
13
13
  const size = react_1.default.useMemo(() => {
14
14
  var _a, _b;
@@ -1 +1 @@
1
- {"version":3,"file":"useReactiveResultStackProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveResultStackProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAA6C;AAC7C,iEAA8D;AAEvD,MAAM,2BAA2B,GAAG,CAAC,OAE3C,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,IAAA,sBAAc,GAAE,CAAC;IACrC,MAAM,iBAAiB,GAAG,IAAA,2CAAoB,GAAE,CAAC;IAEjD,MAAM,IAAI,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QAC9B,OAAO,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,mCAAI,EAAE,CAAC;IACzD,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IAEpC,OAAO,eAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,IAAI;QACJ,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,OAAO;QAClB,eAAe,EAAE,KAAK;QACtB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,MAAM;QACnB,cAAc,EAAE,KAAK;QACrB,UAAU,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,MAAK,iBAAiB;QAC7D,cAAc,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,MAAK,iBAAiB;QACjE,eAAe,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,mDAAmD;KACjF,CAAC,EACF,CAAC,WAAW,EAAE,iBAAiB,EAAE,OAAO,CAAC,QAAQ,CAAC,CACnD,CAAC;AACJ,CAAC,CAAC;AA1BW,QAAA,2BAA2B,+BA0BtC","sourcesContent":["import React from \"react\";\n\nimport { useFilterStack } from \"../../hooks\";\nimport { useReactiveReactProp } from \"./useReactiveReactProp\";\n\nexport const useReactiveResultStackProps = (options: {\n pageSize?: number;\n}) => {\n const filterStack = useFilterStack();\n const reactiveReactProp = useReactiveReactProp();\n\n const size = React.useMemo(() => {\n return options.pageSize ?? filterStack?.pageSize ?? 20;\n }, [options.pageSize, filterStack]);\n\n return React.useMemo(\n () => ({\n size,\n URLParams: true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: reactiveReactProp,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: filterStack?.paginationType !== \"infinite_scroll\",\n infiniteScroll: filterStack?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n }),\n [filterStack, reactiveReactProp, options.pageSize]\n );\n};\n"]}
1
+ {"version":3,"file":"useReactiveResultStackProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveResultStackProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAA6C;AAC7C,iEAA8D;AAEvD,MAAM,2BAA2B,GAAG,CAAC,OAA8B,EAAE,EAAE;IAC5E,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,sBAAc,GAAE,CAAC;IACzC,MAAM,iBAAiB,GAAG,IAAA,2CAAoB,GAAE,CAAC;IAEjD,MAAM,IAAI,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QAC9B,OAAO,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,mCAAI,EAAE,CAAC;IACzD,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IAEpC,OAAO,eAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,IAAI;QACJ,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,OAAO;QAClB,eAAe,EAAE,KAAK;QACtB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,MAAM;QACnB,cAAc,EAAE,KAAK;QACrB,UAAU,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,MAAK,iBAAiB;QAC7D,cAAc,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,MAAK,iBAAiB;QACjE,eAAe,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,mDAAmD;KACjF,CAAC,EACF,CAAC,WAAW,EAAE,iBAAiB,EAAE,OAAO,CAAC,QAAQ,CAAC,CACnD,CAAC;AACJ,CAAC,CAAC;AAxBW,QAAA,2BAA2B,+BAwBtC","sourcesContent":["import React from \"react\";\n\nimport { useFilterStack } from \"../../hooks\";\nimport { useReactiveReactProp } from \"./useReactiveReactProp\";\n\nexport const useReactiveResultStackProps = (options: { pageSize?: number }) => {\n const { filterStack } = useFilterStack();\n const reactiveReactProp = useReactiveReactProp();\n\n const size = React.useMemo(() => {\n return options.pageSize ?? filterStack?.pageSize ?? 20;\n }, [options.pageSize, filterStack]);\n\n return React.useMemo(\n () => ({\n size,\n URLParams: true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: reactiveReactProp,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: filterStack?.paginationType !== \"infinite_scroll\",\n infiniteScroll: filterStack?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n }),\n [filterStack, reactiveReactProp, options.pageSize]\n );\n};\n"]}
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.useAnalytics = void 0;
16
16
  const axios_1 = __importDefault(require("axios"));
17
17
  const hooks_1 = require("../hooks");
18
+ const utility_1 = require("../utility");
18
19
  const useAnalytics = () => {
19
20
  const { options } = (0, hooks_1.useReactifySearchContext)();
20
21
  const url = "https://analytics.search.reactify.app/record/";
@@ -23,6 +24,7 @@ const useAnalytics = () => {
23
24
  console.warn(new Error('Unable to send tracking event, missing value for "shopifyPermanentDomain".'));
24
25
  return;
25
26
  }
27
+ utility_1.debug.log("useAnalytics", "track", event);
26
28
  const events = getTrackEvents(event);
27
29
  return axios_1.default.post(url, { events }, { headers: { "X-Reactify-Tenant": options.shopifyPermanentDomain } });
28
30
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useAnalytics.js","sourceRoot":"","sources":["../../../src/hooks/useAnalytics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,oCAAoD;AAE7C,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/C,MAAM,GAAG,GAAG,+CAA+C,CAAC;IAC5D,MAAM,KAAK,GAAG,CAAO,KAAiB,EAAE,EAAE;QACxC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE;YACnC,OAAO,CAAC,IAAI,CACV,IAAI,KAAK,CACP,4EAA4E,CAC7E,CACF,CAAC;YAEF,OAAO;SACR;QAED,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACrC,OAAO,eAAK,CAAC,IAAI,CACf,GAAG,EACH,EAAE,MAAM,EAAE,EACV,EAAE,OAAO,EAAE,EAAE,mBAAmB,EAAE,OAAO,CAAC,sBAAsB,EAAE,EAAE,CACrE,CAAC;IACJ,CAAC,CAAA,CAAC;IAEF,OAAO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,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;KACT;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import axios from \"axios\";\n\nimport { useReactifySearchContext } from \"../hooks\";\n\nexport const useAnalytics = () => {\n const { options } = useReactifySearchContext();\n const url = \"https://analytics.search.reactify.app/record/\";\n const track = async (event: TrackEvent) => {\n if (!options.shopifyPermanentDomain) {\n console.warn(\n new Error(\n 'Unable to send tracking event, missing value for \"shopifyPermanentDomain\".'\n )\n );\n\n return;\n }\n\n const events = getTrackEvents(event);\n return axios.post(\n url,\n { events },\n { headers: { \"X-Reactify-Tenant\": options.shopifyPermanentDomain } }\n );\n };\n\n return { track };\n};\n\nfunction getTrackEvents(event: TrackEvent): TrackEvent[] {\n const { eventName } = event;\n let events: TrackEvent[] = [];\n\n switch (eventName) {\n case \"search\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"zeroResults\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"viewProduct\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"clickProduct\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"viewPromotion\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"clickPromotion\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"paginationChange\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"sortChange\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"filterChange\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n }\n\n return events;\n}\n\nexport type TrackEvent =\n | TrackEvent.SearchEvent\n | TrackEvent.ZeroResultsEvent\n | TrackEvent.ViewProductEvent\n | TrackEvent.ClickProductEvent\n | TrackEvent.ViewPromotionEvent\n | TrackEvent.ClickPromotionEvent\n | TrackEvent.PaginationChangeEvent\n | TrackEvent.SortChangeEvent\n | TrackEvent.FilterChangeEvent;\n\nexport namespace TrackEvent {\n export interface SearchEvent {\n eventName: \"search\";\n payload: SearchEvent.Payload;\n }\n\n export namespace SearchEvent {\n export interface Payload {\n searchTerm: string;\n }\n }\n\n export interface ZeroResultsEvent {\n eventName: \"zeroResults\";\n payload: ZeroResultsEvent.Payload;\n }\n\n export namespace ZeroResultsEvent {\n export interface Payload {\n searchTerm: string;\n }\n }\n\n export interface ViewProductEvent {\n eventName: \"viewProduct\";\n payload: ViewProductEvent.Payload;\n }\n\n export namespace ViewProductEvent {\n export interface Payload {\n elasticProduct: ElasticProduct;\n }\n }\n\n export interface ClickProductEvent {\n eventName: \"clickProduct\";\n payload: ClickProductEvent.Payload;\n }\n\n export namespace ClickProductEvent {\n export interface Payload {\n elasticProduct: ElasticProduct;\n }\n }\n\n export interface ViewPromotionEvent {\n eventName: \"viewPromotion\";\n payload: ViewPromotionEvent.Payload;\n }\n\n export namespace ViewPromotionEvent {\n export interface Payload {\n link: string;\n title: string;\n }\n }\n\n export interface ClickPromotionEvent {\n eventName: \"clickPromotion\";\n payload: ClickPromotionEvent.Payload;\n }\n\n export namespace ClickPromotionEvent {\n export interface Payload {\n link: string;\n title: string;\n }\n }\n\n export interface PaginationChangeEvent {\n eventName: \"paginationChange\";\n payload: PaginationChangeEvent.Payload;\n }\n\n export namespace PaginationChangeEvent {\n export interface Payload {\n page: number;\n source: \"search\" | \"collection\";\n }\n }\n\n export interface SortChangeEvent {\n eventName: \"sortChange\";\n payload: SortChangeEvent.Payload;\n }\n\n export namespace SortChangeEvent {\n export interface Payload {\n type: string;\n }\n }\n\n export interface FilterChangeEvent {\n eventName: \"filterChange\";\n payload: FilterChangeEvent.Payload;\n }\n\n export namespace FilterChangeEvent {\n export interface Payload {\n name: string;\n value: string;\n }\n }\n\n export interface ElasticProduct {\n id: number;\n title: string;\n }\n}\n"]}
1
+ {"version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KAAK,aAAa;YAChB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,cAAc;YACjB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,eAAe;YAClB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,gBAAgB;YACnB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,kBAAkB;YACrB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,YAAY;YACf,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,cAAc;YACjB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;KACT;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import axios from \"axios\";\n\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useAnalytics = () => {\n const { options } = useReactifySearchContext();\n const url = \"https://analytics.search.reactify.app/record/\";\n const track = async (event: TrackEvent) => {\n if (!options.shopifyPermanentDomain) {\n console.warn(\n new Error(\n 'Unable to send tracking event, missing value for \"shopifyPermanentDomain\".'\n )\n );\n\n return;\n }\n\n debug.log(\"useAnalytics\", \"track\", event);\n\n const events = getTrackEvents(event);\n return axios.post(\n url,\n { events },\n { headers: { \"X-Reactify-Tenant\": options.shopifyPermanentDomain } }\n );\n };\n\n return { track };\n};\n\nfunction getTrackEvents(event: TrackEvent): TrackEvent[] {\n const { eventName } = event;\n let events: TrackEvent[] = [];\n\n switch (eventName) {\n case \"search\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"zeroResults\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"viewProduct\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"clickProduct\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"viewPromotion\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"clickPromotion\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"paginationChange\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"sortChange\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"filterChange\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n }\n\n return events;\n}\n\nexport type TrackEvent =\n | TrackEvent.SearchEvent\n | TrackEvent.ZeroResultsEvent\n | TrackEvent.ViewProductEvent\n | TrackEvent.ClickProductEvent\n | TrackEvent.ViewPromotionEvent\n | TrackEvent.ClickPromotionEvent\n | TrackEvent.PaginationChangeEvent\n | TrackEvent.SortChangeEvent\n | TrackEvent.FilterChangeEvent;\n\nexport namespace TrackEvent {\n export interface SearchEvent {\n eventName: \"search\";\n payload: SearchEvent.Payload;\n }\n\n export namespace SearchEvent {\n export interface Payload {\n searchTerm: string;\n }\n }\n\n export interface ZeroResultsEvent {\n eventName: \"zeroResults\";\n payload: ZeroResultsEvent.Payload;\n }\n\n export namespace ZeroResultsEvent {\n export interface Payload {\n searchTerm: string;\n }\n }\n\n export interface ViewProductEvent {\n eventName: \"viewProduct\";\n payload: ViewProductEvent.Payload;\n }\n\n export namespace ViewProductEvent {\n export interface Payload {\n elasticProduct: ElasticProduct;\n }\n }\n\n export interface ClickProductEvent {\n eventName: \"clickProduct\";\n payload: ClickProductEvent.Payload;\n }\n\n export namespace ClickProductEvent {\n export interface Payload {\n elasticProduct: ElasticProduct;\n }\n }\n\n export interface ViewPromotionEvent {\n eventName: \"viewPromotion\";\n payload: ViewPromotionEvent.Payload;\n }\n\n export namespace ViewPromotionEvent {\n export interface Payload {\n link: string;\n title: string;\n }\n }\n\n export interface ClickPromotionEvent {\n eventName: \"clickPromotion\";\n payload: ClickPromotionEvent.Payload;\n }\n\n export namespace ClickPromotionEvent {\n export interface Payload {\n link: string;\n title: string;\n }\n }\n\n export interface PaginationChangeEvent {\n eventName: \"paginationChange\";\n payload: PaginationChangeEvent.Payload;\n }\n\n export namespace PaginationChangeEvent {\n export interface Payload {\n page: number;\n source: \"search\" | \"collection\";\n }\n }\n\n export interface SortChangeEvent {\n eventName: \"sortChange\";\n payload: SortChangeEvent.Payload;\n }\n\n export namespace SortChangeEvent {\n export interface Payload {\n type: string;\n }\n }\n\n export interface FilterChangeEvent {\n eventName: \"filterChange\";\n payload: FilterChangeEvent.Payload;\n }\n\n export namespace FilterChangeEvent {\n export interface Payload {\n name: string;\n value: string;\n }\n }\n\n export interface ElasticProduct {\n id: number;\n title: string;\n }\n}\n"]}
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.useConfig = void 0;
16
16
  const react_1 = __importDefault(require("react"));
17
- const debug = require("debug")("reactify-search:useConfig");
17
+ const utility_1 = require("../utility");
18
18
  // 5 minute cache expiry
19
19
  const CACHE_EXPIRY = 5 * 60 * 1000;
20
20
  const useConfig = (shopifyPermanentDomain, configId) => {
@@ -24,23 +24,24 @@ const useConfig = (shopifyPermanentDomain, configId) => {
24
24
  if (typeof window === "undefined") {
25
25
  return;
26
26
  }
27
- debug("checking config cache");
27
+ utility_1.debug.log("useConfig", "checking config cache");
28
28
  // skip checking cache if url search param "nocache" is set
29
29
  const skipCache = new URLSearchParams(window.location.href.split("?")[1]).get("nocache") !==
30
30
  null;
31
31
  if (skipCache) {
32
- debug("config cache is disabled");
32
+ utility_1.debug.log("config cache is disabled");
33
33
  return;
34
34
  }
35
35
  const sessionConfig = JSON.parse((_a = window.sessionStorage.getItem("reactify-search:config")) !== null && _a !== void 0 ? _a : "null");
36
36
  if (sessionConfig) {
37
37
  const sessionConfigTtl = sessionConfig.expiresAt - Date.now();
38
38
  if (sessionConfigTtl > 0) {
39
- debug(`config cache valid, expires in ${(sessionConfigTtl / 1000).toFixed()} seconds`);
39
+ utility_1.debug.log("useConfig", `config cache valid, expires in ${(sessionConfigTtl / 1000).toFixed()} seconds`);
40
40
  return sessionConfig.config;
41
41
  }
42
42
  else {
43
- debug(`config cache invalid, expired ${((sessionConfigTtl * -1) / 1000).toFixed()} seconds ago`);
43
+ utility_1.debug.log("useConfig", `config cache invalid, expired ${((sessionConfigTtl * -1) /
44
+ 1000).toFixed()} seconds ago`);
44
45
  }
45
46
  }
46
47
  return;
@@ -51,7 +52,7 @@ const useConfig = (shopifyPermanentDomain, configId) => {
51
52
  return;
52
53
  }
53
54
  (() => __awaiter(void 0, void 0, void 0, function* () {
54
- debug("loading fresh config");
55
+ utility_1.debug.log("useConfig", "loading fresh config");
55
56
  const searchParams = new URLSearchParams();
56
57
  searchParams.set("shop", shopifyPermanentDomain);
57
58
  if (configId) {
@@ -63,7 +64,7 @@ const useConfig = (shopifyPermanentDomain, configId) => {
63
64
  }
64
65
  const json = yield fetch(`https://config.search.reactify.app/?${searchParams.toString()}`).then((response) => response.json());
65
66
  setConfig(json.body);
66
- debug("loaded fresh config");
67
+ utility_1.debug.log("useConfig", "loaded fresh config");
67
68
  window.sessionStorage.setItem("reactify-search:config", JSON.stringify({
68
69
  expiresAt: new Date().getTime() + CACHE_EXPIRY,
69
70
  noCache: skipCache,
@@ -72,7 +73,7 @@ const useConfig = (shopifyPermanentDomain, configId) => {
72
73
  }))();
73
74
  }, [shopifyPermanentDomain, configId]);
74
75
  react_1.default.useEffect(() => {
75
- debug("variable[config]", config);
76
+ utility_1.debug.log("useConfig", "config", config);
76
77
  }, [config]);
77
78
  return {
78
79
  config,
@@ -1 +1 @@
1
- {"version":3,"file":"useConfig.js","sourceRoot":"","sources":["../../../src/hooks/useConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,2BAA2B,CAAC,CAAC;AAE5D,wBAAwB;AACxB,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE5B,MAAM,SAAS,GAAG,CACvB,sBAA8B,EAC9B,QAAiB,EAGjB,EAAE;IAEF,2EAA2E;IAC3E,MAAM,YAAY,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QACtC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,OAAO;SACR;QACD,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAE/B,2DAA2D;QAC3D,MAAM,SAAS,GACb,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;YACtE,IAAI,CAAC;QACP,IAAI,SAAS,EAAE;YACb,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAElC,OAAO;SACR;QAED,MAAM,aAAa,GAGR,IAAI,CAAC,KAAK,CACnB,MAAA,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,wBAAwB,CAAC,mCAAI,MAAM,CAClE,CAAC;QAEF,IAAI,aAAa,EAAE;YACjB,MAAM,gBAAgB,GAAG,aAAa,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC9D,IAAI,gBAAgB,GAAG,CAAC,EAAE;gBACxB,KAAK,CAAC,kCAAkC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;YAErB,KAAK,CAAC,qBAAqB,CAAC,CAAC;YAE7B,MAAM,CAAC,cAAc,CAAC,OAAO,CAC3B,wBAAwB,EACxB,IAAI,CAAC,SAAS,CAAC;gBACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,YAAY;gBAC9C,OAAO,EAAE,SAAS;gBAClB,MAAM,EAAE,IAAI,CAAC,IAAI;aAClB,CAAC,CACH,CAAC;QACJ,CAAC,CAAA,CAAC,EAAE,CAAC;IACP,CAAC,EAAE,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEvC,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,KAAK,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO;QACL,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AAhGW,QAAA,SAAS,aAgGpB","sourcesContent":["import React from \"react\";\nimport { Config } from \"../types/config\";\n\nconst debug = require(\"debug\")(\"reactify-search:useConfig\");\n\n// 5 minute cache expiry\nconst CACHE_EXPIRY = 5 * 60 * 1000;\n\nexport const useConfig = (\n shopifyPermanentDomain: string,\n configId?: string\n): {\n config: Config | undefined;\n} => {\n\n // synchronously returns cached and non-expired config from session storage\n const cachedConfig = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n debug(\"checking config cache\");\n\n // skip checking cache if url search param \"nocache\" is set\n const skipCache =\n new URLSearchParams(window.location.href.split(\"?\")[1]).get(\"nocache\") !==\n null;\n if (skipCache) {\n debug(\"config cache is disabled\");\n\n return;\n }\n\n const sessionConfig: {\n expiresAt: number;\n config: Config;\n } | null = JSON.parse(\n window.sessionStorage.getItem(\"reactify-search:config\") ?? \"null\"\n );\n\n if (sessionConfig) {\n const sessionConfigTtl = sessionConfig.expiresAt - Date.now();\n if (sessionConfigTtl > 0) {\n debug(`config cache valid, expires in ${(sessionConfigTtl / 1000).toFixed()} seconds`);\n\n return sessionConfig.config;\n } else {\n debug(`config cache invalid, expired ${((sessionConfigTtl * -1) / 1000).toFixed()} seconds ago`);\n }\n }\n\n return;\n }, []);\n\n const [config, setConfig] = React.useState<Config | undefined>(cachedConfig);\n\n React.useEffect(() => {\n if (config) {\n return;\n }\n\n (async () => {\n debug(\"loading fresh config\");\n const searchParams = new URLSearchParams();\n searchParams.set(\"shop\", shopifyPermanentDomain);\n\n if (configId) {\n searchParams.set(\"id\", configId);\n }\n\n const skipCache =\n new URLSearchParams(window.location.href.split(\"?\")[1]).get(\n \"nocache\"\n ) !== null;\n\n if (skipCache) {\n searchParams.set(\"nocache\", \"true\");\n }\n\n const json = await fetch(\n `https://config.search.reactify.app/?${searchParams.toString()}`\n ).then((response) => response.json());\n\n setConfig(json.body);\n\n debug(\"loaded fresh config\");\n\n window.sessionStorage.setItem(\n \"reactify-search:config\",\n JSON.stringify({\n expiresAt: new Date().getTime() + CACHE_EXPIRY,\n noCache: skipCache,\n config: json.body,\n })\n );\n })();\n }, [shopifyPermanentDomain, configId]);\n\n React.useEffect(() => {\n debug(\"variable[config]\", config);\n }, [config]);\n\n return {\n config,\n };\n};\n"]}
1
+ {"version":3,"file":"useConfig.js","sourceRoot":"","sources":["../../../src/hooks/useConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,wCAAmC;AAEnC,wBAAwB;AACxB,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE5B,MAAM,SAAS,GAAG,CACvB,sBAA8B,EAC9B,QAAiB,EAGjB,EAAE;IACF,2EAA2E;IAC3E,MAAM,YAAY,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QACtC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,OAAO;SACR;QACD,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;QAEhD,2DAA2D;QAC3D,MAAM,SAA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AA1GW,QAAA,SAAS,aA0GpB","sourcesContent":["import React from \"react\";\n\nimport { Config } from \"../types/config\";\nimport { debug } from \"../utility\";\n\n// 5 minute cache expiry\nconst CACHE_EXPIRY = 5 * 60 * 1000;\n\nexport const useConfig = (\n shopifyPermanentDomain: string,\n configId?: string\n): {\n config: Config | undefined;\n} => {\n // synchronously returns cached and non-expired config from session storage\n const cachedConfig = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n debug.log(\"useConfig\", \"checking config cache\");\n\n // skip checking cache if url search param \"nocache\" is set\n const skipCache =\n new URLSearchParams(window.location.href.split(\"?\")[1]).get(\"nocache\") !==\n null;\n if (skipCache) {\n debug.log(\"config cache is disabled\");\n\n return;\n }\n\n const sessionConfig: {\n expiresAt: number;\n config: Config;\n } | null = JSON.parse(\n window.sessionStorage.getItem(\"reactify-search:config\") ?? \"null\"\n );\n\n if (sessionConfig) {\n const sessionConfigTtl = sessionConfig.expiresAt - Date.now();\n if (sessionConfigTtl > 0) {\n debug.log(\n \"useConfig\",\n `config cache valid, expires in ${(\n sessionConfigTtl / 1000\n ).toFixed()} seconds`\n );\n\n return sessionConfig.config;\n } else {\n debug.log(\n \"useConfig\",\n `config cache invalid, expired ${(\n (sessionConfigTtl * -1) /\n 1000\n ).toFixed()} seconds ago`\n );\n }\n }\n\n return;\n }, []);\n\n const [config, setConfig] = React.useState<Config | undefined>(cachedConfig);\n\n React.useEffect(() => {\n if (config) {\n return;\n }\n\n (async () => {\n debug.log(\"useConfig\", \"loading fresh config\");\n const searchParams = new URLSearchParams();\n searchParams.set(\"shop\", shopifyPermanentDomain);\n\n if (configId) {\n searchParams.set(\"id\", configId);\n }\n\n const skipCache =\n new URLSearchParams(window.location.href.split(\"?\")[1]).get(\n \"nocache\"\n ) !== null;\n\n if (skipCache) {\n searchParams.set(\"nocache\", \"true\");\n }\n\n const json = await fetch(\n `https://config.search.reactify.app/?${searchParams.toString()}`\n ).then((response) => response.json());\n\n setConfig(json.body);\n\n debug.log(\"useConfig\", \"loaded fresh config\");\n\n window.sessionStorage.setItem(\n \"reactify-search:config\",\n JSON.stringify({\n expiresAt: new Date().getTime() + CACHE_EXPIRY,\n noCache: skipCache,\n config: json.body,\n })\n );\n })();\n }, [shopifyPermanentDomain, configId]);\n\n React.useEffect(() => {\n debug.log(\"useConfig\", \"config\", config);\n }, [config]);\n\n return {\n config,\n };\n};\n"]}
@@ -6,11 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useCuration = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const hooks_1 = require("../hooks");
9
+ const utility_1 = require("../utility");
9
10
  const useCuration = () => {
10
11
  const { options, config } = (0, hooks_1.useReactifySearchContext)();
11
12
  const { searchQuery } = (0, hooks_1.useSearch)();
12
- return react_1.default.useMemo(() => {
13
- const handleOrSearchTerm = options.mode === "collection" ? options.collection ? options.collection.handle : searchQuery : "";
13
+ const curation = react_1.default.useMemo(() => {
14
+ const handleOrSearchTerm = options.mode === "collection"
15
+ ? options.collection
16
+ ? options.collection.handle
17
+ : searchQuery
18
+ : "";
14
19
  const normalisedHandleOrSearchTerm = handleOrSearchTerm
15
20
  .toLowerCase()
16
21
  .trim();
@@ -47,7 +52,15 @@ const useCuration = () => {
47
52
  : globalCuration
48
53
  ? globalCuration
49
54
  : undefined;
50
- }, [config, options.mode === "collection" ? options.collection : undefined, searchQuery]);
55
+ }, [
56
+ config,
57
+ options.mode === "collection" ? options.collection : undefined,
58
+ searchQuery,
59
+ ]);
60
+ react_1.default.useEffect(() => {
61
+ utility_1.debug.log("useCuration", "curation", curation);
62
+ }, [curation]);
63
+ return curation;
51
64
  };
52
65
  exports.useCuration = useCuration;
53
66
  //# sourceMappingURL=useCuration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCuration.js","sourceRoot":"","sources":["../../../src/hooks/useCuration.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAA+D;AAExD,MAAM,WAAW,GAAG,G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AK,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,MAAM,iBAAiB,GAAG,CAAC,QAAwB,EAAE,EAAE;YACrD,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC;YAC5D,IAAI,CAAC,oBAAoB,EAAE;gBACzB,OAAO,QAAQ,CAAC;aACjB;YAED,MAAM,gBAAgB,GACpB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM;gBACpC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAEtC,IAAI,gBAAgB,IAAI,CAAC,cAAc,EAAE;gBACvC,OAAO,QAAQ,CAAC;aACjB;YAED,MAAM,0BAA0B,GAAG,gCAC9B,QAAQ,KACX,QAAQ,EAAE,cAAc,CAAC,QAAQ,GAChB,CAAC;YAEpB,OAAO,0BAA0B,CAAC;QACpC,CAAC,CAAC;QAEF,OAAO,QAAQ;YACb,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC;YAC7B,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;AAC5F,CAAC,CAAA;AAlEY,QAAA,WAAW,eAkEvB","sourcesContent":["import React from \"react\";\n\nimport { ConfigCuration } from \"../types\";\nimport { useReactifySearchContext, useSearch } from \"../hooks\";\n\nexport const useCuration = (): ConfigCuration | undefined => {\n\tconst { options, config } = useReactifySearchContext();\n const { searchQuery } = useSearch();\n\n\treturn React.useMemo(() => {\n const handleOrSearchTerm = options.mode === \"collection\" ? options.collection ? options.collection.handle : searchQuery : \"\";\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = config.curations.find(\n (curation) => curation.id === \"global\" && curation.type === options.mode\n );\n\n const curation = config.curations.find((curation) => {\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n const curationIsCollection = curation.type === \"collection\";\n if (!curationIsCollection) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules || !globalCuration) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n return curation\n ? addGlobalBoosting(curation)\n : globalCuration\n ? globalCuration\n : undefined;\n }, [config, options.mode === \"collection\" ? options.collection : undefined, searchQuery]);\n}\n"]}
1
+ {"version":3,"file":"useCuration.js","sourceRoot":"","sources":["../../../src/hooks/useCuration.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAA+D;AAC/D,wCAAmC;AAE5B,MAAM,WAAW,GAAG,GAA+B,EAAE;IAC1D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEpC,MAAM,QAAQ,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,MAAM,kBAAkB,GACtB,OAAO,CAAC,IAAI,KAAK,YAAY;YAC3B,CAAC,CAAC,OAAO,CAAC,UAAU;gBAClB,CAAC,CAAC,OAAO,CAAC,UAA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AC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAEtC,IAAI,gBAAgB,IAAI,CAAC,cAAc,EAAE;gBACvC,OAAO,QAAQ,CAAC;aACjB;YAED,MAAM,0BAA0B,GAAG,gCAC9B,QAAQ,KACX,QAAQ,EAAE,cAAc,CAAC,QAAQ,GAChB,CAAC;YAEpB,OAAO,0BAA0B,CAAC;QACpC,CAAC,CAAC;QAEF,OAAO,QAAQ;YACb,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC;YAC7B,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC,EAAE;QACD,MAAM;QACN,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;QAC9D,WAAW;KACZ,CAAC,CAAC;IAEH,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAjFW,QAAA,WAAW,eAiFtB","sourcesContent":["import React from \"react\";\n\nimport { ConfigCuration } from \"../types\";\nimport { useReactifySearchContext, useSearch } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useCuration = (): ConfigCuration | undefined => {\n const { options, config } = useReactifySearchContext();\n const { searchQuery } = useSearch();\n\n const curation = React.useMemo(() => {\n const handleOrSearchTerm =\n options.mode === \"collection\"\n ? options.collection\n ? options.collection.handle\n : searchQuery\n : \"\";\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = config.curations.find(\n (curation) => curation.id === \"global\" && curation.type === options.mode\n );\n\n const curation = config.curations.find((curation) => {\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n const curationIsCollection = curation.type === \"collection\";\n if (!curationIsCollection) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules || !globalCuration) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n return curation\n ? addGlobalBoosting(curation)\n : globalCuration\n ? globalCuration\n : undefined;\n }, [\n config,\n options.mode === \"collection\" ? options.collection : undefined,\n searchQuery,\n ]);\n\n React.useEffect(() => {\n debug.log(\"useCuration\", \"curation\", curation);\n }, [curation]);\n\n return curation;\n};\n"]}
@@ -0,0 +1 @@
1
+ export declare const useDebugger: (namespace: string, message: string, value: unknown) => void;
@@ -0,0 +1,15 @@
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.useDebugger = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const utility_1 = require("../utility");
9
+ const useDebugger = (namespace, message, value) => {
10
+ react_1.default.useEffect(() => {
11
+ utility_1.debug.log(namespace, message, value);
12
+ }, [value]);
13
+ };
14
+ exports.useDebugger = useDebugger;
15
+ //# sourceMappingURL=useDebugger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebugger.js","sourceRoot":"","sources":["../../../src/hooks/useDebugger.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,wCAAmC;AAE5B,MAAM,WAAW,GAAG,CACzB,SAAiB,EACjB,OAAe,EACf,KAAc,EACd,EAAE;IACF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACd,CAAC,CAAC;AARW,QAAA,WAAW,eAQtB","sourcesContent":["import React from \"react\";\n\nimport { debug } from \"../utility\";\n\nexport const useDebugger = (\n namespace: string,\n message: string,\n value: unknown\n) => {\n React.useEffect(() => {\n debug.log(namespace, message, value);\n }, [value]);\n};\n"]}
@@ -1,2 +1,4 @@
1
1
  import { ConfigFilter } from "../types";
2
- export declare const useFilterStack: () => ConfigFilter | undefined;
2
+ export declare const useFilterStack: () => {
3
+ filterStack?: ConfigFilter | undefined;
4
+ };