@mindful-web/marko-web-search 1.0.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/.eslintignore +1 -0
- package/LICENSE +21 -0
- package/browser/.eslintrc.js +1 -0
- package/browser/index.js +9 -0
- package/browser/sort-select.vue +37 -0
- package/browser/toggle-filter-button.vue +69 -0
- package/browser/toggle-filters-button.vue +87 -0
- package/components/build-href.marko +14 -0
- package/components/build-href.marko.js +46 -0
- package/components/filters/content-types.marko +12 -0
- package/components/filters/content-types.marko.js +40 -0
- package/components/filters/filter-block.marko +66 -0
- package/components/filters/filter-block.marko.js +151 -0
- package/components/filters/filter-container.marko +29 -0
- package/components/filters/filter-container.marko.js +85 -0
- package/components/filters/load-website-sections.js +69 -0
- package/components/filters/marko.json +36 -0
- package/components/filters/selected/index.marko +51 -0
- package/components/filters/selected/index.marko.js +113 -0
- package/components/filters/selected/item.marko +27 -0
- package/components/filters/selected/item.marko.js +101 -0
- package/components/filters/selected/marko.json +8 -0
- package/components/filters/website-sections-by-alias.marko +46 -0
- package/components/filters/website-sections-by-alias.marko.js +139 -0
- package/components/filters/website-sections.marko +42 -0
- package/components/filters/website-sections.marko.js +123 -0
- package/components/form/index.marko +23 -0
- package/components/form/index.marko.js +79 -0
- package/components/form/input.marko +8 -0
- package/components/form/input.marko.js +30 -0
- package/components/form/marko.json +10 -0
- package/components/links/link.marko +14 -0
- package/components/links/link.marko.js +47 -0
- package/components/links/marko.json +17 -0
- package/components/links/next-page.marko +25 -0
- package/components/links/next-page.marko.js +59 -0
- package/components/links/previous-page.marko +25 -0
- package/components/links/previous-page.marko.js +59 -0
- package/components/links/reset-filter.marko +24 -0
- package/components/links/reset-filter.marko.js +55 -0
- package/components/links/set-filter-value.marko +45 -0
- package/components/links/set-filter-value.marko.js +86 -0
- package/components/marko.json +25 -0
- package/components/pagination-controls.marko +42 -0
- package/components/pagination-controls.marko.js +108 -0
- package/components/query-child-sections.marko +24 -0
- package/components/query-child-sections.marko.js +60 -0
- package/components/query.marko +30 -0
- package/components/query.marko.js +67 -0
- package/components/sort-by/index.marko +25 -0
- package/components/sort-by/index.marko.js +72 -0
- package/components/sort-by/marko.json +5 -0
- package/config/index.js +84 -0
- package/config/param.js +69 -0
- package/config/query-params.js +101 -0
- package/index.js +113 -0
- package/loaders/search.js +108 -0
- package/marko.json +6 -0
- package/middleware.js +9 -0
- package/package.json +32 -0
package/.eslintignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.marko.js
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Parameter1 LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../../eslintrc.browser');
|
package/browser/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const ToggleFilterContainer = () => import(/* webpackChunkName: "marko-web-search-toggle-filter-container" */ './toggle-filters-button.vue');
|
|
2
|
+
const ToggleFilter = () => import(/* webpackChunkName: "marko-web-search-toggle-filter" */ './toggle-filter-button.vue');
|
|
3
|
+
const SortSelect = () => import(/* webpackChunkName: "marko-web-search-sort-select" */ './sort-select.vue');
|
|
4
|
+
|
|
5
|
+
export default (Browser) => {
|
|
6
|
+
Browser.register('MarkoWebSearchToggleFilterContainer', ToggleFilterContainer);
|
|
7
|
+
Browser.register('MarkoWebSearchToggleFilter', ToggleFilter);
|
|
8
|
+
Browser.register('MarkoWebSearchSortSelect', SortSelect);
|
|
9
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<select class="custom-select" @change="onChange">
|
|
3
|
+
<option
|
|
4
|
+
v-for="option in options"
|
|
5
|
+
:key="option.id"
|
|
6
|
+
:selected="option.id === selectedId"
|
|
7
|
+
:value="option.id"
|
|
8
|
+
>
|
|
9
|
+
{{ option.label }}
|
|
10
|
+
</option>
|
|
11
|
+
</select>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
props: {
|
|
17
|
+
options: {
|
|
18
|
+
type: Array,
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
selectedId: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: 'PUBLISHED',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
methods: {
|
|
27
|
+
onChange(event) {
|
|
28
|
+
const { value } = event.target;
|
|
29
|
+
const url = new URL(window.location);
|
|
30
|
+
const params = new URLSearchParams(window.location.search);
|
|
31
|
+
params.set('sortField', value);
|
|
32
|
+
url.search = `${params}`;
|
|
33
|
+
window.location.href = `${url}`;
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button
|
|
3
|
+
:class="className"
|
|
4
|
+
type="button"
|
|
5
|
+
:aria-label="buttonLabel"
|
|
6
|
+
@click="toggle"
|
|
7
|
+
>
|
|
8
|
+
<span>{{ label }}</span>
|
|
9
|
+
<component :is="icon" />
|
|
10
|
+
</button>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import IconChevronDown from '@mindful-web/marko-web-icons/browser/chevron-down.vue';
|
|
15
|
+
import IconChevronUp from '@mindful-web/marko-web-icons/browser/chevron-up.vue';
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
components: {
|
|
19
|
+
IconChevronDown,
|
|
20
|
+
IconChevronUp,
|
|
21
|
+
},
|
|
22
|
+
props: {
|
|
23
|
+
className: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'marko-web-search-toggle-filter',
|
|
26
|
+
},
|
|
27
|
+
target: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
toggleClass: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
label: {
|
|
36
|
+
type: String,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
data: () => ({
|
|
41
|
+
expanded: true,
|
|
42
|
+
iconName: 'chevron-up',
|
|
43
|
+
expandedIconName: 'chevron-down',
|
|
44
|
+
}),
|
|
45
|
+
|
|
46
|
+
computed: {
|
|
47
|
+
buttonLabel() {
|
|
48
|
+
return `Toggle ${this.label} Filter`;
|
|
49
|
+
},
|
|
50
|
+
icon() {
|
|
51
|
+
if (this.expanded) return `icon-${this.expandedIconName}`;
|
|
52
|
+
return `icon-${this.iconName}`;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
watch: {
|
|
57
|
+
expanded() {
|
|
58
|
+
const element = document.querySelector(this.target);
|
|
59
|
+
element.classList.toggle(this.toggleClass);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
methods: {
|
|
64
|
+
toggle() {
|
|
65
|
+
this.expanded = !this.expanded;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
</script>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button
|
|
3
|
+
:class="className"
|
|
4
|
+
type="button"
|
|
5
|
+
:aria-label="buttonLabel"
|
|
6
|
+
@click="toggle"
|
|
7
|
+
>
|
|
8
|
+
<span>{{ label }}</span>
|
|
9
|
+
<component :is="icon" />
|
|
10
|
+
</button>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import IconChevronDown from '@mindful-web/marko-web-icons/browser/chevron-down.vue';
|
|
15
|
+
import IconChevronUp from '@mindful-web/marko-web-icons/browser/chevron-up.vue';
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
components: {
|
|
19
|
+
IconChevronDown,
|
|
20
|
+
IconChevronUp,
|
|
21
|
+
},
|
|
22
|
+
props: {
|
|
23
|
+
className: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'marko-web-search-toggle-filter-container',
|
|
26
|
+
},
|
|
27
|
+
openMediaQuery: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: '(min-width: 992px)',
|
|
30
|
+
},
|
|
31
|
+
target: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
toggleClass: {
|
|
36
|
+
type: String,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
label: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: 'Filters',
|
|
42
|
+
},
|
|
43
|
+
buttonLabel: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: 'Toggle Filters',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
data: () => ({
|
|
49
|
+
expanded: false,
|
|
50
|
+
iconName: 'chevron-up',
|
|
51
|
+
expandedIconName: 'chevron-down',
|
|
52
|
+
}),
|
|
53
|
+
|
|
54
|
+
computed: {
|
|
55
|
+
icon() {
|
|
56
|
+
if (this.expanded) return `icon-${this.expandedIconName}`;
|
|
57
|
+
return `icon-${this.iconName}`;
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
watch: {
|
|
62
|
+
expanded() {
|
|
63
|
+
const element = document.querySelector(this.target);
|
|
64
|
+
element.classList.toggle(this.toggleClass);
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
mounted() {
|
|
69
|
+
const mql = window.matchMedia(this.openMediaQuery);
|
|
70
|
+
this.handleMediaQueryState(mql.matches);
|
|
71
|
+
mql.addEventListener('change', ({ matches }) => {
|
|
72
|
+
this.handleMediaQueryState(matches);
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
methods: {
|
|
77
|
+
handleMediaQueryState(matches) {
|
|
78
|
+
this.expanded = matches;
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
toggle() {
|
|
82
|
+
this.hasUserInteraction = true;
|
|
83
|
+
this.expanded = !this.expanded;
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import defaultValue from "@mindful-web/marko-core/utils/default-value";
|
|
2
|
+
import { cleanPath } from "@mindful-web/utils";
|
|
3
|
+
import { get } from "@mindful-web/object-path";
|
|
4
|
+
|
|
5
|
+
$ const { req, $markoWebSearch: search } = out.global;
|
|
6
|
+
$ const path = defaultValue(input.path, req.path);
|
|
7
|
+
$ const rootAlias = get(search, "config.rootAlias");
|
|
8
|
+
|
|
9
|
+
$ const omit = rootAlias && rootAlias !== "search" ? { assignedToWebsiteSectionIds: true } : {}
|
|
10
|
+
|
|
11
|
+
$ const queryString = search.buildQueryString(input.queryValues, omit);
|
|
12
|
+
$ const href = `/${cleanPath(path)}${queryString}`;
|
|
13
|
+
|
|
14
|
+
<${input.renderBody} href=href />
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.0.0/components/build-href.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
|
+
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
9
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
10
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
11
|
+
cleanPath = module_utils_module.cleanPath,
|
|
12
|
+
module_objectPath_module = require("@mindful-web/object-path"),
|
|
13
|
+
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
14
|
+
get = module_objectPath_module.get,
|
|
15
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag");
|
|
16
|
+
|
|
17
|
+
function render(input, out, __component, component, state) {
|
|
18
|
+
var data = input;
|
|
19
|
+
|
|
20
|
+
const { req, $markoWebSearch: search } = out.global;
|
|
21
|
+
|
|
22
|
+
const path = defaultValue(input.path, req.path);
|
|
23
|
+
|
|
24
|
+
const rootAlias = get(search, "config.rootAlias");
|
|
25
|
+
|
|
26
|
+
const omit = rootAlias && rootAlias !== "search" ? { assignedToWebsiteSectionIds: true } : {}
|
|
27
|
+
|
|
28
|
+
const queryString = search.buildQueryString(input.queryValues, omit);
|
|
29
|
+
|
|
30
|
+
const href = `/${cleanPath(path)}${queryString}`;
|
|
31
|
+
|
|
32
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
33
|
+
return {
|
|
34
|
+
href: href
|
|
35
|
+
};
|
|
36
|
+
}, null, null, null, __component, "0");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
marko_template._ = marko_renderer(render, {
|
|
40
|
+
d_: true,
|
|
41
|
+
e_: marko_componentType
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
marko_template.meta = {
|
|
45
|
+
id: "/@mindful-web/marko-web-search$1.0.0/components/build-href.marko"
|
|
46
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isFunction } from '@mindful-web/utils';
|
|
2
|
+
|
|
3
|
+
$ const { $markoWebSearch: search, i18n } = out.global;
|
|
4
|
+
|
|
5
|
+
$ const title = isFunction(i18n) ? i18n("Content Types") : "Content Types";
|
|
6
|
+
|
|
7
|
+
<marko-web-search-filter-block
|
|
8
|
+
filter-key="contentTypes"
|
|
9
|
+
items=search.config.contentTypeObjects
|
|
10
|
+
>
|
|
11
|
+
<@title value=title />
|
|
12
|
+
</marko-web-search-filter-block>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.0.0/components/filters/content-types.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
8
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
9
|
+
isFunction = module_utils_module.isFunction,
|
|
10
|
+
marko_web_search_filter_block_template = require("./filter-block.marko"),
|
|
11
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
12
|
+
marko_web_search_filter_block_tag = marko_loadTag(marko_web_search_filter_block_template);
|
|
13
|
+
|
|
14
|
+
function render(input, out, __component, component, state) {
|
|
15
|
+
var data = input;
|
|
16
|
+
|
|
17
|
+
const { $markoWebSearch: search, i18n } = out.global;
|
|
18
|
+
|
|
19
|
+
const title = isFunction(i18n) ? i18n("Content Types") : "Content Types";
|
|
20
|
+
|
|
21
|
+
marko_web_search_filter_block_tag({
|
|
22
|
+
filterKey: "contentTypes",
|
|
23
|
+
items: search.config.contentTypeObjects,
|
|
24
|
+
title: {
|
|
25
|
+
value: title
|
|
26
|
+
}
|
|
27
|
+
}, out, __component, "0");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
marko_template._ = marko_renderer(render, {
|
|
31
|
+
d_: true,
|
|
32
|
+
e_: marko_componentType
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
marko_template.meta = {
|
|
36
|
+
id: "/@mindful-web/marko-web-search$1.0.0/components/filters/content-types.marko",
|
|
37
|
+
tags: [
|
|
38
|
+
"./filter-block.marko"
|
|
39
|
+
]
|
|
40
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { get, getAsArray, getAsObject } from "@mindful-web/object-path";
|
|
2
|
+
import { dasherize } from "@mindful-web/inflector";
|
|
3
|
+
import defaultValue from "@mindful-web/marko-core/utils/default-value";
|
|
4
|
+
import { isFunction } from '@mindful-web/utils';
|
|
5
|
+
|
|
6
|
+
$ const { $markoWebSearch: search, i18n } = out.global;
|
|
7
|
+
|
|
8
|
+
$ const blockName = "marko-web-search-filter";
|
|
9
|
+
$ const items = getAsArray(input.items);
|
|
10
|
+
$ const { title, filterKey } = input;
|
|
11
|
+
$ const item = getAsObject(input.item);
|
|
12
|
+
$ const itemIdPath = defaultValue(item.idPath, "id");
|
|
13
|
+
$ const itemLabelPath = defaultValue(item.labelPath, "label");
|
|
14
|
+
$ const titleModifier = dasherize(filterKey);
|
|
15
|
+
|
|
16
|
+
<if(items.length)>
|
|
17
|
+
<marko-web-block name=blockName modifiers=input.modifiers>
|
|
18
|
+
<if(title)>
|
|
19
|
+
<if(title.renderBlock)>
|
|
20
|
+
<${title.renderBlock} />
|
|
21
|
+
</if>
|
|
22
|
+
<else>
|
|
23
|
+
<marko-web-browser-component
|
|
24
|
+
name="MarkoWebSearchToggleFilter"
|
|
25
|
+
props={
|
|
26
|
+
label: title.value,
|
|
27
|
+
target: `.${blockName}__items--${titleModifier}`,
|
|
28
|
+
toggleClass: `${blockName}__items--open`,
|
|
29
|
+
}
|
|
30
|
+
/>
|
|
31
|
+
</else>
|
|
32
|
+
</if>
|
|
33
|
+
<marko-web-element
|
|
34
|
+
tag="ul"
|
|
35
|
+
block-name=blockName
|
|
36
|
+
name="items"
|
|
37
|
+
modifiers=["open", titleModifier]
|
|
38
|
+
>
|
|
39
|
+
<for|node| of=items>
|
|
40
|
+
$ const id = get(node, itemIdPath);
|
|
41
|
+
$ const label = get(node, itemLabelPath);
|
|
42
|
+
$ const value = search.isArrayParam(filterKey) ? [id] : id;
|
|
43
|
+
$ const isSelected = search.isInputValueSelectedFor(filterKey, value);
|
|
44
|
+
$ const modifiers = isSelected ? ["selected"] : [];
|
|
45
|
+
<marko-web-element ...item.element tag="li" block-name=blockName name="item" modifiers=modifiers>
|
|
46
|
+
<if(item.renderBody)>
|
|
47
|
+
<!-- custom filter item rendering -->
|
|
48
|
+
<${item.renderBody}
|
|
49
|
+
node=node
|
|
50
|
+
block-name=blockName
|
|
51
|
+
id=id
|
|
52
|
+
label=`${isFunction(i18n) ? i18n(label) : label}`
|
|
53
|
+
is-selected=isSelected
|
|
54
|
+
/>
|
|
55
|
+
</if>
|
|
56
|
+
<else>
|
|
57
|
+
<!-- default item rendering -->
|
|
58
|
+
<marko-web-search-set-filter-value-link name=filterKey value=id reset-class=`${blockName}__clear-item`>
|
|
59
|
+
${isFunction(i18n) ? i18n(label) : label}
|
|
60
|
+
</marko-web-search-set-filter-value-link>
|
|
61
|
+
</else>
|
|
62
|
+
</marko-web-element>
|
|
63
|
+
</for>
|
|
64
|
+
</marko-web-element>
|
|
65
|
+
</marko-web-block>
|
|
66
|
+
</if>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.0.0/components/filters/filter-block.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
|
+
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
9
|
+
get = module_objectPath_module.get,
|
|
10
|
+
getAsArray = module_objectPath_module.getAsArray,
|
|
11
|
+
getAsObject = module_objectPath_module.getAsObject,
|
|
12
|
+
module_inflector_module = require("@mindful-web/inflector"),
|
|
13
|
+
inflector_module = module_inflector_module.default || module_inflector_module,
|
|
14
|
+
dasherize = module_inflector_module.dasherize,
|
|
15
|
+
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
16
|
+
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
17
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
18
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
19
|
+
isFunction = module_utils_module.isFunction,
|
|
20
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
21
|
+
marko_web_browser_component_template = require("@mindful-web/marko-web/components/browser-component.marko"),
|
|
22
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
23
|
+
marko_web_browser_component_tag = marko_loadTag(marko_web_browser_component_template),
|
|
24
|
+
marko_forOf = require("marko/dist/runtime/helpers/for-of"),
|
|
25
|
+
helpers_escape_xml = require("marko/dist/runtime/html/helpers/escape-xml"),
|
|
26
|
+
marko_escapeXml = helpers_escape_xml.x,
|
|
27
|
+
marko_web_search_set_filter_value_link_template = require("../links/set-filter-value.marko"),
|
|
28
|
+
marko_web_search_set_filter_value_link_tag = marko_loadTag(marko_web_search_set_filter_value_link_template),
|
|
29
|
+
marko_assign = require("marko/dist/runtime/helpers/assign"),
|
|
30
|
+
marko_web_element_template = require("@mindful-web/marko-web/components/element/index.marko"),
|
|
31
|
+
marko_web_element_tag = marko_loadTag(marko_web_element_template),
|
|
32
|
+
marko_web_block_template = require("@mindful-web/marko-web/components/element/block.marko"),
|
|
33
|
+
marko_web_block_tag = marko_loadTag(marko_web_block_template);
|
|
34
|
+
|
|
35
|
+
function render(input, out, __component, component, state) {
|
|
36
|
+
var data = input;
|
|
37
|
+
|
|
38
|
+
const { $markoWebSearch: search, i18n } = out.global;
|
|
39
|
+
|
|
40
|
+
const blockName = "marko-web-search-filter";
|
|
41
|
+
|
|
42
|
+
const items = getAsArray(input.items);
|
|
43
|
+
|
|
44
|
+
const { title, filterKey } = input;
|
|
45
|
+
|
|
46
|
+
const item = getAsObject(input.item);
|
|
47
|
+
|
|
48
|
+
const itemIdPath = defaultValue(item.idPath, "id");
|
|
49
|
+
|
|
50
|
+
const itemLabelPath = defaultValue(item.labelPath, "label");
|
|
51
|
+
|
|
52
|
+
const titleModifier = dasherize(filterKey);
|
|
53
|
+
|
|
54
|
+
if (items.length) {
|
|
55
|
+
marko_web_block_tag({
|
|
56
|
+
name: blockName,
|
|
57
|
+
tag: "div",
|
|
58
|
+
modifiers: input.modifiers,
|
|
59
|
+
renderBody: function(out) {
|
|
60
|
+
if (title) {
|
|
61
|
+
if (title.renderBlock) {
|
|
62
|
+
marko_dynamicTag(out, title.renderBlock, null, null, null, null, __component, "1");
|
|
63
|
+
} else {
|
|
64
|
+
marko_web_browser_component_tag({
|
|
65
|
+
name: "MarkoWebSearchToggleFilter",
|
|
66
|
+
props: {
|
|
67
|
+
label: title.value,
|
|
68
|
+
target: (("." + blockName) + "__items--") + titleModifier,
|
|
69
|
+
toggleClass: blockName + "__items--open"
|
|
70
|
+
}
|
|
71
|
+
}, out, __component, "2");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
marko_web_element_tag({
|
|
76
|
+
name: "items",
|
|
77
|
+
tag: "ul",
|
|
78
|
+
blockName: blockName,
|
|
79
|
+
modifiers: [
|
|
80
|
+
"open",
|
|
81
|
+
titleModifier
|
|
82
|
+
],
|
|
83
|
+
renderBody: function(out) {
|
|
84
|
+
var $for$0 = 0;
|
|
85
|
+
|
|
86
|
+
marko_forOf(items, function(node) {
|
|
87
|
+
const id = get(node, itemIdPath);
|
|
88
|
+
|
|
89
|
+
const label = get(node, itemLabelPath);
|
|
90
|
+
|
|
91
|
+
const value = search.isArrayParam(filterKey) ? [id] : id;
|
|
92
|
+
|
|
93
|
+
const isSelected = search.isInputValueSelectedFor(filterKey, value);
|
|
94
|
+
|
|
95
|
+
const modifiers = isSelected ? ["selected"] : [];
|
|
96
|
+
|
|
97
|
+
var $keyScope$0 = "[" + (($for$0++) + "]");
|
|
98
|
+
|
|
99
|
+
marko_web_element_tag(marko_assign({
|
|
100
|
+
name: "default",
|
|
101
|
+
tag: "div"
|
|
102
|
+
}, item.element, {
|
|
103
|
+
tag: "li",
|
|
104
|
+
blockName: blockName,
|
|
105
|
+
name: "item",
|
|
106
|
+
modifiers: modifiers,
|
|
107
|
+
renderBody: function(out) {
|
|
108
|
+
if (item.renderBody) {
|
|
109
|
+
marko_dynamicTag(out, item.renderBody, function() {
|
|
110
|
+
return {
|
|
111
|
+
node: node,
|
|
112
|
+
"block-name": blockName,
|
|
113
|
+
id: id,
|
|
114
|
+
label: "" + (isFunction(i18n) ? i18n(label) : label),
|
|
115
|
+
"is-selected": isSelected
|
|
116
|
+
};
|
|
117
|
+
}, null, null, null, __component, "5" + $keyScope$0);
|
|
118
|
+
} else {
|
|
119
|
+
marko_web_search_set_filter_value_link_tag({
|
|
120
|
+
name: filterKey,
|
|
121
|
+
value: id,
|
|
122
|
+
resetClass: blockName + "__clear-item",
|
|
123
|
+
renderBody: function(out) {
|
|
124
|
+
out.w(marko_escapeXml(isFunction(i18n) ? i18n(label) : label));
|
|
125
|
+
}
|
|
126
|
+
}, out, __component, "6" + $keyScope$0);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}), out, __component, "4" + $keyScope$0);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}, out, __component, "3");
|
|
133
|
+
}
|
|
134
|
+
}, out, __component, "0");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
marko_template._ = marko_renderer(render, {
|
|
139
|
+
d_: true,
|
|
140
|
+
e_: marko_componentType
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
marko_template.meta = {
|
|
144
|
+
id: "/@mindful-web/marko-web-search$1.0.0/components/filters/filter-block.marko",
|
|
145
|
+
tags: [
|
|
146
|
+
"@mindful-web/marko-web/components/browser-component.marko",
|
|
147
|
+
"../links/set-filter-value.marko",
|
|
148
|
+
"@mindful-web/marko-web/components/element/index.marko",
|
|
149
|
+
"@mindful-web/marko-web/components/element/block.marko"
|
|
150
|
+
]
|
|
151
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getAsObject } from "@mindful-web/object-path";
|
|
2
|
+
import defaultValue from "@mindful-web/marko-core/utils/default-value";
|
|
3
|
+
|
|
4
|
+
$ const blockName = "marko-web-search-filter-container";
|
|
5
|
+
$ const title = getAsObject(input, "title");
|
|
6
|
+
|
|
7
|
+
<marko-web-block name=blockName modifiers=input.modifiers>
|
|
8
|
+
<if(input.beforeTitle)>
|
|
9
|
+
<${input.beforeTitle} block-name=blockName />
|
|
10
|
+
</if>
|
|
11
|
+
<marko-web-element block-name=blockName name="title">
|
|
12
|
+
<if(title.renderBlock)>
|
|
13
|
+
<${title.renderBlock} />
|
|
14
|
+
</if>
|
|
15
|
+
<else>
|
|
16
|
+
<marko-web-browser-component
|
|
17
|
+
name="MarkoWebSearchToggleFilterContainer"
|
|
18
|
+
props={
|
|
19
|
+
label: title.value,
|
|
20
|
+
target: `.${blockName}__sections`,
|
|
21
|
+
toggleClass: `${blockName}__sections--open`,
|
|
22
|
+
}
|
|
23
|
+
/>
|
|
24
|
+
</else>
|
|
25
|
+
</marko-web-element>
|
|
26
|
+
<marko-web-element block-name=blockName name="sections">
|
|
27
|
+
<${input.renderBody} />
|
|
28
|
+
</marko-web-element>
|
|
29
|
+
</marko-web-block>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.0.0/components/filters/filter-container.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
|
+
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
9
|
+
getAsObject = module_objectPath_module.getAsObject,
|
|
10
|
+
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
11
|
+
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
12
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
13
|
+
marko_web_browser_component_template = require("@mindful-web/marko-web/components/browser-component.marko"),
|
|
14
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
15
|
+
marko_web_browser_component_tag = marko_loadTag(marko_web_browser_component_template),
|
|
16
|
+
marko_web_element_template = require("@mindful-web/marko-web/components/element/index.marko"),
|
|
17
|
+
marko_web_element_tag = marko_loadTag(marko_web_element_template),
|
|
18
|
+
marko_web_block_template = require("@mindful-web/marko-web/components/element/block.marko"),
|
|
19
|
+
marko_web_block_tag = marko_loadTag(marko_web_block_template);
|
|
20
|
+
|
|
21
|
+
function render(input, out, __component, component, state) {
|
|
22
|
+
var data = input;
|
|
23
|
+
|
|
24
|
+
const blockName = "marko-web-search-filter-container";
|
|
25
|
+
|
|
26
|
+
const title = getAsObject(input, "title");
|
|
27
|
+
|
|
28
|
+
marko_web_block_tag({
|
|
29
|
+
name: blockName,
|
|
30
|
+
tag: "div",
|
|
31
|
+
modifiers: input.modifiers,
|
|
32
|
+
renderBody: function(out) {
|
|
33
|
+
if (input.beforeTitle) {
|
|
34
|
+
marko_dynamicTag(out, input.beforeTitle, function() {
|
|
35
|
+
return {
|
|
36
|
+
"block-name": blockName
|
|
37
|
+
};
|
|
38
|
+
}, null, null, null, __component, "1");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
marko_web_element_tag({
|
|
42
|
+
name: "title",
|
|
43
|
+
tag: "div",
|
|
44
|
+
blockName: blockName,
|
|
45
|
+
renderBody: function(out) {
|
|
46
|
+
if (title.renderBlock) {
|
|
47
|
+
marko_dynamicTag(out, title.renderBlock, null, null, null, null, __component, "3");
|
|
48
|
+
} else {
|
|
49
|
+
marko_web_browser_component_tag({
|
|
50
|
+
name: "MarkoWebSearchToggleFilterContainer",
|
|
51
|
+
props: {
|
|
52
|
+
label: title.value,
|
|
53
|
+
target: ("." + blockName) + "__sections",
|
|
54
|
+
toggleClass: blockName + "__sections--open"
|
|
55
|
+
}
|
|
56
|
+
}, out, __component, "4");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, out, __component, "2");
|
|
60
|
+
|
|
61
|
+
marko_web_element_tag({
|
|
62
|
+
name: "sections",
|
|
63
|
+
tag: "div",
|
|
64
|
+
blockName: blockName,
|
|
65
|
+
renderBody: function(out) {
|
|
66
|
+
marko_dynamicTag(out, input.renderBody, null, null, null, null, __component, "6");
|
|
67
|
+
}
|
|
68
|
+
}, out, __component, "5");
|
|
69
|
+
}
|
|
70
|
+
}, out, __component, "0");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
marko_template._ = marko_renderer(render, {
|
|
74
|
+
d_: true,
|
|
75
|
+
e_: marko_componentType
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
marko_template.meta = {
|
|
79
|
+
id: "/@mindful-web/marko-web-search$1.0.0/components/filters/filter-container.marko",
|
|
80
|
+
tags: [
|
|
81
|
+
"@mindful-web/marko-web/components/browser-component.marko",
|
|
82
|
+
"@mindful-web/marko-web/components/element/index.marko",
|
|
83
|
+
"@mindful-web/marko-web/components/element/block.marko"
|
|
84
|
+
]
|
|
85
|
+
};
|