@usereactify/search 5.25.0 → 5.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/package.json +11 -10
  3. package/dist/src/components/ClearAll/ClearAll.js +3 -31
  4. package/dist/src/components/ClearAll/ClearAll.js.map +1 -1
  5. package/dist/src/components/Example/ExampleFilterRange.js +1 -3
  6. package/dist/src/components/Example/ExampleFilterRange.js.map +1 -1
  7. package/dist/src/components/Example/ExampleFilterSlider.js +7 -24
  8. package/dist/src/components/Example/ExampleFilterSlider.js.map +1 -1
  9. package/dist/src/components/Example/ExampleFilters.d.ts +3 -1
  10. package/dist/src/components/Example/ExampleFilters.js +4 -8
  11. package/dist/src/components/Example/ExampleFilters.js.map +1 -1
  12. package/dist/src/components/Example/ExampleFiltersSelected.js +10 -24
  13. package/dist/src/components/Example/ExampleFiltersSelected.js.map +1 -1
  14. package/dist/src/components/Example/index.d.ts +0 -3
  15. package/dist/src/components/Example/index.js +0 -3
  16. package/dist/src/components/Example/index.js.map +1 -1
  17. package/dist/src/components/Filter/Filter.d.ts +2 -2
  18. package/dist/src/components/Filter/Filter.js +18 -91
  19. package/dist/src/components/Filter/Filter.js.map +1 -1
  20. package/dist/src/components/Filter/Filters.d.ts +3 -17
  21. package/dist/src/components/Filter/Filters.js +2 -1
  22. package/dist/src/components/Filter/Filters.js.map +1 -1
  23. package/dist/src/components/Filter/FiltersSelected.d.ts +2 -7
  24. package/dist/src/components/Filter/FiltersSelected.js +2 -45
  25. package/dist/src/components/Filter/FiltersSelected.js.map +1 -1
  26. package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.d.ts +7 -5
  27. package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js +24 -42
  28. package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -1
  29. package/dist/src/components/Result/Results.js +9 -24
  30. package/dist/src/components/Result/Results.js.map +1 -1
  31. package/dist/src/components/Sensor/SensorCollection.js +0 -4
  32. package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
  33. package/dist/src/components/Sensor/SensorInventoryAvailable.js +1 -6
  34. package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -1
  35. package/dist/src/components/Sensor/SensorPublished.js +6 -13
  36. package/dist/src/components/Sensor/SensorPublished.js.map +1 -1
  37. package/dist/src/components/Sensor/SensorSearchTerm.js +66 -78
  38. package/dist/src/components/Sensor/SensorSearchTerm.js.map +1 -1
  39. package/dist/src/components/Sensor/SensorSort.js +65 -75
  40. package/dist/src/components/Sensor/SensorSort.js.map +1 -1
  41. package/dist/src/components/Sensor/SensorSortScore.d.ts +2 -0
  42. package/dist/src/components/Sensor/SensorSortScore.js +13 -0
  43. package/dist/src/components/Sensor/SensorSortScore.js.map +1 -0
  44. package/dist/src/components/Sensor/index.d.ts +1 -0
  45. package/dist/src/components/Sensor/index.js +2 -0
  46. package/dist/src/components/Sensor/index.js.map +1 -1
  47. package/dist/src/components/index.d.ts +0 -1
  48. package/dist/src/components/index.js +0 -1
  49. package/dist/src/components/index.js.map +1 -1
  50. package/dist/src/hooks/index.d.ts +0 -3
  51. package/dist/src/hooks/index.js +0 -3
  52. package/dist/src/hooks/index.js.map +1 -1
  53. package/dist/src/hooks/reactivesearch/useReactiveBaseProps.d.ts +7 -2
  54. package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +3 -10
  55. package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js.map +1 -1
  56. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +27 -0
  57. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +71 -0
  58. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js.map +1 -0
  59. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +0 -1
  60. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +5 -3
  61. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js.map +1 -1
  62. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +0 -1
  63. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +5 -3
  64. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +1 -1
  65. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +1 -1
  66. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js.map +1 -1
  67. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +3 -1
  68. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +1 -1
  69. package/dist/src/hooks/reactivesearch/useReactiveReactProp.d.ts +1 -2
  70. package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +3 -8
  71. package/dist/src/hooks/reactivesearch/useReactiveReactProp.js.map +1 -1
  72. package/dist/src/hooks/useAnalytics.js +3 -23
  73. package/dist/src/hooks/useAnalytics.js.map +1 -1
  74. package/dist/src/hooks/useConfig.js +27 -9
  75. package/dist/src/hooks/useConfig.js.map +1 -1
  76. package/dist/src/hooks/useCuration.js +1 -12
  77. package/dist/src/hooks/useCuration.js.map +1 -1
  78. package/dist/src/hooks/useFilterListProps.js +2 -15
  79. package/dist/src/hooks/useFilterListProps.js.map +1 -1
  80. package/dist/src/hooks/useFilterRangeProps.d.ts +10 -1
  81. package/dist/src/hooks/useFilterRangeProps.js +47 -36
  82. package/dist/src/hooks/useFilterRangeProps.js.map +1 -1
  83. package/dist/src/hooks/useFilterSliderProps.d.ts +8 -6
  84. package/dist/src/hooks/useFilterSliderProps.js +10 -31
  85. package/dist/src/hooks/useFilterSliderProps.js.map +1 -1
  86. package/dist/src/hooks/usePaginationLoadMore.d.ts +15 -0
  87. package/dist/src/hooks/usePaginationLoadMore.js +38 -0
  88. package/dist/src/hooks/usePaginationLoadMore.js.map +1 -0
  89. package/dist/src/hooks/useReactifySearchContext.d.ts +11 -19
  90. package/dist/src/hooks/useReactifySearchContext.js.map +1 -1
  91. package/dist/src/hooks/useSearch.js +2 -4
  92. package/dist/src/hooks/useSearch.js.map +1 -1
  93. package/dist/src/types/config.d.ts +5 -11
  94. package/dist/src/types/config.js.map +1 -1
  95. package/dist/src/types/elastic.d.ts +17 -53
  96. package/dist/src/types/elastic.js.map +1 -1
  97. package/dist/src/types/firestore.d.ts +0 -3
  98. package/dist/src/types/firestore.js.map +1 -1
  99. package/dist/src/types/reactivesearch.d.ts +1 -1
  100. package/dist/src/types/reactivesearch.js.map +1 -1
  101. package/package.json +1 -1
  102. package/dist/src/components/Example/ExampleHookUseResults.d.ts +0 -2
  103. package/dist/src/components/Example/ExampleHookUseResults.js +0 -25
  104. package/dist/src/components/Example/ExampleHookUseResults.js.map +0 -1
  105. package/dist/src/components/Example/ExampleSuggestions.d.ts +0 -4
  106. package/dist/src/components/Example/ExampleSuggestions.js +0 -16
  107. package/dist/src/components/Example/ExampleSuggestions.js.map +0 -1
  108. package/dist/src/components/Suggestions/Suggestions.d.ts +0 -12
  109. package/dist/src/components/Suggestions/Suggestions.js +0 -44
  110. package/dist/src/components/Suggestions/Suggestions.js.map +0 -1
  111. package/dist/src/components/Suggestions/index.d.ts +0 -1
  112. package/dist/src/components/Suggestions/index.js +0 -14
  113. package/dist/src/components/Suggestions/index.js.map +0 -1
  114. package/dist/src/hooks/react-slider/useReactSliderProps.d.ts +0 -4
  115. package/dist/src/hooks/react-slider/useReactSliderProps.js +0 -28
  116. package/dist/src/hooks/react-slider/useReactSliderProps.js.map +0 -1
  117. package/dist/src/hooks/useFlags.d.ts +0 -17
  118. package/dist/src/hooks/useFlags.js +0 -45
  119. package/dist/src/hooks/useFlags.js.map +0 -1
  120. package/dist/src/hooks/useIndices.d.ts +0 -5
  121. package/dist/src/hooks/useIndices.js +0 -49
  122. package/dist/src/hooks/useIndices.js.map +0 -1
  123. package/dist/src/hooks/useResults.d.ts +0 -21
  124. package/dist/src/hooks/useResults.js +0 -19
  125. package/dist/src/hooks/useResults.js.map +0 -1
