y200subcontrols 0.0.30 → 0.0.31

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.
@@ -0,0 +1,105 @@
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
+ let dialog;
6
+ export async function showDialog() {
7
+ const okButton = document.getElementById("okButtonDialog");
8
+ const cancelButton = document.getElementById("cancelButtonDialog");
9
+ const p = new Promise((resolve) => {
10
+ function closeDialog(result) {
11
+ dialog.dismissDialog();
12
+ resolve(result);
13
+ }
14
+ function acceptDialog() {
15
+ closeDialog("accept");
16
+ }
17
+ function cancelDialog() {
18
+ closeDialog("cancel");
19
+ }
20
+ dialog.openDialog();
21
+ okButton?.addEventListener("click", acceptDialog);
22
+ cancelButton?.addEventListener("click", cancelDialog);
23
+ });
24
+ return p;
25
+ }
26
+ </script>
27
+
28
+ <ModalDialog bind:this={dialog} showCloseButton={false} allowSubmit={false}>
29
+ <slot slot="title">Title goes here</slot>
30
+ <div
31
+ class="flex
32
+ {style === 'warning' ? 'text-amber-500' : ''}
33
+ {style === 'info' ? 'text-blue-500' : ''}
34
+ {style === 'danger' ? 'text-red-500' : ''}
35
+ {style === 'success' ? 'text-green-500' : ''}
36
+ "
37
+ >
38
+ <div class="mx-auto">
39
+ {#if style === 'warning' || style === 'danger'}
40
+ <svg
41
+ class="w-10 h-10"
42
+ aria-hidden="true"
43
+ xmlns="http://www.w3.org/2000/svg"
44
+ width="24"
45
+ height="24"
46
+ fill="currentColor"
47
+ viewBox="0 0 24 24"
48
+ >
49
+ <path
50
+ fill-rule="evenodd"
51
+ 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"
52
+ clip-rule="evenodd"
53
+ />
54
+ </svg>
55
+ {/if}
56
+ {#if style === 'info'}
57
+ <svg
58
+ class="w-10 h-10"
59
+ aria-hidden="true"
60
+ xmlns="http://www.w3.org/2000/svg"
61
+ width="24"
62
+ height="24"
63
+ fill="currentColor"
64
+ viewBox="0 0 24 24"
65
+ >
66
+ <path
67
+ fill-rule="evenodd"
68
+ 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"
69
+ clip-rule="evenodd"
70
+ />
71
+ </svg>
72
+ {/if}
73
+ {#if style === 'success'}
74
+ <svg
75
+ class="w-10 h-10"
76
+ aria-hidden="true"
77
+ xmlns="http://www.w3.org/2000/svg"
78
+ width="24"
79
+ height="24"
80
+ fill="currentColor"
81
+ viewBox="0 0 24 24"
82
+ >
83
+ <path
84
+ fill-rule="evenodd"
85
+ 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"
86
+ clip-rule="evenodd"
87
+ />
88
+ </svg>
89
+ {/if}
90
+ </div>
91
+ </div>
92
+ <slot>
93
+ <div class="text-center">
94
+ {@html message}
95
+ </div>
96
+ </slot>
97
+ <div class="grid grid-cols-2 gap-2" slot="buttons">
98
+ <Button type="button" id="okButtonDialog">
99
+ <span>Ok</span>
100
+ </Button>
101
+ <Button type="button" buttonStyle="dark" id="cancelButtonDialog">
102
+ <span>Cancel</span>
103
+ </Button>
104
+ </div>
105
+ </ModalDialog>
@@ -0,0 +1,23 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ message?: string | undefined;
5
+ style?: "warning" | "info" | "danger" | "success";
6
+ showDialog?: () => Promise<"cancel" | "accept">;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {
12
+ default: {};
13
+ };
14
+ exports?: {} | undefined;
15
+ bindings?: string | undefined;
16
+ };
17
+ export type ConfirmModalDialogProps = typeof __propDef.props;
18
+ export type ConfirmModalDialogEvents = typeof __propDef.events;
19
+ export type ConfirmModalDialogSlots = typeof __propDef.slots;
20
+ export default class ConfirmModalDialog extends SvelteComponent<ConfirmModalDialogProps, ConfirmModalDialogEvents, ConfirmModalDialogSlots> {
21
+ get showDialog(): () => Promise<"cancel" | "accept">;
22
+ }
23
+ 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
- <div class="ml-auto my-auto">
50
- <button
51
- type="button"
52
- data-close-dialog="true"
53
- on:click={fireCancelDialog}
54
- class="text-slate-400 dark:text-slate-200
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
- <path
67
- stroke="currentColor"
68
- stroke-linecap="round"
69
- stroke-linejoin="round"
70
- stroke-width="2"
71
- d="M6 18 17.94 6M18 18 6.06 6"
72
- />
73
- </svg>
74
- </button>
75
- </div>
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</Button
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>
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  allowSubmit?: boolean;
5
5
  busy?: boolean;
6
6
  dialogSize?: "sm" | "md" | "lg";
7
+ showCloseButton?: boolean;
7
8
  openDialog?: () => void;
8
9
  dismissDialog?: () => void;
9
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "y200subcontrols",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",