This commit is contained in:
Xon 2025-02-27 13:16:54 +00:00
commit e468a28d14
10 changed files with 151 additions and 139 deletions

View file

@ -1,4 +1,4 @@
/*! choices.js v11.0.5 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v11.0.6 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@ -3822,15 +3822,9 @@
if (clearSearchFlag) {
_this._isSearching = false;
}
var items = {};
if (!replaceItems) {
_this._store.items.forEach(function (item) {
items[item.value] = item;
});
}
// Clear choices if needed
if (replaceChoices) {
_this.clearChoices();
_this.clearChoices(true, replaceItems);
}
var isDefaultValue = value === 'value';
var isDefaultLabel = label === 'label';
@ -3848,9 +3842,6 @@
choice = __assign(__assign({}, choice), { value: choice[value], label: choice[label] });
}
var choiceFull = mapInputToChoice(choice, false);
if (!replaceItems && choiceFull.value in items) {
choiceFull.selected = true;
}
_this._addChoice(choiceFull);
if (choiceFull.placeholder && !_this._hasNonChoicePlaceholder) {
_this._placeholderValue = unwrapStringForEscaped(choiceFull.label);
@ -3936,22 +3927,38 @@
}
return this;
};
Choices.prototype.clearChoices = function (clearOptions) {
Choices.prototype.clearChoices = function (clearOptions, clearItems) {
var _this = this;
if (clearOptions === void 0) { clearOptions = true; }
if (clearItems === void 0) { clearItems = false; }
if (clearOptions) {
this.passedElement.element.replaceChildren('');
if (clearItems) {
this.passedElement.element.replaceChildren('');
}
else {
this.passedElement.element.querySelectorAll(':not([selected])').forEach(function (el) {
el.remove();
});
}
}
this.itemList.element.replaceChildren('');
this.choiceList.element.replaceChildren('');
this._clearNotice();
this._store.reset();
this._store.withTxn(function () {
var items = clearItems ? [] : _this._store.items;
_this._store.reset();
items.forEach(function (item) {
_this._store.dispatch(addChoice(item));
_this._store.dispatch(addItem(item));
});
});
// @todo integrate with Store
this._searcher.reset();
return this;
};
Choices.prototype.clearStore = function (clearOptions) {
if (clearOptions === void 0) { clearOptions = true; }
this.clearChoices(clearOptions);
this.clearChoices(clearOptions, true);
this._stopSearch();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
@ -4809,7 +4816,6 @@
if (target === this.input.element) {
return;
}
var preventDefault = true;
var item = target.closest('[data-button],[data-item],[data-choice]');
if (item instanceof HTMLElement) {
if ('button' in item.dataset) {
@ -4817,16 +4823,12 @@
}
else if ('item' in item.dataset) {
this._handleItemAction(item, event.shiftKey);
// don't prevent default to support dragging
preventDefault = false;
}
else if ('choice' in item.dataset) {
this._handleChoiceAction(item);
}
}
if (preventDefault) {
event.preventDefault();
}
event.preventDefault();
};
/**
* Handles mouseover event over this.dropdown
@ -5218,7 +5220,7 @@
throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it"));
}
};
Choices.version = '11.0.5';
Choices.version = '11.0.6';
return Choices;
}());

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
/*! choices.js v11.0.5 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v11.0.6 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/******************************************************************************
Copyright (c) Microsoft Corporation.
@ -3816,15 +3816,9 @@ var Choices = /** @class */ (function () {
if (clearSearchFlag) {
_this._isSearching = false;
}
var items = {};
if (!replaceItems) {
_this._store.items.forEach(function (item) {
items[item.value] = item;
});
}
// Clear choices if needed
if (replaceChoices) {
_this.clearChoices();
_this.clearChoices(true, replaceItems);
}
var isDefaultValue = value === 'value';
var isDefaultLabel = label === 'label';
@ -3842,9 +3836,6 @@ var Choices = /** @class */ (function () {
choice = __assign(__assign({}, choice), { value: choice[value], label: choice[label] });
}
var choiceFull = mapInputToChoice(choice, false);
if (!replaceItems && choiceFull.value in items) {
choiceFull.selected = true;
}
_this._addChoice(choiceFull);
if (choiceFull.placeholder && !_this._hasNonChoicePlaceholder) {
_this._placeholderValue = unwrapStringForEscaped(choiceFull.label);
@ -3930,22 +3921,38 @@ var Choices = /** @class */ (function () {
}
return this;
};
Choices.prototype.clearChoices = function (clearOptions) {
Choices.prototype.clearChoices = function (clearOptions, clearItems) {
var _this = this;
if (clearOptions === void 0) { clearOptions = true; }
if (clearItems === void 0) { clearItems = false; }
if (clearOptions) {
this.passedElement.element.replaceChildren('');
if (clearItems) {
this.passedElement.element.replaceChildren('');
}
else {
this.passedElement.element.querySelectorAll(':not([selected])').forEach(function (el) {
el.remove();
});
}
}
this.itemList.element.replaceChildren('');
this.choiceList.element.replaceChildren('');
this._clearNotice();
this._store.reset();
this._store.withTxn(function () {
var items = clearItems ? [] : _this._store.items;
_this._store.reset();
items.forEach(function (item) {
_this._store.dispatch(addChoice(item));
_this._store.dispatch(addItem(item));
});
});
// @todo integrate with Store
this._searcher.reset();
return this;
};
Choices.prototype.clearStore = function (clearOptions) {
if (clearOptions === void 0) { clearOptions = true; }
this.clearChoices(clearOptions);
this.clearChoices(clearOptions, true);
this._stopSearch();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
@ -4803,7 +4810,6 @@ var Choices = /** @class */ (function () {
if (target === this.input.element) {
return;
}
var preventDefault = true;
var item = target.closest('[data-button],[data-item],[data-choice]');
if (item instanceof HTMLElement) {
if ('button' in item.dataset) {
@ -4811,16 +4817,12 @@ var Choices = /** @class */ (function () {
}
else if ('item' in item.dataset) {
this._handleItemAction(item, event.shiftKey);
// don't prevent default to support dragging
preventDefault = false;
}
else if ('choice' in item.dataset) {
this._handleChoiceAction(item);
}
}
if (preventDefault) {
event.preventDefault();
}
event.preventDefault();
};
/**
* Handles mouseover event over this.dropdown
@ -5212,7 +5214,7 @@ var Choices = /** @class */ (function () {
throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it"));
}
};
Choices.version = '11.0.5';
Choices.version = '11.0.6';
return Choices;
}());

View file

@ -1,4 +1,4 @@
/*! choices.js v11.0.5 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v11.0.6 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@ -3340,15 +3340,9 @@
if (clearSearchFlag) {
_this._isSearching = false;
}
var items = {};
if (!replaceItems) {
_this._store.items.forEach(function (item) {
items[item.value] = item;
});
}
// Clear choices if needed
if (replaceChoices) {
_this.clearChoices();
_this.clearChoices(true, replaceItems);
}
var isDefaultValue = value === 'value';
var isDefaultLabel = label === 'label';
@ -3366,9 +3360,6 @@
choice = __assign(__assign({}, choice), { value: choice[value], label: choice[label] });
}
var choiceFull = mapInputToChoice(choice, false);
if (!replaceItems && choiceFull.value in items) {
choiceFull.selected = true;
}
_this._addChoice(choiceFull);
if (choiceFull.placeholder && !_this._hasNonChoicePlaceholder) {
_this._placeholderValue = unwrapStringForEscaped(choiceFull.label);
@ -3454,22 +3445,38 @@
}
return this;
};
Choices.prototype.clearChoices = function (clearOptions) {
Choices.prototype.clearChoices = function (clearOptions, clearItems) {
var _this = this;
if (clearOptions === void 0) { clearOptions = true; }
if (clearItems === void 0) { clearItems = false; }
if (clearOptions) {
this.passedElement.element.replaceChildren('');
if (clearItems) {
this.passedElement.element.replaceChildren('');
}
else {
this.passedElement.element.querySelectorAll(':not([selected])').forEach(function (el) {
el.remove();
});
}
}
this.itemList.element.replaceChildren('');
this.choiceList.element.replaceChildren('');
this._clearNotice();
this._store.reset();
this._store.withTxn(function () {
var items = clearItems ? [] : _this._store.items;
_this._store.reset();
items.forEach(function (item) {
_this._store.dispatch(addChoice(item));
_this._store.dispatch(addItem(item));
});
});
// @todo integrate with Store
this._searcher.reset();
return this;
};
Choices.prototype.clearStore = function (clearOptions) {
if (clearOptions === void 0) { clearOptions = true; }
this.clearChoices(clearOptions);
this.clearChoices(clearOptions, true);
this._stopSearch();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
@ -4327,7 +4334,6 @@
if (target === this.input.element) {
return;
}
var preventDefault = true;
var item = target.closest('[data-button],[data-item],[data-choice]');
if (item instanceof HTMLElement) {
if ('button' in item.dataset) {
@ -4335,16 +4341,12 @@
}
else if ('item' in item.dataset) {
this._handleItemAction(item, event.shiftKey);
// don't prevent default to support dragging
preventDefault = false;
}
else if ('choice' in item.dataset) {
this._handleChoiceAction(item);
}
}
if (preventDefault) {
event.preventDefault();
}
event.preventDefault();
};
/**
* Handles mouseover event over this.dropdown
@ -4736,7 +4738,7 @@
throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it"));
}
};
Choices.version = '11.0.5';
Choices.version = '11.0.6';
return Choices;
}());

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
/*! choices.js v11.0.5 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v11.0.6 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/******************************************************************************
Copyright (c) Microsoft Corporation.
@ -3334,15 +3334,9 @@ var Choices = /** @class */ (function () {
if (clearSearchFlag) {
_this._isSearching = false;
}
var items = {};
if (!replaceItems) {
_this._store.items.forEach(function (item) {
items[item.value] = item;
});
}
// Clear choices if needed
if (replaceChoices) {
_this.clearChoices();
_this.clearChoices(true, replaceItems);
}
var isDefaultValue = value === 'value';
var isDefaultLabel = label === 'label';
@ -3360,9 +3354,6 @@ var Choices = /** @class */ (function () {
choice = __assign(__assign({}, choice), { value: choice[value], label: choice[label] });
}
var choiceFull = mapInputToChoice(choice, false);
if (!replaceItems && choiceFull.value in items) {
choiceFull.selected = true;
}
_this._addChoice(choiceFull);
if (choiceFull.placeholder && !_this._hasNonChoicePlaceholder) {
_this._placeholderValue = unwrapStringForEscaped(choiceFull.label);
@ -3448,22 +3439,38 @@ var Choices = /** @class */ (function () {
}
return this;
};
Choices.prototype.clearChoices = function (clearOptions) {
Choices.prototype.clearChoices = function (clearOptions, clearItems) {
var _this = this;
if (clearOptions === void 0) { clearOptions = true; }
if (clearItems === void 0) { clearItems = false; }
if (clearOptions) {
this.passedElement.element.replaceChildren('');
if (clearItems) {
this.passedElement.element.replaceChildren('');
}
else {
this.passedElement.element.querySelectorAll(':not([selected])').forEach(function (el) {
el.remove();
});
}
}
this.itemList.element.replaceChildren('');
this.choiceList.element.replaceChildren('');
this._clearNotice();
this._store.reset();
this._store.withTxn(function () {
var items = clearItems ? [] : _this._store.items;
_this._store.reset();
items.forEach(function (item) {
_this._store.dispatch(addChoice(item));
_this._store.dispatch(addItem(item));
});
});
// @todo integrate with Store
this._searcher.reset();
return this;
};
Choices.prototype.clearStore = function (clearOptions) {
if (clearOptions === void 0) { clearOptions = true; }
this.clearChoices(clearOptions);
this.clearChoices(clearOptions, true);
this._stopSearch();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
@ -4321,7 +4328,6 @@ var Choices = /** @class */ (function () {
if (target === this.input.element) {
return;
}
var preventDefault = true;
var item = target.closest('[data-button],[data-item],[data-choice]');
if (item instanceof HTMLElement) {
if ('button' in item.dataset) {
@ -4329,16 +4335,12 @@ var Choices = /** @class */ (function () {
}
else if ('item' in item.dataset) {
this._handleItemAction(item, event.shiftKey);
// don't prevent default to support dragging
preventDefault = false;
}
else if ('choice' in item.dataset) {
this._handleChoiceAction(item);
}
}
if (preventDefault) {
event.preventDefault();
}
event.preventDefault();
};
/**
* Handles mouseover event over this.dropdown
@ -4730,7 +4732,7 @@ var Choices = /** @class */ (function () {
throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it"));
}
};
Choices.version = '11.0.5';
Choices.version = '11.0.6';
return Choices;
}());

View file

@ -1,4 +1,4 @@
/*! choices.js v11.0.5 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v11.0.6 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@ -2182,15 +2182,9 @@
if (clearSearchFlag) {
_this._isSearching = false;
}
var items = {};
if (!replaceItems) {
_this._store.items.forEach(function (item) {
items[item.value] = item;
});
}
// Clear choices if needed
if (replaceChoices) {
_this.clearChoices();
_this.clearChoices(true, replaceItems);
}
var isDefaultValue = value === 'value';
var isDefaultLabel = label === 'label';
@ -2208,9 +2202,6 @@
choice = __assign(__assign({}, choice), { value: choice[value], label: choice[label] });
}
var choiceFull = mapInputToChoice(choice, false);
if (!replaceItems && choiceFull.value in items) {
choiceFull.selected = true;
}
_this._addChoice(choiceFull);
if (choiceFull.placeholder && !_this._hasNonChoicePlaceholder) {
_this._placeholderValue = unwrapStringForEscaped(choiceFull.label);
@ -2296,22 +2287,38 @@
}
return this;
};
Choices.prototype.clearChoices = function (clearOptions) {
Choices.prototype.clearChoices = function (clearOptions, clearItems) {
var _this = this;
if (clearOptions === void 0) { clearOptions = true; }
if (clearItems === void 0) { clearItems = false; }
if (clearOptions) {
this.passedElement.element.replaceChildren('');
if (clearItems) {
this.passedElement.element.replaceChildren('');
}
else {
this.passedElement.element.querySelectorAll(':not([selected])').forEach(function (el) {
el.remove();
});
}
}
this.itemList.element.replaceChildren('');
this.choiceList.element.replaceChildren('');
this._clearNotice();
this._store.reset();
this._store.withTxn(function () {
var items = clearItems ? [] : _this._store.items;
_this._store.reset();
items.forEach(function (item) {
_this._store.dispatch(addChoice(item));
_this._store.dispatch(addItem(item));
});
});
// @todo integrate with Store
this._searcher.reset();
return this;
};
Choices.prototype.clearStore = function (clearOptions) {
if (clearOptions === void 0) { clearOptions = true; }
this.clearChoices(clearOptions);
this.clearChoices(clearOptions, true);
this._stopSearch();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
@ -3169,7 +3176,6 @@
if (target === this.input.element) {
return;
}
var preventDefault = true;
var item = target.closest('[data-button],[data-item],[data-choice]');
if (item instanceof HTMLElement) {
if ('button' in item.dataset) {
@ -3177,16 +3183,12 @@
}
else if ('item' in item.dataset) {
this._handleItemAction(item, event.shiftKey);
// don't prevent default to support dragging
preventDefault = false;
}
else if ('choice' in item.dataset) {
this._handleChoiceAction(item);
}
}
if (preventDefault) {
event.preventDefault();
}
event.preventDefault();
};
/**
* Handles mouseover event over this.dropdown
@ -3578,7 +3580,7 @@
throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it"));
}
};
Choices.version = '11.0.5';
Choices.version = '11.0.6';
return Choices;
}());

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
/*! choices.js v11.0.5 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v11.0.6 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/******************************************************************************
Copyright (c) Microsoft Corporation.
@ -2176,15 +2176,9 @@ var Choices = /** @class */ (function () {
if (clearSearchFlag) {
_this._isSearching = false;
}
var items = {};
if (!replaceItems) {
_this._store.items.forEach(function (item) {
items[item.value] = item;
});
}
// Clear choices if needed
if (replaceChoices) {
_this.clearChoices();
_this.clearChoices(true, replaceItems);
}
var isDefaultValue = value === 'value';
var isDefaultLabel = label === 'label';
@ -2202,9 +2196,6 @@ var Choices = /** @class */ (function () {
choice = __assign(__assign({}, choice), { value: choice[value], label: choice[label] });
}
var choiceFull = mapInputToChoice(choice, false);
if (!replaceItems && choiceFull.value in items) {
choiceFull.selected = true;
}
_this._addChoice(choiceFull);
if (choiceFull.placeholder && !_this._hasNonChoicePlaceholder) {
_this._placeholderValue = unwrapStringForEscaped(choiceFull.label);
@ -2290,22 +2281,38 @@ var Choices = /** @class */ (function () {
}
return this;
};
Choices.prototype.clearChoices = function (clearOptions) {
Choices.prototype.clearChoices = function (clearOptions, clearItems) {
var _this = this;
if (clearOptions === void 0) { clearOptions = true; }
if (clearItems === void 0) { clearItems = false; }
if (clearOptions) {
this.passedElement.element.replaceChildren('');
if (clearItems) {
this.passedElement.element.replaceChildren('');
}
else {
this.passedElement.element.querySelectorAll(':not([selected])').forEach(function (el) {
el.remove();
});
}
}
this.itemList.element.replaceChildren('');
this.choiceList.element.replaceChildren('');
this._clearNotice();
this._store.reset();
this._store.withTxn(function () {
var items = clearItems ? [] : _this._store.items;
_this._store.reset();
items.forEach(function (item) {
_this._store.dispatch(addChoice(item));
_this._store.dispatch(addItem(item));
});
});
// @todo integrate with Store
this._searcher.reset();
return this;
};
Choices.prototype.clearStore = function (clearOptions) {
if (clearOptions === void 0) { clearOptions = true; }
this.clearChoices(clearOptions);
this.clearChoices(clearOptions, true);
this._stopSearch();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
@ -3163,7 +3170,6 @@ var Choices = /** @class */ (function () {
if (target === this.input.element) {
return;
}
var preventDefault = true;
var item = target.closest('[data-button],[data-item],[data-choice]');
if (item instanceof HTMLElement) {
if ('button' in item.dataset) {
@ -3171,16 +3177,12 @@ var Choices = /** @class */ (function () {
}
else if ('item' in item.dataset) {
this._handleItemAction(item, event.shiftKey);
// don't prevent default to support dragging
preventDefault = false;
}
else if ('choice' in item.dataset) {
this._handleChoiceAction(item);
}
}
if (preventDefault) {
event.preventDefault();
}
event.preventDefault();
};
/**
* Handles mouseover event over this.dropdown
@ -3572,7 +3574,7 @@ var Choices = /** @class */ (function () {
throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it"));
}
};
Choices.version = '11.0.5';
Choices.version = '11.0.6';
return Choices;
}());

View file

@ -145,7 +145,7 @@ declare class Choices {
setChoices(choicesArrayOrFetcher?: (InputChoice | InputGroup)[] | ((instance: Choices) => (InputChoice | InputGroup)[] | Promise<(InputChoice | InputGroup)[]>), value?: string | null, label?: string, replaceChoices?: boolean, clearSearchFlag?: boolean, replaceItems?: boolean): this | Promise<this>;
refresh(withEvents?: boolean, selectFirstOption?: boolean, deselectAll?: boolean): this;
removeChoice(value: string): this;
clearChoices(clearOptions?: boolean): this;
clearChoices(clearOptions?: boolean, clearItems?: boolean): this;
clearStore(clearOptions?: boolean): this;
clearInput(): this;
_validateConfig(): void;