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.
Files changed (238) hide show
  1. package/CHANGELOG.md +30 -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/layout/list/Header.d.ts +6 -1
  12. package/dist/components/layout/list/Header.d.ts.map +1 -1
  13. package/dist/components/layout/list/Header.js +6 -1
  14. package/dist/components/layout/list/Header.js.map +1 -1
  15. package/dist/components/layout/list/Item.d.ts +3 -0
  16. package/dist/components/layout/list/Item.d.ts.map +1 -1
  17. package/dist/components/layout/list/Item.js +20 -6
  18. package/dist/components/layout/list/Item.js.map +1 -1
  19. package/dist/components/layout/list/Item.module.scss +16 -1
  20. package/dist/components/layout/list/Label.d.ts +1 -0
  21. package/dist/components/layout/list/Label.d.ts.map +1 -1
  22. package/dist/components/layout/list/Label.js +2 -1
  23. package/dist/components/layout/list/Label.js.map +1 -1
  24. package/dist/components/layout/list/List.d.ts +6 -1
  25. package/dist/components/layout/list/List.d.ts.map +1 -1
  26. package/dist/components/layout/list/List.js +16 -1
  27. package/dist/components/layout/list/List.js.map +1 -1
  28. package/dist/components/layout/list/List.module.scss +4 -0
  29. package/dist/components/layout/list/Value.d.ts +4 -1
  30. package/dist/components/layout/list/Value.d.ts.map +1 -1
  31. package/dist/components/layout/list/Value.js +2 -1
  32. package/dist/components/layout/list/Value.js.map +1 -1
  33. package/dist/components/ui/button/Button.d.ts.map +1 -1
  34. package/dist/components/ui/button/Button.js +2 -2
  35. package/dist/components/ui/button/Button.js.map +1 -1
  36. package/dist/components/ui/modal/Modal.d.ts +18 -0
  37. package/dist/components/ui/modal/Modal.d.ts.map +1 -0
  38. package/dist/components/ui/modal/Modal.js +108 -0
  39. package/dist/components/ui/modal/Modal.js.map +1 -0
  40. package/dist/components/ui/modal/Modal.module.scss +92 -0
  41. package/dist/components/ui/modal/ModalButton.d.ts +8 -0
  42. package/dist/components/ui/modal/ModalButton.d.ts.map +1 -0
  43. package/dist/components/ui/modal/ModalButton.js +31 -0
  44. package/dist/components/ui/modal/ModalButton.js.map +1 -0
  45. package/dist/components/ui/modal/ModalButtons.d.ts +10 -0
  46. package/dist/components/ui/modal/ModalButtons.d.ts.map +1 -0
  47. package/dist/components/ui/modal/ModalButtons.js +15 -0
  48. package/dist/components/ui/modal/ModalButtons.js.map +1 -0
  49. package/dist/components/ui/modal/ModalButtons.module.scss +32 -0
  50. package/dist/components/ui/modal/ModalNoMargin.d.ts +6 -0
  51. package/dist/components/ui/modal/ModalNoMargin.d.ts.map +1 -0
  52. package/dist/components/ui/modal/ModalNoMargin.js +22 -0
  53. package/dist/components/ui/modal/ModalNoMargin.js.map +1 -0
  54. package/dist/components/ui/tabs/Item.d.ts +10 -0
  55. package/dist/components/ui/tabs/Item.d.ts.map +1 -0
  56. package/dist/components/ui/tabs/Item.js +39 -0
  57. package/dist/components/ui/tabs/Item.js.map +1 -0
  58. package/dist/components/ui/tabs/Item.module.scss +11 -0
  59. package/dist/components/ui/tabs/Selector.d.ts +10 -0
  60. package/dist/components/ui/tabs/Selector.d.ts.map +1 -0
  61. package/dist/components/ui/tabs/Selector.js +46 -0
  62. package/dist/components/ui/tabs/Selector.js.map +1 -0
  63. package/dist/components/ui/tabs/Selector.module.scss +6 -0
  64. package/dist/components/ui/toaster/Notification.d.ts +9 -0
  65. package/dist/components/ui/toaster/Notification.d.ts.map +1 -0
  66. package/dist/components/ui/toaster/Notification.js +39 -0
  67. package/dist/components/ui/toaster/Notification.js.map +1 -0
  68. package/dist/components/ui/toaster/Toaster.d.ts +18 -0
  69. package/dist/components/ui/toaster/Toaster.d.ts.map +1 -0
  70. package/dist/components/ui/toaster/Toaster.js +79 -0
  71. package/dist/components/ui/toaster/Toaster.js.map +1 -0
  72. package/dist/components/ui/toaster/Toaster.module.scss +32 -0
  73. package/dist/components/ui/toaster/types.d.ts +7 -0
  74. package/dist/components/ui/toaster/types.d.ts.map +1 -0
  75. package/dist/components/ui/toaster/types.js +3 -0
  76. package/dist/components/ui/toaster/types.js.map +1 -0
  77. package/dist/global.scss +12 -0
  78. package/dist/index.d.ts +5 -0
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +5 -0
  81. package/dist/index.js.map +1 -1
  82. package/dist/types/form.d.ts +7 -0
  83. package/dist/types/form.d.ts.map +1 -0
  84. package/dist/types/form.js +3 -0
  85. package/dist/types/form.js.map +1 -0
  86. package/dist/utils/index.d.ts +3 -0
  87. package/dist/utils/index.d.ts.map +1 -0
  88. package/dist/utils/index.js +15 -0
  89. package/dist/utils/index.js.map +1 -0
  90. package/dist/utils/toObjectValue.d.ts +4 -0
  91. package/dist/utils/toObjectValue.d.ts.map +1 -0
  92. package/dist/utils/toObjectValue.js +8 -0
  93. package/dist/utils/toObjectValue.js.map +1 -0
  94. package/docs/assets/js/search.js +1 -1
  95. package/docs/assets/js/search.json +1 -1
  96. package/docs/classes/ToasterProvider.html +1096 -0
  97. package/docs/enums/ICON.html +33 -8
  98. package/docs/index.html +35 -4
  99. package/docs/modules/Item.html +17 -4
  100. package/docs/modules/List.html +17 -4
  101. package/docs/modules/Modal.html +160 -0
  102. package/docs/modules/ModalButtons.html +160 -0
  103. package/docs/modules/Section.html +16 -3
  104. package/docs/modules/StickyHeader.html +17 -4
  105. package/docs/modules.html +132 -23
  106. package/docs/pages/Tutorials/Test.html +16 -3
  107. package/esm/components/form/choice/Choice.d.ts +11 -0
  108. package/esm/components/form/choice/Choice.d.ts.map +1 -0
  109. package/esm/components/form/choice/Choice.js +13 -0
  110. package/esm/components/form/choice/Choice.js.map +1 -0
  111. package/esm/components/form/choice/Choice.module.scss +43 -0
  112. package/esm/components/form/choice/ChoiceItem.d.ts +11 -0
  113. package/esm/components/form/choice/ChoiceItem.d.ts.map +1 -0
  114. package/esm/components/form/choice/ChoiceItem.js +11 -0
  115. package/esm/components/form/choice/ChoiceItem.js.map +1 -0
  116. package/esm/components/layout/list/Header.d.ts +6 -1
  117. package/esm/components/layout/list/Header.d.ts.map +1 -1
  118. package/esm/components/layout/list/Header.js +6 -1
  119. package/esm/components/layout/list/Header.js.map +1 -1
  120. package/esm/components/layout/list/Item.d.ts +3 -0
  121. package/esm/components/layout/list/Item.d.ts.map +1 -1
  122. package/esm/components/layout/list/Item.js +20 -6
  123. package/esm/components/layout/list/Item.js.map +1 -1
  124. package/esm/components/layout/list/Item.module.scss +16 -1
  125. package/esm/components/layout/list/Label.d.ts +1 -0
  126. package/esm/components/layout/list/Label.d.ts.map +1 -1
  127. package/esm/components/layout/list/Label.js +2 -1
  128. package/esm/components/layout/list/Label.js.map +1 -1
  129. package/esm/components/layout/list/List.d.ts +6 -1
  130. package/esm/components/layout/list/List.d.ts.map +1 -1
  131. package/esm/components/layout/list/List.js +16 -1
  132. package/esm/components/layout/list/List.js.map +1 -1
  133. package/esm/components/layout/list/List.module.scss +4 -0
  134. package/esm/components/layout/list/Value.d.ts +4 -1
  135. package/esm/components/layout/list/Value.d.ts.map +1 -1
  136. package/esm/components/layout/list/Value.js +2 -1
  137. package/esm/components/layout/list/Value.js.map +1 -1
  138. package/esm/components/ui/button/Button.d.ts.map +1 -1
  139. package/esm/components/ui/button/Button.js +2 -2
  140. package/esm/components/ui/button/Button.js.map +1 -1
  141. package/esm/components/ui/modal/Modal.d.ts +18 -0
  142. package/esm/components/ui/modal/Modal.d.ts.map +1 -0
  143. package/esm/components/ui/modal/Modal.js +83 -0
  144. package/esm/components/ui/modal/Modal.js.map +1 -0
  145. package/esm/components/ui/modal/Modal.module.scss +92 -0
  146. package/esm/components/ui/modal/ModalButton.d.ts +8 -0
  147. package/esm/components/ui/modal/ModalButton.d.ts.map +1 -0
  148. package/esm/components/ui/modal/ModalButton.js +13 -0
  149. package/esm/components/ui/modal/ModalButton.js.map +1 -0
  150. package/esm/components/ui/modal/ModalButtons.d.ts +10 -0
  151. package/esm/components/ui/modal/ModalButtons.d.ts.map +1 -0
  152. package/esm/components/ui/modal/ModalButtons.js +9 -0
  153. package/esm/components/ui/modal/ModalButtons.js.map +1 -0
  154. package/esm/components/ui/modal/ModalButtons.module.scss +32 -0
  155. package/esm/components/ui/modal/ModalNoMargin.d.ts +6 -0
  156. package/esm/components/ui/modal/ModalNoMargin.d.ts.map +1 -0
  157. package/esm/components/ui/modal/ModalNoMargin.js +16 -0
  158. package/esm/components/ui/modal/ModalNoMargin.js.map +1 -0
  159. package/esm/components/ui/tabs/Item.d.ts +10 -0
  160. package/esm/components/ui/tabs/Item.d.ts.map +1 -0
  161. package/esm/components/ui/tabs/Item.js +14 -0
  162. package/esm/components/ui/tabs/Item.js.map +1 -0
  163. package/esm/components/ui/tabs/Item.module.scss +11 -0
  164. package/esm/components/ui/tabs/Selector.d.ts +10 -0
  165. package/esm/components/ui/tabs/Selector.d.ts.map +1 -0
  166. package/esm/components/ui/tabs/Selector.js +21 -0
  167. package/esm/components/ui/tabs/Selector.js.map +1 -0
  168. package/esm/components/ui/tabs/Selector.module.scss +6 -0
  169. package/esm/components/ui/toaster/Notification.d.ts +9 -0
  170. package/esm/components/ui/toaster/Notification.d.ts.map +1 -0
  171. package/esm/components/ui/toaster/Notification.js +14 -0
  172. package/esm/components/ui/toaster/Notification.js.map +1 -0
  173. package/esm/components/ui/toaster/Toaster.d.ts +18 -0
  174. package/esm/components/ui/toaster/Toaster.d.ts.map +1 -0
  175. package/esm/components/ui/toaster/Toaster.js +74 -0
  176. package/esm/components/ui/toaster/Toaster.js.map +1 -0
  177. package/esm/components/ui/toaster/Toaster.module.scss +32 -0
  178. package/esm/components/ui/toaster/types.d.ts +7 -0
  179. package/esm/components/ui/toaster/types.d.ts.map +1 -0
  180. package/esm/components/ui/toaster/types.js +2 -0
  181. package/esm/components/ui/toaster/types.js.map +1 -0
  182. package/esm/global.scss +12 -0
  183. package/esm/index.d.ts +5 -0
  184. package/esm/index.d.ts.map +1 -1
  185. package/esm/index.js +5 -0
  186. package/esm/index.js.map +1 -1
  187. package/esm/types/form.d.ts +7 -0
  188. package/esm/types/form.d.ts.map +1 -0
  189. package/esm/types/form.js +2 -0
  190. package/esm/types/form.js.map +1 -0
  191. package/esm/utils/index.d.ts +3 -0
  192. package/esm/utils/index.d.ts.map +1 -0
  193. package/esm/utils/index.js +3 -0
  194. package/esm/utils/index.js.map +1 -0
  195. package/esm/utils/toObjectValue.d.ts +4 -0
  196. package/esm/utils/toObjectValue.d.ts.map +1 -0
  197. package/esm/utils/toObjectValue.js +5 -0
  198. package/esm/utils/toObjectValue.js.map +1 -0
  199. package/package.json +6 -6
  200. package/src/components/form/choice/Choice.module.scss +43 -0
  201. package/src/components/form/choice/Choice.tsx +32 -0
  202. package/src/components/form/choice/ChoiceItem.tsx +30 -0
  203. package/src/components/layout/list/Header.tsx +16 -2
  204. package/src/components/layout/list/Item.module.scss +16 -1
  205. package/src/components/layout/list/Item.tsx +28 -7
  206. package/src/components/layout/list/Label.tsx +3 -1
  207. package/src/components/layout/list/List.module.scss +4 -0
  208. package/src/components/layout/list/List.tsx +28 -2
  209. package/src/components/layout/list/Value.tsx +7 -2
  210. package/src/components/ui/button/Button.tsx +4 -2
  211. package/src/components/ui/modal/Modal.module.scss +92 -0
  212. package/src/components/ui/modal/Modal.tsx +136 -0
  213. package/src/components/ui/modal/ModalButton.tsx +25 -0
  214. package/src/components/ui/modal/ModalButtons.module.scss +32 -0
  215. package/src/components/ui/modal/ModalButtons.tsx +17 -0
  216. package/src/components/ui/modal/ModalNoMargin.tsx +22 -0
  217. package/src/components/ui/tabs/Item.module.scss +11 -0
  218. package/src/components/ui/tabs/Item.tsx +26 -0
  219. package/src/components/ui/tabs/Selector.module.scss +6 -0
  220. package/src/components/ui/tabs/Selector.tsx +31 -0
  221. package/src/components/ui/toaster/Notification.tsx +31 -0
  222. package/src/components/ui/toaster/Toaster.module.scss +32 -0
  223. package/src/components/ui/toaster/Toaster.tsx +101 -0
  224. package/src/components/ui/toaster/types.ts +9 -0
  225. package/src/demo/Demo.tsx +7 -4
  226. package/src/demo/Menu.module.scss +1 -0
  227. package/src/demo/components/form/Choice.tsx +19 -0
  228. package/src/demo/components/layout/list/Inset.tsx +24 -0
  229. package/src/demo/components/layout/list/Selection.tsx +17 -0
  230. package/src/demo/components/ui/modal/Modal.tsx +110 -0
  231. package/src/demo/components/ui/tabs/Tabs.tsx +15 -0
  232. package/src/demo/components/ui/toaster/Toaster.tsx +28 -0
  233. package/src/demo/componentsMap.ts +41 -0
  234. package/src/global.scss +12 -0
  235. package/src/index.ts +5 -0
  236. package/src/types/form.ts +7 -0
  237. package/src/utils/index.ts +2 -0
  238. package/src/utils/toObjectValue.ts +9 -0
