@blaze-cms/react-page-builder 0.123.0-alpha.7 → 0.123.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +106 -792
  2. package/lib/components/Card/Card.js +20 -6
  3. package/lib/components/Card/Card.js.map +1 -1
  4. package/lib/components/Card/CardContainer.js +20 -4
  5. package/lib/components/Card/CardContainer.js.map +1 -1
  6. package/lib/components/CarouselWrapper.js +12 -5
  7. package/lib/components/CarouselWrapper.js.map +1 -1
  8. package/lib/components/DataSummary/helpers/get-link-based-on-value.js +4 -0
  9. package/lib/components/DataSummary/helpers/get-link-based-on-value.js.map +1 -1
  10. package/lib/components/List/components/Cards/CardsRenderItem.js +23 -4
  11. package/lib/components/List/components/Cards/CardsRenderItem.js.map +1 -1
  12. package/lib/components/Menu/Menu.js +4 -3
  13. package/lib/components/Menu/Menu.js.map +1 -1
  14. package/lib/components/SearchContent/index.js +32 -23
  15. package/lib/components/SearchContent/index.js.map +1 -1
  16. package/lib/components/SearchFilter/SearchFilter/FiltersList.js +16 -11
  17. package/lib/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
  18. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +15 -50
  19. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  20. package/lib/components/SearchFilter/components/Select.js +22 -10
  21. package/lib/components/SearchFilter/components/Select.js.map +1 -1
  22. package/lib/components/index.js +5 -0
  23. package/lib/components/index.js.map +1 -1
  24. package/lib/constants/index.js +5 -2
  25. package/lib/constants/index.js.map +1 -1
  26. package/lib-es/components/Card/Card.js +18 -4
  27. package/lib-es/components/Card/Card.js.map +1 -1
  28. package/lib-es/components/Card/CardContainer.js +21 -5
  29. package/lib-es/components/Card/CardContainer.js.map +1 -1
  30. package/lib-es/components/CarouselWrapper.js +12 -5
  31. package/lib-es/components/CarouselWrapper.js.map +1 -1
  32. package/lib-es/components/DataSummary/helpers/get-link-based-on-value.js +5 -1
  33. package/lib-es/components/DataSummary/helpers/get-link-based-on-value.js.map +1 -1
  34. package/lib-es/components/List/components/Cards/CardsRenderItem.js +23 -4
  35. package/lib-es/components/List/components/Cards/CardsRenderItem.js.map +1 -1
  36. package/lib-es/components/Menu/Menu.js +4 -3
  37. package/lib-es/components/Menu/Menu.js.map +1 -1
  38. package/lib-es/components/SearchContent/index.js +29 -22
  39. package/lib-es/components/SearchContent/index.js.map +1 -1
  40. package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js +20 -16
  41. package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
  42. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +10 -40
  43. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  44. package/lib-es/components/SearchFilter/components/Select.js +22 -6
  45. package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
  46. package/lib-es/components/index.js +4 -1
  47. package/lib-es/components/index.js.map +1 -1
  48. package/lib-es/constants/index.js +3 -1
  49. package/lib-es/constants/index.js.map +1 -1
  50. package/package.json +3 -3
  51. package/src/components/Card/Card.js +28 -3
  52. package/src/components/Card/CardContainer.js +18 -2
  53. package/src/components/CarouselWrapper.js +8 -5
  54. package/src/components/DataSummary/helpers/get-link-based-on-value.js +9 -1
  55. package/src/components/List/components/Cards/CardsRenderItem.js +22 -3
  56. package/src/components/Menu/Menu.js +4 -3
  57. package/src/components/SearchContent/index.js +27 -18
  58. package/src/components/SearchFilter/SearchFilter/FiltersList.js +5 -2
  59. package/src/components/SearchFilter/SearchFilter/SearchFilter.js +113 -148
  60. package/src/components/SearchFilter/components/Select.js +29 -6
  61. package/src/components/index.js +2 -1
  62. package/src/constants/index.js +3 -1
  63. package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +10 -10
  64. package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +8 -8
  65. package/tests/unit/src/components/Card/__snapshots__/CardRender.test.js.snap +2 -2
  66. package/tests/unit/src/components/Card/mockData.js +2 -0
  67. package/tests/unit/src/components/DataSummary/helpers/get-link-based-on-value.test.js +29 -0
  68. package/tests/unit/src/components/List/components/Cards/__snapshots__/CardsRender.test.js.snap +12 -12
  69. package/tests/unit/src/components/Menu/Menu.test.js +3 -1
  70. package/tests/unit/src/components/Menu/__snapshots__/Menu.test.js.snap +3 -0
  71. package/tests/unit/src/components/SearchFilter/SearchFilter/SearchFilter.test.js +64 -86
  72. package/tests/unit/src/components/SearchFilter/SearchFilter/__snapshots__/SearchFilter.test.js.snap +133 -61
  73. package/tests/unit/src/components/SearchFilter/components/Select.test.js +58 -4
  74. package/tests/unit/src/components/SearchFilter/components/__snapshots__/Select.test.js.snap +28 -5
  75. package/tests/unit/src/components/__snapshots__/index.test.js.snap +4 -0
