@pzerelles/headlessui-svelte 2.0.0-next.1 → 2.1.2-next.10

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 (284) hide show
  1. package/dist/button/Button.svelte +61 -0
  2. package/dist/button/Button.svelte.d.ts +47 -0
  3. package/dist/button/index.d.ts +1 -0
  4. package/dist/button/index.js +1 -0
  5. package/dist/checkbox/Checkbox.svelte +95 -63
  6. package/dist/checkbox/Checkbox.svelte.d.ts +43 -29
  7. package/dist/close-button/CloseButton.svelte +11 -0
  8. package/dist/close-button/CloseButton.svelte.d.ts +48 -0
  9. package/dist/close-button/index.d.ts +1 -0
  10. package/dist/close-button/index.js +1 -0
  11. package/dist/combobox/Combobox.svelte +6 -0
  12. package/dist/combobox/Combobox.svelte.d.ts +50 -0
  13. package/dist/data-interactive/DataInteractive.svelte +41 -0
  14. package/dist/data-interactive/DataInteractive.svelte.d.ts +39 -0
  15. package/dist/data-interactive/index.d.ts +1 -0
  16. package/dist/data-interactive/index.js +1 -0
  17. package/dist/description/Description.svelte +16 -41
  18. package/dist/description/Description.svelte.d.ts +15 -23
  19. package/dist/description/context.svelte.d.ts +17 -0
  20. package/dist/description/context.svelte.js +51 -0
  21. package/dist/dialog/Dialog.svelte +51 -0
  22. package/dist/dialog/Dialog.svelte.d.ts +60 -0
  23. package/dist/dialog/DialogBackdrop.svelte +39 -0
  24. package/dist/dialog/DialogBackdrop.svelte.d.ts +38 -0
  25. package/dist/dialog/DialogPanel.svelte +46 -0
  26. package/dist/dialog/DialogPanel.svelte.d.ts +40 -0
  27. package/dist/dialog/DialogTitle.svelte +29 -0
  28. package/dist/dialog/DialogTitle.svelte.d.ts +34 -0
  29. package/dist/dialog/InternalDialog.svelte +233 -0
  30. package/dist/dialog/InternalDialog.svelte.d.ts +42 -0
  31. package/dist/dialog/context.svelte.d.ts +15 -0
  32. package/dist/dialog/context.svelte.js +16 -0
  33. package/dist/dialog/index.d.ts +4 -0
  34. package/dist/dialog/index.js +4 -0
  35. package/dist/field/Field.svelte +14 -17
  36. package/dist/field/Field.svelte.d.ts +21 -17
  37. package/dist/fieldset/Fieldset.svelte +19 -17
  38. package/dist/fieldset/Fieldset.svelte.d.ts +21 -17
  39. package/dist/focus-trap/FocusTrap.svelte +325 -0
  40. package/dist/focus-trap/FocusTrap.svelte.d.ts +46 -0
  41. package/dist/focus-trap/FocusTrapFeatures.d.ts +14 -0
  42. package/dist/focus-trap/FocusTrapFeatures.js +15 -0
  43. package/dist/hooks/document-overflow/adjust-scrollbar-padding.d.ts +2 -0
  44. package/dist/hooks/document-overflow/adjust-scrollbar-padding.js +18 -0
  45. package/dist/hooks/document-overflow/handle-ios-locking.d.ts +6 -0
  46. package/dist/hooks/document-overflow/handle-ios-locking.js +134 -0
  47. package/dist/hooks/document-overflow/overflow-store.d.ts +19 -0
  48. package/dist/hooks/document-overflow/overflow-store.js +76 -0
  49. package/dist/hooks/document-overflow/prevent-scroll.d.ts +2 -0
  50. package/dist/hooks/document-overflow/prevent-scroll.js +7 -0
  51. package/dist/hooks/document-overflow/use-document-overflow.svelte.d.ts +7 -0
  52. package/dist/hooks/document-overflow/use-document-overflow.svelte.js +27 -0
  53. package/dist/hooks/use-active-press.svelte.d.ts +14 -0
  54. package/dist/{actions/activePress.svelte.js → hooks/use-active-press.svelte.js} +33 -39
  55. package/dist/hooks/use-by-comparator.d.ts +2 -0
  56. package/dist/hooks/use-by-comparator.js +15 -0
  57. package/dist/hooks/use-controllable.svelte.d.ts +6 -0
  58. package/dist/hooks/use-controllable.svelte.js +34 -0
  59. package/dist/hooks/use-did-element-move.svelte.d.ts +6 -0
  60. package/dist/hooks/use-did-element-move.svelte.js +27 -0
  61. package/dist/hooks/use-disabled.d.ts +3 -0
  62. package/dist/hooks/use-disabled.js +9 -0
  63. package/dist/hooks/use-element-size.svelte.d.ts +7 -0
  64. package/dist/hooks/use-element-size.svelte.js +36 -0
  65. package/dist/hooks/use-escape.svelte.d.ts +5 -0
  66. package/dist/hooks/use-escape.svelte.js +26 -0
  67. package/dist/hooks/use-event-listener.svelte.d.ts +6 -0
  68. package/dist/hooks/use-event-listener.svelte.js +12 -0
  69. package/dist/hooks/use-flags.svelte.d.ts +8 -0
  70. package/dist/hooks/use-flags.svelte.js +18 -0
  71. package/dist/hooks/use-focus-ring.svelte.d.ts +10 -0
  72. package/dist/hooks/use-focus-ring.svelte.js +24 -0
  73. package/dist/hooks/use-hover.svelte.d.ts +26 -0
  74. package/dist/hooks/use-hover.svelte.js +124 -0
  75. package/dist/hooks/use-id.d.ts +1 -0
  76. package/dist/hooks/use-id.js +1 -0
  77. package/dist/hooks/use-inert-others.svelte.d.ts +32 -0
  78. package/dist/hooks/use-inert-others.svelte.js +114 -0
  79. package/dist/hooks/use-is-mounted.svelte.d.ts +3 -0
  80. package/dist/hooks/use-is-mounted.svelte.js +14 -0
  81. package/dist/hooks/use-is-top-layer.svelte.d.ts +29 -0
  82. package/dist/hooks/use-is-top-layer.svelte.js +82 -0
  83. package/dist/hooks/use-is-touch-device.svelte.d.ts +3 -0
  84. package/dist/hooks/use-is-touch-device.svelte.js +20 -0
  85. package/dist/hooks/use-on-disappear.svelte.d.ts +12 -0
  86. package/dist/hooks/use-on-disappear.svelte.js +38 -0
  87. package/dist/hooks/use-outside-click.svelte.d.ts +10 -0
  88. package/dist/hooks/use-outside-click.svelte.js +150 -0
  89. package/dist/hooks/use-reducer.d.ts +4 -0
  90. package/dist/hooks/use-reducer.js +11 -0
  91. package/dist/hooks/use-resolve-button-type.svelte.d.ts +10 -0
  92. package/dist/hooks/use-resolve-button-type.svelte.js +19 -0
  93. package/dist/hooks/use-root-containers.svelte.d.ts +9 -0
  94. package/dist/hooks/use-root-containers.svelte.js +50 -0
  95. package/dist/hooks/use-scroll-lock.svelte.d.ts +5 -0
  96. package/dist/hooks/use-scroll-lock.svelte.js +24 -0
  97. package/dist/hooks/use-sync-refs.d.ts +7 -0
  98. package/dist/hooks/use-sync-refs.js +22 -0
  99. package/dist/hooks/use-tab-direction.svelte.d.ts +7 -0
  100. package/dist/hooks/use-tab-direction.svelte.js +25 -0
  101. package/dist/hooks/use-text-value.svelte.d.ts +3 -0
  102. package/dist/hooks/use-text-value.svelte.js +20 -0
  103. package/dist/hooks/use-tracked-pointer.d.ts +4 -0
  104. package/dist/hooks/use-tracked-pointer.js +26 -0
  105. package/dist/hooks/use-transition.svelte.d.ts +20 -0
  106. package/dist/hooks/use-transition.svelte.js +253 -0
  107. package/dist/hooks/use-tree-walker.svelte.d.ts +8 -0
  108. package/dist/hooks/use-tree-walker.svelte.js +19 -0
  109. package/dist/hooks/use-watch.svelte.d.ts +4 -0
  110. package/dist/hooks/use-watch.svelte.js +16 -0
  111. package/dist/hooks/use-window-event.svelte.d.ts +6 -0
  112. package/dist/hooks/use-window-event.svelte.js +12 -0
  113. package/dist/index.d.ts +14 -0
  114. package/dist/index.js +14 -0
  115. package/dist/input/Input.svelte +59 -0
  116. package/dist/input/Input.svelte.d.ts +50 -0
  117. package/dist/input/index.d.ts +1 -0
  118. package/dist/input/index.js +1 -0
  119. package/dist/internal/FocusSentinel.svelte +45 -0
  120. package/dist/internal/FocusSentinel.svelte.d.ts +20 -0
  121. package/dist/internal/ForcePortalRoot.svelte +6 -0
  122. package/dist/internal/ForcePortalRoot.svelte.d.ts +22 -0
  123. package/dist/internal/FormFields.svelte +2 -4
  124. package/dist/internal/FormFields.svelte.d.ts +9 -7
  125. package/dist/internal/FormResolver.svelte +11 -16
  126. package/dist/internal/FormResolver.svelte.d.ts +6 -4
  127. package/dist/internal/Hidden.svelte +6 -14
  128. package/dist/internal/Hidden.svelte.d.ts +36 -23
  129. package/dist/internal/HiddenFeatures.d.ts +5 -0
  130. package/dist/internal/HiddenFeatures.js +9 -0
  131. package/dist/internal/HoistFormFields.svelte.d.ts +5 -2
  132. package/dist/internal/MainTreeProvider.svelte +45 -0
  133. package/dist/internal/MainTreeProvider.svelte.d.ts +31 -0
  134. package/dist/internal/Portal.svelte.d.ts +5 -2
  135. package/dist/internal/close-provider.d.ts +7 -0
  136. package/dist/internal/close-provider.js +7 -0
  137. package/dist/internal/floating.svelte.d.ts +62 -0
  138. package/dist/internal/floating.svelte.js +488 -0
  139. package/dist/internal/frozen.svelte.d.ts +6 -0
  140. package/dist/internal/frozen.svelte.js +18 -0
  141. package/dist/internal/open-closed.d.ts +14 -0
  142. package/dist/internal/open-closed.js +17 -0
  143. package/dist/internal/portal-force-root.svelte.d.ts +6 -0
  144. package/dist/internal/portal-force-root.svelte.js +11 -0
  145. package/dist/label/Label.svelte +22 -49
  146. package/dist/label/Label.svelte.d.ts +19 -23
  147. package/dist/label/context.svelte.d.ts +17 -0
  148. package/dist/label/context.svelte.js +56 -0
  149. package/dist/legend/Legend.svelte +4 -3
  150. package/dist/legend/Legend.svelte.d.ts +33 -16
  151. package/dist/listbox/Listbox.svelte +434 -0
  152. package/dist/listbox/Listbox.svelte.d.ts +116 -0
  153. package/dist/listbox/ListboxButton.svelte +138 -0
  154. package/dist/listbox/ListboxButton.svelte.d.ts +50 -0
  155. package/dist/listbox/ListboxOption.svelte +135 -0
  156. package/dist/listbox/ListboxOption.svelte.d.ts +50 -0
  157. package/dist/listbox/ListboxOptions.svelte +268 -0
  158. package/dist/listbox/ListboxOptions.svelte.d.ts +55 -0
  159. package/dist/listbox/ListboxSelectedOption.svelte +33 -0
  160. package/dist/listbox/ListboxSelectedOption.svelte.d.ts +40 -0
  161. package/dist/listbox/ListboxStates.d.ts +12 -0
  162. package/dist/listbox/ListboxStates.js +15 -0
  163. package/dist/listbox/index.d.ts +5 -0
  164. package/dist/listbox/index.js +5 -0
  165. package/dist/menu/Menu.svelte +235 -0
  166. package/dist/menu/Menu.svelte.d.ts +42 -0
  167. package/dist/menu/MenuButton.svelte +127 -0
  168. package/dist/menu/MenuButton.svelte.d.ts +52 -0
  169. package/dist/menu/MenuHeading.svelte +19 -0
  170. package/dist/menu/MenuHeading.svelte.d.ts +39 -0
  171. package/dist/menu/MenuItem.svelte +114 -0
  172. package/dist/menu/MenuItem.svelte.d.ts +49 -0
  173. package/dist/menu/MenuItems.svelte +244 -0
  174. package/dist/menu/MenuItems.svelte.d.ts +55 -0
  175. package/dist/menu/MenuSection.svelte +14 -0
  176. package/dist/menu/MenuSection.svelte.d.ts +35 -0
  177. package/dist/menu/MenuSeparator.svelte +9 -0
  178. package/dist/menu/MenuSeparator.svelte.d.ts +35 -0
  179. package/dist/menu/context.svelte.d.ts +47 -0
  180. package/dist/menu/context.svelte.js +21 -0
  181. package/dist/menu/index.d.ts +7 -0
  182. package/dist/menu/index.js +7 -0
  183. package/dist/portal/InternalPortal.svelte +97 -0
  184. package/dist/portal/InternalPortal.svelte.d.ts +43 -0
  185. package/dist/portal/Portal.svelte +7 -0
  186. package/dist/portal/Portal.svelte.d.ts +23 -0
  187. package/dist/portal/PortalGroup.svelte +14 -0
  188. package/dist/portal/PortalGroup.svelte.d.ts +40 -0
  189. package/dist/switch/Switch.svelte +153 -0
  190. package/dist/switch/Switch.svelte.d.ts +61 -0
  191. package/dist/switch/SwitchGroup.svelte +37 -0
  192. package/dist/switch/SwitchGroup.svelte.d.ts +34 -0
  193. package/dist/switch/index.d.ts +2 -0
  194. package/dist/switch/index.js +2 -0
  195. package/dist/tabs/Tab.svelte +156 -0
  196. package/dist/tabs/Tab.svelte.d.ts +48 -0
  197. package/dist/tabs/TabGroup.svelte +241 -0
  198. package/dist/tabs/TabGroup.svelte.d.ts +67 -0
  199. package/dist/tabs/TabList.svelte +16 -0
  200. package/dist/tabs/TabList.svelte.d.ts +35 -0
  201. package/dist/tabs/TabPanel.svelte +61 -0
  202. package/dist/tabs/TabPanel.svelte.d.ts +47 -0
  203. package/dist/tabs/TabPanels.svelte +12 -0
  204. package/dist/tabs/TabPanels.svelte.d.ts +34 -0
  205. package/dist/tabs/index.d.ts +5 -0
  206. package/dist/tabs/index.js +5 -0
  207. package/dist/test-utils/accessability-assertions.d.ts +271 -0
  208. package/dist/test-utils/accessability-assertions.js +1572 -0
  209. package/dist/test-utils/fake-pointer.d.ts +24 -0
  210. package/dist/test-utils/fake-pointer.js +48 -0
  211. package/dist/test-utils/interactions.d.ts +61 -0
  212. package/dist/test-utils/interactions.js +453 -0
  213. package/dist/test-utils/suppress-console-logs.d.ts +7 -0
  214. package/dist/test-utils/suppress-console-logs.js +17 -0
  215. package/dist/textarea/Textarea.svelte +67 -0
  216. package/dist/textarea/Textarea.svelte.d.ts +50 -0
  217. package/dist/textarea/index.d.ts +1 -0
  218. package/dist/textarea/index.js +1 -0
  219. package/dist/transition/InternalTransitionChild.svelte +178 -0
  220. package/dist/transition/InternalTransitionChild.svelte.d.ts +55 -0
  221. package/dist/transition/Transition.svelte +89 -0
  222. package/dist/transition/Transition.svelte.d.ts +42 -0
  223. package/dist/transition/TransitionChild.svelte +16 -0
  224. package/dist/transition/TransitionChild.svelte.d.ts +44 -0
  225. package/dist/transition/context.svelte.d.ts +64 -0
  226. package/dist/transition/context.svelte.js +120 -0
  227. package/dist/transition/index.d.ts +2 -0
  228. package/dist/transition/index.js +2 -0
  229. package/dist/utils/ElementOrComponent.svelte +26 -0
  230. package/dist/utils/ElementOrComponent.svelte.d.ts +56 -0
  231. package/dist/utils/Generic.svelte +44 -0
  232. package/dist/utils/Generic.svelte.d.ts +35 -0
  233. package/dist/utils/StableCollection.svelte +43 -0
  234. package/dist/utils/StableCollection.svelte.d.ts +22 -0
  235. package/dist/utils/active-element-history.d.ts +1 -0
  236. package/dist/utils/active-element-history.js +35 -0
  237. package/dist/utils/alternative-types.d.ts +21 -0
  238. package/dist/utils/alternative-types.js +1 -0
  239. package/dist/utils/calculate-active-index.d.ts +25 -0
  240. package/dist/utils/calculate-active-index.js +74 -0
  241. package/dist/utils/class-names.d.ts +1 -0
  242. package/dist/utils/class-names.js +10 -0
  243. package/dist/utils/default-map.d.ts +5 -0
  244. package/dist/utils/default-map.js +15 -0
  245. package/dist/utils/disposables.d.ts +14 -12
  246. package/dist/utils/disposables.js +13 -10
  247. package/dist/utils/dom.d.ts +0 -2
  248. package/dist/utils/dom.js +2 -4
  249. package/dist/utils/env.d.ts +17 -0
  250. package/dist/utils/env.js +39 -0
  251. package/dist/utils/focus-management.d.ts +45 -0
  252. package/dist/utils/focus-management.js +242 -0
  253. package/dist/utils/focusVisible.svelte.d.ts +3 -3
  254. package/dist/utils/focusVisible.svelte.js +52 -41
  255. package/dist/utils/get-text-value.d.ts +1 -0
  256. package/dist/utils/get-text-value.js +71 -0
  257. package/dist/utils/id.d.ts +2 -2
  258. package/dist/utils/id.js +1 -1
  259. package/dist/utils/match.d.ts +1 -0
  260. package/dist/utils/match.js +13 -0
  261. package/dist/utils/on-document-ready.d.ts +1 -0
  262. package/dist/utils/on-document-ready.js +12 -0
  263. package/dist/utils/once.d.ts +1 -0
  264. package/dist/utils/once.js +9 -0
  265. package/dist/utils/owner.d.ts +1 -0
  266. package/dist/utils/owner.js +8 -0
  267. package/dist/utils/platform.d.ts +2 -0
  268. package/dist/utils/platform.js +17 -0
  269. package/dist/utils/ref.svelte.d.ts +4 -0
  270. package/dist/utils/ref.svelte.js +4 -0
  271. package/dist/utils/render.d.ts +34 -0
  272. package/dist/utils/render.js +119 -0
  273. package/dist/utils/state.d.ts +7 -1
  274. package/dist/utils/state.js +10 -6
  275. package/dist/utils/store.d.ts +11 -0
  276. package/dist/utils/store.js +20 -0
  277. package/dist/utils/types.d.ts +24 -0
  278. package/dist/utils/types.js +1 -0
  279. package/package.json +37 -29
  280. package/dist/actions/activePress.svelte.d.ts +0 -8
  281. package/dist/actions/focusRing.svelte.d.ts +0 -9
  282. package/dist/actions/focusRing.svelte.js +0 -34
  283. package/dist/utils/disabled.d.ts +0 -3
  284. package/dist/utils/disabled.js +0 -2
