@usereactify/search 4.4.0-beta.0 → 5.0.0-beta.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.
- package/CHANGELOG.md +49 -0
- package/package.json +8 -10
- package/dist/filter/Filter.d.ts +0 -12
- package/dist/filter/Filter.js +0 -71
- package/dist/filter/FilterList.d.ts +0 -4
- package/dist/filter/FilterList.js +0 -15
- package/dist/filter/FilterStack.d.ts +0 -11
- package/dist/filter/FilterStack.js +0 -25
- package/dist/filter/index.d.ts +0 -3
- package/dist/filter/index.js +0 -15
- package/dist/hooks/index.d.ts +0 -14
- package/dist/hooks/index.js +0 -26
- package/dist/hooks/reactivesearch/index.d.ts +0 -5
- package/dist/hooks/reactivesearch/index.js +0 -17
- package/dist/hooks/reactivesearch/useReactiveBaseProps.d.ts +0 -7
- package/dist/hooks/reactivesearch/useReactiveBaseProps.js +0 -43
- package/dist/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +0 -28
- package/dist/hooks/reactivesearch/useReactiveDataSearchProps.js +0 -71
- package/dist/hooks/reactivesearch/useReactiveFilterListProps.d.ts +0 -68
- package/dist/hooks/reactivesearch/useReactiveFilterListProps.js +0 -106
- package/dist/hooks/reactivesearch/useReactiveReactProp.d.ts +0 -3
- package/dist/hooks/reactivesearch/useReactiveReactProp.js +0 -25
- package/dist/hooks/reactivesearch/useReactiveResultListProps.d.ts +0 -19
- package/dist/hooks/reactivesearch/useReactiveResultListProps.js +0 -32
- package/dist/hooks/useAnalytics.d.ts +0 -95
- package/dist/hooks/useAnalytics.js +0 -110
- package/dist/hooks/useCollection.d.ts +0 -1
- package/dist/hooks/useCollection.js +0 -6
- package/dist/hooks/useConfig.d.ts +0 -1
- package/dist/hooks/useConfig.js +0 -6
- package/dist/hooks/useCuration.d.ts +0 -1
- package/dist/hooks/useCuration.js +0 -6
- package/dist/hooks/useFilterCollapsedState.d.ts +0 -8
- package/dist/hooks/useFilterCollapsedState.js +0 -27
- package/dist/hooks/useFilterListProps.d.ts +0 -22
- package/dist/hooks/useFilterListProps.js +0 -35
- package/dist/hooks/useFilterStack.d.ts +0 -1
- package/dist/hooks/useFilterStack.js +0 -6
- package/dist/hooks/useFilters.d.ts +0 -1
- package/dist/hooks/useFilters.js +0 -17
- package/dist/hooks/useLiveConfig.d.ts +0 -4
- package/dist/hooks/useLiveConfig.js +0 -74
- package/dist/hooks/usePages.d.ts +0 -10
- package/dist/hooks/usePages.js +0 -97
- package/dist/hooks/useProductPrice.d.ts +0 -12
- package/dist/hooks/useProductPrice.js +0 -61
- package/dist/hooks/useSearch.d.ts +0 -8
- package/dist/hooks/useSearch.js +0 -16
- package/dist/hooks/useSort.d.ts +0 -5
- package/dist/hooks/useSort.js +0 -24
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -24
- package/dist/provider.d.ts +0 -78
- package/dist/provider.js +0 -287
- package/dist/result/ResultCard.d.ts +0 -14
- package/dist/result/ResultCard.js +0 -66
- package/dist/result/ResultCardCallout.d.ts +0 -13
- package/dist/result/ResultCardCallout.js +0 -53
- package/dist/result/ResultList.d.ts +0 -34
- package/dist/result/ResultList.js +0 -93
- package/dist/result/ResultLoadMoreButton.d.ts +0 -10
- package/dist/result/ResultLoadMoreButton.js +0 -61
- package/dist/result/ResultPagination.d.ts +0 -10
- package/dist/result/ResultPagination.js +0 -60
- package/dist/result/ResultPaginationNextPrev.d.ts +0 -8
- package/dist/result/ResultPaginationNextPrev.js +0 -30
- package/dist/result/ResultStateProvider.d.ts +0 -7
- package/dist/result/ResultStateProvider.js +0 -10
- package/dist/result/index.d.ts +0 -6
- package/dist/result/index.js +0 -18
- package/dist/search/SearchInput.d.ts +0 -9
- package/dist/search/SearchInput.js +0 -17
- package/dist/search/index.d.ts +0 -1
- package/dist/search/index.js +0 -13
- package/dist/sensor/SensorCollection.d.ts +0 -2
- package/dist/sensor/SensorCollection.js +0 -41
- package/dist/sensor/SensorInventoryAvailable.d.ts +0 -2
- package/dist/sensor/SensorInventoryAvailable.js +0 -52
- package/dist/sensor/SensorPublished.d.ts +0 -2
- package/dist/sensor/SensorPublished.js +0 -16
- package/dist/sensor/SensorSearch.d.ts +0 -2
- package/dist/sensor/SensorSearch.js +0 -82
- package/dist/sensor/SensorSort.d.ts +0 -2
- package/dist/sensor/SensorSort.js +0 -205
- package/dist/sensor/SensorSortScore.d.ts +0 -2
- package/dist/sensor/SensorSortScore.js +0 -12
- package/dist/sensor/SensorStack.d.ts +0 -2
- package/dist/sensor/SensorStack.js +0 -31
- package/dist/sensor/index.d.ts +0 -8
- package/dist/sensor/index.js +0 -29
- package/dist/types/config.d.ts +0 -25
- package/dist/types/config.js +0 -2
- package/dist/types/elastic.d.ts +0 -209
- package/dist/types/elastic.js +0 -18
- package/dist/types/firestore.d.ts +0 -280
- package/dist/types/firestore.js +0 -18
- package/dist/types/graphql.d.ts +0 -26545
- package/dist/types/graphql.js +0 -4687
- package/dist/types/reactivesearch.d.ts +0 -73
- package/dist/types/reactivesearch.js +0 -2
- package/dist/types/shopify.d.ts +0 -21
- package/dist/types/shopify.js +0 -27
- package/dist/utility/UtilityAuthenticatedReactiveBase.d.ts +0 -2
- package/dist/utility/UtilityAuthenticatedReactiveBase.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,55 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [5.0.0-beta.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2022-07-26)
|
|
6
|
+
|
|
7
|
+
## [5.0.0-beta.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.1...v5.0.0-beta.0) (2022-07-25)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
* separate monolith provider into hooks and context
|
|
13
|
+
* align code and docs for v5
|
|
14
|
+
|
|
15
|
+
* align code and docs for v5 ([e1823a5](https://bitbucket.org/usereactify/reactify-search-ui/commit/e1823a5ab06dcea89b848bde4156f488241dea01))
|
|
16
|
+
* separate monolith provider into hooks and context ([4a85878](https://bitbucket.org/usereactify/reactify-search-ui/commit/4a858787ad547e87e10d3c3859ce41f87a4c3bbe))
|
|
17
|
+
|
|
18
|
+
## [5.0.0-beta.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.1...v5.0.0-beta.1) (2022-07-25)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### ⚠ BREAKING CHANGES
|
|
22
|
+
|
|
23
|
+
* separate monolith provider into hooks and context
|
|
24
|
+
* align code and docs for v5
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* add support for beta deployments ([e8249c1](https://bitbucket.org/usereactify/reactify-search-ui/commit/e8249c1e68647ec45a9eb90607bfc6ae8b0f17f2))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
* align code and docs for v5 ([e1823a5](https://bitbucket.org/usereactify/reactify-search-ui/commit/e1823a5ab06dcea89b848bde4156f488241dea01))
|
|
32
|
+
* separate monolith provider into hooks and context ([f29d15f](https://bitbucket.org/usereactify/reactify-search-ui/commit/f29d15f8d370403fdc72dd642bc5987868db7f15))
|
|
33
|
+
|
|
34
|
+
## [5.0.0-beta.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.1...v5.0.0-beta.0) (2022-07-25)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### ⚠ BREAKING CHANGES
|
|
38
|
+
|
|
39
|
+
* separate monolith provider into hooks and context
|
|
40
|
+
* align code and docs for v5
|
|
41
|
+
|
|
42
|
+
* align code and docs for v5 ([e1823a5](https://bitbucket.org/usereactify/reactify-search-ui/commit/e1823a5ab06dcea89b848bde4156f488241dea01))
|
|
43
|
+
* separate monolith provider into hooks and context ([f29d15f](https://bitbucket.org/usereactify/reactify-search-ui/commit/f29d15f8d370403fdc72dd642bc5987868db7f15))
|
|
44
|
+
|
|
45
|
+
### [4.4.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.0...v4.4.1) (2022-07-21)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Bug Fixes
|
|
49
|
+
|
|
50
|
+
* correct tsconfig ([e82defa](https://bitbucket.org/usereactify/reactify-search-ui/commit/e82defac47d754df543fc276319ba759de607507))
|
|
51
|
+
|
|
52
|
+
## [4.4.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.0-beta.0...v4.4.0) (2022-07-21)
|
|
53
|
+
|
|
5
54
|
## [4.4.0-beta.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.3.1...v4.4.0-beta.0) (2022-07-21)
|
|
6
55
|
|
|
7
56
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usereactify/search",
|
|
3
3
|
"description": "React UI library for Reactify Search",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-beta.1",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "dist/src/index.js",
|
|
7
|
+
"types": "dist/src/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
10
|
"README.md",
|
|
@@ -12,14 +12,11 @@
|
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"watch": "tsc --watch",
|
|
15
|
-
"release": "standard-version",
|
|
16
|
-
"release:
|
|
17
|
-
"release:beta": "standard-version --release-as minor --prerelease beta",
|
|
18
|
-
"release:local": "yalc publish",
|
|
15
|
+
"release": "standard-version --prerelease rc",
|
|
16
|
+
"release:beta": "standard-version --prerelease beta",
|
|
19
17
|
"build": "rimraf dist && tsc",
|
|
20
18
|
"prettier": "prettier --write .",
|
|
21
|
-
"storybook": "start-storybook -p 6006"
|
|
22
|
-
"build-storybook": "build-storybook"
|
|
19
|
+
"storybook": "start-storybook -p 6006"
|
|
23
20
|
},
|
|
24
21
|
"husky": {
|
|
25
22
|
"hooks": {
|
|
@@ -33,7 +30,8 @@
|
|
|
33
30
|
]
|
|
34
31
|
},
|
|
35
32
|
"dependencies": {
|
|
36
|
-
"@sentry/react": "7.
|
|
33
|
+
"@sentry/react": "7.7.0",
|
|
34
|
+
"@sentry/tracing": "7.7.0",
|
|
37
35
|
"ahooks": "2.10.11",
|
|
38
36
|
"axios": "0.26.1",
|
|
39
37
|
"currency.js": "2.0.4",
|
package/dist/filter/Filter.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ConfigFilterOption } from "../types/config";
|
|
3
|
-
import { useFilterListProps, useFilterCollapsedState } from "../hooks";
|
|
4
|
-
declare type Props = {
|
|
5
|
-
noWrapper?: boolean;
|
|
6
|
-
filter: ConfigFilterOption;
|
|
7
|
-
renderFilterList?: (props: Omit<Props, "renderFilterList"> & {
|
|
8
|
-
filterListProps: ReturnType<typeof useFilterListProps>;
|
|
9
|
-
}) => JSX.Element;
|
|
10
|
-
} & Partial<ReturnType<typeof useFilterCollapsedState>>;
|
|
11
|
-
export declare const Filter: React.FC<Props>;
|
|
12
|
-
export {};
|
package/dist/filter/Filter.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Filter = void 0;
|
|
18
|
-
const react_1 = __importDefault(require("react"));
|
|
19
|
-
const MultiList_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/list/MultiList"));
|
|
20
|
-
const SingleList_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/list/SingleList"));
|
|
21
|
-
const hooks_1 = require("../hooks");
|
|
22
|
-
const FilterList_1 = require("./FilterList");
|
|
23
|
-
const hooks_2 = require("../hooks");
|
|
24
|
-
const Filter = (props) => {
|
|
25
|
-
const { filter } = props;
|
|
26
|
-
const reactiveFilterListProps = (0, hooks_2.useReactiveFilterListProps)(filter);
|
|
27
|
-
if ("single" === filter.displayType) {
|
|
28
|
-
return (react_1.default.createElement(SingleList_1.default, Object.assign({}, reactiveFilterListProps, { render: (reactivesearchFilterProps) => (react_1.default.createElement(FilterListInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps }))) })));
|
|
29
|
-
}
|
|
30
|
-
if ("multi" === filter.displayType) {
|
|
31
|
-
return (react_1.default.createElement(MultiList_1.default, Object.assign({ showCheckbox: false }, reactiveFilterListProps, { render: (reactivesearchFilterProps) => (react_1.default.createElement(FilterListInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps }))) })));
|
|
32
|
-
}
|
|
33
|
-
console.log(`filter with display type "${filter.displayType}" not yet supported`);
|
|
34
|
-
return null;
|
|
35
|
-
};
|
|
36
|
-
exports.Filter = Filter;
|
|
37
|
-
// inner component exists only so we can use memos in reactivesearch render functions
|
|
38
|
-
const FilterListInner = (props) => {
|
|
39
|
-
const { filter, noWrapper, renderFilterList, reactivesearchFilterProps } = props, otherProps = __rest(props, ["filter", "noWrapper", "renderFilterList", "reactivesearchFilterProps"]);
|
|
40
|
-
const { track } = (0, hooks_1.useAnalytics)();
|
|
41
|
-
const _a = (0, hooks_2.useFilterListProps)(filter, reactivesearchFilterProps), { handleChange } = _a, filterListProps = __rest(_a, ["handleChange"]);
|
|
42
|
-
const handleFilterChange = react_1.default.useCallback((value) => {
|
|
43
|
-
handleChange(value);
|
|
44
|
-
track({
|
|
45
|
-
eventName: "filterChange",
|
|
46
|
-
payload: {
|
|
47
|
-
name: filter.name,
|
|
48
|
-
value: value,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}, [filterListProps]);
|
|
52
|
-
const updatedFilterListProps = Object.assign(Object.assign({}, filterListProps), { handleChange: handleFilterChange });
|
|
53
|
-
// hide entire filter when no options available
|
|
54
|
-
if (0 === filterListProps.options.length)
|
|
55
|
-
return null;
|
|
56
|
-
if (renderFilterList) {
|
|
57
|
-
return renderFilterList(Object.assign({ filterListProps: updatedFilterListProps, filter }, otherProps));
|
|
58
|
-
}
|
|
59
|
-
if (noWrapper) {
|
|
60
|
-
return react_1.default.createElement(FilterList_1.FilterList, Object.assign({}, updatedFilterListProps));
|
|
61
|
-
}
|
|
62
|
-
return (react_1.default.createElement(FilterWrapper, Object.assign({}, props),
|
|
63
|
-
react_1.default.createElement(FilterList_1.FilterList, Object.assign({}, updatedFilterListProps))));
|
|
64
|
-
};
|
|
65
|
-
// wrap the filter with a clickable title
|
|
66
|
-
const FilterWrapper = ({ filter, children, collapsed, shouldRender, collapsedToggle }) => {
|
|
67
|
-
return (react_1.default.createElement("div", null,
|
|
68
|
-
react_1.default.createElement("h1", { onClick: () => collapsedToggle && collapsedToggle() }, filter.name),
|
|
69
|
-
("undefined" === typeof shouldRender || !!shouldRender) && (react_1.default.createElement("div", { style: { display: collapsed ? "none" : "block" } }, children)),
|
|
70
|
-
"undefined" !== typeof collapsed && !!collapsed && (react_1.default.createElement("div", null, "Filter is collapsed."))));
|
|
71
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FilterList = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const FilterList = ({ options, handleChange }) => (react_1.default.createElement("ul", null, options.map(({ key, doc_count, checked }) => (react_1.default.createElement("li", { key: key },
|
|
9
|
-
react_1.default.createElement("label", null,
|
|
10
|
-
react_1.default.createElement("input", { value: key, type: "checkbox", checked: checked, onChange: ({ target: { value } }) => handleChange(value) }),
|
|
11
|
-
key,
|
|
12
|
-
" (",
|
|
13
|
-
doc_count,
|
|
14
|
-
")"))))));
|
|
15
|
-
exports.FilterList = FilterList;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ConfigFilterOption } from "../types/config";
|
|
3
|
-
import { useFilterCollapsedState } from "../hooks";
|
|
4
|
-
declare type Props = {
|
|
5
|
-
render?: (filters: ConfigFilterOption[]) => JSX.Element;
|
|
6
|
-
renderFilter?: (props: {
|
|
7
|
-
filter: ConfigFilterOption;
|
|
8
|
-
} & ReturnType<typeof useFilterCollapsedState>) => JSX.Element;
|
|
9
|
-
};
|
|
10
|
-
export declare const FilterStack: React.FC<Props>;
|
|
11
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FilterStack = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const Filter_1 = require("./Filter");
|
|
9
|
-
const hooks_1 = require("../hooks");
|
|
10
|
-
const FilterStack = (props) => {
|
|
11
|
-
const { render } = props;
|
|
12
|
-
const filters = (0, hooks_1.useFilters)();
|
|
13
|
-
if (0 === filters.length)
|
|
14
|
-
return null;
|
|
15
|
-
if (render)
|
|
16
|
-
return render(filters);
|
|
17
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, filters.map((filter) => (react_1.default.createElement(FilterWithState, Object.assign({ key: filter.id, filter: filter }, props))))));
|
|
18
|
-
};
|
|
19
|
-
exports.FilterStack = FilterStack;
|
|
20
|
-
const FilterWithState = ({ filter, renderFilter, }) => {
|
|
21
|
-
const collapsedProps = (0, hooks_1.useFilterCollapsedState)(filter);
|
|
22
|
-
if (renderFilter)
|
|
23
|
-
return renderFilter(Object.assign({ filter }, collapsedProps));
|
|
24
|
-
return react_1.default.createElement(Filter_1.Filter, Object.assign({ filter: filter }, collapsedProps));
|
|
25
|
-
};
|
package/dist/filter/index.d.ts
DELETED
package/dist/filter/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./Filter"), exports);
|
|
14
|
-
__exportStar(require("./FilterList"), exports);
|
|
15
|
-
__exportStar(require("./FilterStack"), exports);
|
package/dist/hooks/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from "./reactivesearch";
|
|
2
|
-
export * from "./useSort";
|
|
3
|
-
export * from "./usePages";
|
|
4
|
-
export * from "./useConfig";
|
|
5
|
-
export * from "./useSearch";
|
|
6
|
-
export * from "./useFilters";
|
|
7
|
-
export * from "./useCuration";
|
|
8
|
-
export * from "./useAnalytics";
|
|
9
|
-
export * from "./useCollection";
|
|
10
|
-
export * from "./useFilterStack";
|
|
11
|
-
export * from "./useProductPrice";
|
|
12
|
-
export * from "./useFilterListProps";
|
|
13
|
-
export * from "./useFilterCollapsedState";
|
|
14
|
-
export * from "./useLiveConfig";
|
package/dist/hooks/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./reactivesearch"), exports);
|
|
14
|
-
__exportStar(require("./useSort"), exports);
|
|
15
|
-
__exportStar(require("./usePages"), exports);
|
|
16
|
-
__exportStar(require("./useConfig"), exports);
|
|
17
|
-
__exportStar(require("./useSearch"), exports);
|
|
18
|
-
__exportStar(require("./useFilters"), exports);
|
|
19
|
-
__exportStar(require("./useCuration"), exports);
|
|
20
|
-
__exportStar(require("./useAnalytics"), exports);
|
|
21
|
-
__exportStar(require("./useCollection"), exports);
|
|
22
|
-
__exportStar(require("./useFilterStack"), exports);
|
|
23
|
-
__exportStar(require("./useProductPrice"), exports);
|
|
24
|
-
__exportStar(require("./useFilterListProps"), exports);
|
|
25
|
-
__exportStar(require("./useFilterCollapsedState"), exports);
|
|
26
|
-
__exportStar(require("./useLiveConfig"), exports);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./useReactiveBaseProps"), exports);
|
|
14
|
-
__exportStar(require("./useReactiveReactProp"), exports);
|
|
15
|
-
__exportStar(require("./useReactiveFilterListProps"), exports);
|
|
16
|
-
__exportStar(require("./useReactiveResultListProps"), exports);
|
|
17
|
-
__exportStar(require("./useReactiveDataSearchProps"), exports);
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.useReactiveBaseProps = void 0;
|
|
16
|
-
const react_1 = __importDefault(require("react"));
|
|
17
|
-
const provider_1 = require("../../provider");
|
|
18
|
-
const useReactiveBaseProps = () => {
|
|
19
|
-
const { index, credentials, theme } = (0, provider_1.useContext)();
|
|
20
|
-
return react_1.default.useMemo(() => ({
|
|
21
|
-
app: index,
|
|
22
|
-
url: credentials.endpoint,
|
|
23
|
-
credentials: `${credentials.username}:${credentials.password}`,
|
|
24
|
-
theme,
|
|
25
|
-
transformResponse: (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
var _a, _b, _c, _d;
|
|
27
|
-
// support filtering inside nested aggregations by moving the inner aggregation
|
|
28
|
-
// up one level such that reactivesearch understands it
|
|
29
|
-
//
|
|
30
|
-
// see useReactiveFilterListProps > defaultQuery to see how a filter is being applied
|
|
31
|
-
// to variant aggregations to ensure that only in stock sizes are displayed as filter
|
|
32
|
-
// options, this involves a nested filter, which requires this fix
|
|
33
|
-
//
|
|
34
|
-
// https://github.com/appbaseio/reactivesearch/issues/1530
|
|
35
|
-
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.aggregations) === null || _a === void 0 ? void 0 : _a.reactivesearch_nested) === null || _b === void 0 ? void 0 : _b.reactify_nested_outer) {
|
|
36
|
-
response.aggregations.reactivesearch_nested =
|
|
37
|
-
(_d = (_c = response === null || response === void 0 ? void 0 : response.aggregations) === null || _c === void 0 ? void 0 : _c.reactivesearch_nested) === null || _d === void 0 ? void 0 : _d.reactify_nested_outer;
|
|
38
|
-
}
|
|
39
|
-
return response;
|
|
40
|
-
}),
|
|
41
|
-
}), [credentials, theme]);
|
|
42
|
-
};
|
|
43
|
-
exports.useReactiveBaseProps = useReactiveBaseProps;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
declare type Props = {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
debounce?: number;
|
|
4
|
-
placeholder?: string;
|
|
5
|
-
inputClassName?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const useReactiveDataSearchProps: (props?: Props) => {
|
|
8
|
-
debounce?: number | undefined;
|
|
9
|
-
placeholder: string;
|
|
10
|
-
inputClassName?: string | undefined;
|
|
11
|
-
type: string;
|
|
12
|
-
showIcon: boolean;
|
|
13
|
-
fuzziness: 0 | 1 | 2 | "AUTO";
|
|
14
|
-
queryFormat: "and" | "or";
|
|
15
|
-
autosuggest: boolean;
|
|
16
|
-
value: string;
|
|
17
|
-
onKeyUp: (e: any) => void;
|
|
18
|
-
componentId: string;
|
|
19
|
-
dataField: string[];
|
|
20
|
-
fieldWeights: number[];
|
|
21
|
-
onChange: (value: string, triggerQuery: () => {}) => void;
|
|
22
|
-
onBlur: () => void;
|
|
23
|
-
onFocus: () => void;
|
|
24
|
-
innerClass: {
|
|
25
|
-
input: string | undefined;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useReactiveDataSearchProps = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const ahooks_1 = require("ahooks");
|
|
9
|
-
const debug = require("debug")("reactify-search:useReactiveDataSearchProps");
|
|
10
|
-
const __1 = require("../");
|
|
11
|
-
// default field for when zero search fields have been configured in Reactify
|
|
12
|
-
const defaultSearchField = {
|
|
13
|
-
id: "title",
|
|
14
|
-
field: "title",
|
|
15
|
-
importance: 0,
|
|
16
|
-
searchType: "instant_search",
|
|
17
|
-
};
|
|
18
|
-
const useReactiveDataSearchProps = (props = {}) => {
|
|
19
|
-
const { debounce, placeholder, inputClassName } = props;
|
|
20
|
-
react_1.default.useEffect(() => {
|
|
21
|
-
debug("props", props);
|
|
22
|
-
}, [props]);
|
|
23
|
-
const { fields } = (0, __1.useConfig)();
|
|
24
|
-
const { searchQuery, submitSearch, setSearchQuery, setShowInstantSearchResults, } = (0, __1.useSearch)();
|
|
25
|
-
const searchFields = react_1.default.useMemo(() => 0 < fields.length
|
|
26
|
-
? fields.filter((field) => ["always_search", "instant_search"].includes(field.searchType))
|
|
27
|
-
: [defaultSearchField], []);
|
|
28
|
-
react_1.default.useEffect(() => {
|
|
29
|
-
debug("searchFields", searchFields);
|
|
30
|
-
}, [searchFields]);
|
|
31
|
-
const handleKeyPress = react_1.default.useCallback((e) => {
|
|
32
|
-
if ("Enter" !== e.key)
|
|
33
|
-
return;
|
|
34
|
-
submitSearch();
|
|
35
|
-
}, [submitSearch]);
|
|
36
|
-
const { track } = (0, __1.useAnalytics)();
|
|
37
|
-
const trackQuery = react_1.default.useCallback(() => {
|
|
38
|
-
if (!searchQuery || (searchQuery && searchQuery.length < 3))
|
|
39
|
-
return;
|
|
40
|
-
track({ eventName: "search", payload: { searchTerm: searchQuery } });
|
|
41
|
-
}, [searchQuery, track]);
|
|
42
|
-
const { run: runDebouncedTriggerQuery, cancel: cancelDebouncedTriggerQuery } = (0, ahooks_1.useDebounceFn)((triggerQuery) => {
|
|
43
|
-
triggerQuery();
|
|
44
|
-
trackQuery();
|
|
45
|
-
}, {
|
|
46
|
-
wait: debounce !== null && debounce !== void 0 ? debounce : 300,
|
|
47
|
-
});
|
|
48
|
-
return react_1.default.useMemo(() => (Object.assign({ type: "search", showIcon: false, fuzziness: 1, queryFormat: "and", autosuggest: false, value: searchQuery !== null && searchQuery !== void 0 ? searchQuery : "", onKeyUp: handleKeyPress, componentId: "SearchInput", placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Search for a product...", dataField: searchFields.map((field) => field.field), fieldWeights: searchFields.map((field) => field.importance), onChange: (value, triggerQuery) => {
|
|
49
|
-
setSearchQuery(value);
|
|
50
|
-
if (!!value)
|
|
51
|
-
runDebouncedTriggerQuery(triggerQuery);
|
|
52
|
-
else
|
|
53
|
-
cancelDebouncedTriggerQuery();
|
|
54
|
-
}, onBlur: () => {
|
|
55
|
-
// setTimeout ensures that results are still clickable before close
|
|
56
|
-
setTimeout(() => setShowInstantSearchResults(false), 300);
|
|
57
|
-
}, onFocus: () => {
|
|
58
|
-
setShowInstantSearchResults(true);
|
|
59
|
-
}, innerClass: {
|
|
60
|
-
input: inputClassName,
|
|
61
|
-
} }, props)), [
|
|
62
|
-
searchQuery,
|
|
63
|
-
handleKeyPress,
|
|
64
|
-
placeholder,
|
|
65
|
-
searchFields,
|
|
66
|
-
setSearchQuery,
|
|
67
|
-
runDebouncedTriggerQuery,
|
|
68
|
-
cancelDebouncedTriggerQuery,
|
|
69
|
-
]);
|
|
70
|
-
};
|
|
71
|
-
exports.useReactiveDataSearchProps = useReactiveDataSearchProps;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { ConfigFilterOption } from "../../types/config";
|
|
2
|
-
export declare const useReactiveFilterListProps: (filter: ConfigFilterOption) => {
|
|
3
|
-
nestedField: string | undefined;
|
|
4
|
-
customQuery: ((value?: string | string[] | undefined) => {
|
|
5
|
-
query?: undefined;
|
|
6
|
-
} | {
|
|
7
|
-
query: {
|
|
8
|
-
nested: {
|
|
9
|
-
path: string;
|
|
10
|
-
query: {
|
|
11
|
-
bool: {
|
|
12
|
-
must: ({
|
|
13
|
-
match: {
|
|
14
|
-
"variants.available": string;
|
|
15
|
-
};
|
|
16
|
-
terms?: undefined;
|
|
17
|
-
} | {
|
|
18
|
-
terms: {
|
|
19
|
-
[x: string]: string[];
|
|
20
|
-
};
|
|
21
|
-
match?: undefined;
|
|
22
|
-
})[];
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
}) | undefined;
|
|
28
|
-
defaultQuery: (() => {
|
|
29
|
-
aggs: {
|
|
30
|
-
reactivesearch_nested: {
|
|
31
|
-
nested: {
|
|
32
|
-
path: string;
|
|
33
|
-
};
|
|
34
|
-
aggs: {
|
|
35
|
-
reactify_nested_outer: {
|
|
36
|
-
filter: {
|
|
37
|
-
match: {
|
|
38
|
-
"variants.available": string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
aggs: {
|
|
42
|
-
[x: string]: {
|
|
43
|
-
terms: {
|
|
44
|
-
field: string;
|
|
45
|
-
size: number;
|
|
46
|
-
order: {
|
|
47
|
-
_count: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
}) | undefined;
|
|
57
|
-
URLParams: boolean;
|
|
58
|
-
componentId: string;
|
|
59
|
-
dataField: string;
|
|
60
|
-
filterLabel: string;
|
|
61
|
-
react: {
|
|
62
|
-
and: string[];
|
|
63
|
-
};
|
|
64
|
-
size: number | undefined;
|
|
65
|
-
showFilter: true;
|
|
66
|
-
showLoadMore: boolean;
|
|
67
|
-
showSearch: boolean;
|
|
68
|
-
};
|