react-miui 0.8.0 → 0.9.3
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 +26 -0
- package/dist/components/form/Checkbox.d.ts +2 -0
- package/dist/components/form/Checkbox.d.ts.map +1 -1
- package/dist/components/form/Checkbox.js +14 -4
- package/dist/components/form/Checkbox.js.map +1 -1
- package/dist/components/form/Checkbox.module.scss +54 -30
- package/dist/components/form/Input.d.ts.map +1 -1
- package/dist/components/form/Input.js +2 -0
- package/dist/components/form/Input.js.map +1 -1
- package/dist/components/form/Input.module.scss +21 -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 +1 -0
- package/dist/components/layout/list/Header.d.ts.map +1 -1
- package/dist/components/layout/list/Header.js +2 -2
- package/dist/components/layout/list/Header.js.map +1 -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.map +1 -1
- package/dist/components/layout/list/List.js +4 -3
- package/dist/components/layout/list/List.js.map +1 -1
- 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/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 +16 -3
- 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 +4 -4
- 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/Checkbox.d.ts +2 -0
- package/esm/components/form/Checkbox.d.ts.map +1 -1
- package/esm/components/form/Checkbox.js +14 -4
- package/esm/components/form/Checkbox.js.map +1 -1
- package/esm/components/form/Checkbox.module.scss +54 -30
- package/esm/components/form/Input.d.ts.map +1 -1
- package/esm/components/form/Input.js +2 -0
- package/esm/components/form/Input.js.map +1 -1
- package/esm/components/form/Input.module.scss +21 -0
- 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 +1 -0
- package/esm/components/layout/list/Header.d.ts.map +1 -1
- package/esm/components/layout/list/Header.js +2 -2
- package/esm/components/layout/list/Header.js.map +1 -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.map +1 -1
- package/esm/components/layout/list/List.js +4 -3
- package/esm/components/layout/list/List.js.map +1 -1
- 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/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 +16 -3
- 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 +7 -7
- package/src/components/form/Checkbox.module.scss +54 -30
- package/src/components/form/Checkbox.tsx +25 -4
- package/src/components/form/Input.module.scss +21 -0
- package/src/components/form/Input.tsx +2 -0
- 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 +3 -2
- package/src/components/layout/list/Label.tsx +3 -1
- package/src/components/layout/list/List.tsx +5 -6
- package/src/components/layout/list/Value.tsx +7 -2
- 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/Checkbox.tsx +19 -1
- package/src/demo/components/form/Choice.tsx +19 -0
- package/src/demo/components/form/Input.tsx +4 -0
- package/src/demo/components/ui/tabs/Tabs.tsx +15 -0
- package/src/demo/componentsMap.ts +10 -0
- package/src/global.scss +16 -3
- 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":"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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-miui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"author": "Jacek Nowacki",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"lint": "eslint src --ext .ts,.tsx,.js,.jsx,.mjs",
|
|
14
14
|
"lint:fix": "yarn lint --fix",
|
|
15
15
|
"prepack": "yarn compile",
|
|
16
|
-
"prepublishOnly": "yarn lint && yarn test && yarn docs",
|
|
16
|
+
"prepublishOnly": "yarn audit && yarn lint && yarn test && yarn docs",
|
|
17
17
|
"start:dev": "next dev",
|
|
18
18
|
"deploy:dev": "next build && next export && netlify deploy --dir out"
|
|
19
19
|
},
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
"eslint-plugin-react": "^7.24.0",
|
|
49
49
|
"fast-glob": "^3.2.7",
|
|
50
50
|
"fs-extra": "^9.0.1",
|
|
51
|
-
"husky": "^
|
|
52
|
-
"jest": "^27.
|
|
51
|
+
"husky": "^7.0.4",
|
|
52
|
+
"jest": "^27.5.1",
|
|
53
53
|
"must": "^0.13.4",
|
|
54
|
-
"next": "^11.1.
|
|
54
|
+
"next": "^11.1.4",
|
|
55
55
|
"react": "^17.0.2",
|
|
56
56
|
"react-dom": "^17.0.2",
|
|
57
57
|
"react-use": "^17.2.4",
|
|
58
58
|
"sass": "^1.35.2",
|
|
59
59
|
"ts-node": "^9.0.0",
|
|
60
|
-
"typedoc": "^0.21.
|
|
60
|
+
"typedoc": "^0.21.10",
|
|
61
61
|
"typedoc-plugin-pages-fork-fork": "^0.0.3",
|
|
62
62
|
"typescript": "^4.2.4"
|
|
63
63
|
},
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"libraryTemplate": {
|
|
74
|
-
"version": "3.4.
|
|
74
|
+
"version": "3.4.1",
|
|
75
75
|
"language": "typescript",
|
|
76
76
|
"fixDefaultForCommonJS": true,
|
|
77
77
|
"jsx": true
|
|
@@ -6,42 +6,66 @@
|
|
|
6
6
|
margin: 0;
|
|
7
7
|
vertical-align: middle;
|
|
8
8
|
|
|
9
|
-
+ span {
|
|
10
|
-
border-radius: 100px;
|
|
11
|
-
background: var(--inactive-bg);
|
|
12
|
-
width: 18px;
|
|
13
|
-
height: 18px;
|
|
14
|
-
display: inline-flex;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
align-items: center;
|
|
17
|
-
vertical-align: middle;
|
|
18
|
-
|
|
19
|
-
svg {
|
|
20
|
-
width: 9px;
|
|
21
|
-
height: 9px;
|
|
22
|
-
fill: white;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
+ span {
|
|
26
|
-
vertical-align: middle;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
9
|
&:focus-visible {
|
|
31
|
-
+
|
|
10
|
+
+ .checkmark {
|
|
32
11
|
box-shadow: 0 0 5px black;
|
|
33
12
|
}
|
|
34
13
|
}
|
|
35
14
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
color: var(--main-color);
|
|
39
|
-
background: currentColor;
|
|
40
|
-
}
|
|
15
|
+
+ .checkmark + .label:not(:empty) {
|
|
16
|
+
margin-left: 0.75em;
|
|
41
17
|
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
42
20
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
.checkmark {
|
|
22
|
+
border-radius: 100px;
|
|
23
|
+
background: none;
|
|
24
|
+
border: 1px solid var(--inactive-bg);
|
|
25
|
+
width: 18px;
|
|
26
|
+
height: 18px;
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
align-items: center;
|
|
30
|
+
vertical-align: middle;
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
|
|
33
|
+
svg {
|
|
34
|
+
display: none;
|
|
35
|
+
width: 9px;
|
|
36
|
+
height: 9px;
|
|
37
|
+
fill: white;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
+ .label {
|
|
41
|
+
vertical-align: middle;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.checkmarkChecked {
|
|
46
|
+
border-width: 0;
|
|
47
|
+
color: var(--main-color);
|
|
48
|
+
background: currentColor;
|
|
49
|
+
|
|
50
|
+
svg {
|
|
51
|
+
display: inline-block;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&.checkmarkDisabled {
|
|
55
|
+
background: var(--inactive-dark-bg);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.checkmarkDisabled {
|
|
60
|
+
background: var(--active-bg);
|
|
61
|
+
|
|
62
|
+
+ .label {
|
|
63
|
+
color: var(--input-disabled-text);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.checkmarkReadOnly {
|
|
68
|
+
+ .label {
|
|
69
|
+
color: var(--input-disabled-text);
|
|
46
70
|
}
|
|
47
71
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
2
3
|
|
|
3
4
|
import styles from "./Checkbox.module.scss";
|
|
4
5
|
import { Checkmark } from "../icons/Checkmark.js";
|
|
@@ -8,17 +9,37 @@ interface Props {
|
|
|
8
9
|
name: string;
|
|
9
10
|
onChange: () => void;
|
|
10
11
|
checked: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
readOnly?: boolean;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
const Checkbox: React.FC<Props> = (props) => {
|
|
14
17
|
const style: React.CSSProperties = {};
|
|
15
18
|
props.color && (style.color = props.color);
|
|
16
19
|
|
|
20
|
+
const cls = classnames(styles.checkbox, {
|
|
21
|
+
[styles.disabled]: props.disabled,
|
|
22
|
+
[styles.readOnly]: props.readOnly,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const checkmarkCls = classnames(styles.checkmark, {
|
|
26
|
+
[styles.checkmarkDisabled]: props.disabled,
|
|
27
|
+
[styles.checkmarkChecked]: props.checked,
|
|
28
|
+
[styles.checkmarkReadOnly]: props.readOnly,
|
|
29
|
+
});
|
|
30
|
+
|
|
17
31
|
return (
|
|
18
|
-
<label className={
|
|
19
|
-
<input
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
<label className={cls}>
|
|
33
|
+
<input
|
|
34
|
+
type={"checkbox"}
|
|
35
|
+
name={props.name}
|
|
36
|
+
onChange={props.onChange}
|
|
37
|
+
checked={props.checked}
|
|
38
|
+
disabled={props.disabled}
|
|
39
|
+
readOnly={props.readOnly}
|
|
40
|
+
/>
|
|
41
|
+
<span style={style} className={checkmarkCls}><Checkmark /></span>
|
|
42
|
+
<span className={styles.label}>{props.children}</span>
|
|
22
43
|
</label>
|
|
23
44
|
);
|
|
24
45
|
};
|
|
@@ -24,6 +24,27 @@
|
|
|
24
24
|
padding: 0 calc(36px / var(--ratio-dimensions));
|
|
25
25
|
border: calc(1px / var(--ratio-border)) solid var(--border);
|
|
26
26
|
align-items: center;
|
|
27
|
+
|
|
28
|
+
.input {
|
|
29
|
+
flex: 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.disabled {
|
|
33
|
+
background: var(--input-disabled-bg);
|
|
34
|
+
color: var(--input-disabled-text);
|
|
35
|
+
|
|
36
|
+
.input {
|
|
37
|
+
color: var(--input-disabled-text);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.readOnly {
|
|
42
|
+
color: var(--input-disabled-text);
|
|
43
|
+
|
|
44
|
+
.input {
|
|
45
|
+
color: var(--input-disabled-text);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
27
48
|
}
|
|
28
49
|
|
|
29
50
|
.textarea {
|
|
@@ -29,6 +29,8 @@ const Input: React.FC<Omit<React.InputHTMLAttributes<HTMLInputElement>, "prefix"
|
|
|
29
29
|
|
|
30
30
|
const wrapperCls = classnames(styles.wrapper, {
|
|
31
31
|
[styles.wrapperFocused]: focused,
|
|
32
|
+
[styles.disabled]: props.disabled,
|
|
33
|
+
[styles.readOnly]: props.readOnly,
|
|
32
34
|
}, className);
|
|
33
35
|
|
|
34
36
|
const prefixElem = prefix ? <div className={styles.prefix}>{prefix}</div> : null;
|
|
@@ -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 };
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import classnames from "classnames";
|
|
3
3
|
|
|
4
|
+
import { makeVariants } from "../../../utils/makeVariants";
|
|
4
5
|
import styles from "./Item.module.scss";
|
|
5
6
|
import headerStyles from "./Header.module.scss";
|
|
6
|
-
import { makeVariants } from "../../../utils/makeVariants";
|
|
7
7
|
|
|
8
8
|
type Variant = "inset";
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
11
|
+
className?: string;
|
|
11
12
|
variant?: Variant | Variant[];
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
const Header: React.FC<Props> = (props) => {
|
|
15
16
|
const v = makeVariants(props.variant);
|
|
16
17
|
|
|
17
|
-
const cls = classnames(styles.item, headerStyles.header, {
|
|
18
|
+
const cls = classnames(props.className, styles.item, headerStyles.header, {
|
|
18
19
|
[styles.inset]: v.includes("inset"),
|
|
19
20
|
});
|
|
20
21
|
|
|
@@ -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>
|
|
@@ -30,13 +30,12 @@ const List: React.FC<Props> & SubComponents = (props) => {
|
|
|
30
30
|
return child;
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
const cls = classnames(props.className, styles.list, {
|
|
34
|
+
[styles.inset]: v.includes("inset"),
|
|
35
|
+
});
|
|
36
|
+
|
|
33
37
|
return (
|
|
34
|
-
<ul
|
|
35
|
-
className={classnames(styles.list, {
|
|
36
|
-
[styles.inset]: v.includes("inset"),
|
|
37
|
-
})}
|
|
38
|
-
>{chld}
|
|
39
|
-
</ul>
|
|
38
|
+
<ul className={cls}>{chld}</ul>
|
|
40
39
|
);
|
|
41
40
|
};
|
|
42
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
|
|
|
@@ -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 };
|
|
@@ -2,13 +2,31 @@ import React, { useCallback, useState } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { Checkbox } from "../../../index.js";
|
|
4
4
|
|
|
5
|
+
const handleChangeNoop = () => undefined;
|
|
6
|
+
|
|
5
7
|
const CheckboxDemo: React.FC = (props) => {
|
|
6
8
|
const [v, setV] = useState(false);
|
|
7
9
|
|
|
8
10
|
const handleToggle = useCallback(() => { setV((prevV) => !prevV); }, []);
|
|
9
11
|
|
|
10
12
|
return (
|
|
11
|
-
|
|
13
|
+
<>
|
|
14
|
+
<Checkbox name={"a"} onChange={handleToggle} checked={!v}>I want something something</Checkbox>
|
|
15
|
+
<hr />
|
|
16
|
+
<Checkbox name={"a"} onChange={handleChangeNoop} checked={true} disabled={true}>
|
|
17
|
+
Something else - disabled
|
|
18
|
+
</Checkbox>
|
|
19
|
+
<Checkbox name={"a"} onChange={handleChangeNoop} checked={false} disabled={true}>
|
|
20
|
+
Something else - disabled
|
|
21
|
+
</Checkbox>
|
|
22
|
+
<hr />
|
|
23
|
+
<Checkbox name={"a"} onChange={handleChangeNoop} checked={true} readOnly={true}>
|
|
24
|
+
Last option - readonly
|
|
25
|
+
</Checkbox>
|
|
26
|
+
<Checkbox name={"a"} onChange={handleChangeNoop} checked={false} readOnly={true}>
|
|
27
|
+
Last option - readonly
|
|
28
|
+
</Checkbox>
|
|
29
|
+
</>
|
|
12
30
|
);
|
|
13
31
|
};
|
|
14
32
|
|
|
@@ -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 };
|
|
@@ -6,6 +6,10 @@ const InputDemo: React.FC = () => {
|
|
|
6
6
|
return (
|
|
7
7
|
<>
|
|
8
8
|
<Input placeholder={"Capacity"} prefix={<Icon name={ICON.battery} />} suffix={"kWh"} />
|
|
9
|
+
<Input value={"William J. Welter"} />
|
|
10
|
+
<Input prefix={"Text prefix"} value={"Polly W. Wilson"} />
|
|
11
|
+
<Input prefix={"Disabled"} value={"Clayton J. Foster"} disabled={true} />
|
|
12
|
+
<Input prefix={"Read only"} value={"Norma J. Gomez"} readOnly={true} />
|
|
9
13
|
</>
|
|
10
14
|
);
|
|
11
15
|
};
|
|
@@ -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
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
--background: white;
|
|
9
9
|
|
|
10
|
-
--main-color: #008ad2;
|
|
10
|
+
--main-color: #008ad2;
|
|
11
11
|
--main-color-alt: #006AA9;
|
|
12
12
|
|
|
13
|
-
--active-bg: #
|
|
14
|
-
--inactive-bg: #d3d3d3;
|
|
13
|
+
--active-bg: #e7e7e7;
|
|
14
|
+
--inactive-bg: #d3d3d3;
|
|
15
|
+
--inactive-dark-bg: #999;
|
|
15
16
|
|
|
16
17
|
--toggle-handle-bg: #e0e0e0;
|
|
17
18
|
--toggle-handle-border: #cdcdcd;
|
|
@@ -32,6 +33,18 @@
|
|
|
32
33
|
--modal-button-bg: #f8f8f8;
|
|
33
34
|
--modal-button-border: #c2c2c2;
|
|
34
35
|
|
|
36
|
+
--input-disabled-bg: #f3f3f3;
|
|
37
|
+
--input-disabled-text: #959595;
|
|
38
|
+
|
|
39
|
+
--choice-bg: #ffffff;
|
|
40
|
+
--choice-text: #999999;
|
|
41
|
+
--choice-active-bg: #f3f3f3;
|
|
42
|
+
--choice-active-text: #313131;
|
|
43
|
+
--choice-border: #cfcfcf;
|
|
44
|
+
|
|
45
|
+
--selector-text: #606060;
|
|
46
|
+
--selector-active: var(--main-color);
|
|
47
|
+
|
|
35
48
|
// Shades: https://maketintsandshades.com/#038bf4,ff7200,7357e8,3ec234,3ec234,ff388f,ea2700
|
|
36
49
|
--blue1: #038bf4;
|
|
37
50
|
--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";
|