vue-instantsearch 4.10.3 → 4.10.5
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 +3 -3
- package/src/__tests__/common.test.js +257 -0
- package/src/components/HitsPerPage.vue +1 -0
- 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/HitsPerPage.vue.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/HitsPerPage.vue.js +1 -1
- package/vue3/es/src/components/HitsPerPage.vue_vue&type=script&lang.js.map +1 -1
- package/vue3/es/src/components/HitsPerPage.vue_vue&type=template&id=d68f3530&lang.js +2 -0
- package/vue3/es/src/components/HitsPerPage.vue_vue&type=template&id=d68f3530&lang.js.map +1 -0
- package/vue3/umd/index.js +1 -1
- package/vue3/umd/index.js.map +1 -1
- package/vue3/es/src/components/HitsPerPage.vue_vue&type=template&id=654e3b4a&lang.js +0 -2
- package/vue3/es/src/components/HitsPerPage.vue_vue&type=template&id=654e3b4a&lang.js.map +0 -1
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"autocomplete"
|
|
17
17
|
],
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"version": "4.10.
|
|
19
|
+
"version": "4.10.5",
|
|
20
20
|
"files": [
|
|
21
21
|
"vue2",
|
|
22
22
|
"vue3",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test:exports:vue3": "node ./test/module/vue3/is-es-module.mjs && node ./test/module/vue3/is-cjs-module.cjs"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"instantsearch.js": "4.56.
|
|
38
|
+
"instantsearch.js": "4.56.5",
|
|
39
39
|
"mitt": "^2.1.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"vuex": "3.5.1",
|
|
88
88
|
"vuex4": "npm:vuex@4.0.0"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "99119060ec345379181f0446ea4ca8d7cf331354"
|
|
91
91
|
}
|
|
@@ -11,6 +11,12 @@ import {
|
|
|
11
11
|
createHitsTests,
|
|
12
12
|
createRangeInputTests,
|
|
13
13
|
createInstantSearchTests,
|
|
14
|
+
createCurrentRefinementsTests,
|
|
15
|
+
createHitsPerPageTests,
|
|
16
|
+
createNumericMenuTests,
|
|
17
|
+
createRatingMenuTests,
|
|
18
|
+
createToggleRefinementTests,
|
|
19
|
+
createSharedTests,
|
|
14
20
|
} from '@instantsearch/tests';
|
|
15
21
|
|
|
16
22
|
import { nextTick, mountApp } from '../../test/utils';
|
|
@@ -28,7 +34,24 @@ import {
|
|
|
28
34
|
AisHits,
|
|
29
35
|
AisIndex,
|
|
30
36
|
AisRangeInput,
|
|
37
|
+
AisCurrentRefinements,
|
|
38
|
+
AisHitsPerPage,
|
|
39
|
+
AisNumericMenu,
|
|
40
|
+
AisRatingMenu,
|
|
41
|
+
AisToggleRefinement,
|
|
31
42
|
} from '../instantsearch';
|
|
43
|
+
import {
|
|
44
|
+
connectBreadcrumb,
|
|
45
|
+
connectCurrentRefinements,
|
|
46
|
+
connectHierarchicalMenu,
|
|
47
|
+
connectHitsPerPage,
|
|
48
|
+
connectMenu,
|
|
49
|
+
connectNumericMenu,
|
|
50
|
+
connectPagination,
|
|
51
|
+
connectRatingMenu,
|
|
52
|
+
connectRefinementList,
|
|
53
|
+
connectToggleRefinement,
|
|
54
|
+
} from 'instantsearch.js/es/connectors';
|
|
32
55
|
jest.unmock('instantsearch.js/es');
|
|
33
56
|
|
|
34
57
|
/**
|
|
@@ -46,10 +69,18 @@ const GlobalErrorSwallower = {
|
|
|
46
69
|
};
|
|
47
70
|
|
|
48
71
|
createRefinementListTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
72
|
+
const RefinementListURL = createURLComponent({
|
|
73
|
+
connector: connectRefinementList,
|
|
74
|
+
name: 'RefinementList',
|
|
75
|
+
requiredProps: ['attribute'],
|
|
76
|
+
urlValue: 'value',
|
|
77
|
+
});
|
|
78
|
+
|
|
49
79
|
mountApp(
|
|
50
80
|
{
|
|
51
81
|
render: renderCompat((h) =>
|
|
52
82
|
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
83
|
+
h(RefinementListURL, { props: widgetParams }),
|
|
53
84
|
h(AisRefinementList, { props: widgetParams }),
|
|
54
85
|
h(GlobalErrorSwallower),
|
|
55
86
|
])
|
|
@@ -62,10 +93,18 @@ createRefinementListTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
|
62
93
|
});
|
|
63
94
|
|
|
64
95
|
createHierarchicalMenuTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
96
|
+
const HierarchicalMenuURL = createURLComponent({
|
|
97
|
+
connector: connectHierarchicalMenu,
|
|
98
|
+
name: 'HierarchicalMenu',
|
|
99
|
+
requiredProps: ['attributes'],
|
|
100
|
+
urlValue: 'value',
|
|
101
|
+
});
|
|
102
|
+
|
|
65
103
|
mountApp(
|
|
66
104
|
{
|
|
67
105
|
render: renderCompat((h) =>
|
|
68
106
|
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
107
|
+
h(HierarchicalMenuURL, { props: widgetParams }),
|
|
69
108
|
h(AisHierarchicalMenu, { props: widgetParams }),
|
|
70
109
|
h(GlobalErrorSwallower),
|
|
71
110
|
])
|
|
@@ -83,10 +122,18 @@ createBreadcrumbTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
|
83
122
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
84
123
|
const { transformItems, ...hierarchicalWidgetParams } = widgetParams;
|
|
85
124
|
|
|
125
|
+
const BreadcrumbURL = createURLComponent({
|
|
126
|
+
connector: connectBreadcrumb,
|
|
127
|
+
name: 'Breadcrumb',
|
|
128
|
+
requiredProps: ['attributes'],
|
|
129
|
+
urlValue: 'Apple > iPhone',
|
|
130
|
+
});
|
|
131
|
+
|
|
86
132
|
mountApp(
|
|
87
133
|
{
|
|
88
134
|
render: renderCompat((h) =>
|
|
89
135
|
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
136
|
+
h(BreadcrumbURL, { props: widgetParams }),
|
|
90
137
|
h(AisBreadcrumb, { props: widgetParams }),
|
|
91
138
|
h(AisHierarchicalMenu, { props: hierarchicalWidgetParams }),
|
|
92
139
|
h(GlobalErrorSwallower),
|
|
@@ -100,10 +147,18 @@ createBreadcrumbTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
|
100
147
|
});
|
|
101
148
|
|
|
102
149
|
createMenuTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
150
|
+
const MenuURL = createURLComponent({
|
|
151
|
+
connector: connectMenu,
|
|
152
|
+
name: 'Menu',
|
|
153
|
+
requiredProps: ['attribute'],
|
|
154
|
+
urlValue: 'value',
|
|
155
|
+
});
|
|
156
|
+
|
|
103
157
|
mountApp(
|
|
104
158
|
{
|
|
105
159
|
render: renderCompat((h) =>
|
|
106
160
|
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
161
|
+
h(MenuURL, { props: widgetParams }),
|
|
107
162
|
h(AisMenu, { props: widgetParams }),
|
|
108
163
|
h(GlobalErrorSwallower),
|
|
109
164
|
])
|
|
@@ -116,10 +171,17 @@ createMenuTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
|
116
171
|
});
|
|
117
172
|
|
|
118
173
|
createPaginationTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
174
|
+
const PaginationURL = createURLComponent({
|
|
175
|
+
connector: connectPagination,
|
|
176
|
+
name: 'Pagination',
|
|
177
|
+
urlValue: 10,
|
|
178
|
+
});
|
|
179
|
+
|
|
119
180
|
mountApp(
|
|
120
181
|
{
|
|
121
182
|
render: renderCompat((h) =>
|
|
122
183
|
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
184
|
+
h(PaginationURL, { props: widgetParams }),
|
|
123
185
|
h(AisPagination, { props: widgetParams }),
|
|
124
186
|
h(GlobalErrorSwallower),
|
|
125
187
|
])
|
|
@@ -303,6 +365,138 @@ createRangeInputTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
|
303
365
|
await nextTick();
|
|
304
366
|
});
|
|
305
367
|
|
|
368
|
+
createCurrentRefinementsTests(
|
|
369
|
+
async ({ instantSearchOptions, widgetParams }) => {
|
|
370
|
+
const CurrentRefinementsURL = createURLComponent({
|
|
371
|
+
connector: connectCurrentRefinements,
|
|
372
|
+
name: 'CurrentRefinements',
|
|
373
|
+
urlValue: {
|
|
374
|
+
attribute: 'brand',
|
|
375
|
+
type: 'disjunctive',
|
|
376
|
+
value: 'Apple',
|
|
377
|
+
label: 'Apple',
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
mountApp(
|
|
382
|
+
{
|
|
383
|
+
render: renderCompat((h) =>
|
|
384
|
+
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
385
|
+
h(CurrentRefinementsURL, { props: widgetParams }),
|
|
386
|
+
h(AisCurrentRefinements),
|
|
387
|
+
h(AisRefinementList, { props: { attribute: 'brand' } }),
|
|
388
|
+
h(GlobalErrorSwallower),
|
|
389
|
+
])
|
|
390
|
+
),
|
|
391
|
+
},
|
|
392
|
+
document.body.appendChild(document.createElement('div'))
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
await nextTick();
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
createHitsPerPageTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
400
|
+
const HitsPerPageURL = createURLComponent({
|
|
401
|
+
connector: connectHitsPerPage,
|
|
402
|
+
name: 'HitsPerPage',
|
|
403
|
+
requiredProps: ['items'],
|
|
404
|
+
urlValue: 12,
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
mountApp(
|
|
408
|
+
{
|
|
409
|
+
render: renderCompat((h) =>
|
|
410
|
+
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
411
|
+
h(HitsPerPageURL, { props: widgetParams }),
|
|
412
|
+
h(AisHitsPerPage, { props: widgetParams }),
|
|
413
|
+
h(GlobalErrorSwallower),
|
|
414
|
+
])
|
|
415
|
+
),
|
|
416
|
+
},
|
|
417
|
+
document.body.appendChild(document.createElement('div'))
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
await nextTick();
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
createNumericMenuTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
424
|
+
const NumericMenuURL = createURLComponent({
|
|
425
|
+
connector: connectNumericMenu,
|
|
426
|
+
name: 'NumericMenu',
|
|
427
|
+
requiredProps: ['attribute', 'items'],
|
|
428
|
+
urlValue: encodeURI('{ "start": 500 }'),
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
mountApp(
|
|
432
|
+
{
|
|
433
|
+
render: renderCompat((h) =>
|
|
434
|
+
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
435
|
+
h(NumericMenuURL, { props: widgetParams }),
|
|
436
|
+
h(AisNumericMenu, { props: widgetParams }),
|
|
437
|
+
h(GlobalErrorSwallower),
|
|
438
|
+
])
|
|
439
|
+
),
|
|
440
|
+
},
|
|
441
|
+
document.body.appendChild(document.createElement('div'))
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
await nextTick();
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
createRatingMenuTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
448
|
+
const RatingMenuURL = createURLComponent({
|
|
449
|
+
connector: connectRatingMenu,
|
|
450
|
+
name: 'RatingMenu',
|
|
451
|
+
requiredProps: ['attribute'],
|
|
452
|
+
urlValue: encodeURI('5'),
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
mountApp(
|
|
456
|
+
{
|
|
457
|
+
render: renderCompat((h) =>
|
|
458
|
+
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
459
|
+
h(RatingMenuURL, { props: widgetParams }),
|
|
460
|
+
h(AisRatingMenu, { props: widgetParams }),
|
|
461
|
+
h(GlobalErrorSwallower),
|
|
462
|
+
])
|
|
463
|
+
),
|
|
464
|
+
},
|
|
465
|
+
document.body.appendChild(document.createElement('div'))
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
await nextTick();
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
createToggleRefinementTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
472
|
+
const ToggleRefinementURL = createURLComponent({
|
|
473
|
+
name: 'ToggleRefinement',
|
|
474
|
+
connector: connectToggleRefinement,
|
|
475
|
+
requiredProps: ['attribute', 'label'],
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// Label is required in Vue
|
|
479
|
+
const props = {
|
|
480
|
+
...widgetParams,
|
|
481
|
+
label: 'Free Shipping',
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
mountApp(
|
|
485
|
+
{
|
|
486
|
+
render: renderCompat((h) =>
|
|
487
|
+
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
488
|
+
h(ToggleRefinementURL, { props }),
|
|
489
|
+
h(AisToggleRefinement, { props }),
|
|
490
|
+
h(GlobalErrorSwallower),
|
|
491
|
+
])
|
|
492
|
+
),
|
|
493
|
+
},
|
|
494
|
+
document.body.appendChild(document.createElement('div'))
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
await nextTick();
|
|
498
|
+
});
|
|
499
|
+
|
|
306
500
|
createInstantSearchTests(({ instantSearchOptions }) => {
|
|
307
501
|
mountApp(
|
|
308
502
|
{
|
|
@@ -327,3 +521,66 @@ createInstantSearchTests(({ instantSearchOptions }) => {
|
|
|
327
521
|
],
|
|
328
522
|
};
|
|
329
523
|
});
|
|
524
|
+
|
|
525
|
+
createSharedTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
526
|
+
const MenuURL = createURLComponent({
|
|
527
|
+
connector: connectMenu,
|
|
528
|
+
name: 'Menu',
|
|
529
|
+
requiredProps: ['attribute'],
|
|
530
|
+
urlValue: 'value',
|
|
531
|
+
});
|
|
532
|
+
const PaginationURL = createURLComponent({
|
|
533
|
+
connector: connectPagination,
|
|
534
|
+
name: 'Pagination',
|
|
535
|
+
urlValue: 10,
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
mountApp(
|
|
539
|
+
{
|
|
540
|
+
render: renderCompat((h) =>
|
|
541
|
+
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
542
|
+
h(MenuURL, { props: widgetParams.menu }),
|
|
543
|
+
h(AisMenu, { props: widgetParams.menu }),
|
|
544
|
+
h(AisHits, { props: widgetParams.hits }),
|
|
545
|
+
h(PaginationURL, { props: widgetParams.pagination }),
|
|
546
|
+
h(AisPagination, { props: widgetParams.pagination }),
|
|
547
|
+
h(GlobalErrorSwallower),
|
|
548
|
+
])
|
|
549
|
+
),
|
|
550
|
+
},
|
|
551
|
+
document.body.appendChild(document.createElement('div'))
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
await nextTick();
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
function createURLComponent({ connector, name, urlValue, requiredProps = [] }) {
|
|
558
|
+
return {
|
|
559
|
+
name: `${name}URL`,
|
|
560
|
+
mixins: [createWidgetMixin({ connector })],
|
|
561
|
+
props: Object.fromEntries(
|
|
562
|
+
requiredProps.map((prop) => [prop, { required: true }])
|
|
563
|
+
),
|
|
564
|
+
computed: {
|
|
565
|
+
widgetParams() {
|
|
566
|
+
return Object.fromEntries(
|
|
567
|
+
requiredProps.map((prop) => [prop, this[prop]])
|
|
568
|
+
);
|
|
569
|
+
},
|
|
570
|
+
},
|
|
571
|
+
render: renderCompat(function (h) {
|
|
572
|
+
return this.state
|
|
573
|
+
? h(
|
|
574
|
+
'a',
|
|
575
|
+
{
|
|
576
|
+
attrs: {
|
|
577
|
+
'data-testid': `${name}-link`,
|
|
578
|
+
href: this.state.createURL(urlValue),
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
'LINK'
|
|
582
|
+
)
|
|
583
|
+
: null;
|
|
584
|
+
}),
|
|
585
|
+
};
|
|
586
|
+
}
|