@usereactify/search 5.45.0 → 5.46.0-beta.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 (38) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/package.json +2 -1
  3. package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.d.ts +6 -0
  4. package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js +3 -3
  5. package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -1
  6. package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
  7. package/dist/src/components/Sensor/SensorCustom.js +1 -1
  8. package/dist/src/components/Sensor/SensorCustom.js.map +1 -1
  9. package/dist/src/components/Suggestions/Suggestions.js +2 -2
  10. package/dist/src/components/Suggestions/Suggestions.js.map +1 -1
  11. package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +40 -35
  12. package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js.map +1 -1
  13. package/dist/src/hooks/useAnalytics.js +3 -0
  14. package/dist/src/hooks/useAnalytics.js.map +1 -1
  15. package/dist/src/hooks/useConfig.d.ts +1 -1
  16. package/dist/src/hooks/useConfig.js +3 -6
  17. package/dist/src/hooks/useConfig.js.map +1 -1
  18. package/dist/src/hooks/useFlags.js +8 -2
  19. package/dist/src/hooks/useFlags.js.map +1 -1
  20. package/dist/src/hooks/useReactifySearchContext.d.ts +8 -0
  21. package/dist/src/hooks/useReactifySearchContext.js.map +1 -1
  22. package/dist/src/hooks/useSortBy.js +4 -1
  23. package/dist/src/hooks/useSortBy.js.map +1 -1
  24. package/dist/src/index.d.ts +3 -0
  25. package/dist/src/index.js +3 -0
  26. package/dist/src/index.js.map +1 -1
  27. package/dist/src/types/config.d.ts +0 -3
  28. package/dist/src/types/config.js.map +1 -1
  29. package/dist/src/utility/config.d.ts +4 -0
  30. package/dist/src/utility/config.js +57 -0
  31. package/dist/src/utility/config.js.map +1 -0
  32. package/dist/src/utility/props.d.ts +292 -0
  33. package/dist/src/utility/props.js +255 -0
  34. package/dist/src/utility/props.js.map +1 -0
  35. package/dist/src/utility/server.d.ts +2 -0
  36. package/dist/src/utility/server.js +36 -0
  37. package/dist/src/utility/server.js.map +1 -0
  38. package/package.json +2 -1
package/dist/src/index.js CHANGED
@@ -20,4 +20,7 @@ __exportStar(require("./components"), exports);
20
20
  __exportStar(require("./hooks"), exports);
21
21
  __exportStar(require("./types"), exports);
22
22
  __exportStar(require("./utility/liquid"), exports);
