@koine/react 1.0.5 → 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 +232 -239
- 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 -9456
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* @file
|
|
5
|
+
*
|
|
6
|
+
* Maybe do a simplified version following this example:
|
|
7
|
+
* https://codesandbox.io/s/framer-motion-accordion-qx958?file=/src/Example.tsx
|
|
8
|
+
*/
|
|
9
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
10
|
+
import styled from "styled-components";
|
|
11
|
+
import { m } from "framer-motion";
|
|
12
|
+
import { Disclosure, DisclosureButton, DisclosurePanel, } from "@reach/disclosure";
|
|
13
|
+
import { BsBoxArrowInDown as IconCollapse } from "react-icons/bs";
|
|
14
|
+
// FIXME: ssr likely problem
|
|
15
|
+
import { uid } from "@koine/utils";
|
|
16
|
+
import { btnStyleReset } from "../Buttons";
|
|
17
|
+
import { useWindowSize } from "../hooks/useWindowSize";
|
|
18
|
+
import { InputInvisible } from "../Forms/styles";
|
|
19
|
+
export const CollapsableHeadRoot = styled(m.label).attrs((props) => ({
|
|
20
|
+
htmlFor: `${props.id}-input`,
|
|
21
|
+
})) `
|
|
22
|
+
${btnStyleReset}
|
|
23
|
+
width: 100%;
|
|
24
|
+
padding: 0;
|
|
25
|
+
text-align: left;
|
|
26
|
+
display: flex;
|
|
27
|
+
justify-content: space-between;
|
|
28
|
+
align-items: center;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
`;
|
|
31
|
+
export const CollapsableHeadSpace = styled.div `
|
|
32
|
+
flex: 1;
|
|
33
|
+
padding-left: 20px;
|
|
34
|
+
`;
|
|
35
|
+
export const CollapsableHeadAction = styled.div `
|
|
36
|
+
padding-left: 20px;
|
|
37
|
+
`;
|
|
38
|
+
export const CollaspableHeadLine = styled(m.div) `
|
|
39
|
+
width: 0%;
|
|
40
|
+
height: 1px;
|
|
41
|
+
background: #bbb;
|
|
42
|
+
`;
|
|
43
|
+
export const collapsableHeadLineMotion = {
|
|
44
|
+
hover: {
|
|
45
|
+
width: "100%",
|
|
46
|
+
transition: {
|
|
47
|
+
duration: 0.4,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
export const CollapsableHeadText = styled.div ``;
|
|
52
|
+
export const CollapsableHeadIcon = styled(m.div) ``;
|
|
53
|
+
export const CollapsableHead = ({ $expanded, id, onClick, HeadRoot = CollapsableHeadRoot, HeadAction = CollapsableHeadAction, HeadIcon = CollapsableHeadIcon, children, }) => {
|
|
54
|
+
return (_jsxs(DisclosureButton, Object.assign({ onClick: onClick,
|
|
55
|
+
// tabIndex={0}
|
|
56
|
+
// role="tab"
|
|
57
|
+
initial: "rest", whileHover: "hover", "$expanded": $expanded, as: HeadRoot, id: id }, { children: [_jsx(CollapsableHeadText, { children: children }), _jsx(CollapsableHeadSpace, { children: _jsx(CollaspableHeadLine, { variants: collapsableHeadLineMotion, animate: $expanded ? "hover" : "" }) }), HeadAction && (_jsx(HeadAction, { children: HeadIcon && (_jsx(HeadIcon, Object.assign({ animate: { rotate: $expanded ? 180 : 0 } }, { children: _jsx(IconCollapse, {}) }))) }))] })));
|
|
58
|
+
};
|
|
59
|
+
export const CollapsableInput = styled(InputInvisible).attrs({
|
|
60
|
+
type: "checkbox",
|
|
61
|
+
}) ``;
|
|
62
|
+
export const CollasableBodyWrap = styled(DisclosurePanel) `
|
|
63
|
+
/* this is because @reach adds the "hidden" attribute */
|
|
64
|
+
|
|
65
|
+
&[hidden] {
|
|
66
|
+
display: block;
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
export const CollapsableBodyRoot = styled(m.div) `
|
|
70
|
+
.no-js & {
|
|
71
|
+
transition: margin-top 0.2s ease;
|
|
72
|
+
}
|
|
73
|
+
.no-js ${CollapsableInput}:checked + ${CollasableBodyWrap} & {
|
|
74
|
+
margin-top: 0 !important;
|
|
75
|
+
opacity: 1 !important;
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
export const CollapsableBody = forwardRef(function CollapsableBody(props, ref) {
|
|
79
|
+
return _jsx(CollapsableBodyRoot, Object.assign({ ref: ref }, props));
|
|
80
|
+
});
|
|
81
|
+
export const Collapsable = (_a) => {
|
|
82
|
+
var { expanded: propExpanded, recalc, onChange, id, head, body,
|
|
83
|
+
// autoCollapse,
|
|
84
|
+
components = {}, ariaExpand = "Expand", ariaCollapse = "Collapse" } = _a, props = __rest(_a, ["expanded", "recalc", "onChange", "id", "head", "body", "components", "ariaExpand", "ariaCollapse"]);
|
|
85
|
+
const isControlled = typeof propExpanded !== "undefined";
|
|
86
|
+
const [stateExpanded, setStateExpanded] = useState(propExpanded);
|
|
87
|
+
const [height, setHeight] = useState(0);
|
|
88
|
+
const hash = id ? `#${id}` : "";
|
|
89
|
+
const winSize = useWindowSize();
|
|
90
|
+
const expanded = isControlled ? propExpanded : stateExpanded;
|
|
91
|
+
const [overflow, setOverflow] = useState(expanded ? "unset" : "hidden");
|
|
92
|
+
const content = useRef(null);
|
|
93
|
+
// FIXME: ssr likely problem
|
|
94
|
+
id = id || uid();
|
|
95
|
+
const handleClick = useCallback(() => {
|
|
96
|
+
if (hash) {
|
|
97
|
+
window.history.replaceState(null, "", expanded ? window.location.pathname + window.location.search : hash);
|
|
98
|
+
}
|
|
99
|
+
if (onChange) {
|
|
100
|
+
onChange();
|
|
101
|
+
}
|
|
102
|
+
if (!isControlled) {
|
|
103
|
+
setStateExpanded((prevExpanded) => !prevExpanded);
|
|
104
|
+
}
|
|
105
|
+
}, [expanded, hash, onChange, isControlled]);
|
|
106
|
+
const handleAnimationStart = useCallback(() => {
|
|
107
|
+
setOverflow("hidden");
|
|
108
|
+
}, []);
|
|
109
|
+
const handleAnimationComplete = useCallback(() => {
|
|
110
|
+
setOverflow(expanded ? "unset" : "hidden");
|
|
111
|
+
}, [expanded]);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (content.current) {
|
|
114
|
+
setHeight(Math.ceil(content.current.offsetHeight));
|
|
115
|
+
}
|
|
116
|
+
}, [winSize, recalc]);
|
|
117
|
+
// deeplink on mount
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (!isControlled && hash && window.location.hash === hash) {
|
|
120
|
+
setStateExpanded(true);
|
|
121
|
+
}
|
|
122
|
+
}, [hash, isControlled]);
|
|
123
|
+
return (_jsxs(Disclosure, Object.assign({ id: id }, props, { open: expanded || false }, { children: [head !== null && (_jsx(CollapsableHead, Object.assign({ id: id, "$expanded": expanded, onClick: handleClick }, components, { children: head }))), _jsx(CollapsableInput, { id: `${id}-input` }), _jsx(CollasableBodyWrap, Object.assign({ "$expanded": expanded, style: { overflow } }, { children: _jsx(CollapsableBody, Object.assign({ ref: content, "$expanded": expanded,
|
|
124
|
+
// aria-expanded={expanded}
|
|
125
|
+
// aria-label={expanded ? ariaCollapse : ariaExpand}
|
|
126
|
+
style: {
|
|
127
|
+
pointerEvents: expanded ? "all" : "none",
|
|
128
|
+
}, onAnimationStart: handleAnimationStart, onAnimationComplete: handleAnimationComplete, animate: {
|
|
129
|
+
marginTop: expanded ? 0 : height ? `-${height}px` : "-100vh",
|
|
130
|
+
opacity: expanded ? 1 : 0.4,
|
|
131
|
+
} }, { children: body })) }))] })));
|
|
132
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Collapsable";
|
package/Debug/Debug.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
const Root = styled.div `
|
|
4
|
+
background: #f4f4f4;
|
|
5
|
+
border: 1px solid #ddd;
|
|
6
|
+
border-left: 3px solid #f36d33;
|
|
7
|
+
color: #666;
|
|
8
|
+
page-break-inside: avoid;
|
|
9
|
+
font-family: monospace;
|
|
10
|
+
font-size: small;
|
|
11
|
+
line-height: 1.6;
|
|
12
|
+
margin-bottom: 1.6em;
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
overflow: auto;
|
|
15
|
+
padding: 1em 1.5em;
|
|
16
|
+
display: block;
|
|
17
|
+
word-wrap: break-word;
|
|
18
|
+
`;
|
|
19
|
+
export const Debug = ({ data }) => {
|
|
20
|
+
return _jsx(Root, { children: JSON.stringify(data, undefined, 2) });
|
|
21
|
+
};
|
package/Debug/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Debug";
|
package/Dialog/Dialog.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import styled, { css } from "styled-components";
|
|
4
|
+
import { AnimatePresence, m } from "framer-motion";
|
|
5
|
+
import { MdClear as IconClose } from "react-icons/md";
|
|
6
|
+
import { DialogOverlay as BaseDialogOverlay, DialogContent as BaseDialogContent, } from "@reach/dialog";
|
|
7
|
+
import { min } from "../styles/media";
|
|
8
|
+
import { inset0 } from "../styles/styled";
|
|
9
|
+
import { IconButton } from "../Buttons";
|
|
10
|
+
export const koineDialogBg = css `
|
|
11
|
+
z-index: 1;
|
|
12
|
+
position: relative;
|
|
13
|
+
background: var(--bodyBg);
|
|
14
|
+
box-shadow: var(--shadow);
|
|
15
|
+
`;
|
|
16
|
+
export const koineDialogBackdropMotion = {
|
|
17
|
+
animate: {
|
|
18
|
+
backdropFilter: "blur(10px)",
|
|
19
|
+
background: "rgba(255,255,255,0.33)",
|
|
20
|
+
},
|
|
21
|
+
exit: {
|
|
22
|
+
backdropFilter: "blur(0px)",
|
|
23
|
+
background: "rgba(255,255,255,0)",
|
|
24
|
+
transition: { delay: 0.2 },
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export const koineDialogInnerMotion = {
|
|
28
|
+
initial: {
|
|
29
|
+
// scale: .7,
|
|
30
|
+
opacity: 0,
|
|
31
|
+
},
|
|
32
|
+
animate: {
|
|
33
|
+
scale: 1,
|
|
34
|
+
opacity: 1,
|
|
35
|
+
// transition: { delay: 0.2 },
|
|
36
|
+
},
|
|
37
|
+
exit: {
|
|
38
|
+
scale: 0.9,
|
|
39
|
+
opacity: 0,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export const KoineDialogOverlay = styled(BaseDialogOverlay) `
|
|
43
|
+
z-index: 100;
|
|
44
|
+
position: fixed;
|
|
45
|
+
${inset0}
|
|
46
|
+
`;
|
|
47
|
+
export const KoineDialogBackdrop = styled(m.div) `
|
|
48
|
+
z-index: 2;
|
|
49
|
+
position: fixed;
|
|
50
|
+
${inset0}
|
|
51
|
+
backdrop-filter: blur(0px);
|
|
52
|
+
`;
|
|
53
|
+
export const KoineDialogInner = styled(m.div) `
|
|
54
|
+
z-index: 3;
|
|
55
|
+
position: absolute;
|
|
56
|
+
${inset0}
|
|
57
|
+
overflow: hidden scroll;
|
|
58
|
+
${(p) => p.$centered &&
|
|
59
|
+
`${min.sm} {
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
align-items: center;
|
|
63
|
+
}`};
|
|
64
|
+
`;
|
|
65
|
+
// export const KoineDialogContent = styled(m(BaseDialogContent))<
|
|
66
|
+
export const KoineDialogContent = styled(BaseDialogContent) `
|
|
67
|
+
position: relative;
|
|
68
|
+
outline: 0px;
|
|
69
|
+
width: 100%;
|
|
70
|
+
margin: 0 auto;
|
|
71
|
+
`;
|
|
72
|
+
export const KoineDialogCloseButton = styled(IconButton) `
|
|
73
|
+
position: absolute;
|
|
74
|
+
padding: 0;
|
|
75
|
+
`;
|
|
76
|
+
export const KoineDialogHeader = styled.div `
|
|
77
|
+
z-index: 2;
|
|
78
|
+
position: relative;
|
|
79
|
+
`;
|
|
80
|
+
export const KoineDialogBody = styled.div `
|
|
81
|
+
position: relative;
|
|
82
|
+
|
|
83
|
+
&:hover ${KoineDialogCloseButton} {
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
export const KoineDialogBodyChildren = styled.div `
|
|
87
|
+
position: relative;
|
|
88
|
+
overflow: auto;
|
|
89
|
+
`;
|
|
90
|
+
export const KoineDialog = (_a) => {
|
|
91
|
+
var { children, title, onDismiss, isOpen, $centered = true } = _a, props = __rest(_a, ["children", "title", "onDismiss", "isOpen", "$centered"]);
|
|
92
|
+
return (_jsx(AnimatePresence, { children: isOpen && (_jsxs(KoineDialogOverlay, Object.assign({}, props, { onDismiss: onDismiss, isOpen: isOpen }, { children: [_jsx(KoineDialogBackdrop, Object.assign({}, koineDialogBackdropMotion)), _jsx(KoineDialogInner, Object.assign({}, koineDialogInnerMotion, { "$centered": $centered }, { children: _jsxs(KoineDialogContent, Object.assign({ "aria-label": title || "", "$centered": $centered }, { children: [title && _jsx(KoineDialogHeader, { children: title }), _jsxs(KoineDialogBody, { children: [_jsx(KoineDialogCloseButton, Object.assign({ onClick: onDismiss }, { children: _jsx(IconClose, {}) })), _jsx(KoineDialogBodyChildren, { children: children })] })] })) }))] }), "DialogOverlay")) }));
|
|
93
|
+
};
|
package/Dialog/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Dialog";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { useEditor, EditorContent } from "@tiptap/react";
|
|
5
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
6
|
+
import { EditorGlobalStyles, EditorRoot, EditorBarRoot, EditorBarBtn, EditorIconBold, EditorIconItalic, } from "./components";
|
|
7
|
+
export const EditorBar = ({ editor }) => {
|
|
8
|
+
const handleClick = useCallback((e, type) => {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus()[`toggle${type}`]().run();
|
|
11
|
+
}, [editor]);
|
|
12
|
+
if (!editor) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return (_jsxs(EditorBarRoot, { children: [_jsx(EditorBarBtn, Object.assign({ onClick: (e) => handleClick(e, "Bold"), className: editor.isActive("bold") ? "is-active" : "" }, { children: _jsx(EditorIconBold, {}) })), _jsx(EditorBarBtn, Object.assign({ onClick: (e) => handleClick(e, "Italic"), className: editor.isActive("bold") ? "is-active" : "" }, { children: _jsx(EditorIconItalic, {}) }))] }));
|
|
16
|
+
};
|
|
17
|
+
export const Editor = (_a) => {
|
|
18
|
+
var { options } = _a, props = __rest(_a, ["options"]);
|
|
19
|
+
const editor = useEditor(Object.assign({ extensions: [StarterKit], content: "" }, (options || {})));
|
|
20
|
+
return (_jsxs(EditorRoot, { children: [_jsx(EditorGlobalStyles, {}), _jsx(EditorBar, { editor: editor }), _jsx(EditorContent, Object.assign({ className: "EditorContent", editor: editor }, props))] }));
|
|
21
|
+
};
|
package/Editor/components.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { MdFormatBold as EditorIconBold } from "
|
|
2
|
-
export { MdFormatItalic as EditorIconItalic } from "@react-icons/all-files/md/MdFormatItalic";
|
|
1
|
+
export { MdFormatBold as EditorIconBold, MdFormatItalic as EditorIconItalic, } from "react-icons/md";
|
|
3
2
|
export declare const EditorRoot: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
4
3
|
export declare const EditorBarRoot: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
5
4
|
export declare const EditorBarBtn: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, import("..").KoineButtonUiProps & {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import styled, { createGlobalStyle } from "styled-components";
|
|
2
|
+
import { IconButton } from "../Buttons/IconButton";
|
|
3
|
+
import { inputPadding, inputBorder, inputFocus } from "../Forms/styles";
|
|
4
|
+
export { MdFormatBold as EditorIconBold, MdFormatItalic as EditorIconItalic, } from "react-icons/md";
|
|
5
|
+
export const EditorRoot = styled.div `
|
|
6
|
+
${inputBorder}
|
|
7
|
+
${inputFocus}
|
|
8
|
+
`;
|
|
9
|
+
export const EditorBarRoot = styled.div `
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: flex-end;
|
|
12
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
13
|
+
/* background: var(--grey900); */
|
|
14
|
+
`;
|
|
15
|
+
export const EditorBarBtn = styled(IconButton) ``;
|
|
16
|
+
export const EditorGlobalStyles = createGlobalStyle `
|
|
17
|
+
.ProseMirror {
|
|
18
|
+
${inputPadding}
|
|
19
|
+
|
|
20
|
+
&:focus {
|
|
21
|
+
outline:none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
> *:first-child {
|
|
25
|
+
margin-top: 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
package/Editor/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Editor--tiptap";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Favicon tags.
|
|
4
|
+
*
|
|
5
|
+
* This component is meant to be wrapped in a `<head>` manager component.
|
|
6
|
+
*
|
|
7
|
+
* These tags have been produced by [realfavicongenerator.net](https://realfavicongenerator.net/)
|
|
8
|
+
* on _**16 Feb 2022**_.
|
|
9
|
+
*
|
|
10
|
+
* @see https://realfavicongenerator.net/
|
|
11
|
+
*/
|
|
12
|
+
export const FaviconTags = ({ name, color, safariTabColor, tileColor, themeColor, }) => {
|
|
13
|
+
return (_jsxs(_Fragment, { children: [_jsx("link", { rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" }), _jsx("link", { rel: "icon", type: "image/png", sizes: "32x32", href: "/favicon-32x32.png" }), _jsx("link", { rel: "icon", type: "image/png", sizes: "16x16", href: "/favicon-16x16.png" }), _jsx("link", { rel: "manifest", href: "/site.webmanifest" }), _jsx("link", { rel: "mask-icon", href: "/safari-pinned-tab.svg", color: safariTabColor || color }), _jsx("meta", { name: "apple-mobile-web-app-title", content: name }), _jsx("meta", { name: "application-name", content: name }), _jsx("meta", { name: "msapplication-TileColor", content: tileColor || color }), _jsx("meta", { name: "theme-color", content: themeColor || color })] }));
|
|
14
|
+
};
|
package/Favicon/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FaviconTags";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { Toggle, ToggleLabel, ToggleIndicatorSquared } from "../Toggle";
|
|
5
|
+
import { useToggle } from "../Toggle/useToggle";
|
|
6
|
+
export const CheckboxRoot = styled.label `
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
`;
|
|
11
|
+
export const CheckboxToggle = styled(Toggle) `
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
`;
|
|
14
|
+
export const CheckboxIndicator = styled(ToggleIndicatorSquared) ``;
|
|
15
|
+
export const CheckboxLabel = styled(ToggleLabel) `
|
|
16
|
+
font-size: 0.8em;
|
|
17
|
+
`;
|
|
18
|
+
/**
|
|
19
|
+
* All logic and invisible Inputs come from the `useToggle` hook
|
|
20
|
+
*/
|
|
21
|
+
export const Checkbox = forwardRef(function Checkbox(props, ref) {
|
|
22
|
+
const { rootProps, Inputs, label } = useToggle(props, ref);
|
|
23
|
+
return (_jsxs(CheckboxRoot, Object.assign({}, rootProps, { children: [_jsxs(CheckboxToggle, { children: [Inputs, _jsx(CheckboxIndicator, {})] }), label && _jsx(CheckboxLabel, { children: label })] })));
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Checkbox";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
const Root = styled.div `
|
|
4
|
+
margin-top: 0.2em;
|
|
5
|
+
font-size: 12px;
|
|
6
|
+
${(p) => (p.$danger ? `color: var(--danger);` : "")}
|
|
7
|
+
`;
|
|
8
|
+
export const Feedback = ({ $danger, children }) => {
|
|
9
|
+
return (_jsx(Root, Object.assign({ role: "alert", "$danger": $danger }, { children: children })));
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Feedback";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import styled, { css } from "styled-components";
|
|
4
|
+
import { Feedback } from "../Feedback";
|
|
5
|
+
export const field = css `
|
|
6
|
+
padding-bottom: 20px;
|
|
7
|
+
`;
|
|
8
|
+
export const FieldBase = styled.div `
|
|
9
|
+
${field}
|
|
10
|
+
`;
|
|
11
|
+
export const FieldRoot = styled(FieldBase) `
|
|
12
|
+
${(p) => {
|
|
13
|
+
return (p.$danger &&
|
|
14
|
+
`
|
|
15
|
+
color: var(--danger);
|
|
16
|
+
|
|
17
|
+
textarea,
|
|
18
|
+
input,
|
|
19
|
+
select {
|
|
20
|
+
color: var(--danger);
|
|
21
|
+
}
|
|
22
|
+
`);
|
|
23
|
+
}}
|
|
24
|
+
`;
|
|
25
|
+
/**
|
|
26
|
+
* Yup's errors produce by these validations:
|
|
27
|
+
*
|
|
28
|
+
* ```
|
|
29
|
+
* email: string().email().required(),
|
|
30
|
+
* name: string().required()
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* determine the `error.type` of the `FieldError` to be "required" and "email".
|
|
34
|
+
* We assume these as standard translations keys without needing to pass
|
|
35
|
+
* a string into the validation, e.g. `required("mySpecialKey")`.
|
|
36
|
+
*/
|
|
37
|
+
const YUP_ERROR_TYPES_AS_KEYS = {
|
|
38
|
+
required: 1,
|
|
39
|
+
email: 1,
|
|
40
|
+
};
|
|
41
|
+
export const Field = (_a) => {
|
|
42
|
+
var { name, t, error, errors, children } = _a, props = __rest(_a, ["name", "t", "error", "errors", "children"]);
|
|
43
|
+
const err = errors && name ? errors[name] : error;
|
|
44
|
+
let msg = "";
|
|
45
|
+
if (err) {
|
|
46
|
+
if (name && t && err.type !== "plain") {
|
|
47
|
+
const translationKey = err.type && YUP_ERROR_TYPES_AS_KEYS[err.type] ? err.type : "";
|
|
48
|
+
msg = t(`errors.${name}.${translationKey || err.message}`);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
msg = err.message;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// dynamic i18n namespace loading does not seem to work yet
|
|
55
|
+
// const t = useT("core.Forms");
|
|
56
|
+
// const { locale } = useRouter();
|
|
57
|
+
// useEffect(() => {
|
|
58
|
+
// i18n.addResourceBundle(locale, "core.Forms", null);
|
|
59
|
+
// }, []);
|
|
60
|
+
return (_jsxs(FieldRoot, Object.assign({ "$danger": !!err }, props, { children: [children, msg && _jsx(Feedback, Object.assign({ "$danger": true }, { children: msg }))] })));
|
|
61
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { useFormState } from "react-hook-form";
|
|
5
|
+
import { decode } from "@koine/utils";
|
|
6
|
+
import { Field } from "./Field";
|
|
7
|
+
import { FieldHint } from "./FieldHint";
|
|
8
|
+
import { InputHoneypot } from "../styles";
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* - it expects the `field` object from our `useForm` wrapper around react-hook-form
|
|
12
|
+
* - automatically get translated strings from the given `t` function` for the
|
|
13
|
+
* field `label`, `placeholder` and `errors`. The .json expected by the `t` function
|
|
14
|
+
* look like this:
|
|
15
|
+
*
|
|
16
|
+
* ```json
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export const FieldControl = (_a) => {
|
|
20
|
+
var { control, register, setValue, name: maybeEncodedName, label, placeholder, hint, t, showError = true, children, encode } = _a, props = __rest(_a, ["control", "register", "setValue", "name", "label", "placeholder", "hint", "t", "showError", "children", "encode"]);
|
|
21
|
+
const name = encode ? decode(maybeEncodedName) : maybeEncodedName;
|
|
22
|
+
const { errors } = useFormState({ name, control });
|
|
23
|
+
const error = showError && errors[name] ? errors[name] : null;
|
|
24
|
+
const FormFieldContent = useMemo(() => children({
|
|
25
|
+
control,
|
|
26
|
+
register,
|
|
27
|
+
setValue,
|
|
28
|
+
name: maybeEncodedName,
|
|
29
|
+
// @see https://github.com/vinissimus/next-translate/pull/461
|
|
30
|
+
// @see https://github.com/vinissimus/next-translate/issues/429
|
|
31
|
+
label: label || t(`labels.${name}`, undefined, { default: "" }),
|
|
32
|
+
placeholder: placeholder || t(`placeholders.${name}`, undefined, { fallback: "" }),
|
|
33
|
+
}), [
|
|
34
|
+
children,
|
|
35
|
+
control,
|
|
36
|
+
register,
|
|
37
|
+
setValue,
|
|
38
|
+
name,
|
|
39
|
+
label,
|
|
40
|
+
t,
|
|
41
|
+
maybeEncodedName,
|
|
42
|
+
placeholder,
|
|
43
|
+
]);
|
|
44
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Field, Object.assign({ name: maybeEncodedName, t: t, error: error }, props, { children: [FormFieldContent, hint && _jsx(FieldHint, { children: hint })] })), encode && register && _jsx(InputHoneypot, Object.assign({}, register(name)))] }));
|
|
45
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { overlay, centered } from "../../styles/styled";
|
|
6
|
+
import { Collapsable } from "../../Collapsable";
|
|
7
|
+
import { ProgressCircular } from "../../Progress";
|
|
8
|
+
import { Alert } from "../../Alert";
|
|
9
|
+
export const FormRoot = styled.form `
|
|
10
|
+
position: relative;
|
|
11
|
+
`;
|
|
12
|
+
export const FormOverlay = styled.div `
|
|
13
|
+
z-index: 4;
|
|
14
|
+
${overlay}
|
|
15
|
+
${centered}
|
|
16
|
+
background: rgba(var(--bodyBg--rgb),.8);
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
backdrop-filter: blur(2px);
|
|
19
|
+
`;
|
|
20
|
+
export const FormFeedback = styled(Alert) `
|
|
21
|
+
padding: 2em 0;
|
|
22
|
+
`;
|
|
23
|
+
export const Form = (_a) => {
|
|
24
|
+
var { ok, fail, loading, Ok = FormFeedback, okProps = {
|
|
25
|
+
children: "Sent!",
|
|
26
|
+
}, Fail = FormFeedback, failProps = {
|
|
27
|
+
children: "Failed.",
|
|
28
|
+
}, collapseOnOk, collapseOnFail, okTimeout = 3000, failTimeout = 3000, children } = _a, props = __rest(_a, ["ok", "fail", "loading", "Ok", "okProps", "Fail", "failProps", "collapseOnOk", "collapseOnFail", "okTimeout", "failTimeout", "children"]);
|
|
29
|
+
const [expanded, setExpanded] = useState("");
|
|
30
|
+
const commonProps = {
|
|
31
|
+
head: null,
|
|
32
|
+
components: {
|
|
33
|
+
HeadIcon: null,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!loading) {
|
|
38
|
+
if (ok)
|
|
39
|
+
setExpanded("ok");
|
|
40
|
+
else if (fail)
|
|
41
|
+
setExpanded("fail");
|
|
42
|
+
}
|
|
43
|
+
}, [ok, fail, loading]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
let timeout;
|
|
46
|
+
if (expanded === "fail" && failTimeout) {
|
|
47
|
+
timeout = setTimeout(() => setExpanded(""), failTimeout);
|
|
48
|
+
}
|
|
49
|
+
else if (expanded === "ok" && okTimeout) {
|
|
50
|
+
timeout = setTimeout(() => setExpanded(""), okTimeout);
|
|
51
|
+
}
|
|
52
|
+
return () => {
|
|
53
|
+
if (timeout) {
|
|
54
|
+
clearTimeout(timeout);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, [expanded, failTimeout, okTimeout]);
|
|
58
|
+
let formExpanded = true;
|
|
59
|
+
if (collapseOnFail && fail)
|
|
60
|
+
formExpanded = false;
|
|
61
|
+
if (collapseOnOk && ok)
|
|
62
|
+
formExpanded = false;
|
|
63
|
+
return (_jsxs(FormRoot, Object.assign({ method: "post", noValidate: true }, props, { children: [_jsx(Collapsable, Object.assign({}, commonProps, { expanded: formExpanded, recalc: loading, body: _jsxs(_Fragment, { children: [children, loading && (_jsx(FormOverlay, { children: _jsx(ProgressCircular, { size: "2em", color: "var(--accent300)" }) }))] }) })), _jsx(Collapsable, Object.assign({}, commonProps, { expanded: expanded === "ok" && !loading, body: _jsx(Ok, Object.assign({}, okProps)) })), _jsx(Collapsable, Object.assign({}, commonProps, { expanded: expanded === "fail" && !loading, body: _jsx(Fail, Object.assign({}, failProps)) }))] })));
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Form";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { Label } from "../Label/Label";
|
|
6
|
+
import { inputBase, inputFocus } from "../styles";
|
|
7
|
+
export const InputWrap = styled.div `
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
`;
|
|
12
|
+
export const InputMain = styled.div `
|
|
13
|
+
flex: 1;
|
|
14
|
+
`;
|
|
15
|
+
export const InputPre = styled.div ``;
|
|
16
|
+
export const InputPost = styled.div ``;
|
|
17
|
+
export const InputNative = styled.input `
|
|
18
|
+
${inputBase}
|
|
19
|
+
${inputFocus}
|
|
20
|
+
`;
|
|
21
|
+
export const Input = forwardRef(function Input(_a, ref) {
|
|
22
|
+
var { register, name, label } = _a, props = __rest(_a, ["register", "name", "label"]);
|
|
23
|
+
// console.log("Input: render");
|
|
24
|
+
return (_jsxs(_Fragment, { children: [label && _jsx(Label, { children: label }), _jsx(InputNative, Object.assign({}, (register ? register(name) : { name, ref }), props))] }));
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Input";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { KoineButton } from "../../Buttons";
|
|
4
|
+
import { field } from "../Field";
|
|
5
|
+
import { max, min } from "../../styles/media";
|
|
6
|
+
export const InputGroupRoot = styled.div `
|
|
7
|
+
${field}
|
|
8
|
+
display: flex;
|
|
9
|
+
${max.sm} {
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
export const InputGroupMain = styled.div `
|
|
14
|
+
flex: 1;
|
|
15
|
+
`;
|
|
16
|
+
export const InputGroupButtonPre = styled(KoineButton) `
|
|
17
|
+
${max.sm} {
|
|
18
|
+
border-bottom: 0;
|
|
19
|
+
border-bottom-left-radius: 0;
|
|
20
|
+
border-bottom-right-radius: 0;
|
|
21
|
+
}
|
|
22
|
+
${min.sm} {
|
|
23
|
+
border-right: 0;
|
|
24
|
+
border-top-right-radius: 0;
|
|
25
|
+
border-bottom-right-radius: 0;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
export const InputGroupButtonPost = styled(KoineButton) `
|
|
29
|
+
${max.sm} {
|
|
30
|
+
border-top: 0;
|
|
31
|
+
border-top-left-radius: 0;
|
|
32
|
+
border-top-right-radius: 0;
|
|
33
|
+
}
|
|
34
|
+
${min.sm} {
|
|
35
|
+
border-left: 0;
|
|
36
|
+
border-top-left-radius: 0;
|
|
37
|
+
border-bottom-left-radius: 0;
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
export const InputGroup = ({ pre, post, Button = KoineButton, btnProps = {}, children, }) => {
|
|
41
|
+
return (_jsxs(InputGroupRoot, { children: [pre && _jsx(InputGroupButtonPre, Object.assign({ as: Button }, btnProps)), _jsx(InputGroupMain, { children: children }), post && _jsx(InputGroupButtonPost, Object.assign({ as: Button }, btnProps))] }));
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./InputGroup";
|