@koine/react 2.0.0-beta.72 → 2.0.0-beta.73
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/calendar/CalendarDaygridCell.js +42 -0
- package/calendar/CalendarDaygridNav.js +22 -0
- package/calendar/CalendarDaygridTable.js +50 -0
- package/calendar/CalendarLegend.js +4 -0
- package/calendar/calendar-api-google.js +90 -0
- package/calendar/types.js +1 -0
- package/calendar/useCalendar.js +175 -0
- package/calendar/useDateLocale.js +16 -0
- package/calendar/utils.js +172 -0
- package/calendar.js +7 -0
- package/components/FaviconTags.js +4 -0
- package/components/Meta.js +4 -0
- package/components/NoJs.js +6 -0
- package/forms/antispam.js +29 -0
- package/forms.js +1 -0
- package/hooks/index.js +19 -0
- package/hooks/useAsyncFn.js +25 -0
- package/hooks/useFirstMountState.js +9 -0
- package/hooks/useFixedOffset.js +41 -0
- package/hooks/useFocus.js +8 -0
- package/hooks/useInterval.js +19 -0
- package/hooks/useIsomorphicLayoutEffect.js +3 -0
- package/hooks/useKeyUp.js +15 -0
- package/hooks/useMeasure.js +118 -0
- package/hooks/useMountedState.js +12 -0
- package/hooks/useNavigateAway.js +24 -0
- package/hooks/usePrevious.js +8 -0
- package/hooks/usePreviousRef.js +8 -0
- package/hooks/useReveal.js +41 -0
- package/hooks/useScrollPosition.js +57 -0
- package/hooks/useScrollThreshold.js +25 -0
- package/hooks/useScrollTo.js +17 -0
- package/hooks/useSmoothScroll.js +31 -0
- package/hooks/useSpinDelay.js +35 -0
- package/hooks/useTraceUpdate.js +16 -0
- package/hooks/useUpdateEffect.js +10 -0
- package/hooks/useWindowSize.js +19 -0
- package/index.cjs.js +2 -2
- package/index.esm.js +2 -2
- package/index.js +3 -0
- package/package.json +3 -3
- package/types.js +1 -0
- package/utils/Polymorphic.js +1 -0
- package/utils/classed.js +40 -0
- package/utils/createUseMediaQueryWidth.js +37 -0
- package/utils/extendComponent.js +8 -0
- package/utils/index.js +4 -0
- package/utils/mergeRefs.js +12 -0
package/utils/classed.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { createElement, forwardRef } from "react";
|
|
2
|
+
export let classed = (component) => {
|
|
3
|
+
const type = component.type || component;
|
|
4
|
+
return function (strings, ...args) {
|
|
5
|
+
const WrappedComponent = forwardRef(function (props, ref) {
|
|
6
|
+
const argResolved = args
|
|
7
|
+
.map((arg, index) => {
|
|
8
|
+
let result = "";
|
|
9
|
+
if (typeof arg === "function") {
|
|
10
|
+
result = arg(props);
|
|
11
|
+
}
|
|
12
|
+
else if (typeof arg !== "undefined") {
|
|
13
|
+
result = arg.toString();
|
|
14
|
+
}
|
|
15
|
+
return strings[index] + result;
|
|
16
|
+
})
|
|
17
|
+
.join("");
|
|
18
|
+
const isNativeHtmlElement = typeof type === "string";
|
|
19
|
+
const propsToForward = isNativeHtmlElement
|
|
20
|
+
? {}
|
|
21
|
+
: props;
|
|
22
|
+
if (isNativeHtmlElement) {
|
|
23
|
+
for (const key in props) {
|
|
24
|
+
if (!key.startsWith("$")) {
|
|
25
|
+
propsToForward[key] = props[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
let className = argResolved || strings[0];
|
|
30
|
+
className = className.match(/class="([^"]*)/)?.[1] || className;
|
|
31
|
+
className += props?.className ? " " + props?.className : "";
|
|
32
|
+
return createElement(type, {
|
|
33
|
+
...propsToForward,
|
|
34
|
+
className: className || undefined,
|
|
35
|
+
ref,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return WrappedComponent;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { getMediaQueryWidthResolvers, isUndefined, } from "@koine/utils";
|
|
3
|
+
import { useIsomorphicLayoutEffect } from "../hooks";
|
|
4
|
+
export let createUseMediaQueryWidth = (customBreakpoints) => {
|
|
5
|
+
const queryResolvers = getMediaQueryWidthResolvers(customBreakpoints);
|
|
6
|
+
return function useMediaQueryWidth(media, serverValue) {
|
|
7
|
+
const definition = media.substring(1);
|
|
8
|
+
let [rule, ruleBreakpoint] = definition.split("-");
|
|
9
|
+
if (isUndefined(ruleBreakpoint)) {
|
|
10
|
+
ruleBreakpoint = rule;
|
|
11
|
+
}
|
|
12
|
+
if (isUndefined(rule)) {
|
|
13
|
+
rule = "min";
|
|
14
|
+
}
|
|
15
|
+
const [br1, br2] = ruleBreakpoint.split("_");
|
|
16
|
+
const query = queryResolvers[rule](br1, br2);
|
|
17
|
+
const [matches, setMatches] = useState(isUndefined(serverValue) ? null : serverValue);
|
|
18
|
+
useIsomorphicLayoutEffect(() => {
|
|
19
|
+
const mq = window.matchMedia(query);
|
|
20
|
+
const handleChange = (event) => {
|
|
21
|
+
setMatches(event.matches);
|
|
22
|
+
};
|
|
23
|
+
setMatches(mq.matches);
|
|
24
|
+
if (!mq.addEventListener) {
|
|
25
|
+
mq.addListener(handleChange);
|
|
26
|
+
return () => {
|
|
27
|
+
mq.removeListener(handleChange);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
mq.addEventListener("change", handleChange);
|
|
31
|
+
return () => {
|
|
32
|
+
mq.removeEventListener("change", handleChange);
|
|
33
|
+
};
|
|
34
|
+
}, [query]);
|
|
35
|
+
return matches;
|
|
36
|
+
};
|
|
37
|
+
};
|
package/utils/index.js
ADDED