@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AO,CAAC,MAAM,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,gBAAgB,EAAE;QACpB,MAAM,SAAS,GAAG,gBAAgB,CAAC;QACnC,OAAO,CACL,8BAAC,SAAS,kBACR,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;KACH;IAED,OAAO,CACL,8BAAC,8BAAiB,kBAChB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\nimport MultiList from \"@appbaseio/reactivesearch/lib/components/list/MultiList\";\nimport SingleList from \"@appbaseio/reactivesearch/lib/components/list/SingleList\";\nimport SingleRange from \"@appbaseio/reactivesearch/lib/components/range/SingleRange\";\nimport MultiRange from \"@appbaseio/reactivesearch/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterOption,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useReactiveFilterListProps,\n useReactiveFilterRangeProps,\n useReactiveFilterSharedProps,\n useReactiveFilterSliderProps,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterOption;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterOption;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterOption;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterOption;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n // reactSliderProps: ReturnType<typeof useReactSliderProps>;\n }>;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.warn(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <SingleList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <MultiList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactiveFilterRangeProps = useReactiveFilterRangeProps(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...reactiveFilterRangeProps}\n value={filterRangeProps.values[0]}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactiveFilterRangeProps = useReactiveFilterRangeProps(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...reactiveFilterRangeProps}\n value={filterRangeProps.values}\n // @note: onChange handler must be defined for controlled component to work correctly\n onChange={() => {}}\n onValueChange={(values) => {\n if (values.length === 0) {\n filterRangeProps.handleClear();\n }\n }}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactiveFilterSharedProps = useReactiveFilterSharedProps(props.filter);\n\n return (\n <ReactiveComponent\n {...reactiveFilterSharedProps}\n defaultQuery={() => ({\n aggs: {\n min: {\n min: {\n field: props.filter.field,\n },\n },\n max: {\n max: {\n field: props.filter.field,\n },\n },\n },\n })}\n render={(reactivesearchFilterProps) => {\n if (\n reactivesearchFilterProps?.aggregations?.min?.value ===\n reactivesearchFilterProps?.aggregations?.max?.value\n ) {\n return null;\n }\n\n return (\n <FilterSliderInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n );\n }}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterSliderInner: React.FC<\n FilterProps & { reactivesearchFilterProps: any }\n> = (props) => {\n const {\n filter,\n renderFilterSlider,\n reactivesearchFilterProps,\n ...otherProps\n } = props;\n\n const filterSliderProps = useFilterSliderProps(filter);\n\n React.useEffect(() => {\n if (reactivesearchFilterProps.aggregations) {\n filterSliderProps.handleRange([\n reactivesearchFilterProps.aggregations.min.value,\n reactivesearchFilterProps.aggregations.max.value,\n ]);\n }\n }, [\n reactivesearchFilterProps.aggregations?.min.value,\n reactivesearchFilterProps.aggregations?.max.value,\n ]);\n\n React.useEffect(() => {\n if (filterSliderProps.value[0] === 0 && filterSliderProps.value[1] === 0) {\n return;\n }\n\n props.reactivesearchFilterProps.setQuery({\n query: {\n query: {\n bool: {\n must: [\n {\n bool: {\n must: [\n {\n match: {\n published: true,\n },\n },\n {\n range: {\n [props.filter.field]: {\n gte: filterSliderProps.value[0],\n lte: filterSliderProps.value[1],\n boost: 2,\n },\n },\n },\n ],\n },\n },\n ],\n },\n },\n },\n value: filterSliderProps.value,\n });\n }, [filterSliderProps.value]);\n\n if (renderFilterSlider) {\n const Component = renderFilterSlider;\n return (\n <Component\n filterSliderProps={filterSliderProps}\n filter={filter}\n {...otherProps}\n />\n );\n }\n\n return (\n <ExampleFilterSlider\n filterSliderProps={filterSliderProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (0 === filterListProps.options.length) {\n return null;\n }\n\n if (renderFilterList) {\n const Component = renderFilterList;\n return (\n <Component\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n }\n\n return (\n <ExampleFilterList\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,wGAAgF;AAChF,0GAAkF;AAClF,2HAAmG;AACnG,6GAAqF;AACrF,2GAAmF;AAMnF,uCAQqB;AACrB,iDAI0B;AAwBnB,MAAM,MAAM,GAA0B,CAAC,KAAK,EAAE,EAAE;IACrD,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACzC,IAAI,OAAO,KAAK,KAAK,CAAC,M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kB,EAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IAE9E,+CAA+C;IAC/C,IAAI,CAAC,KAAK,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,gBAAgB,EAAE;QACpB,MAAM,SAAS,GAAG,gBAAgB,CAAC;QACnC,OAAO,CACL,8BAAC,SAAS,kBACR,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;KACH;IAED,OAAO,CACL,8BAAC,8BAAiB,kBAChB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport MultiList from \"@appbaseio/reactivesearch/lib/components/list/MultiList\";\nimport SingleList from \"@appbaseio/reactivesearch/lib/components/list/SingleList\";\nimport DynamicRangeSlider from \"@appbaseio/reactivesearch/lib/components/range/DynamicRangeSlider\";\nimport SingleRange from \"@appbaseio/reactivesearch/lib/components/range/SingleRange\";\nimport MultiRange from \"@appbaseio/reactivesearch/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterOption,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useFilterRangeMultiProps,\n useReactiveFilterListProps,\n useReactiveFilterRangeProps,\n useReactiveFilterSliderProps,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterOption;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterOption;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterOption;\n filterRangeProps:\n | ReturnType<typeof useFilterRangeProps>\n | ReturnType<typeof useFilterRangeMultiProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterOption;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n }>;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.log(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <SingleList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <MultiList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactiveFilterRangeProps = useReactiveFilterRangeProps(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...reactiveFilterRangeProps}\n value={filterRangeProps.value}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactiveFilterRangeProps = useReactiveFilterRangeProps(props.filter);\n\n const filterRangeProps = useFilterRangeMultiProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...reactiveFilterRangeProps}\n value={filterRangeProps.values}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactiveFilterSliderProps = useReactiveFilterSliderProps(props.filter);\n\n const filterSliderProps = useFilterSliderProps(props.filter);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <>\n {props.renderFilterSlider ? (\n <div\n style={{\n display: \"none\",\n }}\n >\n <DynamicRangeSlider\n {...reactiveFilterSliderProps}\n value={() => filterSliderProps.value}\n onChange={(value) =>\n filterSliderProps.handleChange({\n start: value[0],\n end: value[1],\n })\n }\n />\n </div>\n ) : null}\n <RenderSliderComponent\n filterSliderProps={filterSliderProps}\n filter={props.filter}\n />\n </>\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (0 === filterListProps.options.length) {\n return null;\n }\n\n if (renderFilterList) {\n const Component = renderFilterList;\n return (\n <Component\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n }\n\n return (\n <ExampleFilterList\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
@@ -1,21 +1,7 @@
1
1
  import React from "react";
2
- import { useFilterListProps, useFilterRangeProps, useFilterSliderProps } from "../../hooks";
3
- import { ConfigFilterOption } from "../../types";
2
+ import { useFilters } from "../../hooks";
4
3
  export declare type FiltersProps = {
5
- /** Render method for List filters */
6
- renderFilterList?: React.FC<{
7
- filter: ConfigFilterOption;
8
- filterListProps: ReturnType<typeof useFilterListProps>;
9
- }>;
10
- /** Render method for Range filters */
11
- renderFilterRange?: React.FC<{
12
- filter: ConfigFilterOption;
13
- filterRangeProps: ReturnType<typeof useFilterRangeProps>;
14
- }>;
15
- /** Render method for Slider filters */
16
- renderFilterSlider?: React.FC<{
17
- filter: ConfigFilterOption;
18
- filterSliderProps: ReturnType<typeof useFilterSliderProps>;
19
- }>;
4
+ /** Render method called once for all filters */
5
+ render?: React.FC<ReturnType<typeof useFilters>>;
20
6
  };
