musae 0.0.16-0 → 0.1.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/dist/button/button.d.ts +10 -0
- package/dist/button/button.js +16 -0
- package/dist/button/index.d.ts +2 -0
- package/dist/button/span.d.ts +12 -0
- package/dist/button/span.js +16 -0
- package/dist/button/wrapper.d.ts +11 -0
- package/dist/button/wrapper.js +20 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +4 -1
- package/dist/input/hooks.d.ts +2 -3
- package/dist/input/hooks.js +4 -13
- package/dist/input/input.d.ts +2 -3
- package/dist/input/input.js +42 -20
- package/dist/input/label.d.ts +7 -0
- package/dist/input/label.js +14 -0
- package/dist/input/styled-input.d.ts +6 -0
- package/dist/input/styled-input.js +13 -0
- package/dist/input/wrapper.d.ts +7 -0
- package/dist/input/wrapper.js +13 -0
- package/dist/menu/index.d.ts +2 -2
- package/dist/menu/{Menu.js → menu.js} +1 -1
- package/dist/menu-item/index.d.ts +2 -6
- package/dist/menu-item/{MenuItem.d.ts → menu-item.d.ts} +1 -1
- package/dist/message/holder.d.ts +4 -0
- package/dist/message/holder.js +20 -0
- package/dist/message/hooks.d.ts +8 -0
- package/dist/message/hooks.js +30 -0
- package/dist/message/index.d.ts +1 -0
- package/dist/message/message.d.ts +4 -0
- package/dist/message/message.js +14 -0
- package/dist/message/wrappers.d.ts +22 -0
- package/dist/message/wrappers.js +33 -0
- package/dist/popper/index.d.ts +2 -0
- package/dist/popper/popper.d.ts +4 -0
- package/dist/popper/popper.js +29 -0
- package/dist/popper/wrapper.d.ts +7 -0
- package/dist/popper/wrapper.js +9 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/select.d.ts +3 -0
- package/dist/select/select.js +21 -0
- package/dist/theme/hooks.d.ts +19 -0
- package/dist/theme/hooks.js +75 -0
- package/dist/theme/theme-provider.d.ts +11 -0
- package/package.json +8 -4
- package/styles/input.css +0 -67
- /package/dist/menu/{Menu.d.ts → menu.d.ts} +0 -0
- /package/dist/menu-item/{MenuItem.js → menu-item.js} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Wrapper from './wrapper.js';
|
|
2
|
+
import Span from './span.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @author murukal
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* button
|
|
10
|
+
*/
|
|
11
|
+
const Button = ({ children, onClick }) => {
|
|
12
|
+
return (React.createElement(Wrapper, { onClick: onClick },
|
|
13
|
+
React.createElement(Span, null, children)));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { Button as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* @author murukal
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* content
|
|
7
|
+
*/
|
|
8
|
+
declare const Span: import("@emotion/styled").StyledComponent<{
|
|
9
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
10
|
+
as?: import("react").ElementType<any> | undefined;
|
|
11
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
12
|
+
export default Span;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { useTheme } from '../theme/hooks.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @author murukal
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
* content
|
|
9
|
+
*/
|
|
10
|
+
const Span = styled.span(() => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const theme = useTheme();
|
|
13
|
+
return Object.assign({ marginLeft: 8, marginRight: 8, color: "#fff" }, (_b = (_a = theme.typography) === null || _a === void 0 ? void 0 : _a.label) === null || _b === void 0 ? void 0 : _b.large);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { Span as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* @author murukal
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
*/
|
|
7
|
+
declare const Wrapper: import("@emotion/styled").StyledComponent<{
|
|
8
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
9
|
+
as?: import("react").ElementType<any> | undefined;
|
|
10
|
+
}, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
|
|
11
|
+
export default Wrapper;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { useTheme } from '../theme/hooks.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @author murukal
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
*/
|
|
9
|
+
const Wrapper = styled.button(() => {
|
|
10
|
+
var _a;
|
|
11
|
+
const theme = useTheme();
|
|
12
|
+
return {
|
|
13
|
+
borderRadius: 999,
|
|
14
|
+
padding: "10px 16px",
|
|
15
|
+
backgroundColor: (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
|
|
16
|
+
border: "none",
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export { Wrapper as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* components
|
|
4
|
+
*/
|
|
1
5
|
export { Avatar, AvatarFallback, AvatarImage } from "./avatar";
|
|
2
6
|
export { Menu, type Props as MenuProps } from "./menu";
|
|
3
7
|
export { Loading } from "./loading";
|
|
4
8
|
export { Input } from "./input";
|
|
9
|
+
export { Select } from "./select";
|
|
10
|
+
export { Button } from "./button";
|
|
11
|
+
/**
|
|
12
|
+
* @description
|
|
13
|
+
* hooks
|
|
14
|
+
*/
|
|
15
|
+
export { useMessage } from "./message";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { default as Avatar } from './avatar/Avatar.js';
|
|
2
2
|
export { default as AvatarImage } from './avatar/AvatarImage.js';
|
|
3
3
|
export { default as AvatarFallback } from './avatar/AvatarFallback.js';
|
|
4
|
-
export { default as Menu } from './menu/
|
|
4
|
+
export { default as Menu } from './menu/menu.js';
|
|
5
5
|
export { default as Loading } from './loading/Loading.js';
|
|
6
6
|
export { default as Input } from './input/input.js';
|
|
7
|
+
export { default as Select } from './select/select.js';
|
|
8
|
+
export { default as Button } from './button/button.js';
|
|
9
|
+
export { useMessage } from './message/hooks.js';
|
package/dist/input/hooks.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { Variant } from "./types";
|
|
|
2
2
|
/**
|
|
3
3
|
* @description class name for input
|
|
4
4
|
*/
|
|
5
|
-
export declare const useStyles: ([variant, isFocused
|
|
6
|
-
|
|
7
|
-
wrapper: string;
|
|
5
|
+
export declare const useStyles: ([variant, isFocused]: [variant: Variant, isFocused: boolean]) => {
|
|
6
|
+
wrapperClassName: string;
|
|
8
7
|
};
|
package/dist/input/hooks.js
CHANGED
|
@@ -4,24 +4,15 @@ import clsx from 'clsx';
|
|
|
4
4
|
/**
|
|
5
5
|
* @description class name for input
|
|
6
6
|
*/
|
|
7
|
-
const useStyles = ([variant, isFocused
|
|
8
|
-
/// input
|
|
9
|
-
const input = useMemo(() => {
|
|
10
|
-
return clsx({
|
|
11
|
-
["musae-input"]: true,
|
|
12
|
-
["musae-input-focused"]: !hasWrapper && isFocused,
|
|
13
|
-
});
|
|
14
|
-
}, [isFocused, hasWrapper]);
|
|
7
|
+
const useStyles = ([variant, isFocused]) => {
|
|
15
8
|
/// wrapper
|
|
16
|
-
const
|
|
9
|
+
const wrapperClassName = useMemo(() => {
|
|
17
10
|
return clsx({
|
|
18
11
|
["musae-input-wrapper"]: true,
|
|
19
|
-
["musae-input-wrapper-focused"]: isFocused,
|
|
20
12
|
});
|
|
21
|
-
}, [
|
|
13
|
+
}, []);
|
|
22
14
|
return {
|
|
23
|
-
|
|
24
|
-
wrapper,
|
|
15
|
+
wrapperClassName,
|
|
25
16
|
};
|
|
26
17
|
};
|
|
27
18
|
|
package/dist/input/input.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import "
|
|
3
|
-
import type { Props } from "./types";
|
|
2
|
+
import type { InputRef, Props } from "./types";
|
|
4
3
|
/**
|
|
5
4
|
* @author murukal
|
|
6
5
|
* @description input component
|
|
7
6
|
*/
|
|
8
|
-
declare const Input: React.ForwardRefExoticComponent<Props & React.RefAttributes<
|
|
7
|
+
declare const Input: React.ForwardRefExoticComponent<Props & React.RefAttributes<InputRef>>;
|
|
9
8
|
export default Input;
|
package/dist/input/input.js
CHANGED
|
@@ -1,37 +1,59 @@
|
|
|
1
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
1
|
+
import React, { forwardRef, useRef, useImperativeHandle, useMemo } from 'react';
|
|
2
2
|
import { useStyles } from './hooks.js';
|
|
3
|
-
import '../../styles/input.css';
|
|
4
3
|
import { useBoolean } from '@aiszlab/relax';
|
|
4
|
+
import Label from './label.js';
|
|
5
|
+
import Wrapper from './wrapper.js';
|
|
6
|
+
import StyledInput from './styled-input.js';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* @author murukal
|
|
8
10
|
* @description input component
|
|
9
11
|
*/
|
|
10
12
|
const Input = forwardRef((props, ref) => {
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const inputRef = useRef(null);
|
|
14
|
+
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
|
+
useImperativeHandle(ref, () => ({
|
|
24
|
+
input: inputRef.current,
|
|
25
|
+
wrapper: wrapperRef.current,
|
|
26
|
+
}));
|
|
27
|
+
/// is focused
|
|
15
28
|
const { isOn: isFocused, turnOn: focus, turnOff: blur } = useBoolean();
|
|
29
|
+
/// variant
|
|
16
30
|
const variant = useMemo(() => props.variant || "outlined", [props.variant]);
|
|
17
|
-
|
|
31
|
+
/// style
|
|
32
|
+
const { wrapperClassName } = useStyles([variant, isFocused]);
|
|
33
|
+
/// used input props
|
|
18
34
|
const inputProps = useMemo(() => {
|
|
19
35
|
return {
|
|
20
|
-
onFocus:
|
|
21
|
-
|
|
36
|
+
onFocus: (event) => {
|
|
37
|
+
var _a;
|
|
38
|
+
focus();
|
|
39
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
40
|
+
},
|
|
41
|
+
onBlur: (event) => {
|
|
42
|
+
var _a;
|
|
43
|
+
blur();
|
|
44
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
45
|
+
},
|
|
22
46
|
type: props.type || "text",
|
|
23
|
-
ref:
|
|
24
|
-
className:
|
|
47
|
+
ref: inputRef,
|
|
48
|
+
className: "musae-input",
|
|
25
49
|
};
|
|
26
|
-
}, [focus, blur, props.type,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
return React.createElement("input", Object.assign({}, inputProps));
|
|
50
|
+
}, [focus, blur, props.type, props.onFocus, props.onBlur]);
|
|
51
|
+
/// render
|
|
52
|
+
return (React.createElement(Wrapper, { ref: wrapperRef, className: wrapperClassName, isFocused: isFocused },
|
|
53
|
+
props.prefix,
|
|
54
|
+
!!props.label && (React.createElement(Label, { isFocused: isFocused, className: "musae-input-label" }, props.label)),
|
|
55
|
+
React.createElement(StyledInput, Object.assign({}, inputProps)),
|
|
56
|
+
props.suffix));
|
|
35
57
|
});
|
|
36
58
|
|
|
37
59
|
export { Input as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { LabelProps } from "./types";
|
|
3
|
+
declare const Label: import("@emotion/styled").StyledComponent<{
|
|
4
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
5
|
+
as?: import("react").ElementType<any> | undefined;
|
|
6
|
+
} & LabelProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>, {}>;
|
|
7
|
+
export default Label;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { useTheme } from '../theme/hooks.js';
|
|
3
|
+
|
|
4
|
+
const Label = styled.legend(({ isFocused }) => {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
return Object.assign(Object.assign(Object.assign({}, (_b = (_a = theme.typography) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.small), {
|
|
8
|
+
// layout
|
|
9
|
+
paddingInlineStart: 4, paddingInlineEnd: 4 }), (isFocused && {
|
|
10
|
+
color: (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.primary,
|
|
11
|
+
}));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { Label as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { useTheme } from '../theme/hooks.js';
|
|
3
|
+
|
|
4
|
+
const Wrapper = styled.fieldset(({ isFocused }) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
return Object.assign({ textAlign: "start", height: 56, margin: 0, paddingTop: 0, paddingBottom: 0, display: "flex", alignItems: "center", borderColor: "#79747e", borderWidth: 1, borderStyle: "solid", borderRadius: 4, boxSizing: "border-box" }, (isFocused && {
|
|
8
|
+
borderColor: (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
|
|
9
|
+
borderWidth: 2,
|
|
10
|
+
}));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { Wrapper as default };
|
package/dist/menu/index.d.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { forwardRef, useState, useImperativeHandle, useCallback } from 'react';
|
|
2
|
+
import { HolderWrapper } from './wrappers.js';
|
|
3
|
+
import Message from './message.js';
|
|
4
|
+
|
|
5
|
+
const Holder = forwardRef((props, ref) => {
|
|
6
|
+
const [messages, setMessages] = useState([]);
|
|
7
|
+
useImperativeHandle(ref, () => ({
|
|
8
|
+
add: (props) => {
|
|
9
|
+
setMessages([...messages, props]);
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
/// remove message
|
|
13
|
+
const hidden = useCallback((id) => setMessages((messages) => messages.filter((message) => message.id !== id)), []);
|
|
14
|
+
if (messages.length === 0) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return (React.createElement(HolderWrapper, null, messages.map((item) => (React.createElement(Message, Object.assign({ onHidden: hidden, key: item.id }, item))))));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export { Holder as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useRef, useState, useCallback } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import Holder from './holder.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @author murukal
|
|
7
|
+
* @description hook for message
|
|
8
|
+
*/
|
|
9
|
+
const useMessage = () => {
|
|
10
|
+
const ref = useRef(null);
|
|
11
|
+
const [holder] = useState(() => {
|
|
12
|
+
return createPortal(React.createElement(Holder, { ref: ref }), document.body);
|
|
13
|
+
});
|
|
14
|
+
const error = useCallback(() => {
|
|
15
|
+
var _a;
|
|
16
|
+
return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.add({
|
|
17
|
+
id: crypto.randomUUID(),
|
|
18
|
+
type: "error",
|
|
19
|
+
duration: 3000,
|
|
20
|
+
});
|
|
21
|
+
}, []);
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
error,
|
|
25
|
+
},
|
|
26
|
+
holder,
|
|
27
|
+
];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useMessage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useMessage } from "./hooks";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MessageWrapper } from './wrappers.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useTimeout } from '@aiszlab/relax';
|
|
4
|
+
|
|
5
|
+
const Message = ({ duration, type, onHidden, id }) => {
|
|
6
|
+
useTimeout(() => {
|
|
7
|
+
onHidden === null || onHidden === void 0 ? void 0 : onHidden(id);
|
|
8
|
+
}, {
|
|
9
|
+
duration,
|
|
10
|
+
});
|
|
11
|
+
return React.createElement(MessageWrapper, null, type);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { Message as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* @author murukal
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* wrapper of holder
|
|
7
|
+
*/
|
|
8
|
+
declare const HolderWrapper: import("@emotion/styled").StyledComponent<{
|
|
9
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
10
|
+
as?: import("react").ElementType<any> | undefined;
|
|
11
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
12
|
+
/**
|
|
13
|
+
* @author murukal
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* wrapper of message
|
|
17
|
+
*/
|
|
18
|
+
declare const MessageWrapper: import("@emotion/styled").StyledComponent<{
|
|
19
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
20
|
+
as?: import("react").ElementType<any> | undefined;
|
|
21
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
22
|
+
export { HolderWrapper, MessageWrapper };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { useTheme } from '../theme/hooks.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @author murukal
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
* wrapper of holder
|
|
9
|
+
*/
|
|
10
|
+
const HolderWrapper = styled.div(() => {
|
|
11
|
+
return {
|
|
12
|
+
position: "fixed",
|
|
13
|
+
top: "8px",
|
|
14
|
+
display: "flex",
|
|
15
|
+
flexDirection: "column",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
width: "100vw",
|
|
18
|
+
pointerEvents: "none",
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* @author murukal
|
|
23
|
+
*
|
|
24
|
+
* @description
|
|
25
|
+
* wrapper of message
|
|
26
|
+
*/
|
|
27
|
+
const MessageWrapper = styled.div(() => {
|
|
28
|
+
var _a;
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
return Object.assign({ marginTop: 8, marginBottom: 8, padding: "8px 12px", borderRadius: 6, backgroundColor: "#ffffff" }, (_a = theme.elevations) === null || _a === void 0 ? void 0 : _a[1]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export { HolderWrapper, MessageWrapper };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { createPopper } from '@popperjs/core';
|
|
4
|
+
import Wrapper from './wrapper.js';
|
|
5
|
+
|
|
6
|
+
const Popper = ({ children, isVisible, trigger }) => {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!isVisible)
|
|
10
|
+
return void 0;
|
|
11
|
+
if (!trigger)
|
|
12
|
+
return void 0;
|
|
13
|
+
if (!ref.current)
|
|
14
|
+
return void 0;
|
|
15
|
+
const popper = createPopper(trigger, ref.current, {
|
|
16
|
+
placement: "bottom",
|
|
17
|
+
});
|
|
18
|
+
return () => {
|
|
19
|
+
popper.destroy();
|
|
20
|
+
};
|
|
21
|
+
}, [isVisible, trigger]);
|
|
22
|
+
/// destory after hide
|
|
23
|
+
if (!isVisible) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return createPortal(React.createElement(Wrapper, { ref: ref, isVisible: isVisible }, children), document.body);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { Popper as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
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").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
7
|
+
export default Wrapper;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import Popper from '../popper/popper.js';
|
|
3
|
+
import { useBoolean } from '@aiszlab/relax';
|
|
4
|
+
import Input from '../input/input.js';
|
|
5
|
+
|
|
6
|
+
const Select = () => {
|
|
7
|
+
var _a;
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
const { isOn: isVisible, turnOn: open, turnOff: close } = useBoolean();
|
|
10
|
+
return (React.createElement(React.Fragment, null,
|
|
11
|
+
React.createElement(Input, { ref: ref, type: "text", onFocus: open, onBlur: close }),
|
|
12
|
+
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")))));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { Select as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Theme } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* @author murukal
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* we set some presets theme
|
|
7
|
+
* let ui components display well
|
|
8
|
+
*/
|
|
9
|
+
export declare const presets: Theme;
|
|
10
|
+
/**
|
|
11
|
+
* @author murukal
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* hook wrapper for emotion theme hook
|
|
15
|
+
* because emotion theme has the default value
|
|
16
|
+
* but the default value can not be changed
|
|
17
|
+
* set the preset theme for musae ui component
|
|
18
|
+
*/
|
|
19
|
+
export declare const useTheme: () => Theme;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useTheme as useTheme$1 } from '@emotion/react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @author murukal
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
* we set some presets theme
|
|
9
|
+
* let ui components display well
|
|
10
|
+
*/
|
|
11
|
+
const presets = {
|
|
12
|
+
colors: {
|
|
13
|
+
primary: "#6750a4",
|
|
14
|
+
},
|
|
15
|
+
typography: {
|
|
16
|
+
body: {
|
|
17
|
+
small: {
|
|
18
|
+
fontSize: 12,
|
|
19
|
+
fontWeight: 400,
|
|
20
|
+
lineHeight: "16px",
|
|
21
|
+
},
|
|
22
|
+
large: {
|
|
23
|
+
fontSize: 16,
|
|
24
|
+
fontWeight: 400,
|
|
25
|
+
lineHeight: "24px",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
label: {
|
|
29
|
+
large: {
|
|
30
|
+
fontSize: 14,
|
|
31
|
+
fontWeight: 500,
|
|
32
|
+
lineHeight: "20px",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
elevations: [
|
|
37
|
+
{
|
|
38
|
+
boxShadow: "none",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
boxShadow: "0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
boxShadow: "0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
boxShadow: "0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15)",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
boxShadow: "0px 2px 3px 0px rgba(0, 0, 0, 0.30), 0px 6px 10px 4px rgba(0, 0, 0, 0.15)",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.30), 0px 8px 12px 6px rgba(0, 0, 0, 0.15)",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* @author murukal
|
|
59
|
+
*
|
|
60
|
+
* @description
|
|
61
|
+
* hook wrapper for emotion theme hook
|
|
62
|
+
* because emotion theme has the default value
|
|
63
|
+
* but the default value can not be changed
|
|
64
|
+
* set the preset theme for musae ui component
|
|
65
|
+
*/
|
|
66
|
+
const useTheme = () => {
|
|
67
|
+
// emotion theme
|
|
68
|
+
const theme = useTheme$1();
|
|
69
|
+
// if theme is empty
|
|
70
|
+
const isThemeEmpty = useMemo(() => Object.keys(theme).length === 0, [theme]);
|
|
71
|
+
// when is empty, we always think there are not any theme. use presets!!!
|
|
72
|
+
return useMemo(() => (isThemeEmpty ? presets : theme), [theme, isThemeEmpty]);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export { presets, useTheme };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import type { Props } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* @author murukal
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* theme provider
|
|
8
|
+
* if user provider theme, we will merge it with presets theme
|
|
9
|
+
*/
|
|
10
|
+
declare const ThemeProvider: FC<Props>;
|
|
11
|
+
export default ThemeProvider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musae",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "musae-ui",
|
|
5
5
|
"author": "tutu@fantufantu.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,11 +10,15 @@
|
|
|
10
10
|
"dev": "rollup -c -w",
|
|
11
11
|
"build": "rollup -c",
|
|
12
12
|
"clean:build": "rm -rf dist && rm -rf typings",
|
|
13
|
-
"
|
|
13
|
+
"pub": "npm run clean:build && npm run build && npm publish"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@aiszlab/relax": "^1.0.
|
|
17
|
-
"
|
|
16
|
+
"@aiszlab/relax": "^1.0.11",
|
|
17
|
+
"@emotion/react": "^11.11.1",
|
|
18
|
+
"@emotion/styled": "^11.11.0",
|
|
19
|
+
"@popperjs/core": "^2.11.8",
|
|
20
|
+
"clsx": "^1.2.1",
|
|
21
|
+
"deepmerge": "^4.3.1"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
24
|
"@babel/core": "^7.22.5",
|
package/styles/input.css
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
.musae-input,
|
|
2
|
-
.musae-input-wrapper {
|
|
3
|
-
/* border */
|
|
4
|
-
border-radius: 4px;
|
|
5
|
-
border-width: 1px;
|
|
6
|
-
border-style: solid;
|
|
7
|
-
border-color: #79747e;
|
|
8
|
-
|
|
9
|
-
/* layout */
|
|
10
|
-
box-sizing: border-box;
|
|
11
|
-
height: 56px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.musae-input {
|
|
15
|
-
padding: 4px 0 4px 16px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.musae-input-wrapper {
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: row;
|
|
21
|
-
align-items: center;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.musae-input-wrapper > .musae-input {
|
|
25
|
-
outline: none;
|
|
26
|
-
border: 0;
|
|
27
|
-
height: auto;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.musae-input-wrapper::before {
|
|
31
|
-
content: attr(aria-label);
|
|
32
|
-
position: absolute;
|
|
33
|
-
padding: 0 4px 0 4px;
|
|
34
|
-
background-color: #fff;
|
|
35
|
-
line-height: 16px;
|
|
36
|
-
font-size: 14px;
|
|
37
|
-
color: #49454f;
|
|
38
|
-
transform: translateX(8px) translateY(-28px);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/* prefix */
|
|
42
|
-
|
|
43
|
-
.musae-input-prefix,
|
|
44
|
-
.musae-input-suffix {
|
|
45
|
-
width: 48px;
|
|
46
|
-
height: 48px;
|
|
47
|
-
display: flex;
|
|
48
|
-
flex-direction: row;
|
|
49
|
-
justify-content: center;
|
|
50
|
-
align-items: center;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.musae-input-prefix + .musae-input {
|
|
54
|
-
padding-left: 0;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* style change after focused */
|
|
58
|
-
|
|
59
|
-
.musae-input-focused,
|
|
60
|
-
.musae-input-wrapper-focused {
|
|
61
|
-
border-color: #6750a4;
|
|
62
|
-
border-width: 2px;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.musae-input-wrapper-focused::before {
|
|
66
|
-
color: #6750a4;
|
|
67
|
-
}
|
|
File without changes
|
|
File without changes
|