dragselect 3.1.1 → 3.1.4
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/CHANGELOG.md +9 -0
- package/dist/DragSelect.d.ts +11 -1
- package/dist/DragSelect.es6m.js +3886 -0
- package/dist/DragSelect.esm.js +60 -19
- package/dist/DragSelect.js +60 -19
- package/dist/ds.es6m.min.js +1 -0
- package/dist/ds.esm.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/methods/addModificationObservers.d.ts +11 -0
- package/dist/methods/canScroll.d.ts +3 -0
- package/dist/methods/createSelectorAreaElement.d.ts +3 -0
- package/dist/methods/createSelectorElement.d.ts +3 -0
- package/dist/methods/debounce.d.ts +3 -0
- package/dist/methods/documentScroll.d.ts +6 -0
- package/dist/methods/getAllParentNodes.d.ts +3 -0
- package/dist/methods/getAreaRect.d.ts +3 -0
- package/dist/methods/getBoundingClientRect.d.ts +4 -0
- package/dist/methods/getCurrentScroll.d.ts +3 -0
- package/dist/methods/getOverflowEdges.d.ts +7 -0
- package/dist/methods/getPointerPos.d.ts +5 -0
- package/dist/methods/getSelectorPosition.d.ts +12 -0
- package/dist/methods/getStylePosition.d.ts +3 -0
- package/dist/methods/handleElementOverflow.d.ts +10 -0
- package/dist/methods/handleElementPositionAttribute.d.ts +6 -0
- package/dist/methods/handleKeyboardDragPosDifference.d.ts +13 -0
- package/dist/methods/handleSelection.d.ts +9 -0
- package/dist/methods/handleUnSelection.d.ts +9 -0
- package/dist/methods/hydrateSettings.d.ts +3 -0
- package/dist/methods/index.d.ts +30 -0
- package/dist/methods/isCollision.d.ts +13 -0
- package/dist/methods/moveElement.d.ts +8 -0
- package/dist/methods/removeModificationObservers.d.ts +3 -0
- package/dist/methods/scrollElement.d.ts +3 -0
- package/dist/methods/setStylePosition.d.ts +3 -0
- package/dist/methods/subscriberAliases.d.ts +14 -0
- package/dist/methods/toArray.d.ts +3 -0
- package/dist/methods/updateElementStylePos.d.ts +8 -0
- package/dist/methods/vect2.d.ts +8 -0
- package/dist/modules/Area.d.ts +80 -0
- package/dist/modules/Drag.d.ts +71 -0
- package/dist/modules/DropZone.d.ts +90 -0
- package/dist/modules/DropZones.d.ts +73 -0
- package/dist/modules/Interaction.d.ts +51 -0
- package/dist/modules/PubSub.d.ts +37 -0
- package/dist/modules/SelectableSet.d.ts +43 -0
- package/dist/modules/SelectedSet.d.ts +32 -0
- package/dist/modules/Selection.d.ts +54 -0
- package/dist/modules/Selector.d.ts +29 -0
- package/dist/modules/SelectorArea.d.ts +58 -0
- package/dist/modules/index.d.ts +11 -0
- package/dist/stores/KeyStore.d.ts +34 -0
- package/dist/stores/PointerStore.d.ts +83 -0
- package/dist/stores/ScrollStore.d.ts +38 -0
- package/dist/stores/SettingsStore.d.ts +39 -0
- package/dist/stores/index.d.ts +5 -0
- package/dist/types.d.ts +276 -0
- package/package.json +5 -8
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export default class Selection {
|
|
2
|
+
/**
|
|
3
|
+
* @constructor Selection
|
|
4
|
+
* @param {{ DS:DragSelect }} p
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
constructor({ DS }: {
|
|
8
|
+
DS: DragSelect;
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* @type {Set}
|
|
12
|
+
* @private
|
|
13
|
+
* */
|
|
14
|
+
private _prevSelectedSet;
|
|
15
|
+
DS: DragSelect;
|
|
16
|
+
Settings: Settings;
|
|
17
|
+
/**
|
|
18
|
+
* Stores the previous selection (solves #9)
|
|
19
|
+
* @param {DSEvent} event
|
|
20
|
+
* @private
|
|
21
|
+
* */
|
|
22
|
+
private _storePrevious;
|
|
23
|
+
/** @param {{event:DSEvent,isDragging:boolean}} event */
|
|
24
|
+
start: ({ event, isDragging }: {
|
|
25
|
+
event: DSEvent;
|
|
26
|
+
isDragging: boolean;
|
|
27
|
+
}) => void;
|
|
28
|
+
update: ({ isDragging }: {
|
|
29
|
+
isDragging: any;
|
|
30
|
+
}) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if any selectable element is inside selection.
|
|
33
|
+
* @param {boolean} [force]
|
|
34
|
+
* @param {DSEvent} [event]
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
private _handleInsideSelection;
|
|
38
|
+
/**
|
|
39
|
+
* Can be overridden to apply further filtering logic after the items to select are identified but before they actually get selected
|
|
40
|
+
* Is expected to return the select / unselect maps in the same shape as passed in
|
|
41
|
+
* @param {{select:Map<DSElement,DSBoundingRect>, unselect:Map<DSElement,DSBoundingRect>, selectorRect:DSBoundingRect}} obj
|
|
42
|
+
* @returns {{select:Map<DSElement,DSBoundingRect>, unselect:Map<DSElement,DSBoundingRect>}}
|
|
43
|
+
*/
|
|
44
|
+
filterSelected: ({ select, unselect, selectorRect }: {
|
|
45
|
+
select: Map<DSElement, DSBoundingRect>;
|
|
46
|
+
unselect: Map<DSElement, DSBoundingRect>;
|
|
47
|
+
selectorRect: DSBoundingRect;
|
|
48
|
+
}) => {
|
|
49
|
+
select: Map<DSElement, DSBoundingRect>;
|
|
50
|
+
unselect: Map<DSElement, DSBoundingRect>;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
import DragSelect from "../DragSelect";
|
|
54
|
+
import "../types"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default class Selector {
|
|
2
|
+
/**
|
|
3
|
+
* @constructor Selector
|
|
4
|
+
* @param {{ DS:DragSelect }} p
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
constructor({ DS }: {
|
|
8
|
+
DS: DragSelect;
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* @type {DSBoundingRect}
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
private _rect;
|
|
15
|
+
DS: DragSelect;
|
|
16
|
+
attachSelector: () => void;
|
|
17
|
+
HTMLNode: HTMLElement;
|
|
18
|
+
start: ({ isDragging }: {
|
|
19
|
+
isDragging: any;
|
|
20
|
+
}) => void;
|
|
21
|
+
stop: () => void;
|
|
22
|
+
/** Moves the selection to the correct place */
|
|
23
|
+
update: ({ isDragging }: {
|
|
24
|
+
isDragging: any;
|
|
25
|
+
}) => void;
|
|
26
|
+
get rect(): DSBoundingRect | DOMRect;
|
|
27
|
+
}
|
|
28
|
+
import DragSelect from "../DragSelect";
|
|
29
|
+
import "../types"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export default class SelectorArea {
|
|
2
|
+
/**
|
|
3
|
+
* @class SelectorArea
|
|
4
|
+
* @constructor SelectorArea
|
|
5
|
+
* @param {{ DS:DragSelect }} obj
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
constructor({ DS }: {
|
|
9
|
+
DS: DragSelect;
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* @type {*}
|
|
13
|
+
* @private
|
|
14
|
+
* */
|
|
15
|
+
private _scrollInterval;
|
|
16
|
+
/**
|
|
17
|
+
* @type {DSBoundingRect}
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
private _rect;
|
|
21
|
+
/**
|
|
22
|
+
* @type {DSEdges}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
private currentEdges;
|
|
26
|
+
DS: DragSelect;
|
|
27
|
+
HTMLNode: HTMLDivElement;
|
|
28
|
+
start: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Adding / Removing elements to document
|
|
31
|
+
* @param {'append'|'remove'} method
|
|
32
|
+
*/
|
|
33
|
+
applyElements: (method?: 'append' | 'remove') => void;
|
|
34
|
+
/** Updates the selectorAreas positions to match the areas */
|
|
35
|
+
updatePos: () => void;
|
|
36
|
+
stop: (remove: any) => void;
|
|
37
|
+
startAutoScroll: () => void;
|
|
38
|
+
/** Creates an interval that auto-scrolls while the cursor is near the edge */
|
|
39
|
+
handleAutoScroll: () => void;
|
|
40
|
+
stopAutoScroll: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Checks if the element is either inside the Selector Area
|
|
43
|
+
* (as a reachable child or touching the area)
|
|
44
|
+
* @param {DSElement} element
|
|
45
|
+
* @param {DSBoundingRect} [elementRect] - slight performance improvements
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
isInside: (element: DSElement, elementRect?: DSBoundingRect) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* checks if the click was triggered on the area.
|
|
51
|
+
* @param {DSEvent} [event]
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
isClicked(event?: DSEvent): boolean;
|
|
55
|
+
get rect(): DSBoundingRect | DOMRect;
|
|
56
|
+
}
|
|
57
|
+
import DragSelect from "../DragSelect";
|
|
58
|
+
import "../types"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as Area } from "./Area";
|
|
2
|
+
export { default as Drag } from "./Drag";
|
|
3
|
+
export { default as DropZones } from "./DropZones";
|
|
4
|
+
export { default as Interaction } from "./Interaction";
|
|
5
|
+
export { default as PubSub } from "./PubSub";
|
|
6
|
+
export { default as SelectableSet } from "./SelectableSet";
|
|
7
|
+
export { default as SelectedSet } from "./SelectedSet";
|
|
8
|
+
export { default as Selection } from "./Selection";
|
|
9
|
+
export { default as Selector } from "./Selector";
|
|
10
|
+
export { default as SelectorArea } from "./SelectorArea";
|
|
11
|
+
import "../types"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default class KeyStore {
|
|
2
|
+
/**
|
|
3
|
+
* @class KeyStore
|
|
4
|
+
* @constructor KeyStore
|
|
5
|
+
* @param {{DS:DragSelect}} p
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
constructor({ DS }: {
|
|
9
|
+
DS: DragSelect;
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* @type {Set<string>}
|
|
13
|
+
* @private
|
|
14
|
+
* */
|
|
15
|
+
private _currentValues;
|
|
16
|
+
/**
|
|
17
|
+
* @type {{control:string,shift:string,meta:string}}
|
|
18
|
+
* @private
|
|
19
|
+
* */
|
|
20
|
+
private _keyMapping;
|
|
21
|
+
DS: DragSelect;
|
|
22
|
+
init: () => void;
|
|
23
|
+
/** @param {KeyboardEvent} event */
|
|
24
|
+
keydown: (event: KeyboardEvent) => void;
|
|
25
|
+
/** @param {KeyboardEvent} event */
|
|
26
|
+
keyup: (event: KeyboardEvent) => void;
|
|
27
|
+
stop: () => void;
|
|
28
|
+
reset: () => void;
|
|
29
|
+
/** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
30
|
+
isMultiSelectKeyPressed(event?: KeyboardEvent | MouseEvent | PointerEvent | TouchEvent): boolean;
|
|
31
|
+
get currentValues(): string[];
|
|
32
|
+
}
|
|
33
|
+
import DragSelect from "../DragSelect";
|
|
34
|
+
import "../types"
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export default class PointerStore {
|
|
2
|
+
/**
|
|
3
|
+
* @class PointerStore
|
|
4
|
+
* @constructor PointerStore
|
|
5
|
+
* @param {{DS:DragSelect}} p
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
constructor({ DS }: {
|
|
9
|
+
DS: DragSelect;
|
|
10
|
+
});
|
|
11
|
+
/** @type {boolean} */
|
|
12
|
+
_isMouseInteraction: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @type {Vect2}
|
|
15
|
+
* @private
|
|
16
|
+
* */
|
|
17
|
+
private _initialValArea;
|
|
18
|
+
/**
|
|
19
|
+
* @type {Vect2}
|
|
20
|
+
* @private
|
|
21
|
+
* */
|
|
22
|
+
private _currentValArea;
|
|
23
|
+
/**
|
|
24
|
+
* @type {Vect2}
|
|
25
|
+
* @private
|
|
26
|
+
* */
|
|
27
|
+
private _lastValArea;
|
|
28
|
+
/**
|
|
29
|
+
* @type {Vect2}
|
|
30
|
+
* @private
|
|
31
|
+
* */
|
|
32
|
+
private _initialVal;
|
|
33
|
+
/**
|
|
34
|
+
* @type {Vect2}
|
|
35
|
+
* @private
|
|
36
|
+
* */
|
|
37
|
+
private _currentVal;
|
|
38
|
+
/**
|
|
39
|
+
* @type {Vect2}
|
|
40
|
+
* @private
|
|
41
|
+
* */
|
|
42
|
+
private _lastVal;
|
|
43
|
+
/**
|
|
44
|
+
* @type {TouchEvent}
|
|
45
|
+
* @private
|
|
46
|
+
* */
|
|
47
|
+
private _lastTouch;
|
|
48
|
+
DS: DragSelect;
|
|
49
|
+
Settings: Settings;
|
|
50
|
+
init: () => void;
|
|
51
|
+
/** @param {DSEvent} [event] */
|
|
52
|
+
start(event?: DSEvent): void;
|
|
53
|
+
set currentVal(arg: Vect2);
|
|
54
|
+
/** Current pointer position */
|
|
55
|
+
get currentVal(): Vect2;
|
|
56
|
+
set initialVal(arg: Vect2);
|
|
57
|
+
/** First recorded pointer position */
|
|
58
|
+
get initialVal(): Vect2;
|
|
59
|
+
/** @param {DSEvent} event */
|
|
60
|
+
getPointerPosition: (event: DSEvent) => Vect2;
|
|
61
|
+
/** @param {DSEvent} [event] */
|
|
62
|
+
update: (event?: DSEvent) => void;
|
|
63
|
+
stop: () => void;
|
|
64
|
+
/** @param {DSEvent} [event] */
|
|
65
|
+
reset: (event?: DSEvent) => void;
|
|
66
|
+
set lastVal(arg: Vect2);
|
|
67
|
+
/** Last recorded pointer position */
|
|
68
|
+
get lastVal(): Vect2;
|
|
69
|
+
/**
|
|
70
|
+
* @param {DSEvent} event
|
|
71
|
+
* @return {MouseEvent|PointerEvent|Touch}
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
private _normalizedEvent;
|
|
75
|
+
/** First recorded pointer position within the area */
|
|
76
|
+
get initialValArea(): Vect2;
|
|
77
|
+
/** Current pointer position within the area */
|
|
78
|
+
get currentValArea(): Vect2;
|
|
79
|
+
/** Last recorded pointer position within the area */
|
|
80
|
+
get lastValArea(): Vect2;
|
|
81
|
+
}
|
|
82
|
+
import DragSelect from "../DragSelect";
|
|
83
|
+
import "../types"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default class ScrollStore {
|
|
2
|
+
/**
|
|
3
|
+
* @class ScrollStore
|
|
4
|
+
* @constructor ScrollStore
|
|
5
|
+
* @param {{ DS:DragSelect }} p
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
constructor({ DS }: {
|
|
9
|
+
DS: DragSelect;
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* @type {Vect2}
|
|
13
|
+
* @private */
|
|
14
|
+
private _initialVal;
|
|
15
|
+
/**
|
|
16
|
+
* @type {Vect2}
|
|
17
|
+
* @private */
|
|
18
|
+
private _currentVal;
|
|
19
|
+
/**
|
|
20
|
+
* @type {boolean}
|
|
21
|
+
* @private */
|
|
22
|
+
private _canScroll;
|
|
23
|
+
DS: DragSelect;
|
|
24
|
+
init: () => void;
|
|
25
|
+
start: () => void;
|
|
26
|
+
update: () => Vect2;
|
|
27
|
+
stop: () => void;
|
|
28
|
+
reset: () => void;
|
|
29
|
+
get canScroll(): boolean;
|
|
30
|
+
get scrollAmount(): {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
};
|
|
34
|
+
get initialVal(): Vect2;
|
|
35
|
+
get currentVal(): Vect2;
|
|
36
|
+
}
|
|
37
|
+
import DragSelect from "../DragSelect";
|
|
38
|
+
import "../types"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default class SettingsStore {
|
|
2
|
+
/**
|
|
3
|
+
* @class ScrollStore
|
|
4
|
+
* @constructor ScrollStore
|
|
5
|
+
* @param {{ DS:DragSelect, settings:Settings }} p
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
constructor({ DS, settings }: {
|
|
9
|
+
DS: DragSelect;
|
|
10
|
+
settings: Settings;
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* @type {Settings}
|
|
14
|
+
* @private
|
|
15
|
+
* */
|
|
16
|
+
private _settings;
|
|
17
|
+
/**
|
|
18
|
+
* Holds the settings and their previous value `:pre`
|
|
19
|
+
* @example {
|
|
20
|
+
* autoScrollSpeed: 3,
|
|
21
|
+
* 'autoScrollSpeed:pre': 5
|
|
22
|
+
* }
|
|
23
|
+
* @type {Settings}
|
|
24
|
+
* */
|
|
25
|
+
s: Settings;
|
|
26
|
+
DS: DragSelect;
|
|
27
|
+
/** @param {{settings: Settings, init?: boolean}} props */
|
|
28
|
+
update: ({ settings, init }: {
|
|
29
|
+
settings: Settings;
|
|
30
|
+
init?: boolean;
|
|
31
|
+
}) => void;
|
|
32
|
+
/** @param {{settings: Settings, init: boolean}} props */
|
|
33
|
+
_update: ({ settings, init }: {
|
|
34
|
+
settings: Settings;
|
|
35
|
+
init: boolean;
|
|
36
|
+
}) => void;
|
|
37
|
+
}
|
|
38
|
+
import DragSelect from "../DragSelect";
|
|
39
|
+
import "../types"
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Settings to be passed to the Class
|
|
3
|
+
*/
|
|
4
|
+
type Settings = {
|
|
5
|
+
/**
|
|
6
|
+
* area in which you can drag. If not provided it will be the whole document
|
|
7
|
+
*/
|
|
8
|
+
area?: HTMLElement | SVGElement | Document;
|
|
9
|
+
/**
|
|
10
|
+
* the elements that can be selected
|
|
11
|
+
*/
|
|
12
|
+
selectables?: DSInputElements;
|
|
13
|
+
/**
|
|
14
|
+
* Speed in which the area scrolls while selecting (if available). Unit is pixel per movement.
|
|
15
|
+
*/
|
|
16
|
+
autoScrollSpeed?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Tolerance for autoScroll (how close one has to be near an edges for autoScroll to start)
|
|
19
|
+
*/
|
|
20
|
+
overflowTolerance?: Vect2;
|
|
21
|
+
/**
|
|
22
|
+
* Zoom scale factor (in case of using CSS style transform: scale() which messes with real positions). Unit scale zoom.
|
|
23
|
+
*/
|
|
24
|
+
zoom?: number;
|
|
25
|
+
/**
|
|
26
|
+
* if set to true, no styles (except for position absolute) will be applied by default
|
|
27
|
+
*/
|
|
28
|
+
customStyles?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Add newly selected elements to the selection instead of replacing them
|
|
31
|
+
*/
|
|
32
|
+
multiSelectMode?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether or not to toggle already active elements while multi-selecting
|
|
35
|
+
*/
|
|
36
|
+
multiSelectToggling?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Keys that allows switching to the multi-select mode (see the multiSelectMode option). Any key value is possible ([see MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)). Note that the best support is given for <kbd>Control</kbd>, <kbd>Shift</kbd> and <kbd>Meta</kbd>. Provide an empty array `[]` if you want to turn off the functionality.
|
|
39
|
+
*/
|
|
40
|
+
multiSelectKeys?: DSMultiSelectKeys;
|
|
41
|
+
/**
|
|
42
|
+
* the square that will draw the selection
|
|
43
|
+
*/
|
|
44
|
+
selector?: HTMLElement;
|
|
45
|
+
/**
|
|
46
|
+
* how much % of the element has to be selected to be considered selected (0 = just touching, 1 = inside the selection)
|
|
47
|
+
*/
|
|
48
|
+
selectionThreshold?: number;
|
|
49
|
+
/**
|
|
50
|
+
* When a user is dragging on an already selected element, the selection is dragged.
|
|
51
|
+
*/
|
|
52
|
+
draggability?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether an element is draggable from the start or needs to be selected first
|
|
55
|
+
*/
|
|
56
|
+
immediateDrag?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether or not the user can drag with the keyboard (we don't recommend disabling it)
|
|
59
|
+
*/
|
|
60
|
+
keyboardDrag?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The keys available to drag element using the keyboard.
|
|
63
|
+
*/
|
|
64
|
+
dragKeys?: DSDragKeys;
|
|
65
|
+
/**
|
|
66
|
+
* The speed at which elements are dragged using the keyboard. In pixels per keydown.
|
|
67
|
+
*/
|
|
68
|
+
keyboardDragSpeed?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Whether to use hardware accelerated css transforms when dragging or top/left instead
|
|
71
|
+
*/
|
|
72
|
+
useTransform?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Refresh rate on memoization, higher numbers mean better performance but more lag if elements are moving, lower numbers mean less lag but worse performance. If none of your DOMNodes are moving, you can set it to a very high number to increase performance. Value in milliseconds.
|
|
75
|
+
*/
|
|
76
|
+
refreshMemoryRate?: number;
|
|
77
|
+
/**
|
|
78
|
+
* one or more drop-elements: where the selectables can be dropped into
|
|
79
|
+
*/
|
|
80
|
+
dropZones?: DSInputDropZone[];
|
|
81
|
+
/**
|
|
82
|
+
* how much % of the item has to be inside the dropzone to be considered inside (0 = barely touching, 1 = completely inside)
|
|
83
|
+
*/
|
|
84
|
+
dropInsideThreshold?: number;
|
|
85
|
+
/**
|
|
86
|
+
* how much % of the zone does the pointer has to be in to be considered a target (0 = anywhere in the zone, max: 0.5 = has to point at the center of the zone)
|
|
87
|
+
*/
|
|
88
|
+
dropTargetThreshold?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Whether to use Pointer Events to replace traditional Mouse or Touch Events. Useful for tools like Google Blockly.
|
|
91
|
+
*/
|
|
92
|
+
usePointerEvents?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* the class assigned to the mouse hovered items
|
|
95
|
+
*/
|
|
96
|
+
hoverClass?: string;
|
|
97
|
+
/**
|
|
98
|
+
* the class assigned to the elements that can be selected
|
|
99
|
+
*/
|
|
100
|
+
selectableClass?: string;
|
|
101
|
+
/**
|
|
102
|
+
* the class assigned to the selected items
|
|
103
|
+
*/
|
|
104
|
+
selectedClass?: string;
|
|
105
|
+
/**
|
|
106
|
+
* the class assigned to the square selector helper
|
|
107
|
+
*/
|
|
108
|
+
selectorClass?: string;
|
|
109
|
+
/**
|
|
110
|
+
* the class assigned to the square in which the selector resides. By default it's invisible
|
|
111
|
+
*/
|
|
112
|
+
selectorAreaClass?: string;
|
|
113
|
+
/**
|
|
114
|
+
* on an item corresponding the target dropzone. This is also the prefix for ds-dropped-target-${zone.id}
|
|
115
|
+
*/
|
|
116
|
+
droppedTargetClass?: string;
|
|
117
|
+
/**
|
|
118
|
+
* on an item that is within its dropzone bounds after a drop. This is also the prefix for ds-dropped-inside-${zone.id}
|
|
119
|
+
*/
|
|
120
|
+
droppedInsideClass?: string;
|
|
121
|
+
/**
|
|
122
|
+
* on element that can be dropped into at least one container. This is also the prefix for ds-droppable-${zone.id}
|
|
123
|
+
*/
|
|
124
|
+
droppableClass?: string;
|
|
125
|
+
/**
|
|
126
|
+
* on each dropZone
|
|
127
|
+
*/
|
|
128
|
+
dropZoneClass?: string;
|
|
129
|
+
/**
|
|
130
|
+
* on corresponding dropZone when element is dragged
|
|
131
|
+
*/
|
|
132
|
+
dropZoneReadyClass?: string;
|
|
133
|
+
/**
|
|
134
|
+
* on dropZone that has elements from any successful target drop
|
|
135
|
+
*/
|
|
136
|
+
dropZoneTargetClass?: string;
|
|
137
|
+
/**
|
|
138
|
+
* on dropZone that has elements inside after any drop
|
|
139
|
+
*/
|
|
140
|
+
dropZoneInsideClass?: string;
|
|
141
|
+
/**
|
|
142
|
+
* whether to drag multiple elements as a single block or as individual items
|
|
143
|
+
*/
|
|
144
|
+
dragAsBlock?: boolean;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* The Object that is passed back to any callback method
|
|
148
|
+
*/
|
|
149
|
+
type CallbackObject = {
|
|
150
|
+
/**
|
|
151
|
+
* The items currently selected
|
|
152
|
+
*/
|
|
153
|
+
items?: Array<HTMLElement | SVGElement | any>;
|
|
154
|
+
/**
|
|
155
|
+
* The respective event object
|
|
156
|
+
*/
|
|
157
|
+
event?: MouseEvent | TouchEvent | PointerEvent | KeyboardEvent | Event;
|
|
158
|
+
/**
|
|
159
|
+
* The single item currently interacted with
|
|
160
|
+
*/
|
|
161
|
+
item?: HTMLElement | SVGElement | any;
|
|
162
|
+
/**
|
|
163
|
+
* Whether the interaction is a drag or a select
|
|
164
|
+
*/
|
|
165
|
+
isDragging?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Whether or not the drag interaction is via keyboard
|
|
168
|
+
*/
|
|
169
|
+
isDraggingKeyboard?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Pressed key (lowercase)
|
|
172
|
+
*/
|
|
173
|
+
key?: string;
|
|
174
|
+
/**
|
|
175
|
+
* the settings being updates/manipulated/passed, also holds the previous value. i.e. updating selectorClass will publish { settings: { selectorClass: 'newVal', 'selectorClass:pre': 'oldVal' } }
|
|
176
|
+
*/
|
|
177
|
+
settings?: Settings;
|
|
178
|
+
scroll_directions?: Array<'top' | 'bottom' | 'left' | 'right' | undefined>;
|
|
179
|
+
scroll_multiplier?: number;
|
|
180
|
+
/**
|
|
181
|
+
* The dropZone element that the element was dropped into (or the mouse is currently hovering over)
|
|
182
|
+
*/
|
|
183
|
+
dropTarget?: DSDropZone;
|
|
184
|
+
};
|
|
185
|
+
type DSCallback = Function;
|
|
186
|
+
type DSInputDropZone = {
|
|
187
|
+
/**
|
|
188
|
+
* can be any unique identifier of type string
|
|
189
|
+
*/
|
|
190
|
+
id: string;
|
|
191
|
+
/**
|
|
192
|
+
* is the dropzone itself
|
|
193
|
+
*/
|
|
194
|
+
element: DSElement;
|
|
195
|
+
/**
|
|
196
|
+
* the elements that can be dropped into that zone. This is optional, by default it will be all selectables
|
|
197
|
+
*/
|
|
198
|
+
droppables?: DSInputElements;
|
|
199
|
+
};
|
|
200
|
+
type DSDropZone = {
|
|
201
|
+
id: string;
|
|
202
|
+
element: DSElement;
|
|
203
|
+
droppables: DSElements;
|
|
204
|
+
/**
|
|
205
|
+
* the items related to the target zone
|
|
206
|
+
*/
|
|
207
|
+
itemsDropped?: DSElements;
|
|
208
|
+
/**
|
|
209
|
+
* the items that are within the targets bounds
|
|
210
|
+
*/
|
|
211
|
+
itemsInside?: DSElements;
|
|
212
|
+
};
|
|
213
|
+
type Vect2 = {
|
|
214
|
+
x: number;
|
|
215
|
+
y: number;
|
|
216
|
+
};
|
|
217
|
+
type DSElementPos = {
|
|
218
|
+
x: number;
|
|
219
|
+
y: number;
|
|
220
|
+
w: number;
|
|
221
|
+
h: number;
|
|
222
|
+
r: number;
|
|
223
|
+
b: number;
|
|
224
|
+
};
|
|
225
|
+
type DSEdges = Array<'top' | 'bottom' | 'left' | 'right' | undefined>;
|
|
226
|
+
/**
|
|
227
|
+
* area within which you can drag
|
|
228
|
+
*/
|
|
229
|
+
type DSArea = HTMLElement | SVGElement | Document;
|
|
230
|
+
/**
|
|
231
|
+
* area in which you can drag
|
|
232
|
+
*/
|
|
233
|
+
type DSSelectorArea = HTMLElement;
|
|
234
|
+
/**
|
|
235
|
+
* the elements that can be selected
|
|
236
|
+
*/
|
|
237
|
+
type DSInputElements = Array<HTMLElement | SVGElement> | HTMLElement | SVGElement;
|
|
238
|
+
/**
|
|
239
|
+
* the elements that can be selected
|
|
240
|
+
*/
|
|
241
|
+
type DSElements = Array<HTMLElement | SVGElement>;
|
|
242
|
+
/**
|
|
243
|
+
* a single element that can be selected
|
|
244
|
+
*/
|
|
245
|
+
type DSElement = HTMLElement | SVGElement;
|
|
246
|
+
/**
|
|
247
|
+
* en event from a touch or mouse interaction
|
|
248
|
+
*/
|
|
249
|
+
type DSEvent = MouseEvent | TouchEvent | PointerEvent;
|
|
250
|
+
/**
|
|
251
|
+
* An array of keys that allows switching to the multi-select mode
|
|
252
|
+
*/
|
|
253
|
+
type DSMultiSelectKeys = Array<'Shift' | 'Control' | 'Meta' | string>;
|
|
254
|
+
type DSEventNames = 'dragmove' | 'autoscroll' | 'dragstart' | 'elementselect' | 'elementunselect' | 'callback';
|
|
255
|
+
type DSInternalEventNames = 'Interaction:init' | 'Interaction:start' | 'Interaction:end' | 'Interaction:update' | 'Area:modified' | 'Area:scroll' | 'PointerStore:updated' | 'Selected:added' | 'Selected:removed' | 'Selectable:click' | 'Selectable:added' | 'Selectable:removed' | 'Selectable:pointer' | 'KeyStore:down' | 'KeyStore:up';
|
|
256
|
+
type DSInternalEventNamesPre = 'Interaction:init:pre' | 'Interaction:start:pre' | 'Interaction:end:pre' | 'Interaction:update:pre' | 'Area:modified:pre' | 'Area:scroll:pre' | 'PointerStore:updated:pre' | 'Selected:added:pre' | 'Selected:removed:pre' | 'Selectable:click:pre' | 'Selectable:added:pre' | 'Selectable:removed:pre' | 'Selectable:pointer:pre' | 'KeyStore:down:pre' | 'KeyStore:up:pre';
|
|
257
|
+
type DSInternalSettingEvents = 'Settings:updated' | 'Settings:updated:pre' | 'Settings:updated:*' | 'Settings:updated:*:pre';
|
|
258
|
+
/**
|
|
259
|
+
* the name of the callback
|
|
260
|
+
*/
|
|
261
|
+
type DSCallbackNames = DSEventNames | DSInternalEventNames | DSInternalEventNamesPre | DSInternalSettingEvents;
|
|
262
|
+
type DSBoundingRect = {
|
|
263
|
+
top: number;
|
|
264
|
+
left: number;
|
|
265
|
+
bottom: number;
|
|
266
|
+
right: number;
|
|
267
|
+
width: number;
|
|
268
|
+
height: number;
|
|
269
|
+
};
|
|
270
|
+
type DSDragKeys = {
|
|
271
|
+
up: string[];
|
|
272
|
+
down: string[];
|
|
273
|
+
left: string[];
|
|
274
|
+
right: string[];
|
|
275
|
+
};
|
|
276
|
+
type DSModificationCallback = (event: any) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dragselect",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"description": "Easy JavaScript library for selecting and moving elements. With no dependencies. Drag-Select & Drag-And-Drop.",
|
|
5
5
|
"main": "./dist/DragSelect.js",
|
|
6
6
|
"module": "./dist/DragSelect.esm.js",
|
|
@@ -25,15 +25,12 @@
|
|
|
25
25
|
"@jest/globals": "^29.7.0",
|
|
26
26
|
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
27
27
|
"@rollup/plugin-typescript": "^11.1.3",
|
|
28
|
-
"@types/expect-puppeteer": "^5.0.3",
|
|
29
28
|
"@types/jest": "^29.5.5",
|
|
30
|
-
"@types/jest-environment-puppeteer": "^5.0.4",
|
|
31
|
-
"@types/puppeteer": "^7.0.4",
|
|
32
29
|
"@typescript-eslint/eslint-plugin-tslint": "^6.7.2",
|
|
33
30
|
"@typescript-eslint/parser": "^6.7.2",
|
|
34
31
|
"better-docs": "^2.7.2",
|
|
35
32
|
"concurrently": "^8.2.1",
|
|
36
|
-
"eslint": "^
|
|
33
|
+
"eslint": "^9.26.0",
|
|
37
34
|
"eslint-config-airbnb": "^19.0.4",
|
|
38
35
|
"eslint-config-prettier": "^9.0.0",
|
|
39
36
|
"eslint-config-standard": "^17.1.0",
|
|
@@ -45,13 +42,13 @@
|
|
|
45
42
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
46
43
|
"eslint-plugin-security": "^1.7.1",
|
|
47
44
|
"eslint-plugin-standard": "^5.0.0",
|
|
48
|
-
"glob": "^10.
|
|
45
|
+
"glob": "^10.5.0",
|
|
49
46
|
"jest": "^29.7.0",
|
|
50
47
|
"jest-environment-jsdom": "^29.7.0",
|
|
51
|
-
"jest-puppeteer": "^
|
|
48
|
+
"jest-puppeteer": "^11.0.0",
|
|
52
49
|
"minami": "^1.2.3",
|
|
53
50
|
"prettier": "^3.0.3",
|
|
54
|
-
"puppeteer": "
|
|
51
|
+
"puppeteer": "25.12.0",
|
|
55
52
|
"rollup": "^3.29.5",
|
|
56
53
|
"rollup-plugin-dts": "^6.0.2",
|
|
57
54
|
"rollup-plugin-terser": "^7.0.2",
|