mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 09:26:00 +00:00
input styles
This commit is contained in:
34
packages/web/src/forms/FormPasswordFieldRaw.svelte
Normal file
34
packages/web/src/forms/FormPasswordFieldRaw.svelte
Normal file
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
|
||||
import InlineButton from '../widgets/InlineButton.svelte';
|
||||
|
||||
import { getFormContext } from './FormProviderCore.svelte';
|
||||
import TextField from './TextField.svelte';
|
||||
|
||||
export let name;
|
||||
export let disabled = false;
|
||||
|
||||
const { values, setFieldValue } = getFormContext();
|
||||
|
||||
let showPassword = false;
|
||||
|
||||
$: value = $values[name];
|
||||
$: isCrypted = value && value.startsWith('crypt:');
|
||||
</script>
|
||||
|
||||
<div class="flex">
|
||||
<TextField
|
||||
{...$$restProps}
|
||||
{disabled}
|
||||
value={isCrypted ? '' : value}
|
||||
on:change={e => setFieldValue(name, e.target['value'])}
|
||||
placeholder={isCrypted ? '(Password is encrypted)' : undefined}
|
||||
type={isCrypted || showPassword ? 'text' : 'password'}
|
||||
/>
|
||||
{#if !isCrypted}
|
||||
<InlineButton on:click={() => (showPassword = !showPassword)} {disabled}>
|
||||
<FontIcon icon="icon eye" />
|
||||
</InlineButton>
|
||||
{/if}
|
||||
</div>
|
||||
Reference in New Issue
Block a user