y200subcontrols 0.0.333 → 0.0.334

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.
@@ -1,15 +1,20 @@
1
- <script>import Button from "./Button.svelte";
1
+ <script>import { onMount } from "svelte";
2
+ import Button from "./Button.svelte";
2
3
  import ModalDialog from "./ModalDialog.svelte";
3
4
  export let message = "Message goes here";
4
5
  export let style = "warning";
5
6
  export let okButtonContent = "<span>Ok</span>";
6
- export let cancelButtonContent = "<span>Ok</span>";
7
+ export let cancelButtonContent = "<span>Cancel</span>";
7
8
  let dialog;
9
+ let dialogId = "";
10
+ let buttonsContainer;
8
11
  export async function showDialog() {
9
- const okButton = document.getElementById("okButtonDialog");
10
- const cancelButton = document.getElementById("cancelButtonDialog");
12
+ const okButton = document.getElementById(`okButtonDialog-${dialogId}`);
13
+ const cancelButton = document.getElementById(`cancelButtonDialog-${dialogId}`);
11
14
  const p = new Promise((resolve) => {
12
15
  function closeDialog(result) {
16
+ console.log(okButton);
17
+ console.log(cancelButton);
13
18
  okButton?.removeEventListener("click", acceptDialog);
14
19
  cancelButton?.removeEventListener("click", cancelDialog);
15
20
  dialog.dismissDialog();
@@ -27,10 +32,14 @@ export async function showDialog() {
27
32
  });
28
33
  return p;
29
34
  }
35
+ onMount(() => {
36
+ let r = (Math.random() + 1).toString(36).substring(2);
37
+ dialogId = `dialog-${r}`;
38
+ });
30
39
  </script>
31
40
 
32
41
  <ModalDialog bind:this={dialog} showCloseButton={false} allowSubmit={false}>
33
- <slot slot="title" >Title goes here</slot>
42
+ <slot slot="title" name="title">Title goes here</slot>
34
43
  <div
35
44
  class="flex
36
45
  {style === 'warning' ? 'text-amber-500' : ''}
@@ -98,11 +107,11 @@ export async function showDialog() {
98
107
  {@html message}
99
108
  </div>
100
109
  </slot>
101
- <div class="grid grid-cols-2 gap-2" slot="buttons">
102
- <Button type="button" id="okButtonDialog">
110
+ <div class="grid grid-cols-2 gap-2" slot="buttons" bind:this={buttonsContainer}>
111
+ <Button type="button" id="okButtonDialog-{dialogId}">
103
112
  {@html okButtonContent}
104
113
  </Button>
105
- <Button type="button" buttonStyle="dark" id="cancelButtonDialog">
114
+ <Button type="button" buttonStyle="dark" id="cancelButtonDialog-{dialogId}">
106
115
  {@html cancelButtonContent}
107
116
  </Button>
108
117
  </div>
@@ -11,6 +11,9 @@ declare const __propDef: {
11
11
  [evt: string]: CustomEvent<any>;
12
12
  };
13
13
  slots: {
14
+ title: {
15
+ slot: string;
16
+ };
14
17
  default: {};
15
18
  };
16
19
  exports?: {} | undefined;
@@ -45,7 +45,22 @@ onMount(() => {
45
45
  class="px-3 py-1 rounded bg-emerald-500 text-emerald-50"
46
46
  on:click={openMenu}
47
47
  >
48
- <i class="bi bi-three-dots-vertical"></i>
48
+ <svg
49
+ class="w-6 h-6 text-white"
50
+ aria-hidden="true"
51
+ xmlns="http://www.w3.org/2000/svg"
52
+ width="24"
53
+ height="24"
54
+ fill="none"
55
+ viewBox="0 0 24 24"
56
+ >
57
+ <path
58
+ stroke="currentColor"
59
+ stroke-linecap="round"
60
+ stroke-width="3"
61
+ d="M12 6h.01M12 12h.01M12 18h.01"
62
+ />
63
+ </svg>
49
64
  </button>
50
65
  {#if true}
51
66
  <!-- svelte-ignore a11y-click-events-have-key-events -->
@@ -106,7 +121,11 @@ onMount(() => {
106
121
  <ConfirmModalDialog
107
122
  bind:this={deleteDialog}
108
123
  style="danger"
109
- message="Are you sure you want to delete this record"
124
+ okButtonContent="Yes, delete"
125
+ cancelButtonContent="Cancel"
110
126
  >
111
- <span> Confirm Delete </span>
127
+ <span slot="title"> Confirm Delete </span>
128
+ <div class="text-center my-2">
129
+ <span class="text-lg"> Are you sure you want to delete this record ?</span>
130
+ </div>
112
131
  </ConfirmModalDialog>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "y200subcontrols",
3
- "version": "0.0.333",
3
+ "version": "0.0.334",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",