23
+ __exportStar(require("./utility/server"), exports);
24
+ __exportStar(require("./utility/config"), exports);
25
+ __exportStar(require("./utility/props"), exports);
23
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAkC;AAClC,mEAAkC;AAElC,eAAK,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,sBAAG,CAAC,IAAI,KAAK,sBAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAEpD,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB;AACxB,mDAAiC","sourcesContent":["import { debug } from \"./utility\";\nimport pkg from \"../package.json\";\n\ndebug.log(\"package\", `${pkg.name} v${pkg.version}`);\n\nexport * from \"./components\";\nexport * from \"./hooks\";\nexport * from \"./types\";\nexport * from \"./utility/liquid\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAkC;AAClC,mEAAkC;AAElC,eAAK,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,sBAAG,CAAC,IAAI,KAAK,sBAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAEpD,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB;AACxB,mDAAiC;AACjC,mDAAiC;AACjC,mDAAiC;AACjC,kDAAgC","sourcesContent":["import { debug } from \"./utility\";\nimport pkg from \"../package.json\";\n\ndebug.log(\"package\", `${pkg.name} v${pkg.version}`);\n\nexport * from \"./components\";\nexport * from \"./hooks\";\nexport * from \"./types\";\nexport * from \"./utility/liquid\";\nexport * from \"./utility/server\";\nexport * from \"./utility/config\";\nexport * from \"./utility/props\";"]}
@@ -13,9 +13,6 @@ export interface Config {
13
13
  redirects: Array<ConfigRedirect>;
14
14
  curations: Array<ConfigCuration>;
15
15
  markets: Array<ConfigMarket>;
16
- suggestions: {
17
- exclude: Array<string>;
18
- };
19
16
  sensors: {
20
17
  search: Array<unknown>;
21
18
  collection: Array<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/types/config.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Sort,\n Filter,\n FilterOption,\n Redirect,\n Field,\n Curation,\n} from \"./firestore\";\n\n// when exposed as config, most resources have the `enabled` and `keywords` attributes removed\n// curation boosting groupings and sortings both have a json encoded elastic query added to them\nexport interface Config {\n index: string;\n endpoint: string;\n version: string;\n cache: {\n enabled: boolean;\n seconds: number;\n };\n sort: Array<ConfigSort>;\n fields: Array<ConfigField>;\n filters: Array<ConfigFilter>;\n redirects: Array<ConfigRedirect>;\n curations: Array<ConfigCuration>;\n markets: Array<ConfigMarket>;\n suggestions: {\n exclude: Array<string>;\n };\n sensors: {\n search: Array<unknown>;\n collection: Array<unknown>;\n };\n}\n\nexport type ConfigSort = Omit<Sort, \"enabled\">;\nexport type ConfigField = Omit<Field, \"enabled\">;\nexport type ConfigRedirect = Omit<Redirect, \"enabled\" | \"keywords\">;\nexport type ConfigFilter = Omit<Filter, \"enabled\" | \"keywords\"> & {\n options: Omit<FilterOption, \"enabled\">[];\n};\nexport type ConfigFilterOption = Omit<FilterOption, \"enabled\">;\nexport type ConfigCuration = Omit<\n Curation,\n \"keywords\" | \"boosting\" | \"longRunningTask\" | \"callouts\"\n> & {\n boosting: {\n groupings: (NonNullable<\n NonNullable<Curation[\"boosting\"]>[\"groupings\"]\n >[0] & { query: string })[];\n sortings: (NonNullable<NonNullable<Curation[\"boosting\"]>[\"sortings\"]>[0] & {\n query: string;\n })[];\n };\n};\nexport type ConfigMarket = {\n id: string;\n label: string;\n handle: string;\n enabled: boolean;\n}"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/types/config.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Sort,\n Filter,\n FilterOption,\n Redirect,\n Field,\n Curation,\n} from \"./firestore\";\n\n// when exposed as config, most resources have the `enabled` and `keywords` attributes removed\n// curation boosting groupings and sortings both have a json encoded elastic query added to them\nexport interface Config {\n index: string;\n endpoint: string;\n version: string;\n cache: {\n enabled: boolean;\n seconds: number;\n };\n sort: Array<ConfigSort>;\n fields: Array<ConfigField>;\n filters: Array<ConfigFilter>;\n redirects: Array<ConfigRedirect>;\n curations: Array<ConfigCuration>;\n markets: Array<ConfigMarket>;\n sensors: {\n search: Array<unknown>;\n collection: Array<unknown>;\n };\n}\n\nexport type ConfigSort = Omit<Sort, \"enabled\">;\nexport type ConfigField = Omit<Field, \"enabled\">;\nexport type ConfigRedirect = Omit<Redirect, \"enabled\" | \"keywords\">;\nexport type ConfigFilter = Omit<Filter, \"enabled\" | \"keywords\"> & {\n options: Omit<FilterOption, \"enabled\">[];\n};\nexport type ConfigFilterOption = Omit<FilterOption, \"enabled\">;\nexport type ConfigCuration = Omit<\n Curation,\n \"keywords\" | \"boosting\" | \"longRunningTask\" | \"callouts\"\n> & {\n boosting: {\n groupings: (NonNullable<\n NonNullable<Curation[\"boosting\"]>[\"groupings\"]\n >[0] & { query: string })[];\n sortings: (NonNullable<NonNullable<Curation[\"boosting\"]>[\"sortings\"]>[0] & {\n query: string;\n })[];\n };\n};\nexport type ConfigMarket = {\n id: string;\n label: string;\n handle: string;\n enabled: boolean;\n}"]}