@@ -0,0 +1,2 @@
1
+ export { default as Transition, type TransitionRootProps } from "./Transition.svelte";
2
+ export { default as TransitionChild, type TransitionChildProps } from "./TransitionChild.svelte";
@@ -0,0 +1,2 @@
1
+ export { default as Transition } from "./Transition.svelte";
2
+ export { default as TransitionChild } from "./TransitionChild.svelte";
@@ -0,0 +1,26 @@
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
+ );
24
+ </script>
25
+
26
+ {#if render}<Generic {...rest} {...hiddenProps} {slot} tag={defaultTag} {name} bind:ref bind:value bind:checked />{/if}
@@ -0,0 +1,56 @@
1
+ import type { ElementType } from "./types.js";
2
+ import { RenderFeatures } from "./render.js";
3
+ declare class __sveltets_Render<TFeature extends RenderFeatures, TTag extends ElementType, TSlot, TValue> {
4
+ props(): {
5
+ ourProps?: Expand<{
6
+ [x: string]: any;
7
+ [x: number]: any;
8
+ } & {
9
+ children?: import("./types.js").Children<TSlot> | undefined;
10
+ ref?: HTMLElement;
11
+ } & {
12
+ class?: any;
13
+ } & Expand<((TFeature extends RenderFeatures.Static ? {
14
+ static?: boolean;
15
+ } : {}) extends infer T ? T extends (TFeature extends RenderFeatures.Static ? {
16
+ static?: boolean;
17
+ } : {}) ? T extends any ? (x: T) => any : never : never : never) | ((TFeature extends RenderFeatures.RenderStrategy ? {
18
+ unmount?: boolean;
19
+ } : {}) extends infer T_1 ? T_1 extends (TFeature extends RenderFeatures.RenderStrategy ? {
20
+ unmount?: boolean;
21
+ } : {}) ? T_1 extends any ? (x: T_1) => any : never : never : never) extends (x: infer R) => any ? R : never>> | undefined;
22
+ theirProps: {
23
+ as?: TTag | undefined;
24
+ children?: import("./types.js").Children<TSlot> | undefined;
25
+ ref?: HTMLElement | undefined;
26
+ class?: any;
27
+ };
28
+ slot?: TSlot | undefined;
29
+ slots?: TSlot | undefined;
30
+ defaultTag: ElementType;
31
+ features?: TFeature | undefined;
32
+ visible?: boolean;
33
+ name: string;
34
+ ref?: HTMLElement;
35
+ value?: TValue | undefined;
36
+ checked?: boolean;
37
+ };
38
+ events(): {} & {
39
+ [evt: string]: CustomEvent<any>;
40
+ };
41
+ slots(): {};
42
+ bindings(): "ref" | "value" | "checked";
43
+ exports(): {};
44
+ }
45
+ interface $$IsomorphicComponent {
46
+ new <TFeature extends RenderFeatures, TTag extends ElementType, TSlot, TValue>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TFeature, TTag, TSlot, TValue>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TFeature, TTag, TSlot, TValue>['props']>, ReturnType<__sveltets_Render<TFeature, TTag, TSlot, TValue>['events']>, ReturnType<__sveltets_Render<TFeature, TTag, TSlot, TValue>['slots']>> & {
47
+ $$bindings?: ReturnType<__sveltets_Render<TFeature, TTag, TSlot, TValue>['bindings']>;
48
+ } & ReturnType<__sveltets_Render<TFeature, TTag, TSlot, TValue>['exports']>;
49
+ <TFeature extends RenderFeatures, TTag extends ElementType, TSlot, TValue>(internal: unknown, props: ReturnType<__sveltets_Render<TFeature, TTag, TSlot, TValue>['props']> & {
50
+ $$events?: ReturnType<__sveltets_Render<TFeature, TTag, TSlot, TValue>['events']>;
51
+ }): ReturnType<__sveltets_Render<TFeature, TTag, TSlot, TValue>['exports']>;
52
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any, any>['bindings']>;
53
+ }
54
+ declare const ElementOrComponent: $$IsomorphicComponent;
55
+ type ElementOrComponent<TFeature extends RenderFeatures, TTag extends ElementType, TSlot, TValue> = InstanceType<typeof ElementOrComponent<TFeature, TTag, TSlot, TValue>>;
56
+ export default ElementOrComponent;
@@ -0,0 +1,44 @@
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
+ );
18
+ </script>
19
+
20
+ {#if as === "svelte:fragment"}
21
+ {#if children}{@render children(slot, {
22
+ ...props,
23
+ ...(resolvedClass ? { class: resolvedClass } : {}),
24
+ ...stateFromSlot(slot),
25
+ })}{/if}
26
+ {:else if children}
27
+ {#if as === "select"}
28
+ <select bind:this={ref} {...props} class={resolvedClass} {...stateFromSlot(slot)} bind:value>
29
+ {@render children(slot, {})}
30
+ </select>
31
+ {:else}
32
+ <svelte:element this={as} bind:this={ref} {...props} class={resolvedClass} {...stateFromSlot(slot)}>
33
+ {@render children(slot, {})}
34
+ </svelte:element>
35
+ {/if}
36
+ {:else if as === "input" && props.type === "checkbox"}
37
+ <input type="checkbox" bind:this={ref} {...props} class={resolvedClass} {...stateFromSlot(slot)} bind:checked />
38
+ {:else if as === "input"}
39
+ <input bind:this={ref} {...props} class={resolvedClass} {...stateFromSlot(slot)} bind:value />
40
+ {:else if as === "textarea"}
41
+ <textarea bind:this={ref} {...props} class={resolvedClass} {...stateFromSlot(slot)} bind:value></textarea>
42
+ {:else}
43
+ <svelte:element this={as} bind:this={ref} {...props} class={resolvedClass} {...stateFromSlot(slot)} />
44
+ {/if}
@@ -0,0 +1,35 @@
1
+ import type { ElementType, SvelteHTMLProps } from "./types.js";
2
+ declare class __sveltets_Render<TTag extends keyof SvelteHTMLProps, TSlot, TValue> {
3
+ props(): {
4
+ as?: TTag | undefined;
5
+ slot: TSlot;
6
+ tag: ElementType;
7
+ name: string;
8
+ ref?: HTMLElement;
9
+ value?: TValue | undefined;
10
+ checked?: boolean;
11
+ } & (Exclude<keyof import("./types.js").PropsOf<TTag>, "as" | "children" | "refName" | "class"> extends infer T extends keyof import("./types.js").PropsOf<TTag> ? { [P in T]: import("./types.js").PropsOf<TTag>[P]; } : never) & {
12
+ children?: import("./types.js").Children<TSlot> | undefined;
13
+ ref?: HTMLElement;
14
+ } & (true extends (import("./types.js").PropsOf<TTag> extends infer T_1 ? T_1 extends import("./types.js").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) ? {
15
+ class?: import("./types.js").PropsOf<TTag>["class"] | ((bag: TSlot) => string) | undefined;
16
+ } : {});
17
+ events(): {} & {
18
+ [evt: string]: CustomEvent<any>;
19
+ };
20
+ slots(): {};
21
+ bindings(): "ref" | "value" | "checked";
22
+ exports(): {};
23
+ }
24
+ interface $$IsomorphicComponent {
25
+ new <TTag extends keyof SvelteHTMLProps, TSlot, TValue>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TTag, TSlot, TValue>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TTag, TSlot, TValue>['props']>, ReturnType<__sveltets_Render<TTag, TSlot, TValue>['events']>, ReturnType<__sveltets_Render<TTag, TSlot, TValue>['slots']>> & {
26
+ $$bindings?: ReturnType<__sveltets_Render<TTag, TSlot, TValue>['bindings']>;
27
+ } & ReturnType<__sveltets_Render<TTag, TSlot, TValue>['exports']>;
28
+ <TTag extends keyof SvelteHTMLProps, TSlot, TValue>(internal: unknown, props: ReturnType<__sveltets_Render<TTag, TSlot, TValue>['props']> & {
29
+ $$events?: ReturnType<__sveltets_Render<TTag, TSlot, TValue>['events']>;
30
+ }): ReturnType<__sveltets_Render<TTag, TSlot, TValue>['exports']>;
31
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
32
+ }
33
+ declare const Generic: $$IsomorphicComponent;
34
+ type Generic<TTag extends keyof SvelteHTMLProps, TSlot, TValue> = InstanceType<typeof Generic<TTag, TSlot, TValue>>;
35
+ export default Generic;
@@ -0,0 +1,43 @@
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);
22
+ }
23
+ }
24
+ return [index, release];
25
+ }
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
+ }
36
+ </script>
37
+
38
+ <script lang="ts">const collection = createCollection();
39
+ setContext("StableCollection", collection);
40
+ let { children } = $props();
41
+ </script>
42
+
43
+ {#if children}{@render children()}{/if}
@@ -0,0 +1,22 @@
1
+ import { type Snippet } from "svelte";
2
+ export declare function useStableCollectionIndex(group: string): number;
3
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
4
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
5
+ $$bindings?: Bindings;
6
+ } & Exports;
7
+ (internal: unknown, props: Props & {
8
+ $$events?: Events;
9
+ $$slots?: Slots;
10
+ }): Exports & {
11
+ $set?: any;
12
+ $on?: any;
13
+ };
14
+ z_$$bindings?: Bindings;
15
+ }
16
+ declare const StableCollection: $$__sveltets_2_IsomorphicComponent<{
17
+ children: Snippet;
18
+ }, {
19
+ [evt: string]: CustomEvent<any>;
20
+ }, {}, {}, "">;
21
+ type StableCollection = InstanceType<typeof StableCollection>;
22
+ export default StableCollection;
@@ -0,0 +1 @@
1
+ export declare let history: HTMLElement[];
@@ -0,0 +1,35 @@
1
+ import { focusableSelector } from "./focus-management.js";
2
+ import { onDocumentReady } from "./on-document-ready.js";
3
+ export let history = [];
4
+ onDocumentReady(() => {
5
+ function handle(e) {
6
+ if (!(e.target instanceof HTMLElement))
7
+ return;
8
+ if (e.target === document.body)
9
+ return;
10
+ if (history[0] === e.target)
11
+ return;
12
+ let focusableElement = e.target;
13
+ // Figure out the closest focusable element, this is needed in a situation
14
+ // where you click on a non-focusable element inside a focusable element.
15
+ //
16
+ // E.g.:
17
+ //
18
+ // ```html
19
+ // <button>
20
+ // <span>Click me</span>
21
+ // </button>
22
+ // ```
23
+ focusableElement = focusableElement.closest(focusableSelector);
24
+ history.unshift(focusableElement ?? e.target);
25
+ // Filter out DOM Nodes that don't exist anymore
26
+ history = history.filter((x) => x != null && x.isConnected);
27
+ history.splice(10); // Only keep the 10 most recent items
28
+ }
29
+ window.addEventListener("click", handle, { capture: true });
30
+ window.addEventListener("mousedown", handle, { capture: true });
31
+ window.addEventListener("focus", handle, { capture: true });
32
+ document.body.addEventListener("click", handle, { capture: true });
33
+ document.body.addEventListener("mousedown", handle, { capture: true });
34
+ document.body.addEventListener("focus", handle, { capture: true });
35
+ });
@@ -0,0 +1,21 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { SvelteHTMLElements } from "svelte/elements";
3
+ export interface SvelteHTMLProps extends SvelteHTMLElements {
4
+ "svelte:fragment": {};
5
+ }
6
+ export type ElementType = keyof SvelteHTMLProps;
7
+ export type Expand<T> = T extends infer O ? {
8
+ [K in keyof O]: O[K];
9
+ } : never;
10
+ export type Children<TSlot> = Snippet | Snippet<[TSlot, Record<string, any>]>;
11
+ type OurProps<TSlot> = {
12
+ children?: Children<TSlot>;
13
+ ref?: HTMLElement;
14
+ class?: string | null | ((bag: TSlot) => string);
15
+ };
16
+ type MergeProps3<T, U, V> = {
17
+ [K in keyof T | keyof U | keyof V]?: K extends keyof V ? V[K] : K extends keyof U ? U[K] : K extends keyof T ? T[K] : never;
18
+ };
19
+ export type Props<TTag extends ElementType, TSlot = {}, TOmittableProps extends PropertyKey = never, Overrides = {}> = MergeProps3<SvelteHTMLProps[TTag], OurProps<TSlot>, Overrides>;
20
+ export type EnsureArray<T> = T extends any[] ? T : Expand<T>[];
21
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ export declare enum Focus {
2
+ /** Focus the first non-disabled item. */
3
+ First = 0,
4
+ /** Focus the previous non-disabled item. */
5
+ Previous = 1,
6
+ /** Focus the next non-disabled item. */
7
+ Next = 2,
8
+ /** Focus the last non-disabled item. */
9
+ Last = 3,
10
+ /** Focus a specific item based on the `id` of the item. */
11
+ Specific = 4,
12
+ /** Focus no items at all. */
13
+ Nothing = 5
14
+ }
15
+ export declare function calculateActiveIndex<TItem>(action: {
16
+ focus: Focus.Specific;
17
+ id: string;
18
+ } | {
19
+ focus: Exclude<Focus, Focus.Specific>;
20
+ }, resolvers: {
21
+ resolveItems(): TItem[];
22
+ resolveActiveIndex(): number | null;
23
+ resolveId(item: TItem, index: number, items: TItem[]): string;
24
+ resolveDisabled(item: TItem, index: number, items: TItem[]): boolean;
25
+ }): number | null;
@@ -0,0 +1,74 @@
1
+ function assertNever(x) {
2
+ throw new Error("Unexpected object: " + x);
3
+ }
4
+ export var Focus;
5
+ (function (Focus) {
6
+ /** Focus the first non-disabled item. */
7
+ Focus[Focus["First"] = 0] = "First";
8
+ /** Focus the previous non-disabled item. */
9
+ Focus[Focus["Previous"] = 1] = "Previous";
10
+ /** Focus the next non-disabled item. */
11
+ Focus[Focus["Next"] = 2] = "Next";
12
+ /** Focus the last non-disabled item. */
13
+ Focus[Focus["Last"] = 3] = "Last";
14
+ /** Focus a specific item based on the `id` of the item. */
15
+ Focus[Focus["Specific"] = 4] = "Specific";
16
+ /** Focus no items at all. */
17
+ Focus[Focus["Nothing"] = 5] = "Nothing";
18
+ })(Focus || (Focus = {}));
19
+ export function calculateActiveIndex(action, resolvers) {
20
+ const items = resolvers.resolveItems();
21
+ if (items.length <= 0)
22
+ return null;
23
+ const currentActiveIndex = resolvers.resolveActiveIndex();
24
+ let activeIndex = currentActiveIndex ?? -1;
25
+ switch (action.focus) {
26
+ case Focus.First: {
27
+ for (let i = 0; i < items.length; ++i) {
28
+ if (!resolvers.resolveDisabled(items[i], i, items)) {
29
+ return i;
30
+ }
31
+ }
32
+ return currentActiveIndex;
33
+ }
34
+ case Focus.Previous: {
35
+ // If nothing is active, focus the last relevant item
36
+ if (activeIndex === -1)
37
+ activeIndex = items.length;
38
+ for (let i = activeIndex - 1; i >= 0; --i) {
39
+ if (!resolvers.resolveDisabled(items[i], i, items)) {
40
+ return i;
41
+ }
42
+ }
43
+ return currentActiveIndex;
44
+ }
45
+ case Focus.Next: {
46
+ for (let i = activeIndex + 1; i < items.length; ++i) {
47
+ if (!resolvers.resolveDisabled(items[i], i, items)) {
48
+ return i;
49
+ }
50
+ }
51
+ return currentActiveIndex;
52
+ }
53
+ case Focus.Last: {
54
+ for (let i = items.length - 1; i >= 0; --i) {
55
+ if (!resolvers.resolveDisabled(items[i], i, items)) {
56
+ return i;
57
+ }
58
+ }
59
+ return currentActiveIndex;
60
+ }
61
+ case Focus.Specific: {
62
+ for (let i = 0; i < items.length; ++i) {
63
+ if (resolvers.resolveId(items[i], i, items) === action.id) {
64
+ return i;
65
+ }
66
+ }
67
+ return currentActiveIndex;
68
+ }
69
+ case Focus.Nothing:
70
+ return null;
71
+ default:
72
+ assertNever(action);
73
+ }
74
+ }
@@ -0,0 +1 @@
1
+ export declare function classNames(...classes: (false | null | undefined | string)[]): string;
@@ -0,0 +1,10 @@
1
+ export function classNames(...classes) {
2
+ return Array.from(new Set(classes.flatMap((value) => {
3
+ if (typeof value === "string") {
4
+ return value.split(" ");
5
+ }
6
+ return [];
7
+ })))
8
+ .filter(Boolean)
9
+ .join(" ");
10
+ }
@@ -0,0 +1,5 @@
1
+ export declare class DefaultMap<T = string, V = any> extends Map<T, V> {
2
+ private factory;
3
+ constructor(factory: (key: T) => V);
4
+ get(key: T): V;
5
+ }
@@ -0,0 +1,15 @@
1
+ export class DefaultMap extends Map {
2
+ factory;
3
+ constructor(factory) {
4
+ super();
5
+ this.factory = factory;
6
+ }
7
+ get(key) {
8
+ let value = super.get(key);
9
+ if (value === undefined) {
10
+ value = this.factory(key);
11
+ this.set(key, value);
12
+ }
13
+ return value;
14
+ }
15
+ }
@@ -1,4 +1,15 @@
1
- export type Disposables = ReturnType<typeof disposables>;
1
+ import { microTask } from "./microTask.js";
2
+ export type Disposables = {
3
+ addEventListener: <TEventName extends keyof WindowEventMap>(element: HTMLElement | Window | Document, name: TEventName, listener: (event: WindowEventMap[TEventName]) => any, options?: boolean | AddEventListenerOptions) => () => void;
4
+ requestAnimationFrame: (...args: Parameters<typeof requestAnimationFrame>) => () => void;
5
+ nextFrame: (...args: Parameters<typeof requestAnimationFrame>) => () => void;
6
+ setTimeout: (...args: Parameters<typeof setTimeout>) => () => void;
7
+ microTask: (...args: Parameters<typeof microTask>) => () => void;
8
+ style: (node: HTMLElement, property: string, value: string) => () => void;
9
+ group: (cb: (d: Disposables) => void) => () => void;
10
+ add: (cb: () => void) => () => void;
11
+ dispose: () => void;
12
+ };
2
13
  /**
3
14
  * Disposables are a way to manage event handlers and functions like
4
15
  * `setTimeout` and `requestAnimationFrame` that need to be cleaned up when they
@@ -11,14 +22,5 @@ export type Disposables = ReturnType<typeof disposables>;
11
22
  * `dispose` function on the collection itself that can be used to clean up all
12
23
  * pending disposables in that collection.
13
24
  */
