|
1 | 1 | <script lang="ts"> |
| 2 | + import { createBubbler } from 'svelte/legacy'; |
| 3 | +
|
| 4 | + const bubble = createBubbler(); |
2 | 5 | import { fade, scale } from "svelte/transition"; |
3 | 6 | import type { DataType } from "./popup"; |
4 | 7 | import { onMount } from "svelte"; |
|
8 | 11 | import IntValue from "./intValue.svelte"; |
9 | 12 | import SelectorValue from "./selectorValue.svelte"; |
10 | 13 |
|
11 | | - export let title: string; |
12 | | - export let zIndex = 50; |
13 | 14 | |
14 | | - let content: DataType<any>[] = []; |
15 | | - export let builder: () => DataType<any>[]; |
16 | | -
|
17 | | - export let action1: string | undefined = undefined; |
18 | | - export let action1Handler: ((data: DataType<any>[]) => void) | undefined = undefined; |
19 | | - export let action2: string | undefined = undefined; |
20 | | - export let action2Handler: ((data: DataType<any>[]) => void) | undefined = undefined; |
| 15 | + let content: DataType<any>[] = $state([]); |
| 16 | +
|
| 17 | +
|
| 18 | + interface Props { |
| 19 | + title: string; |
| 20 | + zIndex?: number; |
| 21 | + builder: () => DataType<any>[]; |
| 22 | + action1?: string | undefined; |
| 23 | + action1Handler?: ((data: DataType<any>[]) => void) | undefined; |
| 24 | + action2?: string | undefined; |
| 25 | + action2Handler?: ((data: DataType<any>[]) => void) | undefined; |
| 26 | + close: () => void; |
| 27 | + } |
21 | 28 |
|
22 | | - export let close: () => void; |
| 29 | + let { |
| 30 | + title, |
| 31 | + zIndex = 50, |
| 32 | + builder, |
| 33 | + action1 = undefined, |
| 34 | + action1Handler = undefined, |
| 35 | + action2 = undefined, |
| 36 | + action2Handler = undefined, |
| 37 | + close |
| 38 | + }: Props = $props(); |
23 | 39 |
|
24 | 40 | onMount(() => { |
25 | 41 | content = builder(); |
|
32 | 48 |
|
33 | 49 | <div class="header"> |
34 | 50 | <h2>{title}</h2> |
35 | | - <span on:click={close} on:keydown class="material-icons icon-medium clickable hover-primary">close</span> |
| 51 | + <span onclick={close} onkeydown={bubble('keydown')} class="material-icons icon-medium clickable hover-primary">close</span> |
36 | 52 | </div> |
37 | 53 |
|
38 | 54 | <div class="content"> |
|
60 | 76 |
|
61 | 77 | <div class="buttons default-margin"> |
62 | 78 | {#if action1 != undefined} |
63 | | - <button class="text-medium" on:click={() => (action1Handler ?? (() => {}))(content)} on:keydown>{action1}</button> |
| 79 | + <button class="text-medium" onclick={() => (action1Handler ?? (() => {}))(content)} onkeydown={bubble('keydown')}>{action1}</button> |
64 | 80 | {/if} |
65 | 81 | {#if action2 != undefined} |
66 | | - <button class="text-medium" on:click={() => (action2Handler ?? (() => {}))(content)} on:keydown>{action2}</button> |
| 82 | + <button class="text-medium" onclick={() => (action2Handler ?? (() => {}))(content)} onkeydown={bubble('keydown')}>{action2}</button> |
67 | 83 | {/if} |
68 | 84 | </div> |
69 | 85 | </div> |
|
0 commit comments