21
7
  export declare const Filters: React.FC<FiltersProps>;
@@ -10,7 +10,8 @@ const components_1 = require("../../components");
10
10
  const Filters = (props) => {
11
11
  var _a;
12
12
  const filterStackHook = (0, hooks_1.useFilters)();
13
- return (react_1.default.createElement(react_1.default.Fragment, null, (_a = filterStackHook.filters) === null || _a === void 0 ? void 0 : _a.map((filter) => (react_1.default.createElement(components_1.Filter, { key: filter.id, filter: filter, renderFilterList: props.renderFilterList, renderFilterSlider: props.renderFilterSlider, renderFilterRange: props.renderFilterRange })))));
13
+ const RenderComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleFilters;
14
+ return react_1.default.createElement(RenderComponent, Object.assign({}, filterStackHook));
14
15
  };
15
16
  exports.Filters = Filters;
16
17
  //# sourceMappingURL=Filters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Filters.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filters.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAKqB;AACrB,iDAA0C;AAqBnC,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;;IACvD,MAAM,eAAe,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,OAAO,CACL,8DACG,MAAA,eAAe,CAAC,OAAO,0CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACxC,8BAAC,mBAAM,IACL,GAAG,EAAE,MAAM,CAAC,EAAE,EACd,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EACxC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,GAC1C,CACH,CAAC,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,OAAO,WAgBlB","sourcesContent":["import React from \"react\";\n\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilters,\n useFilterSliderProps,\n} from \"../../hooks\";\nimport { Filter } from \"../../components\";\nimport { ConfigFilterOption } from \"../../types\";\n\nexport type FiltersProps = {\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterOption;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterOption;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterOption;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n }>;\n};\n\nexport const Filters: React.FC<FiltersProps> = (props) => {\n const filterStackHook = useFilters();\n\n return (\n <>\n {filterStackHook.filters?.map((filter) => (\n <Filter\n key={filter.id}\n filter={filter}\n renderFilterList={props.renderFilterList}\n renderFilterSlider={props.renderFilterSlider}\n renderFilterRange={props.renderFilterRange}\n />\n ))}\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"Filters.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filters.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAAyC;AACzC,iDAAkD;AAO3C,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;;IACvD,MAAM,eAAe,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,2BAAc,CAAC;IAEvD,OAAO,8BAAC,eAAe,oBAAK,eAAe,EAAI,CAAC;AAClD,CAAC,CAAC;AANW,QAAA,OAAO,WAMlB","sourcesContent":["import React from \"react\";\n\nimport { useFilters } from \"../../hooks\";\nimport { ExampleFilters } from \"../../components\";\n\nexport type FiltersProps = {\n /** Render method called once for all filters */\n render?: React.FC<ReturnType<typeof useFilters>>;\n};\n\nexport const Filters: React.FC<FiltersProps> = (props) => {\n const filterStackHook = useFilters();\n\n const RenderComponent = props.render ?? ExampleFilters;\n\n return <RenderComponent {...filterStackHook} />;\n};\n"]}
@@ -6,16 +6,11 @@ export declare type FiltersSelectedProps = {
6
6
  key: string;
7
7
  label: string;
8
8
  value: Array<string> | string | {
9
- label: string;
10
9
  start: number;
11
10
  end: number;
12
- } | Array<{
13
- label: string;
14
- start: number;
15
- end: number;
16
- }>;
11
+ };
17
12
  }>;
18
- handleRemove: (filterKey: string, filterValues?: Array<string | number>) => void;
13
+ handleRemove: (filterKey: string) => void;
19
14
  }>;
20
15
  };
21
16
  export declare const FiltersSelected: React.FC<FiltersSelectedProps>;
@@ -7,10 +7,8 @@ exports.FiltersSelected = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const SelectedFilters_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/SelectedFilters"));
9
9
  const components_1 = require("../../components");
