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.
Files changed (102) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/components/form/choice/Choice.d.ts +11 -0
  3. package/dist/components/form/choice/Choice.d.ts.map +1 -0
  4. package/dist/components/form/choice/Choice.js +19 -0
  5. package/dist/components/form/choice/Choice.js.map +1 -0
  6. package/dist/components/form/choice/Choice.module.scss +43 -0
  7. package/dist/components/form/choice/ChoiceItem.d.ts +11 -0
  8. package/dist/components/form/choice/ChoiceItem.d.ts.map +1 -0
  9. package/dist/components/form/choice/ChoiceItem.js +33 -0
  10. package/dist/components/form/choice/ChoiceItem.js.map +1 -0
  11. package/dist/components/ui/tabs/Item.d.ts +10 -0
  12. package/dist/components/ui/tabs/Item.d.ts.map +1 -0
  13. package/dist/components/ui/tabs/Item.js +39 -0
  14. package/dist/components/ui/tabs/Item.js.map +1 -0
  15. package/dist/components/ui/tabs/Item.module.scss +11 -0
  16. package/dist/components/ui/tabs/Selector.d.ts +10 -0
  17. package/dist/components/ui/tabs/Selector.d.ts.map +1 -0
  18. package/dist/components/ui/tabs/Selector.js +46 -0
  19. package/dist/components/ui/tabs/Selector.js.map +1 -0
  20. package/dist/components/ui/tabs/Selector.module.scss +6 -0
  21. package/dist/global.scss +9 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +2 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/types/form.d.ts +7 -0
  27. package/dist/types/form.d.ts.map +1 -0
  28. package/dist/types/form.js +3 -0
  29. package/dist/types/form.js.map +1 -0
  30. package/dist/utils/index.d.ts +3 -0
  31. package/dist/utils/index.d.ts.map +1 -0
  32. package/dist/utils/index.js +15 -0
  33. package/dist/utils/index.js.map +1 -0
  34. package/dist/utils/toObjectValue.d.ts +4 -0
  35. package/dist/utils/toObjectValue.d.ts.map +1 -0
  36. package/dist/utils/toObjectValue.js +8 -0
  37. package/dist/utils/toObjectValue.js.map +1 -0
  38. package/docs/assets/js/search.js +1 -1
  39. package/docs/assets/js/search.json +1 -1
  40. package/docs/classes/ToasterProvider.html +14 -8
  41. package/docs/enums/ICON.html +14 -8
  42. package/docs/index.html +10 -4
  43. package/docs/modules/Item.html +3 -3
  44. package/docs/modules/List.html +3 -3
  45. package/docs/modules/Modal.html +3 -3
  46. package/docs/modules/ModalButtons.html +3 -3
  47. package/docs/modules/Section.html +3 -3
  48. package/docs/modules/StickyHeader.html +4 -4
  49. package/docs/modules.html +53 -25
  50. package/docs/pages/Tutorials/Test.html +3 -3
  51. package/esm/components/form/choice/Choice.d.ts +11 -0
  52. package/esm/components/form/choice/Choice.d.ts.map +1 -0
  53. package/esm/components/form/choice/Choice.js +13 -0
  54. package/esm/components/form/choice/Choice.js.map +1 -0
  55. package/esm/components/form/choice/Choice.module.scss +43 -0
  56. package/esm/components/form/choice/ChoiceItem.d.ts +11 -0
  57. package/esm/components/form/choice/ChoiceItem.d.ts.map +1 -0
  58. package/esm/components/form/choice/ChoiceItem.js +11 -0
  59. package/esm/components/form/choice/ChoiceItem.js.map +1 -0
  60. package/esm/components/ui/tabs/Item.d.ts +10 -0
  61. package/esm/components/ui/tabs/Item.d.ts.map +1 -0
  62. package/esm/components/ui/tabs/Item.js +14 -0
  63. package/esm/components/ui/tabs/Item.js.map +1 -0
  64. package/esm/components/ui/tabs/Item.module.scss +11 -0
  65. package/esm/components/ui/tabs/Selector.d.ts +10 -0
  66. package/esm/components/ui/tabs/Selector.d.ts.map +1 -0
  67. package/esm/components/ui/tabs/Selector.js +21 -0
  68. package/esm/components/ui/tabs/Selector.js.map +1 -0
  69. package/esm/components/ui/tabs/Selector.module.scss +6 -0
  70. package/esm/global.scss +9 -0
  71. package/esm/index.d.ts +2 -0
  72. package/esm/index.d.ts.map +1 -1
  73. package/esm/index.js +2 -0
  74. package/esm/index.js.map +1 -1
  75. package/esm/types/form.d.ts +7 -0
  76. package/esm/types/form.d.ts.map +1 -0
  77. package/esm/types/form.js +2 -0
  78. package/esm/types/form.js.map +1 -0
  79. package/esm/utils/index.d.ts +3 -0
  80. package/esm/utils/index.d.ts.map +1 -0
  81. package/esm/utils/index.js +3 -0
  82. package/esm/utils/index.js.map +1 -0
  83. package/esm/utils/toObjectValue.d.ts +4 -0
  84. package/esm/utils/toObjectValue.d.ts.map +1 -0
  85. package/esm/utils/toObjectValue.js +5 -0
  86. package/esm/utils/toObjectValue.js.map +1 -0
  87. package/package.json +1 -1
  88. package/src/components/form/choice/Choice.module.scss +43 -0
  89. package/src/components/form/choice/Choice.tsx +32 -0
  90. package/src/components/form/choice/ChoiceItem.tsx +30 -0
  91. package/src/components/ui/tabs/Item.module.scss +11 -0
  92. package/src/components/ui/tabs/Item.tsx +26 -0
  93. package/src/components/ui/tabs/Selector.module.scss +6 -0
  94. package/src/components/ui/tabs/Selector.tsx +31 -0
  95. package/src/demo/components/form/Choice.tsx +19 -0
  96. package/src/demo/components/ui/tabs/Tabs.tsx +15 -0
  97. package/src/demo/componentsMap.ts +10 -0
  98. package/src/global.scss +9 -0
  99. package/src/index.ts +2 -0
  100. package/src/types/form.ts +7 -0
  101. package/src/utils/index.ts +2 -0
  102. package/src/utils/toObjectValue.ts +9 -0
