@pzerelles/headlessui-svelte 2.1.2-next.7 → 2.1.2-next.8

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.
Files changed (55) hide show
  1. package/dist/button/Button.svelte +54 -84
  2. package/dist/checkbox/Checkbox.svelte +120 -174
  3. package/dist/close-button/CloseButton.svelte +6 -12
  4. package/dist/combobox/Combobox.svelte +3 -50
  5. package/dist/data-interactive/DataInteractive.svelte +29 -57
  6. package/dist/description/Description.svelte +21 -32
  7. package/dist/dialog/Dialog.svelte +34 -69
  8. package/dist/dialog/DialogBackdrop.svelte +12 -29
  9. package/dist/dialog/DialogPanel.svelte +26 -49
  10. package/dist/dialog/DialogTitle.svelte +23 -38
  11. package/dist/dialog/InternalDialog.svelte +202 -263
  12. package/dist/field/Field.svelte +26 -49
  13. package/dist/fieldset/Fieldset.svelte +29 -50
  14. package/dist/focus-trap/FocusTrap.svelte +283 -419
  15. package/dist/input/Input.svelte +53 -84
  16. package/dist/internal/FocusSentinel.svelte +8 -16
  17. package/dist/internal/ForcePortalRoot.svelte +3 -7
  18. package/dist/internal/FormFields.svelte +20 -31
  19. package/dist/internal/FormResolver.svelte +15 -20
  20. package/dist/internal/Hidden.svelte +23 -44
  21. package/dist/internal/HoistFormFields.svelte +4 -7
  22. package/dist/internal/MainTreeProvider.svelte +36 -89
  23. package/dist/internal/Portal.svelte +14 -18
  24. package/dist/label/Label.svelte +57 -91
  25. package/dist/legend/Legend.svelte +3 -18
  26. package/dist/listbox/Listbox.svelte +396 -588
  27. package/dist/listbox/ListboxButton.svelte +127 -176
  28. package/dist/listbox/ListboxOption.svelte +125 -166
  29. package/dist/listbox/ListboxOptions.svelte +244 -340
  30. package/dist/listbox/ListboxSelectedOption.svelte +15 -38
  31. package/dist/menu/Menu.svelte +218 -307
  32. package/dist/menu/MenuButton.svelte +115 -157
  33. package/dist/menu/MenuHeading.svelte +14 -34
  34. package/dist/menu/MenuItem.svelte +107 -145
  35. package/dist/menu/MenuItems.svelte +224 -298
  36. package/dist/menu/MenuSection.svelte +9 -26
  37. package/dist/menu/MenuSeparator.svelte +4 -20
  38. package/dist/portal/InternalPortal.svelte +85 -141
  39. package/dist/portal/Portal.svelte +2 -5
  40. package/dist/portal/PortalGroup.svelte +9 -30
  41. package/dist/switch/Switch.svelte +132 -179
  42. package/dist/switch/SwitchGroup.svelte +31 -44
  43. package/dist/tabs/Tab.svelte +143 -195
  44. package/dist/tabs/TabGroup.svelte +205 -292
  45. package/dist/tabs/TabList.svelte +11 -31
  46. package/dist/tabs/TabPanel.svelte +43 -68
  47. package/dist/tabs/TabPanels.svelte +7 -18
  48. package/dist/textarea/Textarea.svelte +53 -84
  49. package/dist/transition/InternalTransitionChild.svelte +170 -259
  50. package/dist/transition/Transition.svelte +66 -96
  51. package/dist/transition/TransitionChild.svelte +11 -31
  52. package/dist/utils/ElementOrComponent.svelte +23 -44
  53. package/dist/utils/Generic.svelte +17 -29
  54. package/dist/utils/StableCollection.svelte +36 -54
  55. package/package.json +1 -1
@@ -1,36 +1,16 @@
1
- <script lang="ts" module>
2
- import type { ElementType, Props } from "../utils/types.js"
3
- import { RenderFeatures, type PropsForFeatures } from "../utils/render.js"
4
- import type { TransitionEvents, TransitionClasses } from "./context.svelte.js"
5
-
6
- type TransitionChildPropsWeControl = never
7
-
8
- export type TransitionChildProps<TTag extends ElementType> = Props<
9
- TTag,
10
- TransitionChildRenderPropArg,
11
- TransitionChildPropsWeControl,
12
- PropsForFeatures<typeof TransitionChildRenderFeatures> &
13
- TransitionClasses &
14
- TransitionEvents & { transition?: boolean; appear?: boolean }
15
- >
16
-
17
- export const DEFAULT_TRANSITION_CHILD_TAG = "svelte:fragment"
18
- export type TransitionChildRenderPropArg = HTMLElement
19
- export const TransitionChildRenderFeatures = RenderFeatures.RenderStrategy
1
+ <script lang="ts" module>import { RenderFeatures } from "../utils/render.js";
2
+ export const DEFAULT_TRANSITION_CHILD_TAG = "svelte:fragment";
3
+ export const TransitionChildRenderFeatures = RenderFeatures.RenderStrategy;
20
4
  </script>
21
5
 