10
- const hooks_1 = require("../../hooks");
11
10
  const FiltersSelected = (props) => {
12
11
  var _a;
13
- const filtersHook = (0, hooks_1.useFilters)();
14
12
  const RenderComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleFiltersSelected;
15
13
  return (react_1.default.createElement(SelectedFilters_1.default, { render: ({ selectedValues, setValue }) => {
16
14
  const selectedFilters = Object.entries(selectedValues)
@@ -25,49 +23,8 @@ const FiltersSelected = (props) => {
25
23
  label: item.label,
26
24
  value: item.value,
27
25
  }));
28
- const handleRemove = (selectedFilterKey, selectedFilterValues = []) => {
29
- var _a;
30
- const filter = (_a = filtersHook.filters) === null || _a === void 0 ? void 0 : _a.find((filter) => filter.handle === selectedFilterKey);
31
- if (!filter) {
32
- return;
33
- }
34
- if (filter.displayType === "slider") {
35
- const event = new CustomEvent(`@usereactify/search:filter:${filter.handle}:update`, {
36
- detail: {
37
- handle: filter.handle,
38
- value: [],
39
- },
40
- });
41
- window.dispatchEvent(event);
42
- return;
43
- }
44
- if (selectedFilterValues.length === 0) {
45
- setValue(selectedFilterKey, null);
46
- return;
47
- }
48
- if (selectedFilterValues.length > 0) {
49
- if (filter.displayType === "single") {
50
- setValue(selectedFilterKey, null);
51
- }
52
- if (filter.displayType === "multi") {
53
- if (filter.displayView === "range") {
54
- const values = selectedValues[selectedFilterKey].value
55
- .filter((value) => !selectedFilterValues.includes(value.label))
56
- .map((value) => value.label);
57
- const event = new CustomEvent(`@usereactify/search:filter:${filter.handle}:update`, {
58
- detail: {
59
- handle: filter.handle,
60
- value: values,
61
- },
62
- });
63
- window.dispatchEvent(event);
64
- }
65
- if (filter.displayView !== "range") {
66
- const values = selectedValues[selectedFilterKey].value.filter((value) => !selectedFilterValues.includes(value));
67
- setValue(selectedFilterKey, values);
68
- }
69
- }
70
- }
26
+ const handleRemove = (selectedFilterKey) => {
27
+ setValue(selectedFilterKey, null);
71
28
  };
72
29
  if (!selectedFilters.length) {
73
30
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"FiltersSelected.js","sourceRoot":"","sources":["../../../../src/components/Filter/FiltersSelected.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,qHAA6F;AAE7F,iDAA0D;AAC1D,uCAAyC;AAqBlC,MAAM,eAAe,GAAmC,CAAC,KAAK,EAAE,EAAE;;IACvE,MAAM,WAAW,GAAG,IAAA,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AE,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzD,CAAC;4BACF,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;yBACrC;qBACF;iBACF;YACH,CAAC,CAAC;YAEF,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;gBAC3B,OAAO,IAAI,CAAC;aACb;YAED,OAAO,CACL,8BAAC,eAAe,IACd,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GAC1B,CACH,CAAC;QACJ,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAtGW,QAAA,eAAe,mBAsG1B","sourcesContent":["import React from \"react\";\nimport SelectedFilters from \"@appbaseio/reactivesearch/lib/components/basic/SelectedFilters\";\n\nimport { ExampleFiltersSelected } from \"../../components\";\nimport { useFilters } from \"../../hooks\";\n\nexport type FiltersSelectedProps = {\n /** Render method called once for all active filters */\n render?: React.FC<{\n selectedFilters: Array<{\n key: string;\n label: string;\n value:\n | Array<string>\n | string\n | { label: string; start: number; end: number }\n | Array<{ label: string; start: number; end: number }>;\n }>;\n handleRemove: (\n filterKey: string,\n filterValues?: Array<string | number>\n ) => void;\n }>;\n};\n\nexport const FiltersSelected: React.FC<FiltersSelectedProps> = (props) => {\n const filtersHook = useFilters();\n\n const RenderComponent = props.render ?? ExampleFiltersSelected;\n\n return (\n <SelectedFilters\n render={({ selectedValues, setValue }) => {\n const selectedFilters = (\n Object.entries(selectedValues) as Array<[string, any]>\n )\n .filter(\n ([key, item]) =>\n item?.URLParams &&\n item?.showFilter &&\n (!!item?.value?.length || !!item?.value?.label)\n )\n .map(([key, item]) => ({\n key: key,\n label: item.label,\n value: item.value,\n }));\n\n const handleRemove = (\n selectedFilterKey: string,\n selectedFilterValues: Array<string | number> = []\n ) => {\n const filter = filtersHook.filters?.find(\n (filter) => filter.handle === selectedFilterKey\n );\n if (!filter) {\n return;\n }\n\n if (filter.displayType === \"slider\") {\n const event = new CustomEvent<{\n handle: string;\n value: [];\n }>(`@usereactify/search:filter:${filter.handle}:update`, {\n detail: {\n handle: filter.handle,\n value: [],\n },\n });\n window.dispatchEvent(event);\n\n return;\n }\n\n if (selectedFilterValues.length === 0) {\n setValue(selectedFilterKey, null);\n\n return;\n }\n\n if (selectedFilterValues.length > 0) {\n if (filter.displayType === \"single\") {\n setValue(selectedFilterKey, null);\n }\n if (filter.displayType === \"multi\") {\n if (filter.displayView === \"range\") {\n const values = selectedValues[selectedFilterKey].value\n .filter(\n (value: { label: string }) =>\n !selectedFilterValues.includes(value.label)\n )\n .map((value: { label: string }) => value.label);\n\n const event = new CustomEvent<{\n handle: string;\n value: Array<string>;\n }>(`@usereactify/search:filter:${filter.handle}:update`, {\n detail: {\n handle: filter.handle,\n value: values,\n },\n });\n window.dispatchEvent(event);\n }\n if (filter.displayView !== \"range\") {\n const values = selectedValues[selectedFilterKey].value.filter(\n (value: string) => !selectedFilterValues.includes(value)\n );\n setValue(selectedFilterKey, values);\n }\n }\n }\n };\n\n if (!selectedFilters.length) {\n return null;\n }\n\n return (\n <RenderComponent\n selectedFilters={selectedFilters}\n handleRemove={handleRemove}\n />\n );\n }}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"FiltersSelected.js","sourceRoot":"","sources":["../../../../src/components/Filter/FiltersSelected.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,qHAA6F;AAE7F,iDAA0D;AAcnD,MAAM,eAAe,GAAmC,CAAC,KAAK,EAAE,EAAE;;IACvE,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,mCAAsB,CAAC;IAE/D,OAAO,CACL,8BAAC,yBAAe,IACd,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,EAAE;YACvC,MAAM,eAAe,GACnB,MAAM,CAAC,OAAO,CAAC,cAAc,CAC9B;iBACE,MAAM,CACL,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;;gBACd,OAAA,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS;qBACf,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAA;oBAChB,CAAC,CAAC,CAAC,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,MAAM,CAAA,IAAI,CAAC,CAAC,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,KAAK,CAAA,CAAC,CAAA;aAAA,CAClD;iBACA,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;gBACrB,GAAG,EAAE,GAAG;gBACR,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC,CAAC,CAAC;YAEN,MAAM,YAAY,GAAG,CAAC,iBAAyB,EAAE,EAAE;gBACjD,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;YACpC,CAAC,CAAC;YAEF,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;gBAC3B,OAAO,IAAI,CAAC;aACb;YAED,OAAO,CACL,8BAAC,eAAe,IACd,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GAC1B,CACH,CAAC;QACJ,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAtCW,QAAA,eAAe,mBAsC1B","sourcesContent":["import React from \"react\";\nimport SelectedFilters from \"@appbaseio/reactivesearch/lib/components/basic/SelectedFilters\";\n\nimport { ExampleFiltersSelected } from \"../../components\";\n\nexport type FiltersSelectedProps = {\n /** Render method called once for all active filters */\n render?: React.FC<{\n selectedFilters: Array<{\n key: string;\n label: string;\n value: Array<string> | string | { start: number; end: number };\n }>;\n handleRemove: (filterKey: string) => void;\n }>;\n};\n\nexport const FiltersSelected: React.FC<FiltersSelectedProps> = (props) => {\n const RenderComponent = props.render ?? ExampleFiltersSelected;\n\n return (\n <SelectedFilters\n render={({ selectedValues, setValue }) => {\n const selectedFilters = (\n Object.entries(selectedValues) as Array<[string, any]>\n )\n .filter(\n ([key, item]) =>\n item?.URLParams &&\n item?.showFilter &&\n (!!item?.value?.length || !!item?.value?.label)\n )\n .map(([key, item]) => ({\n key: key,\n label: item.label,\n value: item.value,\n }));\n\n const handleRemove = (selectedFilterKey: string) => {\n setValue(selectedFilterKey, null);\n };\n\n if (!selectedFilters.length) {\n return null;\n }\n\n return (\n <RenderComponent\n selectedFilters={selectedFilters}\n handleRemove={handleRemove}\n />\n );\n }}\n />\n );\n};\n"]}
@@ -10,10 +10,10 @@ export declare type ReactifySearchProviderProps = {
10
10
  onRedirect?: (type: "redirect" | "search", url: string) => void;
11
11
  /** Render method to display a component when the config is loading */
12
12
  renderBooting?: () => JSX.Element | null;
13
- /** Advanced usage: Override the default Reactify Search id (for telemetry) */
14
- clientId?: string;
15
13
  /** Advanced usage: Override the default Filters selection logic */
16
14
  filtersHandle?: string;
15
+ /** Advanced usage: Allows you to wrap the ReactifySearchProvider in your own ReactiveBase component */
16
+ noReactiveBase?: boolean;
17
17
  /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */
18
18
  additionalComponentIds?: string[];
19
19
  /** Advanced usage: Override the default Elasticsearch index */
@@ -21,9 +21,11 @@ export declare type ReactifySearchProviderProps = {
21
21
  /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */
22
22
  configId?: string;
23
23
  /** Advanced usage: Override the default Elasticsearch credentials */
24
- credentials?: string;
25
- /** Advanced usage: Override the default Elasticsearch endpoint */
26
- endpoint?: string;
24
+ credentials?: {
25
+ username: string;
26
+ password: string;
27
+ endpoint: string;
28
+ };
27
29
  /** Advanced usage: Override the default ReactiveBase theme */
28
30
  theme?: Record<string, unknown>;
29
31
  /** Advanced usage: Fields to include in the Elasticsearch response e.g. ["title"] */
@@ -25,9 +25,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.ReactifySearchProvider = void 0;
26
26
  const react_1 = __importDefault(require("react"));
27
27
  const Sentry = __importStar(require("@sentry/react"));
28
- // @ts-expect-error missing types
29
- const GaGtag = __importStar(require("ga-gtag"));
30
- const package_json_1 = __importDefault(require("../../../package.json"));
31
28
  const hooks_1 = require("../../hooks");
32
29
  const components_1 = require("../../components");
33
30
  const utility_1 = require("../../utility");
@@ -41,22 +38,23 @@ const ReactifySearchProvider = (props) => {
41
38
  "reactifysearch.collection": props.mode === "collection" ? props.collectionHandle : undefined,
42
39
  "reactifysearch.filter": props.filtersHandle,
43
40
  });
44
- GaGtag.install("G-DV00Z0X5VP", {
45
- cookie_prefix: "_rs",
46
- user_properties: {
47
- shop: props.shopifyPermanentDomain,
48
- version: package_json_1.default.version,
49
- },
50
- });
51
41
  }, [props]);
52
42
  return (react_1.default.createElement(Sentry.ErrorBoundary, { fallback: react_1.default.createElement("p", null, "An error has occurred") },
53
43
  react_1.default.createElement(ReactifySearchInner, Object.assign({}, props))));
54
44
  };
55
45
  exports.ReactifySearchProvider = ReactifySearchProvider;
56
46
  const ReactifySearchInner = (props) => {
57
- var _a;
47
+ var _a, _b;
58
48
  const { config } = (0, hooks_1.useConfig)(props.shopifyPermanentDomain, props.configId);
59
- const theme = (_a = props.theme) !== null && _a !== void 0 ? _a : {
49
+ const [searchTerm, setSearchTerm] = react_1.default.useState("");
50
+ const [showInstantSearchResults, setShowInstantSearchResults] = react_1.default.useState(false);
51
+ const [sortOption, setSortOption] = react_1.default.useState("");
52
+ const credentials = (_a = props.credentials) !== null && _a !== void 0 ? _a : {
53
+ username: "guest",
54
+ password: "password",
55
+ endpoint: "https://api.search.reactify.app",
56
+ };
57
+ const theme = (_b = props.theme) !== null && _b !== void 0 ? _b : {
60
58
  typography: {
61
59
  fontFamily: "inherit",
62
60
  fontSize: "inherit",
@@ -78,19 +76,6 @@ const ReactifySearchInner = (props) => {
78
76
  const urlParams = new URLSearchParams(window.location.search);
79
77
  return (_a = urlParams.get("sort")) !== null && _a !== void 0 ? _a : undefined;
80
78
  }, [typeof window !== "undefined" && window.location.search]);
81
- const indexFromURL = react_1.default.useMemo(() => {
82
- var _a;
83
- if (typeof window === "undefined") {
84
- return;
85
- }
86
- const urlParams = new URLSearchParams(window.location.search);
87
- return (_a = urlParams.get("index")) !== null && _a !== void 0 ? _a : undefined;
88
- }, [typeof window !== "undefined" && window.location.search]);
89
- const [searchTerm, setSearchTerm] = react_1.default.useState(searchTermFromURL !== null && searchTermFromURL !== void 0 ? searchTermFromURL : "");
90
- const [showInstantSearchResults, setShowInstantSearchResults] = react_1.default.useState(false);
91
- const [sortOption, setSortOption] = react_1.default.useState(searchSortFromURL !== null && searchSortFromURL !== void 0 ? searchSortFromURL : "");
92
- const [results, setResults] = react_1.default.useState([]);
93
- const [resultStats, setResultStats] = react_1.default.useState();
94
79
  react_1.default.useEffect(() => {
95
80
  if (searchTermFromURL && searchTerm !== searchTermFromURL) {
96
81
  setSearchTerm(searchTermFromURL);
@@ -101,14 +86,22 @@ const ReactifySearchInner = (props) => {
101
86
  setSortOption(searchSortFromURL);
102
87
  }
103
88
  }, [searchSortFromURL]);
89
+ react_1.default.useEffect(() => {
90
+ if (typeof window == "undefined") {
91
+ return;
92
+ }
93
+ if (window.location.search === "" && sortOption) {
94
+ setSortOption(sortOption);
95
+ }
96
+ }, [typeof window !== "undefined" && window.location.search]);
104
97
  const contextValue = react_1.default.useMemo(() => {
105
- var _a, _b, _c, _d;
98
+ var _a;
106
99
  if (!config) {
107
100
  return;
108
101
  }
109
102
  return {
110
103
  config: config,
111
- options: Object.assign(Object.assign({}, props), { clientId: (_a = props.clientId) !== null && _a !== void 0 ? _a : "theme", index: (_c = (_b = props.index) !== null && _b !== void 0 ? _b : indexFromURL) !== null && _c !== void 0 ? _c : config.index, filtersHandle: props.filtersHandle, credentials: props.credentials, endpoint: (_d = props.endpoint) !== null && _d !== void 0 ? _d : "https://api.search.reactify.app", theme: theme }),
104
+ options: Object.assign(Object.assign({}, props), { index: (_a = props.index) !== null && _a !== void 0 ? _a : config.index, filtersHandle: props.filtersHandle, credentials: credentials, theme: theme }),
112
105
  search: {
113
106
  searchTerm: searchTerm,
114
107
  setSearchTerm: setSearchTerm,
@@ -119,22 +112,8 @@ const ReactifySearchInner = (props) => {
119
112
  sortOption: sortOption,
120
113
  setSortOption: setSortOption,
121
114
  },
122
- results: {
123
- results: results,
124
- setResults: setResults,
125
- resultStats: resultStats,
126
- setResultStats: setResultStats,
127
- },
128
115
  };
129
- }, [
130
- config,
131
- props,
132
- searchTerm,
133
- showInstantSearchResults,
134
- sortOption,
135
- results,
136
- resultStats,
137
- ]);
116
+ }, [config, props, searchTerm, showInstantSearchResults, sortOption]);
138
117
  utility_1.debug.hook("ReactifySearchProvider", "context", contextValue);
139
118
  if (!contextValue) {
140
119
  if (props.renderBooting) {
@@ -142,6 +121,9 @@ const ReactifySearchInner = (props) => {
142
121
  }
143
122
  return null;
144
123
  }
124
+ if (props.noReactiveBase) {
125
+ return (react_1.default.createElement(hooks_1.ReactifySearchContext.Provider, { value: contextValue }, props.children));
126
+ }
145
127
  return (react_1.default.createElement(hooks_1.ReactifySearchContext.Provider, { value: contextValue },
146
128
  react_1.default.createElement(components_1.UtilityAuthenticatedReactiveBase, null, props.children)));
147
129
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,sDAAwC;AACxC,iCAAiC;AACjC,gDAAkC;AAElC,yEAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAgD/B,MAAM,sBAAsB,GAA0C,CAC3E,KAAK,EACL,EAAE;IACF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CA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;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;aAC7B;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,OAAO;gBAChB,UAAU,EAAE,UAAU;gBACtB,WAAW,EAAE,WAAW;gBACxB,cAAc,EAAE,cAAc;aAC/B;SACF,CAAC;IACJ,CAAC,EAAE;QACD,MAAM;QACN,KAAK;QACL,UAAU;QACV,wBAAwB;QACxB,UAAU;QACV,OAAO;QACP,WAAW;KACZ,CAAC,CAAC;IAEH,eAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAE9D,IAAI,CAAC,YAAY,EAAE;QACjB,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAC9B,KAAK,CAAC,QAAQ,CACkB,CACJ,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport * as Sentry from \"@sentry/react\";\n// @ts-expect-error missing types\nimport * as GaGtag from \"ga-gtag\";\n\nimport pkg from \"../../../package.json\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\nimport { ReactivesearchResultProps } from \"../../types\";\n\nexport type ReactifySearchProviderProps = {\n /** Standard react children */\n children?: React.ReactNode | undefined;\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\";\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Callback function for redirects, suitable for headless sites to avoid full page refresh */\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n /** Render method to display a component when the config is loading */\n renderBooting?: () => JSX.Element | null;\n /** Advanced usage: Override the default Reactify Search id (for telemetry) */\n clientId?: string;\n /** Advanced usage: Override the default Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: string[];\n /** Advanced usage: Override the default Elasticsearch index */\n index?: string;\n /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */\n configId?: string;\n /** Advanced usage: Override the default Elasticsearch credentials */\n credentials?: string;\n /** Advanced usage: Override the default Elasticsearch endpoint */\n endpoint?: string;\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: string[];\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: string[];\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n);\n\nexport const ReactifySearchProvider: React.FC<ReactifySearchProviderProps> = (\n props\n) => {\n React.useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n Sentry.setTags({\n \"reactifysearch.index\": props.index,\n \"reactifysearch.shop\": props.shopifyPermanentDomain,\n \"reactifysearch.mode\": props.mode,\n \"reactifysearch.collection\":\n props.mode === \"collection\" ? props.collectionHandle : undefined,\n \"reactifysearch.filter\": props.filtersHandle,\n });\n\n GaGtag.install(\"G-DV00Z0X5VP\", {\n cookie_prefix: \"_rs\",\n user_properties: {\n shop: props.shopifyPermanentDomain,\n version: pkg.version,\n },\n });\n }, [props]);\n\n return (\n <Sentry.ErrorBoundary fallback={<p>An error has occurred</p>}>\n <ReactifySearchInner {...props} />\n </Sentry.ErrorBoundary>\n );\n};\n\nconst ReactifySearchInner: React.FC<ReactifySearchProviderProps> = (props) => {\n const { config } = useConfig(props.shopifyPermanentDomain, props.configId);\n\n const theme = props.theme ?? {\n typography: {\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n },\n };\n\n const searchTermFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"q\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const indexFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"index\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const [searchTerm, setSearchTerm] = React.useState<string>(\n searchTermFromURL ?? \"\"\n );\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n const [sortOption, setSortOption] = React.useState<string>(\n searchSortFromURL ?? \"\"\n );\n\n const [results, setResults] = React.useState<\n ReactivesearchResultProps[\"data\"]\n >([]);\n const [resultStats, setResultStats] =\n React.useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n React.useEffect(() => {\n if (searchTermFromURL && searchTerm !== searchTermFromURL) {\n setSearchTerm(searchTermFromURL);\n }\n }, [searchTermFromURL]);\n\n React.useEffect(() => {\n if (searchSortFromURL && sortOption !== searchSortFromURL) {\n setSortOption(searchSortFromURL);\n }\n }, [searchSortFromURL]);\n\n const contextValue = React.useMemo(() => {\n if (!config) {\n return;\n }\n\n return {\n config: config,\n options: {\n ...props,\n clientId: props.clientId ?? \"theme\",\n index: props.index ?? indexFromURL ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: props.credentials,\n endpoint: props.endpoint ?? \"https://api.search.reactify.app\",\n theme: theme,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n results: {\n results: results,\n setResults: setResults,\n resultStats: resultStats,\n setResultStats: setResultStats,\n },\n };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n sortOption,\n results,\n resultStats,\n ]);\n\n debug.hook(\"ReactifySearchProvider\", \"context\", contextValue);\n\n if (!contextValue) {\n if (props.renderBooting) {\n return props.renderBooting();\n }\n return null;\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>\n {props.children}\n </UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n};\n"]}
1
+ {"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,sDAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAiD/B,MAAM,sBAAsB,GAA0C,CAC3E,KAAK,EACL,EAAE;IACF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CAAC;YACb,sBAAsB,EAAE,KAAK,CAAC,KAAK;YACnC,qBAAqB,EAAE,KAAK,CAAC,sBAAsB;YACnD,qBAAqB,EAAE,KAAK,CAAC,IAAI;YACjC,2BAA2B,EACzB,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;YAClE,uBAAuB,EAAE,KAAK,CAAC,aAAa;SAC7C,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,8BAAC,MAAM,CAAC,aAAa,IAAC,QAAQ,EAAE,iEAA4B;QAC1D,8BAAC,mBAAmB,oB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AAK,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,MAAM,CAAC,KAAK,EAClC,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,GACb;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;gBAC5B,wBAAwB,EAAE,wBAAwB;gBAClD,2BAA2B,EAAE,2BAA2B;aACzD;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;aAC7B;SACF,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,UAAU,CAAC,CAAC,CAAC;IAEtE,eAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAE9D,IAAI,CAAC,YAAY,EAAE;QACjB,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC;KACb;IAED,IAAI,KAAK,CAAC,cAAc,EAAE;QACxB,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAChD,KAAK,CAAC,QAAQ,CACgB,CAClC,CAAC;KACH;IAED,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAC9B,KAAK,CAAC,QAAQ,CACkB,CACJ,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport * as Sentry from \"@sentry/react\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\n\nexport type ReactifySearchProviderProps = {\n /** Standard react children */\n children?: React.ReactNode | undefined;\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\";\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Callback function for redirects, suitable for headless sites to avoid full page refresh */\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n /** Render method to display a component when the config is loading */\n renderBooting?: () => JSX.Element | null;\n /** Advanced usage: Override the default Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Allows you to wrap the ReactifySearchProvider in your own ReactiveBase component */\n noReactiveBase?: boolean;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: string[];\n /** Advanced usage: Override the default Elasticsearch index */\n index?: string;\n /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */\n configId?: string;\n /** Advanced usage: Override the default Elasticsearch credentials */\n credentials?: {\n username: string;\n password: string;\n endpoint: string;\n };\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: string[];\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: string[];\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n);\n\nexport const ReactifySearchProvider: React.FC<ReactifySearchProviderProps> = (\n props\n) => {\n React.useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n Sentry.setTags({\n \"reactifysearch.index\": props.index,\n \"reactifysearch.shop\": props.shopifyPermanentDomain,\n \"reactifysearch.mode\": props.mode,\n \"reactifysearch.collection\":\n props.mode === \"collection\" ? props.collectionHandle : undefined,\n \"reactifysearch.filter\": props.filtersHandle,\n });\n }, [props]);\n\n return (\n <Sentry.ErrorBoundary fallback={<p>An error has occurred</p>}>\n <ReactifySearchInner {...props} />\n </Sentry.ErrorBoundary>\n );\n};\n\nconst ReactifySearchInner: React.FC<ReactifySearchProviderProps> = (props) => {\n const { config } = useConfig(props.shopifyPermanentDomain, props.configId);\n\n const [searchTerm, setSearchTerm] = React.useState<string>(\"\");\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n const [sortOption, setSortOption] = React.useState<string>(\"\");\n\n const credentials = props.credentials ?? {\n username: \"guest\",\n password: \"password\",\n endpoint: \"https://api.search.reactify.app\",\n };\n\n const theme = props.theme ?? {\n typography: {\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n },\n };\n\n const searchTermFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"q\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n React.useEffect(() => {\n if (searchTermFromURL && searchTerm !== searchTermFromURL) {\n setSearchTerm(searchTermFromURL);\n }\n }, [searchTermFromURL]);\n\n React.useEffect(() => {\n if (searchSortFromURL && sortOption !== searchSortFromURL) {\n setSortOption(searchSortFromURL);\n }\n }, [searchSortFromURL]);\n\n React.useEffect(() => {\n if (typeof window == \"undefined\") {\n return;\n }\n\n if (window.location.search === \"\" && sortOption) {\n setSortOption(sortOption);\n }\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const contextValue = React.useMemo(() => {\n if (!config) {\n return;\n }\n\n return {\n config: config,\n options: {\n ...props,\n index: props.index ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: credentials,\n theme: theme,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n };\n }, [config, props, searchTerm, showInstantSearchResults, sortOption]);\n\n debug.hook(\"ReactifySearchProvider\", \"context\", contextValue);\n\n if (!contextValue) {\n if (props.renderBooting) {\n return props.renderBooting();\n }\n return null;\n }\n\n if (props.noReactiveBase) {\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n {props.children}\n </ReactifySearchContext.Provider>\n );\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>\n {props.children}\n </UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n};\n"]}
@@ -23,18 +23,15 @@ const Results = (props) => {
23
23
  const { track } = (0, hooks_1.useAnalytics)();
24
24
  const { searchTerm } = (0, hooks_1.useSearch)();
25
25
  return (react_1.default.createElement(ReactiveList_1.default, Object.assign({}, reactiveReactiveListProps, { render: (reactivesearchResultProps) => (react_1.default.createElement(ResultsInner, Object.assign({}, props, { reactivesearchResultProps: reactivesearchResultProps }))), onData: (renderProps) => {
26
- if (renderProps.resultStats.numberOfResults === 0) {
27
- let trimmedSearchTerm = searchTerm.trim();
28
- if (!trimmedSearchTerm ||
29
- (trimmedSearchTerm && trimmedSearchTerm.length < 3)) {
30
- return;
26
+ if (!renderProps.loading && !renderProps.resultStats.numberOfResults) {
27
+ if (searchTerm) {
28
+ track({
29
+ eventName: "zeroResults",
30
+ payload: {
31
+ searchTerm: searchTerm,
32
+ },
33
+ });
31
34
  }
32
- track({
33
- eventName: "zeroResults",
34
- payload: {
35
- searchTerm: trimmedSearchTerm,
36
- },
37
- });
38
35
  }
39
36
  }, renderPagination: (reactivesearchPaginationProps) => (react_1.default.createElement(ResultsPaginationStack, Object.assign({}, props, reactivesearchPaginationProps))) })));
40
37
  };
@@ -51,10 +48,8 @@ const ResultsRenderNoResultsComponent = () => {
51
48
  return react_1.default.createElement("div", null, "No results");
52
49
  };
53
50
  const ResultsInner = (props) => {
54
- var _a, _b, _c, _d, _e, _f;
55
- const context = (0, hooks_1.useReactifySearchContext)();
51
+ var _a, _b, _c, _d, _e;
56
52
  const filtersHook = (0, hooks_1.useFilters)();
57
- const resultsHook = (0, hooks_1.useResults)();
58
53
  const initialSearchHasRun = react_1.default.useMemo(() => "undefined" !==
59
54
  typeof props.reactivesearchResultProps.resultStats.numberOfResults, [props.reactivesearchResultProps]);
60
55
  const listStyle = react_1.default.useMemo(() => {
@@ -78,10 +73,6 @@ const ResultsInner = (props) => {
78
73
  props.reactivesearchResultProps.resultStats.displayedResults,
79
74
  props.infiniteScrollPosition,
80
75
  ]);
81
- react_1.default.useEffect(() => {
82
- resultsHook.setResults(props.reactivesearchResultProps.data);
83
- resultsHook.setResultStats(props.reactivesearchResultProps.resultStats);
84
- }, [props.reactivesearchResultProps.data.map((item) => item._id).join("")]);
85
76
  if (props.reactivesearchResultProps.error) {
86
77
  utility_1.debug.breadcrumb({
87
78
  category: "result",
@@ -102,12 +93,6 @@ const ResultsInner = (props) => {
102
93
  const RenderNoResultsComponent = (_e = props.renderNoResults) !== null && _e !== void 0 ? _e : ResultsRenderNoResultsComponent;
103
94
  return react_1.default.createElement(RenderNoResultsComponent, null);
104
95
  }
105
- if (["search", "instant-search"].includes(context.options.mode)) {
106
- if (!context.search.searchTerm) {
107
- const RenderNoResultsComponent = (_f = props.renderNoResults) !== null && _f !== void 0 ? _f : ResultsRenderNoResultsComponent;
108
- return react_1.default.createElement(RenderNoResultsComponent, null);
109
- }
110
- }
111
96
  return (react_1.default.createElement(react_1.default.Fragment, null,
112
97
  react_1.default.createElement("section", { style: listStyle, className: props.listClassName }, props.reactivesearchResultProps.data.map((item, key) => {
113
98
  if (types_1.ElasticDocumentType.Product === item.type) {
@@ -1 +1 @@
1
- {"version":3,"file":"Results.js","sourceRoot":"","sources":["../../../../src/components/Result/Results.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gHAAwF;AAExF,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AAEtE,uCAOqB;AACrB,uCAUqB;AACrB,2CAAsC;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W,EAAE,GAAG,IAAA,kBAAU,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,IAAI,iBAAiB,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QACrD,OAAO,CACL,8BAAC,+DAA8B,oBACzB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,8BAA8B,IAC5C,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 ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n} from \"../../types\";\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilters,\n useReactiveReactiveListProps,\n useProductPrice,\n usePagination,\n usePaginationLoadable,\n useResults,\n} from \"../../hooks\";\nimport { debug } from \"../../utility\";\nimport { ResultPaginationInfiniteScroll } from \"./ResultPaginationInfiniteScroll\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultsProps = {\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.FC<\n ReturnType<typeof useProductPrice> & {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.FC<{\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }>;\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadable>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<\n ReturnType<typeof usePaginationLoadable>\n >;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n /** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */\n infiniteScrollContainer?: React.ComponentProps<\n typeof ReactiveList\n >[\"scrollTarget\"];\n /** Advanced Usage: Provide a specific result position to trigger loading more results (infinite scroll) */\n infiniteScrollPosition?: number;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactiveReactiveListProps = useReactiveReactiveListProps({\n pageSize: props.pageSize,\n scrollTarget: props.infiniteScrollContainer,\n });\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n return (\n <ReactiveList\n {...reactiveReactiveListProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultsInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n onData={(renderProps) => {\n if (renderProps.resultStats.numberOfResults === 0) {\n let trimmedSearchTerm = searchTerm.trim();\n\n if (\n !trimmedSearchTerm ||\n (trimmedSearchTerm && trimmedSearchTerm.length < 3)\n ) {\n return;\n }\n\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: trimmedSearchTerm,\n },\n });\n }\n }}\n renderPagination={(\n reactivesearchPaginationProps: ReactivesearchPaginationProps\n ) => (\n <ResultsPaginationStack {...props} {...reactivesearchPaginationProps} />\n )}\n />\n );\n};\n\nconst ResultsRenderErrorComponent: ResultsProps[\"renderError\"] = (props) => {\n return (\n <div>\n {\"Error: \"}\n {props.error.statusText}\n </div>\n );\n};\n\nconst ResultsRenderLoadingComponent: ResultsProps[\"renderLoading\"] = () => {\n return <div>{\"Loading\"}</div>;\n};\n\nconst ResultsRenderNoResultsComponent: ResultsProps[\"renderNoResults\"] = () => {\n return <div>{\"No results\"}</div>;\n};\n\nconst ResultsInner: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const context = useReactifySearchContext();\n const filtersHook = useFilters();\n const resultsHook = useResults();\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 const infiniteScrollPosition = React.useMemo<number>(() => {\n if (!props.infiniteScrollPosition) {\n return NaN;\n }\n\n const scrollPositionOffset =\n props.reactivesearchResultProps.resultStats.displayedResults -\n (props.pageSize ?? filtersHook.filterStack?.pageSize ?? 0);\n\n return scrollPositionOffset + (props.infiniteScrollPosition ?? 0);\n }, [\n props.pageSize ?? filtersHook.filterStack?.pageSize,\n props.reactivesearchResultProps.resultStats.displayedResults,\n props.infiniteScrollPosition,\n ]);\n\n React.useEffect(() => {\n resultsHook.setResults(props.reactivesearchResultProps.data);\n resultsHook.setResultStats(props.reactivesearchResultProps.resultStats);\n }, [props.reactivesearchResultProps.data.map((item) => item._id).join(\"\")]);\n\n if (props.reactivesearchResultProps.error) {\n debug.breadcrumb({\n category: \"result\",\n message: \"error\",\n data: {\n error: props.reactivesearchResultProps.error,\n },\n });\n\n const RenderErrorComponent =\n props.renderError ?? ResultsRenderErrorComponent;\n\n return (\n <RenderErrorComponent error={props.reactivesearchResultProps.error} />\n );\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent =\n props.renderLoading ?? ResultsRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n\n if (\n !props.reactivesearchResultProps.loading &&\n !props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n\n if ([\"search\", \"instant-search\"].includes(context.options.mode)) {\n if (!context.search.searchTerm) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {props.reactivesearchResultProps.data.map((item, key) => {\n if (ElasticDocumentType.Product === 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 {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\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 {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultsPaginationStackLoadable\n {...props}\n {...props.reactivesearchResultProps}\n />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultsPaginationStack: React.FC<\n ResultsProps & ReactivesearchPaginationProps\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\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 ResultsPaginationStackLoadable: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\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 if (\"infinite_scroll\" === filterStack?.paginationType) {\n return (\n <ResultPaginationInfiniteScroll\n {...props.reactivesearchResultProps}\n render={props.renderPaginationInfiniteScroll}\n />\n );\n }\n\n return null;\n};\n"]}
1
+ {"version":3,"file":"Results.js","sourceRoot":"","sources":["../../../../src/components/Result/Results.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gHAAwF;AAExF,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AAEtE,uCAOqB;AACrB,uCASqB;AACrB,2CAAsC;AACtC,qFAAkF;AAwD3E,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,yBAAyB,GAAG,IAAA,oCAA4B,EAAC;QAC7D,Q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C,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,qEAAqE;AACrE,MAAM,8BAA8B,GAEhC,CAAC,KAAK,EAAE,EAAE;IACZ,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,kBAAU,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,IAAI,iBAAiB,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QACrD,OAAO,CACL,8BAAC,+DAA8B,oBACzB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,8BAA8B,IAC5C,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 ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n} from \"../../types\";\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilters,\n useReactiveReactiveListProps,\n useProductPrice,\n usePagination,\n usePaginationLoadable,\n} from \"../../hooks\";\nimport { debug } from \"../../utility\";\nimport { ResultPaginationInfiniteScroll } from \"./ResultPaginationInfiniteScroll\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultsProps = {\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.FC<\n ReturnType<typeof useProductPrice> & {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.FC<{\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }>;\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadable>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<\n ReturnType<typeof usePaginationLoadable>\n >;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n /** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */\n infiniteScrollContainer?: React.ComponentProps<\n typeof ReactiveList\n >[\"scrollTarget\"];\n /** Advanced Usage: Provide a specific result position to trigger loading more results (infinite scroll) */\n infiniteScrollPosition?: number;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactiveReactiveListProps = useReactiveReactiveListProps({\n pageSize: props.pageSize,\n scrollTarget: props.infiniteScrollContainer,\n });\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n return (\n <ReactiveList\n {...reactiveReactiveListProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultsInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n onData={(renderProps) => {\n if (!renderProps.loading && !renderProps.resultStats.numberOfResults) {\n if (searchTerm) {\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: searchTerm,\n },\n });\n }\n }\n }}\n renderPagination={(\n reactivesearchPaginationProps: ReactivesearchPaginationProps\n ) => (\n <ResultsPaginationStack {...props} {...reactivesearchPaginationProps} />\n )}\n />\n );\n};\n\nconst ResultsRenderErrorComponent: ResultsProps[\"renderError\"] = (props) => {\n return (\n <div>\n {\"Error: \"}\n {props.error.statusText}\n </div>\n );\n};\n\nconst ResultsRenderLoadingComponent: ResultsProps[\"renderLoading\"] = () => {\n return <div>{\"Loading\"}</div>;\n};\n\nconst ResultsRenderNoResultsComponent: ResultsProps[\"renderNoResults\"] = () => {\n return <div>{\"No results\"}</div>;\n};\n\nconst ResultsInner: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const filtersHook = useFilters();\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 const infiniteScrollPosition = React.useMemo<number>(() => {\n if (!props.infiniteScrollPosition) {\n return NaN;\n }\n\n const scrollPositionOffset =\n props.reactivesearchResultProps.resultStats.displayedResults -\n (props.pageSize ?? filtersHook.filterStack?.pageSize ?? 0);\n\n return scrollPositionOffset + (props.infiniteScrollPosition ?? 0);\n }, [\n props.pageSize ?? filtersHook.filterStack?.pageSize,\n props.reactivesearchResultProps.resultStats.displayedResults,\n props.infiniteScrollPosition,\n ]);\n\n if (props.reactivesearchResultProps.error) {\n debug.breadcrumb({\n category: \"result\",\n message: \"error\",\n data: {\n error: props.reactivesearchResultProps.error,\n },\n });\n\n const RenderErrorComponent =\n props.renderError ?? ResultsRenderErrorComponent;\n\n return (\n <RenderErrorComponent error={props.reactivesearchResultProps.error} />\n );\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent =\n props.renderLoading ?? ResultsRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n\n if (\n !props.reactivesearchResultProps.loading &&\n !props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {props.reactivesearchResultProps.data.map((item, key) => {\n if (ElasticDocumentType.Product === 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 {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\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 {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultsPaginationStackLoadable\n {...props}\n {...props.reactivesearchResultProps}\n />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultsPaginationStack: React.FC<\n ResultsProps & ReactivesearchPaginationProps\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\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 ResultsPaginationStackLoadable: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\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 if (\"infinite_scroll\" === filterStack?.paginationType) {\n return (\n <ResultPaginationInfiniteScroll\n {...props.reactivesearchResultProps}\n render={props.renderPaginationInfiniteScroll}\n />\n );\n }\n\n return null;\n};\n"]}
@@ -8,14 +8,10 @@ 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 SensorCollection = () => {
11
- const flagsHook = (0, hooks_1.useFlags)();
12
11
  const { options } = (0, hooks_1.useReactifySearchContext)();
13
12
  if (options.mode !== "collection") {
14
13
  return null;
15
14
  }
16
- if (!flagsHook.flags["reactify-search:flag_sensor_collection"]) {
17
- return null;
18
- }
19
15
  return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorCollection", customQuery: () => ({
20
16
  query: {
21
17
  bool: {
@@ -1 +1 @@
1
- {"version":3,"file":"SensorCollection.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCollection.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAAiE;AAE1D,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC7C,MAAM,SAAS,GAAG,IAAA,gBAAQ,GAAE,CAAC;IAC7B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE;QACjC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,wCAAwC,CAAC,EAAE;QAC9D,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,8BAAC,2BAAiB,IAChB,WAAW,EAAC,kBAAkB,EAC9B,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;YAClB,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,MAAM,EAAE;wBACN;4BACE,MAAM,EAAE;gCACN,IAAI,EAAE,aAAa;gCACnB,KAAK,EAAE;oCACL,IAAI,EAAE;wCACJ,4BAA4B,EAAE,OAAO,CAAC,gBAAgB;qCACvD;iCACF;6BACF;yBACF;wBACD;4BACE,MAAM,EAAE;gCACN,IAAI,EAAE,WAAW;gCACjB,KAAK,EAAE;oCACL,IAAI,EAAE;wCACJ,oCAAoC,EAClC,OAAO,CAAC,gBAAgB;qCAC3B;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AA9CW,QAAA,gBAAgB,oBA8C3B","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useFlags, useReactifySearchContext } from \"../../hooks\";\n\nexport const SensorCollection: React.FC = () => {\n const flagsHook = useFlags();\n const { options } = useReactifySearchContext();\n\n if (options.mode !== \"collection\") {\n return null;\n }\n\n if (!flagsHook.flags[\"reactify-search:flag_sensor_collection\"]) {\n return null;\n }\n\n return (\n <ReactiveComponent\n componentId=\"SensorCollection\"\n customQuery={() => ({\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n })}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"SensorCollection.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCollection.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAAuD;AAEhD,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE;QACjC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,8BAAC,2BAAiB,IAChB,WAAW,EAAC,kBAAkB,EAC9B,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;YAClB,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,MAAM,EAAE;wBACN;4BACE,MAAM,EAAE;gCACN,IAAI,EAAE,aAAa;gCACnB,KAAK,EAAE;oCACL,IAAI,EAAE;wCACJ,4BAA4B,EAAE,OAAO,CAAC,gBAAgB;qCACvD;iCACF;6BACF;yBACF;wBACD;4BACE,MAAM,EAAE;gCACN,IAAI,EAAE,WAAW;gCACjB,KAAK,EAAE;oCACL,IAAI,EAAE;wCACJ,oCAAoC,EAClC,OAAO,CAAC,gBAAgB;qCAC3B;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AAzCW,QAAA,gBAAgB,oBAyC3B","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\n\nexport const SensorCollection: React.FC = () => {\n const { options } = useReactifySearchContext();\n\n if (options.mode !== \"collection\") {\n return null;\n }\n\n return (\n <ReactiveComponent\n componentId=\"SensorCollection\"\n customQuery={() => ({\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n })}\n />\n );\n};\n"]}