Skip to content

Commit b058263

Browse files
committed
[FIX] clean code
1 parent 54bbd0b commit b058263

6 files changed

Lines changed: 13 additions & 14 deletions

File tree

packages/react-tools/src/components/Show.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { PropsWithChildren, ReactNode } from "react";
22

33
export const Show = ({ when, fallback, children }: PropsWithChildren<{ when: boolean, fallback?: ReactNode }>) => {
44
if (!when) {
5-
return fallback ? fallback : null;
5+
return fallback ? <>{fallback}</> : null;
66
}
7-
return children;
7+
return <>{children}</>;
88
}

packages/react-tools/src/hooks/api-dom/usePopover.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComponentPropsWithRef, useCallback, useMemo, useRef } from "react";
2-
import { UsePopoverProps, UsePopoverResult } from "../../models";
2+
import { HTMLAttributes, UsePopoverProps, UsePopoverResult } from "../../models";
33
import { useId, useMergedRef } from "../performance";
44
import { useSyncExternalStore } from "../state";
55

@@ -9,7 +9,7 @@ import { useSyncExternalStore } from "../state";
99
* @param {"auto"|"manual"} param.mode - popover state: __auto__ indicates that popover can be "light dismissed" by selecting outside the popover area, by contrast __manual__ popover must always be explicity hidden.
1010
* @param {(evt: ToggleEvent) => void} [param.onBeforeToggle] - function that will be executed before popover showed/hidden.
1111
* @param {(evt: ToggleEvent) => void} [param.onToggle] - function that will be executed when popover has been showed/hidden.
12-
* @returns {UsePopoverResult} reuslt
12+
* @returns {UsePopoverResult} result
1313
* Object with these properties:
1414
* - __isSupported__: boolean that indicates if Popover API is supported or not.
1515
* - __isSupported__: boolean that indicates if popover is opened or not.
@@ -48,7 +48,7 @@ function usePopover({ mode, onBeforeToggle, onToggle }: UsePopoverProps): UsePop
4848
const ref = useMergedRef(popoverRef, popoverListenerRef);
4949

5050
const Popover = useMemo(() => {
51-
return (({ children, ...rest }: ComponentPropsWithRef<"div">) => {
51+
return (({ children, ...rest }: ComponentPropsWithRef<"div"> & HTMLAttributes<"div">) => {
5252
return "showPopover" in document.body && <div id={id} ref={ref} popover={mode} {...rest}>
5353
{children}
5454
</div>

packages/react-tools/src/hooks/lifecycle/useRerender.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useReducer } from "react"
1+
import { useReducer } from "react"
22

33
/**
44
* **`useRerender`**: Hook that force a render.

packages/react-tools/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type {
2626
ExtractMiddle,
2727
ExtractTail,
2828
GeoLocationObject,
29+
HTMLAttributes,
2930
HTMLMediaControls,
3031
HTMLMediaState,
3132
LanguageBCP47Tags,

packages/react-tools/src/models/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type { UseFPSProps, UseFPSResult } from './useFPS.model';
1515
export type { UsePointerLockProps, UsePointerLockResult } from './usePointerLock.model';
1616
export type { UsePIPProps, UsePIPResult } from './usePIP.model';
1717
export type { DocumentPictureInPictureEvent, DocumentPIPOptions, UseDocumentPIPProps, UseDocumentPIPResult } from './useDocumentPIP.model';
18-
export type { UsePopoverProps, UsePopoverResult } from './usePopover.model';
18+
export type { UsePopoverProps, UsePopoverResult, HTMLAttributes } from './usePopover.model';
1919
export type { UseRemotePlaybackProps, UseRemotePlaybackResult } from './useRemotePlayback.model';
2020
export type { UseAnimationProps, UseAnimationResult } from './useAnimation.model';
2121
export type { UseAudioProps, UseAudioResult } from './useAudio.model';
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { ComponentPropsWithRef } from "react";
2-
3-
declare module 'react' {
4-
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
5-
popover?: "auto" | "manual";
6-
}
1+
import { ComponentPropsWithRef, AriaAttributes, DOMAttributes } from "react";
72

3+
export interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
4+
popover?: "auto" | "manual";
85
}
6+
97
export interface UsePopoverProps {
108
mode: "auto" | "manual";
119
onBeforeToggle?: (evt: ToggleEvent) => void;
@@ -18,5 +16,5 @@ export interface UsePopoverResult {
1816
showPopover: () => void,
1917
hidePopover: () => void,
2018
togglePopover: () => void,
21-
Popover: ({ children, ...rest }: ComponentPropsWithRef<"div">) => false | JSX.Element;
19+
Popover: ({ children, ...rest }: ComponentPropsWithRef<"div"> & HTMLAttributes<"div">) => false | JSX.Element;
2220
}

0 commit comments

Comments
 (0)