@axel669/zephyr 0.2.0-beta.3 → 0.3.6
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/package.json +33 -33
- package/readme.md +63 -63
- package/src/async/button.md +27 -0
- package/src/async/button.svelte +29 -31
- package/src/async/load-zone.md +42 -0
- package/src/async/load-zone.svelte +22 -20
- package/src/composed/data-table/th.md +21 -0
- package/src/composed/data-table/th.svelte +61 -61
- package/src/composed/data-table.md +86 -85
- package/src/composed/data-table.svelte +199 -149
- package/src/composed/entry-button.md +44 -34
- package/src/composed/entry-button.svelte +31 -31
- package/src/composed/table-functions.js +13 -13
- package/src/composed/toast/message.svelte +56 -56
- package/src/composed/toast.md +45 -36
- package/src/composed/toast.svelte +70 -70
- package/src/control/button.md +41 -41
- package/src/control/button.svelte +27 -27
- package/src/control/input.md +87 -0
- package/src/control/input.svelte +109 -109
- package/src/control/label.md +48 -49
- package/src/control/label.svelte +38 -38
- package/src/control/link.md +50 -50
- package/src/control/link.svelte +32 -30
- package/src/control/radio.md +58 -58
- package/src/control/radio.svelte +28 -28
- package/src/control/select.md +70 -70
- package/src/control/select.svelte +64 -64
- package/src/control/tabs.md +47 -47
- package/src/control/tabs.svelte +43 -41
- package/src/control/toggle.md +61 -61
- package/src/control/toggle.svelte +49 -49
- package/src/data-display/avatar.md +36 -36
- package/src/data-display/avatar.svelte +25 -25
- package/src/data-display/badge.md +30 -30
- package/src/data-display/badge.svelte +14 -14
- package/src/data-display/chip.md +36 -36
- package/src/data-display/chip.svelte +28 -28
- package/src/data-display/details.md +42 -3
- package/src/data-display/details.svelte +25 -25
- package/src/data-display/popover.md +32 -32
- package/src/data-display/popover.svelte +25 -25
- package/src/data-display/progress.md +46 -46
- package/src/data-display/progress.svelte +27 -27
- package/src/data-display/table.md +59 -7
- package/src/data-display/table.svelte +38 -38
- package/src/data-display/tooltip.md +29 -29
- package/src/data-display/tooltip.svelte +17 -17
- package/src/dialogs/alert.md +42 -3
- package/src/dialogs/alert.svelte +34 -34
- package/src/dialogs/confirm.md +56 -3
- package/src/dialogs/confirm.svelte +45 -45
- package/src/functions.md +108 -83
- package/src/handler$.mjs +20 -20
- package/src/hash.js +14 -0
- package/src/index.mjs +53 -52
- package/src/info/icon.md +21 -21
- package/src/info/icon.svelte +9 -9
- package/src/info/notification.md +36 -36
- package/src/info/notification.svelte +16 -16
- package/src/info/titlebar.md +75 -75
- package/src/info/titlebar.svelte +18 -18
- package/src/info/toaster.md +26 -26
- package/src/info/toaster.svelte +14 -14
- package/src/inline-dialog.svelte +23 -23
- package/src/layout/dialog.md +43 -43
- package/src/layout/dialog.svelte +26 -26
- package/src/layout/drawer.md +70 -70
- package/src/layout/drawer.svelte +49 -49
- package/src/layout/flex.md +43 -43
- package/src/layout/flex.svelte +26 -24
- package/src/layout/grid.md +61 -61
- package/src/layout/grid.svelte +30 -28
- package/src/layout/modal.md +50 -50
- package/src/layout/modal.svelte +60 -60
- package/src/layout/paper.md +94 -94
- package/src/layout/paper.svelte +47 -47
- package/src/layout/screen.md +33 -33
- package/src/layout/screen.svelte +34 -34
- package/src/spinner/circle-spinner.svelte +15 -15
- package/src/spinner/hexagon-spinner.svelte +15 -15
- package/src/spinner/spinners.md +22 -3
- package/src/text.md +34 -34
- package/src/text.svelte +22 -22
- package/src/variant.mjs +12 -12
- package/src/wsx.mjs +24 -24
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
# Progress
|
|
2
|
-
|
|
3
|
-
Displays progress bar with an optional label.
|
|
4
|
-
|
|
5
|
-
## Props
|
|
6
|
-
|
|
7
|
-
### color
|
|
8
|
-
`string`
|
|
9
|
-
|
|
10
|
-
Sets `$color`
|
|
11
|
-
|
|
12
|
-
### label
|
|
13
|
-
`string`
|
|
14
|
-
|
|
15
|
-
The label for the bar
|
|
16
|
-
|
|
17
|
-
### max
|
|
18
|
-
`number`
|
|
19
|
-
|
|
20
|
-
Sets the max value for the progress bar. Default is 1
|
|
21
|
-
|
|
22
|
-
### outline
|
|
23
|
-
`bool`
|
|
24
|
-
|
|
25
|
-
Sets `$outline`
|
|
26
|
-
|
|
27
|
-
### row
|
|
28
|
-
`bool`
|
|
29
|
-
|
|
30
|
-
Sets `$row`
|
|
31
|
-
|
|
32
|
-
### value
|
|
33
|
-
`number`
|
|
34
|
-
|
|
35
|
-
Sets the value of the progress bar. Combined with max to determine how
|
|
36
|
-
filled the bar is.
|
|
37
|
-
|
|
38
|
-
## Example
|
|
39
|
-
```svelte
|
|
40
|
-
<script>
|
|
41
|
-
import { Progress } from "@axel669/zephyr"
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<Progress color="primary" value={0.1} />
|
|
45
|
-
<Progress color="primary" value={5} max={10} />
|
|
46
|
-
```
|
|
1
|
+
# Progress
|
|
2
|
+
|
|
3
|
+
Displays progress bar with an optional label.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### color
|
|
8
|
+
`string`
|
|
9
|
+
|
|
10
|
+
Sets `$color`
|
|
11
|
+
|
|
12
|
+
### label
|
|
13
|
+
`string`
|
|
14
|
+
|
|
15
|
+
The label for the bar
|
|
16
|
+
|
|
17
|
+
### max
|
|
18
|
+
`number`
|
|
19
|
+
|
|
20
|
+
Sets the max value for the progress bar. Default is 1
|
|
21
|
+
|
|
22
|
+
### outline
|
|
23
|
+
`bool`
|
|
24
|
+
|
|
25
|
+
Sets `$outline`
|
|
26
|
+
|
|
27
|
+
### row
|
|
28
|
+
`bool`
|
|
29
|
+
|
|
30
|
+
Sets `$row`
|
|
31
|
+
|
|
32
|
+
### value
|
|
33
|
+
`number`
|
|
34
|
+
|
|
35
|
+
Sets the value of the progress bar. Combined with max to determine how
|
|
36
|
+
filled the bar is.
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
```svelte
|
|
40
|
+
<script>
|
|
41
|
+
import { Progress } from "@axel669/zephyr"
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<Progress color="primary" value={0.1} />
|
|
45
|
+
<Progress color="primary" value={5} max={10} />
|
|
46
|
+
```
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import wsx from "../wsx.mjs"
|
|
5
|
-
|
|
6
|
-
export let value = 0
|
|
7
|
-
export let max = 1
|
|
8
|
-
export let color = "default"
|
|
9
|
-
export let outline = false
|
|
10
|
-
export let row = false
|
|
11
|
-
export let label = null
|
|
12
|
-
|
|
13
|
-
$: wind = {
|
|
14
|
-
"
|
|
15
|
-
"$outline": outline,
|
|
16
|
-
"$color": color,
|
|
17
|
-
$row: row,
|
|
18
|
-
...$$restProps,
|
|
19
|
-
}
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<label use:wsx={wind}>
|
|
23
|
-
{#if label}
|
|
24
|
-
<span ws-x="$
|
|
25
|
-
{/if}
|
|
26
|
-
<progress {value} {max} />
|
|
27
|
-
</label>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import wsx from "../wsx.mjs"
|
|
5
|
+
|
|
6
|
+
export let value = 0
|
|
7
|
+
export let max = 1
|
|
8
|
+
export let color = "default"
|
|
9
|
+
export let outline = false
|
|
10
|
+
export let row = false
|
|
11
|
+
export let label = null
|
|
12
|
+
|
|
13
|
+
$: wind = {
|
|
14
|
+
"@progress": true,
|
|
15
|
+
"$outline": outline,
|
|
16
|
+
"$color": color,
|
|
17
|
+
$row: row,
|
|
18
|
+
...$$restProps,
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<label use:wsx={wind}>
|
|
23
|
+
{#if label}
|
|
24
|
+
<span ws-x="[$progress-label] [t-ws nowrap]">{label}</span>
|
|
25
|
+
{/if}
|
|
26
|
+
<progress {value} {max} />
|
|
27
|
+
</label>
|
|
@@ -1,7 +1,59 @@
|
|
|
1
|
-
# Table
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
# Table
|
|
2
|
+
Wrapper for making tables in a way that is easy to maintain.
|
|
3
|
+
|
|
4
|
+
## Props
|
|
5
|
+
|
|
6
|
+
### color
|
|
7
|
+
`string`
|
|
8
|
+
|
|
9
|
+
Sets the $color macro.
|
|
10
|
+
|
|
11
|
+
### data
|
|
12
|
+
`Array`
|
|
13
|
+
|
|
14
|
+
The data to display in the table.
|
|
15
|
+
|
|
16
|
+
### fillHeader
|
|
17
|
+
`bool`
|
|
18
|
+
|
|
19
|
+
If true, the header row will have the background filled instead of just the
|
|
20
|
+
colored border.
|
|
21
|
+
|
|
22
|
+
## Slots
|
|
23
|
+
|
|
24
|
+
### header
|
|
25
|
+
Used to render the header for the table. Needs to include the `tr`.
|
|
26
|
+
|
|
27
|
+
### row
|
|
28
|
+
Used to render an item that is not `undefined`. Needs to include the `tr`. Uses
|
|
29
|
+
`let:row` for the row data, and `let:rowNum` for the row number (0-based).
|
|
30
|
+
|
|
31
|
+
### empty-row
|
|
32
|
+
If given, will render when the item in the array is `undefined`. Uses
|
|
33
|
+
`let:rowNum` for the row number (0-based).
|
|
34
|
+
|
|
35
|
+
## Example
|
|
36
|
+
```svelte
|
|
37
|
+
<script>
|
|
38
|
+
import { Table } from "@axel669/zephyr"
|
|
39
|
+
|
|
40
|
+
const data = Array.from(
|
|
41
|
+
{ length: 20 },
|
|
42
|
+
(_, i) => [i, i ** 2, i ** 3]
|
|
43
|
+
)
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<Table>
|
|
47
|
+
<tr slot="header">
|
|
48
|
+
<th>N</th>
|
|
49
|
+
<th>Squared</th>
|
|
50
|
+
<th>Cubed</th>
|
|
51
|
+
</tr>
|
|
52
|
+
|
|
53
|
+
<tr slot="row" let:row>
|
|
54
|
+
<td>{row[0]}</td>
|
|
55
|
+
<td>{row[1]}</td>
|
|
56
|
+
<td>{row[2]}</td>
|
|
57
|
+
</tr>
|
|
58
|
+
</Table>
|
|
59
|
+
```
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import wsx from "../wsx.mjs"
|
|
5
|
-
|
|
6
|
-
export let color = false
|
|
7
|
-
export let fillHeader = false
|
|
8
|
-
export let data = []
|
|
9
|
-
|
|
10
|
-
$: wind = {
|
|
11
|
-
"$color": color,
|
|
12
|
-
"$header-fill": fillHeader,
|
|
13
|
-
...$$restProps,
|
|
14
|
-
}
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<table use:wsx={wind}>
|
|
18
|
-
<thead>
|
|
19
|
-
<slot name="header">
|
|
20
|
-
<tr>
|
|
21
|
-
<th>No Header Template</th>
|
|
22
|
-
</tr>
|
|
23
|
-
</slot>
|
|
24
|
-
</thead>
|
|
25
|
-
<tbody>
|
|
26
|
-
{#each data as row, rowNum}
|
|
27
|
-
{#if row === undefined}
|
|
28
|
-
<slot name="empty-row" {rowNum} />
|
|
29
|
-
{:else}
|
|
30
|
-
<slot name="row" {row} {rowNum}>
|
|
31
|
-
<tr>
|
|
32
|
-
<td>No Row Template</td>
|
|
33
|
-
</tr>
|
|
34
|
-
</slot>
|
|
35
|
-
{/if}
|
|
36
|
-
{/each}
|
|
37
|
-
</tbody>
|
|
38
|
-
</table>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import wsx from "../wsx.mjs"
|
|
5
|
+
|
|
6
|
+
export let color = false
|
|
7
|
+
export let fillHeader = false
|
|
8
|
+
export let data = []
|
|
9
|
+
|
|
10
|
+
$: wind = {
|
|
11
|
+
"$color": color,
|
|
12
|
+
"$header-fill": fillHeader,
|
|
13
|
+
...$$restProps,
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<table use:wsx={wind}>
|
|
18
|
+
<thead>
|
|
19
|
+
<slot name="header">
|
|
20
|
+
<tr>
|
|
21
|
+
<th>No Header Template</th>
|
|
22
|
+
</tr>
|
|
23
|
+
</slot>
|
|
24
|
+
</thead>
|
|
25
|
+
<tbody>
|
|
26
|
+
{#each data as row, rowNum}
|
|
27
|
+
{#if row === undefined}
|
|
28
|
+
<slot name="empty-row" {rowNum} />
|
|
29
|
+
{:else}
|
|
30
|
+
<slot name="row" {row} {rowNum}>
|
|
31
|
+
<tr>
|
|
32
|
+
<td>No Row Template</td>
|
|
33
|
+
</tr>
|
|
34
|
+
</slot>
|
|
35
|
+
{/if}
|
|
36
|
+
{/each}
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# Tooltip
|
|
2
|
-
|
|
3
|
-
Displays a tooltip above (or below) some content when it's hovered.
|
|
4
|
-
|
|
5
|
-
## Props
|
|
6
|
-
|
|
7
|
-
### text
|
|
8
|
-
`string`
|
|
9
|
-
|
|
10
|
-
The text to display in the tooltip.
|
|
11
|
-
|
|
12
|
-
### bottom
|
|
13
|
-
`bool`
|
|
14
|
-
|
|
15
|
-
If true, the tooltip will be shown under the content instead of over.
|
|
16
|
-
|
|
17
|
-
## Example
|
|
18
|
-
```svelte
|
|
19
|
-
<script>
|
|
20
|
-
import { Tooltip, Button } from "@axel669/zephyr"
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Tooltip text="This is a button">
|
|
24
|
-
<Button>Do Thing</Button>
|
|
25
|
-
</Tooltip>
|
|
26
|
-
<Tooltip text="This shows under" bottom>
|
|
27
|
-
Just some text content
|
|
28
|
-
</Tooltip>
|
|
29
|
-
```
|
|
1
|
+
# Tooltip
|
|
2
|
+
|
|
3
|
+
Displays a tooltip above (or below) some content when it's hovered.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### text
|
|
8
|
+
`string`
|
|
9
|
+
|
|
10
|
+
The text to display in the tooltip.
|
|
11
|
+
|
|
12
|
+
### bottom
|
|
13
|
+
`bool`
|
|
14
|
+
|
|
15
|
+
If true, the tooltip will be shown under the content instead of over.
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
```svelte
|
|
19
|
+
<script>
|
|
20
|
+
import { Tooltip, Button } from "@axel669/zephyr"
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Tooltip text="This is a button">
|
|
24
|
+
<Button>Do Thing</Button>
|
|
25
|
+
</Tooltip>
|
|
26
|
+
<Tooltip text="This shows under" bottom>
|
|
27
|
+
Just some text content
|
|
28
|
+
</Tooltip>
|
|
29
|
+
```
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import wsx from "../wsx.mjs"
|
|
5
|
-
|
|
6
|
-
export let text = ""
|
|
7
|
-
export let bottom = false
|
|
8
|
-
|
|
9
|
-
$: wind = {
|
|
10
|
-
$bottom: bottom,
|
|
11
|
-
...$$restProps,
|
|
12
|
-
}
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<ws-tooltip ws-text={text} use:wsx={wind}>
|
|
16
|
-
<slot />
|
|
17
|
-
</ws-tooltip>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import wsx from "../wsx.mjs"
|
|
5
|
+
|
|
6
|
+
export let text = ""
|
|
7
|
+
export let bottom = false
|
|
8
|
+
|
|
9
|
+
$: wind = {
|
|
10
|
+
$bottom: bottom,
|
|
11
|
+
...$$restProps,
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<ws-tooltip ws-text={text} use:wsx={wind}>
|
|
16
|
+
<slot />
|
|
17
|
+
</ws-tooltip>
|
package/src/dialogs/alert.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
# Alert Dialog
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Alert Dialog
|
|
2
|
+
A nicer alert dialog to use with [Modal](../layout/dialog.md).
|
|
3
|
+
|
|
4
|
+
## Props
|
|
5
|
+
|
|
6
|
+
### color
|
|
7
|
+
Sets the $color macro.
|
|
8
|
+
|
|
9
|
+
### icon
|
|
10
|
+
The name of an icon to show with the title of the alert.
|
|
11
|
+
|
|
12
|
+
### message
|
|
13
|
+
The message to shwo in the alert.
|
|
14
|
+
|
|
15
|
+
### okText
|
|
16
|
+
The text for the button that closes the alert.
|
|
17
|
+
|
|
18
|
+
### title
|
|
19
|
+
The title for the alert.
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
```svelte
|
|
23
|
+
<script>
|
|
24
|
+
import { Alert, Button, EntryButton, Modal } from "@axel669/zephyr"
|
|
25
|
+
|
|
26
|
+
let alertModal = null
|
|
27
|
+
const alertProps = {
|
|
28
|
+
title: "Alert Example",
|
|
29
|
+
message: "This is an alert!"
|
|
30
|
+
}
|
|
31
|
+
const show = () => alertModal.show(alertProps)
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<Modal component={Alert} bind:this={alertModal} />
|
|
35
|
+
<Button on:click={show}>
|
|
36
|
+
Show Alert
|
|
37
|
+
</Button>
|
|
38
|
+
|
|
39
|
+
<EntryButton props={alertProps}>
|
|
40
|
+
Show Alert
|
|
41
|
+
</EntryButton>
|
|
42
|
+
```
|
package/src/dialogs/alert.svelte
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import Button from "../control/button.svelte"
|
|
5
|
-
import Dialog from "../layout/dialog.svelte"
|
|
6
|
-
import Icon from "../info/icon.svelte"
|
|
7
|
-
import Text from "../text.svelte"
|
|
8
|
-
import Titlebar from "../info/titlebar.svelte"
|
|
9
|
-
|
|
10
|
-
export let close
|
|
11
|
-
export let title = "Alert"
|
|
12
|
-
export let icon
|
|
13
|
-
export let message
|
|
14
|
-
export let okText = "OK"
|
|
15
|
-
export let color = "primary"
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<Dialog card {color}>
|
|
19
|
-
<Titlebar slot="header" {color}>
|
|
20
|
-
<Text title slot="title">
|
|
21
|
-
<Icon name={icon}>
|
|
22
|
-
{title}
|
|
23
|
-
</Icon>
|
|
24
|
-
</Text>
|
|
25
|
-
</Titlebar>
|
|
26
|
-
|
|
27
|
-
<Text>
|
|
28
|
-
{message}
|
|
29
|
-
</Text>
|
|
30
|
-
|
|
31
|
-
<Button slot="footer" on:click={close} {color}>
|
|
32
|
-
{okText}
|
|
33
|
-
</Button>
|
|
34
|
-
</Dialog>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import Button from "../control/button.svelte"
|
|
5
|
+
import Dialog from "../layout/dialog.svelte"
|
|
6
|
+
import Icon from "../info/icon.svelte"
|
|
7
|
+
import Text from "../text.svelte"
|
|
8
|
+
import Titlebar from "../info/titlebar.svelte"
|
|
9
|
+
|
|
10
|
+
export let close
|
|
11
|
+
export let title = "Alert"
|
|
12
|
+
export let icon
|
|
13
|
+
export let message
|
|
14
|
+
export let okText = "OK"
|
|
15
|
+
export let color = "@primary"
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Dialog card {color}>
|
|
19
|
+
<Titlebar slot="header" {color}>
|
|
20
|
+
<Text title slot="title">
|
|
21
|
+
<Icon name={icon}>
|
|
22
|
+
{title}
|
|
23
|
+
</Icon>
|
|
24
|
+
</Text>
|
|
25
|
+
</Titlebar>
|
|
26
|
+
|
|
27
|
+
<Text>
|
|
28
|
+
{message}
|
|
29
|
+
</Text>
|
|
30
|
+
|
|
31
|
+
<Button slot="footer" on:click={close} {color}>
|
|
32
|
+
{okText}
|
|
33
|
+
</Button>
|
|
34
|
+
</Dialog>
|
package/src/dialogs/confirm.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
-
# Confirm Dialog
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Confirm Dialog
|
|
2
|
+
A nicer confirm dialog to use with [Modal](../layout/dialog.md).
|
|
3
|
+
|
|
4
|
+
## Props
|
|
5
|
+
|
|
6
|
+
### color
|
|
7
|
+
Sets the $color macro.
|
|
8
|
+
|
|
9
|
+
### icon
|
|
10
|
+
The name of an icon to show with the title of the dialog.
|
|
11
|
+
|
|
12
|
+
### message
|
|
13
|
+
The message to shwo in the confirm.
|
|
14
|
+
|
|
15
|
+
### cancelText
|
|
16
|
+
The text for the button that cancels the dialog.
|
|
17
|
+
|
|
18
|
+
### okText
|
|
19
|
+
The text for the button that confirms the dialog.
|
|
20
|
+
|
|
21
|
+
### title
|
|
22
|
+
The title for the dialog.
|
|
23
|
+
|
|
24
|
+
## Return Values
|
|
25
|
+
The Confirm component will return `true` from the `Modal.show` function if the
|
|
26
|
+
OK button is clicked, and false if the Cancel button is clicked.
|
|
27
|
+
|
|
28
|
+
## Example
|
|
29
|
+
```svelte
|
|
30
|
+
<script>
|
|
31
|
+
import { Confirm, Button, EntryButton, Modal } from "@axel669/zephyr"
|
|
32
|
+
|
|
33
|
+
let confirmModal = null
|
|
34
|
+
const confirmProps = {
|
|
35
|
+
title: "Confirm Example",
|
|
36
|
+
message: "This is an confirm!"
|
|
37
|
+
}
|
|
38
|
+
const show = async () => {
|
|
39
|
+
const result = await confirmModal.show(confirmProps)
|
|
40
|
+
if (result === true) {
|
|
41
|
+
console.log("confirmed!")
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
console.log("cancelled :(")
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<Modal component={Confirm} bind:this={confirmModal} />
|
|
49
|
+
<Button on:click={show}>
|
|
50
|
+
Show Confirm
|
|
51
|
+
</Button>
|
|
52
|
+
|
|
53
|
+
<EntryButton props={confirmProps}>
|
|
54
|
+
Show Confirm
|
|
55
|
+
</EntryButton>
|
|
56
|
+
```
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import Button from "../control/button.svelte"
|
|
5
|
-
import Dialog from "../layout/dialog.svelte"
|
|
6
|
-
import Grid from "../layout/grid.svelte"
|
|
7
|
-
import Icon from "../info/icon.svelte"
|
|
8
|
-
import Text from "../text.svelte"
|
|
9
|
-
import Titlebar from "../info/titlebar.svelte"
|
|
10
|
-
|
|
11
|
-
import { handler$ } from "../handler$.mjs"
|
|
12
|
-
|
|
13
|
-
export let close
|
|
14
|
-
export let title = "Confirm"
|
|
15
|
-
export let icon
|
|
16
|
-
export let message
|
|
17
|
-
export let okText = "OK"
|
|
18
|
-
export let cancelText = "Cancel"
|
|
19
|
-
export let color = "primary"
|
|
20
|
-
|
|
21
|
-
const cls = handler$(close)
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<Dialog card {color}>
|
|
25
|
-
<Titlebar slot="header" {color}>
|
|
26
|
-
<Text title slot="title">
|
|
27
|
-
<Icon name={icon}>
|
|
28
|
-
{title}
|
|
29
|
-
</Icon>
|
|
30
|
-
</Text>
|
|
31
|
-
</Titlebar>
|
|
32
|
-
|
|
33
|
-
<Text>
|
|
34
|
-
{message}
|
|
35
|
-
</Text>
|
|
36
|
-
|
|
37
|
-
<Grid cols="1fr 1fr" slot="footer" pad="0px">
|
|
38
|
-
<Button on:click={cls(false)} color="danger">
|
|
39
|
-
{cancelText}
|
|
40
|
-
</Button>
|
|
41
|
-
<Button on:click={cls(true)} color="secondary">
|
|
42
|
-
{okText}
|
|
43
|
-
</Button>
|
|
44
|
-
</Grid>
|
|
45
|
-
</Dialog>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import Button from "../control/button.svelte"
|
|
5
|
+
import Dialog from "../layout/dialog.svelte"
|
|
6
|
+
import Grid from "../layout/grid.svelte"
|
|
7
|
+
import Icon from "../info/icon.svelte"
|
|
8
|
+
import Text from "../text.svelte"
|
|
9
|
+
import Titlebar from "../info/titlebar.svelte"
|
|
10
|
+
|
|
11
|
+
import { handler$ } from "../handler$.mjs"
|
|
12
|
+
|
|
13
|
+
export let close
|
|
14
|
+
export let title = "Confirm"
|
|
15
|
+
export let icon
|
|
16
|
+
export let message
|
|
17
|
+
export let okText = "OK"
|
|
18
|
+
export let cancelText = "Cancel"
|
|
19
|
+
export let color = "@primary"
|
|
20
|
+
|
|
21
|
+
const cls = handler$(close)
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<Dialog card {color}>
|
|
25
|
+
<Titlebar slot="header" {color}>
|
|
26
|
+
<Text title slot="title">
|
|
27
|
+
<Icon name={icon}>
|
|
28
|
+
{title}
|
|
29
|
+
</Icon>
|
|
30
|
+
</Text>
|
|
31
|
+
</Titlebar>
|
|
32
|
+
|
|
33
|
+
<Text>
|
|
34
|
+
{message}
|
|
35
|
+
</Text>
|
|
36
|
+
|
|
37
|
+
<Grid cols="1fr 1fr" slot="footer" pad="0px">
|
|
38
|
+
<Button on:click={cls(false)} color="danger">
|
|
39
|
+
{cancelText}
|
|
40
|
+
</Button>
|
|
41
|
+
<Button on:click={cls(true)} color="secondary">
|
|
42
|
+
{okText}
|
|
43
|
+
</Button>
|
|
44
|
+
</Grid>
|
|
45
|
+
</Dialog>
|