From c01dd710239c4d81bc60b898a68b7db267342c47 Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Tue, 1 Jul 2025 14:58:05 -0700 Subject: [PATCH] add focus element utility --- package.json | 4 ++++ util.ts | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 util.ts diff --git a/package.json b/package.json index 70280a9..027e651 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,10 @@ "module": "index.ts", "main": "index.ts", "exports": { + "./util": { + "types": "./util.ts", + "svelte": "./util.ts" + }, "./complete": { "types": "./complete.ts", "svelte": "./complete.ts" diff --git a/util.ts b/util.ts new file mode 100644 index 0000000..0a40718 --- /dev/null +++ b/util.ts @@ -0,0 +1,9 @@ +import type { Action } from 'svelte/action'; + +/** + * Focuses the given HTML element. + * @param node - The HTML element to focus. + */ +export const focus: Action = (node) => { + node.focus(); +};