@koine/react 1.0.3 → 1.0.8
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.js +18 -0
- package/Alert/index.js +1 -0
- package/Animations/Reveal.js +17 -0
- package/Animations/Underline.js +15 -0
- package/Animations/index.js +3 -0
- package/Animations/useReveal.js +70 -0
- package/Autocomplete/AutocompleteDownshift.js +158 -0
- package/Autocomplete/AutocompleteDownshiftMultiselect.js +353 -0
- package/Autocomplete/AutocompleteMui.js +172 -0
- package/Autocomplete/AutocompleteReach.js +112 -0
- package/Autocomplete/components.js +89 -0
- package/Autocomplete/helpers.js +28 -0
- package/Autocomplete/index.js +3 -0
- package/Bg/BgColor.js +33 -0
- package/Bg/BgPhoto.js +59 -0
- package/Bg/BgSvg.js +15 -0
- package/Bg/index.js +3 -0
- package/Breadcrumbs/Breadcrumbs.js +70 -0
- package/Breadcrumbs/index.js +1 -0
- package/Buttons/Button.js +79 -0
- package/Buttons/ButtonComposite.d.ts +1 -1
- package/Buttons/ButtonComposite.js +53 -0
- package/Buttons/ButtonFab.js +8 -0
- package/Buttons/ButtonLink.js +16 -0
- package/Buttons/IconButton.js +19 -0
- package/Buttons/index.js +5 -0
- package/Calendar/CalendarDaygridCell.js +52 -0
- package/Calendar/CalendarDaygridNav.js +23 -0
- package/Calendar/CalendarDaygridTable.js +49 -0
- package/Calendar/CalendarLegend.js +12 -0
- package/Calendar/calendar-api-google.js +97 -0
- package/Calendar/index.js +6 -0
- package/Calendar/types.js +1 -0
- package/Calendar/useCalendar.js +166 -0
- package/Calendar/utils.js +197 -0
- package/Carousel/Carousel.js +378 -0
- package/Carousel/CarouselCss.js +39 -0
- package/Carousel/index.js +1 -0
- package/Collapsable/Collapsable.js +132 -0
- package/Collapsable/index.js +1 -0
- package/Debug/Debug.js +21 -0
- package/Debug/index.js +1 -0
- package/Dialog/Dialog.js +93 -0
- package/Dialog/index.js +1 -0
- package/Editor/Editor--tiptap.js +21 -0
- package/Editor/components.d.ts +1 -2
- package/Editor/components.js +28 -0
- package/Editor/index.js +1 -0
- package/Favicon/FaviconTags.js +14 -0
- package/Favicon/index.js +1 -0
- package/Forms/Checkbox/Checkbox.js +24 -0
- package/Forms/Checkbox/index.js +1 -0
- package/Forms/Feedback/Feedback.js +10 -0
- package/Forms/Feedback/index.js +1 -0
- package/Forms/Field/Field.js +61 -0
- package/Forms/Field/FieldControl.js +45 -0
- package/Forms/Field/FieldHint.js +6 -0
- package/Forms/Field/index.js +2 -0
- package/Forms/Form/Form.js +64 -0
- package/Forms/Form/index.js +1 -0
- package/Forms/Input/Input.js +25 -0
- package/Forms/Input/index.js +1 -0
- package/Forms/InputGroup/InputGroup.js +42 -0
- package/Forms/InputGroup/index.js +1 -0
- package/Forms/Label/Label.js +24 -0
- package/Forms/Label/index.js +1 -0
- package/Forms/Password/Password.js +32 -0
- package/Forms/Password/index.js +1 -0
- package/Forms/Radio/Radio.js +31 -0
- package/Forms/Radio/index.js +1 -0
- package/Forms/Switch/Switch.js +50 -0
- package/Forms/Switch/index.js +1 -0
- package/Forms/Textarea/Textarea.js +15 -0
- package/Forms/Textarea/TextareaRich.js +44 -0
- package/Forms/Textarea/index.js +2 -0
- package/Forms/Toggle/Toggle.js +79 -0
- package/Forms/Toggle/index.js +1 -0
- package/Forms/Toggle/useToggle.js +143 -0
- package/Forms/antispam.js +56 -0
- package/Forms/helpers.js +44 -0
- package/Forms/index.js +17 -0
- package/Forms/styles.js +60 -0
- package/Gauge/Gauge.js +102 -0
- package/Grid/Grid.js +79 -0
- package/Grid/index.js +1 -0
- package/Hamburger/Hamburger.js +55 -0
- package/Hamburger/index.js +1 -0
- package/Header/index.js +1 -0
- package/Header/useHeader.js +30 -0
- package/Hidden/Hidden.js +14 -0
- package/Hidden/index.js +1 -0
- package/Img/Img.js +34 -0
- package/Img/index.js +1 -0
- package/Link/Link.js +2 -0
- package/Link/LinkBlank.d.ts +1 -1
- package/Link/LinkBlank.js +28 -0
- package/Link/index.js +2 -0
- package/Menu/Menu.js +11 -0
- package/Menu/index.js +1 -0
- package/MenuItem/MenuItem.js +20 -0
- package/MenuItem/index.js +1 -0
- package/Meta/Meta.js +4 -0
- package/Meta/index.js +1 -0
- package/NoJs/NoJs.js +6 -0
- package/NoJs/index.js +1 -0
- package/Pagination/PaginationNav.js +87 -0
- package/Pagination/PaginationResults.js +10 -0
- package/Pagination/index.js +2 -0
- package/Pill/Pill.js +37 -0
- package/Pill/index.js +1 -0
- package/Progress/ProgressCircular.js +38 -0
- package/Progress/ProgressLinear.js +34 -0
- package/Progress/ProgressOverlay.js +40 -0
- package/Progress/index.js +3 -0
- package/Rating/Rating.js +93 -0
- package/Rating/index.js +45 -0
- package/Select/SelectDownshift.js +38 -0
- package/Select/components.js +20 -0
- package/Select/index.js +3 -0
- package/Sidebar/Sidebar.js +48 -0
- package/Sidebar/index.js +1 -0
- package/Spacing/Spacing.js +47 -0
- package/Spacing/index.js +1 -0
- package/Sticky/Sticky.js +220 -0
- package/Sticky/StickyCss.js +6 -0
- package/Sticky/index.js +1 -0
- package/Tabs/Tabs.js +67 -0
- package/Tabs/index.js +1 -0
- package/Typography/CopyPasteVisible.js +6 -0
- package/Typography/Native.js +47 -0
- package/Typography/ReadMore.js +71 -0
- package/Typography/TextLoop.js +45 -0
- package/Typography/TypeStairs.js +46 -0
- package/Typography/index.js +5 -0
- package/helpers/index.js +19 -0
- package/hooks/index.js +5 -0
- package/hooks/useDateLocale.js +30 -0
- package/hooks/useFocus.js +11 -0
- package/hooks/usePrevious.js +8 -0
- package/hooks/useTraceUpdate.js +20 -0
- package/hooks/useWindowSize.js +13 -0
- package/index.js +36 -0
- package/index.umd.js +234 -257
- package/package.json +15 -9
- package/styles/Body.js +17 -0
- package/styles/Global.js +50 -0
- package/styles/classed.js +11 -0
- package/styles/index.js +7 -0
- package/styles/media.js +150 -0
- package/styles/spacing.d.ts +6 -6
- package/styles/spacing.js +46 -0
- package/styles/styled.d.ts +2 -2
- package/styles/styled.js +27 -0
- package/styles/theme--vanilla.js +53 -0
- package/styles/theme.d.ts +0 -7
- package/styles/theme.js +38 -0
- package/types.js +1 -0
- package/typings.d.ts +21 -0
- package/index.esm.js +0 -9472
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { min } from "../styles/media";
|
|
3
|
+
export const p = `
|
|
4
|
+
margin: 0 0 1em 0;
|
|
5
|
+
`;
|
|
6
|
+
export const h1 = `
|
|
7
|
+
margin: 0 0 10px 0;
|
|
8
|
+
font-size: 30px;
|
|
9
|
+
font-weight: 800;
|
|
10
|
+
line-height: var(--headingsLineHeight);
|
|
11
|
+
${min.md} {
|
|
12
|
+
font-size: 50px;
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
export const h2 = `
|
|
16
|
+
margin: 0 0 1em 0;
|
|
17
|
+
font-size: 24px;
|
|
18
|
+
font-weight: 800;
|
|
19
|
+
line-height: var(--headingsLineHeight);
|
|
20
|
+
`;
|
|
21
|
+
export const h3 = `
|
|
22
|
+
margin: 0 0 1em 0;
|
|
23
|
+
font-size: 20px;
|
|
24
|
+
font-weight: 600;
|
|
25
|
+
line-height: var(--headingsLineHeight);
|
|
26
|
+
`;
|
|
27
|
+
export const h4 = `
|
|
28
|
+
margin: 0 0 1em 0;
|
|
29
|
+
font-size: 13px;
|
|
30
|
+
font-weight: 600;
|
|
31
|
+
line-height: var(--headingsLineHeight);
|
|
32
|
+
`;
|
|
33
|
+
export const P = styled.div `
|
|
34
|
+
${p}
|
|
35
|
+
`;
|
|
36
|
+
export const H1 = styled.div `
|
|
37
|
+
${h1}
|
|
38
|
+
`;
|
|
39
|
+
export const H2 = styled.div `
|
|
40
|
+
${h2}
|
|
41
|
+
`;
|
|
42
|
+
export const H3 = styled.div `
|
|
43
|
+
${h3}
|
|
44
|
+
`;
|
|
45
|
+
export const H4 = styled.div `
|
|
46
|
+
${h4}
|
|
47
|
+
`;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef, useMemo } from "react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { useIsomorphicLayoutEffect } from "react-use";
|
|
6
|
+
import { m, useSpring } from "framer-motion";
|
|
7
|
+
// import { CgArrowsExpandDownRight as IconExpand } from "react-icons/cg";
|
|
8
|
+
const Root = styled.div ``;
|
|
9
|
+
const Content = styled.div `
|
|
10
|
+
& p:first-child {
|
|
11
|
+
margin-top: 0;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
const BtnWrap = styled.span `
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: flex-end;
|
|
17
|
+
transition: transform 0.18s ease-in-out;
|
|
18
|
+
text-align: right;
|
|
19
|
+
transform: translateY(${(p) => (p.$expanded ? "0" : "-100%")});
|
|
20
|
+
opacity: ${(p) => (p.$expanded ? 0 : 1)};
|
|
21
|
+
`;
|
|
22
|
+
const BtnFader = styled.div `
|
|
23
|
+
width: 30%;
|
|
24
|
+
transition: transform 0.18s ease-in-out;
|
|
25
|
+
background: linear-gradient(45deg, transparent 50%, ${(p) => p.$bg} 70%);
|
|
26
|
+
`;
|
|
27
|
+
const Btn = styled.span `
|
|
28
|
+
padding: 0 10px 0 10px;
|
|
29
|
+
line-height: ${(p) => (p.$lineHeight ? p.$lineHeight : "inherit")};
|
|
30
|
+
background: var(--bodyBg);
|
|
31
|
+
color: var(--grey600);
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
font-size: ${(p) => p.$fontSize}px;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
`;
|
|
36
|
+
const BtnIcon = styled.span `
|
|
37
|
+
display: inline-block;
|
|
38
|
+
margin: 0 0 0 4px;
|
|
39
|
+
transition: transform 0.18s ease-in-out;
|
|
40
|
+
${(p) => (p.$expanded ? "transform: rotate(180deg);" : "")};
|
|
41
|
+
font-size: ${(p) => p.$fontSize}px;
|
|
42
|
+
`;
|
|
43
|
+
export const ReadMore = (_a) => {
|
|
44
|
+
var { lines = 3, lineHeight = 1.6, fontSize = 14, bg = "var(--bodyBg)", expand = "Expand", collapse = "Collapse" } = _a, props = __rest(_a, ["lines", "lineHeight", "fontSize", "bg", "expand", "collapse"]);
|
|
45
|
+
const defaultMaxHeight = lines * (lineHeight * fontSize);
|
|
46
|
+
const [expanded, setExpanded] = useState(false);
|
|
47
|
+
const [maxHeight, setMaxHeight] = useState(defaultMaxHeight);
|
|
48
|
+
const [fullHeight, setFullHeight] = useState(0);
|
|
49
|
+
const [exceeds, setExceeds] = useState(false);
|
|
50
|
+
const content = useRef(null);
|
|
51
|
+
const height = useSpring(defaultMaxHeight);
|
|
52
|
+
const styles = useMemo(() => (exceeds ? { height, overflow: "hidden" } : {}), [exceeds, height]);
|
|
53
|
+
const handleExpandClick = () => {
|
|
54
|
+
setExpanded((prevExpanded) => !prevExpanded);
|
|
55
|
+
};
|
|
56
|
+
useIsomorphicLayoutEffect(() => {
|
|
57
|
+
if (content.current) {
|
|
58
|
+
const elementHeight = content.current.offsetHeight;
|
|
59
|
+
const newExceeds = elementHeight > maxHeight;
|
|
60
|
+
if (!newExceeds) {
|
|
61
|
+
setMaxHeight(elementHeight);
|
|
62
|
+
}
|
|
63
|
+
setExceeds(newExceeds);
|
|
64
|
+
setFullHeight(elementHeight);
|
|
65
|
+
}
|
|
66
|
+
}, [content, maxHeight]);
|
|
67
|
+
useIsomorphicLayoutEffect(() => {
|
|
68
|
+
height.set(expanded ? fullHeight : maxHeight);
|
|
69
|
+
}, [expanded, height, fullHeight, maxHeight]);
|
|
70
|
+
return (_jsxs(Root, { children: [_jsx(m.div, Object.assign({ style: styles }, { children: _jsx(Content, Object.assign({ ref: content }, props)) })), exceeds && (_jsxs(BtnWrap, Object.assign({ "$expanded": expanded }, { children: [_jsx(BtnFader, { "$bg": bg }), _jsxs(Btn, Object.assign({ "$fontSize": fontSize, "$lineHeight": lineHeight, onClick: handleExpandClick, "aria-expanded": expanded, "aria-label": expanded ? collapse : expand }, { children: [expanded ? collapse : expand, _jsx(BtnIcon, { "$expanded": expanded })] }))] })))] }));
|
|
71
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { m, AnimatePresence } from "framer-motion";
|
|
5
|
+
export const TextLoopPiece = ({ text = "", style = {}, className = "", direction = "up", inline = true, noOverflow = true, delay = 400, }) => {
|
|
6
|
+
const placeholderRef = useRef(null);
|
|
7
|
+
const [content, setContent] = useState({ data: "", key: "" });
|
|
8
|
+
const [width, setWidth] = useState(inline ? 0 : "auto");
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const timeoutId = setTimeout(() => {
|
|
11
|
+
if (!placeholderRef.current)
|
|
12
|
+
return;
|
|
13
|
+
placeholderRef.current.innerHTML = text + "";
|
|
14
|
+
if (inline)
|
|
15
|
+
setWidth(placeholderRef.current.offsetWidth);
|
|
16
|
+
setContent({ data: text + "", key: new Date() + "" });
|
|
17
|
+
}, delay);
|
|
18
|
+
return () => clearTimeout(timeoutId);
|
|
19
|
+
}, [text, delay, inline]);
|
|
20
|
+
return (_jsxs("div", Object.assign({ className: className, style: Object.assign(Object.assign({}, style), { position: "relative", display: inline ? "inline-block" : "block", width, whiteSpace: inline ? "nowrap" : "normal" }) }, { children: [_jsx("span", { ref: placeholderRef, style: { visibility: "hidden" } }), _jsx("div", Object.assign({ style: {
|
|
21
|
+
overflow: noOverflow ? "hidden" : "visible",
|
|
22
|
+
display: "block",
|
|
23
|
+
position: "absolute",
|
|
24
|
+
top: 0,
|
|
25
|
+
left: 0,
|
|
26
|
+
height: "100%",
|
|
27
|
+
width: "100%",
|
|
28
|
+
} }, { children: _jsx(AnimatePresence, { children: _jsx(m.div, Object.assign({ style: { position: "absolute" }, initial: {
|
|
29
|
+
opacity: 0,
|
|
30
|
+
y: direction === "down" ? "-100%" : "100%",
|
|
31
|
+
}, animate: { opacity: 1, y: 0 }, exit: {
|
|
32
|
+
opacity: 0,
|
|
33
|
+
y: direction === "down" ? "100%" : "-100%",
|
|
34
|
+
} }, { children: content.data }), content.key) }) }))] })));
|
|
35
|
+
};
|
|
36
|
+
export const TextLoop = (_a) => {
|
|
37
|
+
var { texts, interval = 3000 } = _a, props = __rest(_a, ["texts", "interval"]);
|
|
38
|
+
const [index, setIndex] = useState(0);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const intervalId = setInterval(() => setIndex((index) => index + 1), interval // every 3 seconds
|
|
41
|
+
);
|
|
42
|
+
return () => clearTimeout(intervalId);
|
|
43
|
+
}, [interval]);
|
|
44
|
+
return _jsx(TextLoopPiece, Object.assign({}, props, { text: texts[index % texts.length] }));
|
|
45
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
export const TypeStairs = forwardRef(({ children, limit }, ref) => {
|
|
4
|
+
// split in rows or just use one row if there is no limit
|
|
5
|
+
const rows = limit ? splitTextIntoRows(children, limit) : [children];
|
|
6
|
+
return rows.length > 1 ? (_jsx(_Fragment, { children: rows.map((row, rowIndex) => {
|
|
7
|
+
return (_jsxs("span", { children: [renderRow(row, rowIndex, ref), rowIndex !== rows.length - 1 && _jsx("br", {})] }, `row-${rowIndex}`));
|
|
8
|
+
}) })) : (renderRow(rows[0], 0, ref));
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* every number chars find a space and break, then restart the gradient weight
|
|
12
|
+
* @see https://stackoverflow.com/a/25770787
|
|
13
|
+
*/
|
|
14
|
+
function splitTextIntoRows(input = "", limit = 18) {
|
|
15
|
+
const rows = [];
|
|
16
|
+
const arr = input.split(" ");
|
|
17
|
+
let currow = arr[0];
|
|
18
|
+
let rowlen = currow.length;
|
|
19
|
+
for (let i = 1; i < arr.length; i++) {
|
|
20
|
+
const word = arr[i];
|
|
21
|
+
rowlen += word.length + 1;
|
|
22
|
+
if (rowlen <= limit) {
|
|
23
|
+
currow += " " + word;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
rows.push(currow);
|
|
27
|
+
currow = word;
|
|
28
|
+
rowlen = word.length;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
rows.push(currow);
|
|
32
|
+
return rows;
|
|
33
|
+
}
|
|
34
|
+
function renderRow(row, rowIndex, ref) {
|
|
35
|
+
const letters = row.split("");
|
|
36
|
+
let fontWeightIdx = 1;
|
|
37
|
+
// const fontWeight = Math.min(fontWeightIdx * 100, 800);
|
|
38
|
+
return (_jsx(_Fragment, { children: letters.map((letter, letterIndex) => {
|
|
39
|
+
const fontWeight = Math.min(fontWeightIdx * 100, 800);
|
|
40
|
+
// don't waste a fontWeight for a white space
|
|
41
|
+
if (letter !== " ") {
|
|
42
|
+
fontWeightIdx++;
|
|
43
|
+
}
|
|
44
|
+
return (_jsx("span", Object.assign({ style: { fontWeight }, ref: ref }, { children: letter }), `letter-${rowIndex}-${letterIndex}`));
|
|
45
|
+
}) }));
|
|
46
|
+
}
|
package/helpers/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isBrowser } from "@koine/utils";
|
|
2
|
+
import { useHeader } from "../Header";
|
|
3
|
+
export function useScrollTo(id = "", offset = 0) {
|
|
4
|
+
const [, , headerHeight] = useHeader();
|
|
5
|
+
if (!isBrowser) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const headerOffset = headerHeight || 0;
|
|
9
|
+
let element = document.getElementById(id);
|
|
10
|
+
let top = 0;
|
|
11
|
+
if (element && element.offsetParent) {
|
|
12
|
+
do {
|
|
13
|
+
top += element.offsetTop;
|
|
14
|
+
} while ((element = element.offsetParent));
|
|
15
|
+
}
|
|
16
|
+
top -= offset;
|
|
17
|
+
top -= headerOffset;
|
|
18
|
+
window.scroll(0, top);
|
|
19
|
+
}
|
package/hooks/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Dynamically import the date-fns correct locale
|
|
5
|
+
*
|
|
6
|
+
* Inspired by:
|
|
7
|
+
* @see https://robertmarshall.dev/blog/dynamically-import-datefns-locale-mui-datepicker-localization/
|
|
8
|
+
*/
|
|
9
|
+
export function useDateLocale(locale, defaultLocale = "en") {
|
|
10
|
+
const [data, setData] = useState();
|
|
11
|
+
const [current, setCurrent] = useState(defaultLocale);
|
|
12
|
+
// const [ready, setReady] = useState(false);
|
|
13
|
+
// If the user changes the locale listen to the change and import the locale that is now required.
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const importLocaleFile = () => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
// This webpack option stops all of the date-fns files being imported and chunked.
|
|
17
|
+
const localeToSet = yield import(
|
|
18
|
+
/* webpackMode: "lazy", webpackChunkName: "df-[index]", webpackExclude: /_lib/ */
|
|
19
|
+
`date-fns/locale/${locale}/index.js`);
|
|
20
|
+
setCurrent(locale || current);
|
|
21
|
+
setData(localeToSet.default);
|
|
22
|
+
// setReady(true);
|
|
23
|
+
});
|
|
24
|
+
// If the locale has not yet been loaded.
|
|
25
|
+
if (locale !== current) {
|
|
26
|
+
importLocaleFile();
|
|
27
|
+
}
|
|
28
|
+
}, [locale, current]);
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://stackoverflow.com/a/54159564/1938970
|
|
4
|
+
*/
|
|
5
|
+
export const useFocus = () => {
|
|
6
|
+
const element = useRef(null);
|
|
7
|
+
const setFocus = () => {
|
|
8
|
+
element.current && element.current.focus();
|
|
9
|
+
};
|
|
10
|
+
return [element, setFocus];
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://stackoverflow.com/a/51082563/9122820
|
|
4
|
+
*/
|
|
5
|
+
export function useTraceUpdate(props) {
|
|
6
|
+
const prev = useRef(props);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const changedProps = Object.entries(props).reduce((ps, [k, v]) => {
|
|
9
|
+
if (prev.current[k] !== v) {
|
|
10
|
+
// @ts-expect-error Does not matter here...
|
|
11
|
+
ps[k] = [prev.current[k], v];
|
|
12
|
+
}
|
|
13
|
+
return ps;
|
|
14
|
+
}, {});
|
|
15
|
+
if (Object.keys(changedProps).length > 0) {
|
|
16
|
+
console.log("Changed props:", changedProps);
|
|
17
|
+
}
|
|
18
|
+
prev.current = props;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
export function useWindowSize() {
|
|
3
|
+
const [size, setSize] = useState([0, 0]);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
function updateSize() {
|
|
6
|
+
setSize([window.innerWidth, window.innerHeight]);
|
|
7
|
+
}
|
|
8
|
+
window.addEventListener("resize", updateSize);
|
|
9
|
+
updateSize();
|
|
10
|
+
return () => window.removeEventListener("resize", updateSize);
|
|
11
|
+
}, []);
|
|
12
|
+
return size;
|
|
13
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export * from "./Alert";
|
|
2
|
+
export * from "./Animations";
|
|
3
|
+
export * from "./Autocomplete";
|
|
4
|
+
export * from "./Bg";
|
|
5
|
+
export * from "./Breadcrumbs";
|
|
6
|
+
export * from "./Buttons";
|
|
7
|
+
export * from "./Carousel";
|
|
8
|
+
export * from "./Calendar";
|
|
9
|
+
export * from "./Collapsable";
|
|
10
|
+
export * from "./Debug";
|
|
11
|
+
export * from "./Dialog";
|
|
12
|
+
export * from "./Favicon";
|
|
13
|
+
export * from "./Forms";
|
|
14
|
+
export * from "./Grid";
|
|
15
|
+
export * from "./Hamburger";
|
|
16
|
+
export * from "./Header";
|
|
17
|
+
export * from "./helpers";
|
|
18
|
+
export * from "./Hidden";
|
|
19
|
+
export * from "./hooks";
|
|
20
|
+
export * from "./Img";
|
|
21
|
+
export * from "./Link";
|
|
22
|
+
export * from "./MenuItem";
|
|
23
|
+
export * from "./Meta";
|
|
24
|
+
export * from "./NoJs";
|
|
25
|
+
export * from "./Pagination";
|
|
26
|
+
export * from "./Pill";
|
|
27
|
+
export * from "./Progress";
|
|
28
|
+
export * from "./Rating";
|
|
29
|
+
// export * from "./Select";
|
|
30
|
+
export * from "./Sidebar";
|
|
31
|
+
export * from "./Spacing";
|
|
32
|
+
export * from "./Sticky";
|
|
33
|
+
export * from "./styles";
|
|
34
|
+
export * from "./Tabs";
|
|
35
|
+
export * from "./Typography";
|
|
36
|
+
export * from "./types";
|