-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add field functionality, FOR REAL final final final
- Loading branch information
Showing
3 changed files
with
43 additions
and
4 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
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,17 +1,51 @@ | ||
<script> | ||
import {getContext} from "svelte" | ||
import {getContext, onDestroy} from "svelte" | ||
import FancyPassword from "./components/FancyPassword.svelte"; | ||
let secret; | ||
export let field; | ||
export let thiccness; | ||
export let greenThreshold; | ||
export let max; | ||
export let poorMessage = '💩'; | ||
export let goodMessage = '✅'; | ||
const {styleable} = getContext("sdk") | ||
const component = getContext("component") | ||
const formContext = getContext("form"); | ||
const formStepContext = getContext("form-step"); | ||
const formApi = formContext?.formApi; | ||
$: formStep = formStepContext ? $formStepContext ?? 1 : 1; | ||
$: formField = formApi?.registerField(field, "text", "", false, null, formStep); | ||
let fieldApi; | ||
let fieldState; | ||
$: unsubscribe = formField?.subscribe((value) => { | ||
fieldState = value?.fieldState; | ||
fieldApi = value?.fieldApi; | ||
}); | ||
onDestroy(() => { | ||
fieldApi?.deregister(); | ||
unsubscribe?.(); | ||
}); | ||
$: { | ||
fieldApi?.setValue(secret); | ||
} | ||
</script> | ||
<div use:styleable={$component.styles}> | ||
<FancyPassword {thiccness} {greenThreshold} {max} {poorMessage} {goodMessage} /> | ||
<FancyPassword | ||
bind:secret={secret} | ||
{thiccness} | ||
{greenThreshold} | ||
{max} | ||
{poorMessage} | ||
{goodMessage} | ||
/> | ||
</div> |
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