-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui-component): Add event listeners on table level (#13923)
- Loading branch information
Showing
14 changed files
with
323 additions
and
74 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
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
28 changes: 18 additions & 10 deletions
28
frontend/libs/studio-components/src/components/StudioInputTable/Cell/CellTextarea.tsx
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
30 changes: 20 additions & 10 deletions
30
frontend/libs/studio-components/src/components/StudioInputTable/Cell/CellTextfield.tsx
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
31 changes: 31 additions & 0 deletions
31
frontend/libs/studio-components/src/components/StudioInputTable/Cell/useEventProps.ts
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,31 @@ | ||
import type { HTMLAttributes } from 'react'; | ||
import { useMemo } from 'react'; | ||
import { useStudioInputTableContext } from '../StudioInputTableContext'; | ||
import type { HTMLCellInputElement } from '../types/HTMLCellInputElement'; | ||
import type { EventProps } from '../types/EventProps'; | ||
|
||
export function useEventProps<Element extends HTMLCellInputElement>({ | ||
onBlur, | ||
onFocus, | ||
onChange, | ||
}: Partial<HTMLAttributes<Element>>): EventProps<Element> { | ||
const { onChangeAny, onBlurAny, onFocusAny } = useStudioInputTableContext<Element>(); | ||
|
||
return useMemo<EventProps<Element>>( | ||
() => ({ | ||
onChange: (event) => { | ||
onChange?.(event); | ||
onChangeAny?.(event); | ||
}, | ||
onFocus: (event) => { | ||
onFocus?.(event); | ||
onFocusAny?.(event); | ||
}, | ||
onBlur: (event) => { | ||
onBlur?.(event); | ||
onBlurAny?.(event); | ||
}, | ||
}), | ||
[onChange, onFocus, onBlur, onChangeAny, onBlurAny, onFocusAny], | ||
); | ||
} |
Oops, something went wrong.