Skip to content

Commit

Permalink
fix(typings): update types to support ref
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed Dec 10, 2023
1 parent 49ef16a commit 444f60f
Show file tree
Hide file tree
Showing 175 changed files with 484 additions and 419 deletions.
7 changes: 1 addition & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ export {
StrictBreadcrumbSectionProps,
} from './dist/commonjs/collections/Breadcrumb/BreadcrumbSection'

export {
default as Form,
FormComponent,
FormProps,
StrictFormProps,
} from './dist/commonjs/collections/Form'
export { default as Form, FormProps, StrictFormProps } from './dist/commonjs/collections/Form'
export {
default as FormButton,
FormButtonProps,
Expand Down
6 changes: 3 additions & 3 deletions src/addons/Confirm/Confirm.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'

import { SemanticShorthandItem } from '../../generic'
import { ForwardRefComponent, SemanticShorthandItem } from '../../generic'
import { ButtonProps } from '../../elements/Button'
import { StrictModalProps } from '../../modules/Modal'
import { ModalContentProps } from '../../modules/Modal/ModalContent'
Expand Down Expand Up @@ -42,10 +42,10 @@ export interface StrictConfirmProps extends StrictModalProps {
/** Whether or not the modal is visible. */
open?: boolean

/** A confirm can vary in size. */
/** A Confirm can vary in size. */
size?: 'mini' | 'tiny' | 'small' | 'large' | 'fullscreen'
}

declare const Confirm: React.ComponentClass<ConfirmProps>
declare const Confirm: ForwardRefComponent<ConfirmProps, HTMLDivElement>

export default Confirm
6 changes: 3 additions & 3 deletions src/addons/Pagination/Pagination.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'

import { SemanticShorthandItem } from '../../generic'
import { ForwardRefComponent, SemanticShorthandItem } from '../../generic'
import PaginationItem, { PaginationItemProps } from './PaginationItem'

export interface PaginationProps extends StrictPaginationProps {
Expand Down Expand Up @@ -56,8 +56,8 @@ export interface StrictPaginationProps {
totalPages: number | string
}

declare class Pagination extends React.Component<PaginationProps> {
static Item: typeof PaginationItem
declare const Pagination: ForwardRefComponent<PaginationProps, HTMLDivElement> & {
Item: typeof PaginationItem
}

export default Pagination
3 changes: 2 additions & 1 deletion src/addons/Pagination/PaginationItem.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react'
import { ForwardRefComponent } from '../../generic'

export interface PaginationItemProps extends StrictPaginationItemProps {
[key: string]: any
Expand Down Expand Up @@ -31,6 +32,6 @@ export interface StrictPaginationItemProps {
type?: 'ellipsisItem' | 'firstItem' | 'prevItem' | 'pageItem' | 'nextItem' | 'lastItem'
}

declare class PaginationItem extends React.Component<PaginationItemProps> {}
declare const PaginationItem: ForwardRefComponent<PaginationItemProps, HTMLDivElement>

export default PaginationItem
4 changes: 2 additions & 2 deletions src/addons/Portal/Portal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export interface StrictPortalProps {
triggerRef?: React.Ref<any>
}

declare class Portal extends React.Component<PortalProps> {
static Inner: typeof PortalInner
declare const Portal: React.FC<PortalProps> & {
Inner: typeof PortalInner
}

export default Portal
2 changes: 1 addition & 1 deletion src/addons/Portal/PortalInner.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export interface StrictPortalInnerProps {
onUnmount?: (nothing: null, data: PortalInnerProps) => void
}

declare class PortalInner extends React.Component<PortalInnerProps> {}
declare const PortalInner: React.FC<PortalInnerProps>

export default PortalInner
4 changes: 2 additions & 2 deletions src/addons/Radio/Radio.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react'
import { ForwardRefComponent } from '../../generic'
import { StrictCheckboxProps } from '../../modules/Checkbox'

export interface RadioProps extends StrictRadioProps {
Expand All @@ -16,6 +16,6 @@ export interface StrictRadioProps extends StrictCheckboxProps {
type?: 'checkbox' | 'radio'
}

declare const Radio: React.FC<RadioProps>
declare const Radio: ForwardRefComponent<RadioProps, HTMLInputElement>

export default Radio
7 changes: 2 additions & 5 deletions src/addons/Select/Select.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as React from 'react'

import { StrictDropdownProps } from '../../modules/Dropdown'
import DropdownDivider from '../../modules/Dropdown/DropdownDivider'
import DropdownHeader from '../../modules/Dropdown/DropdownHeader'
import DropdownItem, { DropdownItemProps } from '../../modules/Dropdown/DropdownItem'
import DropdownMenu from '../../modules/Dropdown/DropdownMenu'
import { ForwardRefComponent } from '../../generic'

export interface SelectProps extends StrictSelectProps {
[key: string]: any
Expand All @@ -15,13 +14,11 @@ export interface StrictSelectProps extends StrictDropdownProps {
options: DropdownItemProps[]
}

interface SelectComponent extends React.FC<SelectProps> {
declare const Select: ForwardRefComponent<SelectProps, HTMLDivElement> & {
Divider: typeof DropdownDivider
Header: typeof DropdownHeader
Item: typeof DropdownItem
Menu: typeof DropdownMenu
}

declare const Select: SelectComponent

export default Select
5 changes: 2 additions & 3 deletions src/addons/TextArea/TextArea.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react'
import { ForwardRefComponent } from '../../generic'

export interface TextAreaProps extends StrictTextAreaProps {
[key: string]: any
Expand Down Expand Up @@ -31,8 +32,6 @@ export interface StrictTextAreaProps {
value?: number | string
}

declare class TextArea extends React.Component<TextAreaProps> {
focus: () => void
}
declare const TextArea: ForwardRefComponent<TextAreaProps, HTMLTextAreaElement>

export default TextArea
5 changes: 2 additions & 3 deletions src/collections/Breadcrumb/Breadcrumb.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react'

import {
ForwardRefComponent,
SemanticShorthandCollection,
SemanticShorthandContent,
SemanticShorthandItem,
Expand Down Expand Up @@ -38,11 +39,9 @@ export interface StrictBreadcrumbProps {
size?: 'mini' | 'tiny' | 'small' | 'large' | 'big' | 'huge' | 'massive'
}

interface BreadcrumbComponent extends React.ComponentClass<BreadcrumbProps> {
declare const Breadcrumb: ForwardRefComponent<BreadcrumbProps, HTMLDivElement> & {
Divider: typeof BreadcrumbDivider
Section: typeof BreadcrumbSection
}

declare const Breadcrumb: BreadcrumbComponent

export default Breadcrumb
4 changes: 2 additions & 2 deletions src/collections/Breadcrumb/BreadcrumbDivider.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'

import { SemanticShorthandContent, SemanticShorthandItem } from '../../generic'
import { ForwardRefComponent, SemanticShorthandContent, SemanticShorthandItem } from '../../generic'
import { IconProps } from '../../elements/Icon'

export interface BreadcrumbDividerProps extends StrictBreadcrumbDividerProps {
Expand All @@ -24,6 +24,6 @@ export interface StrictBreadcrumbDividerProps {
icon?: SemanticShorthandItem<IconProps>
}

declare const BreadcrumbDivider: React.FC<BreadcrumbDividerProps>
declare const BreadcrumbDivider: ForwardRefComponent<BreadcrumbDividerProps, HTMLDivElement>

export default BreadcrumbDivider
4 changes: 2 additions & 2 deletions src/collections/Breadcrumb/BreadcrumbSection.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { SemanticShorthandContent } from '../../generic'
import { ForwardRefComponent, SemanticShorthandContent } from '../../generic'

export interface BreadcrumbSectionProps extends StrictBreadcrumbSectionProps {
[key: string]: any
Expand Down Expand Up @@ -37,6 +37,6 @@ export interface StrictBreadcrumbSectionProps {
onClick?: (event: React.MouseEvent<HTMLAnchorElement>, data: BreadcrumbSectionProps) => void
}

declare const BreadcrumbSection: React.ComponentClass<BreadcrumbSectionProps>
declare const BreadcrumbSection: ForwardRefComponent<BreadcrumbSectionProps, HTMLDivElement>

export default BreadcrumbSection
5 changes: 2 additions & 3 deletions src/collections/Form/Form.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import FormInput from './FormInput'
import FormRadio from './FormRadio'
import FormSelect from './FormSelect'
import FormTextArea from './FormTextArea'
import { ForwardRefComponent } from '../../generic'

export interface FormProps extends StrictFormProps {
[key: string]: any
Expand Down Expand Up @@ -58,7 +59,7 @@ export interface StrictFormProps {
widths?: 'equal'
}

export interface FormComponent extends React.FC<FormProps> {
declare const Form: ForwardRefComponent<FormProps, HTMLFormElement> & {
Field: typeof FormField
Button: typeof FormButton
Checkbox: typeof FormCheckbox
Expand All @@ -70,6 +71,4 @@ export interface FormComponent extends React.FC<FormProps> {
TextArea: typeof FormTextArea
}

declare const Form: FormComponent

export default Form
6 changes: 2 additions & 4 deletions src/collections/Form/FormButton.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as React from 'react'

import { SemanticShorthandItem } from '../../generic'
import { ForwardRefComponent, SemanticShorthandItem } from '../../generic'
import { StrictButtonProps } from '../../elements/Button'
import { LabelProps } from '../../elements/Label'
import { StrictFormFieldProps } from './FormField'
Expand All @@ -22,6 +20,6 @@ export interface StrictFormButtonProps
label?: SemanticShorthandItem<LabelProps>
}

declare const FormButton: React.FC<FormButtonProps>
declare const FormButton: ForwardRefComponent<FormButtonProps, HTMLButtonElement>

export default FormButton
5 changes: 2 additions & 3 deletions src/collections/Form/FormCheckbox.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react'

import { StrictCheckboxProps } from '../../modules/Checkbox'
import { ForwardRefComponent } from '../../generic'
import { StrictFormFieldProps } from './FormField'

export interface FormCheckboxProps extends StrictFormCheckboxProps {
Expand All @@ -18,6 +17,6 @@ export interface StrictFormCheckboxProps extends StrictFormFieldProps, StrictChe
type?: 'checkbox' | 'radio'
}

declare const FormCheckbox: React.FC<FormCheckboxProps>
declare const FormCheckbox: ForwardRefComponent<FormCheckboxProps, HTMLInputElement>

export default FormCheckbox
5 changes: 2 additions & 3 deletions src/collections/Form/FormDropdown.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react'

import { StrictDropdownProps } from '../../modules/Dropdown'
import { ForwardRefComponent } from '../../generic'
import { StrictFormFieldProps } from './FormField'

export interface FormDropdownProps extends StrictFormDropdownProps {
Expand All @@ -18,6 +17,6 @@ export interface StrictFormDropdownProps extends StrictFormFieldProps, StrictDro
error?: any
}

declare const FormDropdown: React.FC<FormDropdownProps>
declare const FormDropdown: ForwardRefComponent<FormDropdownProps, HTMLDivElement>

export default FormDropdown
3 changes: 2 additions & 1 deletion src/collections/Form/FormField.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react'

import {
ForwardRefComponent,
HtmlLabelProps,
SemanticShorthandContent,
SemanticShorthandItem,
Expand Down Expand Up @@ -57,6 +58,6 @@ export interface StrictFormFieldProps {
width?: SemanticWIDTHS
}

declare const FormField: React.FC<FormFieldProps>
declare const FormField: ForwardRefComponent<FormFieldProps, HTMLElement>

export default FormField
4 changes: 2 additions & 2 deletions src/collections/Form/FormGroup.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { SemanticWIDTHS } from '../../generic'
import { ForwardRefComponent, SemanticWIDTHS } from '../../generic'

export interface FormGroupProps extends StrictFormGroupProps {
[key: string]: any
Expand Down Expand Up @@ -34,6 +34,6 @@ export interface StrictFormGroupProps {
widths?: SemanticWIDTHS | 'equal'
}

declare const FormGroup: React.FC<FormGroupProps>
declare const FormGroup: ForwardRefComponent<FormGroupProps, HTMLInputElement>

export default FormGroup
6 changes: 2 additions & 4 deletions src/collections/Form/FormInput.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as React from 'react'

import { SemanticShorthandItem } from '../../generic'
import { ForwardRefComponent, SemanticShorthandItem } from '../../generic'
import { LabelProps } from '../../elements/Label'
import { StrictInputProps } from '../../elements/Input'
import { StrictFormFieldProps } from './FormField'
Expand All @@ -25,6 +23,6 @@ export interface StrictFormInputProps
label?: SemanticShorthandItem<LabelProps>
}

declare const FormInput: React.FC<FormInputProps>
declare const FormInput: ForwardRefComponent<FormInputProps, HTMLInputElement>

export default FormInput
5 changes: 2 additions & 3 deletions src/collections/Form/FormRadio.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react'

import { StrictRadioProps } from '../../addons/Radio'
import { ForwardRefComponent } from '../../generic'
import { StrictFormFieldProps } from './FormField'

export interface FormRadioProps extends StrictFormRadioProps {
Expand All @@ -18,6 +17,6 @@ export interface StrictFormRadioProps extends StrictFormFieldProps, StrictRadioP
type?: 'checkbox' | 'radio'
}

declare const FormRadio: React.FC<FormRadioProps>
declare const FormRadio: ForwardRefComponent<FormRadioProps, HTMLInputElement>

export default FormRadio
7 changes: 2 additions & 5 deletions src/collections/Form/FormSelect.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import * as React from 'react'

import { StrictSelectProps } from '../../addons/Select'
import { DropdownItemProps } from '../../modules/Dropdown/DropdownItem'
import { StrictFormFieldProps } from './FormField'
import { SemanticShorthandItem } from '../../generic'
import { LabelProps } from '../../elements/Label'
import { ForwardRefComponent } from '../../generic'

export interface FormSelectProps extends StrictFormSelectProps {
[key: string]: any
Expand All @@ -24,6 +21,6 @@ export interface StrictFormSelectProps extends StrictFormFieldProps, StrictSelec
options: DropdownItemProps[]
}

declare const FormSelect: React.FC<FormSelectProps>
declare const FormSelect: ForwardRefComponent<FormSelectProps, HTMLDivElement>

export default FormSelect
5 changes: 2 additions & 3 deletions src/collections/Form/FormTextArea.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react'

import { StrictTextAreaProps } from '../../addons/TextArea'
import { ForwardRefComponent } from '../../generic'
import { StrictFormFieldProps } from './FormField'

export interface FormTextAreaProps extends StrictFormTextAreaProps {
Expand All @@ -15,6 +14,6 @@ export interface StrictFormTextAreaProps extends StrictFormFieldProps, StrictTex
control?: any
}

declare const FormTextArea: React.FC<FormTextAreaProps>
declare const FormTextArea: ForwardRefComponent<FormTextAreaProps, HTMLTextAreaElement>

export default FormTextArea
2 changes: 1 addition & 1 deletion src/collections/Form/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default, FormComponent, FormProps, StrictFormProps } from './Form'
export { default, FormProps, StrictFormProps } from './Form'
11 changes: 7 additions & 4 deletions src/collections/Grid/Grid.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as React from 'react'

import { SemanticTEXTALIGNMENTS, SemanticVERTICALALIGNMENTS, SemanticWIDTHS } from '../../generic'
import {
ForwardRefComponent,
SemanticTEXTALIGNMENTS,
SemanticVERTICALALIGNMENTS,
SemanticWIDTHS,
} from '../../generic'
import GridColumn from './GridColumn'
import GridRow from './GridRow'

Expand Down Expand Up @@ -70,11 +75,9 @@ export interface StrictGridProps {
verticalAlign?: SemanticVERTICALALIGNMENTS
}

interface GridComponent extends React.FC<GridProps> {
declare const Grid: ForwardRefComponent<GridProps, HTMLDivElement> & {
Column: typeof GridColumn
Row: typeof GridRow
}

declare const Grid: GridComponent

export default Grid
Loading

0 comments on commit 444f60f

Please sign in to comment.