-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: convert events to concrete event classes
- Loading branch information
1 parent
fe44902
commit a41d080
Showing
12 changed files
with
327 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const PIN_INPUT_CELL_FILLED_TYPE = 'cell-filled'; | ||
export const PIN_INPUT_CELL_CLEARED_TYPE = 'cell-cleared'; | ||
export const PIN_INPUT_CELL_CLEARED_ALL_TYPE = 'cell-cleared-all-with-meta-key'; | ||
export const PIN_INPUT_CELL_ARROW_KEY_PRESSED_TYPE = 'arrow-key-pressed'; | ||
export const PIN_INPUT_CELL_OVERFLOW_VALUE_TYPE = 'overflow-value'; |
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,122 @@ | ||
import { | ||
PIN_INPUT_CELL_ARROW_KEY_PRESSED_TYPE, | ||
PIN_INPUT_CELL_CLEARED_ALL_TYPE, | ||
PIN_INPUT_CELL_CLEARED_TYPE, | ||
PIN_INPUT_CELL_FILLED_TYPE, | ||
PIN_INPUT_CELL_OVERFLOW_VALUE_TYPE, | ||
} from './constants'; | ||
import { ValueChangedEventParams } from './types'; | ||
|
||
export class PinInputCellFilled extends Event { | ||
public message: string; | ||
public details: ValueChangedEventParams; | ||
|
||
constructor( | ||
message: string, | ||
details: ValueChangedEventParams, | ||
eventInitDict: EventInit = {}, | ||
) { | ||
const _eventInitDict = { | ||
bubbles: true, | ||
composed: false, | ||
...eventInitDict, | ||
}; | ||
const type = PIN_INPUT_CELL_FILLED_TYPE; | ||
super(type, _eventInitDict); | ||
|
||
this.details = details; | ||
this.message = message; | ||
} | ||
} | ||
|
||
export class PinInputCellCleared extends Event { | ||
public message: string; | ||
public details: ValueChangedEventParams; | ||
|
||
constructor( | ||
message: string, | ||
details: ValueChangedEventParams, | ||
eventInitDict: EventInit = {}, | ||
) { | ||
const _eventInitDict = { | ||
bubbles: true, | ||
composed: false, | ||
...eventInitDict, | ||
}; | ||
|
||
const type = PIN_INPUT_CELL_CLEARED_TYPE; | ||
super(type, _eventInitDict); | ||
|
||
this.details = details; | ||
this.message = message; | ||
} | ||
} | ||
|
||
export class PinInputCellClearedAll extends Event { | ||
public message: string; | ||
public details: ValueChangedEventParams; | ||
|
||
constructor( | ||
message: string, | ||
details: ValueChangedEventParams, | ||
eventInitDict: EventInit = {}, | ||
) { | ||
const _eventInitDict = { | ||
bubbles: true, | ||
composed: false, | ||
...eventInitDict, | ||
}; | ||
|
||
const type = PIN_INPUT_CELL_CLEARED_ALL_TYPE; | ||
super(type, _eventInitDict); | ||
|
||
this.details = details; | ||
this.message = message; | ||
} | ||
} | ||
|
||
export class PinInputCellArrowKeyPressed<T = 'left' | 'right'> extends Event { | ||
public message: string; | ||
public details: ValueChangedEventParams<T>; | ||
|
||
constructor( | ||
message: string, | ||
details: ValueChangedEventParams<T>, | ||
eventInitDict: EventInit = {}, | ||
) { | ||
const _eventInitDict = { | ||
bubbles: true, | ||
composed: false, | ||
...eventInitDict, | ||
}; | ||
|
||
const type = PIN_INPUT_CELL_ARROW_KEY_PRESSED_TYPE; | ||
super(type, _eventInitDict); | ||
|
||
this.details = details; | ||
this.message = message; | ||
} | ||
} | ||
|
||
export class PinInputCellOverflowValue extends Event { | ||
public message: string; | ||
public details: ValueChangedEventParams; | ||
|
||
constructor( | ||
message: string, | ||
details: ValueChangedEventParams, | ||
eventInitDict: EventInit = {}, | ||
) { | ||
const _eventInitDict = { | ||
bubbles: true, | ||
composed: false, | ||
...eventInitDict, | ||
}; | ||
|
||
const type = PIN_INPUT_CELL_OVERFLOW_VALUE_TYPE; | ||
super(type, _eventInitDict); | ||
|
||
this.details = details; | ||
this.message = message; | ||
} | ||
} |
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 @@ | ||
export const PIN_INPUT_FILLED_TYPE = 'input-filled'; |
Oops, something went wrong.