@nosto/search-js 3.1.1 → 3.2.0

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 (138) hide show
  1. package/dist/BaseElement-Ds4INJSy.cjs +1 -0
  2. package/dist/BaseElement-fZSwbg09.js +17 -0
  3. package/dist/{InfiniteScrollWithObserver-B6k7NAW1.js → InfiniteScrollWithObserver-BsydJKFj.js} +61 -63
  4. package/dist/InfiniteScrollWithObserver-wzwXCrZ7.cjs +1 -0
  5. package/dist/baseConfig-CTN0CcW-.js +48 -0
  6. package/dist/baseConfig-KREDcxnC.cjs +1 -0
  7. package/dist/core/core.cjs.js +1 -1
  8. package/dist/core/core.es.js +6 -6
  9. package/dist/currencies/currencies.cjs.js +1 -1
  10. package/dist/currencies/currencies.es.js +32 -32
  11. package/dist/eventBusSubscribe-B75y7otR.cjs +1 -0
  12. package/dist/eventBusSubscribe-Cxw0xUAm.js +25 -0
  13. package/dist/{unique-m1TIDWdl.js → isBot-C58Y7eiv.js} +12 -36
  14. package/dist/{unique-Blp-K9zG.cjs → isBot-CheH1DcZ.cjs} +1 -1
  15. package/dist/preact/autocomplete/autocomplete.cjs.js +1 -0
  16. package/dist/preact/autocomplete/autocomplete.d.ts +5 -0
  17. package/dist/preact/autocomplete/autocomplete.es.js +49 -0
  18. package/dist/preact/{src/config/pages/autocomplete/config.d.ts → autocomplete/src/AutocompleteConfig.d.ts} +5 -5
  19. package/dist/preact/{src/config/pages/autocomplete/provider.d.ts → autocomplete/src/AutocompletePageProvider.d.ts} +2 -2
  20. package/dist/preact/{src → autocomplete/src}/components/AutocompleteElement.d.ts +2 -2
  21. package/dist/preact/category/category.cjs.js +1 -0
  22. package/dist/preact/category/category.d.ts +3 -0
  23. package/dist/preact/category/category.es.js +25 -0
  24. package/dist/preact/{src/config/pages/category/config.d.ts → category/src/CategoryConfig.d.ts} +5 -5
  25. package/dist/preact/{src/config/pages/category/provider.d.ts → category/src/CategoryPageProvider.d.ts} +2 -2
  26. package/dist/preact/common/common.cjs.js +1 -0
  27. package/dist/preact/{common.d.ts → common/common.d.ts} +3 -3
  28. package/dist/preact/{common.es.js → common/common.es.js} +6 -6
  29. package/dist/preact/{src → common/src}/actions/newSearch.d.ts +2 -2
  30. package/dist/preact/{src → common/src}/actions/replaceFilter.d.ts +1 -1
  31. package/dist/preact/{src → common/src}/actions/toggleProductFilter.d.ts +1 -1
  32. package/dist/preact/{src → common/src}/actions/updateSearch.d.ts +2 -2
  33. package/dist/preact/{src/search/defaults.d.ts → common/src/actions/withDefaultQuery.d.ts} +2 -4
  34. package/dist/preact/{src/config/base → common/src/config}/baseConfig.d.ts +1 -2
  35. package/dist/preact/common/src/config/config.d.ts +4 -0
  36. package/dist/preact/common/src/config/configContext.d.ts +6 -0
  37. package/dist/preact/common/src/store/components/StoreActionsListener.d.ts +1 -0
  38. package/dist/preact/{src/api → common/src}/types.d.ts +6 -0
  39. package/dist/preact/events/events.cjs.js +1 -0
  40. package/dist/preact/events/events.d.ts +3 -0
  41. package/dist/preact/events/events.es.js +23 -0
  42. package/dist/preact/events/src/eventBusDispatch.d.ts +10 -0
  43. package/dist/preact/events/src/eventBusSubscribe.d.ts +8 -0
  44. package/dist/preact/events/src/types.d.ts +26 -0
  45. package/dist/preact/hooks/hooks.cjs.js +1 -0
  46. package/dist/preact/hooks/hooks.d.ts +18 -0
  47. package/dist/preact/hooks/hooks.es.js +414 -0
  48. package/dist/preact/{src/hooks → hooks/src}/useNostoAppState.d.ts +1 -1
  49. package/dist/preact/legacy/legacy.cjs.js +1 -0
  50. package/dist/preact/legacy/legacy.d.ts +6 -0
  51. package/dist/preact/legacy/legacy.es.js +10 -0
  52. package/dist/preact/serp/serp.cjs.js +1 -0
  53. package/dist/preact/serp/serp.d.ts +4 -0
  54. package/dist/preact/serp/serp.es.js +39 -0
  55. package/dist/preact/{src/config/pages/serp/config.d.ts → serp/src/SerpConfig.d.ts} +5 -5
  56. package/dist/preact/{src/config/pages/serp/provider.d.ts → serp/src/SerpPageProvider.d.ts} +2 -2
  57. package/dist/preact/{src → serp/src}/components/SerpElement.d.ts +2 -2
  58. package/dist/search-DweKaGAI.js +162 -0
  59. package/dist/search-sG5OjNAe.cjs +1 -0
  60. package/dist/thumbnails/thumbnails.cjs.js +1 -1
  61. package/dist/thumbnails/thumbnails.es.js +26 -27
  62. package/dist/unique-3gEanSFU.cjs +1 -0
  63. package/dist/unique-DxrT0M20.js +39 -0
  64. package/dist/useActions-B-wWOcHo.cjs +1 -0
  65. package/dist/useActions-BIIcXXS6.js +229 -0
  66. package/dist/useLoadMore-BWgWw24W.cjs +1 -0
  67. package/dist/useLoadMore-Dw7GDu8a.js +31 -0
  68. package/dist/utils/utils.cjs.js +1 -1
  69. package/dist/utils/utils.es.js +24 -24
  70. package/package.json +45 -39
  71. package/dist/BaseElement-B0hSjDTT.cjs +0 -1
  72. package/dist/BaseElement-IyqEeIiJ.js +0 -18
  73. package/dist/InfiniteScrollWithObserver-DtlqmHSY.cjs +0 -1
  74. package/dist/baseConfig-BFFqFSg5.cjs +0 -1
  75. package/dist/baseConfig-Bafl02NY.js +0 -21
  76. package/dist/configContext-BR7w4VlU.cjs +0 -1
  77. package/dist/configContext-GuZOIX3o.js +0 -63
  78. package/dist/deepMerge-CZwCJzEe.js +0 -17
  79. package/dist/deepMerge-lDscDfII.cjs +0 -1
  80. package/dist/preact/autocomplete.cjs.js +0 -1
  81. package/dist/preact/autocomplete.d.ts +0 -5
  82. package/dist/preact/autocomplete.es.js +0 -46
  83. package/dist/preact/category.cjs.js +0 -1
  84. package/dist/preact/category.d.ts +0 -3
  85. package/dist/preact/category.es.js +0 -22
  86. package/dist/preact/common.cjs.js +0 -1
  87. package/dist/preact/hooks.cjs.js +0 -1
  88. package/dist/preact/hooks.d.ts +0 -18
  89. package/dist/preact/hooks.es.js +0 -453
  90. package/dist/preact/legacy.cjs.js +0 -1
  91. package/dist/preact/legacy.d.ts +0 -6
  92. package/dist/preact/legacy.es.js +0 -9
  93. package/dist/preact/preact.d.ts +0 -30
  94. package/dist/preact/serp.cjs.js +0 -1
  95. package/dist/preact/serp.d.ts +0 -4
  96. package/dist/preact/serp.es.js +0 -36
  97. package/dist/preact/src/actions/types.d.ts +0 -6
  98. package/dist/preact/src/config/config.d.ts +0 -4
  99. package/dist/preact/src/config/configContext.d.ts +0 -6
  100. package/dist/search-Bhebxu8K.cjs +0 -1
  101. package/dist/search-BrR80UbS.js +0 -164
  102. package/dist/useLoadMore-CeqFdxt1.cjs +0 -1
  103. package/dist/useLoadMore-FglaJn2W.js +0 -204
  104. /package/dist/preact/{src → autocomplete/src}/components/SearchInput.d.ts +0 -0
  105. /package/dist/preact/{src/components → autocomplete/src}/types.d.ts +0 -0
  106. /package/dist/preact/{src → common/src}/components/BaseElement.d.ts +0 -0
  107. /package/dist/preact/{src → common/src}/components/InfiniteScroll/InfiniteScroll.d.ts +0 -0
  108. /package/dist/preact/{src → common/src}/components/InfiniteScroll/InfiniteScrollWithLink.d.ts +0 -0
  109. /package/dist/preact/{src → common/src}/components/InfiniteScroll/InfiniteScrollWithObserver.d.ts +0 -0
  110. /package/dist/preact/{src → common/src}/components/InfiniteScroll/LoadMoreLink.d.ts +0 -0
  111. /package/dist/preact/{src → common/src}/components/InfiniteScroll/utils.d.ts +0 -0
  112. /package/dist/preact/{src → common/src/store}/store.d.ts +0 -0
  113. /package/dist/preact/{src → common/src/store}/storeContext.d.ts +0 -0
  114. /package/dist/preact/{src → common/src/store}/storeExtensions.d.ts +0 -0
  115. /package/dist/preact/{src/hooks → hooks/src}/types.d.ts +0 -0
  116. /package/dist/preact/{src/hooks → hooks/src}/useActions.d.ts +0 -0
  117. /package/dist/preact/{src/hooks → hooks/src}/useCheckClientScript.d.ts +0 -0
  118. /package/dist/preact/{src/hooks → hooks/src}/useDecoratedSearchResults.d.ts +0 -0
  119. /package/dist/preact/{src/hooks → hooks/src}/useFacet.d.ts +0 -0
  120. /package/dist/preact/{src/hooks → hooks/src}/useFacets.d.ts +0 -0
  121. /package/dist/preact/{src/hooks → hooks/src}/useLoadMore/getNextPageQuery.d.ts +0 -0
  122. /package/dist/preact/{src/hooks → hooks/src}/useLoadMore/useLoadMore.d.ts +0 -0
  123. /package/dist/preact/{src/hooks → hooks/src}/usePagination.d.ts +0 -0
  124. /package/dist/preact/{src/hooks → hooks/src}/usePersonalization.d.ts +0 -0
  125. /package/dist/preact/{src/hooks → hooks/src}/useProductFilters/useProductFilters.d.ts +0 -0
  126. /package/dist/preact/{src/hooks → hooks/src}/useProductFilters/useProductFiltersUtils.d.ts +0 -0
  127. /package/dist/preact/{src/hooks → hooks/src}/useRange.d.ts +0 -0
  128. /package/dist/preact/{src/hooks → hooks/src}/useRangeSelector.d.ts +0 -0
  129. /package/dist/preact/{src/hooks → hooks/src}/useResponse.d.ts +0 -0
  130. /package/dist/preact/{src/hooks → hooks/src}/useSelectedFiltersCount.d.ts +0 -0
  131. /package/dist/preact/{src/hooks → hooks/src}/useSizeOptions.d.ts +0 -0
  132. /package/dist/preact/{src/hooks → hooks/src}/useSort/useSort.d.ts +0 -0
  133. /package/dist/preact/{src/hooks → hooks/src}/useSort/utils.d.ts +0 -0
  134. /package/dist/preact/{src/hooks → hooks/src}/useSpeechToText.d.ts +0 -0
  135. /package/dist/preact/{src/hooks → hooks/src}/useSwatches/aggregateSwatches.d.ts +0 -0
  136. /package/dist/preact/{src/hooks → hooks/src}/useSwatches/applySelectionStates.d.ts +0 -0
  137. /package/dist/preact/{src/hooks → hooks/src}/useSwatches/sortOptions.d.ts +0 -0
  138. /package/dist/preact/{src/hooks → hooks/src}/useSwatches/useSwatches.d.ts +0 -0