@@ -1,9 +1,77 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`SearchFilter component should render without throwing error and match snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <form
6
+ class="filter__form filter__form--initial filter__form--collapsible"
7
+ data-testid="filter-test-form"
8
+ id="filter-test-form"
9
+ >
10
+ <div
11
+ class="filter filter--search-refine"
12
+ >
13
+ <div
14
+ class="filter__reset"
15
+ >
16
+ <button
17
+ class="icon-button icon-button--reset"
18
+ data-testid="reset-icon"
19
+ title="reset--button"
20
+ type="button"
21
+ >
22
+ <i>
23
+ <svg
24
+ fill="currentColor"
25
+ height="1em"
26
+ stroke="currentColor"
27
+ stroke-width="0"
28
+ viewBox="0 0 512 512"
29
+ width="1em"
30
+ xmlns="http://www.w3.org/2000/svg"
31
+ >
32
+ <path
33
+ d="M256.455 8c66.269.119 126.437 26.233 170.859 68.685l35.715-35.715C478.149 25.851 504 36.559 504 57.941V192c0 13.255-10.745 24-24 24H345.941c-21.382 0-32.09-25.851-16.971-40.971l41.75-41.75c-30.864-28.899-70.801-44.907-113.23-45.273-92.398-.798-170.283 73.977-169.484 169.442C88.764 348.009 162.184 424 256 424c41.127 0 79.997-14.678 110.629-41.556 4.743-4.161 11.906-3.908 16.368.553l39.662 39.662c4.872 4.872 4.631 12.815-.482 17.433C378.202 479.813 319.926 504 256 504 119.034 504 8.001 392.967 8 256.002 7.999 119.193 119.646 7.755 256.455 8z"
34
+ />
35
+ </svg>
36
+ </i>
37
+ </button>
38
+ <div
39
+ data-testid="reset-button"
40
+ role="button"
41
+ >
42
+ Reset all filters
43
+ </div>
44
+ </div>
45
+ <div
46
+ class="filter__wrapper filter__wrapper--search-refine"
47
+ >
48
+ <br />
49
+ <button
50
+ class="button button--full-width"
51
+ type="submit"
52
+ >
53
+ Search
54
+ </button>
55
+ </div>
56
+ </div>
57
+ </form>
58
+ <div
59
+ class="filter__refine filter__refine--mobile-close"
60
+ data-testid="refine-mobile"
61
+ >
62
+ <div
63
+ role="button"
64
+ >
65
+ Refine Search
66
+ </div>
67
+ </div>
68
+ </DocumentFragment>
69
+ `;
70
+
3
71
  exports[`SearchFilter component when groupAfterMobile = 0 and groupAfterDesktop > 0 should render without throwing error and match snapshot 1`] = `
4
72
  <DocumentFragment>
5
73
  <form
6
- class=""
74
+ class="filter__form filter__form--initial filter__form--collapsible"
7
75
  data-testid="filter-test-form"
8
76
  id="filter-test-form"
9
77
  >
@@ -160,13 +228,23 @@ exports[`SearchFilter component when groupAfterMobile = 0 and groupAfterDesktop
160
228
  </div>
161
229
  </div>
162
230
  </form>
