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,51 @@
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.restore_on_backspace = factory());
10
+})(this, (function () { 'use strict';
11
+
12
+	/**
13
+	 * Plugin: "restore_on_backspace" (Tom Select)
14
+	 * Copyright (c) contributors
15
+	 *
16
+	 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
17
+	 * file except in compliance with the License. You may obtain a copy of the License at:
18
+	 * http://www.apache.org/licenses/LICENSE-2.0
19
+	 *
20
+	 * Unless required by applicable law or agreed to in writing, software distributed under
21
+	 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
22
+	 * ANY KIND, either express or implied. See the License for the specific language
23
+	 * governing permissions and limitations under the License.
24
+	 *
25
+	 */
26
+	function plugin (userOptions) {
27
+	  const self = this;
28
+	  const options = Object.assign({
29
+	    text: option => {
30
+	      return option[self.settings.labelField];
31
+	    }
32
+	  }, userOptions);
33
+	  self.on('item_remove', function (value) {
34
+	    if (!self.isFocused) {
35
+	      return;
36
+	    }
37
+
38
+	    if (self.control_input.value.trim() === '') {
39
+	      var option = self.options[value];
40
+
41
+	      if (option) {
42
+	        self.setTextboxValue(options.text.call(self, option));
43
+	      }
44
+	    }
45
+	  });
46
+	}
47
+
48
+	return plugin;
49
+
50
+}));
51
+//# sourceMappingURL=restore_on_backspace.js.map