@pzerelles/headlessui-svelte 2.1.2-next.39 → 2.1.2-next.40

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 (69) hide show
  1. package/dist/button/Button.svelte.d.ts +1 -0
  2. package/dist/close-button/CloseButton.svelte.d.ts +1 -0
  3. package/dist/data-interactive/DataInteractive.svelte.d.ts +1 -0
  4. package/dist/description/Description.svelte.d.ts +1 -0
  5. package/dist/dialog/Dialog.svelte.d.ts +1 -0
  6. package/dist/dialog/DialogBackdrop.svelte.d.ts +1 -0
  7. package/dist/dialog/DialogPanel.svelte.d.ts +1 -0
  8. package/dist/dialog/DialogTitle.svelte.d.ts +1 -0
  9. package/dist/field/Field.svelte.d.ts +1 -0
  10. package/dist/fieldset/Fieldset.svelte.d.ts +1 -0
  11. package/dist/focus-trap/FocusTrap.svelte.d.ts +1 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +1 -0
  14. package/dist/internal/FloatingProvider.svelte.d.ts +4 -2
  15. package/dist/internal/FocusSentinel.svelte.d.ts +4 -2
  16. package/dist/internal/ForcePortalRoot.svelte.d.ts +4 -2
  17. package/dist/internal/FormFields.svelte.d.ts +4 -2
  18. package/dist/internal/FormFieldsProvider.svelte.d.ts +4 -2
  19. package/dist/internal/FormResolver.svelte.d.ts +4 -2
  20. package/dist/internal/Hidden.svelte.d.ts +1 -0
  21. package/dist/internal/MainTreeProvider.svelte.d.ts +4 -2
  22. package/dist/internal/Portal.svelte.d.ts +4 -2
  23. package/dist/label/Label.svelte +0 -2
  24. package/dist/label/Label.svelte.d.ts +1 -0
  25. package/dist/legend/Legend.svelte.d.ts +1 -0
  26. package/dist/listbox/ListboxButton.svelte.d.ts +1 -0
  27. package/dist/listbox/ListboxOptions.svelte.d.ts +1 -0
  28. package/dist/listbox/ListboxSelectedOption.svelte.d.ts +1 -0
  29. package/dist/menu/Menu.svelte.d.ts +1 -0
  30. package/dist/menu/MenuButton.svelte.d.ts +1 -0
  31. package/dist/menu/MenuHeading.svelte.d.ts +1 -0
  32. package/dist/menu/MenuItem.svelte.d.ts +1 -0
  33. package/dist/menu/MenuItems.svelte.d.ts +1 -0
  34. package/dist/menu/MenuSection.svelte.d.ts +1 -0
  35. package/dist/menu/MenuSeparator.svelte.d.ts +1 -0
  36. package/dist/popover/Popover.svelte.d.ts +1 -0
  37. package/dist/popover/PopoverBackdrop.svelte.d.ts +1 -0
  38. package/dist/popover/PopoverButton.svelte.d.ts +1 -0
  39. package/dist/popover/PopoverGroup.svelte.d.ts +1 -0
  40. package/dist/popover/PopoverPanel.svelte.d.ts +1 -0
  41. package/dist/portal/InternalPortal.svelte.d.ts +1 -0
  42. package/dist/portal/Portal.svelte.d.ts +1 -0
  43. package/dist/portal/PortalGroup.svelte.d.ts +1 -0
  44. package/dist/radio-group/Radio.svelte +135 -0
  45. package/dist/radio-group/Radio.svelte.d.ts +35 -0
  46. package/dist/radio-group/RadioGroup.svelte +223 -0
  47. package/dist/radio-group/RadioGroup.svelte.d.ts +34 -0
  48. package/dist/radio-group/RadioOption.svelte +138 -0
  49. package/dist/radio-group/RadioOption.svelte.d.ts +37 -0
  50. package/dist/radio-group/contest.svelte.d.ts +30 -0
  51. package/dist/radio-group/contest.svelte.js +40 -0
  52. package/dist/radio-group/index.d.ts +3 -0
  53. package/dist/radio-group/index.js +3 -0
  54. package/dist/select/Select.svelte.d.ts +1 -0
  55. package/dist/switch/Switch.svelte.d.ts +1 -0
  56. package/dist/switch/SwitchGroup.svelte.d.ts +1 -0
  57. package/dist/tabs/Tab.svelte.d.ts +1 -0
  58. package/dist/tabs/TabGroup.svelte.d.ts +1 -0
  59. package/dist/tabs/TabList.svelte.d.ts +1 -0
  60. package/dist/tabs/TabPanel.svelte.d.ts +1 -0
  61. package/dist/tabs/TabPanels.svelte.d.ts +1 -0
  62. package/dist/transition/InternalTransitionChild.svelte.d.ts +1 -0
  63. package/dist/transition/Transition.svelte.d.ts +1 -0
  64. package/dist/transition/TransitionChild.svelte.d.ts +1 -0
  65. package/dist/utils/DisabledProvider.svelte.d.ts +4 -2
  66. package/dist/utils/StableCollection.svelte.d.ts +4 -2
  67. package/dist/utils/floating-ui/svelte/components/FloatingNode.svelte.d.ts +1 -0
  68. package/dist/utils/floating-ui/svelte/components/FloatingTree.svelte.d.ts +1 -0
  69. package/package.json +31 -31
