fuma 0.3.35 → 0.3.37
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.
- package/dist/private/store.d.ts +2 -0
- package/dist/private/store.js +2 -0
- package/dist/ui/drawer/Drawer.svelte +26 -8
- package/dist/ui/drawer/Drawer.svelte.d.ts +3 -0
- package/dist/ui/drawer/drawerFly.d.ts +10 -0
- package/dist/ui/drawer/drawerFly.js +24 -0
- package/dist/ui/drawer/index.d.ts +1 -0
- package/dist/ui/drawer/index.js +1 -0
- package/dist/ui/form/Form.svelte +5 -5
- package/dist/utils/eventEmitter.js +0 -1
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
<script>import { onDestroy } from "svelte";
|
|
2
|
-
import { fade
|
|
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";
|
|
10
|
+
import { writable } from "svelte/store";
|
|
9
11
|
export let title = "";
|
|
10
12
|
export let key;
|
|
11
13
|
let klass = "";
|
|
@@ -13,6 +15,9 @@ export { klass as class };
|
|
|
13
15
|
export let maxWidth = "32rem";
|
|
14
16
|
export let classHeader = "";
|
|
15
17
|
export let classBody = "";
|
|
18
|
+
export let duration = 180;
|
|
19
|
+
export let noOverlay = false;
|
|
20
|
+
export let transitionX = 0;
|
|
16
21
|
export function open(value = 1, options = {}) {
|
|
17
22
|
return goto($urlParam.with({ [key]: value }), {
|
|
18
23
|
...options,
|
|
@@ -26,27 +31,40 @@ export function close(options = {}) {
|
|
|
26
31
|
const { offset, index, destroy, isActive } = subscibeDrawerLayers(key);
|
|
27
32
|
onDestroy(destroy);
|
|
28
33
|
contextContainer.set("drawer");
|
|
34
|
+
let clientWidth = 0;
|
|
29
35
|
</script>
|
|
30
36
|
|
|
31
|
-
{#if $isActive}
|
|
37
|
+
{#if !noOverlay && $isActive}
|
|
32
38
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
33
39
|
<div
|
|
34
40
|
on:click={() => close()}
|
|
35
41
|
on:keyup={() => close()}
|
|
36
|
-
transition:fade={{ duration
|
|
42
|
+
transition:fade={{ duration }}
|
|
37
43
|
style="z-index: {10 + $index};"
|
|
38
44
|
class="fixed inset-0 bg-black/15 backdrop-blur-[1.5px] dark:bg-white/15"
|
|
39
45
|
/>
|
|
46
|
+
{/if}
|
|
40
47
|
|
|
48
|
+
{#if $isActive}
|
|
41
49
|
<aside
|
|
42
|
-
|
|
50
|
+
bind:clientWidth
|
|
51
|
+
transition:drawerFly|local={{
|
|
52
|
+
x: clientWidth,
|
|
53
|
+
duration,
|
|
54
|
+
opacity: 1,
|
|
55
|
+
onTransition(pos) {
|
|
56
|
+
transitionX = pos.x
|
|
57
|
+
}
|
|
58
|
+
}}
|
|
43
59
|
style="
|
|
44
60
|
z-index: {10 + $index};
|
|
45
61
|
max-width: min(100%, {maxWidth});
|
|
46
62
|
transform: translateX({-$offset * 4}rem);
|
|
63
|
+
transition-duration: {duration}ms;
|
|
47
64
|
"
|
|
48
|
-
class=
|
|
49
|
-
|
|
65
|
+
class:border-l={noOverlay}
|
|
66
|
+
class="{klass} fixed
|
|
67
|
+
bottom-0 right-0 top-0 z-10 flex
|
|
50
68
|
w-full flex-col overflow-y-scroll bg-base-100
|
|
51
69
|
transition-transform
|
|
52
70
|
"
|
|
@@ -54,10 +72,10 @@ contextContainer.set("drawer");
|
|
|
54
72
|
<div
|
|
55
73
|
class="{classHeader}
|
|
56
74
|
sticky top-0 z-20 flex items-center
|
|
57
|
-
justify-between gap-
|
|
75
|
+
justify-between gap-2 border-b bg-base-100 p-4 pl-8
|
|
58
76
|
"
|
|
59
77
|
>
|
|
60
|
-
<h2 class="title">{title}</h2>
|
|
78
|
+
<h2 class="title min-w-0 overflow-hidden">{title}</h2>
|
|
61
79
|
<button on:click={() => close()} class="btn btn-square btn-sm">
|
|
62
80
|
<Icon path={mdiClose} title="annuler" />
|
|
63
81
|
</button>
|
|
@@ -7,6 +7,9 @@ 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;
|
|
12
|
+
transitionX?: number | undefined;
|
|
10
13
|
open?: ((value?: number, options?: {
|
|
11
14
|
replaceState?: boolean | undefined;
|
|
12
15
|
noScroll?: boolean | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { FlyParams, TransitionConfig } from 'svelte/transition';
|
|
3
|
+
export type DrawerFlyParams = FlyParams & {
|
|
4
|
+
onTransition?: (pos: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}) => unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare function drawerFly(node: HTMLElement, { delay, duration, easing, x, y, opacity, onTransition }?: DrawerFlyParams): TransitionConfig;
|
|
10
|
+
export declare function split_css_unit(value: number | string): [number, string];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { cubicOut } from 'svelte/easing';
|
|
2
|
+
export function drawerFly(node, { delay = 0, duration = 400, easing = cubicOut, x = 0, y = 0, opacity = 0, onTransition = () => { } } = {}) {
|
|
3
|
+
const style = getComputedStyle(node);
|
|
4
|
+
const target_opacity = +style.opacity;
|
|
5
|
+
const transform = style.transform === 'none' ? '' : style.transform;
|
|
6
|
+
const od = target_opacity * (1 - opacity);
|
|
7
|
+
const [xValue, xUnit] = split_css_unit(x);
|
|
8
|
+
const [yValue, yUnit] = split_css_unit(y);
|
|
9
|
+
return {
|
|
10
|
+
delay,
|
|
11
|
+
duration,
|
|
12
|
+
easing,
|
|
13
|
+
css: (t, u) => `
|
|
14
|
+
transform: ${transform} translate(${(1 - t) * xValue}${xUnit}, ${(1 - t) * yValue}${yUnit});
|
|
15
|
+
opacity: ${target_opacity - od * u}`,
|
|
16
|
+
tick: (t, u) => {
|
|
17
|
+
onTransition({ x: t * xValue, y: t * yValue });
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function split_css_unit(value) {
|
|
22
|
+
const split = typeof value === 'string' && value.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);
|
|
23
|
+
return split ? [parseFloat(split[1]), split[2] || 'px'] : [value, 'px'];
|
|
24
|
+
}
|
package/dist/ui/drawer/index.js
CHANGED
package/dist/ui/form/Form.svelte
CHANGED
|
@@ -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
|
|
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>
|