@@ -0,0 +1,4 @@
1
+ import { Config } from "../types/config";
2
+ export declare const getConfigFromCache: () => Config | undefined;
3
+ export declare const getConfigFromNetwork: (shopifyPermanentDomain: string) => Promise<Config | undefined>;
4
+ export declare const getConfig: (shopifyPermanentDomain: string) => Promise<Config>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getConfig = exports.getConfigFromNetwork = exports.getConfigFromCache = void 0;
13
+ const getConfigFromCache = () => {
14
+ var _a, _b;
15
+ if (typeof window === "undefined") {
16
+ return;
17
+ }
18
+ const configFromCache = JSON.parse((_a = window.sessionStorage.getItem("reactify-search:config")) !== null && _a !== void 0 ? _a : "null");
19
+ if (configFromCache) {
20
+ if (((_b = configFromCache.config.cache) === null || _b === void 0 ? void 0 : _b.enabled) === false) {
21
+ return;
22
+ }
23
+ return configFromCache.config;
24
+ }
25
+ return;
26
+ };
27
+ exports.getConfigFromCache = getConfigFromCache;
28
+ const getConfigFromNetwork = (shopifyPermanentDomain) => __awaiter(void 0, void 0, void 0, function* () {
29
+ var _a, _b;
30
+ let configFromNetwork;
31
+ try {
32
+ configFromNetwork = (_a = (yield fetch(`https://config.usereactify.com/?shop=${shopifyPermanentDomain}`).then((response) => response.json()))) === null || _a === void 0 ? void 0 : _a.body;
33
+ }
34
+ catch (error) {
35
+ configFromNetwork = (_b = (yield fetch(`https://config.usereactify.com/?shop=${shopifyPermanentDomain}`).then((response) => response.json()))) === null || _b === void 0 ? void 0 : _b.body;
36
+ }
37
+ return configFromNetwork;
38
+ });
39
+ exports.getConfigFromNetwork = getConfigFromNetwork;
40
+ const getConfig = (shopifyPermanentDomain) => __awaiter(void 0, void 0, void 0, function* () {
41
+ const configFromCache = (0, exports.getConfigFromCache)();
42
+ if (configFromCache) {
43
+ return configFromCache;
44
+ }
45
+ const configFromNetwork = yield (0, exports.getConfigFromNetwork)(shopifyPermanentDomain);
46
+ if (!configFromNetwork) {
47
+ throw new Error("Unable to load config");
48
+ }
49
+ if (typeof window !== "undefined") {
50
+ window.sessionStorage.setItem("reactify-search:config", JSON.stringify({
51
+ config: configFromNetwork,
52
+ }));
53
+ }
54
+ return configFromNetwork;
55
+ });
56
+ exports.getConfig = getConfig;
57
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utility/config.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAEO,MAAM,kBAAkB,GAAG,GAAuB,EAAE;;IACzD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO;KACR;IAED,MAAM,eAAe,GAEV,IAAI,CAAC,KAAK,CACnB,MAAA,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,wBAAwB,CAAC,mCAAI,MAAM,CAClE,CAAC;IAEF,IAAI,eAAe,EAAE;QACnB,IAAI,CAAA,MAAA,eAAe,CAAC,MAAM,CAAC,KAAK,0CAAE,OAAO,MAAK,KAAK,EAAE;YACnD,OAAO;SACR;QAED,OAAO,eAAe,CAAC,MAAM,CAAC;KAC/B;IAED,OAAO;AACT,CAAC,CAAC;AApBW,QAAA,kBAAkB,sBAoB7B;AAEK,MAAM,oBAAoB,GAAG,CAAO,sBAA8B,EAA+B,EAAE;;IACxG,IAAI,iBAAqC,CAAC;IAC1C,IAAI;QACF,iBAAiB,GAAG,MAAA,CAAC,MAAM,KAAK,CAC9B,wCAAwC,sBAAsB,EAAE,CACjE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,0CAAE,IAAI,CAAC;KAE9C;IAAC,OAAO,KAAK,EAAE;QACd,iBAAiB,GAAG,MAAA,CAAC,MAAM,KAAK,CAC9B,wCAAwC,sBAAsB,EAAE,CACjE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,0CAAE,IAAI,CAAC;KAC9C;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAA,CAAC;AAdW,QAAA,oBAAoB,wBAc/B;AAEK,MAAM,SAAS,GAAG,CAAO,sBAA8B,EAAmB,EAAE;IACjF,MAAM,eAAe,GAAG,IAAA,0BAAkB,GAAE,CAAC;IAC7C,IAAI,eAAe,EAAE;QACnB,OAAO,eAAe,CAAC;KACxB;IAED,MAAM,iBAAiB,GAAG,MAAM,IAAA,4BAAoB,EAAC,sBAAsB,CAAC,CAAC;IAE7E,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;KAC1C;IAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,MAAM,CAAC,cAAc,CAAC,OAAO,CAC3B,wBAAwB,EACxB,IAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,iBAAiB;SAC1B,CAAC,CACH,CAAC;KACH;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAA,CAAC;AAtBW,QAAA,SAAS,aAsBpB","sourcesContent":["import { Config } from \"../types/config\";\n\nexport const getConfigFromCache = (): Config | undefined => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const configFromCache: {\n config: Config;\n } | null = JSON.parse(\n window.sessionStorage.getItem(\"reactify-search:config\") ?? \"null\"\n );\n\n if (configFromCache) {\n if (configFromCache.config.cache?.enabled === false) {\n return;\n }\n\n return configFromCache.config;\n }\n\n return;\n};\n\nexport const getConfigFromNetwork = async (shopifyPermanentDomain: string): Promise<Config | undefined> => {\n let configFromNetwork: Config | undefined;\n try {\n configFromNetwork = (await fetch(\n `https://config.usereactify.com/?shop=${shopifyPermanentDomain}`\n ).then((response) => response.json()))?.body;\n \n } catch (error) {\n configFromNetwork = (await fetch(\n `https://config.usereactify.com/?shop=${shopifyPermanentDomain}`\n ).then((response) => response.json()))?.body;\n }\n\n return configFromNetwork;\n};\n\nexport const getConfig = async (shopifyPermanentDomain: string): Promise<Config> => {\n const configFromCache = getConfigFromCache();\n if (configFromCache) {\n return configFromCache;\n }\n\n const configFromNetwork = await getConfigFromNetwork(shopifyPermanentDomain);\n\n if (!configFromNetwork) {\n throw new Error(\"Unable to load config\");\n }\n\n if (typeof window !== \"undefined\") {\n window.sessionStorage.setItem(\n \"reactify-search:config\",\n JSON.stringify({\n config: configFromNetwork,\n })\n );\n }\n\n return configFromNetwork;\n};\n"]}
@@ -0,0 +1,292 @@
1
+ /// <reference types="react" />
2
+ import { ReactiveList } from "@appbaseio/reactivesearch";
3
+ import { Config, ConfigFilter, ConfigFilterOption } from "../types";
4
+ export declare type GeneratePropsFilterGroupOptions = {
5
+ mode: "search" | "instant-search" | "collection";
6
+ config: Config;
7
+ filterGroup: ConfigFilter;
8
+ additionalComponentIds?: Array<string>;
9
+ includeFields?: Array<string>;
10
+ excludeFields?: Array<string>;
11
+ };
12
+ export declare const getPropsFilterGroup: (options: GeneratePropsFilterGroupOptions) => ({
13
+ URLParams: boolean;
14
+ componentId: string;
15
+ dataField: string;
16
+ filterLabel: string;
17
+ nestedField: string | undefined;
18
+ customQuery: ((value?: string | string[] | undefined) => {
19
+ query?: undefined;
20
+ } | {
21
+ query: {
22
+ nested: {
23
+ path: string;
24
+ query: {
25
+ bool: {
26
+ must: ({
27
+ match: {
28
+ "variants.available": string;
29
+ };
30
+ terms?: undefined;
31
+ } | {
32
+ terms: {
33
+ [x: string]: string[];
34
+ };
35
+ match?: undefined;
36
+ })[];
37
+ };
38
+ };
39
+ };
40
+ };
41
+ }) | undefined;
42
+ defaultQuery: (() => {
43
+ aggs: {
44
+ reactivesearch_nested: {
45
+ nested: {
46
+ path: string;
47
+ };
48
+ aggs: {
49
+ reactify_nested_outer: {
50
+ filter: {
51
+ bool: {
52
+ minimum_should_match: number;
53
+ should: {
54
+ match: {
55
+ "variants.available": string;
56
+ };
57
+ }[];
58
+ };
59
+ };
60
+ aggs: {
61
+ [x: string]: {
62
+ terms: {
63
+ field: string;
64
+ size: number;
65
+ order: {
66
+ _count: string;
67
+ };
68
+ };
69
+ aggs: {
70
+ parent_docs: {
71
+ reverse_nested: {};
72
+ };
73
+ };
74
+ };
75
+ };
76
+ };
77
+ };
78
+ };
79
+ };
80
+ }) | undefined;
81
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/SingleList").SingleList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/MultiList").MultiList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/SingleRange").SingleRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/MultiRange").MultiRangeProps, any> | undefined;
82
+ react: {
83
+ and: string[];
84
+ };
85
+ } | {
86
+ size: number;
87
+ URLParams: boolean;
88
+ showLoader: boolean;
89
+ dataField: string;
90
+ showResultStats: boolean;
91
+ react: {
92
+ and: string[];
93
+ };
94
+ includeFields: string[];
95
+ excludeFields: string[];
96
+ componentId: string;
97
+ scrollOnChange: boolean;
98
+ pagination: boolean;
99
+ infiniteScroll: boolean;
100
+ renderNoResults: () => null;
101
+ source: typeof ReactiveList;
102
+ })[];
103
+ export declare const getPropsFilterGroupOption: (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {
104
+ URLParams: boolean;
105
+ componentId: string;
106
+ dataField: string;
107
+ filterLabel: string;
108
+ nestedField: string | undefined;
109
+ customQuery: ((value?: string | string[] | undefined) => {
110
+ query?: undefined;
111
+ } | {
112
+ query: {
113
+ nested: {
114
+ path: string;
115
+ query: {
116
+ bool: {
117
+ must: ({
118
+ match: {
119
+ "variants.available": string;
120
+ };
121
+ terms?: undefined;
122
+ } | {
123
+ terms: {
124
+ [x: string]: string[];
125
+ };
126
+ match?: undefined;
127
+ })[];
128
+ };
129
+ };
130
+ };
131
+ };
132
+ }) | undefined;
133
+ defaultQuery: (() => {
134
+ aggs: {
135
+ reactivesearch_nested: {
136
+ nested: {
137
+ path: string;
138
+ };
139
+ aggs: {
140
+ reactify_nested_outer: {
141
+ filter: {
142
+ bool: {
143
+ minimum_should_match: number;
144
+ should: {
145
+ match: {
146
+ "variants.available": string;
147
+ };
148
+ }[];
149
+ };
150
+ };
151
+ aggs: {
152
+ [x: string]: {
153
+ terms: {
154
+ field: string;
155
+ size: number;
156
+ order: {
157
+ _count: string;
158
+ };
159
+ };
160
+ aggs: {
161
+ parent_docs: {
162
+ reverse_nested: {};
163
+ };
164
+ };
165
+ };
166
+ };
167
+ };
168
+ };
169
+ };
170
+ };
171
+ }) | undefined;
172
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/SingleList").SingleList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/MultiList").MultiList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/SingleRange").SingleRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/MultiRange").MultiRangeProps, any> | undefined;
173
+ react: {
174
+ and: string[];
175
+ };
176
+ };
177
+ export declare const getPropsResults: (options: GeneratePropsFilterGroupOptions) => {
178
+ size: number;
179
+ URLParams: boolean;
180
+ showLoader: boolean;
181
+ dataField: string;
182
+ showResultStats: boolean;
183
+ react: {
184
+ and: string[];
185
+ };
186
+ includeFields: string[];
187
+ excludeFields: string[];
188
+ componentId: string;
189
+ scrollOnChange: boolean;
190
+ pagination: boolean;
191
+ infiniteScroll: boolean;
192
+ renderNoResults: () => null;
193
+ source: typeof ReactiveList;
194
+ };
195
+ export declare const getPropsReact: (options: GeneratePropsFilterGroupOptions, filterGroupOption?: ConfigFilterOption | undefined) => {
196
+ and: string[];
197
+ };
198
+ export declare const getPropsShared: (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {
199
+ URLParams: boolean;
200
+ componentId: string;
201
+ dataField: string;
202
+ filterLabel: string;
203
+ nestedField: string | undefined;
204
+ customQuery: ((value?: string | string[] | undefined) => {
205
+ query?: undefined;
206
+ } | {
207
+ query: {
208
+ nested: {
209
+ path: string;
210
+ query: {
211
+ bool: {
212
+ must: ({
213
+ match: {
214
+ "variants.available": string;
215
+ };
216
+ terms?: undefined;
217
+ } | {
218
+ terms: {
219
+ [x: string]: string[];
220
+ };
221
+ match?: undefined;
222
+ })[];
223
+ };
224
+ };
225
+ };
226
+ };
227
+ }) | undefined;
228
+ defaultQuery: (() => {
229
+ aggs: {
230
+ reactivesearch_nested: {
231
+ nested: {
232
+ path: string;
233
+ };
234
+ aggs: {
235
+ reactify_nested_outer: {
236
+ filter: {
237
+ bool: {
238
+ minimum_should_match: number;
239
+ should: {
240
+ match: {
241
+ "variants.available": string;
242
+ };
243
+ }[];
244
+ };
245
+ };
246
+ aggs: {
247
+ [x: string]: {
248
+ terms: {
249
+ field: string;
250
+ size: number;
251
+ order: {
252
+ _count: string;
253
+ };
254
+ };
255
+ aggs: {
256
+ parent_docs: {
257
+ reverse_nested: {};
258
+ };
259
+ };
260
+ };
261
+ };
262
+ };
263
+ };
264
+ };
265
+ };
266
+ }) | undefined;
267
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/SingleList").SingleList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/MultiList").MultiList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/SingleRange").SingleRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/MultiRange").MultiRangeProps, any> | undefined;
268
+ react: {
269
+ and: string[];
270
+ };
271
+ };
272
+ export declare const getPropsFilterList: (filterGroupOption: ConfigFilterOption) => {
273
+ size: number | undefined;
274
+ queryFormat: "and" | "or";
275
+ showFilter: boolean;
276
+ showLoadMore: boolean;
277
+ showSearch: boolean;
278
+ showRadio: boolean;
279
+ showCheckbox: boolean;
280
+ };
281
+ export declare const getPropsFilterRange: (filterGroupOption: ConfigFilterOption) => {
282
+ queryFormat: "and" | "or";
283
+ showFilter: boolean;
284
+ showRadio: boolean;
285
+ showCheckbox: boolean;
286
+ data: {
287
+ label: string;
288
+ start: number;
289
+ end: number;
290
+ }[];
291
+ };
292
+ export declare const getPropsFilterSlider: (filterGroupOption: ConfigFilterOption) => {};
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPropsFilterSlider = exports.getPropsFilterRange = exports.getPropsFilterList = exports.getPropsShared = exports.getPropsReact = exports.getPropsResults = exports.getPropsFilterGroupOption = exports.getPropsFilterGroup = void 0;
4
+ const reactivesearch_1 = require("@appbaseio/reactivesearch");
5
+ const components_1 = require("../components");
6
+ const getPropsFilterGroup = (options) => {
7
+ return [
8
+ ...options.filterGroup.options.map((filterGroupOption) => (0, exports.getPropsFilterGroupOption)(options, filterGroupOption)),
9
+ (0, exports.getPropsResults)(options),
10
+ ];
11
+ };
12
+ exports.getPropsFilterGroup = getPropsFilterGroup;
13
+ const getPropsFilterGroupOption = (options, filterGroupOption) => {
14
+ let filterProps = {};
15
+ if (filterGroupOption.displayType === "slider") {
16
+ filterProps = (0, exports.getPropsFilterSlider)(filterGroupOption);
17
+ }
18
+ if (filterGroupOption.displayType === "single" || filterGroupOption.displayType === "multi") {
19
+ if (filterGroupOption.displayView === "range") {
20
+ filterProps = (0, exports.getPropsFilterRange)(filterGroupOption);
21
+ }
22
+ else {
23
+ filterProps = (0, exports.getPropsFilterList)(filterGroupOption);
24
+ }
25
+ }
26
+ const sharedProps = (0, exports.getPropsShared)(options, filterGroupOption);
27
+ return Object.assign(Object.assign({}, sharedProps), filterProps);
28
+ };
29
+ exports.getPropsFilterGroupOption = getPropsFilterGroupOption;
30
+ const getPropsResults = (options) => {
31
+ var _a, _b;
32
+ const includeFieldsProp = (() => {
33
+ var _a;
34
+ return [
35
+ ...((_a = options.includeFields) !== null && _a !== void 0 ? _a : []),
36
+ "id",
37
+ "title",
38
+ "type",
39
+ "handle",
40
+ "image",
41
+ "variants.id",
42
+ "variants.presentment_prices",
43
+ "callout",
44
+ ];
45
+ })();
46
+ const excludeFieldsProp = (() => {
47
+ var _a;
48
+ return [...((_a = options.excludeFields) !== null && _a !== void 0 ? _a : [])];
49
+ })();
50
+ return {
51
+ size: options.filterGroup.pageSize,
52
+ URLParams: true,
53
+ showLoader: false,
54
+ dataField: "title",
55
+ showResultStats: false,
56
+ react: (0, exports.getPropsReact)(options),
57
+ includeFields: includeFieldsProp,
58
+ excludeFields: excludeFieldsProp,
59
+ // scrollTarget: options.scrollTarget,
60
+ componentId: "page",
61
+ scrollOnChange: false,
62
+ pagination: ((_a = options.filterGroup) === null || _a === void 0 ? void 0 : _a.paginationType) !== "infinite_scroll",
63
+ infiniteScroll: ((_b = options.filterGroup) === null || _b === void 0 ? void 0 : _b.paginationType) === "infinite_scroll",
64
+ renderNoResults: () => null,
65
+ source: reactivesearch_1.ReactiveList,
66
+ };
67
+ };
68
+ exports.getPropsResults = getPropsResults;
69
+ const getPropsReact = (options, filterGroupOption) => {
70
+ const sensorIds = (0, components_1.SENSOR_IDS)(options.mode, options.config);
71
+ const reactProp = (() => {
72
+ var _a, _b, _c;
73
+ if (filterGroupOption === null || filterGroupOption === void 0 ? void 0 : filterGroupOption.settingsShowEmptyValues) {
74
+ return {
75
+ and: sensorIds,
76
+ };
77
+ }
78
+ return {
79
+ and: [
80
+ ...sensorIds,
81
+ ...((_a = options.additionalComponentIds) !== null && _a !== void 0 ? _a : []),
82
+ ...((_c = (_b = options.filterGroup) === null || _b === void 0 ? void 0 : _b.options.map((filter) => filter.handle)) !== null && _c !== void 0 ? _c : []),
83
+ ].filter((handle) => handle !== (filterGroupOption === null || filterGroupOption === void 0 ? void 0 : filterGroupOption.handle)),
84
+ };
85
+ })();
86
+ return reactProp;
87
+ };
88
+ exports.getPropsReact = getPropsReact;
89
+ const getPropsShared = (options, filterGroupOption) => {
90
+ const reactProp = (0, exports.getPropsReact)(options, filterGroupOption);
91
+ const nestedFieldProp = (() => {
92
+ const nestedFields = ["variants"];
93
+ const topField = filterGroupOption.field.split(".")[0];
94
+ if (nestedFields.includes(topField)) {
95
+ return topField;
96
+ }
97
+ return undefined;
98
+ })();
99
+ const customQueryProp = (() => {
100
+ if (!filterGroupOption.settingsHideUnavailable ||
101
+ !filterGroupOption.field.startsWith("variants."))
102
+ return undefined;
103
+ return (value) => {
104
+ if (!value)
105
+ return {};
106
+ // reactivesearch sometimes returns string, sometimes string[]
107
+ const valueArray = "string" === typeof value ? [value] : value;
108
+ if (0 === valueArray.length)
109
+ return {};
110
+ return {
111
+ query: {
112
+ nested: {
113
+ path: "variants",
114
+ query: {
115
+ bool: {
116
+ must: [
117
+ {
118
+ match: {
119
+ "variants.available": "true",
120
+ },
121
+ },
122
+ {
123
+ terms: {
124
+ [filterGroupOption.field]: valueArray,
125
+ },
126
+ },
127
+ ],
128
+ },
129
+ },
130
+ },
131
+ },
132
+ };
133
+ };
134
+ })();
135
+ const defaultQueryProp = (() => {
136
+ if (!filterGroupOption.field.startsWith("variants.")) {
137
+ return undefined;
138
+ }
139
+ // override the aggregation query to filter the results by the variants.available attribute
140
+ return () => {
141
+ return {
142
+ aggs: {
143
+ reactivesearch_nested: {
144
+ nested: { path: "variants" },
145
+ aggs: {
146
+ reactify_nested_outer: {
147
+ filter: {
148
+ bool: {
149
+ minimum_should_match: 1,
150
+ should: [
151
+ {
152
+ match: {
153
+ "variants.available": "true",
154
+ },
155
+ },
156
+ {
157
+ match: {
158
+ "variants.available": filterGroupOption.settingsHideUnavailable
159
+ ? "true"
160
+ : "false",
161
+ },
162
+ },
163
+ ],
164
+ },
165
+ },
166
+ aggs: {
167
+ [filterGroupOption.field]: {
168
+ terms: {
169
+ field: filterGroupOption.field,
170
+ size: 100,
171
+ order: { _count: "desc" },
172
+ },
173
+ aggs: {
174
+ parent_docs: { reverse_nested: {} },
175
+ },
176
+ },
177
+ },
178
+ },
179
+ },
180
+ },
181
+ },
182
+ };
183
+ };
184
+ })();
185
+ const sourceProp = (() => {
186
+ if (filterGroupOption.displayType === "slider") {
187
+ return reactivesearch_1.ReactiveComponent;
188
+ }
189
+ if (filterGroupOption.displayType === "single") {
190
+ if (filterGroupOption.displayView === "range") {
191
+ return reactivesearch_1.SingleRange;
192
+ }
193
+ return reactivesearch_1.SingleList;
194
+ }
195
+ if (filterGroupOption.displayType === "multi") {
196
+ if (filterGroupOption.displayView === "range") {
197
+ return reactivesearch_1.MultiRange;
198
+ }
199
+ return reactivesearch_1.MultiList;
200
+ }
201
+ return;
202
+ })();
203
+ return {
204
+ URLParams: true,
205
+ componentId: filterGroupOption.handle,
206
+ dataField: filterGroupOption.field,
207
+ filterLabel: filterGroupOption.name,
208
+ nestedField: nestedFieldProp,
209
+ customQuery: customQueryProp,
210
+ defaultQuery: defaultQueryProp,
211
+ source: sourceProp,
212
+ react: reactProp,
213
+ };
214
+ };
215
+ exports.getPropsShared = getPropsShared;
216
+ const getPropsFilterList = (filterGroupOption) => {
217
+ var _a, _b, _c, _d;
218
+ return {
219
+ size: parseInt(filterGroupOption.displaySize) || undefined,
220
+ queryFormat: (_a = filterGroupOption.settingsFilterLogic) !== null && _a !== void 0 ? _a : "or",
221
+ showFilter: (_b = filterGroupOption.settingsShowFilter) !== null && _b !== void 0 ? _b : true,
222
+ showLoadMore: (_c = filterGroupOption.settingsShowMore) !== null && _c !== void 0 ? _c : false,
223
+ showSearch: (_d = filterGroupOption.settingsShowSearch) !== null && _d !== void 0 ? _d : false,
224
+ showRadio: false,
225
+ showCheckbox: false,
226
+ };
227
+ };
228
+ exports.getPropsFilterList = getPropsFilterList;
229
+ const getPropsFilterRange = (filterGroupOption) => {
230
+ var _a, _b;
231
+ const data = (() => {
232
+ var _a, _b;
233
+ return ((_b = (_a = filterGroupOption.displayRangeOptions) === null || _a === void 0 ? void 0 : _a.map((option) => {
234
+ const [label, start, end] = option.split(":");
235
+ return {
236
+ label: label,
237
+ start: start ? parseInt(start) : 0,
238
+ end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,
239
+ };
240
+ })) !== null && _b !== void 0 ? _b : []);
241
+ })();
242
+ return {
243
+ queryFormat: (_a = filterGroupOption.settingsFilterLogic) !== null && _a !== void 0 ? _a : "or",
244
+ showFilter: (_b = filterGroupOption.settingsShowFilter) !== null && _b !== void 0 ? _b : true,
245
+ showRadio: false,
246
+ showCheckbox: false,
247
+ data: data,
248
+ };
249
+ };
250
+ exports.getPropsFilterRange = getPropsFilterRange;
251
+ const getPropsFilterSlider = (filterGroupOption) => {
252
+ return {};
253
+ };
254
+ exports.getPropsFilterSlider = getPropsFilterSlider;
255
+ //# sourceMappingURL=props.js.map