@pzerelles/headlessui-svelte 2.1.2-next.3 → 2.1.2-next.5
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/button/Button.svelte +84 -54
- package/dist/checkbox/Checkbox.svelte +174 -120
- package/dist/close-button/CloseButton.svelte +12 -6
- package/dist/combobox/Combobox.svelte +50 -3
- package/dist/data-interactive/DataInteractive.svelte +57 -29
- package/dist/description/Description.svelte +32 -21
- package/dist/dialog/Dialog.svelte +69 -34
- package/dist/dialog/DialogBackdrop.svelte +29 -12
- package/dist/dialog/DialogPanel.svelte +49 -26
- package/dist/dialog/DialogTitle.svelte +38 -23
- package/dist/dialog/InternalDialog.svelte +263 -202
- package/dist/field/Field.svelte +49 -26
- package/dist/fieldset/Fieldset.svelte +50 -29
- package/dist/focus-trap/FocusTrap.svelte +419 -290
- 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/input/Input.svelte +85 -53
- package/dist/internal/FocusSentinel.svelte +16 -8
- package/dist/internal/ForcePortalRoot.svelte +7 -3
- package/dist/internal/FormFields.svelte +31 -20
- package/dist/internal/FormResolver.svelte +20 -15
- package/dist/internal/Hidden.svelte +44 -27
- package/dist/internal/Hidden.svelte.d.ts +2 -5
- package/dist/internal/HiddenFeatures.d.ts +5 -0
- package/dist/internal/HiddenFeatures.js +9 -0
- package/dist/internal/HoistFormFields.svelte +7 -4
- package/dist/internal/MainTreeProvider.svelte +89 -36
- package/dist/internal/Portal.svelte +18 -14
- package/dist/label/Label.svelte +91 -57
- package/dist/legend/Legend.svelte +18 -3
- package/dist/listbox/Listbox.svelte +588 -409
- package/dist/listbox/Listbox.svelte.d.ts +2 -12
- package/dist/listbox/ListboxButton.svelte +176 -127
- package/dist/listbox/ListboxOption.svelte +166 -125
- package/dist/listbox/ListboxOptions.svelte +340 -244
- package/dist/listbox/ListboxSelectedOption.svelte +38 -15
- package/dist/listbox/ListboxStates.d.ts +12 -0
- package/dist/listbox/ListboxStates.js +15 -0
- package/dist/menu/Menu.svelte +307 -218
- package/dist/menu/MenuButton.svelte +157 -115
- package/dist/menu/MenuHeading.svelte +34 -14
- package/dist/menu/MenuItem.svelte +145 -107
- package/dist/menu/MenuItems.svelte +298 -224
- package/dist/menu/MenuSection.svelte +26 -9
- package/dist/menu/MenuSeparator.svelte +20 -4
- package/dist/portal/InternalPortal.svelte +141 -85
- package/dist/portal/Portal.svelte +5 -2
- package/dist/portal/PortalGroup.svelte +30 -9
- package/dist/switch/Switch.svelte +179 -122
- package/dist/switch/Switch.svelte.d.ts +4 -4
- package/dist/switch/SwitchGroup.svelte +44 -31
- package/dist/tabs/Tab.svelte +195 -143
- package/dist/tabs/TabGroup.svelte +292 -205
- package/dist/tabs/TabList.svelte +31 -11
- package/dist/tabs/TabPanel.svelte +68 -43
- package/dist/tabs/TabPanels.svelte +18 -7
- package/dist/textarea/Textarea.svelte +83 -53
- package/dist/transition/InternalTransitionChild.svelte +259 -170
- package/dist/transition/Transition.svelte +96 -66
- package/dist/transition/TransitionChild.svelte +31 -11
- package/dist/utils/ElementOrComponent.svelte +44 -23
- package/dist/utils/Generic.svelte +29 -17
- package/dist/utils/StableCollection.svelte +54 -36
- package/package.json +10 -10
|
@@ -1,26 +1,47 @@
|
|
|
1
|
-
<script lang="ts" generics="TFeature extends RenderFeatures, TTag extends ElementType, TSlot, TValue">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
<script lang="ts" generics="TFeature extends RenderFeatures, TTag extends ElementType, TSlot, TValue">
|
|
2
|
+
import type { ElementType, Props } from "./types.js"
|
|
3
|
+
import { mergePropsAdvanced, RenderFeatures, RenderStrategy, type PropsForFeatures } from "./render.js"
|
|
4
|
+
import Generic from "./Generic.svelte"
|
|
5
|
+
import type { ComponentProps } from "svelte"
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ourProps,
|
|
9
|
+
theirProps,
|
|
10
|
+
slots,
|
|
11
|
+
slot = slots,
|
|
12
|
+
defaultTag,
|
|
13
|
+
features,
|
|
14
|
+
visible = true,
|
|
15
|
+
name,
|
|
16
|
+
ref = $bindable(),
|
|
17
|
+
value = $bindable(),
|
|
18
|
+
checked = $bindable(),
|
|
19
|
+
}: {
|
|
20
|
+
ourProps?: Expand<Props<any, TSlot> & PropsForFeatures<TFeature>>
|
|
21
|
+
theirProps: Expand<{ as?: TTag } & Props<any, TSlot, any>>
|
|
22
|
+
slot?: TSlot
|
|
23
|
+
slots?: TSlot
|
|
24
|
+
defaultTag: ElementType
|
|
25
|
+
features?: TFeature
|
|
26
|
+
visible?: boolean
|
|
27
|
+
name: string
|
|
28
|
+
ref?: HTMLElement
|
|
29
|
+
value?: TValue
|
|
30
|
+
checked?: boolean
|
|
31
|
+
} = $props()
|
|
32
|
+
|
|
33
|
+
const featureFlags = $derived(features ?? RenderFeatures.None)
|
|
34
|
+
const { static: isStatic = false, unmount = true, ...rest } = $derived(mergePropsAdvanced(theirProps, ourProps ?? {}))
|
|
35
|
+
const render = $derived(
|
|
36
|
+
visible ||
|
|
37
|
+
(featureFlags & RenderFeatures.Static && isStatic) ||
|
|
38
|
+
(featureFlags & RenderFeatures.RenderStrategy && !unmount)
|
|
39
|
+
)
|
|
40
|
+
const hiddenProps = $derived(
|
|
41
|
+
!visible && !(featureFlags & RenderFeatures.Static) && featureFlags & RenderFeatures.RenderStrategy && !unmount
|
|
42
|
+
? { hidden: true, style: "display: none;" }
|
|
43
|
+
: {}
|
|
44
|
+
)
|
|
24
45
|
</script>
|
|
25
46
|
|
|
26
47
|
{#if render}<Generic {...rest} {...hiddenProps} {slot} tag={defaultTag} {name} bind:ref bind:value bind:checked />{/if}
|
|
@@ -1,20 +1,32 @@
|
|
|
1
|
-
<script lang="ts" generics="TTag extends keyof SvelteHTMLProps, TSlot, TValue">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
<script lang="ts" generics="TTag extends keyof SvelteHTMLProps, TSlot, TValue">
|
|
2
|
+
import { stateFromSlot } from "./state.js"
|
|
3
|
+
import type { ElementType, Props, SvelteHTMLProps } from "./types.js"
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
slot = {} as TSlot,
|
|
7
|
+
tag,
|
|
8
|
+
name,
|
|
9
|
+
ref = $bindable(),
|
|
10
|
+
value = $bindable(),
|
|
11
|
+
checked = $bindable(),
|
|
12
|
+
children,
|
|
13
|
+
as = tag as TTag,
|
|
14
|
+
unmount,
|
|
15
|
+
static: isStatic,
|
|
16
|
+
...props
|
|
17
|
+
}: {
|
|
18
|
+
as?: TTag
|
|
19
|
+
slot: TSlot
|
|
20
|
+
tag: ElementType
|
|
21
|
+
name: string
|
|
22
|
+
ref?: HTMLElement
|
|
23
|
+
value?: TValue
|
|
24
|
+
checked?: boolean
|
|
25
|
+
} & Props<TTag, TSlot> = $props()
|
|
26
|
+
|
|
27
|
+
const resolvedClass = $derived(
|
|
28
|
+
typeof props.class === "function" ? props.class(slot) : (props.class as string | undefined)
|
|
29
|
+
)
|
|
18
30
|
</script>
|
|
19
31
|
|
|
20
32
|
{#if as === "svelte:fragment"}
|
|
@@ -1,43 +1,61 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { useId } from "../hooks/use-id.js"
|
|
3
|
+
import { getContext, setContext, type Snippet } from "svelte"
|
|
4
|
+
|
|
5
|
+
type CollectionKey = string | symbol
|
|
6
|
+
type CollectionItem = [number, () => void]
|
|
7
|
+
type Collection = ReturnType<typeof createCollection>
|
|
8
|
+
|
|
9
|
+
function createCollection() {
|
|
10
|
+
return {
|
|
11
|
+
/** @type {Map<string, Map<string, number>>} */
|
|
12
|
+
groups: new Map(),
|
|
13
|
+
|
|
14
|
+
get(group: string, key: CollectionKey): CollectionItem {
|
|
15
|
+
let list = this.groups.get(group)
|
|
16
|
+
if (!list) {
|
|
17
|
+
list = new Map()
|
|
18
|
+
this.groups.set(group, list)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let renders = list.get(key) ?? 0
|
|
22
|
+
// FIXME: This is a side-effect during render. `release` is only called in
|
|
23
|
+
// an effect cleanup so we may never release if we had to render multiple
|
|
24
|
+
// times before commit e.g. when a sibling suspends.
|
|
25
|
+
list.set(key, renders + 1)
|
|
26
|
+
|
|
27
|
+
let index = Array.from(list.keys()).indexOf(key)
|
|
28
|
+
function release() {
|
|
29
|
+
let renders = list.get(key)
|
|
30
|
+
if (renders > 1) {
|
|
31
|
+
list.set(key, renders - 1)
|
|
32
|
+
} else {
|
|
33
|
+
list.delete(key)
|
|
34
|
+
}
|
|
22
35
|
}
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
|
|
37
|
+
return [index, release]
|
|
38
|
+
},
|
|
25
39
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function useStableCollectionIndex(group) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function useStableCollectionIndex(group: string) {
|
|
43
|
+
let collection = getContext<Collection>("StableCollection")
|
|
44
|
+
if (!collection) throw new Error("You must wrap your component in a <StableCollection>")
|
|
45
|
+
|
|
46
|
+
let key = useId()
|
|
47
|
+
let [idx, cleanupIdx] = collection.get(group, key)
|
|
48
|
+
|
|
49
|
+
$effect(() => cleanupIdx)
|
|
50
|
+
return idx
|
|
51
|
+
}
|
|
36
52
|
</script>
|
|
37
53
|
|
|
38
|
-
<script lang="ts">
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
<script lang="ts">
|
|
55
|
+
const collection = createCollection()
|
|
56
|
+
setContext<Collection>("StableCollection", collection)
|
|
57
|
+
|
|
58
|
+
let { children }: { children: Snippet } = $props()
|
|
41
59
|
</script>
|
|
42
60
|
|
|
43
61
|
{#if children}{@render children()}{/if}
|
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.5",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"!dist/**/*.spec.*"
|
|
14
14
|
],
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"svelte": "^5.0.0-next.
|
|
16
|
+
"svelte": "^5.0.0-next.242"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@changesets/cli": "^2.27.7",
|
|
@@ -21,15 +21,14 @@
|
|
|
21
21
|
"@playwright/test": "^1.46.1",
|
|
22
22
|
"@pzerelles/heroicons-svelte": "^2.1.5",
|
|
23
23
|
"@sveltejs/adapter-auto": "^3.2.4",
|
|
24
|
-
"@sveltejs/kit": "^2.5.
|
|
24
|
+
"@sveltejs/kit": "^2.5.25",
|
|
25
25
|
"@sveltejs/package": "^2.3.4",
|
|
26
|
-
"@sveltejs/vite-plugin-svelte": "
|
|
26
|
+
"@sveltejs/vite-plugin-svelte": "4.0.0-next.6",
|
|
27
27
|
"@testing-library/jest-dom": "^6.5.0",
|
|
28
28
|
"@testing-library/svelte": "^5.2.1",
|
|
29
|
-
"@types/eslint": "^
|
|
29
|
+
"@types/eslint": "^9.6.1",
|
|
30
30
|
"@types/node": "^20.16.1",
|
|
31
31
|
"autoprefixer": "^10.4.20",
|
|
32
|
-
"clsx": "^2.1.1",
|
|
33
32
|
"eslint": "^9.9.1",
|
|
34
33
|
"eslint-config-prettier": "^9.1.0",
|
|
35
34
|
"eslint-plugin-svelte": "^2.43.0",
|
|
@@ -39,20 +38,21 @@
|
|
|
39
38
|
"postcss": "^8.4.41",
|
|
40
39
|
"prettier": "^3.3.3",
|
|
41
40
|
"prettier-plugin-svelte": "^3.2.6",
|
|
42
|
-
"prettier-plugin-tailwindcss": "^0.
|
|
43
|
-
"publint": "^0.
|
|
44
|
-
"svelte": "5.0.0-next.
|
|
41
|
+
"prettier-plugin-tailwindcss": "^0.6.6",
|
|
42
|
+
"publint": "^0.2.10",
|
|
43
|
+
"svelte": "^5.0.0-next.242",
|
|
45
44
|
"svelte-check": "^3.8.6",
|
|
46
45
|
"tailwindcss": "^3.4.10",
|
|
47
46
|
"tslib": "^2.7.0",
|
|
48
47
|
"typescript": "^5.5.4",
|
|
49
|
-
"typescript-eslint": "8.
|
|
48
|
+
"typescript-eslint": "^8.3.0",
|
|
50
49
|
"vite": "^5.4.2",
|
|
51
50
|
"vitest": "^2.0.5"
|
|
52
51
|
},
|
|
53
52
|
"dependencies": {
|
|
54
53
|
"@floating-ui/core": "^1.6.7",
|
|
55
54
|
"@floating-ui/dom": "^1.6.10",
|
|
55
|
+
"clsx": "^2.1.1",
|
|
56
56
|
"esm-env": "^1.0.0",
|
|
57
57
|
"nanoid": "^5.0.7"
|
|
58
58
|
},
|