@ainias42/react-bootstrap-mobile 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrapReactMobile.ts +1 -0
- package/dist/bootstrapReactMobile.d.ts +1 -0
- package/dist/bootstrapReactMobile.js +32 -7
- package/dist/bootstrapReactMobile.js.map +1 -1
- package/dist/src/Components/Clickable/Clickable.d.ts +1 -0
- package/dist/src/Components/Hooks/useRerender.d.ts +1 -0
- package/package.json +1 -1
- package/src/Components/Clickable/Clickable.tsx +4 -1
- package/src/Components/Hooks/useRerender.ts +21 -0
|
@@ -18,6 +18,7 @@ export type ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMous
|
|
|
18
18
|
id?: string;
|
|
19
19
|
tabIndex?: number;
|
|
20
20
|
draggable?: boolean;
|
|
21
|
+
title?: string;
|
|
21
22
|
} & OnClickListener<OnClickData> & OnPointerDownListener<OnMouseDownData> & OnPointerMoveListener<OnMouseMoveData> & OnPointerUpListener<OnMouseUpData> & OnDropListener<OnDropData> & OnDragStartListener<OnDragStartData> & OnDragOverListener<OnDragOverData> & OptionalListener<'onClickCapture', OnClickCaptureData> & OptionalListener<'onMouseEnter', OnMouseEnterData> & OptionalListener<'onMouseLeave', OnMouseLeaveData, MouseEvent | ReactMouseEvent> & OptionalListener<'onDoubleClick', OnDoubleClickData>>;
|
|
22
23
|
declare const ClickableMemo: import("../../helper/withForwardRef").RefComponent<ClickableProps<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, string | undefined>, HTMLAnchorElement | HTMLSpanElement>;
|
|
23
24
|
export { ClickableMemo as Clickable };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useRerender(defaultDelay?: number): readonly [(delay?: number) => void, number];
|
package/package.json
CHANGED
|
@@ -48,6 +48,7 @@ export type ClickableProps<
|
|
|
48
48
|
id?: string;
|
|
49
49
|
tabIndex?: number;
|
|
50
50
|
draggable?: boolean
|
|
51
|
+
title?: string;
|
|
51
52
|
} & OnClickListener<OnClickData> &
|
|
52
53
|
OnPointerDownListener<OnMouseDownData> &
|
|
53
54
|
OnPointerMoveListener<OnMouseMoveData> &
|
|
@@ -88,6 +89,7 @@ function Clickable<
|
|
|
88
89
|
useReactOnMouseLeave = false,
|
|
89
90
|
tabIndex,
|
|
90
91
|
draggable,
|
|
92
|
+
title,
|
|
91
93
|
...clickData
|
|
92
94
|
}: ClickableProps<OnClickData, OnPointerDownData, OnPointerMoveData, OnPointerUpData, OnClickCaptureData, OnDropData,OnDragStartData, OnDragOverData,OnMouseEnterData, OnMouseLeaveData, OnDoubleClickData, HrefType>,
|
|
93
95
|
ref: ForwardedRef<HrefType extends string ? HTMLAnchorElement : HTMLSpanElement>
|
|
@@ -311,7 +313,8 @@ function Clickable<
|
|
|
311
313
|
onDoubleClick: realOnDoubleClick,
|
|
312
314
|
tabIndex: interactable ? 0 : tabIndex,
|
|
313
315
|
draggable,
|
|
314
|
-
onDragStart: realOnDragStartListener
|
|
316
|
+
onDragStart: realOnDragStartListener,
|
|
317
|
+
title,
|
|
315
318
|
};
|
|
316
319
|
if (typeof href === 'string') {
|
|
317
320
|
return (
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export function useRerender(defaultDelay = 0){
|
|
4
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout>|undefined>();
|
|
5
|
+
const [renderCounter, updateRenderCounter] = useState(0);
|
|
6
|
+
const update = useCallback((delay = defaultDelay) => {
|
|
7
|
+
if (delay === 0){
|
|
8
|
+
clearTimeout(timeoutRef.current);
|
|
9
|
+
timeoutRef.current = undefined;
|
|
10
|
+
updateRenderCounter(old => old + 1);
|
|
11
|
+
} else if (!timeoutRef.current) {
|
|
12
|
+
timeoutRef.current = setTimeout(() => {
|
|
13
|
+
clearTimeout(timeoutRef.current);
|
|
14
|
+
timeoutRef.current = undefined;
|
|
15
|
+
updateRenderCounter(old => old + 1);
|
|
16
|
+
}, delay);
|
|
17
|
+
}
|
|
18
|
+
}, [])
|
|
19
|
+
|
|
20
|
+
return [update, renderCounter] as const;
|
|
21
|
+
}
|