Skip to content

Commit

Permalink
Compile JS files
Browse files Browse the repository at this point in the history
  • Loading branch information
Xon committed Sep 4, 2024
1 parent 09e0a97 commit 97a655b
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 89 deletions.
49 changes: 35 additions & 14 deletions public/assets/scripts/choices.js
Original file line number Diff line number Diff line change
Expand Up @@ -3489,7 +3489,7 @@
this.passedElement.reveal();
this.containerOuter.unwrap(this.passedElement.element);
this._store._listeners = []; // prevents select/input value being wiped
this.clearStore();
this.clearStore(false);
this._stopSearch();
this._templates = Choices.defaults.templates;
this.initialised = false;
Expand Down Expand Up @@ -3745,12 +3745,13 @@
* }], 'value', 'label', false);
* ```
*/
Choices.prototype.setChoices = function (choicesArrayOrFetcher, value, label, replaceChoices) {
Choices.prototype.setChoices = function (choicesArrayOrFetcher, value, label, replaceChoices, clearSearchFlag) {
var _this = this;
if (choicesArrayOrFetcher === void 0) { choicesArrayOrFetcher = []; }
if (value === void 0) { value = 'value'; }
if (label === void 0) { label = 'label'; }
if (replaceChoices === void 0) { replaceChoices = false; }
if (clearSearchFlag === void 0) { clearSearchFlag = true; }
if (!this.initialisedOK) {
this._warnChoicesInitFailed('setChoices');
return this;
Expand Down Expand Up @@ -3795,6 +3796,9 @@
}
this.containerOuter.removeLoadingState();
this._store.withTxn(function () {
if (clearSearchFlag) {
_this._isSearching = false;
}
var isDefaultValue = value === 'value';
var isDefaultLabel = label === 'label';
choicesArrayOrFetcher.forEach(function (groupOrChoice) {
Expand Down Expand Up @@ -3841,7 +3845,7 @@
}
});
}
_this.clearStore();
_this.clearStore(false);
choicesFromOptions.forEach(function (groupOrChoice) {
if ('choices' in groupOrChoice) {
return;
Expand Down Expand Up @@ -3890,13 +3894,26 @@
return this;
};
Choices.prototype.clearChoices = function () {
this.passedElement.element.replaceChildren('');
return this.clearStore();
var _this = this;
this._store.withTxn(function () {
_this._store.choices.forEach(function (choice) {
if (!choice.selected) {
_this._store.dispatch(removeChoice(choice));
}
});
});
// @todo integrate with Store
this._searcher.reset();
return this;
};
Choices.prototype.clearStore = function () {
Choices.prototype.clearStore = function (clearOptions) {
if (clearOptions === void 0) { clearOptions = true; }
this._stopSearch();
if (clearOptions) {
this.passedElement.element.replaceChildren('');
}
this.itemList.element.replaceChildren('');
this.choiceList.element.replaceChildren('');
this._stopSearch();
this._store.reset();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
Expand Down Expand Up @@ -4410,19 +4427,18 @@
if (!results.length) {
this._displayNotice(resolveStringFunction(this.config.noResultsText), NoticeTypes.noResults);
}
else if (noticeType === NoticeTypes.noResults) {
else {
this._clearNotice();
}
}
this._store.dispatch(filterChoices(results));
return results.length;
};
Choices.prototype._stopSearch = function () {
var wasSearching = this._isSearching;
this._currentValue = '';
this._isSearching = false;
this._clearNotice();
if (wasSearching) {
if (this._isSearching) {
this._currentValue = '';
this._isSearching = false;
this._clearNotice();
this._store.dispatch(activateChoices(true));
this.passedElement.triggerEvent(EventType.search, {
value: '',
Expand Down Expand Up @@ -4945,11 +4961,16 @@
if (choice.id) {
throw new TypeError('Can not re-add a choice which has already been added');
}
var config = this.config;
if ((this._isSelectElement || !config.duplicateItemsAllowed) &&
this._store.choices.find(function (c) { return config.valueComparer(c.value, choice.value); })) {
return;
}
// Generate unique id, in-place update is required so chaining _addItem works as expected
this._lastAddedChoiceId++;
choice.id = this._lastAddedChoiceId;
choice.elementId = "".concat(this._baseId, "-").concat(this._idNames.itemChoice, "-").concat(choice.id);
var _a = this.config, prependValue = _a.prependValue, appendValue = _a.appendValue;
var prependValue = config.prependValue, appendValue = config.appendValue;
if (prependValue) {
choice.value = prependValue + choice.value;
}
Expand Down
2 changes: 1 addition & 1 deletion public/assets/scripts/choices.min.js

Large diffs are not rendered by default.

49 changes: 35 additions & 14 deletions public/assets/scripts/choices.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3483,7 +3483,7 @@ var Choices = /** @class */ (function () {
this.passedElement.reveal();
this.containerOuter.unwrap(this.passedElement.element);
this._store._listeners = []; // prevents select/input value being wiped
this.clearStore();
this.clearStore(false);
this._stopSearch();
this._templates = Choices.defaults.templates;
this.initialised = false;
Expand Down Expand Up @@ -3739,12 +3739,13 @@ var Choices = /** @class */ (function () {
* }], 'value', 'label', false);
* ```
*/
Choices.prototype.setChoices = function (choicesArrayOrFetcher, value, label, replaceChoices) {
Choices.prototype.setChoices = function (choicesArrayOrFetcher, value, label, replaceChoices, clearSearchFlag) {
var _this = this;
if (choicesArrayOrFetcher === void 0) { choicesArrayOrFetcher = []; }
if (value === void 0) { value = 'value'; }
if (label === void 0) { label = 'label'; }
if (replaceChoices === void 0) { replaceChoices = false; }
if (clearSearchFlag === void 0) { clearSearchFlag = true; }
if (!this.initialisedOK) {
this._warnChoicesInitFailed('setChoices');
return this;
Expand Down Expand Up @@ -3789,6 +3790,9 @@ var Choices = /** @class */ (function () {
}
this.containerOuter.removeLoadingState();
this._store.withTxn(function () {
if (clearSearchFlag) {
_this._isSearching = false;
}
var isDefaultValue = value === 'value';
var isDefaultLabel = label === 'label';
choicesArrayOrFetcher.forEach(function (groupOrChoice) {
Expand Down Expand Up @@ -3835,7 +3839,7 @@ var Choices = /** @class */ (function () {
}
});
}
_this.clearStore();
_this.clearStore(false);
choicesFromOptions.forEach(function (groupOrChoice) {
if ('choices' in groupOrChoice) {
return;
Expand Down Expand Up @@ -3884,13 +3888,26 @@ var Choices = /** @class */ (function () {
return this;
};
Choices.prototype.clearChoices = function () {
this.passedElement.element.replaceChildren('');
return this.clearStore();
var _this = this;
this._store.withTxn(function () {
_this._store.choices.forEach(function (choice) {
if (!choice.selected) {
_this._store.dispatch(removeChoice(choice));
}
});
});
// @todo integrate with Store
this._searcher.reset();
return this;
};
Choices.prototype.clearStore = function () {
Choices.prototype.clearStore = function (clearOptions) {
if (clearOptions === void 0) { clearOptions = true; }
this._stopSearch();
if (clearOptions) {
this.passedElement.element.replaceChildren('');
}
this.itemList.element.replaceChildren('');
this.choiceList.element.replaceChildren('');
this._stopSearch();
this._store.reset();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
Expand Down Expand Up @@ -4404,19 +4421,18 @@ var Choices = /** @class */ (function () {
if (!results.length) {
this._displayNotice(resolveStringFunction(this.config.noResultsText), NoticeTypes.noResults);
}
else if (noticeType === NoticeTypes.noResults) {
else {
this._clearNotice();
}
}
this._store.dispatch(filterChoices(results));
return results.length;
};
Choices.prototype._stopSearch = function () {
var wasSearching = this._isSearching;
this._currentValue = '';
this._isSearching = false;
this._clearNotice();
if (wasSearching) {
if (this._isSearching) {
this._currentValue = '';
this._isSearching = false;
this._clearNotice();
this._store.dispatch(activateChoices(true));
this.passedElement.triggerEvent(EventType.search, {
value: '',
Expand Down Expand Up @@ -4939,11 +4955,16 @@ var Choices = /** @class */ (function () {
if (choice.id) {
throw new TypeError('Can not re-add a choice which has already been added');
}
var config = this.config;
if ((this._isSelectElement || !config.duplicateItemsAllowed) &&
this._store.choices.find(function (c) { return config.valueComparer(c.value, choice.value); })) {
return;
}
// Generate unique id, in-place update is required so chaining _addItem works as expected
this._lastAddedChoiceId++;
choice.id = this._lastAddedChoiceId;
choice.elementId = "".concat(this._baseId, "-").concat(this._idNames.itemChoice, "-").concat(choice.id);
var _a = this.config, prependValue = _a.prependValue, appendValue = _a.appendValue;
var prependValue = config.prependValue, appendValue = config.appendValue;
if (prependValue) {
choice.value = prependValue + choice.value;
}
Expand Down
49 changes: 35 additions & 14 deletions public/assets/scripts/choices.search-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3007,7 +3007,7 @@
this.passedElement.reveal();
this.containerOuter.unwrap(this.passedElement.element);
this._store._listeners = []; // prevents select/input value being wiped
this.clearStore();
this.clearStore(false);
this._stopSearch();
this._templates = Choices.defaults.templates;
this.initialised = false;
Expand Down Expand Up @@ -3263,12 +3263,13 @@
* }], 'value', 'label', false);
* ```
*/
Choices.prototype.setChoices = function (choicesArrayOrFetcher, value, label, replaceChoices) {
Choices.prototype.setChoices = function (choicesArrayOrFetcher, value, label, replaceChoices, clearSearchFlag) {
var _this = this;
if (choicesArrayOrFetcher === void 0) { choicesArrayOrFetcher = []; }
if (value === void 0) { value = 'value'; }
if (label === void 0) { label = 'label'; }
if (replaceChoices === void 0) { replaceChoices = false; }
if (clearSearchFlag === void 0) { clearSearchFlag = true; }
if (!this.initialisedOK) {
this._warnChoicesInitFailed('setChoices');
return this;
Expand Down Expand Up @@ -3313,6 +3314,9 @@
}
this.containerOuter.removeLoadingState();
this._store.withTxn(function () {
if (clearSearchFlag) {
_this._isSearching = false;
}
var isDefaultValue = value === 'value';
var isDefaultLabel = label === 'label';
choicesArrayOrFetcher.forEach(function (groupOrChoice) {
Expand Down Expand Up @@ -3359,7 +3363,7 @@
}
});
}
_this.clearStore();
_this.clearStore(false);
choicesFromOptions.forEach(function (groupOrChoice) {
if ('choices' in groupOrChoice) {
return;
Expand Down Expand Up @@ -3408,13 +3412,26 @@
return this;
};
Choices.prototype.clearChoices = function () {
this.passedElement.element.replaceChildren('');
return this.clearStore();
var _this = this;
this._store.withTxn(function () {
_this._store.choices.forEach(function (choice) {
if (!choice.selected) {
_this._store.dispatch(removeChoice(choice));
}
});
});
// @todo integrate with Store
this._searcher.reset();
return this;
};
Choices.prototype.clearStore = function () {
Choices.prototype.clearStore = function (clearOptions) {
if (clearOptions === void 0) { clearOptions = true; }
this._stopSearch();
if (clearOptions) {
this.passedElement.element.replaceChildren('');
}
this.itemList.element.replaceChildren('');
this.choiceList.element.replaceChildren('');
this._stopSearch();
this._store.reset();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
Expand Down Expand Up @@ -3928,19 +3945,18 @@
if (!results.length) {
this._displayNotice(resolveStringFunction(this.config.noResultsText), NoticeTypes.noResults);
}
else if (noticeType === NoticeTypes.noResults) {
else {
this._clearNotice();
}
}
this._store.dispatch(filterChoices(results));
return results.length;
};
Choices.prototype._stopSearch = function () {
var wasSearching = this._isSearching;
this._currentValue = '';
this._isSearching = false;
this._clearNotice();
if (wasSearching) {
if (this._isSearching) {
this._currentValue = '';
this._isSearching = false;
this._clearNotice();
this._store.dispatch(activateChoices(true));
this.passedElement.triggerEvent(EventType.search, {
value: '',
Expand Down Expand Up @@ -4463,11 +4479,16 @@
if (choice.id) {
throw new TypeError('Can not re-add a choice which has already been added');
}
var config = this.config;
if ((this._isSelectElement || !config.duplicateItemsAllowed) &&
this._store.choices.find(function (c) { return config.valueComparer(c.value, choice.value); })) {
return;
}
// Generate unique id, in-place update is required so chaining _addItem works as expected
this._lastAddedChoiceId++;
choice.id = this._lastAddedChoiceId;
choice.elementId = "".concat(this._baseId, "-").concat(this._idNames.itemChoice, "-").concat(choice.id);
var _a = this.config, prependValue = _a.prependValue, appendValue = _a.appendValue;
var prependValue = config.prependValue, appendValue = config.appendValue;
if (prependValue) {
choice.value = prependValue + choice.value;
}
Expand Down
2 changes: 1 addition & 1 deletion public/assets/scripts/choices.search-basic.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 97a655b

Please sign in to comment.