Skip to content

Commit

Permalink
chore: fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ht-lovrozagar committed Aug 28, 2024
1 parent 6d17ef2 commit 54783ac
Show file tree
Hide file tree
Showing 86 changed files with 69 additions and 205 deletions.
5 changes: 5 additions & 0 deletions .todo
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@

-refactor: collapsible to use css height: calc-size(auto) when better browser support
-also see what can be done with starting style and and transition behaviour when better browser support

- fix: react ref types in hooks
- refactor: make prop naming more consistend, modal/isModal, open/isOpen...

- refactor: remove barrell imports to better support treeshaking with different bundlers/frameworks

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions src/components/_shared/components/field/field/field.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// biome-ignore lint/style/useImportType: react import needed here
import React from 'react'
import type React from 'react'

const ChevronDownIcon = (props: React.ComponentPropsWithRef<'svg'>) => {
return (
Expand Down
3 changes: 1 addition & 2 deletions src/components/_shared/components/icons/cross-small-icon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// biome-ignore lint/style/useImportType: react import needed here
import React from 'react'
import type React from 'react'

const CrossSmallIcon = (props: React.ComponentPropsWithRef<'svg'>) => {
return (
Expand Down
3 changes: 1 addition & 2 deletions src/components/_shared/components/icons/eye-open-icon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// biome-ignore lint/style/useImportType: react import needed here
import React from 'react'
import type React from 'react'

const EyeOpenIcon = (props: React.ComponentPropsWithRef<'svg'>) => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cx } from '@renderui/utils'
import React from 'react'

import { Text, type TextProps } from '@/components/text'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cx } from '@renderui/utils'
import React from 'react'

import { Flex, type FlexProps } from '@/components/flex'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cx } from '@renderui/utils'
import React from 'react'

import { Grid, type GridProps } from '@/components/grid'

Expand Down
10 changes: 5 additions & 5 deletions src/components/_shared/hooks/use-aria-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { mergeProps } from '@renderui/utils'
import React from 'react'
import {
useFocus,
useFocusRing,
useHover,
useLongPress,
usePress,
type FocusProps,
type FocusRingProps,
type HoverProps,
type LongPressProps,
type PressEvent,
type PressHookProps,
useFocus,
useFocusRing,
useHover,
useLongPress,
usePress,
} from 'react-aria'

import type { UseAriaHandlersProps } from '@/components/_shared/types/aria'
Expand Down
5 changes: 2 additions & 3 deletions src/components/_shared/hooks/use-controllable-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import { useFreshRef } from '@/components/_shared/hooks/use-fresh-ref'
import {
type UseControllableStateProps,
useUncontrolledState,
type UseControllableStateProps,
} from '@/components/_shared/hooks/use-uncontrolled-state'
import { isFunction } from '@renderui/utils'
import { noop } from '@renderui/utils'
import { isFunction, noop } from '@renderui/utils'
import React from 'react'

type SetStateFunction<T> = (previousState?: T) => T
Expand Down
28 changes: 28 additions & 0 deletions src/components/_shared/hooks/use-is-online.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use client'

import { useSyncExternalStore } from 'react'

function getClientSnapshot() {
return navigator.onLine
}

function getServerSnapshot() {
return true
}

function subscribe(callback: () => void) {
window.addEventListener('online', callback)
window.addEventListener('offline', callback)
return () => {
window.removeEventListener('online', callback)
window.removeEventListener('offline', callback)
}
}

function useIsOnline() {
const isOnline = useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot)

return isOnline
}

export { useIsOnline }
1 change: 0 additions & 1 deletion src/components/accordion/components/accordion-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { AccordionContent as AccordionContentPrimitive } from '@radix-ui/react-accordion'
import { cn, getAnimationStyleVariables, getOptionalObject, polymorphic } from '@renderui/utils'
import React from 'react'

import {
DEFAULT_ACCORDION_CONTENT_CHILDREN_CONTAINER_CLASSNAME,
Expand Down
1 change: 0 additions & 1 deletion src/components/accordion/components/accordion-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { AccordionItem as AccordionItemPrimitive } from '@radix-ui/react-accordion'
import { cn } from '@renderui/utils'
import React from 'react'

import { DEFAULT_ACCORDION_ITEM_CLASSNAME } from '@/components/accordion/constants/constants'
import type { AccordionItemProps } from '@/components/accordion/types/accordion-item'
Expand Down
1 change: 0 additions & 1 deletion src/components/accordion/components/accordion-trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
AccordionTrigger as AccordionTriggerPrimitive,
} from '@radix-ui/react-accordion'
import { cn, getOptionalObject } from '@renderui/utils'
import React from 'react'

import { ChevronDownIcon } from '@/components/_shared/components/icons/chevron-down-icon'
import {
Expand Down
1 change: 0 additions & 1 deletion src/components/accordion/components/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { Accordion as AccordionPrimitive } from '@radix-ui/react-accordion'
import { cn } from '@renderui/utils'
import React from 'react'

import type { AccordionProps } from '@/components/accordion/types/accordion'

Expand Down
1 change: 0 additions & 1 deletion src/components/aspect-ratio/components/aspect-ratio.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { polymorphic } from '@renderui/utils'
import React from 'react'

import type { AspectRatioProps } from '@/components/aspect-ratio/types/aspect-ratio'
import { getMergedStyles } from '@/components/aspect-ratio/utils/get-merged-styles'
Expand Down
1 change: 0 additions & 1 deletion src/components/box/components/box.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { polymorphic } from '@renderui/utils'
import React from 'react'

import type { BoxProps } from '@/components/box/types/box'
import { getMergedClassName } from '@/components/box/utils/get-merged-class-name'
Expand Down
1 change: 0 additions & 1 deletion src/components/card/components/card-body.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cn, polymorphic } from '@renderui/utils'
import React from 'react'

import { DEFAULT_CARD_BODY_CLASSNAME } from '@/components/card/constants/constants'
import type { CardBodyProps } from '@/components/card/types/card-body'
Expand Down
1 change: 0 additions & 1 deletion src/components/card/components/card-header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cn, getOptionalObject, polymorphic } from '@renderui/utils'
import React from 'react'

import {
DEFAULT_CARD_HEADER_CHILDREN_CLASSNAME,
Expand Down
1 change: 0 additions & 1 deletion src/components/card/components/card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cn, polymorphic } from '@renderui/utils'
import React from 'react'

import { cardClasses } from '@/components/card/classes/card-classes'
import type { CardProps } from '@/components/card/types/card'
Expand Down
1 change: 0 additions & 1 deletion src/components/collapsible/components/collapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import type { CollapsibleProps } from '@/components/collapsible/types/collapsible'
import { Collapsible as CollapsiblePrimitive } from '@radix-ui/react-collapsible'
import { cn } from '@renderui/utils'
import React from 'react'

const Collapsible = (props: CollapsibleProps) => {
const { className, ...restProps } = props
Expand Down
1 change: 0 additions & 1 deletion src/components/combobox/components/combobox-input.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client'

import { cn } from '@renderui/utils'
import React from 'react'

import type { ComboboxInputProps } from '@/components/combobox/types/combobox-input'
import { CommandInput } from '@/components/command/components/command-input'
Expand Down
1 change: 0 additions & 1 deletion src/components/command/components/command-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cx } from '@renderui/utils'
import React from 'react'

