@koine/react 1.0.105 → 1.1.0
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/Alert/Alert.d.ts +1 -1
- package/Animations/Reveal.d.ts +1 -1
- package/Animations/useReveal.d.ts +1 -1
- package/Autocomplete/AutocompleteMui.d.ts +4 -4
- package/Autocomplete/helpers.d.ts +1 -1
- package/Bg/BgColor.d.ts +1 -1
- package/Bg/BgPhoto.d.ts +2 -2
- package/Bg/BgSvg.d.ts +1 -1
- package/Breadcrumbs/Breadcrumbs.d.ts +3 -3
- package/Buttons/Button.d.ts +2 -2
- package/Buttons/ButtonComposite.d.ts +3 -3
- package/Buttons/ButtonFab.d.ts +1 -1
- package/Buttons/ButtonLink.d.ts +2 -2
- package/Buttons/IconButton.d.ts +2 -2
- package/Calendar/CalendarDaygridCell.d.ts +6 -6
- package/Calendar/CalendarDaygridNav.d.ts +3 -3
- package/Calendar/CalendarDaygridTable.d.ts +4 -4
- package/Calendar/CalendarLegend.d.ts +3 -3
- package/Calendar/calendar-api-google.d.ts +1 -1
- package/Calendar/types.d.ts +13 -13
- package/Calendar/useCalendar.d.ts +5 -5
- package/Carousel/CarouselCss.d.ts +2 -2
- package/Collapsable/CollapsableReach.js +1 -2
- package/Debug/Debug.d.ts +1 -1
- package/Details/Details.d.ts +6 -6
- package/Dialog/DialogMui.d.ts +8 -8
- package/Dialog/DialogMui.js +1 -1
- package/Dialog/css/bare.d.ts +1 -1
- package/Dialog/m/bare.d.ts +1 -1
- package/Dialog/m/bare.js +1 -1
- package/Dialog/sc/bare.d.ts +1 -1
- package/Dialog/sc/framer.d.ts +1 -1
- package/Dialog/sc/framerMaterial.d.ts +1 -1
- package/Dialog/sc/material.d.ts +1 -1
- package/Dialog/tw/bare.d.ts +7 -7
- package/Dialog/tw/elegant.d.ts +7 -7
- package/Dialog/tw/framer.d.ts +3 -3
- package/Dialog/tw/framerMaterial.d.ts +5 -5
- package/Dialog/tw/material.d.ts +7 -7
- package/Editor/Editor--tiptap.d.ts +2 -2
- package/Favicon/FaviconTags.d.ts +1 -1
- package/Favicon/FaviconTags.js +1 -1
- package/Form/Form.d.ts +7 -7
- package/Forms/Checkbox/Checkbox.d.ts +2 -2
- package/Forms/Feedback/Feedback.d.ts +1 -1
- package/Forms/Field/Field.d.ts +3 -3
- package/Forms/Field/FieldControl.d.ts +2 -2
- package/Forms/Input/Input.d.ts +2 -2
- package/Forms/InputGroup/InputGroup.d.ts +1 -1
- package/Forms/Password/Password.d.ts +2 -2
- package/Forms/Radio/Radio.d.ts +3 -3
- package/Forms/Switch/Switch.d.ts +2 -2
- package/Forms/Textarea/Textarea.d.ts +2 -2
- package/Forms/Textarea/TextareaRich.d.ts +2 -2
- package/Forms/Toggle/Toggle.d.ts +3 -3
- package/Forms/Toggle/useToggle.d.ts +1 -1
- package/Forms/antispam.d.ts +18 -1
- package/Forms/helpers.d.ts +5 -5
- package/Gauge/Gauge.d.ts +1 -1
- package/Grid/Grid.d.ts +6 -6
- package/Hamburger/Hamburger.d.ts +1 -1
- package/Header/useHeader.d.ts +5 -5
- package/Hidden/Hidden.d.ts +1 -1
- package/Img/sc/bare.d.ts +1 -1
- package/Img/types.d.ts +2 -2
- package/Link/Link.d.ts +1 -1
- package/Link/LinkBlank.d.ts +1 -1
- package/Menu/MenuMui.d.ts +5 -5
- package/Menu/MenuMui.js +1 -1
- package/MenuItem/MenuItemMui.d.ts +1 -1
- package/Meta/Meta.d.ts +1 -1
- package/NoJs/NoJs.d.ts +1 -1
- package/Pagination/PaginationNav.d.ts +2 -2
- package/Pagination/PaginationResults.d.ts +1 -1
- package/Pill/Pill.d.ts +1 -1
- package/Progress/ProgressCircular.d.ts +1 -1
- package/Progress/ProgressLinear.d.ts +1 -1
- package/Progress/ProgressOverlay.d.ts +1 -1
- package/Rating/Rating.d.ts +3 -3
- package/Select/SelectDownshift.d.ts +1 -1
- package/Select/components.d.ts +1 -1
- package/Sidebar/Sidebar.d.ts +1 -1
- package/Spacing/Spacing.d.ts +6 -6
- package/Sticky/Sticky.d.ts +1 -1
- package/Sticky/StickyCss.d.ts +1 -1
- package/Tabs/TabsMui.d.ts +11 -11
- package/Tabs/TabsMui.js +1 -1
- package/Tabs/tw/bare.d.ts +4 -4
- package/Tabs/tw/material.d.ts +10 -10
- package/Typography/ReadMore.d.ts +1 -1
- package/Typography/TextLoop.d.ts +2 -2
- package/Typography/TypeStairs.d.ts +1 -1
- package/helpers/classed.d.ts +3 -3
- package/helpers/classed.js +1 -0
- package/helpers/createUseMediaQueryWidth.d.ts +3 -3
- package/helpers/extend-component.d.ts +4 -4
- package/helpers/extend-component.js +1 -0
- package/hooks/index.d.ts +4 -1
- package/hooks/index.js +4 -1
- package/hooks/types.d.ts +2 -2
- package/hooks/useAsyncFn.d.ts +4 -4
- package/hooks/useAsyncFn.js +1 -0
- package/hooks/useDateLocale.d.ts +1 -0
- package/hooks/useDateLocale.js +1 -0
- package/hooks/useEffectOnce.d.ts +1 -0
- package/hooks/useEffectOnce.js +1 -0
- package/hooks/useFirstMountState.d.ts +1 -0
- package/hooks/useFirstMountState.js +1 -0
- package/hooks/useFocus.d.ts +1 -0
- package/hooks/useFocus.js +1 -0
- package/hooks/useId.d.ts +1 -0
- package/hooks/useId.js +1 -0
- package/hooks/useInterval.d.ts +7 -0
- package/hooks/useInterval.js +28 -0
- package/hooks/useIsomorphicLayoutEffect.d.ts +1 -0
- package/hooks/useIsomorphicLayoutEffect.js +1 -0
- package/hooks/useKeyUp.d.ts +2 -0
- package/hooks/useKeyUp.js +23 -0
- package/hooks/useMeasure.d.ts +3 -3
- package/hooks/useMount.d.ts +1 -0
- package/hooks/useMount.js +1 -0
- package/hooks/useMountedState.d.ts +1 -0
- package/hooks/useMountedState.js +1 -0
- package/hooks/useNavigateAway.d.ts +32 -0
- package/hooks/useNavigateAway.js +68 -0
- package/hooks/usePrevious.d.ts +5 -1
- package/hooks/usePrevious.js +11 -7
- package/hooks/usePreviousRef.d.ts +2 -0
- package/hooks/usePreviousRef.js +9 -0
- package/hooks/useScrollPosition.d.ts +3 -3
- package/hooks/useScrollPosition.js +1 -0
- package/hooks/useScrollTo.d.ts +1 -0
- package/hooks/useScrollTo.js +1 -0
- package/hooks/useTraceUpdate.d.ts +1 -0
- package/hooks/useTraceUpdate.js +1 -0
- package/hooks/useUpdateEffect.d.ts +1 -0
- package/hooks/useUpdateEffect.js +1 -0
- package/hooks/useWindowSize.d.ts +1 -0
- package/hooks/useWindowSize.js +4 -2
- package/m/MotionProvider.d.ts +2 -2
- package/node/Collapsable/CollapsableReach.js +1 -2
- package/node/Dialog/DialogMui.js +1 -1
- package/node/Dialog/m/bare.js +1 -1
- package/node/Favicon/FaviconTags.js +1 -1
- package/node/Menu/MenuMui.js +1 -1
- package/node/Tabs/TabsMui.js +1 -1
- package/node/helpers/classed.js +1 -0
- package/node/helpers/extend-component.js +1 -0
- package/node/hooks/index.js +4 -1
- package/node/hooks/useAsyncFn.js +1 -0
- package/node/hooks/useDateLocale.js +4 -2
- package/node/hooks/useEffectOnce.js +1 -0
- package/node/hooks/useFirstMountState.js +1 -0
- package/node/hooks/useFocus.js +1 -0
- package/node/hooks/useInterval.js +32 -0
- package/node/hooks/useIsomorphicLayoutEffect.js +1 -0
- package/node/hooks/useKeyUp.js +27 -0
- package/node/hooks/useMount.js +1 -0
- package/node/hooks/useMountedState.js +1 -0
- package/node/hooks/useNavigateAway.js +72 -0
- package/node/hooks/usePrevious.js +10 -6
- package/node/hooks/usePreviousRef.js +13 -0
- package/node/hooks/useScrollPosition.js +1 -0
- package/node/hooks/useScrollTo.js +1 -0
- package/node/hooks/useTraceUpdate.js +1 -0
- package/node/hooks/useUpdateEffect.js +1 -0
- package/node/hooks/useWindowSize.js +4 -2
- package/package.json +35 -23
- package/styles/media.d.ts +3 -3
- package/styles/spacing.d.ts +7 -7
- package/styles/theme--vanilla.d.ts +4 -4
- package/styles/theme.d.ts +4 -4
- package/types.d.ts +4 -4
- package/hooks/useMediaQueryWidthCreator.d.ts +0 -6
- package/hooks/useMediaQueryWidthCreator.js +0 -169
- package/hooks/useMqWidthCreator.d.ts +0 -3
- package/hooks/useMqWidthCreator.js +0 -225
- package/node/hooks/useId.js +0 -12
package/hooks/index.d.ts
CHANGED
|
@@ -4,12 +4,15 @@ export * from "./useEffectOnce";
|
|
|
4
4
|
export * from "./useFirstMountState";
|
|
5
5
|
export * from "./useFixedOffset";
|
|
6
6
|
export * from "./useFocus";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./useInterval";
|
|
8
8
|
export * from "./useIsomorphicLayoutEffect";
|
|
9
|
+
export * from "./useKeyUp";
|
|
9
10
|
export * from "./useMeasure";
|
|
10
11
|
export * from "./useMount";
|
|
11
12
|
export * from "./useMountedState";
|
|
13
|
+
export * from "./useNavigateAway";
|
|
12
14
|
export * from "./usePrevious";
|
|
15
|
+
export * from "./usePreviousRef";
|
|
13
16
|
export * from "./useScrollPosition";
|
|
14
17
|
export * from "./useSmoothScroll";
|
|
15
18
|
export * from "./useTraceUpdate";
|
package/hooks/index.js
CHANGED
|
@@ -4,12 +4,15 @@ export * from "./useEffectOnce";
|
|
|
4
4
|
export * from "./useFirstMountState";
|
|
5
5
|
export * from "./useFixedOffset";
|
|
6
6
|
export * from "./useFocus";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./useInterval";
|
|
8
8
|
export * from "./useIsomorphicLayoutEffect";
|
|
9
|
+
export * from "./useKeyUp";
|
|
9
10
|
export * from "./useMeasure";
|
|
10
11
|
export * from "./useMount";
|
|
11
12
|
export * from "./useMountedState";
|
|
13
|
+
export * from "./useNavigateAway";
|
|
12
14
|
export * from "./usePrevious";
|
|
15
|
+
export * from "./usePreviousRef";
|
|
13
16
|
export * from "./useScrollPosition";
|
|
14
17
|
// export * from "./useScrollTo";
|
|
15
18
|
export * from "./useSmoothScroll";
|
package/hooks/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/misc/types.ts)
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type PromiseType<P extends Promise<any>> = P extends Promise<infer T> ? T : never;
|
|
5
5
|
/**
|
|
6
6
|
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/misc/types.ts)
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type FunctionReturningPromise = (...args: any[]) => Promise<any>;
|
package/hooks/useAsyncFn.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { FunctionReturningPromise, PromiseType } from "./types";
|
|
3
|
-
export
|
|
3
|
+
export type AsyncState<T> = {
|
|
4
4
|
loading: boolean;
|
|
5
5
|
error?: undefined;
|
|
6
6
|
value?: undefined;
|
|
@@ -17,10 +17,10 @@ export declare type AsyncState<T> = {
|
|
|
17
17
|
error?: undefined;
|
|
18
18
|
value: T;
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
export
|
|
20
|
+
type StateFromFunctionReturningPromise<T extends FunctionReturningPromise> = AsyncState<PromiseType<ReturnType<T>>>;
|
|
21
|
+
export type AsyncFnReturn<T extends FunctionReturningPromise = FunctionReturningPromise> = [StateFromFunctionReturningPromise<T>, T];
|
|
22
22
|
/**
|
|
23
23
|
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts)
|
|
24
24
|
*/
|
|
25
25
|
export declare function useAsyncFn<T extends FunctionReturningPromise>(fn: T, deps?: React.DependencyList, initialState?: StateFromFunctionReturningPromise<T>): AsyncFnReturn<T>;
|
|
26
|
-
export
|
|
26
|
+
export default useAsyncFn;
|
package/hooks/useAsyncFn.js
CHANGED
package/hooks/useDateLocale.d.ts
CHANGED
package/hooks/useDateLocale.js
CHANGED
package/hooks/useEffectOnce.d.ts
CHANGED
package/hooks/useEffectOnce.js
CHANGED
package/hooks/useFocus.d.ts
CHANGED
package/hooks/useFocus.js
CHANGED
package/hooks/useId.d.ts
CHANGED
package/hooks/useId.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @borrows [dan abramov](https://overreacted.io/making-setinterval-declarative-with-react-hooks/)
|
|
3
|
+
*
|
|
4
|
+
* We just add `deps` array argument and typescript support
|
|
5
|
+
*/
|
|
6
|
+
export declare function useInterval<T extends () => unknown>(callback: T, delay: number, deps?: unknown[]): void;
|
|
7
|
+
export default useInterval;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { noop } from "@koine/utils";
|
|
4
|
+
/**
|
|
5
|
+
* @borrows [dan abramov](https://overreacted.io/making-setinterval-declarative-with-react-hooks/)
|
|
6
|
+
*
|
|
7
|
+
* We just add `deps` array argument and typescript support
|
|
8
|
+
*/
|
|
9
|
+
export function useInterval(callback, delay, deps) {
|
|
10
|
+
if (deps === void 0) { deps = []; }
|
|
11
|
+
var savedCallback = useRef();
|
|
12
|
+
useEffect(function () {
|
|
13
|
+
savedCallback.current = callback;
|
|
14
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
+
}, __spreadArray([callback], deps, true));
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
function tick() {
|
|
18
|
+
if (savedCallback.current)
|
|
19
|
+
savedCallback.current();
|
|
20
|
+
}
|
|
21
|
+
if (delay !== null) {
|
|
22
|
+
var id_1 = setInterval(tick, delay);
|
|
23
|
+
return function () { return clearInterval(id_1); };
|
|
24
|
+
}
|
|
25
|
+
return noop;
|
|
26
|
+
}, [delay]);
|
|
27
|
+
}
|
|
28
|
+
export default useInterval;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { on } from "@koine/dom";
|
|
4
|
+
export function useKeyUp(callback, deps) {
|
|
5
|
+
if (deps === void 0) { deps = []; }
|
|
6
|
+
useEffect(function () {
|
|
7
|
+
var listener = on(window, "keyup", function (event) {
|
|
8
|
+
// const { key } = event;
|
|
9
|
+
// be sure we do not intercept keys combinations maybe used for other
|
|
10
|
+
// actions like native browser navigation shortcuts
|
|
11
|
+
// @see https://stackoverflow.com/a/37559790/1938970
|
|
12
|
+
if (!event.ctrlKey &&
|
|
13
|
+
!event.altKey &&
|
|
14
|
+
!event.shiftKey &&
|
|
15
|
+
!event.metaKey) {
|
|
16
|
+
callback(event);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return listener;
|
|
20
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
+
}, __spreadArray([callback], deps, true));
|
|
22
|
+
}
|
|
23
|
+
export default useKeyUp;
|
package/hooks/useMeasure.d.ts
CHANGED
|
@@ -9,11 +9,11 @@ interface RectReadOnly {
|
|
|
9
9
|
readonly left: number;
|
|
10
10
|
[key: string]: number;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
export
|
|
12
|
+
type HTMLOrSVGElement = HTMLElement | SVGElement;
|
|
13
|
+
export type UseMeasureOptions = {
|
|
14
14
|
scroll?: boolean;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type UseMeasureReturn = [
|
|
17
17
|
(element: HTMLOrSVGElement | null) => void,
|
|
18
18
|
RectReadOnly,
|
|
19
19
|
() => void
|
package/hooks/useMount.d.ts
CHANGED
package/hooks/useMount.js
CHANGED
package/hooks/useMountedState.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @return A custom error message (most browser will ignore it), or just a
|
|
3
|
+
* boolean to signal whether we want to prompt the user
|
|
4
|
+
*
|
|
5
|
+
* We might instead return an array with the above as first element and two
|
|
6
|
+
* callbacks, but the callback technique is too cumbersome and unreliable
|
|
7
|
+
* probably:
|
|
8
|
+
* 2) A callback on confirmed leaving
|
|
9
|
+
* 3) A callback on cancel, user stays on page
|
|
10
|
+
*/
|
|
11
|
+
export type UseNavigateAwayHandler = (event: BeforeUnloadEvent) => string | boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @resources
|
|
14
|
+
*
|
|
15
|
+
* About browser's specs see:
|
|
16
|
+
* - https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_event
|
|
17
|
+
* - https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5
|
|
18
|
+
* - https://stackoverflow.com/questions/58009424/pagehide-event-on-google-chrome
|
|
19
|
+
*
|
|
20
|
+
* About react see:
|
|
21
|
+
* - https://github.com/jacobbuck/react-beforeunload
|
|
22
|
+
* - https://github.com/dioscarey/react-beforeunload-component
|
|
23
|
+
*
|
|
24
|
+
* About next.js see:
|
|
25
|
+
* - https://github.com/vercel/next.js/issues/2476
|
|
26
|
+
* - https://github.com/vercel/next.js/issues/2694
|
|
27
|
+
*
|
|
28
|
+
* For the callback technique see:
|
|
29
|
+
* - https://stackoverflow.com/a/11835394/1938970
|
|
30
|
+
*/
|
|
31
|
+
export declare const useNavigateAway: (handler: UseNavigateAwayHandler) => void;
|
|
32
|
+
export default useNavigateAway;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { on } from "@koine/dom";
|
|
3
|
+
// type UseNavigateAwayPagehideHandler = (event: PageTransitionEvent) => unknown;
|
|
4
|
+
/**
|
|
5
|
+
* @resources
|
|
6
|
+
*
|
|
7
|
+
* About browser's specs see:
|
|
8
|
+
* - https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_event
|
|
9
|
+
* - https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5
|
|
10
|
+
* - https://stackoverflow.com/questions/58009424/pagehide-event-on-google-chrome
|
|
11
|
+
*
|
|
12
|
+
* About react see:
|
|
13
|
+
* - https://github.com/jacobbuck/react-beforeunload
|
|
14
|
+
* - https://github.com/dioscarey/react-beforeunload-component
|
|
15
|
+
*
|
|
16
|
+
* About next.js see:
|
|
17
|
+
* - https://github.com/vercel/next.js/issues/2476
|
|
18
|
+
* - https://github.com/vercel/next.js/issues/2694
|
|
19
|
+
*
|
|
20
|
+
* For the callback technique see:
|
|
21
|
+
* - https://stackoverflow.com/a/11835394/1938970
|
|
22
|
+
*/
|
|
23
|
+
export var useNavigateAway = function (handler) {
|
|
24
|
+
var beforeUnloadHandlerRef = useRef();
|
|
25
|
+
// const pagehideHandlerRef = useRef<UseNavigateAwayPagehideHandler | undefined>();
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
beforeUnloadHandlerRef.current = function (event) {
|
|
28
|
+
var customMessageOrCondition = handler(event);
|
|
29
|
+
if (customMessageOrCondition) {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
}
|
|
32
|
+
// Handle legacy `event.returnValue` property
|
|
33
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
|
|
34
|
+
if (typeof customMessageOrCondition === "string") {
|
|
35
|
+
return (event.returnValue = customMessageOrCondition);
|
|
36
|
+
}
|
|
37
|
+
// Chrome doesn't support `event.preventDefault()` on `BeforeUnloadEvent`,
|
|
38
|
+
// instead it requires `event.returnValue` to be set
|
|
39
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#browser_compatibility
|
|
40
|
+
if (event.defaultPrevented) {
|
|
41
|
+
return (event.returnValue = "");
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
};
|
|
45
|
+
// pagehideHandlerRef.current = (event) => {
|
|
46
|
+
// const returnValue = handler?.(event);
|
|
47
|
+
// if (event.persisted) {
|
|
48
|
+
// // If the event's persisted property is `true` the page is about
|
|
49
|
+
// // to enter the Back-Forward Cache, which is also in the frozen state.
|
|
50
|
+
// } else {
|
|
51
|
+
// // If the event's persisted property is not `true` the page is
|
|
52
|
+
// // about to be unloaded.
|
|
53
|
+
// }
|
|
54
|
+
// };
|
|
55
|
+
}, [handler]);
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
var listenerBeforeunload = on(window, "beforeunload", function (event) { var _a; return (_a = beforeUnloadHandlerRef.current) === null || _a === void 0 ? void 0 : _a.call(beforeUnloadHandlerRef, event); });
|
|
58
|
+
// const listenerPagehide = on(window, "pagehide", (event) =>
|
|
59
|
+
// pagehideHandlerRef.current?.(event)
|
|
60
|
+
// );
|
|
61
|
+
return listenerBeforeunload;
|
|
62
|
+
// return () => {
|
|
63
|
+
// listenerBeforeunload();
|
|
64
|
+
// // listenerPagehide();
|
|
65
|
+
// };
|
|
66
|
+
}, []);
|
|
67
|
+
};
|
|
68
|
+
export default useNavigateAway;
|
package/hooks/usePrevious.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @borrows [samselikoff/animated-carousel](https://github.com/samselikoff/2022-06-02-animated-carousel/blob/main/pages/final.jsx)
|
|
3
|
+
*/
|
|
4
|
+
export declare function usePrevious<T>(state: T, defaulValue: T): T;
|
|
5
|
+
export default usePrevious;
|
package/hooks/usePrevious.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @borrows [samselikoff/animated-carousel](https://github.com/samselikoff/2022-06-02-animated-carousel/blob/main/pages/final.jsx)
|
|
4
|
+
*/
|
|
5
|
+
export function usePrevious(state, defaulValue) {
|
|
6
|
+
var _a = useState([state, defaulValue]), tuple = _a[0], setTuple = _a[1];
|
|
7
|
+
if (tuple[1] !== state) {
|
|
8
|
+
setTuple([tuple[1], state]);
|
|
9
|
+
}
|
|
10
|
+
return tuple[0];
|
|
8
11
|
}
|
|
12
|
+
export default usePrevious;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
type Position = {
|
|
3
3
|
x: number;
|
|
4
4
|
y: number;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
type ElementRef = React.MutableRefObject<HTMLElement | undefined>;
|
|
7
7
|
/**
|
|
8
8
|
* @borrows [@n8tb1t/use-scroll-position@2.0.3](https://github.com/n8tb1t/use-scroll-position) by `n8tb1t <n8tb1t@gmail.com>`
|
|
9
9
|
*
|
|
@@ -12,4 +12,4 @@ declare type ElementRef = React.MutableRefObject<HTMLElement | undefined>;
|
|
|
12
12
|
* - compacted object arguments in functions as plain argument list to improve compression
|
|
13
13
|
*/
|
|
14
14
|
export declare const useScrollPosition: (effect: (currentPosition: Position, prevPosition: Position) => void, deps?: import("react").DependencyList, element?: ElementRef, useWindow?: boolean, wait?: number, boundingElement?: ElementRef) => void;
|
|
15
|
-
export
|
|
15
|
+
export default useScrollPosition;
|
package/hooks/useScrollTo.d.ts
CHANGED
package/hooks/useScrollTo.js
CHANGED
package/hooks/useTraceUpdate.js
CHANGED
package/hooks/useUpdateEffect.js
CHANGED
package/hooks/useWindowSize.d.ts
CHANGED
package/hooks/useWindowSize.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
+
import { on } from "@koine/dom";
|
|
2
3
|
export function useWindowSize() {
|
|
3
4
|
var _a = useState([0, 0]), size = _a[0], setSize = _a[1];
|
|
4
5
|
useEffect(function () {
|
|
5
6
|
function updateSize() {
|
|
6
7
|
setSize([window.innerWidth, window.innerHeight]);
|
|
7
8
|
}
|
|
8
|
-
window
|
|
9
|
+
var listener = on(window, "resize", updateSize);
|
|
9
10
|
updateSize();
|
|
10
|
-
return
|
|
11
|
+
return listener;
|
|
11
12
|
}, []);
|
|
12
13
|
return size;
|
|
13
14
|
}
|
|
15
|
+
export default useWindowSize;
|
package/m/MotionProvider.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LazyProps } from "framer-motion";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type MotionProviderFeatures = LazyProps["features"];
|
|
4
|
+
export type MotionProviderProps = LazyProps & React.PropsWithChildren<{}>;
|
|
5
5
|
/**
|
|
6
6
|
* `<LazyMotion />` provider wrapper from `framer-motion`
|
|
7
7
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Maybe do a simplified version following this example:
|
|
6
6
|
* https://codesandbox.io/s/framer-motion-accordion-qx958?file=/src/Example.tsx
|
|
7
7
|
*/
|
|
8
|
-
// import { forwardRef, useCallback, useEffect,
|
|
8
|
+
// import { forwardRef, useCallback, useEffect, useId, useRef, useState } from "react";
|
|
9
9
|
// import styled from "styled-components";
|
|
10
10
|
// import { MotionProps, m } from "framer-motion";
|
|
11
11
|
// import {
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
// import { btnStyleReset } from "../Buttons";
|
|
18
18
|
// import { useWindowSize } from "../hooks/useWindowSize";
|
|
19
19
|
// import { InputInvisible } from "../Forms/styles";
|
|
20
|
-
// import { useId } from "../hooks/useId";
|
|
21
20
|
// export type CollapsableStyledProps = {
|
|
22
21
|
// $expanded?: boolean;
|
|
23
22
|
// };
|
package/node/Dialog/DialogMui.js
CHANGED
|
@@ -70,7 +70,7 @@ var DialogWithRef = (0, react_1.forwardRef)(function Dialog(_a, ref) {
|
|
|
70
70
|
onClose(event, "backdropClick");
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(exports.Root, tslib_1.__assign({
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(exports.Root, tslib_1.__assign({ slots: { backdrop: exports.Backdrop }, onClick: handleBackdropClick, onClose: onClose, ref: ref }, props, { children: (0, jsx_runtime_1.jsx)(exports.Container, tslib_1.__assign({ "$scrollPaper": $scrollPaper, onMouseDown: handleMouseDown }, { children: (0, jsx_runtime_1.jsxs)(exports.Paper, tslib_1.__assign({ "aria-label": title || "", "$scrollPaper": $scrollPaper }, { children: [title && (0, jsx_runtime_1.jsx)(exports.Header, { children: title }), (0, jsx_runtime_1.jsx)(exports.Close, tslib_1.__assign({ onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(md_1.MdClear, {}) })), (0, jsx_runtime_1.jsx)(exports.Body, { children: children })] })) })) })));
|
|
74
74
|
});
|
|
75
75
|
exports.KoineDialog = (0, helpers_1.extendComponent)(DialogWithRef, {
|
|
76
76
|
Root: exports.Root,
|
package/node/Dialog/m/bare.js
CHANGED
|
@@ -40,7 +40,7 @@ var Dialog = (0, react_1.forwardRef)(function Dialog(_a, ref) {
|
|
|
40
40
|
onClose(event, "backdropClick");
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(Root, tslib_1.__assign({ keepMounted: true,
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(Root, tslib_1.__assign({ keepMounted: true, slots: { backdrop: BackdropMotion }, onClick: handleBackdropClick, onClose: onClose, ref: ref }, props, { style: (0, index_1.mRootStyle)(props) }, { children: (0, jsx_runtime_1.jsx)(Container, tslib_1.__assign({ "$scrollPaper": $scrollPaper, onMouseDown: handleMouseDown }, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: props.open && (
|
|
44
44
|
// @ts-expect-error framer props collision...
|
|
45
45
|
(0, jsx_runtime_1.jsxs)(Paper, tslib_1.__assign({}, mPaper, { "aria-label": title || "", "$scrollPaper": $scrollPaper }, { children: [title && (0, jsx_runtime_1.jsx)(Header, { children: title }), (0, jsx_runtime_1.jsx)(Close, tslib_1.__assign({ onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(md_1.MdClear, {}) })), (0, jsx_runtime_1.jsx)(Body, { children: children })] }))) }) })) })));
|
|
46
46
|
});
|
|
@@ -14,6 +14,6 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
14
14
|
*/
|
|
15
15
|
var FaviconTags = function (_a) {
|
|
16
16
|
var name = _a.name, color = _a.color, safariTabColor = _a.safariTabColor, tileColor = _a.tileColor, themeColor = _a.themeColor;
|
|
17
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("link", { rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", type: "image/png", sizes: "32x32", href: "/favicon-32x32.png" }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", type: "image/png", sizes: "16x16", href: "/favicon-16x16.png" }), (0, jsx_runtime_1.jsx)("link", { rel: "manifest", href: "/site.webmanifest" }), (0, jsx_runtime_1.jsx)("link", { rel: "mask-icon", href: "/safari-pinned-tab.svg", color: safariTabColor || color }), (0, jsx_runtime_1.jsx)("meta", { name: "apple-mobile-web-app-title", content: name }), (0, jsx_runtime_1.jsx)("meta", { name: "application-name", content: name }), (0, jsx_runtime_1.jsx)("meta", { name: "msapplication-TileColor", content: tileColor || color }), (0, jsx_runtime_1.jsx)("meta", { name: "theme-color", content: themeColor || color })] }));
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("link", { rel: "shortcut icon", href: "/favicon.ico", type: "image/x-icon" }), (0, jsx_runtime_1.jsx)("link", { rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", type: "image/png", sizes: "32x32", href: "/favicon-32x32.png" }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", type: "image/png", sizes: "16x16", href: "/favicon-16x16.png" }), (0, jsx_runtime_1.jsx)("link", { rel: "manifest", href: "/site.webmanifest" }), (0, jsx_runtime_1.jsx)("link", { rel: "mask-icon", href: "/safari-pinned-tab.svg", color: safariTabColor || color }), (0, jsx_runtime_1.jsx)("meta", { name: "apple-mobile-web-app-title", content: name }), (0, jsx_runtime_1.jsx)("meta", { name: "application-name", content: name }), (0, jsx_runtime_1.jsx)("meta", { name: "msapplication-TileColor", content: tileColor || color }), (0, jsx_runtime_1.jsx)("meta", { name: "theme-color", content: themeColor || color })] }));
|
|
18
18
|
};
|
|
19
19
|
exports.FaviconTags = FaviconTags;
|
package/node/Menu/MenuMui.js
CHANGED
|
@@ -67,7 +67,7 @@ exports.Menu = (0, react_1.forwardRef)(function Menu(props, ref) {
|
|
|
67
67
|
var childrenProps = { close: close };
|
|
68
68
|
return children(childrenProps);
|
|
69
69
|
}, [children, close]);
|
|
70
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button, { ref: buttonRef, id: id, "aria-haspopup": "true", "aria-controls": open ? id : undefined, "aria-expanded": open ? "true" : undefined, onClick: handleButtonClick, onKeyDown: handleButtonKeyDown }), (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: open && ((0, jsx_runtime_1.jsx)(ModalUnstyled_1.default, tslib_1.__assign({
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button, { ref: buttonRef, id: id, "aria-haspopup": "true", "aria-controls": open ? id : undefined, "aria-expanded": open ? "true" : undefined, onClick: handleButtonClick, onKeyDown: handleButtonKeyDown }), (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: open && ((0, jsx_runtime_1.jsx)(ModalUnstyled_1.default, tslib_1.__assign({ slots: { backdrop: MenuBackdrop }, onClose: close, onBackdropClick: close, open: open }, { children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(ClickAwayListener_1.default, tslib_1.__assign({ onClickAway: close }, { children: (0, jsx_runtime_1.jsx)(MenuRoot, tslib_1.__assign({ initial: {
|
|
71
71
|
opacity: 0,
|
|
72
72
|
}, animate: {
|
|
73
73
|
opacity: 1,
|
package/node/Tabs/TabsMui.js
CHANGED
|
@@ -15,7 +15,7 @@ exports.List = TabsListUnstyled_1.default;
|
|
|
15
15
|
exports.Indicator = "span";
|
|
16
16
|
exports.Panel = TabPanelUnstyled_1.default;
|
|
17
17
|
exports.Tab = (0, react_1.forwardRef)(function Tab(_a, ref) {
|
|
18
|
-
var children = _a.children, component = _a.component,
|
|
18
|
+
var children = _a.children, component = _a.component, slotProps = _a.slotProps, slots = _a.slots, Indicator = _a.Indicator, props = tslib_1.__rest(_a, ["children", "component", "slotProps", "slots", "Indicator"]);
|
|
19
19
|
var _b = (0, TabUnstyled_1.useTab)(tslib_1.__assign(tslib_1.__assign({}, props), { ref: ref })), active = _b.active, disabled = _b.disabled, selected = _b.selected;
|
|
20
20
|
var indicatorProps = { active: active, disabled: disabled, selected: selected };
|
|
21
21
|
return ((0, jsx_runtime_1.jsxs)(TabUnstyled_1.default /* ref={ref} */, tslib_1.__assign({}, props, { children: [children, Indicator && (0, jsx_runtime_1.jsx)(Indicator, tslib_1.__assign({}, indicatorProps))] })));
|
package/node/helpers/classed.js
CHANGED
|
@@ -14,3 +14,4 @@ var extendComponent = function (component, defaultProps) {
|
|
|
14
14
|
return Object.assign(NewComponent, tslib_1.__assign(tslib_1.__assign({}, defaultProps), { defaultProps: defaultProps }));
|
|
15
15
|
};
|
|
16
16
|
exports.extendComponent = extendComponent;
|
|
17
|
+
exports.default = exports.extendComponent;
|
package/node/hooks/index.js
CHANGED
|
@@ -7,12 +7,15 @@ tslib_1.__exportStar(require("./useEffectOnce"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./useFirstMountState"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./useFixedOffset"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./useFocus"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./
|
|
10
|
+
tslib_1.__exportStar(require("./useInterval"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./useIsomorphicLayoutEffect"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./useKeyUp"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./useMeasure"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./useMount"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./useMountedState"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./useNavigateAway"), exports);
|
|
15
17
|
tslib_1.__exportStar(require("./usePrevious"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./usePreviousRef"), exports);
|
|
16
19
|
tslib_1.__exportStar(require("./useScrollPosition"), exports);
|
|
17
20
|
// export * from "./useScrollTo";
|
|
18
21
|
tslib_1.__exportStar(require("./useSmoothScroll"), exports);
|
package/node/hooks/useAsyncFn.js
CHANGED