@@ -0,0 +1,14 @@
1
+ import React, { useCallback } from "react";
2
+ import classnames from "classnames";
3
+ import styles from "./Item.module.scss";
4
+ const Item = (props) => {
5
+ const handleClick = useCallback(() => {
6
+ props.onClick(props.value.value);
7
+ }, [props.onClick, props.value.value, props.value.label]);
8
+ const cls = classnames(styles.button, {
9
+ [styles.active]: props.active,
10
+ });
11
+ return React.createElement("button", { onClick: handleClick, className: cls, type: "button" }, props.value.label);
12
+ };
13
+ export { Item };
14
+ //# sourceMappingURL=Item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/components/ui/tabs/Item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,UAAU,MAAM,YAAY,CAAC;AAIpC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAQxC,MAAM,IAAI,GAAoB,CAAC,KAAK,EAAE,EAAE;IACpC,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACjC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAE1D,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE;QAClC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM;KAChC,CAAC,CAAC;IAEH,OAAO,gCAAQ,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,IAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAU,CAAC;AACtG,CAAC,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -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,10 @@
1
+ import React from "react";
2
+ import type { Value } from "../../../types/form";
3
+ interface Props {
4
+ values: Value[];
5
+ value?: string;
6
+ onChange?: (value: string) => void;
7
+ }
8
+ declare const Selector: React.FC<Props>;
9
+ export { Selector };
10
+ //# sourceMappingURL=Selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Selector.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/tabs/Selector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAKjD,UAAU,KAAK;IACX,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAe7B,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import React, { useCallback, useState } from "react";
2
+ import { toObjectValue } from "../../../utils";
3
+ import { Item } from "./Item";
4
+ import styles from "./Selector.module.scss";
5
+ const Selector = (props) => {
6
+ var _a;
7
+ const [current, setCurrent] = useState(props.value);
8
+ const handleCurrent = useCallback((value) => {
9
+ var _a;
10
+ setCurrent(value);
11
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value);
12
+ }, [props.onChange]);
13
+ const crr = (_a = props.value) !== null && _a !== void 0 ? _a : current;
14
+ const vals = props.values.map(v => {
15
+ const ov = toObjectValue(v);
16
+ return React.createElement(Item, { key: ov.value, value: ov, onClick: handleCurrent, active: crr === ov.value });
17
+ });
18
+ return React.createElement("div", { className: styles.selector }, vals);
19
+ };
20
+ export { Selector };
21
+ //# sourceMappingURL=Selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Selector.js","sourceRoot":"","sources":["../../../../src/components/ui/tabs/Selector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGrD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAQ5C,MAAM,QAAQ,GAAoB,CAAC,KAAK,EAAE,EAAE;;IACxC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEpD,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,KAAa,EAAE,EAAE;;QAChD,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,MAAA,KAAK,CAAC,QAAQ,+CAAd,KAAK,EAAY,KAAK,CAAC,CAAC;IAC5B,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAErB,MAAM,GAAG,GAAG,MAAA,KAAK,CAAC,KAAK,mCAAI,OAAO,CAAC;IAEnC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QAC9B,MAAM,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QAC5B,OAAO,oBAAC,IAAI,IAAC,GAAG,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,KAAK,GAAI,CAAC;IAChG,CAAC,CAAC,CAAC;IACH,OAAO,6BAAK,SAAS,EAAE,MAAM,CAAC,QAAQ,IAAG,IAAI,CAAO,CAAC;AACzD,CAAC,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -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,9 @@
1
+ import React from "react";
2
+ import type { Toast } from "./types";
3
+ interface Props {
4
+ toast: Toast;
5
+ onRemove: (id: Toast["id"]) => void;
6
+ }
7
+ declare const Notification: React.FC<Props>;
8
+ export { Notification };
9
+ //# sourceMappingURL=Notification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notification.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/toaster/Notification.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,UAAU,KAAK;IACX,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;CACvC;AAGD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAgBjC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import React, { useCallback } from "react";
2
+ import classnames from "classnames";
3
+ import styles from "./Toaster.module.scss";
4
+ const Notification = (props) => {
5
+ const handleRemove = useCallback(() => {
6
+ props.onRemove(props.toast.id);
7
+ }, [props.toast.id]);
8
+ return (React.createElement("div", { className: classnames(styles.toast, {
9
+ [styles.hide]: props.toast.hide,
10
+ }), key: props.toast.id, onTransitionEnd: handleRemove },
11
+ React.createElement("span", null, props.toast.text)));
12
+ };
13
+ export { Notification };
14
+ //# sourceMappingURL=Notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notification.js","sourceRoot":"","sources":["../../../../src/components/ui/toaster/Notification.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAQ3C,MAAM,YAAY,GAAoB,CAAC,KAAK,EAAE,EAAE;IAC5C,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAErB,OAAO,CACH,6BACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE;YAChC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI;SAClC,CAAC,EACF,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,EACnB,eAAe,EAAE,YAAY;QAE7B,kCAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAQ,CAC7B,CACT,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import type { Toast } from "./types";
3
+ declare type ToasterFn = (text: string) => void;
4
+ interface Props {
5
+ }
6
+ interface State {
7
+ list: Toast[];
8
+ }
9
+ declare class ToasterProvider extends React.Component<Props, State> {
10
+ constructor(props: Props, context: unknown);
11
+ private readonly _add;
12
+ private readonly _handleRemove;
13
+ private readonly _removeAllToasts;
14
+ render(): JSX.Element;
15
+ }
16
+ declare const useToaster: () => ToasterFn;
17
+ export { ToasterProvider, useToaster };
18
+ //# sourceMappingURL=Toaster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toaster.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/toaster/Toaster.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIrC,aAAK,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AASxC,UAAU,KAAK;CAAG;AAClB,UAAU,KAAK;IACX,IAAI,EAAE,KAAK,EAAE,CAAC;CACjB;AAID,cAAM,eAAgB,SAAQ,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;gBACpC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO;IAQjD,OAAO,CAAC,QAAQ,CAAC,IAAI,CA6BnB;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAK5B;IAEF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAa/B;IAEK,MAAM;CAYhB;AAED,QAAA,MAAM,UAAU,iBAAmC,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,74 @@
1
+ import React, { createContext, useContext } from "react";
2
+ import { Notification } from "./Notification";
3
+ const ToasterContext = createContext(() => {
4
+ throw new Error("Toaster Provider missing in the tree");
5
+ });
6
+ const prefix = `${Date.now()}_`;
7
+ let counter = 0;
8
+ const DEFAULT_TIMEOUT = 5000;
9
+ class ToasterProvider extends React.Component {
10
+ constructor(props, context) {
11
+ super(props, context);
12
+ this._add = (text) => {
13
+ this._removeAllToasts();
14
+ const id = prefix + String(counter++);
15
+ const hide = false;
16
+ this.setState(prev => ({
17
+ ...prev,
18
+ list: [...prev.list, {
19
+ id,
20
+ text,
21
+ hide,
22
+ }],
23
+ }));
24
+ setTimeout(() => {
25
+ this.setState(prev => ({
26
+ ...prev,
27
+ list: prev.list.map(p => {
28
+ if (p.id !== id) {
29
+ return p;
30
+ }
31
+ return {
32
+ ...p,
33
+ hide: true,
34
+ };
35
+ }),
36
+ }));
37
+ }, DEFAULT_TIMEOUT);
38
+ };
39
+ this._handleRemove = (id) => {
40
+ this.setState(prev => ({
41
+ ...prev,
42
+ list: prev.list.filter(p => p.id !== id),
43
+ }));
44
+ };
45
+ this._removeAllToasts = () => {
46
+ this.setState(prev => ({
47
+ ...prev,
48
+ list: prev.list.map(p => {
49
+ if (p.hide) {
50
+ return p;
51
+ }
52
+ return {
53
+ ...p,
54
+ hide: true,
55
+ };
56
+ }),
57
+ }));
58
+ };
59
+ this.state = {
60
+ list: [],
61
+ };
62
+ }
63
+ render() {
64
+ const notifications = this.state.list.map((t) => {
65
+ return React.createElement(Notification, { onRemove: this._handleRemove, key: t.id, toast: t });
66
+ });
67
+ return (React.createElement(ToasterContext.Provider, { value: this._add },
68
+ notifications,
69
+ this.props.children));
70
+ }
71
+ }
72
+ const useToaster = () => useContext(ToasterContext);
73
+ export { ToasterProvider, useToaster };
74
+ //# sourceMappingURL=Toaster.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toaster.js","sourceRoot":"","sources":["../../../../src/components/ui/toaster/Toaster.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAIzD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,MAAM,cAAc,GAAG,aAAa,CAAY,GAAG,EAAE;IACjD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;AAChC,IAAI,OAAO,GAAG,CAAC,CAAC;AAOhB,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,MAAM,eAAgB,SAAQ,KAAK,CAAC,SAAuB;IACvD,YAAmB,KAAY,EAAE,OAAgB;QAC7C,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAOT,SAAI,GAAG,CAAC,IAAY,EAAE,EAAE;YACrC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAExB,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC;YAEnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACnB,GAAG,IAAI;gBACP,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE;wBACjB,EAAE;wBACF,IAAI;wBACJ,IAAI;qBACP,CAAC;aACL,CAAC,CAAC,CAAC;YAEJ,UAAU,CAAC,GAAG,EAAE;gBACZ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBACnB,GAAG,IAAI;oBACP,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;wBACpB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;4BACb,OAAO,CAAC,CAAC;yBACZ;wBACD,OAAO;4BACH,GAAG,CAAC;4BACJ,IAAI,EAAE,IAAI;yBACb,CAAC;oBACN,CAAC,CAAC;iBACL,CAAC,CAAC,CAAC;YACR,CAAC,EAAE,eAAe,CAAC,CAAC;QACxB,CAAC,CAAC;QAEe,kBAAa,GAAG,CAAC,EAAe,EAAE,EAAE;YACjD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACnB,GAAG,IAAI;gBACP,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;aAC3C,CAAC,CAAC,CAAC;QACR,CAAC,CAAC;QAEe,qBAAgB,GAAG,GAAG,EAAE;YACrC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACnB,GAAG,IAAI;gBACP,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;oBACpB,IAAI,CAAC,CAAC,IAAI,EAAE;wBACR,OAAO,CAAC,CAAC;qBACZ;oBACD,OAAO;wBACH,GAAG,CAAC;wBACJ,IAAI,EAAE,IAAI;qBACb,CAAC;gBACN,CAAC,CAAC;aACL,CAAC,CAAC,CAAC;QACR,CAAC,CAAC;QAxDE,IAAI,CAAC,KAAK,GAAG;YACT,IAAI,EAAE,EAAE;SACX,CAAC;IACN,CAAC;IAuDM,MAAM;QACT,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5C,OAAO,oBAAC,YAAY,IAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAI,CAAC;QAC/E,CAAC,CAAC,CAAC;QAEH,OAAO,CACH,oBAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,CAAC,IAAI;YACpC,aAAa;YACb,IAAI,CAAC,KAAK,CAAC,QAAQ,CACE,CAC7B,CAAC;IACN,CAAC;CACJ;AAED,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC"}
@@ -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,7 @@
1
+ interface Toast {
2
+ id: string;
3
+ text: string;
4
+ hide: boolean;
5
+ }
6
+ export type { Toast, };
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/toaster/types.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACjB;AAED,YAAY,EACR,KAAK,GACR,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/ui/toaster/types.ts"],"names":[],"mappings":""}
package/esm/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/esm/index.d.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";
@@ -16,4 +17,8 @@ export * from "./components/ui/action/Action.js";
16
17
  export * from "./components/ui/action/EqualActions.js";
