@biggive/components 202311201334.0.0 → 202311211120.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/hydrate/index.js CHANGED
@@ -6821,60 +6821,6 @@ class BiggiveCampaignCardFilterGrid {
6821
6821
  button.remove();
6822
6822
  });
6823
6823
  }
6824
- let filters = {
6825
- beneficiaries: searchAndFilterObj.filterBeneficiary,
6826
- categories: searchAndFilterObj.filterCategory,
6827
- funding: searchAndFilterObj.filterFunding,
6828
- locations: searchAndFilterObj.filterLocation,
6829
- };
6830
- const keys = Object.keys(filters);
6831
- for (const filterKey of keys) {
6832
- // https://stackoverflow.com/a/69757191/2803757
6833
- const filterValue = filters[filterKey];
6834
- if (filterValue === null || filterValue.length === 0) {
6835
- continue;
6836
- }
6837
- let button = document.createElement('span');
6838
- button.classList.add('button');
6839
- button.dataset.id = filterKey;
6840
- button.innerText = filterValue;
6841
- if (selectedFilters) {
6842
- selectedFilters.appendChild(button);
6843
- }
6844
- button.addEventListener('click', () => {
6845
- var _a;
6846
- switch (filterKey) {
6847
- case 'beneficiaries':
6848
- this.selectedFilterBeneficiary = null;
6849
- break;
6850
- case 'categories':
6851
- this.selectedFilterCategory = null;
6852
- break;
6853
- case 'funding':
6854
- this.selectedFilterFunding = null;
6855
- break;
6856
- case 'locations':
6857
- this.selectedFilterLocation = null;
6858
- break;
6859
- default:
6860
- // This asks the compiler to check that we are in dead code, i.e. we covered all the possible filter keys
6861
- // above. If we missed one we would get a compile error trying to assign a string to a never.
6862
- const exhaustiveSwitch = filterKey;
6863
- console.error(exhaustiveSwitch);
6864
- }
6865
- button.remove();
6866
- this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
6867
- if (button.dataset.id === undefined) {
6868
- return;
6869
- }
6870
- const selectEl = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById(button.dataset.id);
6871
- if (!selectEl) {
6872
- return;
6873
- }
6874
- selectEl.selectedLabel = null;
6875
- selectEl.selectedValue = null;
6876
- });
6877
- }
6878
6824
  this.filtersApplied =
6879
6825
  typeof searchAndFilterObj.filterBeneficiary === 'string' ||
6880
6826
  typeof searchAndFilterObj.filterCategory === 'string' ||
@@ -6962,6 +6908,35 @@ class BiggiveCampaignCardFilterGrid {
6962
6908
  filterLocation: this.selectedFilterLocation,
6963
6909
  };
6964
6910
  }
