react-miui 0.8.0 → 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 +5 -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/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/global.scss +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -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 +14 -8
- package/docs/enums/ICON.html +14 -8
- package/docs/index.html +10 -4
- package/docs/modules/Item.html +3 -3
- package/docs/modules/List.html +3 -3
- package/docs/modules/Modal.html +3 -3
- package/docs/modules/ModalButtons.html +3 -3
- package/docs/modules/Section.html +3 -3
- package/docs/modules/StickyHeader.html +4 -4
- package/docs/modules.html +53 -25
- package/docs/pages/Tutorials/Test.html +3 -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/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/global.scss +9 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -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 +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/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/demo/components/form/Choice.tsx +19 -0
- package/src/demo/components/ui/tabs/Tabs.tsx +15 -0
- package/src/demo/componentsMap.ts +10 -0
- package/src/global.scss +9 -0
- package/src/index.ts +2 -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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toObjectValue.d.ts","sourceRoot":"","sources":["../../src/utils/toObjectValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAExD,QAAA,MAAM,aAAa,MAAO,KAAK,KAAG,WAEjC,CAAC;AAEF,OAAO,EACH,aAAa,GAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toObjectValue.js","sourceRoot":"","sources":["../../src/utils/toObjectValue.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAG,CAAC,CAAQ,EAAe,EAAE;IAC5C,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,OAAO,EACH,aAAa,GAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.choice {
|
|
2
|
+
input {
|
|
3
|
+
width: 0;
|
|
4
|
+
height: 0;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
opacity: 0;
|
|
7
|
+
margin: 0;
|
|
8
|
+
position: absolute;
|
|
9
|
+
|
|
10
|
+
&:checked + span {
|
|
11
|
+
color: var(--choice-active-text);
|
|
12
|
+
background: var(--choice-active-bg);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
span {
|
|
17
|
+
display: flex;
|
|
18
|
+
padding: 0;
|
|
19
|
+
flex: 1;
|
|
20
|
+
height: 100%;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
font-size: calc(24px / var(--ratio-font));
|
|
24
|
+
color: var(--choice-text);
|
|
25
|
+
background: var(--choice-bg);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
display: flex;
|
|
29
|
+
border: 1px solid var(--choice-border); // @TODO width
|
|
30
|
+
position: relative;
|
|
31
|
+
border-radius: 8px;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
|
|
34
|
+
label {
|
|
35
|
+
flex: 1;
|
|
36
|
+
height: calc(89px / var(--ratio-dimensions));
|
|
37
|
+
display: flex;
|
|
38
|
+
|
|
39
|
+
+ label {
|
|
40
|
+
border-left: 1px solid var(--choice-border);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { Value } from "../../../types/form";
|
|
4
|
+
import { toObjectValue } from "../../../utils";
|
|
5
|
+
import { ChoiceItem } from "./ChoiceItem";
|
|
6
|
+
import styles from "./Choice.module.scss";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
values: Value[];
|
|
10
|
+
value: string;
|
|
11
|
+
name: string;
|
|
12
|
+
onChange: (value: string) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Choice: React.FC<Props> = (props) => {
|
|
16
|
+
const opts = props.values.map(option => {
|
|
17
|
+
const opt = toObjectValue(option);
|
|
18
|
+
return (
|
|
19
|
+
<ChoiceItem
|
|
20
|
+
key={opt.value}
|
|
21
|
+
name={props.name}
|
|
22
|
+
value={opt}
|
|
23
|
+
onChange={props.onChange}
|
|
24
|
+
active={props.value === opt.value}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return <div className={styles.choice}>{opts}</div>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { Choice };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import type { ObjectValue } from "../../../types/form";
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
name: string;
|
|
6
|
+
value: ObjectValue;
|
|
7
|
+
onChange: (value: string) => void;
|
|
8
|
+
active: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ChoiceItem: React.FC<Props> = (props) => {
|
|
12
|
+
const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
13
|
+
props.onChange(e.currentTarget.value);
|
|
14
|
+
}, [props.onChange]);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<label key={props.value.value} tabIndex={0}>
|
|
18
|
+
<input
|
|
19
|
+
type={"radio"}
|
|
20
|
+
name={props.name}
|
|
21
|
+
value={props.value.value}
|
|
22
|
+
checked={props.active}
|
|
23
|
+
onChange={handleChange}
|
|
24
|
+
/>
|
|
25
|
+
<span>{props.value.label}</span>
|
|
26
|
+
</label>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { ChoiceItem };
|
|
@@ -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,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,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 };
|
|
@@ -38,6 +38,8 @@ import { ToasterDemo } from "./components/ui/toaster/Toaster";
|
|
|
38
38
|
import { ModalCenteredDemo, ModalDemo, ModalOptionsDemo } from "./components/ui/modal/Modal";
|
|
39
39
|
import { ListInsetDemo } from "./components/layout/list/Inset";
|
|
40
40
|
import { ListSelectionDemo } from "./components/layout/list/Selection";
|
|
41
|
+
import { TabsDemo } from "./components/ui/tabs/Tabs";
|
|
42
|
+
import { ChoiceDemo } from "./components/form/Choice";
|
|
41
43
|
|
|
42
44
|
interface TheMap {
|
|
43
45
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
@@ -79,6 +81,10 @@ const componentsMap: TheMap = {
|
|
|
79
81
|
name: "Toggle",
|
|
80
82
|
Component: ToggleDemo,
|
|
81
83
|
},
|
|
84
|
+
Choice: {
|
|
85
|
+
name: "Choice",
|
|
86
|
+
Component: ChoiceDemo,
|
|
87
|
+
},
|
|
82
88
|
},
|
|
83
89
|
},
|
|
84
90
|
Header: {
|
|
@@ -153,6 +159,10 @@ const componentsMap: TheMap = {
|
|
|
153
159
|
},
|
|
154
160
|
},
|
|
155
161
|
},
|
|
162
|
+
Tabs: {
|
|
163
|
+
name: "Tabs",
|
|
164
|
+
Component: TabsDemo,
|
|
165
|
+
},
|
|
156
166
|
ListItem: {
|
|
157
167
|
name: "List & Item",
|
|
158
168
|
Component: ListItemDemo,
|
package/src/global.scss
CHANGED
|
@@ -32,6 +32,15 @@
|
|
|
32
32
|
--modal-button-bg: #f8f8f8;
|
|
33
33
|
--modal-button-border: #c2c2c2;
|
|
34
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);
|
|
43
|
+
|
|
35
44
|
// Shades: https://maketintsandshades.com/#038bf4,ff7200,7357e8,3ec234,3ec234,ff388f,ea2700
|
|
36
45
|
--blue1: #038bf4;
|
|
37
46
|
--orange1: #ff7200;
|
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";
|
|
@@ -21,4 +22,5 @@ export * from "./components/ui/button/Button.js";
|
|
|
21
22
|
export * from "./components/ui/directionPad/Pad.js";
|
|
22
23
|
export * from "./components/ui/modal/Modal.js";
|
|
23
24
|
export * from "./components/ui/modal/ModalButtons.js";
|
|
25
|
+
export * from "./components/ui/tabs/Selector.js";
|
|
24
26
|
export * from "./components/ui/toaster/Toaster.js";
|