17
18
  export * from "./components/ui/button/Button.js";
18
19
  export * from "./components/ui/directionPad/Pad.js";
20
+ export * from "./components/ui/modal/Modal.js";
21
+ export * from "./components/ui/modal/ModalButtons.js";
22
+ export * from "./components/ui/tabs/Selector.js";
23
+ export * from "./components/ui/toaster/Toaster.js";
19
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AAEvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AAEvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC"}
package/esm/index.js 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";
@@ -16,4 +17,8 @@ export * from "./components/ui/action/Action.js";
16
17
  export * from "./components/ui/action/EqualActions.js";
17
18
  export * from "./components/ui/button/Button.js";
18
19
  export * from "./components/ui/directionPad/Pad.js";
20
+ export * from "./components/ui/modal/Modal.js";
21
+ export * from "./components/ui/modal/ModalButtons.js";
22
+ export * from "./components/ui/tabs/Selector.js";
23
+ export * from "./components/ui/toaster/Toaster.js";
19
24
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AAEvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AAEvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC"}
@@ -0,0 +1,7 @@
1
+ interface ObjectValue {
2
+ value: string;
3
+ label: string;
4
+ }
5
+ declare type Value = string | ObjectValue;
6
+ export type { ObjectValue, Value, };
7
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/types/form.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACtD,aAAK,KAAK,GAAG,MAAM,GAAG,WAAW,CAAC;AAElC,YAAY,EACR,WAAW,EACX,KAAK,GACR,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/types/form.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from "./makeVariants";
2
+ export * from "./toObjectValue";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
@@ -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.7.0",
3
+ "version": "0.9.2",
4
4
  "author": "Jacek Nowacki",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -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": "^4.3.0",
