fuma 0.3.32 → 0.3.33

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.
@@ -10,7 +10,7 @@ export declare function createDragHandler<Type = unknown>(listElement: HTMLDivEl
10
10
  dragStart: void;
11
11
  dragMove: void;
12
12
  dragEnd: void;
13
- }[K]) => unknown) => void;
13
+ }[K]) => unknown) => () => void;
14
14
  off: <K_1 extends "dragStart" | "dragMove" | "dragEnd">(eventKey: K_1, callback: (arg: {
15
15
  dragStart: void;
16
16
  dragMove: void;
@@ -11,11 +11,13 @@ export function createDragHandler(listElement, itemElement, options) {
11
11
  let indexFrom = 0;
12
12
  let indexTo = 0;
13
13
  let currentPosition = { clientX: 0, clientY: 0 };
14
- const events = createEventEmitter({
15
- dragStart: options.onDragStart ? [options.onDragStart] : [],
16
- dragMove: options.onDragMove ? [options.onDragMove] : [],
17
- dragEnd: options.onDragEnd ? [options.onDragEnd] : []
18
- });
14
+ const events = createEventEmitter();
15
+ if (options.onDragStart)
16
+ events.on('dragStart', options.onDragStart);
17
+ if (options.onDragMove)
18
+ events.on('dragStart', options.onDragMove);
19
+ if (options.onDragEnd)
20
+ events.on('dragStart', options.onDragEnd);
19
21
  return {
20
22
  on: events.on,
21
23
  off: events.off,
@@ -53,7 +53,7 @@ contextContainer.set("drawer");
53
53
  >
54
54
  <div
55
55
  class="{classHeader}
56
- sticky top-0 z-10 flex items-center
56
+ sticky top-0 z-20 flex items-center
57
57
  justify-between gap-32 border-b bg-base-100 p-4 pl-8
58
58
  "
59
59
  >
@@ -1,7 +1,5 @@
1
- export declare function createEventEmitter<EventMap extends Record<string, any>>(initialEvents: {
2
- [K in keyof EventMap]: Callback<EventMap[K]>[];
3
- }): {
4
- on<K extends keyof EventMap>(eventKey: K, callback: Callback<EventMap[K]>): void;
1
+ export declare function createEventEmitter<EventMap extends Record<string, any>>(): {
2
+ on<K extends keyof EventMap>(eventKey: K, callback: Callback<EventMap[K]>): () => void;
5
3
  off<K_1 extends keyof EventMap>(eventKey: K_1, callback: Callback<EventMap[K_1]>): void;
6
4
  emit<K_2 extends keyof EventMap>(...args: EventEmitterArgs<EventMap, K_2>): void;
7
5
  };
@@ -1,14 +1,26 @@
1
- export function createEventEmitter(initialEvents) {
2
- const events = { ...initialEvents };
1
+ export function createEventEmitter() {
2
+ const events = {};
3
3
  return {
4
4
  on(eventKey, callback) {
5
+ if (!events[eventKey])
6
+ events[eventKey] = [];
5
7
  events[eventKey].push(callback);
8
+ return function unsubscribe() {
9
+ if (!events[eventKey])
10
+ events[eventKey] = [];
11
+ const index = events[eventKey].indexOf(callback);
12
+ events[eventKey].splice(index, 1);
13
+ };
6
14
  },
7
15
  off(eventKey, callback) {
16
+ if (!events[eventKey])
17
+ events[eventKey] = [];
8
18
  const index = events[eventKey].indexOf(callback);
9
19
  events[eventKey].splice(index, 1);
10
20
  },
11
21
  emit(...args) {
22
+ if (!events[args[0]])
23
+ events[args[0]] = [];
12
24
  // @ts-ignore
13
25
  events[args[0]].forEach((callback) => callback(args[1]));
14
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma",
3
- "version": "0.3.32",
3
+ "version": "0.3.33",
4
4
  "description": "My fullstack material build with sveltekit, daisyui, zod, prisma, lucia",
5
5
  "author": {
6
6
  "name": "Jonas Voisard",