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,84 @@
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.input_autogrow = factory());
10
+})(this, (function () { 'use strict';
11
+
12
+	/**
13
+	 * Converts a scalar to its best string representation
14
+	 * for hash keys and HTML attribute values.
15
+	 *
16
+	 * Transformations:
17
+	 *   'str'     -> 'str'
18
+	 *   null      -> ''
19
+	 *   undefined -> ''
20
+	 *   true      -> '1'
21
+	 *   false     -> '0'
22
+	 *   0         -> '0'
23
+	 *   1         -> '1'
24
+	 *
25
+	 */
26
+	/**
27
+	 * Add event helper
28
+	 *
29
+	 */
30
+
31
+	const addEvent = (target, type, callback, options) => {
32
+	  target.addEventListener(type, callback, options);
33
+	};
34
+
35
+	/**
36
+	 * Plugin: "input_autogrow" (Tom Select)
37
+	 *
38
+	 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
39
+	 * file except in compliance with the License. You may obtain a copy of the License at:
40
+	 * http://www.apache.org/licenses/LICENSE-2.0
41
+	 *
42
+	 * Unless required by applicable law or agreed to in writing, software distributed under
43
+	 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
44
+	 * ANY KIND, either express or implied. See the License for the specific language
45
+	 * governing permissions and limitations under the License.
46
+	 *
47
+	 */
48
+	function plugin () {
49
+	  var self = this;
50
+	  self.on('initialize', () => {
51
+	    var test_input = document.createElement('span');
52
+	    var control = self.control_input;
53
+	    test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
54
+	    self.wrapper.appendChild(test_input);
55
+	    var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
56
+
57
+	    for (const style_name of transfer_styles) {
58
+	      // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
59
+	      test_input.style[style_name] = control.style[style_name];
60
+	    }
61
+	    /**
62
+	     * Set the control width
63
+	     *
64
+	     */
65
+
66
+
67
+	    var resize = () => {
68
+	      test_input.textContent = control.value;
69
+	      control.style.width = test_input.clientWidth + 'px';
70
+	    };
71
+
72
+	    resize();
73
+	    self.on('update item_add item_remove', resize);
74
+	    addEvent(control, 'input', resize);
75
+	    addEvent(control, 'keyup', resize);
76
+	    addEvent(control, 'blur', resize);
77
+	    addEvent(control, 'update', resize);
78
+	  });
79
+	}
80
+
81
+	return plugin;
82
+
83
+}));
84
+//# sourceMappingURL=input_autogrow.js.map