musae 0.1.2 → 0.1.4

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 (69) hide show
  1. package/dist/button/button.d.ts +2 -2
  2. package/dist/button/button.js +3 -3
  3. package/dist/button/{wrapper.d.ts → styled.d.ts} +1 -7
  4. package/dist/button/{wrapper.js → styled.js} +1 -6
  5. package/dist/button/types.d.ts +4 -3
  6. package/dist/checkbox/checkbox.d.ts +2 -2
  7. package/dist/checkbox/checkbox.js +1 -1
  8. package/dist/checkbox/group.d.ts +2 -2
  9. package/dist/{radio/wrapper.d.ts → checkbox/styled.d.ts} +1 -2
  10. package/dist/checkbox/{wrapper.js → styled.js} +1 -1
  11. package/dist/checkbox/types.d.ts +4 -4
  12. package/dist/index.d.ts +1 -1
  13. package/dist/input/input.d.ts +2 -2
  14. package/dist/input/input.js +1 -10
  15. package/dist/input/styled.d.ts +10 -0
  16. package/dist/input/{wrapper.js → styled.js} +10 -1
  17. package/dist/input/types.d.ts +1 -1
  18. package/dist/loading/circle.d.ts +2 -2
  19. package/dist/loading/loading.js +46 -46
  20. package/dist/loading/{wrapper.d.ts → styled.d.ts} +1 -2
  21. package/dist/loading/{wrapper.js → styled.js} +1 -1
  22. package/dist/loading/types.d.ts +2 -2
  23. package/dist/menu/group.d.ts +11 -0
  24. package/dist/menu/group.js +23 -0
  25. package/dist/menu/index.d.ts +0 -4
  26. package/dist/menu/item.d.ts +4 -0
  27. package/dist/menu/item.js +33 -0
  28. package/dist/menu/menu.d.ts +5 -2
  29. package/dist/menu/menu.js +6 -9
  30. package/dist/menu/styled.d.ts +44 -0
  31. package/dist/menu/styled.js +65 -0
  32. package/dist/menu/types.d.ts +41 -0
  33. package/dist/message/holder.js +1 -1
  34. package/dist/message/message.d.ts +2 -2
  35. package/dist/message/message.js +1 -1
  36. package/dist/message/types.d.ts +3 -3
  37. package/dist/node_modules/tslib/tslib.es6.js +14 -0
  38. package/dist/popper/popper.d.ts +2 -2
  39. package/dist/popper/popper.js +1 -1
  40. package/dist/popper/{wrapper.d.ts → styled.d.ts} +1 -2
  41. package/dist/popper/{wrapper.js → styled.js} +1 -1
  42. package/dist/popper/types.d.ts +7 -3
  43. package/dist/radio/group.d.ts +2 -2
  44. package/dist/radio/radio.d.ts +2 -2
  45. package/dist/radio/radio.js +1 -1
  46. package/dist/{checkbox/wrapper.d.ts → radio/styled.d.ts} +1 -2
  47. package/dist/radio/{wrapper.js → styled.js} +1 -1
  48. package/dist/radio/types.d.ts +4 -4
  49. package/dist/select/hooks.d.ts +3 -2
  50. package/dist/select/hooks.js +11 -0
  51. package/dist/select/select.d.ts +2 -2
  52. package/dist/select/select.js +4 -6
  53. package/dist/select/types.d.ts +1 -1
  54. package/dist/switch/{wrapper.d.ts → styled.d.ts} +1 -2
  55. package/dist/switch/{wrapper.js → styled.js} +1 -1
  56. package/dist/switch/switch.js +1 -1
  57. package/dist/theme/hooks.d.ts +1 -1
  58. package/dist/theme/hooks.js +82 -1
  59. package/dist/theme/types.d.ts +21 -1
  60. package/package.json +5 -3
  61. package/dist/input/styled-input.d.ts +0 -6
  62. package/dist/input/styled-input.js +0 -13
  63. package/dist/input/wrapper.d.ts +0 -7
  64. package/dist/menu-item/index.d.ts +0 -2
  65. package/dist/menu-item/menu-item.d.ts +0 -4
  66. package/dist/menu-item/menu-item.js +0 -8
  67. package/dist/menu-item/types.d.ts +0 -11
  68. /package/dist/message/{wrappers.d.ts → styled.d.ts} +0 -0
  69. /package/dist/message/{wrappers.js → styled.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { Props } from "./types";
1
+ import type { ButtonProps } from "./types";
2
2
  import React from "react";
3
3
  /**
4
4
  * @author murukal
@@ -6,5 +6,5 @@ import React from "react";
6
6
  * @description
7
7
  * button
8
8
  */
9
- declare const Button: ({ children, onClick }: Props) => React.JSX.Element;
9
+ declare const Button: ({ children, className, onClick }: ButtonProps) => React.JSX.Element;
10
10
  export default Button;
@@ -1,4 +1,4 @@
1
- import Wrapper from './wrapper.js';
1
+ import { Wrapper } from './styled.js';
2
2
  import Span from './span.js';
3
3
  import React from 'react';
4
4
 
@@ -8,8 +8,8 @@ import React from 'react';
8
8
  * @description
9
9
  * button
10
10
  */
11
- const Button = ({ children, onClick }) => {
12
- return (React.createElement(Wrapper, { onClick: onClick },
11
+ const Button = ({ children, className, onClick }) => {
12
+ return (React.createElement(Wrapper, { onClick: onClick, className: className },
13
13
  React.createElement(Span, null, children)));
14
14
  };
15
15
 
@@ -1,11 +1,5 @@
1
1
  /// <reference types="react" />
2
- /**
3
- * @author murukal
4
- *
5
- * @description
6
- */
7
- declare const Wrapper: import("@emotion/styled").StyledComponent<{
2
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
8
3
  theme?: import("@emotion/react").Theme | undefined;
9
4
  as?: import("react").ElementType<any> | undefined;
10
5
  }, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
11
- export default Wrapper;
@@ -1,11 +1,6 @@
1
1
  import styled from '@emotion/styled';
2
2
  import { useTheme } from '../theme/hooks.js';
3
3
 
4
- /**
5
- * @author murukal
6
- *
7
- * @description
8
- */
9
4
  const Wrapper = styled.button(() => {
10
5
  var _a;
11
6
  const theme = useTheme();
@@ -17,4 +12,4 @@ const Wrapper = styled.button(() => {
17
12
  };
18
13
  });
19
14
 
20
- export { Wrapper as default };
15
+ export { Wrapper };
@@ -3,9 +3,10 @@ import type { MouseEventHandler, ReactNode } from "react";
3
3
  * @author murukal
4
4
  *
5
5
  * @description
6
- * button props
6
+ * button render props
7
7
  */
8
- export interface Props {
9
- children: ReactNode;
8
+ export interface ButtonProps {
9
+ className?: string;
10
+ children?: ReactNode;
10
11
  onClick?: MouseEventHandler<HTMLButtonElement>;
11
12
  }
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import { CheckboxRenderProps } from "./types";
3
- declare const Checkbox: (props: CheckboxRenderProps) => React.JSX.Element;
2
+ import { CheckboxProps } from "./types";
3
+ declare const Checkbox: (props: CheckboxProps) => React.JSX.Element;
4
4
  export default Checkbox;
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useMemo, useCallback } from 'react';
2
- import Wrapper from './wrapper.js';
2
+ import { Wrapper } from './styled.js';
3
3
  import { useControlledState } from '@aiszlab/relax';
4
4
  import Context from './context.js';
5
5
 
@@ -1,4 +1,4 @@
1
- import { GroupRenderProps } from "./types";
1
+ import { type CheckboxGroupProps } from "./types";
2
2
  import React from "react";
3
- declare const Group: (props: GroupRenderProps) => React.JSX.Element;
3
+ declare const Group: (props: CheckboxGroupProps) => React.JSX.Element;
4
4
  export default Group;
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare const Wrapper: import("@emotion/styled").StyledComponent<{
2
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any> | undefined;
5
5
  }, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
6
- export default Wrapper;
@@ -46,4 +46,4 @@ const Wrapper = styled.input(() => {
46
46
  };
47
47
  });
48
48
 
49
- export { Wrapper as default };
49
+ export { Wrapper };
@@ -13,18 +13,18 @@ export interface ContextValue {
13
13
  * @author murukal
14
14
  *
15
15
  * @description
16
- * group render props
16
+ * checkbox group props
17
17
  */
18
- export interface GroupRenderProps {
18
+ export interface CheckboxGroupProps {
19
19
  children: ReactNode;
20
20
  }
21
21
  /**
22
22
  * @author murukal
23
23
  *
24
24
  * @description
25
- * checkbox render props
25
+ * checkbox props
26
26
  */
27
- export interface CheckboxRenderProps {
27
+ export interface CheckboxProps {
28
28
  isChecked?: boolean;
29
29
  value?: string;
30
30
  }
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * components
4
4
  */
5
5
  export { Avatar } from "./avatar";
6
- export { Menu, type Props as MenuProps } from "./menu";
6
+ export { Menu } from "./menu";
7
7
  export { Loading } from "./loading";
8
8
  export { Input } from "./input";
9
9
  export { Select } from "./select";
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
- import type { InputRef, Props } from "./types";
2
+ import type { InputRef, InputProps } from "./types";
3
3
  /**
4
4
  * @author murukal
5
5
  * @description input component
6
6
  */
7
- declare const Input: React.ForwardRefExoticComponent<Props & React.RefAttributes<InputRef>>;
7
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>>;
8
8
  export default Input;
@@ -2,8 +2,7 @@ import React, { forwardRef, useRef, useImperativeHandle, useMemo } from 'react';
2
2
  import { useStyles } from './hooks.js';
3
3
  import { useBoolean } from '@aiszlab/relax';
4
4
  import Label from './label.js';
5
- import Wrapper from './wrapper.js';
6
- import StyledInput from './styled-input.js';
5
+ import { Wrapper, StyledInput } from './styled.js';
7
6
 
8
7
  /**
9
8
  * @author murukal
@@ -12,14 +11,6 @@ import StyledInput from './styled-input.js';
12
11
  const Input = forwardRef((props, ref) => {
13
12
  const inputRef = useRef(null);
14
13
  const wrapperRef = useRef(null);
15
- // const { isOn: isNotEmpty, turnOn, turnOff } = useBoolean();
16
- // useEffect(() => {
17
- // if (!!inputRef.current?.value) {
18
- // turnOn();
19
- // } else {
20
- // turnOff();
21
- // }
22
- // }, [!!inputRef.current?.value]);
23
14
  useImperativeHandle(ref, () => ({
24
15
  input: inputRef.current,
25
16
  wrapper: wrapperRef.current,
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import type { WrapperProps } from "./types";
3
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
4
+ theme?: import("@emotion/react").Theme | undefined;
5
+ as?: import("react").ElementType<any> | undefined;
6
+ } & WrapperProps, import("react").DetailedHTMLProps<import("react").FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, {}>;
7
+ export declare const StyledInput: import("@emotion/styled").StyledComponent<{
8
+ theme?: import("@emotion/react").Theme | undefined;
9
+ as?: import("react").ElementType<any> | undefined;
10
+ }, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
@@ -9,5 +9,14 @@ const Wrapper = styled.fieldset(({ isFocused }) => {
9
9
  borderWidth: 2,
10
10
  }));
11
11
  });
12
+ const StyledInput = styled.input(() => {
13
+ return {
14
+ padding: 0,
15
+ backgroundColor: "transparent",
16
+ outline: "none",
17
+ border: "none",
18
+ height: "auto",
19
+ };
20
+ });
12
21
 
13
- export { Wrapper as default };
22
+ export { StyledInput, Wrapper };
@@ -6,7 +6,7 @@ export type Variant = "outlined" | "filled" | "standard";
6
6
  /**
7
7
  * @description component props
8
8
  */
9
- export interface Props {
9
+ export interface InputProps {
10
10
  label?: string;
11
11
  placeholder?: string;
12
12
  variant?: Variant;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { CircleRenderProps } from "./types";
2
+ import { CircleProps } from "./types";
3
3
  declare const Circle: import("@emotion/styled").StyledComponent<{
4
4
  theme?: import("@emotion/react").Theme | undefined;
5
5
  as?: import("react").ElementType<any> | undefined;
6
- } & CircleRenderProps, import("react").SVGProps<SVGCircleElement>, {}>;
6
+ } & CircleProps, import("react").SVGProps<SVGCircleElement>, {}>;
7
7
  export default Circle;
@@ -1,53 +1,8 @@
1
1
  import React from 'react';
2
2
  import { keyframes } from '@emotion/react';
3
3
  import Circle from './circle.js';
4
- import Wrapper from './wrapper.js';
4
+ import { Wrapper } from './styled.js';
5
5
 
6
- const left = keyframes `
7
- from {
8
- stroke-dasharray: 0 440;
9
- stroke-width: 20;
10
- stroke-dashoffset: 0;
11
- }
12
-
13
- 8% {
14
- stroke-dasharray: 40 400;
15
- stroke-width: 30;
16
- stroke-dashoffset: -5;
17
- }
18
-
19
- 28% {
20
- stroke-dasharray: 40 400;
21
- stroke-width: 30;
22
- stroke-dashoffset: -175;
23
- }
24
-
25
- 36%,
26
- 58% {
27
- stroke-dasharray: 0 440;
28
- stroke-width: 20;
29
- stroke-dashoffset: -220;
30
- }
31
-
32
- 66% {
33
- stroke-dasharray: 40 400;
34
- stroke-width: 30;
35
- stroke-dashoffset: -225;
36
- }
37
-
38
- 86% {
39
- stroke-dasharray: 40 400;
40
- stroke-width: 30;
41
- stroke-dashoffset: -395;
42
- }
43
-
44
- 94%,
45
- to {
46
- stroke-dasharray: 0 440;
47
- stroke-width: 20;
48
- stroke-dashoffset: -440;
49
- }
50
- `;
51
6
  const large = keyframes `
52
7
  from,
53
8
  4% {
@@ -140,6 +95,51 @@ const small = keyframes `
140
95
  stroke-dashoffset: -330;
141
96
  }
142
97
  `;
98
+ const left = keyframes `
99
+ from {
100
+ stroke-dasharray: 0 440;
101
+ stroke-width: 20;
102
+ stroke-dashoffset: 0;
103
+ }
104
+
105
+ 8% {
106
+ stroke-dasharray: 40 400;
107
+ stroke-width: 30;
108
+ stroke-dashoffset: -5;
109
+ }
110
+
111
+ 28% {
112
+ stroke-dasharray: 40 400;
113
+ stroke-width: 30;
114
+ stroke-dashoffset: -175;
115
+ }
116
+
117
+ 36%,
118
+ 58% {
119
+ stroke-dasharray: 0 440;
120
+ stroke-width: 20;
121
+ stroke-dashoffset: -220;
122
+ }
123
+
124
+ 66% {
125
+ stroke-dasharray: 40 400;
126
+ stroke-width: 30;
127
+ stroke-dashoffset: -225;
128
+ }
129
+
130
+ 86% {
131
+ stroke-dasharray: 40 400;
132
+ stroke-width: 30;
133
+ stroke-dashoffset: -395;
134
+ }
135
+
136
+ 94%,
137
+ to {
138
+ stroke-dasharray: 0 440;
139
+ stroke-width: 20;
140
+ stroke-dashoffset: -440;
141
+ }
142
+ `;
143
143
  const right = keyframes `
144
144
  from,
145
145
  8% {
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare const Wrapper: import("@emotion/styled").StyledComponent<{
2
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any> | undefined;
5
5
  }, import("react").SVGProps<SVGSVGElement>, {}>;
6
- export default Wrapper;
@@ -7,4 +7,4 @@ const Wrapper = styled.svg(() => {
7
7
  };
8
8
  });
9
9
 
10
- export { Wrapper as default };
10
+ export { Wrapper };
@@ -2,8 +2,8 @@
2
2
  * @author murukal
3
3
  *
4
4
  * @description
5
- * circle render props
5
+ * circle props
6
6
  */
7
- export interface CircleRenderProps {
7
+ export interface CircleProps {
8
8
  animationName: string;
9
9
  }
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ /**
3
+ * @author murukal
4
+ *
5
+ * @description
6
+ * menu group
7
+ */
8
+ declare const Group: React.ForwardRefExoticComponent<import("./types").MenuProps & import("./types").WithLevel & {
9
+ isCollapsed: boolean;
10
+ } & React.RefAttributes<HTMLUListElement>>;
11
+ export default Group;
@@ -0,0 +1,23 @@
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 Item from './item.js';
5
+
6
+ /**
7
+ * @author murukal
8
+ *
9
+ * @description
10
+ * menu group
11
+ */
12
+ const Group = forwardRef(({ items, level, isCollapsed }, ref) => {
13
+ /// 菜单条目渲染结果
14
+ const children = useMemo(() => {
15
+ return items.map((_a) => {
16
+ var { key } = _a, itemProps = __rest(_a, ["key"]);
17
+ return React.createElement(Item, Object.assign({ key: key, level: level }, itemProps));
18
+ });
19
+ }, [items, level]);
20
+ return (React.createElement(StyledMenuGroup, { ref: ref, isCollapsed: isCollapsed }, children));
21
+ });
22
+
23
+ export { Group as default };
@@ -1,6 +1,2 @@
1
- import { Props as MenuItemProps } from "../menu-item/types";
2
1
  import Menu from "./menu";
3
- export interface Props {
4
- items: MenuItemProps[];
5
- }
6
2
  export { Menu };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { MenuItemRenderProps } from "./types";
3
+ declare const Item: ({ level, label, children, prefix }: MenuItemRenderProps) => React.JSX.Element;
4
+ export default Item;
@@ -0,0 +1,33 @@
1
+ import React, { useMemo, 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
+
7
+ const Item = ({ level, label, children, prefix }) => {
8
+ /// has children
9
+ const hasChildren = useMemo(() => !!(children === null || children === void 0 ? void 0 : children.length), [children]);
10
+ const [scope, animate] = useAnimate();
11
+ /// if is collapsed
12
+ const { isOn: isCollapsed, toggle } = useBoolean(false);
13
+ /// if there are children, render trailing arrow
14
+ const collapser = useMemo(() => {
15
+ if (!hasChildren)
16
+ return null;
17
+ return React.createElement(StyledMenuItemCollapser, null, isCollapsed ? "展开" : "收起");
18
+ }, [hasChildren, isCollapsed]);
19
+ const onCollapserToggle = useCallback(() => {
20
+ animate(scope.current, {
21
+ height: isCollapsed ? "auto" : 0,
22
+ });
23
+ toggle();
24
+ }, [toggle, isCollapsed, animate]);
25
+ return (React.createElement("li", null,
26
+ React.createElement(StyledMenuItemWrapper, { level: level, onClick: onCollapserToggle },
27
+ !!prefix && React.createElement(StyledMenuItemPrefix, null, prefix),
28
+ label,
29
+ collapser),
30
+ hasChildren && React.createElement(Group, { ref: scope, items: children, level: level + 1, isCollapsed: isCollapsed })));
31
+ };
32
+
33
+ export { Item as default };
@@ -1,7 +1,10 @@
1
1
  import React from "react";
2
- import { Props } from "./index";
2
+ import type { MenuProps } from "./types";
3
3
  /**
4
4
  * @author murukal
5
+ *
6
+ * @description
7
+ * menu component
5
8
  */
6
- declare const Menu: (props: Props) => React.JSX.Element;
9
+ declare const Menu: (props: MenuProps) => React.JSX.Element;
7
10
  export default Menu;
package/dist/menu/menu.js CHANGED
@@ -1,17 +1,14 @@
1
- import React, { useMemo } from 'react';
2
- import MenuItem from '../menu-item/menu-item.js';
1
+ import React from 'react';
2
+ import Group from './group.js';
3
3
 
4
4
  /**
5
5
  * @author murukal
6
+ *
7
+ * @description
8
+ * menu component
6
9
  */
7
10
  const Menu = (props) => {
8
- /// 菜单条目渲染结果
9
- const items = useMemo(() => {
10
- return props.items.map((item) => {
11
- return React.createElement(MenuItem, Object.assign({}, item));
12
- });
13
- }, [props.items]);
14
- return React.createElement("ul", { className: "list-none m-0 p-0" }, items);
11
+ return React.createElement(Group, Object.assign({ level: 0 }, props, { isCollapsed: false }));
15
12
  };
16
13
 
17
14
  export { Menu as default };
@@ -0,0 +1,44 @@
1
+ /// <reference types="react" />
2
+ import { WithLevel } from "./types";
3
+ /**
4
+ * @author murukal
5
+ *
6
+ * @description
7
+ * styled menu item wrapper
8
+ */
9
+ export declare const StyledMenuItemWrapper: import("@emotion/styled").StyledComponent<{
10
+ theme?: import("@emotion/react").Theme | undefined;
11
+ as?: import("react").ElementType<any> | undefined;
12
+ } & WithLevel, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
13
+ /**
14
+ * @author murukal
15
+ *
16
+ * @description
17
+ * styled menu item prefix
18
+ */
19
+ export declare const StyledMenuItemPrefix: import("@emotion/styled").StyledComponent<{
20
+ theme?: import("@emotion/react").Theme | undefined;
21
+ as?: import("react").ElementType<any> | undefined;
22
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
23
+ /**
24
+ * @author murukal
25
+ *
26
+ * @description
27
+ * styled menu collapser
28
+ */
29
+ export declare const StyledMenuItemCollapser: import("@emotion/styled").StyledComponent<{
30
+ theme?: import("@emotion/react").Theme | undefined;
31
+ as?: import("react").ElementType<any> | undefined;
32
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
33
+ /**
34
+ * @author murukal
35
+ *
36
+ * @description
37
+ * styled menu group
38
+ */
39
+ export declare const StyledMenuGroup: import("@emotion/styled").StyledComponent<{
40
+ theme?: import("@emotion/react").Theme | undefined;
41
+ as?: import("react").ElementType<any> | undefined;
42
+ } & {
43
+ isCollapsed: boolean;
44
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
@@ -0,0 +1,65 @@
1
+ import styled from '@emotion/styled';
2
+ import { useTheme } from '../theme/hooks.js';
3
+
4
+ /**
5
+ * @author murukal
6
+ *
7
+ * @description
8
+ * styled menu item wrapper
9
+ */
10
+ const StyledMenuItemWrapper = styled.div(({ level }) => {
11
+ return {
12
+ display: "flex",
13
+ alignItems: "center",
14
+ minHeight: 24,
15
+ cursor: "pointer",
16
+ paddingTop: 8,
17
+ paddingBottom: 8,
18
+ paddingRight: 12,
19
+ paddingLeft: 12 + level * 24,
20
+ borderRadius: 8,
21
+ transition: "background-color 300ms",
22
+ ":hover": {
23
+ backgroundColor: "#f5f7fa",
24
+ },
25
+ };
26
+ });
27
+ /**
28
+ * @author murukal
29
+ *
30
+ * @description
31
+ * styled menu item prefix
32
+ */
33
+ const StyledMenuItemPrefix = styled.span(() => {
34
+ return {
35
+ marginRight: "0.5rem",
36
+ };
37
+ });
38
+ /**
39
+ * @author murukal
40
+ *
41
+ * @description
42
+ * styled menu collapser
43
+ */
44
+ const StyledMenuItemCollapser = styled.span(() => {
45
+ var _a, _b;
46
+ const theme = useTheme();
47
+ return Object.assign({ marginLeft: "auto" }, (_b = (_a = theme.typography) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.small);
48
+ });
49
+ /**
50
+ * @author murukal
51
+ *
52
+ * @description
53
+ * styled menu group
54
+ */
55
+ const StyledMenuGroup = styled.ul(({ isCollapsed }) => {
56
+ return {
57
+ margin: 0,
58
+ listStyleType: "none",
59
+ padding: 0,
60
+ width: 240,
61
+ overflow: "hidden",
62
+ };
63
+ });
64
+
65
+ export { StyledMenuGroup, StyledMenuItemCollapser, StyledMenuItemPrefix, StyledMenuItemWrapper };
@@ -0,0 +1,41 @@
1
+ import type { Key, ReactNode } from "react";
2
+ export interface WithLevel {
3
+ level: number;
4
+ }
5
+ /**
6
+ * @author murukal
7
+ *
8
+ * @description
9
+ * menu props
10
+ */
11
+ export interface MenuProps {
12
+ items: MenuItemProps[];
13
+ }
14
+ /**
15
+ * @author murukal
16
+ *
17
+ * @description
18
+ * menu item props
19
+ */
20
+ export interface MenuItemProps {
21
+ key: Key;
22
+ label?: string;
23
+ prefix?: ReactNode;
24
+ children?: MenuItemProps[];
25
+ }
26
+ /**
27
+ * @author murukal
28
+ *
29
+ * @description
30
+ * menu group render props
31
+ */
32
+ export type MenuGroupRenderProps = MenuProps & WithLevel & {
33
+ isCollapsed: boolean;
34
+ };
35
+ /**
36
+ * @author murukal
37
+ *
38
+ * @description
39
+ * menu item render props
40
+ */
41
+ export type MenuItemRenderProps = Omit<MenuItemProps, "key"> & WithLevel;
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef, useState, useImperativeHandle, useCallback } from 'react';
2
- import { HolderWrapper } from './wrappers.js';
2
+ import { HolderWrapper } from './styled.js';
3
3
  import Message from './message.js';
4
4
 
5
5
  const Holder = forwardRef((props, ref) => {
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import type { Props } from "./types";
3
- declare const Message: ({ duration, type, onHidden, id }: Props) => React.JSX.Element;
2
+ import type { MessageProps } from "./types";
3
+ declare const Message: ({ duration, type, onHidden, id }: MessageProps) => React.JSX.Element;
4
4
  export default Message;
@@ -1,4 +1,4 @@
1
- import { MessageWrapper } from './wrappers.js';
1
+ import { MessageWrapper } from './styled.js';
2
2
  import React from 'react';
3
3
  import { useTimeout } from '@aiszlab/relax';
4
4
 
@@ -11,9 +11,9 @@ export interface Messager {
11
11
  * @author murukal
12
12
  *
13
13
  * @description
14
- * props for message
14
+ * message props
15
15
  */
16
- export interface Props {
16
+ export interface MessageProps {
17
17
  id: string;
18
18
  type: "error" | "success" | "warning";
19
19
  duration: number;
@@ -26,5 +26,5 @@ export interface Props {
26
26
  * message ref
27
27
  */
28
28
  export interface MessageRef {
29
- add: (props: Props) => void;
29
+ add: (props: MessageProps) => void;
30
30
  }
@@ -0,0 +1,14 @@
1
+ function __rest(s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
4
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
6
+ }
7
+ return t;
8
+ }
9
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
10
+ var e = new Error(message);
11
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
12
+ };
13
+
14
+ export { __rest };
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import { Props } from "./types";
3
- declare const Popper: ({ children, isVisible, trigger }: Props) => React.ReactPortal | null;
2
+ import { type PopperProps } from "./types";
3
+ declare const Popper: ({ children, isVisible, trigger }: PopperProps) => React.ReactPortal | null;
4
4
  export default Popper;
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useEffect } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
  import { createPopper } from '@popperjs/core';
4
- import Wrapper from './wrapper.js';
4
+ import { Wrapper } from './styled.js';
5
5
 
6
6
  const Popper = ({ children, isVisible, trigger }) => {
7
7
  const ref = useRef(null);
@@ -1,7 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { WrapperProps } from "./types";
3
- declare const Wrapper: import("@emotion/styled").StyledComponent<{
3
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
4
4
  theme?: import("@emotion/react").Theme | undefined;
5
5
  as?: import("react").ElementType<any> | undefined;
6
6
  } & WrapperProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
7
- export default Wrapper;
@@ -6,4 +6,4 @@ const Wrapper = styled.div(({ isVisible }) => {
6
6
  };
7
7
  });
8
8
 
9
- export { Wrapper as default };
9
+ export { Wrapper };
@@ -1,16 +1,20 @@
1
1
  import type { ReactNode } from "react";
2
2
  /**
3
3
  * @author murukal
4
- * @description popper props
4
+ *
5
+ * @description
6
+ * popper props
5
7
  */
6
- export interface Props {
8
+ export interface PopperProps {
7
9
  children: ReactNode;
8
10
  isVisible: boolean;
9
11
  trigger?: Element | null;
10
12
  }
11
13
  /**
12
14
  * @author murukal
13
- * @description wrapper props
15
+ *
16
+ * @description
17
+ * wrapper props
14
18
  */
15
19
  export interface WrapperProps {
16
20
  isVisible: boolean;
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import { GroupRenderProps } from "./types";
3
- declare const Group: (props: GroupRenderProps) => React.JSX.Element;
2
+ import { RadioGroupProps } from "./types";
3
+ declare const Group: (props: RadioGroupProps) => React.JSX.Element;
4
4
  export default Group;
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import { RadioRenderProps } from "./types";
3
- declare const Radio: ({ value }: RadioRenderProps) => React.JSX.Element;
2
+ import { RadioProps } from "./types";
3
+ declare const Radio: ({ value }: RadioProps) => React.JSX.Element;
4
4
  export default Radio;
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useMemo, useCallback } from 'react';
2
- import Wrapper from './wrapper.js';
2
+ import { Wrapper } from './styled.js';
3
3
  import Context from './context.js';
4
4
 
5
5
  const Radio = ({ value }) => {
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare const Wrapper: import("@emotion/styled").StyledComponent<{
2
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any> | undefined;
5
5
  }, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
6
- export default Wrapper;
@@ -31,4 +31,4 @@ const Wrapper = styled.input(() => {
31
31
  };
32
32
  });
33
33
 
34
- export { Wrapper as default };
34
+ export { Wrapper };
@@ -13,9 +13,9 @@ export interface ContextValue {
13
13
  * @author murukal
14
14
  *
15
15
  * @description
16
- * group render props
16
+ * radio group props
17
17
  */
18
- export interface GroupRenderProps {
18
+ export interface RadioGroupProps {
19
19
  children: ReactNode;
20
20
  value?: string;
21
21
  }
@@ -23,8 +23,8 @@ export interface GroupRenderProps {
23
23
  * @author murukal
24
24
  *
25
25
  * @description
26
- * radio render props
26
+ * radio props
27
27
  */
28
- export interface RadioRenderProps {
28
+ export interface RadioProps {
29
29
  value: string;
30
30
  }
@@ -1,8 +1,9 @@
1
- import type { Props } from "./types";
1
+ import { MenuItemProps } from "../menu/types";
2
+ import type { SelectProps } from "./types";
2
3
  /**
3
4
  * @author murukal
4
5
  *
5
6
  * @description
6
7
  * options => menu items
7
8
  */
8
- export declare const useMenuItems: <Value extends string | number>([options]: [options: import("./types").Option<Value>[]]) => never[];
9
+ export declare const useMenuItems: <Value extends string | number>([options]: [options: import("./types").Option<Value>[]]) => MenuItemProps[];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @author murukal
3
+ *
4
+ * @description
5
+ * options => menu items
6
+ */
7
+ const useMenuItems = ([options]) => {
8
+ return [];
9
+ };
10
+
11
+ export { useMenuItems };
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import { Props } from "./types";
3
- declare const Select: <Value extends string | number>(props: Props<Value>) => React.JSX.Element;
2
+ import { type SelectProps } from "./types";
3
+ declare const Select: <Value extends string | number>(props: SelectProps<Value>) => React.JSX.Element;
4
4
  export default Select;
@@ -2,20 +2,18 @@ import React, { useRef } from 'react';
2
2
  import Popper from '../popper/popper.js';
3
3
  import { useBoolean } from '@aiszlab/relax';
4
4
  import Input from '../input/input.js';
5
+ import Menu from '../menu/menu.js';
6
+ import { useMenuItems } from './hooks.js';
5
7
 
6
8
  const Select = (props) => {
7
9
  var _a;
8
10
  const ref = useRef(null);
9
11
  const { isOn: isVisible, turnOn: open, turnOff: close } = useBoolean();
12
+ const menuItems = useMenuItems([props.options]);
10
13
  return (React.createElement(React.Fragment, null,
11
14
  React.createElement(Input, { ref: ref, type: "text", onFocus: open, onBlur: close }),
12
15
  React.createElement(Popper, { trigger: (_a = ref.current) === null || _a === void 0 ? void 0 : _a.wrapper, isVisible: isVisible },
13
- React.createElement("ul", { onMouseDown: (e) => {
14
- e.preventDefault();
15
- } },
16
- React.createElement("li", null, "12321"),
17
- React.createElement("li", null, "222"),
18
- React.createElement("li", null, "2333")))));
16
+ React.createElement(Menu, { items: menuItems }))));
19
17
  };
20
18
 
21
19
  export { Select as default };
@@ -8,6 +8,6 @@ export interface Option<T extends string | number> {
8
8
  * @description
9
9
  * select props
10
10
  */
11
- export interface Props<Value extends string | number> {
11
+ export interface SelectProps<Value extends string | number> {
12
12
  options: Option<Value>[];
13
13
  }
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare const Wrapper: import("@emotion/styled").StyledComponent<{
2
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any> | undefined;
5
5
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
- export default Wrapper;
@@ -34,4 +34,4 @@ const Wrapper = styled.div(() => {
34
34
  };
35
35
  });
36
36
 
37
- export { Wrapper as default };
37
+ export { Wrapper };
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback } from 'react';
2
- import Wrapper from './wrapper.js';
2
+ import { Wrapper } from './styled.js';
3
3
  import { useControlledState } from '@aiszlab/relax';
4
4
 
5
5
  const Switch = ({ value }) => {
@@ -1,4 +1,4 @@
1
- import { Theme } from "./types";
1
+ import type { Theme } from "./types";
2
2
  /**
3
3
  * @author murukal
4
4
  *
@@ -1,6 +1,83 @@
1
1
  import { useMemo } from 'react';
2
2
  import { useTheme as useTheme$1 } from '@emotion/react';
3
3
 
4
+ const palettes = {
5
+ primary: {
6
+ "0": "#000",
7
+ "10": "#21005D",
8
+ "20": "#381E72",
9
+ "30": "#4F378B",
10
+ "40": "#6750A4",
11
+ "50": "#7F67BE",
12
+ "60": "#9A82DB",
13
+ "70": "#B69DF8",
14
+ "80": "#D0BCFF",
15
+ "90": "#EADDFF",
16
+ "95": "#F6EDFF",
17
+ "99": "#FFFBFE",
18
+ "100": "#FFF",
19
+ },
20
+ secondary: {
21
+ "0": "#000",
22
+ "10": "#1D192B",
23
+ "20": "#332D41",
24
+ "30": "#4F378B",
25
+ "40": "#625B71",
26
+ "50": "#7A7289",
27
+ "60": "#958DA5",
28
+ "70": "#B0A7C0",
29
+ "80": "#CCC2DC",
30
+ "90": "#E8DEF8",
31
+ "95": "#F6EDFF",
32
+ "99": "#FFFBFE",
33
+ "100": "#FFF",
34
+ },
35
+ tertiary: {
36
+ "0": "#000",
37
+ "10": "#31111D",
38
+ "20": "#492532",
39
+ "30": "#633B48",
40
+ "40": "#7D5260",
41
+ "50": "#986977",
42
+ "60": "#B58392",
43
+ "70": "#D29DAC",
44
+ "80": "#EFB8C8",
45
+ "90": "#FFD8E4",
46
+ "95": "#FFECF1",
47
+ "99": "#FFFBFA",
48
+ "100": "#FFF",
49
+ },
50
+ error: {
51
+ "0": "#000",
52
+ "10": "#410E0B",
53
+ "20": "#601410",
54
+ "30": "#8C1D18",
55
+ "40": "#B3261E",
56
+ "50": "#DC362E",
57
+ "60": "#E46962",
58
+ "70": "#EC928E",
59
+ "80": "#F2B8B5",
60
+ "90": "#F9DEDC",
61
+ "95": "#FCEEEE",
62
+ "99": "#FFFBF9",
63
+ "100": "#FFF",
64
+ },
65
+ neutral: {
66
+ "0": "#000",
67
+ "10": "#1D1B20",
68
+ "20": "#48464C",
69
+ "30": "#48464C",
70
+ "40": "#605D64",
71
+ "50": "#79767D",
72
+ "60": "#938F96",
73
+ "70": "#AEA9B1",
74
+ "80": "#CAC5CD",
75
+ "90": "#E6E0E9",
76
+ "95": "#F5EFF7",
77
+ "99": "#FFFBFE",
78
+ "100": "#FFF",
79
+ },
80
+ };
4
81
  /**
5
82
  * @author murukal
6
83
  *
@@ -10,7 +87,10 @@ import { useTheme as useTheme$1 } from '@emotion/react';
10
87
  */
11
88
  const presets = {
12
89
  colors: {
13
- primary: "#6750a4",
90
+ primary: palettes.primary[40],
91
+ secondary: palettes.secondary[40],
92
+ tertiary: palettes.tertiary[40],
93
+ error: palettes.error[40],
14
94
  },
15
95
  typography: {
16
96
  body: {
@@ -53,6 +133,7 @@ const presets = {
53
133
  boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.30), 0px 8px 12px 6px rgba(0, 0, 0, 0.15)",
54
134
  },
55
135
  ],
136
+ palettes,
56
137
  };
57
138
  /**
58
139
  * @author murukal
@@ -9,7 +9,7 @@ type Elevation = Pick<CSSProperties, "boxShadow">;
9
9
  */
10
10
  export interface Theme {
11
11
  colors?: {
12
- primary?: string;
12
+ [key in ColorProperty]?: string;
13
13
  };
14
14
  typography?: {
15
15
  body?: {
@@ -22,6 +22,7 @@ export interface Theme {
22
22
  };
23
23
  };
24
24
  elevations?: [Elevation, Elevation, Elevation, Elevation, Elevation, Elevation];
25
+ palettes?: Palettes;
25
26
  }
26
27
  /**
27
28
  * @author murukal
@@ -33,4 +34,23 @@ export interface Props {
33
34
  children: ReactNode;
34
35
  theme: Theme;
35
36
  }
37
+ type ColorReference = {
38
+ [key in 0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 95 | 99 | 100]: string;
39
+ };
40
+ declare enum ColorProperty {
41
+ Primary = "primary",
42
+ Secondary = "secondary",
43
+ Tertiary = "tertiary",
44
+ Error = "error",
45
+ Neutral = "neutral"
46
+ }
47
+ /**
48
+ * @author murukal
49
+ *
50
+ * @description
51
+ * palettes
52
+ */
53
+ export type Palettes = {
54
+ [key in ColorProperty]: ColorReference;
55
+ };
36
56
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musae",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "musae-ui",
5
5
  "author": "tutu@fantufantu.com",
6
6
  "license": "MIT",
@@ -10,7 +10,8 @@
10
10
  "dev": "rollup -c -w",
11
11
  "build": "rollup -c",
12
12
  "clean:build": "rm -rf dist && rm -rf typings",
13
- "pub": "npm run clean:build && npm run build && npm publish"
13
+ "pub": "npm run clean:build && npm run build && npm publish",
14
+ "relink": "yarn unlink && yarn link"
14
15
  },
15
16
  "dependencies": {
16
17
  "@aiszlab/relax": "^1.0.14",
@@ -18,7 +19,8 @@
18
19
  "@emotion/styled": "^11.11.0",
19
20
  "@popperjs/core": "^2.11.8",
20
21
  "clsx": "^1.2.1",
21
- "deepmerge": "^4.3.1"
22
+ "deepmerge": "^4.3.1",
23
+ "framer-motion": "^10.16.1"
22
24
  },
23
25
  "devDependencies": {
24
26
  "@babel/core": "^7.22.5",
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- declare const StyledInput: import("@emotion/styled").StyledComponent<{
3
- theme?: import("@emotion/react").Theme | undefined;
4
- as?: import("react").ElementType<any> | undefined;
5
- }, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
6
- export default StyledInput;
@@ -1,13 +0,0 @@
1
- import styled from '@emotion/styled';
2
-
3
- const StyledInput = styled.input(() => {
4
- return {
5
- padding: 0,
6
- backgroundColor: "transparent",
7
- outline: "none",
8
- border: "none",
9
- height: "auto",
10
- };
11
- });
12
-
13
- export { StyledInput as default };
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import type { WrapperProps } from "./types";
3
- declare const Wrapper: import("@emotion/styled").StyledComponent<{
4
- theme?: import("@emotion/react").Theme | undefined;
5
- as?: import("react").ElementType<any> | undefined;
6
- } & WrapperProps, import("react").DetailedHTMLProps<import("react").FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, {}>;
7
- export default Wrapper;
@@ -1,2 +0,0 @@
1
- import MenuItem from "./menu-item";
2
- export { MenuItem };
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import type { Props } from "./types";
3
- declare const MenuItem: (props: Props) => React.JSX.Element;
4
- export default MenuItem;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import clsx from 'clsx';
3
-
4
- const MenuItem = (props) => {
5
- return React.createElement("li", { className: clsx([props.className]) }, props.children);
6
- };
7
-
8
- export { MenuItem as default };
@@ -1,11 +0,0 @@
1
- import type { ReactNode } from "react";
2
- /**
3
- * @author murukal
4
- *
5
- * @description
6
- * menu item props
7
- */
8
- export interface Props {
9
- children: ReactNode;
10
- className?: string;
11
- }
File without changes
File without changes