Skip to content

Commit

Permalink
chore: convert the ReadonlyPassword example component into TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Sep 23, 2024
1 parent 1a2286c commit 0fce9a1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/routes/components/ReadonlyPassword.svelte
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
<svelte:options immutable={true} />

<script>
<script lang="ts">
import Icon from 'svelte-awesome'
import { faLock } from '@fortawesome/free-solid-svg-icons'
import { createValueSelection } from 'svelte-jsoneditor'
import { createEditValueSelection, type OnSelect } from 'svelte-jsoneditor'
import type { JSONPath } from 'immutable-json-patch'
export let value
export let path
export let readOnly
export let onSelect
export let value: string
export let path: JSONPath
export let readOnly: boolean
export let onSelect: OnSelect
$: hiddenValue = '*'.repeat(Math.max(String(value).length, 3))
function handleValueDoubleClick(event) {
function handleValueDoubleClick(event: Event) {
if (!readOnly) {
event.preventDefault()
event.stopPropagation()
// open in edit mode
onSelect(createValueSelection(path, true))
onSelect(createEditValueSelection(path))
}
}
</script>
Expand Down

0 comments on commit 0fce9a1

Please sign in to comment.