@@ -15,4 +15,5 @@ export type ButtonOwnProps = {
15
15
  };
16
16
  export type ButtonProps = Props<typeof DEFAULT_BUTTON_TAG, ButtonRenderPropArg, ButtonOwnProps>;
17
17
  declare const Button: import("svelte").Component<ButtonProps, {}, "element">;
18
+ type Button = ReturnType<typeof Button>;
18
19
  export default Button;
@@ -1,4 +1,5 @@
1
1
  import { type ButtonProps } from "../button/Button.svelte";
2
2
  export type CloseButtonProps = ButtonProps;
3
3
  declare const CloseButton: import("svelte").Component<ButtonProps, {}, "element">;
4
+ type CloseButton = ReturnType<typeof CloseButton>;
4
5
  export default CloseButton;
@@ -10,4 +10,5 @@ declare const DataInteractive: import("svelte").Component<{
10
10
  props?: Record<string, any>;
11
11
  }]> | undefined;
12
12
  }, {}, "">;
13
+ type DataInteractive = ReturnType<typeof DataInteractive>;
13
14
  export default DataInteractive;
@@ -6,4 +6,5 @@ export type DescriptionOwnProps = {
6
6
  };
7
7
  export type DescriptionProps = Props<typeof DEFAULT_DESCRIPTION_TAG, {}, DescriptionOwnProps>;
8
8
  declare const Description: import("svelte").Component<DescriptionProps, {}, "element">;
9
+ type Description = ReturnType<typeof Description>;
9
10
  export default Description;
@@ -18,4 +18,5 @@ export type DialogOwnProps = PropsForFeatures<typeof DialogRenderFeatures> & {
18
18
  };
19
19
  export type DialogProps = Props<typeof DEFAULT_DIALOG_TAG, DialogRenderPropArg, DialogOwnProps>;
20
20
  declare const Dialog: import("svelte").Component<DialogProps, {}, "element">;
21
+ type Dialog = ReturnType<typeof Dialog>;
21
22
  export default Dialog;
@@ -9,4 +9,5 @@ export type DialogBackdropOwnProps = {
9
9
  };
10
10
  export type DialogBackdropProps = Props<typeof DEFAULT_BACKDROP_TAG, BackdropRenderPropArg, DialogBackdropOwnProps>;
11
11
  declare const DialogBackdrop: import("svelte").Component<DialogBackdropProps, {}, "element">;
12
+ type DialogBackdrop = ReturnType<typeof DialogBackdrop>;
12
13
  export default DialogBackdrop;
@@ -10,4 +10,5 @@ export type DialogPanelOwnProps = {
10
10
  };
