@marianmeres/stuic 1.68.0 → 1.70.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.
@@ -18,7 +18,7 @@ export interface DroppableOptions {
18
18
  id?: string;
19
19
  enabled?: boolean;
20
20
  onDrop: (data: any, e: DragEvent) => void;
21
- onDragover?: (data: any) => void;
21
+ onDragover?: (e: DragEvent) => void;
22
22
  dropEffect?: DropEffect;
23
23
  isDraggedOver?: Writable<string | null>;
24
24
  logger?: (...args: any[]) => void;
@@ -45,6 +45,7 @@ export const draggable = (node, options) => {
45
45
  const _init = (_opts) => {
46
46
  _log('_init', _opts);
47
47
  _removeListeners();
48
+ options?.isDragged?.set(null);
48
49
  if (_opts.enabled) {
49
50
  node.setAttribute('draggable', 'true');
50
51
  node.setAttribute('aria-grabbed', 'false');
@@ -87,9 +88,10 @@ export const droppable = (node, options) => {
87
88
  };
88
89
  const onDragover = (e) => {
89
90
  // _log('onDragover', e.dataTransfer); // too much spam
90
- // prevent default to allow drop
91
- // this alse prevents animation (todo: really?)
92
- e.preventDefault();
91
+ options?.isDraggedOver?.set(options.id);
92
+ if (_isFn(options.onDragover)) {
93
+ return options.onDragover(e);
94
+ }
93
95
  };
94
96
  const onDragleave = (e) => {
95
97
  _log('onDragleave', e.dataTransfer);
@@ -124,6 +126,7 @@ export const droppable = (node, options) => {
124
126
  const _init = (_opts) => {
125
127
  _log('_init', _opts);
126
128
  _removeListeners();
129
+ options?.isDraggedOver?.set(null);
127
130
  if (_opts.enabled) {
128
131
  node.addEventListener('dragenter', onDragenter);
129
132
  node.addEventListener('dragover', onDragover);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "1.68.0",
3
+ "version": "1.70.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package && node ./scripts/date.js",