tom-select-rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +26 -0
  4. data/Rakefile +3 -0
  5. data/lib/tom-select-rails/engine.rb +8 -0
  6. data/lib/tom-select-rails/version.rb +5 -0
  7. data/lib/tom-select-rails.rb +7 -0
  8. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js +4887 -0
  9. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.complete.js.map +1 -0
  10. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js +4085 -0
  11. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js.map +1 -0
  12. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js +4337 -0
  13. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.popular.js.map +1 -0
  14. data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js +196 -0
  15. data/vendor/assets/javascripts/tom-select-rails/cjs/utils.js.map +1 -0
  16. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js +162 -0
  17. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js.map +1 -0
  18. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js +50 -0
  19. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js.map +1 -0
  20. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js +172 -0
  21. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js.map +1 -0
  22. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js +91 -0
  23. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js.map +1 -0
  24. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js +62 -0
  25. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js.map +1 -0
  26. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js +118 -0
  27. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js.map +1 -0
  28. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js +230 -0
  29. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js.map +1 -0
  30. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js +80 -0
  31. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js.map +1 -0
  32. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js +25 -0
  33. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js.map +1 -0
  34. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js +32 -0
  35. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js.map +1 -0
  36. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js +108 -0
  37. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js.map +1 -0
  38. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js +146 -0
  39. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js.map +1 -0
  40. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js +43 -0
  41. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js.map +1 -0
  42. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js +261 -0
  43. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js.map +1 -0
  44. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js +4885 -0
  45. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.complete.js.map +1 -0
  46. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js +4083 -0
  47. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js.map +1 -0
  48. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js +4335 -0
  49. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.popular.js.map +1 -0
  50. data/vendor/assets/javascripts/tom-select-rails/esm/utils.js +181 -0
  51. data/vendor/assets/javascripts/tom-select-rails/esm/utils.js.map +1 -0
  52. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js +170 -0
  53. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js.map +1 -0
  54. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js +58 -0
  55. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js.map +1 -0
  56. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js +180 -0
  57. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js.map +1 -0
  58. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js +99 -0
  59. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js.map +1 -0
  60. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js +70 -0
  61. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js.map +1 -0
  62. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js +126 -0
  63. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js.map +1 -0
  64. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js +238 -0
  65. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js.map +1 -0
  66. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js +88 -0
  67. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js.map +1 -0
  68. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js +33 -0
  69. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js.map +1 -0
  70. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js +40 -0
  71. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js.map +1 -0
  72. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js +116 -0
  73. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js.map +1 -0
  74. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js +154 -0
  75. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js.map +1 -0
  76. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js +51 -0
  77. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js.map +1 -0
  78. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js +269 -0
  79. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js.map +1 -0
  80. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js +4092 -0
  81. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js.map +1 -0
  82. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js +303 -0
  83. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js.map +1 -0
  84. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js +4894 -0
  85. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js.map +1 -0
  86. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js +362 -0
  87. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js.map +1 -0
  88. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js +4344 -0
  89. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js.map +1 -0
  90. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js +324 -0
  91. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js.map +1 -0
  92. data/vendor/assets/javascripts/tom-select-rails/types/constants.d.ts +12 -0
  93. data/vendor/assets/javascripts/tom-select-rails/types/contrib/highlight.d.ts +13 -0
  94. data/vendor/assets/javascripts/tom-select-rails/types/contrib/microevent.d.ts +20 -0
  95. data/vendor/assets/javascripts/tom-select-rails/types/contrib/microplugin.d.ts +71 -0
  96. data/vendor/assets/javascripts/tom-select-rails/types/defaults.d.ts +51 -0
  97. data/vendor/assets/javascripts/tom-select-rails/types/getSettings.d.ts +3 -0
  98. data/vendor/assets/javascripts/tom-select-rails/types/plugins/caret_position/plugin.d.ts +16 -0
  99. data/vendor/assets/javascripts/tom-select-rails/types/plugins/change_listener/plugin.d.ts +16 -0
  100. data/vendor/assets/javascripts/tom-select-rails/types/plugins/checkbox_options/plugin.d.ts +16 -0
  101. data/vendor/assets/javascripts/tom-select-rails/types/plugins/clear_button/plugin.d.ts +17 -0
  102. data/vendor/assets/javascripts/tom-select-rails/types/plugins/clear_button/types.d.ts +5 -0
  103. data/vendor/assets/javascripts/tom-select-rails/types/plugins/drag_drop/plugin.d.ts +16 -0
  104. data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_header/plugin.d.ts +17 -0
  105. data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_header/types.d.ts +8 -0
  106. data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_input/plugin.d.ts +16 -0
  107. data/vendor/assets/javascripts/tom-select-rails/types/plugins/input_autogrow/plugin.d.ts +15 -0
  108. data/vendor/assets/javascripts/tom-select-rails/types/plugins/no_active_items/plugin.d.ts +15 -0
  109. data/vendor/assets/javascripts/tom-select-rails/types/plugins/no_backspace_delete/plugin.d.ts +15 -0
  110. data/vendor/assets/javascripts/tom-select-rails/types/plugins/optgroup_columns/plugin.d.ts +16 -0
  111. data/vendor/assets/javascripts/tom-select-rails/types/plugins/remove_button/plugin.d.ts +17 -0
  112. data/vendor/assets/javascripts/tom-select-rails/types/plugins/remove_button/types.d.ts +6 -0
  113. data/vendor/assets/javascripts/tom-select-rails/types/plugins/restore_on_backspace/plugin.d.ts +21 -0
  114. data/vendor/assets/javascripts/tom-select-rails/types/plugins/virtual_scroll/plugin.d.ts +16 -0
  115. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.complete.d.ts +2 -0
  116. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.d.ts +579 -0
  117. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.popular.d.ts +2 -0
  118. data/vendor/assets/javascripts/tom-select-rails/types/types/core.d.ts +44 -0
  119. data/vendor/assets/javascripts/tom-select-rails/types/types/index.d.ts +2 -0
  120. data/vendor/assets/javascripts/tom-select-rails/types/types/settings.d.ts +81 -0
  121. data/vendor/assets/javascripts/tom-select-rails/types/utils.d.ts +76 -0
  122. data/vendor/assets/javascripts/tom-select-rails/types/vanilla.d.ts +76 -0
  123. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css +548 -0
  124. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css.map +1 -0
  125. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css +2 -0
  126. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css.map +1 -0
  127. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css +592 -0
  128. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css.map +1 -0
  129. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css +2 -0
  130. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css.map +1 -0
  131. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css +391 -0
  132. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css.map +1 -0
  133. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css +476 -0
  134. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css.map +1 -0
  135. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css +2 -0
  136. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css.map +1 -0
  137. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css +2 -0
  138. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css.map +1 -0
  139. data/vendor/assets/stylesheets/tom-select-rails/scss/_dropdown.scss +104 -0
  140. data/vendor/assets/stylesheets/tom-select-rails/scss/_items.scss +115 -0
  141. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/checkbox_options.scss +5 -0
  142. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/clear_button.scss +30 -0
  143. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/drag_drop.scss +16 -0
  144. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/dropdown_header.scss +23 -0
  145. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/dropdown_input.scss +47 -0
  146. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/input_autogrow.scss +18 -0
  147. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/optgroup_columns.scss +23 -0
  148. data/vendor/assets/stylesheets/tom-select-rails/scss/plugins/remove_button.scss +44 -0
  149. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap4.scss +219 -0
  150. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.bootstrap5.scss +274 -0
  151. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.default.scss +87 -0
  152. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.scss +175 -0
  153. metadata +195 -0
