@biggive/components 1.0.136 → 1.0.138

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.
@@ -128,10 +128,7 @@ const BiggiveCampaignCardFilterGrid = class {
128
128
  this.filterBeneficiary = null;
129
129
  this.filterLocation = null;
130
130
  this.filterFunding = null;
131
- this.handleSortByChanged = (event) => {
132
- this.sortBy = event.target.value;
133
- this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
134
- };
131
+ this.sortByPlaceholderText = 'Sort by';
135
132
  this.handleApplyFilterButtonClick = () => {
136
133
  this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
137
134
  };
@@ -169,15 +166,28 @@ const BiggiveCampaignCardFilterGrid = class {
169
166
  };
170
167
  return event;
171
168
  }
172
- doOptionSelectCompletedHandler() {
169
+ doOptionSelectCompletedHandler(event) {
173
170
  this.sortBy = this.el.shadowRoot.getElementById('sort-by').selectedValue;
174
171
  this.filterCategory = this.el.shadowRoot.getElementById('categories').selectedValue;
175
172
  this.filterBeneficiary = this.el.shadowRoot.getElementById('beneficiaries').selectedValue;
176
173
  this.filterLocation = this.el.shadowRoot.getElementById('locations').selectedValue;
177
174
  this.filterFunding = this.el.shadowRoot.getElementById('funding').selectedValue;
175
+ // If this method was trigerred by the selection of a 'Sort by' dropdown option, then
176
+ // emit an event to search, but do NOT emit an event for example when filter options
177
+ // are selected, until the 'Apply filters' button is pressed which is handled separately
178
+ // by `handleApplyFilterButtonClick()`.
179
+ // Additional note -> we could, instead, do this:
180
+ // `<biggive-form-field-select placeholder="Sort by" id="sort-by" onDoSelectChange={this.someHandleMethod}>`
181
+ // but the problem with that is that `someHandleMethod` gets called first and then this
182
+ // method gets called, leading to two calls and more risk for error. DON-570.
183
+ if (event.detail.placeholder === this.sortByPlaceholderText) {
184
+ console.log('emitting event:');
185
+ console.log(this.getSearchAndFilterObject());
186
+ this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
187
+ }
178
188
  }
179
189
  render() {
180
- return (index.h("div", { class: 'container space-below-' + this.spaceBelow }, index.h("div", { class: "sleeve" }, index.h("div", { class: "search-wrap" }, index.h("h4", null, this.intro), index.h("div", { class: "field-wrap" }, index.h("div", { class: "input-wrap" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, index.h("path", { d: index$1.faMagnifyingGlass.icon[4].toString() })), index.h("input", { type: "text", value: this.searchText, class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), index.h("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), index.h("div", { class: "sort-filter-wrap" }, index.h("div", { class: "sort-wrap" }, index.h("biggive-form-field-select", { placeholder: "Sort by", id: "sort-by", onDoSelectChange: this.handleSortByChanged }, index.h("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), index.h("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }))), index.h("div", { class: "filter-wrap" }, index.h("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), index.h("biggive-popup", { id: "filter-popup" }, index.h("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), index.h("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
190
+ return (index.h("div", { class: 'container space-below-' + this.spaceBelow }, index.h("div", { class: "sleeve" }, index.h("div", { class: "search-wrap" }, index.h("h4", null, this.intro), index.h("div", { class: "field-wrap" }, index.h("div", { class: "input-wrap" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, index.h("path", { d: index$1.faMagnifyingGlass.icon[4].toString() })), index.h("input", { type: "text", value: this.searchText, class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), index.h("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), index.h("div", { class: "sort-filter-wrap" }, index.h("div", { class: "sort-wrap" }, index.h("biggive-form-field-select", { placeholder: "Sort by", id: "sort-by" }, index.h("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), index.h("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }))), index.h("div", { class: "filter-wrap" }, index.h("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), index.h("biggive-popup", { id: "filter-popup" }, index.h("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), index.h("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
181
191
  ? undefined
182
192
  : this.categoryOptions.map(option => index.h("biggive-form-field-select-option", { value: option, label: option }))), index.h("biggive-form-field-select", { placeholder: "Beneficiary", id: "beneficiaries", "space-below": "2" }, this.beneficiaryOptions.length === 0
183
193
  ? undefined
@@ -254,17 +264,25 @@ const BiggiveFormFieldSelect = class {
254
264
  doOptionSelectCompletedHandler(event) {
255
265
  this.selectedValue = event.detail.value;
256
266
  this.selectedLabel = event.detail.label;
257
- this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel });
258
- const dropdown = this.el.shadowRoot.querySelector('.dropdown');
259
- dropdown.classList.remove('active');
267
+ this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel, placeholder: this.placeholder });
268
+ if (this.el.shadowRoot !== null && this.el.shadowRoot !== undefined) {
269
+ const dropdown = this.el.shadowRoot.querySelector('.dropdown');
270
+ if (dropdown !== null && dropdown !== undefined) {
271
+ dropdown.classList.remove('active');
272
+ }
273
+ }
260
274
  }
261
275
  toggleFocus(event) {
262
- const dropdown = event.target.parentElement.parentElement;
263
- if (dropdown.classList.contains('active')) {
264
- dropdown.classList.remove('active');
265
- }
266
- else {
267
- dropdown.classList.add('active');
276
+ if (event.target) {
277
+ const dropdown = event.target.parentElement.parentElement;
278
+ if (dropdown !== null && dropdown !== undefined) {
279
+ if (dropdown.classList.contains('active')) {
280
+ dropdown.classList.remove('active');
281
+ }
282
+ else {
283
+ dropdown.classList.add('active');
284
+ }
285
+ }
268
286
  }
269
287
  }
270
288
  render() {
@@ -8,10 +8,7 @@ export class BiggiveCampaignCardFilterGrid {
8
8
  this.filterBeneficiary = null;
9
9
  this.filterLocation = null;
10
10
  this.filterFunding = null;
11
- this.handleSortByChanged = (event) => {
12
- this.sortBy = event.target.value;
13
- this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
14
- };
11
+ this.sortByPlaceholderText = 'Sort by';
15
12
  this.handleApplyFilterButtonClick = () => {
16
13
  this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
17
14
  };
@@ -49,15 +46,28 @@ export class BiggiveCampaignCardFilterGrid {
49
46
  };
50
47
  return event;
51
48
  }
52
- doOptionSelectCompletedHandler() {
49
+ doOptionSelectCompletedHandler(event) {
53
50
  this.sortBy = this.el.shadowRoot.getElementById('sort-by').selectedValue;
54
51
  this.filterCategory = this.el.shadowRoot.getElementById('categories').selectedValue;
55
52
  this.filterBeneficiary = this.el.shadowRoot.getElementById('beneficiaries').selectedValue;
56
53
  this.filterLocation = this.el.shadowRoot.getElementById('locations').selectedValue;
57
54
  this.filterFunding = this.el.shadowRoot.getElementById('funding').selectedValue;
55
+ // If this method was trigerred by the selection of a 'Sort by' dropdown option, then
56
+ // emit an event to search, but do NOT emit an event for example when filter options
57
+ // are selected, until the 'Apply filters' button is pressed which is handled separately
58
+ // by `handleApplyFilterButtonClick()`.
59
+ // Additional note -> we could, instead, do this:
60
+ // `<biggive-form-field-select placeholder="Sort by" id="sort-by" onDoSelectChange={this.someHandleMethod}>`
61
+ // but the problem with that is that `someHandleMethod` gets called first and then this
62
+ // method gets called, leading to two calls and more risk for error. DON-570.
63
+ if (event.detail.placeholder === this.sortByPlaceholderText) {
64
+ console.log('emitting event:');
65
+ console.log(this.getSearchAndFilterObject());
66
+ this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
67
+ }
58
68
  }
59
69
  render() {
60
- return (h("div", { class: 'container space-below-' + this.spaceBelow }, h("div", { class: "sleeve" }, h("div", { class: "search-wrap" }, h("h4", null, this.intro), h("div", { class: "field-wrap" }, h("div", { class: "input-wrap" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, h("path", { d: faMagnifyingGlass.icon[4].toString() })), h("input", { type: "text", value: this.searchText, class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), h("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), h("div", { class: "sort-filter-wrap" }, h("div", { class: "sort-wrap" }, h("biggive-form-field-select", { placeholder: "Sort by", id: "sort-by", onDoSelectChange: this.handleSortByChanged }, h("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), h("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }))), h("div", { class: "filter-wrap" }, h("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), h("biggive-popup", { id: "filter-popup" }, h("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), h("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
70
+ return (h("div", { class: 'container space-below-' + this.spaceBelow }, h("div", { class: "sleeve" }, h("div", { class: "search-wrap" }, h("h4", null, this.intro), h("div", { class: "field-wrap" }, h("div", { class: "input-wrap" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, h("path", { d: faMagnifyingGlass.icon[4].toString() })), h("input", { type: "text", value: this.searchText, class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), h("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), h("div", { class: "sort-filter-wrap" }, h("div", { class: "sort-wrap" }, h("biggive-form-field-select", { placeholder: "Sort by", id: "sort-by" }, h("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), h("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }))), h("div", { class: "filter-wrap" }, h("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), h("biggive-popup", { id: "filter-popup" }, h("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), h("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
61
71
  ? undefined
62
72
  : this.categoryOptions.map(option => h("biggive-form-field-select-option", { value: option, label: option }))), h("biggive-form-field-select", { placeholder: "Beneficiary", id: "beneficiaries", "space-below": "2" }, this.beneficiaryOptions.length === 0
63
73
  ? undefined
@@ -9,17 +9,25 @@ export class BiggiveFormFieldSelect {
9
9
  doOptionSelectCompletedHandler(event) {
10
10
  this.selectedValue = event.detail.value;
11
11
  this.selectedLabel = event.detail.label;
12
- this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel });
13
- const dropdown = this.el.shadowRoot.querySelector('.dropdown');
14
- dropdown.classList.remove('active');
12
+ this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel, placeholder: this.placeholder });
13
+ if (this.el.shadowRoot !== null && this.el.shadowRoot !== undefined) {
14
+ const dropdown = this.el.shadowRoot.querySelector('.dropdown');
15
+ if (dropdown !== null && dropdown !== undefined) {
16
+ dropdown.classList.remove('active');
17
+ }
18
+ }
15
19
  }
16
20
  toggleFocus(event) {
17
- const dropdown = event.target.parentElement.parentElement;
18
- if (dropdown.classList.contains('active')) {
19
- dropdown.classList.remove('active');
20
- }
21
- else {
22
- dropdown.classList.add('active');
21
+ if (event.target) {
22
+ const dropdown = event.target.parentElement.parentElement;
23
+ if (dropdown !== null && dropdown !== undefined) {
24
+ if (dropdown.classList.contains('active')) {
25
+ dropdown.classList.remove('active');
26
+ }
27
+ else {
28
+ dropdown.classList.add('active');
29
+ }
30
+ }
23
31
  }
24
32
  }
25
33
  render() {
@@ -19,10 +19,7 @@ const BiggiveCampaignCardFilterGrid$1 = /*@__PURE__*/ proxyCustomElement(class e
19
19
  this.filterBeneficiary = null;
20
20
  this.filterLocation = null;
21
21
  this.filterFunding = null;
22
- this.handleSortByChanged = (event) => {
23
- this.sortBy = event.target.value;
24
- this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
25
- };
22
+ this.sortByPlaceholderText = 'Sort by';
26
23
  this.handleApplyFilterButtonClick = () => {
27
24
  this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
28
25
  };
@@ -60,15 +57,28 @@ const BiggiveCampaignCardFilterGrid$1 = /*@__PURE__*/ proxyCustomElement(class e
60
57
  };
61
58
  return event;
62
59
  }
63
- doOptionSelectCompletedHandler() {
60
+ doOptionSelectCompletedHandler(event) {
64
61
  this.sortBy = this.el.shadowRoot.getElementById('sort-by').selectedValue;
65
62
  this.filterCategory = this.el.shadowRoot.getElementById('categories').selectedValue;
66
63
  this.filterBeneficiary = this.el.shadowRoot.getElementById('beneficiaries').selectedValue;
67
64
  this.filterLocation = this.el.shadowRoot.getElementById('locations').selectedValue;
68
65
  this.filterFunding = this.el.shadowRoot.getElementById('funding').selectedValue;
66
+ // If this method was trigerred by the selection of a 'Sort by' dropdown option, then
67
+ // emit an event to search, but do NOT emit an event for example when filter options
68
+ // are selected, until the 'Apply filters' button is pressed which is handled separately
69
+ // by `handleApplyFilterButtonClick()`.
70
+ // Additional note -> we could, instead, do this:
71
+ // `<biggive-form-field-select placeholder="Sort by" id="sort-by" onDoSelectChange={this.someHandleMethod}>`
72
+ // but the problem with that is that `someHandleMethod` gets called first and then this
73
+ // method gets called, leading to two calls and more risk for error. DON-570.
74
+ if (event.detail.placeholder === this.sortByPlaceholderText) {
75
+ console.log('emitting event:');
76
+ console.log(this.getSearchAndFilterObject());
77
+ this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
78
+ }
69
79
  }
70
80
  render() {
71
- return (h("div", { class: 'container space-below-' + this.spaceBelow }, h("div", { class: "sleeve" }, h("div", { class: "search-wrap" }, h("h4", null, this.intro), h("div", { class: "field-wrap" }, h("div", { class: "input-wrap" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, h("path", { d: faMagnifyingGlass.icon[4].toString() })), h("input", { type: "text", value: this.searchText, class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), h("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), h("div", { class: "sort-filter-wrap" }, h("div", { class: "sort-wrap" }, h("biggive-form-field-select", { placeholder: "Sort by", id: "sort-by", onDoSelectChange: this.handleSortByChanged }, h("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), h("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }))), h("div", { class: "filter-wrap" }, h("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), h("biggive-popup", { id: "filter-popup" }, h("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), h("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
81
+ return (h("div", { class: 'container space-below-' + this.spaceBelow }, h("div", { class: "sleeve" }, h("div", { class: "search-wrap" }, h("h4", null, this.intro), h("div", { class: "field-wrap" }, h("div", { class: "input-wrap" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, h("path", { d: faMagnifyingGlass.icon[4].toString() })), h("input", { type: "text", value: this.searchText, class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), h("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), h("div", { class: "sort-filter-wrap" }, h("div", { class: "sort-wrap" }, h("biggive-form-field-select", { placeholder: "Sort by", id: "sort-by" }, h("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), h("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }))), h("div", { class: "filter-wrap" }, h("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), h("biggive-popup", { id: "filter-popup" }, h("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), h("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
72
82
  ? undefined
73
83
  : this.categoryOptions.map(option => h("biggive-form-field-select-option", { value: option, label: option }))), h("biggive-form-field-select", { placeholder: "Beneficiary", id: "beneficiaries", "space-below": "2" }, this.beneficiaryOptions.length === 0
74
84
  ? undefined
@@ -16,17 +16,25 @@ const BiggiveFormFieldSelect = /*@__PURE__*/ proxyCustomElement(class extends HT
16
16
  doOptionSelectCompletedHandler(event) {
17
17
  this.selectedValue = event.detail.value;
18
18
  this.selectedLabel = event.detail.label;
19
- this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel });
20
- const dropdown = this.el.shadowRoot.querySelector('.dropdown');
21
- dropdown.classList.remove('active');
19
+ this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel, placeholder: this.placeholder });
20
+ if (this.el.shadowRoot !== null && this.el.shadowRoot !== undefined) {
21
+ const dropdown = this.el.shadowRoot.querySelector('.dropdown');
22
+ if (dropdown !== null && dropdown !== undefined) {
23
+ dropdown.classList.remove('active');
24
+ }
25
+ }
22
26
  }
23
27
  toggleFocus(event) {
24
- const dropdown = event.target.parentElement.parentElement;
25
- if (dropdown.classList.contains('active')) {
26
- dropdown.classList.remove('active');
27
- }
28
- else {
29
- dropdown.classList.add('active');
28
+ if (event.target) {
29
+ const dropdown = event.target.parentElement.parentElement;
30
+ if (dropdown !== null && dropdown !== undefined) {
31
+ if (dropdown.classList.contains('active')) {
32
+ dropdown.classList.remove('active');
33
+ }
34
+ else {
35
+ dropdown.classList.add('active');
36
+ }
37
+ }
30
38
  }
31
39
  }
32
40
  render() {
@@ -124,10 +124,7 @@ const BiggiveCampaignCardFilterGrid = class {
124
124
  this.filterBeneficiary = null;
125
125
  this.filterLocation = null;
126
126
  this.filterFunding = null;
127
- this.handleSortByChanged = (event) => {
128
- this.sortBy = event.target.value;
129
- this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
130
- };
127
+ this.sortByPlaceholderText = 'Sort by';
131
128
  this.handleApplyFilterButtonClick = () => {
132
129
  this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
133
130
  };
@@ -165,15 +162,28 @@ const BiggiveCampaignCardFilterGrid = class {
165
162
  };
166
163
  return event;
167
164
  }
168
- doOptionSelectCompletedHandler() {
165
+ doOptionSelectCompletedHandler(event) {
169
166
  this.sortBy = this.el.shadowRoot.getElementById('sort-by').selectedValue;
170
167
  this.filterCategory = this.el.shadowRoot.getElementById('categories').selectedValue;
171
168
  this.filterBeneficiary = this.el.shadowRoot.getElementById('beneficiaries').selectedValue;
172
169
  this.filterLocation = this.el.shadowRoot.getElementById('locations').selectedValue;
173
170
  this.filterFunding = this.el.shadowRoot.getElementById('funding').selectedValue;
171
+ // If this method was trigerred by the selection of a 'Sort by' dropdown option, then
172
+ // emit an event to search, but do NOT emit an event for example when filter options
173
+ // are selected, until the 'Apply filters' button is pressed which is handled separately
174
+ // by `handleApplyFilterButtonClick()`.
175
+ // Additional note -> we could, instead, do this:
176
+ // `<biggive-form-field-select placeholder="Sort by" id="sort-by" onDoSelectChange={this.someHandleMethod}>`
177
+ // but the problem with that is that `someHandleMethod` gets called first and then this
178
+ // method gets called, leading to two calls and more risk for error. DON-570.
179
+ if (event.detail.placeholder === this.sortByPlaceholderText) {
180
+ console.log('emitting event:');
181
+ console.log(this.getSearchAndFilterObject());
182
+ this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
183
+ }
174
184
  }
175
185
  render() {
176
- return (h("div", { class: 'container space-below-' + this.spaceBelow }, h("div", { class: "sleeve" }, h("div", { class: "search-wrap" }, h("h4", null, this.intro), h("div", { class: "field-wrap" }, h("div", { class: "input-wrap" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, h("path", { d: faMagnifyingGlass.icon[4].toString() })), h("input", { type: "text", value: this.searchText, class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), h("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), h("div", { class: "sort-filter-wrap" }, h("div", { class: "sort-wrap" }, h("biggive-form-field-select", { placeholder: "Sort by", id: "sort-by", onDoSelectChange: this.handleSortByChanged }, h("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), h("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }))), h("div", { class: "filter-wrap" }, h("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), h("biggive-popup", { id: "filter-popup" }, h("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), h("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
186
+ return (h("div", { class: 'container space-below-' + this.spaceBelow }, h("div", { class: "sleeve" }, h("div", { class: "search-wrap" }, h("h4", null, this.intro), h("div", { class: "field-wrap" }, h("div", { class: "input-wrap" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "icon", viewBox: "0 0 512 512" }, h("path", { d: faMagnifyingGlass.icon[4].toString() })), h("input", { type: "text", value: this.searchText, class: "input-text", placeholder: this.placeholderText, onInput: this.handleSearchTextChanged, onKeyDown: this.handleEnterPressed })), h("biggive-button", { onClick: this.handleSearchButtonPressed, label: this.buttonText }))), h("div", { class: "sort-filter-wrap" }, h("div", { class: "sort-wrap" }, h("biggive-form-field-select", { placeholder: "Sort by", id: "sort-by" }, h("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), h("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }))), h("div", { class: "filter-wrap" }, h("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), h("biggive-popup", { id: "filter-popup" }, h("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), h("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
177
187
  ? undefined
178
188
  : this.categoryOptions.map(option => h("biggive-form-field-select-option", { value: option, label: option }))), h("biggive-form-field-select", { placeholder: "Beneficiary", id: "beneficiaries", "space-below": "2" }, this.beneficiaryOptions.length === 0
179
189
  ? undefined
@@ -250,17 +260,25 @@ const BiggiveFormFieldSelect = class {
250
260
  doOptionSelectCompletedHandler(event) {
251
261
  this.selectedValue = event.detail.value;
252
262
  this.selectedLabel = event.detail.label;
253
- this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel });
254
- const dropdown = this.el.shadowRoot.querySelector('.dropdown');
255
- dropdown.classList.remove('active');
263
+ this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel, placeholder: this.placeholder });
264
+ if (this.el.shadowRoot !== null && this.el.shadowRoot !== undefined) {
265
+ const dropdown = this.el.shadowRoot.querySelector('.dropdown');
266
+ if (dropdown !== null && dropdown !== undefined) {
267
+ dropdown.classList.remove('active');
268
+ }
269
+ }
256
270
  }
257
271
  toggleFocus(event) {
258
- const dropdown = event.target.parentElement.parentElement;
259
- if (dropdown.classList.contains('active')) {
260
- dropdown.classList.remove('active');
261
- }
262
- else {
263
- dropdown.classList.add('active');
272
+ if (event.target) {
273
+ const dropdown = event.target.parentElement.parentElement;
274
+ if (dropdown !== null && dropdown !== undefined) {
275
+ if (dropdown.classList.contains('active')) {
276
+ dropdown.classList.remove('active');
277
+ }
278
+ else {
279
+ dropdown.classList.add('active');
280
+ }
281
+ }
264
282
  }
265
283
  }
266
284
  render() {
@@ -19,6 +19,7 @@ export declare class BiggiveCampaignCardFilterGrid {
19
19
  filterBeneficiary: string;
20
20
  filterLocation: string;
21
21
  filterFunding: string;
22
+ sortByPlaceholderText: string;
22
23
  /**
23
24
  * Space below component
24
25
  */
@@ -53,8 +54,7 @@ export declare class BiggiveCampaignCardFilterGrid {
53
54
  */
54
55
  fundingOptions: string[];
55
56
  private getSearchAndFilterObject;
56
- doOptionSelectCompletedHandler(): void;
57
- private handleSortByChanged;
57
+ doOptionSelectCompletedHandler(event: any): void;
58
58
  private handleApplyFilterButtonClick;
59
59
  private handleSearchButtonPressed;
60
60
  private handleSearchTextChanged;
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from '../../stencil-public-runtime';
2
2
  export declare class BiggiveFormFieldSelect {
3
- el: HTMLBiggiveFormFieldSelectElement;
3
+ el: HTMLDivElement;
4
4
  /**
5
5
  * This event `doChange` event is emitted and propogates to the parent
6
6
  * component which handles it
package/hydrate/index.js CHANGED
@@ -6536,10 +6536,7 @@ class BiggiveCampaignCardFilterGrid {
6536
6536
  this.filterBeneficiary = null;
6537
6537
  this.filterLocation = null;
6538
6538
  this.filterFunding = null;
6539
- this.handleSortByChanged = (event) => {
6540
- this.sortBy = event.target.value;
6541
- this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
6542
- };
6539
+ this.sortByPlaceholderText = 'Sort by';
6543
6540
  this.handleApplyFilterButtonClick = () => {
6544
6541
  this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
6545
6542
  };
@@ -6577,15 +6574,28 @@ class BiggiveCampaignCardFilterGrid {
6577
6574
  };
6578
6575
  return event;
6579
6576
  }
6580
- doOptionSelectCompletedHandler() {
6577
+ doOptionSelectCompletedHandler(event) {
6581
6578
  this.sortBy = this.el.shadowRoot.getElementById('sort-by').selectedValue;
6582
6579
  this.filterCategory = this.el.shadowRoot.getElementById('categories').selectedValue;
6583
6580
  this.filterBeneficiary = this.el.shadowRoot.getElementById('beneficiaries').selectedValue;
6584
6581
  this.filterLocation = this.el.shadowRoot.getElementById('locations').selectedValue;
6585
6582
  this.filterFunding = this.el.shadowRoot.getElementById('funding').selectedValue;
6583
+ // If this method was trigerred by the selection of a 'Sort by' dropdown option, then
6584
+ // emit an event to search, but do NOT emit an event for example when filter options
6585
+ // are selected, until the 'Apply filters' button is pressed which is handled separately
6586
+ // by `handleApplyFilterButtonClick()`.
6587
+ // Additional note -> we could, instead, do this:
6588
+ // `<biggive-form-field-select placeholder="Sort by" id="sort-by" onDoSelectChange={this.someHandleMethod}>`
6589
+ // but the problem with that is that `someHandleMethod` gets called first and then this
6590
+ // method gets called, leading to two calls and more risk for error. DON-570.
6591
+ if (event.detail.placeholder === this.sortByPlaceholderText) {
6592
+ console.log('emitting event:');
6593
+ console.log(this.getSearchAndFilterObject());
6594
+ this.doSearchAndFilterUpdate.emit(this.getSearchAndFilterObject());
6595
+ }
6586
6596
  }
6587
6597
  render() {
6588
- 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: this.searchText, 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: "sort-wrap" }, hAsync("biggive-form-field-select", { placeholder: "Sort by", id: "sort-by", onDoSelectChange: this.handleSortByChanged }, hAsync("biggive-form-field-select-option", { value: "amountRaised", label: "Most raised" }), hAsync("biggive-form-field-select-option", { value: "matchFundsRemaining", label: "Match funds remaining" }))), hAsync("div", { class: "filter-wrap" }, hAsync("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), hAsync("biggive-popup", { id: "filter-popup" }, hAsync("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), hAsync("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
6598
+ 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: this.searchText, 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: "sort-wrap" }, hAsync("biggive-form-field-select", { placeholder: "Sort by", 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" }))), hAsync("div", { class: "filter-wrap" }, hAsync("biggive-button", { class: "filter", onClick: this.handleFilterButtonClick, label: "Filters" }), hAsync("biggive-popup", { id: "filter-popup" }, hAsync("h4", { class: "space-above-0 space-below-3 colour-primary" }, "Filters"), hAsync("biggive-form-field-select", { placeholder: "Category", id: "categories", "space-below": "2" }, this.categoryOptions.length === 0
6589
6599
  ? undefined
6590
6600
  : this.categoryOptions.map(option => hAsync("biggive-form-field-select-option", { value: option, label: option }))), hAsync("biggive-form-field-select", { placeholder: "Beneficiary", id: "beneficiaries", "space-below": "2" }, this.beneficiaryOptions.length === 0
6591
6601
  ? undefined
@@ -6763,17 +6773,25 @@ class BiggiveFormFieldSelect {
6763
6773
  doOptionSelectCompletedHandler(event) {
6764
6774
  this.selectedValue = event.detail.value;
6765
6775
  this.selectedLabel = event.detail.label;
6766
- this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel });
6767
- const dropdown = this.el.shadowRoot.querySelector('.dropdown');
6768
- dropdown.classList.remove('active');
6776
+ this.doSelectChange.emit({ value: this.selectedValue, label: this.selectedLabel, placeholder: this.placeholder });
6777
+ if (this.el.shadowRoot !== null && this.el.shadowRoot !== undefined) {
6778
+ const dropdown = this.el.shadowRoot.querySelector('.dropdown');
6779
+ if (dropdown !== null && dropdown !== undefined) {
6780
+ dropdown.classList.remove('active');
6781
+ }
6782
+ }
6769
6783
  }
6770
6784
  toggleFocus(event) {
6771
- const dropdown = event.target.parentElement.parentElement;
6772
- if (dropdown.classList.contains('active')) {
6773
- dropdown.classList.remove('active');
6774
- }
6775
- else {
6776
- dropdown.classList.add('active');
6785
+ if (event.target) {
6786
+ const dropdown = event.target.parentElement.parentElement;
6787
+ if (dropdown !== null && dropdown !== undefined) {
6788
+ if (dropdown.classList.contains('active')) {
6789
+ dropdown.classList.remove('active');
6790
+ }
6791
+ else {
6792
+ dropdown.classList.add('active');
6793
+ }
6794
+ }
6777
6795
  }
6778
6796
  }
6779
6797
  render() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biggive/components",
3
- "version": "1.0.136",
3
+ "version": "1.0.138",
4
4
  "description": "Big Give Components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",