react-miui 0.5.2 → 0.9.0
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 +31 -0
- package/assets/sources/battery.fla +0 -0
- package/assets/sources/search.fla +0 -0
- package/dist/components/form/Input.d.ts +9 -0
- package/dist/components/form/Input.d.ts.map +1 -0
- package/dist/components/form/Input.js +62 -0
- package/dist/components/form/Input.js.map +1 -0
- package/dist/components/form/Input.module.scss +48 -0
- package/dist/components/form/Label.d.ts +8 -0
- package/dist/components/form/Label.d.ts.map +1 -0
- package/dist/components/form/Label.js +22 -0
- package/dist/components/form/Label.js.map +1 -0
- package/dist/components/form/Label.module.scss +15 -0
- package/dist/components/form/TextArea.d.ts +7 -0
- package/dist/components/form/TextArea.d.ts.map +1 -0
- package/dist/components/form/TextArea.js +57 -0
- package/dist/components/form/TextArea.js.map +1 -0
- package/dist/components/form/Toggle.d.ts +1 -1
- package/dist/components/form/Toggle.d.ts.map +1 -1
- package/dist/components/form/Toggle.js.map +1 -1
- 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/icons/Back.d.ts +1 -1
- package/dist/components/icons/Back.d.ts.map +1 -1
- package/dist/components/icons/Back.js.map +1 -1
- package/dist/components/icons/Battery.d.ts +7 -0
- package/dist/components/icons/Battery.d.ts.map +1 -0
- package/dist/components/icons/Battery.js +14 -0
- package/dist/components/icons/Battery.js.map +1 -0
- package/dist/components/icons/Forward.d.ts +1 -1
- package/dist/components/icons/Forward.d.ts.map +1 -1
- package/dist/components/icons/Forward.js.map +1 -1
- package/dist/components/icons/Icon.d.ts +3 -1
- package/dist/components/icons/Icon.d.ts.map +1 -1
- package/dist/components/icons/Icon.js +6 -0
- package/dist/components/icons/Icon.js.map +1 -1
- package/dist/components/icons/Search.d.ts +7 -0
- package/dist/components/icons/Search.d.ts.map +1 -0
- package/dist/components/icons/Search.js +13 -0
- package/dist/components/icons/Search.js.map +1 -0
- package/dist/components/layout/header/HeaderIconAction.d.ts +1 -1
- package/dist/components/layout/header/HeaderIconAction.d.ts.map +1 -1
- package/dist/components/layout/header/HeaderIconAction.js.map +1 -1
- package/dist/components/layout/list/Header.d.ts +5 -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/List.d.ts +6 -1
- package/dist/components/layout/list/List.d.ts.map +1 -1
- package/dist/components/layout/list/List.js +15 -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/section/SearchContainer.d.ts +4 -0
- package/dist/components/layout/section/SearchContainer.d.ts.map +1 -0
- package/dist/components/layout/section/SearchContainer.js +13 -0
- package/dist/components/layout/section/SearchContainer.js.map +1 -0
- package/dist/components/layout/section/SearchContainer.module.scss +3 -0
- package/dist/components/layout/section/Section.module.scss +7 -0
- package/dist/components/ui/action/Action.d.ts +1 -1
- package/dist/components/ui/action/Action.d.ts.map +1 -1
- package/dist/components/ui/action/Action.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 +13 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -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/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- 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 +71 -6
- package/docs/index.html +47 -4
- package/docs/modules/Item.html +16 -3
- 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 +187 -22
- package/docs/pages/Tutorials/Test.html +16 -3
- package/esm/components/form/Input.d.ts +9 -0
- package/esm/components/form/Input.d.ts.map +1 -0
- package/esm/components/form/Input.js +25 -0
- package/esm/components/form/Input.js.map +1 -0
- package/esm/components/form/Input.module.scss +48 -0
- package/esm/components/form/Label.d.ts +8 -0
- package/esm/components/form/Label.d.ts.map +1 -0
- package/esm/components/form/Label.js +16 -0
- package/esm/components/form/Label.js.map +1 -0
- package/esm/components/form/Label.module.scss +15 -0
- package/esm/components/form/TextArea.d.ts +7 -0
- package/esm/components/form/TextArea.d.ts.map +1 -0
- package/esm/components/form/TextArea.js +20 -0
- package/esm/components/form/TextArea.js.map +1 -0
- package/esm/components/form/Toggle.d.ts +1 -1
- package/esm/components/form/Toggle.d.ts.map +1 -1
- package/esm/components/form/Toggle.js.map +1 -1
- 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/icons/Back.d.ts +1 -1
- package/esm/components/icons/Back.d.ts.map +1 -1
- package/esm/components/icons/Back.js.map +1 -1
- package/esm/components/icons/Battery.d.ts +7 -0
- package/esm/components/icons/Battery.d.ts.map +1 -0
- package/esm/components/icons/Battery.js +8 -0
- package/esm/components/icons/Battery.js.map +1 -0
- package/esm/components/icons/Forward.d.ts +1 -1
- package/esm/components/icons/Forward.d.ts.map +1 -1
- package/esm/components/icons/Forward.js.map +1 -1
- package/esm/components/icons/Icon.d.ts +3 -1
- package/esm/components/icons/Icon.d.ts.map +1 -1
- package/esm/components/icons/Icon.js +6 -0
- package/esm/components/icons/Icon.js.map +1 -1
- package/esm/components/icons/Search.d.ts +7 -0
- package/esm/components/icons/Search.d.ts.map +1 -0
- package/esm/components/icons/Search.js +7 -0
- package/esm/components/icons/Search.js.map +1 -0
- package/esm/components/layout/header/HeaderIconAction.d.ts +1 -1
- package/esm/components/layout/header/HeaderIconAction.d.ts.map +1 -1
- package/esm/components/layout/header/HeaderIconAction.js.map +1 -1
- package/esm/components/layout/list/Header.d.ts +5 -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/List.d.ts +6 -1
- package/esm/components/layout/list/List.d.ts.map +1 -1
- package/esm/components/layout/list/List.js +15 -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/section/SearchContainer.d.ts +4 -0
- package/esm/components/layout/section/SearchContainer.d.ts.map +1 -0
- package/esm/components/layout/section/SearchContainer.js +7 -0
- package/esm/components/layout/section/SearchContainer.js.map +1 -0
- package/esm/components/layout/section/SearchContainer.module.scss +3 -0
- package/esm/components/layout/section/Section.module.scss +7 -0
- package/esm/components/ui/action/Action.d.ts +1 -1
- package/esm/components/ui/action/Action.d.ts.map +1 -1
- package/esm/components/ui/action/Action.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 +13 -0
- package/esm/index.d.ts +9 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +9 -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/types.d.ts +1 -1
- package/esm/types.d.ts.map +1 -1
- 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 +2 -2
- package/src/components/form/Input.module.scss +48 -0
- package/src/components/form/Input.tsx +48 -0
- package/src/components/form/Label.module.scss +15 -0
- package/src/components/form/Label.tsx +29 -0
- package/src/components/form/TextArea.tsx +38 -0
- package/src/components/form/Toggle.tsx +1 -1
- 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/icons/Back.tsx +1 -1
- package/src/components/icons/Battery.tsx +34 -0
- package/src/components/icons/Forward.tsx +1 -1
- package/src/components/icons/Icon.tsx +6 -0
- package/src/components/icons/Search.tsx +29 -0
- package/src/components/layout/header/HeaderIconAction.tsx +1 -1
- package/src/components/layout/list/Header.tsx +15 -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/List.module.scss +4 -0
- package/src/components/layout/list/List.tsx +29 -2
- package/src/components/layout/section/SearchContainer.module.scss +3 -0
- package/src/components/layout/section/SearchContainer.tsx +11 -0
- package/src/components/layout/section/Section.module.scss +7 -0
- package/src/components/ui/action/Action.tsx +1 -1
- 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/form/Form.tsx +35 -0
- package/src/demo/components/form/Input.tsx +13 -0
- package/src/demo/components/form/Label.tsx +14 -0
- package/src/demo/components/form/Search.tsx +36 -0
- package/src/demo/components/form/TextArea.tsx +12 -0
- package/src/demo/components/form/Toggle.tsx +1 -1
- 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 +74 -11
- package/src/global.scss +13 -0
- package/src/index.ts +9 -0
- package/src/types/form.ts +7 -0
- package/src/types.ts +1 -1
- package/src/utils/index.ts +2 -0
- package/src/utils/toObjectValue.ts +9 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
import type { Toast } from "./types";
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
5
|
+
import { Notification } from "./Notification";
|
|
6
|
+
|
|
7
|
+
type ToasterFn = (text: string) => void;
|
|
8
|
+
|
|
9
|
+
const ToasterContext = createContext<ToasterFn>(() => {
|
|
10
|
+
throw new Error("Toaster Provider missing in the tree");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const prefix = `${Date.now()}_`;
|
|
14
|
+
let counter = 0;
|
|
15
|
+
|
|
16
|
+
interface Props {}
|
|
17
|
+
interface State {
|
|
18
|
+
list: Toast[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const DEFAULT_TIMEOUT = 5000;
|
|
22
|
+
|
|
23
|
+
class ToasterProvider extends React.Component<Props, State> {
|
|
24
|
+
public constructor(props: Props, context: unknown) {
|
|
25
|
+
super(props, context);
|
|
26
|
+
|
|
27
|
+
this.state = {
|
|
28
|
+
list: [],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private readonly _add = (text: string) => {
|
|
33
|
+
this._removeAllToasts();
|
|
34
|
+
|
|
35
|
+
const id = prefix + String(counter++);
|
|
36
|
+
const hide = false;
|
|
37
|
+
|
|
38
|
+
this.setState(prev => ({
|
|
39
|
+
...prev,
|
|
40
|
+
list: [...prev.list, {
|
|
41
|
+
id,
|
|
42
|
+
text,
|
|
43
|
+
hide,
|
|
44
|
+
}],
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
this.setState(prev => ({
|
|
49
|
+
...prev,
|
|
50
|
+
list: prev.list.map(p => {
|
|
51
|
+
if (p.id !== id) {
|
|
52
|
+
return p;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...p,
|
|
56
|
+
hide: true,
|
|
57
|
+
};
|
|
58
|
+
}),
|
|
59
|
+
}));
|
|
60
|
+
}, DEFAULT_TIMEOUT);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
private readonly _handleRemove = (id: Toast["id"]) => {
|
|
64
|
+
this.setState(prev => ({
|
|
65
|
+
...prev,
|
|
66
|
+
list: prev.list.filter(p => p.id !== id),
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
private readonly _removeAllToasts = () => {
|
|
71
|
+
this.setState(prev => ({
|
|
72
|
+
...prev,
|
|
73
|
+
list: prev.list.map(p => {
|
|
74
|
+
if (p.hide) {
|
|
75
|
+
return p;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...p,
|
|
79
|
+
hide: true,
|
|
80
|
+
};
|
|
81
|
+
}),
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
public render() {
|
|
86
|
+
const notifications = this.state.list.map((t) => {
|
|
87
|
+
return <Notification onRemove={this._handleRemove} key={t.id} toast={t} />;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<ToasterContext.Provider value={this._add}>
|
|
92
|
+
{notifications}
|
|
93
|
+
{this.props.children}
|
|
94
|
+
</ToasterContext.Provider>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const useToaster = () => useContext(ToasterContext);
|
|
100
|
+
|
|
101
|
+
export { ToasterProvider, useToaster };
|
package/src/demo/Demo.tsx
CHANGED
|
@@ -4,13 +4,16 @@ import styles from "./Demo.module.scss";
|
|
|
4
4
|
import { Menu } from "./Menu";
|
|
5
5
|
import { Main } from "./Main";
|
|
6
6
|
import { componentsMap } from "./componentsMap";
|
|
7
|
+
import { ToasterProvider } from "../components/ui/toaster/Toaster";
|
|
7
8
|
|
|
8
9
|
const Demo: React.FC = (props) => {
|
|
9
10
|
return (
|
|
10
|
-
<
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
<ToasterProvider>
|
|
12
|
+
<div className={styles.container}>
|
|
13
|
+
<Menu list={componentsMap} />
|
|
14
|
+
<Main />
|
|
15
|
+
</div>
|
|
16
|
+
</ToasterProvider>
|
|
14
17
|
);
|
|
15
18
|
};
|
|
16
19
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Choice } from "../../../components/form/choice/Choice";
|
|
3
|
+
import { Section } from "../../../components/layout/section/Section";
|
|
4
|
+
|
|
5
|
+
interface Props {}
|
|
6
|
+
|
|
7
|
+
const values = ["Single", "Multiple"];
|
|
8
|
+
|
|
9
|
+
const ChoiceDemo: React.FC<Props> = () => {
|
|
10
|
+
const [current, handleCurrent] = useState(values[0]);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Section variant={["vertical", "horizontal"]}>
|
|
14
|
+
<Choice values={values} value={current} name={"rnd"} onChange={handleCurrent} />
|
|
15
|
+
</Section>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { ChoiceDemo };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Section } from "../../../components/layout/section/Section";
|
|
3
|
+
import { SectionContainer } from "../../../components/layout/section/SectionContainer";
|
|
4
|
+
import { Input } from "../../../components/form/Input";
|
|
5
|
+
import { Label } from "../../../components/form/Label";
|
|
6
|
+
import { Button } from "../../../components/ui/button/Button";
|
|
7
|
+
import { TextArea } from "../../../components/form/TextArea";
|
|
8
|
+
|
|
9
|
+
// @TODO add checkbox
|
|
10
|
+
// @TODO add toggle
|
|
11
|
+
// @TODO some kind of `form` wrapper which also takes cares of margins?
|
|
12
|
+
const FormDemo = () => {
|
|
13
|
+
return (
|
|
14
|
+
<SectionContainer>
|
|
15
|
+
<Section>
|
|
16
|
+
<Section variant={["vertical", "horizontal"]}>
|
|
17
|
+
<Label label={"First name"}>
|
|
18
|
+
<Input placeholder={""} />
|
|
19
|
+
</Label>
|
|
20
|
+
<Label label={"E-mail"}>
|
|
21
|
+
<Input placeholder={"Don't forget the @"} suffix={".com"} />
|
|
22
|
+
</Label>
|
|
23
|
+
<Label label={"Your story"}>
|
|
24
|
+
<TextArea placeholder={"Hello"} />
|
|
25
|
+
</Label>
|
|
26
|
+
<Label>
|
|
27
|
+
<Button>Submit</Button>
|
|
28
|
+
</Label>
|
|
29
|
+
</Section>
|
|
30
|
+
</Section>
|
|
31
|
+
</SectionContainer>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { FormDemo };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Input } from "../../../components/form/Input";
|
|
3
|
+
import { ICON, Icon } from "../../../components/icons/Icon";
|
|
4
|
+
|
|
5
|
+
const InputDemo: React.FC = () => {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<Input placeholder={"Capacity"} prefix={<Icon name={ICON.battery} />} suffix={"kWh"} />
|
|
9
|
+
</>
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { InputDemo };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Label } from "../../../components/form/Label";
|
|
3
|
+
import { Input } from "../../../components/form/Input";
|
|
4
|
+
import { ICON, Icon } from "../../../components/icons/Icon";
|
|
5
|
+
|
|
6
|
+
const LabelDemo = () => {
|
|
7
|
+
return (
|
|
8
|
+
<Label label={"Capacity"}>
|
|
9
|
+
<Input placeholder={"ie: 500"} prefix={<Icon name={ICON.battery} />} suffix={"kWh"} />
|
|
10
|
+
</Label>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { LabelDemo };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SearchContainer } from "../../../components/layout/section/SearchContainer";
|
|
3
|
+
import { Input } from "../../../components/form/Input";
|
|
4
|
+
import { ICON, Icon } from "../../../components/icons/Icon";
|
|
5
|
+
import { Section } from "../../../components/layout/section/Section";
|
|
6
|
+
import { SectionContainer } from "../../../components/layout/section/SectionContainer";
|
|
7
|
+
import { List } from "../../../components/layout/list/List";
|
|
8
|
+
import { Item } from "../../../components/layout/list/Item";
|
|
9
|
+
|
|
10
|
+
const SearchDemo = () => {
|
|
11
|
+
return (
|
|
12
|
+
<SectionContainer>
|
|
13
|
+
<SearchContainer>
|
|
14
|
+
<Input placeholder={"Search..."} prefix={<Icon name={ICON.search} />} />
|
|
15
|
+
</SearchContainer>
|
|
16
|
+
<Section>
|
|
17
|
+
<List>
|
|
18
|
+
<List.Header>Messages</List.Header>
|
|
19
|
+
<Item>Lorem</Item>
|
|
20
|
+
<Item>Ipsum</Item>
|
|
21
|
+
<Item>Dolor</Item>
|
|
22
|
+
</List>
|
|
23
|
+
</Section>
|
|
24
|
+
<Section>
|
|
25
|
+
<List>
|
|
26
|
+
<List.Header>Contacts</List.Header>
|
|
27
|
+
<Item>Lorem</Item>
|
|
28
|
+
<Item>Ipsum</Item>
|
|
29
|
+
<Item>Dolor</Item>
|
|
30
|
+
</List>
|
|
31
|
+
</Section>
|
|
32
|
+
</SectionContainer>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { SearchDemo };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { List } from "../../../../components/layout/list/List";
|
|
3
|
+
import { Item } from "../../../../components/layout/list/Item";
|
|
4
|
+
import { Header } from "../../../../components/layout/list/Header";
|
|
5
|
+
|
|
6
|
+
const ListInsetDemo = () => {
|
|
7
|
+
return (
|
|
8
|
+
<List variant={"inset"}>
|
|
9
|
+
<Header>Section name</Header>
|
|
10
|
+
<Item>Item</Item>
|
|
11
|
+
<Item>Another item</Item>
|
|
12
|
+
<Item>One more</Item>
|
|
13
|
+
<Header>Status section</Header>
|
|
14
|
+
<Item>Item</Item>
|
|
15
|
+
<Item>One more</Item>
|
|
16
|
+
<Header>Selection</Header>
|
|
17
|
+
<Item>Item</Item>
|
|
18
|
+
<Item>Another item</Item>
|
|
19
|
+
<Item>One more</Item>
|
|
20
|
+
</List>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { ListInsetDemo };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { List } from "../../../../components/layout/list/List";
|
|
3
|
+
import { Item } from "../../../../components/layout/list/Item";
|
|
4
|
+
import { Header } from "../../../../components/layout/list/Header";
|
|
5
|
+
|
|
6
|
+
const ListSelectionDemo = () => {
|
|
7
|
+
return (
|
|
8
|
+
<List>
|
|
9
|
+
<Header>Select your favourite meal</Header>
|
|
10
|
+
<Item selected={false}>Stick</Item>
|
|
11
|
+
<Item selected={true}>Stone</Item>
|
|
12
|
+
<Item selected={false}>Bone</Item>
|
|
13
|
+
</List>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { ListSelectionDemo };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
import { Modal } from "../../../../components/ui/modal/Modal";
|
|
3
|
+
import { Button } from "../../../../components/ui/button/Button";
|
|
4
|
+
import { Input } from "../../../../components/form/Input";
|
|
5
|
+
import { Checkbox } from "../../../../components/form/Checkbox";
|
|
6
|
+
import { Label } from "../../../../components/form/Label";
|
|
7
|
+
import { ModalButtons } from "../../../../components/ui/modal/ModalButtons";
|
|
8
|
+
import { List } from "../../../../components/layout/list/List";
|
|
9
|
+
import { Item } from "../../../../components/layout/list/Item";
|
|
10
|
+
|
|
11
|
+
interface Props {}
|
|
12
|
+
|
|
13
|
+
const handleNoop = () => undefined;
|
|
14
|
+
|
|
15
|
+
const ModalDemo: React.FC<Props> = (props) => {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
17
|
+
const [open, setIsOpen] = useState(false);
|
|
18
|
+
|
|
19
|
+
const handleClose = useCallback(() => {
|
|
20
|
+
setIsOpen(false);
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
const handleOpen = useCallback(() => {
|
|
24
|
+
setIsOpen(true);
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div>
|
|
29
|
+
<Button onClick={handleOpen}>Open modal</Button>
|
|
30
|
+
<Modal onClose={handleClose} isOpen={open} title={"95.5 MHz"} variant={["bottom", "full"]}>
|
|
31
|
+
<Label>
|
|
32
|
+
<Input placeholder={"New station"} />
|
|
33
|
+
</Label>
|
|
34
|
+
<Label>
|
|
35
|
+
<Checkbox name={""} onChange={handleNoop} checked={true}>
|
|
36
|
+
Remember me
|
|
37
|
+
</Checkbox>
|
|
38
|
+
</Label>
|
|
39
|
+
<ModalButtons>
|
|
40
|
+
<ModalButtons.Button onClick={handleClose}>
|
|
41
|
+
Cancel
|
|
42
|
+
</ModalButtons.Button>
|
|
43
|
+
<ModalButtons.Button variant={"main"} onClick={handleClose}>
|
|
44
|
+
Ok
|
|
45
|
+
</ModalButtons.Button>
|
|
46
|
+
</ModalButtons>
|
|
47
|
+
</Modal>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const ModalCenteredDemo: React.FC<Props> = (props) => {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
54
|
+
const [open, setIsOpen] = useState(false);
|
|
55
|
+
|
|
56
|
+
const handleClose = useCallback(() => {
|
|
57
|
+
setIsOpen(false);
|
|
58
|
+
}, []);
|
|
59
|
+
|
|
60
|
+
const handleOpen = useCallback(() => {
|
|
61
|
+
setIsOpen(true);
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div>
|
|
66
|
+
<Button onClick={handleOpen}>Open modal</Button>
|
|
67
|
+
<Modal onClose={handleClose} isOpen={open} title={"Format C:?"}>
|
|
68
|
+
<ModalButtons>
|
|
69
|
+
<ModalButtons.Button onClick={handleClose}>
|
|
70
|
+
Nope
|
|
71
|
+
</ModalButtons.Button>
|
|
72
|
+
<ModalButtons.Button variant={"main"} onClick={handleClose}>
|
|
73
|
+
Yes, please
|
|
74
|
+
</ModalButtons.Button>
|
|
75
|
+
</ModalButtons>
|
|
76
|
+
</Modal>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const ModalOptionsDemo: React.FC<Props> = (props) => {
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
83
|
+
const [open, setIsOpen] = useState(false);
|
|
84
|
+
|
|
85
|
+
const handleClose = useCallback(() => {
|
|
86
|
+
setIsOpen(false);
|
|
87
|
+
}, []);
|
|
88
|
+
|
|
89
|
+
const handleOpen = useCallback(() => {
|
|
90
|
+
setIsOpen(true);
|
|
91
|
+
}, []);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div>
|
|
95
|
+
<Button onClick={handleOpen}>Open modal</Button>
|
|
96
|
+
<Modal onClose={handleClose} isOpen={open} title={"Format C:?"}>
|
|
97
|
+
<Modal.NegateMargin>
|
|
98
|
+
<List variant={"inset"}>
|
|
99
|
+
<Item selected={false} onClick={handleClose}>First item</Item>
|
|
100
|
+
<Item selected={true} onClick={handleClose}>Second item</Item>
|
|
101
|
+
<Item selected={false} onClick={handleClose}>Third item</Item>
|
|
102
|
+
<Item selected={false} onClick={handleClose}>Last option</Item>
|
|
103
|
+
</List>
|
|
104
|
+
</Modal.NegateMargin>
|
|
105
|
+
</Modal>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export { ModalDemo, ModalCenteredDemo, ModalOptionsDemo };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Header } from "../../../../components/layout/header/Header";
|
|
3
|
+
import { Selector } from "../../../../components/ui/tabs/Selector";
|
|
4
|
+
|
|
5
|
+
interface Props {}
|
|
6
|
+
|
|
7
|
+
const values = ["Recent", "Categories", "Whole Disk"];
|
|
8
|
+
|
|
9
|
+
const TabsDemo: React.FC<Props> = () => {
|
|
10
|
+
const [current, handleCurrent] = useState("Recent");
|
|
11
|
+
|
|
12
|
+
return <Header><Selector values={values} value={current} onChange={handleCurrent} /></Header>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { TabsDemo };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
import { useToaster } from "../../../../components/ui/toaster/Toaster";
|
|
3
|
+
import { Button } from "../../../../components/ui/button/Button";
|
|
4
|
+
import { Input } from "../../../../components/form/Input";
|
|
5
|
+
|
|
6
|
+
interface Props {}
|
|
7
|
+
|
|
8
|
+
const ToasterDemo: React.FC<Props> = (props) => {
|
|
9
|
+
const toast = useToaster();
|
|
10
|
+
const [text, setText] = useState("");
|
|
11
|
+
|
|
12
|
+
const handleToast = useCallback(() => {
|
|
13
|
+
toast(text || "Lorem ipsum dolor sit amet");
|
|
14
|
+
}, [text]);
|
|
15
|
+
|
|
16
|
+
const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
17
|
+
setText(e.target.value);
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div>
|
|
22
|
+
<Input onChange={handleChange} value={text} placeholder={"Fill in text to display"} />
|
|
23
|
+
<Button onClick={handleToast}>Show toast</Button>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { ToasterDemo };
|