Skip to content

Commit 1b93e24

Browse files
committed
fix: unknown event handler property issue
1 parent 817ca96 commit 1b93e24

File tree

7 files changed

+60
-12
lines changed

7 files changed

+60
-12
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
},
6666
"dependencies": {
6767
"@emotion/core": "^10.0.4",
68+
"@emotion/is-prop-valid": "^0.7.3",
6869
"@emotion/styled": "^10.0.4",
6970
"rxjs": "^6.3.3"
7071
},

src/Bar/Bar.styled.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from '@emotion/styled';
22

33
import { ExpandInteractiveArea } from '../types';
4+
import { ignoreProps } from '../utils';
45

56
interface StyledBarProps {
67
size?: number;
@@ -10,7 +11,20 @@ interface StyledInteractiveAreaProps extends ExpandInteractiveArea {
1011
vertical: boolean;
1112
}
1213

13-
export const StyledBar = styled.div<StyledBarProps>(({ size = 10 }) => ({
14+
const customStyledBarProps = [
15+
// ChildProps
16+
'context',
17+
'innerRef',
18+
// BarProps
19+
'size',
20+
'onClick',
21+
'expandInteractiveArea',
22+
'onStatusChanged',
23+
];
24+
25+
export const StyledBar = styled('div', {
26+
shouldForwardProp: ignoreProps(customStyledBarProps),
27+
})<StyledBarProps>(({ size = 10 }) => ({
1428
position: 'relative',
1529
flex: `0 0 ${size}px`,
1630
}));

src/Bar/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ class BarComponent extends React.PureComponent<Props> {
8383
}
8484

8585
render() {
86-
const { onClick: _, ...props } = this.props;
87-
8886
return (
89-
<StyledBar {...props} ref={this.ref}>
87+
<StyledBar {...this.props} ref={this.ref}>
9088
{this.props.children}
9189
<StyledInteractiveArea
9290
{...this.props.expandInteractiveArea}

src/Container/Container.styled.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
import styled from '@emotion/styled';
22

3+
import { ignoreProps } from '../utils';
4+
35
interface StyledContainerProps {
46
vertical?: boolean;
57
}
68

7-
export const StyledContainer = styled.div<StyledContainerProps>(
8-
({ vertical }) => ({
9-
display: 'flex',
10-
flexDirection: vertical ? 'column' : 'row',
11-
}),
12-
);
9+
const customStyledContainerProps = [
10+
'vertical',
11+
'onActivate',
12+
'beforeApplyResizer',
13+
'afterResizing',
14+
];
15+
16+
export const StyledContainer = styled('div', {
17+
shouldForwardProp: ignoreProps(customStyledContainerProps),
18+
})<StyledContainerProps>(({ vertical }) => ({
19+
display: 'flex',
20+
flexDirection: vertical ? 'column' : 'row',
21+
}));

src/Section/Section.styled.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
import styled from '@emotion/styled';
22
import { ChildProps } from '../types';
3+
import { ignoreProps } from '../utils';
34

45
interface StyledSectionProps extends ChildProps {
56
flexGrow: number;
67
flexShrink: number;
78
flexBasis: number;
89
}
910

10-
export const StyledSection = styled.div<StyledSectionProps>(
11+
const customProps = [
12+
'onSizeChanged',
13+
// ChildProps
14+
'size',
15+
'defaultSize',
16+
'maxSize',
17+
'minSize',
18+
'context',
19+
'disableResponsive',
20+
'innerRef',
21+
// StyledSectionProps
22+
'flexGrow',
23+
'flexShrink',
24+
'flexBasis',
25+
];
26+
27+
export const StyledSection = styled('div', {
28+
shouldForwardProp: ignoreProps(customProps),
29+
})<StyledSectionProps>(
1130
({ context, maxSize, minSize, flexGrow, flexShrink, flexBasis }) => ({
1231
overflow: 'hidden',
1332
[context.vertical ? 'maxHeight' : 'maxWidth']: maxSize,

src/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
import isPropValid from '@emotion/is-prop-valid';
2+
13
export function isValidNumber(num?: number): num is number {
24
return typeof num === 'number' && num === num;
35
}
46

57
export function noop() {}
8+
9+
export function ignoreProps(ignoreList: string[]) {
10+
return (propName: string) =>
11+
ignoreList.indexOf(propName) === -1 && isPropValid(propName);
12+
}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
resolved "https://registry.npmjs.org/@emotion/hash/-/hash-0.7.1.tgz#9833722341379fb7d67f06a4b00ab3c37913da53"
665665
integrity sha512-OYpa/Sg+2GDX+jibUfpZVn1YqSVRpYmTLF2eyAfrFTIJSbwyIrc+YscayoykvaOME/wV4BV0Sa0yqdMrgse6mA==
666666

667-
"@emotion/is-prop-valid@0.7.3":
667+
"@emotion/is-prop-valid@0.7.3", "@emotion/is-prop-valid@^0.7.3":
668668
version "0.7.3"
669669
resolved "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.7.3.tgz#a6bf4fa5387cbba59d44e698a4680f481a8da6cc"
670670
integrity sha512-uxJqm/sqwXw3YPA5GXX365OBcJGFtxUVkB6WyezqFHlNe9jqUWH5ur2O2M8dGBz61kn1g3ZBlzUunFQXQIClhA==

0 commit comments

Comments
 (0)