14
- export declare function disposables(): {
15
- addEventListener<TEventName extends keyof WindowEventMap>(element: HTMLElement | Window | Document, name: TEventName, listener: (event: WindowEventMap[TEventName]) => any, options?: boolean | AddEventListenerOptions): () => void;
16
- requestAnimationFrame(callback: FrameRequestCallback): () => void;
17
- nextFrame(callback: FrameRequestCallback): () => void;
18
- setTimeout(callback: (args: void) => void, ms?: number | undefined): () => void;
19
- microTask(cb: () => void): () => void;
20
- style(node: HTMLElement, property: string, value: string): () => void;
21
- group(cb: (d: typeof this) => void): () => void;
22
- add(cb: () => void): () => void;
23
- dispose(): void;
24
- };
25
+ export declare function disposables(): Disposables;
26
+ export { disposables as useDisposables };
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import { microTask } from "./microTask.js";
2
3
  /**
3
4
  * Disposables are a way to manage event handlers and functions like
@@ -12,14 +13,15 @@ import { microTask } from "./microTask.js";
12
13
  * pending disposables in that collection.
13
14
  */
14
15
  export function disposables() {
15
- let _disposables = [];
16
- let api = {
16
+ // eslint-disable-next-line @typescript-eslint/ban-types
17
+ const _disposables = [];
18
+ const api = {
17
19
  addEventListener(element, name, listener, options) {
18
20
  element.addEventListener(name, listener, options);
19
21
  return api.add(() => element.removeEventListener(name, listener, options));
20
22
  },
21
23
  requestAnimationFrame(...args) {
22
- let raf = requestAnimationFrame(...args);
24
+ const raf = requestAnimationFrame(...args);
23
25
  return api.add(() => cancelAnimationFrame(raf));
24
26
  },
25
27
  nextFrame(...args) {
@@ -28,11 +30,11 @@ export function disposables() {
28
30
  });
29
31
  },
30
32
  setTimeout(...args) {
31
- let timer = setTimeout(...args);
33
+ const timer = setTimeout(...args);
32
34
  return api.add(() => clearTimeout(timer));
33
35
  },
34
36
  microTask(...args) {
35
- let task = { current: true };
37
+ const task = { current: true };
36
38
  microTask(() => {
37
39
  if (task.current) {
38
40
  args[0]();
@@ -43,14 +45,14 @@ export function disposables() {
43
45
  });
44
46
  },
45
47
  style(node, property, value) {
46
- let previous = node.style.getPropertyValue(property);
48
+ const previous = node.style.getPropertyValue(property);
47
49
  Object.assign(node.style, { [property]: value });
48
50
  return this.add(() => {
49
51
  Object.assign(node.style, { [property]: previous });
50
52
  });
51
53
  },
52
54
  group(cb) {
53
- let d = disposables();
55
+ const d = disposables();
54
56
  cb(d);
55
57
  return this.add(() => d.dispose());
56
58
  },
@@ -60,19 +62,20 @@ export function disposables() {
60
62
  _disposables.push(cb);
61
63
  }
62
64
  return () => {
63
- let idx = _disposables.indexOf(cb);
65
+ const idx = _disposables.indexOf(cb);
64
66
  if (idx >= 0) {
65
- for (let dispose of _disposables.splice(idx, 1)) {
67
+ for (const dispose of _disposables.splice(idx, 1)) {
66
68
  dispose();
67
69
  }
68
70
  }
69
71
  };
70
72
  },
71
73
  dispose() {
72
- for (let dispose of _disposables.splice(0)) {
74
+ for (const dispose of _disposables.splice(0)) {
73
75
  dispose();
74
76
  }
75
77
  },
76
78
  };
77
79
  return api;
78
80
  }
81
+ export { disposables as useDisposables };
@@ -1,3 +1 @@
1
- /// <reference types="node" />
2
- export declare const getOwnerDocument: (el: Element | null | undefined) => Document;
3
1
  export declare const getOwnerWindow: (el: (Window & typeof global) | Element | null | undefined) => Window & typeof global;
package/dist/utils/dom.js CHANGED
@@ -1,10 +1,8 @@
1
- export const getOwnerDocument = (el) => {
2
- return el?.ownerDocument ?? document;
3
- };
1
+ import { getOwnerDocument } from "./owner.js";
4
2
  export const getOwnerWindow = (el) => {
5
3
  if (el && "window" in el && el.window === el) {
6
4
  return el;
7
5
  }
8
6
  const doc = getOwnerDocument(el);
9
- return doc.defaultView || window;
7
+ return doc?.defaultView || window;
10
8
  };
@@ -0,0 +1,17 @@
1
+ type RenderEnv = "client" | "server";
2
+ type HandoffState = "pending" | "complete";
3
+ declare class Env {
4
+ current: RenderEnv;
5
+ handoffState: HandoffState;
6
+ currentId: number;
7
+ set(env: RenderEnv): void;
8
+ reset(): void;
9
+ nextId(): number;
10
+ get isServer(): boolean;
11
+ get isClient(): boolean;
12
+ private detect;
13
+ handoff(): void;
14
+ get isHandoffComplete(): boolean;
15
+ }
16
+ export declare let env: Env;
17
+ export {};
@@ -0,0 +1,39 @@
1
+ class Env {
2
+ current = this.detect();
3
+ handoffState = "pending";
4
+ currentId = 0;
5
+ set(env) {
6
+ if (this.current === env)
7
+ return;
8
+ this.handoffState = "pending";
9
+ this.currentId = 0;
10
+ this.current = env;
11
+ }
12
+ reset() {
13
+ this.set(this.detect());
14
+ }
15
+ nextId() {
16
+ return ++this.currentId;
17
+ }
18
+ get isServer() {
19
+ return this.current === "server";
20
+ }
21
+ get isClient() {
22
+ return this.current === "client";
23
+ }
24
+ detect() {
25
+ if (typeof window === "undefined" || typeof document === "undefined") {
26
+ return "server";
27
+ }
28
+ return "client";
29
+ }
30
+ handoff() {
31
+ if (this.handoffState === "pending") {
32
+ this.handoffState = "complete";
33
+ }
34
+ }
35
+ get isHandoffComplete() {
36
+ return this.handoffState === "complete";
37
+ }
38
+ }
39
+ export let env = new Env();