Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: factored selector-input out (#4931)
- Loading branch information
Showing
4 changed files
with
52 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,19 @@ | ||
<script lang="typescript"> | ||
import { localize } from '@core/i18n' | ||
import { InputContainer, Modal, TextInput, AliasSelector } from 'shared/components' | ||
import { Modal, AliasSelector, SelectorInput } from 'shared/components' | ||
export let alias: string | ||
export let error: string = '' | ||
let inputElement: HTMLInputElement = undefined | ||
let modal: Modal = undefined | ||
let hasFocus: boolean | ||
$: hasFocus && (error = '') | ||
$: if (hasFocus) { | ||
setTimeout(() => modal?.open(), 101) | ||
} | ||
</script> | ||
|
||
<alias-input class="w-full relative"> | ||
<InputContainer bind:inputElement clearPadding isFocused={hasFocus} {error}> | ||
<TextInput | ||
bind:inputElement | ||
bind:value={alias} | ||
bind:hasFocus | ||
clearBackground | ||
clearBorder | ||
label={localize('popups.mintNativeToken.property.alias')} | ||
placeholder={localize('popups.mintNativeToken.property.alias')} | ||
fontSize="sm" | ||
{...$$restProps} | ||
/> | ||
</InputContainer> | ||
<SelectorInput | ||
labelLocale="popups.mintNativeToken.property.alias" | ||
bind:value={alias} | ||
bind:inputElement | ||
bind:modal | ||
{error} | ||
> | ||
<AliasSelector bind:modal bind:selected={alias} onClose={() => inputElement.blur()} /> | ||
</alias-input> | ||
</SelectorInput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<script lang="typescript"> | ||
import { localize } from '@core/i18n' | ||
import { InputContainer, Modal, TextInput } from 'shared/components' | ||
export let value: string | ||
export let error: string = '' | ||
export let disabled: boolean = false | ||
export let labelLocale: string = '' | ||
export let modal: Modal = undefined | ||
export let inputElement: HTMLInputElement = undefined | ||
let hasFocus: boolean | ||
$: hasFocus && (error = '') | ||
$: if (hasFocus) { | ||
setTimeout(() => modal?.open(), 100) | ||
} | ||
</script> | ||
|
||
<selector-input class="w-full relative"> | ||
<InputContainer bind:inputElement clearPadding isFocused={hasFocus} {error}> | ||
<TextInput | ||
bind:inputElement | ||
bind:value | ||
bind:hasFocus | ||
clearBackground | ||
clearBorder | ||
{disabled} | ||
label={localize(labelLocale)} | ||
placeholder={localize(labelLocale)} | ||
fontSize="sm" | ||
{...$$restProps} | ||
/> | ||
</InputContainer> | ||
<slot onClose={() => inputElement.blur()}> | ||
<!-- Contains Custom Selector --> | ||
</slot> | ||
</selector-input> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters