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
|
@@ -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,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 };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
1
2
|
import type { AnyComponent } from "../types";
|
|
2
3
|
import { CheckboxDemo } from "./components/form/Checkbox";
|
|
3
4
|
import {
|
|
@@ -33,6 +34,12 @@ import { InputDemo } from "./components/form/Input";
|
|
|
33
34
|
import { FormDemo } from "./components/form/Form";
|
|
34
35
|
import { SearchDemo } from "./components/form/Search";
|
|
35
36
|
import { LabelDemo } from "./components/form/Label";
|
|
37
|
+
import { ToasterDemo } from "./components/ui/toaster/Toaster";
|
|
38
|
+
import { ModalCenteredDemo, ModalDemo, ModalOptionsDemo } from "./components/ui/modal/Modal";
|
|
39
|
+
import { ListInsetDemo } from "./components/layout/list/Inset";
|
|
40
|
+
import { ListSelectionDemo } from "./components/layout/list/Selection";
|
|
41
|
+
import { TabsDemo } from "./components/ui/tabs/Tabs";
|
|
42
|
+
import { ChoiceDemo } from "./components/form/Choice";
|
|
36
43
|
|
|
37
44
|
interface TheMap {
|
|
38
45
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
@@ -74,6 +81,10 @@ const componentsMap: TheMap = {
|
|
|
74
81
|
name: "Toggle",
|
|
75
82
|
Component: ToggleDemo,
|
|
76
83
|
},
|
|
84
|
+
Choice: {
|
|
85
|
+
name: "Choice",
|
|
86
|
+
Component: ChoiceDemo,
|
|
87
|
+
},
|
|
77
88
|
},
|
|
78
89
|
},
|
|
79
90
|
Header: {
|
|
@@ -148,6 +159,10 @@ const componentsMap: TheMap = {
|
|
|
148
159
|
},
|
|
149
160
|
},
|
|
150
161
|
},
|
|
162
|
+
Tabs: {
|
|
163
|
+
name: "Tabs",
|
|
164
|
+
Component: TabsDemo,
|
|
165
|
+
},
|
|
151
166
|
ListItem: {
|
|
152
167
|
name: "List & Item",
|
|
153
168
|
Component: ListItemDemo,
|
|
@@ -160,6 +175,14 @@ const componentsMap: TheMap = {
|
|
|
160
175
|
name: "Header",
|
|
161
176
|
Component: ListHeaderDemo,
|
|
162
177
|
},
|
|
178
|
+
Inset: {
|
|
179
|
+
name: "Inset",
|
|
180
|
+
Component: ListInsetDemo,
|
|
181
|
+
},
|
|
182
|
+
Selection: {
|
|
183
|
+
name: "Selection",
|
|
184
|
+
Component: ListSelectionDemo,
|
|
185
|
+
},
|
|
163
186
|
Label: {
|
|
164
187
|
name: "Label",
|
|
165
188
|
Component: ItemLabelDemo,
|
|
@@ -186,6 +209,24 @@ const componentsMap: TheMap = {
|
|
|
186
209
|
name: "Icons",
|
|
187
210
|
Component: IconsDemo,
|
|
188
211
|
},
|
|
212
|
+
Toaster: {
|
|
213
|
+
name: "Toaster",
|
|
214
|
+
Component: ToasterDemo,
|
|
215
|
+
},
|
|
216
|
+
Modal: {
|
|
217
|
+
name: "Modal",
|
|
218
|
+
Component: ModalDemo,
|
|
219
|
+
children: {
|
|
220
|
+
Centered: {
|
|
221
|
+
name: "Centered & smaller",
|
|
222
|
+
Component: ModalCenteredDemo,
|
|
223
|
+
},
|
|
224
|
+
WithOptions: {
|
|
225
|
+
name: "With options to pick",
|
|
226
|
+
Component: ModalOptionsDemo,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
189
230
|
};
|
|
190
231
|
|
|
191
232
|
export {
|
package/src/global.scss
CHANGED
|
@@ -28,6 +28,18 @@
|
|
|
28
28
|
|
|
29
29
|
--toolbar-border: #ababab;
|
|
30
30
|
--toolbar-bg: #f8f8f8;
|
|
31
|
+
--modal-bg: #f7f7f7;
|
|
32
|
+
--modal-button-bg: #f8f8f8;
|
|
33
|
+
--modal-button-border: #c2c2c2;
|
|
34
|
+
|
|
35
|
+
--choice-bg: #ffffff;
|
|
36
|
+
--choice-text: #999999;
|
|
37
|
+
--choice-active-bg: #f3f3f3;
|
|
38
|
+
--choice-active-text: #313131;
|
|
39
|
+
--choice-border: #cfcfcf;
|
|
40
|
+
|
|
41
|
+
--selector-text: #606060;
|
|
42
|
+
--selector-active: var(--main-color);
|
|
31
43
|
|
|
32
44
|
// Shades: https://maketintsandshades.com/#038bf4,ff7200,7357e8,3ec234,3ec234,ff388f,ea2700
|
|
33
45
|
--blue1: #038bf4;
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./components/form/choice/Choice.js";
|
|
1
2
|
export * from "./components/form/Checkbox.js";
|
|
2
3
|
export * from "./components/form/Input.js";
|
|
3
4
|
export * from "./components/form/Label.js";
|
|
@@ -19,3 +20,7 @@ export * from "./components/ui/action/Action.js";
|
|
|
19
20
|
export * from "./components/ui/action/EqualActions.js";
|
|
20
21
|
export * from "./components/ui/button/Button.js";
|
|
21
22
|
export * from "./components/ui/directionPad/Pad.js";
|
|
23
|
+
export * from "./components/ui/modal/Modal.js";
|
|
24
|
+
export * from "./components/ui/modal/ModalButtons.js";
|
|
25
|
+
export * from "./components/ui/tabs/Selector.js";
|
|
26
|
+
export * from "./components/ui/toaster/Toaster.js";
|