vue-instantsearch 4.13.1 → 4.13.2
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 +6 -6
- package/src/components/HierarchicalMenuList.vue +1 -2
- package/src/components/SearchInput.vue +8 -4
- package/src/components/__tests__/HierarchicalMenu.js +0 -343
- package/src/components/__tests__/__snapshots__/HierarchicalMenu.js.snap +0 -568
- 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/HierarchicalMenuList.vue.js +1 -1
- package/vue2/es/src/components/SearchInput.vue.js +1 -1
- package/vue2/es/src/components/SearchInput.vue_rollup-plugin-vue=script.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/HierarchicalMenuList.vue.js +1 -1
- package/vue3/es/src/components/HierarchicalMenuList.vue_vue&type=script&lang.js.map +1 -1
- package/vue3/es/src/components/{HierarchicalMenuList.vue_vue&type=template&id=eb2af574&lang.js → HierarchicalMenuList.vue_vue&type=template&id=420e1cd4&lang.js} +2 -2
- package/vue3/es/src/components/HierarchicalMenuList.vue_vue&type=template&id=420e1cd4&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 +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=3a66396c&lang.js +2 -0
- package/vue3/es/src/components/SearchInput.vue_vue&type=template&id=3a66396c&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/HierarchicalMenuList.vue_vue&type=template&id=eb2af574&lang.js.map +0 -1
- package/vue3/es/src/components/SearchInput.vue_vue&type=template&id=2e14ab6e&lang.js +0 -2
- package/vue3/es/src/components/SearchInput.vue_vue&type=template&id=2e14ab6e&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.13.
|
|
19
|
+
"version": "4.13.2",
|
|
20
20
|
"files": [
|
|
21
21
|
"vue2",
|
|
22
22
|
"vue3",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"prebuild": "rm -rf vue2 vue3",
|
|
31
31
|
"build": "rollup -c",
|
|
32
|
-
"storybook": "start-storybook -p 6006 -c .storybook",
|
|
33
|
-
"storybook:build": "build-storybook -c .storybook -o ../../website/stories/vue",
|
|
32
|
+
"storybook": "NODE_OPTIONS=--openssl-legacy-provider start-storybook -p 6006 -c .storybook",
|
|
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
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.
|
|
38
|
+
"instantsearch.js": "4.63.0",
|
|
39
39
|
"mitt": "^2.1.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@vue/test-utils": "1.3.0",
|
|
61
61
|
"@vue/test-utils2": "npm:@vue/test-utils@2.0.0-rc.11",
|
|
62
62
|
"algoliasearch": "4.14.3",
|
|
63
|
-
"algoliasearch-helper": "3.16.
|
|
63
|
+
"algoliasearch-helper": "3.16.1",
|
|
64
64
|
"instantsearch.css": "8.1.0",
|
|
65
65
|
"rollup": "1.32.1",
|
|
66
66
|
"rollup-plugin-babel": "4.4.0",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"vuex": "3.5.1",
|
|
88
88
|
"vuex4": "npm:vuex@4.0.0"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "b90c55a93cd6fe56128d9d6c746c153dbb3c3649"
|
|
91
91
|
}
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
:key="item.value"
|
|
13
13
|
:class="[
|
|
14
14
|
suit('item'),
|
|
15
|
-
item.data && item.data.length > 0 && suit('item', 'parent'),
|
|
16
15
|
item.isRefined && suit('item', 'selected'),
|
|
16
|
+
item.data && item.data.length > 0 && suit('item', 'parent'),
|
|
17
17
|
]"
|
|
18
18
|
>
|
|
19
19
|
<a
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
<span :class="suit('label')">{{ item.label }}</span>
|
|
25
25
|
<span :class="suit('count')">{{ item.count }}</span>
|
|
26
26
|
</a>
|
|
27
|
-
|
|
28
27
|
<hierarchical-menu-list
|
|
29
28
|
v-if="item.data"
|
|
30
29
|
:items="item.data"
|
|
@@ -23,10 +23,8 @@
|
|
|
23
23
|
:value="value || modelValue"
|
|
24
24
|
@focus="$emit('focus', $event)"
|
|
25
25
|
@blur="$emit('blur', $event)"
|
|
26
|
-
@input="
|
|
27
|
-
|
|
28
|
-
$emit('update:modelValue', $event.target.value);
|
|
29
|
-
"
|
|
26
|
+
@input="onInput($event)"
|
|
27
|
+
@compositionend="onInput($event)"
|
|
30
28
|
ref="input"
|
|
31
29
|
/>
|
|
32
30
|
<button
|
|
@@ -162,6 +160,12 @@ export default {
|
|
|
162
160
|
isFocused() {
|
|
163
161
|
return document.activeElement === this.$refs.input;
|
|
164
162
|
},
|
|
163
|
+
onInput(event) {
|
|
164
|
+
if (event.type === 'compositionend' || !event.isComposing) {
|
|
165
|
+
this.$emit('input', event.target.value);
|
|
166
|
+
this.$emit('update:modelValue', event.target.value);
|
|
167
|
+
}
|
|
168
|
+
},
|
|
165
169
|
onFormSubmit() {
|
|
166
170
|
const input = this.$refs.input;
|
|
167
171
|
input.blur();
|
|
@@ -139,349 +139,6 @@ const defaultProps = {
|
|
|
139
139
|
attributes: ['categories.lvl0', 'categories.lvl1', 'categories.lvl2'],
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
it('accepts an attributes prop', () => {
|
|
143
|
-
__setState({
|
|
144
|
-
...defaultState,
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
148
|
-
propsData: defaultProps,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
expect(wrapper.vm.widgetParams.attributes).toEqual([
|
|
152
|
-
'categories.lvl0',
|
|
153
|
-
'categories.lvl1',
|
|
154
|
-
'categories.lvl2',
|
|
155
|
-
]);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('accepts a limit prop (without showMore)', () => {
|
|
159
|
-
__setState({
|
|
160
|
-
...defaultState,
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
164
|
-
propsData: {
|
|
165
|
-
...defaultProps,
|
|
166
|
-
showMore: false,
|
|
167
|
-
limit: 2,
|
|
168
|
-
showMoreLimit: 5,
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
expect(wrapper.vm.widgetParams.limit).toBe(2);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it('accepts a showMoreLimit prop (with showMore)', () => {
|
|
176
|
-
__setState({
|
|
177
|
-
...defaultState,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
181
|
-
propsData: {
|
|
182
|
-
...defaultProps,
|
|
183
|
-
showMore: true,
|
|
184
|
-
limit: 2,
|
|
185
|
-
showMoreLimit: 5,
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
expect(wrapper.vm.widgetParams.showMoreLimit).toBe(5);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('accepts a separator prop', () => {
|
|
193
|
-
__setState({
|
|
194
|
-
...defaultState,
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
198
|
-
propsData: {
|
|
199
|
-
...defaultProps,
|
|
200
|
-
separator: ' --> ',
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
expect(wrapper.vm.widgetParams.separator).toBe(' --> ');
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('accepts a rootPath prop', () => {
|
|
208
|
-
__setState({
|
|
209
|
-
...defaultState,
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
213
|
-
propsData: {
|
|
214
|
-
...defaultProps,
|
|
215
|
-
rootPath: 'Apple > MacBook',
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
expect(wrapper.vm.widgetParams.rootPath).toBe('Apple > MacBook');
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('accepts a showParentLevel prop', () => {
|
|
223
|
-
__setState({
|
|
224
|
-
...defaultState,
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
228
|
-
propsData: {
|
|
229
|
-
...defaultProps,
|
|
230
|
-
showParentLevel: false,
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
expect(wrapper.vm.widgetParams.showParentLevel).toBe(false);
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it('accepts a sortBy prop', () => {
|
|
238
|
-
__setState({
|
|
239
|
-
...defaultState,
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
243
|
-
propsData: {
|
|
244
|
-
...defaultProps,
|
|
245
|
-
sortBy: ['count:asc'],
|
|
246
|
-
},
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
expect(wrapper.vm.widgetParams.sortBy).toEqual(['count:asc']);
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('accepts a transformItems prop', () => {
|
|
253
|
-
__setState({
|
|
254
|
-
...defaultState,
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
const transformItems = () => {};
|
|
258
|
-
|
|
259
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
260
|
-
propsData: {
|
|
261
|
-
...defaultProps,
|
|
262
|
-
transformItems,
|
|
263
|
-
},
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
expect(wrapper.vm.widgetParams.transformItems).toBe(transformItems);
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
describe('default render', () => {
|
|
270
|
-
it('renders correctly', () => {
|
|
271
|
-
__setState({ ...defaultState });
|
|
272
|
-
|
|
273
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
274
|
-
propsData: defaultProps,
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
it('renders correctly without refinement', () => {
|
|
281
|
-
__setState({
|
|
282
|
-
...defaultState,
|
|
283
|
-
items: [],
|
|
284
|
-
canRefine: false,
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
288
|
-
propsData: defaultProps,
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('renders correctly the parent of sub categories', () => {
|
|
295
|
-
__setState({
|
|
296
|
-
...defaultState,
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
300
|
-
propsData: defaultProps,
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
expect(wrapper.findAll('.ais-HierarchicalMenu-item--parent')).toHaveLength(
|
|
304
|
-
3 // 2 Apple + 1 Samsung
|
|
305
|
-
);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('renders correctly the list of sub categories', () => {
|
|
309
|
-
__setState({
|
|
310
|
-
...defaultState,
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
314
|
-
propsData: defaultProps,
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
expect(wrapper.findAll('.ais-HierarchicalMenu-list--lvl0')).toHaveLength(1);
|
|
318
|
-
expect(wrapper.findAll('.ais-HierarchicalMenu-list--lvl1')).toHaveLength(2);
|
|
319
|
-
expect(wrapper.findAll('.ais-HierarchicalMenu-list--lvl2')).toHaveLength(1);
|
|
320
|
-
|
|
321
|
-
expect(wrapper.findAll('.ais-HierarchicalMenu-list--child')).toHaveLength(
|
|
322
|
-
3 // 2 Apple + 1 Samsung
|
|
323
|
-
);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it('renders correctly with a URL for the href', () => {
|
|
327
|
-
__setState({
|
|
328
|
-
...defaultState,
|
|
329
|
-
createURL: (value) => `/categories/${value}`,
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
333
|
-
propsData: defaultProps,
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
it('renders correctly a sub categories selected', () => {
|
|
340
|
-
__setState({
|
|
341
|
-
...defaultState,
|
|
342
|
-
items: [
|
|
343
|
-
{
|
|
344
|
-
...apple,
|
|
345
|
-
isRefined: true,
|
|
346
|
-
data: [
|
|
347
|
-
iphone,
|
|
348
|
-
ipad,
|
|
349
|
-
{
|
|
350
|
-
...macbook,
|
|
351
|
-
isRefined: true,
|
|
352
|
-
data: [macbook13, macbook15, macbook12],
|
|
353
|
-
},
|
|
354
|
-
],
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
...samsung,
|
|
358
|
-
data: [galaxy, note],
|
|
359
|
-
},
|
|
360
|
-
microsoft,
|
|
361
|
-
],
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
365
|
-
propsData: defaultProps,
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
expect(
|
|
369
|
-
wrapper.findAll('.ais-HierarchicalMenu-item--selected')
|
|
370
|
-
).toHaveLength(2);
|
|
371
|
-
|
|
372
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
it('renders correctly with show more disabled', () => {
|
|
376
|
-
__setState({
|
|
377
|
-
...defaultState,
|
|
378
|
-
canToggleShowMore: false,
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
382
|
-
propsData: {
|
|
383
|
-
...defaultProps,
|
|
384
|
-
showMore: true,
|
|
385
|
-
},
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
const button = wrapper.find('button');
|
|
389
|
-
expect(button).vueToBeDisabled();
|
|
390
|
-
expect(button.classes()).toContain(
|
|
391
|
-
'ais-HierarchicalMenu-showMore--disabled'
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
expect(wrapper.htmlCompat()).toMatchSnapshot();
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it('renders correctly with show more label', () => {
|
|
398
|
-
__setState({
|
|
399
|
-
...defaultState,
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
403
|
-
propsData: {
|
|
404
|
-
...defaultProps,
|
|
405
|
-
showMore: true,
|
|
406
|
-
},
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
const showMoreButton = wrapper.find('.ais-HierarchicalMenu-showMore');
|
|
410
|
-
|
|
411
|
-
expect(showMoreButton.text()).toBe('Show more');
|
|
412
|
-
expect(showMoreButton.html()).toMatchSnapshot();
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
it('renders correctly with show more label toggled', async () => {
|
|
416
|
-
__setState({
|
|
417
|
-
...defaultState,
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
421
|
-
propsData: {
|
|
422
|
-
...defaultProps,
|
|
423
|
-
showMore: true,
|
|
424
|
-
limit: 1,
|
|
425
|
-
},
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
const button = wrapper.find('button');
|
|
429
|
-
|
|
430
|
-
await button.trigger('click');
|
|
431
|
-
|
|
432
|
-
await wrapper.setData({
|
|
433
|
-
state: {
|
|
434
|
-
isShowingMore: true,
|
|
435
|
-
},
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
expect(button.text()).toBe('Show less');
|
|
439
|
-
expect(button.html()).toMatchSnapshot();
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
it('calls refine on link click', async () => {
|
|
443
|
-
const refine = jest.fn();
|
|
444
|
-
|
|
445
|
-
__setState({
|
|
446
|
-
...defaultState,
|
|
447
|
-
refine,
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
451
|
-
propsData: defaultProps,
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
await wrapper
|
|
455
|
-
.find(
|
|
456
|
-
'.ais-HierarchicalMenu-list--lvl2 .ais-HierarchicalMenu-item:nth-child(2) a'
|
|
457
|
-
)
|
|
458
|
-
.trigger('click');
|
|
459
|
-
|
|
460
|
-
expect(refine).toHaveBeenCalledTimes(1);
|
|
461
|
-
expect(refine).toHaveBeenCalledWith('Apple > MacBook > MacBook 15"');
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
it('calls toggleShowMore on button click', async () => {
|
|
465
|
-
const toggleShowMore = jest.fn();
|
|
466
|
-
__setState({
|
|
467
|
-
...defaultState,
|
|
468
|
-
toggleShowMore,
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
const wrapper = mount(HierarchicalMenu, {
|
|
472
|
-
propsData: {
|
|
473
|
-
...defaultProps,
|
|
474
|
-
showMore: true,
|
|
475
|
-
limit: 1,
|
|
476
|
-
},
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
await wrapper.find('button').trigger('click');
|
|
480
|
-
|
|
481
|
-
expect(toggleShowMore).toHaveBeenCalledTimes(1);
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
|
|
485
142
|
it('exposes send-event method for insights middleware', async () => {
|
|
486
143
|
const sendEvent = jest.fn();
|
|
487
144
|
__setState({
|