@@ -0,0 +1,579 @@
1
+ import Sifter from '@orchidjs/sifter/lib/sifter';
2
+ import { TomInput, TomArgObject, TomOption, TomOptions, TomCreateCallback, TomItem, TomSettings, TomTemplateNames } from './types/index';
3
+ declare const TomSelect_base: {
4
+ new (): {
5
+ [x: string]: any;
6
+ plugins: {
7
+ names: string[];
8
+ settings: {
9
+ [key: string]: any;
10
+ };
11
+ requested: {
12
+ [key: string]: boolean;
13
+ };
14
+ loaded: {
15
+ [key: string]: any;
16
+ };
17
+ };
18
+ initializePlugins(plugins: string[] | import("./contrib/microplugin").TPluginHash | import("./contrib/microplugin").TPluginItem[]): void;
19
+ loadPlugin(name: string): void;
20
+ require(name: string): any;
21
+ };
22
+ [x: string]: any;
23
+ define(name: string, fn: (this: any, settings: {
24
+ [key: string]: any;
25
+ }) => any): void;
26
+ };
27
+ export default class TomSelect extends TomSelect_base {
28
+ control_input: HTMLInputElement;
29
+ wrapper: HTMLElement;
30
+ dropdown: HTMLElement;
31
+ control: HTMLElement;
32
+ dropdown_content: HTMLElement;
33
+ focus_node: HTMLElement;
34
+ order: number;
35
+ settings: TomSettings;
36
+ input: TomInput;
37
+ tabIndex: number;
38
+ is_select_tag: boolean;
39
+ rtl: boolean;
40
+ private inputId;
41
+ private _destroy;
42
+ sifter: Sifter;
43
+ isOpen: boolean;
44
+ isDisabled: boolean;
45
+ isRequired: boolean;
46
+ isInvalid: boolean;
47
+ isValid: boolean;
48
+ isLocked: boolean;
49
+ isFocused: boolean;
50
+ isInputHidden: boolean;
51
+ isSetup: boolean;
52
+ ignoreFocus: boolean;
53
+ hasOptions: boolean;
54
+ currentResults?: ReturnType<Sifter['search']>;
55
+ lastValue: string;
56
+ caretPos: number;
57
+ loading: number;
58
+ loadedSearches: {
59
+ [key: string]: boolean;
60
+ };
61
+ activeOption: null | HTMLElement;
62
+ activeItems: TomItem[];
63
+ optgroups: TomOptions;
64
+ options: TomOptions;
65
+ userOptions: {
66
+ [key: string]: boolean;
67
+ };
68
+ items: string[];
69
+ constructor(input_arg: string | TomInput, user_settings: Partial<TomSettings>);
70
+ /**
71
+ * set up event bindings.
72
+ *
73
+ */
74
+ setup(): void;
75
+ /**
76
+ * Register options and optgroups
77
+ *
78
+ */
79
+ setupOptions(options?: TomOption[], optgroups?: TomOption[]): void;
80
+ /**
81
+ * Sets up default rendering functions.
82
+ */
83
+ setupTemplates(): void;
84
+ /**
85
+ * Maps fired events to callbacks provided
86
+ * in the settings used when creating the control.
87
+ */
88
+ setupCallbacks(): void;
89
+ /**
90
+ * Sync the Tom Select instance with the original input or select
91
+ *
92
+ */
93
+ sync(get_settings?: boolean): void;
94
+ /**
95
+ * Triggered when the main control element
96
+ * has a click event.
97
+ *
98
+ */
99
+ onClick(): void;
100
+ /**
101
+ * @deprecated v1.7
102
+ *
103
+ */
104
+ onMouseDown(): void;
105
+ /**
106
+ * Triggered when the value of the control has been changed.
107
+ * This should propagate the event to the original DOM
108
+ * input / select element.
109
+ */
110
+ onChange(): void;
111
+ /**
112
+ * Triggered on <input> paste.
113
+ *
114
+ */
115
+ onPaste(e: MouseEvent | KeyboardEvent): void;
116
+ /**
117
+ * Triggered on <input> keypress.
118
+ *
119
+ */
120
+ onKeyPress(e: KeyboardEvent): void;
121
+ /**
122
+ * Triggered on <input> keydown.
123
+ *
124
+ */
125
+ onKeyDown(e: KeyboardEvent): void;
126
+ /**
127
+ * Triggered on <input> keyup.
128
+ *
129
+ */
130
+ onInput(e: MouseEvent | KeyboardEvent): void;
131
+ /**
132
+ * Triggered on <input> focus.
133
+ *
134
+ */
135
+ onFocus(e?: MouseEvent | KeyboardEvent): void;
136
+ /**
137
+ * Triggered on <input> blur.
138
+ *
139
+ */
140
+ onBlur(e?: FocusEvent): void;
141
+ /**
142
+ * Triggered when the user clicks on an option
143
+ * in the autocomplete dropdown menu.
144
+ *
145
+ */
146
+ onOptionSelect(evt: MouseEvent | KeyboardEvent, option: HTMLElement): void;
147
+ /**
148
+ * Return true if the given option can be selected
149
+ *
150
+ */
151
+ canSelect(option: HTMLElement | null): boolean;
152
+ /**
153
+ * Triggered when the user clicks on an item
154
+ * that has been selected.
155
+ *
156
+ */
157
+ onItemSelect(evt?: MouseEvent, item?: TomItem): boolean;
158
+ /**
159
+ * Determines whether or not to invoke
160
+ * the user-provided option provider / loader
161
+ *
162
+ * Note, there is a subtle difference between
163
+ * this.canLoad() and this.settings.shouldLoad();
164
+ *
165
+ * - settings.shouldLoad() is a user-input validator.
166
+ * When false is returned, the not_loading template
167
+ * will be added to the dropdown
168
+ *
169
+ * - canLoad() is lower level validator that checks
170
+ * the Tom Select instance. There is no inherent user
171
+ * feedback when canLoad returns false
172
+ *
173
+ */
174
+ canLoad(value: string): boolean;
175
+ /**
176
+ * Invokes the user-provided option provider / loader.
177
+ *
178
+ */
179
+ load(value: string): void;
180
+ /**
181
+ * Invoked by the user-provided option provider
182
+ *
183
+ */
184
+ loadCallback(options: TomOption[], optgroups: TomOption[]): void;
185
+ preload(): void;
186
+ /**
187
+ * Sets the input field of the control to the specified value.
188
+ *
189
+ */
190
+ setTextboxValue(value?: string): void;
191
+ /**
192
+ * Returns the value of the control. If multiple items
193
+ * can be selected (e.g. <select multiple>), this returns
194
+ * an array. If only one item can be selected, this
195
+ * returns a string.
196
+ *
197
+ */
198
+ getValue(): string | string[];
199
+ /**
200
+ * Resets the selected items to the given value.
201
+ *
202
+ */
203
+ setValue(value: string | string[], silent?: boolean): void;
204
+ /**
205
+ * Resets the number of max items to the given value
206
+ *
207
+ */
208
+ setMaxItems(value: null | number): void;
209
+ /**
210
+ * Sets the selected item.
211
+ *
212
+ */
213
+ setActiveItem(item?: TomItem, e?: MouseEvent | KeyboardEvent): void;
214
+ /**
215
+ * Set the active and last-active classes
216
+ *
217
+ */
218
+ setActiveItemClass(item: TomItem): void;
219
+ /**
220
+ * Remove active item
221
+ *
222
+ */
223
+ removeActiveItem(item: TomItem): void;
224
+ /**
225
+ * Clears all the active items
226
+ *
227
+ */
228
+ clearActiveItems(): void;
229
+ /**
230
+ * Sets the selected item in the dropdown menu
231
+ * of available options.
232
+ *
233
+ */
234
+ setActiveOption(option: null | HTMLElement): void;
235
+ /**
236
+ * Sets the dropdown_content scrollTop to display the option
237
+ *
238
+ */
239
+ scrollToOption(option: null | HTMLElement, behavior?: string): void;
240
+ /**
241
+ * Scroll the dropdown to the given position
242
+ *
243
+ */
244
+ scroll(scrollTop: number, behavior?: string): void;
245
+ /**
246
+ * Clears the active option
247
+ *
248
+ */
249
+ clearActiveOption(): void;
250
+ /**
251
+ * Selects all items (CTRL + A).
252
+ */
253
+ selectAll(): void;
254
+ /**
255
+ * Determines if the control_input should be in a hidden or visible state
256
+ *
257
+ */
258
+ inputState(): void;
259
+ /**
260
+ * Hides the input element out of view, while
261
+ * retaining its focus.
262
+ * @deprecated 1.3
263
+ */
264
+ hideInput(): void;
265
+ /**
266
+ * Restores input visibility.
267
+ * @deprecated 1.3
268
+ */
269
+ showInput(): void;
270
+ /**
271
+ * Get the input value
272
+ */
273
+ inputValue(): string;
274
+ /**
275
+ * Gives the control focus.
276
+ */
277
+ focus(): void;
278
+ /**
279
+ * Forces the control out of focus.
280
+ *
281
+ */
282
+ blur(): void;
283
+ /**
284
+ * Returns a function that scores an object
285
+ * to show how good of a match it is to the
286
+ * provided query.
287
+ *
288
+ * @return {function}
289
+ */
290
+ getScoreFunction(query: string): (data: {}) => any;
291
+ /**
292
+ * Returns search options for sifter (the system
293
+ * for scoring and sorting results).
294
+ *
295
+ * @see https://github.com/orchidjs/sifter.js
296
+ * @return {object}
297
+ */
298
+ getSearchOptions(): {
299
+ fields: string[];
300
+ conjunction: string;
301
+ sort: string | import("@orchidjs/sifter/lib/types").SortFn | import("@orchidjs/sifter/lib/types").Sort[];
302
+ nesting: boolean;
303
+ };
304
+ /**
305
+ * Searches through available options and returns
306
+ * a sorted array of matches.
307
+ *
308
+ */
309
+ search(query: string): ReturnType<Sifter['search']>;
310
+ /**
311
+ * Refreshes the list of available options shown
312
+ * in the autocomplete dropdown menu.
313
+ *
314
+ */
315
+ refreshOptions(triggerDropdown?: boolean): void;
316
+ /**
317
+ * Return list of selectable options
318
+ *
319
+ */
320
+ selectable(): NodeList;
321
+ /**
322
+ * Adds an available option. If it already exists,
323
+ * nothing will happen. Note: this does not refresh
324
+ * the options list dropdown (use `refreshOptions`
325
+ * for that).
326
+ *
327
+ * Usage:
328
+ *
329
+ * this.addOption(data)
330
+ *
331
+ */
332
+ addOption(data: TomOption, user_created?: boolean): false | string;
333
+ /**
334
+ * Add multiple options
335
+ *
336
+ */
337
+ addOptions(data: TomOption[], user_created?: boolean): void;
338
+ /**
339
+ * @deprecated 1.7.7
340
+ */
341
+ registerOption(data: TomOption): false | string;
342
+ /**
343
+ * Registers an option group to the pool of option groups.
344
+ *
345
+ * @return {boolean|string}
346
+ */
347
+ registerOptionGroup(data: TomOption): string | false;
348
+ /**
349
+ * Registers a new optgroup for options
350
+ * to be bucketed into.
351
+ *
352
+ */
353
+ addOptionGroup(id: string, data: TomOption): void;
354
+ /**
355
+ * Removes an existing option group.
356
+ *
357
+ */
358
+ removeOptionGroup(id: string): void;
359
+ /**
360
+ * Clears all existing option groups.
361
+ */
362
+ clearOptionGroups(): void;
363
+ /**
364
+ * Updates an option available for selection. If
365
+ * it is visible in the selected items or options
366
+ * dropdown, it will be re-rendered automatically.
367
+ *
368
+ */
369
+ updateOption(value: string, data: TomOption): void;
370
+ /**
371
+ * Removes a single option.
372
+ *
373
+ */
374
+ removeOption(value: string, silent?: boolean): void;
375
+ /**
376
+ * Clears all options.
377
+ */
378
+ clearOptions(): void;
379
+ /**
380
+ * Returns the dom element of the option
381
+ * matching the given value.
382
+ *
383
+ */
384
+ getOption(value: null | string, create?: boolean): null | HTMLElement;
385
+ /**
386
+ * Returns the dom element of the next or previous dom element of the same type
387
+ * Note: adjacent options may not be adjacent DOM elements (optgroups)
388
+ *
389
+ */
390
+ getAdjacent(option: null | HTMLElement, direction: number, type?: string): HTMLElement | null;
391
+ /**
392
+ * Returns the dom element of the item
393
+ * matching the given value.
394
+ *
395
+ */
396
+ getItem(item: string | TomItem | null): null | TomItem;
397
+ /**
398
+ * "Selects" multiple items at once. Adds them to the list
399
+ * at the current caret position.
400
+ *
401
+ */
402
+ addItems(values: string | string[], silent?: boolean): void;
403
+ /**
404
+ * "Selects" an item. Adds it to the list
405
+ * at the current caret position.
406
+ *
407
+ */
408
+ addItem(value: string, silent?: boolean): void;
409
+ /**
410
+ * Removes the selected item matching
411
+ * the provided value.
412
+ *
413
+ */
414
+ removeItem(item?: string | TomItem | null, silent?: boolean): void;
415
+ /**
416
+ * Invokes the `create` method provided in the
417
+ * TomSelect options that should provide the data
418
+ * for the new item, given the user input.
419
+ *
420
+ * Once this completes, it will be added
421
+ * to the item list.
422
+ *
423
+ */
424
+ createItem(input?: null | string, triggerDropdown?: boolean, callback?: TomCreateCallback): boolean;
425
+ /**
426
+ * Re-renders the selected item lists.
427
+ */
428
+ refreshItems(): void;
429
+ /**
430
+ * Updates all state-dependent attributes
431
+ * and CSS classes.
432
+ */
433
+ refreshState(): void;
434
+ /**
435
+ * Update the `required` attribute of both input and control input.
436
+ *
437
+ * The `required` property needs to be activated on the control input
438
+ * for the error to be displayed at the right place. `required` also
439
+ * needs to be temporarily deactivated on the input since the input is
440
+ * hidden and can't show errors.
441
+ */
442
+ refreshValidityState(): void;
443
+ /**
444
+ * Determines whether or not more items can be added
445
+ * to the control without exceeding the user-defined maximum.
446
+ *
447
+ * @returns {boolean}
448
+ */
449
+ isFull(): boolean;
450
+ /**
451
+ * Refreshes the original <select> or <input>
452
+ * element to reflect the current state.
453
+ *
454
+ */
455
+ updateOriginalInput(opts?: TomArgObject): void;
456
+ /**
457
+ * Shows the autocomplete dropdown containing
458
+ * the available options.
459
+ */
460
+ open(): void;
461
+ /**
462
+ * Closes the autocomplete dropdown menu.
463
+ */
464
+ close(setTextboxValue?: boolean): void;
465
+ /**
466
+ * Calculates and applies the appropriate
467
+ * position of the dropdown if dropdownParent = 'body'.
468
+ * Otherwise, position is determined by css
469
+ */
470
+ positionDropdown(): void;
471
+ /**
472
+ * Resets / clears all selected items
473
+ * from the control.
474
+ *
475
+ */
476
+ clear(silent?: boolean): void;
477
+ /**
478
+ * A helper method for inserting an element
479
+ * at the current caret position.
480
+ *
481
+ */
482
+ insertAtCaret(el: HTMLElement): void;
483
+ /**
484
+ * Removes the current selected item(s).
485
+ *
486
+ */
487
+ deleteSelection(e: KeyboardEvent): boolean;
488
+ /**
489
+ * Selects the previous / next item (depending on the `direction` argument).
490
+ *
491
+ * > 0 - right
492
+ * < 0 - left
493
+ *
494
+ */
495
+ advanceSelection(direction: number, e?: MouseEvent | KeyboardEvent): void;
496
+ moveCaret(direction: number): void;
497
+ /**
498
+ * Get the last active item
499
+ *
500
+ */
501
+ getLastActive(direction?: number): any;
502
+ /**
503
+ * Moves the caret to the specified index.
504
+ *
505
+ * The input must be moved by leaving it in place and moving the
506
+ * siblings, due to the fact that focus cannot be restored once lost
507
+ * on mobile webkit devices
508
+ *
509
+ */
510
+ setCaret(new_pos: number): void;
511
+ /**
512
+ * Return list of item dom elements
513
+ *
514
+ */
515
+ controlChildren(): TomItem[];
516
+ /**
517
+ * Disables user input on the control. Used while
518
+ * items are being asynchronously created.
519
+ */
520
+ lock(): void;
521
+ /**
522
+ * Re-enables user input on the control.
523
+ */
524
+ unlock(): void;
525
+ /**
526
+ * Disables user input on the control completely.
527
+ * While disabled, it cannot receive focus.
528
+ */
529
+ disable(): void;
530
+ /**
531
+ * Enables the control so that it can respond
532
+ * to focus and user input.
533
+ */
534
+ enable(): void;
535
+ /**
536
+ * Completely destroys the control and
537
+ * unbinds all event listeners so that it can
538
+ * be garbage collected.
539
+ */
540
+ destroy(): void;
541
+ /**
542
+ * A helper method for rendering "item" and
543
+ * "option" templates, given the data.
544
+ *
545
+ */
546
+ render(templateName: TomTemplateNames, data?: any): null | HTMLElement;
547
+ /**
548
+ * _render() can be called directly when we know we don't want to hit the cache
549
+ * return type could be null for some templates, we need https://github.com/microsoft/TypeScript/issues/33014
550
+ */
551
+ _render(templateName: TomTemplateNames, data?: any): HTMLElement;
552
+ /**
553
+ * Clears the render cache for a template. If
554
+ * no template is given, clears all render
555
+ * caches.
556
+ *
557
+ */
558
+ clearCache(): void;
559
+ /**
560
+ * Removes a value from item and option caches
561
+ *
562
+ */
563
+ uncacheValue(value: string): void;
564
+ /**
565
+ * Determines whether or not to display the
566
+ * create item prompt, given a user input.
567
+ *
568
+ */
569
+ canCreate(input: string): boolean;
570
+ /**
571
+ * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
572
+ *
573
+ * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
574
+ *
575
+ * });
576
+ */
577
+ hook(when: string, method: string, new_fn: any): void;
578
+ }
579
+ export {};
@@ -0,0 +1,2 @@
1
+ import TomSelect from './tom-select';
2
+ export default TomSelect;
@@ -0,0 +1,44 @@
1
+ import TomSelect from '../tom-select';
2
+ import { escape_html } from '../utils';
3
+ export interface TomInput extends HTMLElement {
4
+ tomselect?: TomSelect;
5
+ disabled: boolean;
6
+ required: boolean;
7
+ value: string;
8
+ type: string;
9
+ checkValidity: () => boolean;
10
+ }
11
+ export declare type TomArgObject = {
12
+ silent?: boolean;
13
+ };
14
+ export declare type TomOption = {
15
+ [key: string]: any;
16
+ };
17
+ export declare type TomOptions = {
18
+ [key: string]: TomOption;
19
+ };
20
+ export declare type TomCreateFilter = (input: string) => boolean;
21
+ export declare type TomCreateCallback = (data?: TomOption) => void;
22
+ export declare type TomCreate = (input: string, create: TomCreateCallback) => boolean;
23
+ export interface TomItem extends HTMLElement {
24
+ dataset: {
25
+ value: string;
26
+ };
27
+ }
28
+ export declare type TomLoadCallback = TomSelect['loadCallback'];
29
+ export declare type TomTemplate = (data: TomOption, escape: typeof escape_html) => string | HTMLElement;
30
+ export declare type TomTemplateNull = (data: TomOption, escape: typeof escape_html) => null | string | HTMLElement;
31
+ export declare type TomTemplates = {
32
+ 'dropdown': TomTemplate;
33
+ 'optgroup': TomTemplate;
34
+ 'optgroup_header': TomTemplate;
35
+ 'option': TomTemplate;
36
+ 'item': TomTemplate;
37
+ 'option_create': TomTemplate;
38
+ 'no_results': TomTemplate;
39
+ 'loading': TomTemplate;
40
+ 'not_loading': TomTemplateNull;
41
+ 'loading_more': TomTemplateNull;
42
+ 'no_more_results': TomTemplateNull;
43
+ };
44
+ export declare type TomTemplateNames = keyof TomTemplates;
@@ -0,0 +1,2 @@
1
+ export * from './core';
2
+ export * from './settings';
@@ -0,0 +1,81 @@
1
+ import { TomCreateFilter, TomCreate, TomLoadCallback } from './index';
2
+ import { escape_html } from '../utils';
3
+ import { TPluginItem, TPluginHash } from '../contrib/microplugin';
4
+ import * as SifterTypes from '@orchidjs/sifter/lib/types';
5
+ export declare type TomSettings = {
6
+ options?: any[];
7
+ optgroups?: any[];
8
+ items?: string[];
9
+ plugins: string[] | TPluginItem[] | TPluginHash;
10
+ delimiter: string;
11
+ splitOn: RegExp | string;
12
+ persist: boolean;
13
+ diacritics: boolean;
14
+ create: boolean | TomCreate;
15
+ createOnBlur: boolean;
16
+ createFilter: RegExp | string | TomCreateFilter;
17
+ highlight: boolean;
18
+ openOnFocus: boolean;
19
+ shouldOpen: boolean;
20
+ maxOptions: number;
21
+ maxItems: null | number;
22
+ hideSelected: boolean;
23
+ duplicates: boolean;
24
+ addPrecedence: boolean;
25
+ selectOnTab: boolean;
26
+ preload: boolean | string;
27
+ allowEmptyOption: boolean;
28
+ closeAfterSelect: boolean;
29
+ loadThrottle: number;
30
+ loadingClass: string;
31
+ dataAttr: string;
32
+ optgroupField: string;
33
+ valueField: string;
34
+ labelField: string;
35
+ disabledField: string;
36
+ optgroupLabelField: string;
37
+ optgroupValueField: string;
38
+ lockOptgroupOrder: boolean;
39
+ sortField: string | SifterTypes.Sort[] | SifterTypes.SortFn;
40
+ searchField: string[];
41
+ searchConjunction: string;
42
+ nesting: boolean;
43
+ mode: string;
44
+ wrapperClass: string;
45
+ controlClass: string;
46
+ dropdownClass: string;
47
+ dropdownContentClass: string;
48
+ itemClass: string;
49
+ optionClass: string;
50
+ dropdownParent: string;
51
+ controlInput: string | HTMLInputElement;
52
+ copyClassesToDropdown: boolean;
53
+ placeholder: string;
54
+ hidePlaceholder: boolean;
55
+ load: (value: string, callback: TomLoadCallback) => void;
56
+ score?: (query: string) => () => any;
57
+ shouldLoad: (query: string) => boolean;
58
+ onInitialize: (evt: Event) => void;
59
+ onChange: (evt: Event) => void;
60
+ onItemAdd: (evt: Event) => void;
61
+ onItemRemove: (evt: Event) => void;
62
+ onClear: (evt: Event) => void;
63
+ onOptionAdd: (evt: Event) => void;
64
+ onOptionRemove: (evt: Event) => void;
65
+ onOptionClear: (evt: Event) => void;
66
+ onOptionGroupAdd: (evt: Event) => void;
67
+ onOptionGroupRemove: (evt: Event) => void;
68
+ onOptionGroupClear: (evt: Event) => void;
69
+ onDropdownOpen: (evt: Event) => void;
70
+ onDropdownClose: (evt: Event) => void;
71
+ onType: (evt: Event) => void;
72
+ onLoad: (evt: Event) => void;
73
+ onFocus: (evt: Event) => void;
74
+ onBlur: (evt: Event) => void;
75
+ onDelete: (values: string[], evt: KeyboardEvent | MouseEvent) => boolean;
76
+ render: {
77
+ [key: string]: (data: any, escape: typeof escape_html) => string | HTMLElement;
78
+ };
79
+ firstUrl: (query: string) => any;
80
+ shouldLoadMore: () => boolean;
81
+ };