52
- "jest": "^27.0.6",
51
+ "husky": "^7.0.4",
52
+ "jest": "^27.5.1",
53
53
  "must": "^0.13.4",
54
- "next": "^11.1.3",
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.2",
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.0",
74
+ "version": "3.4.1",
75
75
  "language": "typescript",
76
76
  "fixDefaultForCommonJS": true,
77
77
  "jsx": true
@@ -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,13 +1,27 @@
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
7
 
7
- const Header: React.FC = (props) => {
8
+ type Variant = "inset";
9
+
10
+ interface Props {
11
+ className?: string;
12
+ variant?: Variant | Variant[];
13
+ }
14
+
15
+ const Header: React.FC<Props> = (props) => {
16
+ const v = makeVariants(props.variant);
17
+
18
+ const cls = classnames(props.className, styles.item, headerStyles.header, {
19
+ [styles.inset]: v.includes("inset"),
20
+ });
21
+
8
22
  // @TODO way to use h1, h2, h3 instead of div
9
23
  return (
10
- <li className={classnames(styles.item, headerStyles.header)}>
24
+ <li className={cls}>
11
25
  <div>{props.children}</div>
12
26
  </li>
13
27
  );
@@ -4,7 +4,7 @@
4
4
  padding: 0;
5
5
  font-size: calc(34px / var(--ratio-font));
6
6
 
7
- &:not(:first-child) > * {
7
+ &:not(:first-child) {
8
8
  border-top: 0.37px solid var(--header-border);
9
9
  }
10
10
 
@@ -29,3 +29,18 @@
29
29
  min-height: calc(174px / var(--ratio-dimensions));
30
30
  align-items: center;
31
31
  }
32
+
33
+ .inset {
34
+ padding-left: calc(37px / var(--ratio-dimensions));
35
+ padding-right: calc(37px / var(--ratio-dimensions));
36
+ }
37
+
38
+ .icon {
39
+ width: 7px;
40
+ margin-right: 10px;
41
+ display: inline-block;
42
+ }
43
+
44
+ .selected {
45
+ color: var(--main-color);
46
+ }