react-miui 0.23.4 → 0.23.6

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 (158) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/components/form/Suggestions.js.map +1 -1
  3. package/dist/components/form/Toggle.js.map +1 -1
  4. package/dist/components/form/input/Input.js.map +1 -1
  5. package/dist/components/icons/Icon.js.map +1 -1
  6. package/dist/components/layout/header/Header.d.ts +2 -3
  7. package/dist/components/layout/header/Header.d.ts.map +1 -1
  8. package/dist/components/layout/header/Header.js +14 -2
  9. package/dist/components/layout/header/Header.js.map +1 -1
  10. package/dist/components/layout/header/HeaderIconAction.js.map +1 -1
  11. package/dist/components/layout/header/StickyHeader.js.map +1 -1
  12. package/dist/components/layout/list/Item.js.map +1 -1
  13. package/dist/components/layout/list/List.js.map +1 -1
  14. package/dist/components/native/index.d.ts +82 -0
  15. package/dist/components/native/index.d.ts.map +1 -0
  16. package/dist/components/native/index.js +7 -0
  17. package/dist/components/native/index.js.map +1 -0
  18. package/dist/components/ui/action/Action.d.ts +3 -1
  19. package/dist/components/ui/action/Action.d.ts.map +1 -1
  20. package/dist/components/ui/action/Action.js +9 -9
  21. package/dist/components/ui/action/Action.js.map +1 -1
  22. package/dist/components/ui/action/Action.stories.d.ts +8 -0
  23. package/dist/components/ui/action/Action.stories.d.ts.map +1 -0
  24. package/dist/components/ui/action/Action.stories.js +29 -0
  25. package/dist/components/ui/action/Action.stories.js.map +1 -0
  26. package/dist/components/ui/action/Action.styled.d.ts +242 -0
  27. package/dist/components/ui/action/Action.styled.d.ts.map +1 -0
  28. package/dist/components/ui/action/Action.styled.js +27 -0
  29. package/dist/components/ui/action/Action.styled.js.map +1 -0
  30. package/dist/components/ui/action/EqualActions.js.map +1 -1
  31. package/dist/components/ui/drawer/Drawer.js.map +1 -1
  32. package/dist/components/ui/keyValue/KeyValue.js.map +1 -1
  33. package/dist/components/ui/loader/CoveringLoader.js.map +1 -1
  34. package/dist/components/ui/loader/Loader.js.map +1 -1
  35. package/dist/components/ui/loader/Loading.js.map +1 -1
  36. package/dist/components/ui/modal/Modal.js.map +1 -1
  37. package/dist/components/ui/pop/OnButtonClick.js.map +1 -1
  38. package/dist/components/ui/pop/Pop.js.map +1 -1
  39. package/dist/components/ui/stats/Stats.js.map +1 -1
  40. package/dist/components/ui/toaster/Toaster.js.map +1 -1
  41. package/dist/components/utils/HandleEsc.js.map +1 -1
  42. package/dist/components/utils/If.js.map +1 -1
  43. package/dist/utils/makeVariants.js.map +1 -1
  44. package/dist/utils/useKeyPress.js.map +1 -1
  45. package/docs/assets/search.js +1 -1
  46. package/docs/classes/Drawer.html +14 -14
  47. package/docs/classes/Pop.html +14 -14
  48. package/docs/classes/ToasterProvider.html +10 -10
  49. package/docs/enums/ICON.html +14 -14
  50. package/docs/functions/Action.html +11 -5
  51. package/docs/functions/Button.html +8 -5
  52. package/docs/functions/Card.html +8 -5
  53. package/docs/functions/Checkbox.html +8 -5
  54. package/docs/functions/Choice.html +11 -8
  55. package/docs/functions/CoveringLoader.html +8 -5
  56. package/docs/functions/DirectionPad.html +8 -5
  57. package/docs/functions/EqualActions.html +8 -5
  58. package/docs/functions/FullLoader.html +8 -5
  59. package/docs/functions/HandleEsc.html +8 -5
  60. package/docs/functions/Header.html +10 -7
  61. package/docs/functions/HeaderIconAction.html +8 -5
  62. package/docs/functions/Icon-1.html +8 -5
  63. package/docs/functions/If.html +8 -5
  64. package/docs/functions/Input.html +11 -8
  65. package/docs/functions/KeyValue.html +8 -5
  66. package/docs/functions/Label.html +8 -5
  67. package/docs/functions/List-1.html +8 -5
  68. package/docs/functions/Loader.html +8 -5
  69. package/docs/functions/Loading.html +8 -5
  70. package/docs/functions/Message.html +8 -5
  71. package/docs/functions/Modal-1.html +8 -5
  72. package/docs/functions/ModalButtons.html +8 -5
  73. package/docs/functions/PopLoader.html +8 -5
  74. package/docs/functions/PopOption.html +8 -5
  75. package/docs/functions/SearchContainer.html +8 -5
  76. package/docs/functions/Section.html +8 -5
  77. package/docs/functions/Select.html +8 -5
  78. package/docs/functions/Selector.html +9 -6
  79. package/docs/functions/Spacer.html +8 -5
  80. package/docs/functions/Stats.html +8 -5
  81. package/docs/functions/StickyHeader-1.html +8 -5
  82. package/docs/functions/StickyHeader.Content.html +5 -5
  83. package/docs/functions/Table.html +8 -5
  84. package/docs/functions/TextArea.html +8 -5
  85. package/docs/functions/Toggle.html +8 -5
  86. package/docs/functions/getCssText.html +8 -5
  87. package/docs/functions/styled.html +8 -5
  88. package/docs/functions/useToaster.html +9 -6
  89. package/docs/index.html +8 -5
  90. package/docs/interfaces/ActionProps.html +41 -18
  91. package/docs/interfaces/ChoiceProps.html +125 -0
  92. package/docs/interfaces/InputCustomProps.html +120 -0
  93. package/docs/modules/List.html +7 -7
  94. package/docs/modules/Modal.html +6 -6
  95. package/docs/modules/StickyHeader.html +6 -6
  96. package/docs/modules.html +11 -5
  97. package/docs/pages/tutorials/Test.html +8 -5
  98. package/docs/types/InputProps.html +104 -0
  99. package/docs/types/ThemeCSS.html +9 -6
  100. package/docs/variables/List.Header.html +5 -5
  101. package/docs/variables/List.Item.html +5 -5
  102. package/docs/variables/Modal.RemovePadding.html +5 -5
  103. package/docs/variables/cssReset.html +9 -6
  104. package/docs/variables/miuiScrollbars.html +9 -6
  105. package/esm/components/form/Suggestions.js.map +1 -1
  106. package/esm/components/form/Toggle.js.map +1 -1
  107. package/esm/components/form/input/Input.js.map +1 -1
  108. package/esm/components/icons/Icon.js.map +1 -1
  109. package/esm/components/layout/header/Header.d.ts +2 -3
  110. package/esm/components/layout/header/Header.d.ts.map +1 -1
  111. package/esm/components/layout/header/Header.js +3 -2
  112. package/esm/components/layout/header/Header.js.map +1 -1
  113. package/esm/components/layout/header/HeaderIconAction.js.map +1 -1
  114. package/esm/components/layout/header/StickyHeader.js.map +1 -1
  115. package/esm/components/layout/list/Item.js.map +1 -1
  116. package/esm/components/layout/list/List.js.map +1 -1
  117. package/esm/components/native/index.d.ts +82 -0
  118. package/esm/components/native/index.d.ts.map +1 -0
  119. package/esm/components/native/index.js +4 -0
  120. package/esm/components/native/index.js.map +1 -0
  121. package/esm/components/ui/action/Action.d.ts +3 -1
  122. package/esm/components/ui/action/Action.d.ts.map +1 -1
  123. package/esm/components/ui/action/Action.js +9 -9
  124. package/esm/components/ui/action/Action.js.map +1 -1
  125. package/esm/components/ui/action/Action.stories.d.ts +8 -0
  126. package/esm/components/ui/action/Action.stories.d.ts.map +1 -0
  127. package/esm/components/ui/action/Action.stories.js +23 -0
  128. package/esm/components/ui/action/Action.stories.js.map +1 -0
  129. package/esm/components/ui/action/Action.styled.d.ts +242 -0
  130. package/esm/components/ui/action/Action.styled.d.ts.map +1 -0
  131. package/esm/components/ui/action/Action.styled.js +29 -0
  132. package/esm/components/ui/action/Action.styled.js.map +1 -0
  133. package/esm/components/ui/action/EqualActions.js.map +1 -1
  134. package/esm/components/ui/drawer/Drawer.js.map +1 -1
  135. package/esm/components/ui/keyValue/KeyValue.js.map +1 -1
  136. package/esm/components/ui/loader/CoveringLoader.js.map +1 -1
  137. package/esm/components/ui/loader/Loader.js.map +1 -1
  138. package/esm/components/ui/loader/Loading.js.map +1 -1
  139. package/esm/components/ui/modal/Modal.js.map +1 -1
  140. package/esm/components/ui/pop/OnButtonClick.js.map +1 -1
  141. package/esm/components/ui/pop/Pop.js.map +1 -1
  142. package/esm/components/ui/stats/Stats.js.map +1 -1
  143. package/esm/components/ui/toaster/Toaster.js.map +1 -1
  144. package/esm/components/utils/HandleEsc.js.map +1 -1
  145. package/esm/components/utils/If.js.map +1 -1
  146. package/esm/utils/makeVariants.js.map +1 -1
  147. package/esm/utils/useKeyPress.js.map +1 -1
  148. package/package.json +26 -26
  149. package/pnpm-lock.yaml +3480 -3715
  150. package/src/components/layout/header/Header.tsx +13 -7
  151. package/src/components/native/index.ts +5 -0
  152. package/src/components/ui/action/Action.stories.tsx +35 -0
  153. package/src/components/ui/action/Action.styled.ts +40 -0
  154. package/src/components/ui/action/Action.tsx +45 -11
  155. package/src/demo/componentsMap.ts +4 -4
  156. package/dist/components/ui/action/Action.module.scss +0 -26
  157. package/esm/components/ui/action/Action.module.scss +0 -26
  158. package/src/components/ui/action/Action.module.scss +0 -26
