@drecchia/tom-select 2.5.2-virtual-scroll.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.
- package/LICENSE +202 -0
- package/README.md +104 -0
- package/dist/css/tom-select.bootstrap4.css +573 -0
- package/dist/css/tom-select.bootstrap5.css +612 -0
- package/dist/css/tom-select.css +405 -0
- package/dist/css/tom-select.default.css +497 -0
- package/dist/css/tom-select.default.css.map +1 -0
- package/dist/esm/plugins/caret_position/plugin.js +163 -0
- package/dist/esm/plugins/caret_position/plugin.js.map +1 -0
- package/dist/esm/plugins/change_listener/plugin.js +51 -0
- package/dist/esm/plugins/change_listener/plugin.js.map +1 -0
- package/dist/esm/plugins/checkbox_options/plugin.js +179 -0
- package/dist/esm/plugins/checkbox_options/plugin.js.map +1 -0
- package/dist/esm/plugins/clear_button/plugin.js +76 -0
- package/dist/esm/plugins/clear_button/plugin.js.map +1 -0
- package/dist/esm/plugins/drag_drop/plugin.js +220 -0
- package/dist/esm/plugins/drag_drop/plugin.js.map +1 -0
- package/dist/esm/plugins/dropdown_header/plugin.js +102 -0
- package/dist/esm/plugins/dropdown_header/plugin.js.map +1 -0
- package/dist/esm/plugins/dropdown_input/plugin.js +224 -0
- package/dist/esm/plugins/dropdown_input/plugin.js.map +1 -0
- package/dist/esm/plugins/input_autogrow/plugin.js +74 -0
- package/dist/esm/plugins/input_autogrow/plugin.js.map +1 -0
- package/dist/esm/plugins/local_virtual_scroll/plugin.js +305 -0
- package/dist/esm/plugins/local_virtual_scroll/plugin.js.map +1 -0
- package/dist/esm/plugins/no_active_items/plugin.js +26 -0
- package/dist/esm/plugins/no_active_items/plugin.js.map +1 -0
- package/dist/esm/plugins/no_backspace_delete/plugin.js +32 -0
- package/dist/esm/plugins/no_backspace_delete/plugin.js.map +1 -0
- package/dist/esm/plugins/optgroup_columns/plugin.js +86 -0
- package/dist/esm/plugins/optgroup_columns/plugin.js.map +1 -0
- package/dist/esm/plugins/remove_button/plugin.js +134 -0
- package/dist/esm/plugins/remove_button/plugin.js.map +1 -0
- package/dist/esm/plugins/restore_on_backspace/plugin.js +42 -0
- package/dist/esm/plugins/restore_on_backspace/plugin.js.map +1 -0
- package/dist/esm/plugins/virtual_scroll/plugin.js +272 -0
- package/dist/esm/plugins/virtual_scroll/plugin.js.map +1 -0
- package/dist/js/plugins/caret_position.js +171 -0
- package/dist/js/plugins/caret_position.js.map +1 -0
- package/dist/js/plugins/change_listener.js +59 -0
- package/dist/js/plugins/change_listener.js.map +1 -0
- package/dist/js/plugins/checkbox_options.js +187 -0
- package/dist/js/plugins/checkbox_options.js.map +1 -0
- package/dist/js/plugins/clear_button.js +84 -0
- package/dist/js/plugins/clear_button.js.map +1 -0
- package/dist/js/plugins/drag_drop.js +228 -0
- package/dist/js/plugins/drag_drop.js.map +1 -0
- package/dist/js/plugins/dropdown_header.js +110 -0
- package/dist/js/plugins/dropdown_header.js.map +1 -0
- package/dist/js/plugins/dropdown_input.js +232 -0
- package/dist/js/plugins/dropdown_input.js.map +1 -0
- package/dist/js/plugins/input_autogrow.js +82 -0
- package/dist/js/plugins/input_autogrow.js.map +1 -0
- package/dist/js/plugins/local_virtual_scroll.js +313 -0
- package/dist/js/plugins/local_virtual_scroll.js.map +1 -0
- package/dist/js/plugins/no_active_items.js +34 -0
- package/dist/js/plugins/no_active_items.js.map +1 -0
- package/dist/js/plugins/no_backspace_delete.js +40 -0
- package/dist/js/plugins/no_backspace_delete.js.map +1 -0
- package/dist/js/plugins/optgroup_columns.js +94 -0
- package/dist/js/plugins/optgroup_columns.js.map +1 -0
- package/dist/js/plugins/remove_button.js +142 -0
- package/dist/js/plugins/remove_button.js.map +1 -0
- package/dist/js/plugins/restore_on_backspace.js +50 -0
- package/dist/js/plugins/restore_on_backspace.js.map +1 -0
- package/dist/js/plugins/virtual_scroll.js +280 -0
- package/dist/js/plugins/virtual_scroll.js.map +1 -0
- package/dist/js/tom-select.base.js +4167 -0
- package/dist/js/tom-select.base.js.map +1 -0
- package/dist/js/tom-select.base.min.js +373 -0
- package/dist/js/tom-select.base.min.js.map +1 -0
- package/dist/js/tom-select.complete.js +5364 -0
- package/dist/js/tom-select.complete.js.map +1 -0
- package/dist/js/tom-select.complete.min.js +489 -0
- package/dist/js/tom-select.complete.min.js.map +1 -0
- package/dist/js/tom-select.popular.js +4436 -0
- package/dist/js/tom-select.popular.js.map +1 -0
- package/dist/js/tom-select.popular.min.js +396 -0
- package/dist/js/tom-select.popular.min.js.map +1 -0
- package/dist/types/constants.d.ts +12 -0
- package/dist/types/contrib/highlight.d.ts +13 -0
- package/dist/types/contrib/microevent.d.ts +20 -0
- package/dist/types/contrib/microplugin.d.ts +71 -0
- package/dist/types/defaults.d.ts +53 -0
- package/dist/types/getSettings.d.ts +3 -0
- package/dist/types/plugins/caret_position/plugin.d.ts +16 -0
- package/dist/types/plugins/change_listener/plugin.d.ts +16 -0
- package/dist/types/plugins/checkbox_options/plugin.d.ts +17 -0
- package/dist/types/plugins/checkbox_options/types.d.ts +14 -0
- package/dist/types/plugins/clear_button/plugin.d.ts +17 -0
- package/dist/types/plugins/clear_button/types.d.ts +7 -0
- package/dist/types/plugins/drag_drop/plugin.d.ts +16 -0
- package/dist/types/plugins/dropdown_header/plugin.d.ts +17 -0
- package/dist/types/plugins/dropdown_header/types.d.ts +8 -0
- package/dist/types/plugins/dropdown_input/plugin.d.ts +16 -0
- package/dist/types/plugins/input_autogrow/plugin.d.ts +15 -0
- package/dist/types/plugins/local_virtual_scroll/plugin.d.ts +19 -0
- package/dist/types/plugins/local_virtual_scroll/types.d.ts +14 -0
- package/dist/types/plugins/no_active_items/plugin.d.ts +15 -0
- package/dist/types/plugins/no_backspace_delete/plugin.d.ts +15 -0
- package/dist/types/plugins/optgroup_columns/plugin.d.ts +16 -0
- package/dist/types/plugins/remove_button/plugin.d.ts +17 -0
- package/dist/types/plugins/remove_button/types.d.ts +6 -0
- package/dist/types/plugins/restore_on_backspace/plugin.d.ts +21 -0
- package/dist/types/plugins/virtual_scroll/plugin.d.ts +16 -0
- package/dist/types/tom-select.complete.d.ts +2 -0
- package/dist/types/tom-select.d.ts +594 -0
- package/dist/types/tom-select.popular.d.ts +2 -0
- package/dist/types/types/core.d.ts +50 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/settings.d.ts +81 -0
- package/dist/types/utils.d.ts +95 -0
- package/dist/types/vanilla.d.ts +76 -0
- package/package.json +156 -0
- package/src/constants.ts +13 -0
- package/src/contrib/highlight.ts +81 -0
- package/src/contrib/microevent.ts +73 -0
- package/src/contrib/microplugin.ts +137 -0
- package/src/defaults.ts +95 -0
- package/src/getSettings.ts +176 -0
- package/src/plugins/caret_position/plugin.ts +73 -0
- package/src/plugins/change_listener/plugin.ts +23 -0
- package/src/plugins/checkbox_options/plugin.scss +11 -0
- package/src/plugins/checkbox_options/plugin.ts +130 -0
- package/src/plugins/checkbox_options/types.ts +15 -0
- package/src/plugins/clear_button/plugin.scss +33 -0
- package/src/plugins/clear_button/plugin.ts +54 -0
- package/src/plugins/clear_button/types.ts +8 -0
- package/src/plugins/drag_drop/plugin.scss +10 -0
- package/src/plugins/drag_drop/plugin.ts +143 -0
- package/src/plugins/dropdown_header/plugin.scss +24 -0
- package/src/plugins/dropdown_header/plugin.ts +57 -0
- package/src/plugins/dropdown_header/types.ts +9 -0
- package/src/plugins/dropdown_input/plugin.scss +43 -0
- package/src/plugins/dropdown_input/plugin.ts +97 -0
- package/src/plugins/input_autogrow/plugin.scss +15 -0
- package/src/plugins/input_autogrow/plugin.ts +56 -0
- package/src/plugins/local_virtual_scroll/plugin.ts +309 -0
- package/src/plugins/local_virtual_scroll/types.ts +9 -0
- package/src/plugins/no_active_items/plugin.ts +20 -0
- package/src/plugins/no_backspace_delete/plugin.ts +30 -0
- package/src/plugins/optgroup_columns/plugin.scss +25 -0
- package/src/plugins/optgroup_columns/plugin.ts +59 -0
- package/src/plugins/remove_button/plugin.scss +70 -0
- package/src/plugins/remove_button/plugin.ts +78 -0
- package/src/plugins/remove_button/types.ts +7 -0
- package/src/plugins/restore_on_backspace/plugin.ts +44 -0
- package/src/plugins/virtual_scroll/plugin.ts +219 -0
- package/src/scss/-tom-select.bootstrap4.scss +4 -0
- package/src/scss/-tom-select.bootstrap5.scss +4 -0
- package/src/scss/_dropdown.scss +99 -0
- package/src/scss/_items.scss +114 -0
- package/src/scss/tom-select.bootstrap4.scss +218 -0
- package/src/scss/tom-select.bootstrap5.scss +270 -0
- package/src/scss/tom-select.default.scss +89 -0
- package/src/scss/tom-select.scss +179 -0
- package/src/tom-select.complete.ts +35 -0
- package/src/tom-select.popular.ts +15 -0
- package/src/tom-select.ts +2807 -0
- package/src/types/core.ts +68 -0
- package/src/types/index.ts +3 -0
- package/src/types/settings.ts +98 -0
- package/src/utils.ts +230 -0
- package/src/vanilla.ts +210 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TomCreateOptgroup, TomCreateFilter, TomCreate, TomLoadCallback, TomTemplates, TomOption } from './index.ts';
|
|
2
|
+
import { TPluginItem, TPluginHash } from '../contrib/microplugin.ts';
|
|
3
|
+
import { type Sort as SifterSort, type SortFn as SifterSortFn } from '@orchidjs/sifter';
|
|
4
|
+
export type TomSettings = {
|
|
5
|
+
options?: any[];
|
|
6
|
+
optgroups?: any[];
|
|
7
|
+
items?: string[];
|
|
8
|
+
plugins: string[] | TPluginItem[] | TPluginHash;
|
|
9
|
+
delimiter: string;
|
|
10
|
+
splitOn: RegExp | string;
|
|
11
|
+
persist: boolean;
|
|
12
|
+
diacritics: boolean;
|
|
13
|
+
create: boolean | TomCreate;
|
|
14
|
+
createOnBlur: boolean;
|
|
15
|
+
createFilter: RegExp | string | TomCreateFilter;
|
|
16
|
+
highlight: boolean;
|
|
17
|
+
openOnFocus: boolean;
|
|
18
|
+
shouldOpen: boolean;
|
|
19
|
+
maxOptions: null | number;
|
|
20
|
+
maxItems: null | number;
|
|
21
|
+
hideSelected: boolean;
|
|
22
|
+
duplicates: boolean;
|
|
23
|
+
addPrecedence: boolean;
|
|
24
|
+
selectOnTab: boolean;
|
|
25
|
+
preload: boolean | string;
|
|
26
|
+
allowEmptyOption: boolean;
|
|
27
|
+
closeAfterSelect: boolean;
|
|
28
|
+
clearAfterSelect: boolean;
|
|
29
|
+
refreshThrottle: number;
|
|
30
|
+
loadThrottle: number;
|
|
31
|
+
loadingClass: string;
|
|
32
|
+
dataAttr: string;
|
|
33
|
+
optgroupField: string;
|
|
34
|
+
valueField: string;
|
|
35
|
+
labelField: string;
|
|
36
|
+
disabledField: string;
|
|
37
|
+
optgroupLabelField: string;
|
|
38
|
+
optgroupValueField: string;
|
|
39
|
+
lockOptgroupOrder: boolean;
|
|
40
|
+
optionGroupRegister: TomCreateOptgroup;
|
|
41
|
+
sortField: string | SifterSort[] | SifterSortFn;
|
|
42
|
+
searchField: string[];
|
|
43
|
+
searchConjunction: string;
|
|
44
|
+
nesting: boolean;
|
|
45
|
+
mode: string;
|
|
46
|
+
wrapperClass: string;
|
|
47
|
+
controlClass: string;
|
|
48
|
+
dropdownClass: string;
|
|
49
|
+
dropdownContentClass: string;
|
|
50
|
+
itemClass: string;
|
|
51
|
+
optionClass: string;
|
|
52
|
+
dropdownParent: string;
|
|
53
|
+
controlInput: null | string | HTMLInputElement;
|
|
54
|
+
copyClassesToDropdown: boolean;
|
|
55
|
+
placeholder: string;
|
|
56
|
+
hidePlaceholder: boolean;
|
|
57
|
+
load: (value: string, callback: TomLoadCallback) => void;
|
|
58
|
+
score?: (query: string) => () => any;
|
|
59
|
+
shouldLoad: (query: string) => boolean;
|
|
60
|
+
onInitialize: () => void;
|
|
61
|
+
onChange: (value: string | number) => void;
|
|
62
|
+
onItemAdd: (value: string | number, item: HTMLDivElement) => void;
|
|
63
|
+
onItemRemove: (value: string | number, item: HTMLDivElement) => void;
|
|
64
|
+
onClear: () => void;
|
|
65
|
+
onOptionAdd: (value: string | number, data: TomOption) => void;
|
|
66
|
+
onOptionRemove: (value: string | number) => void;
|
|
67
|
+
onOptionClear: () => void;
|
|
68
|
+
onOptionGroupAdd: (value: string | number, data: TomOption) => void;
|
|
69
|
+
onOptionGroupRemove: (value: string | number) => void;
|
|
70
|
+
onOptionGroupClear: () => void;
|
|
71
|
+
onDropdownOpen: (dropdown: HTMLDivElement) => void;
|
|
72
|
+
onDropdownClose: (dropdown: HTMLDivElement) => void;
|
|
73
|
+
onType: (str: string) => void;
|
|
74
|
+
onLoad: (options: TomOption[], optgroups: TomOption[]) => void;
|
|
75
|
+
onFocus: () => void;
|
|
76
|
+
onBlur: () => void;
|
|
77
|
+
onDelete: (values: string[], evt: KeyboardEvent | MouseEvent) => boolean;
|
|
78
|
+
render: TomTemplates;
|
|
79
|
+
firstUrl: (query: string) => any;
|
|
80
|
+
shouldLoadMore: () => boolean;
|
|
81
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type TomSelect from './tom-select.ts';
|
|
2
|
+
import { TomLoadCallback } from './types/index.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a scalar to its best string representation
|
|
5
|
+
* for hash keys and HTML attribute values.
|
|
6
|
+
*
|
|
7
|
+
* Transformations:
|
|
8
|
+
* 'str' -> 'str'
|
|
9
|
+
* null -> ''
|
|
10
|
+
* undefined -> ''
|
|
11
|
+
* true -> '1'
|
|
12
|
+
* false -> '0'
|
|
13
|
+
* 0 -> '0'
|
|
14
|
+
* 1 -> '1'
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export declare const hash_key: (value: undefined | null | boolean | string | number) => string | null;
|
|
18
|
+
export declare const get_hash: (value: boolean | string | number) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Escapes a string for use within HTML.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare const escape_html: (str: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* use setTimeout if timeout > 0
|
|
26
|
+
*/
|
|
27
|
+
export declare const timeout: (fn: () => void, timeout: number) => number | null;
|
|
28
|
+
/**
|
|
29
|
+
* Debounce the user provided load function
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
export declare const loadDebounce: (fn: (value: string, callback: TomLoadCallback) => void, delay: number) => (this: TomSelect, value: string, callback: TomLoadCallback) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Debounce all fired events types listed in `types`
|
|
35
|
+
* while executing the provided `fn`.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export declare const debounce_events: (self: TomSelect, types: string[], fn: () => void) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Determines the current selection within a text input control.
|
|
41
|
+
* Returns an object containing:
|
|
42
|
+
* - start
|
|
43
|
+
* - length
|
|
44
|
+
*
|
|
45
|
+
* Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
|
|
46
|
+
* - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
|
|
47
|
+
*/
|
|
48
|
+
export declare const getSelection: (input: HTMLInputElement) => {
|
|
49
|
+
start: number;
|
|
50
|
+
length: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Prevent default
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
export declare const preventDefault: (evt?: Event, stop?: boolean) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Add event helper
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
export declare const addEvent: (target: EventTarget, type: string, callback: EventListenerOrEventListenerObject, options?: object) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Return true if the requested key is down
|
|
64
|
+
* Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
|
|
65
|
+
* The current evt may not always set ( eg calling advanceSelection() )
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
export declare const isKeyDown: (key_name: keyof (KeyboardEvent | MouseEvent), evt?: KeyboardEvent | MouseEvent) => boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get the id of an element
|
|
71
|
+
* If the id attribute is not set, set the attribute with the given id
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
export declare const getId: (el: Element, id: string) => string;
|
|
75
|
+
/**
|
|
76
|
+
* Returns a string with backslashes added before characters that need to be escaped.
|
|
77
|
+
*/
|
|
78
|
+
export declare const addSlashes: (str: string) => string;
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
export declare const append: (parent: Element | DocumentFragment, node: string | Node | null | undefined) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Iterates over arrays and hashes.
|
|
85
|
+
*
|
|
86
|
+
* ```
|
|
87
|
+
* iterate(this.items, function(item, id) {
|
|
88
|
+
* // invoked for each item
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
export declare const iterate: (object: [] | {
|
|
94
|
+
[key: string]: any;
|
|
95
|
+
}, callback: (value: any, key: any) => any) => void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return a dom element from either a dom query string, jQuery object, a dom element or html string
|
|
3
|
+
* https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
|
|
4
|
+
*
|
|
5
|
+
* param query should be {}
|
|
6
|
+
*/
|
|
7
|
+
export declare const getDom: (query: any) => HTMLElement;
|
|
8
|
+
export declare const isHtmlString: (arg: any) => boolean;
|
|
9
|
+
export declare const escapeQuery: (query: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Dispatch an event
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export declare const triggerEvent: (dom_el: HTMLElement, event_name: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Apply CSS rules to a dom element
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export declare const applyCSS: (dom_el: HTMLElement, css: {
|
|
20
|
+
[key: string]: string | number;
|
|
21
|
+
}) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Add css classes
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export declare const addClasses: (elmts: HTMLElement | HTMLElement[], ...classes: string[] | string[][]) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Remove css classes
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export declare const removeClasses: (elmts: HTMLElement | HTMLElement[], ...classes: string[] | string[][]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Return arguments
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
export declare const classesArray: (args: string[] | string[][]) => string[];
|
|
37
|
+
/**
|
|
38
|
+
* Create an array from arg if it's not already an array
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
export declare const castAsArray: (arg: any) => Array<any>;
|
|
42
|
+
/**
|
|
43
|
+
* Get the closest node to the evt.target matching the selector
|
|
44
|
+
* Stops at wrapper
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
export declare const parentMatch: (target: null | HTMLElement, selector: string, wrapper?: HTMLElement) => HTMLElement | void;
|
|
48
|
+
/**
|
|
49
|
+
* Get the first or last item from an array
|
|
50
|
+
*
|
|
51
|
+
* > 0 - right (last)
|
|
52
|
+
* <= 0 - left (first)
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
export declare const getTail: (list: Array<any> | NodeList, direction?: number) => any;
|
|
56
|
+
/**
|
|
57
|
+
* Return true if an object is empty
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
export declare const isEmptyObject: (obj: object) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Get the index of an element amongst sibling nodes of the same type
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
export declare const nodeIndex: (el: null | Element, amongst?: string) => number;
|
|
66
|
+
/**
|
|
67
|
+
* Set attributes of an element
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
export declare const setAttr: (el: Element, attrs: {
|
|
71
|
+
[key: string]: null | string | number;
|
|
72
|
+
}) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Replace a node
|
|
75
|
+
*/
|
|
76
|
+
export declare const replaceNode: (existing: Node, replacement: Node) => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@drecchia/tom-select",
|
|
3
|
+
"keywords": [
|
|
4
|
+
"select",
|
|
5
|
+
"ui",
|
|
6
|
+
"form",
|
|
7
|
+
"input",
|
|
8
|
+
"control",
|
|
9
|
+
"autocomplete",
|
|
10
|
+
"tagging",
|
|
11
|
+
"tag"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "dist/cjs/tom-select.complete.js",
|
|
15
|
+
"module": "dist/esm/tom-select.complete.js",
|
|
16
|
+
"browser": "dist/js/tom-select.complete.js",
|
|
17
|
+
"style": "dist/css/tom-select.default.css",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./dist/esm/tom-select.complete.js",
|
|
21
|
+
"require": "./dist/cjs/tom-select.complete.js"
|
|
22
|
+
},
|
|
23
|
+
"./base": {
|
|
24
|
+
"import": "./dist/esm/tom-select.js",
|
|
25
|
+
"require": "./dist/cjs/tom-select.js"
|
|
26
|
+
},
|
|
27
|
+
"./popular": {
|
|
28
|
+
"import": "./dist/esm/tom-select.popular.js",
|
|
29
|
+
"require": "./dist/cjs/tom-select.popular.js"
|
|
30
|
+
},
|
|
31
|
+
"./utils": {
|
|
32
|
+
"import": "./dist/esm/utils.js",
|
|
33
|
+
"require": "./dist/cjs/utils.js"
|
|
34
|
+
},
|
|
35
|
+
"./plugins/*": {
|
|
36
|
+
"import": "./dist/esm/plugins/*",
|
|
37
|
+
"require": "./dist/cjs/plugins/*"
|
|
38
|
+
},
|
|
39
|
+
"./src/*": "./src/*",
|
|
40
|
+
"./dist/*": "./dist/*",
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"description": "Tom Select is a versatile and dynamic <select> UI control. Forked from Selectize.js to provide a framework agnostic autocomplete widget with native-feeling keyboard navigation, it's useful for tagging, contact lists, country selectors, etc.",
|
|
44
|
+
"homepage": "https://tom-select.js.org",
|
|
45
|
+
"version": "2.5.2-virtual-scroll.0",
|
|
46
|
+
"files": [
|
|
47
|
+
"/dist",
|
|
48
|
+
"/src"
|
|
49
|
+
],
|
|
50
|
+
"author": "Josh Schmidt (https://github.com/oyejorge)",
|
|
51
|
+
"contributors": [
|
|
52
|
+
"Brian Reavis <brian@thirdroute.com>",
|
|
53
|
+
"Nicolas CARPi @ Deltablot"
|
|
54
|
+
],
|
|
55
|
+
"license": "Apache-2.0",
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/drecchia/tom-select.git"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@11ty/eleventy": "^3.0.0",
|
|
62
|
+
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
|
|
63
|
+
"@arethetypeswrong/cli": "^0.17.0",
|
|
64
|
+
"@babel/core": "^7.26.0",
|
|
65
|
+
"@babel/preset-env": "^7.26.0",
|
|
66
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
67
|
+
"@lodder/grunt-postcss": "^3.1.1",
|
|
68
|
+
"@popperjs/core": "^2.11.8",
|
|
69
|
+
"@rollup/plugin-alias": "^5.1.1",
|
|
70
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
71
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
72
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
73
|
+
"autoprefixer": "^10.4.20",
|
|
74
|
+
"bootstrap": "npm:bootstrap@4",
|
|
75
|
+
"bootstrap-sass": "^3.4.3",
|
|
76
|
+
"bootstrap5": "npm:bootstrap@^5.3.3",
|
|
77
|
+
"broken-link-checker": "^0.7.8",
|
|
78
|
+
"chai": "^4.5.0",
|
|
79
|
+
"cssnano": "^7.0.6",
|
|
80
|
+
"grunt": "^1.6.1",
|
|
81
|
+
"grunt-cli": "^1.5.0",
|
|
82
|
+
"grunt-contrib-clean": "^2.0.1",
|
|
83
|
+
"grunt-contrib-connect": "^5.0.1",
|
|
84
|
+
"grunt-contrib-copy": "^1.0.0",
|
|
85
|
+
"grunt-contrib-watch": "^1.1.0",
|
|
86
|
+
"grunt-replace": "^2.0.2",
|
|
87
|
+
"grunt-sass": "^3.1.0",
|
|
88
|
+
"grunt-shell": "^4.0.0",
|
|
89
|
+
"husky": "^9.1.6",
|
|
90
|
+
"icon-blender": "^1.0.0-beta.4",
|
|
91
|
+
"jsdom": "^25.0.1",
|
|
92
|
+
"karma": "^6.4.4",
|
|
93
|
+
"karma-browserstack-launcher": "^1.6.0",
|
|
94
|
+
"karma-chai": "^0.1.0",
|
|
95
|
+
"karma-chrome-launcher": "^3.2.0",
|
|
96
|
+
"karma-coverage": "^2.2.1",
|
|
97
|
+
"karma-coveralls": "^2.1.0",
|
|
98
|
+
"karma-firefox-launcher": "^2.1.3",
|
|
99
|
+
"karma-mocha": "^2.0.1",
|
|
100
|
+
"karma-mocha-reporter": "^2.2.5",
|
|
101
|
+
"karma-safari-launcher": "^1.0.0",
|
|
102
|
+
"karma-sourcemap-loader": "^0.4.0",
|
|
103
|
+
"load-grunt-tasks": "^5.1.0",
|
|
104
|
+
"mocha": "^11.0.1",
|
|
105
|
+
"postcss": "^8.4.49",
|
|
106
|
+
"puppeteer": "^24.1.1",
|
|
107
|
+
"rollup": "^4.27.2",
|
|
108
|
+
"rollup-plugin-insert": "^1.3.2",
|
|
109
|
+
"sass": "^1.81.0",
|
|
110
|
+
"stylelint": "^16.10.0",
|
|
111
|
+
"stylelint-config-prettier-scss": "^1.0.0",
|
|
112
|
+
"stylelint-config-standard": "^36.0.1",
|
|
113
|
+
"stylelint-config-standard-scss": "^14.0.0",
|
|
114
|
+
"syn": "^0.15.0",
|
|
115
|
+
"tslib": "^2.8.1",
|
|
116
|
+
"typescript": "^5.7.2"
|
|
117
|
+
},
|
|
118
|
+
"scripts": {
|
|
119
|
+
"build": "grunt build",
|
|
120
|
+
"build:docs": "grunt builddocs",
|
|
121
|
+
"build:js": "npm run build:js:esm && npm run build:js:cjs && npm run build:js:umd",
|
|
122
|
+
"build:js:esm": "tsc -p .config/tsconfig.esm.json",
|
|
123
|
+
"build:js:cjs": "tsc -p .config/tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
|
|
124
|
+
"build:js:umd": "rollup -c .config/rollup.config.mjs && echo '{\"type\":\"commonjs\"}' > ./dist/js/package.json",
|
|
125
|
+
"build:types": "tsc -p .config/tsconfig.types.json",
|
|
126
|
+
"test": "karma start .config/karma.conf.cjs",
|
|
127
|
+
"test:one": "karma start --test_one .config/karma.conf.cjs",
|
|
128
|
+
"test:types": "attw --pack --profile node16 .",
|
|
129
|
+
"start": "grunt serve",
|
|
130
|
+
"pretest": "grunt build",
|
|
131
|
+
"prepare": "husky",
|
|
132
|
+
"stylelint": "stylelint -c .config/stylelintrc.json 'src/**/*.scss'"
|
|
133
|
+
},
|
|
134
|
+
"engines": {
|
|
135
|
+
"node": "*"
|
|
136
|
+
},
|
|
137
|
+
"browserslist": [
|
|
138
|
+
">= 0.5%",
|
|
139
|
+
"not dead",
|
|
140
|
+
"Chrome >= 60",
|
|
141
|
+
"Firefox >= 60",
|
|
142
|
+
"Firefox ESR",
|
|
143
|
+
"Edge >= 17",
|
|
144
|
+
"iOS >= 12",
|
|
145
|
+
"Safari >= 12",
|
|
146
|
+
"not Explorer <= 11"
|
|
147
|
+
],
|
|
148
|
+
"funding": {
|
|
149
|
+
"type": "opencollective",
|
|
150
|
+
"url": "https://opencollective.com/tom-select"
|
|
151
|
+
},
|
|
152
|
+
"dependencies": {
|
|
153
|
+
"@orchidjs/sifter": "^1.1.0",
|
|
154
|
+
"@orchidjs/unicode-variants": "^1.1.2"
|
|
155
|
+
}
|
|
156
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const KEY_A = 65;
|
|
2
|
+
export const KEY_RETURN = 13;
|
|
3
|
+
export const KEY_ESC = 27;
|
|
4
|
+
export const KEY_LEFT = 37;
|
|
5
|
+
export const KEY_UP = 38;
|
|
6
|
+
export const KEY_RIGHT = 39;
|
|
7
|
+
export const KEY_DOWN = 40;
|
|
8
|
+
export const KEY_BACKSPACE = 8;
|
|
9
|
+
export const KEY_DELETE = 46;
|
|
10
|
+
export const KEY_TAB = 9;
|
|
11
|
+
|
|
12
|
+
export const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
|
|
13
|
+
export const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
|
|
3
|
+
* Highlights arbitrary terms in a node.
|
|
4
|
+
*
|
|
5
|
+
* - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
|
|
6
|
+
* - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {replaceNode} from '../vanilla.ts';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const highlight = (element:HTMLElement, regex:string|RegExp) => {
|
|
13
|
+
|
|
14
|
+
if( regex === null ) return;
|
|
15
|
+
|
|
16
|
+
// convet string to regex
|
|
17
|
+
if( typeof regex === 'string' ){
|
|
18
|
+
|
|
19
|
+
if( !regex.length ) return;
|
|
20
|
+
regex = new RegExp(regex, 'i');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// Wrap matching part of text node with highlighting <span>, e.g.
|
|
25
|
+
// Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
|
|
26
|
+
const highlightText = ( node:Text ):number => {
|
|
27
|
+
|
|
28
|
+
var match = node.data.match(regex);
|
|
29
|
+
if( match && node.data.length > 0 ){
|
|
30
|
+
var spannode = document.createElement('span');
|
|
31
|
+
spannode.className = 'highlight';
|
|
32
|
+
var middlebit = node.splitText(match.index as number);
|
|
33
|
+
|
|
34
|
+
middlebit.splitText(match[0]!.length);
|
|
35
|
+
var middleclone = middlebit.cloneNode(true);
|
|
36
|
+
|
|
37
|
+
spannode.appendChild(middleclone);
|
|
38
|
+
replaceNode(middlebit, spannode);
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return 0;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Recurse element node, looking for child text nodes to highlight, unless element
|
|
46
|
+
// is childless, <script>, <style>, or already highlighted: <span class="hightlight">
|
|
47
|
+
const highlightChildren = ( node:Element ):void => {
|
|
48
|
+
if( node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && ( node.className !== 'highlight' || node.tagName !== 'SPAN' ) ){
|
|
49
|
+
Array.from(node.childNodes).forEach(element => {
|
|
50
|
+
highlightRecursive(element);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
const highlightRecursive = ( node:Node|Element ):number => {
|
|
57
|
+
|
|
58
|
+
if( node.nodeType === 3 ){
|
|
59
|
+
return highlightText(node as Text);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
highlightChildren(node as Element);
|
|
63
|
+
|
|
64
|
+
return 0;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
highlightRecursive( element );
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* removeHighlight fn copied from highlight v5 and
|
|
72
|
+
* edited to remove with(), pass js strict mode, and use without jquery
|
|
73
|
+
*/
|
|
74
|
+
export const removeHighlight = (el:HTMLElement) => {
|
|
75
|
+
var elements = el.querySelectorAll("span.highlight");
|
|
76
|
+
Array.prototype.forEach.call(elements, function(el:HTMLElement){
|
|
77
|
+
var parent = el.parentNode as Node;
|
|
78
|
+
parent.replaceChild(el.firstChild as Node, el);
|
|
79
|
+
parent.normalize();
|
|
80
|
+
});
|
|
81
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MicroEvent - to make any js object an event emitter
|
|
3
|
+
*
|
|
4
|
+
* - pure javascript - server compatible, browser compatible
|
|
5
|
+
* - dont rely on the browser doms
|
|
6
|
+
* - super simple - you get it immediatly, no mistery, no magic involved
|
|
7
|
+
*
|
|
8
|
+
* @author Jerome Etienne (https://github.com/jeromeetienne)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
type TCallback = (...args:any) => any;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Execute callback for each event in space separated list of event names
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
function forEvents(events:string,callback:(event:string)=>any){
|
|
18
|
+
events.split(/\s+/).forEach((event) =>{
|
|
19
|
+
callback(event);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default class MicroEvent{
|
|
24
|
+
|
|
25
|
+
public _events: {[key:string]:TCallback[]};
|
|
26
|
+
|
|
27
|
+
constructor(){
|
|
28
|
+
this._events = {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
on(events:string, fct:TCallback){
|
|
32
|
+
forEvents(events,(event) => {
|
|
33
|
+
const event_array = this._events[event] || [];
|
|
34
|
+
event_array.push(fct);
|
|
35
|
+
this._events[event] = event_array;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
off(events:string, fct:TCallback){
|
|
40
|
+
var n = arguments.length;
|
|
41
|
+
if( n === 0 ){
|
|
42
|
+
this._events = {};
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
forEvents(events,(event) => {
|
|
47
|
+
|
|
48
|
+
if (n === 1){
|
|
49
|
+
delete this._events[event];
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const event_array = this._events[event];
|
|
54
|
+
if( event_array === undefined ) return;
|
|
55
|
+
|
|
56
|
+
event_array.splice(event_array.indexOf(fct), 1);
|
|
57
|
+
this._events[event] = event_array;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
trigger(events:string, ...args:any){
|
|
62
|
+
var self = this;
|
|
63
|
+
|
|
64
|
+
forEvents(events,(event) => {
|
|
65
|
+
const event_array = self._events[event];
|
|
66
|
+
if( event_array === undefined ) return;
|
|
67
|
+
event_array.forEach(fct => {
|
|
68
|
+
fct.apply(self, args );
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|