@invopop/popui 0.0.83 → 0.0.85

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
  >
@@ -57,7 +57,7 @@ onMount(() => {
57
57
  {:else if item.icon}
58
58
  <Icon
59
59
  src={item.icon}
60
- class="w-4 h-4 {item.destructive ? 'text-danger-500' : 'text-neutral-500'}"
60
+ class="w-4 h-4 {item.destructive ? 'text-danger-500' : item.iconClass || 'text-neutral-500'}"
61
61
  />
62
62
  {/if}
63
63
  <div class="whitespace-nowrap flex-1 text-left flex flex-col truncate" title={item.label}>
package/dist/types.d.ts CHANGED
@@ -25,6 +25,7 @@ export type DrawerOption = SelectOption & {
25
25
  color?: StatusType;
26
26
  picture?: string;
27
27
  sandbox?: boolean;
28
+ iconClass?: string;
28
29
  };
29
30
  export type Company = {
30
31
  id: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@invopop/popui",
3
3
  "license": "MIT",
4
- "version": "0.0.83",
4
+ "version": "0.0.85",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run package",