@@ -5,6 +5,7 @@ import classnames from "classnames";
5
5
 
6
6
  import { Action } from "../../ui/action/Action";
7
7
  import { EqualActions } from "../../ui/action/EqualActions";
8
+ import { Div } from "../../native";
8
9
 
9
10
  import styles from "./Header.module.scss";
10
11
 
@@ -13,17 +14,22 @@ interface Props {
13
14
  variant?: "toolbar" | "colored";
14
15
  /**
15
16
  * This indicates just how the borders are drawn and how content is aligned, not the actual position on the screen.
16
- * To set up position on the screen you need to properly style parent element.
17
+ * To set up position on the screen, you need to properly style the parent element.
17
18
  */
18
19
  position?: "top" | "left" | "right" | "bottom"; // @TODO disallow left/right if not inside StickyHeader?
19
- className?: string;
20
20
  before?: ReactNode;
21
21
  after?: ReactNode;
22
- children: React.ReactNode;
23
22
  }
24
23
 
25
- const Header: React.FC<Props> = (props) => {
26
- const { center, children, variant, position = "top" } = props;
24
+ const Header: React.FC<React.ComponentProps<typeof Div> & Props> = (props) => {
25
+ const {
26
+ center,
27
+ variant,
28
+ position = "top",
29
+ className: _className, before: _before, after: _after,
30
+ children,
31
+ ...rest
32
+ } = props;
27
33
 
28
34
  const chld = React.Children.toArray(props.children);
29
35
  const justActions = chld.every(c => {
@@ -53,13 +59,13 @@ const Header: React.FC<Props> = (props) => {
53
59
  }
54
60
 
55
61
  return (
56
- <div className={cls}>
62
+ <Div className={cls} {...rest}>
57
63
  {before}
58
64
  <div className={styles.contents}>
59
65
  {contents}
60
66
  </div>
61
67
  {after}
62
- </div>
68
+ </Div>
63
69
  );
64
70
  };
65
71
 
@@ -0,0 +1,5 @@
1
+ import { styled } from "../../theme";
2
+
3
+ const Div = styled("div", {});
4
+
5
+ export { Div };
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+
3
+ import type { StoryObj, Meta } from "@storybook/react";
4
+
5
+ import { Action } from "./Action";
6
+
7
+ const meta: Meta = {
8
+ title: "Components/UI/Action",
9
+ component: Action,
10
+ tags: ["autodocs", "ui"],
11
+ };
12
+
13
+ type Story = StoryObj<typeof Action>;
14
+
15
+ const Primary: Story = {
16
+ args: {
17
+ label: "Section name",
18
+ icon: "checkmark",
19
+ },
20
+ render: (args) => {
21
+ const props = { ...args };
22
+ if (!args.label) {
23
+ delete props.label;
24
+ }
25
+ return (
26
+ <Action {...props} />
27
+ );
28
+ },
29
+ };
30
+
31
+ export {
32
+ Primary,
33
+ };
34
+
35
+ export default meta;
@@ -0,0 +1,40 @@
1
+ import type { ThemeCSS } from "../../../theme";
2
+
3
+ import { borderPxToRem, dimensionsPxToRem, styled } from "../../../theme";
4
+
5
+ const StyledAction = styled("div", {
6
+ height: dimensionsPxToRem(102),
7
+ width: dimensionsPxToRem(102),
8
+ borderRadius: dimensionsPxToRem(102),
9
+ border: `${borderPxToRem(1)} solid $buttonBorder`,
10
+ background: "white",
11
+ padding: 0,
12
+ display: "flex",
13
+ alignItems: "center",
14
+ justifyContent: "center",
15
+ });
16
+
17
+ const sharedCss: ThemeCSS = {
18
+ display: "inline-flex",
19
+ flexDirection: "column",
20
+ alignItems: "center",
21
+ gap: dimensionsPxToRem(18),
22
+
23
+ };
24
+
25
+ const Anchor = styled("a", {
26
+ ...sharedCss,
27
+ });
28
+
29
+ const Button = styled("button", {
30
+ ...sharedCss,
31
+ border: "none",
32
+ padding: 0,
33
+ background: "none",
34
+ });
35
+
36
+ export {
37
+ StyledAction,
38
+ Anchor,
39
+ Button,
40
+ };
@@ -1,13 +1,12 @@
1
1
  import React from "react";
2
2
  import type { ReactNode } from "react";
3
3
 
4
- import classnames from "classnames";
5
-
6
4
  import type { ICON } from "../../icons/Icon";
5
+ import type { ThemeCSS } from "../../../theme";
7
6
 
8
7
  import { Icon } from "../../icons/Icon";
9
8
 
10
- import styles from "./Action.module.scss";
9
+ import { Anchor, Button, StyledAction } from "./Action.styled";
11
10
 
12
11
  interface LinkProps { // @TODO extract? - same on list item
13
12
  href: string;
@@ -15,28 +14,59 @@ interface LinkProps { // @TODO extract? - same on list item
15
14
  }
16
15
 
17
16
  interface Props {
17
+ /**
18
+ * If action should be a native link provide target URL as `href`
19
+ */
18
20
  href?: string;
21
+ /**
22
+ * If action should be a routed link provide target URL as `to` and `Link` component
23
+ */
19
24
  to?: string;
25
+ /**
26
+ * If action should be a routed link provide target URL as `to` and `Link` component
27
+ */
28
+ Link?: React.ComponentClass<LinkProps> | React.FC<LinkProps>;
29
+ /**
30
+ * Standard onClick handler (with no event)
31
+ */
20
32
  onClick?: () => void;
33
+ /**
34
+ * Icon to be displayed
35
+ */
21
36
  icon?: ICON | Exclude<ReactNode, string>;
22
- Link?: React.ComponentClass<LinkProps> | React.FC<LinkProps>;
37
+ /**
38
+ * Label to be displayed below the icon
39
+ */
23
40
  label?: ReactNode;
41
+ /**
42
+ * Custom class name
43
+ */
24
44
  className?: string;
45
+ /**
46
+ * Custom CSS
47
+ */
48
+ css?: ThemeCSS;
25
49
  }
26
50
 
51
+ /**
52
+ * Action is a round-shaped button or a link, usually used at headers/toolbars.
53
+ *
54
+ * Its label is displayed below the circular shape.
55
+ */
27
56
  const Action: React.FC<Props> = (props) => {
28
- const { icon, label, href, to, Link, ...restProps } = props;
57
+ const { icon, label, href, to, Link, css, ...restProps } = props;
58
+ const maybeCss = css ? { css } : {};
29
59
 
30
60
  let iconElem: ReactNode = icon;
31
61
  if (typeof icon === "string") {
32
62
  iconElem = <Icon name={icon as ICON} />;
33
63
  }
34
64
 
35
- const labelElem = label ? <div className={styles.label}>{label}</div> : null;
65
+ const labelElem = label ? <div>{label}</div> : null;
36
66
 
37
67
  const content = (
38
68
  <>
39
- <div className={styles.action}>{iconElem}</div>
69
+ <StyledAction>{iconElem}</StyledAction>
40
70
  {labelElem}
41
71
  </>
42
72
  );
@@ -46,17 +76,21 @@ const Action: React.FC<Props> = (props) => {
46
76
  throw new TypeError("`to` prop given without `Link` component");
47
77
  }
48
78
 
49
- return <Link href={to} {...restProps}><a className={classnames(styles.a, props.className)}>{content}</a></Link>;
79
+ return (
80
+ <Link href={to} {...restProps}>
81
+ <Anchor className={props.className} {...maybeCss}>{content}</Anchor>
82
+ </Link>
83
+ );
50
84
  }
51
85
 
52
86
  if (href) {
53
- return <a href={href} className={classnames(styles.a, props.className)} {...restProps}>{content}</a>;
87
+ return <Anchor href={href} className={props.className} {...restProps} {...maybeCss}>{content}</Anchor>;
54
88
  }
55
89
 
56
90
  return (
57
- <button onClick={props.onClick} className={classnames(styles.button, props.className)}>
91
+ <Button onClick={props.onClick} className={props.className} {...maybeCss}>
58
92
  {content}
59
- </button>
93
+ </Button>
60
94
  );
61
95
  };
62
96
 
@@ -7,13 +7,13 @@ import {
7
7
  HeaderDemo,
8
8
  HeaderWithButtonsDemo,
9
9
  HeaderWithButtonsOnSideDemo, ToolbarVariantDemo,
10
- } from "./components/layout/header/Header.js";
10
+ } from "./components/layout/header/Header";
11
11
  import {
12
12
  StickyColoredBg,
13
13
  StickyHeaderBottomDemo,
14
14
  StickyHeaderDemo, StickyHeaderLeftCenterDemo, StickyHeaderLeftDemo, StickyHeaderRightDemo,
15
15
  StickyHeaderTopBottomDemo,
16
- } from "./components/layout/header/StickyHeader.js";
16
+ } from "./components/layout/header/StickyHeader";
17
17
  import { DirectionPadDemo } from "./components/ui/directionPad/Pad";
18
18
  import { IconsDemo } from "./components/ui/icons/Icons";
19
19
  import {
@@ -22,7 +22,7 @@ import {
22
22
  ActionsDemo,
23
23
  ActionsOnBottom,
24
24
  ActionsOnLeft,
25
- } from "./components/ui/action/Action.js";
25
+ } from "./components/ui/action/Action";
26
26
  import { ToggleDemo } from "./components/form/Toggle";
27
27
  import { CardDemo } from "./components/layout/card/Card";
28
28
  import { FormDemo } from "./components/form/Form";
@@ -136,7 +136,7 @@ const componentsMap: TheMap = {
136
136
  },
137
137
  },