22
- <script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG">
23
- import { useOpenClosed } from "../internal/open-closed.js"
24
- import { getContext } from "svelte"
25
- import InternalTransitionChild from "./InternalTransitionChild.svelte"
26
- import Transition from "./Transition.svelte"
27
-
28
- const hasTransitionContext = !!getContext("TransitionContext")
29
- const hasOpenClosedContext = useOpenClosed() !== null
30
-
31
- let { ref = $bindable(), as, ...props }: { as?: TTag } & TransitionChildProps<TTag> = $props()
32
-
33
- const TransitionRootOrChild = !hasTransitionContext && hasOpenClosedContext ? Transition : InternalTransitionChild
6
+ <script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG">import { useOpenClosed } from "../internal/open-closed.js";
7
+ import { getContext } from "svelte";
8
+ import InternalTransitionChild from "./InternalTransitionChild.svelte";
9
+ import Transition from "./Transition.svelte";
10
+ const hasTransitionContext = !!getContext("TransitionContext");
11
+ const hasOpenClosedContext = useOpenClosed() !== null;
12
+ let { ref = $bindable(), as, ...props } = $props();
13
+ const TransitionRootOrChild = !hasTransitionContext && hasOpenClosedContext ? Transition : InternalTransitionChild;
34
14
  </script>
35
15
 
36
16
  <TransitionRootOrChild bind:ref {...props} />
@@ -1,47 +1,26 @@
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
- )
1
+ <script lang="ts" generics="TFeature extends RenderFeatures, TTag extends ElementType, TSlot, TValue">import { mergePropsAdvanced, RenderFeatures, RenderStrategy } from "./render.js";
2
+ import Generic from "./Generic.svelte";
3
+ let {
4
+ ourProps,
5
+ theirProps,
6
+ slots,
7
+ slot = slots,
8
+ defaultTag,
9
+ features,
10
+ visible = true,
11
+ name,
12
+ ref = $bindable(),
13
+ value = $bindable(),
14
+ checked = $bindable()
15
+ } = $props();
16
+ const featureFlags = $derived(features ?? RenderFeatures.None);
17
+ const { static: isStatic = false, unmount = true, ...rest } = $derived(mergePropsAdvanced(theirProps, ourProps ?? {}));
18
+ const render = $derived(
19
+ visible || featureFlags & RenderFeatures.Static && isStatic || featureFlags & RenderFeatures.RenderStrategy && !unmount
20
+ );
21
+ const hiddenProps = $derived(
22
+ !visible && !(featureFlags & RenderFeatures.Static) && featureFlags & RenderFeatures.RenderStrategy && !unmount ? { hidden: true, style: "display: none;" } : {}
23
+ );
45
24
  </script>
46
25
 
47
26
  {#if render}<Generic {...rest} {...hiddenProps} {slot} tag={defaultTag} {name} bind:ref bind:value bind:checked />{/if}
@@ -1,32 +1,20 @@
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
- )
1
+ <script lang="ts" generics="TTag extends keyof SvelteHTMLProps, TSlot, TValue">import { stateFromSlot } from "./state.js";
2
+ let {
3
+ slot = {},
4
+ tag,
5
+ name,
6
+ ref = $bindable(),
7
+ value = $bindable(),
8
+ checked = $bindable(),
9
+ children,
10
+ as = tag,
11
+ unmount,
12
+ static: isStatic,
13
+ ...props
14
+ } = $props();
15
+ const resolvedClass = $derived(
16
+ typeof props.class === "function" ? props.class(slot) : props.class
17
+ );
30
18
  </script>
31
19
 
32
20
  {#if as === "svelte:fragment"}
@@ -1,61 +1,43 @@
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
- }
1
+ <script lang="ts" module>import { useId } from "../hooks/use-id.js";
2
+ import { getContext, setContext } from "svelte";
3
+ function createCollection() {
4
+ return {
5
+ /** @type {Map<string, Map<string, number>>} */
6
+ groups: /* @__PURE__ */ new Map(),
7
+ get(group, key) {
8
+ let list = this.groups.get(group);
9
+ if (!list) {
10
+ list = /* @__PURE__ */ new Map();
11
+ this.groups.set(group, list);
12
+ }
13
+ let renders = list.get(key) ?? 0;
14
+ list.set(key, renders + 1);
15
+ let index = Array.from(list.keys()).indexOf(key);
16
+ function release() {
17
+ let renders2 = list.get(key);
18
+ if (renders2 > 1) {
19
+ list.set(key, renders2 - 1);
20
+ } else {
21
+ list.delete(key);
35
22
  }
36
-
37
- return [index, release]
38
- },
23
+ }
24
+ return [index, release];
39
25
  }
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
- }
26
+ };
27
+ }
28
+ export function useStableCollectionIndex(group) {
29
+ let collection = getContext("StableCollection");
30
+ if (!collection) throw new Error("You must wrap your component in a <StableCollection>");
31
+ let key = useId();
32
+ let [idx, cleanupIdx] = collection.get(group, key);
33
+ $effect(() => cleanupIdx);
34
+ return idx;
35
+ }
52
36
  </script>
53
37
 
54
- <script lang="ts">
55
- const collection = createCollection()
56
- setContext<Collection>("StableCollection", collection)
57
-
58
- let { children }: { children: Snippet } = $props()
38
+ <script lang="ts">const collection = createCollection();
39
+ setContext("StableCollection", collection);
40
+ let { children } = $props();
59
41
  </script>
60
42
 
61
43
  {#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.7",
3
+ "version": "2.1.2-next.8",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",