11
11
  export type DialogPanelProps = Props<typeof DEFAULT_PANEL_TAG, PanelRenderPropArg, DialogPanelOwnProps>;
12
12
  declare const DialogPanel: import("svelte").Component<DialogPanelProps, {}, "element">;
13
+ type DialogPanel = ReturnType<typeof DialogPanel>;
13
14
  export default DialogPanel;
@@ -9,4 +9,5 @@ export type DialogTitleOwnProps = {
9
9
  };
10
10
  export type DialogTitleProps = Props<typeof DEFAULT_TITLE_TAG, TitleRenderPropArg, DialogTitleOwnProps>;
11
11
  declare const DialogTitle: import("svelte").Component<DialogTitleProps, {}, "element">;
12
+ type DialogTitle = ReturnType<typeof DialogTitle>;
12
13
  export default DialogTitle;
@@ -6,4 +6,5 @@ export type FieldOwnProps = {
6
6
  };
7
7
  export type FieldProps = Props<typeof DEFAULT_FIELD_TAG, {}, FieldOwnProps>;
8
8
  declare const Field: import("svelte").Component<FieldProps, {}, "element">;
9
+ type Field = ReturnType<typeof Field>;
9
10
  export default Field;
@@ -6,4 +6,5 @@ export type FieldsetOwnProps = {
6
6
  };
7
7
  export type FieldsetProps = Props<typeof DEFAULT_FIELDSET_TAG, {}, FieldsetOwnProps>;
8
8
  declare const Fieldset: import("svelte").Component<FieldsetProps, {}, "element">;
9
+ type Fieldset = ReturnType<typeof Fieldset>;
9
10
  export default Fieldset;
@@ -12,4 +12,5 @@ export type FocusTrapOwnProps = {
12
12
  };
13
13
  export type FocusTrapProps = Props<typeof DEFAULT_FOCUS_TRAP_TAG, {}, FocusTrapOwnProps>;
14
14
  declare const FocusTrap: import("svelte").Component<FocusTrapProps, {}, "element">;
15
+ type FocusTrap = ReturnType<typeof FocusTrap>;
15
16
  export default FocusTrap;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from "./legend/index.js";
12
12
  export * from "./listbox/index.js";
13
13
  export * from "./menu/index.js";
14
14
  export * from "./popover/index.js";
15
+ export * from "./radio-group/index.js";
15
16
  export * from "./select/index.js";
16
17
  export * from "./switch/index.js";
17
18
  export * from "./tabs/index.js";
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ export * from "./legend/index.js";
12
12
  export * from "./listbox/index.js";
13
13
  export * from "./menu/index.js";
14
14
  export * from "./popover/index.js";
15
+ export * from "./radio-group/index.js";
15
16
  export * from "./select/index.js";
16
17
  export * from "./switch/index.js";
17
18
  export * from "./tabs/index.js";
@@ -1,6 +1,8 @@
1
1
  import type { Snippet } from "svelte";
2
- declare const FloatingProvider: import("svelte").Component<{
2
+ type $$ComponentProps = {
3
3
  children: Snippet;
4
4
  enabled?: boolean;
5
- }, {}, "">;
5
+ };
6
+ declare const FloatingProvider: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type FloatingProvider = ReturnType<typeof FloatingProvider>;
6
8
  export default FloatingProvider;
@@ -1,4 +1,6 @@
1
- declare const FocusSentinel: import("svelte").Component<{
1
+ interface FocusSentinelProps {
2
2
  onfocus: () => boolean;
3
- }, {}, "">;
3
+ }
4
+ declare const FocusSentinel: import("svelte").Component<FocusSentinelProps, {}, "">;
5
+ type FocusSentinel = ReturnType<typeof FocusSentinel>;
4
6
  export default FocusSentinel;
@@ -1,6 +1,8 @@
1
1
  import type { Snippet } from "svelte";
