@mindful-web/marko-web-search 1.11.9 → 1.27.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.
- package/components/build-href.marko.js +2 -2
- package/components/filters/content-types.marko.js +2 -2
- package/components/filters/filter-block.marko.js +2 -2
- package/components/filters/filter-container.marko.js +2 -2
- package/components/filters/selected/index.marko.js +2 -2
- package/components/filters/selected/item.marko.js +2 -2
- package/components/filters/website-sections-by-alias.marko.js +2 -2
- package/components/filters/website-sections.marko.js +2 -2
- package/components/form/index.marko +7 -1
- package/components/form/index.marko.js +9 -3
- package/components/form/input.marko.js +2 -2
- package/components/links/link.marko.js +2 -2
- package/components/links/next-page.marko +15 -4
- package/components/links/next-page.marko.js +19 -9
- package/components/links/previous-page.marko +15 -4
- package/components/links/previous-page.marko.js +19 -9
- package/components/links/reset-filter.marko.js +2 -2
- package/components/links/set-filter-value.marko.js +2 -2
- package/components/marko.json +1 -0
- package/components/pagination-controls.marko +5 -2
- package/components/pagination-controls.marko.js +9 -5
- package/components/query-child-sections.marko.js +2 -2
- package/components/query.marko +26 -11
- package/components/query.marko.js +26 -16
- package/components/sort-by/index.marko.js +2 -2
- package/config/index.js +31 -20
- package/config/query-params.js +14 -6
- package/index.js +36 -3
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/build-href.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -42,5 +42,5 @@ marko_template._ = marko_renderer(render, {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
marko_template.meta = {
|
|
45
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
45
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/build-href.marko"
|
|
46
46
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/filters/content-types.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -35,7 +35,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
marko_template.meta = {
|
|
38
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
38
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/filters/content-types.marko",
|
|
39
39
|
tags: [
|
|
40
40
|
"./filter-block.marko"
|
|
41
41
|
]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/filters/filter-block.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -141,7 +141,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
marko_template.meta = {
|
|
144
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
144
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/filters/filter-block.marko",
|
|
145
145
|
tags: [
|
|
146
146
|
"@mindful-web/marko-web/components/browser-component.marko",
|
|
147
147
|
"../links/set-filter-value.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/filters/filter-container.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -76,7 +76,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
marko_template.meta = {
|
|
79
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
79
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/filters/filter-container.marko",
|
|
80
80
|
tags: [
|
|
81
81
|
"@mindful-web/marko-web/components/browser-component.marko",
|
|
82
82
|
"@mindful-web/marko-web/components/element/index.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/filters/selected/index.marko",
|
|
6
6
|
marko_component = require("./index.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
@@ -105,7 +105,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
105
105
|
}, marko_component);
|
|
106
106
|
|
|
107
107
|
marko_template.meta = {
|
|
108
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
108
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/filters/selected/index.marko",
|
|
109
109
|
component: "./index.marko",
|
|
110
110
|
tags: [
|
|
111
111
|
"./item.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/filters/selected/item.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -91,7 +91,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
marko_template.meta = {
|
|
94
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
94
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/filters/selected/item.marko",
|
|
95
95
|
tags: [
|
|
96
96
|
"@mindful-web/marko-web/components/element/index.marko",
|
|
97
97
|
"@mindful-web/marko-web-icons/components/icon.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/filters/website-sections-by-alias.marko",
|
|
6
6
|
marko_component = require("./website-sections-by-alias.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
@@ -130,7 +130,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
130
130
|
}, marko_component);
|
|
131
131
|
|
|
132
132
|
marko_template.meta = {
|
|
133
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
133
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/filters/website-sections-by-alias.marko",
|
|
134
134
|
component: "./website-sections-by-alias.marko",
|
|
135
135
|
tags: [
|
|
136
136
|
"../links/set-filter-value.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/filters/website-sections.marko",
|
|
6
6
|
marko_component = require("./website-sections.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
@@ -114,7 +114,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
114
114
|
}, marko_component);
|
|
115
115
|
|
|
116
116
|
marko_template.meta = {
|
|
117
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
117
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/filters/website-sections.marko",
|
|
118
118
|
component: "./website-sections.marko",
|
|
119
119
|
tags: [
|
|
120
120
|
"../links/set-filter-value.marko",
|
|
@@ -5,7 +5,13 @@ import { cleanPath } from "@mindful-web/utils";
|
|
|
5
5
|
$ const blockName = "marko-web-search-form";
|
|
6
6
|
$ const { req, $markoWebSearch: search } = out.global;
|
|
7
7
|
$ const path = defaultValue(input.path, req.path);
|
|
8
|
-
$ const params = search.buildURLSearchParams({
|
|
8
|
+
$ const params = search.buildURLSearchParams({
|
|
9
|
+
...(search.config.useMindful && {
|
|
10
|
+
cursorDirection: 'AFTER',
|
|
11
|
+
cursorValue: '',
|
|
12
|
+
}),
|
|
13
|
+
page: 1,
|
|
14
|
+
}, { searchQuery: true });
|
|
9
15
|
|
|
10
16
|
<marko-web-block ...input.block tag="form" name=blockName>
|
|
11
17
|
<@attrs
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/form/index.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -29,7 +29,13 @@ function render(input, out, __component, component, state) {
|
|
|
29
29
|
|
|
30
30
|
const path = defaultValue(input.path, req.path);
|
|
31
31
|
|
|
32
|
-
const params = search.buildURLSearchParams({
|
|
32
|
+
const params = search.buildURLSearchParams({
|
|
33
|
+
...(search.config.useMindful && {
|
|
34
|
+
cursorDirection: 'AFTER',
|
|
35
|
+
cursorValue: '',
|
|
36
|
+
}),
|
|
37
|
+
page: 1,
|
|
38
|
+
}, { searchQuery: true });
|
|
33
39
|
|
|
34
40
|
marko_web_block_tag(marko_assign({
|
|
35
41
|
name: "block",
|
|
@@ -72,7 +78,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
72
78
|
});
|
|
73
79
|
|
|
74
80
|
marko_template.meta = {
|
|
75
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
81
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/form/index.marko",
|
|
76
82
|
tags: [
|
|
77
83
|
"@mindful-web/marko-web/components/element/block.marko"
|
|
78
84
|
]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/form/input.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
marko_mergeAttrs = require("marko/dist/runtime/html/helpers/merge-attrs");
|
|
8
8
|
|
|
@@ -26,5 +26,5 @@ marko_template._ = marko_renderer(render, {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
marko_template.meta = {
|
|
29
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
29
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/form/input.marko"
|
|
30
30
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/links/link.marko",
|
|
6
6
|
marko_component = require("./link.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
@@ -38,7 +38,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
38
38
|
}, marko_component);
|
|
39
39
|
|
|
40
40
|
marko_template.meta = {
|
|
41
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
41
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/links/link.marko",
|
|
42
42
|
component: "./link.marko",
|
|
43
43
|
tags: [
|
|
44
44
|
"@mindful-web/marko-web/components/element/link.marko",
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { isFunction } from '@mindful-web/utils';
|
|
2
|
+
import defaultValue from "@mindful-web/marko-core/utils/default-value";
|
|
2
3
|
|
|
3
4
|
$ const { $markoWebSearch: search, i18n } = out.global;
|
|
5
|
+
$ const { useMindful } = search.config;
|
|
6
|
+
$ const pageInfo = defaultValue(input.pageInfo, {});
|
|
7
|
+
$ const { sortField, sortOrder } = search.input;
|
|
4
8
|
|
|
5
|
-
$ const
|
|
9
|
+
$ const queryValues = useMindful ? {
|
|
10
|
+
cursorDirection: 'AFTER',
|
|
11
|
+
cursorValue: pageInfo.endCursor,
|
|
12
|
+
sortField, sortOrder,
|
|
13
|
+
} : {
|
|
14
|
+
page: search.getNextPage(input.totalCount), sortField, sortOrder
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
$ const hasNextPage = useMindful ? pageInfo.hasNextPage : search.getNextPage(input.totalCount);
|
|
6
18
|
|
|
7
|
-
$ const { sortField, sortOrder } = search.input;
|
|
8
19
|
|
|
9
|
-
<if(
|
|
20
|
+
<if(hasNextPage)>
|
|
10
21
|
<marko-web-search-link
|
|
11
22
|
path=input.path
|
|
12
|
-
query-values=
|
|
23
|
+
query-values=queryValues
|
|
13
24
|
class=input.class
|
|
14
25
|
target=input.target
|
|
15
26
|
rel=input.rel
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/links/next-page.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_utils_module = require("@mindful-web/utils"),
|
|
8
8
|
utils_module = module_utils_module.default || module_utils_module,
|
|
9
9
|
isFunction = module_utils_module.isFunction,
|
|
10
|
+
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
11
|
+
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
10
12
|
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
11
13
|
helpers_escape_xml = require("marko/dist/runtime/html/helpers/escape-xml"),
|
|
12
14
|
marko_escapeXml = helpers_escape_xml.x,
|
|
@@ -19,18 +21,26 @@ function render(input, out, __component, component, state) {
|
|
|
19
21
|
|
|
20
22
|
const { $markoWebSearch: search, i18n } = out.global;
|
|
21
23
|
|
|
22
|
-
const
|
|
24
|
+
const { useMindful } = search.config;
|
|
25
|
+
|
|
26
|
+
const pageInfo = defaultValue(input.pageInfo, {});
|
|
23
27
|
|
|
24
28
|
const { sortField, sortOrder } = search.input;
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
const queryValues = useMindful ? {
|
|
31
|
+
cursorDirection: 'AFTER',
|
|
32
|
+
cursorValue: pageInfo.endCursor,
|
|
33
|
+
sortField, sortOrder,
|
|
34
|
+
} : {
|
|
35
|
+
page: search.getNextPage(input.totalCount), sortField, sortOrder
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const hasNextPage = useMindful ? pageInfo.hasNextPage : search.getNextPage(input.totalCount);
|
|
39
|
+
|
|
40
|
+
if (hasNextPage) {
|
|
27
41
|
marko_web_search_link_tag({
|
|
28
42
|
path: input.path,
|
|
29
|
-
queryValues:
|
|
30
|
-
page: nextPage,
|
|
31
|
-
sortField: sortField,
|
|
32
|
-
sortOrder: sortOrder
|
|
33
|
-
},
|
|
43
|
+
queryValues: queryValues,
|
|
34
44
|
class: input.class,
|
|
35
45
|
target: input.target,
|
|
36
46
|
rel: input.rel,
|
|
@@ -52,7 +62,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
52
62
|
});
|
|
53
63
|
|
|
54
64
|
marko_template.meta = {
|
|
55
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
65
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/links/next-page.marko",
|
|
56
66
|
tags: [
|
|
57
67
|
"./link.marko"
|
|
58
68
|
]
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { isFunction } from '@mindful-web/utils';
|
|
2
|
+
import defaultValue from "@mindful-web/marko-core/utils/default-value";
|
|
2
3
|
|
|
3
4
|
$ const { $markoWebSearch: search, i18n } = out.global;
|
|
5
|
+
$ const { useMindful } = search.config;
|
|
6
|
+
$ const pageInfo = defaultValue(input.pageInfo, {});
|
|
7
|
+
$ const { sortField, sortOrder } = search.input;
|
|
4
8
|
|
|
5
|
-
$ const
|
|
9
|
+
$ const queryValues = useMindful ? {
|
|
10
|
+
cursorDirection: 'BEFORE',
|
|
11
|
+
cursorValue: pageInfo.startCursor,
|
|
12
|
+
sortField, sortOrder,
|
|
13
|
+
} : {
|
|
14
|
+
page: search.getPrevPage(), sortField, sortOrder
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
$ const hasPreviousPage = useMindful ? pageInfo.hasPreviousPage : search.getPrevPage();
|
|
6
18
|
|
|
7
|
-
$ const { sortField, sortOrder } = search.input;
|
|
8
19
|
|
|
9
|
-
<if(
|
|
20
|
+
<if(hasPreviousPage)>
|
|
10
21
|
<marko-web-search-link
|
|
11
22
|
path=input.path
|
|
12
|
-
query-values=
|
|
23
|
+
query-values=queryValues
|
|
13
24
|
class=input.class
|
|
14
25
|
target=input.target
|
|
15
26
|
rel=input.rel
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/links/previous-page.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_utils_module = require("@mindful-web/utils"),
|
|
8
8
|
utils_module = module_utils_module.default || module_utils_module,
|
|
9
9
|
isFunction = module_utils_module.isFunction,
|
|
10
|
+
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
11
|
+
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
10
12
|
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
11
13
|
helpers_escape_xml = require("marko/dist/runtime/html/helpers/escape-xml"),
|
|
12
14
|
marko_escapeXml = helpers_escape_xml.x,
|
|
@@ -19,18 +21,26 @@ function render(input, out, __component, component, state) {
|
|
|
19
21
|
|
|
20
22
|
const { $markoWebSearch: search, i18n } = out.global;
|
|
21
23
|
|
|
22
|
-
const
|
|
24
|
+
const { useMindful } = search.config;
|
|
25
|
+
|
|
26
|
+
const pageInfo = defaultValue(input.pageInfo, {});
|
|
23
27
|
|
|
24
28
|
const { sortField, sortOrder } = search.input;
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
const queryValues = useMindful ? {
|
|
31
|
+
cursorDirection: 'BEFORE',
|
|
32
|
+
cursorValue: pageInfo.startCursor,
|
|
33
|
+
sortField, sortOrder,
|
|
34
|
+
} : {
|
|
35
|
+
page: search.getPrevPage(), sortField, sortOrder
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const hasPreviousPage = useMindful ? pageInfo.hasPreviousPage : search.getPrevPage();
|
|
39
|
+
|
|
40
|
+
if (hasPreviousPage) {
|
|
27
41
|
marko_web_search_link_tag({
|
|
28
42
|
path: input.path,
|
|
29
|
-
queryValues:
|
|
30
|
-
page: previousPage,
|
|
31
|
-
sortField: sortField,
|
|
32
|
-
sortOrder: sortOrder
|
|
33
|
-
},
|
|
43
|
+
queryValues: queryValues,
|
|
34
44
|
class: input.class,
|
|
35
45
|
target: input.target,
|
|
36
46
|
rel: input.rel,
|
|
@@ -52,7 +62,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
52
62
|
});
|
|
53
63
|
|
|
54
64
|
marko_template.meta = {
|
|
55
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
65
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/links/previous-page.marko",
|
|
56
66
|
tags: [
|
|
57
67
|
"./link.marko"
|
|
58
68
|
]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/links/reset-filter.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -48,7 +48,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
marko_template.meta = {
|
|
51
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
51
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/links/reset-filter.marko",
|
|
52
52
|
tags: [
|
|
53
53
|
"./link.marko"
|
|
54
54
|
]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/links/set-filter-value.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -79,7 +79,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
marko_template.meta = {
|
|
82
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
82
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/links/set-filter-value.marko",
|
|
83
83
|
tags: [
|
|
84
84
|
"./link.marko"
|
|
85
85
|
]
|
package/components/marko.json
CHANGED
|
@@ -4,6 +4,7 @@ import { isFunction } from '@mindful-web/utils';
|
|
|
4
4
|
|
|
5
5
|
$ const { $markoWebSearch: search, i18n } = out.global;
|
|
6
6
|
$ const totalCount = defaultValue(input.totalCount, 0);
|
|
7
|
+
$ const pageInfo = defaultValue(input.pageInfo, {});
|
|
7
8
|
$ const linkClasses = get(input.link, "class");
|
|
8
9
|
|
|
9
10
|
$ const blockName = "marko-web-search-pagination-controls";
|
|
@@ -13,11 +14,12 @@ $ const blockName = "marko-web-search-pagination-controls";
|
|
|
13
14
|
<marko-web-search-previous-page-link
|
|
14
15
|
...input.link
|
|
15
16
|
class=`${linkClasses} ${blockName}__prev`
|
|
17
|
+
page-info=pageInfo
|
|
16
18
|
/>
|
|
17
19
|
|
|
18
20
|
<marko-web-element block-name=blockName name="pages">
|
|
19
|
-
$ const currentPage = search.getCurrentPage();
|
|
20
|
-
$ const totalPages = search.getTotalPages(totalCount);
|
|
21
|
+
$ const currentPage = search.getCurrentPage(pageInfo);
|
|
22
|
+
$ const totalPages = search.getTotalPages(totalCount, pageInfo);
|
|
21
23
|
<if(input.renderBody)>
|
|
22
24
|
<!-- custom rendering -->
|
|
23
25
|
<${input.renderBody} current-page=currentPage total-pages=totalPages />
|
|
@@ -36,6 +38,7 @@ $ const blockName = "marko-web-search-pagination-controls";
|
|
|
36
38
|
<marko-web-search-next-page-link
|
|
37
39
|
...input.link
|
|
38
40
|
class=`${linkClasses} ${blockName}__next`
|
|
41
|
+
page-info=pageInfo
|
|
39
42
|
total-count=totalCount
|
|
40
43
|
/>
|
|
41
44
|
</marko-web-block>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/pagination-controls.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -33,6 +33,8 @@ function render(input, out, __component, component, state) {
|
|
|
33
33
|
|
|
34
34
|
const totalCount = defaultValue(input.totalCount, 0);
|
|
35
35
|
|
|
36
|
+
const pageInfo = defaultValue(input.pageInfo, {});
|
|
37
|
+
|
|
36
38
|
const linkClasses = get(input.link, "class");
|
|
37
39
|
|
|
38
40
|
const blockName = "marko-web-search-pagination-controls";
|
|
@@ -45,7 +47,8 @@ function render(input, out, __component, component, state) {
|
|
|
45
47
|
name: blockName,
|
|
46
48
|
renderBody: function(out) {
|
|
47
49
|
marko_web_search_previous_page_link_tag(marko_assign({}, input.link, {
|
|
48
|
-
class: ((linkClasses + " ") + blockName) + "__prev"
|
|
50
|
+
class: ((linkClasses + " ") + blockName) + "__prev",
|
|
51
|
+
pageInfo: pageInfo
|
|
49
52
|
}), out, __component, "1");
|
|
50
53
|
|
|
51
54
|
marko_web_element_tag({
|
|
@@ -53,9 +56,9 @@ function render(input, out, __component, component, state) {
|
|
|
53
56
|
tag: "div",
|
|
54
57
|
blockName: blockName,
|
|
55
58
|
renderBody: function(out) {
|
|
56
|
-
const currentPage = search.getCurrentPage();
|
|
59
|
+
const currentPage = search.getCurrentPage(pageInfo);
|
|
57
60
|
|
|
58
|
-
const totalPages = search.getTotalPages(totalCount);
|
|
61
|
+
const totalPages = search.getTotalPages(totalCount, pageInfo);
|
|
59
62
|
|
|
60
63
|
if (input.renderBody) {
|
|
61
64
|
marko_dynamicTag(out, input.renderBody, function() {
|
|
@@ -85,6 +88,7 @@ function render(input, out, __component, component, state) {
|
|
|
85
88
|
|
|
86
89
|
marko_web_search_next_page_link_tag(marko_assign({}, input.link, {
|
|
87
90
|
class: ((linkClasses + " ") + blockName) + "__next",
|
|
91
|
+
pageInfo: pageInfo,
|
|
88
92
|
totalCount: totalCount
|
|
89
93
|
}), out, __component, "4");
|
|
90
94
|
}
|
|
@@ -98,7 +102,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
98
102
|
});
|
|
99
103
|
|
|
100
104
|
marko_template.meta = {
|
|
101
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
105
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/pagination-controls.marko",
|
|
102
106
|
tags: [
|
|
103
107
|
"./links/previous-page.marko",
|
|
104
108
|
"@mindful-web/marko-web/components/element/index.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/query-child-sections.marko",
|
|
6
6
|
marko_component = require("./query-child-sections.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_gql = require("graphql-tag"),
|
|
@@ -52,7 +52,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
52
52
|
}, marko_component);
|
|
53
53
|
|
|
54
54
|
marko_template.meta = {
|
|
55
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
55
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/query-child-sections.marko",
|
|
56
56
|
component: "./query-child-sections.marko",
|
|
57
57
|
tags: [
|
|
58
58
|
"@mindful-web/marko-core/components/queries/website-sections.marko"
|
package/components/query.marko
CHANGED
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
import loader from "../loaders/search";
|
|
2
2
|
|
|
3
3
|
$ const {
|
|
4
|
-
apollo: apolloMindfulWebCMS,
|
|
5
4
|
$baseBrowse: apolloBaseBrowse,
|
|
5
|
+
$markoWebSearch,
|
|
6
|
+
apollo: apolloMindfulWebCMS,
|
|
6
7
|
config,
|
|
7
8
|
site
|
|
8
9
|
} = out.global;
|
|
9
10
|
$ const { assignedToWebsiteSectionIds } = input;
|
|
10
11
|
|
|
11
|
-
$ const
|
|
12
|
-
limit: input.limit,
|
|
13
|
-
skip: input.skip,
|
|
14
|
-
searchQuery: input.searchQuery,
|
|
15
|
-
sortField: input.sortField,
|
|
16
|
-
sortOrder: input.sortOrder,
|
|
17
|
-
contentTypes: input.contentTypes,
|
|
18
|
-
countryCodes: input.countryCodes,
|
|
12
|
+
$ const common = {
|
|
19
13
|
...(assignedToWebsiteSectionIds && assignedToWebsiteSectionIds.length
|
|
20
14
|
? { assignedToWebsiteSectionIds }
|
|
21
15
|
: { assignedToWebsiteSiteIds: [config.website("id")] }
|
|
22
16
|
),
|
|
23
|
-
|
|
17
|
+
contentTypes: input.contentTypes,
|
|
18
|
+
limit: input.limit,
|
|
24
19
|
opSuffix: input.opSuffix,
|
|
20
|
+
queryFragment: input.queryFragment,
|
|
21
|
+
searchQuery: input.searchQuery,
|
|
25
22
|
searchType: site.get('search.type'),
|
|
23
|
+
sortField: input.sortField,
|
|
24
|
+
sortOrder: input.sortOrder,
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
$ const runQuery = () => {
|
|
28
|
+
if ($markoWebSearch.config.useMindful) {
|
|
29
|
+
return $markoWebSearch.mindful.searchPostsAsContentUsingLegacyParams({
|
|
30
|
+
...common,
|
|
31
|
+
apolloMindfulWebCMS,
|
|
32
|
+
cursorDirection: input.cursorDirection,
|
|
33
|
+
cursorValue: input.cursorValue,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return loader({ apolloMindfulWebCMS, apolloBaseBrowse }, {
|
|
37
|
+
...common, skip: input.skip, countryCodes: input.countryCodes
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
<marko-web-resolve|{ resolved }| promise=runQuery()>
|
|
29
42
|
<${input.renderBody} ...resolved />
|
|
30
43
|
</marko-web-resolve>
|
|
44
|
+
|
|
45
|
+
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/query.marko",
|
|
6
6
|
marko_component = require("./query.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_loader = require("../loaders/search"),
|
|
@@ -16,36 +16,46 @@ function render(input, out, __component, component, state) {
|
|
|
16
16
|
var data = input;
|
|
17
17
|
|
|
18
18
|
const {
|
|
19
|
-
apollo: apolloMindfulWebCMS,
|
|
20
19
|
$baseBrowse: apolloBaseBrowse,
|
|
20
|
+
$markoWebSearch,
|
|
21
|
+
apollo: apolloMindfulWebCMS,
|
|
21
22
|
config,
|
|
22
23
|
site
|
|
23
24
|
} = out.global;
|
|
24
25
|
|
|
25
26
|
const { assignedToWebsiteSectionIds } = input;
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
-
limit: input.limit,
|
|
29
|
-
skip: input.skip,
|
|
30
|
-
searchQuery: input.searchQuery,
|
|
31
|
-
sortField: input.sortField,
|
|
32
|
-
sortOrder: input.sortOrder,
|
|
33
|
-
contentTypes: input.contentTypes,
|
|
34
|
-
countryCodes: input.countryCodes,
|
|
28
|
+
const common = {
|
|
35
29
|
...(assignedToWebsiteSectionIds && assignedToWebsiteSectionIds.length
|
|
36
30
|
? { assignedToWebsiteSectionIds }
|
|
37
31
|
: { assignedToWebsiteSiteIds: [config.website("id")] }
|
|
38
32
|
),
|
|
39
|
-
|
|
33
|
+
contentTypes: input.contentTypes,
|
|
34
|
+
limit: input.limit,
|
|
40
35
|
opSuffix: input.opSuffix,
|
|
36
|
+
queryFragment: input.queryFragment,
|
|
37
|
+
searchQuery: input.searchQuery,
|
|
41
38
|
searchType: site.get('search.type'),
|
|
39
|
+
sortField: input.sortField,
|
|
40
|
+
sortOrder: input.sortOrder,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const runQuery = () => {
|
|
44
|
+
if ($markoWebSearch.config.useMindful) {
|
|
45
|
+
return $markoWebSearch.mindful.searchPostsAsContentUsingLegacyParams({
|
|
46
|
+
...common,
|
|
47
|
+
apolloMindfulWebCMS,
|
|
48
|
+
cursorDirection: input.cursorDirection,
|
|
49
|
+
cursorValue: input.cursorValue,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return loader({ apolloMindfulWebCMS, apolloBaseBrowse }, {
|
|
53
|
+
...common, skip: input.skip, countryCodes: input.countryCodes
|
|
54
|
+
});
|
|
42
55
|
};
|
|
43
56
|
|
|
44
57
|
marko_web_resolve_tag({
|
|
45
|
-
promise:
|
|
46
|
-
apolloMindfulWebCMS: apolloMindfulWebCMS,
|
|
47
|
-
apolloBaseBrowse: apolloBaseBrowse
|
|
48
|
-
}, params),
|
|
58
|
+
promise: runQuery(),
|
|
49
59
|
renderBody: function(out, { resolved }) {
|
|
50
60
|
marko_dynamicTag(out, input.renderBody, function() {
|
|
51
61
|
return resolved;
|
|
@@ -59,7 +69,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
59
69
|
}, marko_component);
|
|
60
70
|
|
|
61
71
|
marko_template.meta = {
|
|
62
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
72
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/query.marko",
|
|
63
73
|
component: "./query.marko",
|
|
64
74
|
tags: [
|
|
65
75
|
"@mindful-web/marko-core/components/resolve.marko"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.27.0/components/sort-by/index.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -64,7 +64,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
marko_template.meta = {
|
|
67
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
67
|
+
id: "/@mindful-web/marko-web-search$1.27.0/components/sort-by/index.marko",
|
|
68
68
|
tags: [
|
|
69
69
|
"@mindful-web/marko-web/components/browser-component.marko",
|
|
70
70
|
"@mindful-web/marko-web/components/element/block.marko"
|
package/config/index.js
CHANGED
|
@@ -8,31 +8,18 @@ const defaultContentTypes = getDefaultContentTypes();
|
|
|
8
8
|
|
|
9
9
|
class MarkoWebSearchConfig {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {object} params
|
|
13
|
-
*
|
|
14
|
-
* @param {object} [params.resultsPerPage=10] The results per page setting.
|
|
15
|
-
* @param {number} [params.resultsPerPage.min=1]
|
|
16
|
-
* @param {number} [params.resultsPerPage.max=100]
|
|
17
|
-
* @param {number} [params.resultsPerPage.default=20]
|
|
18
|
-
*
|
|
19
|
-
* @param {string[]} [params.contentTypes] The allowed content type filters. Defaults to all.
|
|
20
|
-
* Should be provided as an array of classified content
|
|
21
|
-
* type strings, e.g. ['Article', 'MediaGallery'] etc.
|
|
22
|
-
*
|
|
23
|
-
* @param {object[]} [params.assignedToWebsiteSectionIds] The allowed website section filters.
|
|
24
|
-
* Defaults to none. Should be an array of
|
|
25
|
-
* section IDs, e.g. [123, 321]
|
|
26
|
-
*
|
|
27
|
-
* @param {string} [params.rootAlias] The root alias for the search page defaults to 'search'
|
|
11
|
+
* @param {MarkoWebSearchConfigParams} params
|
|
28
12
|
*/
|
|
29
13
|
constructor(params = {}) {
|
|
14
|
+
/** @type {MarkoWebSearchConfigParams} */
|
|
30
15
|
const {
|
|
31
|
-
resultsPerPage,
|
|
32
|
-
contentTypes,
|
|
33
16
|
assignedToWebsiteSectionIds,
|
|
17
|
+
contentTypes,
|
|
34
18
|
defaultSortField,
|
|
19
|
+
mindful,
|
|
20
|
+
resultsPerPage,
|
|
35
21
|
rootAlias,
|
|
22
|
+
useMindful,
|
|
36
23
|
} = validate(Joi.object({
|
|
37
24
|
resultsPerPage: Joi.object({
|
|
38
25
|
min: Joi.number().integer().default(1),
|
|
@@ -55,6 +42,9 @@ class MarkoWebSearchConfig {
|
|
|
55
42
|
defaultSortField: Joi.string().allow('NAME', 'PUBLISHED', 'SCORE').default('PUBLISHED'),
|
|
56
43
|
|
|
57
44
|
rootAlias: Joi.string().default('search'),
|
|
45
|
+
|
|
46
|
+
useMindful: Joi.boolean(),
|
|
47
|
+
mindful: Joi.object(),
|
|
58
48
|
}).default(), params);
|
|
59
49
|
|
|
60
50
|
this.contentTypeObjects = contentTypes.sort().map((type) => (type.label ? ({
|
|
@@ -72,13 +62,34 @@ class MarkoWebSearchConfig {
|
|
|
72
62
|
|
|
73
63
|
this.assignedToWebsiteSectionIds = assignedToWebsiteSectionIds;
|
|
74
64
|
|
|
65
|
+
if (useMindful && !mindful) {
|
|
66
|
+
throw new Error('In order to use native Mindful search, you must provided the Mindful service');
|
|
67
|
+
}
|
|
68
|
+
this.useMindful = useMindful;
|
|
69
|
+
this.mindful = mindful;
|
|
70
|
+
|
|
75
71
|
this.queryParams = new MarkoWebSearchQueryParamConfig({
|
|
76
|
-
resultsPerPage,
|
|
77
72
|
contentTypeIds: this.contentTypeObjects.map(({ id }) => id),
|
|
78
73
|
defaultSortField,
|
|
74
|
+
resultsPerPage,
|
|
79
75
|
});
|
|
80
76
|
this.rootAlias = rootAlias;
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @typedef MarkoWebSearchConfigParams
|
|
82
|
+
* @prop {object} resultsPerPage The results per page setting.
|
|
83
|
+
* @prop {number} resultsPerPage.min
|
|
84
|
+
* @prop {number} resultsPerPage.max
|
|
85
|
+
* @prop {number} resultsPerPage.default
|
|
86
|
+
* @prop {string[]} contentTypes The allowed content type filters. Defaults to all. Should be
|
|
87
|
+
* provided as an array of classified content type strings, e.g. `['Article', 'MediaGallery']` etc.
|
|
88
|
+
* @prop {object[]} assignedToWebsiteSectionIds The allowed website section filters. Defaults to
|
|
89
|
+
* none. Should be an array of section IDs, e.g. `[123, 321]`
|
|
90
|
+
* @prop {string} rootAlias The root alias for the search page defaults to 'search'
|
|
91
|
+
* @prop {import("@mindful-web/mindful/marko-web/service").MindfulMarkoWebService} [mindful]
|
|
92
|
+
* @prop {boolean} [useMindful]
|
|
93
|
+
*/
|
|
94
|
+
|
|
84
95
|
module.exports = MarkoWebSearchConfig;
|
package/config/query-params.js
CHANGED
|
@@ -24,9 +24,9 @@ const sortOrderSet = new Set(['DESC', 'ASC']);
|
|
|
24
24
|
|
|
25
25
|
class MarkoWebSearchQueryParamConfig {
|
|
26
26
|
constructor({
|
|
27
|
-
resultsPerPage = {},
|
|
28
27
|
contentTypeIds = [],
|
|
29
28
|
defaultSortField = 'PUBLISHED',
|
|
29
|
+
resultsPerPage = {},
|
|
30
30
|
} = {}) {
|
|
31
31
|
this.params = new Map();
|
|
32
32
|
|
|
@@ -36,11 +36,13 @@ class MarkoWebSearchQueryParamConfig {
|
|
|
36
36
|
}, new Map());
|
|
37
37
|
|
|
38
38
|
this
|
|
39
|
-
.add('
|
|
40
|
-
type:
|
|
41
|
-
defaultValue:
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
.add('cursorValue', {
|
|
40
|
+
type: String,
|
|
41
|
+
defaultValue: '',
|
|
42
|
+
}).add('cursorDirection', {
|
|
43
|
+
type: String,
|
|
44
|
+
defaultValue: 'AFTER',
|
|
45
|
+
validator: (v) => v === 'AFTER' || v === 'BEFORE',
|
|
44
46
|
})
|
|
45
47
|
.add('page', {
|
|
46
48
|
type: Number,
|
|
@@ -52,6 +54,12 @@ class MarkoWebSearchQueryParamConfig {
|
|
|
52
54
|
},
|
|
53
55
|
toInput: (v) => parseInt(v, 10),
|
|
54
56
|
})
|
|
57
|
+
.add('limit', {
|
|
58
|
+
type: Number,
|
|
59
|
+
defaultValue: resultsPerPage.default,
|
|
60
|
+
validator: (v) => (v >= resultsPerPage.min && v <= resultsPerPage.max),
|
|
61
|
+
toInput: (v) => parseInt(v, 10),
|
|
62
|
+
})
|
|
55
63
|
.add('searchQuery', {
|
|
56
64
|
type: String,
|
|
57
65
|
defaultValue: '',
|
package/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
class MarkoWebSearch {
|
|
2
|
+
/**
|
|
3
|
+
* @param {object} params
|
|
4
|
+
* @param {import("./config")} params.config
|
|
5
|
+
* @param {Record<string, any>} params.query The Express request query object.
|
|
6
|
+
*/
|
|
2
7
|
constructor({ config, query = {} } = {}) {
|
|
3
8
|
this.config = config;
|
|
4
9
|
this.query = query;
|
|
@@ -81,7 +86,21 @@ class MarkoWebSearch {
|
|
|
81
86
|
return this.config.queryParams.names();
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
|
|
89
|
+
getCursorDirection() {
|
|
90
|
+
return this.getInputValueFor('cursorDirection');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getCursorValue() {
|
|
94
|
+
return this.getInputValueFor('cursorValue');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @param {PageInfo} [pageInfo]
|
|
99
|
+
*/
|
|
100
|
+
getCurrentPage(pageInfo) {
|
|
101
|
+
if (this.config.useMindful && pageInfo) {
|
|
102
|
+
return ((pageInfo.startingPosition - 1) / this.getLimit()) + 1;
|
|
103
|
+
}
|
|
85
104
|
return this.getInputValueFor('page');
|
|
86
105
|
}
|
|
87
106
|
|
|
@@ -93,8 +112,18 @@ class MarkoWebSearch {
|
|
|
93
112
|
return this.getLimit() * (this.getCurrentPage() - 1);
|
|
94
113
|
}
|
|
95
114
|
|
|
96
|
-
|
|
97
|
-
|
|
115
|
+
/**
|
|
116
|
+
* @param {number} totalCount
|
|
117
|
+
* @param {PageInfo} [pageInfo]
|
|
118
|
+
*/
|
|
119
|
+
getTotalPages(totalCount, pageInfo) {
|
|
120
|
+
const total = totalCount || 0;
|
|
121
|
+
|
|
122
|
+
if (this.config.useMindful && pageInfo) {
|
|
123
|
+
return Math.ceil(total / this.getLimit());
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const count = (total) > 10000 ? 10000 : total;
|
|
98
127
|
return Math.ceil(count / this.getLimit());
|
|
99
128
|
}
|
|
100
129
|
|
|
@@ -110,4 +139,8 @@ class MarkoWebSearch {
|
|
|
110
139
|
}
|
|
111
140
|
}
|
|
112
141
|
|
|
142
|
+
/**
|
|
143
|
+
* @typedef {import("@mindful-web/mindful/marko-web/service").PostsAsContentPageInfo} PageInfo
|
|
144
|
+
*/
|
|
145
|
+
|
|
113
146
|
module.exports = MarkoWebSearch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindful-web/marko-web-search",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"author": "Jacob Bare <jacob@parameter1.com>",
|
|
5
5
|
"repository": "https://github.com/parameter1/mindful-web/tree/main/packages/marko-web-search",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@mindful-web/marko-web-icons": "^1.0.0",
|
|
17
17
|
"@mindful-web/object-path": "^1.11.9",
|
|
18
18
|
"@mindful-web/utils": "^1.11.9",
|
|
19
|
-
"@mindful-web/web-common": "^1.
|
|
19
|
+
"@mindful-web/web-common": "^1.20.2",
|
|
20
20
|
"@parameter1/joi": "^1.2.10",
|
|
21
21
|
"graphql": "^14.7.0",
|
|
22
22
|
"graphql-tag": "^2.12.6"
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "b21ead88aea0a41608df9fd615f1b61038bb0b0a"
|
|
32
32
|
}
|