231
+ <div
232
+ class="filter__refine filter__refine--mobile-close"
233
+ data-testid="refine-mobile"
234
+ >
235
+ <div
236
+ role="button"
237
+ >
238
+ Refine Search
239
+ </div>
240
+ </div>
163
241
  </DocumentFragment>
164
242
  `;
165
243
 
166
244
  exports[`SearchFilter component when groupAfterMobile > 0 and groupAfterDesktop = 0 should render without throwing error and match snapshot 1`] = `
167
245
  <DocumentFragment>
168
246
  <form
169
- class=""
247
+ class="filter__form filter__form--initial filter__form--collapsible"
170
248
  data-testid="filter-test-form"
171
249
  id="filter-test-form"
172
250
  >
@@ -323,13 +401,23 @@ exports[`SearchFilter component when groupAfterMobile > 0 and groupAfterDesktop
323
401
  </div>
324
402
  </div>
325
403
  </form>
404
+ <div
405
+ class="filter__refine filter__refine--mobile-close"
406
+ data-testid="refine-mobile"
407
+ >
408
+ <div
409
+ role="button"
410
+ >
411
+ Refine Search
412
+ </div>
413
+ </div>
326
414
  </DocumentFragment>
327
415
  `;
328
416
 
329
417
  exports[`SearchFilter component when groupAfterMobile > 0 and groupAfterDesktop > 0 should render without throwing error and match snapshot 1`] = `
330
418
  <DocumentFragment>
331
419
  <form
332
- class=""
420
+ class="filter__form filter__form--initial filter__form--collapsible"
333
421
  data-testid="filter-test-form"
334
422
  id="filter-test-form"
335
423
  >
@@ -492,71 +580,23 @@ exports[`SearchFilter component when groupAfterMobile > 0 and groupAfterDesktop
492
580
  </div>
493
581
  </div>
494
582
  </form>
495
- </DocumentFragment>
496
- `;
497
-
498
- exports[`SearchFilter component when the device is desktop should render without throwing error and match snapshot 1`] = `
499
- <DocumentFragment>
500
- <form
501
- class=""
502
- data-testid="filter-test-form"
503
- id="filter-test-form"
583
+ <div
584
+ class="filter__refine filter__refine--mobile-close"
585
+ data-testid="refine-mobile"
504
586
  >
505
587
  <div
506
- class="filter filter--search-refine"
588
+ role="button"
507
589
  >
508
- <div
509
- class="filter__reset"
510
- >
511
- <button
512
- class="icon-button icon-button--reset"
513
- data-testid="reset-icon"
514
- title="reset--button"
515
- type="button"
516
- >
517
- <i>
518
- <svg
519
- fill="currentColor"
520
- height="1em"
521
- stroke="currentColor"
522
- stroke-width="0"
523
- viewBox="0 0 512 512"
524
- width="1em"
525
- xmlns="http://www.w3.org/2000/svg"
526
- >
527
- <path
528
- d="M256.455 8c66.269.119 126.437 26.233 170.859 68.685l35.715-35.715C478.149 25.851 504 36.559 504 57.941V192c0 13.255-10.745 24-24 24H345.941c-21.382 0-32.09-25.851-16.971-40.971l41.75-41.75c-30.864-28.899-70.801-44.907-113.23-45.273-92.398-.798-170.283 73.977-169.484 169.442C88.764 348.009 162.184 424 256 424c41.127 0 79.997-14.678 110.629-41.556 4.743-4.161 11.906-3.908 16.368.553l39.662 39.662c4.872 4.872 4.631 12.815-.482 17.433C378.202 479.813 319.926 504 256 504 119.034 504 8.001 392.967 8 256.002 7.999 119.193 119.646 7.755 256.455 8z"
529
- />
530
- </svg>
531
- </i>
532
- </button>
533
- <div
534
- data-testid="reset-button"
535
- role="button"
536
- >
537
- Reset all filters
538
- </div>
539
- </div>
540
- <div
541
- class="filter__wrapper filter__wrapper--search-refine"
542
- >
543
- <br />
544
- <button
545
- class="button button--full-width"
546
- type="submit"
547
- >
548
- Search
549
- </button>
550
- </div>
590
+ Refine Search
551
591
  </div>
552
- </form>
592
+ </div>
553
593
  </DocumentFragment>
554
594
  `;
555
595
 
556
- exports[`SearchFilter component when the device is mobile when isCollapsedOnResponsive = false, displaySearchFilter = false should render without throwing error and match snapshot 1`] = `
596
+ exports[`SearchFilter component when isCollapsedOnResponsive = false, displaySearchFilter = false should render without throwing error and match snapshot 1`] = `
557
597
  <DocumentFragment>
558
598
  <form
559
- class=""
599
+ class="filter__form filter__form--initial"
560
600
  data-testid="filter-test-form"
561
601
  id="filter-test-form"
562
602
  >
@@ -611,10 +651,10 @@ exports[`SearchFilter component when the device is mobile when isCollapsedOnResp
611
651
  </DocumentFragment>
612
652
  `;
613
653
 
614
- exports[`SearchFilter component when the device is mobile when isCollapsedOnResponsive = true, displaySearchFilter = true should render without throwing error and match snapshot 1`] = `
654
+ exports[`SearchFilter component when isCollapsedOnResponsive = true, displaySearchFilter = true should render without throwing error and match snapshot 1`] = `
615
655
  <DocumentFragment>
616
656
  <form
617
- class="filter__form filter__form--mobile"
657
+ class="filter__form filter__form--initial filter__form--mobile filter__form--collapsible"
618
658
  data-testid="filter-test-form"
619
659
  id="filter-test-form"
620
660
  >
@@ -649,6 +689,38 @@ exports[`SearchFilter component when the device is mobile when isCollapsedOnResp
649
689
  <div
650
690
  class="filter filter--search-refine"
651
691
  >
692
+ <div
693
+ class="filter__reset"
694
+ >
695
+ <button
696
+ class="icon-button icon-button--reset"
697
+ data-testid="reset-icon"
698
+ title="reset--button"
699
+ type="button"
700
+ >
701
+ <i>
702
+ <svg
703
+ fill="currentColor"
704
+ height="1em"
705
+ stroke="currentColor"
706
+ stroke-width="0"
707
+ viewBox="0 0 512 512"
708
+ width="1em"
709
+ xmlns="http://www.w3.org/2000/svg"
710
+ >
711
+ <path
712
+ d="M256.455 8c66.269.119 126.437 26.233 170.859 68.685l35.715-35.715C478.149 25.851 504 36.559 504 57.941V192c0 13.255-10.745 24-24 24H345.941c-21.382 0-32.09-25.851-16.971-40.971l41.75-41.75c-30.864-28.899-70.801-44.907-113.23-45.273-92.398-.798-170.283 73.977-169.484 169.442C88.764 348.009 162.184 424 256 424c41.127 0 79.997-14.678 110.629-41.556 4.743-4.161 11.906-3.908 16.368.553l39.662 39.662c4.872 4.872 4.631 12.815-.482 17.433C378.202 479.813 319.926 504 256 504 119.034 504 8.001 392.967 8 256.002 7.999 119.193 119.646 7.755 256.455 8z"
713
+ />
714
+ </svg>
715
+ </i>
716
+ </button>
717
+ <div
718
+ data-testid="reset-button"
719
+ role="button"
720
+ >
721
+ Reset all filters
722
+ </div>
723
+ </div>
652
724
  <div
653
725
  class="filter__wrapper filter__wrapper--search-refine"
654
726
  >
@@ -1,23 +1,27 @@
1
1
  import { render } from '@blaze-cms/tools/test-helpers/test-functions';
2
- import { screen } from '@testing-library/react';
2
+ import { screen, fireEvent, act } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
  import { SelectFilter } from '../../../../../../src/components/SearchFilter/components';
5
+ import { DEFAULT_OPTION } from '../../../../../../src/components/SearchFilter/constants';
5
6
 
6
7
  jest.mock('next/router', () => ({
7
8
  useRouter: jest.fn(() => ({ asPath: 'test-url' }))
8
9
  }));
9
10
 
11
+ const changeValue = 'name2';
12
+ const testId = 'filter-name';
10
13
  const props = {
11
14
  data: {
12
15
  name: {
13
- buckets: [{ key: 'name1' }, { key: 'name2' }]
16
+ buckets: [{ key: 'name1' }, { key: changeValue }]
14
17
  }
15
18
  },
16
19
  filterValues: {},
17
20
  updateFilterValues: jest.fn(),
18
21
  prop: 'name',
19
22
  buttonRef: {},
20
- hasUrl: false
23
+ hasUrl: false,
24
+ shouldSearch: true
21
25
  };
22
26
 
23
27
  describe('Select component', () => {
@@ -26,10 +30,60 @@ describe('Select component', () => {
26
30
  expect(asFragment()).toMatchSnapshot();
27
31
  });
28
32
 
29
- it('should match snapshot with label', () => {
33
+ it('should match snapshot with label', () => {
30
34
  const label = 'Select name';
31
35
  const propsWithLabel = { ...props, label };
32
36
  render(SelectFilter, propsWithLabel);
33
37
  expect(screen.getByLabelText(label)).toBeInTheDocument();
34
38
  });
39
+
40
+ it('should pass on changed value', () => {
41
+ const { getByTestId } = render(SelectFilter, props);
42
+ act(() => {
43
+ fireEvent.change(getByTestId(testId), { target: { value: changeValue } });
44
+ });
45
+
46
+ expect(props.updateFilterValues).toHaveBeenCalledWith(
47
+ {
48
+ [props.prop]: changeValue
49
+ },
50
+ props.shouldSearch
51
+ );
52
+ });
53
+
54
+ it('should reset value if default option selected', () => {
55
+ const { getByTestId } = render(SelectFilter, props);
56
+ act(() => {
57
+ fireEvent.change(getByTestId(testId), { target: { value: DEFAULT_OPTION } });
58
+ });
59
+
60
+ expect(props.updateFilterValues).toHaveBeenCalledWith(
61
+ {
62
+ [props.prop]: ''
63
+ },
64
+ props.shouldSearch
65
+ );
66
+ });
67
+
68
+ it('should display label as placeholder with no label tag', () => {
69
+ const label = 'Placeholder label';
70
+ const { asFragment, getByTestId, queryByText } = render(SelectFilter, {
71
+ ...props,
72
+ label,
73
+ displayLabelAsPlaceholder: true
74
+ });
75
+ expect(asFragment()).toMatchSnapshot();
76
+ expect(queryByText(DEFAULT_OPTION)).toBeNull();
77
+
78
+ act(() => {
79
+ fireEvent.change(getByTestId(testId), { target: { value: label } });
80
+ });
81
+
82
+ expect(props.updateFilterValues).toHaveBeenCalledWith(
83
+ {
84
+ [props.prop]: ''
85
+ },
86
+ props.shouldSearch
87
+ );
88
+ });
35
89
  });
@@ -1,5 +1,32 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`Select component should display label as placeholder with no label tag 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="form-field form-field--select"
7
+ >
8
+ <select
9
+ data-testid="filter-name"
10
+ id="name"
11
+ >
12
+ <option>
13
+ Placeholder label
14
+ </option>
15
+ <option
16
+ value="name1"
17
+ >
18
+ name1
19
+ </option>
20
+ <option
21
+ value="name2"
22
+ >
23
+ name2
24
+ </option>
25
+ </select>
26
+ </div>
27
+ </DocumentFragment>
28
+ `;
29
+
3
30
  exports[`Select component should render witout throwing an error and match snapshot 1`] = `
4
31
  <DocumentFragment>
5
32
  <div
@@ -12,14 +39,10 @@ exports[`Select component should render witout throwing an error and match snaps
12
39
  name
13
40
  </label>
14
41
  <select
42
+ data-testid="filter-name"
15
43
  id="name"
16
44
  >
17
45
  <option>
18
- Please Choose...
19
- </option>
20
- <option
21
- value="Any"
22
- >
23
46
  Any
24
47
  </option>
25
48
  <option
@@ -6,6 +6,10 @@ Object {
6
6
  "$$typeof": Symbol(react.forward_ref),
7
7
  "render": [Function],
8
8
  },
9
+ "breadcrumb": Object {
10
+ "$$typeof": Symbol(react.forward_ref),
11
+ "render": [Function],
12
+ },
9
13
  "button": Object {
10
14
  "$$typeof": Symbol(react.forward_ref),
11
15
  "render": [Function],