2
- declare const ForcePortalRoot: import("svelte").Component<{
2
+ type $$ComponentProps = {
3
3
  force: boolean;
4
4
  children: Snippet;
5
- }, {}, "">;
5
+ };
6
+ declare const ForcePortalRoot: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type ForcePortalRoot = ReturnType<typeof ForcePortalRoot>;
6
8
  export default ForcePortalRoot;
@@ -1,8 +1,10 @@
1
- declare const FormFields: import("svelte").Component<{
1
+ type $$ComponentProps = {
2
2
  data: Record<string, any>;
3
3
  overrides?: Record<string, any>;
4
4
  form?: string;
5
5
  disabled?: boolean;
6
6
  onReset?: (e: Event) => void;
7
- }, {}, "">;
7
+ };
8
+ declare const FormFields: import("svelte").Component<$$ComponentProps, {}, "">;
9
+ type FormFields = ReturnType<typeof FormFields>;
8
10
  export default FormFields;
@@ -1,5 +1,7 @@
1
1
  import type { Snippet } from "svelte";
2
- declare const FormFieldsProvider: import("svelte").Component<{
2
+ type $$ComponentProps = {
3
3
  children?: Snippet;
4
- }, {}, "">;
4
+ };
5
+ declare const FormFieldsProvider: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type FormFieldsProvider = ReturnType<typeof FormFieldsProvider>;
5
7
  export default FormFieldsProvider;
@@ -1,5 +1,7 @@
1
- declare const FormResolver: import("svelte").Component<{
1
+ type $$ComponentProps = {
2
2
  setForm: (form: HTMLFormElement) => void;
3
3
  formId?: string;
4
- }, {}, "">;
4
+ };
5
+ declare const FormResolver: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type FormResolver = ReturnType<typeof FormResolver>;
5
7
  export default FormResolver;
@@ -8,4 +8,5 @@ export type HiddenProps = Props<typeof DEFAULT_VISUALLY_HIDDEN_TAG, HiddenRender
8
8
  features?: HiddenFeatures;
9
9
  }>;
10
10
  declare const Hidden: import("svelte").Component<HiddenProps, {}, "element">;
11
+ type Hidden = ReturnType<typeof Hidden>;
11
12
  export default Hidden;
@@ -8,8 +8,10 @@ export declare function useMainTreeNode(options?: {
8
8
  fallbackMainTreeNode?: HTMLElement | null;
9
9
  }): MainTreeContext;
10
10
  import { type Snippet } from "svelte";
11
- declare const MainTreeProvider: import("svelte").Component<{
11
+ type $$ComponentProps = {
12
12
  children: Snippet;
13
13
  node?: HTMLElement | null;
14
- }, {}, "">;
14
+ };
15
+ declare const MainTreeProvider: import("svelte").Component<$$ComponentProps, {}, "">;
16
+ type MainTreeProvider = ReturnType<typeof MainTreeProvider>;
15
17
  export default MainTreeProvider;
@@ -1,6 +1,8 @@
1
1
  import { type Snippet } from "svelte";
2
- declare const Portal: import("svelte").Component<{
2
+ type $$ComponentProps = {
3
3
  target: HTMLElement;
4
4
  children: Snippet;
5
- }, {}, "">;
5
+ };
6
+ declare const Portal: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type Portal = ReturnType<typeof Portal>;
6
8
  export default Portal;
@@ -48,8 +48,6 @@
48
48
  e.preventDefault()
49
49
  }
50
50
 
