fuma 0.3.32 → 0.3.34

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,
@@ -14,7 +14,7 @@ export { klass as class };
14
14
  </div>
15
15
  <slot />
16
16
  <div class="mt-10 flex justify-end gap-2">
17
- <button type="button" class="btn btn-ghost btn-sm" on:click={() => dialog.close()}>
17
+ <button type="button" class="btn btn-ghost" on:click={() => dialog.close()}>
18
18
  Annuler
19
19
  </button>
20
20
  <slot name="action" />
@@ -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
  >
@@ -31,6 +31,7 @@ export let action = "";
31
31
  export let actionCreate = "_create";
32
32
  export let actionDelete = "_delete";
33
33
  export let actionUpdate = "_update";
34
+ export let simpleAction = false;
34
35
  export let options = {};
35
36
  let dataInput = initData(fields);
36
37
  export { dataInput as data };
@@ -90,7 +91,7 @@ const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === vo
90
91
 
91
92
  <form
92
93
  method="post"
93
- action="{action}{data.id ? actionUpdate : actionCreate}"
94
+ action="{action}{simpleAction ? '' : data.id ? actionUpdate : actionCreate}"
94
95
  enctype="multipart/form-data"
95
96
  class="{klass} flex flex-col gap-4"
96
97
  use:enhance
@@ -138,7 +139,7 @@ const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === vo
138
139
  >
139
140
  <button class="btn btn-primary"> Valider </button>
140
141
  <div class="grow" />
141
- {#if data.id && actionDelete}
142
+ {#if !simpleAction && data.id && actionDelete}
142
143
  {@const formaction = `${action}${actionDelete}`}
143
144
  <slot name="delete" {formaction}>
144
145
  <ButtonDelete {formaction}>Supprimer</ButtonDelete>
@@ -15,6 +15,7 @@ declare class __sveltets_Render<Shape extends z.ZodRawShape, ReturnData extends
15
15
  actionCreate?: string | undefined;
16
16
  actionDelete?: string | undefined;
17
17
  actionUpdate?: string | undefined;
18
+ /** Ignore actionCreate, actionDelete and actionUpdate */ simpleAction?: boolean | undefined;
18
19
  options?: UseFormOptions<ReturnData> | undefined;
19
20
  data?: Nullable<Data> | undefined;
20
21
  set?: (<K extends keyof Shape>(key: K, value: Nullable<Data>[K]) => void) | undefined;
@@ -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.34",
4
4
  "description": "My fullstack material build with sveltekit, daisyui, zod, prisma, lucia",
5
5
  "author": {
6
6
  "name": "Jonas Voisard",