@pzerelles/headlessui-svelte 2.1.2-next.4 → 2.1.2-next.6
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.
- package/dist/focus-trap/FocusTrap.svelte +2 -19
- package/dist/focus-trap/FocusTrap.svelte.d.ts +2 -14
- package/dist/focus-trap/FocusTrapFeatures.d.ts +14 -0
- package/dist/focus-trap/FocusTrapFeatures.js +15 -0
- package/dist/label/Label.svelte +2 -2
- package/dist/listbox/Listbox.svelte +2 -14
- package/dist/listbox/Listbox.svelte.d.ts +2 -12
- package/dist/listbox/ListboxStates.d.ts +12 -0
- package/dist/listbox/ListboxStates.js +15 -0
- package/dist/textarea/Textarea.svelte +1 -1
- package/dist/textarea/Textarea.svelte.d.ts +3 -3
- package/package.json +3 -3
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { useDisposables } from "../utils/disposables.js"
|
|
14
14
|
import Hidden, { HiddenFeatures } from "../internal/Hidden.svelte"
|
|
15
15
|
import ElementOrComponent from "../utils/ElementOrComponent.svelte"
|
|
16
|
+
import { FocusTrapFeatures } from "./FocusTrapFeatures.js"
|
|
16
17
|
|
|
17
18
|
type Containers =
|
|
18
19
|
// Lazy resolved containers
|
|
@@ -36,25 +37,7 @@
|
|
|
36
37
|
|
|
37
38
|
let DEFAULT_FOCUS_TRAP_TAG = "div" as const
|
|
38
39
|
|
|
39
|
-
export
|
|
40
|
-
/** No features enabled for the focus trap. */
|
|
41
|
-
None = 0,
|
|
42
|
-
|
|
43
|
-
/** Ensure that we move focus initially into the container. */
|
|
44
|
-
InitialFocus = 1 << 0,
|
|
45
|
-
|
|
46
|
-
/** Ensure that pressing `Tab` and `Shift+Tab` is trapped within the container. */
|
|
47
|
-
TabLock = 1 << 1,
|
|
48
|
-
|
|
49
|
-
/** Ensure that programmatically moving focus outside of the container is disallowed. */
|
|
50
|
-
FocusLock = 1 << 2,
|
|
51
|
-
|
|
52
|
-
/** Ensure that we restore the focus when unmounting the focus trap. */
|
|
53
|
-
RestoreFocus = 1 << 3,
|
|
54
|
-
|
|
55
|
-
/** Initial focus should look for the `data-autofocus` */
|
|
56
|
-
AutoFocus = 1 << 4,
|
|
57
|
-
}
|
|
40
|
+
export * from "./FocusTrapFeatures.js"
|
|
58
41
|
|
|
59
42
|
type FocusTrapRenderPropArg = {}
|
|
60
43
|
type FocusTrapPropsWeControl = never
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import type { ElementType, Props } from "../utils/types.js";
|
|
2
|
+
import { FocusTrapFeatures } from "./FocusTrapFeatures.js";
|
|
2
3
|
type Containers = (() => Iterable<HTMLElement>) | Iterable<HTMLElement>;
|
|
3
4
|
declare let DEFAULT_FOCUS_TRAP_TAG: "div";
|
|
4
|
-
export
|
|
5
|
-
/** No features enabled for the focus trap. */
|
|
6
|
-
None = 0,
|
|
7
|
-
/** Ensure that we move focus initially into the container. */
|
|
8
|
-
InitialFocus = 1,
|
|
9
|
-
/** Ensure that pressing `Tab` and `Shift+Tab` is trapped within the container. */
|
|
10
|
-
TabLock = 2,
|
|
11
|
-
/** Ensure that programmatically moving focus outside of the container is disallowed. */
|
|
12
|
-
FocusLock = 4,
|
|
13
|
-
/** Ensure that we restore the focus when unmounting the focus trap. */
|
|
14
|
-
RestoreFocus = 8,
|
|
15
|
-
/** Initial focus should look for the `data-autofocus` */
|
|
16
|
-
AutoFocus = 16
|
|
17
|
-
}
|
|
5
|
+
export * from "./FocusTrapFeatures.js";
|
|
18
6
|
type FocusTrapRenderPropArg = {};
|
|
19
7
|
type FocusTrapPropsWeControl = never;
|
|
20
8
|
export type FocusTrapProps<TTag extends ElementType = typeof DEFAULT_FOCUS_TRAP_TAG> = Props<TTag, FocusTrapRenderPropArg, FocusTrapPropsWeControl, {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum FocusTrapFeatures {
|
|
2
|
+
/** No features enabled for the focus trap. */
|
|
3
|
+
None = 0,
|
|
4
|
+
/** Ensure that we move focus initially into the container. */
|
|
5
|
+
InitialFocus = 1,
|
|
6
|
+
/** Ensure that pressing `Tab` and `Shift+Tab` is trapped within the container. */
|
|
7
|
+
TabLock = 2,
|
|
8
|
+
/** Ensure that programmatically moving focus outside of the container is disallowed. */
|
|
9
|
+
FocusLock = 4,
|
|
10
|
+
/** Ensure that we restore the focus when unmounting the focus trap. */
|
|
11
|
+
RestoreFocus = 8,
|
|
12
|
+
/** Initial focus should look for the `data-autofocus` */
|
|
13
|
+
AutoFocus = 16
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export var FocusTrapFeatures;
|
|
2
|
+
(function (FocusTrapFeatures) {
|
|
3
|
+
/** No features enabled for the focus trap. */
|
|
4
|
+
FocusTrapFeatures[FocusTrapFeatures["None"] = 0] = "None";
|
|
5
|
+
/** Ensure that we move focus initially into the container. */
|
|
6
|
+
FocusTrapFeatures[FocusTrapFeatures["InitialFocus"] = 1] = "InitialFocus";
|
|
7
|
+
/** Ensure that pressing `Tab` and `Shift+Tab` is trapped within the container. */
|
|
8
|
+
FocusTrapFeatures[FocusTrapFeatures["TabLock"] = 2] = "TabLock";
|
|
9
|
+
/** Ensure that programmatically moving focus outside of the container is disallowed. */
|
|
10
|
+
FocusTrapFeatures[FocusTrapFeatures["FocusLock"] = 4] = "FocusLock";
|
|
11
|
+
/** Ensure that we restore the focus when unmounting the focus trap. */
|
|
12
|
+
FocusTrapFeatures[FocusTrapFeatures["RestoreFocus"] = 8] = "RestoreFocus";
|
|
13
|
+
/** Initial focus should look for the `data-autofocus` */
|
|
14
|
+
FocusTrapFeatures[FocusTrapFeatures["AutoFocus"] = 16] = "AutoFocus";
|
|
15
|
+
})(FocusTrapFeatures || (FocusTrapFeatures = {}));
|
package/dist/label/Label.svelte
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
if (current instanceof HTMLLabelElement) {
|
|
48
|
-
let target = document.getElementById(current.getAttribute("
|
|
48
|
+
let target = document.getElementById(current.getAttribute("for") ?? "")
|
|
49
49
|
if (target) {
|
|
50
50
|
// Bail if the target element is disabled
|
|
51
51
|
let actuallyDisabled = target.getAttribute("disabled")
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
const slot = $derived({ disabled })
|
|
82
82
|
const ourProps = $derived({
|
|
83
83
|
id,
|
|
84
|
-
|
|
84
|
+
for: passive ? undefined : htmlFor,
|
|
85
85
|
onclick: passive ? undefined : handleClick,
|
|
86
86
|
...stateFromSlot(slot),
|
|
87
87
|
})
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { useRef, type MutableRefObject } from "../utils/ref.svelte.js"
|
|
9
9
|
import type { ElementType, EnsureArray, Props } from "../utils/types.js"
|
|
10
10
|
import { getContext, setContext, type Snippet } from "svelte"
|
|
11
|
+
import { ActivationTrigger, ListboxStates, ValueMode } from "./ListboxStates.js"
|
|
11
12
|
|
|
12
13
|
let DEFAULT_LISTBOX_TAG = "svelte:fragment"
|
|
13
14
|
type ListboxRenderPropArg<T> = {
|
|
@@ -43,20 +44,7 @@
|
|
|
43
44
|
|
|
44
45
|
export type ListboxChildren<T> = Snippet<[ListboxRenderPropArg<T>]>
|
|
45
46
|
|
|
46
|
-
export
|
|
47
|
-
Open,
|
|
48
|
-
Closed,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export enum ValueMode {
|
|
52
|
-
Single,
|
|
53
|
-
Multi,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export enum ActivationTrigger {
|
|
57
|
-
Pointer,
|
|
58
|
-
Other,
|
|
59
|
-
}
|
|
47
|
+
export * from "./ListboxStates.js"
|
|
60
48
|
|
|
61
49
|
export type ListboxOptionDataRef<T> = MutableRefObject<{
|
|
62
50
|
textValue?: string
|
|
@@ -3,6 +3,7 @@ import { Focus } from "../utils/calculate-active-index.js";
|
|
|
3
3
|
import { type MutableRefObject } from "../utils/ref.svelte.js";
|
|
4
4
|
import type { ElementType, Props } from "../utils/types.js";
|
|
5
5
|
import { type Snippet } from "svelte";
|
|
6
|
+
import { ActivationTrigger, ListboxStates, ValueMode } from "./ListboxStates.js";
|
|
6
7
|
declare let DEFAULT_LISTBOX_TAG: string;
|
|
7
8
|
type ListboxRenderPropArg<T> = {
|
|
8
9
|
open: boolean;
|
|
@@ -24,18 +25,7 @@ export type ListboxProps<TTag extends ElementType = typeof DEFAULT_LISTBOX_TAG,
|
|
|
24
25
|
__demoMode?: boolean;
|
|
25
26
|
}>;
|
|
26
27
|
export type ListboxChildren<T> = Snippet<[ListboxRenderPropArg<T>]>;
|
|
27
|
-
export
|
|
28
|
-
Open = 0,
|
|
29
|
-
Closed = 1
|
|
30
|
-
}
|
|
31
|
-
export declare enum ValueMode {
|
|
32
|
-
Single = 0,
|
|
33
|
-
Multi = 1
|
|
34
|
-
}
|
|
35
|
-
export declare enum ActivationTrigger {
|
|
36
|
-
Pointer = 0,
|
|
37
|
-
Other = 1
|
|
38
|
-
}
|
|
28
|
+
export * from "./ListboxStates.js";
|
|
39
29
|
export type ListboxOptionDataRef<T> = MutableRefObject<{
|
|
40
30
|
textValue?: string;
|
|
41
31
|
disabled: boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export var ListboxStates;
|
|
2
|
+
(function (ListboxStates) {
|
|
3
|
+
ListboxStates[ListboxStates["Open"] = 0] = "Open";
|
|
4
|
+
ListboxStates[ListboxStates["Closed"] = 1] = "Closed";
|
|
5
|
+
})(ListboxStates || (ListboxStates = {}));
|
|
6
|
+
export var ValueMode;
|
|
7
|
+
(function (ValueMode) {
|
|
8
|
+
ValueMode[ValueMode["Single"] = 0] = "Single";
|
|
9
|
+
ValueMode[ValueMode["Multi"] = 1] = "Multi";
|
|
10
|
+
})(ValueMode || (ValueMode = {}));
|
|
11
|
+
export var ActivationTrigger;
|
|
12
|
+
(function (ActivationTrigger) {
|
|
13
|
+
ActivationTrigger[ActivationTrigger["Pointer"] = 0] = "Pointer";
|
|
14
|
+
ActivationTrigger[ActivationTrigger["Other"] = 1] = "Other";
|
|
15
|
+
})(ActivationTrigger || (ActivationTrigger = {}));
|
|
@@ -11,12 +11,12 @@ type TextareaPropsWeControl = "aria-labelledby" | "aria-describedby";
|
|
|
11
11
|
export type TextareaProps<TTag extends ElementType = typeof DEFAULT_TEXTAREA_TAG> = Props<TTag, TextareaRenderPropArg, TextareaPropsWeControl, {
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
invalid?: boolean;
|
|
14
|
-
|
|
14
|
+
autofocus?: boolean;
|
|
15
15
|
}>;
|
|
16
16
|
declare class __sveltets_Render<TTag extends ElementType = typeof DEFAULT_TEXTAREA_TAG> {
|
|
17
17
|
props(): {
|
|
18
18
|
as?: TTag | undefined;
|
|
19
|
-
} & (Exclude<keyof PropsOf<TTag>, ("as" | "children" | "refName" | "class") | "invalid" | "disabled" |
|
|
19
|
+
} & (Exclude<keyof PropsOf<TTag>, ("as" | "children" | "refName" | "class") | "invalid" | "disabled" | "autofocus" | TextareaPropsWeControl> extends infer T extends keyof PropsOf<TTag> ? { [P in T]: PropsOf<TTag>[P]; } : never) & {
|
|
20
20
|
children?: import("../utils/types.js").Children<TextareaRenderPropArg> | undefined;
|
|
21
21
|
ref?: HTMLElement;
|
|
22
22
|
} & (true extends (PropsOf<TTag> extends infer T_1 ? T_1 extends PropsOf<TTag> ? T_1 extends never ? never : "class" extends infer T_2 ? T_2 extends "class" ? T_2 extends keyof T_1 ? true : never : never : never : never : never) ? {
|
|
@@ -24,7 +24,7 @@ declare class __sveltets_Render<TTag extends ElementType = typeof DEFAULT_TEXTAR
|
|
|
24
24
|
} : {}) & {
|
|
25
25
|
disabled?: boolean;
|
|
26
26
|
invalid?: boolean;
|
|
27
|
-
|
|
27
|
+
autofocus?: boolean;
|
|
28
28
|
};
|
|
29
29
|
events(): {} & {
|
|
30
30
|
[evt: string]: CustomEvent<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pzerelles/headlessui-svelte",
|
|
3
|
-
"version": "2.1.2-next.
|
|
3
|
+
"version": "2.1.2-next.6",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@testing-library/jest-dom": "^6.5.0",
|
|
28
28
|
"@testing-library/svelte": "^5.2.1",
|
|
29
29
|
"@types/eslint": "^9.6.1",
|
|
30
|
-
"@types/node": "^20.16.
|
|
30
|
+
"@types/node": "^20.16.3",
|
|
31
31
|
"autoprefixer": "^10.4.20",
|
|
32
32
|
"eslint": "^9.9.1",
|
|
33
33
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"globals": "^15.9.0",
|
|
36
36
|
"jsdom": "^24.1.3",
|
|
37
37
|
"outdent": "^0.8.0",
|
|
38
|
-
"postcss": "^8.4.
|
|
38
|
+
"postcss": "^8.4.44",
|
|
39
39
|
"prettier": "^3.3.3",
|
|
40
40
|
"prettier-plugin-svelte": "^3.2.6",
|
|
41
41
|
"prettier-plugin-tailwindcss": "^0.6.6",
|