138
138
  Action: {
139
- name: "Action",
139
+ name: "Action", // TODO move all action demos to storybook
140
140
  Component: ActionDemo,
141
141
  children: {
142
142
  ActionOnBottom: {
@@ -1,26 +0,0 @@
1
- .action {
2
- height: calc(102px / var(--ratio-dimensions));
3
- width: calc(102px / var(--ratio-dimensions));
4
- border-radius: 100px;
5
- border: calc(1px / var(--ratio-border)) solid var(--button-border);
6
- background: white;
7
- padding: 0;
8
- display: flex;
9
- align-items: center;
10
- justify-content: center;
11
- }
12
-
13
- .a {
14
- display: inline-block;
15
- vertical-align: middle;
16
- }
17
-
18
- .button {
19
- border: none;
20
- padding: 0;
21
- background: none;
22
- display: inline-flex;
23
- flex-direction: column;
24
- align-items: center;
25
- gap: calc(18px / var(--ratio-dimensions));
26
- }
@@ -1,26 +0,0 @@
1
- .action {
2
- height: calc(102px / var(--ratio-dimensions));
3
- width: calc(102px / var(--ratio-dimensions));
4
- border-radius: 100px;
5
- border: calc(1px / var(--ratio-border)) solid var(--button-border);
6
- background: white;
7
- padding: 0;
8
- display: flex;
9
- align-items: center;
10
- justify-content: center;
11
- }
12
-
13
- .a {
14
- display: inline-block;
15
- vertical-align: middle;
16
- }
17
-
18
- .button {
19
- border: none;
20
- padding: 0;
21
- background: none;
22
- display: inline-flex;
23
- flex-direction: column;
24
- align-items: center;
25
- gap: calc(18px / var(--ratio-dimensions));
26
- }
@@ -1,26 +0,0 @@
1
- .action {
2
- height: calc(102px / var(--ratio-dimensions));
3
- width: calc(102px / var(--ratio-dimensions));
4
- border-radius: 100px;
5
- border: calc(1px / var(--ratio-border)) solid var(--button-border);
6
- background: white;
7
- padding: 0;
8
- display: flex;
9
- align-items: center;
10
- justify-content: center;
11
- }
12
-
13
- .a {
14
- display: inline-block;
15
- vertical-align: middle;
16
- }
17
-
18
- .button {
19
- border: none;
20
- padding: 0;
21
- background: none;
22
- display: inline-flex;
23
- flex-direction: column;
24
- align-items: center;
25
- gap: calc(18px / var(--ratio-dimensions));
26
- }