@axel669/zephyr 1.0.0-beta.1 → 1.0.0-dev.1
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/LICENSE +21 -21
- package/compiler/build.js +13 -0
- package/compiler/parser.js +2973 -0
- package/compiler/rollup.js +28 -0
- package/compiler/transpiler.js +140 -0
- package/dist/zephyr-unstyled.js +587 -0
- package/dist/zephyr-unstyled.min.js +1 -0
- package/dist/zephyr.js +2002 -0
- package/dist/zephyr.min.js +47 -0
- package/package.json +35 -33
- package/readme.md +194 -19
- package/src/changed.svelte.js +0 -23
- package/src/component/adorn.svelte +0 -9
- package/src/component/alert.svelte +0 -32
- package/src/component/application.svelte +0 -17
- package/src/component/async-button.svelte +0 -53
- package/src/component/avatar.svelte +0 -15
- package/src/component/badge.svelte +0 -7
- package/src/component/button.svelte +0 -7
- package/src/component/chip.svelte +0 -10
- package/src/component/circle-spinner.svelte +0 -6
- package/src/component/confirm.svelte +0 -40
- package/src/component/control-label.svelte +0 -41
- package/src/component/data-table.svelte +0 -227
- package/src/component/details.svelte +0 -22
- package/src/component/dialog-element.svelte +0 -36
- package/src/component/dialog.svelte +0 -43
- package/src/component/drawer.svelte +0 -20
- package/src/component/flex.svelte +0 -7
- package/src/component/grid.svelte +0 -7
- package/src/component/hexagon-spinner.svelte +0 -6
- package/src/component/icon.svelte +0 -7
- package/src/component/link.svelte +0 -11
- package/src/component/modal.svelte +0 -32
- package/src/component/paper.svelte +0 -33
- package/src/component/popover.svelte +0 -19
- package/src/component/progress.svelte +0 -6
- package/src/component/prompt.svelte +0 -58
- package/src/component/route.svelte +0 -62
- package/src/component/routing.svelte.js +0 -63
- package/src/component/screen.svelte +0 -30
- package/src/component/select.svelte +0 -40
- package/src/component/suspend.svelte +0 -44
- package/src/component/table.svelte +0 -49
- package/src/component/tabs.svelte +0 -2
- package/src/component/text.svelte +0 -26
- package/src/component/title.svelte +0 -28
- package/src/component/titlebar.svelte +0 -23
- package/src/component/toast.svelte +0 -7
- package/src/component/toaster.svelte +0 -60
- package/src/component/toggle-label.svelte +0 -11
- package/src/component/tooltip.svelte +0 -11
- package/src/handler$.js +0 -20
- package/src/hash.js +0 -14
- package/src/index.js +0 -65
- package/src/internals.js +0 -12
- package/src/main.js +0 -40
- package/src/props.js +0 -24
- package/src/variant.js +0 -10
- package/src/wind.js +0 -4
- package/src/ws.js +0 -10
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Button from "./button.svelte"
|
|
3
|
-
import Paper from "./paper.svelte"
|
|
4
|
-
import Text from "./text.svelte"
|
|
5
|
-
import Titlebar from "./titlebar.svelte"
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
message,
|
|
9
|
-
close,
|
|
10
|
-
color = "@primary",
|
|
11
|
-
} = $props()
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<Paper ws="@color: {color}; variant.outline;">
|
|
15
|
-
{#snippet header()}
|
|
16
|
-
<Titlebar ws="@color: {color};">
|
|
17
|
-
<Text header>
|
|
18
|
-
Alert
|
|
19
|
-
</Text>
|
|
20
|
-
</Titlebar>
|
|
21
|
-
{/snippet}
|
|
22
|
-
|
|
23
|
-
<Text ws="p: 8px;">
|
|
24
|
-
{message}
|
|
25
|
-
</Text>
|
|
26
|
-
|
|
27
|
-
{#snippet footer()}
|
|
28
|
-
<Button ws="@color: @success;" onclick={() => close(true)}>
|
|
29
|
-
OK
|
|
30
|
-
</Button>
|
|
31
|
-
{/snippet}
|
|
32
|
-
</Paper>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Dialog from "./dialog.svelte"
|
|
3
|
-
import Toaster from "./toaster.svelte"
|
|
4
|
-
import { wsAttr } from "../ws.js"
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
baseline = "",
|
|
8
|
-
theme = "tron",
|
|
9
|
-
children,
|
|
10
|
-
} = $props()
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<svelte:body use:wsAttr={`#theme.${theme}; ${baseline}`} />
|
|
14
|
-
|
|
15
|
-
<Toaster />
|
|
16
|
-
<Dialog />
|
|
17
|
-
{@render children?.()}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { ws } from "../ws.js"
|
|
3
|
-
|
|
4
|
-
ws.component("ze-async-button")`
|
|
5
|
-
disp: inline-grid;
|
|
6
|
-
pos.rel;
|
|
7
|
-
`
|
|
8
|
-
|
|
9
|
-
ws.macro("async.button.spinner")`
|
|
10
|
-
@size: 100%;
|
|
11
|
-
pos.abs;
|
|
12
|
-
x: 50%;
|
|
13
|
-
y: 0px;
|
|
14
|
-
tf: translateX(-50%);
|
|
15
|
-
h: 100%;
|
|
16
|
-
`
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<script>
|
|
20
|
-
import Button from "./button.svelte"
|
|
21
|
-
import CircleSpinner from "./circle-spinner.svelte"
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
onclick,
|
|
25
|
-
onresolve,
|
|
26
|
-
hideSpinner = false,
|
|
27
|
-
children,
|
|
28
|
-
disabled,
|
|
29
|
-
spinnerWS = "",
|
|
30
|
-
...props
|
|
31
|
-
} = $props()
|
|
32
|
-
|
|
33
|
-
let waiting = $state(false)
|
|
34
|
-
const handler = async (e) => {
|
|
35
|
-
waiting = true
|
|
36
|
-
const value = await onclick?.(e)
|
|
37
|
-
waiting = false
|
|
38
|
-
onresolve?.(value)
|
|
39
|
-
}
|
|
40
|
-
const dis = $derived(
|
|
41
|
-
disabled === true
|
|
42
|
-
|| waiting === true
|
|
43
|
-
)
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
|
-
<ze-async-button>
|
|
47
|
-
<Button {...props} onclick={handler} disabled={dis}>
|
|
48
|
-
{@render children?.()}
|
|
49
|
-
</Button>
|
|
50
|
-
{#if waiting === true && hideSpinner === false}
|
|
51
|
-
<CircleSpinner ws="async.button.spinner; {spinnerWS}" />
|
|
52
|
-
{/if}
|
|
53
|
-
</ze-async-button>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const { ws, image, type = "image/png", text, children, ...rest } = $props()
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<ws-avatar data-ws={ws} {...rest}>
|
|
6
|
-
{#if children !== undefined}
|
|
7
|
-
{@render children()}
|
|
8
|
-
{:else if text !== undefined}
|
|
9
|
-
{text}
|
|
10
|
-
{:else}
|
|
11
|
-
<!-- svelte-ignore a11y_missing_attribute -->
|
|
12
|
-
<!-- svelte-ignore element_invalid_self_closing_tag -->
|
|
13
|
-
<object data={image} {type} />
|
|
14
|
-
{/if}
|
|
15
|
-
</ws-avatar>
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Button from "./button.svelte"
|
|
3
|
-
import Grid from "./grid.svelte"
|
|
4
|
-
import Paper from "./paper.svelte"
|
|
5
|
-
import Text from "./text.svelte"
|
|
6
|
-
import Titlebar from "./titlebar.svelte"
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
message,
|
|
10
|
-
close,
|
|
11
|
-
color = "@primary",
|
|
12
|
-
okText = "OK",
|
|
13
|
-
cancelText = "Cancel",
|
|
14
|
-
} = $props()
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<Paper ws="@color: {color}; variant.outline;">
|
|
18
|
-
{#snippet header()}
|
|
19
|
-
<Titlebar ws="@color: {color};">
|
|
20
|
-
<Text header>
|
|
21
|
-
Confirm
|
|
22
|
-
</Text>
|
|
23
|
-
</Titlebar>
|
|
24
|
-
{/snippet}
|
|
25
|
-
|
|
26
|
-
<Text ws="p: 8px;">
|
|
27
|
-
{message}
|
|
28
|
-
</Text>
|
|
29
|
-
|
|
30
|
-
{#snippet footer()}
|
|
31
|
-
<Grid ws="gr.cols: 1fr 1fr; p: 0px;">
|
|
32
|
-
<Button ws="@color: @error;" onclick={() => close(false)}>
|
|
33
|
-
{cancelText}
|
|
34
|
-
</Button>
|
|
35
|
-
<Button ws="@color: @success;" onclick={() => close(true)}>
|
|
36
|
-
{okText}
|
|
37
|
-
</Button>
|
|
38
|
-
</Grid>
|
|
39
|
-
{/snippet}
|
|
40
|
-
</Paper>
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const {
|
|
3
|
-
ws,
|
|
4
|
-
labelWS,
|
|
5
|
-
label,
|
|
6
|
-
children,
|
|
7
|
-
start,
|
|
8
|
-
end,
|
|
9
|
-
extra,
|
|
10
|
-
...rest
|
|
11
|
-
} = $props()
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<label control data-ws={ws ?? ""} {...rest}>
|
|
15
|
-
{#if label}
|
|
16
|
-
<ws-text label-text data-ws={labelWS}>
|
|
17
|
-
{#if typeof label !== "function"}
|
|
18
|
-
{label}
|
|
19
|
-
{:else}
|
|
20
|
-
{@render label()}
|
|
21
|
-
{/if}
|
|
22
|
-
</ws-text>
|
|
23
|
-
{/if}
|
|
24
|
-
{@render children()}
|
|
25
|
-
|
|
26
|
-
{#if start}
|
|
27
|
-
<ze-input-start data-ws="area: start; grid;">
|
|
28
|
-
{@render start()}
|
|
29
|
-
</ze-input-start>
|
|
30
|
-
{/if}
|
|
31
|
-
{#if end}
|
|
32
|
-
<ze-input-end data-ws="area: end; grid;">
|
|
33
|
-
{@render end()}
|
|
34
|
-
</ze-input-end>
|
|
35
|
-
{/if}
|
|
36
|
-
{#if extra}
|
|
37
|
-
<ze-input-extra data-ws="area: extra; grid;">
|
|
38
|
-
{@render extra()}
|
|
39
|
-
</ze-input-extra>
|
|
40
|
-
{/if}
|
|
41
|
-
</label>
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { ws as wind } from "../ws.js"
|
|
3
|
-
|
|
4
|
-
wind.component("ze-data-table")`
|
|
5
|
-
pos.rel;
|
|
6
|
-
grid;
|
|
7
|
-
gr.cols: 1fr;
|
|
8
|
-
gr.rows: 1fr min-content;
|
|
9
|
-
p: 0px;
|
|
10
|
-
h: 100%;
|
|
11
|
-
w: 100%;
|
|
12
|
-
h.max: 100%;
|
|
13
|
-
w.max: 100%;
|
|
14
|
-
`
|
|
15
|
-
wind.component("ze-data-scroller")`
|
|
16
|
-
pos.rel;
|
|
17
|
-
over: auto;
|
|
18
|
-
! &::before {
|
|
19
|
-
*content: "";
|
|
20
|
-
pos.abs;
|
|
21
|
-
w: 1px;
|
|
22
|
-
h: @h;
|
|
23
|
-
z: -1;
|
|
24
|
-
}
|
|
25
|
-
`
|
|
26
|
-
wind.component("ze-fake-scroll")`
|
|
27
|
-
disp: block;
|
|
28
|
-
w: 100%;
|
|
29
|
-
h: @h;
|
|
30
|
-
pos.stick;
|
|
31
|
-
y: 0px;
|
|
32
|
-
over: hidden;
|
|
33
|
-
`
|
|
34
|
-
wind.component("ze-data-footer")`
|
|
35
|
-
pos: rel;
|
|
36
|
-
grid;
|
|
37
|
-
`
|
|
38
|
-
|
|
39
|
-
const itemRange = (info) => {
|
|
40
|
-
const {
|
|
41
|
-
scrollPos,
|
|
42
|
-
scrollMax,
|
|
43
|
-
rowSize,
|
|
44
|
-
length,
|
|
45
|
-
containerHeight,
|
|
46
|
-
} = info
|
|
47
|
-
if (scrollMax === null) {
|
|
48
|
-
return [0, 0]
|
|
49
|
-
}
|
|
50
|
-
const displayed = Math.ceil(containerHeight / rowSize) - 1
|
|
51
|
-
const itemPos = Math.floor(
|
|
52
|
-
(scrollPos / scrollMax) * (length - displayed)
|
|
53
|
-
)
|
|
54
|
-
return [
|
|
55
|
-
itemPos - 1,
|
|
56
|
-
itemPos + displayed + 1,
|
|
57
|
-
displayed + 2,
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
const emptyRow = Symbol("empty row")
|
|
61
|
-
const nullRow = Symbol("null row")
|
|
62
|
-
|
|
63
|
-
const sliceData = (data, range) => {
|
|
64
|
-
const displayed = data.slice(
|
|
65
|
-
Math.max(range[0], 0),
|
|
66
|
-
range[1]
|
|
67
|
-
)
|
|
68
|
-
if (range[0] === -1) {
|
|
69
|
-
return [emptyRow, ...displayed]
|
|
70
|
-
}
|
|
71
|
-
if (displayed.length < range[2]) {
|
|
72
|
-
return [
|
|
73
|
-
...displayed,
|
|
74
|
-
...Array.from(
|
|
75
|
-
{ length: range[2] - displayed.length },
|
|
76
|
-
() => nullRow
|
|
77
|
-
)
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
return displayed
|
|
81
|
-
}
|
|
82
|
-
</script>
|
|
83
|
-
<script>
|
|
84
|
-
import { onMount } from "svelte"
|
|
85
|
-
import { on } from "svelte/events"
|
|
86
|
-
|
|
87
|
-
const {
|
|
88
|
-
rowSize = 30,
|
|
89
|
-
headerSize = rowSize,
|
|
90
|
-
header = Header,
|
|
91
|
-
row = Row,
|
|
92
|
-
ws = "",
|
|
93
|
-
data,
|
|
94
|
-
footer = Footer,
|
|
95
|
-
} = $props()
|
|
96
|
-
|
|
97
|
-
const keys = $derived(
|
|
98
|
-
Object.keys(data?.[0] ?? {})
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
const itemsHeight = $derived(
|
|
102
|
-
rowSize * data.length
|
|
103
|
-
)
|
|
104
|
-
const tableHeight = $derived(itemsHeight + headerSize)
|
|
105
|
-
|
|
106
|
-
let scrollPos = $state(0)
|
|
107
|
-
let scrollMax = $state(null)
|
|
108
|
-
let containerHeight = $state(null)
|
|
109
|
-
const scrollHandler = (evt) => {
|
|
110
|
-
scrollPos = container.scrollTop
|
|
111
|
-
}
|
|
112
|
-
const range = $derived(
|
|
113
|
-
itemRange({
|
|
114
|
-
scrollPos,
|
|
115
|
-
scrollMax,
|
|
116
|
-
containerHeight,
|
|
117
|
-
rowSize,
|
|
118
|
-
length: data.length,
|
|
119
|
-
})
|
|
120
|
-
)
|
|
121
|
-
let container = $state(null)
|
|
122
|
-
|
|
123
|
-
$inspect(scrollMax, containerHeight)
|
|
124
|
-
|
|
125
|
-
onMount(() => {
|
|
126
|
-
containerHeight = container.clientHeight
|
|
127
|
-
scrollMax = container.scrollHeight - containerHeight
|
|
128
|
-
on(container, "scroll", scrollHandler, { passive: true })
|
|
129
|
-
const observer = new ResizeObserver(
|
|
130
|
-
() => {
|
|
131
|
-
containerHeight = container.clientHeight
|
|
132
|
-
scrollMax = container.scrollHeight - containerHeight
|
|
133
|
-
}
|
|
134
|
-
)
|
|
135
|
-
observer.observe(container)
|
|
136
|
-
return () => observer.unobserve(container)
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
const displayed = $derived(range[2])
|
|
140
|
-
const displayedRows = $derived(
|
|
141
|
-
sliceData(data, range)
|
|
142
|
-
)
|
|
143
|
-
const show = $derived({
|
|
144
|
-
start: Math.max(1, range[0] + 2),
|
|
145
|
-
end: Math.min(data.length, range[1] - 1),
|
|
146
|
-
total: data.length,
|
|
147
|
-
})
|
|
148
|
-
const correction = $derived(
|
|
149
|
-
(data.length - displayed) * rowSize
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
const itemOffset = $derived(
|
|
153
|
-
range[0] * rowSize - scrollPos
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
const containerWS = $derived(
|
|
157
|
-
wind.x({
|
|
158
|
-
"! & :where(thead, tbody)": {
|
|
159
|
-
w: "100%",
|
|
160
|
-
},
|
|
161
|
-
"! & thead > tr": {
|
|
162
|
-
h: "@header",
|
|
163
|
-
z: "+5",
|
|
164
|
-
"pos.rel": true,
|
|
165
|
-
},
|
|
166
|
-
"! & tbody > tr": {
|
|
167
|
-
h: "@row",
|
|
168
|
-
},
|
|
169
|
-
})
|
|
170
|
-
)
|
|
171
|
-
</script>
|
|
172
|
-
|
|
173
|
-
{#snippet Header(keys)}
|
|
174
|
-
<tr>
|
|
175
|
-
{#each keys as key}
|
|
176
|
-
<th>{key}</th>
|
|
177
|
-
{/each}
|
|
178
|
-
</tr>
|
|
179
|
-
{/snippet}
|
|
180
|
-
{#snippet Row(item, keys)}
|
|
181
|
-
<tr>
|
|
182
|
-
{#each keys as key}
|
|
183
|
-
<td>{item[key]}</td>
|
|
184
|
-
{/each}
|
|
185
|
-
</tr>
|
|
186
|
-
{/snippet}
|
|
187
|
-
{#snippet Footer(show, displayed)}
|
|
188
|
-
<div data-ws="flex; fl.cn; h.min: 32px;">
|
|
189
|
-
<div>
|
|
190
|
-
Showing: {show.start} - {show.end} of {show.total}
|
|
191
|
-
</div>
|
|
192
|
-
</div>
|
|
193
|
-
{/snippet}
|
|
194
|
-
|
|
195
|
-
<ze-data-table data-ws={containerWS}>
|
|
196
|
-
<ze-data-scroller
|
|
197
|
-
bind:this={container}
|
|
198
|
-
data-ws="@h: {tableHeight}px; @header: {headerSize}px; @row: {rowSize}px;"
|
|
199
|
-
>
|
|
200
|
-
<ze-fake-scroll data-ws="@h: {containerHeight}px;">
|
|
201
|
-
<table data-ws="w: 100%; {ws}">
|
|
202
|
-
<thead>
|
|
203
|
-
{#if data?.length > 0}
|
|
204
|
-
{@render header(keys)}
|
|
205
|
-
{:else}
|
|
206
|
-
<tr>
|
|
207
|
-
<td>N/A</td>
|
|
208
|
-
</tr>
|
|
209
|
-
{/if}
|
|
210
|
-
</thead>
|
|
211
|
-
<tbody data-ws="tf: translateY({itemOffset}px);">
|
|
212
|
-
{#each displayedRows as item}
|
|
213
|
-
{@render row(item, keys)}
|
|
214
|
-
{:else}
|
|
215
|
-
<tr>
|
|
216
|
-
<td>No Items</td>
|
|
217
|
-
</tr>
|
|
218
|
-
{/each}
|
|
219
|
-
</tbody>
|
|
220
|
-
</table>
|
|
221
|
-
</ze-fake-scroll>
|
|
222
|
-
</ze-data-scroller>
|
|
223
|
-
|
|
224
|
-
<ze-data-footer>
|
|
225
|
-
{@render footer(show, displayedRows)}
|
|
226
|
-
</ze-data-footer>
|
|
227
|
-
</ze-data-table>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
let {
|
|
3
|
-
open = $bindable(false),
|
|
4
|
-
ws,
|
|
5
|
-
summaryWS,
|
|
6
|
-
children,
|
|
7
|
-
label = "",
|
|
8
|
-
summary,
|
|
9
|
-
...rest
|
|
10
|
-
} = $props()
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<details data-ws={ws ?? ""} bind:open {...rest}>
|
|
14
|
-
<summary data-ws={summaryWS}>
|
|
15
|
-
{#if summary !== undefined}
|
|
16
|
-
{@render summary()}
|
|
17
|
-
{:else}
|
|
18
|
-
{label}
|
|
19
|
-
{/if}
|
|
20
|
-
</summary>
|
|
21
|
-
{@render children()}
|
|
22
|
-
</details>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { onMount } from "svelte"
|
|
3
|
-
import Modal from "./modal.svelte"
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
options,
|
|
7
|
-
dialog,
|
|
8
|
-
} = $props()
|
|
9
|
-
|
|
10
|
-
let open = $state(false)
|
|
11
|
-
|
|
12
|
-
onMount(() => open = true)
|
|
13
|
-
|
|
14
|
-
const {
|
|
15
|
-
tIn,
|
|
16
|
-
tOut,
|
|
17
|
-
close,
|
|
18
|
-
ws = "",
|
|
19
|
-
persistent,
|
|
20
|
-
...opts
|
|
21
|
-
} = options
|
|
22
|
-
const dialogClose = (value) => {
|
|
23
|
-
open = false
|
|
24
|
-
setTimeout(
|
|
25
|
-
() => close(value),
|
|
26
|
-
tOut.duration
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
const onClose = () => dialogClose(null)
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<Modal bind:open inTime={0} outTime={tOut.duration} {onClose} {persistent}>
|
|
33
|
-
<ws-dialog in:tIn.func={tIn} out:tOut.func={tOut} data-ws={ws} tabindex="-1">
|
|
34
|
-
{@render dialog({ ...opts, close: dialogClose })}
|
|
35
|
-
</ws-dialog>
|
|
36
|
-
</Modal>
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { fade } from "svelte/transition"
|
|
3
|
-
|
|
4
|
-
import DialogElement from "./dialog-element.svelte"
|
|
5
|
-
let stack = $state([])
|
|
6
|
-
|
|
7
|
-
const defTf = {
|
|
8
|
-
duration: 250,
|
|
9
|
-
func: fade
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const showDialog = (options) => new Promise(
|
|
13
|
-
(resolve) => {
|
|
14
|
-
const {
|
|
15
|
-
dialog = null,
|
|
16
|
-
transition = defTf,
|
|
17
|
-
transitionIn = transition,
|
|
18
|
-
transitionOut = transition,
|
|
19
|
-
...opts
|
|
20
|
-
} = options
|
|
21
|
-
if (dialog === null) {
|
|
22
|
-
return false
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const id = `${Math.random()}:${Date.now()}`
|
|
26
|
-
const close = (value) => {
|
|
27
|
-
stack = stack.filter(
|
|
28
|
-
(dia) => dia[2] !== id
|
|
29
|
-
)
|
|
30
|
-
resolve(value)
|
|
31
|
-
}
|
|
32
|
-
stack.push([
|
|
33
|
-
dialog,
|
|
34
|
-
{ ...opts, tIn: transitionIn, tOut: transitionOut, close },
|
|
35
|
-
id
|
|
36
|
-
])
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
{#each stack as [dialog, options, id] (id)}
|
|
42
|
-
<DialogElement {options} {dialog} />
|
|
43
|
-
{/each}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { fly } from "svelte/transition"
|
|
3
|
-
import Modal from "./modal.svelte"
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
open = $bindable(false),
|
|
7
|
-
ws = "",
|
|
8
|
-
children,
|
|
9
|
-
onclose,
|
|
10
|
-
animTime = 250,
|
|
11
|
-
tr = fly,
|
|
12
|
-
trArgs = { x: "-100%" }
|
|
13
|
-
} = $props()
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<Modal bind:open {onclose} {animTime}>
|
|
17
|
-
<ws-drawer transition:tr={{ ...trArgs, duration: animTime }} data-ws={ws}>
|
|
18
|
-
{@render children?.()}
|
|
19
|
-
</ws-drawer>
|
|
20
|
-
</Modal>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
let {
|
|
3
|
-
open = $bindable(false),
|
|
4
|
-
children,
|
|
5
|
-
ws = "",
|
|
6
|
-
onclose,
|
|
7
|
-
animTime,
|
|
8
|
-
inTime = animTime,
|
|
9
|
-
outTime = animTime,
|
|
10
|
-
persistent = false,
|
|
11
|
-
} = $props()
|
|
12
|
-
|
|
13
|
-
const vis = (node, opts) => {
|
|
14
|
-
const { duration } = opts
|
|
15
|
-
return {
|
|
16
|
-
duration,
|
|
17
|
-
css: (t, u) => "visibility: visible;"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const close = (evt) => {
|
|
22
|
-
open = false
|
|
23
|
-
onclose?.(evt)
|
|
24
|
-
}
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
{#if open === true}
|
|
28
|
-
<ws-modal open data-ws={ws} onclose={close} {persistent}
|
|
29
|
-
in:vis={{ duration: inTime }} out:vis={{ duration: outTime }}>
|
|
30
|
-
{@render children?.()}
|
|
31
|
-
</ws-modal>
|
|
32
|
-
{/if}
|