regenerate assets

This commit is contained in:
alex 2023-07-25 10:31:40 +02:00
parent 561a61de0f
commit 774eee1f84
8 changed files with 104 additions and 40 deletions

View file

@ -1,4 +1,4 @@
/*! choices.js v10.2.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v10.2.0 | © 2023 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
@ -390,7 +390,7 @@ var Choices = /** @class */function () {
this._store.subscribe(this._render);
this._render();
this._addEventListeners();
var shouldDisable = !this.config.addItems || this.passedElement.element.hasAttribute('disabled');
var shouldDisable = this.passedElement.element.hasAttribute('disabled');
if (shouldDisable) {
this.disable();
}
@ -785,8 +785,13 @@ var Choices = /** @class */function () {
Choices.prototype._renderChoices = function () {
var _this = this;
var _a = this._store,
activeItems = _a.activeItems,
disabledChoices = _a.disabledChoices,
choices = _a.choices,
activeGroups = _a.activeGroups,
activeChoices = _a.activeChoices;
var value = this.input.value;
var canAddItem = this._canAddItem(activeItems, value);
var choiceListFragment = document.createDocumentFragment();
this.choiceList.clear();
if (this.config.resetScrollPosition) {
@ -809,14 +814,34 @@ var Choices = /** @class */function () {
}
// If we have choices to show
if (choiceListFragment.childNodes && choiceListFragment.childNodes.length > 0) {
var activeItems = this._store.activeItems;
var canAddItem = this._canAddItem(activeItems, this.input.value);
var addNotice = false;
// ...and we can select them
if (canAddItem.response) {
// ...append them and highlight the first choice
// ...append them
this.choiceList.append(choiceListFragment);
this._highlightChoice();
// ...handle case that items can be added
if (this.config.addItems && value) {
var isInChoices = (0, utils_1.existsInArray)(choices, value);
addNotice = true;
if (this._isSelectMultipleElement && (0, utils_1.existsInArray)(disabledChoices, value)) {
// adding disabled element is disabled here, so remove message
addNotice = false;
} else if (this._isSelectOneElement && isInChoices) {
// adding existing element is disabled here, so remove message
addNotice = false;
}
// ...highlight the first choice when element exists in choices
if (isInChoices) {
this._highlightChoice();
}
} else {
// ...highlight the first choice
this._highlightChoice();
}
} else {
addNotice = true;
}
if (addNotice) {
var notice = this._getTemplate('notice', canAddItem.notice);
this.choiceList.append(notice);
}
@ -824,7 +849,9 @@ var Choices = /** @class */function () {
// Otherwise show a notice
var dropdownItem = void 0;
var notice = void 0;
if (this._isSearching) {
if (this.config.addItems && canAddItem.response && value) {
dropdownItem = this._getTemplate('notice', canAddItem.notice);
} else if (this._isSearching) {
notice = typeof this.config.noResultsText === 'function' ? this.config.noResultsText() : this.config.noResultsText;
dropdownItem = this._getTemplate('notice', notice, 'no-results');
} else {
@ -1166,10 +1193,10 @@ var Choices = /** @class */function () {
canAddItem = false;
notice = typeof this.config.uniqueItemText === 'function' ? this.config.uniqueItemText(value) : this.config.uniqueItemText;
}
if (this._isTextElement && this.config.addItems && canAddItem && typeof this.config.addItemFilter === 'function' && !this.config.addItemFilter(value)) {
canAddItem = false;
notice = typeof this.config.customAddItemText === 'function' ? this.config.customAddItemText(value) : this.config.customAddItemText;
}
}
if (this.config.addItems && canAddItem && typeof this.config.addItemFilter === 'function' && !this.config.addItemFilter(value)) {
canAddItem = false;
notice = typeof this.config.customAddItemText === 'function' ? this.config.customAddItemText(value) : this.config.customAddItemText;
}
return {
response: canAddItem,
@ -1259,7 +1286,10 @@ var Choices = /** @class */function () {
};
Choices.prototype._onKeyDown = function (event) {
var keyCode = event.keyCode;
var activeItems = this._store.activeItems;
var _a = this._store,
activeItems = _a.activeItems,
choices = _a.choices,
disabledChoices = _a.disabledChoices;
var hasFocusedInput = this.input.isFocussed;
var hasActiveDropdown = this.dropdown.isActive;
var hasItems = this.itemList.hasChildren();
@ -1290,14 +1320,22 @@ var Choices = /** @class */function () {
case A_KEY:
return this._onSelectKey(event, hasItems);
case ENTER_KEY:
return this._onEnterKey(event, activeItems, hasActiveDropdown);
// existing choices are not producable
if (this._isSelectOneElement) {
return this._onEnterKey(event, activeItems, choices, hasActiveDropdown);
}
return this._onEnterKey(event, activeItems, disabledChoices, hasActiveDropdown);
case ESC_KEY:
return this._onEscapeKey(hasActiveDropdown);
case UP_KEY:
case PAGE_UP_KEY:
case DOWN_KEY:
case PAGE_DOWN_KEY:
return this._onDirectionKey(event, hasActiveDropdown);
// don't activate deselect for existing choices
if (this._isSelectOneElement) {
return this._onDirectionKey(event, activeItems, choices, hasActiveDropdown);
}
return this._onDirectionKey(event, activeItems, disabledChoices, hasActiveDropdown);
case DELETE_KEY:
case BACK_KEY:
return this._onDeleteKey(event, activeItems, hasFocusedInput);
@ -1312,10 +1350,10 @@ var Choices = /** @class */function () {
var canAddItem = this._canAddItem(activeItems, value);
var backKey = constants_1.KEY_CODES.BACK_KEY,
deleteKey = constants_1.KEY_CODES.DELETE_KEY;
var canShowDropdownNotice = this.config.addItems && canAddItem.notice && value;
// We are typing into a text input and have a value, we want to show a dropdown
// notice. Otherwise hide the dropdown
if (this._isTextElement) {
var canShowDropdownNotice = canAddItem.notice && value;
if (canShowDropdownNotice) {
var dropdownItem = this._getTemplate('notice', canAddItem.notice);
this.dropdown.element.innerHTML = dropdownItem.outerHTML;
@ -1331,7 +1369,7 @@ var Choices = /** @class */function () {
if (userHasRemovedValue && canReactivateChoices) {
this._isSearching = false;
this._store.dispatch((0, choices_1.activateChoices)(true));
} else if (canSearch) {
} else if (canSearch || canShowDropdownNotice) {
this._handleSearch(this.input.rawValue);
}
}
@ -1350,28 +1388,17 @@ var Choices = /** @class */function () {
}
}
};
Choices.prototype._onEnterKey = function (event, activeItems, hasActiveDropdown) {
Choices.prototype._onEnterKey = function (event, activeItems, nonproducibleChoices, hasActiveDropdown) {
var target = event.target;
var enterKey = constants_1.KEY_CODES.ENTER_KEY;
var targetWasButton = target && target.hasAttribute('data-button');
if (this._isTextElement && target && target.value) {
var value = this.input.value;
var canAddItem = this._canAddItem(activeItems, value);
if (canAddItem.response) {
this.hideDropdown(true);
this._addItem({
value: value
});
this._triggerChange(value);
this.clearInput();
}
}
var highlightedChoice = null;
if (targetWasButton) {
this._handleButtonAction(activeItems, target);
event.preventDefault();
}
if (hasActiveDropdown) {
var highlightedChoice = this.dropdown.getChild(".".concat(this.config.classNames.highlightedState));
highlightedChoice = this.dropdown.getChild(".".concat(this.config.classNames.highlightedState));
if (highlightedChoice) {
// add enter keyCode value
if (activeItems[0]) {
@ -1384,6 +1411,19 @@ var Choices = /** @class */function () {
} else if (this._isSelectOneElement) {
this.showDropdown();
event.preventDefault();
return;
}
if (this.config.addItems && !highlightedChoice && target && target.value) {
var value = this.input.value;
var canAddItem = this._canAddItem(activeItems, value);
if (canAddItem.response && !(0, utils_1.existsInArray)(nonproducibleChoices, value)) {
this.hideDropdown(true);
this._setChoiceOrItem({
value: value
});
this._triggerChange(value);
this.clearInput();
}
}
};
Choices.prototype._onEscapeKey = function (hasActiveDropdown) {
@ -1392,9 +1432,10 @@ var Choices = /** @class */function () {
this.containerOuter.focus();
}
};
Choices.prototype._onDirectionKey = function (event, hasActiveDropdown) {
Choices.prototype._onDirectionKey = function (event, activeItems, nonproducibleChoices, hasActiveDropdown) {
var keyCode = event.keyCode,
metaKey = event.metaKey;
metaKey = event.metaKey,
target = event.target;
var downKey = constants_1.KEY_CODES.DOWN_KEY,
pageUpKey = constants_1.KEY_CODES.PAGE_UP_KEY,
pageDownKey = constants_1.KEY_CODES.PAGE_DOWN_KEY;
@ -1427,6 +1468,13 @@ var Choices = /** @class */function () {
this.choiceList.scrollToChildElement(nextEl, directionInt);
}
this._highlightChoice(nextEl);
} else if (this.config.addItems && target && target.value) {
// can unselect all items for creating new options
var value = this.input.value;
var canAddItem = this._canAddItem(activeItems, value);
if (canAddItem.response && !(0, utils_1.existsInArray)(nonproducibleChoices, value)) {
this.unhighlightAll();
}
}
// Prevent default to maintain cursor position whilst
// traversing dropdown options
@ -3759,6 +3807,18 @@ var Store = /** @class */function () {
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "disabledChoices", {
/**
* Get disabled choices from store
*/
get: function () {
return this.choices.filter(function (choice) {
return choice.disabled === true;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "selectableChoices", {
/**
* Get selectable choices from store

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
/*! choices.js v10.2.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
/*! choices.js v10.2.0 | © 2023 Josh Johnson | https://github.com/jshjohnson/Choices#readme */

View file

@ -157,9 +157,9 @@ declare class Choices implements Choices {
_onKeyDown(event: KeyboardEvent): void;
_onKeyUp({ target, keyCode, }: Pick<KeyboardEvent, 'target' | 'keyCode'>): void;
_onSelectKey(event: KeyboardEvent, hasItems: boolean): void;
_onEnterKey(event: KeyboardEvent, activeItems: Item[], hasActiveDropdown: boolean): void;
_onEnterKey(event: KeyboardEvent, activeItems: Item[], nonproducibleChoices: Choice[], hasActiveDropdown: boolean): void;
_onEscapeKey(hasActiveDropdown: boolean): void;
_onDirectionKey(event: KeyboardEvent, hasActiveDropdown: boolean): void;
_onDirectionKey(event: KeyboardEvent, activeItems: Item[], nonproducibleChoices: Choice[], hasActiveDropdown: boolean): void;
_onDeleteKey(event: KeyboardEvent, activeItems: Item[], hasFocusedInput: boolean): void;
_onTouchMove(): void;
_onTouchEnd(event: TouchEvent): void;

File diff suppressed because one or more lines are too long

View file

@ -97,9 +97,9 @@ export interface Options {
*/
maxItemCount: number;
/**
* Whether a user can add items.
* Whether a user can add new items.
*
* **Input types affected:** text
* **Input types affected:** text, select, select-multiple
*
* @default true
*/

View file

@ -38,6 +38,10 @@ export default class Store {
* Get active choices from store
*/
get activeChoices(): Choice[];
/**
* Get disabled choices from store
*/
get disabledChoices(): Choice[];
/**
* Get selectable choices from store
*/

View file

@ -1 +1 @@
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/store/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,IAAI,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC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