Skip to content

Commit

Permalink
Deprecate dot notation (#3170)
Browse files Browse the repository at this point in the history
* Expose new components under dot notation

Most of them already where so only a couple were missing.

* Deprecate dot notation

* Add deprecation to `RadioGroupOption`

* Update deprecations

* Update changelog

* Update changelog
  • Loading branch information
thecrypticace authored May 3, 2024
1 parent 0bd8c47 commit 8d20cfb
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/@headlessui-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Change default tags for `ListboxOptions`, `ListboxOption`, `ComboboxOptions`, `ComboboxOption` and `TabGroup` components ([#3109](https://github.com/tailwindlabs/headlessui/pull/3109))
- Change default tag from `div` to `Fragment` on `Transition` components ([#3110](https://github.com/tailwindlabs/headlessui/pull/3110))
- Update minimal peer dependency version requirements for `react` and `react-dom` ([#3131](https://github.com/tailwindlabs/headlessui/pull/3131))
- Deprecate dot notation for components ([#2887](https://github.com/tailwindlabs/headlessui/pull/2887), [#3170](https://github.com/tailwindlabs/headlessui/pull/3170))

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1971,10 +1971,14 @@ export let ComboboxOptions = forwardRefWithAs(OptionsFn) as _internal_ComponentC
export let ComboboxOption = forwardRefWithAs(OptionFn) as _internal_ComponentComboboxOption

export let Combobox = Object.assign(ComboboxRoot, {
/** @deprecated use `<ComboboxInput>` instead of `<Combobox.Input>` */
Input: ComboboxInput,
/** @deprecated use `<ComboboxButton>` instead of `<Combobox.Button>` */
Button: ComboboxButton,
/** @deprecated use `<Label>` instead of `<Combobox.Label>` */
Label: ComboboxLabel,
/** @deprecated use `<ComboboxOptions>` instead of `<Combobox.Options>` */
Options: ComboboxOptions,
/** @deprecated use `<ComboboxOption>` instead of `<Combobox.Option>` */
Option: ComboboxOption,
})
6 changes: 6 additions & 0 deletions packages/@headlessui-react/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -658,17 +658,23 @@ export interface _internal_ComponentDialogTitle extends HasDisplayName {
export interface _internal_ComponentDialogDescription extends _internal_ComponentDescription {}

let DialogRoot = forwardRefWithAs(DialogFn) as _internal_ComponentDialog
/** @deprecated use a plain `<div>` instead of `<DialogBackdrop>` */
export let DialogBackdrop = forwardRefWithAs(BackdropFn) as _internal_ComponentDialogBackdrop
export let DialogPanel = forwardRefWithAs(PanelFn) as _internal_ComponentDialogPanel
/** @deprecated use a plain `<div>` instead of `<DialogOverlay>` */
export let DialogOverlay = forwardRefWithAs(OverlayFn) as _internal_ComponentDialogOverlay
export let DialogTitle = forwardRefWithAs(TitleFn) as _internal_ComponentDialogTitle
/** @deprecated use `<Description>` instead of `<DialogDescription>` */
export let DialogDescription = Description as _internal_ComponentDialogDescription

export let Dialog = Object.assign(DialogRoot, {
/** @deprecated use a plain `<div>` instead of `<Dialog.Backdrop>` */
Backdrop: DialogBackdrop,
/** @deprecated use `<DialogPanel>` instead of `<Dialog.Panel>` */
Panel: DialogPanel,
/** @deprecated use a plain `<div>` instead of `<Dialog.Overlay>` */
Overlay: DialogOverlay,
/** @deprecated use `<DialogTitle>` instead of `<Dialog.Title>` */
Title: DialogTitle,
/** @deprecated use `<Description>` instead of `<Dialog.Description>` */
Description: Description as _internal_ComponentDialogDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ export let DisclosureButton = forwardRefWithAs(ButtonFn) as _internal_ComponentD
export let DisclosurePanel = forwardRefWithAs(PanelFn) as _internal_ComponentDisclosurePanel

export let Disclosure = Object.assign(DisclosureRoot, {
/** @deprecated use `<DisclosureButton>` instead of `<Disclosure.Button>` */
Button: DisclosureButton,
/** @deprecated use `<DisclosurePanel>` instead of `<Disclosure.Panel>` */
Panel: DisclosurePanel,
})
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export interface _internal_ComponentFocusTrap extends HasDisplayName {
let FocusTrapRoot = forwardRefWithAs(FocusTrapFn) as _internal_ComponentFocusTrap

export let FocusTrap = Object.assign(FocusTrapRoot, {
/** @deprecated use `FocusTrapFeatures` instead of `FocusTrap.features` */
features: FocusTrapFeatures,
})

Expand Down
5 changes: 5 additions & 0 deletions packages/@headlessui-react/src/components/listbox/listbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1403,9 +1403,14 @@ export let ListboxSelectedOption = forwardRefWithAs(
) as _internal_ComponentListboxSelectedOption

export let Listbox = Object.assign(ListboxRoot, {
/** @deprecated use `<ListboxButton>` instead of `<Listbox.Button>` */
Button: ListboxButton,
/** @deprecated use `<Label>` instead of `<Listbox.Label>` */
Label: ListboxLabel,
/** @deprecated use `<ListboxOptions>` instead of `<Listbox.Options>` */
Options: ListboxOptions,
/** @deprecated use `<ListboxOption>` instead of `<Listbox.Option>` */
Option: ListboxOption,
/** @deprecated use `<ListboxSelectedOption>` instead of `<Listbox.SelectedOption>` */
SelectedOption: ListboxSelectedOption,
})
6 changes: 6 additions & 0 deletions packages/@headlessui-react/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1109,10 +1109,16 @@ export let MenuHeading = forwardRefWithAs(HeadingFn) as _internal_ComponentMenuH
export let MenuSeparator = forwardRefWithAs(SeparatorFn) as _internal_ComponentMenuSeparator

export let Menu = Object.assign(MenuRoot, {
/** @deprecated use `<MenuButton>` instead of `<Menu.Button>` */
Button: MenuButton,
/** @deprecated use `<MenuItems>` instead of `<Menu.Items>` */
Items: MenuItems,
/** @deprecated use `<MenuItem>` instead of `<Menu.Item>` */
Item: MenuItem,
/** @deprecated use `<MenuSection>` instead of `<Menu.Section>` */
Section: MenuSection,
/** @deprecated use `<MenuHeading>` instead of `<Menu.Heading>` */
Heading: MenuHeading,
/** @deprecated use `<MenuSeparator>` instead of `<Menu.Separator>` */
Separator: MenuSeparator,
})
4 changes: 4 additions & 0 deletions packages/@headlessui-react/src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,12 @@ export let PopoverPanel = forwardRefWithAs(PanelFn) as _internal_ComponentPopove
export let PopoverGroup = forwardRefWithAs(GroupFn) as _internal_ComponentPopoverGroup

export let Popover = Object.assign(PopoverRoot, {
/** @deprecated use `<PopoverButton>` instead of `<Popover.Button>` */
Button: PopoverButton,
/** @deprecated use `<PopoverOverlay>` instead of `<Popover.Overlay>` */
Overlay: PopoverOverlay,
/** @deprecated use `<PopoverPanel>` instead of `<Popover.Panel>` */
Panel: PopoverPanel,
/** @deprecated use `<PopoverGroup>` instead of `<Popover.Group>` */
Group: PopoverGroup,
})
5 changes: 4 additions & 1 deletion packages/@headlessui-react/src/components/portal/portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,7 @@ export interface _internal_ComponentPortalGroup extends HasDisplayName {
let PortalRoot = forwardRefWithAs(PortalFn) as unknown as _internal_ComponentPortal
export let PortalGroup = forwardRefWithAs(GroupFn) as _internal_ComponentPortalGroup

export let Portal = Object.assign(PortalRoot, { Group: PortalGroup })
export let Portal = Object.assign(PortalRoot, {
/** @deprecated use `<PortalGroup>` instead of `<Portal.Group>` */
Group: PortalGroup,
})
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ export interface _internal_ComponentRadioLabel extends _internal_ComponentLabel
export interface _internal_ComponentRadioDescription extends _internal_ComponentDescription {}

let RadioGroupRoot = forwardRefWithAs(RadioGroupFn) as _internal_ComponentRadioGroup
/** @deprecated use `<Radio>` instead of `<RadioGroupOption>` */
export let RadioGroupOption = forwardRefWithAs(OptionFn) as _internal_ComponentRadioOption
export let Radio = forwardRefWithAs(RadioFn) as _internal_ComponentRadio
/** @deprecated use `<Label>` instead of `<RadioGroupLabel>` */
Expand All @@ -596,7 +597,10 @@ export let RadioGroupLabel = Label as _internal_ComponentRadioLabel
export let RadioGroupDescription = Description as _internal_ComponentRadioDescription

export let RadioGroup = Object.assign(RadioGroupRoot, {
/** @deprecated use `<Radio>` instead of `<RadioGroup.Option>` */
Option: RadioGroupOption,
/** @deprecated use `<Radio>` instead of `<RadioGroup.Radio>` */
Radio: Radio,
/** @deprecated use `<Label>` instead of `<RadioGroup.Label>` */
Label: RadioGroupLabel,
/** @deprecated use `<Description>` instead of `<RadioGroup.Description>` */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export let SwitchLabel = Label as _internal_ComponentSwitchLabel
export let SwitchDescription = Description as _internal_ComponentSwitchDescription

export let Switch = Object.assign(SwitchRoot, {
/** @deprecated use `<SwitchGroup>` instead of `<Switch.Group>` */
Group: SwitchGroup,
/** @deprecated use `<Label>` instead of `<Switch.Label>` */
Label: SwitchLabel,
Expand Down
4 changes: 4 additions & 0 deletions packages/@headlessui-react/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,12 @@ export let TabPanels = forwardRefWithAs(PanelsFn) as _internal_ComponentTabPanel
export let TabPanel = forwardRefWithAs(PanelFn) as _internal_ComponentTabPanel

export let Tab = Object.assign(TabRoot, {
/** @deprecated use `<TabGroup>` instead of `<Tab.Group>` */
Group: TabGroup,
/** @deprecated use `<TabList>` instead of `<Tab.List>` */
List: TabList,
/** @deprecated use `<TabPanels>` instead of `<Tab.Panels>` */
Panels: TabPanels,
/** @deprecated use `<TabPanel>` instead of `<Tab.Panel>` */
Panel: TabPanel,
})
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ let InternalTransitionChild = forwardRefWithAs(
export let TransitionChild = forwardRefWithAs(ChildFn) as _internal_ComponentTransitionChild

export let Transition = Object.assign(TransitionRoot, {
/** @deprecated use `<TransitionChild>` instead of `<Transition.Child>` */
Child: TransitionChild,
/** @deprecated use `<Transition>` instead of `<Transition.Root>` */
Root: TransitionRoot,
})

0 comments on commit 8d20cfb

Please sign in to comment.