@marianmeres/stuic 1.67.0 → 1.68.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.
@@ -7,7 +7,7 @@ export interface DraggableOptions {
7
7
  enabled?: boolean;
8
8
  payload?: any;
9
9
  effectAllowed?: EffectAllowed;
10
- isDragged?: Writable<Record<string, boolean>>;
10
+ isDragged?: Writable<string | null>;
11
11
  logger?: (...args: any[]) => void;
12
12
  }
13
13
  export declare const draggable: (node: HTMLElement, options: DraggableOptions) => {
@@ -20,7 +20,7 @@ export interface DroppableOptions {
20
20
  onDrop: (data: any, e: DragEvent) => void;
21
21
  onDragover?: (data: any) => void;
22
22
  dropEffect?: DropEffect;
23
- isDraggedOver?: Writable<Record<string, boolean>>;
23
+ isDraggedOver?: Writable<string | null>;
24
24
  logger?: (...args: any[]) => void;
25
25
  }
26
26
  export declare const droppable: (node: HTMLElement, options: DroppableOptions) => {
@@ -19,7 +19,8 @@ export const draggable = (node, options) => {
19
19
  e.dataTransfer?.setData('stuic', JSON.stringify({ id: options.id, payload: pld }));
20
20
  e.dataTransfer.effectAllowed = options.effectAllowed;
21
21
  }
22
- options?.isDragged?.update((old) => ({ ...old, [options.id]: true }));
22
+ // options?.isDragged?.update((old) => ({ ...old, [options.id!]: true }));
23
+ options?.isDragged?.set(options.id);
23
24
  node.setAttribute('aria-grabbed', 'true');
24
25
  };
25
26
  const onDrag = (e) => {
@@ -31,7 +32,8 @@ export const draggable = (node, options) => {
31
32
  const onDragend = (e) => {
32
33
  _log('onDragend', e.dataTransfer);
33
34
  // e.preventDefault();
34
- options?.isDragged?.update((old) => ({ ...old, [options.id]: false }));
35
+ // options?.isDragged?.update((old) => ({ ...old, [options.id!]: false }));
36
+ options?.isDragged?.set(null);
35
37
  node.setAttribute('aria-grabbed', 'false');
36
38
  };
37
39
  const _removeListeners = () => {
@@ -80,7 +82,8 @@ export const droppable = (node, options) => {
80
82
  // e.preventDefault();
81
83
  _log('onDragenter', e.dataTransfer);
82
84
  e.dataTransfer.dropEffect = options.dropEffect;
83
- options?.isDraggedOver?.update((old) => ({ ...old, [options.id]: true }));
85
+ // options?.isDraggedOver?.update((old) => ({ ...old, [options.id!]: true }));
86
+ options?.isDraggedOver?.set(options.id);
84
87
  };
85
88
  const onDragover = (e) => {
86
89
  // _log('onDragover', e.dataTransfer); // too much spam
@@ -91,14 +94,16 @@ export const droppable = (node, options) => {
91
94
  const onDragleave = (e) => {
92
95
  _log('onDragleave', e.dataTransfer);
93
96
  // e.preventDefault();
94
- options?.isDraggedOver?.update((old) => ({ ...old, [options.id]: false }));
97
+ // options?.isDraggedOver?.update((old) => ({ ...old, [options.id!]: false }));
98
+ options?.isDraggedOver?.set(null);
95
99
  };
96
100
  const onDrop = (e) => {
97
101
  _log('onDrop', e.dataTransfer);
98
102
  e.preventDefault();
99
103
  const target = e.target;
100
104
  e.dataTransfer.dropEffect = options.dropEffect;
101
- options?.isDraggedOver?.update((old) => ({ ...old, [options.id]: false }));
105
+ // options?.isDraggedOver?.update((old) => ({ ...old, [options.id!]: false }));
106
+ options?.isDraggedOver?.set(null);
102
107
  if (_isFn(options.onDrop)) {
103
108
  let stuicData = e.dataTransfer?.getData('stuic');
104
109
  // prettier-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "1.67.0",
3
+ "version": "1.68.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package && node ./scripts/date.js",