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