fuma 0.3.35 → 0.3.36

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.
@@ -1,11 +1,12 @@
1
1
  <script>import { onDestroy } from "svelte";
2
- import { fade, fly } from "svelte/transition";
2
+ import { fade } from "svelte/transition";
3
3
  import { mdiClose } from "@mdi/js";
4
4
  import { goto } from "$app/navigation";
5
5
  import { urlParam } from "../../store/param.js";
6
6
  import { Icon } from "../icon/index.js";
7
7
  import { subscibeDrawerLayers } from "./layers.js";
8
8
  import { contextContainer } from "../context.js";
9
+ import { drawerFly } from "./drawerFly.js";
9
10
  export let title = "";
10
11
  export let key;
11
12
  let klass = "";
@@ -13,6 +14,8 @@ export { klass as class };
13
14
  export let maxWidth = "32rem";
14
15
  export let classHeader = "";
15
16
  export let classBody = "";
17
+ export let duration = 180;
18
+ export let noOverlay = false;
16
19
  export function open(value = 1, options = {}) {
17
20
  return goto($urlParam.with({ [key]: value }), {
18
21
  ...options,
@@ -26,27 +29,33 @@ export function close(options = {}) {
26
29
  const { offset, index, destroy, isActive } = subscibeDrawerLayers(key);
27
30
  onDestroy(destroy);
28
31
  contextContainer.set("drawer");
32
+ let clientWidth = 0;
29
33
  </script>
30
34
 
31
- {#if $isActive}
35
+ {#if !noOverlay && $isActive}
32
36
  <!-- svelte-ignore a11y-no-static-element-interactions -->
33
37
  <div
34
38
  on:click={() => close()}
35
39
  on:keyup={() => close()}
36
- transition:fade={{ duration: 200 }}
40
+ transition:fade={{ duration }}
37
41
  style="z-index: {10 + $index};"
38
42
  class="fixed inset-0 bg-black/15 backdrop-blur-[1.5px] dark:bg-white/15"
39
43
  />
44
+ {/if}
40
45
 
46
+ {#if $isActive}
41
47
  <aside
42
- transition:fly|local={{ x: 500, duration: 200, opacity: 1 }}
48
+ bind:clientWidth
49
+ transition:drawerFly|local={{ x: clientWidth, duration, opacity: 1 }}
43
50
  style="
44
51
  z-index: {10 + $index};
45
52
  max-width: min(100%, {maxWidth});
46
53
  transform: translateX({-$offset * 4}rem);
54
+ transition-duration: {duration}ms;
47
55
  "
48
- class="{klass}
49
- fixed bottom-0 right-0 top-0 z-10 flex
56
+ class:border-l={noOverlay}
57
+ class="{klass} fixed
58
+ bottom-0 right-0 top-0 z-10 flex
50
59
  w-full flex-col overflow-y-scroll bg-base-100
51
60
  transition-transform
52
61
  "
@@ -54,10 +63,10 @@ contextContainer.set("drawer");
54
63
  <div
55
64
  class="{classHeader}
56
65
  sticky top-0 z-20 flex items-center
57
- justify-between gap-32 border-b bg-base-100 p-4 pl-8
66
+ justify-between gap-2 border-b bg-base-100 p-4 pl-8
58
67
  "
59
68
  >
60
- <h2 class="title">{title}</h2>
69
+ <h2 class="title min-w-0 overflow-hidden">{title}</h2>
61
70
  <button on:click={() => close()} class="btn btn-square btn-sm">
62
71
  <Icon path={mdiClose} title="annuler" />
63
72
  </button>
@@ -7,6 +7,8 @@ declare const __propDef: {
7
7
  maxWidth?: string | undefined;
8
8
  classHeader?: string | undefined;
9
9
  classBody?: string | undefined;
10
+ duration?: number | undefined;
11
+ noOverlay?: boolean | undefined;
10
12
  open?: ((value?: number, options?: {
11
13
  replaceState?: boolean | undefined;
12
14
  noScroll?: boolean | undefined;
@@ -0,0 +1,8 @@
1
+ /// <reference types="svelte" />
2
+ import type { FlyParams, TransitionConfig } from 'svelte/transition';
3
+ export declare const drawerFlyTransition: import("svelte/store").Writable<{
4
+ x: number;
5
+ y: number;
6
+ }>;
7
+ export declare function drawerFly(node: HTMLElement, { delay, duration, easing, x, y, opacity }?: FlyParams): TransitionConfig;
8
+ export declare function split_css_unit(value: number | string): [number, string];
@@ -0,0 +1,26 @@
1
+ import { cubicOut } from 'svelte/easing';
2
+ import { writable } from 'svelte/store';
3
+ export const drawerFlyTransition = writable({ x: 0, y: 0 });
4
+ export function drawerFly(node, { delay = 0, duration = 400, easing = cubicOut, x = 0, y = 0, opacity = 0 } = {}) {
5
+ const style = getComputedStyle(node);
6
+ const target_opacity = +style.opacity;
7
+ const transform = style.transform === 'none' ? '' : style.transform;
8
+ const od = target_opacity * (1 - opacity);
9
+ const [xValue, xUnit] = split_css_unit(x);
10
+ const [yValue, yUnit] = split_css_unit(y);
11
+ return {
12
+ delay,
13
+ duration,
14
+ easing,
15
+ css: (t, u) => `
16
+ transform: ${transform} translate(${(1 - t) * xValue}${xUnit}, ${(1 - t) * yValue}${yUnit});
17
+ opacity: ${target_opacity - od * u}`,
18
+ tick: (t, u) => {
19
+ drawerFlyTransition.set({ x: t * xValue, y: t * yValue });
20
+ }
21
+ };
22
+ }
23
+ export function split_css_unit(value) {
24
+ const split = typeof value === 'string' && value.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);
25
+ return split ? [parseFloat(split[1]), split[2] || 'px'] : [value, 'px'];
26
+ }
@@ -1 +1,2 @@
1
1
  export { default as Drawer } from './Drawer.svelte';
2
+ export * from './drawerFly.js';
@@ -1 +1,2 @@
1
1
  export { default as Drawer } from './Drawer.svelte';
2
+ export * from './drawerFly.js';
@@ -78,13 +78,13 @@ function lookupValueFromParams() {
78
78
  const actionPadding = getActionPadding();
79
79
  function getActionPadding() {
80
80
  const container = contextContainer.get();
81
- if (container === "card")
82
- return "-mx-2 sm:-mx-8 px-2 sm:px-8";
83
81
  if (container === "drawer")
84
- return "-ml-8 -mr-4 pl-8 pr-4";
82
+ return "bottom-0 -ml-8 -mr-4 pl-8 pr-4";
83
+ if (container === "card")
84
+ return "-bottom-4 -mx-2 sm:-mx-8 px-2 sm:px-8";
85
85
  if (container === "dialog")
86
86
  return "-bottom-4 -mx-4 px-4";
87
- return "";
87
+ return "bottom-0";
88
88
  }
89
89
  const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === void 0 ? !!bool : !!bool(_data);
90
90
  </script>
@@ -134,7 +134,7 @@ const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === vo
134
134
  <div
135
135
  class="
136
136
  {classAction} {actionPadding}
137
- sticky bottom-0 col-span-full mt-2 flex flex-row-reverse gap-2 border-t py-4 backdrop-blur-sm
137
+ sticky col-span-full mt-2 flex flex-row-reverse gap-2 border-t py-4 backdrop-blur-sm
138
138
  "
139
139
  >
140
140
  <button class="btn btn-primary"> Valider </button>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma",
3
- "version": "0.3.35",
3
+ "version": "0.3.36",
4
4
  "description": "My fullstack material build with sveltekit, daisyui, zod, prisma, lucia",
5
5
  "author": {
6
6
  "name": "Jonas Voisard",