Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): update TypeScript definitions for Svelte 4 compatibility #25

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/Pincode.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

export type Code = string[];

export interface PincodeProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["div"]> {
type RestProps = SvelteHTMLElements["div"];

export interface PincodeProps extends RestProps {
/**
* @default []
*/
Expand All @@ -29,6 +31,8 @@ export interface PincodeProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNa
* @default false
*/
selectTextOnFocus?: boolean;

[key: `data-${string}`]: any;
}

export default class Pincode extends SvelteComponentTyped<
Expand All @@ -39,7 +43,9 @@ export default class Pincode extends SvelteComponentTyped<
},
{ default: {} }
> {
focusFirstInput?: () => void;
focusNextEmptyInput?: () => void;
focusLastInput?: () => void;
focusFirstInput: () => void;

focusNextEmptyInput: () => void;

focusLastInput: () => void;
}
16 changes: 12 additions & 4 deletions src/PincodeInput.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

export interface PincodeInputProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["input"]> {
type RestProps = SvelteHTMLElements["input"];

export interface PincodeInputProps extends RestProps {
/**
* @default ""
*/
Expand All @@ -16,10 +18,16 @@ export interface PincodeInputProps extends svelte.JSX.HTMLAttributes<HTMLElement
* @default null
*/
ref?: null | HTMLInputElement;

[key: `data-${string}`]: any;
}

export default class PincodeInput extends SvelteComponentTyped<
PincodeInputProps,
{ focus: WindowEventMap["focus"]; blur: WindowEventMap["blur"]; keydown: WindowEventMap["keydown"] },
{
focus: WindowEventMap["focus"];
blur: WindowEventMap["blur"];
keydown: WindowEventMap["keydown"];
},
{}
> {}
6 changes: 3 additions & 3 deletions test/Pincode.test.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
$: error = complete && !success;

onMount(() => {
ref.focusFirstInput?.();
ref.focusNextEmptyInput?.();
ref.focusLastInput?.();
ref.focusFirstInput();
ref.focusNextEmptyInput();
ref.focusLastInput();
});
</script>

Expand Down