phonograph/svelte/src/filter-menu.webc.svelte

54 lines
1.4 KiB
Svelte
Raw Normal View History

2025-08-24 23:24:01 -07:00
<svelte:options
customElement={{
props: {
identifier_hints: { attribute: "identifier-hints", type: "Array" },
initialValue: { attribute: "initial-value", type: "Object" },
},
shadow: "none",
tag: "filter-menu",
}}
/>
<script lang="ts">
import { type PgExpressionAny } from "./expression.svelte";
2025-12-18 12:55:01 -08:00
import BasicDropdown from "./basic-dropdown.webc.svelte";
2025-08-24 23:24:01 -07:00
import ExpressionEditor from "./expression-editor.webc.svelte";
type Props = {
identifier_hints?: string[];
initialValue?: PgExpressionAny | null;
};
let { identifier_hints = [], initialValue }: Props = $props();
let expr = $state<PgExpressionAny | undefined>(initialValue ?? undefined);
function handle_clear_button_click() {
expr = undefined;
}
</script>
2025-12-18 12:55:01 -08:00
<div class="filter-menu toolbar-item">
<BasicDropdown>
<span slot="button-contents">Filter</span>
<form action="set-filter" class="padded" method="post" slot="popover">
2025-10-25 05:32:22 +00:00
<ExpressionEditor bind:value={expr} {identifier_hints} />
2025-12-18 12:55:01 -08:00
<div class="form__buttons">
2025-10-25 05:32:22 +00:00
<input
name="filter_expression"
type="hidden"
value={JSON.stringify(expr)}
/>
<button
2025-12-18 12:55:01 -08:00
class="button button--secondary"
2025-10-25 05:32:22 +00:00
onclick={handle_clear_button_click}
type="button"
>
Clear
</button>
2025-12-18 12:55:01 -08:00
<button class="button button--primary" type="submit">Apply</button>
2025-10-25 05:32:22 +00:00
</div>
</form>
2025-12-18 12:55:01 -08:00
</BasicDropdown>
2025-08-24 23:24:01 -07:00
</div>