From 934c99fa6caf1375f1d3f71c027db415e3d86535 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Mon, 6 Jan 2025 17:34:46 +0530 Subject: [PATCH 01/12] Update projects, invoices and reporting filters to use choices.js --- hypha/apply/funds/tables.py | 21 ++++++++++++- hypha/apply/funds/widgets.py | 15 +++++++++ hypha/apply/projects/filters.py | 31 +++++++------------ .../application_projects/invoice_list.html | 13 ++++++++ .../application_projects/project_list.html | 13 ++++++++ .../application_projects/reporting.html | 13 ++++++++ 6 files changed, 86 insertions(+), 20 deletions(-) diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py index 8e14f452d8..db8c92a604 100644 --- a/hypha/apply/funds/tables.py +++ b/hypha/apply/funds/tables.py @@ -22,7 +22,7 @@ from hypha.images.models import CustomImage from .models import ApplicationSubmission, Round, ScreeningStatus -from .widgets import Select2MultiCheckboxesWidget +from .widgets import MultiCheckboxesWidget, Select2MultiCheckboxesWidget from .workflows import STATUSES, get_review_active_statuses User = get_user_model() @@ -299,18 +299,37 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) +class MultiCheckboxesMixin(filters.Filter): + def __init__(self, *args, **kwargs): + label = kwargs.get("label") + kwargs.setdefault( + "widget", MultiCheckboxesWidget(attrs={"data-placeholder": label}) + ) + super().__init__(*args, **kwargs) + + class Select2MultipleChoiceFilter( Select2CheckboxWidgetMixin, filters.MultipleChoiceFilter ): pass +class MultipleChoiceFilter(MultiCheckboxesMixin, filters.MultipleChoiceFilter): + pass + + class Select2ModelMultipleChoiceFilter( Select2MultipleChoiceFilter, filters.ModelMultipleChoiceFilter ): pass +class ModelMultipleChoiceFilter( + MultipleChoiceFilter, filters.ModelMultipleChoiceFilter +): + pass + + class StatusMultipleChoiceFilter(Select2MultipleChoiceFilter): def __init__(self, limit_to, *args, **kwargs): choices = [ diff --git a/hypha/apply/funds/widgets.py b/hypha/apply/funds/widgets.py index 6e0b1a916c..45e5767f88 100644 --- a/hypha/apply/funds/widgets.py +++ b/hypha/apply/funds/widgets.py @@ -1,3 +1,4 @@ +from django import forms from django.templatetags.static import static from django_select2.forms import Select2MultipleWidget @@ -23,6 +24,20 @@ def build_attrs(self, *args, **kwargs): return attrs +class MultiCheckboxesWidget(forms.SelectMultiple): + """ + Custom widget for Choices.js. Adds the required attributes. + """ + + def __init__(self, *args, **kwargs): + attrs = kwargs.get("attrs", {}) + # Add the class for Choices.js initialization + attrs.setdefault("class", "js-choices") + attrs.setdefault("data-placeholder", "items") + kwargs["attrs"] = attrs + super().__init__(*args, **kwargs) + + class MetaTermSelect2Widget(Select2MultipleWidget): def create_option( self, name, value, label, selected, index, subindex=None, attrs=None diff --git a/hypha/apply/projects/filters.py b/hypha/apply/projects/filters.py index 2014b3d143..fde96897d5 100644 --- a/hypha/apply/projects/filters.py +++ b/hypha/apply/projects/filters.py @@ -3,11 +3,10 @@ from django.contrib.auth import get_user_model from django.db.models import Q from django.utils.translation import gettext_lazy as _ -from django_select2.forms import Select2Widget from hypha.apply.funds.tables import ( - Select2ModelMultipleChoiceFilter, - Select2MultipleChoiceFilter, + ModelMultipleChoiceFilter, + MultipleChoiceFilter, get_used_funds, ) @@ -28,15 +27,13 @@ def get_project_leads(request): class InvoiceListFilter(filters.FilterSet): - fund = Select2ModelMultipleChoiceFilter( + fund = ModelMultipleChoiceFilter( label=_("Funds"), queryset=get_used_funds, field_name="project__submission__page", ) - status = Select2MultipleChoiceFilter( - label=_("Status"), choices=INVOICE_STATUS_CHOICES - ) - lead = Select2ModelMultipleChoiceFilter( + status = MultipleChoiceFilter(label=_("Status"), choices=INVOICE_STATUS_CHOICES) + lead = ModelMultipleChoiceFilter( label=_("Lead"), queryset=get_project_leads, field_name="project__lead" ) @@ -51,27 +48,23 @@ class ProjectListFilter(filters.FilterSet): (1, "Behind schedule"), ) - project_fund = Select2ModelMultipleChoiceFilter( + project_fund = ModelMultipleChoiceFilter( field_name="submission__page", label=_("Funds"), queryset=get_used_funds ) - project_lead = Select2ModelMultipleChoiceFilter( + project_lead = ModelMultipleChoiceFilter( field_name="lead", label=_("Lead"), queryset=get_project_leads ) - project_status = Select2MultipleChoiceFilter( + project_status = MultipleChoiceFilter( field_name="status", label=_("Status"), choices=PROJECT_STATUS_CHOICES ) query = filters.CharFilter( field_name="title", lookup_expr="icontains", widget=forms.HiddenInput ) - reporting = filters.ChoiceFilter( + reporting = MultipleChoiceFilter( choices=REPORTING_CHOICES, method="filter_reporting", - widget=Select2Widget( - attrs={ - "data-placeholder": "Reporting", - "data-minimum-results-for-search": -1, - } - ), + field_name="reporting", + label="Reporting", ) class Meta: @@ -102,7 +95,7 @@ def decompress(self, value): class ReportingFilter(filters.FilterSet): - current_report_status = Select2MultipleChoiceFilter( + current_report_status = MultipleChoiceFilter( label=_("Status"), choices=[ ("Not started", "Not started"), diff --git a/hypha/apply/projects/templates/application_projects/invoice_list.html b/hypha/apply/projects/templates/application_projects/invoice_list.html index 3d00954745..c77d70548c 100644 --- a/hypha/apply/projects/templates/application_projects/invoice_list.html +++ b/hypha/apply/projects/templates/application_projects/invoice_list.html @@ -37,4 +37,17 @@ {{ filter.form.media.js }} + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/project_list.html b/hypha/apply/projects/templates/application_projects/project_list.html index 0ef8b55a23..56266c4adc 100644 --- a/hypha/apply/projects/templates/application_projects/project_list.html +++ b/hypha/apply/projects/templates/application_projects/project_list.html @@ -37,4 +37,17 @@ {% block extra_js %} {{ filter.form.media.js }} + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/reporting.html b/hypha/apply/projects/templates/application_projects/reporting.html index 2c967e1153..e0643a69c2 100644 --- a/hypha/apply/projects/templates/application_projects/reporting.html +++ b/hypha/apply/projects/templates/application_projects/reporting.html @@ -33,4 +33,17 @@ {% block extra_js %} {{ filter.form.media.js }} + {% endblock %} From 2e8c4787d0f1bf66a95596890417a4ef727555fc Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Tue, 7 Jan 2025 11:55:51 +0530 Subject: [PATCH 02/12] Update categories blocks to use choices js instead of select2 --- hypha/apply/categories/blocks.py | 5 +++-- .../funds/templates/funds/application_base.html | 14 ++++++++++++++ .../funds/applicationsubmission_form.html | 14 ++++++++++++++ hypha/apply/funds/widgets.py | 2 +- .../project_approval_form.html | 14 ++++++++++++++ .../application_projects/project_sow_form.html | 14 ++++++++++++++ .../application_projects/report_form.html | 13 +++++++++++++ 7 files changed, 73 insertions(+), 3 deletions(-) diff --git a/hypha/apply/categories/blocks.py b/hypha/apply/categories/blocks.py index 0b053b04f3..f4f041e9f5 100644 --- a/hypha/apply/categories/blocks.py +++ b/hypha/apply/categories/blocks.py @@ -1,7 +1,6 @@ from django import forms from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ -from django_select2.forms import Select2MultipleWidget from wagtail.blocks import BooleanBlock, CharBlock, ChoiceBlock, TextBlock from wagtail.coreutils import resolve_model_string @@ -73,7 +72,9 @@ def get_widget(self, struct_value): if category_size < 32: return forms.CheckboxSelectMultiple else: - return Select2MultipleWidget + from hypha.apply.funds.tables import MultiCheckboxesWidget + + return MultiCheckboxesWidget else: return forms.RadioSelect diff --git a/hypha/apply/funds/templates/funds/application_base.html b/hypha/apply/funds/templates/funds/application_base.html index 5147e91a7d..0a9a1f330d 100644 --- a/hypha/apply/funds/templates/funds/application_base.html +++ b/hypha/apply/funds/templates/funds/application_base.html @@ -91,4 +91,18 @@

{% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applicat {% endif %} + + {% endblock %} diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_form.html b/hypha/apply/funds/templates/funds/applicationsubmission_form.html index 49df9487b5..0e7c4376fe 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_form.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_form.html @@ -51,4 +51,18 @@ {% if not show_all_group_fields %} {% endif %} + + {% endblock %} diff --git a/hypha/apply/funds/widgets.py b/hypha/apply/funds/widgets.py index 45e5767f88..6c7fcafc49 100644 --- a/hypha/apply/funds/widgets.py +++ b/hypha/apply/funds/widgets.py @@ -33,7 +33,7 @@ def __init__(self, *args, **kwargs): attrs = kwargs.get("attrs", {}) # Add the class for Choices.js initialization attrs.setdefault("class", "js-choices") - attrs.setdefault("data-placeholder", "items") + attrs.setdefault("data-placeholder", "") kwargs["attrs"] = attrs super().__init__(*args, **kwargs) diff --git a/hypha/apply/projects/templates/application_projects/project_approval_form.html b/hypha/apply/projects/templates/application_projects/project_approval_form.html index 74ed54335e..43d6983fc8 100644 --- a/hypha/apply/projects/templates/application_projects/project_approval_form.html +++ b/hypha/apply/projects/templates/application_projects/project_approval_form.html @@ -78,4 +78,18 @@

{% trans "Proposal attachments" %}
{% if not show_all_group_fields %} {% endif %} + + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/project_sow_form.html b/hypha/apply/projects/templates/application_projects/project_sow_form.html index 1c03e88483..3cc1e22f7d 100644 --- a/hypha/apply/projects/templates/application_projects/project_sow_form.html +++ b/hypha/apply/projects/templates/application_projects/project_sow_form.html @@ -74,4 +74,18 @@
{% trans "Proposal attachments" %}
{% if not show_all_group_fields %} {% endif %} + + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/report_form.html b/hypha/apply/projects/templates/application_projects/report_form.html index 689ebfe0a8..3c8e0cc03b 100644 --- a/hypha/apply/projects/templates/application_projects/report_form.html +++ b/hypha/apply/projects/templates/application_projects/report_form.html @@ -77,4 +77,17 @@ {% block extra_js %} + {% endblock %} From 597cd2aeff3b124d53be2016cd7603eda3a18410 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Tue, 7 Jan 2025 15:04:25 +0530 Subject: [PATCH 03/12] Refactor the choicejs code to single js file --- .../funds/templates/funds/application_base.html | 15 ++------------- .../funds/applicationsubmission_form.html | 15 ++------------- .../application_projects/invoice_list.html | 15 ++------------- .../project_approval_form.html | 15 ++------------- .../application_projects/project_list.html | 15 ++------------- .../application_projects/project_sow_form.html | 15 ++------------- .../application_projects/report_form.html | 15 ++------------- .../templates/application_projects/reporting.html | 15 ++------------- hypha/static_src/javascript/choices-select.js | 10 ++++++++++ hypha/static_src/javascript/vendor/choices.min.js | 2 ++ 10 files changed, 28 insertions(+), 104 deletions(-) create mode 100644 hypha/static_src/javascript/choices-select.js create mode 100644 hypha/static_src/javascript/vendor/choices.min.js diff --git a/hypha/apply/funds/templates/funds/application_base.html b/hypha/apply/funds/templates/funds/application_base.html index 0a9a1f330d..fbd8785d76 100644 --- a/hypha/apply/funds/templates/funds/application_base.html +++ b/hypha/apply/funds/templates/funds/application_base.html @@ -92,17 +92,6 @@

{% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applicat {% endif %} - + + {% endblock %} diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_form.html b/hypha/apply/funds/templates/funds/applicationsubmission_form.html index 0e7c4376fe..1b032ce744 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_form.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_form.html @@ -52,17 +52,6 @@ {% endif %} - + + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/invoice_list.html b/hypha/apply/projects/templates/application_projects/invoice_list.html index c77d70548c..7e93ec131b 100644 --- a/hypha/apply/projects/templates/application_projects/invoice_list.html +++ b/hypha/apply/projects/templates/application_projects/invoice_list.html @@ -37,17 +37,6 @@ {{ filter.form.media.js }} - + + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/project_approval_form.html b/hypha/apply/projects/templates/application_projects/project_approval_form.html index 43d6983fc8..71126dd36d 100644 --- a/hypha/apply/projects/templates/application_projects/project_approval_form.html +++ b/hypha/apply/projects/templates/application_projects/project_approval_form.html @@ -79,17 +79,6 @@

{% trans "Proposal attachments" %}
{% endif %} - + + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/project_list.html b/hypha/apply/projects/templates/application_projects/project_list.html index 56266c4adc..b2bf802fb7 100644 --- a/hypha/apply/projects/templates/application_projects/project_list.html +++ b/hypha/apply/projects/templates/application_projects/project_list.html @@ -37,17 +37,6 @@ {% block extra_js %} {{ filter.form.media.js }} - + + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/project_sow_form.html b/hypha/apply/projects/templates/application_projects/project_sow_form.html index 3cc1e22f7d..3e18251718 100644 --- a/hypha/apply/projects/templates/application_projects/project_sow_form.html +++ b/hypha/apply/projects/templates/application_projects/project_sow_form.html @@ -75,17 +75,6 @@
{% trans "Proposal attachments" %}
{% endif %} - + + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/report_form.html b/hypha/apply/projects/templates/application_projects/report_form.html index 3c8e0cc03b..263216f86c 100644 --- a/hypha/apply/projects/templates/application_projects/report_form.html +++ b/hypha/apply/projects/templates/application_projects/report_form.html @@ -77,17 +77,6 @@ {% block extra_js %} - + + {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/reporting.html b/hypha/apply/projects/templates/application_projects/reporting.html index e0643a69c2..9d7107bb99 100644 --- a/hypha/apply/projects/templates/application_projects/reporting.html +++ b/hypha/apply/projects/templates/application_projects/reporting.html @@ -33,17 +33,6 @@ {% block extra_js %} {{ filter.form.media.js }} - + + {% endblock %} diff --git a/hypha/static_src/javascript/choices-select.js b/hypha/static_src/javascript/choices-select.js new file mode 100644 index 0000000000..439b184adf --- /dev/null +++ b/hypha/static_src/javascript/choices-select.js @@ -0,0 +1,10 @@ +const selectElements = document.querySelectorAll('.js-choices'); + +selectElements.forEach(selectElement => { + // eslint-disable-next-line no-undef + new Choices(selectElement, { + shouldSort: false, + allowHTML: true, + removeItemButton: true, + }); +}); diff --git a/hypha/static_src/javascript/vendor/choices.min.js b/hypha/static_src/javascript/vendor/choices.min.js new file mode 100644 index 0000000000..3b79f06839 --- /dev/null +++ b/hypha/static_src/javascript/vendor/choices.min.js @@ -0,0 +1,2 @@ +/*! For license information please see choices.min.js.LICENSE.txt */ +!function(){"use strict";var e={282:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.clearChoices=t.activateChoices=t.filterChoices=t.addChoice=void 0;var n=i(883);t.addChoice=function(e){var t=e.value,i=e.label,r=e.id,s=e.groupId,o=e.disabled,a=e.elementId,c=e.customProperties,l=e.placeholder,h=e.keyCode;return{type:n.ACTION_TYPES.ADD_CHOICE,value:t,label:i,id:r,groupId:s,disabled:o,elementId:a,customProperties:c,placeholder:l,keyCode:h}},t.filterChoices=function(e){return{type:n.ACTION_TYPES.FILTER_CHOICES,results:e}},t.activateChoices=function(e){return void 0===e&&(e=!0),{type:n.ACTION_TYPES.ACTIVATE_CHOICES,active:e}},t.clearChoices=function(){return{type:n.ACTION_TYPES.CLEAR_CHOICES}}},783:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.addGroup=void 0;var n=i(883);t.addGroup=function(e){var t=e.value,i=e.id,r=e.active,s=e.disabled;return{type:n.ACTION_TYPES.ADD_GROUP,value:t,id:i,active:r,disabled:s}}},464:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.highlightItem=t.removeItem=t.addItem=void 0;var n=i(883);t.addItem=function(e){var t=e.value,i=e.label,r=e.id,s=e.choiceId,o=e.groupId,a=e.customProperties,c=e.placeholder,l=e.keyCode;return{type:n.ACTION_TYPES.ADD_ITEM,value:t,label:i,id:r,choiceId:s,groupId:o,customProperties:a,placeholder:c,keyCode:l}},t.removeItem=function(e,t){return{type:n.ACTION_TYPES.REMOVE_ITEM,id:e,choiceId:t}},t.highlightItem=function(e,t){return{type:n.ACTION_TYPES.HIGHLIGHT_ITEM,id:e,highlighted:t}}},137:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.setIsLoading=t.resetTo=t.clearAll=void 0;var n=i(883);t.clearAll=function(){return{type:n.ACTION_TYPES.CLEAR_ALL}},t.resetTo=function(e){return{type:n.ACTION_TYPES.RESET_TO,state:e}},t.setIsLoading=function(e){return{type:n.ACTION_TYPES.SET_IS_LOADING,isLoading:e}}},373:function(e,t,i){var n=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,r=0,s=t.length;r=0?this._store.getGroupById(r):null;return this._store.dispatch((0,l.highlightItem)(i,!0)),t&&this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:i,value:o,label:c,groupValue:h&&h.value?h.value:null}),this},e.prototype.unhighlightItem=function(e){if(!e||!e.id)return this;var t=e.id,i=e.groupId,n=void 0===i?-1:i,r=e.value,s=void 0===r?"":r,o=e.label,a=void 0===o?"":o,c=n>=0?this._store.getGroupById(n):null;return this._store.dispatch((0,l.highlightItem)(t,!1)),this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:t,value:s,label:a,groupValue:c&&c.value?c.value:null}),this},e.prototype.highlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.highlightItem(t)})),this},e.prototype.unhighlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.unhighlightItem(t)})),this},e.prototype.removeActiveItemsByValue=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.value===e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeActiveItems=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.id!==e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeHighlightedItems=function(e){var t=this;return void 0===e&&(e=!1),this._store.highlightedActiveItems.forEach((function(i){t._removeItem(i),e&&t._triggerChange(i.value)})),this},e.prototype.showDropdown=function(e){var t=this;return this.dropdown.isActive||requestAnimationFrame((function(){t.dropdown.show(),t.containerOuter.open(t.dropdown.distanceFromTopWindow),!e&&t._canSearch&&t.input.focus(),t.passedElement.triggerEvent(d.EVENTS.showDropdown,{})})),this},e.prototype.hideDropdown=function(e){var t=this;return this.dropdown.isActive?(requestAnimationFrame((function(){t.dropdown.hide(),t.containerOuter.close(),!e&&t._canSearch&&(t.input.removeActiveDescendant(),t.input.blur()),t.passedElement.triggerEvent(d.EVENTS.hideDropdown,{})})),this):this},e.prototype.getValue=function(e){void 0===e&&(e=!1);var t=this._store.activeItems.reduce((function(t,i){var n=e?i.value:i;return t.push(n),t}),[]);return this._isSelectOneElement?t[0]:t},e.prototype.setValue=function(e){var t=this;return this.initialised?(e.forEach((function(e){return t._setChoiceOrItem(e)})),this):this},e.prototype.setChoiceByValue=function(e){var t=this;return!this.initialised||this._isTextElement||(Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)})),this},e.prototype.setChoices=function(e,t,i,n){var r=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===i&&(i="label"),void 0===n&&(n=!1),!this.initialised)throw new ReferenceError("setChoices was called on a non-initialized instance of Choices");if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if("string"!=typeof t||!t)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(n&&this.clearChoices(),"function"==typeof e){var s=e(this);if("function"==typeof Promise&&s instanceof Promise)return new Promise((function(e){return requestAnimationFrame(e)})).then((function(){return r._handleLoadingState(!0)})).then((function(){return s})).then((function(e){return r.setChoices(e,t,i,n)})).catch((function(e){r.config.silent||console.error(e)})).then((function(){return r._handleLoadingState(!1)})).then((function(){return r}));if(!Array.isArray(s))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof s));return this.setChoices(s,t,i,!1)}if(!Array.isArray(e))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._startLoading(),e.forEach((function(e){if(e.choices)r._addGroup({id:e.id?parseInt("".concat(e.id),10):null,group:e,valueKey:t,labelKey:i});else{var n=e;r._addChoice({value:n[t],label:n[i],isSelected:!!n.selected,isDisabled:!!n.disabled,placeholder:!!n.placeholder,customProperties:n.customProperties})}})),this._stopLoading(),this},e.prototype.clearChoices=function(){return this._store.dispatch((0,a.clearChoices)()),this},e.prototype.clearStore=function(){return this._store.dispatch((0,h.clearAll)()),this},e.prototype.clearInput=function(){var e=!this._isSelectOneElement;return this.input.clear(e),!this._isTextElement&&this._canSearch&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))),this},e.prototype._render=function(){if(!this._store.isLoading()){this._currentState=this._store.state;var e=this._currentState.choices!==this._prevState.choices||this._currentState.groups!==this._prevState.groups||this._currentState.items!==this._prevState.items,t=this._isSelectElement,i=this._currentState.items!==this._prevState.items;e&&(t&&this._renderChoices(),i&&this._renderItems(),this._prevState=this._currentState)}},e.prototype._renderChoices=function(){var e=this,t=this._store,i=t.activeGroups,n=t.activeChoices,r=document.createDocumentFragment();if(this.choiceList.clear(),this.config.resetScrollPosition&&requestAnimationFrame((function(){return e.choiceList.scrollToTop()})),i.length>=1&&!this._isSearching){var s=n.filter((function(e){return!0===e.placeholder&&-1===e.groupId}));s.length>=1&&(r=this._createChoicesFragment(s,r)),r=this._createGroupsFragment(i,n,r)}else n.length>=1&&(r=this._createChoicesFragment(n,r));if(r.childNodes&&r.childNodes.length>0){var o=this._store.activeItems,a=this._canAddItem(o,this.input.value);if(a.response)this.choiceList.append(r),this._highlightChoice();else{var c=this._getTemplate("notice",a.notice);this.choiceList.append(c)}}else{var l=void 0;c=void 0,this._isSearching?(c="function"==typeof this.config.noResultsText?this.config.noResultsText():this.config.noResultsText,l=this._getTemplate("notice",c,"no-results")):(c="function"==typeof this.config.noChoicesText?this.config.noChoicesText():this.config.noChoicesText,l=this._getTemplate("notice",c,"no-choices")),this.choiceList.append(l)}},e.prototype._renderItems=function(){var e=this._store.activeItems||[];this.itemList.clear();var t=this._createItemsFragment(e);t.childNodes&&this.itemList.append(t)},e.prototype._createGroupsFragment=function(e,t,i){var n=this;return void 0===i&&(i=document.createDocumentFragment()),this.config.shouldSort&&e.sort(this.config.sorter),e.forEach((function(e){var r=function(e){return t.filter((function(t){return n._isSelectOneElement?t.groupId===e.id:t.groupId===e.id&&("always"===n.config.renderSelectedChoices||!t.selected)}))}(e);if(r.length>=1){var s=n._getTemplate("choiceGroup",e);i.appendChild(s),n._createChoicesFragment(r,i,!0)}})),i},e.prototype._createChoicesFragment=function(e,t,i){var r=this;void 0===t&&(t=document.createDocumentFragment()),void 0===i&&(i=!1);var s=this.config,o=s.renderSelectedChoices,a=s.searchResultLimit,c=s.renderChoiceLimit,l=this._isSearching?f.sortByScore:this.config.sorter,h=function(e){if("auto"!==o||r._isSelectOneElement||!e.selected){var i=r._getTemplate("choice",e,r.config.itemSelectText);t.appendChild(i)}},u=e;"auto"!==o||this._isSelectOneElement||(u=e.filter((function(e){return!e.selected})));var d=u.reduce((function(e,t){return t.placeholder?e.placeholderChoices.push(t):e.normalChoices.push(t),e}),{placeholderChoices:[],normalChoices:[]}),p=d.placeholderChoices,m=d.normalChoices;(this.config.shouldSort||this._isSearching)&&m.sort(l);var v=u.length,g=this._isSelectOneElement?n(n([],p,!0),m,!0):m;this._isSearching?v=a:c&&c>0&&!i&&(v=c);for(var _=0;_=n){var o=r?this._searchChoices(e):0;this.passedElement.triggerEvent(d.EVENTS.search,{value:e,resultCount:o})}else s&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0)))}},e.prototype._canAddItem=function(e,t){var i=!0,n="function"==typeof this.config.addItemText?this.config.addItemText(t):this.config.addItemText;if(!this._isSelectOneElement){var r=(0,f.existsInArray)(e,t);this.config.maxItemCount>0&&this.config.maxItemCount<=e.length&&(i=!1,n="function"==typeof this.config.maxItemText?this.config.maxItemText(this.config.maxItemCount):this.config.maxItemText),!this.config.duplicateItemsAllowed&&r&&i&&(i=!1,n="function"==typeof this.config.uniqueItemText?this.config.uniqueItemText(t):this.config.uniqueItemText),this._isTextElement&&this.config.addItems&&i&&"function"==typeof this.config.addItemFilter&&!this.config.addItemFilter(t)&&(i=!1,n="function"==typeof this.config.customAddItemText?this.config.customAddItemText(t):this.config.customAddItemText)}return{response:i,notice:n}},e.prototype._searchChoices=function(e){var t="string"==typeof e?e.trim():e,i="string"==typeof this._currentValue?this._currentValue.trim():this._currentValue;if(t.length<1&&t==="".concat(i," "))return 0;var r=this._store.searchableChoices,s=t,c=Object.assign(this.config.fuseOptions,{keys:n([],this.config.searchFields,!0),includeMatches:!0}),l=new o.default(r,c).search(s);return this._currentValue=t,this._highlightPosition=0,this._isSearching=!0,this._store.dispatch((0,a.filterChoices)(l)),l.length},e.prototype._addEventListeners=function(){var e=document.documentElement;e.addEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.addEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(this.containerOuter.element.addEventListener("focus",this._onFocus,{passive:!0}),this.containerOuter.element.addEventListener("blur",this._onBlur,{passive:!0})),this.input.element.addEventListener("keyup",this._onKeyUp,{passive:!0}),this.input.element.addEventListener("focus",this._onFocus,{passive:!0}),this.input.element.addEventListener("blur",this._onBlur,{passive:!0}),this.input.element.form&&this.input.element.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=document.documentElement;e.removeEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.removeEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(this.containerOuter.element.removeEventListener("focus",this._onFocus),this.containerOuter.element.removeEventListener("blur",this._onBlur)),this.input.element.removeEventListener("keyup",this._onKeyUp),this.input.element.removeEventListener("focus",this._onFocus),this.input.element.removeEventListener("blur",this._onBlur),this.input.element.form&&this.input.element.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this._store.activeItems,n=this.input.isFocussed,r=this.dropdown.isActive,s=this.itemList.hasChildren(),o=String.fromCharCode(t),a=/[^\x00-\x1F]/.test(o),c=d.KEY_CODES.BACK_KEY,l=d.KEY_CODES.DELETE_KEY,h=d.KEY_CODES.ENTER_KEY,u=d.KEY_CODES.A_KEY,p=d.KEY_CODES.ESC_KEY,f=d.KEY_CODES.UP_KEY,m=d.KEY_CODES.DOWN_KEY,v=d.KEY_CODES.PAGE_UP_KEY,g=d.KEY_CODES.PAGE_DOWN_KEY;switch(this._isTextElement||r||!a||(this.showDropdown(),this.input.isFocussed||(this.input.value+=e.key.toLowerCase())),t){case u:return this._onSelectKey(e,s);case h:return this._onEnterKey(e,i,r);case p:return this._onEscapeKey(r);case f:case v:case m:case g:return this._onDirectionKey(e,r);case l:case c:return this._onDeleteKey(e,i,n)}},e.prototype._onKeyUp=function(e){var t=e.target,i=e.keyCode,n=this.input.value,r=this._store.activeItems,s=this._canAddItem(r,n),o=d.KEY_CODES.BACK_KEY,c=d.KEY_CODES.DELETE_KEY;if(this._isTextElement)if(s.notice&&n){var l=this._getTemplate("notice",s.notice);this.dropdown.element.innerHTML=l.outerHTML,this.showDropdown(!0)}else this.hideDropdown(!0);else{var h=(i===o||i===c)&&t&&!t.value,u=!this._isTextElement&&this._isSearching,p=this._canSearch&&s.response;h&&u?(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))):p&&this._handleSearch(this.input.rawValue)}this._canSearch=this.config.searchEnabled},e.prototype._onSelectKey=function(e,t){var i=e.ctrlKey,n=e.metaKey;(i||n)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t,i){var n=e.target,r=d.KEY_CODES.ENTER_KEY,s=n&&n.hasAttribute("data-button");if(this._isTextElement&&n&&n.value){var o=this.input.value;this._canAddItem(t,o).response&&(this.hideDropdown(!0),this._addItem({value:o}),this._triggerChange(o),this.clearInput())}if(s&&(this._handleButtonAction(t,n),e.preventDefault()),i){var a=this.dropdown.getChild(".".concat(this.config.classNames.highlightedState));a&&(t[0]&&(t[0].keyCode=r),this._handleChoiceAction(t,a)),e.preventDefault()}else this._isSelectOneElement&&(this.showDropdown(),e.preventDefault())},e.prototype._onEscapeKey=function(e){e&&(this.hideDropdown(!0),this.containerOuter.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode,n=e.metaKey,r=d.KEY_CODES.DOWN_KEY,s=d.KEY_CODES.PAGE_UP_KEY,o=d.KEY_CODES.PAGE_DOWN_KEY;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var a=i===r||i===o?1:-1,c="[data-choice-selectable]",l=void 0;if(n||i===o||i===s)l=a>0?this.dropdown.element.querySelector("".concat(c,":last-of-type")):this.dropdown.element.querySelector(c);else{var h=this.dropdown.element.querySelector(".".concat(this.config.classNames.highlightedState));l=h?(0,f.getAdjacentEl)(h,c,a):this.dropdown.element.querySelector(c)}l&&((0,f.isScrolledIntoView)(l,this.choiceList.element,a)||this.choiceList.scrollToChildElement(l,a),this._highlightChoice(l)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){var n=e.target;this._isSelectOneElement||n.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof HTMLElement){if(_&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild,n="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetX0&&this.unhighlightAll(),this.containerOuter.removeFocusState(),this.hideDropdown(!0))},e.prototype._onFocus=function(e){var t,i=this,n=e.target;n&&this.containerOuter.element.contains(n)&&((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&i.containerOuter.addFocusState()},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.addFocusState(),n===i.input.element&&i.showDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.showDropdown(!0),i.containerOuter.addFocusState())},t)[this.passedElement.element.type]()},e.prototype._onBlur=function(e){var t,i=this,n=e.target;if(n&&this.containerOuter.element.contains(n)&&!this._isScrollingOnIe){var r=this._store.activeItems.some((function(e){return e.highlighted}));((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),r&&i.unhighlightAll(),i.hideDropdown(!0))},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.removeFocusState(),(n===i.input.element||n===i.containerOuter.element&&!i._canSearch)&&i.hideDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),i.hideDropdown(!0),r&&i.unhighlightAll())},t)[this.passedElement.element.type]()}else this._isScrollingOnIe=!1,this.input.element.focus()},e.prototype._onFormReset=function(){this._store.dispatch((0,h.resetTo)(this._initialState))},e.prototype._highlightChoice=function(e){var t=this;void 0===e&&(e=null);var i=Array.from(this.dropdown.element.querySelectorAll("[data-choice-selectable]"));if(i.length){var n=e;Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState))).forEach((function(e){e.classList.remove(t.config.classNames.highlightedState),e.setAttribute("aria-selected","false")})),n?this._highlightPosition=i.indexOf(n):(n=i.length>this._highlightPosition?i[this._highlightPosition]:i[i.length-1])||(n=i[0]),n.classList.add(this.config.classNames.highlightedState),n.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(d.EVENTS.highlightChoice,{el:n}),this.dropdown.isActive&&(this.input.setActiveDescendant(n.id),this.containerOuter.setActiveDescendant(n.id))}},e.prototype._addItem=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,r=e.choiceId,s=void 0===r?-1:r,o=e.groupId,a=void 0===o?-1:o,c=e.customProperties,h=void 0===c?{}:c,u=e.placeholder,p=void 0!==u&&u,f=e.keyCode,m=void 0===f?-1:f,v="string"==typeof t?t.trim():t,g=this._store.items,_=n||v,y=s||-1,E=a>=0?this._store.getGroupById(a):null,b=g?g.length+1:1;this.config.prependValue&&(v=this.config.prependValue+v.toString()),this.config.appendValue&&(v+=this.config.appendValue.toString()),this._store.dispatch((0,l.addItem)({value:v,label:_,id:b,choiceId:y,groupId:a,customProperties:h,placeholder:p,keyCode:m})),this._isSelectOneElement&&this.removeActiveItems(b),this.passedElement.triggerEvent(d.EVENTS.addItem,{id:b,value:v,label:_,customProperties:h,groupValue:E&&E.value?E.value:null,keyCode:m})},e.prototype._removeItem=function(e){var t=e.id,i=e.value,n=e.label,r=e.customProperties,s=e.choiceId,o=e.groupId,a=o&&o>=0?this._store.getGroupById(o):null;t&&s&&(this._store.dispatch((0,l.removeItem)(t,s)),this.passedElement.triggerEvent(d.EVENTS.removeItem,{id:t,value:i,label:n,customProperties:r,groupValue:a&&a.value?a.value:null}))},e.prototype._addChoice=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,r=e.isSelected,s=void 0!==r&&r,o=e.isDisabled,c=void 0!==o&&o,l=e.groupId,h=void 0===l?-1:l,u=e.customProperties,d=void 0===u?{}:u,p=e.placeholder,f=void 0!==p&&p,m=e.keyCode,v=void 0===m?-1:m;if(null!=t){var g=this._store.choices,_=n||t,y=g?g.length+1:1,E="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(y);this._store.dispatch((0,a.addChoice)({id:y,groupId:h,elementId:E,value:t,label:_,disabled:c,customProperties:d,placeholder:f,keyCode:v})),s&&this._addItem({value:t,label:_,choiceId:y,customProperties:d,placeholder:f,keyCode:v})}},e.prototype._addGroup=function(e){var t=this,i=e.group,n=e.id,r=e.valueKey,s=void 0===r?"value":r,o=e.labelKey,a=void 0===o?"label":o,l=(0,f.isType)("Object",i)?i.choices:Array.from(i.getElementsByTagName("OPTION")),h=n||Math.floor((new Date).valueOf()*Math.random()),u=!!i.disabled&&i.disabled;l?(this._store.dispatch((0,c.addGroup)({value:i.label,id:h,active:!0,disabled:u})),l.forEach((function(e){var i=e.disabled||e.parentNode&&e.parentNode.disabled;t._addChoice({value:e[s],label:(0,f.isType)("Object",e)?e[a]:e.innerHTML,isSelected:e.selected,isDisabled:i,groupId:h,customProperties:e.customProperties,placeholder:e.placeholder})}))):this._store.dispatch((0,c.addGroup)({value:i.label,id:i.id,active:!1,disabled:i.disabled}))},e.prototype._getTemplate=function(e){for(var t,i=[],r=1;r0?this.element.scrollTop+o-r:e.offsetTop;requestAnimationFrame((function(){i._animateScroll(a,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t,r=n>1?n:1;this.element.scrollTop=e+r},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t,r=n>1?n:1;this.element.scrollTop=e-r},e.prototype._animateScroll=function(e,t){var i=this,r=n.SCROLLING_SPEED,s=this.element.scrollTop,o=!1;t>0?(this._scrollDown(s,r,e),se&&(o=!0)),o&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}();t.default=r},730:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=i(799),r=function(){function e(e){var t=e.element,i=e.classNames;if(this.element=t,this.classNames=i,!(t instanceof HTMLInputElement||t instanceof HTMLSelectElement))throw new TypeError("Invalid element passed");this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){this.element.classList.add(this.classNames.input),this.element.hidden=!0,this.element.tabIndex=-1;var e=this.element.getAttribute("style");e&&this.element.setAttribute("data-choice-orig-style",e),this.element.setAttribute("data-choice","active")},e.prototype.reveal=function(){this.element.classList.remove(this.classNames.input),this.element.hidden=!1,this.element.removeAttribute("tabindex");var e=this.element.getAttribute("data-choice-orig-style");e?(this.element.removeAttribute("data-choice-orig-style"),this.element.setAttribute("style",e)):this.element.removeAttribute("style"),this.element.removeAttribute("data-choice"),this.element.value=this.element.value},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){(0,n.dispatchEvent)(this.element,e,t)},e}();t.default=r},541:function(e,t,i){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,r=t.delimiter,s=e.call(this,{element:i,classNames:n})||this;return s.delimiter=r,s}return r(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),t}(s(i(730)).default);t.default=o},982:function(e,t,i){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,r=t.template,s=e.call(this,{element:i,classNames:n})||this;return s.template=r,s}return r(t,e),Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optionGroups",{get:function(){return Array.from(this.element.getElementsByTagName("OPTGROUP"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return Array.from(this.element.options)},set:function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){return n=e,r=t.template(n),void i.appendChild(r);var n,r})),this.appendDocFragment(i)},enumerable:!1,configurable:!0}),t.prototype.appendDocFragment=function(e){this.element.innerHTML="",this.element.appendChild(e)},t}(s(i(730)).default);t.default=o},883:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.SCROLLING_SPEED=t.SELECT_MULTIPLE_TYPE=t.SELECT_ONE_TYPE=t.TEXT_TYPE=t.KEY_CODES=t.ACTION_TYPES=t.EVENTS=void 0,t.EVENTS={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},t.ACTION_TYPES={ADD_CHOICE:"ADD_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM",CLEAR_ALL:"CLEAR_ALL",RESET_TO:"RESET_TO",SET_IS_LOADING:"SET_IS_LOADING"},t.KEY_CODES={BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},t.TEXT_TYPE="text",t.SELECT_ONE_TYPE="select-one",t.SELECT_MULTIPLE_TYPE="select-multiple",t.SCROLLING_SPEED=4},789:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CONFIG=t.DEFAULT_CLASSNAMES=void 0;var n=i(799);t.DEFAULT_CLASSNAMES={containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemChoice:"choices__item--choice",placeholder:"choices__placeholder",group:"choices__group",groupHeading:"choices__heading",button:"choices__button",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",selectedState:"is-selected",flippedState:"is-flipped",loadingState:"is-loading",noResults:"has-no-results",noChoices:"has-no-choices"},t.DEFAULT_CONFIG={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,addItems:!0,addItemFilter:null,removeItems:!0,removeItemButton:!1,editItems:!1,allowHTML:!0,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:n.sortByAlpha,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat((0,n.sanitise)(e),'"')},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:t.DEFAULT_CLASSNAMES}},18:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},978:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},948:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},359:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},285:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},533:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},187:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),r(i(18),t),r(i(978),t),r(i(948),t),r(i(359),t),r(i(285),t),r(i(533),t),r(i(287),t),r(i(132),t),r(i(837),t),r(i(598),t),r(i(369),t),r(i(37),t),r(i(47),t),r(i(923),t),r(i(876),t)},287:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},132:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},837:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},598:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},37:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},369:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},47:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},923:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},876:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},799:function(e,t){var i;Object.defineProperty(t,"__esModule",{value:!0}),t.parseCustomProperties=t.diff=t.cloneObject=t.existsInArray=t.dispatchEvent=t.sortByScore=t.sortByAlpha=t.strToEl=t.sanitise=t.isScrolledIntoView=t.getAdjacentEl=t.wrap=t.isType=t.getType=t.generateId=t.generateChars=t.getRandomNumber=void 0,t.getRandomNumber=function(e,t){return Math.floor(Math.random()*(t-e)+e)},t.generateChars=function(e){return Array.from({length:e},(function(){return(0,t.getRandomNumber)(0,36).toString(36)})).join("")},t.generateId=function(e,i){var n=e.id||e.name&&"".concat(e.name,"-").concat((0,t.generateChars)(2))||(0,t.generateChars)(4);return n=n.replace(/(:|\.|\[|\]|,)/g,""),"".concat(i,"-").concat(n)},t.getType=function(e){return Object.prototype.toString.call(e).slice(8,-1)},t.isType=function(e,i){return null!=i&&(0,t.getType)(i)===e},t.wrap=function(e,t){return void 0===t&&(t=document.createElement("div")),e.parentNode&&(e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t)),t.appendChild(e)},t.getAdjacentEl=function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),r=e[n];r;){if(r.matches(t))return r;r=r[n]}return r},t.isScrolledIntoView=function(e,t,i){return void 0===i&&(i=1),!!e&&(i>0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop)},t.sanitise=function(e){return"string"!=typeof e?e:e.replace(/&/g,"&").replace(/>/g,">").replace(/-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(o.choiceId),10)&&(t.selected=!0),t})):e;case"REMOVE_ITEM":var a=n;return a.choiceId&&a.choiceId>-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(a.choiceId),10)&&(t.selected=!1),t})):e;case"FILTER_CHOICES":var c=n;return e.map((function(e){var t=e;return t.active=c.results.some((function(e){var i=e.item,n=e.score;return i.id===t.id&&(t.score=n,!0)})),t}));case"ACTIVATE_CHOICES":var l=n;return e.map((function(e){var t=e;return t.active=l.active,t}));case"CLEAR_CHOICES":return t.defaultState;default:return e}}},871:function(e,t){var i=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,r=0,s=t.length;r0?"treeitem":"option"),Object.assign(E.dataset,{choice:"",id:d,value:p,selectText:i}),g?(E.classList.add(h),E.dataset.choiceDisabled="",E.setAttribute("aria-disabled","true")):(E.classList.add(c),E.dataset.choiceSelectable=""),E},input:function(e,t){var i=e.classNames,n=i.input,r=i.inputCloned,s=Object.assign(document.createElement("input"),{type:"search",name:"search_terms",className:"".concat(n," ").concat(r),autocomplete:"off",autocapitalize:"off",spellcheck:!1});return s.setAttribute("role","textbox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-label",t),s},dropdown:function(e){var t=e.classNames,i=t.list,n=t.listDropdown,r=document.createElement("div");return r.classList.add(i,n),r.setAttribute("aria-expanded","false"),r},notice:function(e,t,i){var n,r=e.allowHTML,s=e.classNames,o=s.item,a=s.itemChoice,c=s.noResults,l=s.noChoices;void 0===i&&(i="");var h=[o,a];return"no-choices"===i?h.push(l):"no-results"===i&&h.push(c),Object.assign(document.createElement("div"),((n={})[r?"innerHTML":"innerText"]=t,n.className=h.join(" "),n))},option:function(e){var t=e.label,i=e.value,n=e.customProperties,r=e.active,s=e.disabled,o=new Option(t,i,!1,r);return n&&(o.dataset.customProperties="".concat(n)),o.disabled=!!s,o}};t.default=i},996:function(e){var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function r(e,t,i){return e.concat(t).map((function(e){return n(e,i)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,i,c){(c=c||{}).arrayMerge=c.arrayMerge||r,c.isMergeableObject=c.isMergeableObject||t,c.cloneUnlessOtherwiseSpecified=n;var l=Array.isArray(i);return l===Array.isArray(e)?l?c.arrayMerge(e,i,c):function(e,t,i){var r={};return i.isMergeableObject(e)&&s(e).forEach((function(t){r[t]=n(e[t],i)})),s(t).forEach((function(s){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(o(e,s)&&i.isMergeableObject(t[s])?r[s]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(s,i)(e[s],t[s],i):r[s]=n(t[s],i))})),r}(e,i,c):n(i,c)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return a(e,i,t)}),{})};var c=a;e.exports=c},221:function(e,t,i){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===l(e)}function r(e){return"string"==typeof e}function s(e){return"number"==typeof e}function o(e){return"object"==typeof e}function a(e){return null!=e}function c(e){return!e.trim().length}function l(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}i.r(t),i.d(t,{default:function(){return R}});const h=Object.prototype.hasOwnProperty;class u{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=d(e);t+=i.weight,this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function d(e){let t=null,i=null,s=null,o=1,a=null;if(r(e)||n(e))s=e,t=p(e),i=f(e);else{if(!h.call(e,"name"))throw new Error("Missing name property in key");const n=e.name;if(s=n,h.call(e,"weight")&&(o=e.weight,o<=0))throw new Error((e=>`Property 'weight' in key '${e}' must be a positive integer`)(n));t=p(n),i=f(n),a=e.getFn}return{path:t,id:i,weight:o,src:s,getFn:a}}function p(e){return n(e)?e:e.split(".")}function f(e){return n(e)?e.join("."):e}var m={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx{if(a(e))if(t[u]){const d=e[t[u]];if(!a(d))return;if(u===t.length-1&&(r(d)||s(d)||function(e){return!0===e||!1===e||function(e){return o(e)&&null!==e}(e)&&"[object Boolean]"==l(e)}(d)))i.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(d));else if(n(d)){c=!0;for(let e=0,i=d.length;e{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,r(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();r(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t{let o=t.getFn?t.getFn(e):this.getFn(e,t.path);if(a(o))if(n(o)){let e=[];const t=[{nestedArrIndex:-1,value:o}];for(;t.length;){const{nestedArrIndex:i,value:s}=t.pop();if(a(s))if(r(s)&&!c(s)){let t={v:s,i:i,n:this.norm.get(s)};e.push(t)}else n(s)&&s.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[s]=e}else if(r(o)&&!c(o)){let e={v:o,n:this.norm.get(o)};i.$[s]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function _(e,t,{getFn:i=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const r=new g({getFn:i,fieldNormWeight:n});return r.setKeys(e.map(d)),r.setSources(t),r.create(),r}function y(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:r=m.distance,ignoreLocation:s=m.ignoreLocation}={}){const o=t/e.length;if(s)return o;const a=Math.abs(n-i);return r?o+a/r:a?1:o}const E=32;function b(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:b(e),startIndex:t})},h=this.pattern.length;if(h>E){let e=0;const t=h%E,i=h-t;for(;e{const{isMatch:f,score:v,indices:g}=function(e,t,i,{location:n=m.location,distance:r=m.distance,threshold:s=m.threshold,findAllMatches:o=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,includeMatches:c=m.includeMatches,ignoreLocation:l=m.ignoreLocation}={}){if(t.length>E)throw new Error("Pattern length exceeds max of 32.");const h=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=s,f=d;const v=a>1||c,g=v?Array(u):[];let _;for(;(_=e.indexOf(t,f))>-1;){let e=y(t,{currentLocation:_,expectedLocation:d,distance:r,ignoreLocation:l});if(p=Math.min(e,p),f=_+h,v){let e=0;for(;e=c;s-=1){let o=s-1,a=i[e.charAt(o)];if(v&&(g[o]=+!!a),_[s]=(_[s+1]<<1|1)&a,n&&(_[s]|=(b[s+1]|b[s])<<1|1|b[s+1]),_[s]&I&&(S=y(t,{errors:n,currentLocation:o,expectedLocation:d,distance:r,ignoreLocation:l}),S<=p)){if(p=S,f=o,f<=d)break;c=Math.max(1,2*d-f)}}if(y(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:r,ignoreLocation:l})>p)break;b=_}const C={isMatch:f>=0,score:Math.max(.001,S)};if(v){const e=function(e=[],t=m.minMatchCharLength){let i=[],n=-1,r=-1,s=0;for(let o=e.length;s=t&&i.push([n,r]),n=-1)}return e[s-1]&&s-n>=t&&i.push([n,s-1]),i}(g,a);e.length?c&&(C.indices=e):C.isMatch=!1}return C}(e,t,d,{location:n+p,distance:r,threshold:s,findAllMatches:o,minMatchCharLength:a,includeMatches:i,ignoreLocation:c});f&&(u=!0),h+=v,f&&g&&(l=[...l,...g])}));let d={isMatch:u,score:u?h/this.chunks.length:1};return u&&i&&(d.indices=l),d}}class O{constructor(e){this.pattern=e}static isMultiMatch(e){return I(e,this.multiRegex)}static isSingleMatch(e){return I(e,this.singleRegex)}search(){}}function I(e,t){const i=e.match(t);return i?i[1]:null}class C extends O{constructor(e,{location:t=m.location,threshold:i=m.threshold,distance:n=m.distance,includeMatches:r=m.includeMatches,findAllMatches:s=m.findAllMatches,minMatchCharLength:o=m.minMatchCharLength,isCaseSensitive:a=m.isCaseSensitive,ignoreLocation:c=m.ignoreLocation}={}){super(e),this._bitapSearch=new S(e,{location:t,threshold:i,distance:n,includeMatches:r,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class T extends O{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,i=0;const n=[],r=this.pattern.length;for(;(t=e.indexOf(this.pattern,i))>-1;)i=t+r,n.push([t,i-1]);const s=!!n.length;return{isMatch:s,score:s?0:1,indices:n}}}const L=[class extends O{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},T,class extends O{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},C],w=L.length,A=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,M=new Set([C.type,T.type]);const P=[];function x(e,t){for(let i=0,n=P.length;i!(!e.$and&&!e.$or),j=e=>({[N]:Object.keys(e).map((t=>({[t]:e[t]})))});function F(e,t,{auto:i=!0}={}){const s=e=>{let a=Object.keys(e);const c=(e=>!!e.$path)(e);if(!c&&a.length>1&&!D(e))return s(j(e));if((e=>!n(e)&&o(e)&&!D(e))(e)){const n=c?e.$path:a[0],s=c?e.$val:e[n];if(!r(s))throw new Error((e=>`Invalid value for key ${e}`)(n));const o={keyId:f(n),pattern:s};return i&&(o.searcher=x(s,t)),o}let l={children:[],operator:a[0]};return a.forEach((t=>{const i=e[t];n(i)&&i.forEach((e=>{l.children.push(s(e))}))})),l};return D(e)||(e=j(e)),s(e)}function k(e,t){const i=e.matches;t.matches=[],a(i)&&i.forEach((e=>{if(!a(e.indices)||!e.indices.length)return;const{indices:i,value:n}=e;let r={indices:i,value:n};e.key&&(r.key=e.key.src),e.idx>-1&&(r.refIndex=e.idx),t.matches.push(r)}))}function K(e,t){t.score=e.score}class R{constructor(e,t={},i){this.options={...m,...t},this.options.useExtendedSearch,this._keyStore=new u(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof g))throw new Error("Incorrect 'index' type");this._myIndex=t||_(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){a(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=(()=>!1)){const t=[];for(let i=0,n=this._docs.length;i{let i=1;e.matches.forEach((({key:e,norm:n,score:r})=>{const s=e?e.weight:null;i*=Math.pow(0===r&&s?Number.EPSILON:r,(s||1)*(t?1:n))})),e.score=i}))}(l,{ignoreFieldNorm:c}),o&&l.sort(a),s(t)&&t>-1&&(l=l.slice(0,t)),function(e,t,{includeMatches:i=m.includeMatches,includeScore:n=m.includeScore}={}){const r=[];return i&&r.push(k),n&&r.push(K),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return r.length&&r.forEach((t=>{t(e,n)})),n}))}(l,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=x(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i:i,n:r})=>{if(!a(e))return;const{isMatch:s,score:o,indices:c}=t.searchIn(e);s&&n.push({item:e,idx:i,matches:[{score:o,value:e,norm:r,indices:c}]})})),n}_searchLogical(e){const t=F(e,this.options),i=(e,t,n)=>{if(!e.children){const{keyId:i,searcher:r}=e,s=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:r});return s&&s.length?[{idx:n,item:t,matches:s}]:[]}const r=[];for(let s=0,o=e.children.length;s{if(a(e)){let o=i(t,e,n);o.length&&(r[n]||(r[n]={idx:n,item:e,matches:[]},s.push(r[n])),o.forEach((({matches:e})=>{r[n].matches.push(...e)})))}})),s}_searchObjectList(e){const t=x(e,this.options),{keys:i,records:n}=this._myIndex,r=[];return n.forEach((({$:e,i:n})=>{if(!a(e))return;let s=[];i.forEach(((i,n)=>{s.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),s.length&&r.push({idx:n,item:e,matches:s})})),r}_findMatches({key:e,value:t,searcher:i}){if(!a(t))return[];let r=[];if(n(t))t.forEach((({v:t,i:n,n:s})=>{if(!a(t))return;const{isMatch:o,score:c,indices:l}=i.searchIn(t);o&&r.push({score:c,key:e,value:t,idx:n,norm:s,indices:l})}));else{const{v:n,n:s}=t,{isMatch:o,score:a,indices:c}=i.searchIn(n);o&&r.push({score:a,key:e,value:n,norm:s,indices:c})}return r}}R.version="6.6.2",R.createIndex=_,R.parseIndex=function(e,{getFn:t=m.getFn,fieldNormWeight:i=m.fieldNormWeight}={}){const{keys:n,records:r}=e,s=new g({getFn:t,fieldNormWeight:i});return s.setKeys(n),s.setIndexRecords(r),s},R.config=m,R.parseQuery=F,function(...e){P.push(...e)}(class{constructor(e,{isCaseSensitive:t=m.isCaseSensitive,includeMatches:i=m.includeMatches,minMatchCharLength:n=m.minMatchCharLength,ignoreLocation:r=m.ignoreLocation,findAllMatches:s=m.findAllMatches,location:o=m.location,threshold:a=m.threshold,distance:c=m.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:i,minMatchCharLength:n,findAllMatches:s,ignoreLocation:r,location:o,threshold:a,distance:c},this.pattern=t?e:e.toLowerCase(),this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(A).filter((e=>e&&!!e.trim())),n=[];for(let e=0,r=i.length;e Date: Tue, 7 Jan 2025 16:12:57 +0530 Subject: [PATCH 04/12] Rebased and fixed biome lint issue --- hypha/static_src/javascript/choices-select.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hypha/static_src/javascript/choices-select.js b/hypha/static_src/javascript/choices-select.js index 439b184adf..e4edc687a5 100644 --- a/hypha/static_src/javascript/choices-select.js +++ b/hypha/static_src/javascript/choices-select.js @@ -1,10 +1,11 @@ -const selectElements = document.querySelectorAll('.js-choices'); +const selectElements = document.querySelectorAll(".js-choices"); -selectElements.forEach(selectElement => { - // eslint-disable-next-line no-undef - new Choices(selectElement, { - shouldSort: false, - allowHTML: true, - removeItemButton: true, - }); +selectElements.forEach((selectElement) => { + // eslint-disable-next-line no-undef + // biome-ignore lint: undeclared + new Choices(selectElement, { + shouldSort: false, + allowHTML: true, + removeItemButton: true, + }); }); From bcc1879fe8386eca518142dc3e0585ee2246a8c6 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Tue, 7 Jan 2025 21:51:29 +0530 Subject: [PATCH 05/12] Replace select2 from submissions and use choices js --- .../dashboard/reviewer_dashboard.html | 2 + hypha/apply/funds/forms.py | 6 +- hypha/apply/funds/tables.py | 63 ++++++------------- .../funds/base_submissions_table.html | 2 + .../includes/update_meta_terms_form.html | 2 +- hypha/apply/funds/templates/funds/rounds.html | 2 + hypha/apply/funds/widgets.py | 25 +------- hypha/urls.py | 1 - 8 files changed, 29 insertions(+), 74 deletions(-) diff --git a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html index 33388fab72..3f4d20d916 100644 --- a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html +++ b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html @@ -93,4 +93,6 @@

{% block extra_js %} {{ filter.form.media.js }} + + {% endblock %} diff --git a/hypha/apply/funds/forms.py b/hypha/apply/funds/forms.py index cdfc781206..4d5af23571 100644 --- a/hypha/apply/funds/forms.py +++ b/hypha/apply/funds/forms.py @@ -21,7 +21,7 @@ ) from .permissions import can_change_external_reviewers from .utils import model_form_initial, render_icon -from .widgets import MetaTermSelect2Widget, Select2MultiCheckboxesWidget +from .widgets import MetaTermWidget, MultiCheckboxesWidget class ApplicationSubmissionModelForm(forms.ModelForm): @@ -234,7 +234,7 @@ class BatchUpdateReviewersForm(forms.Form): ) external_reviewers = forms.ModelMultipleChoiceField( queryset=User.objects.reviewers().only("pk", "full_name"), - widget=Select2MultiCheckboxesWidget(attrs={"data-placeholder": "Select..."}), + widget=MultiCheckboxesWidget(attrs={"data-placeholder": "Select..."}), label=_("External Reviewers"), required=False, ) @@ -398,7 +398,7 @@ def label_from_instance(self, obj): class UpdateMetaTermsForm(ApplicationSubmissionModelForm): meta_terms = GroupedModelMultipleChoiceField( queryset=None, # updated in init method - widget=MetaTermSelect2Widget(attrs={"data-placeholder": "Select..."}), + widget=MetaTermWidget(attrs={"data-placeholder": "Select..."}), label=_("Meta terms"), choices_groupby="get_parent", required=False, diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py index db8c92a604..21da0286ba 100644 --- a/hypha/apply/funds/tables.py +++ b/hypha/apply/funds/tables.py @@ -22,7 +22,7 @@ from hypha.images.models import CustomImage from .models import ApplicationSubmission, Round, ScreeningStatus -from .widgets import MultiCheckboxesWidget, Select2MultiCheckboxesWidget +from .widgets import MultiCheckboxesWidget from .workflows import STATUSES, get_review_active_statuses User = get_user_model() @@ -290,15 +290,6 @@ def get_meta_terms_from_dataset(dataset): ).distinct() -class Select2CheckboxWidgetMixin(filters.Filter): - def __init__(self, *args, **kwargs): - label = kwargs.get("label") - kwargs.setdefault( - "widget", Select2MultiCheckboxesWidget(attrs={"data-placeholder": label}) - ) - super().__init__(*args, **kwargs) - - class MultiCheckboxesMixin(filters.Filter): def __init__(self, *args, **kwargs): label = kwargs.get("label") @@ -308,29 +299,17 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) -class Select2MultipleChoiceFilter( - Select2CheckboxWidgetMixin, filters.MultipleChoiceFilter -): - pass - - class MultipleChoiceFilter(MultiCheckboxesMixin, filters.MultipleChoiceFilter): pass -class Select2ModelMultipleChoiceFilter( - Select2MultipleChoiceFilter, filters.ModelMultipleChoiceFilter -): - pass - - class ModelMultipleChoiceFilter( MultipleChoiceFilter, filters.ModelMultipleChoiceFilter ): pass -class StatusMultipleChoiceFilter(Select2MultipleChoiceFilter): +class StatusMultipleChoiceFilter(MultipleChoiceFilter): def __init__(self, limit_to, *args, **kwargs): choices = [ (slugify(name), name) @@ -356,25 +335,21 @@ def get_filter_predicate(self, v): class SubmissionFilter(filters.FilterSet): - fund = Select2ModelMultipleChoiceFilter( + fund = ModelMultipleChoiceFilter( field_name="page", queryset=get_used_funds, label=_("Funds") ) - round = Select2ModelMultipleChoiceFilter( - queryset=get_used_rounds, label=_("Rounds") - ) - lead = Select2ModelMultipleChoiceFilter(queryset=get_round_leads, label=_("Leads")) - screening_statuses = Select2ModelMultipleChoiceFilter( + round = ModelMultipleChoiceFilter(queryset=get_used_rounds, label=_("Rounds")) + lead = ModelMultipleChoiceFilter(queryset=get_round_leads, label=_("Leads")) + screening_statuses = ModelMultipleChoiceFilter( queryset=get_screening_statuses, label=_("Screening"), null_label=_("No Status") ) - reviewers = Select2ModelMultipleChoiceFilter( + reviewers = ModelMultipleChoiceFilter( queryset=get_all_reviewers, label=_("Reviewers") ) - category_options = Select2MultipleChoiceFilter( + category_options = MultipleChoiceFilter( choices=[], label=_("Category"), method="filter_category_options" ) - meta_terms = Select2ModelMultipleChoiceFilter( - queryset=get_meta_terms, label=_("Terms") - ) + meta_terms = ModelMultipleChoiceFilter(queryset=get_meta_terms, label=_("Terms")) class Meta: model = ApplicationSubmission @@ -474,10 +449,8 @@ def filter_archived(self, queryset, name, value): class SubmissionDashboardFilter(filters.FilterSet): - round = Select2ModelMultipleChoiceFilter( - queryset=get_used_rounds, label=_("Rounds") - ) - fund = Select2ModelMultipleChoiceFilter( + round = ModelMultipleChoiceFilter(queryset=get_used_rounds, label=_("Rounds")) + fund = ModelMultipleChoiceFilter( field_name="page", queryset=get_used_funds, label=_("Funds") ) @@ -547,7 +520,7 @@ def get_column_class_names(self, classes_set, bound_column): return classes_set -class ActiveRoundFilter(Select2MultipleChoiceFilter): +class ActiveRoundFilter(MultipleChoiceFilter): def __init__(self, *args, **kwargs): super().__init__( self, @@ -567,7 +540,7 @@ def filter(self, qs, value): return qs.inactive() -class OpenRoundFilter(Select2MultipleChoiceFilter): +class OpenRoundFilter(MultipleChoiceFilter): def __init__(self, *args, **kwargs): super().__init__( self, @@ -590,8 +563,8 @@ def filter(self, qs, value): class RoundsFilter(filters.FilterSet): - fund = Select2ModelMultipleChoiceFilter(queryset=get_used_funds, label=_("Funds")) - lead = Select2ModelMultipleChoiceFilter(queryset=get_round_leads, label=_("Leads")) + fund = ModelMultipleChoiceFilter(queryset=get_used_funds, label=_("Funds")) + lead = ModelMultipleChoiceFilter(queryset=get_round_leads, label=_("Leads")) active = ActiveRoundFilter(label=_("Active")) round_state = OpenRoundFilter(label=_("Open")) @@ -620,17 +593,17 @@ class ReviewerLeaderboardFilter(filters.FilterSet): field_name="full_name", lookup_expr="icontains", widget=forms.HiddenInput ) - reviewer = Select2ModelMultipleChoiceFilter( + reviewer = ModelMultipleChoiceFilter( field_name="pk", label=_("Reviewers"), queryset=get_all_reviewers, ) - funds = Select2ModelMultipleChoiceFilter( + funds = ModelMultipleChoiceFilter( field_name="applicationsubmission__page", label=_("Funds"), queryset=get_used_funds, ) - rounds = Select2ModelMultipleChoiceFilter( + rounds = ModelMultipleChoiceFilter( field_name="applicationsubmission__round", label=_("Rounds"), queryset=get_used_rounds, diff --git a/hypha/apply/funds/templates/funds/base_submissions_table.html b/hypha/apply/funds/templates/funds/base_submissions_table.html index a14d32980e..6dc67b2905 100644 --- a/hypha/apply/funds/templates/funds/base_submissions_table.html +++ b/hypha/apply/funds/templates/funds/base_submissions_table.html @@ -20,4 +20,6 @@ + + {% endblock %} diff --git a/hypha/apply/funds/templates/funds/includes/update_meta_terms_form.html b/hypha/apply/funds/templates/funds/includes/update_meta_terms_form.html index 4cd0446730..ed82697022 100644 --- a/hypha/apply/funds/templates/funds/includes/update_meta_terms_form.html +++ b/hypha/apply/funds/templates/funds/includes/update_meta_terms_form.html @@ -8,7 +8,7 @@ {% comment %} Do this here as the select elements for different roles are dynamically generated. {% endcomment %} import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}"; - const selectElements = document.querySelectorAll('#metaterms_form select'); + const selectElements = document.querySelectorAll('#id_meta_terms'); // add choices to all select elements selectElements.forEach((selectElement) => { diff --git a/hypha/apply/funds/templates/funds/rounds.html b/hypha/apply/funds/templates/funds/rounds.html index 12eab4d8bb..290dc61e6f 100644 --- a/hypha/apply/funds/templates/funds/rounds.html +++ b/hypha/apply/funds/templates/funds/rounds.html @@ -23,4 +23,6 @@ {% block extra_js %} {{ filter.form.media.js }} + + {% endblock %} diff --git a/hypha/apply/funds/widgets.py b/hypha/apply/funds/widgets.py index 6c7fcafc49..2d26950356 100644 --- a/hypha/apply/funds/widgets.py +++ b/hypha/apply/funds/widgets.py @@ -1,27 +1,4 @@ from django import forms -from django.templatetags.static import static -from django_select2.forms import Select2MultipleWidget - - -class Select2MultiCheckboxesWidget(Select2MultipleWidget): - class Media: - js = ( - static("js/select2.multi-checkboxes.js"), - static("js/django_select2-checkboxes.js"), - ) - - def __init__(self, *args, **kwargs): - attrs = kwargs.get("attrs", {}) - attrs.setdefault("data-placeholder", "items") - kwargs["attrs"] = attrs - super().__init__(*args, **kwargs) - - def build_attrs(self, *args, **kwargs): - attrs = super().build_attrs(*args, **kwargs) - attrs["class"] = attrs["class"].replace( - "django-select2", "django-select2-checkboxes" - ) - return attrs class MultiCheckboxesWidget(forms.SelectMultiple): @@ -38,7 +15,7 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) -class MetaTermSelect2Widget(Select2MultipleWidget): +class MetaTermWidget(forms.SelectMultiple): def create_option( self, name, value, label, selected, index, subindex=None, attrs=None ): diff --git a/hypha/urls.py b/hypha/urls.py index 996f461805..13e28dcf7f 100644 --- a/hypha/urls.py +++ b/hypha/urls.py @@ -43,7 +43,6 @@ path("", include(tf_urls, "two_factor")), path("", include((user_urls, "users"))), path("tinymce/", include("tinymce.urls")), - path("select2/", include("django_select2.urls")), ] if settings.HIJACK_ENABLE: From 11d07b3d8b6bbb913a5a930048682f0a13b711c8 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 9 Jan 2025 12:33:34 +0530 Subject: [PATCH 06/12] Removed django select2 --- .../static/js/django_select2-checkboxes.js | 34 ----- .../static/js/select2.multi-checkboxes.js | 124 ------------------ .../includes/table_filter_and_search.html | 2 +- hypha/settings/django.py | 1 - .../javascript/submission-filters.js | 88 ------------- .../static_src/sass/abstracts/_variables.scss | 3 - hypha/static_src/sass/components/_form.scss | 15 --- .../static_src/sass/components/_select2.scss | 99 -------------- hypha/static_src/sass/main.scss | 1 - pyproject.toml | 1 - requirements/dev.txt | 6 - requirements/prod.txt | 6 - uv.lock | 15 --- 13 files changed, 1 insertion(+), 394 deletions(-) delete mode 100644 hypha/apply/dashboard/static/js/django_select2-checkboxes.js delete mode 100644 hypha/apply/dashboard/static/js/select2.multi-checkboxes.js delete mode 100644 hypha/static_src/sass/components/_select2.scss diff --git a/hypha/apply/dashboard/static/js/django_select2-checkboxes.js b/hypha/apply/dashboard/static/js/django_select2-checkboxes.js deleted file mode 100644 index 376d189207..0000000000 --- a/hypha/apply/dashboard/static/js/django_select2-checkboxes.js +++ /dev/null @@ -1,34 +0,0 @@ -(function ($) { - $.fn.select2.amd.require( - ["select2/multi-checkboxes/selection", "select2/multi-checkboxes/results"], - function (SelectionAdapter, ResultsAdapter) { - $(function () { - $(".django-select2-checkboxes").each(function (i, element) { - var $element = $(element); - $element.select2({ - placeholder: $element.data("placeholder"), - closeOnSelect: false, - templateSelection: function (data) { - let filterType = $element.data("placeholder"); - - if (!data.selected.length) { - return filterType; - } else if (data.selected.length == data.all.length) { - return "All " + filterType + " selected"; - } - return ( - data.selected.length + - " of " + - data.all.length + - " " + - filterType - ); - }, - selectionAdapter: SelectionAdapter, - returnesultsAdapter: ResultsAdapter, - }); - }); - }); - } - ); -})(this.jQuery); diff --git a/hypha/apply/dashboard/static/js/select2.multi-checkboxes.js b/hypha/apply/dashboard/static/js/select2.multi-checkboxes.js deleted file mode 100644 index 6821ab8b30..0000000000 --- a/hypha/apply/dashboard/static/js/select2.multi-checkboxes.js +++ /dev/null @@ -1,124 +0,0 @@ -/** - * jQuery Select2 Multi checkboxes - * - allow to select multi values via normal dropdown control - * - * author : wasikuss - * repo : https://github.com/wasikuss/select2-multi-checkboxes/tree/amd - * inspired by : https://github.com/select2/select2/issues/411 - * License : MIT - */ - -/* global define jQuery */ -(function (factory) { - if (typeof define === "function" && define.amd) { - define(["jquery"], factory); - } else { - // Browser globals - factory(jQuery); - } -})(function (jQuery) { - if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) { - define = jQuery.fn.select2.amd.define; - } - var define; - - /* global define */ - define("select2/multi-checkboxes/dropdown", [ - "select2/utils", - "select2/dropdown", - "select2/dropdown/search", - "select2/dropdown/attachBody", - ], function (Utils, Dropdown, DropdownSearch, AttachBody) { - return Utils.Decorate(Utils.Decorate(Dropdown, DropdownSearch), AttachBody); - }); - - /* global define */ - define("select2/multi-checkboxes/results", [ - "jquery", - "select2/utils", - "select2/results", - ], function ($, Utils, _Results) { - function Results() { - Results.__super__.constructor.apply(this, arguments); - } - Utils.Extend(Results, _Results); - - Results.prototype.highlightFirstItem = function () { - this.ensureHighlightVisible(); - }; - - Results.prototype.bind = function (container) { - container.on("open", function () { - var $options = this.$results.find( - ".select2-results__option[aria-selected]" - ); - var $selected = $options.filter("[aria-selected=true]"); - var $optionToScrollTo = ( - $selected.length > 0 ? $selected : $selected - ).first(); - $optionToScrollTo.trigger("mouseenter"); - }); - Results.__super__.bind.apply(this, arguments); - }; - - Results.prototype.template = function (result, container) { - var template = this.options.get("templateResult"); - var escapeMarkup = this.options.get("escapeMarkup"); - - var content = template(result, container); - $(container).addClass("multi-checkboxes_wrap"); - - if (content == null) { - container.style.display = "none"; - } else if (typeof content === "string") { - container.innerHTML = escapeMarkup(content); - } else { - $(container).append(content); - } - }; - - return Results; - }); - - /* global define */ - define("select2/multi-checkboxes/selection", [ - "select2/utils", - "select2/selection/multiple", - "select2/selection/placeholder", - "select2/selection/single", - "select2/selection/eventRelay", - ], function ( - Utils, - MultipleSelection, - Placeholder, - SingleSelection, - EventRelay - ) { - var adapter = Utils.Decorate(MultipleSelection, Placeholder); - adapter = Utils.Decorate(adapter, EventRelay); - - adapter.prototype.render = function () { - return SingleSelection.prototype.render.call(this); - }; - - adapter.prototype.update = function (data) { - var $rendered = this.$selection.find(".select2-selection__rendered"); - var formatted = ""; - - if (data.length === 0) { - formatted = this.options.get("placeholder") || ""; - } else { - var itemsData = { - selected: data || [], - all: this.$element.find("option") || [], - }; - formatted = this.display(itemsData, $rendered); - } - - $rendered.empty().append(formatted); - $rendered.prop("title", formatted); - }; - - return adapter; - }); -}); diff --git a/hypha/apply/funds/templates/funds/includes/table_filter_and_search.html b/hypha/apply/funds/templates/funds/includes/table_filter_and_search.html index a7e5ebfd25..73d50ee68a 100644 --- a/hypha/apply/funds/templates/funds/includes/table_filter_and_search.html +++ b/hypha/apply/funds/templates/funds/includes/table_filter_and_search.html @@ -97,7 +97,7 @@

{{ heading }}

-
    +
      {{ filter.form.as_ul }}
    • diff --git a/hypha/settings/django.py b/hypha/settings/django.py index 39e4484b51..f55211726e 100644 --- a/hypha/settings/django.py +++ b/hypha/settings/django.py @@ -48,7 +48,6 @@ "tinymce", "django_tables2", "django_filters", - "django_select2", "hypha.addressfield", "django_nh3", "django_fsm", diff --git a/hypha/static_src/javascript/submission-filters.js b/hypha/static_src/javascript/submission-filters.js index e75deeb3e1..b469bc9a47 100644 --- a/hypha/static_src/javascript/submission-filters.js +++ b/hypha/static_src/javascript/submission-filters.js @@ -21,33 +21,6 @@ $(".js-toggle-filters").text("Clear filters"); } - // Add active class to filters - dropdowns are dynamically appended to the dom, - // so we have to listen for the event higher up - $("body").on("click", ".select2-dropdown", (e) => { - // get the id of the dropdown - let selectId = e.target.parentElement.parentElement.id; - - // find the matching dropdown - let match = $(`.select2-selection[aria-owns="${selectId}"]`); - - if (match.length !== 0) { - // if the dropdown contains a clear class, the filters are active - if ($(match[0]).find("span.select2-selection__clear").length !== 0) { - match[0].classList.add(filterActiveClass); - } else { - match[0].classList.remove(filterActiveClass); - } - } - }); - - // remove active class on clearing select2 - $(".select2").on("select2:unselecting", (e) => { - const dropdown = e.target.nextElementSibling.firstChild.firstChild; - if (dropdown.classList.contains(filterActiveClass)) { - dropdown.classList.remove(filterActiveClass); - } - }); - // toggle filters $toggleButton.on("click", (e) => { // find the nearest filters @@ -95,67 +68,11 @@ } } - /** - * Corrects spacing of dropdowns when toggled on mobile. - * @param {object} element - element to adjust padding for - */ - function mobileFilterPadding(element) { - const expanded = "expanded-filter-element"; - const dropdown = $(element).closest(".select2"); - const openDropdown = $(".select2 ." + expanded); - let dropdownMargin = 0; - - if ( - openDropdown.length > 0 && - !openDropdown.hasClass("select2-container--open") - ) { - // reset the margin of the select we previously worked - openDropdown.removeClass(expanded); - // store the offset to adjust the new select box (elements above the old dropdown unaffected) - if (dropdown.position().top > openDropdown.position().top) { - dropdownMargin = parseInt(openDropdown.css("marginBottom")); - } - openDropdown.css("margin-bottom", "0px"); - } - - if (dropdown.hasClass("select2-container--open")) { - dropdown.addClass(expanded); - const dropdownID = $(element) - .closest(".select2-selection") - .attr("aria-owns"); - // Element which has the height of the select dropdown - const match = $(`ul#${dropdownID}`); - const dropdownHeight = match.outerHeight(true); - - // Element which has the position of the dropdown - const positionalMatch = match.closest(".select2-container"); - - // Pad the bottom of the select box - dropdown.css("margin-bottom", `${dropdownHeight}px`); - - // bump up the dropdown options by height of closed elements - positionalMatch.css( - "top", - positionalMatch.position().top - dropdownMargin - ); - } - } - // clear all filters $clearButton.on("click", () => { const dropdowns = document.querySelectorAll(".form__filters select"); dropdowns.forEach((dropdown) => { $(dropdown).val(null).trigger("change"); - $(".select2-selection.is-active").removeClass(filterActiveClass); - mobileFilterPadding(dropdown); - }); - }); - - $(function () { - // Add active class to select2 checkboxes after page has been filtered - const clearButtons = document.querySelectorAll(".select2-selection__clear"); - clearButtons.forEach((clearButton) => { - clearButton.parentElement.parentElement.classList.add(filterActiveClass); }); }); @@ -168,11 +85,6 @@ // update filter button text $(".js-toggle-filters").text("Filters"); - - // Correct spacing of dropdowns when toggled - $(".select2").on("click", (e) => { - mobileFilterPadding(e.target); - }); } else { $(".filters").addClass("filters-open"); } diff --git a/hypha/static_src/sass/abstracts/_variables.scss b/hypha/static_src/sass/abstracts/_variables.scss index 66b899fba3..7ac3d7e601 100644 --- a/hypha/static_src/sass/abstracts/_variables.scss +++ b/hypha/static_src/sass/abstracts/_variables.scss @@ -103,6 +103,3 @@ $breakpoints: ( "xl" "(min-width: 1280px)", "2xl" "(min-width: 1536px)" ); - -// Filters -$filter-dropdown: ".select2 .select2-selection.select2-selection--single"; diff --git a/hypha/static_src/sass/components/_form.scss b/hypha/static_src/sass/components/_form.scss index 3becca3b31..934c05cb52 100644 --- a/hypha/static_src/sass/components/_form.scss +++ b/hypha/static_src/sass/components/_form.scss @@ -157,21 +157,6 @@ } &__filters { - #{variables.$filter-dropdown} { - border: 0; - border-block-start: 1px solid variables.$color--mid-grey; - - &.is-active { - font-weight: variables.$weight--normal; - background-color: variables.$color--light-blue-90; - border-color: variables.$color--mid-grey; - } - - @include mixins.media-query(lg) { - border: 1px solid variables.$color--mid-grey; - } - } - @include mixins.media-query(lg) { display: flex; align-items: flex-start; diff --git a/hypha/static_src/sass/components/_select2.scss b/hypha/static_src/sass/components/_select2.scss deleted file mode 100644 index a5bcd9357f..0000000000 --- a/hypha/static_src/sass/components/_select2.scss +++ /dev/null @@ -1,99 +0,0 @@ -@use "../abstracts/mixins"; -@use "../abstracts/variables"; - -// stylelint-disable selector-class-pattern - -.select2 { - &-container { - z-index: 99995; // to override any modals - } - - .select2-container--default, - &.select2-container--default { - width: 100% !important; - - .select2-selection--single { - height: variables.$dropdown-height; - border: 1px solid variables.$color--mid-grey; - border-radius: 0; - - &.is-active { - font-weight: variables.$weight--bold; - border-color: variables.$color--primary; - } - - .select2-selection__clear { - display: none; - } - - .select2-selection__rendered { - padding-inline-start: 15px; - padding-inline-end: 30px; - line-height: variables.$dropdown-height; - } - - .select2-selection__arrow { - inset-inline-end: 15px; - height: variables.$dropdown-height; - pointer-events: none; - background: url("./../images/dropdown.svg") transparent - no-repeat 95% center; - background-size: 8px; - width: 8px; - - b[role="presentation"] { - display: none; - } - } - - .select2-selection__placeholder { - color: variables.$color--default; - } - } - } -} - -// stylelint-disable-next-line no-duplicate-selectors -.select2-container { - &--default { - .select2-results__option--highlighted[aria-selected] { - color: variables.$color--default !important; - background-color: variables.$color--light-blue-90 !important; - } - } - - .select2-dropdown { - border: 0; - border-block-end: 1px solid variables.$color--mid-grey; - border-radius: 0; - - @include mixins.media-query(sm) { - border: 1px solid variables.$color--mid-grey; - } - } - - .select2-results__option { - display: flex; - align-items: center; - padding: 6px; - - &::before { - min-width: 20px; - height: 20px; - margin-inline-end: 10px; - background: variables.$color--white; - border: 1px solid variables.$color--mid-grey; - content: ""; - } - - &[aria-selected="true"] { - &::before { - background: url("./../images/tick.svg") - variables.$color--dark-blue center no-repeat; - background-size: 12px; - border: 1px solid variables.$color--dark-blue; - content: ""; - } - } - } -} diff --git a/hypha/static_src/sass/main.scss b/hypha/static_src/sass/main.scss index 9b15709c84..893fc8f29b 100644 --- a/hypha/static_src/sass/main.scss +++ b/hypha/static_src/sass/main.scss @@ -33,7 +33,6 @@ @use "components/reviews-summary"; @use "components/reviews-sidebar"; @use "components/round-block"; -@use "components/select2"; @use "components/status-block"; @use "components/submission-meta"; @use "components/table"; diff --git a/pyproject.toml b/pyproject.toml index f9adf07365..b62fd1a203 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,6 @@ dependencies = [ "django-pagedown~=2.2.1", "django-ratelimit~=4.1.0", "django-role-permissions~=3.2.0", - "django-select2~=8.2.1", "django-slack~=5.19.0", "django-storages~=1.14.2", "django-tables2~=2.7.0", diff --git a/requirements/dev.txt b/requirements/dev.txt index 820428bae9..202a3aa5ee 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -266,9 +266,6 @@ django==4.2.17 \ django-anymail==12.0 \ --hash=sha256:65789c1b0f42915aa0450a4f173f77572d4c552979b748ddd8125af41972ad30 \ --hash=sha256:de8458d713d0f9776da9ed04dcd3a0161be23e9ecbcb49dcf149219700ecd274 -django-appconf==1.0.6 \ - --hash=sha256:c3ae442fba1ff7ec830412c5184b17169a7a1e71cf0864a4c3f93cf4c98a1993 \ - --hash=sha256:cfe87ea827c4ee04b9a70fab90b86d704cb02f2981f89da8423cb0fabf88efbf django-basic-auth-ip-whitelist==0.6.0 \ --hash=sha256:51fbef4d483cfccb15d0c38605fd149fd307314ad8a9308580a6b693b94b3329 \ --hash=sha256:f866c1822861ab6612efb9adec03b12279a82314783aa721c843acfbea04b0b7 @@ -337,9 +334,6 @@ django-ratelimit==4.1.0 \ django-role-permissions==3.2.0 \ --hash=sha256:39c4237e9ed2983c0d7fa38bd7f7c4942a04daac739d5be1921efccb074a0606 \ --hash=sha256:5a89eaa098f3da951b4633e655d5f3188f3d6ec5f0b846a8b1690d094ddc6ea6 -django-select2==8.2.3 \ - --hash=sha256:1de547c89ee2f005f1d461f76db89b440897939fcea894db8ba756b6f1ad36c1 \ - --hash=sha256:a3bc3f3bfb21d73791be1bc0dd8cc674d11e167129d605847c257942e7a2143b django-slack==5.19.0 \ --hash=sha256:4d7b5e6ee229eacc58be6ab43786c14323b52df96e84e6941907315bebef8b32 \ --hash=sha256:cdc6b58ec4e30be6287287c147868f9124cf86c5945ae200c230663c6fa9846c diff --git a/requirements/prod.txt b/requirements/prod.txt index b43858874e..d0b6cbb82b 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -201,9 +201,6 @@ django==4.2.17 \ django-anymail==12.0 \ --hash=sha256:65789c1b0f42915aa0450a4f173f77572d4c552979b748ddd8125af41972ad30 \ --hash=sha256:de8458d713d0f9776da9ed04dcd3a0161be23e9ecbcb49dcf149219700ecd274 -django-appconf==1.0.6 \ - --hash=sha256:c3ae442fba1ff7ec830412c5184b17169a7a1e71cf0864a4c3f93cf4c98a1993 \ - --hash=sha256:cfe87ea827c4ee04b9a70fab90b86d704cb02f2981f89da8423cb0fabf88efbf django-basic-auth-ip-whitelist==0.6.0 \ --hash=sha256:51fbef4d483cfccb15d0c38605fd149fd307314ad8a9308580a6b693b94b3329 \ --hash=sha256:f866c1822861ab6612efb9adec03b12279a82314783aa721c843acfbea04b0b7 @@ -260,9 +257,6 @@ django-ratelimit==4.1.0 \ django-role-permissions==3.2.0 \ --hash=sha256:39c4237e9ed2983c0d7fa38bd7f7c4942a04daac739d5be1921efccb074a0606 \ --hash=sha256:5a89eaa098f3da951b4633e655d5f3188f3d6ec5f0b846a8b1690d094ddc6ea6 -django-select2==8.2.3 \ - --hash=sha256:1de547c89ee2f005f1d461f76db89b440897939fcea894db8ba756b6f1ad36c1 \ - --hash=sha256:a3bc3f3bfb21d73791be1bc0dd8cc674d11e167129d605847c257942e7a2143b django-slack==5.19.0 \ --hash=sha256:4d7b5e6ee229eacc58be6ab43786c14323b52df96e84e6941907315bebef8b32 \ --hash=sha256:cdc6b58ec4e30be6287287c147868f9124cf86c5945ae200c230663c6fa9846c diff --git a/uv.lock b/uv.lock index 89e1c0d500..c928e22f94 100644 --- a/uv.lock +++ b/uv.lock @@ -863,19 +863,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/21/03/baa0d85a7b82bf8fa02f31627d789f39245841975717fd93a973f1a35afc/django_role_permissions-3.2.0-py3-none-any.whl", hash = "sha256:39c4237e9ed2983c0d7fa38bd7f7c4942a04daac739d5be1921efccb074a0606", size = 12782 }, ] -[[package]] -name = "django-select2" -version = "8.2.3" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "django" }, - { name = "django-appconf" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/db/f0/3e1969c99e193bc50fec7c6ef301867acc900f3ec5aca96fe5662ff5049b/django_select2-8.2.3.tar.gz", hash = "sha256:1de547c89ee2f005f1d461f76db89b440897939fcea894db8ba756b6f1ad36c1", size = 13255 } -wheels = [ - { url = "https://files.pythonhosted.org/packages/1e/3a/fb6efff46f3d5257aca87737ee3c8ce2c9de059ab5142913b92181d021e1/django_select2-8.2.3-py3-none-any.whl", hash = "sha256:a3bc3f3bfb21d73791be1bc0dd8cc674d11e167129d605847c257942e7a2143b", size = 15401 }, -] - [[package]] name = "django-slack" version = "5.19.0" @@ -1334,7 +1321,6 @@ dependencies = [ { name = "django-pagedown" }, { name = "django-ratelimit" }, { name = "django-role-permissions" }, - { name = "django-select2" }, { name = "django-slack" }, { name = "django-storages" }, { name = "django-stubs" }, @@ -1432,7 +1418,6 @@ requires-dist = [ { name = "django-pagedown", specifier = "~=2.2.1" }, { name = "django-ratelimit", specifier = "~=4.1.0" }, { name = "django-role-permissions", specifier = "~=3.2.0" }, - { name = "django-select2", specifier = "~=8.2.1" }, { name = "django-slack", specifier = "~=5.19.0" }, { name = "django-storages", specifier = "~=1.14.2" }, { name = "django-stubs", specifier = "~=4.2.0" }, From bd703dd57a03da15a6ff874158cda8f88200a33b Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 9 Jan 2025 12:37:12 +0530 Subject: [PATCH 07/12] Added django-appconf back to requirements --- requirements/dev.txt | 3 +++ requirements/prod.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/requirements/dev.txt b/requirements/dev.txt index 202a3aa5ee..ef2e8d3f64 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -266,6 +266,9 @@ django==4.2.17 \ django-anymail==12.0 \ --hash=sha256:65789c1b0f42915aa0450a4f173f77572d4c552979b748ddd8125af41972ad30 \ --hash=sha256:de8458d713d0f9776da9ed04dcd3a0161be23e9ecbcb49dcf149219700ecd274 +django-appconf==1.0.6 \ + --hash=sha256:c3ae442fba1ff7ec830412c5184b17169a7a1e71cf0864a4c3f93cf4c98a1993 \ + --hash=sha256:cfe87ea827c4ee04b9a70fab90b86d704cb02f2981f89da8423cb0fabf88efbf django-basic-auth-ip-whitelist==0.6.0 \ --hash=sha256:51fbef4d483cfccb15d0c38605fd149fd307314ad8a9308580a6b693b94b3329 \ --hash=sha256:f866c1822861ab6612efb9adec03b12279a82314783aa721c843acfbea04b0b7 diff --git a/requirements/prod.txt b/requirements/prod.txt index d0b6cbb82b..b6c2774658 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -201,6 +201,9 @@ django==4.2.17 \ django-anymail==12.0 \ --hash=sha256:65789c1b0f42915aa0450a4f173f77572d4c552979b748ddd8125af41972ad30 \ --hash=sha256:de8458d713d0f9776da9ed04dcd3a0161be23e9ecbcb49dcf149219700ecd274 +django-appconf==1.0.6 \ + --hash=sha256:c3ae442fba1ff7ec830412c5184b17169a7a1e71cf0864a4c3f93cf4c98a1993 \ + --hash=sha256:cfe87ea827c4ee04b9a70fab90b86d704cb02f2981f89da8423cb0fabf88efbf django-basic-auth-ip-whitelist==0.6.0 \ --hash=sha256:51fbef4d483cfccb15d0c38605fd149fd307314ad8a9308580a6b693b94b3329 \ --hash=sha256:f866c1822861ab6612efb9adec03b12279a82314783aa721c843acfbea04b0b7 From 7415793bc9aec753a53ab84b1fdc9b88319955d6 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 9 Jan 2025 14:24:49 +0530 Subject: [PATCH 08/12] Fix lint issue by removing django appconf --- requirements/dev.txt | 3 --- requirements/prod.txt | 3 --- 2 files changed, 6 deletions(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index ef2e8d3f64..202a3aa5ee 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -266,9 +266,6 @@ django==4.2.17 \ django-anymail==12.0 \ --hash=sha256:65789c1b0f42915aa0450a4f173f77572d4c552979b748ddd8125af41972ad30 \ --hash=sha256:de8458d713d0f9776da9ed04dcd3a0161be23e9ecbcb49dcf149219700ecd274 -django-appconf==1.0.6 \ - --hash=sha256:c3ae442fba1ff7ec830412c5184b17169a7a1e71cf0864a4c3f93cf4c98a1993 \ - --hash=sha256:cfe87ea827c4ee04b9a70fab90b86d704cb02f2981f89da8423cb0fabf88efbf django-basic-auth-ip-whitelist==0.6.0 \ --hash=sha256:51fbef4d483cfccb15d0c38605fd149fd307314ad8a9308580a6b693b94b3329 \ --hash=sha256:f866c1822861ab6612efb9adec03b12279a82314783aa721c843acfbea04b0b7 diff --git a/requirements/prod.txt b/requirements/prod.txt index b6c2774658..d0b6cbb82b 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -201,9 +201,6 @@ django==4.2.17 \ django-anymail==12.0 \ --hash=sha256:65789c1b0f42915aa0450a4f173f77572d4c552979b748ddd8125af41972ad30 \ --hash=sha256:de8458d713d0f9776da9ed04dcd3a0161be23e9ecbcb49dcf149219700ecd274 -django-appconf==1.0.6 \ - --hash=sha256:c3ae442fba1ff7ec830412c5184b17169a7a1e71cf0864a4c3f93cf4c98a1993 \ - --hash=sha256:cfe87ea827c4ee04b9a70fab90b86d704cb02f2981f89da8423cb0fabf88efbf django-basic-auth-ip-whitelist==0.6.0 \ --hash=sha256:51fbef4d483cfccb15d0c38605fd149fd307314ad8a9308580a6b693b94b3329 \ --hash=sha256:f866c1822861ab6612efb9adec03b12279a82314783aa721c843acfbea04b0b7 From 9f4ef09a9153509fa7e29877f28b951c6b16d9fd Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Mon, 13 Jan 2025 12:12:39 +0530 Subject: [PATCH 09/12] Use choices.js code in base.html and updated class to data atrribute for choices initialisation/selection --- .../templates/dashboard/reviewer_dashboard.html | 2 -- hypha/apply/funds/forms.py | 4 +++- .../funds/templates/funds/application_base.html | 3 --- .../funds/applicationsubmission_form.html | 3 --- .../templates/funds/base_submissions_table.html | 2 -- .../funds/includes/update_meta_terms_form.html | 15 --------------- hypha/apply/funds/templates/funds/rounds.html | 2 -- hypha/apply/funds/widgets.py | 4 ++-- .../application_projects/invoice_list.html | 2 -- .../project_approval_form.html | 3 --- .../application_projects/project_list.html | 2 -- .../application_projects/project_sow_form.html | 3 --- .../application_projects/report_form.html | 2 -- .../application_projects/reporting.html | 2 -- hypha/static_src/javascript/choices-select.js | 11 ----------- .../static_src/javascript/vendor/choices.min.js | 2 -- hypha/templates/base.html | 17 +++++++++++++++++ 17 files changed, 22 insertions(+), 57 deletions(-) delete mode 100644 hypha/static_src/javascript/choices-select.js delete mode 100644 hypha/static_src/javascript/vendor/choices.min.js diff --git a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html index 3f4d20d916..33388fab72 100644 --- a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html +++ b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html @@ -93,6 +93,4 @@

      {% block extra_js %} {{ filter.form.media.js }} - - {% endblock %} diff --git a/hypha/apply/funds/forms.py b/hypha/apply/funds/forms.py index 4d5af23571..3e3bf483cd 100644 --- a/hypha/apply/funds/forms.py +++ b/hypha/apply/funds/forms.py @@ -398,7 +398,9 @@ def label_from_instance(self, obj): class UpdateMetaTermsForm(ApplicationSubmissionModelForm): meta_terms = GroupedModelMultipleChoiceField( queryset=None, # updated in init method - widget=MetaTermWidget(attrs={"data-placeholder": "Select..."}), + widget=MetaTermWidget( + attrs={"data-placeholder": "Select...", "data-js-choices": ""} + ), label=_("Meta terms"), choices_groupby="get_parent", required=False, diff --git a/hypha/apply/funds/templates/funds/application_base.html b/hypha/apply/funds/templates/funds/application_base.html index fbd8785d76..5147e91a7d 100644 --- a/hypha/apply/funds/templates/funds/application_base.html +++ b/hypha/apply/funds/templates/funds/application_base.html @@ -91,7 +91,4 @@

      {% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applicat {% endif %} - - - {% endblock %} diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_form.html b/hypha/apply/funds/templates/funds/applicationsubmission_form.html index 1b032ce744..49df9487b5 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_form.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_form.html @@ -51,7 +51,4 @@ {% if not show_all_group_fields %} {% endif %} - - - {% endblock %} diff --git a/hypha/apply/funds/templates/funds/base_submissions_table.html b/hypha/apply/funds/templates/funds/base_submissions_table.html index 6dc67b2905..a14d32980e 100644 --- a/hypha/apply/funds/templates/funds/base_submissions_table.html +++ b/hypha/apply/funds/templates/funds/base_submissions_table.html @@ -20,6 +20,4 @@ - - {% endblock %} diff --git a/hypha/apply/funds/templates/funds/includes/update_meta_terms_form.html b/hypha/apply/funds/templates/funds/includes/update_meta_terms_form.html index ed82697022..d3cb742926 100644 --- a/hypha/apply/funds/templates/funds/includes/update_meta_terms_form.html +++ b/hypha/apply/funds/templates/funds/includes/update_meta_terms_form.html @@ -3,18 +3,3 @@
      {% include 'funds/includes/dialog_form_base.html' with form=form value=value %}
      - - diff --git a/hypha/apply/funds/templates/funds/rounds.html b/hypha/apply/funds/templates/funds/rounds.html index 290dc61e6f..12eab4d8bb 100644 --- a/hypha/apply/funds/templates/funds/rounds.html +++ b/hypha/apply/funds/templates/funds/rounds.html @@ -23,6 +23,4 @@ {% block extra_js %} {{ filter.form.media.js }} - - {% endblock %} diff --git a/hypha/apply/funds/widgets.py b/hypha/apply/funds/widgets.py index 2d26950356..db96dd4171 100644 --- a/hypha/apply/funds/widgets.py +++ b/hypha/apply/funds/widgets.py @@ -8,8 +8,8 @@ class MultiCheckboxesWidget(forms.SelectMultiple): def __init__(self, *args, **kwargs): attrs = kwargs.get("attrs", {}) - # Add the class for Choices.js initialization - attrs.setdefault("class", "js-choices") + # Add the date attribute for Choices.js initialization + attrs.setdefault("data-js-choices", "") attrs.setdefault("data-placeholder", "") kwargs["attrs"] = attrs super().__init__(*args, **kwargs) diff --git a/hypha/apply/projects/templates/application_projects/invoice_list.html b/hypha/apply/projects/templates/application_projects/invoice_list.html index 7e93ec131b..3d00954745 100644 --- a/hypha/apply/projects/templates/application_projects/invoice_list.html +++ b/hypha/apply/projects/templates/application_projects/invoice_list.html @@ -37,6 +37,4 @@ {{ filter.form.media.js }} - - {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/project_approval_form.html b/hypha/apply/projects/templates/application_projects/project_approval_form.html index 71126dd36d..74ed54335e 100644 --- a/hypha/apply/projects/templates/application_projects/project_approval_form.html +++ b/hypha/apply/projects/templates/application_projects/project_approval_form.html @@ -78,7 +78,4 @@

      {% trans "Proposal attachments" %}
      {% if not show_all_group_fields %} {% endif %} - - - {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/project_list.html b/hypha/apply/projects/templates/application_projects/project_list.html index b2bf802fb7..0ef8b55a23 100644 --- a/hypha/apply/projects/templates/application_projects/project_list.html +++ b/hypha/apply/projects/templates/application_projects/project_list.html @@ -37,6 +37,4 @@ {% block extra_js %} {{ filter.form.media.js }} - - {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/project_sow_form.html b/hypha/apply/projects/templates/application_projects/project_sow_form.html index 3e18251718..1c03e88483 100644 --- a/hypha/apply/projects/templates/application_projects/project_sow_form.html +++ b/hypha/apply/projects/templates/application_projects/project_sow_form.html @@ -74,7 +74,4 @@
      {% trans "Proposal attachments" %}
      {% if not show_all_group_fields %} {% endif %} - - - {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/report_form.html b/hypha/apply/projects/templates/application_projects/report_form.html index 263216f86c..689ebfe0a8 100644 --- a/hypha/apply/projects/templates/application_projects/report_form.html +++ b/hypha/apply/projects/templates/application_projects/report_form.html @@ -77,6 +77,4 @@ {% block extra_js %} - - {% endblock %} diff --git a/hypha/apply/projects/templates/application_projects/reporting.html b/hypha/apply/projects/templates/application_projects/reporting.html index 9d7107bb99..2c967e1153 100644 --- a/hypha/apply/projects/templates/application_projects/reporting.html +++ b/hypha/apply/projects/templates/application_projects/reporting.html @@ -33,6 +33,4 @@ {% block extra_js %} {{ filter.form.media.js }} - - {% endblock %} diff --git a/hypha/static_src/javascript/choices-select.js b/hypha/static_src/javascript/choices-select.js deleted file mode 100644 index e4edc687a5..0000000000 --- a/hypha/static_src/javascript/choices-select.js +++ /dev/null @@ -1,11 +0,0 @@ -const selectElements = document.querySelectorAll(".js-choices"); - -selectElements.forEach((selectElement) => { - // eslint-disable-next-line no-undef - // biome-ignore lint: undeclared - new Choices(selectElement, { - shouldSort: false, - allowHTML: true, - removeItemButton: true, - }); -}); diff --git a/hypha/static_src/javascript/vendor/choices.min.js b/hypha/static_src/javascript/vendor/choices.min.js deleted file mode 100644 index 3b79f06839..0000000000 --- a/hypha/static_src/javascript/vendor/choices.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! For license information please see choices.min.js.LICENSE.txt */ -!function(){"use strict";var e={282:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.clearChoices=t.activateChoices=t.filterChoices=t.addChoice=void 0;var n=i(883);t.addChoice=function(e){var t=e.value,i=e.label,r=e.id,s=e.groupId,o=e.disabled,a=e.elementId,c=e.customProperties,l=e.placeholder,h=e.keyCode;return{type:n.ACTION_TYPES.ADD_CHOICE,value:t,label:i,id:r,groupId:s,disabled:o,elementId:a,customProperties:c,placeholder:l,keyCode:h}},t.filterChoices=function(e){return{type:n.ACTION_TYPES.FILTER_CHOICES,results:e}},t.activateChoices=function(e){return void 0===e&&(e=!0),{type:n.ACTION_TYPES.ACTIVATE_CHOICES,active:e}},t.clearChoices=function(){return{type:n.ACTION_TYPES.CLEAR_CHOICES}}},783:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.addGroup=void 0;var n=i(883);t.addGroup=function(e){var t=e.value,i=e.id,r=e.active,s=e.disabled;return{type:n.ACTION_TYPES.ADD_GROUP,value:t,id:i,active:r,disabled:s}}},464:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.highlightItem=t.removeItem=t.addItem=void 0;var n=i(883);t.addItem=function(e){var t=e.value,i=e.label,r=e.id,s=e.choiceId,o=e.groupId,a=e.customProperties,c=e.placeholder,l=e.keyCode;return{type:n.ACTION_TYPES.ADD_ITEM,value:t,label:i,id:r,choiceId:s,groupId:o,customProperties:a,placeholder:c,keyCode:l}},t.removeItem=function(e,t){return{type:n.ACTION_TYPES.REMOVE_ITEM,id:e,choiceId:t}},t.highlightItem=function(e,t){return{type:n.ACTION_TYPES.HIGHLIGHT_ITEM,id:e,highlighted:t}}},137:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.setIsLoading=t.resetTo=t.clearAll=void 0;var n=i(883);t.clearAll=function(){return{type:n.ACTION_TYPES.CLEAR_ALL}},t.resetTo=function(e){return{type:n.ACTION_TYPES.RESET_TO,state:e}},t.setIsLoading=function(e){return{type:n.ACTION_TYPES.SET_IS_LOADING,isLoading:e}}},373:function(e,t,i){var n=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,r=0,s=t.length;r=0?this._store.getGroupById(r):null;return this._store.dispatch((0,l.highlightItem)(i,!0)),t&&this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:i,value:o,label:c,groupValue:h&&h.value?h.value:null}),this},e.prototype.unhighlightItem=function(e){if(!e||!e.id)return this;var t=e.id,i=e.groupId,n=void 0===i?-1:i,r=e.value,s=void 0===r?"":r,o=e.label,a=void 0===o?"":o,c=n>=0?this._store.getGroupById(n):null;return this._store.dispatch((0,l.highlightItem)(t,!1)),this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:t,value:s,label:a,groupValue:c&&c.value?c.value:null}),this},e.prototype.highlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.highlightItem(t)})),this},e.prototype.unhighlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.unhighlightItem(t)})),this},e.prototype.removeActiveItemsByValue=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.value===e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeActiveItems=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.id!==e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeHighlightedItems=function(e){var t=this;return void 0===e&&(e=!1),this._store.highlightedActiveItems.forEach((function(i){t._removeItem(i),e&&t._triggerChange(i.value)})),this},e.prototype.showDropdown=function(e){var t=this;return this.dropdown.isActive||requestAnimationFrame((function(){t.dropdown.show(),t.containerOuter.open(t.dropdown.distanceFromTopWindow),!e&&t._canSearch&&t.input.focus(),t.passedElement.triggerEvent(d.EVENTS.showDropdown,{})})),this},e.prototype.hideDropdown=function(e){var t=this;return this.dropdown.isActive?(requestAnimationFrame((function(){t.dropdown.hide(),t.containerOuter.close(),!e&&t._canSearch&&(t.input.removeActiveDescendant(),t.input.blur()),t.passedElement.triggerEvent(d.EVENTS.hideDropdown,{})})),this):this},e.prototype.getValue=function(e){void 0===e&&(e=!1);var t=this._store.activeItems.reduce((function(t,i){var n=e?i.value:i;return t.push(n),t}),[]);return this._isSelectOneElement?t[0]:t},e.prototype.setValue=function(e){var t=this;return this.initialised?(e.forEach((function(e){return t._setChoiceOrItem(e)})),this):this},e.prototype.setChoiceByValue=function(e){var t=this;return!this.initialised||this._isTextElement||(Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)})),this},e.prototype.setChoices=function(e,t,i,n){var r=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===i&&(i="label"),void 0===n&&(n=!1),!this.initialised)throw new ReferenceError("setChoices was called on a non-initialized instance of Choices");if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if("string"!=typeof t||!t)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(n&&this.clearChoices(),"function"==typeof e){var s=e(this);if("function"==typeof Promise&&s instanceof Promise)return new Promise((function(e){return requestAnimationFrame(e)})).then((function(){return r._handleLoadingState(!0)})).then((function(){return s})).then((function(e){return r.setChoices(e,t,i,n)})).catch((function(e){r.config.silent||console.error(e)})).then((function(){return r._handleLoadingState(!1)})).then((function(){return r}));if(!Array.isArray(s))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof s));return this.setChoices(s,t,i,!1)}if(!Array.isArray(e))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._startLoading(),e.forEach((function(e){if(e.choices)r._addGroup({id:e.id?parseInt("".concat(e.id),10):null,group:e,valueKey:t,labelKey:i});else{var n=e;r._addChoice({value:n[t],label:n[i],isSelected:!!n.selected,isDisabled:!!n.disabled,placeholder:!!n.placeholder,customProperties:n.customProperties})}})),this._stopLoading(),this},e.prototype.clearChoices=function(){return this._store.dispatch((0,a.clearChoices)()),this},e.prototype.clearStore=function(){return this._store.dispatch((0,h.clearAll)()),this},e.prototype.clearInput=function(){var e=!this._isSelectOneElement;return this.input.clear(e),!this._isTextElement&&this._canSearch&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))),this},e.prototype._render=function(){if(!this._store.isLoading()){this._currentState=this._store.state;var e=this._currentState.choices!==this._prevState.choices||this._currentState.groups!==this._prevState.groups||this._currentState.items!==this._prevState.items,t=this._isSelectElement,i=this._currentState.items!==this._prevState.items;e&&(t&&this._renderChoices(),i&&this._renderItems(),this._prevState=this._currentState)}},e.prototype._renderChoices=function(){var e=this,t=this._store,i=t.activeGroups,n=t.activeChoices,r=document.createDocumentFragment();if(this.choiceList.clear(),this.config.resetScrollPosition&&requestAnimationFrame((function(){return e.choiceList.scrollToTop()})),i.length>=1&&!this._isSearching){var s=n.filter((function(e){return!0===e.placeholder&&-1===e.groupId}));s.length>=1&&(r=this._createChoicesFragment(s,r)),r=this._createGroupsFragment(i,n,r)}else n.length>=1&&(r=this._createChoicesFragment(n,r));if(r.childNodes&&r.childNodes.length>0){var o=this._store.activeItems,a=this._canAddItem(o,this.input.value);if(a.response)this.choiceList.append(r),this._highlightChoice();else{var c=this._getTemplate("notice",a.notice);this.choiceList.append(c)}}else{var l=void 0;c=void 0,this._isSearching?(c="function"==typeof this.config.noResultsText?this.config.noResultsText():this.config.noResultsText,l=this._getTemplate("notice",c,"no-results")):(c="function"==typeof this.config.noChoicesText?this.config.noChoicesText():this.config.noChoicesText,l=this._getTemplate("notice",c,"no-choices")),this.choiceList.append(l)}},e.prototype._renderItems=function(){var e=this._store.activeItems||[];this.itemList.clear();var t=this._createItemsFragment(e);t.childNodes&&this.itemList.append(t)},e.prototype._createGroupsFragment=function(e,t,i){var n=this;return void 0===i&&(i=document.createDocumentFragment()),this.config.shouldSort&&e.sort(this.config.sorter),e.forEach((function(e){var r=function(e){return t.filter((function(t){return n._isSelectOneElement?t.groupId===e.id:t.groupId===e.id&&("always"===n.config.renderSelectedChoices||!t.selected)}))}(e);if(r.length>=1){var s=n._getTemplate("choiceGroup",e);i.appendChild(s),n._createChoicesFragment(r,i,!0)}})),i},e.prototype._createChoicesFragment=function(e,t,i){var r=this;void 0===t&&(t=document.createDocumentFragment()),void 0===i&&(i=!1);var s=this.config,o=s.renderSelectedChoices,a=s.searchResultLimit,c=s.renderChoiceLimit,l=this._isSearching?f.sortByScore:this.config.sorter,h=function(e){if("auto"!==o||r._isSelectOneElement||!e.selected){var i=r._getTemplate("choice",e,r.config.itemSelectText);t.appendChild(i)}},u=e;"auto"!==o||this._isSelectOneElement||(u=e.filter((function(e){return!e.selected})));var d=u.reduce((function(e,t){return t.placeholder?e.placeholderChoices.push(t):e.normalChoices.push(t),e}),{placeholderChoices:[],normalChoices:[]}),p=d.placeholderChoices,m=d.normalChoices;(this.config.shouldSort||this._isSearching)&&m.sort(l);var v=u.length,g=this._isSelectOneElement?n(n([],p,!0),m,!0):m;this._isSearching?v=a:c&&c>0&&!i&&(v=c);for(var _=0;_=n){var o=r?this._searchChoices(e):0;this.passedElement.triggerEvent(d.EVENTS.search,{value:e,resultCount:o})}else s&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0)))}},e.prototype._canAddItem=function(e,t){var i=!0,n="function"==typeof this.config.addItemText?this.config.addItemText(t):this.config.addItemText;if(!this._isSelectOneElement){var r=(0,f.existsInArray)(e,t);this.config.maxItemCount>0&&this.config.maxItemCount<=e.length&&(i=!1,n="function"==typeof this.config.maxItemText?this.config.maxItemText(this.config.maxItemCount):this.config.maxItemText),!this.config.duplicateItemsAllowed&&r&&i&&(i=!1,n="function"==typeof this.config.uniqueItemText?this.config.uniqueItemText(t):this.config.uniqueItemText),this._isTextElement&&this.config.addItems&&i&&"function"==typeof this.config.addItemFilter&&!this.config.addItemFilter(t)&&(i=!1,n="function"==typeof this.config.customAddItemText?this.config.customAddItemText(t):this.config.customAddItemText)}return{response:i,notice:n}},e.prototype._searchChoices=function(e){var t="string"==typeof e?e.trim():e,i="string"==typeof this._currentValue?this._currentValue.trim():this._currentValue;if(t.length<1&&t==="".concat(i," "))return 0;var r=this._store.searchableChoices,s=t,c=Object.assign(this.config.fuseOptions,{keys:n([],this.config.searchFields,!0),includeMatches:!0}),l=new o.default(r,c).search(s);return this._currentValue=t,this._highlightPosition=0,this._isSearching=!0,this._store.dispatch((0,a.filterChoices)(l)),l.length},e.prototype._addEventListeners=function(){var e=document.documentElement;e.addEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.addEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(this.containerOuter.element.addEventListener("focus",this._onFocus,{passive:!0}),this.containerOuter.element.addEventListener("blur",this._onBlur,{passive:!0})),this.input.element.addEventListener("keyup",this._onKeyUp,{passive:!0}),this.input.element.addEventListener("focus",this._onFocus,{passive:!0}),this.input.element.addEventListener("blur",this._onBlur,{passive:!0}),this.input.element.form&&this.input.element.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=document.documentElement;e.removeEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.removeEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(this.containerOuter.element.removeEventListener("focus",this._onFocus),this.containerOuter.element.removeEventListener("blur",this._onBlur)),this.input.element.removeEventListener("keyup",this._onKeyUp),this.input.element.removeEventListener("focus",this._onFocus),this.input.element.removeEventListener("blur",this._onBlur),this.input.element.form&&this.input.element.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this._store.activeItems,n=this.input.isFocussed,r=this.dropdown.isActive,s=this.itemList.hasChildren(),o=String.fromCharCode(t),a=/[^\x00-\x1F]/.test(o),c=d.KEY_CODES.BACK_KEY,l=d.KEY_CODES.DELETE_KEY,h=d.KEY_CODES.ENTER_KEY,u=d.KEY_CODES.A_KEY,p=d.KEY_CODES.ESC_KEY,f=d.KEY_CODES.UP_KEY,m=d.KEY_CODES.DOWN_KEY,v=d.KEY_CODES.PAGE_UP_KEY,g=d.KEY_CODES.PAGE_DOWN_KEY;switch(this._isTextElement||r||!a||(this.showDropdown(),this.input.isFocussed||(this.input.value+=e.key.toLowerCase())),t){case u:return this._onSelectKey(e,s);case h:return this._onEnterKey(e,i,r);case p:return this._onEscapeKey(r);case f:case v:case m:case g:return this._onDirectionKey(e,r);case l:case c:return this._onDeleteKey(e,i,n)}},e.prototype._onKeyUp=function(e){var t=e.target,i=e.keyCode,n=this.input.value,r=this._store.activeItems,s=this._canAddItem(r,n),o=d.KEY_CODES.BACK_KEY,c=d.KEY_CODES.DELETE_KEY;if(this._isTextElement)if(s.notice&&n){var l=this._getTemplate("notice",s.notice);this.dropdown.element.innerHTML=l.outerHTML,this.showDropdown(!0)}else this.hideDropdown(!0);else{var h=(i===o||i===c)&&t&&!t.value,u=!this._isTextElement&&this._isSearching,p=this._canSearch&&s.response;h&&u?(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))):p&&this._handleSearch(this.input.rawValue)}this._canSearch=this.config.searchEnabled},e.prototype._onSelectKey=function(e,t){var i=e.ctrlKey,n=e.metaKey;(i||n)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t,i){var n=e.target,r=d.KEY_CODES.ENTER_KEY,s=n&&n.hasAttribute("data-button");if(this._isTextElement&&n&&n.value){var o=this.input.value;this._canAddItem(t,o).response&&(this.hideDropdown(!0),this._addItem({value:o}),this._triggerChange(o),this.clearInput())}if(s&&(this._handleButtonAction(t,n),e.preventDefault()),i){var a=this.dropdown.getChild(".".concat(this.config.classNames.highlightedState));a&&(t[0]&&(t[0].keyCode=r),this._handleChoiceAction(t,a)),e.preventDefault()}else this._isSelectOneElement&&(this.showDropdown(),e.preventDefault())},e.prototype._onEscapeKey=function(e){e&&(this.hideDropdown(!0),this.containerOuter.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode,n=e.metaKey,r=d.KEY_CODES.DOWN_KEY,s=d.KEY_CODES.PAGE_UP_KEY,o=d.KEY_CODES.PAGE_DOWN_KEY;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var a=i===r||i===o?1:-1,c="[data-choice-selectable]",l=void 0;if(n||i===o||i===s)l=a>0?this.dropdown.element.querySelector("".concat(c,":last-of-type")):this.dropdown.element.querySelector(c);else{var h=this.dropdown.element.querySelector(".".concat(this.config.classNames.highlightedState));l=h?(0,f.getAdjacentEl)(h,c,a):this.dropdown.element.querySelector(c)}l&&((0,f.isScrolledIntoView)(l,this.choiceList.element,a)||this.choiceList.scrollToChildElement(l,a),this._highlightChoice(l)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){var n=e.target;this._isSelectOneElement||n.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof HTMLElement){if(_&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild,n="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetX0&&this.unhighlightAll(),this.containerOuter.removeFocusState(),this.hideDropdown(!0))},e.prototype._onFocus=function(e){var t,i=this,n=e.target;n&&this.containerOuter.element.contains(n)&&((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&i.containerOuter.addFocusState()},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.addFocusState(),n===i.input.element&&i.showDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.showDropdown(!0),i.containerOuter.addFocusState())},t)[this.passedElement.element.type]()},e.prototype._onBlur=function(e){var t,i=this,n=e.target;if(n&&this.containerOuter.element.contains(n)&&!this._isScrollingOnIe){var r=this._store.activeItems.some((function(e){return e.highlighted}));((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),r&&i.unhighlightAll(),i.hideDropdown(!0))},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.removeFocusState(),(n===i.input.element||n===i.containerOuter.element&&!i._canSearch)&&i.hideDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),i.hideDropdown(!0),r&&i.unhighlightAll())},t)[this.passedElement.element.type]()}else this._isScrollingOnIe=!1,this.input.element.focus()},e.prototype._onFormReset=function(){this._store.dispatch((0,h.resetTo)(this._initialState))},e.prototype._highlightChoice=function(e){var t=this;void 0===e&&(e=null);var i=Array.from(this.dropdown.element.querySelectorAll("[data-choice-selectable]"));if(i.length){var n=e;Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState))).forEach((function(e){e.classList.remove(t.config.classNames.highlightedState),e.setAttribute("aria-selected","false")})),n?this._highlightPosition=i.indexOf(n):(n=i.length>this._highlightPosition?i[this._highlightPosition]:i[i.length-1])||(n=i[0]),n.classList.add(this.config.classNames.highlightedState),n.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(d.EVENTS.highlightChoice,{el:n}),this.dropdown.isActive&&(this.input.setActiveDescendant(n.id),this.containerOuter.setActiveDescendant(n.id))}},e.prototype._addItem=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,r=e.choiceId,s=void 0===r?-1:r,o=e.groupId,a=void 0===o?-1:o,c=e.customProperties,h=void 0===c?{}:c,u=e.placeholder,p=void 0!==u&&u,f=e.keyCode,m=void 0===f?-1:f,v="string"==typeof t?t.trim():t,g=this._store.items,_=n||v,y=s||-1,E=a>=0?this._store.getGroupById(a):null,b=g?g.length+1:1;this.config.prependValue&&(v=this.config.prependValue+v.toString()),this.config.appendValue&&(v+=this.config.appendValue.toString()),this._store.dispatch((0,l.addItem)({value:v,label:_,id:b,choiceId:y,groupId:a,customProperties:h,placeholder:p,keyCode:m})),this._isSelectOneElement&&this.removeActiveItems(b),this.passedElement.triggerEvent(d.EVENTS.addItem,{id:b,value:v,label:_,customProperties:h,groupValue:E&&E.value?E.value:null,keyCode:m})},e.prototype._removeItem=function(e){var t=e.id,i=e.value,n=e.label,r=e.customProperties,s=e.choiceId,o=e.groupId,a=o&&o>=0?this._store.getGroupById(o):null;t&&s&&(this._store.dispatch((0,l.removeItem)(t,s)),this.passedElement.triggerEvent(d.EVENTS.removeItem,{id:t,value:i,label:n,customProperties:r,groupValue:a&&a.value?a.value:null}))},e.prototype._addChoice=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,r=e.isSelected,s=void 0!==r&&r,o=e.isDisabled,c=void 0!==o&&o,l=e.groupId,h=void 0===l?-1:l,u=e.customProperties,d=void 0===u?{}:u,p=e.placeholder,f=void 0!==p&&p,m=e.keyCode,v=void 0===m?-1:m;if(null!=t){var g=this._store.choices,_=n||t,y=g?g.length+1:1,E="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(y);this._store.dispatch((0,a.addChoice)({id:y,groupId:h,elementId:E,value:t,label:_,disabled:c,customProperties:d,placeholder:f,keyCode:v})),s&&this._addItem({value:t,label:_,choiceId:y,customProperties:d,placeholder:f,keyCode:v})}},e.prototype._addGroup=function(e){var t=this,i=e.group,n=e.id,r=e.valueKey,s=void 0===r?"value":r,o=e.labelKey,a=void 0===o?"label":o,l=(0,f.isType)("Object",i)?i.choices:Array.from(i.getElementsByTagName("OPTION")),h=n||Math.floor((new Date).valueOf()*Math.random()),u=!!i.disabled&&i.disabled;l?(this._store.dispatch((0,c.addGroup)({value:i.label,id:h,active:!0,disabled:u})),l.forEach((function(e){var i=e.disabled||e.parentNode&&e.parentNode.disabled;t._addChoice({value:e[s],label:(0,f.isType)("Object",e)?e[a]:e.innerHTML,isSelected:e.selected,isDisabled:i,groupId:h,customProperties:e.customProperties,placeholder:e.placeholder})}))):this._store.dispatch((0,c.addGroup)({value:i.label,id:i.id,active:!1,disabled:i.disabled}))},e.prototype._getTemplate=function(e){for(var t,i=[],r=1;r0?this.element.scrollTop+o-r:e.offsetTop;requestAnimationFrame((function(){i._animateScroll(a,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t,r=n>1?n:1;this.element.scrollTop=e+r},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t,r=n>1?n:1;this.element.scrollTop=e-r},e.prototype._animateScroll=function(e,t){var i=this,r=n.SCROLLING_SPEED,s=this.element.scrollTop,o=!1;t>0?(this._scrollDown(s,r,e),se&&(o=!0)),o&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}();t.default=r},730:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=i(799),r=function(){function e(e){var t=e.element,i=e.classNames;if(this.element=t,this.classNames=i,!(t instanceof HTMLInputElement||t instanceof HTMLSelectElement))throw new TypeError("Invalid element passed");this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){this.element.classList.add(this.classNames.input),this.element.hidden=!0,this.element.tabIndex=-1;var e=this.element.getAttribute("style");e&&this.element.setAttribute("data-choice-orig-style",e),this.element.setAttribute("data-choice","active")},e.prototype.reveal=function(){this.element.classList.remove(this.classNames.input),this.element.hidden=!1,this.element.removeAttribute("tabindex");var e=this.element.getAttribute("data-choice-orig-style");e?(this.element.removeAttribute("data-choice-orig-style"),this.element.setAttribute("style",e)):this.element.removeAttribute("style"),this.element.removeAttribute("data-choice"),this.element.value=this.element.value},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){(0,n.dispatchEvent)(this.element,e,t)},e}();t.default=r},541:function(e,t,i){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,r=t.delimiter,s=e.call(this,{element:i,classNames:n})||this;return s.delimiter=r,s}return r(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),t}(s(i(730)).default);t.default=o},982:function(e,t,i){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,r=t.template,s=e.call(this,{element:i,classNames:n})||this;return s.template=r,s}return r(t,e),Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optionGroups",{get:function(){return Array.from(this.element.getElementsByTagName("OPTGROUP"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return Array.from(this.element.options)},set:function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){return n=e,r=t.template(n),void i.appendChild(r);var n,r})),this.appendDocFragment(i)},enumerable:!1,configurable:!0}),t.prototype.appendDocFragment=function(e){this.element.innerHTML="",this.element.appendChild(e)},t}(s(i(730)).default);t.default=o},883:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.SCROLLING_SPEED=t.SELECT_MULTIPLE_TYPE=t.SELECT_ONE_TYPE=t.TEXT_TYPE=t.KEY_CODES=t.ACTION_TYPES=t.EVENTS=void 0,t.EVENTS={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},t.ACTION_TYPES={ADD_CHOICE:"ADD_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM",CLEAR_ALL:"CLEAR_ALL",RESET_TO:"RESET_TO",SET_IS_LOADING:"SET_IS_LOADING"},t.KEY_CODES={BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},t.TEXT_TYPE="text",t.SELECT_ONE_TYPE="select-one",t.SELECT_MULTIPLE_TYPE="select-multiple",t.SCROLLING_SPEED=4},789:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CONFIG=t.DEFAULT_CLASSNAMES=void 0;var n=i(799);t.DEFAULT_CLASSNAMES={containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemChoice:"choices__item--choice",placeholder:"choices__placeholder",group:"choices__group",groupHeading:"choices__heading",button:"choices__button",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",selectedState:"is-selected",flippedState:"is-flipped",loadingState:"is-loading",noResults:"has-no-results",noChoices:"has-no-choices"},t.DEFAULT_CONFIG={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,addItems:!0,addItemFilter:null,removeItems:!0,removeItemButton:!1,editItems:!1,allowHTML:!0,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:n.sortByAlpha,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat((0,n.sanitise)(e),'"')},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:t.DEFAULT_CLASSNAMES}},18:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},978:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},948:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},359:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},285:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},533:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},187:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),r(i(18),t),r(i(978),t),r(i(948),t),r(i(359),t),r(i(285),t),r(i(533),t),r(i(287),t),r(i(132),t),r(i(837),t),r(i(598),t),r(i(369),t),r(i(37),t),r(i(47),t),r(i(923),t),r(i(876),t)},287:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},132:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},837:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},598:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},37:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},369:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},47:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},923:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},876:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},799:function(e,t){var i;Object.defineProperty(t,"__esModule",{value:!0}),t.parseCustomProperties=t.diff=t.cloneObject=t.existsInArray=t.dispatchEvent=t.sortByScore=t.sortByAlpha=t.strToEl=t.sanitise=t.isScrolledIntoView=t.getAdjacentEl=t.wrap=t.isType=t.getType=t.generateId=t.generateChars=t.getRandomNumber=void 0,t.getRandomNumber=function(e,t){return Math.floor(Math.random()*(t-e)+e)},t.generateChars=function(e){return Array.from({length:e},(function(){return(0,t.getRandomNumber)(0,36).toString(36)})).join("")},t.generateId=function(e,i){var n=e.id||e.name&&"".concat(e.name,"-").concat((0,t.generateChars)(2))||(0,t.generateChars)(4);return n=n.replace(/(:|\.|\[|\]|,)/g,""),"".concat(i,"-").concat(n)},t.getType=function(e){return Object.prototype.toString.call(e).slice(8,-1)},t.isType=function(e,i){return null!=i&&(0,t.getType)(i)===e},t.wrap=function(e,t){return void 0===t&&(t=document.createElement("div")),e.parentNode&&(e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t)),t.appendChild(e)},t.getAdjacentEl=function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),r=e[n];r;){if(r.matches(t))return r;r=r[n]}return r},t.isScrolledIntoView=function(e,t,i){return void 0===i&&(i=1),!!e&&(i>0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop)},t.sanitise=function(e){return"string"!=typeof e?e:e.replace(/&/g,"&").replace(/>/g,">").replace(/-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(o.choiceId),10)&&(t.selected=!0),t})):e;case"REMOVE_ITEM":var a=n;return a.choiceId&&a.choiceId>-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(a.choiceId),10)&&(t.selected=!1),t})):e;case"FILTER_CHOICES":var c=n;return e.map((function(e){var t=e;return t.active=c.results.some((function(e){var i=e.item,n=e.score;return i.id===t.id&&(t.score=n,!0)})),t}));case"ACTIVATE_CHOICES":var l=n;return e.map((function(e){var t=e;return t.active=l.active,t}));case"CLEAR_CHOICES":return t.defaultState;default:return e}}},871:function(e,t){var i=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,r=0,s=t.length;r0?"treeitem":"option"),Object.assign(E.dataset,{choice:"",id:d,value:p,selectText:i}),g?(E.classList.add(h),E.dataset.choiceDisabled="",E.setAttribute("aria-disabled","true")):(E.classList.add(c),E.dataset.choiceSelectable=""),E},input:function(e,t){var i=e.classNames,n=i.input,r=i.inputCloned,s=Object.assign(document.createElement("input"),{type:"search",name:"search_terms",className:"".concat(n," ").concat(r),autocomplete:"off",autocapitalize:"off",spellcheck:!1});return s.setAttribute("role","textbox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-label",t),s},dropdown:function(e){var t=e.classNames,i=t.list,n=t.listDropdown,r=document.createElement("div");return r.classList.add(i,n),r.setAttribute("aria-expanded","false"),r},notice:function(e,t,i){var n,r=e.allowHTML,s=e.classNames,o=s.item,a=s.itemChoice,c=s.noResults,l=s.noChoices;void 0===i&&(i="");var h=[o,a];return"no-choices"===i?h.push(l):"no-results"===i&&h.push(c),Object.assign(document.createElement("div"),((n={})[r?"innerHTML":"innerText"]=t,n.className=h.join(" "),n))},option:function(e){var t=e.label,i=e.value,n=e.customProperties,r=e.active,s=e.disabled,o=new Option(t,i,!1,r);return n&&(o.dataset.customProperties="".concat(n)),o.disabled=!!s,o}};t.default=i},996:function(e){var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function r(e,t,i){return e.concat(t).map((function(e){return n(e,i)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,i,c){(c=c||{}).arrayMerge=c.arrayMerge||r,c.isMergeableObject=c.isMergeableObject||t,c.cloneUnlessOtherwiseSpecified=n;var l=Array.isArray(i);return l===Array.isArray(e)?l?c.arrayMerge(e,i,c):function(e,t,i){var r={};return i.isMergeableObject(e)&&s(e).forEach((function(t){r[t]=n(e[t],i)})),s(t).forEach((function(s){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(o(e,s)&&i.isMergeableObject(t[s])?r[s]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(s,i)(e[s],t[s],i):r[s]=n(t[s],i))})),r}(e,i,c):n(i,c)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return a(e,i,t)}),{})};var c=a;e.exports=c},221:function(e,t,i){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===l(e)}function r(e){return"string"==typeof e}function s(e){return"number"==typeof e}function o(e){return"object"==typeof e}function a(e){return null!=e}function c(e){return!e.trim().length}function l(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}i.r(t),i.d(t,{default:function(){return R}});const h=Object.prototype.hasOwnProperty;class u{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=d(e);t+=i.weight,this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function d(e){let t=null,i=null,s=null,o=1,a=null;if(r(e)||n(e))s=e,t=p(e),i=f(e);else{if(!h.call(e,"name"))throw new Error("Missing name property in key");const n=e.name;if(s=n,h.call(e,"weight")&&(o=e.weight,o<=0))throw new Error((e=>`Property 'weight' in key '${e}' must be a positive integer`)(n));t=p(n),i=f(n),a=e.getFn}return{path:t,id:i,weight:o,src:s,getFn:a}}function p(e){return n(e)?e:e.split(".")}function f(e){return n(e)?e.join("."):e}var m={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx{if(a(e))if(t[u]){const d=e[t[u]];if(!a(d))return;if(u===t.length-1&&(r(d)||s(d)||function(e){return!0===e||!1===e||function(e){return o(e)&&null!==e}(e)&&"[object Boolean]"==l(e)}(d)))i.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(d));else if(n(d)){c=!0;for(let e=0,i=d.length;e{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,r(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();r(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t{let o=t.getFn?t.getFn(e):this.getFn(e,t.path);if(a(o))if(n(o)){let e=[];const t=[{nestedArrIndex:-1,value:o}];for(;t.length;){const{nestedArrIndex:i,value:s}=t.pop();if(a(s))if(r(s)&&!c(s)){let t={v:s,i:i,n:this.norm.get(s)};e.push(t)}else n(s)&&s.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[s]=e}else if(r(o)&&!c(o)){let e={v:o,n:this.norm.get(o)};i.$[s]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function _(e,t,{getFn:i=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const r=new g({getFn:i,fieldNormWeight:n});return r.setKeys(e.map(d)),r.setSources(t),r.create(),r}function y(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:r=m.distance,ignoreLocation:s=m.ignoreLocation}={}){const o=t/e.length;if(s)return o;const a=Math.abs(n-i);return r?o+a/r:a?1:o}const E=32;function b(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:b(e),startIndex:t})},h=this.pattern.length;if(h>E){let e=0;const t=h%E,i=h-t;for(;e{const{isMatch:f,score:v,indices:g}=function(e,t,i,{location:n=m.location,distance:r=m.distance,threshold:s=m.threshold,findAllMatches:o=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,includeMatches:c=m.includeMatches,ignoreLocation:l=m.ignoreLocation}={}){if(t.length>E)throw new Error("Pattern length exceeds max of 32.");const h=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=s,f=d;const v=a>1||c,g=v?Array(u):[];let _;for(;(_=e.indexOf(t,f))>-1;){let e=y(t,{currentLocation:_,expectedLocation:d,distance:r,ignoreLocation:l});if(p=Math.min(e,p),f=_+h,v){let e=0;for(;e=c;s-=1){let o=s-1,a=i[e.charAt(o)];if(v&&(g[o]=+!!a),_[s]=(_[s+1]<<1|1)&a,n&&(_[s]|=(b[s+1]|b[s])<<1|1|b[s+1]),_[s]&I&&(S=y(t,{errors:n,currentLocation:o,expectedLocation:d,distance:r,ignoreLocation:l}),S<=p)){if(p=S,f=o,f<=d)break;c=Math.max(1,2*d-f)}}if(y(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:r,ignoreLocation:l})>p)break;b=_}const C={isMatch:f>=0,score:Math.max(.001,S)};if(v){const e=function(e=[],t=m.minMatchCharLength){let i=[],n=-1,r=-1,s=0;for(let o=e.length;s=t&&i.push([n,r]),n=-1)}return e[s-1]&&s-n>=t&&i.push([n,s-1]),i}(g,a);e.length?c&&(C.indices=e):C.isMatch=!1}return C}(e,t,d,{location:n+p,distance:r,threshold:s,findAllMatches:o,minMatchCharLength:a,includeMatches:i,ignoreLocation:c});f&&(u=!0),h+=v,f&&g&&(l=[...l,...g])}));let d={isMatch:u,score:u?h/this.chunks.length:1};return u&&i&&(d.indices=l),d}}class O{constructor(e){this.pattern=e}static isMultiMatch(e){return I(e,this.multiRegex)}static isSingleMatch(e){return I(e,this.singleRegex)}search(){}}function I(e,t){const i=e.match(t);return i?i[1]:null}class C extends O{constructor(e,{location:t=m.location,threshold:i=m.threshold,distance:n=m.distance,includeMatches:r=m.includeMatches,findAllMatches:s=m.findAllMatches,minMatchCharLength:o=m.minMatchCharLength,isCaseSensitive:a=m.isCaseSensitive,ignoreLocation:c=m.ignoreLocation}={}){super(e),this._bitapSearch=new S(e,{location:t,threshold:i,distance:n,includeMatches:r,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class T extends O{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,i=0;const n=[],r=this.pattern.length;for(;(t=e.indexOf(this.pattern,i))>-1;)i=t+r,n.push([t,i-1]);const s=!!n.length;return{isMatch:s,score:s?0:1,indices:n}}}const L=[class extends O{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},T,class extends O{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},C],w=L.length,A=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,M=new Set([C.type,T.type]);const P=[];function x(e,t){for(let i=0,n=P.length;i!(!e.$and&&!e.$or),j=e=>({[N]:Object.keys(e).map((t=>({[t]:e[t]})))});function F(e,t,{auto:i=!0}={}){const s=e=>{let a=Object.keys(e);const c=(e=>!!e.$path)(e);if(!c&&a.length>1&&!D(e))return s(j(e));if((e=>!n(e)&&o(e)&&!D(e))(e)){const n=c?e.$path:a[0],s=c?e.$val:e[n];if(!r(s))throw new Error((e=>`Invalid value for key ${e}`)(n));const o={keyId:f(n),pattern:s};return i&&(o.searcher=x(s,t)),o}let l={children:[],operator:a[0]};return a.forEach((t=>{const i=e[t];n(i)&&i.forEach((e=>{l.children.push(s(e))}))})),l};return D(e)||(e=j(e)),s(e)}function k(e,t){const i=e.matches;t.matches=[],a(i)&&i.forEach((e=>{if(!a(e.indices)||!e.indices.length)return;const{indices:i,value:n}=e;let r={indices:i,value:n};e.key&&(r.key=e.key.src),e.idx>-1&&(r.refIndex=e.idx),t.matches.push(r)}))}function K(e,t){t.score=e.score}class R{constructor(e,t={},i){this.options={...m,...t},this.options.useExtendedSearch,this._keyStore=new u(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof g))throw new Error("Incorrect 'index' type");this._myIndex=t||_(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){a(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=(()=>!1)){const t=[];for(let i=0,n=this._docs.length;i{let i=1;e.matches.forEach((({key:e,norm:n,score:r})=>{const s=e?e.weight:null;i*=Math.pow(0===r&&s?Number.EPSILON:r,(s||1)*(t?1:n))})),e.score=i}))}(l,{ignoreFieldNorm:c}),o&&l.sort(a),s(t)&&t>-1&&(l=l.slice(0,t)),function(e,t,{includeMatches:i=m.includeMatches,includeScore:n=m.includeScore}={}){const r=[];return i&&r.push(k),n&&r.push(K),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return r.length&&r.forEach((t=>{t(e,n)})),n}))}(l,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=x(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i:i,n:r})=>{if(!a(e))return;const{isMatch:s,score:o,indices:c}=t.searchIn(e);s&&n.push({item:e,idx:i,matches:[{score:o,value:e,norm:r,indices:c}]})})),n}_searchLogical(e){const t=F(e,this.options),i=(e,t,n)=>{if(!e.children){const{keyId:i,searcher:r}=e,s=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:r});return s&&s.length?[{idx:n,item:t,matches:s}]:[]}const r=[];for(let s=0,o=e.children.length;s{if(a(e)){let o=i(t,e,n);o.length&&(r[n]||(r[n]={idx:n,item:e,matches:[]},s.push(r[n])),o.forEach((({matches:e})=>{r[n].matches.push(...e)})))}})),s}_searchObjectList(e){const t=x(e,this.options),{keys:i,records:n}=this._myIndex,r=[];return n.forEach((({$:e,i:n})=>{if(!a(e))return;let s=[];i.forEach(((i,n)=>{s.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),s.length&&r.push({idx:n,item:e,matches:s})})),r}_findMatches({key:e,value:t,searcher:i}){if(!a(t))return[];let r=[];if(n(t))t.forEach((({v:t,i:n,n:s})=>{if(!a(t))return;const{isMatch:o,score:c,indices:l}=i.searchIn(t);o&&r.push({score:c,key:e,value:t,idx:n,norm:s,indices:l})}));else{const{v:n,n:s}=t,{isMatch:o,score:a,indices:c}=i.searchIn(n);o&&r.push({score:a,key:e,value:n,norm:s,indices:c})}return r}}R.version="6.6.2",R.createIndex=_,R.parseIndex=function(e,{getFn:t=m.getFn,fieldNormWeight:i=m.fieldNormWeight}={}){const{keys:n,records:r}=e,s=new g({getFn:t,fieldNormWeight:i});return s.setKeys(n),s.setIndexRecords(r),s},R.config=m,R.parseQuery=F,function(...e){P.push(...e)}(class{constructor(e,{isCaseSensitive:t=m.isCaseSensitive,includeMatches:i=m.includeMatches,minMatchCharLength:n=m.minMatchCharLength,ignoreLocation:r=m.ignoreLocation,findAllMatches:s=m.findAllMatches,location:o=m.location,threshold:a=m.threshold,distance:c=m.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:i,minMatchCharLength:n,findAllMatches:s,ignoreLocation:r,location:o,threshold:a,distance:c},this.pattern=t?e:e.toLowerCase(),this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(A).filter((e=>e&&!!e.trim())),n=[];for(let e=0,r=i.length;e + + + {% include "includes/_modal-placeholder.html" %} {% include "includes/_toast-placeholder.html" %} From 72132e2df368457ff6e7e2160c7ce0555c13227d Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Fri, 17 Jan 2025 16:05:20 +0530 Subject: [PATCH 10/12] Fix UI issues --- .../static_src/sass/components/_filters.scss | 2 +- .../tailwind/components/choices.css | 12 ++++++------ hypha/templates/base.html | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/hypha/static_src/sass/components/_filters.scss b/hypha/static_src/sass/components/_filters.scss index 01c4792f0b..130e91e566 100644 --- a/hypha/static_src/sass/components/_filters.scss +++ b/hypha/static_src/sass/components/_filters.scss @@ -32,7 +32,7 @@ inset-block-end: auto; height: auto; background: transparent; - max-height: 85px; + max-height: fit-content; pointer-events: all; } } diff --git a/hypha/static_src/tailwind/components/choices.css b/hypha/static_src/tailwind/components/choices.css index 9810d96383..719aa79f4d 100644 --- a/hypha/static_src/tailwind/components/choices.css +++ b/hypha/static_src/tailwind/components/choices.css @@ -206,14 +206,9 @@ } @media (min-width: 640px) { - .choices__list--dropdown .choices__item--selectable, - .choices__list[aria-expanded] .choices__item--selectable { - padding-right: 100px; - } - .choices__list--dropdown .choices__item--selectable::after, .choices__list[aria-expanded] .choices__item--selectable::after { - content: attr(data-select-text); + content: ""; font-size: 12px; opacity: 0; position: absolute; @@ -286,6 +281,11 @@ @apply hidden w-0 h-0; } +.choices__input--cloned { + color: #000; /* Darker placeholder */ + font-weight: 600; /* Semibold text */ +} + [dir="rtl"] .choices__input { @apply pl-0 pr-1; } diff --git a/hypha/templates/base.html b/hypha/templates/base.html index e4191a770a..7e84606b75 100644 --- a/hypha/templates/base.html +++ b/hypha/templates/base.html @@ -137,6 +137,25 @@ removeItemButton: true, }); }); + + const choicesElements = document.querySelectorAll(".choices__input--cloned") + choicesElements.forEach((choiceElement) => { + const inputPlaceholder = choiceElement.getAttribute("placeholder"); + // Get the computed min-width of the input element otherwise it reset to 1 + const minWidth = window.getComputedStyle(choiceElement).getPropertyValue("min-width"); + choiceElement.addEventListener("focus", () => { + if (choiceElement) { + choiceElement.placeholder = "" + } + }); + + choiceElement.addEventListener("blur", () => { + if (choiceElement) { + choiceElement.placeholder = inputPlaceholder + choiceElement.style.minWidth = minWidth; + } + }); + }); }); From fc00d3fdbeaee7a0045de0734115b081bf598e92 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Sun, 26 Jan 2025 16:14:23 +0530 Subject: [PATCH 11/12] Fix warnings and add search indicator placeholder --- hypha/templates/base.html | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hypha/templates/base.html b/hypha/templates/base.html index 7e84606b75..ee42370f21 100644 --- a/hypha/templates/base.html +++ b/hypha/templates/base.html @@ -131,11 +131,14 @@ const selectElements = document.querySelectorAll("[data-js-choices]"); selectElements.forEach((selectElement) => { - new Choices(selectElement, { - shouldSort: false, - allowHTML: true, - removeItemButton: true, - }); + if (!selectElement.choicesInstance) { + const choicesInstance = new Choices(selectElement, { + shouldSort: false, + allowHTML: true, + removeItemButton: true, + }); + selectElement.choicesInstance = choicesInstance; + }; }); const choicesElements = document.querySelectorAll(".choices__input--cloned") @@ -145,7 +148,7 @@ const minWidth = window.getComputedStyle(choiceElement).getPropertyValue("min-width"); choiceElement.addEventListener("focus", () => { if (choiceElement) { - choiceElement.placeholder = "" + choiceElement.placeholder = "Search..." } }); From 11b20cfdc8fa2427003d35b939a4f82d6cf56cff Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Mon, 27 Jan 2025 10:40:37 +0530 Subject: [PATCH 12/12] Fixed search placeholder min width --- hypha/templates/base.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hypha/templates/base.html b/hypha/templates/base.html index ee42370f21..845aba8f00 100644 --- a/hypha/templates/base.html +++ b/hypha/templates/base.html @@ -131,13 +131,13 @@ const selectElements = document.querySelectorAll("[data-js-choices]"); selectElements.forEach((selectElement) => { - if (!selectElement.choicesInstance) { + if (!selectElement.hasChoicesInstance) { const choicesInstance = new Choices(selectElement, { shouldSort: false, allowHTML: true, removeItemButton: true, }); - selectElement.choicesInstance = choicesInstance; + selectElement.hasChoicesInstance = true; }; }); @@ -149,6 +149,7 @@ choiceElement.addEventListener("focus", () => { if (choiceElement) { choiceElement.placeholder = "Search..." + choiceElement.style.minWidth = '7ch'; } });