react-miui 0.7.0 → 0.9.2
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/CHANGELOG.md +30 -0
- package/dist/components/form/choice/Choice.d.ts +11 -0
- package/dist/components/form/choice/Choice.d.ts.map +1 -0
- package/dist/components/form/choice/Choice.js +19 -0
- package/dist/components/form/choice/Choice.js.map +1 -0
- package/dist/components/form/choice/Choice.module.scss +43 -0
- package/dist/components/form/choice/ChoiceItem.d.ts +11 -0
- package/dist/components/form/choice/ChoiceItem.d.ts.map +1 -0
- package/dist/components/form/choice/ChoiceItem.js +33 -0
- package/dist/components/form/choice/ChoiceItem.js.map +1 -0
- package/dist/components/layout/list/Header.d.ts +6 -1
- package/dist/components/layout/list/Header.d.ts.map +1 -1
- package/dist/components/layout/list/Header.js +6 -1
- package/dist/components/layout/list/Header.js.map +1 -1
- package/dist/components/layout/list/Item.d.ts +3 -0
- package/dist/components/layout/list/Item.d.ts.map +1 -1
- package/dist/components/layout/list/Item.js +20 -6
- package/dist/components/layout/list/Item.js.map +1 -1
- package/dist/components/layout/list/Item.module.scss +16 -1
- package/dist/components/layout/list/Label.d.ts +1 -0
- package/dist/components/layout/list/Label.d.ts.map +1 -1
- package/dist/components/layout/list/Label.js +2 -1
- package/dist/components/layout/list/Label.js.map +1 -1
- package/dist/components/layout/list/List.d.ts +6 -1
- package/dist/components/layout/list/List.d.ts.map +1 -1
- package/dist/components/layout/list/List.js +16 -1
- package/dist/components/layout/list/List.js.map +1 -1
- package/dist/components/layout/list/List.module.scss +4 -0
- package/dist/components/layout/list/Value.d.ts +4 -1
- package/dist/components/layout/list/Value.d.ts.map +1 -1
- package/dist/components/layout/list/Value.js +2 -1
- package/dist/components/layout/list/Value.js.map +1 -1
- package/dist/components/ui/button/Button.d.ts.map +1 -1
- package/dist/components/ui/button/Button.js +2 -2
- package/dist/components/ui/button/Button.js.map +1 -1
- package/dist/components/ui/modal/Modal.d.ts +18 -0
- package/dist/components/ui/modal/Modal.d.ts.map +1 -0
- package/dist/components/ui/modal/Modal.js +108 -0
- package/dist/components/ui/modal/Modal.js.map +1 -0
- package/dist/components/ui/modal/Modal.module.scss +92 -0
- package/dist/components/ui/modal/ModalButton.d.ts +8 -0
- package/dist/components/ui/modal/ModalButton.d.ts.map +1 -0
- package/dist/components/ui/modal/ModalButton.js +31 -0
- package/dist/components/ui/modal/ModalButton.js.map +1 -0
- package/dist/components/ui/modal/ModalButtons.d.ts +10 -0
- package/dist/components/ui/modal/ModalButtons.d.ts.map +1 -0
- package/dist/components/ui/modal/ModalButtons.js +15 -0
- package/dist/components/ui/modal/ModalButtons.js.map +1 -0
- package/dist/components/ui/modal/ModalButtons.module.scss +32 -0
- package/dist/components/ui/modal/ModalNoMargin.d.ts +6 -0
- package/dist/components/ui/modal/ModalNoMargin.d.ts.map +1 -0
- package/dist/components/ui/modal/ModalNoMargin.js +22 -0
- package/dist/components/ui/modal/ModalNoMargin.js.map +1 -0
- package/dist/components/ui/tabs/Item.d.ts +10 -0
- package/dist/components/ui/tabs/Item.d.ts.map +1 -0
- package/dist/components/ui/tabs/Item.js +39 -0
- package/dist/components/ui/tabs/Item.js.map +1 -0
- package/dist/components/ui/tabs/Item.module.scss +11 -0
- package/dist/components/ui/tabs/Selector.d.ts +10 -0
- package/dist/components/ui/tabs/Selector.d.ts.map +1 -0
- package/dist/components/ui/tabs/Selector.js +46 -0
- package/dist/components/ui/tabs/Selector.js.map +1 -0
- package/dist/components/ui/tabs/Selector.module.scss +6 -0
- package/dist/components/ui/toaster/Notification.d.ts +9 -0
- package/dist/components/ui/toaster/Notification.d.ts.map +1 -0
- package/dist/components/ui/toaster/Notification.js +39 -0
- package/dist/components/ui/toaster/Notification.js.map +1 -0
- package/dist/components/ui/toaster/Toaster.d.ts +18 -0
- package/dist/components/ui/toaster/Toaster.d.ts.map +1 -0
- package/dist/components/ui/toaster/Toaster.js +79 -0
- package/dist/components/ui/toaster/Toaster.js.map +1 -0
- package/dist/components/ui/toaster/Toaster.module.scss +32 -0
- package/dist/components/ui/toaster/types.d.ts +7 -0
- package/dist/components/ui/toaster/types.d.ts.map +1 -0
- package/dist/components/ui/toaster/types.js +3 -0
- package/dist/components/ui/toaster/types.js.map +1 -0
- package/dist/global.scss +12 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/types/form.d.ts +7 -0
- package/dist/types/form.d.ts.map +1 -0
- package/dist/types/form.js +3 -0
- package/dist/types/form.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +15 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/toObjectValue.d.ts +4 -0
- package/dist/utils/toObjectValue.d.ts.map +1 -0
- package/dist/utils/toObjectValue.js +8 -0
- package/dist/utils/toObjectValue.js.map +1 -0
- package/docs/assets/js/search.js +1 -1
- package/docs/assets/js/search.json +1 -1
- package/docs/classes/ToasterProvider.html +1096 -0
- package/docs/enums/ICON.html +33 -8
- package/docs/index.html +35 -4
- package/docs/modules/Item.html +17 -4
- package/docs/modules/List.html +17 -4
- package/docs/modules/Modal.html +160 -0
- package/docs/modules/ModalButtons.html +160 -0
- package/docs/modules/Section.html +16 -3
- package/docs/modules/StickyHeader.html +17 -4
- package/docs/modules.html +132 -23
- package/docs/pages/Tutorials/Test.html +16 -3
- package/esm/components/form/choice/Choice.d.ts +11 -0
- package/esm/components/form/choice/Choice.d.ts.map +1 -0
- package/esm/components/form/choice/Choice.js +13 -0
- package/esm/components/form/choice/Choice.js.map +1 -0
- package/esm/components/form/choice/Choice.module.scss +43 -0
- package/esm/components/form/choice/ChoiceItem.d.ts +11 -0
- package/esm/components/form/choice/ChoiceItem.d.ts.map +1 -0
- package/esm/components/form/choice/ChoiceItem.js +11 -0
- package/esm/components/form/choice/ChoiceItem.js.map +1 -0
- package/esm/components/layout/list/Header.d.ts +6 -1
- package/esm/components/layout/list/Header.d.ts.map +1 -1
- package/esm/components/layout/list/Header.js +6 -1
- package/esm/components/layout/list/Header.js.map +1 -1
- package/esm/components/layout/list/Item.d.ts +3 -0
- package/esm/components/layout/list/Item.d.ts.map +1 -1
- package/esm/components/layout/list/Item.js +20 -6
- package/esm/components/layout/list/Item.js.map +1 -1
- package/esm/components/layout/list/Item.module.scss +16 -1
- package/esm/components/layout/list/Label.d.ts +1 -0
- package/esm/components/layout/list/Label.d.ts.map +1 -1
- package/esm/components/layout/list/Label.js +2 -1
- package/esm/components/layout/list/Label.js.map +1 -1
- package/esm/components/layout/list/List.d.ts +6 -1
- package/esm/components/layout/list/List.d.ts.map +1 -1
- package/esm/components/layout/list/List.js +16 -1
- package/esm/components/layout/list/List.js.map +1 -1
- package/esm/components/layout/list/List.module.scss +4 -0
- package/esm/components/layout/list/Value.d.ts +4 -1
- package/esm/components/layout/list/Value.d.ts.map +1 -1
- package/esm/components/layout/list/Value.js +2 -1
- package/esm/components/layout/list/Value.js.map +1 -1
- package/esm/components/ui/button/Button.d.ts.map +1 -1
- package/esm/components/ui/button/Button.js +2 -2
- package/esm/components/ui/button/Button.js.map +1 -1
- package/esm/components/ui/modal/Modal.d.ts +18 -0
- package/esm/components/ui/modal/Modal.d.ts.map +1 -0
- package/esm/components/ui/modal/Modal.js +83 -0
- package/esm/components/ui/modal/Modal.js.map +1 -0
- package/esm/components/ui/modal/Modal.module.scss +92 -0
- package/esm/components/ui/modal/ModalButton.d.ts +8 -0
- package/esm/components/ui/modal/ModalButton.d.ts.map +1 -0
- package/esm/components/ui/modal/ModalButton.js +13 -0
- package/esm/components/ui/modal/ModalButton.js.map +1 -0
- package/esm/components/ui/modal/ModalButtons.d.ts +10 -0
- package/esm/components/ui/modal/ModalButtons.d.ts.map +1 -0
- package/esm/components/ui/modal/ModalButtons.js +9 -0
- package/esm/components/ui/modal/ModalButtons.js.map +1 -0
- package/esm/components/ui/modal/ModalButtons.module.scss +32 -0
- package/esm/components/ui/modal/ModalNoMargin.d.ts +6 -0
- package/esm/components/ui/modal/ModalNoMargin.d.ts.map +1 -0
- package/esm/components/ui/modal/ModalNoMargin.js +16 -0
- package/esm/components/ui/modal/ModalNoMargin.js.map +1 -0
- package/esm/components/ui/tabs/Item.d.ts +10 -0
- package/esm/components/ui/tabs/Item.d.ts.map +1 -0
- package/esm/components/ui/tabs/Item.js +14 -0
- package/esm/components/ui/tabs/Item.js.map +1 -0
- package/esm/components/ui/tabs/Item.module.scss +11 -0
- package/esm/components/ui/tabs/Selector.d.ts +10 -0
- package/esm/components/ui/tabs/Selector.d.ts.map +1 -0
- package/esm/components/ui/tabs/Selector.js +21 -0
- package/esm/components/ui/tabs/Selector.js.map +1 -0
- package/esm/components/ui/tabs/Selector.module.scss +6 -0
- package/esm/components/ui/toaster/Notification.d.ts +9 -0
- package/esm/components/ui/toaster/Notification.d.ts.map +1 -0
- package/esm/components/ui/toaster/Notification.js +14 -0
- package/esm/components/ui/toaster/Notification.js.map +1 -0
- package/esm/components/ui/toaster/Toaster.d.ts +18 -0
- package/esm/components/ui/toaster/Toaster.d.ts.map +1 -0
- package/esm/components/ui/toaster/Toaster.js +74 -0
- package/esm/components/ui/toaster/Toaster.js.map +1 -0
- package/esm/components/ui/toaster/Toaster.module.scss +32 -0
- package/esm/components/ui/toaster/types.d.ts +7 -0
- package/esm/components/ui/toaster/types.d.ts.map +1 -0
- package/esm/components/ui/toaster/types.js +2 -0
- package/esm/components/ui/toaster/types.js.map +1 -0
- package/esm/global.scss +12 -0
- package/esm/index.d.ts +5 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +5 -0
- package/esm/index.js.map +1 -1
- package/esm/types/form.d.ts +7 -0
- package/esm/types/form.d.ts.map +1 -0
- package/esm/types/form.js +2 -0
- package/esm/types/form.js.map +1 -0
- package/esm/utils/index.d.ts +3 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +3 -0
- package/esm/utils/index.js.map +1 -0
- package/esm/utils/toObjectValue.d.ts +4 -0
- package/esm/utils/toObjectValue.d.ts.map +1 -0
- package/esm/utils/toObjectValue.js +5 -0
- package/esm/utils/toObjectValue.js.map +1 -0
- package/package.json +6 -6
- package/src/components/form/choice/Choice.module.scss +43 -0
- package/src/components/form/choice/Choice.tsx +32 -0
- package/src/components/form/choice/ChoiceItem.tsx +30 -0
- package/src/components/layout/list/Header.tsx +16 -2
- package/src/components/layout/list/Item.module.scss +16 -1
- package/src/components/layout/list/Item.tsx +28 -7
- package/src/components/layout/list/Label.tsx +3 -1
- package/src/components/layout/list/List.module.scss +4 -0
- package/src/components/layout/list/List.tsx +28 -2
- package/src/components/layout/list/Value.tsx +7 -2
- package/src/components/ui/button/Button.tsx +4 -2
- package/src/components/ui/modal/Modal.module.scss +92 -0
- package/src/components/ui/modal/Modal.tsx +136 -0
- package/src/components/ui/modal/ModalButton.tsx +25 -0
- package/src/components/ui/modal/ModalButtons.module.scss +32 -0
- package/src/components/ui/modal/ModalButtons.tsx +17 -0
- package/src/components/ui/modal/ModalNoMargin.tsx +22 -0
- package/src/components/ui/tabs/Item.module.scss +11 -0
- package/src/components/ui/tabs/Item.tsx +26 -0
- package/src/components/ui/tabs/Selector.module.scss +6 -0
- package/src/components/ui/tabs/Selector.tsx +31 -0
- package/src/components/ui/toaster/Notification.tsx +31 -0
- package/src/components/ui/toaster/Toaster.module.scss +32 -0
- package/src/components/ui/toaster/Toaster.tsx +101 -0
- package/src/components/ui/toaster/types.ts +9 -0
- package/src/demo/Demo.tsx +7 -4
- package/src/demo/Menu.module.scss +1 -0
- package/src/demo/components/form/Choice.tsx +19 -0
- package/src/demo/components/layout/list/Inset.tsx +24 -0
- package/src/demo/components/layout/list/Selection.tsx +17 -0
- package/src/demo/components/ui/modal/Modal.tsx +110 -0
- package/src/demo/components/ui/tabs/Tabs.tsx +15 -0
- package/src/demo/components/ui/toaster/Toaster.tsx +28 -0
- package/src/demo/componentsMap.ts +41 -0
- package/src/global.scss +12 -0
- package/src/index.ts +5 -0
- package/src/types/form.ts +7 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/toObjectValue.ts +9 -0
|
@@ -4,11 +4,15 @@ import classnames from "classnames";
|
|
|
4
4
|
import styles from "./Item.module.scss";
|
|
5
5
|
import { Value } from "./Value.js";
|
|
6
6
|
import { Label } from "./Label.js";
|
|
7
|
+
import { makeVariants } from "../../../utils/makeVariants";
|
|
8
|
+
import { ICON, Icon } from "../../icons/Icon";
|
|
7
9
|
|
|
8
10
|
interface LinkProps {
|
|
9
11
|
href: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
14
|
+
type Variant = "inset";
|
|
15
|
+
|
|
12
16
|
interface Props {
|
|
13
17
|
href?: string;
|
|
14
18
|
to?: string;
|
|
@@ -16,6 +20,8 @@ interface Props {
|
|
|
16
20
|
className?: string;
|
|
17
21
|
Link?: React.ComponentClass<LinkProps> | React.FC<LinkProps>;
|
|
18
22
|
ratio?: string; // @TODO number/number/number/.. type?
|
|
23
|
+
variant?: Variant | Variant[];
|
|
24
|
+
selected?: boolean | undefined;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
interface SubComponents {
|
|
@@ -23,11 +29,26 @@ interface SubComponents {
|
|
|
23
29
|
Value: typeof Value;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
const icon = <Icon className={styles.icon} name={ICON.forward} />;
|
|
33
|
+
const noIcon = <span className={styles.icon} />;
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line max-statements,max-lines-per-function
|
|
27
36
|
const Item: React.FC<Props> & SubComponents = (props) => {
|
|
28
|
-
const { className, children, href, to, onClick, Link, ratio, ...restProps } = props;
|
|
37
|
+
const { className, children, href, to, onClick, Link, ratio, variant, selected, ...restProps } = props;
|
|
38
|
+
const v = makeVariants(variant);
|
|
29
39
|
const cls = classnames(styles.item, className);
|
|
30
40
|
|
|
41
|
+
const innerCls = classnames(styles.content, {
|
|
42
|
+
[styles.inset]: v.includes("inset"),
|
|
43
|
+
[styles.selected]: selected,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const pre = typeof selected === "boolean"
|
|
47
|
+
? (
|
|
48
|
+
selected ? icon : noIcon
|
|
49
|
+
)
|
|
50
|
+
: null;
|
|
51
|
+
|
|
31
52
|
const liProps = {
|
|
32
53
|
className: cls,
|
|
33
54
|
};
|
|
@@ -42,7 +63,7 @@ const Item: React.FC<Props> & SubComponents = (props) => {
|
|
|
42
63
|
if (index in r) {
|
|
43
64
|
flex = r[index];
|
|
44
65
|
}
|
|
45
|
-
return <div style={{ flex }}>{child}</div>;
|
|
66
|
+
return <div style={{ flex }}>{pre}{child}</div>;
|
|
46
67
|
});
|
|
47
68
|
|
|
48
69
|
if (to) {
|
|
@@ -50,25 +71,25 @@ const Item: React.FC<Props> & SubComponents = (props) => {
|
|
|
50
71
|
throw new TypeError("`to` prop given without `Link` component");
|
|
51
72
|
}
|
|
52
73
|
|
|
53
|
-
return <li {...liProps}><Link href={to} {...restProps}><a className={
|
|
74
|
+
return <li {...liProps}><Link href={to} {...restProps}><a className={innerCls}>{ren}</a></Link></li>;
|
|
54
75
|
}
|
|
55
76
|
if (href) {
|
|
56
77
|
const aProps: typeof restProps & { onClick?: Props["onClick"]} = { ...restProps };
|
|
57
78
|
if (onClick) {
|
|
58
79
|
aProps.onClick = onClick;
|
|
59
80
|
}
|
|
60
|
-
return <li {...liProps}><a href={href} {...aProps} className={
|
|
81
|
+
return <li {...liProps}><a href={href} {...aProps} className={innerCls}>{ren}</a></li>;
|
|
61
82
|
}
|
|
62
83
|
if (onClick) {
|
|
63
84
|
return (
|
|
64
85
|
<li {...liProps}>
|
|
65
|
-
<button className={classnames(styles.button,
|
|
86
|
+
<button className={classnames(styles.button, innerCls)} onClick={props.onClick} {...restProps}>
|
|
66
87
|
{ren}
|
|
67
88
|
</button>
|
|
68
89
|
</li>
|
|
69
90
|
);
|
|
70
91
|
}
|
|
71
|
-
return <li {...liProps}><div {...restProps} className={
|
|
92
|
+
return <li {...liProps}><div {...restProps} className={innerCls}>{ren}</div></li>;
|
|
72
93
|
};
|
|
73
94
|
|
|
74
95
|
Item.Label = Label;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
2
3
|
import type { ReactNode } from "react";
|
|
3
4
|
|
|
4
5
|
import styles from "./Label.module.scss";
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
sub?: ReactNode;
|
|
9
|
+
className?: string;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
const Label: React.FC<Props> = (props) => {
|
|
11
13
|
const sub = props.sub ? <div className={styles.sub}>{props.sub}</div> : null;
|
|
12
14
|
|
|
13
15
|
return (
|
|
14
|
-
<div className={styles.root}>
|
|
16
|
+
<div className={classnames(styles.root, props.className)}>
|
|
15
17
|
<div>{props.children}</div>
|
|
16
18
|
{sub}
|
|
17
19
|
</div>
|
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
2
3
|
|
|
3
4
|
import { Header } from "./Header.js";
|
|
5
|
+
import { makeVariants } from "../../../utils/makeVariants";
|
|
6
|
+
import { Item } from "./Item";
|
|
4
7
|
import styles from "./List.module.scss";
|
|
5
8
|
|
|
9
|
+
type Variant = "inset";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
className?: string;
|
|
13
|
+
variant?: Variant | Variant[];
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
interface SubComponents {
|
|
7
17
|
Header: typeof Header;
|
|
8
18
|
}
|
|
9
19
|
|
|
10
|
-
const List: React.FC & SubComponents = (props) => {
|
|
20
|
+
const List: React.FC<Props> & SubComponents = (props) => {
|
|
21
|
+
const v = makeVariants(props.variant);
|
|
22
|
+
|
|
23
|
+
const chld = React.Children.map(props.children, (child) => {
|
|
24
|
+
if (child && typeof child === "object" && "type" in child && (child.type === Item || child.type === Header)) {
|
|
25
|
+
return React.cloneElement(child, {
|
|
26
|
+
// @TODO this will override but should merge?
|
|
27
|
+
variant: props.variant,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return child;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const cls = classnames(props.className, styles.list, {
|
|
34
|
+
[styles.inset]: v.includes("inset"),
|
|
35
|
+
});
|
|
36
|
+
|
|
11
37
|
return (
|
|
12
|
-
<ul className={
|
|
38
|
+
<ul className={cls}>{chld}</ul>
|
|
13
39
|
);
|
|
14
40
|
};
|
|
15
41
|
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
2
3
|
|
|
3
4
|
import styles from "./Value.module.scss";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
interface Props {
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Value: React.FC<Props> = (props) => {
|
|
6
11
|
return (
|
|
7
|
-
<div className={styles.value}>{props.children}</div>
|
|
12
|
+
<div className={classnames(styles.value, props.className)}>{props.children}</div>
|
|
8
13
|
);
|
|
9
14
|
};
|
|
10
15
|
|
|
@@ -8,8 +8,10 @@ interface Props {
|
|
|
8
8
|
variant?: "inline" | "outline";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const Button: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & Props> = ({
|
|
12
|
-
|
|
11
|
+
const Button: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & Props> = ({
|
|
12
|
+
className, children, variant, ...props
|
|
13
|
+
}) => {
|
|
14
|
+
const variants = makeVariants(variant);
|
|
13
15
|
|
|
14
16
|
const cls = classnames(styles.btn, {
|
|
15
17
|
[styles["btn--inline"]]: variants.includes("inline"),
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
@keyframes overlay {
|
|
2
|
+
from {
|
|
3
|
+
background: #00000000;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
to {
|
|
7
|
+
background: #0000004c;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.overlay {
|
|
12
|
+
position: fixed;
|
|
13
|
+
z-index: 4;
|
|
14
|
+
top: 0;
|
|
15
|
+
bottom: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
right: 0;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
animation: overlay 300ms;
|
|
22
|
+
animation-fill-mode: forwards;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.overlayOnBottom {
|
|
26
|
+
align-items: flex-end;
|
|
27
|
+
padding-bottom: calc(24px / var(--ratio-dimensions));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@keyframes container {
|
|
31
|
+
from {
|
|
32
|
+
transform: translateY(30px);
|
|
33
|
+
opacity: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
to {
|
|
37
|
+
transform: translateY(0);
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.container {
|
|
43
|
+
background: var(--modal-bg);
|
|
44
|
+
border-radius: calc(12px / var(--ratio-dimensions));
|
|
45
|
+
max-width: 333px;
|
|
46
|
+
width: calc(100% - 30px);
|
|
47
|
+
padding: 20px;
|
|
48
|
+
position: relative;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
animation: container 300ms;
|
|
51
|
+
animation-fill-mode: forwards;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.full {
|
|
55
|
+
width: calc(100vw - 30px);
|
|
56
|
+
max-width: 1000px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.isClosing {
|
|
60
|
+
// keep this after .overlay .container to prevent overwriting
|
|
61
|
+
animation-direction: reverse;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.close {
|
|
65
|
+
position: absolute;
|
|
66
|
+
top: 20px;
|
|
67
|
+
right: 20px;
|
|
68
|
+
background: none;
|
|
69
|
+
border: none;
|
|
70
|
+
padding: 0;
|
|
71
|
+
margin: 0;
|
|
72
|
+
|
|
73
|
+
+ .title {
|
|
74
|
+
margin-right: 40px;
|
|
75
|
+
margin-top: -4px;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.title {
|
|
80
|
+
font-size: calc(40px / var(--ratio-font));
|
|
81
|
+
text-align: center;
|
|
82
|
+
color: black;
|
|
83
|
+
margin: calc(90px / var(--ratio-dimensions)) 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.negateMargin {
|
|
87
|
+
margin: 0 -20px -20px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.removeMargin {
|
|
91
|
+
margin: 0;
|
|
92
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
|
|
4
|
+
import styles from "./Modal.module.scss";
|
|
5
|
+
import { makeVariants } from "../../../utils/makeVariants";
|
|
6
|
+
import { ModalNegateMargin } from "./ModalNoMargin";
|
|
7
|
+
|
|
8
|
+
type Variant = "bottom" | "full";
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
onOverlayClick?: (() => void) | "close" | null;
|
|
12
|
+
closeOnEsc?: boolean;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
title?: React.ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
variant?: Variant | Variant[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface SubComponents {
|
|
21
|
+
NegateMargin: typeof ModalNegateMargin;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line max-lines-per-function,max-statements
|
|
25
|
+
const Modal: React.FC<Props> & SubComponents = ({
|
|
26
|
+
children,
|
|
27
|
+
onClose,
|
|
28
|
+
isOpen,
|
|
29
|
+
title,
|
|
30
|
+
className,
|
|
31
|
+
onOverlayClick = "close",
|
|
32
|
+
closeOnEsc = true,
|
|
33
|
+
variant,
|
|
34
|
+
}) => {
|
|
35
|
+
const [isClosing, setIsClosing] = useState(false);
|
|
36
|
+
const [isRendered, setIsRendered] = useState(false);
|
|
37
|
+
const overlayRef = useRef<HTMLDivElement>(null);
|
|
38
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
39
|
+
|
|
40
|
+
const v = makeVariants(variant);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!isOpen || !closeOnEsc) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
48
|
+
if (e.key === "Escape") {
|
|
49
|
+
onClose();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
document.addEventListener("keydown", onKeyDown);
|
|
53
|
+
return () => {
|
|
54
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
55
|
+
};
|
|
56
|
+
}, [isOpen, closeOnEsc]);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!isOpen) {
|
|
60
|
+
setIsClosing(true);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
setIsRendered(true);
|
|
64
|
+
setIsClosing(false);
|
|
65
|
+
}, [isOpen]);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!isClosing) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!overlayRef.current || !containerRef.current) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
overlayRef.current.style.animation = "none";
|
|
77
|
+
containerRef.current.style.animation = "none";
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
79
|
+
overlayRef.current.offsetHeight; // force sync document reflow
|
|
80
|
+
overlayRef.current.style.removeProperty("animation");
|
|
81
|
+
containerRef.current.style.removeProperty("animation");
|
|
82
|
+
}, [isClosing]);
|
|
83
|
+
|
|
84
|
+
const titleElem = title && <div className={styles.title}>{title}</div>;
|
|
85
|
+
|
|
86
|
+
const handleOverlayClick = useCallback((e: React.MouseEvent) => {
|
|
87
|
+
if (e.target !== e.currentTarget) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (onOverlayClick === "close") {
|
|
91
|
+
onClose();
|
|
92
|
+
}
|
|
93
|
+
if (typeof onOverlayClick === "function") {
|
|
94
|
+
onOverlayClick();
|
|
95
|
+
}
|
|
96
|
+
}, [onOverlayClick, onClose]);
|
|
97
|
+
|
|
98
|
+
const handleAnimationEnd = useCallback(() => {
|
|
99
|
+
if (isOpen) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setIsRendered(false);
|
|
104
|
+
}, [isOpen]);
|
|
105
|
+
|
|
106
|
+
if (!isRendered) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const overlayCls = classnames(styles.overlay, {
|
|
111
|
+
[styles.isClosing]: isClosing,
|
|
112
|
+
[styles.overlayOnBottom]: v.includes("bottom"),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const containerCls = classnames(styles.container, className, {
|
|
116
|
+
[styles.isClosing]: isClosing,
|
|
117
|
+
[styles.full]: v.includes("full"),
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div
|
|
122
|
+
className={overlayCls}
|
|
123
|
+
onClick={handleOverlayClick}
|
|
124
|
+
ref={overlayRef}
|
|
125
|
+
onAnimationEnd={handleAnimationEnd}
|
|
126
|
+
>
|
|
127
|
+
<div className={containerCls} ref={containerRef}>
|
|
128
|
+
{titleElem}
|
|
129
|
+
{children}
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
Modal.NegateMargin = ModalNegateMargin;
|
|
135
|
+
|
|
136
|
+
export { Modal };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import styles from "./ModalButtons.module.scss";
|
|
4
|
+
import { makeVariants } from "../../../utils/makeVariants";
|
|
5
|
+
import classnames from "classnames";
|
|
6
|
+
|
|
7
|
+
type Variant = "main";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
variant?: Variant | Variant[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const ModalButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & Props> = ({
|
|
14
|
+
className, children, variant, ...props
|
|
15
|
+
}) => {
|
|
16
|
+
const v = makeVariants(variant);
|
|
17
|
+
|
|
18
|
+
const cls = classnames(styles.button, {
|
|
19
|
+
[styles.buttonMain]: v.includes("main"),
|
|
20
|
+
}, className);
|
|
21
|
+
|
|
22
|
+
return <button {...props} className={cls}>{children}</button>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { ModalButton };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
margin-top: calc(100px / var(--ratio-dimensions));
|
|
4
|
+
margin-left: -20px;
|
|
5
|
+
margin-right: -20px;
|
|
6
|
+
margin-bottom: -20px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.button {
|
|
10
|
+
border: none;
|
|
11
|
+
border-top: 1px solid var(--modal-button-border);
|
|
12
|
+
background: var(--modal-button-bg);
|
|
13
|
+
flex: 1;
|
|
14
|
+
height: calc(156px / var(--ratio-dimensions));
|
|
15
|
+
font-weight: 500;
|
|
16
|
+
|
|
17
|
+
&:not(:first-child) {
|
|
18
|
+
border-left: 1px solid var(--modal-button-border);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:first-child {
|
|
22
|
+
border-bottom-left-radius: calc(12px / var(--ratio-dimensions));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:last-child {
|
|
26
|
+
border-bottom-right-radius: calc(12px / var(--ratio-dimensions));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.buttonMain {
|
|
31
|
+
color: var(--main-color);
|
|
32
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ModalButton } from "./ModalButton";
|
|
3
|
+
|
|
4
|
+
import styles from "./ModalButtons.module.scss";
|
|
5
|
+
|
|
6
|
+
interface Props {}
|
|
7
|
+
|
|
8
|
+
interface SubComponents {
|
|
9
|
+
Button: typeof ModalButton;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ModalButtons: React.FC<Props> & SubComponents = (props) => {
|
|
13
|
+
return <div className={styles.container}>{props.children}</div>;
|
|
14
|
+
};
|
|
15
|
+
ModalButtons.Button = ModalButton;
|
|
16
|
+
|
|
17
|
+
export { ModalButtons };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import styles from "./Modal.module.scss";
|
|
4
|
+
import { List } from "../../layout/list/List";
|
|
5
|
+
|
|
6
|
+
interface Props {}
|
|
7
|
+
|
|
8
|
+
const ModalNegateMargin: React.FC<Props> = (props) => {
|
|
9
|
+
const chld = React.Children.map(props.children, (child, index) => {
|
|
10
|
+
if (child && typeof child === "object" && "type" in child && child.type === List) {
|
|
11
|
+
return React.cloneElement(child, {
|
|
12
|
+
// @TODO this will overwrite className
|
|
13
|
+
className: styles.removeMargin,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return child;
|
|
18
|
+
});
|
|
19
|
+
return <div className={styles.negateMargin}>{chld}</div>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { ModalNegateMargin };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
|
|
4
|
+
import type { ObjectValue } from "../../../types/form";
|
|
5
|
+
|
|
6
|
+
import styles from "./Item.module.scss";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
value: ObjectValue;
|
|
10
|
+
onClick: (value: string) => void;
|
|
11
|
+
active: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Item: React.FC<Props> = (props) => {
|
|
15
|
+
const handleClick = useCallback(() => {
|
|
16
|
+
props.onClick(props.value.value);
|
|
17
|
+
}, [props.onClick, props.value.value, props.value.label]);
|
|
18
|
+
|
|
19
|
+
const cls = classnames(styles.button, {
|
|
20
|
+
[styles.active]: props.active,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return <button onClick={handleClick} className={cls} type={"button"}>{props.value.label}</button>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { Item };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import type { Value } from "../../../types/form";
|
|
4
|
+
import { toObjectValue } from "../../../utils";
|
|
5
|
+
import { Item } from "./Item";
|
|
6
|
+
import styles from "./Selector.module.scss";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
values: Value[];
|
|
10
|
+
value?: string;
|
|
11
|
+
onChange?: (value: string) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Selector: React.FC<Props> = (props) => {
|
|
15
|
+
const [current, setCurrent] = useState(props.value);
|
|
16
|
+
|
|
17
|
+
const handleCurrent = useCallback((value: string) => {
|
|
18
|
+
setCurrent(value);
|
|
19
|
+
props.onChange?.(value);
|
|
20
|
+
}, [props.onChange]);
|
|
21
|
+
|
|
22
|
+
const crr = props.value ?? current;
|
|
23
|
+
|
|
24
|
+
const vals = props.values.map(v => {
|
|
25
|
+
const ov = toObjectValue(v);
|
|
26
|
+
return <Item key={ov.value} value={ov} onClick={handleCurrent} active={crr === ov.value} />;
|
|
27
|
+
});
|
|
28
|
+
return <div className={styles.selector}>{vals}</div>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { Selector };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
|
|
4
|
+
import type { Toast } from "./types";
|
|
5
|
+
import styles from "./Toaster.module.scss";
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
toast: Toast;
|
|
9
|
+
onRemove: (id: Toast["id"]) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
13
|
+
const Notification: React.FC<Props> = (props) => {
|
|
14
|
+
const handleRemove = useCallback(() => {
|
|
15
|
+
props.onRemove(props.toast.id);
|
|
16
|
+
}, [props.toast.id]);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
className={classnames(styles.toast, {
|
|
21
|
+
[styles.hide]: props.toast.hide,
|
|
22
|
+
})}
|
|
23
|
+
key={props.toast.id}
|
|
24
|
+
onTransitionEnd={handleRemove}
|
|
25
|
+
>
|
|
26
|
+
<span>{props.toast.text}</span>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { Notification };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@keyframes show {
|
|
2
|
+
from {
|
|
3
|
+
transform: translateY(calc(100% + calc(190px / var(--ratio-dimensions))))
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.toast {
|
|
8
|
+
position: fixed;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
left: 40px;
|
|
11
|
+
right: 40px;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
z-index: 1;
|
|
15
|
+
|
|
16
|
+
span {
|
|
17
|
+
background: rgba(56, 50, 46, 0.85);
|
|
18
|
+
color: #F9F6F2;
|
|
19
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.37);
|
|
20
|
+
border-radius: 12px; // around 22 @TODO use calc here
|
|
21
|
+
display: inline-block;
|
|
22
|
+
padding: 1em 1em;
|
|
23
|
+
animation: show 500ms 1;
|
|
24
|
+
animation-fill-mode: forwards;
|
|
25
|
+
margin-bottom: calc(190px / var(--ratio-dimensions));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.hide {
|
|
30
|
+
transition: opacity 300ms;
|
|
31
|
+
opacity: 0;
|
|
32
|
+
}
|