musae 0.1.18 → 0.1.19
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/components/breadcrumb/breadcrumb.js +3 -3
- package/dist/components/breadcrumb/styled.js +11 -6
- package/dist/components/button/button.js +1 -3
- package/dist/components/button/styled.js +36 -23
- package/dist/components/button/types.d.ts +6 -1
- package/dist/components/checkbox/checkbox.js +3 -4
- package/dist/components/checkbox/styled.js +2 -2
- package/dist/components/chip/chip.d.ts +4 -0
- package/dist/components/chip/chip.js +10 -0
- package/dist/components/chip/hooks.d.ts +7 -0
- package/dist/components/chip/hooks.js +20 -0
- package/dist/components/chip/styled.d.ts +10 -0
- package/dist/components/chip/styled.js +22 -0
- package/dist/components/chip/types.d.ts +25 -0
- package/dist/components/config/context.d.ts +1 -1
- package/dist/components/config/context.js +5 -1
- package/dist/components/config/provider.js +2 -0
- package/dist/components/config/types.d.ts +19 -1
- package/dist/components/divider/divider.d.ts +1 -1
- package/dist/components/divider/divider.js +6 -4
- package/dist/components/divider/hooks.d.ts +14 -0
- package/dist/components/divider/hooks.js +36 -0
- package/dist/components/divider/styled.js +35 -4
- package/dist/components/divider/types.d.ts +27 -0
- package/dist/components/drawer/drawer.d.ts +4 -0
- package/dist/components/drawer/types.d.ts +12 -0
- package/dist/components/empty/empty.d.ts +7 -0
- package/dist/components/empty/empty.js +21 -0
- package/dist/components/empty/hooks.d.ts +7 -0
- package/dist/components/empty/hooks.js +20 -0
- package/dist/components/empty/index.d.ts +2 -0
- package/dist/components/empty/styled.d.ts +9 -0
- package/dist/components/empty/styled.js +25 -0
- package/dist/components/form/context.d.ts +5 -0
- package/dist/components/form/context.js +9 -0
- package/dist/components/form/field.d.ts +20 -0
- package/dist/components/form/field.js +70 -0
- package/dist/components/form/form.d.ts +5 -0
- package/dist/components/form/form.js +60 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +8 -0
- package/dist/components/form/item.d.ts +8 -0
- package/dist/components/form/item.js +15 -0
- package/dist/components/form/styled.d.ts +25 -0
- package/dist/components/form/styled.js +40 -0
- package/dist/components/form/types.d.ts +124 -0
- package/dist/components/grid/col.js +1 -1
- package/dist/components/grid/row.js +3 -2
- package/dist/components/grid/styled.js +1 -1
- package/dist/components/icons/selected.d.ts +4 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/input/context.d.ts +8 -0
- package/dist/components/input/context.js +9 -0
- package/dist/components/input/hooks.d.ts +26 -2
- package/dist/components/input/hooks.js +68 -6
- package/dist/components/input/input.d.ts +1 -1
- package/dist/components/input/input.js +32 -36
- package/dist/components/input/styled.d.ts +14 -2
- package/dist/components/input/styled.js +58 -15
- package/dist/components/input/types.d.ts +71 -13
- package/dist/components/menu/group.js +9 -11
- package/dist/components/menu/menu.d.ts +1 -1
- package/dist/components/menu/menu.js +7 -7
- package/dist/components/menu/styled.js +18 -6
- package/dist/components/menu/types.d.ts +42 -5
- package/dist/components/message/holder.js +1 -1
- package/dist/components/message/hooks.js +2 -4
- package/dist/components/message/message.js +1 -1
- package/dist/components/message/styled.js +9 -3
- package/dist/components/popper/popper.d.ts +1 -1
- package/dist/components/popper/popper.js +6 -6
- package/dist/components/popper/styled.d.ts +2 -2
- package/dist/components/popper/types.d.ts +31 -3
- package/dist/components/radio/radio.js +3 -3
- package/dist/components/radio/styled.js +20 -15
- package/dist/components/select/hooks.d.ts +22 -3
- package/dist/components/select/hooks.js +70 -4
- package/dist/components/select/select.d.ts +2 -2
- package/dist/components/select/select.js +37 -10
- package/dist/components/select/styled.d.ts +18 -0
- package/dist/components/select/styled.js +34 -0
- package/dist/components/select/types.d.ts +38 -4
- package/dist/components/select/utils.d.ts +12 -0
- package/dist/components/select/utils.js +26 -0
- package/dist/components/switch/styled.js +3 -3
- package/dist/components/tabs/item.js +2 -2
- package/dist/components/tabs/styled.d.ts +2 -2
- package/dist/components/tabs/styled.js +3 -3
- package/dist/components/tabs/tabs.js +7 -9
- package/dist/types/element.d.ts +39 -0
- package/dist/types/lib.d.ts +5 -0
- package/dist/utils/class-name.d.ts +10 -0
- package/dist/utils/class-name.js +14 -0
- package/package.json +11 -3
- package/dist/node_modules/tslib/tslib.es6.js +0 -14
|
@@ -2,17 +2,17 @@ import React, { useMemo, isValidElement } from 'react';
|
|
|
2
2
|
import { StyledSeparator, StyledNav } from './styled.js';
|
|
3
3
|
|
|
4
4
|
const _SEPARATOR = "/";
|
|
5
|
+
const _ROLE = "separator";
|
|
5
6
|
const Breadcrumb = (props) => {
|
|
6
7
|
/// render the children
|
|
7
8
|
const _children = useMemo(() => {
|
|
8
|
-
|
|
9
|
-
const _separator = (_a = props.separator) !== null && _a !== void 0 ? _a : _SEPARATOR;
|
|
9
|
+
const _separator = props.separator ?? _SEPARATOR;
|
|
10
10
|
return props.items.map((_item, _index) => {
|
|
11
11
|
const _isLastElement = _index === props.items.length - 1;
|
|
12
12
|
const _isReactElement = isValidElement(_item.label);
|
|
13
13
|
return [
|
|
14
14
|
React.createElement("li", { key: _index }, _isReactElement ? (_item.label) : _item.href ? (React.createElement("a", { href: _item.href }, _item.label)) : (React.createElement("span", null, _item.label))),
|
|
15
|
-
!_isLastElement && (React.createElement(StyledSeparator, { key:
|
|
15
|
+
!_isLastElement && (React.createElement(StyledSeparator, { key: `${_ROLE}${_index}`, role: _ROLE }, _separator)),
|
|
16
16
|
];
|
|
17
17
|
});
|
|
18
18
|
}, [props.items, props.separator]);
|
|
@@ -2,8 +2,12 @@ import styled from '@emotion/styled';
|
|
|
2
2
|
import { useValidTheme } from '../theme/hooks.js';
|
|
3
3
|
|
|
4
4
|
const StyledNav = styled.nav(({ theme }) => {
|
|
5
|
-
const
|
|
6
|
-
return
|
|
5
|
+
const _theme = useValidTheme(theme);
|
|
6
|
+
return {
|
|
7
|
+
color: _theme.palettes.neutral[30],
|
|
8
|
+
// typography
|
|
9
|
+
..._theme.typography.label.large,
|
|
10
|
+
ol: {
|
|
7
11
|
listStyle: "none",
|
|
8
12
|
display: "flex",
|
|
9
13
|
flexWrap: "wrap",
|
|
@@ -13,15 +17,16 @@ const StyledNav = styled.nav(({ theme }) => {
|
|
|
13
17
|
transition: "all 200ms",
|
|
14
18
|
borderRadius: 4,
|
|
15
19
|
":hover": {
|
|
16
|
-
color:
|
|
17
|
-
backgroundColor:
|
|
20
|
+
color: _theme.palettes.neutral[10],
|
|
21
|
+
backgroundColor: _theme.palettes.neutral[95],
|
|
18
22
|
},
|
|
19
23
|
},
|
|
20
24
|
":last-of-type": {
|
|
21
|
-
color:
|
|
25
|
+
color: _theme.palettes.neutral[10],
|
|
22
26
|
},
|
|
23
27
|
},
|
|
24
|
-
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
25
30
|
});
|
|
26
31
|
const StyledSeparator = styled.li(() => {
|
|
27
32
|
return {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
1
|
import { StyledWrapper, StyledSpan } from './styled.js';
|
|
3
2
|
import React, { forwardRef, useMemo } from 'react';
|
|
4
3
|
|
|
@@ -8,8 +7,7 @@ import React, { forwardRef, useMemo } from 'react';
|
|
|
8
7
|
* @description
|
|
9
8
|
* button
|
|
10
9
|
*/
|
|
11
|
-
const Button = forwardRef((
|
|
12
|
-
var { children, className, onClick, style } = _a, props = __rest(_a, ["children", "className", "onClick", "style"]);
|
|
10
|
+
const Button = forwardRef(({ children, className, onClick, style, ...props }, ref) => {
|
|
13
11
|
/// get which variant is using
|
|
14
12
|
/// variant determin style
|
|
15
13
|
const variant = useMemo(() => props.variant || "filled", [props.variant]);
|
|
@@ -2,26 +2,35 @@ import styled from '@emotion/styled';
|
|
|
2
2
|
import { useValidTheme } from '../theme/hooks.js';
|
|
3
3
|
|
|
4
4
|
const StyledWrapper = styled.button(({ theme, variant, color }) => {
|
|
5
|
-
const
|
|
6
|
-
const _primaryColor =
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
const _theme = useValidTheme(theme);
|
|
6
|
+
const _primaryColor = _theme.palettes[color][40];
|
|
7
|
+
return {
|
|
8
|
+
borderRadius: 999,
|
|
9
|
+
padding: "0.625rem 1.5rem",
|
|
10
|
+
// filled variant style
|
|
11
|
+
...(variant === "filled" && {
|
|
12
|
+
backgroundColor: _primaryColor,
|
|
13
|
+
border: "none",
|
|
14
|
+
span: {
|
|
15
|
+
color: _theme.palettes.primary[100],
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
// outlined variant style
|
|
19
|
+
...(variant === "outlined" && {
|
|
20
|
+
borderWidth: 1,
|
|
21
|
+
borderStyle: "solid",
|
|
22
|
+
borderColor: _theme.palettes.neutral[50],
|
|
23
|
+
span: {
|
|
24
|
+
color: _primaryColor,
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
// text variant style
|
|
28
|
+
...(variant === "text" && {
|
|
29
|
+
span: {
|
|
30
|
+
color: _primaryColor,
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
25
34
|
});
|
|
26
35
|
/**
|
|
27
36
|
* @author murukal
|
|
@@ -30,9 +39,13 @@ const StyledWrapper = styled.button(({ theme, variant, color }) => {
|
|
|
30
39
|
* content
|
|
31
40
|
*/
|
|
32
41
|
const StyledSpan = styled.span(({ theme }) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
const _theme = useValidTheme(theme);
|
|
43
|
+
return {
|
|
44
|
+
marginLeft: 8,
|
|
45
|
+
marginRight: 8,
|
|
46
|
+
/// typography
|
|
47
|
+
..._theme.typography.label.large,
|
|
48
|
+
};
|
|
36
49
|
});
|
|
37
50
|
|
|
38
51
|
export { StyledSpan, StyledWrapper };
|
|
@@ -7,8 +7,13 @@ export type Color = "primary" | "secondary" | "neutral";
|
|
|
7
7
|
* @description
|
|
8
8
|
* button render props
|
|
9
9
|
*/
|
|
10
|
-
export interface ButtonProps {
|
|
10
|
+
export interface ButtonProps extends Partial<Pick<HTMLButtonElement, "type">> {
|
|
11
11
|
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* variant
|
|
15
|
+
* @example filled
|
|
16
|
+
*/
|
|
12
17
|
variant?: Variant;
|
|
13
18
|
/**
|
|
14
19
|
* @description
|
|
@@ -12,12 +12,11 @@ const Checkbox = (props) => {
|
|
|
12
12
|
/// if there is context value, use context value
|
|
13
13
|
/// else use controlled state
|
|
14
14
|
const isChecked = useMemo(() => {
|
|
15
|
-
var _a;
|
|
16
15
|
if (contextValue) {
|
|
17
|
-
return !!
|
|
16
|
+
return !!contextValue.value?.get(props.value || id);
|
|
18
17
|
}
|
|
19
18
|
return _isChecked;
|
|
20
|
-
}, [contextValue
|
|
19
|
+
}, [contextValue?.value]);
|
|
21
20
|
/// change handler
|
|
22
21
|
/// if there is context value, just notify context
|
|
23
22
|
/// else change the controlled state
|
|
@@ -27,7 +26,7 @@ const Checkbox = (props) => {
|
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
_setIsChecked(event.target.checked);
|
|
30
|
-
}, [_setIsChecked, contextValue
|
|
29
|
+
}, [_setIsChecked, contextValue?.onChange]);
|
|
31
30
|
return React.createElement(StyledWrapper, { type: "checkbox", checked: !!isChecked, "aria-checked": !!isChecked, onChange: change });
|
|
32
31
|
};
|
|
33
32
|
|
|
@@ -2,8 +2,8 @@ import styled from '@emotion/styled';
|
|
|
2
2
|
import { useValidTheme } from '../theme/hooks.js';
|
|
3
3
|
|
|
4
4
|
const StyledWrapper = styled.input(({ theme }) => {
|
|
5
|
-
const
|
|
6
|
-
const primaryColor =
|
|
5
|
+
const _theme = useValidTheme(theme);
|
|
6
|
+
const primaryColor = _theme.palettes.primary[40];
|
|
7
7
|
return {
|
|
8
8
|
margin: 0,
|
|
9
9
|
visibility: "hidden",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyledSpan } from './styled.js';
|
|
3
|
+
import { useClassNames } from './hooks.js';
|
|
4
|
+
|
|
5
|
+
const Chip = ({ children, size = "large" }) => {
|
|
6
|
+
const classNames = useClassNames();
|
|
7
|
+
return (React.createElement(StyledSpan, { size: size, className: classNames.chip }, children));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { Chip as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import Context from '../config/context.js';
|
|
3
|
+
import { withPrefix } from '../../utils/class-name.js';
|
|
4
|
+
|
|
5
|
+
var ClassName;
|
|
6
|
+
(function (ClassName) {
|
|
7
|
+
ClassName["Chip"] = "chip";
|
|
8
|
+
})(ClassName || (ClassName = {}));
|
|
9
|
+
/**
|
|
10
|
+
* @description
|
|
11
|
+
* class names
|
|
12
|
+
*/
|
|
13
|
+
const useClassNames = () => {
|
|
14
|
+
const { prefix } = useContext(Context);
|
|
15
|
+
return useMemo(() => ({
|
|
16
|
+
chip: withPrefix(prefix, ClassName.Chip),
|
|
17
|
+
}), [prefix]);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { useClassNames };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ChipRenderProps } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* span with style
|
|
6
|
+
*/
|
|
7
|
+
export declare const StyledSpan: import("@emotion/styled").StyledComponent<{
|
|
8
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
9
|
+
as?: import("react").ElementType<any> | undefined;
|
|
10
|
+
} & ChipRenderProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { useValidTheme } from '../theme/hooks.js';
|
|
3
|
+
|
|
4
|
+
const PADDING_X = new Map().set("small", 8);
|
|
5
|
+
const PADDING_Y = new Map().set("small", 4);
|
|
6
|
+
const RADIUS = new Map().set("small", 4);
|
|
7
|
+
/**
|
|
8
|
+
* @description
|
|
9
|
+
* span with style
|
|
10
|
+
*/
|
|
11
|
+
const StyledSpan = styled.span(({ size, ...props }) => {
|
|
12
|
+
const theme = useValidTheme(props.theme);
|
|
13
|
+
return {
|
|
14
|
+
paddingInline: PADDING_X.get(size) ?? 16,
|
|
15
|
+
paddingBlock: PADDING_Y.get(size) ?? 8,
|
|
16
|
+
borderRadius: RADIUS.get(size) ?? 8,
|
|
17
|
+
backgroundColor: theme.palettes.primary[90],
|
|
18
|
+
...theme.typography.label[size],
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export { StyledSpan };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type Size = "small" | "large";
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* chip props
|
|
6
|
+
*/
|
|
7
|
+
export interface ChipProps {
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* children
|
|
11
|
+
*/
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* @description
|
|
15
|
+
* size
|
|
16
|
+
*/
|
|
17
|
+
size?: Size;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @description
|
|
21
|
+
* chip render props
|
|
22
|
+
*/
|
|
23
|
+
export interface ChipRenderProps extends Required<Pick<ChipProps, "size">> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import Context from './context.js';
|
|
2
2
|
import { useMessage } from '../message/hooks.js';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { PREFIX_MUSAE } from '../../utils/class-name.js';
|
|
4
5
|
|
|
5
6
|
const _Provider = Context.Provider;
|
|
6
7
|
const ConfigProvider = (props) => {
|
|
7
8
|
const [, messageHolder] = useMessage();
|
|
8
9
|
return (React.createElement(_Provider, { value: {
|
|
9
10
|
messageHolder,
|
|
11
|
+
prefix: props.prefix || PREFIX_MUSAE,
|
|
10
12
|
} },
|
|
11
13
|
props.children,
|
|
12
14
|
messageHolder));
|
|
@@ -5,7 +5,16 @@ import { ReactNode, ReactPortal } from "react";
|
|
|
5
5
|
* config context value
|
|
6
6
|
*/
|
|
7
7
|
export interface ContextValue {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* message holder
|
|
11
|
+
*/
|
|
12
|
+
messageHolder: ReactPortal | null;
|
|
13
|
+
/**
|
|
14
|
+
* @description
|
|
15
|
+
* prefix
|
|
16
|
+
*/
|
|
17
|
+
prefix: string;
|
|
9
18
|
}
|
|
10
19
|
/**
|
|
11
20
|
* @description
|
|
@@ -13,5 +22,14 @@ export interface ContextValue {
|
|
|
13
22
|
* config props
|
|
14
23
|
*/
|
|
15
24
|
export interface ConfigProps {
|
|
25
|
+
/**
|
|
26
|
+
* @description
|
|
27
|
+
* children
|
|
28
|
+
*/
|
|
16
29
|
children?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* @description
|
|
32
|
+
* prefix
|
|
33
|
+
*/
|
|
34
|
+
prefix?: string;
|
|
17
35
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
1
|
import { StyledWrapper } from './styled.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useClassNames, useOffset } from './hooks.js';
|
|
3
4
|
|
|
4
|
-
const Divider = (
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const Divider = ({ align, children }) => {
|
|
6
|
+
const classNames = useClassNames();
|
|
7
|
+
const offset = useOffset([align]);
|
|
8
|
+
return (React.createElement(StyledWrapper, { className: classNames.divider, hasChildren: !!children, offset: offset }, !!children && React.createElement("span", { className: classNames.content }, children)));
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export { Divider as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Align } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* class name with prefix
|
|
5
|
+
*/
|
|
6
|
+
export declare const useClassNames: () => {
|
|
7
|
+
divider: string;
|
|
8
|
+
content: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @description
|
|
12
|
+
* offset for children
|
|
13
|
+
*/
|
|
14
|
+
export declare const useOffset: ([align]: [align: Align | undefined]) => 50 | 95 | 5;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import Context from '../config/context.js';
|
|
3
|
+
import { withPrefix } from '../../utils/class-name.js';
|
|
4
|
+
|
|
5
|
+
var ClassName;
|
|
6
|
+
(function (ClassName) {
|
|
7
|
+
ClassName["Divider"] = "divider";
|
|
8
|
+
ClassName["Context"] = "content";
|
|
9
|
+
})(ClassName || (ClassName = {}));
|
|
10
|
+
const OFFSET = new Map([
|
|
11
|
+
["center", 50],
|
|
12
|
+
["left", 5],
|
|
13
|
+
["right", 95],
|
|
14
|
+
]);
|
|
15
|
+
/**
|
|
16
|
+
* @description
|
|
17
|
+
* class name with prefix
|
|
18
|
+
*/
|
|
19
|
+
const useClassNames = () => {
|
|
20
|
+
const { prefix } = useContext(Context);
|
|
21
|
+
return useMemo(() => ({
|
|
22
|
+
divider: withPrefix(prefix, ClassName.Divider),
|
|
23
|
+
content: withPrefix(prefix, ClassName.Context),
|
|
24
|
+
}), [prefix]);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @description
|
|
28
|
+
* offset for children
|
|
29
|
+
*/
|
|
30
|
+
const useOffset = ([align]) => {
|
|
31
|
+
return useMemo(() => {
|
|
32
|
+
return OFFSET.get(align ?? "center") ?? 50;
|
|
33
|
+
}, [align]);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { useClassNames, useOffset };
|
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
+
import { useClassNames } from './hooks.js';
|
|
3
|
+
import { useValidTheme } from '../theme/hooks.js';
|
|
2
4
|
|
|
3
|
-
const StyledWrapper = styled.div(({ hasChildren }) => {
|
|
5
|
+
const StyledWrapper = styled.div(({ hasChildren, offset, ...props }) => {
|
|
6
|
+
const classNames = useClassNames();
|
|
7
|
+
const theme = useValidTheme(props.theme);
|
|
8
|
+
const layoutStyle = {
|
|
9
|
+
width: "100%",
|
|
10
|
+
};
|
|
11
|
+
const dividerStyle = {
|
|
12
|
+
height: 1,
|
|
13
|
+
backgroundColor: "#cac4d0",
|
|
14
|
+
};
|
|
4
15
|
if (!hasChildren) {
|
|
5
16
|
return {
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
...layoutStyle,
|
|
18
|
+
...dividerStyle,
|
|
8
19
|
};
|
|
9
20
|
}
|
|
10
|
-
return {
|
|
21
|
+
return {
|
|
22
|
+
...layoutStyle,
|
|
23
|
+
display: "flex",
|
|
24
|
+
flexDirection: "row",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
"::before": {
|
|
27
|
+
...dividerStyle,
|
|
28
|
+
width: `${offset}%`,
|
|
29
|
+
content: "''",
|
|
30
|
+
},
|
|
31
|
+
"::after": {
|
|
32
|
+
...dividerStyle,
|
|
33
|
+
width: `${100 - offset}%`,
|
|
34
|
+
content: "''",
|
|
35
|
+
},
|
|
36
|
+
[`.${classNames.content}`]: {
|
|
37
|
+
marginInline: 8,
|
|
38
|
+
whiteSpace: "nowrap",
|
|
39
|
+
...theme.typography.body.small,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
11
42
|
});
|
|
12
43
|
|
|
13
44
|
export { StyledWrapper };
|
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
export type Align = "center" | "left" | "right";
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* divider props
|
|
6
|
+
*/
|
|
2
7
|
export interface DividerProps {
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* children
|
|
11
|
+
*/
|
|
3
12
|
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* @description
|
|
15
|
+
* align
|
|
16
|
+
*/
|
|
17
|
+
align?: Align;
|
|
4
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* @description
|
|
21
|
+
* divider render props
|
|
22
|
+
*/
|
|
5
23
|
export interface DividerRenderProps {
|
|
24
|
+
/**
|
|
25
|
+
* @description
|
|
26
|
+
* if there is child
|
|
27
|
+
*/
|
|
6
28
|
hasChildren: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @description
|
|
31
|
+
* offset
|
|
32
|
+
*/
|
|
33
|
+
offset: number;
|
|
7
34
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyledWrapper } from './styled.js';
|
|
3
|
+
import { useClassNames } from './hooks.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* empty component
|
|
8
|
+
*/
|
|
9
|
+
const Empty = () => {
|
|
10
|
+
const classNames = useClassNames();
|
|
11
|
+
return (React.createElement(StyledWrapper, null,
|
|
12
|
+
React.createElement("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg" },
|
|
13
|
+
React.createElement("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd" },
|
|
14
|
+
React.createElement("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }),
|
|
15
|
+
React.createElement("g", { fillRule: "nonzero", stroke: "#d9d9d9" },
|
|
16
|
+
React.createElement("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }),
|
|
17
|
+
React.createElement("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", fill: "#fafafa" })))),
|
|
18
|
+
React.createElement("div", { className: classNames.description }, "\u6682\u65E0\u6570\u636E")));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { Empty as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import Context from '../config/context.js';
|
|
3
|
+
import { withPrefix } from '../../utils/class-name.js';
|
|
4
|
+
|
|
5
|
+
var ClassName;
|
|
6
|
+
(function (ClassName) {
|
|
7
|
+
ClassName["Description"] = "empty-description";
|
|
8
|
+
})(ClassName || (ClassName = {}));
|
|
9
|
+
/**
|
|
10
|
+
* @description
|
|
11
|
+
* class names
|
|
12
|
+
*/
|
|
13
|
+
const useClassNames = () => {
|
|
14
|
+
const { prefix } = useContext(Context);
|
|
15
|
+
return useMemo(() => ({
|
|
16
|
+
description: withPrefix(prefix, ClassName.Description),
|
|
17
|
+
}), [prefix]);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { useClassNames };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* wrapper
|
|
5
|
+
*/
|
|
6
|
+
export declare const StyledWrapper: import("@emotion/styled").StyledComponent<{
|
|
7
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
8
|
+
as?: import("react").ElementType<any> | undefined;
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { useClassNames } from './hooks.js';
|
|
3
|
+
import { useValidTheme } from '../theme/hooks.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* wrapper
|
|
8
|
+
*/
|
|
9
|
+
const StyledWrapper = styled.div(({ theme }) => {
|
|
10
|
+
const classNames = useClassNames();
|
|
11
|
+
const _theme = useValidTheme(theme);
|
|
12
|
+
return {
|
|
13
|
+
display: "flex",
|
|
14
|
+
flexDirection: "column",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
marginBlock: 32,
|
|
17
|
+
marginInline: 8,
|
|
18
|
+
[`.${classNames.description}`]: {
|
|
19
|
+
marginTop: 8,
|
|
20
|
+
..._theme.typography.body.small,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { StyledWrapper };
|