-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
components: InputControl to TypeScript (#33696)
* components: InputControl to TypeScript * Add back event to onChange * Fix on validate and remove todo * Remove cast and allow undefined values * Add explanatory comment for omitting prefix * Use currentTarget * components: Convert Select to TypeScript (#33784) * Convert Select to TypeScript * Stop spreading props into InputBase and add all HTML attributes for select * Remove need for `omit` * Remove unused import * Consistently use currentTarget * Require isFocused props
- Loading branch information
1 parent
10f2ec1
commit 14d80aa
Showing
18 changed files
with
469 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
// eslint-disable-next-line no-restricted-imports | ||
import type { SyntheticEvent } from 'react'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { DragProps } from '../types'; | ||
|
||
export const CHANGE = 'CHANGE'; | ||
export const COMMIT = 'COMMIT'; | ||
export const DRAG_END = 'DRAG_END'; | ||
export const DRAG_START = 'DRAG_START'; | ||
export const DRAG = 'DRAG'; | ||
export const INVALIDATE = 'INVALIDATE'; | ||
export const PRESS_DOWN = 'PRESS_DOWN'; | ||
export const PRESS_ENTER = 'PRESS_ENTER'; | ||
export const PRESS_UP = 'PRESS_UP'; | ||
export const RESET = 'RESET'; | ||
export const UPDATE = 'UPDATE'; | ||
|
||
interface EventPayload { | ||
event?: SyntheticEvent; | ||
} | ||
|
||
interface Action< Type, ExtraPayload = {} > { | ||
type: Type; | ||
payload: EventPayload & ExtraPayload; | ||
} | ||
|
||
interface ValuePayload { | ||
value: string; | ||
} | ||
|
||
export type ChangeAction = Action< typeof CHANGE, ValuePayload >; | ||
export type CommitAction = Action< typeof COMMIT, ValuePayload >; | ||
export type PressUpAction = Action< typeof PRESS_UP >; | ||
export type PressDownAction = Action< typeof PRESS_DOWN >; | ||
export type PressEnterAction = Action< typeof PRESS_ENTER >; | ||
export type DragStartAction = Action< typeof DRAG_START, DragProps >; | ||
export type DragEndAction = Action< typeof DRAG_END, DragProps >; | ||
export type DragAction = Action< typeof DRAG, DragProps >; | ||
export type ResetAction = Action< typeof RESET, Partial< ValuePayload > >; | ||
export type UpdateAction = Action< typeof UPDATE, ValuePayload >; | ||
export type InvalidateAction = Action< | ||
typeof INVALIDATE, | ||
{ error: Error | null } | ||
>; | ||
|
||
export type ChangeEventAction = | ||
| ChangeAction | ||
| ResetAction | ||
| CommitAction | ||
| UpdateAction; | ||
|
||
export type DragEventAction = DragStartAction | DragEndAction | DragAction; | ||
|
||
export type KeyEventAction = PressDownAction | PressUpAction | PressEnterAction; | ||
|
||
export type InputAction = | ||
| ChangeEventAction | ||
| KeyEventAction | ||
| DragEventAction | ||
| InvalidateAction; |
Oops, something went wrong.