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