51
- console.log("click", providedHtmlFor)
52
-
53
51
  if (current instanceof HTMLLabelElement) {
54
52
  let target = document.getElementById(current.getAttribute("for") ?? "")
55
53
  if (target) {
@@ -8,4 +8,5 @@ export type LabelOwnProps = {
8
8
  };
9
9
  export type LabelProps = Props<typeof DEFAULT_LABEL_TAG, {}, LabelOwnProps>;
10
10
  declare const Label: import("svelte").Component<LabelProps, {}, "element">;
11
+ type Label = ReturnType<typeof Label>;
11
12
  export default Label;
@@ -6,4 +6,5 @@ export type LegendOwnProps = {
6
6
  };
7
7
  export type LegendProps = Props<typeof DEFAULT_LEGEND_TAG, {}, LegendOwnProps>;
8
8
  declare const Legend: import("svelte").Component<LegendProps, {}, "">;
9
+ type Legend = ReturnType<typeof Legend>;
9
10
  export default Legend;
@@ -18,4 +18,5 @@ export type ListboxButtonOwnProps = {
18
18
  };
19
19
  export type ListboxButtonProps = Props<typeof DEFAULT_BUTTON_TAG, ButtonRenderPropArg, ListboxButtonOwnProps>;
20
20
  declare const ListboxButton: import("svelte").Component<ListboxButtonProps, {}, "element">;
21
+ type ListboxButton = ReturnType<typeof ListboxButton>;
21
22
  export default ListboxButton;
@@ -16,4 +16,5 @@ export type ListboxOptionsOwnProps = {
16
16
  } & PropsForFeatures<typeof OptionsRenderFeatures>;
17
17
  export type ListboxOptionsProps = Props<typeof DEFAULT_OPTIONS_TAG, OptionsRenderPropArg, ListboxOptionsOwnProps>;
18
18
  declare const ListboxOptions: import("svelte").Component<ListboxOptionsProps, {}, "element">;
19
+ type ListboxOptions = ReturnType<typeof ListboxOptions>;
19
20
  export default ListboxOptions;
@@ -11,4 +11,5 @@ export type ListboxSelectedOptionOwnProps = {
11
11
  };
12
12
  export type ListboxSelectedOptionProps = Props<typeof DEFAULT_SELECTED_OPTION_TAG, SelectedOptionRenderPropArg, ListboxSelectedOptionOwnProps>;
13
13
  declare const ListboxSelectedOption: import("svelte").Component<ListboxSelectedOptionProps, {}, "element">;
14
+ type ListboxSelectedOption = ReturnType<typeof ListboxSelectedOption>;
14
15
  export default ListboxSelectedOption;
@@ -8,4 +8,5 @@ export type MenuOwnProps = {
8
8
  };
9
9
  export type MenuProps = PropsAsChild<MenuRenderPropArg, MenuOwnProps>;
10
10
  declare const Menu: import("svelte").Component<MenuProps, {}, "">;
11
+ type Menu = ReturnType<typeof Menu>;
11
12
  export default Menu;
@@ -17,4 +17,5 @@ export type MenuButtonOwnProps = {
17
17
  };
18
18
  export type MenuButtonProps = Props<typeof DEFAULT_BUTTON_TAG, ButtonRenderPropArg, MenuButtonOwnProps>;
19
19
  declare const MenuButton: import("svelte").Component<MenuButtonProps, {}, "element">;
20
+ type MenuButton = ReturnType<typeof MenuButton>;
20
21
  export default MenuButton;
@@ -6,4 +6,5 @@ export type MenuHeadingOwnProps = {
6
6
  };
7
7
  export type MenuHeadingProps = Props<typeof DEFAULT_HEADING_TAG, {}, MenuHeadingOwnProps>;
8
8
  declare const MenuHeading: import("svelte").Component<MenuHeadingProps, {}, "element">;
9
+ type MenuHeading = ReturnType<typeof MenuHeading>;
9
10
  export default MenuHeading;
@@ -15,4 +15,5 @@ export type MenuItemOwnProps = {
15
15
  };
16
16
  export type MenuItemProps = Props<typeof DEFAULT_ITEM_TAG, ItemRenderPropArg, MenuItemOwnProps>;
17
17
  declare const MenuItem: import("svelte").Component<MenuItemProps, {}, "element">;
18
+ type MenuItem = ReturnType<typeof MenuItem>;
18
19
  export default MenuItem;
@@ -16,4 +16,5 @@ export type MenuItemsOwnProps = {
16
16
  } & PropsForFeatures<typeof ItemsRenderFeatures>;
17
17
  export type MenuItemsProps = Props<typeof DEFAULT_ITEMS_TAG, ItemsRenderPropArg, MenuItemsOwnProps>;
18
18
  declare const MenuItems: import("svelte").Component<MenuItemsProps, {}, "element">;
19
+ type MenuItems = ReturnType<typeof MenuItems>;
19
20
  export default MenuItems;
@@ -5,4 +5,5 @@ export type MenuSectionOwnProps = {
5
5
  };
6
6
  export type MenuSectionProps = Props<typeof DEFAULT_SECTION_TAG, {}, MenuSectionOwnProps>;
7
7
  declare const MenuSection: import("svelte").Component<MenuSectionProps, {}, "element">;
8
+ type MenuSection = ReturnType<typeof MenuSection>;
8
9
  export default MenuSection;
@@ -5,4 +5,5 @@ export type MenuSeparatorOwnProps = {
5
5
  };
6
6
  export type MenuSeparatorProps = Props<typeof DEFAULT_SEPARATOR_TAG, {}, MenuSeparatorOwnProps>;
7
7
  declare const MenuSeparator: import("svelte").Component<MenuSeparatorProps, {}, "element">;
8
+ type MenuSeparator = ReturnType<typeof MenuSeparator>;
8
9
  export default MenuSeparator;
@@ -11,4 +11,5 @@ export type PopoverOwnProps = {
11
11
  export type PopoverProps = Props<typeof DEFAULT_POPOVER_TAG, PopoverRenderPropArg, PopoverOwnProps>;
12
12
  import { type MouseEvent } from "./context.svelte.js";
13
13
  declare const Popover: import("svelte").Component<PopoverProps, {}, "element">;
14
+ type Popover = ReturnType<typeof Popover>;
14
15
  export default Popover;
@@ -13,4 +13,5 @@ export type PopoverBackdropOwnProps = {
13
13
  export type PopoverBackdropProps = Props<typeof DEFAULT_BACKDROP_TAG, BackdropRenderPropArg, PopoverBackdropOwnProps>;
14
14
  export type PopoverOverlayProps = PopoverBackdropProps;
15
15
  declare const PopoverBackdrop: import("svelte").Component<PopoverBackdropProps, {}, "element">;
16
+ type PopoverBackdrop = ReturnType<typeof PopoverBackdrop>;
16
17
  export default PopoverBackdrop;
@@ -17,4 +17,5 @@ export type PopoverButtonOwnProps = {
17
17
  };
18
18
  export type PopoverButtonProps = Props<typeof DEFAULT_BUTTON_TAG, PopoverButtonSlot, PopoverButtonOwnProps>;
19
19
  declare const PopoverButton: import("svelte").Component<PopoverButtonProps, {}, "element">;
20
+ type PopoverButton = ReturnType<typeof PopoverButton>;
20
21
  export default PopoverButton;
@@ -5,4 +5,5 @@ export type PopoverGroupOwnProps = {
5
5
  };
6
6
  export type PopoverGroupProps = Props<typeof DEFAULT_GROUP_TAG, {}, PopoverGroupOwnProps>;
7
7
  declare const PopoverGroup: import("svelte").Component<PopoverGroupProps, {}, "element">;
8
+ type PopoverGroup = ReturnType<typeof PopoverGroup>;
8
9
  export default PopoverGroup;
@@ -18,4 +18,5 @@ export type PopoverPanelOwnProps = {
18
18
  export type PopoverPanelProps = Props<typeof DEFAULT_PANEL_TAG, PanelRenderPropArg, PopoverPanelOwnProps>;
19
19
  import { type AnchorProps } from "../internal/floating.svelte.js";
20
20
  declare const PopoverPanel: import("svelte").Component<PopoverPanelProps, {}, "element">;
21
+ type PopoverPanel = ReturnType<typeof PopoverPanel>;
21
22
  export default PopoverPanel;
@@ -12,4 +12,5 @@ export type PortalProps = Props<typeof DEFAULT_PORTAL_TAG, PortalRenderPropArg,
12
12
  enabled?: boolean;
13
13
  }>;
14
14
  declare const InternalPortal: import("svelte").Component<PortalProps, {}, "element">;
15
+ type InternalPortal = ReturnType<typeof InternalPortal>;
15
16
  export default InternalPortal;
@@ -1,3 +1,4 @@
1
1
  import { type PortalProps } from "./InternalPortal.svelte";
2
2
  declare const Portal: import("svelte").Component<PortalProps, {}, "element">;
3
+ type Portal = ReturnType<typeof Portal>;
3
4
  export default Portal;
@@ -7,4 +7,5 @@ export type PortalGroupProps = PropsAsChild<GroupRenderPropArg, {
7
7
  target: HTMLElement | null;
8
8
  }>;
9
9
  declare const PortalGroup: import("svelte").Component<PortalGroupProps, {}, "">;
10
+ type PortalGroup = ReturnType<typeof PortalGroup>;
10
11
  export default PortalGroup;
@@ -0,0 +1,135 @@
1
+ <script lang="ts" module>
2
+ import type { Props } from "../utils/types.js"
3
+
4
+ const DEFAULT_RADIO_TAG = "span" as const
5
+
6
+ export type RadioRenderPropArg = {
7
+ checked: boolean
8
+ hover: boolean
9
+ focus: boolean
10
+ autofocus: boolean
11
+ disabled: boolean
12
+ }
13
+
14
+ export type RadioOwnProps<TType> = {
15
+ element?: HTMLElement
16
+ value: TType
17
+ disabled?: boolean
18
+ autofocus?: boolean
19
+ }
20
+
21
+ export type RadioProps<TType = string> = Props<typeof DEFAULT_RADIO_TAG, RadioRenderPropArg, RadioOwnProps<TType>>
22
+ </script>
23
+
24
+ <script lang="ts" generics="TType = ComponentProps<typeof RadioGroup>['value']">
25
+ import { default as RadioGroup } from "./RadioGroup.svelte"
26
+ import { useActions, useData } from "./contest.svelte.js"
27
+ import { useId } from "../hooks/use-id.js"
28
+ import { useLabelledBy } from "../label/context.svelte.js"
29
+ import { useDescribedBy } from "../description/context.svelte.js"
30
+ import { onMount, type ComponentProps } from "svelte"
31
+ import ElementOrComponent from "../utils/ElementOrComponent.svelte"
32
+ import { useFocusRing } from "../hooks/use-focus-ring.svelte.js"
33
+ import { useHover } from "../hooks/use-hover.svelte.js"
34
+ import { mergeProps } from "../utils/render.js"
35
+ import { useProvidedId } from "../utils/id.js"
36
+ import { useDisabled } from "../hooks/use-disabled.js"
37
+
38
+ const data = useData("Radio")
39
+ const actions = useActions<TType>("Radio")
40
+
41
+ const internalId = useId()
42
+ const providedId = useProvidedId()
43
+ const providedDisabled = useDisabled()
44
+ let {
45
+ element = $bindable(),
46
+ id: theirId,
47
+ value,
48
+ disabled: theirDisabled = false,
49
+ autofocus = false,
50
+ ...theirProps
51
+ }: RadioProps<TType> = $props()
52
+ const id = $derived(theirId || providedId || `headlessui-radio-${internalId}`)
53
+ const disabled = $derived(data.disabled || providedDisabled.current || theirDisabled)
54
+
55
+ const labelledby = useLabelledBy()
56
+ const describedby = useDescribedBy()
57
+
58
+ const propsRef = {
59
+ get value() {
60
+ return value
61
+ },
62
+ get disabled() {
63
+ return disabled
64
+ },
65
+ }
66
+
67
+ onMount(() => {
68
+ return actions.registerOption({
69
+ id,
70
+ get element() {
71
+ return element
72
+ },
73
+ get propsRef() {
74
+ return propsRef
75
+ },
76
+ })
77
+ })
78
+
79
+ const handleClick = (event: MouseEvent) => {
80
+ //if (isDisabledReactIssue7711(event.currentTarget)) return event.preventDefault()
81
+ if (!actions.change(value)) return
82
+ element?.focus()
83
+ }
84
+
85
+ const { isFocusVisible: focus, focusProps } = $derived(
86
+ useFocusRing({
87
+ get autofocus() {
88
+ return autofocus
89
+ },
90
+ })
91
+ )
92
+ const { isHovered: hover, hoverProps } = $derived(
93
+ useHover({
94
+ get disabled() {
95
+ return disabled
96
+ },
97
+ })
98
+ )
99
+
100
+ const isFirstOption = $derived(data.firstOption?.id === id)
101
+
102
+ const checked = $derived(data.compare(data.value as TType, value))
103
+ const ourProps = $derived(
104
+ mergeProps(
105
+ {
106
+ id,
107
+ role: "radio",
108
+ "aria-checked": checked ? "true" : "false",
109
+ "aria-labelledby": labelledby.value,
110
+ "aria-describedby": describedby.value,
111
+ "aria-disabled": disabled ? true : undefined,
112
+ tabIndex: (() => {
113
+ if (disabled) return -1
114
+ if (checked) return 0
115
+ if (!data.containsCheckedOption && isFirstOption) return 0
116
+ return -1
117
+ })(),
118
+ autofocus,
119
+ onclick: disabled ? undefined : handleClick,
120
+ },
121
+ focusProps,
122
+ hoverProps
123
+ )
124
+ )
125
+
126
+ const slot = $derived({
127
+ checked,
128
+ disabled,
129
+ hover,
130
+ focus,
131
+ autofocus,
132
+ } satisfies RadioRenderPropArg)
133
+ </script>
134
+
135
+ <ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_RADIO_TAG} bind:element name="RadioOption" />
@@ -0,0 +1,35 @@
1
+ import type { Props } from "../utils/types.js";
2
+ declare const DEFAULT_RADIO_TAG: "span";
3
+ export type RadioRenderPropArg = {
4
+ checked: boolean;
5
+ hover: boolean;
6
+ focus: boolean;
7
+ autofocus: boolean;
8
+ disabled: boolean;
9
+ };
10
+ export type RadioOwnProps<TType> = {
11
+ element?: HTMLElement;
12
+ value: TType;
13
+ disabled?: boolean;
14
+ autofocus?: boolean;
15
+ };
16
+ export type RadioProps<TType = string> = Props<typeof DEFAULT_RADIO_TAG, RadioRenderPropArg, RadioOwnProps<TType>>;
17
+ import { default as RadioGroup } from "./RadioGroup.svelte";
18
+ import { type ComponentProps } from "svelte";
19
+ declare class __sveltets_Render<TType = ComponentProps<typeof RadioGroup>['value']> {
20
+ props(): RadioProps<TType>;
21
+ events(): {};
22
+ slots(): {};
23
+ bindings(): "element";
24
+ exports(): {};
25
+ }
26
+ interface $$IsomorphicComponent {
27
+ new <TType = ComponentProps<typeof RadioGroup>['value']>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TType>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TType>['props']>, ReturnType<__sveltets_Render<TType>['events']>, ReturnType<__sveltets_Render<TType>['slots']>> & {
28
+ $$bindings?: ReturnType<__sveltets_Render<TType>['bindings']>;
29
+ } & ReturnType<__sveltets_Render<TType>['exports']>;
30
+ <TType = ComponentProps<typeof RadioGroup>['value']>(internal: unknown, props: ReturnType<__sveltets_Render<TType>['props']> & {}): ReturnType<__sveltets_Render<TType>['exports']>;
31
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
32
+ }
33
+ declare const Radio: $$IsomorphicComponent;
34
+ type Radio<TType = ComponentProps<typeof RadioGroup>['value']> = InstanceType<typeof Radio<TType>>;
35
+ export default Radio;