@fuzdev/fuz_ui 0.185.1 → 0.185.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Svelte 5 attachment that focuses an element on mount.
3
+ *
4
+ * @module
5
+ */
6
+ import type { Attachment } from 'svelte/attachments';
7
+ /**
8
+ * Creates an attachment that focuses the element on mount.
9
+ * Use this instead of the HTML `autofocus` attribute for elements
10
+ * that mount dynamically from reactive conditionals like `{#if}`.
11
+ * @param options - focus options forwarded to `element.focus()`; defaults to `{focusVisible: true}` to show focus indicators on programmatic focus
12
+ */
13
+ export declare const autofocus: (options?: FocusOptions) => Attachment<HTMLElement | SVGElement>;
14
+ //# sourceMappingURL=autofocus.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autofocus.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/autofocus.svelte.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GACpB,UAAU,YAAY,KAAG,UAAU,CAAC,WAAW,GAAG,UAAU,CAI5D,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Svelte 5 attachment that focuses an element on mount.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Creates an attachment that focuses the element on mount.
8
+ * Use this instead of the HTML `autofocus` attribute for elements
9
+ * that mount dynamically from reactive conditionals like `{#if}`.
10
+ * @param options - focus options forwarded to `element.focus()`; defaults to `{focusVisible: true}` to show focus indicators on programmatic focus
11
+ */
12
+ export const autofocus = (options) => (el) => {
13
+ // focusVisible missing from TS lib.dom.d.ts as of 5.9
14
+ el.focus({ focusVisible: true, ...options });
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_ui",
3
- "version": "0.185.1",
3
+ "version": "0.185.2",
4
4
  "description": "Svelte UI library",
5
5
  "motto": "friendly user zystem",
6
6
  "glyph": "🧶",
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Svelte 5 attachment that focuses an element on mount.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import type {Attachment} from 'svelte/attachments';
8
+
9
+ /**
10
+ * Creates an attachment that focuses the element on mount.
11
+ * Use this instead of the HTML `autofocus` attribute for elements
12
+ * that mount dynamically from reactive conditionals like `{#if}`.
13
+ * @param options - focus options forwarded to `element.focus()`; defaults to `{focusVisible: true}` to show focus indicators on programmatic focus
14
+ */
15
+ export const autofocus =
16
+ (options?: FocusOptions): Attachment<HTMLElement | SVGElement> =>
17
+ (el) => {
18
+ // focusVisible missing from TS lib.dom.d.ts as of 5.9
19
+ el.focus({focusVisible: true, ...options} as FocusOptions);
20
+ };