import { Command } from '@/components/command/components/command'
import {
Expand Down
1 change: 0 additions & 1 deletion src/components/command/components/command-empty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { cn } from '@renderui/utils'
import { CommandEmpty as CommandEmptyPrimitive } from 'cmdk'
import React from 'react'

import { DEFAULT_COMMAND_EMPTY_CLASSNAME } from '@/components/command/constants/constants'
import type { CommandEmptyProps } from '@/components/command/types/command-empty'
Expand Down
1 change: 0 additions & 1 deletion src/components/command/components/command-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { cn } from '@renderui/utils'
import { CommandGroup as CommandGroupPrimitive } from 'cmdk'
import React from 'react'

import { DEFAULT_COMMAND_GROUP_CLASSNAME } from '@/components/command/constants/constants'
import type { CommandGroupProps } from '@/components/command/types/command-group'
Expand Down
1 change: 0 additions & 1 deletion src/components/command/components/command-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { cn, getOptionalObject, polymorphic } from '@renderui/utils'
import { CommandInput as CommandInputPrimitive } from 'cmdk'
import React from 'react'

import { MagnifyingGlassIcon } from '@/components/_shared/components/icons/magnifying-glass-icon'
import { useControllableState } from '@/components/_shared/hooks/use-controllable-state'
Expand Down
1 change: 0 additions & 1 deletion src/components/command/components/command-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { cn } from '@renderui/utils'
import { CommandItem as CommandItemPrimitive } from 'cmdk'
import React from 'react'

import { DEFAULT_COMMAND_ITEM_CLASSNAME } from '@/components/command/constants/constants'
import type { CommandItemProps } from '@/components/command/types/command-item'
Expand Down
1 change: 0 additions & 1 deletion src/components/command/components/command-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { cn } from '@renderui/utils'
import { CommandList as CommandListPrimitive } from 'cmdk'
import React from 'react'

import { DEFAULT_COMMAND_LIST_CLASSNAME } from '@/components/command/constants/constants'
import type { CommandListProps } from '@/components/command/types/command-list'
Expand Down
1 change: 0 additions & 1 deletion src/components/container/components/container.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { polymorphic } from '@renderui/utils'
import React from 'react'

import type { ContainerProps } from '@/components/container/types/container'
import { getMergedClassName } from '@/components/container/utils/get-merged-class-name'
Expand Down
1 change: 0 additions & 1 deletion src/components/dialog/components/dialog-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
DialogPortal as DialogPortalPrimitive,
} from '@radix-ui/react-dialog'
import { cn, cx, getOptionalObject } from '@renderui/utils'
import React from 'react'

import { CrossSmallIcon } from '@/components/_shared/components/icons/cross-small-icon'
import { Button } from '@/components/button/components/button'
Expand Down
1 change: 0 additions & 1 deletion src/components/dialog/components/dialog-trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { DialogTrigger as DialogTriggerPrimitive } from '@radix-ui/react-dialog'
import { cn } from '@renderui/utils'
import React from 'react'

import { Button } from '@/components/button/components/button'
import { DEFAULT_DIALOG_TRIGGER_CLASSNAME } from '@/components/dialog/constants/constants'
Expand Down
7 changes: 1 addition & 6 deletions src/components/dialog/components/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
'use client'

import { Dialog as DialogPrimitive } from '@radix-ui/react-dialog'
import React from 'react'

import type { DialogProps } from '@/components/dialog/types/dialog'

const Dialog = (props: DialogProps) => {
const { isModal, ...restProps } = props

return <DialogPrimitive modal={isModal} {...restProps} />
return <DialogPrimitive {...props} />
}

Dialog.displayName = 'Dialog'

export { Dialog }
9 changes: 1 addition & 8 deletions src/components/dialog/types/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import type { Simplify } from '@/components/_shared/types/simplify'
import type { Dialog as DialogPrimitive } from '@radix-ui/react-dialog'
import type React from 'react'

type DialogPrimitiveProps = Omit<React.ComponentProps<typeof DialogPrimitive>, 'modal'>

type DialogCustomProps = {
isModal?: boolean
}

type DialogProps = Simplify<DialogPrimitiveProps & DialogCustomProps>
type DialogProps = React.ComponentProps<typeof DialogPrimitive>

export type { DialogProps }
1 change: 0 additions & 1 deletion src/components/flex/components/flex.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { polymorphic } from '@renderui/utils'
import React from 'react'

import type { FlexProps } from '@/components/flex/types/flex'
import { getMergedClassName } from '@/components/flex/utils/get-merged-class-name'
Expand Down
Loading

0 comments on commit 54783ac

Please sign in to comment.