@blaze-cms/react-page-builder 0.124.0-alpha.4 → 0.124.0-alpha.43
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/CHANGELOG.md +347 -0
- package/README.md +9 -0
- package/example.env +1 -0
- package/lib/BannerContext/index.js.map +1 -1
- package/lib/HOC/withInfiniteScroll.js.map +1 -1
- package/lib/HOC/withTitle.js.map +1 -1
- package/lib/PBContext/index.js.map +1 -1
- package/lib/application/query/index.js +9 -3
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/BackToTop/BackToTop.js.map +1 -1
- package/lib/components/Banner/AdSlotRender.js.map +1 -1
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Banner/BannerRender.js.map +1 -1
- package/lib/components/Banner/helpers.js.map +1 -1
- package/lib/components/Banner/index.js.map +1 -1
- package/lib/components/BlazeLink.js.map +1 -1
- package/lib/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/lib/components/Button.js +18 -5
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Card/CardContainer.js +3 -7
- package/lib/components/Card/CardContainer.js.map +1 -1
- package/lib/components/Card/CardFactory.js +6 -3
- package/lib/components/Card/CardFactory.js.map +1 -1
- package/lib/components/Card/CardRender.js.map +1 -1
- package/lib/components/Card/helpers/filter-query-setup.js.map +1 -1
- package/lib/components/Card/helpers/filters-setup.js.map +1 -1
- package/lib/components/Card/helpers/get-dynamic-grid-classes.js.map +1 -1
- package/lib/components/Carousel/Carousel.js.map +1 -1
- package/lib/components/Carousel/CarouselImage/CarouselImage.js.map +1 -1
- package/lib/components/Carousel/CarouselRender/CarouselRender.js.map +1 -1
- package/lib/components/CarouselWrapper.js +2 -2
- package/lib/components/CarouselWrapper.js.map +1 -1
- package/lib/components/ClickWrapper.js.map +1 -1
- package/lib/components/Code/Code.js.map +1 -1
- package/lib/components/Code/ScriptTag.js.map +1 -1
- package/lib/components/Code/helpers/wrap-script-tags.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryFactory.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryRender.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/HeadingLargeSummary/HeadingLargeSummary.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/HeadingLargeSummary/HeadingLargeSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummary.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/LargeSummary/LargeSummary.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/LargeSummary/LargeSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/ListSummary/ListSummary.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/ListSummary/ListSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/TextSummary/TextSummary.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/TextSummary/TextSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/index.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/get-data-summary-query.js.map +1 -1
- package/lib/components/DataSummary/helpers/get-link-based-on-value.js.map +1 -1
- package/lib/components/DataSummary/helpers/get-prop-value.js.map +1 -1
- package/lib/components/DataSummary/helpers/get-value-from-array.js.map +1 -1
- package/lib/components/DataSummary/helpers/strip-summary-props-content.js.map +1 -1
- package/lib/components/EmailConfirm/EmailConfirm.js.map +1 -1
- package/lib/components/Image/GlobalLightbox/GlobalLightbox.js.map +1 -1
- package/lib/components/Image/GlobalLightbox/NavButton.js.map +1 -1
- package/lib/components/Image/GlobalLightbox/index.js.map +1 -1
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/Image/ImageDetails.js.map +1 -1
- package/lib/components/Image/ImageFactory.js.map +1 -1
- package/lib/components/Image/ImageRender.js +5 -1
- package/lib/components/Image/ImageRender.js.map +1 -1
- package/lib/components/Image/Lightbox/Lightbox.js.map +1 -1
- package/lib/components/ItemList/ItemListButton/ItemListButton.js +161 -0
- package/lib/components/ItemList/ItemListButton/ItemListButton.js.map +1 -0
- package/lib/components/ItemList/ItemListButton/index.js +16 -0
- package/lib/components/ItemList/ItemListButton/index.js.map +1 -0
- package/lib/components/ItemList/ItemListCounter/ItemListCounter.js +83 -0
- package/lib/components/ItemList/ItemListCounter/ItemListCounter.js.map +1 -0
- package/lib/components/ItemList/ItemListCounter/index.js +16 -0
- package/lib/components/ItemList/ItemListCounter/index.js.map +1 -0
- package/lib/components/ItemList/ItemListNew/ItemListNew.js +87 -0
- package/lib/components/ItemList/ItemListNew/ItemListNew.js.map +1 -0
- package/lib/components/ItemList/ItemListNew/index.js +16 -0
- package/lib/components/ItemList/ItemListNew/index.js.map +1 -0
- package/lib/components/ItemList/constants.js +19 -0
- package/lib/components/ItemList/constants.js.map +1 -0
- package/lib/components/ItemList/helpers/get-item-list-data.js +17 -0
- package/lib/components/ItemList/helpers/get-item-list-data.js.map +1 -0
- package/lib/components/ItemList/helpers/get-item-list-id.js +23 -0
- package/lib/components/ItemList/helpers/get-item-list-id.js.map +1 -0
- package/lib/components/ItemList/helpers/get-item-list-ids.js +28 -0
- package/lib/components/ItemList/helpers/get-item-list-ids.js.map +1 -0
- package/lib/components/ItemList/helpers/index.js +50 -0
- package/lib/components/ItemList/helpers/index.js.map +1 -0
- package/lib/components/ItemList/helpers/set-item-list-id.js +22 -0
- package/lib/components/ItemList/helpers/set-item-list-id.js.map +1 -0
- package/lib/components/ItemList/helpers/set-param-and-redirect.js +51 -0
- package/lib/components/ItemList/helpers/set-param-and-redirect.js.map +1 -0
- package/lib/components/ItemList/hooks/index.js +18 -0
- package/lib/components/ItemList/hooks/index.js.map +1 -0
- package/lib/components/ItemList/hooks/use-item-list-id.js +45 -0
- package/lib/components/ItemList/hooks/use-item-list-id.js.map +1 -0
- package/lib/components/Layout/Layout.js.map +1 -1
- package/lib/components/Layout/helpers/check-if-row-has-columns.js.map +1 -1
- package/lib/components/LazyImage/LazyImage.js +5 -1
- package/lib/components/LazyImage/LazyImage.js.map +1 -1
- package/lib/components/LazyImage/index.js.map +1 -1
- package/lib/components/List/ListBuilder.js +12 -6
- package/lib/components/List/ListBuilder.js.map +1 -1
- package/lib/components/List/ListFactory.js +34 -7
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/ListRender.js.map +1 -1
- package/lib/components/List/components/Cards/CardRenderWithInfiniteScroll.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRender.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRenderItem.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRenderWrapper.js.map +1 -1
- package/lib/components/List/components/Full/FullRender.js.map +1 -1
- package/lib/components/List/components/Full/FullRenderItem.js.map +1 -1
- package/lib/components/List/components/Full/FullRenderWithInfiniteScroll.js.map +1 -1
- package/lib/components/List/components/Header/ListHeader.js.map +1 -1
- package/lib/components/List/components/Pagination/Classic.js.map +1 -1
- package/lib/components/List/components/Pagination/ListPagination.js.map +1 -1
- package/lib/components/List/components/Pagination/LoadMore.js.map +1 -1
- package/lib/components/List/helpers/build-az-aggregations.js.map +1 -1
- package/lib/components/List/helpers/build-az-url.js.map +1 -1
- package/lib/components/List/helpers/build-pagination-items.js.map +1 -1
- package/lib/components/List/helpers/build-pagination-url.js.map +1 -1
- package/lib/components/List/helpers/has-required-item-list-details.js +29 -0
- package/lib/components/List/helpers/has-required-item-list-details.js.map +1 -0
- package/lib/components/List/helpers/index.js +8 -0
- package/lib/components/List/helpers/index.js.map +1 -1
- package/lib/components/Login/LoggedInMessage.js.map +1 -1
- package/lib/components/Login/Login.js.map +1 -1
- package/lib/components/Login/LoginForm.js.map +1 -1
- package/lib/components/Menu/Menu.js +41 -28
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/MenuContext.js +20 -0
- package/lib/components/Menu/MenuContext.js.map +1 -0
- package/lib/components/MenuItem/MenuItem.js +26 -7
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/Modal/Modal.js.map +1 -1
- package/lib/components/PasswordReset/PasswordReset.js.map +1 -1
- package/lib/components/PasswordReset/helpers/validatePassword.js.map +1 -1
- package/lib/components/PasswordResetRequest/PasswordResetRequest.js.map +1 -1
- package/lib/components/SearchContent/SearchContent.js +183 -0
- package/lib/components/SearchContent/SearchContent.js.map +1 -0
- package/lib/components/SearchContent/SearchContentItems.js +51 -0
- package/lib/components/SearchContent/SearchContentItems.js.map +1 -0
- package/lib/components/SearchContent/SearchContentResults.js +45 -0
- package/lib/components/SearchContent/SearchContentResults.js.map +1 -0
- package/lib/components/SearchContent/SearchContentToggleIcon.js +42 -0
- package/lib/components/SearchContent/SearchContentToggleIcon.js.map +1 -0
- package/lib/components/SearchContent/index.js +2 -233
- package/lib/components/SearchContent/index.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/CloseMobileForm.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/FiltersList.js +2 -4
- package/lib/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/MobileFormToolbar.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/ResetDesktopForm.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +27 -69
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +87 -23
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/components/Checkbox.js +19 -9
- package/lib/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib/components/SearchFilter/components/Range.js.map +1 -1
- package/lib/components/SearchFilter/components/Select.js +27 -11
- package/lib/components/SearchFilter/components/Select.js.map +1 -1
- package/lib/components/SearchFilter/components/TextSearch.js +1 -5
- package/lib/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/lib/components/SearchFilter/constants.js +1 -1
- package/lib/components/SearchFilter/constants.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js +87 -0
- package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -0
- package/lib/components/SearchFilter/helpers/build-query.js +1 -1
- package/lib/components/SearchFilter/helpers/build-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-raw-query-stringified.js +2 -1
- package/lib/components/SearchFilter/helpers/build-raw-query-stringified.js.map +1 -1
- package/lib/components/SearchFilter/helpers/calculate-min-max.js.map +1 -1
- package/lib/components/SearchFilter/helpers/check-if-range-updated.js.map +1 -1
- package/lib/components/SearchFilter/helpers/get-filter-value-from-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +18 -3
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -1
- package/lib/components/SearchFilter/helpers/get-intersected-prop.js.map +1 -1
- package/lib/components/SearchFilter/helpers/get-range-value.js.map +1 -1
- package/lib/components/SearchFilter/helpers/get-responsive-filter-classnames.js.map +1 -1
- package/lib/components/SearchFilter/helpers/get-select-options.js.map +1 -1
- package/lib/components/SearchFilter/helpers/index.js +8 -0
- package/lib/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib/components/SearchFilter/helpers/parse-filter-value.js +3 -7
- package/lib/components/SearchFilter/helpers/parse-filter-value.js.map +1 -1
- package/lib/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib/components/SocialFollow/SFItem.js.map +1 -1
- package/lib/components/SocialFollow/SocialFollow.js.map +1 -1
- package/lib/components/SocialFollow/SocialFollowRender.js.map +1 -1
- package/lib/components/SubMenu/SubMenu.js.map +1 -1
- package/lib/components/TextBlock/TextBlockRender.js.map +1 -1
- package/lib/components/TextBlock/index.js.map +1 -1
- package/lib/components/Video/Video.js.map +1 -1
- package/lib/components/Video/VideoModal.js.map +1 -1
- package/lib/components/Video/VideoRender.js.map +1 -1
- package/lib/components/Video/providers/Default.js.map +1 -1
- package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js.map +1 -1
- package/lib/components/Video/providers/YouTube/YouTubeProvider.js.map +1 -1
- package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js.map +1 -1
- package/lib/components/Video/providers/get-provider.js.map +1 -1
- package/lib/components/Wrapper.js.map +1 -1
- package/lib/components/index.js +16 -1
- package/lib/components/index.js.map +1 -1
- package/lib/constants/index.js +3 -1
- package/lib/constants/index.js.map +1 -1
- package/lib/helpers/build-inherited-filters.js.map +1 -1
- package/lib/helpers/build-raw-query-base.js.map +1 -1
- package/lib/helpers/build-raw-query.js.map +1 -1
- package/lib/helpers/build-search-values-checkbox-select.js.map +1 -1
- package/lib/helpers/check-props-to-use.js.map +1 -1
- package/lib/helpers/get-entities-with-banner.js.map +1 -1
- package/lib/helpers/get-entity-data.js.map +1 -1
- package/lib/helpers/get-entity-render-props.js.map +1 -1
- package/lib/helpers/get-filter-props.js.map +1 -1
- package/lib/helpers/get-generic-props.js.map +1 -1
- package/lib/helpers/get-generic-render-variables.js.map +1 -1
- package/lib/helpers/get-image-ids.js.map +1 -1
- package/lib/helpers/get-parsed-prop-values.js.map +1 -1
- package/lib/helpers/get-prop-values.js.map +1 -1
- package/lib/helpers/get-query-filters.js.map +1 -1
- package/lib/helpers/get-query-props.js.map +1 -1
- package/lib/helpers/get-updated-filter-by.js.map +1 -1
- package/lib/helpers/inject-banner.js.map +1 -1
- package/lib/helpers/inject-banners-to-entities.js.map +1 -1
- package/lib/helpers/inject-multiple-banners/get-banners-for-entities/get-banners-for-entities.js.map +1 -1
- package/lib/helpers/inject-multiple-banners/get-banners-for-nodes/get-banners-for-nodes.js.map +1 -1
- package/lib/helpers/inject-multiple-banners/get-banners-for-nodes/helpers/group-node-entities.js.map +1 -1
- package/lib/helpers/inject-multiple-banners/inject-multiple-banners.js.map +1 -1
- package/lib/helpers/is-filter-entitys-id.js.map +1 -1
- package/lib/helpers/parse-TextBlock.js.map +1 -1
- package/lib/helpers/parse-props-to-display.js.map +1 -1
- package/lib/helpers/render-children.js.map +1 -1
- package/lib/helpers/sort-response-data.js.map +1 -1
- package/lib/hooks/helpers/RenderComponent.js.map +1 -1
- package/lib/hooks/helpers/append-gtm-classname.js +1 -0
- package/lib/hooks/helpers/append-gtm-classname.js.map +1 -1
- package/lib/hooks/helpers/buildPBComponents.js.map +1 -1
- package/lib/hooks/helpers/getComponent.js.map +1 -1
- package/lib/hooks/helpers/inject-element-banners.js.map +1 -1
- package/lib/hooks/helpers/inject-textblock-banners.js.map +1 -1
- package/lib/hooks/helpers/insert-banners.js.map +1 -1
- package/lib/hooks/helpers/update-targetings.js.map +1 -1
- package/lib/hooks/use-banner-insertion.js.map +1 -1
- package/lib/hooks/use-check-mobile-screen.js.map +1 -1
- package/lib/hooks/use-get-entity-schema.js.map +1 -1
- package/lib/hooks/use-get-entity-schemas-as-obj.js.map +1 -1
- package/lib/hooks/use-get-image-id-from-relation.js.map +1 -1
- package/lib/hooks/use-get-images.js.map +1 -1
- package/lib/hooks/use-get-single-entity-schema.js.map +1 -1
- package/lib/hooks/use-page-builder.js.map +1 -1
- package/lib/utils/get-class-modifiers.js.map +1 -1
- package/lib/utils/get-image-data.js.map +1 -1
- package/lib-es/application/query/index.js +49 -1
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/components/Button.js +18 -6
- package/lib-es/components/Button.js.map +1 -1
- package/lib-es/components/Card/CardContainer.js +3 -7
- package/lib-es/components/Card/CardContainer.js.map +1 -1
- package/lib-es/components/Card/CardFactory.js +7 -4
- package/lib-es/components/Card/CardFactory.js.map +1 -1
- package/lib-es/components/CarouselWrapper.js +2 -2
- package/lib-es/components/CarouselWrapper.js.map +1 -1
- package/lib-es/components/Image/ImageRender.js +4 -1
- package/lib-es/components/Image/ImageRender.js.map +1 -1
- package/lib-es/components/ItemList/ItemListButton/ItemListButton.js +111 -0
- package/lib-es/components/ItemList/ItemListButton/ItemListButton.js.map +1 -0
- package/lib-es/components/ItemList/ItemListButton/index.js +3 -0
- package/lib-es/components/ItemList/ItemListButton/index.js.map +1 -0
- package/lib-es/components/ItemList/ItemListCounter/ItemListCounter.js +60 -0
- package/lib-es/components/ItemList/ItemListCounter/ItemListCounter.js.map +1 -0
- package/lib-es/components/ItemList/ItemListCounter/index.js +3 -0
- package/lib-es/components/ItemList/ItemListCounter/index.js.map +1 -0
- package/lib-es/components/ItemList/ItemListNew/ItemListNew.js +64 -0
- package/lib-es/components/ItemList/ItemListNew/ItemListNew.js.map +1 -0
- package/lib-es/components/ItemList/ItemListNew/index.js +3 -0
- package/lib-es/components/ItemList/ItemListNew/index.js.map +1 -0
- package/lib-es/components/ItemList/constants.js +6 -0
- package/lib-es/components/ItemList/constants.js.map +1 -0
- package/lib-es/components/ItemList/helpers/get-item-list-data.js +7 -0
- package/lib-es/components/ItemList/helpers/get-item-list-data.js.map +1 -0
- package/lib-es/components/ItemList/helpers/get-item-list-id.js +11 -0
- package/lib-es/components/ItemList/helpers/get-item-list-id.js.map +1 -0
- package/lib-es/components/ItemList/helpers/get-item-list-ids.js +13 -0
- package/lib-es/components/ItemList/helpers/get-item-list-ids.js.map +1 -0
- package/lib-es/components/ItemList/helpers/index.js +6 -0
- package/lib-es/components/ItemList/helpers/index.js.map +1 -0
- package/lib-es/components/ItemList/helpers/set-item-list-id.js +10 -0
- package/lib-es/components/ItemList/helpers/set-item-list-id.js.map +1 -0
- package/lib-es/components/ItemList/helpers/set-param-and-redirect.js +20 -0
- package/lib-es/components/ItemList/helpers/set-param-and-redirect.js.map +1 -0
- package/lib-es/components/ItemList/hooks/index.js +2 -0
- package/lib-es/components/ItemList/hooks/index.js.map +1 -0
- package/lib-es/components/ItemList/hooks/use-item-list-id.js +26 -0
- package/lib-es/components/ItemList/hooks/use-item-list-id.js.map +1 -0
- package/lib-es/components/LazyImage/LazyImage.js +4 -1
- package/lib-es/components/LazyImage/LazyImage.js.map +1 -1
- package/lib-es/components/List/ListBuilder.js +12 -6
- package/lib-es/components/List/ListBuilder.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +33 -9
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/helpers/has-required-item-list-details.js +20 -0
- package/lib-es/components/List/helpers/has-required-item-list-details.js.map +1 -0
- package/lib-es/components/List/helpers/index.js +1 -0
- package/lib-es/components/List/helpers/index.js.map +1 -1
- package/lib-es/components/Menu/Menu.js +54 -46
- package/lib-es/components/Menu/Menu.js.map +1 -1
- package/lib-es/components/Menu/MenuContext.js +6 -0
- package/lib-es/components/Menu/MenuContext.js.map +1 -0
- package/lib-es/components/MenuItem/MenuItem.js +24 -9
- package/lib-es/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-es/components/SearchContent/SearchContent.js +129 -0
- package/lib-es/components/SearchContent/SearchContent.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContentItems.js +33 -0
- package/lib-es/components/SearchContent/SearchContentItems.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContentResults.js +31 -0
- package/lib-es/components/SearchContent/SearchContentResults.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContentToggleIcon.js +30 -0
- package/lib-es/components/SearchContent/SearchContentToggleIcon.js.map +1 -0
- package/lib-es/components/SearchContent/index.js +1 -172
- package/lib-es/components/SearchContent/index.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js +2 -4
- package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +21 -46
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +70 -15
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Checkbox.js +18 -9
- package/lib-es/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Select.js +23 -8
- package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
- package/lib-es/components/SearchFilter/components/TextSearch.js +1 -5
- package/lib-es/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/lib-es/components/SearchFilter/constants.js +1 -1
- package/lib-es/components/SearchFilter/constants.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js +54 -0
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/build-query.js +1 -1
- package/lib-es/components/SearchFilter/helpers/build-query.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-raw-query-stringified.js +2 -1
- package/lib-es/components/SearchFilter/helpers/build-raw-query-stringified.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +13 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/index.js +2 -1
- package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/parse-filter-value.js +3 -3
- package/lib-es/components/SearchFilter/helpers/parse-filter-value.js.map +1 -1
- package/lib-es/components/index.js +10 -1
- package/lib-es/components/index.js.map +1 -1
- package/lib-es/constants/index.js +2 -1
- package/lib-es/constants/index.js.map +1 -1
- package/lib-es/helpers/build-raw-query.js.map +1 -1
- package/lib-es/hooks/helpers/append-gtm-classname.js +1 -0
- package/lib-es/hooks/helpers/append-gtm-classname.js.map +1 -1
- package/package.json +5 -4
- package/src/application/query/index.js +55 -1
- package/src/components/Button.js +27 -5
- package/src/components/Card/CardContainer.js +2 -6
- package/src/components/Card/CardFactory.js +5 -3
- package/src/components/CarouselWrapper.js +2 -2
- package/src/components/Image/ImageRender.js +3 -0
- package/src/components/ItemList/ItemListButton/ItemListButton.js +94 -0
- package/src/components/ItemList/ItemListButton/index.js +3 -0
- package/src/components/ItemList/ItemListCounter/ItemListCounter.js +52 -0
- package/src/components/ItemList/ItemListCounter/index.js +3 -0
- package/src/components/ItemList/ItemListNew/ItemListNew.js +51 -0
- package/src/components/ItemList/ItemListNew/index.js +3 -0
- package/src/components/ItemList/constants.js +5 -0
- package/src/components/ItemList/helpers/get-item-list-data.js +6 -0
- package/src/components/ItemList/helpers/get-item-list-id.js +11 -0
- package/src/components/ItemList/helpers/get-item-list-ids.js +10 -0
- package/src/components/ItemList/helpers/index.js +5 -0
- package/src/components/ItemList/helpers/set-item-list-id.js +9 -0
- package/src/components/ItemList/helpers/set-param-and-redirect.js +20 -0
- package/src/components/ItemList/hooks/index.js +1 -0
- package/src/components/ItemList/hooks/use-item-list-id.js +27 -0
- package/src/components/LazyImage/LazyImage.js +11 -1
- package/src/components/List/ListBuilder.js +10 -5
- package/src/components/List/ListFactory.js +48 -12
- package/src/components/List/helpers/has-required-item-list-details.js +14 -0
- package/src/components/List/helpers/index.js +1 -0
- package/src/components/Menu/Menu.js +61 -54
- package/src/components/Menu/MenuContext.js +5 -0
- package/src/components/MenuItem/MenuItem.js +39 -14
- package/src/components/SearchContent/SearchContent.js +136 -0
- package/src/components/SearchContent/SearchContentItems.js +28 -0
- package/src/components/SearchContent/SearchContentResults.js +27 -0
- package/src/components/SearchContent/SearchContentToggleIcon.js +27 -0
- package/src/components/SearchContent/index.js +1 -177
- package/src/components/SearchFilter/SearchFilter/FiltersList.js +30 -37
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +20 -28
- package/src/components/SearchFilter/SearchFilterContainer.js +61 -16
- package/src/components/SearchFilter/components/Checkbox.js +23 -8
- package/src/components/SearchFilter/components/Select.js +18 -11
- package/src/components/SearchFilter/components/TextSearch.js +1 -3
- package/src/components/SearchFilter/constants.js +1 -1
- package/src/components/SearchFilter/helpers/build-filters-query.js +40 -0
- package/src/components/SearchFilter/helpers/build-query.js +3 -1
- package/src/components/SearchFilter/helpers/build-raw-query-stringified.js +2 -1
- package/src/components/SearchFilter/helpers/get-initial-filter-values.js +12 -1
- package/src/components/SearchFilter/helpers/index.js +3 -1
- package/src/components/SearchFilter/helpers/parse-filter-value.js +3 -3
- package/src/components/index.js +10 -1
- package/src/constants/index.js +2 -0
- package/src/helpers/build-raw-query.js +1 -0
- package/src/hooks/helpers/append-gtm-classname.js +3 -0
- package/tests/helpers/mocks.js +4 -4
- package/tests/unit/src/components/Button.test.js +55 -1
- package/tests/unit/src/components/ItemList/ItemListButton.test.js +175 -0
- package/tests/unit/src/components/ItemList/ItemListCounter.test.js +65 -0
- package/tests/unit/src/components/ItemList/ItemListNew.test.js +164 -0
- package/tests/unit/src/components/ItemList/__snapshots__/ItemListButton.test.js.snap +107 -0
- package/tests/unit/src/components/ItemList/__snapshots__/ItemListCounter.test.js.snap +31 -0
- package/tests/unit/src/components/ItemList/__snapshots__/ItemListNew.test.js.snap +27 -0
- package/tests/unit/src/components/ItemList/helpers/get-item-list-data.test.js +28 -0
- package/tests/unit/src/components/ItemList/helpers/get-item-list-id.test.js +20 -0
- package/tests/unit/src/components/ItemList/helpers/get-item-list-ids.test.js +19 -0
- package/tests/unit/src/components/ItemList/helpers/set-item-list-id.test.js +13 -0
- package/tests/unit/src/components/ItemList/helpers/set-param-and-redirect.test.js +30 -0
- package/tests/unit/src/components/ItemList/hooks/use-item-list-id.test.js +32 -0
- package/tests/unit/src/components/List/helpers/has-required-item-list-details.test.js +30 -0
- package/tests/unit/src/components/Menu/Menu.test.js +9 -3
- package/tests/unit/src/components/Menu/__snapshots__/Menu.test.js.snap +12 -11
- package/tests/unit/src/components/MenuItem/MenuItem.test.js +1 -1
- package/tests/unit/src/components/MenuItem/SubMenu.test.js +5 -1
- package/tests/unit/src/components/MenuItem/__snapshots__/MenuItem.test.js.snap +54 -10
- package/tests/unit/src/components/SearchContent/SearchContent.test.js +29 -0
- package/tests/unit/src/components/SearchContent/__snapshots__/SearchContent.test.js.snap +9 -0
- package/tests/unit/src/components/SearchFilter/SearchFilter/SearchFilter.test.js +26 -7
- package/tests/unit/src/components/SearchFilter/SearchFilter/__snapshots__/SearchFilter.test.js.snap +4 -0
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/Checkbox.test.js.snap +2 -0
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/Select.test.js.snap +4 -0
- package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +2 -2
- package/tests/unit/src/components/SearchFilter/helpers/get-initial-filter-values.test.js +25 -11
- package/tests/unit/src/components/SearchFilter/helpers/parse-filter-value.test.js +1 -1
- package/tests/unit/src/components/__snapshots__/index.test.js.snap +12 -0
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
import React, { useState, useRef, useReducer } from 'react';
|
|
2
8
|
import { useRouter } from 'next/router';
|
|
3
9
|
import { useQuery } from '@apollo/client';
|
|
4
10
|
import PropTypes from 'prop-types';
|
|
@@ -6,11 +12,39 @@ import { parseUrl, stringify } from 'query-string';
|
|
|
6
12
|
import SearchFilter from './SearchFilter';
|
|
7
13
|
import { withTitle } from '../../HOC';
|
|
8
14
|
import { getSearchPublishedContent } from '../../application/query';
|
|
9
|
-
import { buildNewQuery, buildRawQueryStringified, getInitialFilterValues } from './helpers';
|
|
15
|
+
import { buildNewQuery, buildRawQueryStringified, getInitialFilterValues, buildFiltersQuery } from './helpers';
|
|
10
16
|
import { getEntityData } from '../../helpers';
|
|
11
17
|
import { RAW_RESULTS, RANGE, CHECKBOX_SELECT } from './constants';
|
|
12
18
|
import { SCROLL_OFFSET } from '../../constants';
|
|
13
19
|
|
|
20
|
+
const reducer = (state, action) => {
|
|
21
|
+
const {
|
|
22
|
+
newValues,
|
|
23
|
+
type,
|
|
24
|
+
shouldSearch = true
|
|
25
|
+
} = action;
|
|
26
|
+
|
|
27
|
+
switch (type) {
|
|
28
|
+
case 'update':
|
|
29
|
+
return _objectSpread(_objectSpread(_objectSpread({}, state), newValues), {}, {
|
|
30
|
+
shouldSearch
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
case 'resetSearch':
|
|
34
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
35
|
+
shouldSearch: false
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
case 'reset':
|
|
39
|
+
return _objectSpread(_objectSpread({}, newValues), {}, {
|
|
40
|
+
shouldSearch
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
default:
|
|
44
|
+
throw new Error();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
14
48
|
const SearchFilterContainer = ({
|
|
15
49
|
entity,
|
|
16
50
|
url,
|
|
@@ -18,13 +52,18 @@ const SearchFilterContainer = ({
|
|
|
18
52
|
name,
|
|
19
53
|
isCollapsedOnResponsive,
|
|
20
54
|
groupAfterMobile,
|
|
21
|
-
groupAfterDesktop
|
|
55
|
+
groupAfterDesktop,
|
|
56
|
+
filterBy,
|
|
57
|
+
filterByProperty,
|
|
58
|
+
shouldAddFilters
|
|
22
59
|
}) => {
|
|
23
60
|
const router = useRouter();
|
|
61
|
+
const {
|
|
62
|
+
asPath
|
|
63
|
+
} = router;
|
|
24
64
|
const searchFilterRef = useRef(null);
|
|
25
65
|
const [key, setKey] = useState(`filter-${name}`);
|
|
26
66
|
const [displaySearchFilter, setDisplaySearchFilter] = useState(false);
|
|
27
|
-
const hasUrl = !!url;
|
|
28
67
|
const {
|
|
29
68
|
url: currentUrl,
|
|
30
69
|
query: {
|
|
@@ -32,14 +71,15 @@ const SearchFilterContainer = ({
|
|
|
32
71
|
sortby
|
|
33
72
|
},
|
|
34
73
|
query
|
|
35
|
-
} = parseUrl(
|
|
74
|
+
} = parseUrl(asPath);
|
|
75
|
+
const [filterValues, dispatch] = useReducer(reducer, getInitialFilterValues(null, filters, query));
|
|
76
|
+
const hasUrl = !!url;
|
|
36
77
|
const sortValues = sort && sortby ? stringify({
|
|
37
78
|
sort,
|
|
38
79
|
sortby
|
|
39
80
|
}) : '';
|
|
40
81
|
const baseQuery = sortValues ? `${currentUrl}?${sortValues}` : currentUrl;
|
|
41
82
|
const action = getSearchPublishedContent(RAW_RESULTS);
|
|
42
|
-
let rawQueryStringified = '';
|
|
43
83
|
const checkboxSelectValues = [];
|
|
44
84
|
const rangeValues = [];
|
|
45
85
|
filters.forEach(({
|
|
@@ -55,11 +95,11 @@ const SearchFilterContainer = ({
|
|
|
55
95
|
const {
|
|
56
96
|
docType
|
|
57
97
|
} = getEntityData(entity);
|
|
58
|
-
|
|
98
|
+
const filtersQuery = shouldAddFilters ? buildFiltersQuery(filterValues || query, filterBy, filterByProperty) : [];
|
|
99
|
+
const rawQueryStringified = buildRawQueryStringified(checkboxSelectValues, rangeValues, docType, filtersQuery);
|
|
59
100
|
const {
|
|
60
101
|
data,
|
|
61
|
-
error
|
|
62
|
-
loading
|
|
102
|
+
error
|
|
63
103
|
} = useQuery(action, {
|
|
64
104
|
variables: {
|
|
65
105
|
rawQueryStringified,
|
|
@@ -68,17 +108,24 @@ const SearchFilterContainer = ({
|
|
|
68
108
|
// we only want aggs so limit=0 for no search results
|
|
69
109
|
skip: !rawQueryStringified
|
|
70
110
|
});
|
|
71
|
-
if (loading) return null;
|
|
72
111
|
if (error) return error.message;
|
|
73
112
|
if (!filters.length) return null;
|
|
74
113
|
const {
|
|
75
114
|
searchPublishedContent: {
|
|
76
115
|
rawResults: {
|
|
77
|
-
aggregations: filterData
|
|
116
|
+
aggregations: filterData
|
|
78
117
|
} = {}
|
|
79
118
|
} = {}
|
|
80
119
|
} = data || {};
|
|
81
|
-
|
|
120
|
+
|
|
121
|
+
if (filterValues.dataNotSet && filterData) {
|
|
122
|
+
const initialFilterValues = getInitialFilterValues(filterData, filters, query);
|
|
123
|
+
dispatch({
|
|
124
|
+
newValues: initialFilterValues,
|
|
125
|
+
shouldSearch: false,
|
|
126
|
+
type: 'update'
|
|
127
|
+
});
|
|
128
|
+
}
|
|
82
129
|
|
|
83
130
|
const handleSearch = newQuery => {
|
|
84
131
|
setDisplaySearchFilter(false);
|
|
@@ -115,15 +162,17 @@ const SearchFilterContainer = ({
|
|
|
115
162
|
}
|
|
116
163
|
};
|
|
117
164
|
|
|
165
|
+
if (!filterValues) return '';
|
|
118
166
|
return /*#__PURE__*/React.createElement(SearchFilter, {
|
|
119
167
|
key: key,
|
|
168
|
+
setAppliedFilters: dispatch,
|
|
120
169
|
searchFilterRef: searchFilterRef,
|
|
121
170
|
data: filterData,
|
|
122
171
|
filters: filters,
|
|
123
172
|
hasUrl: hasUrl,
|
|
124
173
|
entity: entity,
|
|
125
174
|
handleSearch: handleSearch,
|
|
126
|
-
|
|
175
|
+
filterValues: filterValues,
|
|
127
176
|
name: name,
|
|
128
177
|
isCollapsedOnResponsive: isCollapsedOnResponsive,
|
|
129
178
|
displaySearchFilter: displaySearchFilter,
|
|
@@ -140,7 +189,10 @@ SearchFilterContainer.propTypes = {
|
|
|
140
189
|
name: PropTypes.string.isRequired,
|
|
141
190
|
isCollapsedOnResponsive: PropTypes.bool,
|
|
142
191
|
groupAfterMobile: PropTypes.number,
|
|
143
|
-
groupAfterDesktop: PropTypes.number
|
|
192
|
+
groupAfterDesktop: PropTypes.number,
|
|
193
|
+
filterBy: PropTypes.array,
|
|
194
|
+
filterByProperty: PropTypes.array,
|
|
195
|
+
shouldAddFilters: PropTypes.bool
|
|
144
196
|
};
|
|
145
197
|
SearchFilterContainer.defaultProps = {
|
|
146
198
|
url: null,
|
|
@@ -148,7 +200,10 @@ SearchFilterContainer.defaultProps = {
|
|
|
148
200
|
entity: '',
|
|
149
201
|
isCollapsedOnResponsive: true,
|
|
150
202
|
groupAfterMobile: 0,
|
|
151
|
-
groupAfterDesktop: 0
|
|
203
|
+
groupAfterDesktop: 0,
|
|
204
|
+
filterBy: [],
|
|
205
|
+
filterByProperty: [],
|
|
206
|
+
shouldAddFilters: false
|
|
152
207
|
};
|
|
153
208
|
export default withTitle(SearchFilterContainer);
|
|
154
209
|
//# sourceMappingURL=SearchFilterContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchFilterContainer.js","names":["React","useState","useRef","useRouter","useQuery","PropTypes","parseUrl","stringify","SearchFilter","withTitle","getSearchPublishedContent","buildNewQuery","buildRawQueryStringified","getInitialFilterValues","getEntityData","RAW_RESULTS","RANGE","CHECKBOX_SELECT","SCROLL_OFFSET","SearchFilterContainer","entity","url","filters","name","isCollapsedOnResponsive","groupAfterMobile","groupAfterDesktop","router","searchFilterRef","key","setKey","displaySearchFilter","setDisplaySearchFilter","hasUrl","currentUrl","query","sort","sortby","asPath","sortValues","baseQuery","action","rawQueryStringified","checkboxSelectValues","rangeValues","forEach","type","propsToDisplay","includes","push","docType","data","error","loading","variables","limit","skip","message","length","searchPublishedContent","rawResults","aggregations","filterData","initialFilterValues","handleSearch","newQuery","scrollToFirstList","shallow","scroll","then","Date","now","newUrl","list","document","getElementsByClassName","shouldScrollToFirstList","window","scrollTo","left","top","pageYOffset","getBoundingClientRect","propTypes","string","array","isRequired","bool","number","defaultProps"],"sources":["../../../src/components/SearchFilter/SearchFilterContainer.js"],"sourcesContent":["import React, { useState, useRef } from 'react';\nimport { useRouter } from 'next/router';\nimport { useQuery } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { parseUrl, stringify } from 'query-string';\nimport SearchFilter from './SearchFilter';\nimport { withTitle } from '../../HOC';\nimport { getSearchPublishedContent } from '../../application/query';\nimport { buildNewQuery, buildRawQueryStringified, getInitialFilterValues } from './helpers';\nimport { getEntityData } from '../../helpers';\nimport { RAW_RESULTS, RANGE, CHECKBOX_SELECT } from './constants';\nimport { SCROLL_OFFSET } from '../../constants';\n\nconst SearchFilterContainer = ({\n entity,\n url,\n filters,\n name,\n isCollapsedOnResponsive,\n groupAfterMobile,\n groupAfterDesktop\n}) => {\n const router = useRouter();\n const searchFilterRef = useRef(null);\n const [key, setKey] = useState(`filter-${name}`);\n const [displaySearchFilter, setDisplaySearchFilter] = useState(false);\n const hasUrl = !!url;\n const {\n url: currentUrl,\n query: { sort, sortby },\n query\n } = parseUrl(router.asPath);\n const sortValues = sort && sortby ? stringify({ sort, sortby }) : '';\n const baseQuery = sortValues ? `${currentUrl}?${sortValues}` : currentUrl;\n\n const action = getSearchPublishedContent(RAW_RESULTS);\n\n let rawQueryStringified = '';\n\n const checkboxSelectValues = [];\n const rangeValues = [];\n\n filters.forEach(({ type, propsToDisplay }) => {\n if (CHECKBOX_SELECT.includes(type)) {\n checkboxSelectValues.push(propsToDisplay[0]);\n } else if (type === RANGE) {\n rangeValues.push(...propsToDisplay);\n }\n });\n\n const { docType } = getEntityData(entity);\n\n rawQueryStringified = buildRawQueryStringified(checkboxSelectValues, rangeValues, docType);\n\n const { data, error, loading } = useQuery(action, {\n variables: { rawQueryStringified, limit: 0 }, // we only want aggs so limit=0 for no search results\n skip: !rawQueryStringified\n });\n\n if (loading) return null;\n if (error) return error.message;\n if (!filters.length) return null;\n\n const { searchPublishedContent: { rawResults: { aggregations: filterData = {} } = {} } = {} } =\n data || {};\n\n const initialFilterValues = getInitialFilterValues(filterData, filters, query);\n\n const handleSearch = newQuery => {\n setDisplaySearchFilter(false);\n\n if (!newQuery) {\n scrollToFirstList();\n return router.push('/Resolver', baseQuery, { shallow: !hasUrl, scroll: false }).then(() => {\n setKey(`filter-${name}:${Date.now()}`); // remove after range component update\n });\n }\n const newUrl = buildNewQuery(url, currentUrl, newQuery, sortValues);\n scrollToFirstList();\n return router.push('/Resolver', newUrl, { shallow: !hasUrl, scroll: false });\n };\n\n const scrollToFirstList = () => {\n const [list] = document.getElementsByClassName('list-top');\n const shouldScrollToFirstList = !hasUrl && list;\n\n if (shouldScrollToFirstList) {\n window.scrollTo({\n left: 0,\n top: window.pageYOffset - SCROLL_OFFSET + list.getBoundingClientRect().top\n });\n } else {\n window.scrollTo(0, 0);\n }\n };\n\n return (\n <SearchFilter\n key={key}\n searchFilterRef={searchFilterRef}\n data={filterData}\n filters={filters}\n hasUrl={hasUrl}\n entity={entity}\n handleSearch={handleSearch}\n initialFilterValues={initialFilterValues}\n name={name}\n isCollapsedOnResponsive={isCollapsedOnResponsive}\n displaySearchFilter={displaySearchFilter}\n setDisplaySearchFilter={setDisplaySearchFilter}\n groupAfterMobile={groupAfterMobile}\n groupAfterDesktop={groupAfterDesktop}\n />\n );\n};\n\nSearchFilterContainer.propTypes = {\n entity: PropTypes.string,\n url: PropTypes.string,\n filters: PropTypes.array,\n name: PropTypes.string.isRequired,\n isCollapsedOnResponsive: PropTypes.bool,\n groupAfterMobile: PropTypes.number,\n groupAfterDesktop: PropTypes.number\n};\n\nSearchFilterContainer.defaultProps = {\n url: null,\n filters: [],\n entity: '',\n isCollapsedOnResponsive: true,\n groupAfterMobile: 0,\n groupAfterDesktop: 0\n};\n\nexport default withTitle(SearchFilterContainer);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,MAA1B,QAAwC,OAAxC;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,QAAT,QAAyB,gBAAzB;AACA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;IAOE,YAAY,EAAE4C,YAPhB;IAQE,mBAAmB,EAAED,mBARvB;IASE,IAAI,EAAExC,IATR;IAUE,uBAAuB,EAAEC,uBAV3B;IAWE,mBAAmB,EAAEO,mBAXvB;IAYE,sBAAsB,EAAEC,sBAZ1B;IAaE,gBAAgB,EAAEP,gBAbpB;IAcE,iBAAiB,EAAEC;EAdrB,EADF;AAkBD,CArGD;;AAuGAP,qBAAqB,CAACgE,SAAtB,GAAkC;EAChC/D,MAAM,EAAEf,SAAS,CAAC+E,MADc;EAEhC/D,GAAG,EAAEhB,SAAS,CAAC+E,MAFiB;EAGhC9D,OAAO,EAAEjB,SAAS,CAACgF,KAHa;EAIhC9D,IAAI,EAAElB,SAAS,CAAC+E,MAAV,CAAiBE,UAJS;EAKhC9D,uBAAuB,EAAEnB,SAAS,CAACkF,IALH;EAMhC9D,gBAAgB,EAAEpB,SAAS,CAACmF,MANI;EAOhC9D,iBAAiB,EAAErB,SAAS,CAACmF;AAPG,CAAlC;AAUArE,qBAAqB,CAACsE,YAAtB,GAAqC;EACnCpE,GAAG,EAAE,IAD8B;EAEnCC,OAAO,EAAE,EAF0B;EAGnCF,MAAM,EAAE,EAH2B;EAInCI,uBAAuB,EAAE,IAJU;EAKnCC,gBAAgB,EAAE,CALiB;EAMnCC,iBAAiB,EAAE;AANgB,CAArC;AASA,eAAejB,SAAS,CAACU,qBAAD,CAAxB"}
|
|
1
|
+
{"version":3,"file":"SearchFilterContainer.js","names":["React","useState","useRef","useReducer","useRouter","useQuery","PropTypes","parseUrl","stringify","SearchFilter","withTitle","getSearchPublishedContent","buildNewQuery","buildRawQueryStringified","getInitialFilterValues","buildFiltersQuery","getEntityData","RAW_RESULTS","RANGE","CHECKBOX_SELECT","SCROLL_OFFSET","reducer","state","action","newValues","type","shouldSearch","Error","SearchFilterContainer","entity","url","filters","name","isCollapsedOnResponsive","groupAfterMobile","groupAfterDesktop","filterBy","filterByProperty","shouldAddFilters","router","asPath","searchFilterRef","key","setKey","displaySearchFilter","setDisplaySearchFilter","currentUrl","query","sort","sortby","filterValues","dispatch","hasUrl","sortValues","baseQuery","checkboxSelectValues","rangeValues","forEach","propsToDisplay","includes","push","docType","filtersQuery","rawQueryStringified","data","error","variables","limit","skip","message","length","searchPublishedContent","rawResults","aggregations","filterData","dataNotSet","initialFilterValues","handleSearch","newQuery","scrollToFirstList","shallow","scroll","then","Date","now","newUrl","list","document","getElementsByClassName","shouldScrollToFirstList","window","scrollTo","left","top","pageYOffset","getBoundingClientRect","propTypes","string","array","isRequired","bool","number","defaultProps"],"sources":["../../../src/components/SearchFilter/SearchFilterContainer.js"],"sourcesContent":["import React, { useState, useRef, useReducer } from 'react';\nimport { useRouter } from 'next/router';\nimport { useQuery } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { parseUrl, stringify } from 'query-string';\nimport SearchFilter from './SearchFilter';\nimport { withTitle } from '../../HOC';\nimport { getSearchPublishedContent } from '../../application/query';\nimport {\n buildNewQuery,\n buildRawQueryStringified,\n getInitialFilterValues,\n buildFiltersQuery\n} from './helpers';\nimport { getEntityData } from '../../helpers';\nimport { RAW_RESULTS, RANGE, CHECKBOX_SELECT } from './constants';\nimport { SCROLL_OFFSET } from '../../constants';\n\nconst reducer = (state, action) => {\n const { newValues, type, shouldSearch = true } = action;\n\n switch (type) {\n case 'update':\n return { ...state, ...newValues, shouldSearch };\n case 'resetSearch':\n return { ...state, shouldSearch: false };\n case 'reset':\n return { ...newValues, shouldSearch };\n default:\n throw new Error();\n }\n};\n\nconst SearchFilterContainer = ({\n entity,\n url,\n filters,\n name,\n isCollapsedOnResponsive,\n groupAfterMobile,\n groupAfterDesktop,\n filterBy,\n filterByProperty,\n shouldAddFilters\n}) => {\n const router = useRouter();\n const { asPath } = router;\n const searchFilterRef = useRef(null);\n const [key, setKey] = useState(`filter-${name}`);\n const [displaySearchFilter, setDisplaySearchFilter] = useState(false);\n const {\n url: currentUrl,\n query: { sort, sortby },\n query\n } = parseUrl(asPath);\n const [filterValues, dispatch] = useReducer(\n reducer,\n getInitialFilterValues(null, filters, query)\n );\n const hasUrl = !!url;\n\n const sortValues = sort && sortby ? stringify({ sort, sortby }) : '';\n const baseQuery = sortValues ? `${currentUrl}?${sortValues}` : currentUrl;\n\n const action = getSearchPublishedContent(RAW_RESULTS);\n const checkboxSelectValues = [];\n const rangeValues = [];\n\n filters.forEach(({ type, propsToDisplay }) => {\n if (CHECKBOX_SELECT.includes(type)) {\n checkboxSelectValues.push(propsToDisplay[0]);\n } else if (type === RANGE) {\n rangeValues.push(...propsToDisplay);\n }\n });\n\n const { docType } = getEntityData(entity);\n\n const filtersQuery = shouldAddFilters\n ? buildFiltersQuery(filterValues || query, filterBy, filterByProperty)\n : [];\n\n const rawQueryStringified = buildRawQueryStringified(\n checkboxSelectValues,\n rangeValues,\n docType,\n filtersQuery\n );\n\n const { data, error } = useQuery(action, {\n variables: { rawQueryStringified, limit: 0 }, // we only want aggs so limit=0 for no search results\n skip: !rawQueryStringified\n });\n\n if (error) return error.message;\n if (!filters.length) return null;\n\n const { searchPublishedContent: { rawResults: { aggregations: filterData } = {} } = {} } =\n data || {};\n\n if (filterValues.dataNotSet && filterData) {\n const initialFilterValues = getInitialFilterValues(filterData, filters, query);\n dispatch({ newValues: initialFilterValues, shouldSearch: false, type: 'update' });\n }\n\n const handleSearch = newQuery => {\n setDisplaySearchFilter(false);\n\n if (!newQuery) {\n scrollToFirstList();\n return router.push('/Resolver', baseQuery, { shallow: !hasUrl, scroll: false }).then(() => {\n setKey(`filter-${name}:${Date.now()}`); // remove after range component update\n });\n }\n const newUrl = buildNewQuery(url, currentUrl, newQuery, sortValues);\n scrollToFirstList();\n return router.push('/Resolver', newUrl, { shallow: !hasUrl, scroll: false });\n };\n\n const scrollToFirstList = () => {\n const [list] = document.getElementsByClassName('list-top');\n const shouldScrollToFirstList = !hasUrl && list;\n\n if (shouldScrollToFirstList) {\n window.scrollTo({\n left: 0,\n top: window.pageYOffset - SCROLL_OFFSET + list.getBoundingClientRect().top\n });\n } else {\n window.scrollTo(0, 0);\n }\n };\n if (!filterValues) return '';\n\n return (\n <SearchFilter\n key={key}\n setAppliedFilters={dispatch}\n searchFilterRef={searchFilterRef}\n data={filterData}\n filters={filters}\n hasUrl={hasUrl}\n entity={entity}\n handleSearch={handleSearch}\n filterValues={filterValues}\n name={name}\n isCollapsedOnResponsive={isCollapsedOnResponsive}\n displaySearchFilter={displaySearchFilter}\n setDisplaySearchFilter={setDisplaySearchFilter}\n groupAfterMobile={groupAfterMobile}\n groupAfterDesktop={groupAfterDesktop}\n />\n );\n};\n\nSearchFilterContainer.propTypes = {\n entity: PropTypes.string,\n url: PropTypes.string,\n filters: PropTypes.array,\n name: PropTypes.string.isRequired,\n isCollapsedOnResponsive: PropTypes.bool,\n groupAfterMobile: PropTypes.number,\n groupAfterDesktop: PropTypes.number,\n filterBy: PropTypes.array,\n filterByProperty: PropTypes.array,\n shouldAddFilters: PropTypes.bool\n};\n\nSearchFilterContainer.defaultProps = {\n url: null,\n filters: [],\n entity: '',\n isCollapsedOnResponsive: true,\n groupAfterMobile: 0,\n groupAfterDesktop: 0,\n filterBy: [],\n filterByProperty: [],\n shouldAddFilters: false\n};\n\nexport default withTitle(SearchFilterContainer);\n"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,MAA1B,EAAkCC,UAAlC,QAAoD,OAApD;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,QAAT,QAAyB,gBAAzB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,cAApC;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,SAASC,SAAT,QAA0B,WAA1B;AACA,SAASC,yBAAT,QAA0C,yBAA1C;AACA,SACEC,aADF,EAEEC,wBAFF,EAGEC,sBAHF,EAIEC,iBAJF,QAKO,WALP;AAMA,SAASC,aAAT,QAA8B,eAA9B;AACA,SAASC,WAAT,EAAsBC,KAAtB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E7B,SAAS,CAAC+F,MAPG;EAQhCjE,QAAQ,EAAE9B,SAAS,CAAC4F,KARY;EAShC7D,gBAAgB,EAAE/B,SAAS,CAAC4F,KATI;EAUhC5D,gBAAgB,EAAEhC,SAAS,CAAC8F;AAVI,CAAlC;AAaAxE,qBAAqB,CAAC0E,YAAtB,GAAqC;EACnCxE,GAAG,EAAE,IAD8B;EAEnCC,OAAO,EAAE,EAF0B;EAGnCF,MAAM,EAAE,EAH2B;EAInCI,uBAAuB,EAAE,IAJU;EAKnCC,gBAAgB,EAAE,CALiB;EAMnCC,iBAAiB,EAAE,CANgB;EAOnCC,QAAQ,EAAE,EAPyB;EAQnCC,gBAAgB,EAAE,EARiB;EASnCC,gBAAgB,EAAE;AATiB,CAArC;AAYA,eAAe5B,SAAS,CAACkB,qBAAD,CAAxB"}
|
|
@@ -13,9 +13,11 @@ const Checkbox = ({
|
|
|
13
13
|
updateFilterValues,
|
|
14
14
|
filterValues,
|
|
15
15
|
label,
|
|
16
|
-
shouldSearch
|
|
16
|
+
shouldSearch,
|
|
17
|
+
displayFilterCount
|
|
17
18
|
}) => {
|
|
18
19
|
const [checkboxLimit, setCheckboxLimit] = useState(null);
|
|
20
|
+
if (!data[prop]) return null;
|
|
19
21
|
|
|
20
22
|
const handleCheckboxOptions = () => {
|
|
21
23
|
if (checkboxLimit[prop] === LIMIT_MIN) {
|
|
@@ -44,14 +46,19 @@ const Checkbox = ({
|
|
|
44
46
|
|
|
45
47
|
const multiple = [];
|
|
46
48
|
const sortedValues = data[prop].buckets.map(({
|
|
47
|
-
key
|
|
48
|
-
|
|
49
|
+
key,
|
|
50
|
+
doc_count: count
|
|
51
|
+
}) => {
|
|
52
|
+
const optionLabel = displayFilterCount ? `${key} (${count})` : key;
|
|
53
|
+
return [key, optionLabel, !count];
|
|
54
|
+
}).filter(Boolean).sort();
|
|
49
55
|
sortedValues.forEach((value, i) => i < checkboxLimit[prop] && multiple.push({
|
|
50
|
-
label: upperFirst(value),
|
|
51
|
-
value,
|
|
56
|
+
label: upperFirst(value[1]),
|
|
57
|
+
value: value[0],
|
|
52
58
|
name: prop,
|
|
53
|
-
checked: checkboxQueryParams.includes(value),
|
|
54
|
-
id: value
|
|
59
|
+
checked: checkboxQueryParams.includes(value[0]),
|
|
60
|
+
id: value[0],
|
|
61
|
+
disabled: value[2]
|
|
55
62
|
}));
|
|
56
63
|
const shouldDisplayMore = !checkboxLimit || checkboxLimit[prop] === LIMIT_MIN;
|
|
57
64
|
return /*#__PURE__*/React.createElement(React.Fragment, null, label ? /*#__PURE__*/React.createElement("p", null, label) : '', /*#__PURE__*/React.createElement(Checkboxes, {
|
|
@@ -86,11 +93,13 @@ Checkbox.propTypes = {
|
|
|
86
93
|
filterValues: PropTypes.object.isRequired,
|
|
87
94
|
updateFilterValues: PropTypes.func.isRequired,
|
|
88
95
|
shouldSearch: PropTypes.bool,
|
|
89
|
-
label: PropTypes.string
|
|
96
|
+
label: PropTypes.string,
|
|
97
|
+
displayFilterCount: PropTypes.bool
|
|
90
98
|
};
|
|
91
99
|
Checkbox.defaultProps = {
|
|
92
100
|
shouldSearch: false,
|
|
93
|
-
label: ''
|
|
101
|
+
label: '',
|
|
102
|
+
displayFilterCount: false
|
|
94
103
|
};
|
|
95
104
|
export default withTitle(Checkbox);
|
|
96
105
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":["React","useState","PropTypes","upperFirst","Checkboxes","FaChevronDown","FaChevronUp","withTitle","decodeValue","LIMIT_MIN","LIMIT_MAX","MORE","LESS","Checkbox","data","prop","updateFilterValues","filterValues","label","shouldSearch","checkboxLimit","setCheckboxLimit","handleCheckboxOptions","checkboxQueryParams","map","val","multiple","sortedValues","buckets","key","filter","Boolean","sort","forEach","value","i","push","name","checked","includes","id","shouldDisplayMore","eData","newCheckboxValues","length","propTypes","object","isRequired","string","func","bool","defaultProps"],"sources":["../../../../src/components/SearchFilter/components/Checkbox.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport upperFirst from 'lodash.upperfirst';\nimport { Checkboxes } from '@blaze-react/checkboxes';\nimport { FaChevronDown, FaChevronUp } from 'react-icons/fa';\nimport { withTitle } from '../../../HOC';\nimport { decodeValue } from '../helpers';\nimport { LIMIT_MIN, LIMIT_MAX, MORE, LESS } from '../constants';\n\nconst Checkbox = ({
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":["React","useState","PropTypes","upperFirst","Checkboxes","FaChevronDown","FaChevronUp","withTitle","decodeValue","LIMIT_MIN","LIMIT_MAX","MORE","LESS","Checkbox","data","prop","updateFilterValues","filterValues","label","shouldSearch","displayFilterCount","checkboxLimit","setCheckboxLimit","handleCheckboxOptions","checkboxQueryParams","map","val","multiple","sortedValues","buckets","key","doc_count","count","optionLabel","filter","Boolean","sort","forEach","value","i","push","name","checked","includes","id","disabled","shouldDisplayMore","eData","newCheckboxValues","length","propTypes","object","isRequired","string","func","bool","defaultProps"],"sources":["../../../../src/components/SearchFilter/components/Checkbox.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport upperFirst from 'lodash.upperfirst';\nimport { Checkboxes } from '@blaze-react/checkboxes';\nimport { FaChevronDown, FaChevronUp } from 'react-icons/fa';\nimport { withTitle } from '../../../HOC';\nimport { decodeValue } from '../helpers';\nimport { LIMIT_MIN, LIMIT_MAX, MORE, LESS } from '../constants';\n\nconst Checkbox = ({\n data,\n prop,\n updateFilterValues,\n filterValues,\n label,\n shouldSearch,\n displayFilterCount\n}) => {\n const [checkboxLimit, setCheckboxLimit] = useState(null);\n if (!data[prop]) return null;\n\n const handleCheckboxOptions = () => {\n if (checkboxLimit[prop] === LIMIT_MIN) {\n setCheckboxLimit({ [prop]: LIMIT_MAX });\n } else {\n setCheckboxLimit({ [prop]: LIMIT_MIN });\n }\n };\n\n if (!checkboxLimit) {\n setCheckboxLimit({ [prop]: LIMIT_MIN });\n }\n\n if (!checkboxLimit) return null;\n\n let checkboxQueryParams = [];\n\n if (filterValues && filterValues[prop]) {\n checkboxQueryParams =\n typeof filterValues[prop] === 'string'\n ? [decodeValue(filterValues[prop])]\n : filterValues[prop].map(val => decodeValue(val));\n }\n const multiple = [];\n\n const sortedValues = data[prop].buckets\n .map(({ key, doc_count: count }) => {\n const optionLabel = displayFilterCount ? `${key} (${count})` : key;\n return [key, optionLabel, !count];\n })\n .filter(Boolean)\n .sort();\n\n sortedValues.forEach(\n (value, i) =>\n i < checkboxLimit[prop] &&\n multiple.push({\n label: upperFirst(value[1]),\n value: value[0],\n name: prop,\n checked: checkboxQueryParams.includes(value[0]),\n id: value[0],\n disabled: value[2]\n })\n );\n\n const shouldDisplayMore = !checkboxLimit || checkboxLimit[prop] === LIMIT_MIN;\n\n return (\n <>\n {label ? <p>{label}</p> : ''}\n <Checkboxes\n className=\"form-checkbox\"\n options={multiple}\n onChange={({ data: eData }) => {\n const newCheckboxValues = eData\n .filter(({ checked }) => checked)\n .map(({ value }) => value);\n updateFilterValues({ [prop]: newCheckboxValues }, shouldSearch);\n }}\n />\n {data[prop].buckets.length > LIMIT_MIN && (\n <div role=\"button\" className=\"see-more\" onClick={handleCheckboxOptions}>\n {shouldDisplayMore ? (\n <>\n <i>\n <FaChevronDown className=\"inline-icon\" />\n </i>\n {` See ${MORE}`}\n </>\n ) : (\n <>\n <i>\n <FaChevronUp className=\"inline-icon\" />\n </i>\n {` See ${LESS}`}\n </>\n )}\n </div>\n )}\n </>\n );\n};\n\nCheckbox.propTypes = {\n data: PropTypes.object.isRequired,\n prop: PropTypes.string.isRequired,\n filterValues: PropTypes.object.isRequired,\n updateFilterValues: PropTypes.func.isRequired,\n shouldSearch: PropTypes.bool,\n label: PropTypes.string,\n displayFilterCount: PropTypes.bool\n};\n\nCheckbox.defaultProps = {\n shouldSearch: false,\n label: '',\n displayFilterCount: false\n};\n\nexport default withTitle(Checkbox);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAh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AxB"}
|
|
@@ -11,11 +11,22 @@ const SelectFilter = ({
|
|
|
11
11
|
updateFilterValues,
|
|
12
12
|
filterValues,
|
|
13
13
|
shouldSearch,
|
|
14
|
-
displayLabelAsPlaceholder
|
|
14
|
+
displayLabelAsPlaceholder,
|
|
15
|
+
displayFilterCount
|
|
15
16
|
}) => {
|
|
16
17
|
const filterValue = filterValues[prop] || '';
|
|
17
|
-
const
|
|
18
|
-
const
|
|
18
|
+
const disabledOptions = [];
|
|
19
|
+
const {
|
|
20
|
+
buckets = []
|
|
21
|
+
} = data[prop] || {};
|
|
22
|
+
const options = buckets.map(({
|
|
23
|
+
key,
|
|
24
|
+
doc_count: count
|
|
25
|
+
}) => {
|
|
26
|
+
if (!count) disabledOptions.push(key);
|
|
27
|
+
const optionLabel = displayFilterCount ? `${key} (${count})` : key;
|
|
28
|
+
return [key, optionLabel];
|
|
29
|
+
}).filter(Boolean).sort();
|
|
19
30
|
const labelText = label || prop;
|
|
20
31
|
let labelToUse = labelText;
|
|
21
32
|
let defaultTextValue = DEFAULT_OPTION;
|
|
@@ -30,7 +41,7 @@ const SelectFilter = ({
|
|
|
30
41
|
value: filterValue,
|
|
31
42
|
id: prop,
|
|
32
43
|
"data-testid": `filter-${prop}`,
|
|
33
|
-
options:
|
|
44
|
+
options: options,
|
|
34
45
|
defaultTextValue: defaultTextValue,
|
|
35
46
|
onChange: ({
|
|
36
47
|
value
|
|
@@ -40,23 +51,27 @@ const SelectFilter = ({
|
|
|
40
51
|
updateFilterValues({
|
|
41
52
|
[prop]: valueToUse
|
|
42
53
|
}, shouldSearch);
|
|
43
|
-
}
|
|
54
|
+
},
|
|
55
|
+
disabled: disabledOptions
|
|
44
56
|
});
|
|
45
57
|
};
|
|
46
58
|
|
|
47
59
|
SelectFilter.propTypes = {
|
|
48
60
|
data: PropTypes.object.isRequired,
|
|
49
61
|
prop: PropTypes.string.isRequired,
|
|
50
|
-
filterValues: PropTypes.object
|
|
62
|
+
filterValues: PropTypes.object,
|
|
51
63
|
updateFilterValues: PropTypes.func.isRequired,
|
|
52
64
|
shouldSearch: PropTypes.bool,
|
|
53
65
|
label: PropTypes.string,
|
|
54
|
-
displayLabelAsPlaceholder: PropTypes.bool
|
|
66
|
+
displayLabelAsPlaceholder: PropTypes.bool,
|
|
67
|
+
displayFilterCount: PropTypes.bool
|
|
55
68
|
};
|
|
56
69
|
SelectFilter.defaultProps = {
|
|
70
|
+
filterValues: {},
|
|
57
71
|
shouldSearch: false,
|
|
58
72
|
label: '',
|
|
59
|
-
displayLabelAsPlaceholder: false
|
|
73
|
+
displayLabelAsPlaceholder: false,
|
|
74
|
+
displayFilterCount: false
|
|
60
75
|
};
|
|
61
76
|
export default withTitle(SelectFilter);
|
|
62
77
|
//# sourceMappingURL=Select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":["React","PropTypes","Select","withTitle","DEFAULT_OPTION","SelectFilter","data","label","prop","updateFilterValues","filterValues","shouldSearch","displayLabelAsPlaceholder","filterValue","
|
|
1
|
+
{"version":3,"file":"Select.js","names":["React","PropTypes","Select","withTitle","DEFAULT_OPTION","SelectFilter","data","label","prop","updateFilterValues","filterValues","shouldSearch","displayLabelAsPlaceholder","displayFilterCount","filterValue","disabledOptions","buckets","options","map","key","doc_count","count","push","optionLabel","filter","Boolean","sort","labelText","labelToUse","defaultTextValue","value","valueToUse","propTypes","object","isRequired","string","func","bool","defaultProps"],"sources":["../../../../src/components/SearchFilter/components/Select.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Select from '@blaze-react/select';\nimport { withTitle } from '../../../HOC';\nimport { DEFAULT_OPTION } from '../constants';\n\nconst SelectFilter = ({\n data,\n label,\n prop,\n updateFilterValues,\n filterValues,\n shouldSearch,\n displayLabelAsPlaceholder,\n displayFilterCount\n}) => {\n const filterValue = filterValues[prop] || '';\n const disabledOptions = [];\n const { buckets = [] } = data[prop] || {};\n const options = buckets\n .map(({ key, doc_count: count }) => {\n if (!count) disabledOptions.push(key);\n const optionLabel = displayFilterCount ? `${key} (${count})` : key;\n return [key, optionLabel];\n })\n .filter(Boolean)\n .sort();\n\n const labelText = label || prop;\n let labelToUse = labelText;\n let defaultTextValue = DEFAULT_OPTION;\n if (displayLabelAsPlaceholder) {\n defaultTextValue = labelToUse;\n labelToUse = null;\n }\n\n return (\n <Select\n label={labelToUse}\n value={filterValue}\n id={prop}\n data-testid={`filter-${prop}`}\n options={options}\n defaultTextValue={defaultTextValue}\n onChange={({ value }) => {\n let valueToUse = value;\n if (value === defaultTextValue) valueToUse = '';\n updateFilterValues({ [prop]: valueToUse }, shouldSearch);\n }}\n disabled={disabledOptions}\n />\n );\n};\n\nSelectFilter.propTypes = {\n data: PropTypes.object.isRequired,\n prop: PropTypes.string.isRequired,\n filterValues: PropTypes.object,\n updateFilterValues: PropTypes.func.isRequired,\n shouldSearch: PropTypes.bool,\n label: PropTypes.string,\n displayLabelAsPlaceholder: PropTypes.bool,\n displayFilterCount: PropTypes.bool\n};\n\nSelectFilter.defaultProps = {\n filterValues: {},\n shouldSearch: false,\n label: '',\n displayLabelAsPlaceholder: false,\n displayFilterCount: false\n};\n\nexport default withTitle(SelectFilter);\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,cAAT,QAA+B,cAA/B;;AAEA,MAAMC,YAAY,GAAG,CAAC;EACpBC,IADoB;EAEpBC,KAFoB;EAGpBC,IAHoB;EAIpBC,kBAJoB;EAKpBC,YALoB;EAMpBC,YANoB;EAOpBC,yBAPoB;EAQpBC;AARoB,CAAD,KASf;EACJ,MAAMC,WAAW,GAAGJ,YAAY,CAACF,IAAD,CAAZ,IAAsB,EAA1C;EACA,MAAMO,eAAe,GAAG,EAAxB;EACA,MAAM;IAAEC,OAAO,GAAG;EAAZ,IAAmBV,IAA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EAAET,SAAS,CAACgC,MAHD;EAIvBxB,kBAAkB,EAAER,SAAS,CAACmC,IAAV,CAAeF,UAJZ;EAKvBvB,YAAY,EAAEV,SAAS,CAACoC,IALD;EAMvB9B,KAAK,EAAEN,SAAS,CAACkC,MANM;EAOvBvB,yBAAyB,EAAEX,SAAS,CAACoC,IAPd;EAQvBxB,kBAAkB,EAAEZ,SAAS,CAACoC;AARP,CAAzB;AAWAhC,YAAY,CAACiC,YAAb,GAA4B;EAC1B5B,YAAY,EAAE,EADY;EAE1BC,YAAY,EAAE,KAFY;EAG1BJ,KAAK,EAAE,EAHmB;EAI1BK,yBAAyB,EAAE,KAJD;EAK1BC,kBAAkB,EAAE;AALM,CAA5B;AAQA,eAAeV,SAAS,CAACE,YAAD,CAAxB"}
|
|
@@ -8,9 +8,7 @@ import { SEARCH_TERM } from '../constants';
|
|
|
8
8
|
const TextSearch = ({
|
|
9
9
|
label,
|
|
10
10
|
searchValue,
|
|
11
|
-
updateFilterValues
|
|
12
|
-
handleSubmit,
|
|
13
|
-
filterValues
|
|
11
|
+
updateFilterValues
|
|
14
12
|
}) => /*#__PURE__*/React.createElement("div", {
|
|
15
13
|
className: "search"
|
|
16
14
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -40,10 +38,8 @@ const TextSearch = ({
|
|
|
40
38
|
}, /*#__PURE__*/React.createElement("i", null, /*#__PURE__*/React.createElement(MdSearch, null)))));
|
|
41
39
|
|
|
42
40
|
TextSearch.propTypes = {
|
|
43
|
-
filterValues: PropTypes.object.isRequired,
|
|
44
41
|
searchValue: PropTypes.string.isRequired,
|
|
45
42
|
updateFilterValues: PropTypes.func.isRequired,
|
|
46
|
-
handleSubmit: PropTypes.func.isRequired,
|
|
47
43
|
label: PropTypes.string
|
|
48
44
|
};
|
|
49
45
|
TextSearch.defaultProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextSearch.js","names":["React","PropTypes","Input","MdSearch","withTitle","SEARCH_TERM","TextSearch","label","searchValue","updateFilterValues","
|
|
1
|
+
{"version":3,"file":"TextSearch.js","names":["React","PropTypes","Input","MdSearch","withTitle","SEARCH_TERM","TextSearch","label","searchValue","updateFilterValues","value","eValue","e","preventDefault","propTypes","string","isRequired","func","defaultProps"],"sources":["../../../../src/components/SearchFilter/components/TextSearch.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Input from '@blaze-react/input';\nimport { MdSearch } from 'react-icons/md';\nimport { withTitle } from '../../../HOC';\nimport { SEARCH_TERM } from '../constants';\n\nconst TextSearch = ({ label, searchValue, updateFilterValues }) => (\n <div className=\"search\">\n <div className=\"search__wrapper\">\n <div className=\"form-field form-field--input form-field--search\">\n <Input\n id={SEARCH_TERM}\n value={searchValue}\n placeholder={label || 'Search'}\n onChange={({ value: eValue }) => {\n updateFilterValues({ [SEARCH_TERM]: eValue }, false);\n }}\n />\n </div>\n <button\n type=\"button\"\n className=\"icon-button icon-button--search\"\n onClick={e => {\n e.preventDefault();\n updateFilterValues({ [SEARCH_TERM]: searchValue }, true);\n }}>\n <i>\n <MdSearch />\n </i>\n </button>\n </div>\n </div>\n);\n\nTextSearch.propTypes = {\n searchValue: PropTypes.string.isRequired,\n updateFilterValues: PropTypes.func.isRequired,\n label: PropTypes.string\n};\n\nTextSearch.defaultProps = {\n label: ''\n};\n\nexport default withTitle(TextSearch);\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,KAAP,MAAkB,oBAAlB;AACA,SAASC,QAAT,QAAyB,gBAAzB;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,WAAT,QAA4B,cAA5B;;AAEA,MAAMC,UAAU,GAAG,CAAC;EAAEC,KAAF;EAASC,WAAT;EAAsBC;AAAtB,CAAD,kBACjB;EAAK,SAAS,EAAC;AAAf,gBACE;EAAK,SAAS,EAAC;AAAf,gBACE;EAAK,SAAS,EAAC;AAAf,gBACE,oBAAC,KAAD;EACE,EAAE,EAAEJ,WADN;EAEE,KAAK,EAAEG,WAFT;EAGE,WAAW,EAAED,KAAK,IAAI,QAHxB;EAIE,QAAQ,EAAE,CAAC;IAAEG,KAAK,EAAEC;EAAT,CAAD,KAAuB;IAC/BF,kBAAkB,CAAC;MAAE,CAACJ,WAAD,GAAeM;IAAjB,CAAD,EAA4B,KAA5B,CAAlB;EACD;AANH,EADF,CADF,eAWE;EACE,IAAI,EAAC,QADP;EAEE,SAAS,EAAC,iCAFZ;EAGE,OAAO,EAAEC,CAAC,IAAI;IACZA,CAAC,CAACC,cAAF;IACAJ,kBAAkB,CAAC;MAAE,CAACJ,WAAD,GAAeG;IAAjB,CAAD,EAAiC,IAAjC,CAAlB;EACD;AANH,gBAOE,4CACE,oBAAC,QAAD,OADF,CAPF,CAXF,CADF,CADF;;AA4BAF,UAAU,CAACQ,SAAX,GAAuB;EACrBN,WAAW,EAAEP,SAAS,CAACc,MAAV,CAAiBC,UADT;EAErBP,kBAAkB,EAAER,SAAS,CAACgB,IAAV,CAAeD,UAFd;EAGrBT,KAAK,EAAEN,SAAS,CAACc;AAHI,CAAvB;AAMAT,UAAU,CAACY,YAAX,GAA0B;EACxBX,KAAK,EAAE;AADiB,CAA1B;AAIA,eAAeH,SAAS,CAACE,UAAD,CAAxB"}
|
|
@@ -2,7 +2,7 @@ const CHECKBOX = 'checkbox';
|
|
|
2
2
|
const SELECT = 'select';
|
|
3
3
|
const TEXT_SEARCH = 'text-search';
|
|
4
4
|
const SEARCH_TERM = 'search_term';
|
|
5
|
-
const SIZE =
|
|
5
|
+
const SIZE = process.env.BLAZE_PB_SEARCH_FILETER_AGG_SIZE || 500;
|
|
6
6
|
const KEYWORD = 'keyword';
|
|
7
7
|
const RAW_RESULTS = 'rawResults';
|
|
8
8
|
const DEFAULT_OPTION = 'Any';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["CHECKBOX","SELECT","TEXT_SEARCH","SEARCH_TERM","SIZE","KEYWORD","RAW_RESULTS","DEFAULT_OPTION","DEFAULT_VALUES","RANGE","CHECKBOX_SELECT","LIMIT_MIN","LIMIT_MAX","MORE","LESS","UPDATED_RANGES","MIN_VALUE","MAX_VALUE","TABLET_WIDTH","RESET","SEARCH","REFINE","MOBILE_REFINEMENT_TITLE","MORE_FILTERS_CLASSES_BASE","MORE_FILTERS_CLASSES","MOBILE_WRAPPER","MOBILE_CONTENT","MOBILE_TOGGLER","MOBILE_BUTTONS","DESKTOP_WRAPPER","DESKTOP_CONTENT","DESKTOP_TOGGLER","DESKTOP_BUTTONS"],"sources":["../../../src/components/SearchFilter/constants.js"],"sourcesContent":["const CHECKBOX = 'checkbox';\nconst SELECT = 'select';\nconst TEXT_SEARCH = 'text-search';\nconst SEARCH_TERM = 'search_term';\nconst SIZE =
|
|
1
|
+
{"version":3,"file":"constants.js","names":["CHECKBOX","SELECT","TEXT_SEARCH","SEARCH_TERM","SIZE","process","env","BLAZE_PB_SEARCH_FILETER_AGG_SIZE","KEYWORD","RAW_RESULTS","DEFAULT_OPTION","DEFAULT_VALUES","RANGE","CHECKBOX_SELECT","LIMIT_MIN","LIMIT_MAX","MORE","LESS","UPDATED_RANGES","MIN_VALUE","MAX_VALUE","TABLET_WIDTH","RESET","SEARCH","REFINE","MOBILE_REFINEMENT_TITLE","MORE_FILTERS_CLASSES_BASE","MORE_FILTERS_CLASSES","MOBILE_WRAPPER","MOBILE_CONTENT","MOBILE_TOGGLER","MOBILE_BUTTONS","DESKTOP_WRAPPER","DESKTOP_CONTENT","DESKTOP_TOGGLER","DESKTOP_BUTTONS"],"sources":["../../../src/components/SearchFilter/constants.js"],"sourcesContent":["const CHECKBOX = 'checkbox';\nconst SELECT = 'select';\nconst TEXT_SEARCH = 'text-search';\nconst SEARCH_TERM = 'search_term';\nconst SIZE = process.env.BLAZE_PB_SEARCH_FILETER_AGG_SIZE || 500;\nconst KEYWORD = 'keyword';\nconst RAW_RESULTS = 'rawResults';\nconst DEFAULT_OPTION = 'Any';\nconst DEFAULT_VALUES = ['Any', 'Please Choose...'];\nconst RANGE = 'range';\nconst CHECKBOX_SELECT = ['checkbox', 'select'];\nconst LIMIT_MIN = 5;\nconst LIMIT_MAX = 1000;\nconst MORE = 'more';\nconst LESS = 'less';\nconst UPDATED_RANGES = 'updated_ranges';\nconst MIN_VALUE = 'min-value';\nconst MAX_VALUE = 'max-value';\nconst TABLET_WIDTH = 768;\nconst RESET = 'Reset all filters';\nconst SEARCH = 'Search';\nconst REFINE = `Refine Search`;\nconst MOBILE_REFINEMENT_TITLE = 'Search refinement';\n\nconst MORE_FILTERS_CLASSES_BASE = 'filter__more-filters';\nconst MORE_FILTERS_CLASSES = {\n MOBILE_WRAPPER: `${MORE_FILTERS_CLASSES_BASE}-mobile-wrapper`,\n MOBILE_CONTENT: `${MORE_FILTERS_CLASSES_BASE}-mobile-content`,\n MOBILE_TOGGLER: `${MORE_FILTERS_CLASSES_BASE}-mobile-toggler`,\n MOBILE_BUTTONS: `${MORE_FILTERS_CLASSES_BASE}-mobile-buttons`,\n DESKTOP_WRAPPER: `${MORE_FILTERS_CLASSES_BASE}-desktop-wrapper`,\n DESKTOP_CONTENT: `${MORE_FILTERS_CLASSES_BASE}-desktop-content`,\n DESKTOP_TOGGLER: `${MORE_FILTERS_CLASSES_BASE}-desktop-toggler`,\n DESKTOP_BUTTONS: `${MORE_FILTERS_CLASSES_BASE}-desktop-buttons`\n};\n\nexport {\n CHECKBOX,\n SELECT,\n TEXT_SEARCH,\n SEARCH_TERM,\n SIZE,\n KEYWORD,\n RAW_RESULTS,\n DEFAULT_OPTION,\n DEFAULT_VALUES,\n RANGE,\n CHECKBOX_SELECT,\n LIMIT_MIN,\n LIMIT_MAX,\n MORE,\n LESS,\n UPDATED_RANGES,\n MIN_VALUE,\n MAX_VALUE,\n TABLET_WIDTH,\n RESET,\n SEARCH,\n REFINE,\n MOBILE_REFINEMENT_TITLE,\n MORE_FILTERS_CLASSES\n};\n"],"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7B;AAWA,SACE1B,QADF,EAEEC,MAFF,EAGEC,WAHF,EAIEC,WAJF,EAKEC,IALF,EAMEI,OANF,EAOEC,WAPF,EAQEC,cARF,EASEC,cATF,EAUEC,KAVF,EAWEC,eAXF,EAYEC,SAZF,EAaEC,SAbF,EAcEC,IAdF,EAeEC,IAfF,EAgBEC,cAhBF,EAiBEC,SAjBF,EAkBEC,SAlBF,EAmBEC,YAnBF,EAoBEC,KApBF,EAqBEC,MArBF,EAsBEC,MAtBF,EAuBEC,uBAvBF,EAwBEE,oBAxBF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const builFilterObject = (key, value, filters) => {
|
|
2
|
+
const isArray = Array.isArray(value);
|
|
3
|
+
|
|
4
|
+
if (!isArray) {
|
|
5
|
+
const singleFilterObj = {
|
|
6
|
+
match: {
|
|
7
|
+
[key]: value
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
filters.push(singleFilterObj);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
value.forEach(filterValue => {
|
|
15
|
+
filters.push({
|
|
16
|
+
match: {
|
|
17
|
+
[key]: filterValue
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const buildFiltersQuery = (query, filterBy, filterByProperty) => {
|
|
24
|
+
const mustFilters = [];
|
|
25
|
+
Object.keys(query).forEach(queryKey => {
|
|
26
|
+
if (queryKey === 'search_term' || queryKey === 'shouldSearch') return;
|
|
27
|
+
if (!queryKey || !query[queryKey]) return;
|
|
28
|
+
const queryValue = query[queryKey];
|
|
29
|
+
const queryKeyword = `${queryKey}.keyword`;
|
|
30
|
+
builFilterObject(queryKeyword, queryValue, mustFilters);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (filterByProperty && filterByProperty.length) {
|
|
34
|
+
filterByProperty && filterByProperty.forEach(filterByPropOption => {
|
|
35
|
+
const [filterByPropKey] = filterByPropOption.split('/');
|
|
36
|
+
filterBy.forEach(filterByOption => {
|
|
37
|
+
if (filterByOption.indexOf(filterByPropKey) === -1) return;
|
|
38
|
+
const [, filteryByValue] = filterByOption.split('/');
|
|
39
|
+
const filterByKeyword = `${filterByPropKey}.keyword`;
|
|
40
|
+
if (!filteryByValue) return;
|
|
41
|
+
mustFilters.push({
|
|
42
|
+
match: {
|
|
43
|
+
[filterByKeyword]: filteryByValue
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return mustFilters;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default buildFiltersQuery;
|
|
54
|
+
//# sourceMappingURL=build-filters-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-filters-query.js","names":["builFilterObject","key","value","filters","isArray","Array","singleFilterObj","match","push","forEach","filterValue","buildFiltersQuery","query","filterBy","filterByProperty","mustFilters","Object","keys","queryKey","queryValue","queryKeyword","length","filterByPropOption","filterByPropKey","split","filterByOption","indexOf","filteryByValue","filterByKeyword"],"sources":["../../../../src/components/SearchFilter/helpers/build-filters-query.js"],"sourcesContent":["const builFilterObject = (key, value, filters) => {\n const isArray = Array.isArray(value);\n if (!isArray) {\n const singleFilterObj = { match: { [key]: value } };\n filters.push(singleFilterObj);\n return;\n }\n\n value.forEach(filterValue => {\n filters.push({ match: { [key]: filterValue } });\n });\n};\nconst buildFiltersQuery = (query, filterBy, filterByProperty) => {\n const mustFilters = [];\n Object.keys(query).forEach(queryKey => {\n if (queryKey === 'search_term' || queryKey === 'shouldSearch') return;\n if (!queryKey || !query[queryKey]) return;\n const queryValue = query[queryKey];\n const queryKeyword = `${queryKey}.keyword`;\n builFilterObject(queryKeyword, queryValue, mustFilters);\n });\n\n if (filterByProperty && filterByProperty.length) {\n filterByProperty &&\n filterByProperty.forEach(filterByPropOption => {\n const [filterByPropKey] = filterByPropOption.split('/');\n filterBy.forEach(filterByOption => {\n if (filterByOption.indexOf(filterByPropKey) === -1) return;\n const [, filteryByValue] = filterByOption.split('/');\n const filterByKeyword = `${filterByPropKey}.keyword`;\n if (!filteryByValue) return;\n mustFilters.push({ match: { [filterByKeyword]: filteryByValue } });\n });\n });\n }\n\n return mustFilters;\n};\n\nexport default buildFiltersQuery;\n"],"mappings":"AAAA,MAAMA,gBAAgB,GAAG,CAACC,GAAD,EAAMC,KAAN,EAAaC,OAAb,KAAyB;EAChD,MAAMC,OAAO,GAAGC,KAAK,CAACD,OAAN,CAAcF,KAAd,CAAhB;;EACA,IAAI,CAACE,OAAL,EAAc;IACZ,MAAME,eAAe,GAAG;MAAEC,KAAK,EAAE;QAAE,CAACN,GAAD,GAAOC;MAAT;IAAT,CAAxB;IACAC,OAAO,CAACK,IAAR,CAAaF,eAAb;IACA;EACD;;EAEDJ,KAAK,CAACO,OAAN,CAAcC,WAAW,IAAI;IAC3BP,OAAO,CAACK,IAAR,CAAa;MAAED,KAAK,EAAE;QAAE,CAACN,GAAD,GAAOS;MAAT;IAAT,CAAb;EACD,CAFD;AAGD,CAXD;;AAYA,MAAMC,iBAAiB,GAAG,CAACC,KAAD,EAAQC,QAAR,EAAkBC,gBAAlB,KAAuC;EAC/D,MAAMC,WAAW,GAAG,EAApB;EACAC,MAAM,CAACC,IAAP,CAAYL,KAAZ,EAAmBH,OAAnB,CAA2BS,QAAQ,IAAI;IACrC,IAAIA,QAAQ,KAAK,aAAb,IAA8BA,QAAQ,KAAK,cAA/C,EAA+D;IAC/D,IAAI,CAACA,QAAD,IAAa,CAACN,KAAK,CAACM,QAAD,CAAvB,EAAmC;IACnC,MAAMC,UAAU,GAAGP,KAAK,CAACM,QAAD,CAAxB;IACA,MAAME,YAAY,GAAI,GAAEF,QAAS,UAAjC;IACAlB,gBAAgB,CAACoB,YAAD,EAAeD,UAAf,EAA2BJ,WAA3B,CAAhB;EACD,CAND;;EAQA,IAAID,gBAAgB,IAAIA,gBAAgB,CAACO,MAAzC,EAAiD;IAC/CP,gBAAgB,IACdA,gBAAgB,CAACL,OAAjB,CAAyBa,kBAAkB,IAAI;MAC7C,MAAM,CAACC,eAAD,IAAoBD,kBAAkB,CAACE,KAAnB,CAAyB,GAAzB,CAA1B;MACAX,QAAQ,CAACJ,OAAT,CAAiBgB,cAAc,IAAI;QACjC,IAAIA,cAAc,CAACC,OAAf,CAAuBH,eAAvB,MAA4C,CAAC,CAAjD,EAAoD;QACpD,MAAM,GAAGI,cAAH,IAAqBF,cAAc,CAACD,KAAf,CAAqB,GAArB,CAA3B;QACA,MAAMI,eAAe,GAAI,GAAEL,eAAgB,UAA3C;QACA,IAAI,CAACI,cAAL,EAAqB;QACrBZ,WAAW,CAACP,IAAZ,CAAiB;UAAED,KAAK,EAAE;YAAE,CAACqB,eAAD,GAAmBD;UAArB;QAAT,CAAjB;MACD,CAND;IAOD,CATD,CADF;EAWD;;EAED,OAAOZ,WAAP;AACD,CAzBD;;AA2BA,eAAeJ,iBAAf"}
|
|
@@ -3,7 +3,7 @@ import parseFilterValue from './parse-filter-value';
|
|
|
3
3
|
|
|
4
4
|
const buildQuery = (filterValues, filters) => {
|
|
5
5
|
const newQuery = [];
|
|
6
|
-
const searchValue = filterValues[SEARCH_TERM];
|
|
6
|
+
const searchValue = filterValues[SEARCH_TERM] ? encodeURIComponent(filterValues[SEARCH_TERM]) : '';
|
|
7
7
|
if (searchValue) newQuery.push(`${SEARCH_TERM}=${searchValue}`);
|
|
8
8
|
filters.forEach(({
|
|
9
9
|
propsToDisplay,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-query.js","names":["SEARCH_TERM","TEXT_SEARCH","parseFilterValue","buildQuery","filterValues","filters","newQuery","searchValue","push","forEach","propsToDisplay","type","prop","value","parsedValue","includes","join"],"sources":["../../../../src/components/SearchFilter/helpers/build-query.js"],"sourcesContent":["import { SEARCH_TERM, TEXT_SEARCH } from '../constants';\nimport parseFilterValue from './parse-filter-value';\n\nconst buildQuery = (filterValues, filters) => {\n const newQuery = [];\n const searchValue = filterValues[SEARCH_TERM];\n if (searchValue) newQuery.push(`${SEARCH_TERM}=${searchValue}`);\n\n filters.forEach(({ propsToDisplay, type }) => {\n if (type === TEXT_SEARCH) return;\n\n propsToDisplay.forEach(prop => {\n const value = filterValues[prop];\n const parsedValue = parseFilterValue(prop, type, value);\n if (parsedValue && !newQuery.includes(parsedValue)) {\n newQuery.push(parsedValue);\n }\n });\n });\n\n return newQuery.join('&');\n};\n\nexport default buildQuery;\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,WAAtB,QAAyC,cAAzC;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;;AAEA,MAAMC,UAAU,GAAG,CAACC,YAAD,EAAeC,OAAf,KAA2B;EAC5C,MAAMC,QAAQ,GAAG,EAAjB;EACA,MAAMC,WAAW,GAAGH,YAAY,CAACJ,WAAD,
|
|
1
|
+
{"version":3,"file":"build-query.js","names":["SEARCH_TERM","TEXT_SEARCH","parseFilterValue","buildQuery","filterValues","filters","newQuery","searchValue","encodeURIComponent","push","forEach","propsToDisplay","type","prop","value","parsedValue","includes","join"],"sources":["../../../../src/components/SearchFilter/helpers/build-query.js"],"sourcesContent":["import { SEARCH_TERM, TEXT_SEARCH } from '../constants';\nimport parseFilterValue from './parse-filter-value';\n\nconst buildQuery = (filterValues, filters) => {\n const newQuery = [];\n const searchValue = filterValues[SEARCH_TERM]\n ? encodeURIComponent(filterValues[SEARCH_TERM])\n : '';\n if (searchValue) newQuery.push(`${SEARCH_TERM}=${searchValue}`);\n\n filters.forEach(({ propsToDisplay, type }) => {\n if (type === TEXT_SEARCH) return;\n\n propsToDisplay.forEach(prop => {\n const value = filterValues[prop];\n const parsedValue = parseFilterValue(prop, type, value);\n if (parsedValue && !newQuery.includes(parsedValue)) {\n newQuery.push(parsedValue);\n }\n });\n });\n\n return newQuery.join('&');\n};\n\nexport default buildQuery;\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,WAAtB,QAAyC,cAAzC;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;;AAEA,MAAMC,UAAU,GAAG,CAACC,YAAD,EAAeC,OAAf,KAA2B;EAC5C,MAAMC,QAAQ,GAAG,EAAjB;EACA,MAAMC,WAAW,GAAGH,YAAY,CAACJ,WAAD,CAAZ,GAChBQ,kBAAkB,CAACJ,YAAY,CAACJ,WAAD,CAAb,CADF,GAEhB,EAFJ;EAGA,IAAIO,WAAJ,EAAiBD,QAAQ,CAACG,IAAT,CAAe,GAAET,WAAY,IAAGO,WAAY,EAA5C;EAEjBF,OAAO,CAACK,OAAR,CAAgB,CAAC;IAAEC,cAAF;IAAkBC;EAAlB,CAAD,KAA8B;IAC5C,IAAIA,IAAI,KAAKX,WAAb,EAA0B;IAE1BU,cAAc,CAACD,OAAf,CAAuBG,IAAI,IAAI;MAC7B,MAAMC,KAAK,GAAGV,YAAY,CAACS,IAAD,CAA1B;MACA,MAAME,WAAW,GAAGb,gBAAgB,CAACW,IAAD,EAAOD,IAAP,EAAaE,KAAb,CAApC;;MACA,IAAIC,WAAW,IAAI,CAACT,QAAQ,CAACU,QAAT,CAAkBD,WAAlB,CAApB,EAAoD;QAClDT,QAAQ,CAACG,IAAT,CAAcM,WAAd;MACD;IACF,CAND;EAOD,CAVD;EAYA,OAAOT,QAAQ,CAACW,IAAT,CAAc,GAAd,CAAP;AACD,CApBD;;AAsBA,eAAed,UAAf"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KEYWORD, SIZE } from '../constants';
|
|
2
2
|
|
|
3
|
-
const buildRawQueryStringified = (checkboxSelectValues, rangeValues, entity) => {
|
|
3
|
+
const buildRawQueryStringified = (checkboxSelectValues, rangeValues, entity, mustFilters) => {
|
|
4
4
|
if (!checkboxSelectValues.length && !rangeValues.length) return '';
|
|
5
5
|
const aggs = {};
|
|
6
6
|
checkboxSelectValues.forEach(fieldName => {
|
|
@@ -30,6 +30,7 @@ const buildRawQueryStringified = (checkboxSelectValues, rangeValues, entity) =>
|
|
|
30
30
|
docType: entity
|
|
31
31
|
}
|
|
32
32
|
}],
|
|
33
|
+
must: mustFilters,
|
|
33
34
|
minimum_should_match: 1
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-raw-query-stringified.js","names":["KEYWORD","SIZE","buildRawQueryStringified","checkboxSelectValues","rangeValues","entity","length","aggs","forEach","fieldName","terms","field","size","stats","JSON","stringify","query","bool","filter","should","match","docType","minimum_should_match"],"sources":["../../../../src/components/SearchFilter/helpers/build-raw-query-stringified.js"],"sourcesContent":["import { KEYWORD, SIZE } from '../constants';\n\nconst buildRawQueryStringified = (checkboxSelectValues, rangeValues, entity) => {\n if (!checkboxSelectValues.length && !rangeValues.length) return '';\n\n const aggs = {};\n\n checkboxSelectValues.forEach(fieldName => {\n aggs[fieldName] = {\n terms: {\n field: `${fieldName}.${KEYWORD}`,\n size: SIZE\n }\n };\n });\n\n rangeValues.forEach(fieldName => {\n aggs[fieldName] = {\n stats: {\n field: fieldName\n }\n };\n });\n\n return JSON.stringify({\n aggs,\n size: 0,\n query: {\n bool: {\n filter: {\n bool: {\n should: [\n {\n match: {\n docType: entity\n }\n }\n ],\n minimum_should_match: 1\n }\n }\n }\n }\n });\n};\n\nexport default buildRawQueryStringified;\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,IAAlB,QAA8B,cAA9B;;AAEA,MAAMC,wBAAwB,GAAG,CAACC,oBAAD,EAAuBC,WAAvB,EAAoCC,MAApC,
|
|
1
|
+
{"version":3,"file":"build-raw-query-stringified.js","names":["KEYWORD","SIZE","buildRawQueryStringified","checkboxSelectValues","rangeValues","entity","mustFilters","length","aggs","forEach","fieldName","terms","field","size","stats","JSON","stringify","query","bool","filter","should","match","docType","must","minimum_should_match"],"sources":["../../../../src/components/SearchFilter/helpers/build-raw-query-stringified.js"],"sourcesContent":["import { KEYWORD, SIZE } from '../constants';\n\nconst buildRawQueryStringified = (checkboxSelectValues, rangeValues, entity, mustFilters) => {\n if (!checkboxSelectValues.length && !rangeValues.length) return '';\n\n const aggs = {};\n\n checkboxSelectValues.forEach(fieldName => {\n aggs[fieldName] = {\n terms: {\n field: `${fieldName}.${KEYWORD}`,\n size: SIZE\n }\n };\n });\n\n rangeValues.forEach(fieldName => {\n aggs[fieldName] = {\n stats: {\n field: fieldName\n }\n };\n });\n\n return JSON.stringify({\n aggs,\n size: 0,\n query: {\n bool: {\n filter: {\n bool: {\n should: [\n {\n match: {\n docType: entity\n }\n }\n ],\n must: mustFilters,\n minimum_should_match: 1\n }\n }\n }\n }\n });\n};\n\nexport default buildRawQueryStringified;\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,IAAlB,QAA8B,cAA9B;;AAEA,MAAMC,wBAAwB,GAAG,CAACC,oBAAD,EAAuBC,WAAvB,EAAoCC,MAApC,EAA4CC,WAA5C,KAA4D;EAC3F,IAAI,CAACH,oBAAoB,CAACI,MAAtB,IAAgC,CAACH,WAAW,CAACG,MAAjD,EAAyD,OAAO,EAAP;EAEzD,MAAMC,IAAI,GAAG,EAAb;EAEAL,oBAAoB,CAACM,OAArB,CAA6BC,SAAS,IAAI;IACxCF,IAAI,CAACE,SAAD,CAAJ,GAAkB;MAChBC,KAAK,EAAE;QACLC,KAAK,EAAG,GAAEF,SAAU,IAAGV,OAAQ,EAD1B;QAELa,IAAI,EAAEZ;MAFD;IADS,CAAlB;EAMD,CAPD;EASAG,WAAW,CAACK,OAAZ,CAAoBC,SAAS,IAAI;IAC/BF,IAAI,CAACE,SAAD,CAAJ,GAAkB;MAChBI,KAAK,EAAE;QACLF,KAAK,EAAEF;MADF;IADS,CAAlB;EAKD,CAND;EAQA,OAAOK,IAAI,CAACC,SAAL,CAAe;IACpBR,IADoB;IAEpBK,IAAI,EAAE,CAFc;IAGpBI,KAAK,EAAE;MACLC,IAAI,EAAE;QACJC,MAAM,EAAE;UACND,IAAI,EAAE;YACJE,MAAM,EAAE,CACN;cACEC,KAAK,EAAE;gBACLC,OAAO,EAAEjB;cADJ;YADT,CADM,CADJ;YAQJkB,IAAI,EAAEjB,WARF;YASJkB,oBAAoB,EAAE;UATlB;QADA;MADJ;IADD;EAHa,CAAf,CAAP;AAqBD,CA3CD;;AA6CA,eAAetB,wBAAf"}
|