@rainbow-oh/yee-c 0.1.0 → 0.2.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/cjs/Alert/alert.js +10 -4
- package/dist/cjs/Alert/style/index.less +3 -0
- package/dist/cjs/Anchor/anchor-item.js +6 -4
- package/dist/cjs/Anchor/anchor.js +38 -22
- package/dist/cjs/Anchor/demo/auto.d.ts +11 -0
- package/dist/cjs/Anchor/demo/auto.js +85 -0
- package/dist/cjs/Anchor/demo/basic.js +7 -1
- package/dist/cjs/Anchor/demo/controlled.js +42 -30
- package/dist/cjs/Anchor/interface.d.ts +2 -0
- package/dist/cjs/Anchor/style/index.less +2 -2
- package/dist/cjs/Button/button.d.ts +1 -1
- package/dist/cjs/Checkbox/checkbox-group.js +4 -1
- package/dist/cjs/Checkbox/demo/group.js +1 -0
- package/dist/cjs/Checkbox/interface.d.ts +5 -0
- package/dist/cjs/Checkbox/style/index.less +21 -1
- package/dist/cjs/Dropdown/demo/placement.js +2 -1
- package/dist/cjs/Dropdown/dropdown.js +3 -0
- package/dist/cjs/Dropdown/style/index.less +6 -0
- package/dist/cjs/Form/Field.js +33 -3
- package/dist/cjs/Form/Group.js +3 -2
- package/dist/cjs/Form/demo/form-table.js +1 -8
- package/dist/cjs/Form/demo/tooltip.d.ts +3 -0
- package/dist/cjs/Form/demo/tooltip.js +84 -0
- package/dist/cjs/Form/interface.d.ts +34 -1
- package/dist/cjs/Form/style/index.less +22 -7
- package/dist/cjs/Popconfirm/popconfirm.js +1 -1
- package/dist/cjs/Popconfirm/style/index.less +6 -0
- package/dist/cjs/Popover/popover.js +1 -1
- package/dist/cjs/Popover/style/index.less +6 -0
- package/dist/cjs/Progress/progress.js +2 -2
- package/dist/cjs/Radio/style/index.less +13 -6
- package/dist/cjs/Select/option.js +3 -2
- package/dist/cjs/Select/options.js +9 -1
- package/dist/cjs/Select/select.js +1 -0
- package/dist/cjs/Skeleton/demo/basic.js +1 -1
- package/dist/cjs/Space/interface.d.ts +4 -0
- package/dist/cjs/Space/space.js +36 -16
- package/dist/cjs/Splitter/demo/basic.js +1 -1
- package/dist/cjs/Splitter/demo/vertical.js +23 -1
- package/dist/cjs/Splitter/index.d.ts +1 -1
- package/dist/cjs/Splitter/interface.d.ts +9 -3
- package/dist/cjs/Splitter/splitter-handler.d.ts +1 -1
- package/dist/cjs/Splitter/splitter-handler.js +2 -1
- package/dist/cjs/Splitter/splitter.d.ts +2 -9
- package/dist/cjs/Splitter/splitter.js +53 -50
- package/dist/cjs/Splitter/style/index.less +21 -0
- package/dist/cjs/Table/demo/size.js +1 -1
- package/dist/cjs/Tabs/hooks/useTabScroll.d.ts +1 -1
- package/dist/cjs/Tabs/interface.d.ts +1 -1
- package/dist/cjs/Tabs/style/index.less +4 -0
- package/dist/cjs/Tabs/tab-header/index.js +56 -25
- package/dist/cjs/Tooltip/interface.d.ts +4 -0
- package/dist/cjs/Tooltip/style/index.less +8 -8
- package/dist/cjs/Tooltip/tooltip.js +11 -3
- package/dist/cjs/Tree/demo/draggable.d.ts +3 -0
- package/dist/cjs/Tree/demo/draggable.js +88 -0
- package/dist/cjs/Tree/demo/expanded.js +6 -6
- package/dist/cjs/Tree/index.d.ts +1 -0
- package/dist/cjs/Tree/index.js +3 -1
- package/dist/cjs/Tree/interface.d.ts +26 -0
- package/dist/cjs/Tree/style/index.less +25 -0
- package/dist/cjs/Tree/tree-node.js +38 -4
- package/dist/cjs/Tree/tree.d.ts +12 -1
- package/dist/cjs/Tree/tree.js +174 -18
- package/dist/cjs/Tree/utils/tree-tools.d.ts +21 -0
- package/dist/cjs/Tree/utils/tree-tools.js +88 -0
- package/dist/cjs/Trigger/style/index.less +17 -0
- package/dist/cjs/Trigger/trigger.js +3 -1
- package/dist/cjs/hooks/useDebounceFunction.d.ts +1 -1
- package/dist/cjs/hooks/useLayoutEffect.d.ts +1 -1
- package/dist/cjs/style/size.css +13 -4
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +14 -5
- package/dist/cjs/utils/debounce.d.ts +6 -1
- package/dist/cjs/utils/debounce.js +9 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Alert/alert.js +24 -8
- package/dist/esm/Alert/style/index.less +3 -0
- package/dist/esm/Anchor/anchor-item.js +6 -3
- package/dist/esm/Anchor/anchor.js +38 -19
- package/dist/esm/Anchor/demo/auto.d.ts +11 -0
- package/dist/esm/Anchor/demo/auto.js +62 -0
- package/dist/esm/Anchor/demo/basic.js +3 -1
- package/dist/esm/Anchor/demo/controlled.js +14 -9
- package/dist/esm/Anchor/interface.d.ts +2 -0
- package/dist/esm/Anchor/style/index.less +2 -2
- package/dist/esm/Button/button.d.ts +1 -1
- package/dist/esm/Checkbox/checkbox-group.js +4 -2
- package/dist/esm/Checkbox/demo/group.js +1 -0
- package/dist/esm/Checkbox/interface.d.ts +5 -0
- package/dist/esm/Checkbox/style/index.less +21 -1
- package/dist/esm/Dropdown/demo/placement.js +2 -1
- package/dist/esm/Dropdown/dropdown.js +6 -1
- package/dist/esm/Dropdown/style/index.less +6 -0
- package/dist/esm/Form/Field.js +43 -5
- package/dist/esm/Form/Group.js +4 -2
- package/dist/esm/Form/demo/form-table.js +8 -6
- package/dist/esm/Form/demo/tooltip.d.ts +3 -0
- package/dist/esm/Form/demo/tooltip.js +59 -0
- package/dist/esm/Form/interface.d.ts +34 -1
- package/dist/esm/Form/style/index.less +22 -7
- package/dist/esm/Popconfirm/popconfirm.js +3 -1
- package/dist/esm/Popconfirm/style/index.less +6 -0
- package/dist/esm/Popover/popover.js +3 -1
- package/dist/esm/Popover/style/index.less +6 -0
- package/dist/esm/Progress/progress.js +5 -5
- package/dist/esm/Radio/style/index.less +13 -6
- package/dist/esm/Select/option.js +4 -2
- package/dist/esm/Select/options.js +5 -3
- package/dist/esm/Select/select.js +1 -0
- package/dist/esm/Skeleton/demo/basic.js +2 -8
- package/dist/esm/Space/interface.d.ts +4 -0
- package/dist/esm/Space/space.js +24 -13
- package/dist/esm/Splitter/demo/basic.js +2 -0
- package/dist/esm/Splitter/demo/vertical.js +13 -5
- package/dist/esm/Splitter/index.d.ts +1 -1
- package/dist/esm/Splitter/interface.d.ts +9 -3
- package/dist/esm/Splitter/splitter-handler.d.ts +1 -1
- package/dist/esm/Splitter/splitter-handler.js +3 -1
- package/dist/esm/Splitter/splitter.d.ts +2 -9
- package/dist/esm/Splitter/splitter.js +59 -56
- package/dist/esm/Splitter/style/index.less +21 -0
- package/dist/esm/Table/demo/size.js +2 -7
- package/dist/esm/Tabs/hooks/useTabScroll.d.ts +1 -1
- package/dist/esm/Tabs/interface.d.ts +1 -1
- package/dist/esm/Tabs/style/index.less +4 -0
- package/dist/esm/Tabs/tab-header/index.js +11 -5
- package/dist/esm/Tooltip/interface.d.ts +4 -0
- package/dist/esm/Tooltip/style/index.less +8 -8
- package/dist/esm/Tooltip/tooltip.js +14 -2
- package/dist/esm/Tree/demo/draggable.d.ts +3 -0
- package/dist/esm/Tree/demo/draggable.js +61 -0
- package/dist/esm/Tree/demo/expanded.js +6 -6
- package/dist/esm/Tree/index.d.ts +1 -0
- package/dist/esm/Tree/index.js +1 -0
- package/dist/esm/Tree/interface.d.ts +26 -0
- package/dist/esm/Tree/style/index.less +25 -0
- package/dist/esm/Tree/tree-node.js +29 -4
- package/dist/esm/Tree/tree.d.ts +12 -1
- package/dist/esm/Tree/tree.js +135 -4
- package/dist/esm/Tree/utils/tree-tools.d.ts +21 -0
- package/dist/esm/Tree/utils/tree-tools.js +128 -1
- package/dist/esm/Trigger/style/index.less +17 -0
- package/dist/esm/Trigger/trigger.js +4 -3
- package/dist/esm/hooks/useDebounceFunction.d.ts +1 -1
- package/dist/esm/hooks/useLayoutEffect.d.ts +1 -1
- package/dist/esm/style/size.css +13 -4
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +14 -5
- package/dist/esm/utils/debounce.d.ts +6 -1
- package/dist/esm/utils/debounce.js +9 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +2 -2
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +21 -23
- package/src/Alert/alert.tsx +10 -4
- package/src/Alert/style/index.less +3 -0
- package/src/Anchor/anchor-item.tsx +7 -2
- package/src/Anchor/anchor.tsx +49 -23
- package/src/Anchor/demo/auto.tsx +55 -0
- package/src/Anchor/demo/basic.tsx +7 -1
- package/src/Anchor/demo/controlled.tsx +18 -14
- package/src/Anchor/index.en-US.md +17 -0
- package/src/Anchor/index.zh-CN.md +17 -0
- package/src/Anchor/interface.ts +2 -0
- package/src/Anchor/style/index.less +2 -2
- package/src/Checkbox/checkbox-group.tsx +5 -1
- package/src/Checkbox/demo/group.tsx +1 -0
- package/src/Checkbox/interface.ts +5 -0
- package/src/Checkbox/style/index.less +21 -1
- package/src/Dropdown/demo/placement.tsx +1 -0
- package/src/Dropdown/dropdown.tsx +2 -0
- package/src/Dropdown/style/index.less +6 -0
- package/src/Form/Field.tsx +45 -3
- package/src/Form/Group.tsx +4 -1
- package/src/Form/demo/form-table.tsx +7 -7
- package/src/Form/demo/tooltip.tsx +72 -0
- package/src/Form/form-store.ts +1 -1
- package/src/Form/index.en-US.md +2 -0
- package/src/Form/index.zh-CN.md +83 -85
- package/src/Form/interface.ts +36 -1
- package/src/Form/style/index.less +22 -7
- package/src/Popconfirm/popconfirm.tsx +1 -1
- package/src/Popconfirm/style/index.less +6 -0
- package/src/Popover/popover.tsx +1 -1
- package/src/Popover/style/index.less +6 -0
- package/src/Progress/progress.tsx +2 -2
- package/src/Radio/style/index.less +13 -6
- package/src/Select/option.tsx +2 -1
- package/src/Select/options.tsx +7 -2
- package/src/Select/select.tsx +1 -0
- package/src/Skeleton/demo/basic.tsx +3 -3
- package/src/Space/interface.ts +4 -0
- package/src/Space/space.tsx +40 -16
- package/src/Splitter/demo/basic.tsx +2 -2
- package/src/Splitter/demo/vertical.tsx +19 -5
- package/src/Splitter/index.ts +5 -1
- package/src/Splitter/interface.ts +10 -3
- package/src/Splitter/splitter-handler.tsx +4 -2
- package/src/Splitter/splitter.tsx +55 -60
- package/src/Splitter/style/index.less +21 -0
- package/src/Table/demo/size.tsx +3 -3
- package/src/Table/index.zh-CN.md +50 -50
- package/src/Tabs/interface.ts +1 -1
- package/src/Tabs/style/index.less +4 -0
- package/src/Tabs/tab-header/index.tsx +26 -5
- package/src/Tooltip/index.en-US.md +1 -0
- package/src/Tooltip/index.zh-CN.md +1 -0
- package/src/Tooltip/interface.ts +4 -0
- package/src/Tooltip/style/index.less +8 -8
- package/src/Tooltip/tooltip.tsx +10 -1
- package/src/Tree/demo/draggable.tsx +58 -0
- package/src/Tree/demo/expanded.tsx +7 -7
- package/src/Tree/index.en-US.md +3 -0
- package/src/Tree/index.ts +1 -0
- package/src/Tree/index.zh-CN.md +3 -0
- package/src/Tree/interface.ts +28 -0
- package/src/Tree/style/index.less +25 -0
- package/src/Tree/tree-node.tsx +26 -0
- package/src/Tree/tree.tsx +183 -2
- package/src/Tree/utils/tree-tools.ts +107 -0
- package/src/Trigger/style/index.less +17 -0
- package/src/Trigger/trigger.tsx +3 -1
- package/src/style/size.css +13 -4
- package/src/utils/debounce.ts +22 -3
- package/src/version.ts +1 -1
|
@@ -9,15 +9,9 @@
|
|
|
9
9
|
gap: var(--yee-radio-group-gap);
|
|
10
10
|
|
|
11
11
|
&-small {
|
|
12
|
-
@{pls} {
|
|
13
|
-
padding: var(--yee-radio-small-padding, 2px 4px);
|
|
14
|
-
}
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
&-large {
|
|
18
|
-
@{pls} {
|
|
19
|
-
padding: var(--yee-radio-large-padding, 6px 12px);
|
|
20
|
-
}
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
&-solid {
|
|
@@ -67,6 +61,19 @@
|
|
|
67
61
|
content: '';
|
|
68
62
|
}
|
|
69
63
|
|
|
64
|
+
&::before {
|
|
65
|
+
position: absolute;
|
|
66
|
+
z-index: 1;
|
|
67
|
+
right: 5px;
|
|
68
|
+
top: 14px;
|
|
69
|
+
width: 4px;
|
|
70
|
+
height: 8px;
|
|
71
|
+
border: 2px solid #fff;
|
|
72
|
+
border-width: 0 2px 2px 0;
|
|
73
|
+
transform: rotate(45deg);
|
|
74
|
+
content: '';
|
|
75
|
+
}
|
|
76
|
+
|
|
70
77
|
z-index: 1;
|
|
71
78
|
}
|
|
72
79
|
|
package/src/Select/option.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import React, { useContext } from 'react';
|
|
|
4
4
|
import { OptionsCtx } from './options';
|
|
5
5
|
|
|
6
6
|
const Option = (props: any) => {
|
|
7
|
-
const { label, value, disabled, title } = props;
|
|
7
|
+
const { label, value, disabled, title, dataTestId } = props;
|
|
8
8
|
const { prefixCls, selectedKeys, focusedKey, onSelect } =
|
|
9
9
|
useContext(OptionsCtx);
|
|
10
10
|
|
|
@@ -37,6 +37,7 @@ const Option = (props: any) => {
|
|
|
37
37
|
role="option"
|
|
38
38
|
tabIndex={disabled ? undefined : 0}
|
|
39
39
|
title={htmlTitle}
|
|
40
|
+
data-testid={dataTestId}
|
|
40
41
|
>
|
|
41
42
|
{label}
|
|
42
43
|
</div>
|
package/src/Select/options.tsx
CHANGED
|
@@ -16,6 +16,7 @@ const Options = forwardRef((props: any, ref: React.Ref<HTMLDivElement>) => {
|
|
|
16
16
|
popupStyle,
|
|
17
17
|
selectedKeys,
|
|
18
18
|
focusedKey,
|
|
19
|
+
dataTestId,
|
|
19
20
|
onSelect,
|
|
20
21
|
...rest
|
|
21
22
|
} = props;
|
|
@@ -37,8 +38,12 @@ const Options = forwardRef((props: any, ref: React.Ref<HTMLDivElement>) => {
|
|
|
37
38
|
<OptionsCtx.Provider
|
|
38
39
|
value={{ prefixCls, selectedKeys, focusedKey, onSelect }}
|
|
39
40
|
>
|
|
40
|
-
{options.map((option: any) => (
|
|
41
|
-
<Option
|
|
41
|
+
{options.map((option: any, index: number) => (
|
|
42
|
+
<Option
|
|
43
|
+
{...option}
|
|
44
|
+
key={option.value}
|
|
45
|
+
dataTestId={`${dataTestId}-${index}`}
|
|
46
|
+
/>
|
|
42
47
|
))}
|
|
43
48
|
</OptionsCtx.Provider>
|
|
44
49
|
)}
|
package/src/Select/select.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Card, Skeleton
|
|
1
|
+
import { Card, Skeleton } from '@rainbow-oh/yee-c';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
export default () => {
|
|
5
5
|
return (
|
|
6
|
-
<
|
|
6
|
+
<div>
|
|
7
7
|
<Card title="Basic Placeholder">
|
|
8
8
|
<Skeleton />
|
|
9
9
|
</Card>
|
|
@@ -19,6 +19,6 @@ export default () => {
|
|
|
19
19
|
paragraph={{ rows: 3, width: ['100%', '80%', '60%'] }}
|
|
20
20
|
/>
|
|
21
21
|
</Card>
|
|
22
|
-
</
|
|
22
|
+
</div>
|
|
23
23
|
);
|
|
24
24
|
};
|
package/src/Space/interface.ts
CHANGED
|
@@ -27,6 +27,10 @@ export interface SpaceProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
27
27
|
* Alignment
|
|
28
28
|
*/
|
|
29
29
|
align?: 'center' | 'start' | 'end' | 'baseline' | 'flex-start';
|
|
30
|
+
/***
|
|
31
|
+
* Justify content
|
|
32
|
+
* */
|
|
33
|
+
justify?: 'start' | 'end' | 'center' | 'space-around' | 'space-between';
|
|
30
34
|
/**
|
|
31
35
|
* Whether to take up the entire row
|
|
32
36
|
*/
|
package/src/Space/space.tsx
CHANGED
|
@@ -14,6 +14,7 @@ const Space = forwardRef<HTMLDivElement, SpaceProps>((baseprops, ref) => {
|
|
|
14
14
|
gap = 16,
|
|
15
15
|
direction = 'horizontal',
|
|
16
16
|
align = direction === 'horizontal' ? 'center' : undefined,
|
|
17
|
+
justify,
|
|
17
18
|
wrap,
|
|
18
19
|
className,
|
|
19
20
|
style,
|
|
@@ -45,25 +46,47 @@ const Space = forwardRef<HTMLDivElement, SpaceProps>((baseprops, ref) => {
|
|
|
45
46
|
if (!children) {
|
|
46
47
|
return null;
|
|
47
48
|
}
|
|
49
|
+
|
|
50
|
+
const loop = (childs: React.ReactNode[]) => {
|
|
51
|
+
let res = [] as React.ReactElement[];
|
|
52
|
+
|
|
53
|
+
childs.forEach((child, index) => {
|
|
54
|
+
const isItem =
|
|
55
|
+
React.isValidElement(child) && (child.type as any).isSpaceItem;
|
|
56
|
+
const itemClassName = isItem
|
|
57
|
+
? (child.props as any).className
|
|
58
|
+
: undefined;
|
|
59
|
+
const itemStyle = isItem ? (child.props as any).style : undefined;
|
|
60
|
+
const itemChildren = isItem ? (child.props as any).children : child;
|
|
61
|
+
|
|
62
|
+
if (React.isValidElement(child) && child.type === React.Fragment) {
|
|
63
|
+
res = res.concat(
|
|
64
|
+
loop(React.Children.toArray((child.props as any).children)),
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
res.push(
|
|
68
|
+
<div
|
|
69
|
+
className={clsx(
|
|
70
|
+
`${prefixCls}-item`,
|
|
71
|
+
classNames?.item,
|
|
72
|
+
itemClassName,
|
|
73
|
+
)}
|
|
74
|
+
style={{ ...styles?.item, ...itemStyle }}
|
|
75
|
+
key={index}
|
|
76
|
+
>
|
|
77
|
+
{itemChildren}
|
|
78
|
+
</div>,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return res;
|
|
83
|
+
};
|
|
84
|
+
|
|
48
85
|
const childs = React.Children.toArray(children).filter(
|
|
49
86
|
(child) => child !== null && child !== undefined,
|
|
50
87
|
);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
React.isValidElement(child) && (child.type as any).isSpaceItem;
|
|
54
|
-
const itemClassName = isItem ? (child.props as any).className : undefined;
|
|
55
|
-
const itemStyle = isItem ? (child.props as any).style : undefined;
|
|
56
|
-
const itemChildren = isItem ? (child.props as any).children : child;
|
|
57
|
-
return (
|
|
58
|
-
<div
|
|
59
|
-
className={clsx(`${prefixCls}-item`, classNames?.item, itemClassName)}
|
|
60
|
-
style={{ ...styles?.item, ...itemStyle }}
|
|
61
|
-
key={index}
|
|
62
|
-
>
|
|
63
|
-
{itemChildren}
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
});
|
|
88
|
+
|
|
89
|
+
return loop(childs);
|
|
67
90
|
};
|
|
68
91
|
|
|
69
92
|
const packed = pack();
|
|
@@ -76,6 +99,7 @@ const Space = forwardRef<HTMLDivElement, SpaceProps>((baseprops, ref) => {
|
|
|
76
99
|
width: block ? '100%' : undefined,
|
|
77
100
|
gap: gap + 'px',
|
|
78
101
|
alignItems: getAlign(),
|
|
102
|
+
justifyContent: justify,
|
|
79
103
|
...style,
|
|
80
104
|
}}
|
|
81
105
|
ref={componentRef}
|
|
@@ -6,12 +6,12 @@ export default () => {
|
|
|
6
6
|
<div style={{ height: 300 }}>
|
|
7
7
|
<Splitter>
|
|
8
8
|
<Splitter.Item>
|
|
9
|
-
<div style={{ padding: 16, backgroundColor: '#f0f0f0' }}>
|
|
9
|
+
<div style={{ margin: 8, padding: 16, backgroundColor: '#f0f0f0' }}>
|
|
10
10
|
Left Panel
|
|
11
11
|
</div>
|
|
12
12
|
</Splitter.Item>
|
|
13
13
|
<Splitter.Item>
|
|
14
|
-
<div style={{ padding: 16, backgroundColor: '#e0e0e0' }}>
|
|
14
|
+
<div style={{ margin: 8, padding: 16, backgroundColor: '#e0e0e0' }}>
|
|
15
15
|
Right Panel
|
|
16
16
|
</div>
|
|
17
17
|
</Splitter.Item>
|
|
@@ -3,15 +3,29 @@ import React from 'react';
|
|
|
3
3
|
|
|
4
4
|
export default () => {
|
|
5
5
|
return (
|
|
6
|
-
<div style={{ height:
|
|
6
|
+
<div style={{ height: 500 }}>
|
|
7
7
|
<Splitter layout="vertical">
|
|
8
|
-
<Splitter.Item>
|
|
9
|
-
<div
|
|
8
|
+
<Splitter.Item size={250}>
|
|
9
|
+
<div
|
|
10
|
+
style={{
|
|
11
|
+
marginBottom: 8,
|
|
12
|
+
padding: 16,
|
|
13
|
+
backgroundColor: '#f0f0f0',
|
|
14
|
+
height: '100%',
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
10
17
|
Top Panel
|
|
11
18
|
</div>
|
|
12
19
|
</Splitter.Item>
|
|
13
|
-
<Splitter.Item>
|
|
14
|
-
<div
|
|
20
|
+
<Splitter.Item size={250}>
|
|
21
|
+
<div
|
|
22
|
+
style={{
|
|
23
|
+
marginTop: 8,
|
|
24
|
+
padding: 16,
|
|
25
|
+
backgroundColor: '#e0e0e0',
|
|
26
|
+
height: '100%',
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
15
29
|
Bottom Panel
|
|
16
30
|
</div>
|
|
17
31
|
</Splitter.Item>
|
package/src/Splitter/index.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import InternalSplitter from './splitter';
|
|
2
2
|
import Item from './splitter-item';
|
|
3
3
|
|
|
4
|
-
export type {
|
|
4
|
+
export type {
|
|
5
|
+
SplitterItemProps,
|
|
6
|
+
PanelRect as SplitterPanelRect,
|
|
7
|
+
SplitterProps,
|
|
8
|
+
} from './interface';
|
|
5
9
|
|
|
6
10
|
type SplitterType = typeof InternalSplitter & {
|
|
7
11
|
Item: typeof Item;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { DataAttributeProps } from '../utils/types';
|
|
2
2
|
|
|
3
|
+
export type PanelRect = {
|
|
4
|
+
type: 'default' | 'percent' | 'auto';
|
|
5
|
+
size: number;
|
|
6
|
+
currentSize: number;
|
|
7
|
+
min?: string | number;
|
|
8
|
+
max?: string | number;
|
|
9
|
+
};
|
|
10
|
+
|
|
3
11
|
export interface SplitterItemProps {
|
|
4
12
|
/**
|
|
5
13
|
* custom item element class name prefix
|
|
@@ -65,14 +73,13 @@ export interface SplitterProps extends DataAttributeProps {
|
|
|
65
73
|
/**
|
|
66
74
|
* children
|
|
67
75
|
*/
|
|
68
|
-
children?: React.ReactElement
|
|
76
|
+
children?: Array<React.ReactElement | null>;
|
|
69
77
|
/**
|
|
70
78
|
* display border or not
|
|
71
79
|
* */
|
|
72
80
|
bordered?: boolean;
|
|
73
|
-
itemPadding?: number | string;
|
|
74
81
|
/**
|
|
75
82
|
* panel size change event
|
|
76
83
|
* */
|
|
77
|
-
onResize?: (sizes:
|
|
84
|
+
onResize?: (sizes: PanelRect[]) => void;
|
|
78
85
|
}
|
|
@@ -2,7 +2,8 @@ import clsx from 'clsx';
|
|
|
2
2
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
3
3
|
import React, { useContext, useRef } from 'react';
|
|
4
4
|
import useMove from './hooks/useMove';
|
|
5
|
-
import { PanelRect
|
|
5
|
+
import type { PanelRect } from './interface';
|
|
6
|
+
import { SplitterCtx, SplitterWrapperCtx } from './splitter';
|
|
6
7
|
|
|
7
8
|
interface SplitterHandlerProps {
|
|
8
9
|
layout: 'horizontal' | 'vertical';
|
|
@@ -37,7 +38,7 @@ const SplitterHandler = ({
|
|
|
37
38
|
const cref = useRef<HTMLDivElement>(null);
|
|
38
39
|
const handler = useRef<HTMLDivElement | null>(null);
|
|
39
40
|
const { refs } = useContext(SplitterWrapperCtx);
|
|
40
|
-
const { prefixCls } = useContext(SplitterCtx);
|
|
41
|
+
const { prefixCls, onResize } = useContext(SplitterCtx);
|
|
41
42
|
|
|
42
43
|
const status = records[index - 1] || {};
|
|
43
44
|
const next = records[index] || {};
|
|
@@ -85,6 +86,7 @@ const SplitterHandler = ({
|
|
|
85
86
|
currentSize: s,
|
|
86
87
|
};
|
|
87
88
|
newState[index] = { ...newState[index], size: e, currentSize: e };
|
|
89
|
+
onResize?.(newState);
|
|
88
90
|
return newState;
|
|
89
91
|
});
|
|
90
92
|
};
|
|
@@ -4,7 +4,7 @@ import { GlobalContext } from '../Config-Provider';
|
|
|
4
4
|
import mergeContextToProps from '../utils/mergeContextToProps';
|
|
5
5
|
import SplitterHandler from './splitter-handler';
|
|
6
6
|
|
|
7
|
-
import type { SplitterItemProps, SplitterProps } from './interface';
|
|
7
|
+
import type { PanelRect, SplitterItemProps, SplitterProps } from './interface';
|
|
8
8
|
import './style/index.less';
|
|
9
9
|
|
|
10
10
|
type SplitterWrapperCtxType = {
|
|
@@ -13,7 +13,7 @@ type SplitterWrapperCtxType = {
|
|
|
13
13
|
|
|
14
14
|
type SplitterCtxType = {
|
|
15
15
|
prefixCls: string;
|
|
16
|
-
onResize?: (sizes:
|
|
16
|
+
onResize?: (sizes: PanelRect[]) => void;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const SplitterWrapperCtx = React.createContext<SplitterWrapperCtxType>({
|
|
@@ -24,14 +24,6 @@ export const SplitterCtx = React.createContext<SplitterCtxType>({
|
|
|
24
24
|
prefixCls: '',
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
export type PanelRect = {
|
|
28
|
-
type: 'default' | 'percent' | 'auto';
|
|
29
|
-
size: number;
|
|
30
|
-
currentSize: number;
|
|
31
|
-
min?: string | number;
|
|
32
|
-
max?: string | number;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
27
|
const getPanelSize = (
|
|
36
28
|
children: React.ReactNode,
|
|
37
29
|
{
|
|
@@ -156,63 +148,66 @@ const Wrapper = ({ children, itemsSize, onClick, ...props }: any) => {
|
|
|
156
148
|
const arr = React.Children.toArray(children);
|
|
157
149
|
|
|
158
150
|
React.Children.forEach(children, (child, index) => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
(
|
|
166
|
-
|
|
151
|
+
if (React.isValidElement(child)) {
|
|
152
|
+
const n = index + 1;
|
|
153
|
+
const { style } = child.props || ({} as any);
|
|
154
|
+
let currentSize;
|
|
155
|
+
let min = undefined;
|
|
156
|
+
let max = undefined;
|
|
157
|
+
if (itemsSize && itemsSize[index]) {
|
|
158
|
+
({ currentSize, min, max } = itemsSize[index]);
|
|
159
|
+
}
|
|
167
160
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
161
|
+
wrappered.push(
|
|
162
|
+
React.cloneElement(child, {
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
style: {
|
|
165
|
+
...style, // If there is a border or other size-related design, it may cause calculation issues
|
|
166
|
+
flexBasis: currentSize,
|
|
167
|
+
},
|
|
168
|
+
min,
|
|
169
|
+
max,
|
|
170
|
+
index: n,
|
|
171
|
+
key: n,
|
|
172
|
+
ref: (el: HTMLDivElement) => {
|
|
173
|
+
refs.current[`item${n}`] = {
|
|
174
|
+
el: el,
|
|
175
|
+
props: child.props as SplitterItemProps,
|
|
176
|
+
size: { min, max },
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
}),
|
|
180
|
+
);
|
|
181
|
+
const next = arr[index + 1];
|
|
182
|
+
|
|
183
|
+
if (!next || !React.isValidElement(next)) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
188
186
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
187
|
+
const { flexable, expandable } = child.props || ({} as any);
|
|
188
|
+
const { expandable: nextExpandable } = next.props || ({} as any);
|
|
192
189
|
|
|
193
|
-
|
|
194
|
-
const { expandable: nextExpandable } = next.props || ({} as any);
|
|
190
|
+
const _expandable = { start: false, end: false };
|
|
195
191
|
|
|
196
|
-
|
|
192
|
+
if (expandable) {
|
|
193
|
+
_expandable.start = true;
|
|
194
|
+
}
|
|
197
195
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
if (nextExpandable) {
|
|
197
|
+
_expandable.end = true;
|
|
198
|
+
}
|
|
201
199
|
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
wrappered.push(
|
|
201
|
+
<SplitterHandler
|
|
202
|
+
{...props}
|
|
203
|
+
index={n}
|
|
204
|
+
flexable={flexable}
|
|
205
|
+
expandable={_expandable}
|
|
206
|
+
onClick={onClick}
|
|
207
|
+
key={`handler-${n}`}
|
|
208
|
+
/>,
|
|
209
|
+
);
|
|
204
210
|
}
|
|
205
|
-
|
|
206
|
-
wrappered.push(
|
|
207
|
-
<SplitterHandler
|
|
208
|
-
{...props}
|
|
209
|
-
index={n}
|
|
210
|
-
flexable={flexable}
|
|
211
|
-
expandable={_expandable}
|
|
212
|
-
onClick={onClick}
|
|
213
|
-
key={`handler-${n}`}
|
|
214
|
-
/>,
|
|
215
|
-
);
|
|
216
211
|
});
|
|
217
212
|
|
|
218
213
|
return (
|
|
@@ -10,8 +10,18 @@
|
|
|
10
10
|
var(--yee-splitter-border-color);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
&-horizontal {
|
|
14
|
+
@{pls}-handler {
|
|
15
|
+
cursor: e-resize;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
&-vertical {
|
|
14
20
|
flex-direction: column;
|
|
21
|
+
|
|
22
|
+
@{pls}-handler {
|
|
23
|
+
cursor: n-resize;
|
|
24
|
+
}
|
|
15
25
|
}
|
|
16
26
|
}
|
|
17
27
|
|
|
@@ -77,8 +87,19 @@
|
|
|
77
87
|
transition:
|
|
78
88
|
background 0.2s ease-in-out,
|
|
79
89
|
opacity 0.2s ease-in-out;
|
|
90
|
+
border-radius: 2px;
|
|
80
91
|
content: '';
|
|
81
92
|
}
|
|
93
|
+
|
|
94
|
+
&:hover {
|
|
95
|
+
&::after {
|
|
96
|
+
background-color: color-mix(
|
|
97
|
+
in srgb,
|
|
98
|
+
var(--yee-splitter-handler-color),
|
|
99
|
+
black 20%
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
82
103
|
}
|
|
83
104
|
|
|
84
105
|
&-flexable {
|
package/src/Table/demo/size.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Table } from '@rainbow-oh/yee-c';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
export default () => {
|
|
@@ -42,12 +42,12 @@ export default () => {
|
|
|
42
42
|
];
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
|
-
<
|
|
45
|
+
<div>
|
|
46
46
|
<Table columns={columns} dataSource={dataSource} size="small" />
|
|
47
47
|
|
|
48
48
|
<Table columns={columns} dataSource={dataSource} size="default" />
|
|
49
49
|
|
|
50
50
|
<Table columns={columns} dataSource={dataSource} size="large" />
|
|
51
|
-
</
|
|
51
|
+
</div>
|
|
52
52
|
);
|
|
53
53
|
};
|