Files
iTop/node_modules/tom-select/dist/js/plugins/optgroup_columns.js
Benjamin Dalsass b35151f421 N°7063 - Forms SDK - Add Symfony forms component
error forms issue
2023-12-20 14:26:31 +01:00

160 lines
4.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Tom Select v2.3.1
* Licensed under the Apache License, Version 2.0 (the "License");
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.optgroup_columns = factory());
})(this, (function () { 'use strict';
const KEY_LEFT = 37;
const KEY_RIGHT = 39;
// ctrl key or apple key for ma
/*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */
const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
/** @type {TUnicodeMap} */
const latin_convert = {};
/** @type {TUnicodeMap} */
const latin_condensed = {
'/': '',
'0': '߀',
"a": "ⱥɐɑ",
"aa": "ꜳ",
"ae": "æǽǣ",
"ao": "ꜵ",
"au": "ꜷ",
"av": "ꜹꜻ",
"ay": "ꜽ",
"b": "ƀɓƃ",
"c": "ꜿƈȼↄ",
"d": "đɗɖᴅƌꮷԁɦ",
"e": "ɛǝᴇɇ",
"f": "ꝼƒ",
"g": "ǥɠꞡᵹꝿɢ",
"h": "ħⱨⱶɥ",
"i": "ɨı",
"j": "ɉȷ",
"k": "ƙⱪꝁꝃꝅꞣ",
"l": "łƚɫⱡꝉꝇꞁɭ",
"m": "ɱɯϻ",
"n": "ꞥƞɲꞑᴎлԉ",
"o": "øǿɔɵꝋꝍᴑ",
"oe": "œ",
"oi": "ƣ",
"oo": "ꝏ",
"ou": "ȣ",
"p": "ƥᵽꝑꝓꝕρ",
"q": "ꝗꝙɋ",
"r": "ɍɽꝛꞧꞃ",
"s": "ßȿꞩꞅʂ",
"t": "ŧƭʈⱦꞇ",
"th": "þ",
"tz": "ꜩ",
"u": "ʉ",
"v": "ʋꝟʌ",
"vy": "ꝡ",
"w": "ⱳ",
"y": "ƴɏỿ",
"z": "ƶȥɀⱬꝣ",
"hv": "ƕ"
};
for (let latin in latin_condensed) {
let unicode = latin_condensed[latin] || '';
for (let i = 0; i < unicode.length; i++) {
let char = unicode.substring(i, i + 1);
latin_convert[char] = latin;
}
}
new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
/**
* Get the closest node to the evt.target matching the selector
* Stops at wrapper
*
*/
const parentMatch = (target, selector, wrapper) => {
if (wrapper && !wrapper.contains(target)) {
return;
}
while (target && target.matches) {
if (target.matches(selector)) {
return target;
}
target = target.parentNode;
}
};
/**
* Get the index of an element amongst sibling nodes of the same type
*
*/
const nodeIndex = (el, amongst) => {
if (!el) return -1;
amongst = amongst || el.nodeName;
var i = 0;
while (el = el.previousElementSibling) {
if (el.matches(amongst)) {
i++;
}
}
return i;
};
/**
* Plugin: "optgroup_columns" (Tom Select.js)
* Copyright (c) contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*
*/
function plugin () {
var self = this;
var orig_keydown = self.onKeyDown;
self.hook('instead', 'onKeyDown', evt => {
var index, option, options, optgroup;
if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
return orig_keydown.call(self, evt);
}
self.ignoreHover = true;
optgroup = parentMatch(self.activeOption, '[data-group]');
index = nodeIndex(self.activeOption, '[data-selectable]');
if (!optgroup) {
return;
}
if (evt.keyCode === KEY_LEFT) {
optgroup = optgroup.previousSibling;
} else {
optgroup = optgroup.nextSibling;
}
if (!optgroup) {
return;
}
options = optgroup.querySelectorAll('[data-selectable]');
option = options[Math.min(options.length - 1, index)];
if (option) {
self.setActiveOption(option);
}
});
}
return plugin;
}));
//# sourceMappingURL=optgroup_columns.js.map