@@ -0,0 +1,49 @@
1
+ import { u as n } from "../../jsxRuntime.module-Bzuv3cXw.js";
2
+ import { c as m, S as i, C as p } from "../../useActions-BIIcXXS6.js";
3
+ import { d as s, u as l, S as f } from "../../baseConfig-CTN0CcW-.js";
4
+ import { s as C } from "../../index.es-B8mbAxS4.js";
5
+ import { B as d } from "../../BaseElement-fZSwbg09.js";
6
+ import { useCallback as S } from "preact/hooks";
7
+ const g = {
8
+ ...s,
9
+ memoryCache: !1
10
+ };
11
+ function k(e) {
12
+ return {
13
+ pageType: "autocomplete",
14
+ ...g,
15
+ ...e
16
+ };
17
+ }
18
+ function I({ config: e, store: t, children: o }) {
19
+ const r = t ?? m();
20
+ return l(), /* @__PURE__ */ n(p, { value: k(e), children: /* @__PURE__ */ n(i, { value: r, children: [
21
+ /* @__PURE__ */ n(f, {}),
22
+ o
23
+ ] }) });
24
+ }
25
+ function P({
26
+ children: e,
27
+ hit: t,
28
+ as: o,
29
+ componentProps: r
30
+ }) {
31
+ const c = S(() => {
32
+ t && "productId" in t && C((a) => a.recordSearchClick("autocomplete", t));
33
+ }, [t]);
34
+ return /* @__PURE__ */ n(d, { onClick: c, as: o, componentProps: r, children: e });
35
+ }
36
+ function E({ as: e, componentProps: t, onSearchInput: o, children: r }) {
37
+ const c = {
38
+ ...t,
39
+ onInput: (u) => {
40
+ o(u.target);
41
+ }
42
+ }, a = e ?? "input";
43
+ return e || (c.type = "search"), /* @__PURE__ */ n(a, { ...c, children: r });
44
+ }
45
+ export {
46
+ P as AutocompleteElement,
47
+ I as AutocompletePageProvider,
48
+ E as SearchInput
49
+ };
@@ -1,4 +1,4 @@
1
- import { BaseConfig } from '../../base/baseConfig';
1
+ import { BaseConfig } from '../../common/src/config/baseConfig';
2
2
  export declare const defaultAutocompleteConfig: {
3
3
  memoryCache: false;
4
4
  defaultCurrency: string;
@@ -13,11 +13,11 @@ export interface AutocompleteConfig extends BaseConfig {
13
13
  }
14
14
  export type PublicAutocompleteConfig = Omit<AutocompleteConfig, keyof typeof defaultAutocompleteConfig | "pageType"> & Partial<Pick<AutocompleteConfig, keyof typeof defaultAutocompleteConfig>>;
15
15
  export declare function makeAutocompleteConfig(config: PublicAutocompleteConfig): {
16
- search?: import('../../../../../core/src/types').SearchOptions | undefined;
17
- onBeforeSearch?: ((context: import('../../../actions/types').ActionContext, options: import('../../../../../core/src/types').SearchOptions) => void) | undefined;
18
- onSearchError?: ((error: unknown, query: import('@nosto/nosto-js/client').SearchQuery, options: import('../../../../../core/src/types').SearchOptions, pageType: import('../../../api/types').PageType) => void) | undefined;
16
+ search?: import('../../../core/src/types').SearchOptions | undefined;
17
+ onBeforeSearch?: ((context: import('../../common/src/types').ActionContext, options: import('../../../core/src/types').SearchOptions) => void) | undefined;
18
+ onSearchError?: ((error: unknown, query: import('@nosto/nosto-js/client').SearchQuery, options: import('../../../core/src/types').SearchOptions, pageType: import('../../common/src/types').PageType) => void) | undefined;
19
19
  defaultCurrency: string;
20
- queryModifications: (query: import('@nosto/nosto-js/client').SearchQuery, pageType: import('../../../api/types').PageType | undefined) => import('@nosto/nosto-js/client').SearchQuery;
20
+ queryModifications: (query: import('@nosto/nosto-js/client').SearchQuery, pageType: import('../../common/src/types').PageType | undefined) => import('@nosto/nosto-js/client').SearchQuery;
21
21
  memoryCache: boolean;
22
22
  pageType: "autocomplete";
23
23
  };
@@ -1,6 +1,6 @@
1
- import { Store } from '../../../store';
1
+ import { Store } from '../../common/src/store/store';
2
2
  import { ComponentChildren } from 'preact';
3
- import { PublicAutocompleteConfig } from './config';
3
+ import { PublicAutocompleteConfig } from './AutocompleteConfig';
4
4
  type AutocompleteProps = {
5
5
  config: PublicAutocompleteConfig;
6
6
  store?: Store;
@@ -1,5 +1,5 @@
1
- import { AsComponent, BaseElementProps } from './BaseElement';
2
- import { KeywordHit, ProductHit } from './types';
1
+ import { AsComponent, BaseElementProps } from '../../../common/src/components/BaseElement';
2
+ import { KeywordHit, ProductHit } from '../types';
3
3
  export type AutocompleteElementProps<C extends AsComponent> = Omit<BaseElementProps<C>, "onClick"> & {
4
4
  hit: ProductHit | KeywordHit;
5
5
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../jsxRuntime.module-B3sGoTIU.cjs"),r=require("../../useActions-B-wWOcHo.cjs"),o=require("../../baseConfig-KREDcxnC.cjs"),u={...o.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function c(e){return{pageType:"category",...u,...e}}function s({config:e,store:n,children:a}){const i=n??r.createStore();return o.useCheckClientScript(),t.u(r.ConfigContext,{value:c(e),children:t.u(r.StoreContext,{value:i,children:[t.u(o.StoreActionsListener,{}),a]})})}exports.CategoryPageProvider=s;
@@ -0,0 +1,3 @@
1
+ /** @module preact/category */
2
+ export type { PublicCategoryConfig as CategoryConfig } from './src/CategoryConfig';
3
+ export { CategoryPageProvider } from './src/CategoryPageProvider';
@@ -0,0 +1,25 @@
1
+ import { u as t } from "../../jsxRuntime.module-Bzuv3cXw.js";
2
+ import { c as n, S as i, C as s } from "../../useActions-BIIcXXS6.js";
3
+ import { d as c, u as f, S as C } from "../../baseConfig-CTN0CcW-.js";
4
+ const l = {
5
+ ...c,
6
+ persistentSearchCache: !1,
7
+ preservePageScroll: !1
8
+ };
9
+ function u(e) {
10
+ return {
11
+ pageType: "category",
12
+ ...l,
13
+ ...e
14
+ };
15
+ }
16
+ function m({ config: e, store: r, children: o }) {
17
+ const a = r ?? n();
18
+ return f(), /* @__PURE__ */ t(s, { value: u(e), children: /* @__PURE__ */ t(i, { value: a, children: [
19
+ /* @__PURE__ */ t(C, {}),
20
+ o
21
+ ] }) });
22
+ }
23
+ export {
24
+ m as CategoryPageProvider
25
+ };
@@ -1,4 +1,4 @@
1
- import { BaseConfig } from '../../base/baseConfig';
1
+ import { BaseConfig } from '../../common/src/config/baseConfig';
2
2
  export declare const defaultCategoryConfig: {
3
3
  persistentSearchCache: false;
4
4
  preservePageScroll: false;
@@ -25,12 +25,12 @@ export interface CategoryConfig extends BaseConfig {
25
25
  }
26
26
  export type PublicCategoryConfig = Omit<CategoryConfig, keyof typeof defaultCategoryConfig | "pageType"> & Partial<Pick<CategoryConfig, keyof typeof defaultCategoryConfig>>;
27
27
  export declare function makeCategoryConfig(config: PublicCategoryConfig): {
28
- search?: import('../../../../../core/src/types').SearchOptions | undefined;
29
- onBeforeSearch?: ((context: import('../../../actions/types').ActionContext, options: import('../../../../../core/src/types').SearchOptions) => void) | undefined;
30
- onSearchError?: ((error: unknown, query: import('@nosto/nosto-js/client').SearchQuery, options: import('../../../../../core/src/types').SearchOptions, pageType: import('../../../api/types').PageType) => void) | undefined;
28
+ search?: import('../../../core/src/types').SearchOptions | undefined;
29
+ onBeforeSearch?: ((context: import('../../common/src/types').ActionContext, options: import('../../../core/src/types').SearchOptions) => void) | undefined;
30
+ onSearchError?: ((error: unknown, query: import('@nosto/nosto-js/client').SearchQuery, options: import('../../../core/src/types').SearchOptions, pageType: import('../../common/src/types').PageType) => void) | undefined;
31
31
  defaultCurrency: string;
32
- queryModifications: (query: import('@nosto/nosto-js/client').SearchQuery, pageType: import('../../../api/types').PageType | undefined) => import('@nosto/nosto-js/client').SearchQuery;
33
32
  persistentSearchCache: boolean;
34
33
  preservePageScroll: boolean;
34
+ queryModifications: (query: import('@nosto/nosto-js/client').SearchQuery, pageType: import('../../common/src/types').PageType | undefined) => import('@nosto/nosto-js/client').SearchQuery;
35
35
  pageType: "category";
36
36
  };
@@ -1,6 +1,6 @@
1
- import { Store } from '../../../store';
1
+ import { Store } from '../../common/src/store/store';
2
2
  import { ComponentChildren } from 'preact';
3
- import { PublicCategoryConfig } from './config';
3
+ import { PublicCategoryConfig } from './CategoryConfig';
4
4
  type CategoryProps = {
5
5
  config: PublicCategoryConfig;
6
6
  store?: Store;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../isBot-CheH1DcZ.cjs"),t=require("../../jsxRuntime.module-B3sGoTIU.cjs"),s=require("../../useLoadMore-BWgWw24W.cjs"),p=require("../../pick-rYi1lc2m.cjs"),n=require("../../InfiniteScrollWithObserver-wzwXCrZ7.cjs"),q=require("preact"),r=require("../../useActions-B-wWOcHo.cjs");function b({pageSize:o}){const{loadMore:e}=s.useLoadMore(o);return t.u("button",{onClick:e,children:"More results"})}function c({children:o,loadMoreComponent:e,pageSize:i}){const{loading:u,query:l,response:a}=s.useNostoAppState(S=>p.pick(S,"loading","query","response")),d=!u&&n.hasMoreResults(l,a);return t.u(q.Fragment,{children:[o,d&&(e?t.u(e,{pageSize:i}):t.u(b,{pageSize:i}))]})}const M=!f.isBot()&&n.intersectionObserverSupported()?n.InfiniteScrollWithObserver:c;exports.StoreContext=r.StoreContext;exports.createExtendableStore=r.createExtendableStore;exports.createStore=r.createStore;exports.defaultState=r.defaultState;exports.InfiniteScroll=M;exports.InfiniteScrollWithLink=c;
@@ -1,6 +1,6 @@
1
1
  /** @module preact/common */
2
2
  export { InfiniteScroll, type InfiniteScrollProps } from './src/components/InfiniteScroll/InfiniteScroll';
3
3
  export { InfiniteScrollWithLink } from './src/components/InfiniteScroll/InfiniteScrollWithLink';
4
- export { createStore, defaultState, type State, type Store } from './src/store';
5
- export { StoreContext } from './src/storeContext';
6
- export { createExtendableStore, type ExtendedStore } from './src/storeExtensions';
4
+ export { createStore, defaultState, type State, type Store } from './src/store/store';
5
+ export { StoreContext } from './src/store/storeContext';
6
+ export { createExtendableStore, type ExtendedStore } from './src/store/storeExtensions';
@@ -1,10 +1,10 @@
1
- import { i as l } from "../unique-m1TIDWdl.js";
2
- import { u as r } from "../jsxRuntime.module-Bzuv3cXw.js";
3
- import { a as p, b as m } from "../useLoadMore-FglaJn2W.js";
4
- import { p as u } from "../pick-DReBictn.js";
5
- import { h as d, i as f, I as S } from "../InfiniteScrollWithObserver-B6k7NAW1.js";
1
+ import { i as l } from "../../isBot-C58Y7eiv.js";
2
+ import { u as r } from "../../jsxRuntime.module-Bzuv3cXw.js";
3
+ import { u as p, a as m } from "../../useLoadMore-Dw7GDu8a.js";
4
+ import { p as u } from "../../pick-DReBictn.js";
5
+ import { h as d, i as f, I as S } from "../../InfiniteScrollWithObserver-BsydJKFj.js";
6
6
  import { Fragment as h } from "preact";
7
- import { S as O, a as W, c as A, d as B } from "../configContext-GuZOIX3o.js";
7
+ import { S as O, a as W, c as A, d as B } from "../../useActions-BIIcXXS6.js";
8
8
  function M({ pageSize: e }) {
9
9
  const { loadMore: o } = p(e);
10
10
  return /* @__PURE__ */ r("button", { onClick: o, children: "More results" });
@@ -1,4 +1,4 @@
1
- import { SearchOptions } from '../../../core/src/types';
1
+ import { SearchOptions } from '../../../../core/src/types';
2
2
  import { SearchQuery } from '@nosto/nosto-js/client';
3
- import { ActionContext } from './types';
3
+ import { ActionContext } from '../types';
4
4
  export declare function newSearch(context: ActionContext, query: SearchQuery, options?: SearchOptions): Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import { InputSearchRangeFilter } from '@nosto/nosto-js/client';
2
- import { ActionContext } from './types';
2
+ import { ActionContext } from '../types';
3
3
  export declare function replaceFilter(context: ActionContext, field: string, value: InputSearchRangeFilter | string | undefined): Promise<void>;
@@ -1,2 +1,2 @@
1
- import { ActionContext } from './types';
1
+ import { ActionContext } from '../types';
2
2
  export declare function toggleProductFilter(context: ActionContext, field: string, value: string, active: boolean): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { SearchOptions } from '../../../core/src/types';
1
+ import { SearchOptions } from '../../../../core/src/types';
2
2
  import { SearchQuery } from '@nosto/nosto-js/client';
3
- import { ActionContext } from './types';
3
+ import { ActionContext } from '../types';
4
4
  export declare function updateSearch(context: ActionContext, query: SearchQuery, options?: SearchOptions): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { SearchQuery } from '@nosto/nosto-js/client';
2
- import { PageType } from '../api/types';
3
- export declare function applyQueryDefaults(pageType: PageType, query: SearchQuery): {
2
+ import { PageType } from '../types';
3
+ export declare function withDefaultQuery(pageType: PageType, query: SearchQuery): {
4
4
  keywords?: import('@nosto/nosto-js/client').InputSearchQuery["keywords"] & {
5
5
  fields: string[];
6
6
  facets: string[];
@@ -41,5 +41,3 @@ export declare function applyQueryDefaults(pageType: PageType, query: SearchQuer
41
41
  time?: number | undefined;
42
42
  name?: string;
43
43
  };
44
- export declare const defaultProductFields: string[];
45
- export declare const defaultKeywordFields: string[];
@@ -1,7 +1,6 @@
1
1
  import { SearchOptions } from '../../../../core/src/types';
2
2
  import { SearchQuery } from '@nosto/nosto-js/client';
3
- import { ActionContext } from '../../actions/types';
4
- import { PageType } from '../../api/types';
3
+ import { ActionContext, PageType } from '../types';
5
4
  export declare const defaultBaseConfig: {
6
5
  defaultCurrency: string;
7
6
  queryModifications: (query: SearchQuery) => SearchQuery;
@@ -0,0 +1,4 @@
1
+ import { AutocompleteConfig } from '../../../autocomplete/src/AutocompleteConfig';
2
+ import { CategoryConfig } from '../../../category/src/CategoryConfig';
3
+ import { SerpConfig } from '../../../serp/src/SerpConfig';
4
+ export type Config = SerpConfig | CategoryConfig | AutocompleteConfig;
@@ -0,0 +1,6 @@
1
+ import { Config } from './config';
2
+ export declare const ConfigContext: import('preact').Context<Config | null>;
3
+ export declare const useConfig: () => Config;
4
+ export declare const useSerpConfig: () => import('../../../serp/src/SerpConfig').SerpConfig;
5
+ export declare const useCategoryConfig: () => import('../../../category/src/CategoryConfig').CategoryConfig;
6
+ export declare const useAutocompleteConfig: () => import('../../../autocomplete/src/AutocompleteConfig').AutocompleteConfig;
@@ -0,0 +1 @@
1
+ export declare function StoreActionsListener(): null;
@@ -1,4 +1,10 @@
1
1
  import { SearchQuery } from '@nosto/nosto-js/client';
2
+ import { Store } from '../common';
3
+ import { Config } from './config/config';
2
4
  export type PageType = "search" | "category" | "autocomplete";
3
5
  export type MaybeProvider<T> = T | (() => T);
4
6
  export type QueryProvider = MaybeProvider<Partial<SearchQuery>>;
7
+ export type ActionContext = {
8
+ store: Store;
9
+ config: Config;
10
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("preact/hooks"),t=require("../../eventBusSubscribe-B75y7otR.cjs"),o=({event:s,params:e})=>{window.dispatchEvent(new CustomEvent(`@nosto/search-js/${s}`,{detail:e}))},n=({event:s})=>u.useCallback(e=>{o({event:s,params:e})},[s]);exports.subscribeToNostoEvent=t.subscribeToNostoEvent;exports.useEventBusSubscribe=t.useEventBusSubscribe;exports.dispatchNostoEvent=o;exports.useEventBusDispatch=n;
@@ -0,0 +1,3 @@
1
+ /** @module preact/events */
2
+ export { dispatchNostoEvent, useEventBusDispatch } from './src/eventBusDispatch';
3
+ export { subscribeToNostoEvent, useEventBusSubscribe } from './src/eventBusSubscribe';
@@ -0,0 +1,23 @@
1
+ import { useCallback as o } from "preact/hooks";
2
+ import { s as c, u as i } from "../../eventBusSubscribe-Cxw0xUAm.js";
3
+ const e = ({
4
+ event: s,
5
+ params: t
6
+ }) => {
7
+ window.dispatchEvent(
8
+ new CustomEvent(`@nosto/search-js/${s}`, {
9
+ detail: t
10
+ })
11
+ );
12
+ }, r = ({ event: s }) => o(
13
+ (t) => {
14
+ e({ event: s, params: t });
15
+ },
16
+ [s]
17
+ );
18
+ export {
19
+ e as dispatchNostoEvent,
20
+ c as subscribeToNostoEvent,
21
+ r as useEventBusDispatch,
22
+ i as useEventBusSubscribe
23
+ };
@@ -0,0 +1,10 @@
1
+ import { AllowedEvents, EventParams } from './types';
2
+ type Props<T extends AllowedEvents> = {
3
+ event: T;
4
+ };
5
+ export declare const dispatchNostoEvent: <T extends AllowedEvents>({ event, params }: {
6
+ event: T;
7
+ params: EventParams[T];
8
+ }) => void;
9
+ export declare const useEventBusDispatch: <T extends AllowedEvents>({ event }: Props<T>) => (params: EventParams[T]) => void;
10
+ export {};
@@ -0,0 +1,8 @@
1
+ import { AllowedEvents, EventParams } from './types';
2
+ type Props<T extends AllowedEvents> = {
3
+ event: T;
4
+ callback: (params: EventParams[T]) => void;
5
+ };
6
+ export declare const subscribeToNostoEvent: <T extends AllowedEvents>({ event, callback }: Props<T>) => () => void;
7
+ export declare const useEventBusSubscribe: <T extends AllowedEvents>({ event, callback }: Props<T>) => void;
8
+ export {};
@@ -0,0 +1,26 @@
1
+ import { InputSearchRangeFilter, SearchOptions, SearchQuery } from '@nosto/nosto-js/client';
2
+ import { PageType } from '../../common/src/types';
3
+ export type EventParams = {
4
+ ["actions/newSearch"]: {
5
+ query: SearchQuery;
6
+ options?: SearchOptions;
7
+ targetStore: PageType;
8
+ };
9
+ ["actions/updateSearch"]: {
10
+ query: SearchQuery;
11
+ options?: SearchOptions;
12
+ targetStore: PageType;
13
+ };
14
+ ["actions/toggleProductFilter"]: {
15
+ field: string;
16
+ value: string;
17
+ active: boolean;
18
+ targetStore: PageType;
19
+ };
20
+ ["actions/replaceFilter"]: {
21
+ field: string;
22
+ value: InputSearchRangeFilter | string | undefined;
23
+ targetStore: PageType;
24
+ };
25
+ };
26
+ export type AllowedEvents = keyof EventParams;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../../useActions-B-wWOcHo.cjs"),x=require("../../logger-BcHMZObS.cjs"),h=require("../../useLoadMore-BWgWw24W.cjs"),d=require("preact/hooks"),L=require("../../index.es-DlUp67LT.cjs"),y=require("../../parseNumber-FsZ8w61u.cjs");function z(t){const n=h.useNostoAppState(e=>e.response);return t&&Array.isArray(t)||t&&x.isPlainObject(t)?t:n}function P(t,n){const e=t.data?.filter(f=>f.selected).length??0,{active:o}={active:e>0,...n},[r,c]=d.useState(o),{toggleProductFilter:u}=b.useActions(),l=d.useCallback(()=>{c(!r)},[r]);return{active:r,selectedFiltersCount:e,toggleActive:l,toggleProductFilter:u}}function T(){const{loading:t,facets:n}=h.useNostoAppState(e=>({loading:e.loading,facets:e.response?.products?.facets??[]}));return{loading:t,facets:n}}function q(t,n){const e=n-t;return!isNaN(e)&&e>0?new Array(n-t).fill(void 0).map((o,r)=>r+t):[]}function X(t){const{query:n,products:e}=h.useNostoAppState(o=>({query:o.query,products:o.response.products}));return d.useMemo(()=>{if(!e)return{totalPages:0,resultsFrom:0,resultsTo:0,pages:[]};const o=n.products?.from??0,r=t?.width??1/0,c=Math.max(Math.floor(r-1)/2,1),u=e.size>0?Math.floor(o/e.size)+1:1,l=e.size>0?Math.ceil(e.total/e.size):0,f=A=>A>=u-c&&A<=u+c,s=o+1,i=Math.min(o+e.total,e.total),a={from:o,page:u,current:!0},p=A=>({from:(A-1)*e.size,page:A,current:A===u}),S=u>1?p(u-1):void 0,m=u<l?p(u+1):void 0,g=u-c-1>1?p(1):void 0,v=u+c+1<l?p(l):void 0,F=q(1,l+1).filter(f).map(p);return!g&&F[0]?.page===2&&F.unshift(p(1)),!v&&F[F.length-1]?.page===l-1&&F.push(p(l)),{totalPages:l,resultsFrom:s,resultsTo:i,current:a,prev:S,next:m,first:g,last:v,pages:F}},[n,e,t?.width])}function O(){const[t,n]=d.useState([]),[e,o]=d.useState([]);return d.useEffect(()=>{L.s(async r=>{const{products:c,segments:u}=await r.getSearchSessionParams();n(u??[]),o(c?.personalizationBoost??[])})},[]),{segments:t,boost:e}}function j(){const{facets:t}=h.useNostoAppState(s=>({facets:s.response.products?.facets??[]})),{replaceFilter:n,toggleProductFilter:e}=b.useActions(),o=d.useCallback(s=>{const i=t?.find(a=>a.type==="stats"&&a.field===s);if(i&&"min"in i&&"max"in i)return i},[t]),r=d.useCallback(s=>t?.find(i=>i.field===s)?.name??s,[t]),c=d.useCallback(s=>"field"in s&&(s.value instanceof Array||s.range instanceof Array),[]),u=d.useCallback(s=>({...s,range:s.range?.map(i=>({gt:i.gt?Number(i.gt):i.gt,gte:i.gte?Number(i.gte):i.gte,lt:i.lt?Number(i.lt):i.lt,lte:i.lte?Number(i.lte):i.lte}))}),[]),l=d.useCallback(s=>(s.value??[]).map(a=>({value:a,field:s.field,name:r(s.field),filter:u(s),remove:()=>{e(s.field,a,!1)}})),[u,r,e]),f=d.useCallback(s=>(s.range??[]).map(a=>{const p=a.gte??a.gt??o(s.field)?.min,S=a.lte??a.lt??o(s.field)?.max;if(p!==void 0&&S!==void 0)return{value:`${p} - ${S}`,field:s.field,name:r(s.field),filter:u(s),remove:()=>{n(s.field,void 0)}}}).filter(Boolean),[u,o,r,n]);return{selectFilters:c,toValueFilter:l,toRangeFilter:f}}function R(){const{filter:t}=h.useNostoAppState(l=>({filter:l.query.products?.filter??[]})),{updateSearch:n}=b.useActions(),{selectFilters:e,toValueFilter:o,toRangeFilter:r}=j(),c=d.useMemo(()=>t?t.filter(e).flatMap(l=>"value"in l?o(l):"range"in l?r(l):[]).filter(Boolean):[],[t,e,r,o]),u=d.useCallback(()=>{n({products:{filter:[]}})},[n]);return{filters:c,removeAll:u}}function C(t){const{replaceFilter:n}=b.useActions(),{query:e,products:o}=h.useNostoAppState(a=>({query:a.query,products:a.response.products})),r=o?.facets?.find(a=>a.id===t);if(!r)return{min:0,max:0,range:[0,0],updateRange:()=>{}};const c=e.products?.filter?.find(a=>a.field===r.field),u=c?.range?c.range[0]:void 0,l=typeof u=="object"&&("gte"in u||"lte"in u)?[y.parseNumber(u.gte),y.parseNumber(u.lte)]:[void 0,void 0],f="min"in r?Math.floor(r.min):0,s="max"in r?Math.ceil(r.max):0,i=([a,p])=>{const S=a!==void 0?Math.floor(a):void 0,m=p!==void 0?Math.ceil(p):void 0,g=S!==void 0,v=m!==void 0;(f===S||!g)&&(s===m||!v)?n(r.field,void 0):(f===S||!g)&&v?n(r.field,{lte:m.toString()}):(s===m||!v)&&g?n(r.field,{gte:S.toString()}):g&&v&&n(r.field,{gte:S.toString(),lte:m.toString()})};return{min:f,max:s,range:[l[0]??f,l[1]??s],updateRange:i}}function V(t,n){const{min:e,max:o,range:r,updateRange:c}=C(t),{filters:u}=R(),l=d.useMemo(()=>{const a=u.find(g=>g?.filter?.range);let p=null;if(a){const g=a.filter.range?.[0];p=[y.parseNumber(g?.gte),y.parseNumber(g?.lte)]}const S=[];let m=Math.floor(e/n)*n;for(;m<o;){const g=m+n,v=p&&p[0]===m&&p[1]===g;S.push({min:m,max:g,selected:v}),m=g}return S},[u,e,o,n]),f=a=>{c([a,r[1]])},s=a=>{c([r[0],a])},i=e!==r[0]||o!==r[1];return{min:e,max:o,range:r,updateRange:c,ranges:l,handleMinChange:f,handleMaxChange:s,isSelected:i}}function D(){const{products:t,keywords:n}=h.useNostoAppState(e=>e.response);return{products:t??{hits:[],total:0},keywords:n??{hits:[],total:0}}}function B(){const t=h.useNostoAppState(e=>e.query.products?.filter);return d.useMemo(()=>t?t.reduce((e,o)=>e+(Array.isArray(o.value)?o.value.length:1),0):0,[t])}function N(t){return t&&!Number.isNaN(t)?t:0}function _(t,n){const{from:e,size:o,total:r}=h.useNostoAppState(s=>({from:N(s.query.products?.from??0),size:N(s.response?.products?.size??n),total:N(s.response?.products?.total??0)})),{updateSearch:c}=b.useActions(),u=e+o,l=[...t].reverse().filter(s=>s+n<r);return{from:e,to:u,total:r,size:o,sizeOptions:l,handleSizeChange:s=>{c({products:{size:y.parseNumber(s)}})}}}function E(t,n){return t.length!==n.length?!1:t.every(e=>n.find(o=>e.field===o.field&&e.order===o.order))}function U(t){const n=h.useNostoAppState(c=>c.query),{updateSearch:e}=b.useActions();return{activeSort:t.find(c=>E(c.value.sort,n.products?.sort||[]))?.id??t[0]?.id,setSort:c=>{const u=t.find(l=>l.id===c);u&&e({products:{sort:u.value.sort}})}}}const M=window.SpeechRecognition||window.webkitSpeechRecognition,k=!!(M&&typeof M=="function");function $(){return{listening:!1,startListening:()=>{},stopListening:()=>{}}}function I({language:t="en-US",interimResults:n=!1,onResult:e,onError:o}={}){const[r,c]=d.useState(!1),u=d.useRef(null),l=d.useCallback(()=>{const s=new M;s.lang=t,s.interimResults=n,s.onstart=()=>c(!0),e&&(s.onresult=i=>{const{transcript:a}=i.results?.[0]?.[0];e(a)}),o&&(s.onerror=i=>o(i.error)),s.onend=()=>c(!1),u.current=s,s.start()},[t,n,o,e]),f=d.useCallback(()=>{u.current?.stop()},[u]);return{listening:r,startListening:l,stopListening:f}}const Z=k?I:$;function G(t,n){if(!t.length||!n.length)return[];const e=n.reduce((o,r)=>(o[r]={},o),{});return t.forEach(o=>{o.customFields?.forEach(({key:r,value:c})=>{const u=r.toLowerCase();n.includes(u)&&(e[u][c]=e[u][c]||[],e[u][c].push(o))})}),Object.entries(e).filter(o=>Object.keys(o[1]).length).map(([o,r])=>({field:o,options:Object.entries(r).map(([c,u])=>({value:c,skus:u,unavailable:!1,selected:!1}))}))}function H(t,n){return t.length?t.map(({field:e,options:o})=>({field:e,options:o.map(r=>{const c=!r.skus?.some(l=>Object.entries(n).every(([f,s])=>f===e?!0:l.customFields?.find(a=>a.key.toLowerCase()===f)?.value===s)),u=n[e]===r.value;return{...r,unavailable:c,selected:u}})})):[]}const w=["4XS","3XS","2XS","XXS","XS","S","M","L","XL","XXL","2XL","XXXL","3XL","4XL"];function J(t){if(w.includes(t))return 1e3+w.indexOf(t);const n=parseFloat(t);return isNaN(n)?t:n}function K(t,n){return[...n].sort((e,o)=>{const[r,c]=[e.value,o.value].map(J);return r<c?-1:1})}function Q(t=[],n=[]){const[e,o]=d.useState({}),r=d.useMemo(()=>G(t,n).map(({field:s,options:i})=>({field:s,options:K(s,i)})),[t,n]),c=d.useMemo(()=>H(r,e),[r,e]),u=d.useCallback((f,s)=>{o(i=>{const a={...i};return a[f]===s?delete a[f]:a[f]=s,a})},[]),l=d.useMemo(()=>Object.keys(e).filter(i=>e[i]).length===0?[]:c.filter(({field:i})=>e[i]).map(({field:i,options:a})=>{const p=e[i];return a.find(m=>m.value===p)?.skus??[]}).reduce((i,a)=>i.filter(p=>a.includes(p))),[c,e]);return{swatches:c,toggleOption:u,matchedSkus:l}}exports.useActions=b.useActions;exports.useLoadMore=h.useLoadMore;exports.useNostoAppState=h.useNostoAppState;exports.speechToTextSupported=k;exports.useDecoratedSearchResults=z;exports.useFacet=P;exports.useFacets=T;exports.usePagination=X;exports.usePersonalization=O;exports.useProductFilters=R;exports.useRange=C;exports.useRangeSelector=V;exports.useResponse=D;exports.useSelectedFiltersCount=B;exports.useSizeOptions=_;exports.useSort=U;exports.useSpeechToText=Z;exports.useSwatches=Q;
@@ -0,0 +1,18 @@
1
+ /** @module preact/hooks */
2
+ export { useActions } from './src/useActions';
3
+ export { useDecoratedSearchResults } from './src/useDecoratedSearchResults';
4
+ export { useFacet, type UseFacetOptions } from './src/useFacet';
5
+ export { useFacets } from './src/useFacets';
6
+ export { useLoadMore } from './src/useLoadMore/useLoadMore';
7
+ export { useNostoAppState } from './src/useNostoAppState';
8
+ export { type Page, usePagination } from './src/usePagination';
9
+ export { usePersonalization } from './src/usePersonalization';
10
+ export { useProductFilters } from './src/useProductFilters/useProductFilters';
11
+ export { useRange } from './src/useRange';
12
+ export { useRangeSelector } from './src/useRangeSelector';
13
+ export { useResponse } from './src/useResponse';
14
+ export { useSelectedFiltersCount } from './src/useSelectedFiltersCount';
15
+ export { useSizeOptions } from './src/useSizeOptions';
16
+ export { useSort } from './src/useSort/useSort';
17
+ export { type SpeechToText, speechToTextSupported, useSpeechToText } from './src/useSpeechToText';
18
+ export { useSwatches } from './src/useSwatches/useSwatches';