1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/components/alphaPicker/AlphaPickerComponent.tsx
Matthew Haughton a337f7af2b
Update to typescript-eslint v8 (#6372)
* Update typescript-eslint to v8

* Disable @typescript-eslint/prefer-optional-chain

This rule now requires type information which is not currently enabled for
the Typescript ESLint checks.

* Remove unused vars

* Disable no-empty-function for line using updated config

* Disable rule for lines that violate updated typescript-eslint rules

* Use void operator to fix no-floating-promises

Co-authored-by: Bill Thornton <thornbill@users.noreply.github.com>

* Use void operator to fix no-floating-promises

Co-authored-by: Bill Thornton <thornbill@users.noreply.github.com>

---------

Co-authored-by: Bill Thornton <thornbill@users.noreply.github.com>
2025-01-13 13:16:44 -05:00

37 lines
1.1 KiB
TypeScript

import React, { FunctionComponent, useEffect, useRef, useState } from 'react';
import AlphaPicker from './alphaPicker';
type AlphaPickerProps = {
onAlphaPicked?: (e: Event) => void
};
// React compatibility wrapper component for alphaPicker.js
// eslint-disable-next-line no-empty-function
const AlphaPickerComponent: FunctionComponent<AlphaPickerProps> = ({ onAlphaPicked = () => {} }: AlphaPickerProps) => {
const [ alphaPicker, setAlphaPicker ] = useState<AlphaPicker>();
const element = useRef<HTMLDivElement>(null);
useEffect(() => {
setAlphaPicker(new AlphaPicker({
element: element.current,
mode: 'keyboard'
}));
element.current?.addEventListener('alphavalueclicked', onAlphaPicked);
return () => {
alphaPicker?.destroy();
};
// eslint-disable-next-line react-hooks/exhaustive-deps -- Disabled for wrapper components
}, []);
return (
<div
ref={element}
className='alphaPicker align-items-center'
/>
);
};
export default AlphaPickerComponent;