@@ -0,0 +1,3 @@
1
+ export * from "./makeVariants";
2
+ export * from "./toObjectValue";
3
+ //# sourceMappingURL=index.js.map
@@ -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,4 @@
1
+ import type { ObjectValue, Value } from "../types/form";
2
+ declare const toObjectValue: (s: Value) => ObjectValue;
3
+ export { toObjectValue, };
4
+ //# sourceMappingURL=toObjectValue.d.ts.map
@@ -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,5 @@
1
+ const toObjectValue = (s) => {
2
+ return typeof s === "string" ? { value: s, label: s } : s;
3
+ };
4
+ export { toObjectValue, };
5
+ //# sourceMappingURL=toObjectValue.js.map
@@ -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.8.0",
3
+ "version": "0.9.0",
4
4
  "author": "Jacek Nowacki",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -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,11 @@
1
+ .button {
2
+ border: none;
3
+ padding: 0;
4
+ font-size: calc(29px / var(--ratio-font));
5
+ color: var(--selector-text);
6
+ background: none;
7
+ }
8
+
9
+ .active {
10
+ color: var(--selector-active);
11
+ }
@@ -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,6 @@
1
+ .selector {
2
+ display: flex;
3
+ flex: 1;
4
+ justify-content: center;
5
+ gap: calc(114px / var(--ratio-dimensions));
6
+ }
@@ -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";
@@ -0,0 +1,7 @@
1
+ interface ObjectValue { value: string; label: string }
2
+ type Value = string | ObjectValue;
3
+
4
+ export type {
5
+ ObjectValue,
6
+ Value,
7
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./makeVariants";
2
+ export * from "./toObjectValue";
@@ -0,0 +1,9 @@
1
+ import type { ObjectValue, Value } from "../types/form";
2
+
3
+ const toObjectValue = (s: Value): ObjectValue => {
4
+ return typeof s === "string" ? { value: s, label: s } : s;
5
+ };
6
+
7
+ export {
8
+ toObjectValue,
9
+ };