add option to hide revert buttons

This commit is contained in:
llama 2025-10-14 09:28:12 +08:00
parent c74a373cdc
commit 2860e628ee
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3
2 changed files with 8 additions and 2 deletions

View file

@ -18,6 +18,7 @@
export let choices: Choice<T>[]; export let choices: Choice<T>[];
export let disabled: boolean = false; export let disabled: boolean = false;
export let disabledChoices: T[] = []; export let disabledChoices: T[] = [];
export let hideRevert: boolean = false;
</script> </script>
<Row --cols={13}> <Row --cols={13}>
@ -27,7 +28,9 @@
<Col --col-size={6} {breakpoint}> <Col --col-size={6} {breakpoint}>
<ConfigInput> <ConfigInput>
<EnumSelector bind:value {choices} {disabled} {disabledChoices} /> <EnumSelector bind:value {choices} {disabled} {disabledChoices} />
<RevertButton slot="revert" bind:value {defaultValue} /> {#if !hideRevert}
<RevertButton slot="revert" bind:value {defaultValue} />
{/if}
</ConfigInput> </ConfigInput>
</Col> </Col>
</Row> </Row>

View file

@ -13,6 +13,7 @@
export let value: boolean; export let value: boolean;
export let defaultValue: boolean; export let defaultValue: boolean;
export let disabled: boolean = false; export let disabled: boolean = false;
export let hideRevert: boolean = false;
const id = Math.random().toString(36).substring(2); const id = Math.random().toString(36).substring(2);
</script> </script>
@ -22,7 +23,9 @@
<Col --col-justify="flex-end"> <Col --col-justify="flex-end">
<ConfigInput grow={false}> <ConfigInput grow={false}>
<Switch {id} bind:value {disabled} /> <Switch {id} bind:value {disabled} />
<RevertButton slot="revert" bind:value {defaultValue} /> {#if !hideRevert}
<RevertButton slot="revert" bind:value {defaultValue} />
{/if}
</ConfigInput> </ConfigInput>
</Col> </Col>
</Row> </Row>