react-miui 0.23.7-beta.2 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/dist/components/form/Select.styled.d.ts +2 -0
- package/dist/components/form/Select.styled.d.ts.map +1 -1
- package/dist/components/form/input/Input.styled.d.ts +8 -0
- package/dist/components/form/input/Input.styled.d.ts.map +1 -1
- package/dist/components/form/textarea/TextArea.styled.d.ts +2 -0
- package/dist/components/form/textarea/TextArea.styled.d.ts.map +1 -1
- package/dist/components/layout/header/Header.styled.d.ts +8 -0
- package/dist/components/layout/header/Header.styled.d.ts.map +1 -1
- package/dist/components/layout/header/HeaderIconAction.styled.d.ts +6 -0
- package/dist/components/layout/header/HeaderIconAction.styled.d.ts.map +1 -1
- package/dist/components/layout/header/StickyHeader.d.ts +6 -6
- package/dist/components/layout/header/StickyHeader.d.ts.map +1 -1
- package/dist/components/layout/header/StickyHeader.js +35 -14
- package/dist/components/layout/header/StickyHeader.js.map +1 -1
- package/dist/components/layout/header/StickyHeader.stories.d.ts +2 -1
- package/dist/components/layout/header/StickyHeader.stories.d.ts.map +1 -1
- package/dist/components/layout/header/StickyHeader.stories.js +62 -4
- package/dist/components/layout/header/StickyHeader.stories.js.map +1 -1
- package/dist/components/layout/header/StickyHeader.styled.d.ts +4 -0
- package/dist/components/layout/header/StickyHeader.styled.d.ts.map +1 -1
- package/dist/components/layout/list/Header.d.ts +4 -0
- package/dist/components/layout/list/Header.d.ts.map +1 -1
- package/dist/components/layout/list/Item.d.ts +2 -0
- package/dist/components/layout/list/Item.d.ts.map +1 -1
- package/dist/components/layout/list/Label.d.ts +2 -0
- package/dist/components/layout/list/Label.d.ts.map +1 -1
- package/dist/components/layout/list/List.d.ts +2 -0
- package/dist/components/layout/list/List.d.ts.map +1 -1
- package/dist/components/layout/list/Value.d.ts +2 -0
- package/dist/components/layout/list/Value.d.ts.map +1 -1
- package/dist/components/layout/section/Section.d.ts +2 -0
- package/dist/components/layout/section/Section.d.ts.map +1 -1
- package/dist/components/layout/section/SectionContainer.d.ts +2 -0
- package/dist/components/layout/section/SectionContainer.d.ts.map +1 -1
- package/dist/components/native/index.d.ts +2 -0
- package/dist/components/native/index.d.ts.map +1 -1
- package/dist/components/ui/action/Action.styled.d.ts +6 -0
- package/dist/components/ui/action/Action.styled.d.ts.map +1 -1
- package/dist/components/ui/button/Button.styled.d.ts +2 -0
- package/dist/components/ui/button/Button.styled.d.ts.map +1 -1
- package/dist/components/ui/message/Message.d.ts +2 -0
- package/dist/components/ui/message/Message.d.ts.map +1 -1
- package/dist/components/ui/message/Message.styled.d.ts +2 -0
- package/dist/components/ui/message/Message.styled.d.ts.map +1 -1
- package/dist/components/ui/modal/Modal.styled.d.ts +8 -0
- package/dist/components/ui/modal/Modal.styled.d.ts.map +1 -1
- package/dist/components/ui/modal/ModalButtons.styled.d.ts +4 -0
- package/dist/components/ui/modal/ModalButtons.styled.d.ts.map +1 -1
- package/dist/components/ui/pop/Pop.d.ts.map +1 -1
- package/dist/components/ui/pop/Pop.js +3 -8
- package/dist/components/ui/pop/Pop.js.map +1 -1
- package/dist/components/ui/pop/Pop.stories.d.ts +8 -0
- package/dist/components/ui/pop/Pop.stories.d.ts.map +1 -0
- package/dist/components/ui/pop/Pop.stories.js +91 -0
- package/dist/components/ui/pop/Pop.stories.js.map +1 -0
- package/dist/components/ui/pop/Pop.styled.d.ts +494 -0
- package/dist/components/ui/pop/Pop.styled.d.ts.map +1 -0
- package/dist/components/ui/pop/Pop.styled.js +61 -0
- package/dist/components/ui/pop/Pop.styled.js.map +1 -0
- package/dist/components/ui/pop/PopOption.d.ts.map +1 -1
- package/dist/components/ui/pop/PopOption.js +5 -6
- package/dist/components/ui/pop/PopOption.js.map +1 -1
- package/dist/components/ui/progress/Progress.d.ts +13 -0
- package/dist/components/ui/progress/Progress.d.ts.map +1 -0
- package/dist/components/ui/progress/Progress.js +43 -0
- package/dist/components/ui/progress/Progress.js.map +1 -0
- package/dist/components/ui/progress/Progress.stories.d.ts +9 -0
- package/dist/components/ui/progress/Progress.stories.d.ts.map +1 -0
- package/dist/components/ui/progress/Progress.stories.js +36 -0
- package/dist/components/ui/progress/Progress.stories.js.map +1 -0
- package/dist/components/ui/progress/Progress.styled.d.ts +252 -0
- package/dist/components/ui/progress/Progress.styled.d.ts.map +1 -0
- package/dist/components/ui/progress/Progress.styled.js +49 -0
- package/dist/components/ui/progress/Progress.styled.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/theme.d.ts +20 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +3 -1
- package/dist/theme.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Drawer.html +15 -16
- package/docs/classes/Pop.html +19 -16
- package/docs/classes/ToasterProvider.html +11 -12
- package/docs/enums/ICON.html +15 -16
- package/docs/functions/Action.html +11 -8
- package/docs/functions/Button.html +11 -8
- package/docs/functions/Card.html +11 -8
- package/docs/functions/Checkbox.html +11 -8
- package/docs/functions/Choice.html +12 -9
- package/docs/functions/CoveringLoader.html +11 -8
- package/docs/functions/DirectionPad.html +11 -8
- package/docs/functions/EqualActions.html +11 -8
- package/docs/functions/FullLoader.html +11 -8
- package/docs/functions/HandleEsc.html +11 -8
- package/docs/functions/Header.html +11 -8
- package/docs/functions/HeaderIconAction.html +11 -8
- package/docs/functions/Icon-1.html +11 -8
- package/docs/functions/If.html +11 -8
- package/docs/functions/Input.html +12 -9
- package/docs/functions/KeyValue.html +11 -8
- package/docs/functions/Label.html +11 -8
- package/docs/functions/List-1.html +11 -8
- package/docs/functions/Loader.html +11 -8
- package/docs/functions/Loading.html +11 -8
- package/docs/functions/Message.html +11 -8
- package/docs/functions/Modal-1.html +11 -8
- package/docs/functions/ModalButtons.html +11 -8
- package/docs/functions/PopLoader.html +11 -8
- package/docs/functions/PopOption.html +11 -8
- package/docs/functions/{StickyHeader-1.html → Progress.html} +17 -11
- package/docs/functions/SearchContainer.html +11 -8
- package/docs/functions/Section.html +11 -8
- package/docs/functions/Select.html +11 -8
- package/docs/functions/Selector.html +12 -9
- package/docs/functions/Spacer.html +11 -8
- package/docs/functions/Stats.html +11 -8
- package/docs/functions/StickyHeader.html +114 -0
- package/docs/functions/Table.html +11 -8
- package/docs/functions/TextArea.html +11 -8
- package/docs/functions/Toggle.html +11 -8
- package/docs/functions/getCssText.html +11 -8
- package/docs/functions/styled.html +11 -8
- package/docs/functions/useToaster.html +12 -9
- package/docs/index.html +11 -8
- package/docs/interfaces/ActionProps.html +14 -15
- package/docs/interfaces/ChoiceProps.html +12 -13
- package/docs/interfaces/IconProps.html +8 -9
- package/docs/interfaces/InputCustomProps.html +11 -12
- package/docs/interfaces/StickyHeaderProps.html +99 -0
- package/docs/modules/List.html +8 -9
- package/docs/modules/Modal.html +7 -8
- package/docs/modules.html +16 -10
- package/docs/pages/tutorials/Test.html +11 -8
- package/docs/types/InputProps.html +12 -9
- package/docs/types/ThemeCSS.html +12 -9
- package/docs/variables/BackgroundClassName.html +103 -0
- package/docs/variables/List.Header.html +6 -7
- package/docs/variables/List.Item.html +6 -7
- package/docs/variables/Modal.RemovePadding.html +6 -7
- package/docs/variables/ValueClassName.html +103 -0
- package/docs/variables/cssReset.html +12 -9
- package/docs/variables/miuiScrollbars.html +12 -9
- package/esm/components/form/Select.styled.d.ts +2 -0
- package/esm/components/form/Select.styled.d.ts.map +1 -1
- package/esm/components/form/input/Input.styled.d.ts +8 -0
- package/esm/components/form/input/Input.styled.d.ts.map +1 -1
- package/esm/components/form/textarea/TextArea.styled.d.ts +2 -0
- package/esm/components/form/textarea/TextArea.styled.d.ts.map +1 -1
- package/esm/components/layout/header/Header.styled.d.ts +8 -0
- package/esm/components/layout/header/Header.styled.d.ts.map +1 -1
- package/esm/components/layout/header/HeaderIconAction.styled.d.ts +6 -0
- package/esm/components/layout/header/HeaderIconAction.styled.d.ts.map +1 -1
- package/esm/components/layout/header/StickyHeader.d.ts +6 -6
- package/esm/components/layout/header/StickyHeader.d.ts.map +1 -1
- package/esm/components/layout/header/StickyHeader.js +12 -11
- package/esm/components/layout/header/StickyHeader.js.map +1 -1
- package/esm/components/layout/header/StickyHeader.stories.d.ts +2 -1
- package/esm/components/layout/header/StickyHeader.stories.d.ts.map +1 -1
- package/esm/components/layout/header/StickyHeader.stories.js +39 -2
- package/esm/components/layout/header/StickyHeader.stories.js.map +1 -1
- package/esm/components/layout/header/StickyHeader.styled.d.ts +4 -0
- package/esm/components/layout/header/StickyHeader.styled.d.ts.map +1 -1
- package/esm/components/layout/list/Header.d.ts +4 -0
- package/esm/components/layout/list/Header.d.ts.map +1 -1
- package/esm/components/layout/list/Item.d.ts +2 -0
- package/esm/components/layout/list/Item.d.ts.map +1 -1
- package/esm/components/layout/list/Label.d.ts +2 -0
- package/esm/components/layout/list/Label.d.ts.map +1 -1
- package/esm/components/layout/list/List.d.ts +2 -0
- package/esm/components/layout/list/List.d.ts.map +1 -1
- package/esm/components/layout/list/Value.d.ts +2 -0
- package/esm/components/layout/list/Value.d.ts.map +1 -1
- package/esm/components/layout/section/Section.d.ts +2 -0
- package/esm/components/layout/section/Section.d.ts.map +1 -1
- package/esm/components/layout/section/SectionContainer.d.ts +2 -0
- package/esm/components/layout/section/SectionContainer.d.ts.map +1 -1
- package/esm/components/native/index.d.ts +2 -0
- package/esm/components/native/index.d.ts.map +1 -1
- package/esm/components/ui/action/Action.styled.d.ts +6 -0
- package/esm/components/ui/action/Action.styled.d.ts.map +1 -1
- package/esm/components/ui/button/Button.styled.d.ts +2 -0
- package/esm/components/ui/button/Button.styled.d.ts.map +1 -1
- package/esm/components/ui/message/Message.d.ts +2 -0
- package/esm/components/ui/message/Message.d.ts.map +1 -1
- package/esm/components/ui/message/Message.styled.d.ts +2 -0
- package/esm/components/ui/message/Message.styled.d.ts.map +1 -1
- package/esm/components/ui/modal/Modal.styled.d.ts +8 -0
- package/esm/components/ui/modal/Modal.styled.d.ts.map +1 -1
- package/esm/components/ui/modal/ModalButtons.styled.d.ts +4 -0
- package/esm/components/ui/modal/ModalButtons.styled.d.ts.map +1 -1
- package/esm/components/ui/pop/Pop.d.ts.map +1 -1
- package/esm/components/ui/pop/Pop.js +3 -5
- package/esm/components/ui/pop/Pop.js.map +1 -1
- package/esm/components/ui/pop/Pop.stories.d.ts +8 -0
- package/esm/components/ui/pop/Pop.stories.d.ts.map +1 -0
- package/esm/components/ui/pop/Pop.stories.js +65 -0
- package/esm/components/ui/pop/Pop.stories.js.map +1 -0
- package/esm/components/ui/pop/Pop.styled.d.ts +494 -0
- package/esm/components/ui/pop/Pop.styled.d.ts.map +1 -0
- package/esm/components/ui/pop/Pop.styled.js +53 -0
- package/esm/components/ui/pop/Pop.styled.js.map +1 -0
- package/esm/components/ui/pop/PopOption.d.ts.map +1 -1
- package/esm/components/ui/pop/PopOption.js +5 -6
- package/esm/components/ui/pop/PopOption.js.map +1 -1
- package/esm/components/ui/progress/Progress.d.ts +13 -0
- package/esm/components/ui/progress/Progress.d.ts.map +1 -0
- package/esm/components/ui/progress/Progress.js +24 -0
- package/esm/components/ui/progress/Progress.js.map +1 -0
- package/esm/components/ui/progress/Progress.stories.d.ts +9 -0
- package/esm/components/ui/progress/Progress.stories.d.ts.map +1 -0
- package/esm/components/ui/progress/Progress.stories.js +29 -0
- package/esm/components/ui/progress/Progress.stories.js.map +1 -0
- package/esm/components/ui/progress/Progress.styled.d.ts +252 -0
- package/esm/components/ui/progress/Progress.styled.d.ts.map +1 -0
- package/esm/components/ui/progress/Progress.styled.js +44 -0
- package/esm/components/ui/progress/Progress.styled.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/theme.d.ts +20 -0
- package/esm/theme.d.ts.map +1 -1
- package/esm/theme.js +3 -1
- package/esm/theme.js.map +1 -1
- package/package.json +11 -9
- package/pnpm-lock.yaml +2121 -2435
- package/src/components/layout/header/StickyHeader.stories.tsx +47 -1
- package/src/components/layout/header/StickyHeader.tsx +33 -22
- package/src/components/ui/pop/Pop.stories.tsx +102 -0
- package/src/components/ui/pop/Pop.styled.ts +68 -0
- package/src/components/ui/pop/Pop.tsx +12 -10
- package/src/components/ui/pop/PopOption.tsx +6 -8
- package/src/components/ui/progress/Progress.stories.tsx +46 -0
- package/src/components/ui/progress/Progress.styled.ts +56 -0
- package/src/components/ui/progress/Progress.tsx +68 -0
- package/src/demo/componentsMap.ts +0 -5
- package/src/index.ts +1 -0
- package/src/theme.ts +3 -1
- package/dist/components/ui/pop/Pop.module.scss +0 -60
- package/docs/functions/StickyHeader.Content.html +0 -61
- package/docs/modules/StickyHeader.html +0 -58
- package/esm/components/ui/pop/Pop.module.scss +0 -60
- package/src/components/ui/pop/Pop.module.scss +0 -60
- package/src/demo/components/ui/pop/Pop.tsx +0 -77
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
import { useForceUpdate } from "@ezez/hooks";
|
|
2
4
|
|
|
3
5
|
import type { StoryObj, Meta } from "@storybook/react";
|
|
4
6
|
|
|
@@ -9,6 +11,21 @@ const meta: Meta = {
|
|
|
9
11
|
title: "Components/Layout/Header/StickyHeader",
|
|
10
12
|
component: StickyHeader,
|
|
11
13
|
tags: ["autodocs", "layout"],
|
|
14
|
+
argTypes: {
|
|
15
|
+
children: {
|
|
16
|
+
control: {
|
|
17
|
+
disable: true,
|
|
18
|
+
},
|
|
19
|
+
description: "Usual children",
|
|
20
|
+
},
|
|
21
|
+
position: {
|
|
22
|
+
control: {
|
|
23
|
+
type: "select",
|
|
24
|
+
},
|
|
25
|
+
description: "Position of the header",
|
|
26
|
+
options: ["top", "left", "right", "bottom"],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
12
29
|
};
|
|
13
30
|
|
|
14
31
|
type Story = StoryObj<typeof StickyHeader>;
|
|
@@ -34,8 +51,37 @@ const Primary: Story = {
|
|
|
34
51
|
},
|
|
35
52
|
};
|
|
36
53
|
|
|
54
|
+
const RefsDemo: Story = {
|
|
55
|
+
render: (args) => {
|
|
56
|
+
const ref = React.useRef<HTMLDivElement>(null);
|
|
57
|
+
const refContent = React.useRef<HTMLDivElement>(null);
|
|
58
|
+
const handleForceUpdate = useForceUpdate();
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
handleForceUpdate();
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
console.info("RefsDemo", {
|
|
65
|
+
ref: ref.current, refContent: refContent.current,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
<StickyHeader {...args} ref={ref}>
|
|
71
|
+
<Header>x</Header>
|
|
72
|
+
<StickyHeader.Content ref={refContent}>
|
|
73
|
+
{`Ref: ${ref.current ? `set ${ref.current.nodeName}` : "not set"}`}<br />
|
|
74
|
+
{`RefContent: ${refContent.current ? `set ${refContent.current.nodeName}` : "not set"}`}<br />
|
|
75
|
+
</StickyHeader.Content>
|
|
76
|
+
</StickyHeader>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
37
82
|
export {
|
|
38
83
|
Primary,
|
|
84
|
+
RefsDemo,
|
|
39
85
|
};
|
|
40
86
|
|
|
41
87
|
export default meta;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
|
|
3
3
|
import { Header } from "./Header";
|
|
4
4
|
import { Content, StyledStickyHeader } from "./StickyHeader.styled";
|
|
@@ -6,23 +6,36 @@ import { Content, StyledStickyHeader } from "./StickyHeader.styled";
|
|
|
6
6
|
const err = new TypeError("StickyHeader needs two children - Header and StickyHeader.Content");
|
|
7
7
|
|
|
8
8
|
interface ContentComponent {
|
|
9
|
-
|
|
10
|
-
Content: React.FC<ContentProps>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ContentProps {
|
|
14
|
-
className?: string;
|
|
15
|
-
children: React.ReactNode;
|
|
9
|
+
Content: typeof Content;
|
|
16
10
|
}
|
|
17
11
|
|
|
18
12
|
interface Props {
|
|
13
|
+
/**
|
|
14
|
+
* Position of the header
|
|
15
|
+
*/
|
|
19
16
|
position?: "top" | "left" | "right" | "bottom";
|
|
17
|
+
/**
|
|
18
|
+
* Additional class name
|
|
19
|
+
*/
|
|
20
20
|
className?: string;
|
|
21
|
+
/**
|
|
22
|
+
* If you need to pass custom children for some reason and you are sure that you are doing it right - use this prop
|
|
23
|
+
* to disable children type check.
|
|
24
|
+
*/
|
|
25
|
+
__dangerouslyDisableChildrenGuard?: boolean;
|
|
21
26
|
children: React.ReactNode;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
const
|
|
25
|
-
const { children: _children, position = "top", ...rest } = props;
|
|
29
|
+
const StickyHeaderRaw = forwardRef<HTMLDivElement, Props>((props, ref) => {
|
|
30
|
+
const { children: _children, position = "top", __dangerouslyDisableChildrenGuard, ...rest } = props;
|
|
31
|
+
|
|
32
|
+
if (__dangerouslyDisableChildrenGuard) {
|
|
33
|
+
return (
|
|
34
|
+
<StyledStickyHeader ref={ref} {...rest} position={position}>
|
|
35
|
+
{_children}
|
|
36
|
+
</StyledStickyHeader>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
26
39
|
|
|
27
40
|
const children = React.Children.toArray(_children);
|
|
28
41
|
|
|
@@ -32,7 +45,7 @@ const StickyHeader: React.FC<Props> & ContentComponent = (props) => {
|
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
let header = children.find(c => typeof c === "object" && "type" in c && c.type === Header),
|
|
35
|
-
content = children.find(c => typeof c === "object" && "type" in c && c.type ===
|
|
48
|
+
content = children.find(c => typeof c === "object" && "type" in c && c.type === Content);
|
|
36
49
|
|
|
37
50
|
if (!header || !content) {
|
|
38
51
|
throw err;
|
|
@@ -41,20 +54,18 @@ const StickyHeader: React.FC<Props> & ContentComponent = (props) => {
|
|
|
41
54
|
header = header as never; // @TODO find a better way to silence TS on cloneElement
|
|
42
55
|
content = content as never;
|
|
43
56
|
|
|
44
|
-
const contentCls = (content as { props: ContentProps }).props.className;
|
|
45
|
-
|
|
46
57
|
return (
|
|
47
|
-
<StyledStickyHeader {...rest} position={position}>
|
|
58
|
+
<StyledStickyHeader ref={ref} {...rest} position={position}>
|
|
48
59
|
{React.cloneElement(header, { position })}
|
|
49
|
-
|
|
50
|
-
{content}
|
|
51
|
-
</Content>
|
|
60
|
+
{React.cloneElement(content, { position })}
|
|
52
61
|
</StyledStickyHeader>
|
|
53
62
|
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
type StickyHeaderType = React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>> & ContentComponent;
|
|
66
|
+
|
|
67
|
+
const StickyHeader = StickyHeaderRaw as StickyHeaderType;
|
|
68
|
+
StickyHeader.Content = Content; // @TODO remove "position" from this component props
|
|
59
69
|
|
|
60
70
|
export { StickyHeader };
|
|
71
|
+
export type { Props as StickyHeaderProps };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { SunOne } from "@icon-park/react";
|
|
4
|
+
|
|
5
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
6
|
+
|
|
7
|
+
import { HeaderIconAction } from "../../layout/header/HeaderIconAction";
|
|
8
|
+
import { Icon, ICON } from "../../icons/Icon";
|
|
9
|
+
import { StickyHeader } from "../../layout/header/StickyHeader";
|
|
10
|
+
import { Header } from "../../layout/header/Header";
|
|
11
|
+
import { Section } from "../../layout/section/Section";
|
|
12
|
+
|
|
13
|
+
import { Pop } from "./Pop";
|
|
14
|
+
|
|
15
|
+
const meta: Meta = {
|
|
16
|
+
title: "Components/UI/Pop",
|
|
17
|
+
component: Pop,
|
|
18
|
+
tags: ["autodocs", "layout"],
|
|
19
|
+
args: {
|
|
20
|
+
value: 25,
|
|
21
|
+
valueFrom: 15,
|
|
22
|
+
scaleFrom: 10,
|
|
23
|
+
scaleTo: 30,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type Story = StoryObj<typeof Pop>;
|
|
28
|
+
|
|
29
|
+
const handleClick = () => {
|
|
30
|
+
console.info("Clicked an option");
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const Primary: Story = {
|
|
34
|
+
// eslint-disable-next-line max-lines-per-function
|
|
35
|
+
render: (args) => {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
37
|
+
const [open, setOpen] = useState(false);
|
|
38
|
+
const [leftOpen, setLeftOpen] = useState(false);
|
|
39
|
+
|
|
40
|
+
const handleToggle = useCallback(() => {
|
|
41
|
+
setOpen(p => !p);
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const handleLeftToggle = useCallback(() => {
|
|
45
|
+
setLeftOpen(p => !p);
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
const handleClose = useCallback(() => {
|
|
49
|
+
setOpen(false);
|
|
50
|
+
}, []);
|
|
51
|
+
|
|
52
|
+
const handleLeftClose = useCallback(() => {
|
|
53
|
+
setLeftOpen(false);
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
const after = (
|
|
57
|
+
<>
|
|
58
|
+
<HeaderIconAction icon={ICON.config} onClick={handleToggle} />
|
|
59
|
+
<Pop anchor={"prev"} open={open} onClose={handleClose}>
|
|
60
|
+
<Pop.Option icon={<Icon name={ICON.heart} />} onClick={handleClick}>Add new list</Pop.Option>
|
|
61
|
+
<Pop.Option icon={<Icon name={ICON.trash} />} onClick={handleClick}>Remove empty lists</Pop.Option>
|
|
62
|
+
<Pop.Option onClick={handleClick}>Configure</Pop.Option>
|
|
63
|
+
</Pop>
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const left = (
|
|
68
|
+
<>
|
|
69
|
+
<HeaderIconAction icon={ICON.checkmark} onClick={handleLeftToggle} />
|
|
70
|
+
<Pop anchor={"prev"} open={leftOpen} onClose={handleLeftClose}>
|
|
71
|
+
<Pop.Option icon={<Icon name={ICON.heart} />} onClick={handleClick}>Add new list</Pop.Option>
|
|
72
|
+
<Pop.Option icon={<Icon name={ICON.trash} />} onClick={handleClick}>Remove empty lists</Pop.Option>
|
|
73
|
+
<Pop.Option icon={<SunOne />} onClick={handleClick}>Configure</Pop.Option>
|
|
74
|
+
<Pop.Option icon={<Icon name={ICON.heart} />} onClick={handleClick}>Add new list</Pop.Option>
|
|
75
|
+
<Pop.Option icon={<Icon name={ICON.trash} />} onClick={handleClick}>Remove empty lists</Pop.Option>
|
|
76
|
+
<Pop.Option onClick={handleClick}>Configure</Pop.Option>
|
|
77
|
+
<Pop.Option icon={<Icon name={ICON.heart} />} onClick={handleClick}>Add new list</Pop.Option>
|
|
78
|
+
<Pop.Option icon={<Icon name={ICON.trash} />} onClick={handleClick}>Remove empty lists</Pop.Option>
|
|
79
|
+
<Pop.Option icon={<>text</>} onClick={handleClick}>Configure</Pop.Option>
|
|
80
|
+
</Pop>
|
|
81
|
+
</>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<StickyHeader>
|
|
86
|
+
<Header before={left} after={after}>
|
|
87
|
+
Some place
|
|
88
|
+
</Header>
|
|
89
|
+
<StickyHeader.Content>
|
|
90
|
+
<Section horizontal={true} vertical={true} css={{ minHeight: 600 }}>
|
|
91
|
+
Click on the left or right icon to open the menu
|
|
92
|
+
</Section>
|
|
93
|
+
</StickyHeader.Content>
|
|
94
|
+
</StickyHeader>
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default meta;
|
|
100
|
+
export {
|
|
101
|
+
Primary,
|
|
102
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { dimensionsPxToRem, fontPxToRem, styled } from "../../../theme";
|
|
2
|
+
|
|
3
|
+
const Overlay = styled("div", {
|
|
4
|
+
position: "fixed",
|
|
5
|
+
background: "#0000004c",
|
|
6
|
+
inset: 0,
|
|
7
|
+
zIndex: 4,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const List = styled("ul", {
|
|
11
|
+
zIndex: 5,
|
|
12
|
+
position: "absolute",
|
|
13
|
+
background: "white",
|
|
14
|
+
margin: 0,
|
|
15
|
+
padding: 0,
|
|
16
|
+
listStyleType: "none",
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const ListItem = styled("li", {
|
|
20
|
+
"margin": 0,
|
|
21
|
+
"padding": 0,
|
|
22
|
+
"listStyleType": "none",
|
|
23
|
+
|
|
24
|
+
"& + &": {
|
|
25
|
+
borderTop: "1px solid var(--border)",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const Button = styled("button", {
|
|
30
|
+
"border": "none",
|
|
31
|
+
"background": "white",
|
|
32
|
+
"height": dimensionsPxToRem(116),
|
|
33
|
+
"padding": `0 ${dimensionsPxToRem(42)}`,
|
|
34
|
+
"boxSizing": "border-box",
|
|
35
|
+
"width": "100%",
|
|
36
|
+
"minWidth": dimensionsPxToRem(460),
|
|
37
|
+
"textAlign": "left",
|
|
38
|
+
"color": "$popText",
|
|
39
|
+
"fontSize": fontPxToRem(26),
|
|
40
|
+
"fontWeight": "revert",
|
|
41
|
+
"display": "flex",
|
|
42
|
+
"alignItems": "center",
|
|
43
|
+
|
|
44
|
+
"&:hover": {
|
|
45
|
+
background: "$activeBg",
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const Icon = styled("div", {
|
|
50
|
+
fill: "currentColor",
|
|
51
|
+
marginRight: dimensionsPxToRem(42),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const FakeIcon = styled("span", {
|
|
55
|
+
display: "inline-block",
|
|
56
|
+
width: 16,
|
|
57
|
+
height: 16,
|
|
58
|
+
marginRight: dimensionsPxToRem(42),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
Overlay,
|
|
63
|
+
List,
|
|
64
|
+
ListItem,
|
|
65
|
+
Button,
|
|
66
|
+
Icon,
|
|
67
|
+
FakeIcon,
|
|
68
|
+
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React, { Component, createRef } from "react";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import type { ThemeCSS } from "../../../theme";
|
|
4
4
|
|
|
5
5
|
import { HandleEsc } from "../../utils/HandleEsc";
|
|
6
6
|
|
|
7
7
|
import { OnButtonClick } from "./OnButtonClick";
|
|
8
8
|
import { PopOption } from "./PopOption";
|
|
9
|
-
|
|
10
|
-
import styles from "./Pop.module.scss";
|
|
9
|
+
import { List, Overlay } from "./Pop.styled";
|
|
11
10
|
|
|
12
11
|
interface Props {
|
|
13
12
|
open: boolean;
|
|
@@ -51,6 +50,11 @@ const getElementLocation = (element: HTMLElement, outerElement = html): [State["
|
|
|
51
50
|
return [verticalLocation, horizontalLocation];
|
|
52
51
|
};
|
|
53
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Popup menu component.
|
|
55
|
+
*
|
|
56
|
+
* It has a bug that miscalculates the position inside Storybook.
|
|
57
|
+
*/
|
|
54
58
|
class Pop extends Component<Props, State> {
|
|
55
59
|
public constructor(props: Props) {
|
|
56
60
|
super(props);
|
|
@@ -125,7 +129,7 @@ class Pop extends Component<Props, State> {
|
|
|
125
129
|
};
|
|
126
130
|
|
|
127
131
|
public override render() {
|
|
128
|
-
const style:
|
|
132
|
+
const style: ThemeCSS = {};
|
|
129
133
|
|
|
130
134
|
if (this.state.vertical === "top") {
|
|
131
135
|
style.top = this.state.y;
|
|
@@ -148,17 +152,15 @@ class Pop extends Component<Props, State> {
|
|
|
148
152
|
const closeOnEsc = this.props.closeOnEsc ?? true;
|
|
149
153
|
const esc = closeOnEsc && <HandleEsc onPress={this.handleEsc} />;
|
|
150
154
|
|
|
151
|
-
const cls = classnames(this.props.className, styles.overlay);
|
|
152
|
-
|
|
153
155
|
return (
|
|
154
|
-
<
|
|
156
|
+
<Overlay className={this.props.className} ref={this.rootRef} onClick={this.handleOverlayClick}>
|
|
155
157
|
{esc}
|
|
156
158
|
<OnButtonClick onClick={this.handleEsc}>
|
|
157
|
-
<
|
|
159
|
+
<List css={style}>
|
|
158
160
|
{this.props.children}
|
|
159
|
-
</
|
|
161
|
+
</List>
|
|
160
162
|
</OnButtonClick>
|
|
161
|
-
</
|
|
163
|
+
</Overlay>
|
|
162
164
|
);
|
|
163
165
|
}
|
|
164
166
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import styles from "./Pop.module.scss";
|
|
3
|
+
import { Button, FakeIcon, Icon, ListItem } from "./Pop.styled";
|
|
6
4
|
|
|
7
5
|
interface Props {
|
|
8
6
|
icon?: React.ReactElement;
|
|
@@ -14,13 +12,13 @@ interface Props {
|
|
|
14
12
|
|
|
15
13
|
const PopOption: React.FC<Props> = (props) => {
|
|
16
14
|
const ic = props.icon
|
|
17
|
-
? <
|
|
18
|
-
: ((props.forceEmptyIcon ?? true) ? <
|
|
15
|
+
? <Icon>{props.icon}</Icon>
|
|
16
|
+
: ((props.forceEmptyIcon ?? true) ? <FakeIcon /> : null);
|
|
19
17
|
|
|
20
18
|
return (
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
</
|
|
19
|
+
<ListItem className={props.className}>
|
|
20
|
+
<Button onClick={props.onClick}>{ic}{props.children}</Button>
|
|
21
|
+
</ListItem>
|
|
24
22
|
);
|
|
25
23
|
};
|
|
26
24
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { styled } from "../../../theme";
|
|
6
|
+
|
|
7
|
+
import { Progress, ValueClassName } from "./Progress";
|
|
8
|
+
|
|
9
|
+
const meta: Meta = {
|
|
10
|
+
title: "Components/UI/Progress",
|
|
11
|
+
component: Progress,
|
|
12
|
+
tags: ["autodocs", "layout"],
|
|
13
|
+
args: {
|
|
14
|
+
value: 25,
|
|
15
|
+
valueFrom: 15,
|
|
16
|
+
scaleFrom: 10,
|
|
17
|
+
scaleTo: 30,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type Story = StoryObj<typeof Progress>;
|
|
22
|
+
|
|
23
|
+
const Primary: Story = {};
|
|
24
|
+
|
|
25
|
+
const CustomProgress = styled(Progress, {
|
|
26
|
+
"--value-background-color":
|
|
27
|
+
"linear-gradient(to right, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8b00ff)",
|
|
28
|
+
|
|
29
|
+
[`& ${ValueClassName}`]: {
|
|
30
|
+
borderWidth: 0,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const CustomizedColors: Story = {
|
|
35
|
+
render: (args) => {
|
|
36
|
+
return (
|
|
37
|
+
<CustomProgress {...args} />
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default meta;
|
|
43
|
+
export {
|
|
44
|
+
Primary,
|
|
45
|
+
CustomizedColors,
|
|
46
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { borderPxToRem, css, dimensionsPxToRem, styled } from "../../../theme";
|
|
2
|
+
|
|
3
|
+
const Container = styled("div", {
|
|
4
|
+
"height": dimensionsPxToRem(20),
|
|
5
|
+
"position": "relative",
|
|
6
|
+
"overflow": "hidden",
|
|
7
|
+
|
|
8
|
+
"variants": {
|
|
9
|
+
size: {
|
|
10
|
+
big: {
|
|
11
|
+
height: dimensionsPxToRem(40),
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
"--value-border-color": "$colors$blue5",
|
|
17
|
+
"--value-background-color": "$colors$blue4",
|
|
18
|
+
"--container-border-color": "$colors$border",
|
|
19
|
+
"--container-background-color": "$colors$toggleBgDisabled",
|
|
20
|
+
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const sharedValueStyles = css({
|
|
24
|
+
position: "absolute",
|
|
25
|
+
top: 0,
|
|
26
|
+
height: `100%`,
|
|
27
|
+
borderRadius: "9999px",
|
|
28
|
+
border: `${borderPxToRem(1)} solid $border`,
|
|
29
|
+
background: "$background",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const Value = styled("div", sharedValueStyles, {
|
|
33
|
+
borderColor: "var(--value-border-color)",
|
|
34
|
+
background: "var(--value-background-color)",
|
|
35
|
+
transition: "right 0.3s, border-width 0.3s, left 0.3s",
|
|
36
|
+
|
|
37
|
+
variants: {
|
|
38
|
+
zero: {
|
|
39
|
+
true: {
|
|
40
|
+
borderWidth: 0,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const Background = styled("div", sharedValueStyles, {
|
|
47
|
+
borderColor: "var(--container-border-color)",
|
|
48
|
+
background: "var(--container-background-color)",
|
|
49
|
+
width: "100%",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
Container,
|
|
54
|
+
Value,
|
|
55
|
+
Background,
|
|
56
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { cap, scale } from "@ezez/utils";
|
|
4
|
+
|
|
5
|
+
import type { ThemeCSS } from "../../../theme";
|
|
6
|
+
|
|
7
|
+
import { Background, Container, Value } from "./Progress.styled";
|
|
8
|
+
|
|
9
|
+
interface Props extends React.ComponentProps<typeof Container> {
|
|
10
|
+
/**
|
|
11
|
+
* The value of the progress bar. If used alone, it's the percentage value of the progress bar.
|
|
12
|
+
*/
|
|
13
|
+
value?: number | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Value from which the value bar starts. Default is equal to `scaleFrom`.
|
|
16
|
+
*/
|
|
17
|
+
valueFrom?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Redefines the scale of the progress bar. By default, the scale is 0-100. This controls the starting point of the progress bar.
|
|
20
|
+
*/
|
|
21
|
+
scaleFrom?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Redefines the scale of the progress bar. By default, the scale is 0-100. This controls the ending point of the progress bar.
|
|
24
|
+
*/
|
|
25
|
+
scaleTo?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Progress bar component, it can be filled from the start or from any arbitrary point.
|
|
30
|
+
*
|
|
31
|
+
* At the moment, no value (undefined) means starting point, but in the future it will mean "undetermined" state.
|
|
32
|
+
*/
|
|
33
|
+
const Progress: React.FC<Props> = (props) => {
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
35
|
+
const { value, valueFrom, scaleFrom = 0, scaleTo = 100, ...rest } = props;
|
|
36
|
+
|
|
37
|
+
const from = cap(valueFrom ?? scaleFrom, scaleTo, scaleFrom);
|
|
38
|
+
const to = cap(value ?? scaleFrom, scaleTo, scaleFrom);
|
|
39
|
+
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
41
|
+
const scaledFrom = valueFrom != null ? scale(scaleFrom, scaleTo, 0, 100, from) : 0;
|
|
42
|
+
const percFrom = Math.max(scaledFrom, 0);
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
45
|
+
const scaledTo = value != null ? scale(scaleTo, scaleFrom, 0, 100, to) : 100;
|
|
46
|
+
const percTo = Math.max(scaledTo, 0);
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
49
|
+
const isZeroWidth = from >= to || percFrom === 100 || percTo === 100;
|
|
50
|
+
|
|
51
|
+
const css: ThemeCSS = {
|
|
52
|
+
right: `${percTo}%`,
|
|
53
|
+
left: `${percFrom}%`,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Container {...rest}>
|
|
58
|
+
<Background />
|
|
59
|
+
<Value css={css} zero={isZeroWidth} />
|
|
60
|
+
</Container>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const BackgroundClassName = Background.toString();
|
|
65
|
+
const ValueClassName = Value.toString();
|
|
66
|
+
|
|
67
|
+
export { Progress, BackgroundClassName, ValueClassName };
|
|
68
|
+
|
|
@@ -19,7 +19,6 @@ import { LabelDemo } from "./components/form/Label";
|
|
|
19
19
|
import { ToasterDemo } from "./components/ui/toaster/Toaster";
|
|
20
20
|
import { TabsDemo } from "./components/ui/tabs/Tabs";
|
|
21
21
|
import { ChoiceDemo, ChoiceDemo2 } from "./components/form/Choice";
|
|
22
|
-
import { PopDemo } from "./components/ui/pop/Pop";
|
|
23
22
|
import { DrawerDemo } from "./components/ui/drawer/Drawer";
|
|
24
23
|
import { StatsDarkDemo, StatsDemo } from "./components/ui/stats/Stats";
|
|
25
24
|
import { TableDemo } from "./components/layout/table/TableDemo";
|
|
@@ -129,10 +128,6 @@ const componentsMap: TheMap = {
|
|
|
129
128
|
name: "Drawer",
|
|
130
129
|
Component: DrawerDemo,
|
|
131
130
|
},
|
|
132
|
-
Pop: {
|
|
133
|
-
name: "Pop up menu",
|
|
134
|
-
Component: PopDemo,
|
|
135
|
-
},
|
|
136
131
|
Table: {
|
|
137
132
|
name: "Table",
|
|
138
133
|
Component: TableDemo,
|
package/src/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ export * from "./components/ui/loader/PopLoader";
|
|
|
33
33
|
export * from "./components/ui/message/Message";
|
|
34
34
|
export * from "./components/ui/modal/Modal";
|
|
35
35
|
export * from "./components/ui/modal/ModalButtons";
|
|
36
|
+
export * from "./components/ui/progress/Progress";
|
|
36
37
|
export * from "./components/ui/pop/Pop";
|
|
37
38
|
export * from "./components/ui/pop/PopOption";
|
|
38
39
|
export * from "./components/ui/stats/Stats";
|
package/src/theme.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { CSS as StitchesCSS } from "@stitches/react";
|
|
|
5
5
|
|
|
6
6
|
const RATIOS = {
|
|
7
7
|
dimensions: 3,
|
|
8
|
-
border:
|
|
8
|
+
border: 1,
|
|
9
9
|
font: 1.666666,
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -76,6 +76,8 @@ const {
|
|
|
76
76
|
blue1: "#038bf4",
|
|
77
77
|
blue2: "#b7d6f5",
|
|
78
78
|
blue3: "#dbe6ff",
|
|
79
|
+
blue4: "#33b4ff",
|
|
80
|
+
blue5: "#30a2e6",
|
|
79
81
|
orange1: "#ff7200",
|
|
80
82
|
orange1Darker: "#cc5b00",
|
|
81
83
|
purple1: "#7357e8",
|