@usereactify/search 5.0.0-beta.13 → 5.0.0-beta.14
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 +10 -0
- package/dist/package.json +1 -1
- package/dist/src/components/ClearAll/ClearAll.d.ts +8 -0
- package/dist/src/components/ClearAll/ClearAll.js +29 -0
- package/dist/src/components/ClearAll/ClearAll.js.map +1 -0
- package/dist/src/components/ClearAll/index.d.ts +1 -0
- package/dist/src/components/ClearAll/index.js +14 -0
- package/dist/src/components/ClearAll/index.js.map +1 -0
- package/dist/src/components/CustomComponent/CustomComponent.d.ts +4 -0
- package/dist/src/components/CustomComponent/CustomComponent.js +13 -0
- package/dist/src/components/CustomComponent/CustomComponent.js.map +1 -0
- package/dist/src/components/CustomComponent/index.d.ts +1 -0
- package/dist/src/components/CustomComponent/index.js +14 -0
- package/dist/src/components/CustomComponent/index.js.map +1 -0
- package/dist/src/components/Example/ExampleClearAll.d.ts +4 -0
- package/dist/src/components/Example/ExampleClearAll.js +12 -0
- package/dist/src/components/Example/ExampleClearAll.js.map +1 -0
- package/dist/src/components/Example/ExampleFilterList.d.ts +5 -0
- package/dist/src/components/Example/ExampleFilterList.js +80 -9
- package/dist/src/components/Example/ExampleFilterList.js.map +1 -1
- package/dist/src/components/Example/ExampleFilterRange.js +6 -11
- package/dist/src/components/Example/ExampleFilterRange.js.map +1 -1
- package/dist/src/components/Example/ExampleFilterSlider.js +8 -9
- package/dist/src/components/Example/ExampleFilterSlider.js.map +1 -1
- package/dist/src/components/Example/ExampleFiltersActive.d.ts +4 -0
- package/dist/src/components/Example/ExampleFiltersActive.js +23 -0
- package/dist/src/components/Example/ExampleFiltersActive.js.map +1 -0
- package/dist/src/components/Example/ExampleStats.d.ts +4 -0
- package/dist/src/components/Example/ExampleStats.js +15 -0
- package/dist/src/components/Example/ExampleStats.js.map +1 -0
- package/dist/src/components/Example/index.d.ts +3 -0
- package/dist/src/components/Example/index.js +3 -0
- package/dist/src/components/Example/index.js.map +1 -1
- package/dist/src/components/Filter/Filter.d.ts +3 -3
- package/dist/src/components/Filter/Filter.js +22 -10
- package/dist/src/components/Filter/Filter.js.map +1 -1
- package/dist/src/components/Filter/FiltersActive.d.ts +16 -0
- package/dist/src/components/Filter/FiltersActive.js +36 -0
- package/dist/src/components/Filter/FiltersActive.js.map +1 -0
- package/dist/src/components/Filter/index.d.ts +1 -0
- package/dist/src/components/Filter/index.js +1 -0
- package/dist/src/components/Filter/index.js.map +1 -1
- package/dist/src/components/Stats/Stats.d.ts +7 -0
- package/dist/src/components/Stats/Stats.js +15 -0
- package/dist/src/components/Stats/Stats.js.map +1 -0
- package/dist/src/components/Stats/index.d.ts +1 -0
- package/dist/src/components/Stats/index.js +14 -0
- package/dist/src/components/Stats/index.js.map +1 -0
- package/dist/src/components/index.d.ts +3 -0
- package/dist/src/components/index.js +3 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/hooks/index.d.ts +2 -0
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +6 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +12 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +5 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +9 -2
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +1 -1
- package/dist/src/hooks/useConfig.js +1 -1
- package/dist/src/hooks/useConfig.js.map +1 -1
- package/dist/src/hooks/useFilterListProps.d.ts +2 -2
- package/dist/src/hooks/useFilterListProps.js +32 -2
- package/dist/src/hooks/useFilterListProps.js.map +1 -1
- package/dist/src/hooks/useFilterRangeProps.d.ts +10 -0
- package/dist/src/hooks/useFilterRangeProps.js +52 -0
- package/dist/src/hooks/useFilterRangeProps.js.map +1 -0
- package/dist/src/hooks/useFilterSliderProps.d.ts +12 -0
- package/dist/src/hooks/useFilterSliderProps.js +49 -0
- package/dist/src/hooks/useFilterSliderProps.js.map +1 -0
- package/dist/src/types/firestore.d.ts +3 -0
- package/dist/src/types/firestore.js.map +1 -1
- package/dist/src/types/reactivesearch.d.ts +1 -1
- package/dist/src/types/reactivesearch.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,wGAAgF;AAChF,0GAAkF;AAMlF,
|
|
1
|
+
{"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,wGAAgF;AAChF,0GAAkF;AAMlF,uCAOqB;AACrB,iDAI0B;AAC1B,8DAA4E;AAyBrE,MAAM,MAAM,GAA0B,CAAC,KAAK,EAAE,EAAE;IACrD,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACzC,OAAO,8BAAC,gBAAgB,oBAAK,KAAK,EAAI,CAAC;KACxC;IAED,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACxC,OAAO,8BAAC,eAAe,oBAAK,KAAK,EAAI,CAAC;KACvC;IAED,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACxC,OAAO,8BAAC,WAAW,oBAAK,KAAK,EAAI,CAAC;KACnC;IAED,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACzC,OAAO,8BAAC,YAAY,oBAAK,KAAK,EAAI,CAAC;KACpC;IAED,OAAO,CAAC,GAAG,CACT,6BAA6B,KAAK,CAAC,MAAM,CAAC,WAAW,qBAAqB,CAC3E,CA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eAAe,CAAC,OAAO,CAAC,MAAM,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,gBAAgB,EAAE;QACpB,MAAM,SAAS,GAAG,gBAAgB,CAAC;QACnC,OAAO,CACL,8BAAC,SAAS,kBACR,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;KACH;IAED,OAAO,CACL,8BAAC,8BAAiB,kBAChB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport MultiList from \"@appbaseio/reactivesearch/lib/components/list/MultiList\";\nimport SingleList from \"@appbaseio/reactivesearch/lib/components/list/SingleList\";\n\nimport type {\n ConfigFilterOption,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useReactiveFilterListProps,\n useReactiveFilterRangeProps,\n useReactiveFilterSliderProps,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\nimport { DynamicRangeSlider, SingleRange } from \"@appbaseio/reactivesearch\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterOption;\n /** Render method for List filters */\n renderFilterList?: React.FC<\n Omit<FilterProps, \"renderFilterList\"> & {\n filterListProps: ReturnType<typeof useFilterListProps>;\n }\n >;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<\n Omit<FilterProps, \"renderFilterRange\"> & {\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }\n >;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<\n Omit<FilterProps, \"renderFilterSlider\"> & {\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n }\n >;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n return <FilterMultiList {...props} />;\n }\n\n if (\"range\" === props.filter.displayType) {\n return <FilterRange {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n console.log(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <SingleList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <MultiList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRange: React.FC<FilterProps> = (props) => {\n const reactiveFilterRangeProps = useReactiveFilterRangeProps(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...reactiveFilterRangeProps}\n value={filterRangeProps.value}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactiveFilterSliderProps = useReactiveFilterSliderProps(props.filter);\n\n const filterSliderProps = useFilterSliderProps(props.filter);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <>\n {props.renderFilterSlider ? (\n <div\n style={{\n display: \"none\",\n }}\n >\n <DynamicRangeSlider\n {...reactiveFilterSliderProps}\n value={() => filterSliderProps.value}\n onChange={(value) =>\n filterSliderProps.handleChange({\n start: value[0],\n end: value[1],\n })\n }\n />\n </div>\n ) : null}\n <RenderSliderComponent\n filterSliderProps={filterSliderProps}\n filter={props.filter}\n />\n </>\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (0 === filterListProps.options.length) {\n return null;\n }\n\n if (renderFilterList) {\n const Component = renderFilterList;\n return (\n <Component\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n }\n\n return (\n <ExampleFilterList\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare type FiltersActiveProps = {
|
|
3
|
+
/** Render method called once for all active filters */
|
|
4
|
+
renderFiltersActive?: React.FC<{
|
|
5
|
+
selectedFilters: Array<{
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
value: Array<string> | string | {
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
handleRemove: (filterKey: string) => void;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
export declare const FiltersActive: React.FC<FiltersActiveProps>;
|
|
@@ -0,0 +1,36 @@
|
|
|
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.FiltersActive = void 0;
|
|
7
|
+
const reactivesearch_1 = require("@appbaseio/reactivesearch");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const components_1 = require("../../components");
|
|
10
|
+
const FiltersActive = (props) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const RenderFiltersActiveComponent = (_a = props.renderFiltersActive) !== null && _a !== void 0 ? _a : components_1.ExampleFiltersActive;
|
|
13
|
+
return (react_1.default.createElement(reactivesearch_1.SelectedFilters, { render: ({ selectedValues, setValue }) => {
|
|
14
|
+
const selectedFilters = Object.entries(selectedValues)
|
|
15
|
+
.filter(([key, item]) => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
return (item === null || item === void 0 ? void 0 : item.URLParams) &&
|
|
18
|
+
(item === null || item === void 0 ? void 0 : item.showFilter) &&
|
|
19
|
+
(!!((_a = item === null || item === void 0 ? void 0 : item.value) === null || _a === void 0 ? void 0 : _a.length) || !!((_b = item === null || item === void 0 ? void 0 : item.value) === null || _b === void 0 ? void 0 : _b.label));
|
|
20
|
+
})
|
|
21
|
+
.map(([key, item]) => ({
|
|
22
|
+
key: key,
|
|
23
|
+
label: item.label,
|
|
24
|
+
value: item.value,
|
|
25
|
+
}));
|
|
26
|
+
const handleRemove = (selectedFilterKey) => {
|
|
27
|
+
setValue(selectedFilterKey, null);
|
|
28
|
+
};
|
|
29
|
+
if (!selectedFilters.length) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return (react_1.default.createElement(RenderFiltersActiveComponent, { selectedFilters: selectedFilters, handleRemove: handleRemove }));
|
|
33
|
+
} }));
|
|
34
|
+
};
|
|
35
|
+
exports.FiltersActive = FiltersActive;
|
|
36
|
+
//# sourceMappingURL=FiltersActive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FiltersActive.js","sourceRoot":"","sources":["../../../../src/components/Filter/FiltersActive.tsx"],"names":[],"mappings":";;;;;;AAAA,8DAA4D;AAC5D,kDAA0B;AAE1B,iDAAwD;AAcjD,MAAM,aAAa,GAAiC,CAAC,KAAK,EA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["import { SelectedFilters } from \"@appbaseio/reactivesearch\";\nimport React from \"react\";\n\nimport { ExampleFiltersActive } from \"../../components\";\n\nexport type FiltersActiveProps = {\n /** Render method called once for all active filters */\n renderFiltersActive?: React.FC<{\n selectedFilters: Array<{\n key: string;\n label: string;\n value: Array<string> | string | { start: number; end: number };\n }>;\n handleRemove: (filterKey: string) => void;\n }>;\n};\n\nexport const FiltersActive: React.FC<FiltersActiveProps> = (props) => {\n const RenderFiltersActiveComponent =\n props.renderFiltersActive ?? ExampleFiltersActive;\n\n return (\n <SelectedFilters\n render={({ selectedValues, setValue }) => {\n const selectedFilters = (\n Object.entries(selectedValues) as Array<[string, any]>\n )\n .filter(\n ([key, item]) =>\n item?.URLParams &&\n item?.showFilter &&\n (!!item?.value?.length || !!item?.value?.label)\n )\n .map(([key, item]) => ({\n key: key,\n label: item.label,\n value: item.value,\n }));\n\n const handleRemove = (selectedFilterKey: string) => {\n setValue(selectedFilterKey, null);\n };\n\n if (!selectedFilters.length) {\n return null;\n }\n\n return (\n <RenderFiltersActiveComponent\n selectedFilters={selectedFilters}\n handleRemove={handleRemove}\n />\n );\n }}\n />\n );\n};\n"]}
|
|
@@ -12,4 +12,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./Filter"), exports);
|
|
14
14
|
__exportStar(require("./Filters"), exports);
|
|
15
|
+
__exportStar(require("./FiltersActive"), exports);
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Filter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B","sourcesContent":["export * from \"./Filter\";\nexport * from \"./Filters\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Filter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,kDAAgC","sourcesContent":["export * from \"./Filter\";\nexport * from \"./Filters\";\nexport * from \"./FiltersActive\";\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Stats = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const components_1 = require("../../components");
|
|
9
|
+
const Stats = (props) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const RenderStatsComponents = (_a = props.renderStats) !== null && _a !== void 0 ? _a : components_1.ExampleStats;
|
|
12
|
+
return (react_1.default.createElement(components_1.ResultStateProvider, { render: (renderProps) => react_1.default.createElement(RenderStatsComponents, Object.assign({}, renderProps)) }));
|
|
13
|
+
};
|
|
14
|
+
exports.Stats = Stats;
|
|
15
|
+
//# sourceMappingURL=Stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stats.js","sourceRoot":"","sources":["../../../../src/components/Stats/Stats.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,iDAAqE;AAO9D,MAAM,KAAK,GAAyB,CAAC,KAAK,EAAE,EAAE;;IACnD,MAAM,qBAAqB,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,yBAAY,CAAC;IAEhE,OAAO,CACL,8BAAC,gCAAmB,IAClB,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,8BAAC,qBAAqB,oBAAK,WAAW,EAAI,GACnE,CACH,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,KAAK,SAQhB","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchSearchStatePage } from \"../../types\";\nimport { ResultStateProvider, ExampleStats } from \"../../components\";\n\nexport type StatsProps = {\n /** Render method */\n renderStats?: React.FC<ReactivesearchSearchStatePage>;\n};\n\nexport const Stats: React.FC<StatsProps> = (props) => {\n const RenderStatsComponents = props.renderStats ?? ExampleStats;\n\n return (\n <ResultStateProvider\n render={(renderProps) => <RenderStatsComponents {...renderProps} />}\n />\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Stats";
|
|
@@ -0,0 +1,14 @@
|
|
|
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("./Stats"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Stats/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB","sourcesContent":["export * from \"./Stats\";\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from "./Example";
|
|
2
|
+
export * from "./CustomComponent";
|
|
3
|
+
export * from "./ClearAll";
|
|
2
4
|
export * from "./Filter";
|
|
3
5
|
export * from "./ReactifySearchProvider";
|
|
4
6
|
export * from "./Result";
|
|
5
7
|
export * from "./Search";
|
|
6
8
|
export * from "./Sensor";
|
|
7
9
|
export * from "./SortBy";
|
|
10
|
+
export * from "./Stats";
|
|
8
11
|
export * from "./Utility";
|
|
@@ -11,11 +11,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./Example"), exports);
|
|
14
|
+
__exportStar(require("./CustomComponent"), exports);
|
|
15
|
+
__exportStar(require("./ClearAll"), exports);
|
|
14
16
|
__exportStar(require("./Filter"), exports);
|
|
15
17
|
__exportStar(require("./ReactifySearchProvider"), exports);
|
|
16
18
|
__exportStar(require("./Result"), exports);
|
|
17
19
|
__exportStar(require("./Search"), exports);
|
|
18
20
|
__exportStar(require("./Sensor"), exports);
|
|
19
21
|
__exportStar(require("./SortBy"), exports);
|
|
22
|
+
__exportStar(require("./Stats"), exports);
|
|
20
23
|
__exportStar(require("./Utility"), exports);
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,2CAAyB;AACzB,2DAAyC;AACzC,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B","sourcesContent":["export * from \"./Example\";\nexport * from \"./Filter\";\nexport * from \"./ReactifySearchProvider\";\nexport * from \"./Result\";\nexport * from \"./Search\";\nexport * from \"./Sensor\";\nexport * from \"./SortBy\";\nexport * from \"./Utility\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,oDAAkC;AAClC,6CAA2B;AAC3B,2CAAyB;AACzB,2DAAyC;AACzC,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B","sourcesContent":["export * from \"./Example\";\nexport * from \"./CustomComponent\";\nexport * from \"./ClearAll\";\nexport * from \"./Filter\";\nexport * from \"./ReactifySearchProvider\";\nexport * from \"./Result\";\nexport * from \"./Search\";\nexport * from \"./Sensor\";\nexport * from \"./SortBy\";\nexport * from \"./Stats\";\nexport * from \"./Utility\";\n"]}
|
|
@@ -9,6 +9,8 @@ export * from "./useAnalytics";
|
|
|
9
9
|
export * from "./useFilters";
|
|
10
10
|
export * from "./useProductPrice";
|
|
11
11
|
export * from "./useFilterListProps";
|
|
12
|
+
export * from "./useFilterRangeProps";
|
|
13
|
+
export * from "./useFilterSliderProps";
|
|
12
14
|
export * from "./useFilterCollapsedState";
|
|
13
15
|
export * from "./useConfig";
|
|
14
16
|
export * from "./useReactifySearchContext";
|
package/dist/src/hooks/index.js
CHANGED
|
@@ -21,6 +21,8 @@ __exportStar(require("./useAnalytics"), exports);
|
|
|
21
21
|
__exportStar(require("./useFilters"), exports);
|
|
22
22
|
__exportStar(require("./useProductPrice"), exports);
|
|
23
23
|
__exportStar(require("./useFilterListProps"), exports);
|
|
24
|
+
__exportStar(require("./useFilterRangeProps"), exports);
|
|
25
|
+
__exportStar(require("./useFilterSliderProps"), exports);
|
|
24
26
|
__exportStar(require("./useFilterCollapsedState"), exports);
|
|
25
27
|
__exportStar(require("./useConfig"), exports);
|
|
26
28
|
__exportStar(require("./useReactifySearchContext"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC;AAEjC,gDAA8B;AAC9B,8CAA4B;AAC5B,kDAAgC;AAChC,0DAAwC;AACxC,8CAA4B;AAC5B,gDAA8B;AAC9B,iDAA+B;AAC/B,+CAA6B;AAC7B,oDAAkC;AAClC,uDAAqC;AACrC,4DAA0C;AAC1C,8CAA4B;AAC5B,6DAA2C","sourcesContent":["export * from \"./reactivesearch\";\n\nexport * from \"./useDebugger\";\nexport * from \"./useSortBy\";\nexport * from \"./usePagination\";\nexport * from \"./usePaginationLoadMore\";\nexport * from \"./useSearch\";\nexport * from \"./useCuration\";\nexport * from \"./useAnalytics\";\nexport * from \"./useFilters\";\nexport * from \"./useProductPrice\";\nexport * from \"./useFilterListProps\";\nexport * from \"./useFilterCollapsedState\";\nexport * from \"./useConfig\";\nexport * from \"./useReactifySearchContext\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC;AAEjC,gDAA8B;AAC9B,8CAA4B;AAC5B,kDAAgC;AAChC,0DAAwC;AACxC,8CAA4B;AAC5B,gDAA8B;AAC9B,iDAA+B;AAC/B,+CAA6B;AAC7B,oDAAkC;AAClC,uDAAqC;AACrC,wDAAsC;AACtC,yDAAuC;AACvC,4DAA0C;AAC1C,8CAA4B;AAC5B,6DAA2C","sourcesContent":["export * from \"./reactivesearch\";\n\nexport * from \"./useDebugger\";\nexport * from \"./useSortBy\";\nexport * from \"./usePagination\";\nexport * from \"./usePaginationLoadMore\";\nexport * from \"./useSearch\";\nexport * from \"./useCuration\";\nexport * from \"./useAnalytics\";\nexport * from \"./useFilters\";\nexport * from \"./useProductPrice\";\nexport * from \"./useFilterListProps\";\nexport * from \"./useFilterRangeProps\";\nexport * from \"./useFilterSliderProps\";\nexport * from \"./useFilterCollapsedState\";\nexport * from \"./useConfig\";\nexport * from \"./useReactifySearchContext\";\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ConfigFilterOption } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* For use with @appbaseio/reactivesearch SingleRange and MultiRange components
|
|
4
4
|
*/
|
|
@@ -6,6 +6,11 @@ export declare const useReactiveFilterRangeProps: (filter: ConfigFilterOption) =
|
|
|
6
6
|
showFilter: boolean;
|
|
7
7
|
showRadio: boolean;
|
|
8
8
|
showCheckbox: boolean;
|
|
9
|
+
data: {
|
|
10
|
+
label: string;
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
}[];
|
|
9
14
|
nestedField: string | undefined;
|
|
10
15
|
customQuery: ((value?: string | string[] | undefined) => {
|
|
11
16
|
query?: undefined;
|
|
@@ -13,9 +13,20 @@ const useReactiveReactProp_1 = require("./useReactiveReactProp");
|
|
|
13
13
|
const useReactiveFilterRangeProps = (filter) => {
|
|
14
14
|
const reactiveReactProp = (0, useReactiveReactProp_1.useReactiveReactProp)(filter.handle);
|
|
15
15
|
const reactiveFilterSharedProps = (0, useReactiveFilterSharedProps_1.useReactiveFilterSharedProps)(filter);
|
|
16
|
+
const data = react_1.default.useMemo(() => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
return ((_b = (_a = filter.displayRangeOptions) === null || _a === void 0 ? void 0 : _a.map((option) => {
|
|
19
|
+
const [label, start, end] = option.split(":");
|
|
20
|
+
return {
|
|
21
|
+
label: label,
|
|
22
|
+
start: start ? parseInt(start) : 0,
|
|
23
|
+
end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,
|
|
24
|
+
};
|
|
25
|
+
})) !== null && _b !== void 0 ? _b : []);
|
|
26
|
+
}, []);
|
|
16
27
|
const reactiveFilterRangeProps = react_1.default.useMemo(() => {
|
|
17
28
|
var _a;
|
|
18
|
-
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { showFilter: (_a = filter.settingsShowFilter) !== null && _a !== void 0 ? _a : true, showRadio: false, showCheckbox: false }));
|
|
29
|
+
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { showFilter: (_a = filter.settingsShowFilter) !== null && _a !== void 0 ? _a : true, showRadio: false, showCheckbox: false, data: data }));
|
|
19
30
|
}, [filter, reactiveReactProp]);
|
|
20
31
|
return reactiveFilterRangeProps;
|
|
21
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactiveFilterRangeProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveFilterRangeProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;
|
|
1
|
+
{"version":3,"file":"useReactiveFilterRangeProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveFilterRangeProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,iFAA8E;AAC9E,iEAA8D;AAE9D;;GAEG;AACI,MAAM,2BAA2B,GAAG,CAAC,MAA0B,EAAE,EAAE;IACxE,MAAM,iBAAiB,GAAG,IAAA,2CAAoB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9D,MAAM,yBAAyB,GAAG,IAAA,2DAA4B,EAAC,MAAM,CAAC,CAAC;IAEvE,MAAM,IAAI,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QAC9B,OAAO,CACL,MAAA,MAAA,MAAM,CAAC,mBAAmB,0CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACzC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC9C,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB;aACnD,CAAC;QACJ,CAAC,CAAC,mCAAI,EAAE,CACT,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,wBAAwB,GAAG,eAAK,CAAC,OAAO,CAC5C,GAAG,EAAE;;QAAC,OAAA,iCACD,yBAAyB,KAC5B,UAAU,EAAE,MAAA,MAAM,CAAC,kBAAkB,mCAAI,IAAI,EAC7C,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,KAAK,EACnB,IAAI,EAAE,IAAI,IACV,CAAA;KAAA,EACF,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAC5B,CAAC;IAEF,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC;AA7BW,QAAA,2BAA2B,+BA6BtC","sourcesContent":["import React from \"react\";\n\nimport { ConfigFilterOption } from \"../../types\";\n\nimport { useReactiveFilterSharedProps } from \"./useReactiveFilterSharedProps\";\nimport { useReactiveReactProp } from \"./useReactiveReactProp\";\n\n/**\n * For use with @appbaseio/reactivesearch SingleRange and MultiRange components\n */\nexport const useReactiveFilterRangeProps = (filter: ConfigFilterOption) => {\n const reactiveReactProp = useReactiveReactProp(filter.handle);\n const reactiveFilterSharedProps = useReactiveFilterSharedProps(filter);\n\n const data = React.useMemo(() => {\n return (\n filter.displayRangeOptions?.map((option) => {\n const [label, start, end] = option.split(\":\");\n return {\n label: label,\n start: start ? parseInt(start) : 0,\n end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,\n };\n }) ?? []\n );\n }, []);\n\n const reactiveFilterRangeProps = React.useMemo(\n () => ({\n ...reactiveFilterSharedProps,\n showFilter: filter.settingsShowFilter ?? true,\n showRadio: false,\n showCheckbox: false,\n data: data,\n }),\n [filter, reactiveReactProp]\n );\n\n return reactiveFilterRangeProps;\n};\n"]}
|
|
@@ -4,6 +4,11 @@ import type { ConfigFilterOption } from "../../types/config";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const useReactiveFilterSliderProps: (filter: ConfigFilterOption) => {
|
|
6
6
|
showFilter: boolean;
|
|
7
|
+
rangeLabels: (min: number, max: number) => {
|
|
8
|
+
start: string;
|
|
9
|
+
end: string;
|
|
10
|
+
};
|
|
11
|
+
stepValue: number;
|
|
7
12
|
nestedField: string | undefined;
|
|
8
13
|
customQuery: ((value?: string | string[] | undefined) => {
|
|
9
14
|
query?: undefined;
|
|
@@ -13,9 +13,16 @@ const useReactiveReactProp_1 = require("./useReactiveReactProp");
|
|
|
13
13
|
const useReactiveFilterSliderProps = (filter) => {
|
|
14
14
|
const reactiveReactProp = (0, useReactiveReactProp_1.useReactiveReactProp)(filter.handle);
|
|
15
15
|
const reactiveFilterSharedProps = (0, useReactiveFilterSharedProps_1.useReactiveFilterSharedProps)(filter);
|
|
16
|
+
const rangeLabelsFn = react_1.default.useCallback((min, max) => {
|
|
17
|
+
var _a, _b, _c, _d;
|
|
18
|
+
return ({
|
|
19
|
+
start: `${(_a = filter.displaySliderPrefix) !== null && _a !== void 0 ? _a : ""}${min}${(_b = filter.displaySliderSuffix) !== null && _b !== void 0 ? _b : ""}`,
|
|
20
|
+
end: `${(_c = filter.displaySliderPrefix) !== null && _c !== void 0 ? _c : ""}${max}${(_d = filter.displaySliderSuffix) !== null && _d !== void 0 ? _d : ""}`,
|
|
21
|
+
});
|
|
22
|
+
}, []);
|
|
16
23
|
const reactiveFilterSliderProps = react_1.default.useMemo(() => {
|
|
17
|
-
var _a;
|
|
18
|
-
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { showFilter: (_a = filter.settingsShowFilter) !== null && _a !== void 0 ? _a : true }));
|
|
24
|
+
var _a, _b;
|
|
25
|
+
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { showFilter: (_a = filter.settingsShowFilter) !== null && _a !== void 0 ? _a : true, rangeLabels: rangeLabelsFn, stepValue: (_b = parseInt(filter.displaySliderStep)) !== null && _b !== void 0 ? _b : undefined }));
|
|
19
26
|
}, [filter, reactiveReactProp]);
|
|
20
27
|
return reactiveFilterSliderProps;
|
|
21
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactiveFilterSliderProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveFilterSliderProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,iFAA8E;AAE9E,iEAA8D;AAE9D;;GAEG;AACI,MAAM,4BAA4B,GAAG,CAAC,MAA0B,EAAE,EAAE;IACzE,MAAM,iBAAiB,GAAG,IAAA,2CAAoB,EAAC,MAAM,CAAC,MAAM,CAAC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,iBAAiB,CAAC,mCAAI,SAAS,IAC1D,CAAA;KAAA,EACF,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAC5B,CAAC;IAEF,OAAO,yBAAyB,CAAC;AACnC,CAAC,CAAC;AA3BW,QAAA,4BAA4B,gCA2BvC","sourcesContent":["import React from \"react\";\n\nimport type { ConfigFilterOption } from \"../../types/config\";\nimport { useReactiveFilterSharedProps } from \"./useReactiveFilterSharedProps\";\n\nimport { useReactiveReactProp } from \"./useReactiveReactProp\";\n\n/**\n * For use with @appbaseio/reactivesearch RangeSlider component\n */\nexport const useReactiveFilterSliderProps = (filter: ConfigFilterOption) => {\n const reactiveReactProp = useReactiveReactProp(filter.handle);\n const reactiveFilterSharedProps = useReactiveFilterSharedProps(filter);\n\n const rangeLabelsFn = React.useCallback(\n (min: number, max: number) => ({\n start: `${filter.displaySliderPrefix ?? \"\"}${min}${\n filter.displaySliderSuffix ?? \"\"\n }`,\n end: `${filter.displaySliderPrefix ?? \"\"}${max}${\n filter.displaySliderSuffix ?? \"\"\n }`,\n }),\n []\n );\n\n const reactiveFilterSliderProps = React.useMemo(\n () => ({\n ...reactiveFilterSharedProps,\n showFilter: filter.settingsShowFilter ?? true,\n rangeLabels: rangeLabelsFn,\n stepValue: parseInt(filter.displaySliderStep) ?? undefined,\n }),\n [filter, reactiveReactProp]\n );\n\n return reactiveFilterSliderProps;\n};\n"]}
|
|
@@ -29,7 +29,7 @@ const useConfig = (shopifyPermanentDomain, configId) => {
|
|
|
29
29
|
const skipCache = new URLSearchParams(window.location.href.split("?")[1]).get("nocache") !==
|
|
30
30
|
null;
|
|
31
31
|
if (skipCache) {
|
|
32
|
-
utility_1.debug.log("
|
|
32
|
+
utility_1.debug.log("useConfig", "cache is disabled");
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const sessionConfig = JSON.parse((_a = window.sessionStorage.getItem("reactify-search:config")) !== null && _a !== void 0 ? _a : "null");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfig.js","sourceRoot":"","sources":["../../../src/hooks/useConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,wCAAmC;AAEnC,wBAAwB;AACxB,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE5B,MAAM,SAAS,GAAG,CACvB,sBAA8B,EAC9B,QAAiB,EAGjB,EAAE;IACF,2EAA2E;IAC3E,MAAM,YAAY,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QACtC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,OAAO;SACR;QACD,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;QAEhD,2DAA2D;QAC3D,MAAM,SAAS,GACb,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;YACtE,IAAI,CAAC;QACP,IAAI,SAAS,EAAE;YACb,eAAK,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"useConfig.js","sourceRoot":"","sources":["../../../src/hooks/useConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,wCAAmC;AAEnC,wBAAwB;AACxB,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE5B,MAAM,SAAS,GAAG,CACvB,sBAA8B,EAC9B,QAAiB,EAGjB,EAAE;IACF,2EAA2E;IAC3E,MAAM,YAAY,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QACtC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,OAAO;SACR;QACD,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;QAEhD,2DAA2D;QAC3D,MAAM,SAAS,GACb,IAAI,eAAe,CAAC,MAAM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,aA0GpB","sourcesContent":["import React from \"react\";\n\nimport { Config } from \"../types/config\";\nimport { debug } from \"../utility\";\n\n// 5 minute cache expiry\nconst CACHE_EXPIRY = 5 * 60 * 1000;\n\nexport const useConfig = (\n shopifyPermanentDomain: string,\n configId?: string\n): {\n config: Config | undefined;\n} => {\n // synchronously returns cached and non-expired config from session storage\n const cachedConfig = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n debug.log(\"useConfig\", \"checking config cache\");\n\n // skip checking cache if url search param \"nocache\" is set\n const skipCache =\n new URLSearchParams(window.location.href.split(\"?\")[1]).get(\"nocache\") !==\n null;\n if (skipCache) {\n debug.log(\"useConfig\", \"cache is disabled\");\n\n return;\n }\n\n const sessionConfig: {\n expiresAt: number;\n config: Config;\n } | null = JSON.parse(\n window.sessionStorage.getItem(\"reactify-search:config\") ?? \"null\"\n );\n\n if (sessionConfig) {\n const sessionConfigTtl = sessionConfig.expiresAt - Date.now();\n if (sessionConfigTtl > 0) {\n debug.log(\n \"useConfig\",\n `config cache valid, expires in ${(\n sessionConfigTtl / 1000\n ).toFixed()} seconds`\n );\n\n return sessionConfig.config;\n } else {\n debug.log(\n \"useConfig\",\n `config cache invalid, expired ${(\n (sessionConfigTtl * -1) /\n 1000\n ).toFixed()} seconds ago`\n );\n }\n }\n\n return;\n }, []);\n\n const [config, setConfig] = React.useState<Config | undefined>(cachedConfig);\n\n React.useEffect(() => {\n if (config) {\n return;\n }\n\n (async () => {\n debug.log(\"useConfig\", \"loading fresh config\");\n const searchParams = new URLSearchParams();\n searchParams.set(\"shop\", shopifyPermanentDomain);\n\n if (configId) {\n searchParams.set(\"id\", configId);\n }\n\n const skipCache =\n new URLSearchParams(window.location.href.split(\"?\")[1]).get(\n \"nocache\"\n ) !== null;\n\n if (skipCache) {\n searchParams.set(\"nocache\", \"true\");\n }\n\n const json = await fetch(\n `https://config.search.reactify.app/?${searchParams.toString()}`\n ).then((response) => response.json());\n\n setConfig(json.body);\n\n debug.log(\"useConfig\", \"loaded fresh config\");\n\n window.sessionStorage.setItem(\n \"reactify-search:config\",\n JSON.stringify({\n expiresAt: new Date().getTime() + CACHE_EXPIRY,\n noCache: skipCache,\n config: json.body,\n })\n );\n })();\n }, [shopifyPermanentDomain, configId]);\n\n React.useEffect(() => {\n debug.log(\"useConfig\", \"config\", config);\n }, [config]);\n\n return {\n config,\n };\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigFilterOption } from "../types/config";
|
|
2
|
-
import {
|
|
3
|
-
export declare const useFilterListProps: (filter: ConfigFilterOption, reactivesearchFilterProps:
|
|
2
|
+
import { ReactivesearchFilterListProps } from "../types/reactivesearch";
|
|
3
|
+
export declare const useFilterListProps: (filter: ConfigFilterOption, reactivesearchFilterProps: ReactivesearchFilterListProps) => ReactivesearchFilterListProps & {
|
|
4
4
|
filter: ConfigFilterOption;
|
|
5
5
|
options: Array<{
|
|
6
6
|
doc_count: number;
|
|
@@ -7,6 +7,32 @@ exports.useFilterListProps = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const hooks_1 = require("../hooks");
|
|
9
9
|
const utility_1 = require("../utility");
|
|
10
|
+
const DEFAULT_NUMERIC_SORT = ["0000", "000", "00", "0"];
|
|
11
|
+
const DEFAULT_ALPHABETICAL_SORT = [
|
|
12
|
+
"XXXS",
|
|
13
|
+
"XXS",
|
|
14
|
+
"XS",
|
|
15
|
+
"XS/S",
|
|
16
|
+
"S",
|
|
17
|
+
"SM",
|
|
18
|
+
"S/M",
|
|
19
|
+
"M",
|
|
20
|
+
"ML",
|
|
21
|
+
"M/L",
|
|
22
|
+
"L",
|
|
23
|
+
"LXL",
|
|
24
|
+
"L/XL",
|
|
25
|
+
"XL",
|
|
26
|
+
"2L",
|
|
27
|
+
"XXL",
|
|
28
|
+
"3L",
|
|
29
|
+
"XXXL",
|
|
30
|
+
"4L",
|
|
31
|
+
"5L",
|
|
32
|
+
"6L",
|
|
33
|
+
"OS",
|
|
34
|
+
"ONESIZE",
|
|
35
|
+
];
|
|
10
36
|
// converts reactivesearch props returned in filters to a cleaned up/filtered version
|
|
11
37
|
const useFilterListProps = (filter, reactivesearchFilterProps) => {
|
|
12
38
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
@@ -41,8 +67,12 @@ const useFilterListProps = (filter, reactivesearchFilterProps) => {
|
|
|
41
67
|
return false;
|
|
42
68
|
return true;
|
|
43
69
|
})
|
|
44
|
-
.sort((a, b) =>
|
|
45
|
-
.
|
|
70
|
+
.sort((a, b) => DEFAULT_NUMERIC_SORT.indexOf(a.key) -
|
|
71
|
+
DEFAULT_NUMERIC_SORT.indexOf(b.key))
|
|
72
|
+
.sort((a, b) => new Intl.Collator("en", { numeric: true, sensitivity: "base" }).compare(a.key, b.key))
|
|
73
|
+
.sort((a, b) => DEFAULT_ALPHABETICAL_SORT.indexOf(a.key) -
|
|
74
|
+
DEFAULT_ALPHABETICAL_SORT.indexOf(b.key))
|
|
75
|
+
.map((option) => (Object.assign(Object.assign({}, option), { key: filter.settingsUppercase ? option.key.toUpperCase() : option.key, checked: (typeof reactivesearchFilterProps.value === "object" &&
|
|
46
76
|
reactivesearchFilterProps.value[option.key]) ||
|
|
47
77
|
reactivesearchFilterProps.value === option.key })));
|
|
48
78
|
// work out if at least one option selected
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilterListProps.js","sourceRoot":"","sources":["../../../src/hooks/useFilterListProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,oCAAwC;AACxC,wCAAmC;AAEnC,qFAAqF;AAC9E,MAAM,kBAAkB,GAAG,CAChC,MAA0B,EAC1B,
|
|
1
|
+
{"version":3,"file":"useFilterListProps.js","sourceRoot":"","sources":["../../../src/hooks/useFilterListProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,oCAAwC;AACxC,wCAAmC;AAEnC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,KAA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,CAAC,KAAK,KAAK,MAAM,CAAC,GAAG,IAChD,CAAC,CAAC;QAEN,2CAA2C;QAC3C,MAAM,WAAW,GACf,CAAC,OAAO,yBAAyB,CAAC,KAAK,KAAK,QAAQ;YAClD,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;YAC1D,CAAC,OAAO,yBAAyB,CAAC,KAAK,KAAK,QAAQ;gBAClD,CAAC,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;QAEvC,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QAExE,uCACK,yBAAyB,KAC5B,YAAY;YACZ,MAAM;YACN,OAAO;YACP,WAAW;YACX,aAAa,IACb;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,yBAAyB,CAAC,CAAC,CAAC;IAEtD,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AA/FW,QAAA,kBAAkB,sBA+F7B","sourcesContent":["import React from \"react\";\n\nimport { ConfigFilterOption } from \"../types/config\";\nimport { ReactivesearchFilterListProps } from \"../types/reactivesearch\";\nimport { useAnalytics } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nconst DEFAULT_NUMERIC_SORT = [\"0000\", \"000\", \"00\", \"0\"];\nconst DEFAULT_ALPHABETICAL_SORT = [\n \"XXXS\",\n \"XXS\",\n \"XS\",\n \"XS/S\",\n \"S\",\n \"SM\",\n \"S/M\",\n \"M\",\n \"ML\",\n \"M/L\",\n \"L\",\n \"LXL\",\n \"L/XL\",\n \"XL\",\n \"2L\",\n \"XXL\",\n \"3L\",\n \"XXXL\",\n \"4L\",\n \"5L\",\n \"6L\",\n \"OS\",\n \"ONESIZE\",\n];\n\n// converts reactivesearch props returned in filters to a cleaned up/filtered version\nexport const useFilterListProps = (\n filter: ConfigFilterOption,\n reactivesearchFilterProps: ReactivesearchFilterListProps\n): ReactivesearchFilterListProps & {\n filter: ConfigFilterOption;\n options: Array<{\n doc_count: number;\n key: string;\n checked: boolean;\n }>;\n hasSelected: boolean;\n totalSelected: number;\n} => {\n const { track } = useAnalytics();\n\n const handleChange = React.useCallback(\n (value: string) => {\n debug.breadcrumb({\n category: \"filter\",\n message: \"filter option changed\",\n data: {\n filter: filter.name,\n field: filter.field,\n value: value,\n },\n });\n\n debug.log(\"useFilterListProps\", \"handleChange[value]\", value);\n\n reactivesearchFilterProps.handleChange(value);\n track({\n eventName: \"filterChange\",\n payload: {\n name: filter.name,\n value: value,\n },\n });\n },\n [filter]\n );\n\n const filterListProps = React.useMemo(() => {\n // remove excluded options, sort alphabeticaly, map checked boolean\n const options = reactivesearchFilterProps.data\n .filter(({ key }) => {\n if (filter.valuesExclude?.includes(key)) return false;\n if (!!filter.valuesManual?.length && !filter.valuesManual.includes(key))\n return false;\n return true;\n })\n .sort(\n (a, b) =>\n DEFAULT_NUMERIC_SORT.indexOf(a.key) -\n DEFAULT_NUMERIC_SORT.indexOf(b.key)\n )\n .sort((a, b) =>\n new Intl.Collator(\"en\", { numeric: true, sensitivity: \"base\" }).compare(\n a.key,\n b.key\n )\n )\n .sort(\n (a, b) =>\n DEFAULT_ALPHABETICAL_SORT.indexOf(a.key) -\n DEFAULT_ALPHABETICAL_SORT.indexOf(b.key)\n )\n .map((option) => ({\n ...option,\n key: filter.settingsUppercase ? option.key.toUpperCase() : option.key,\n checked:\n (typeof reactivesearchFilterProps.value === \"object\" &&\n reactivesearchFilterProps.value[option.key]) ||\n reactivesearchFilterProps.value === option.key,\n }));\n\n // work out if at least one option selected\n const hasSelected =\n (typeof reactivesearchFilterProps.value === \"object\" &&\n 0 < Object.keys(reactivesearchFilterProps.value).length) ||\n (typeof reactivesearchFilterProps.value !== \"object\" &&\n !!reactivesearchFilterProps.value);\n\n const totalSelected = options.filter((option) => option.checked).length;\n\n return {\n ...reactivesearchFilterProps,\n handleChange,\n filter,\n options,\n hasSelected,\n totalSelected,\n };\n }, [filter, handleChange, reactivesearchFilterProps]);\n\n return filterListProps;\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConfigFilterOption } from "../types/config";
|
|
2
|
+
export declare const useFilterRangeProps: (filter: ConfigFilterOption) => {
|
|
3
|
+
filter: ConfigFilterOption;
|
|
4
|
+
options: Array<{
|
|
5
|
+
key: string;
|
|
6
|
+
checked: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
value: string;
|
|
9
|
+
handleChange: (key: string) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
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.useFilterRangeProps = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const hooks_1 = require("../hooks");
|
|
9
|
+
const utility_1 = require("../utility");
|
|
10
|
+
const useFilterRangeProps = (filter) => {
|
|
11
|
+
const { track } = (0, hooks_1.useAnalytics)();
|
|
12
|
+
const [filterValue, setFilterValue] = react_1.default.useState("");
|
|
13
|
+
const handleChange = react_1.default.useCallback((value) => {
|
|
14
|
+
utility_1.debug.breadcrumb({
|
|
15
|
+
category: "filter",
|
|
16
|
+
message: "filter option changed",
|
|
17
|
+
data: {
|
|
18
|
+
filter: filter.name,
|
|
19
|
+
field: filter.field,
|
|
20
|
+
value: value,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
utility_1.debug.log("useFilterRangeProps", "handleChange[value]", value);
|
|
24
|
+
setFilterValue(value);
|
|
25
|
+
track({
|
|
26
|
+
eventName: "filterChange",
|
|
27
|
+
payload: {
|
|
28
|
+
name: filter.name,
|
|
29
|
+
value: value,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}, [filter]);
|
|
33
|
+
const filterRangeProps = react_1.default.useMemo(() => {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const options = (_b = (_a = filter.displayRangeOptions) === null || _a === void 0 ? void 0 : _a.map((option) => {
|
|
36
|
+
const [key] = option.split(":");
|
|
37
|
+
return {
|
|
38
|
+
key: key,
|
|
39
|
+
checked: filterValue === key,
|
|
40
|
+
};
|
|
41
|
+
})) !== null && _b !== void 0 ? _b : [];
|
|
42
|
+
return {
|
|
43
|
+
handleChange,
|
|
44
|
+
filter,
|
|
45
|
+
value: filterValue,
|
|
46
|
+
options,
|
|
47
|
+
};
|
|
48
|
+
}, [filter, filterValue, handleChange]);
|
|
49
|
+
return filterRangeProps;
|
|
50
|
+
};
|
|
51
|
+
exports.useFilterRangeProps = useFilterRangeProps;
|
|
52
|
+
//# sourceMappingURL=useFilterRangeProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFilterRangeProps.js","sourceRoot":"","sources":["../../../src/hooks/useFilterRangeProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAAwC;AACxC,wCAAmC;AAE5B,MAAM,mBAAmB,GAAG,CACjC,MAA0B,EAS1B,EAAE;IACF,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAS,EAAE,CAAC,CAAC;IAEjE,MAAM,YAAY,GAAG,eAAK,CAAC,WAAW,CACpC,CAAC,KAAa,EAAE,EAAE;QAChB,eAAK,CAAC,UAAU,CAAC;YACf,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,uBAAuB;YAChC,IAAI,EAAE;gBACJ,MAAM,EAAE,MAAM,CAAC,IAAI;gBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,KAAK,EAAE,KAAK;aACb;SACF,CAAC,CAAC;QAEH,eAAK,CAAC,GAAG,CAAC,qBAAqB,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;QAE/D,cAAc,CAAC,KAAK,CAAC,CAAC;QAEtB,KAAK,CAAC;YACJ,SAAS,EAAE,cAAc;YACzB,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,KAAK,EAAE,KAAK;aACb;SACF,CAAC,CAAC;IACL,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,MAAM,gBAAgB,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QAC1C,MAAM,OAAO,GACX,MAAA,MAAA,MAAM,CAAC,mBAAmB,0CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACzC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAChC,OAAO;gBACL,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,WAAW,KAAK,GAAG;aAC7B,CAAC;QACJ,CAAC,CAAC,mCAAI,EAAE,CAAC;QAEX,OAAO;YACL,YAAY;YACZ,MAAM;YACN,KAAK,EAAE,WAAW;YAClB,OAAO;SACR,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;IAExC,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AA5DW,QAAA,mBAAmB,uBA4D9B","sourcesContent":["import React from \"react\";\n\nimport { ConfigFilterOption } from \"../types/config\";\nimport { useAnalytics } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useFilterRangeProps = (\n filter: ConfigFilterOption\n): {\n filter: ConfigFilterOption;\n options: Array<{\n key: string;\n checked: boolean;\n }>;\n value: string;\n handleChange: (key: string) => void;\n} => {\n const { track } = useAnalytics();\n const [filterValue, setFilterValue] = React.useState<string>(\"\");\n\n const handleChange = React.useCallback(\n (value: string) => {\n debug.breadcrumb({\n category: \"filter\",\n message: \"filter option changed\",\n data: {\n filter: filter.name,\n field: filter.field,\n value: value,\n },\n });\n\n debug.log(\"useFilterRangeProps\", \"handleChange[value]\", value);\n\n setFilterValue(value);\n\n track({\n eventName: \"filterChange\",\n payload: {\n name: filter.name,\n value: value,\n },\n });\n },\n [filter]\n );\n\n const filterRangeProps = React.useMemo(() => {\n const options =\n filter.displayRangeOptions?.map((option) => {\n const [key] = option.split(\":\");\n return {\n key: key,\n checked: filterValue === key,\n };\n }) ?? [];\n\n return {\n handleChange,\n filter,\n value: filterValue,\n options,\n };\n }, [filter, filterValue, handleChange]);\n\n return filterRangeProps;\n};\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConfigFilterOption } from "../types/config";
|
|
2
|
+
export declare const useFilterSliderProps: (filter: ConfigFilterOption) => {
|
|
3
|
+
filter: ConfigFilterOption;
|
|
4
|
+
value: {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
};
|
|
8
|
+
handleChange: (value: {
|
|
9
|
+
start: number | string;
|
|
10
|
+
end: number | string;
|
|
11
|
+
}) => void;
|
|
12
|
+
};
|