@koine/react 2.0.0-beta.21 → 2.0.0-beta.23
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/Polymorphic.d.ts +26 -0
- package/Polymorphic.js +1 -0
- package/calendar/CalendarDaygridCell.d.ts +35 -0
- package/calendar/CalendarDaygridCell.js +48 -0
- package/calendar/CalendarDaygridNav.d.ts +27 -0
- package/calendar/CalendarDaygridNav.js +24 -0
- package/calendar/CalendarDaygridTable.d.ts +25 -0
- package/calendar/CalendarDaygridTable.js +45 -0
- package/calendar/CalendarLegend.d.ts +18 -0
- package/calendar/CalendarLegend.js +9 -0
- package/calendar/calendar-api-google.d.ts +10 -0
- package/calendar/calendar-api-google.js +124 -0
- package/calendar/index.d.ts +6 -0
- package/calendar/index.js +6 -0
- package/calendar/types.d.ts +62 -0
- package/calendar/types.js +1 -0
- package/calendar/useCalendar.d.ts +35 -0
- package/calendar/useCalendar.js +176 -0
- package/calendar/utils.d.ts +11 -0
- package/calendar/utils.js +185 -0
- package/classed.d.ts +1 -1
- package/forms/antispam.d.ts +27 -0
- package/forms/antispam.js +29 -0
- package/forms/index.d.ts +1 -0
- package/forms/index.js +1 -0
- package/index.d.ts +1 -0
- package/mergeRefs.d.ts +0 -1
- package/package.json +43 -32
- package/types.d.ts +0 -1
- package/typings.d.ts +0 -93
- package/useDateLocale.d.ts +2 -1
- package/useDateLocale.js +2 -2
- package/useFixedOffset.d.ts +0 -1
- package/useFocus.d.ts +0 -1
- package/useReveal.d.ts +12 -0
- package/useReveal.js +43 -0
- package/useScrollPosition.d.ts +0 -1
- package/useScrollTo.js +1 -4
package/typings.d.ts
CHANGED
|
@@ -1,99 +1,6 @@
|
|
|
1
|
-
import "styled-components";
|
|
2
|
-
|
|
3
|
-
// import type {} from "styled-components/cssprop"; // for `css` prop
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Styled components utility types
|
|
7
|
-
*/
|
|
8
|
-
type Theme = import("./styles/theme").Theme;
|
|
9
|
-
|
|
10
|
-
declare module "styled-components" {
|
|
11
|
-
// extends the global DefaultTheme with our ThemeType.
|
|
12
|
-
export interface DefaultTheme extends Theme {
|
|
13
|
-
maxWidth: number;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
1
|
/**
|
|
18
2
|
* Types specifically related to `@koine/react` exposed on the global unique
|
|
19
3
|
* namespace `Koine`. Most of the types here should be prefixed by `React`, e.g.
|
|
20
4
|
* `ReactSomeFeature` accessible anywhere from `Koine.ReactSomeFeature`
|
|
21
5
|
*/
|
|
22
6
|
declare namespace Koine {}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* React Polymorphic components type utilities
|
|
26
|
-
*
|
|
27
|
-
* @resources
|
|
28
|
-
* - [Polymorphic types from Radix UI in Wanda System](https://github.com/wonderflow-bv/wanda/blob/main/packages/react-components/src/types/polymorphic/index.ts)
|
|
29
|
-
* - [TypeScript + React: Typing Generic forwardRefs](https://fettblog.eu/typescript-react-generic-forward-refs/)
|
|
30
|
-
* - [React with Typescript -- Generics while using React.forwardRef](https://stackoverflow.com/a/58473012/1938970)
|
|
31
|
-
* - [How to write a generic that extracts the prop types of the component that passed in](https://stackoverflow.com/a/57846897/1938970)
|
|
32
|
-
* - [React TS Generic component to pass generic props to children](https://stackoverflow.com/a/68442669/1938970)
|
|
33
|
-
* - [About custom ref prop](https://gist.github.com/gaearon/1a018a023347fe1c2476073330cc5509)
|
|
34
|
-
* - [forwardRef performance](https://github.com/facebook/react/issues/13456)
|
|
35
|
-
* - [React docs: Exposing DOM Refs to Parent Components](https://github.com/facebook/react/issues/13456)
|
|
36
|
-
*/
|
|
37
|
-
declare namespace Polymorphic {
|
|
38
|
-
type AsProp<TComponent extends React.ElementType> = {
|
|
39
|
-
as?: TComponent;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
type ComponentTypes =
|
|
43
|
-
| React.ComponentClass<any>
|
|
44
|
-
| React.FunctionComponent<any>
|
|
45
|
-
| keyof JSX.IntrinsicElements;
|
|
46
|
-
|
|
47
|
-
type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2;
|
|
48
|
-
|
|
49
|
-
type ForwardRefExoticComponent<TComponent, TOwnProps> =
|
|
50
|
-
React.ForwardRefExoticComponent<
|
|
51
|
-
Merge<
|
|
52
|
-
TComponent extends React.ElementType
|
|
53
|
-
? React.ComponentPropsWithRef<TComponent>
|
|
54
|
-
: never,
|
|
55
|
-
TOwnProps & { as?: TComponent }
|
|
56
|
-
>
|
|
57
|
-
>;
|
|
58
|
-
|
|
59
|
-
type InferProps<TComponent extends ComponentTypes> =
|
|
60
|
-
TComponent extends React.ComponentClass<infer Props>
|
|
61
|
-
? Props
|
|
62
|
-
: TComponent extends React.FunctionComponent<infer Props>
|
|
63
|
-
? Props
|
|
64
|
-
: TComponent extends React.ForwardRefExoticComponent<infer Props>
|
|
65
|
-
? Props
|
|
66
|
-
: TComponent extends keyof JSX.IntrinsicElements
|
|
67
|
-
? React.ComponentPropsWithoutRef<TComponent>
|
|
68
|
-
: never;
|
|
69
|
-
|
|
70
|
-
type Ref<TComponent extends React.ElementType> =
|
|
71
|
-
React.ComponentPropsWithRef<TComponent>["ref"];
|
|
72
|
-
|
|
73
|
-
type Props<
|
|
74
|
-
TComponent extends React.ElementType,
|
|
75
|
-
TProps = {}
|
|
76
|
-
> = /* Omit< */ InferProps<TComponent> /* , keyof Props> */ &
|
|
77
|
-
AsProp<TComponent> &
|
|
78
|
-
TProps;
|
|
79
|
-
|
|
80
|
-
type PropsWithRef<TComponent extends React.ElementType, TProps = {}> = Props<
|
|
81
|
-
TComponent,
|
|
82
|
-
TProps
|
|
83
|
-
> & {
|
|
84
|
-
ref?: Ref<TComponent>;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
interface ComponentForwarded<TComponent, TProps = {}>
|
|
88
|
-
extends ForwardRefExoticComponent<TComponent, TProps> {
|
|
89
|
-
<As = TComponent>(
|
|
90
|
-
props: As extends ""
|
|
91
|
-
? { as: keyof JSX.IntrinsicElements }
|
|
92
|
-
: As extends React.ComponentType<infer P>
|
|
93
|
-
? Merge<P, TProps & { as: As }>
|
|
94
|
-
: As extends keyof JSX.IntrinsicElements
|
|
95
|
-
? Merge<JSX.IntrinsicElements[As], TProps & { as: As }>
|
|
96
|
-
: never
|
|
97
|
-
): React.ReactElement | null;
|
|
98
|
-
}
|
|
99
|
-
}
|
package/useDateLocale.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Locale } from "date-fns";
|
|
2
|
+
export declare function useDateLocale(locale?: string, defaultLocale?: string): Locale | undefined;
|
|
2
3
|
export default useDateLocale;
|
package/useDateLocale.js
CHANGED
|
@@ -10,11 +10,11 @@ export function useDateLocale(locale, defaultLocale) {
|
|
|
10
10
|
var localeToSet;
|
|
11
11
|
return __generator(this, function (_a) {
|
|
12
12
|
switch (_a.label) {
|
|
13
|
-
case 0: return [4, import("date-fns/locale/en-US
|
|
13
|
+
case 0: return [4, import("date-fns/locale/en-US")];
|
|
14
14
|
case 1:
|
|
15
15
|
localeToSet = _a.sent();
|
|
16
16
|
setCurrent(locale || current);
|
|
17
|
-
setData(localeToSet.
|
|
17
|
+
setData(localeToSet.enUS);
|
|
18
18
|
return [2];
|
|
19
19
|
}
|
|
20
20
|
});
|
package/useFixedOffset.d.ts
CHANGED
package/useFocus.d.ts
CHANGED
package/useReveal.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type UseRevealOptions = {
|
|
2
|
+
direction?: "left" | "right";
|
|
3
|
+
offsetStartY?: number;
|
|
4
|
+
offsetEndY?: number;
|
|
5
|
+
offsetStartX?: number | "all";
|
|
6
|
+
};
|
|
7
|
+
export declare function useReveal<T extends HTMLElement = HTMLDivElement>({ direction, offsetStartY, offsetEndY, offsetStartX, }: UseRevealOptions): {
|
|
8
|
+
ref: import("react").RefObject<T>;
|
|
9
|
+
startY: number;
|
|
10
|
+
endY: number;
|
|
11
|
+
startX: number;
|
|
12
|
+
};
|
package/useReveal.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
export function useReveal(_a) {
|
|
4
|
+
var _b = _a.direction, direction = _b === void 0 ? "left" : _b, _c = _a.offsetStartY, offsetStartY = _c === void 0 ? -2 : _c, _d = _a.offsetEndY, offsetEndY = _d === void 0 ? 0 : _d, _e = _a.offsetStartX, offsetStartX = _e === void 0 ? "all" : _e;
|
|
5
|
+
var ref = useRef(null);
|
|
6
|
+
var _f = __read(useState(0), 2), startY = _f[0], setStartY = _f[1];
|
|
7
|
+
var _g = __read(useState(0), 2), endY = _g[0], setEndY = _g[1];
|
|
8
|
+
var _h = __read(useState(0), 2), startX = _h[0], setStartX = _h[1];
|
|
9
|
+
useEffect(function () {
|
|
10
|
+
if (!ref.current) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
var rect = ref.current.getBoundingClientRect();
|
|
14
|
+
var scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
15
|
+
var elementHeight = rect.height;
|
|
16
|
+
var elementTop = rect.top;
|
|
17
|
+
var distanceTop = elementTop + scrollTop;
|
|
18
|
+
var offsetTop = offsetStartY ? elementHeight * offsetStartY : 0;
|
|
19
|
+
var offsetBottom = offsetEndY ? elementHeight * offsetEndY : offsetTop;
|
|
20
|
+
var startY = (distanceTop + offsetTop) / document.body.clientHeight;
|
|
21
|
+
var endY = (distanceTop + elementHeight + offsetBottom) / document.body.clientHeight;
|
|
22
|
+
var startX;
|
|
23
|
+
if (offsetStartX === "all") {
|
|
24
|
+
startX = direction === "left" ? -rect.right : rect.left;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
startX = rect.width * offsetStartX;
|
|
28
|
+
startX = direction === "left" ? -startX : startX;
|
|
29
|
+
}
|
|
30
|
+
setStartY(startY);
|
|
31
|
+
setEndY(endY);
|
|
32
|
+
setStartX(startX);
|
|
33
|
+
}, [
|
|
34
|
+
setStartY,
|
|
35
|
+
setEndY,
|
|
36
|
+
setStartX,
|
|
37
|
+
offsetStartY,
|
|
38
|
+
offsetEndY,
|
|
39
|
+
offsetStartX,
|
|
40
|
+
direction,
|
|
41
|
+
]);
|
|
42
|
+
return { ref: ref, startY: startY, endY: endY, startX: startX };
|
|
43
|
+
}
|
package/useScrollPosition.d.ts
CHANGED
package/useScrollTo.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { __read } from "tslib";
|
|
2
1
|
import { isBrowser } from "@koine/utils";
|
|
3
|
-
import useHeader from "./Header/useHeader.js";
|
|
4
2
|
export function useScrollTo(id, offset) {
|
|
5
3
|
if (id === void 0) { id = ""; }
|
|
6
4
|
if (offset === void 0) { offset = 0; }
|
|
7
|
-
var _a = __read(useHeader(), 3), headerHeight = _a[2];
|
|
8
5
|
if (!isBrowser) {
|
|
9
6
|
return;
|
|
10
7
|
}
|
|
11
|
-
var headerOffset =
|
|
8
|
+
var headerOffset = 0;
|
|
12
9
|
var element = document.getElementById(id);
|
|
13
10
|
var top = 0;
|
|
14
11
|
if (element && element.offsetParent) {
|