@invopop/popui 0.0.82 → 0.0.84

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.
@@ -19,10 +19,34 @@ export let cancelText = "Cancel";
19
19
  export let actionText = "OK";
20
20
  export let cancelActionEl = void 0;
21
21
  export let okActionEl = void 0;
22
+ let recentAction = false;
23
+ function cancel() {
24
+ recentAction = true;
25
+ dispatch("cancel");
26
+ setTimeout(() => {
27
+ recentAction = false;
28
+ }, 10);
29
+ }
30
+ function confirm() {
31
+ recentAction = true;
32
+ dispatch("confirm");
33
+ setTimeout(() => {
34
+ recentAction = false;
35
+ }, 10);
36
+ }
37
+ $:
38
+ if (!open) {
39
+ cancelByEsc();
40
+ }
41
+ function cancelByEsc() {
42
+ if (recentAction)
43
+ return;
44
+ dispatch("cancel");
45
+ }
22
46
  </script>
23
47
 
24
48
  <AlertDialog openFocus="[data-alert-dialog-action]:nth-of-type(2)" bind:open>
25
- <AlertDialogTrigger>
49
+ <AlertDialogTrigger class={$$slots.default ? '' : 'hidden'}>
26
50
  <slot />
27
51
  </AlertDialogTrigger>
28
52
  <AlertDialogContent>
@@ -36,11 +60,11 @@ export let okActionEl = void 0;
36
60
  <AlertDialogCancel
37
61
  bind:el={cancelActionEl}
38
62
  on:click={() => {
39
- dispatch('cancel')
63
+ cancel()
40
64
  }}
41
65
  on:keydown={(e) => {
42
66
  if (e.detail.originalEvent.key === 'Enter') {
43
- dispatch('cancel')
67
+ cancel()
44
68
  }
45
69
  }}>{cancelText}</AlertDialogCancel
46
70
  >
@@ -48,11 +72,11 @@ export let okActionEl = void 0;
48
72
  bind:el={okActionEl}
49
73
  {destructive}
50
74
  on:click={() => {
51
- dispatch('confirm')
75
+ confirm()
52
76
  }}
53
77
  on:keydown={(e) => {
54
78
  if (e.detail.originalEvent.key === 'Enter') {
55
- dispatch('confirm')
79
+ confirm()
56
80
  }
57
81
  }}
58
82
  >
@@ -44,7 +44,7 @@ export const toggle = () => {
44
44
  </button>
45
45
  {#if isOpen}
46
46
  <div
47
- class="max-h-40 absolute z-40"
47
+ class="max-h-40 absolute z-[1001]"
48
48
  use:portal
49
49
  use:floatingContent
50
50
  use:clickOutside
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@invopop/popui",
3
3
  "license": "MIT",
4
- "version": "0.0.82",
4
+ "version": "0.0.84",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run package",