vue-instantsearch 4.13.8 → 4.15.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/package.json +8 -6
- package/src/__tests__/common-widgets.test.js +16 -0
- package/src/components/Highlight.vue +1 -2
- package/src/components/Highlighter.js +69 -0
- package/src/components/Hits.js +113 -0
- package/src/components/RefinementList.vue +3 -2
- package/src/components/SearchInput.vue +0 -1
- package/src/components/Snippet.vue +1 -2
- package/src/components/__tests__/Hits.js +1 -1
- package/src/components/__tests__/NumericMenu.js +0 -51
- package/src/util/pragma.js +22 -0
- package/src/{components/Highlighter.vue → util/vue-compat/Highlighter/Highlighter-vue2.vue} +6 -9
- package/src/util/vue-compat/Highlighter/index-vue2.js +1 -0
- package/src/util/vue-compat/Highlighter/index-vue3.js +1 -0
- package/src/util/vue-compat/Highlighter/index.js +1 -0
- package/src/util/vue-compat/index-vue2.js +26 -1
- package/src/util/vue-compat/index-vue3.js +7 -0
- package/src/widgets.js +1 -1
- package/vue2/cjs/index.js +1 -1
- package/vue2/cjs/index.js.map +1 -1
- package/vue2/es/package.json.js +1 -1
- package/vue2/es/src/components/Highlight.vue_rollup-plugin-vue=script.js +1 -1
- package/vue2/es/src/components/Hits.js +2 -0
- package/vue2/es/src/components/Hits.js.map +1 -0
- package/vue2/es/src/components/RefinementList.vue.js +1 -1
- package/vue2/es/src/components/RefinementList.vue_rollup-plugin-vue=script.js.map +1 -1
- package/vue2/es/src/components/Snippet.vue_rollup-plugin-vue=script.js +1 -1
- package/vue2/es/src/instantsearch.js +1 -1
- package/vue2/es/src/util/vue-compat/Highlighter/Highlighter-vue2.vue.js +2 -0
- package/vue2/es/src/util/vue-compat/Highlighter/Highlighter-vue2.vue.js.map +1 -0
- package/vue2/es/src/util/vue-compat/Highlighter/Highlighter-vue2.vue_rollup-plugin-vue=script.js +2 -0
- package/vue2/es/src/util/vue-compat/Highlighter/Highlighter-vue2.vue_rollup-plugin-vue=script.js.map +1 -0
- package/vue2/es/src/util/vue-compat/index-vue2.js +1 -1
- package/vue2/es/src/util/vue-compat/index-vue2.js.map +1 -1
- package/vue2/es/src/widgets.js +1 -1
- package/vue2/umd/index.js +1 -1
- package/vue2/umd/index.js.map +1 -1
- package/vue3/cjs/index.js +1 -1
- package/vue3/cjs/index.js.map +1 -1
- package/vue3/es/package.json.js +1 -1
- package/vue3/es/src/components/Highlight.vue.js +1 -1
- package/vue3/es/src/components/Highlight.vue_vue&type=script&lang.js +1 -1
- package/vue3/es/src/components/Highlight.vue_vue&type=script&lang.js.map +1 -1
- package/vue3/es/src/components/{Highlight.vue_vue&type=template&id=1d5c1fda&lang.js → Highlight.vue_vue&type=template&id=214ecb36&lang.js} +1 -1
- package/vue3/es/src/components/Highlight.vue_vue&type=template&id=214ecb36&lang.js.map +1 -0
- package/vue3/es/src/components/Highlighter.js +2 -0
- package/vue3/es/src/components/Highlighter.js.map +1 -0
- package/vue3/es/src/components/Hits.js +2 -0
- package/vue3/es/src/components/Hits.js.map +1 -0
- package/vue3/es/src/components/RefinementList.vue.js +1 -1
- package/vue3/es/src/components/RefinementList.vue_vue&type=script&lang.js.map +1 -1
- package/vue3/es/src/components/RefinementList.vue_vue&type=template&id=e39e9d16&lang.js +2 -0
- package/vue3/es/src/components/RefinementList.vue_vue&type=template&id=e39e9d16&lang.js.map +1 -0
- package/vue3/es/src/components/SearchInput.vue.js +1 -1
- package/vue3/es/src/components/SearchInput.vue_vue&type=script&lang.js.map +1 -1
- package/vue3/es/src/components/{SearchInput.vue_vue&type=template&id=02fb82e2&lang.js → SearchInput.vue_vue&type=template&id=79e30e4e&lang.js} +1 -1
- package/vue3/es/src/components/SearchInput.vue_vue&type=template&id=79e30e4e&lang.js.map +1 -0
- package/vue3/es/src/components/Snippet.vue.js +1 -1
- package/vue3/es/src/components/Snippet.vue_vue&type=script&lang.js +1 -1
- package/vue3/es/src/components/Snippet.vue_vue&type=script&lang.js.map +1 -1
- package/vue3/es/src/components/{Snippet.vue_vue&type=template&id=1e214b4c&lang.js → Snippet.vue_vue&type=template&id=edc35952&lang.js} +1 -1
- package/vue3/es/src/components/Snippet.vue_vue&type=template&id=edc35952&lang.js.map +1 -0
- package/vue3/es/src/instantsearch.js +1 -1
- package/vue3/es/src/util/pragma.js +2 -0
- package/vue3/es/src/util/pragma.js.map +1 -0
- package/vue3/es/src/util/vue-compat/index-vue3.js +1 -1
- package/vue3/es/src/util/vue-compat/index-vue3.js.map +1 -1
- package/vue3/es/src/widgets.js +1 -1
- package/vue3/umd/index.js +1 -1
- package/vue3/umd/index.js.map +1 -1
- package/src/components/Hits.vue +0 -72
- package/src/components/__tests__/RefinementList.js +0 -199
- package/src/components/__tests__/__snapshots__/RefinementList.js.snap +0 -405
- package/vue2/es/src/components/Highlighter.vue.js +0 -2
- package/vue2/es/src/components/Highlighter.vue.js.map +0 -1
- package/vue2/es/src/components/Highlighter.vue_rollup-plugin-vue=script.js +0 -2
- package/vue2/es/src/components/Highlighter.vue_rollup-plugin-vue=script.js.map +0 -1
- package/vue2/es/src/components/Hits.vue.js +0 -2
- package/vue2/es/src/components/Hits.vue.js.map +0 -1
- package/vue2/es/src/components/Hits.vue_rollup-plugin-vue=script.js +0 -2
- package/vue2/es/src/components/Hits.vue_rollup-plugin-vue=script.js.map +0 -1
- package/vue3/es/src/components/Highlight.vue_vue&type=template&id=1d5c1fda&lang.js.map +0 -1
- package/vue3/es/src/components/Highlighter.vue.js +0 -2
- package/vue3/es/src/components/Highlighter.vue.js.map +0 -1
- package/vue3/es/src/components/Highlighter.vue_vue&type=script&lang.js +0 -2
- package/vue3/es/src/components/Highlighter.vue_vue&type=script&lang.js.map +0 -1
- package/vue3/es/src/components/Highlighter.vue_vue&type=template&id=f822f802&lang.js +0 -2
- package/vue3/es/src/components/Highlighter.vue_vue&type=template&id=f822f802&lang.js.map +0 -1
- package/vue3/es/src/components/Hits.vue.js +0 -2
- package/vue3/es/src/components/Hits.vue.js.map +0 -1
- package/vue3/es/src/components/Hits.vue_vue&type=script&lang.js +0 -2
- package/vue3/es/src/components/Hits.vue_vue&type=script&lang.js.map +0 -1
- package/vue3/es/src/components/Hits.vue_vue&type=template&id=026646d2&lang.js +0 -2
- package/vue3/es/src/components/Hits.vue_vue&type=template&id=026646d2&lang.js.map +0 -1
- package/vue3/es/src/components/RefinementList.vue_vue&type=template&id=80c1baee&lang.js +0 -2
- package/vue3/es/src/components/RefinementList.vue_vue&type=template&id=80c1baee&lang.js.map +0 -1
- package/vue3/es/src/components/SearchInput.vue_vue&type=template&id=02fb82e2&lang.js.map +0 -1
- package/vue3/es/src/components/Snippet.vue_vue&type=template&id=1e214b4c&lang.js.map +0 -1
- package/vue3/es/src/util/parseAlgoliaHit.js +0 -2
- package/vue3/es/src/util/parseAlgoliaHit.js.map +0 -1
- package/vue3/es/src/util/unescape.js +0 -2
- package/vue3/es/src/util/unescape.js.map +0 -1
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"autocomplete"
|
|
17
17
|
],
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"version": "4.
|
|
19
|
+
"version": "4.15.0",
|
|
20
20
|
"files": [
|
|
21
21
|
"vue2",
|
|
22
22
|
"vue3",
|
|
@@ -32,10 +32,12 @@
|
|
|
32
32
|
"storybook": "NODE_OPTIONS=--openssl-legacy-provider start-storybook -p 6006 -c .storybook",
|
|
33
33
|
"storybook:build": "NODE_OPTIONS=--openssl-legacy-provider build-storybook -c .storybook -o ../../website/stories/vue",
|
|
34
34
|
"test:exports": "node ./test/module/vue2/is-es-module.mjs && node ./test/module/vue2/is-cjs-module.cjs",
|
|
35
|
-
"test:exports:vue3": "node ./test/module/vue3/is-es-module.mjs && node ./test/module/vue3/is-cjs-module.cjs"
|
|
35
|
+
"test:exports:vue3": "node ./test/module/vue3/is-es-module.mjs && node ./test/module/vue3/is-cjs-module.cjs",
|
|
36
|
+
"watch:es": "yarn --silent build --watch"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"instantsearch
|
|
39
|
+
"instantsearch-ui-components": "0.4.0",
|
|
40
|
+
"instantsearch.js": "4.66.1",
|
|
39
41
|
"mitt": "^2.1.0"
|
|
40
42
|
},
|
|
41
43
|
"peerDependencies": {
|
|
@@ -59,8 +61,8 @@
|
|
|
59
61
|
"@vue/server-renderer": "3.2.47",
|
|
60
62
|
"@vue/test-utils": "1.3.0",
|
|
61
63
|
"@vue/test-utils2": "npm:@vue/test-utils@2.0.0-rc.11",
|
|
62
|
-
"algoliasearch": "4.
|
|
63
|
-
"algoliasearch-helper": "3.
|
|
64
|
+
"algoliasearch": "4.22.1",
|
|
65
|
+
"algoliasearch-helper": "3.17.0",
|
|
64
66
|
"instantsearch.css": "8.1.0",
|
|
65
67
|
"rollup": "1.32.1",
|
|
66
68
|
"rollup-plugin-babel": "4.4.0",
|
|
@@ -87,5 +89,5 @@
|
|
|
87
89
|
"vuex": "3.5.1",
|
|
88
90
|
"vuex4": "npm:vuex@4.0.0"
|
|
89
91
|
},
|
|
90
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "d309ca3333476a842be080fcb01b8be925aad204"
|
|
91
93
|
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
AisSortBy,
|
|
26
26
|
AisStats,
|
|
27
27
|
AisRatingMenu,
|
|
28
|
+
AisNumericMenu,
|
|
28
29
|
} from '../instantsearch';
|
|
29
30
|
import { renderCompat } from '../util/vue-compat';
|
|
30
31
|
|
|
@@ -421,6 +422,21 @@ const testSetups = {
|
|
|
421
422
|
|
|
422
423
|
await nextTick();
|
|
423
424
|
},
|
|
425
|
+
async createNumericMenuWidgetTests({ instantSearchOptions, widgetParams }) {
|
|
426
|
+
mountApp(
|
|
427
|
+
{
|
|
428
|
+
render: renderCompat((h) =>
|
|
429
|
+
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
430
|
+
h(AisNumericMenu, { props: widgetParams }),
|
|
431
|
+
h(GlobalErrorSwallower),
|
|
432
|
+
])
|
|
433
|
+
),
|
|
434
|
+
},
|
|
435
|
+
document.body.appendChild(document.createElement('div'))
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
await nextTick();
|
|
439
|
+
},
|
|
424
440
|
async createToggleRefinementWidgetTests({
|
|
425
441
|
instantSearchOptions,
|
|
426
442
|
widgetParams,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createHighlightComponent } from 'instantsearch-ui-components';
|
|
2
|
+
import {
|
|
3
|
+
getHighlightedParts,
|
|
4
|
+
getPropertyByPath,
|
|
5
|
+
unescape,
|
|
6
|
+
} from 'instantsearch.js/es/lib/utils';
|
|
7
|
+
|
|
8
|
+
import { createElement, Fragment } from '../util/pragma';
|
|
9
|
+
|
|
10
|
+
const Highlight = createHighlightComponent({ createElement, Fragment });
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
name: 'AisHighlighter',
|
|
14
|
+
props: {
|
|
15
|
+
hit: {
|
|
16
|
+
type: Object,
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
attribute: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
highlightedTagName: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'mark',
|
|
26
|
+
},
|
|
27
|
+
suit: {
|
|
28
|
+
type: Function,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
highlightProperty: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
preTag: {
|
|
36
|
+
type: String,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
postTag: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
render() {
|
|
45
|
+
const property =
|
|
46
|
+
getPropertyByPath(this.hit[this.highlightProperty], this.attribute) || [];
|
|
47
|
+
const properties = Array.isArray(property) ? property : [property];
|
|
48
|
+
|
|
49
|
+
const parts = properties.map((singleValue) =>
|
|
50
|
+
getHighlightedParts(unescape(singleValue.value || '')).map(
|
|
51
|
+
({ value, isHighlighted }) => ({
|
|
52
|
+
// We have to do this because Vue gets rid of TextNodes with a single white space
|
|
53
|
+
value: value === ' ' ? ' ' : value,
|
|
54
|
+
isHighlighted,
|
|
55
|
+
})
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return createElement(Highlight, {
|
|
60
|
+
classNames: {
|
|
61
|
+
root: this.suit(),
|
|
62
|
+
highlighted: this.suit('highlighted'),
|
|
63
|
+
},
|
|
64
|
+
highlightedTagName: this.highlightedTagName,
|
|
65
|
+
nonHighlightedTagName: Fragment,
|
|
66
|
+
parts,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { createHitsComponent } from 'instantsearch-ui-components';
|
|
2
|
+
import { connectHitsWithInsights } from 'instantsearch.js/es/connectors';
|
|
3
|
+
|
|
4
|
+
import { createSuitMixin } from '../mixins/suit';
|
|
5
|
+
import { createWidgetMixin } from '../mixins/widget';
|
|
6
|
+
import { getScopedSlot, renderCompat } from '../util/vue-compat';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
name: 'AisHits',
|
|
10
|
+
mixins: [
|
|
11
|
+
createWidgetMixin(
|
|
12
|
+
{
|
|
13
|
+
connector: connectHitsWithInsights,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
$$widgetType: 'ais.hits',
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
createSuitMixin({ name: 'Hits' }),
|
|
20
|
+
],
|
|
21
|
+
props: {
|
|
22
|
+
escapeHTML: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: true,
|
|
25
|
+
},
|
|
26
|
+
transformItems: {
|
|
27
|
+
type: Function,
|
|
28
|
+
default: undefined,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
computed: {
|
|
32
|
+
items() {
|
|
33
|
+
return this.state.hits;
|
|
34
|
+
},
|
|
35
|
+
widgetParams() {
|
|
36
|
+
return {
|
|
37
|
+
escapeHTML: this.escapeHTML,
|
|
38
|
+
transformItems: this.transformItems,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
render: renderCompat(function (h) {
|
|
43
|
+
if (!this.state) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const defaultSlot = getScopedSlot(this, 'default');
|
|
48
|
+
const itemSlot = getScopedSlot(this, 'item');
|
|
49
|
+
|
|
50
|
+
const itemComponent = ({
|
|
51
|
+
hit,
|
|
52
|
+
index,
|
|
53
|
+
onClick,
|
|
54
|
+
onAuxClick,
|
|
55
|
+
// We don't want to pass the Preact key as a prop
|
|
56
|
+
key: _key,
|
|
57
|
+
...rootProps
|
|
58
|
+
}) => {
|
|
59
|
+
return h(
|
|
60
|
+
'li',
|
|
61
|
+
{
|
|
62
|
+
key: hit.objectID,
|
|
63
|
+
attrs: rootProps,
|
|
64
|
+
on: {
|
|
65
|
+
click: onClick,
|
|
66
|
+
auxclick: onAuxClick,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
[
|
|
70
|
+
(itemSlot &&
|
|
71
|
+
itemSlot({
|
|
72
|
+
item: hit,
|
|
73
|
+
index,
|
|
74
|
+
insights: this.state.insights,
|
|
75
|
+
sendEvent: this.state.sendEvent,
|
|
76
|
+
})) ||
|
|
77
|
+
`objectID: ${hit.objectID}, index: ${index}`,
|
|
78
|
+
]
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// We only want to render the default slot
|
|
83
|
+
// if no other slots are defined
|
|
84
|
+
if (!itemSlot && defaultSlot) {
|
|
85
|
+
return h(
|
|
86
|
+
'div',
|
|
87
|
+
{
|
|
88
|
+
attrs: {
|
|
89
|
+
class: this.suit(),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
[
|
|
93
|
+
defaultSlot({
|
|
94
|
+
items: this.state.hits,
|
|
95
|
+
insights: this.state.insights,
|
|
96
|
+
sendEvent: this.state.sendEvent,
|
|
97
|
+
}),
|
|
98
|
+
]
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return h(createHitsComponent({ createElement: h }), {
|
|
103
|
+
hits: this.state.hits,
|
|
104
|
+
itemComponent,
|
|
105
|
+
sendEvent: this.state.sendEvent,
|
|
106
|
+
classNames: this.classNames && {
|
|
107
|
+
root: this.classNames['ais-Hits'],
|
|
108
|
+
list: this.classNames['ais-Hits-list'],
|
|
109
|
+
item: this.classNames['ais-Hits-item'],
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}),
|
|
113
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
:class="[suit(),
|
|
3
|
+
:class="[suit(), items.length === 0 && suit('', 'noRefinement')]"
|
|
4
4
|
v-if="state"
|
|
5
5
|
>
|
|
6
6
|
<slot
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
<div :class="suit('searchBox')" v-if="searchable">
|
|
20
20
|
<search-input
|
|
21
21
|
v-model="searchForFacetValues"
|
|
22
|
+
:show-loading-indicator="true"
|
|
22
23
|
:placeholder="searchablePlaceholder"
|
|
23
24
|
:class-names="classNames"
|
|
24
25
|
/>
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
>
|
|
31
32
|
<div :class="suit('noResults')">No results.</div>
|
|
32
33
|
</slot>
|
|
33
|
-
<ul :class="suit('list')">
|
|
34
|
+
<ul v-if="items.length > 0" :class="suit('list')">
|
|
34
35
|
<li
|
|
35
36
|
:class="[suit('item'), item.isRefined && suit('item', 'selected')]"
|
|
36
37
|
v-for="item in items"
|
|
@@ -62,57 +62,6 @@ const defaultProps = {
|
|
|
62
62
|
],
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
it('accepts an attribute prop', () => {
|
|
66
|
-
__setState(defaultState);
|
|
67
|
-
|
|
68
|
-
const props = {
|
|
69
|
-
...defaultProps,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const wrapper = mount(NumericMenu, {
|
|
73
|
-
propsData: props,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
expect(wrapper.vm.widgetParams.attribute).toBe('brand');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('accepts an items prop', () => {
|
|
80
|
-
__setState(defaultState);
|
|
81
|
-
|
|
82
|
-
const props = {
|
|
83
|
-
...defaultProps,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const wrapper = mount(NumericMenu, {
|
|
87
|
-
propsData: props,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(wrapper.vm.widgetParams.items).toEqual([
|
|
91
|
-
{ label: 'All' },
|
|
92
|
-
{ label: '<= 10$', end: 10 },
|
|
93
|
-
{ label: '10$ - 100$', start: 10, end: 100 },
|
|
94
|
-
{ label: '100$ - 500$', start: 100, end: 500 },
|
|
95
|
-
{ label: '>= 500$', start: 500 },
|
|
96
|
-
]);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('accepts an transformItems prop', () => {
|
|
100
|
-
__setState(defaultState);
|
|
101
|
-
|
|
102
|
-
const identity = (x) => x;
|
|
103
|
-
|
|
104
|
-
const props = {
|
|
105
|
-
...defaultProps,
|
|
106
|
-
transformItems: identity,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const wrapper = mount(NumericMenu, {
|
|
110
|
-
propsData: props,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
expect(wrapper.vm.widgetParams.transformItems).toBe(identity);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
65
|
describe('default render', () => {
|
|
117
66
|
it('renders correctly', () => {
|
|
118
67
|
__setState(defaultState);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { h, Fragment } from 'vue';
|
|
2
|
+
|
|
3
|
+
export const createElement = (tag, props, children) => {
|
|
4
|
+
if (!children) {
|
|
5
|
+
return h(tag, props);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (tag === Fragment) {
|
|
9
|
+
return h(tag, Array.isArray(children) ? children : [children]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// It does work to just pass a string but outputs a warning about performance issues
|
|
13
|
+
const newChildren =
|
|
14
|
+
typeof children === 'string' ? { default: () => children } : children;
|
|
15
|
+
// Passing a `children` prop to a DOM element outputs a warning
|
|
16
|
+
const newProps =
|
|
17
|
+
typeof tag === 'string' ? props : Object.assign(props, { children });
|
|
18
|
+
|
|
19
|
+
return h(tag, newProps, newChildren);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { Fragment };
|
|
@@ -11,16 +11,13 @@
|
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<script>
|
|
14
|
-
import { parseAlgoliaHit } from '
|
|
15
|
-
import { getDefaultSlot, renderCompat, isVue3 } from '../util/vue-compat';
|
|
14
|
+
import { parseAlgoliaHit } from '../../parseAlgoliaHit';
|
|
16
15
|
|
|
17
|
-
const TextNode =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}),
|
|
23
|
-
};
|
|
16
|
+
const TextNode = {
|
|
17
|
+
render() {
|
|
18
|
+
return this.$slots.default;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
24
21
|
|
|
25
22
|
export default {
|
|
26
23
|
name: 'AisHighlighter',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Highlighter-vue2.vue';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../../components/Highlighter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './index-vue2';
|
|
@@ -7,9 +7,30 @@ const version = Vue.version;
|
|
|
7
7
|
|
|
8
8
|
export { Vue, Vue2, isVue2, isVue3, version };
|
|
9
9
|
|
|
10
|
+
const augmentCreateElement =
|
|
11
|
+
(createElement) =>
|
|
12
|
+
(tag, propsWithClassName = {}, children) => {
|
|
13
|
+
const { className, ...props } = propsWithClassName;
|
|
14
|
+
|
|
15
|
+
if (typeof tag === 'function') {
|
|
16
|
+
return tag(
|
|
17
|
+
Object.assign(props, {
|
|
18
|
+
class: className || props.class,
|
|
19
|
+
children,
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return createElement(
|
|
25
|
+
tag,
|
|
26
|
+
Object.assign(props, { class: className || props.class }),
|
|
27
|
+
[children]
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
10
31
|
export function renderCompat(fn) {
|
|
11
32
|
return function (createElement) {
|
|
12
|
-
return fn.call(this, createElement);
|
|
33
|
+
return fn.call(this, augmentCreateElement(createElement));
|
|
13
34
|
};
|
|
14
35
|
}
|
|
15
36
|
|
|
@@ -17,6 +38,10 @@ export function getDefaultSlot(component) {
|
|
|
17
38
|
return component.$slots.default;
|
|
18
39
|
}
|
|
19
40
|
|
|
41
|
+
export function getScopedSlot(component, name) {
|
|
42
|
+
return (component.$scopedSlots || {})[name];
|
|
43
|
+
}
|
|
44
|
+
|
|
20
45
|
// Vue3-only APIs
|
|
21
46
|
export const computed = undefined;
|
|
22
47
|
export const createApp = undefined;
|
|
@@ -30,6 +30,9 @@ export function renderCompat(fn) {
|
|
|
30
30
|
delete flatProps.props;
|
|
31
31
|
delete flatProps.scopedSlots;
|
|
32
32
|
onPropKeys.forEach((key) => delete flatProps.on[key]);
|
|
33
|
+
if (flatProps.on && Object.keys(flatProps.on).length === 0) {
|
|
34
|
+
delete flatProps.on;
|
|
35
|
+
}
|
|
33
36
|
|
|
34
37
|
return Vue.h(
|
|
35
38
|
tag,
|
|
@@ -59,3 +62,7 @@ export function getDefaultSlot(component) {
|
|
|
59
62
|
// Vue 3 with @vue/compat
|
|
60
63
|
return $slots.default;
|
|
61
64
|
}
|
|
65
|
+
|
|
66
|
+
export function getScopedSlot(component, name) {
|
|
67
|
+
return (component.$slots || component.slots || {})[name];
|
|
68
|
+
}
|
package/src/widgets.js
CHANGED
|
@@ -6,7 +6,7 @@ export { default as AisExperimentalConfigureRelatedItems } from './components/Co
|
|
|
6
6
|
export { default as AisCurrentRefinements } from './components/CurrentRefinements.vue';
|
|
7
7
|
export { default as AisHierarchicalMenu } from './components/HierarchicalMenu.vue';
|
|
8
8
|
export { default as AisHighlight } from './components/Highlight.vue';
|
|
9
|
-
export { default as AisHits } from './components/Hits
|
|
9
|
+
export { default as AisHits } from './components/Hits';
|
|
10
10
|
export { default as AisHitsPerPage } from './components/HitsPerPage.vue';
|
|
11
11
|
export { default as AisIndex } from './components/Index';
|
|
12
12
|
export { default as AisInstantSearch } from './components/InstantSearch';
|