musae 0.1.5 → 0.1.7
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/dist/divider/divider.d.ts +4 -0
- package/dist/divider/divider.js +9 -0
- package/dist/divider/index.d.ts +2 -0
- package/dist/divider/styled.d.ts +6 -0
- package/dist/divider/styled.js +13 -0
- package/dist/divider/types.d.ts +7 -0
- package/dist/icons/hooks.d.ts +2 -0
- package/dist/icons/hooks.js +11 -0
- package/dist/icons/navigate-before.d.ts +4 -0
- package/dist/icons/navigate-before.js +10 -0
- package/dist/icons/types.d.ts +11 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2 -0
- package/dist/menu/group.d.ts +1 -3
- package/dist/menu/group.js +50 -4
- package/dist/menu/styled.d.ts +3 -1
- package/dist/menu/styled.js +9 -9
- package/dist/menu/types.d.ts +1 -3
- package/dist/row/index.d.ts +2 -0
- package/dist/row/row.d.ts +4 -0
- package/dist/row/row.js +8 -0
- package/dist/row/styled.d.ts +5 -0
- package/dist/row/styled.js +8 -0
- package/dist/row/types.d.ts +4 -0
- package/package.json +1 -1
- package/dist/menu/item.d.ts +0 -4
- package/dist/menu/item.js +0 -45
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { StyledWrapper } from './styled.js';
|
|
3
|
+
|
|
4
|
+
const Divider = (props) => {
|
|
5
|
+
const hasChildren = useMemo(() => !!props.children, [props.children]);
|
|
6
|
+
return React.createElement(StyledWrapper, { hasChildren: hasChildren }, props.children);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { Divider as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DividerRenderProps } from "./types";
|
|
3
|
+
export declare const StyledWrapper: import("@emotion/styled").StyledComponent<{
|
|
4
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
5
|
+
as?: import("react").ElementType<any> | undefined;
|
|
6
|
+
} & DividerRenderProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
|
|
3
|
+
const StyledWrapper = styled.div(({ hasChildren }) => {
|
|
4
|
+
if (!hasChildren) {
|
|
5
|
+
return {
|
|
6
|
+
margin: "1.5rem 0",
|
|
7
|
+
borderBlockStart: "1px solid rgba(5, 5, 5, 0.06)",
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
return {};
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { StyledWrapper };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useTheme } from '../theme/hooks.js';
|
|
3
|
+
|
|
4
|
+
const useIconProps = (props) => {
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
const size = useMemo(() => props.size || 24, [props.size, theme]);
|
|
7
|
+
const color = useMemo(() => props.color || "white", [props.color]);
|
|
8
|
+
return { size, color };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { useIconProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIconProps } from './hooks.js';
|
|
3
|
+
|
|
4
|
+
const NavigateBefore = (props) => {
|
|
5
|
+
const iconProps = useIconProps(props);
|
|
6
|
+
return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: iconProps.size, height: iconProps.size, viewBox: "0 0 24 24", fill: "none" },
|
|
7
|
+
React.createElement("path", { d: "M15.7049 7.41L14.2949 6L8.29492 12L14.2949 18L15.7049 16.59L11.1249 12L15.7049 7.41Z", fill: iconProps.color })));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { NavigateBefore as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,15 @@ export { Button } from "./button";
|
|
|
11
11
|
export { Switch } from "./switch";
|
|
12
12
|
export { Radio, RadioGroup } from "./radio";
|
|
13
13
|
export { Checkbox } from "./checkbox";
|
|
14
|
+
export { Row } from "./row";
|
|
15
|
+
export { Divider } from "./divider";
|
|
14
16
|
/**
|
|
15
17
|
* @description
|
|
16
18
|
* hooks
|
|
17
19
|
*/
|
|
18
20
|
export { useMessage } from "./message";
|
|
21
|
+
/**
|
|
22
|
+
* @description
|
|
23
|
+
* declarations
|
|
24
|
+
*/
|
|
25
|
+
export type { MenuItemProps } from "./menu";
|
package/dist/index.js
CHANGED
|
@@ -8,4 +8,6 @@ export { default as Switch } from './switch/switch.js';
|
|
|
8
8
|
export { default as Radio } from './radio/radio.js';
|
|
9
9
|
export { default as RadioGroup } from './radio/group.js';
|
|
10
10
|
export { default as Checkbox } from './checkbox/checkbox.js';
|
|
11
|
+
export { default as Row } from './row/row.js';
|
|
12
|
+
export { default as Divider } from './divider/divider.js';
|
|
11
13
|
export { useMessage } from './message/hooks.js';
|
package/dist/menu/group.d.ts
CHANGED
|
@@ -5,7 +5,5 @@ import React from "react";
|
|
|
5
5
|
* @description
|
|
6
6
|
* menu group
|
|
7
7
|
*/
|
|
8
|
-
declare const Group: React.ForwardRefExoticComponent<import("./types").MenuProps & import("./types").WithLevel &
|
|
9
|
-
isCollapsed?: boolean | undefined;
|
|
10
|
-
} & React.RefAttributes<HTMLUListElement>>;
|
|
8
|
+
declare const Group: React.ForwardRefExoticComponent<import("./types").MenuProps & import("./types").WithLevel & React.RefAttributes<HTMLUListElement>>;
|
|
11
9
|
export default Group;
|
package/dist/menu/group.js
CHANGED
|
@@ -1,15 +1,61 @@
|
|
|
1
1
|
import { __rest } from '../node_modules/tslib/tslib.es6.js';
|
|
2
|
-
import { StyledMenuGroup } from './styled.js';
|
|
3
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
4
|
-
import
|
|
2
|
+
import { StyledMenuGroup, StyledMenuItemCollapser, StyledMenuItemWrapper, StyledMenuItemPrefix } from './styled.js';
|
|
3
|
+
import React, { forwardRef, useMemo, useContext, useCallback } from 'react';
|
|
4
|
+
import { useBoolean } from '@aiszlab/relax';
|
|
5
|
+
import { useAnimate } from 'framer-motion';
|
|
6
|
+
import MenuContext from './context.js';
|
|
7
|
+
import NavigateBefore from '../icons/navigate-before.js';
|
|
5
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @author murukal
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* menu item
|
|
14
|
+
*/
|
|
15
|
+
const Item = ({ level = 0, label, children, prefix, id }) => {
|
|
16
|
+
/// has children
|
|
17
|
+
const hasChildren = useMemo(() => !!(children === null || children === void 0 ? void 0 : children.length), [children]);
|
|
18
|
+
const context = useContext(MenuContext);
|
|
19
|
+
const [scope, animate] = useAnimate();
|
|
20
|
+
/// if is collapsed
|
|
21
|
+
const { isOn: isCollapsed, toggle } = useBoolean(false);
|
|
22
|
+
/// if there are children, render trailing arrow
|
|
23
|
+
const collapser = useMemo(() => {
|
|
24
|
+
if (!hasChildren)
|
|
25
|
+
return null;
|
|
26
|
+
return (React.createElement(StyledMenuItemCollapser, { isCollapsed: isCollapsed },
|
|
27
|
+
React.createElement(NavigateBefore, { size: 16 })));
|
|
28
|
+
}, [hasChildren, isCollapsed]);
|
|
29
|
+
const onCollapserToggle = useCallback(() => {
|
|
30
|
+
var _a;
|
|
31
|
+
// if this item do not has children, mean this is a menu item
|
|
32
|
+
// when click it, handler the change event, pass key
|
|
33
|
+
if (!hasChildren) {
|
|
34
|
+
return (_a = context === null || context === void 0 ? void 0 : context.onClick) === null || _a === void 0 ? void 0 : _a.call(context, id);
|
|
35
|
+
}
|
|
36
|
+
// when item has children, mean this is menu group
|
|
37
|
+
// when click it, handler collapser
|
|
38
|
+
if (!scope.current)
|
|
39
|
+
return;
|
|
40
|
+
animate(scope.current, {
|
|
41
|
+
height: isCollapsed ? "auto" : 0,
|
|
42
|
+
});
|
|
43
|
+
toggle();
|
|
44
|
+
}, [toggle, isCollapsed, animate, id, context === null || context === void 0 ? void 0 : context.onClick, hasChildren]);
|
|
45
|
+
return (React.createElement("li", null,
|
|
46
|
+
React.createElement(StyledMenuItemWrapper, { level: level, onClick: onCollapserToggle },
|
|
47
|
+
!!prefix && React.createElement(StyledMenuItemPrefix, null, prefix),
|
|
48
|
+
label,
|
|
49
|
+
collapser),
|
|
50
|
+
hasChildren && React.createElement(Group, { ref: scope, items: children, level: level + 1 })));
|
|
51
|
+
};
|
|
6
52
|
/**
|
|
7
53
|
* @author murukal
|
|
8
54
|
*
|
|
9
55
|
* @description
|
|
10
56
|
* menu group
|
|
11
57
|
*/
|
|
12
|
-
const Group = forwardRef(({ items, level = 0
|
|
58
|
+
const Group = forwardRef(({ items, level = 0 }, ref) => {
|
|
13
59
|
/// 菜单条目渲染结果
|
|
14
60
|
const children = useMemo(() => {
|
|
15
61
|
return items.map((_a) => {
|
package/dist/menu/styled.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { WithLevel } from "./types";
|
|
2
|
+
import type { WithLevel } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* @author murukal
|
|
5
5
|
*
|
|
@@ -29,6 +29,8 @@ export declare const StyledMenuItemPrefix: import("@emotion/styled").StyledCompo
|
|
|
29
29
|
export declare const StyledMenuItemCollapser: import("@emotion/styled").StyledComponent<{
|
|
30
30
|
theme?: import("@emotion/react").Theme | undefined;
|
|
31
31
|
as?: import("react").ElementType<any> | undefined;
|
|
32
|
+
} & {
|
|
33
|
+
isCollapsed: boolean;
|
|
32
34
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
33
35
|
/**
|
|
34
36
|
* @author murukal
|
package/dist/menu/styled.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
-
import { useTheme } from '../theme/hooks.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* @author murukal
|
|
@@ -19,9 +18,9 @@ const StyledMenuItemWrapper = styled.div(({ level = 0 }) => {
|
|
|
19
18
|
paddingLeft: 12 + level * 24,
|
|
20
19
|
borderRadius: 8,
|
|
21
20
|
transition: "background-color 300ms",
|
|
22
|
-
":hover": {
|
|
23
|
-
|
|
24
|
-
},
|
|
21
|
+
// ":hover": {
|
|
22
|
+
// backgroundColor: "#f5f7fa",
|
|
23
|
+
// },
|
|
25
24
|
};
|
|
26
25
|
});
|
|
27
26
|
/**
|
|
@@ -41,10 +40,12 @@ const StyledMenuItemPrefix = styled.span(() => {
|
|
|
41
40
|
* @description
|
|
42
41
|
* styled menu collapser
|
|
43
42
|
*/
|
|
44
|
-
const StyledMenuItemCollapser = styled.span(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const StyledMenuItemCollapser = styled.span(({ isCollapsed }) => {
|
|
44
|
+
return {
|
|
45
|
+
marginLeft: "auto",
|
|
46
|
+
transform: `rotate(90deg) ${isCollapsed ? "rotateY(180deg)" : "rotateY(0)"}`,
|
|
47
|
+
transition: "transform 200ms",
|
|
48
|
+
};
|
|
48
49
|
});
|
|
49
50
|
/**
|
|
50
51
|
* @author murukal
|
|
@@ -56,7 +57,6 @@ const StyledMenuGroup = styled.ul({
|
|
|
56
57
|
margin: 0,
|
|
57
58
|
listStyleType: "none",
|
|
58
59
|
padding: 0,
|
|
59
|
-
width: 240,
|
|
60
60
|
overflow: "hidden",
|
|
61
61
|
});
|
|
62
62
|
|
package/dist/menu/types.d.ts
CHANGED
|
@@ -39,9 +39,7 @@ export interface MenuItemProps {
|
|
|
39
39
|
* @description
|
|
40
40
|
* menu group render props
|
|
41
41
|
*/
|
|
42
|
-
export type MenuGroupRenderProps = MenuProps & WithLevel
|
|
43
|
-
isCollapsed?: boolean;
|
|
44
|
-
};
|
|
42
|
+
export type MenuGroupRenderProps = MenuProps & WithLevel;
|
|
45
43
|
/**
|
|
46
44
|
* @author murukal
|
|
47
45
|
*
|
package/dist/row/row.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledWrapper: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
package/package.json
CHANGED
package/dist/menu/item.d.ts
DELETED
package/dist/menu/item.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useContext, useCallback } from 'react';
|
|
2
|
-
import { StyledMenuItemCollapser, StyledMenuItemWrapper, StyledMenuItemPrefix } from './styled.js';
|
|
3
|
-
import { useBoolean } from '@aiszlab/relax';
|
|
4
|
-
import Group from './group.js';
|
|
5
|
-
import { useAnimate } from 'framer-motion';
|
|
6
|
-
import MenuContext from './context.js';
|
|
7
|
-
|
|
8
|
-
const Item = ({ level = 0, label, children, prefix, id }) => {
|
|
9
|
-
/// has children
|
|
10
|
-
const hasChildren = useMemo(() => !!(children === null || children === void 0 ? void 0 : children.length), [children]);
|
|
11
|
-
const [scope, animate] = useAnimate();
|
|
12
|
-
/// if is collapsed
|
|
13
|
-
const { isOn: isCollapsed, toggle } = useBoolean(false);
|
|
14
|
-
/// if there are children, render trailing arrow
|
|
15
|
-
const collapser = useMemo(() => {
|
|
16
|
-
if (!hasChildren)
|
|
17
|
-
return null;
|
|
18
|
-
return React.createElement(StyledMenuItemCollapser, null, isCollapsed ? "展开" : "收起");
|
|
19
|
-
}, [hasChildren, isCollapsed]);
|
|
20
|
-
const context = useContext(MenuContext);
|
|
21
|
-
const onCollapserToggle = useCallback(() => {
|
|
22
|
-
var _a;
|
|
23
|
-
// if this item do not has children, mean this is a menu item
|
|
24
|
-
// when click it, handler the change event, pass key
|
|
25
|
-
if (!hasChildren) {
|
|
26
|
-
return (_a = context === null || context === void 0 ? void 0 : context.onClick) === null || _a === void 0 ? void 0 : _a.call(context, id);
|
|
27
|
-
}
|
|
28
|
-
// when item has children, mean this is menu group
|
|
29
|
-
// when click it, handler collapser
|
|
30
|
-
if (!scope.current)
|
|
31
|
-
return;
|
|
32
|
-
animate(scope.current, {
|
|
33
|
-
height: isCollapsed ? "auto" : 0,
|
|
34
|
-
});
|
|
35
|
-
toggle();
|
|
36
|
-
}, [toggle, isCollapsed, animate, id, context === null || context === void 0 ? void 0 : context.onClick, hasChildren]);
|
|
37
|
-
return (React.createElement("li", null,
|
|
38
|
-
React.createElement(StyledMenuItemWrapper, { level: level, onClick: onCollapserToggle },
|
|
39
|
-
!!prefix && React.createElement(StyledMenuItemPrefix, null, prefix),
|
|
40
|
-
label,
|
|
41
|
-
collapser),
|
|
42
|
-
hasChildren && React.createElement(Group, { ref: scope, items: children, level: level + 1, isCollapsed: isCollapsed })));
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export { Item as default };
|