y200subcontrols 0.0.30 → 0.0.32
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/README.md
CHANGED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script>import Button from "./Button.svelte";
|
|
2
|
+
import ModalDialog from "./ModalDialog.svelte";
|
|
3
|
+
export let message = "Message goes here";
|
|
4
|
+
export let style = "warning";
|
|
5
|
+
export let okButtonContent = "<span>Ok</span>";
|
|
6
|
+
export let cancelButtonContent = "<span>Ok</span>";
|
|
7
|
+
let dialog;
|
|
8
|
+
export async function showDialog() {
|
|
9
|
+
const okButton = document.getElementById("okButtonDialog");
|
|
10
|
+
const cancelButton = document.getElementById("cancelButtonDialog");
|
|
11
|
+
const p = new Promise((resolve) => {
|
|
12
|
+
function closeDialog(result) {
|
|
13
|
+
dialog.dismissDialog();
|
|
14
|
+
resolve(result);
|
|
15
|
+
}
|
|
16
|
+
function acceptDialog() {
|
|
17
|
+
closeDialog("accept");
|
|
18
|
+
}
|
|
19
|
+
function cancelDialog() {
|
|
20
|
+
closeDialog("cancel");
|
|
21
|
+
}
|
|
22
|
+
dialog.openDialog();
|
|
23
|
+
okButton?.addEventListener("click", acceptDialog);
|
|
24
|
+
cancelButton?.addEventListener("click", cancelDialog);
|
|
25
|
+
});
|
|
26
|
+
return p;
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<ModalDialog bind:this={dialog} showCloseButton={false} allowSubmit={false}>
|
|
31
|
+
<slot slot="title">Title goes here</slot>
|
|
32
|
+
<div
|
|
33
|
+
class="flex
|
|
34
|
+
{style === 'warning' ? 'text-amber-500' : ''}
|
|
35
|
+
{style === 'info' ? 'text-blue-500' : ''}
|
|
36
|
+
{style === 'danger' ? 'text-red-500' : ''}
|
|
37
|
+
{style === 'success' ? 'text-green-500' : ''}
|
|
38
|
+
"
|
|
39
|
+
>
|
|
40
|
+
<div class="mx-auto">
|
|
41
|
+
{#if style === 'warning' || style === 'danger'}
|
|
42
|
+
<svg
|
|
43
|
+
class="w-10 h-10"
|
|
44
|
+
aria-hidden="true"
|
|
45
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
46
|
+
width="24"
|
|
47
|
+
height="24"
|
|
48
|
+
fill="currentColor"
|
|
49
|
+
viewBox="0 0 24 24"
|
|
50
|
+
>
|
|
51
|
+
<path
|
|
52
|
+
fill-rule="evenodd"
|
|
53
|
+
d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm11-4a1 1 0 1 0-2 0v5a1 1 0 1 0 2 0V8Zm-1 7a1 1 0 1 0 0 2h.01a1 1 0 1 0 0-2H12Z"
|
|
54
|
+
clip-rule="evenodd"
|
|
55
|
+
/>
|
|
56
|
+
</svg>
|
|
57
|
+
{/if}
|
|
58
|
+
{#if style === 'info'}
|
|
59
|
+
<svg
|
|
60
|
+
class="w-10 h-10"
|
|
61
|
+
aria-hidden="true"
|
|
62
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
+
width="24"
|
|
64
|
+
height="24"
|
|
65
|
+
fill="currentColor"
|
|
66
|
+
viewBox="0 0 24 24"
|
|
67
|
+
>
|
|
68
|
+
<path
|
|
69
|
+
fill-rule="evenodd"
|
|
70
|
+
d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm9.408-5.5a1 1 0 1 0 0 2h.01a1 1 0 1 0 0-2h-.01ZM10 10a1 1 0 1 0 0 2h1v3h-1a1 1 0 1 0 0 2h4a1 1 0 1 0 0-2h-1v-4a1 1 0 0 0-1-1h-2Z"
|
|
71
|
+
clip-rule="evenodd"
|
|
72
|
+
/>
|
|
73
|
+
</svg>
|
|
74
|
+
{/if}
|
|
75
|
+
{#if style === 'success'}
|
|
76
|
+
<svg
|
|
77
|
+
class="w-10 h-10"
|
|
78
|
+
aria-hidden="true"
|
|
79
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
80
|
+
width="24"
|
|
81
|
+
height="24"
|
|
82
|
+
fill="currentColor"
|
|
83
|
+
viewBox="0 0 24 24"
|
|
84
|
+
>
|
|
85
|
+
<path
|
|
86
|
+
fill-rule="evenodd"
|
|
87
|
+
d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm13.707-1.293a1 1 0 0 0-1.414-1.414L11 12.586l-1.793-1.793a1 1 0 0 0-1.414 1.414l2.5 2.5a1 1 0 0 0 1.414 0l4-4Z"
|
|
88
|
+
clip-rule="evenodd"
|
|
89
|
+
/>
|
|
90
|
+
</svg>
|
|
91
|
+
{/if}
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<slot>
|
|
95
|
+
<div class="text-center">
|
|
96
|
+
{@html message}
|
|
97
|
+
</div>
|
|
98
|
+
</slot>
|
|
99
|
+
<div class="grid grid-cols-2 gap-2" slot="buttons">
|
|
100
|
+
<Button type="button" id="okButtonDialog">
|
|
101
|
+
{@html okButtonContent}
|
|
102
|
+
</Button>
|
|
103
|
+
<Button type="button" buttonStyle="dark" id="cancelButtonDialog">
|
|
104
|
+
{@html cancelButtonContent}
|
|
105
|
+
</Button>
|
|
106
|
+
</div>
|
|
107
|
+
</ModalDialog>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
message?: string | undefined;
|
|
5
|
+
style?: "warning" | "info" | "danger" | "success";
|
|
6
|
+
okButtonContent?: string;
|
|
7
|
+
cancelButtonContent?: string;
|
|
8
|
+
showDialog?: () => Promise<"cancel" | "accept">;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
default: {};
|
|
15
|
+
};
|
|
16
|
+
exports?: {} | undefined;
|
|
17
|
+
bindings?: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
export type ConfirmModalDialogProps = typeof __propDef.props;
|
|
20
|
+
export type ConfirmModalDialogEvents = typeof __propDef.events;
|
|
21
|
+
export type ConfirmModalDialogSlots = typeof __propDef.slots;
|
|
22
|
+
export default class ConfirmModalDialog extends SvelteComponent<ConfirmModalDialogProps, ConfirmModalDialogEvents, ConfirmModalDialogSlots> {
|
|
23
|
+
get showDialog(): () => Promise<"cancel" | "accept">;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -5,6 +5,7 @@ const dispatch = createEventDispatcher();
|
|
|
5
5
|
export let allowSubmit = true;
|
|
6
6
|
export let busy = false;
|
|
7
7
|
export let dialogSize = "md";
|
|
8
|
+
export let showCloseButton = true;
|
|
8
9
|
let dialog;
|
|
9
10
|
export function openDialog() {
|
|
10
11
|
setTimeout(() => {
|
|
@@ -46,46 +47,48 @@ function dialogClicked(event) {
|
|
|
46
47
|
<Form on:submit isCard={true} {allowSubmit}>
|
|
47
48
|
<div class="flex" slot="title">
|
|
48
49
|
<slot name="title">Title goes here</slot>
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
{#if showCloseButton}
|
|
51
|
+
<div class="ml-auto my-auto">
|
|
52
|
+
<button
|
|
53
|
+
type="button"
|
|
54
|
+
data-close-dialog="true"
|
|
55
|
+
on:click={fireCancelDialog}
|
|
56
|
+
class="text-slate-400 dark:text-slate-200
|
|
55
57
|
hover:text-red-500 px-2 inset-y-0 transition-colors ease-in-out"
|
|
56
|
-
>
|
|
57
|
-
<svg
|
|
58
|
-
class="w-5 h-5"
|
|
59
|
-
aria-hidden="true"
|
|
60
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
61
|
-
width="24"
|
|
62
|
-
height="24"
|
|
63
|
-
fill="none"
|
|
64
|
-
viewBox="0 0 24 24"
|
|
65
58
|
>
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
<svg
|
|
60
|
+
class="w-5 h-5"
|
|
61
|
+
aria-hidden="true"
|
|
62
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
+
width="24"
|
|
64
|
+
height="24"
|
|
65
|
+
fill="none"
|
|
66
|
+
viewBox="0 0 24 24"
|
|
67
|
+
>
|
|
68
|
+
<path
|
|
69
|
+
stroke="currentColor"
|
|
70
|
+
stroke-linecap="round"
|
|
71
|
+
stroke-linejoin="round"
|
|
72
|
+
stroke-width="2"
|
|
73
|
+
d="M6 18 17.94 6M18 18 6.06 6"
|
|
74
|
+
/>
|
|
75
|
+
</svg>
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
{/if}
|
|
76
79
|
</div>
|
|
77
80
|
<slot />
|
|
78
81
|
|
|
79
|
-
<div slot="buttons" class="grid {allowSubmit ? 'grid-cols-2' : 'grid-cols-1'} gap-2 my-2">
|
|
80
|
-
<slot name="buttons">
|
|
82
|
+
<div slot="buttons" class="grid {allowSubmit ? 'grid-cols-2' : 'grid-cols-1'} gap-2 my-2" >
|
|
83
|
+
<slot name="buttons" >
|
|
81
84
|
{#if allowSubmit}
|
|
82
85
|
<Button type="submit" isLoading={busy}>
|
|
83
86
|
<span>Ok</span>
|
|
84
87
|
</Button>
|
|
85
88
|
{/if}
|
|
86
|
-
<Button type="button" buttonStyle="dark" disabled={busy} on:click={fireCancelDialog}
|
|
87
|
-
>Cancel</
|
|
88
|
-
>
|
|
89
|
+
<Button type="button" buttonStyle="dark" disabled={busy} on:click={fireCancelDialog}>
|
|
90
|
+
<span>Cancel</span>
|
|
91
|
+
</Button>
|
|
89
92
|
</slot>
|
|
90
93
|
</div>
|
|
91
94
|
</Form>
|