dragselect 3.0.4 → 3.0.6

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 CHANGED
@@ -1,3 +1,11 @@
1
+ # 3.0.6
2
+
3
+ - Expose the Drag class publicly, solves [#224](https://github.com/ThibaultJanBeyer/DragSelect/issues/224)
4
+
5
+ # 3.0.5
6
+
7
+ - Fix type issue during build bug [#212](https://github.com/ThibaultJanBeyer/DragSelect/issues/212)
8
+
1
9
  # 3.0.4
2
10
 
3
11
  - Fix scrolling bug ([#208](https://github.com/ThibaultJanBeyer/DragSelect/issues/208)) thanks to [@dbougan](https://github.com/dbougan)
@@ -103,7 +103,6 @@ declare class Interaction<E extends DSInputElement> {
103
103
  private removeDocEventListeners;
104
104
  }
105
105
 
106
- type DSPublicPublishEventNames<E extends DSInputElement> = keyof DSPublicPublish<E>;
107
106
  type DSPublicPublishAdditionalEventData<E extends DSInputElement> = {
108
107
  /** The dropZone element that the element was dropped into (or the mouse is currently hovering over) */
109
108
  dropTarget?: DSDropZone<E>;
@@ -440,7 +439,6 @@ type DSInputElement = HTMLElement | SVGElement;
440
439
  type DSMultiSelectKeys = Array<'Shift' | 'Control' | 'Meta' | string>;
441
440
  type DSEvent = KeyboardEvent | MouseEvent | PointerEvent | TouchEvent;
442
441
  type DSInternalEventName = DSSettingsPublishEventNames | DSAreaPublishEventNames | DSKeyStorePublishEventNames | DSPointerStorePublishEventNames | DSInteractionPublishEventNames | DSSelectablePublishEventNames | DSSelectedPublishEventNames;
443
- type DSCallbackName<E extends DSInputElement> = DSPublicPublishEventNames<E> | DSInternalEventName;
444
442
  type DSBoundingRectBase = {
445
443
  top: number;
446
444
  left: number;
@@ -507,7 +505,7 @@ declare class PubSub<E extends DSInputElement> {
507
505
  * @param callback the callback method signature, has to be exactly the same as when subscribing. Consider using "id" instead.
508
506
  * @param id event id returned when subscribed (more performant than callback search)
509
507
  */
510
- unsubscribe: <K extends DSSettingsPublishEventNames | DSKeyStorePublishEventNames | DSPointerStorePublishEventNames | DSSelectedPublishEventNames | keyof DSAreaPublish<E> | keyof DSInteractionPublish | keyof DSSelectablePublish<E> | keyof DSPublicPublish<E>>(eventName: K, callback?: DSCallback<DSPublishMappings<E>[K]> | undefined, id?: number) => void;
508
+ unsubscribe: <K extends DSSettingsPublishEventNames | DSKeyStorePublishEventNames | DSPointerStorePublishEventNames | DSSelectedPublishEventNames | keyof DSAreaPublish<E> | keyof DSInteractionPublish | keyof DSSelectablePublish<E> | keyof DSPublicPublish<E>>(eventName: K, callback?: DSCallback<DSPublishMappings<E>[K]> | null | undefined, id?: number) => void;
511
509
  /**
512
510
  * Publishes an event to all subscribers
513
511
  * @param eventName
@@ -566,6 +564,43 @@ declare class Area<E extends DSInputElement> {
566
564
  private get parentNodes();
567
565
  }
568
566
 
567
+ declare class Drag<E extends DSInputElement> {
568
+ private _prevCursorPos?;
569
+ private _prevScrollPos?;
570
+ private _elements;
571
+ private _dragKeys?;
572
+ private _dragKeysFlat;
573
+ private _selectionRect;
574
+ DS: DragSelect<E>;
575
+ PS: PubSub<E>;
576
+ Settings: DSSettings<E>;
577
+ constructor({ DS, PS }: {
578
+ DS: DragSelect<E>;
579
+ PS: PubSub<E>;
580
+ });
581
+ private assignDragKeys;
582
+ private keyboardDrag;
583
+ private keyboardEnd;
584
+ private start;
585
+ stop: () => void;
586
+ private update;
587
+ private handleZIndex;
588
+ private moveElements;
589
+ private get _cursorDiff();
590
+ private get _scrollDiff();
591
+ /**
592
+ * Can be overridden to apply further filtering logic after the items to move are identified but before they actually get moved
593
+ * Is expected to return the elements in the same shape as passed in
594
+ */
595
+ filterDragElements: ({ elements, direction, }: {
596
+ elements: E[];
597
+ direction: Vect2;
598
+ }) => {
599
+ elements: E[];
600
+ direction: Vect2;
601
+ };
602
+ }
603
+
569
604
  declare class DropZones<E extends DSInputElement> {
570
605
  /** Get the drop zone by the zone element */
571
606
  private _zoneByElement;
@@ -737,7 +772,7 @@ type IsCollision = {
737
772
  (el1?: DSBoundingRectBase, el2?: DSBoundingRectBase, percent?: number): boolean;
738
773
  };
739
774
 
740
- declare class DragSelect<E extends DSInputElement> {
775
+ declare class DragSelect<E extends DSInputElement = DSInputElement> {
741
776
  /** used to skip all current Selection and dragNdrop functionality */
742
777
  continue: boolean;
743
778
  private PubSub;
@@ -753,7 +788,7 @@ declare class DragSelect<E extends DSInputElement> {
753
788
  SelectableSet: SelectableSet<E>;
754
789
  SelectedSet: SelectedSet<E>;
755
790
  Selection: Selection<E>;
756
- private Drag;
791
+ Drag: Drag<E>;
757
792
  DropZones: DropZones<E>;
758
793
  Interaction: Interaction<E>;
759
794
  stopped: boolean;
@@ -764,7 +799,7 @@ declare class DragSelect<E extends DSInputElement> {
764
799
  /** Un-Subscribe from events */
765
800
  unsubscribe: <T extends keyof DSPublicPublish<E>>(eventName: T, callback?: DSCallback<DSPublishMappings<E>[T]> | undefined, id?: number) => void;
766
801
  /** Publish events */
767
- publish: <T extends DSCallbackName<E_1>>(eventName: T | T[], data: DSPublishMappings<E>[T]) => void;
802
+ publish: <T extends keyof DSPublicPublish<E> | DSInternalEventName>(eventName: T | T[], data: DSPublishMappings<E>[T]) => void;
768
803
  /** Initializes the functionality. Automatically triggered when created. Also, reset the functionality after a teardown */
769
804
  start: () => void;
770
805
  /**
@@ -874,4 +909,4 @@ declare class DragSelect<E extends DSInputElement> {
874
909
 
875
910
  type DSPubCallback<T extends keyof DSPublicPublish<E>, E extends DSInputElement = DSInputElement> = DSCallback<DSPublishMappings<E>[T]>;
876
911
 
877
- export { type DSArea, type DSBoundingRect, type DSBoundingRectBase, type DSCallbackName, type DSCallbackObject, type DSDragKeys, type DSEdges, type DSEdgesObj, type DSElementPos, type DSEvent, type DSInputDropZone, type DSInputElement, type DSInternalEventName, type DSMultiSelectKeys, type DSPubCallback, type DSSelectorArea, type Settings, type Vect2, DragSelect as default };
912
+ export { type DSArea, type DSBoundingRect, type DSBoundingRectBase, type DSCallbackObject, type DSDragKeys, type DSEdges, type DSEdgesObj, type DSElementPos, type DSEvent, type DSInputDropZone, type DSInputElement, type DSInternalEventName, type DSMultiSelectKeys, type DSPubCallback, type DSSelectorArea, type Settings, type Vect2, DragSelect as default };
@@ -1,6 +1,6 @@
1
1
  /***
2
2
 
3
- ~~~ Version 3.0.4 ~~~
3
+ ~~~ Version 3.0.6 ~~~
4
4
 
5
5
  ******************************************
6
6
 
@@ -1,6 +1,6 @@
1
1
  /***
2
2
 
3
- ~~~ Version 3.0.4 ~~~
3
+ ~~~ Version 3.0.6 ~~~
4
4
 
5
5
  ******************************************
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragselect",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
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",