Browse code

Add tom select npm package

Benjamin Roth authored on02/02/2023 12:00:30
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,171 @@
1
+/**
2
+* Tom Select v2.2.2
3
+* Licensed under the Apache License, Version 2.0 (the "License");
4
+*/
5
+
6
+(function (global, factory) {
7
+  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
8
+  typeof define === 'function' && define.amd ? define(factory) :
9
+  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.optgroup_columns = factory());
10
+})(this, (function () { 'use strict';
11
+
12
+  const KEY_LEFT = 37;
13
+  const KEY_RIGHT = 39;
14
+  typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
15
+   // ctrl key or apple key for ma
16
+
17
+  /*! @orchidjs/unicode-variants | https://github.com/orchidjs/unicode-variants | Apache License (v2) */
18
+  const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
19
+  /** @type {TUnicodeMap} */
20
+
21
+  const latin_convert = {};
22
+  /** @type {TUnicodeMap} */
23
+
24
+  const latin_condensed = {
25
+    '/': '⁄∕',
26
+    '0': '߀',
27
+    "a": "ⱥɐɑ",
28
+    "aa": "ꜳ",
29
+    "ae": "æǽǣ",
30
+    "ao": "ꜵ",
31
+    "au": "ꜷ",
32
+    "av": "ꜹꜻ",
33
+    "ay": "ꜽ",
34
+    "b": "ƀɓƃ",
35
+    "c": "ꜿƈȼↄ",
36
+    "d": "đɗɖᴅƌꮷԁɦ",
37
+    "e": "ɛǝᴇɇ",
38
+    "f": "ꝼƒ",
39
+    "g": "ǥɠꞡᵹꝿɢ",
40
+    "h": "ħⱨⱶɥ",
41
+    "i": "ɨı",
42
+    "j": "ɉȷ",
43
+    "k": "ƙⱪꝁꝃꝅꞣ",
44
+    "l": "łƚɫⱡꝉꝇꞁɭ",
45
+    "m": "ɱɯϻ",
46
+    "n": "ꞥƞɲꞑᴎлԉ",
47
+    "o": "øǿɔɵꝋꝍᴑ",
48
+    "oe": "œ",
49
+    "oi": "ƣ",
50
+    "oo": "ꝏ",
51
+    "ou": "ȣ",
52
+    "p": "ƥᵽꝑꝓꝕρ",
53
+    "q": "ꝗꝙɋ",
54
+    "r": "ɍɽꝛꞧꞃ",
55
+    "s": "ßȿꞩꞅʂ",
56
+    "t": "ŧƭʈⱦꞇ",
57
+    "th": "þ",
58
+    "tz": "ꜩ",
59
+    "u": "ʉ",
60
+    "v": "ʋꝟʌ",
61
+    "vy": "ꝡ",
62
+    "w": "ⱳ",
63
+    "y": "ƴɏỿ",
64
+    "z": "ƶȥɀⱬꝣ",
65
+    "hv": "ƕ"
66
+  };
67
+
68
+  for (let latin in latin_condensed) {
69
+    let unicode = latin_condensed[latin] || '';
70
+
71
+    for (let i = 0; i < unicode.length; i++) {
72
+      let char = unicode.substring(i, i + 1);
73
+      latin_convert[char] = latin;
74
+    }
75
+  }
76
+
77
+  new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
78
+
79
+  /**
80
+   * Get the closest node to the evt.target matching the selector
81
+   * Stops at wrapper
82
+   *
83
+   */
84
+
85
+  const parentMatch = (target, selector, wrapper) => {
86
+    if (wrapper && !wrapper.contains(target)) {
87
+      return;
88
+    }
89
+
90
+    while (target && target.matches) {
91
+      if (target.matches(selector)) {
92
+        return target;
93
+      }
94
+
95
+      target = target.parentNode;
96
+    }
97
+  };
98
+  /**
99
+   * Get the index of an element amongst sibling nodes of the same type
100
+   *
101
+   */
102
+
103
+  const nodeIndex = (el, amongst) => {
104
+    if (!el) return -1;
105
+    amongst = amongst || el.nodeName;
106
+    var i = 0;
107
+
108
+    while (el = el.previousElementSibling) {
109
+      if (el.matches(amongst)) {
110
+        i++;
111
+      }
112
+    }
113
+
114
+    return i;
115
+  };
116
+
117
+  /**
118
+   * Plugin: "optgroup_columns" (Tom Select.js)
119
+   * Copyright (c) contributors
120
+   *
121
+   * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
122
+   * file except in compliance with the License. You may obtain a copy of the License at:
123
+   * http://www.apache.org/licenses/LICENSE-2.0
124
+   *
125
+   * Unless required by applicable law or agreed to in writing, software distributed under
126
+   * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
127
+   * ANY KIND, either express or implied. See the License for the specific language
128
+   * governing permissions and limitations under the License.
129
+   *
130
+   */
131
+  function plugin () {
132
+    var self = this;
133
+    var orig_keydown = self.onKeyDown;
134
+    self.hook('instead', 'onKeyDown', evt => {
135
+      var index, option, options, optgroup;
136
+
137
+      if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
138
+        return orig_keydown.call(self, evt);
139
+      }
140
+
141
+      self.ignoreHover = true;
142
+      optgroup = parentMatch(self.activeOption, '[data-group]');
143
+      index = nodeIndex(self.activeOption, '[data-selectable]');
144
+
145
+      if (!optgroup) {
146
+        return;
147
+      }
148
+
149
+      if (evt.keyCode === KEY_LEFT) {
150
+        optgroup = optgroup.previousSibling;
151
+      } else {
152
+        optgroup = optgroup.nextSibling;
153
+      }
154
+
155
+      if (!optgroup) {
156
+        return;
157
+      }
158
+
159
+      options = optgroup.querySelectorAll('[data-selectable]');
160
+      option = options[Math.min(options.length - 1, index)];
161
+
162
+      if (option) {
163
+        self.setActiveOption(option);
164
+      }
165
+    });
166
+  }
167
+
168
+  return plugin;
169
+
170
+}));
171
+//# sourceMappingURL=optgroup_columns.js.map