Skip to content

Commit

Permalink
feat(react): remove dir and getRootNode from components
Browse files Browse the repository at this point in the history
  • Loading branch information
cschroeter committed Apr 26, 2024
1 parent fa27b66 commit 9ee7db7
Show file tree
Hide file tree
Showing 141 changed files with 99 additions and 988 deletions.
4 changes: 4 additions & 0 deletions frameworks/react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ description: All notable changes to this project will be documented in this file

## [Unreleased]

### Removed

- BREAKING: Removed `dir` and `getRootNode` from all components. Use `LocaleProvider` instead.

### Changed

- Made the `id` attribute optional for `<Combobox.ItemGroup>` and removed `htmlFor` from `<Combobox.ItemGroupLabel>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>((pro
return (
<AccordionItemPropsProvider value={itemProps}>
<AccordionItemProvider value={item}>
{/* @ts-expect-error TODO fix dir typing */}
<Collapsible.Root
ref={ref}
open={item.expanded}
Expand Down
4 changes: 2 additions & 2 deletions frameworks/react/src/components/accordion/accordion-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export const AccordionRoot = forwardRef<HTMLDivElement, AccordionRootProps>((pro
const [useAccordionProps, localProps] = createSplitProps<UseAccordionProps>()(accordionProps, [
'collapsible',
'defaultValue',
'dir',

'disabled',
'getRootNode',

'id',
'ids',
'multiple',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ describe('Accordion', () => {
expect(onFocusChange).toHaveBeenCalled()
})

it('should render text direction based on dir prop', async () => {
// TODO use locale provider
it.skip('should render text direction based on dir prop', async () => {
render(<ComponentUnderTest dir="rtl" />)

const button = screen.getByRole('button', { name: 'React Trigger' })
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/accordion/use-accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useEnvironmentContext } from '../../providers'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UseAccordionProps extends Optional<accordion.Context, 'id'> {
export interface UseAccordionProps
extends Optional<Omit<accordion.Context, 'dir' | 'getRootNode'>, 'id'> {
/**
* The initial value of the accordion.
*/
Expand Down
2 changes: 0 additions & 2 deletions frameworks/react/src/components/avatar/avatar-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export interface AvatarRootProps extends Assign<HTMLArkProps<'div'>, UseAvatarPr

export const AvatarRoot = forwardRef<HTMLDivElement, AvatarRootProps>((props, ref) => {
const [useAvatarProps, localProps] = createSplitProps<UseAvatarProps>()(props, [
'dir',
'getRootNode',
'id',
'onStatusChange',
])
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/avatar/use-avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UseAvatarProps extends Optional<avatar.Context, 'id'> {}
export interface UseAvatarProps
extends Optional<Omit<avatar.Context, 'dir' | 'getRootNode'>, 'id'> {}
export interface UseAvatarReturn extends avatar.Api<PropTypes> {}

export const useAvatar = (props: UseAvatarProps = {}): UseAvatarReturn => {
Expand Down
3 changes: 1 addition & 2 deletions frameworks/react/src/components/carousel/carousel-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export const CarouselRoot = forwardRef<HTMLDivElement, CarouselRootProps>((props
const [useCarouselProps, localProps] = createSplitProps<UseCarouselProps>()(props, [
'align',
'defaultIndex',
'dir',
'getRootNode',

'id',
'ids',
'index',
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/carousel/use-carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UseCarouselProps extends Optional<carousel.Context, 'id'> {
export interface UseCarouselProps
extends Optional<Omit<carousel.Context, 'dir' | 'getRootNode'>, 'id'> {
/**
* The initial selected index of the carousel.
*/
Expand Down
4 changes: 2 additions & 2 deletions frameworks/react/src/components/checkbox/checkbox-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const CheckboxRoot = forwardRef<HTMLLabelElement, CheckboxRootProps>((pro
const [useCheckboxProps, localProps] = createSplitProps<UseCheckboxProps>()(props, [
'checked',
'defaultChecked',
'dir',

'disabled',
'form',
'getRootNode',

'id',
'ids',
'invalid',
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/checkbox/use-checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UseCheckboxProps extends Optional<checkbox.Context, 'id'> {
export interface UseCheckboxProps
extends Optional<Omit<checkbox.Context, 'dir' | 'getRootNode'>, 'id'> {
/**
* The initial checked state of the checkbox.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface ClipboardRootProps extends Assign<HTMLArkProps<'div'>, UseClipb

export const ClipboardRoot = forwardRef<HTMLDivElement, ClipboardRootProps>((props, ref) => {
const [useClipboardProps, localProps] = createSplitProps<UseClipboardProps>()(props, [
'getRootNode',
'id',
'ids',
'onStatusChange',
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/clipboard/use-clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { useId } from 'react'
import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'

export interface UseClipboardProps extends Optional<clipboard.Context, 'id'> {}
export interface UseClipboardProps
extends Optional<Omit<clipboard.Context, 'dir' | 'getRootNode'>, 'id'> {}
export interface UseClipboardReturn extends clipboard.Api<PropTypes> {}

export const useClipboard = (props: UseClipboardProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import type { UseCollapsibleProps } from './use-collapsible'
export const splitCollapsibleProps = <T extends UseCollapsibleProps>(props: T) =>
createSplitProps<UseCollapsibleProps>()(props, [
'defaultOpen',
'dir',
'disabled',
'getRootNode',
'id',
'ids',
'lazyMount',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { RenderStrategyProps } from '../../utils/render-strategy'
import { useEvent } from '../../utils/use-event'

export interface UseCollapsibleProps
extends Optional<Omit<collapsible.Context, 'open.controlled'>, 'id'>,
extends Optional<Omit<collapsible.Context, 'dir' | 'getRootNode' | 'open.controlled'>, 'id'>,
RenderStrategyProps {
/**
* The initial open state of the collpasible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ export const ColorPickerRoot = forwardRef<HTMLDivElement, ColorPickerRootProps>(
[
'closeOnSelect',
'defaultValue',
'dir',
'disabled',
'format',
'getRootNode',
'id',
'ids',
'initialFocusEl',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UseColorPickerProps
extends Omit<Optional<Omit<colorPicker.Context, 'value'>, 'id'>, 'open.controlled'> {
extends Optional<
Omit<colorPicker.Context, 'value' | 'open.controlled' | 'dir' | 'getRootNode'>,
'id'
> {
/**
* The initial value of the color picker.
*/
Expand Down
2 changes: 0 additions & 2 deletions frameworks/react/src/components/combobox/combobox-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ const ComboboxImpl = <T extends CollectionItem>(
'autoFocus',
'closeOnSelect',
'defaultValue',
'dir',
'disabled',
'dismissable',
'form',
'getRootNode',
'getSelectionValue',
'highlightedValue',
'id',
Expand Down
5 changes: 4 additions & 1 deletion frameworks/react/src/components/combobox/use-combobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { useEvent } from '../../utils/use-event'

export interface UseComboboxProps<T extends CollectionItem>
extends CollectionOptions<T>,
Omit<Optional<combobox.Context<T>, 'id'>, 'collection' | 'open.controlled'> {
Optional<
Omit<combobox.Context<T>, 'dir' | 'getRootNode' | 'collection' | 'open.controlled'>,
'id'
> {
/**
* the initial value of the combobox
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ export const DatePickerRoot = forwardRef<HTMLDivElement, DatePickerRootProps>((p
const [useDatePickerProps, localProps] = createSplitProps<UseDatePickerProps>()(datePickerProps, [
'closeOnSelect',
'defaultValue',
'dir',
'disabled',
'fixedWeeks',
'focusedValue',
'format',
'getRootNode',
'id',
'ids',
'isDateUnavailable',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface UseDatePickerProps
extends Optional<
Omit<
datePicker.Context,
'value' | 'min' | 'max' | 'parse' | 'focusedValue' | 'open.controlled'
'dir' | 'getRootNode' | 'value' | 'min' | 'max' | 'parse' | 'focusedValue' | 'open.controlled'
>,
'id'
> {
Expand Down
4 changes: 2 additions & 2 deletions frameworks/react/src/components/editable/editable-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export const EditableRoot = forwardRef<HTMLDivElement, EditableRootProps>((props
'activationMode',
'autoResize',
'defaultValue',
'dir',

'disabled',
'finalFocusEl',
'form',
'getRootNode',

'id',
'ids',
'invalid',
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/editable/use-editable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UseEditableProps extends Optional<editable.Context, 'id'> {
export interface UseEditableProps
extends Optional<Omit<editable.Context, 'dir' | 'getRootNode'>, 'id'> {
/**
* The initial value of the editable.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const FileUploadRoot = forwardRef<HTMLDivElement, FileUploadRootProps>((p
'accept',
'allowDrop',
'capture',
'dir',

'directory',
'disabled',
'getRootNode',

'id',
'ids',
'locale',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UseFileUploadProps extends Optional<fileUpload.Context, 'id'> {}
export interface UseFileUploadProps
extends Optional<Omit<fileUpload.Context, 'dir' | 'getRootNode'>, 'id'> {}
export interface UseFileUploadReturn extends fileUpload.Api<PropTypes> {}

export const useFileUpload = (props: UseFileUploadProps = {}): UseFileUploadReturn => {
Expand Down
2 changes: 0 additions & 2 deletions frameworks/react/src/components/menu/menu-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export const MenuRoot = (props: MenuRootProps) => {
'anchorPoint',
'aria-label',
'closeOnSelect',
'dir',
'getRootNode',
'highlightedValue',
'id',
'ids',
Expand Down
2 changes: 1 addition & 1 deletion frameworks/react/src/components/menu/tests/menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('Menu', () => {
})

it('should accept a custom placement', async () => {
render(<ComponentUnderTest dir="rtl" positioning={{ placement: 'left-start' }} />)
render(<ComponentUnderTest positioning={{ placement: 'left-start' }} />)

const button = screen.getByRole('button', { name: /open menu/i })
await user.click(button)
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/menu/use-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UseMenuProps extends Omit<Optional<menu.Context, 'id'>, 'open.controlled'> {}
export interface UseMenuProps
extends Optional<Omit<menu.Context, 'open.controlled' | 'dir' | 'getRootNode'>, 'id'> {}
export interface UseMenuReturn {
machine: menu.Service
api: menu.Api<PropTypes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export const NumberInputRoot = forwardRef<HTMLDivElement, NumberInputRootProps>(
'allowOverflow',
'clampValueOnBlur',
'defaultValue',
'dir',

'disabled',
'focusInputOnChange',
'form',
'formatOptions',
'getRootNode',

'id',
'ids',
'inputMode',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UseNumberInputProps extends Optional<numberInput.Context, 'id'> {
export interface UseNumberInputProps
extends Optional<Omit<numberInput.Context, 'dir' | 'getRootNode'>, 'id'> {
/**
* The initial value of the number input.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export const Customized = () => (
count={5000}
pageSize={20}
siblingCount={3}
dir="ltr"
translations={{
nextTriggerLabel: 'Next',
prevTriggerLabel: 'Prev',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export const PaginationRoot = forwardRef<HTMLElement, PaginationRootProps>((prop
const [paginationProps, localProps] = createSplitProps<UsePaginationProps>()(props, [
'count',
'defaultPage',
'dir',
'getRootNode',

'id',
'ids',
'onPageChange',
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/pagination/use-pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UsePaginationProps extends Optional<pagination.Context, 'id'> {
export interface UsePaginationProps
extends Optional<Omit<pagination.Context, 'dir' | 'getRootNode'>, 'id'> {
/**
* The initial page of the pagination.
*/
Expand Down
4 changes: 2 additions & 2 deletions frameworks/react/src/components/pin-input/pin-input-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const PinInputRoot = forwardRef<HTMLDivElement, PinInputRootProps>((props
'autoFocus',
'blurOnComplete',
'defaultValue',
'dir',

'disabled',
'form',
'getRootNode',

'id',
'ids',
'invalid',
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/pin-input/use-pin-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'
import { useEvent } from '../../utils/use-event'

export interface UsePinInputProps extends Optional<pinInput.Context, 'id'> {
export interface UsePinInputProps
extends Optional<Omit<pinInput.Context, 'dir' | 'getRootNode'>, 'id'> {
/**
* The initial value of the pin input.
*/
Expand Down
3 changes: 1 addition & 2 deletions frameworks/react/src/components/progress/progress-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export interface ProgressRootProps extends Assign<HTMLArkProps<'div'>, UseProgre
export const ProgressRoot = forwardRef<HTMLDivElement, ProgressRootProps>((props, ref) => {
const [progressProps, localProps] = createSplitProps<UseProgressProps>()(props, [
'defaultValue',
'dir',
'getRootNode',

'id',
'max',
'min',
Expand Down
3 changes: 2 additions & 1 deletion frameworks/react/src/components/progress/use-progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { useId } from 'react'
import { useEnvironmentContext } from '../../providers/environment'
import type { Optional } from '../../types'

export interface UseProgressProps extends Optional<progress.Context, 'id'> {
export interface UseProgressProps
extends Optional<Omit<progress.Context, 'dir' | 'getRootNode'>, 'id'> {
/**
* The initial value of the progress.
*/
Expand Down
Loading

0 comments on commit 9ee7db7

Please sign in to comment.