6911
+ removeFilter(filterKey) {
6912
+ var _a;
6913
+ switch (filterKey) {
6914
+ case 'beneficiaries':
6915
+ this.selectedFilterBeneficiary = null;
6916
+ break;
6917
+ case 'categories':
6918
+ this.selectedFilterCategory = null;
6919
+ break;
6920
+ case 'funding':
6921
+ this.selectedFilterFunding = null;
6922
+ break;
6923
+ case 'locations':
6924
+ this.selectedFilterLocation = null;
6925
+ break;
6926
+ default:
6927
+ // This asks the compiler to check that we are in dead code, i.e. we covered all the possible filter keys
6928
+ // above. If we missed one we would get a compile error trying to assign a string to a never.
6929
+ const exhaustiveSwitch = filterKey;
6930
+ console.error(exhaustiveSwitch);
6931
+ }
6932
+ const selectEl = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById(filterKey);
6933
+ if (!selectEl) {
6934
+ return;
6935
+ }
6936
+ selectEl.selectedLabel = null;
6937
+ selectEl.selectedValue = null;
6938
+ this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
6939
+ }
6965
6940
  componentWillRender() {
6966
6941
  this.filtersApplied =
6967
6942
  this.selectedFilterCategory !== null || this.selectedFilterBeneficiary !== null || this.selectedFilterFunding !== null || this.selectedFilterLocation !== null;
@@ -6969,10 +6944,18 @@ class BiggiveCampaignCardFilterGrid {
6969
6944
  }
6970
6945
  render() {
6971
6946
  var _a;
6972
- return (hAsync("div", { class: 'container space-below-' + this.spaceBelow }, hAsync("div", { class: "sleeve" }, hAsync("div", { class: "search-wrap" }, hAsync("h4", null, this.intro), hAsync("div", { class: "field-wrap" }, hAsync("div", { class: "input-wrap" }, hAsync("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, hAsync("path", { d: faMagnifyingGlass.icon[4].toString() })), hAsync("input", { type: "text", value: (_a = this.searchText) !== null && _a !== void 0 ? _a : '', class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), hAsync("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), hAsync("div", { class: "sort-filter-wrap" }, hAsync("div", { class: "filter-wrap" }, hAsync("biggive-button", { class: "filter", colourScheme: "primary", onClick: this.handleFilterButtonClick, label: "Filter", fullWidth: true, "space-below": "0" }), hAsync("biggive-popup", { id: "filter-popup" }, hAsync("h4", { class: "space-above-0 space-below-3 text-colour-primary" }, "Filters"), hAsync("div", { class: "select-wrapper-1" }, hAsync("biggive-form-field-select", { backgroundColour: "white", prompt: "Category", placeholder: this.categoriesPlaceHolderText, selectedLabel: this.selectedFilterCategory, options: this.optionsToArray(this.categoryOptions || []), selectionChanged: this.categoryFilterSelectionChanged, id: "categories", "space-below": "2" })), hAsync("div", { class: "select-wrapper-2" }, hAsync("biggive-form-field-select", { backgroundColour: "white", prompt: "Beneficiary", placeholder: this.beneficiariesPlaceHolderText, selectedLabel: this.selectedFilterBeneficiary, options: this.optionsToArray(this.beneficiaryOptions || []), selectionChanged: this.beneficiarySelectionChanged, id: "beneficiaries", "space-below": "2" })), hAsync("div", { class: "select-wrapper-3" }, hAsync("biggive-form-field-select", { backgroundColour: "white", prompt: "Location", placeholder: this.locationsPlaceHolderText, selectedLabel: this.selectedFilterLocation, options: this.optionsToArray(this.locationOptions || []), selectionChanged: this.locationSelectionChanged, id: "locations", "space-below": "2" })), hAsync("div", { class: "select-wrapper-4" }, hAsync("biggive-form-field-select", { backgroundColour: "white", prompt: "Funding", placeholder: this.fundingPlaceHolderText, selectedLabel: this.selectedFilterFunding, options: this.optionsToArray(this.fundingOptions || []), selectionChanged: this.fundingSelectionChanged, id: "funding", "space-below": "2" })), hAsync("div", { class: "align-right" }, hAsync("biggive-button", { label: "Apply filters", onClick: this.handleApplyFilterButtonClick })))), hAsync("div", { class: "sort-wrap" }, hAsync("biggive-form-field-select", { options: [
6947
+ return (hAsync("div", { class: 'container space-below-' + this.spaceBelow }, hAsync("div", { class: "sleeve" }, hAsync("div", { class: "search-wrap" }, hAsync("h4", null, this.intro), hAsync("div", { class: "field-wrap" }, hAsync("div", { class: "input-wrap" }, hAsync("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, hAsync("path", { d: faMagnifyingGlass.icon[4].toString() })), hAsync("input", { type: "text", value: (_a = this.searchText) !== null && _a !== void 0 ? _a : '', class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), hAsync("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), hAsync("div", { class: "sort-filter-wrap" }, hAsync("div", { class: "filter-wrap" }, hAsync("biggive-button", { class: "filter", colourScheme: "primary", onClick: this.handleFilterButtonClick, label: "Filter", fullWidth: true, "space-below": "0" }), hAsync("biggive-popup", { id: "filter-popup" }, hAsync("h4", { class: "space-above-0 space-below-3 text-colour-primary" }, "Filters"), hAsync("div", { class: "select-wrapper-1" }, hAsync("biggive-form-field-select", { backgroundColour: "white", prompt: "Category", placeholder: this.categoriesPlaceHolderText, selectedLabel: this.selectedFilterCategory, selectedValue: this.selectedFilterCategory, options: this.optionsToArray(this.categoryOptions || []), selectionChanged: this.categoryFilterSelectionChanged, id: "categories", "space-below": "2" })), hAsync("div", { class: "select-wrapper-2" }, hAsync("biggive-form-field-select", { backgroundColour: "white", prompt: "Beneficiary", placeholder: this.beneficiariesPlaceHolderText, selectedLabel: this.selectedFilterBeneficiary, selectedValue: this.selectedFilterBeneficiary, options: this.optionsToArray(this.beneficiaryOptions || []), selectionChanged: this.beneficiarySelectionChanged, id: "beneficiaries", "space-below": "2" })), hAsync("div", { class: "select-wrapper-3" }, hAsync("biggive-form-field-select", { backgroundColour: "white", prompt: "Location", placeholder: this.locationsPlaceHolderText, selectedLabel: this.selectedFilterLocation, selectedValue: this.selectedFilterLocation, options: this.optionsToArray(this.locationOptions || []), selectionChanged: this.locationSelectionChanged, id: "locations", "space-below": "2" })), hAsync("div", { class: "select-wrapper-4" }, hAsync("biggive-form-field-select", { backgroundColour: "white", prompt: "Funding", placeholder: this.fundingPlaceHolderText, selectedLabel: this.selectedFilterFunding, selectedValue: this.selectedFilterFunding, options: this.optionsToArray(this.fundingOptions || []), selectionChanged: this.fundingSelectionChanged, id: "funding", "space-below": "2" })), hAsync("div", { class: "align-right" }, hAsync("biggive-button", { label: "Apply filters", onClick: this.handleApplyFilterButtonClick })))), hAsync("div", { class: "sort-wrap" }, hAsync("biggive-form-field-select", { options: [
6973
6948
  { value: 'amountRaised', label: 'Most raised' },
6974
6949
  { value: 'matchFundsRemaining', label: 'Match funds remaining' },
6975
- ], prompt: null, "select-style": "underlined", placeholder: this.sortByPlaceholderText, selectedLabel: this.selectedSortByOption, selectionChanged: this.sortBySelectionChanged, id: "sort-by" }, hAsync("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), hAsync("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }), (this.searchText || '').length > 0 ? hAsync("biggive-form-field-select-option", { value: "Relevance", label: "Relevance" }) : null))), hAsync("div", { class: "selected-filter-wrap" }, hAsync("div", { class: "selected-filters" }), hAsync("div", { class: "clear-all" }, hAsync("a", { onClick: this.handleClearAll }, "Clear all"))), hAsync("div", { class: "campaign-grid" }, hAsync("slot", { name: "campaign-grid" })))));
6950
+ ], prompt: null, "select-style": "underlined", placeholder: this.sortByPlaceholderText, selectedLabel: this.selectedSortByOption, selectionChanged: this.sortBySelectionChanged, id: "sort-by" }, hAsync("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), hAsync("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }), (this.searchText || '').length > 0 ? hAsync("biggive-form-field-select-option", { value: "Relevance", label: "Relevance" }) : null))), hAsync("div", { class: "selected-filter-wrap" }, hAsync("div", { class: "selected-filters" }, this.selectedFilterCategory && (hAsync("span", { class: "button", onClick: () => {
6951
+ this.removeFilter('categories');
6952
+ } }, this.selectedFilterCategory)), this.selectedFilterBeneficiary && (hAsync("span", { class: "button", onClick: () => {
6953
+ this.removeFilter('beneficiaries');
6954
+ } }, this.selectedFilterBeneficiary)), this.selectedFilterLocation && (hAsync("span", { class: "button", onClick: () => {
6955
+ this.removeFilter('locations');
6956
+ } }, this.selectedFilterLocation)), this.selectedFilterFunding && (hAsync("span", { class: "button", onClick: () => {
6957
+ this.removeFilter('funding');
6958
+ } }, this.selectedFilterFunding))), hAsync("div", { class: "clear-all" }, hAsync("a", { onClick: this.handleClearAll }, "Clear all"))), hAsync("div", { class: "campaign-grid" }, hAsync("slot", { name: "campaign-grid" })))));
6976
6959
  }
6977
6960
  optionsToArray(options) {
6978
6961
  if (typeof options === 'string') {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@biggive/components",
3
3
  "_comment": "Version number below is automatically replaced during CircleCI build.",
4
- "version": "202311201334.0.0",
4
+ "version": "202311211120.0.0",
5
5
  "description": "Big Give Components",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.js",