Skip to content

Commit b5e1303

Browse files
authored
Merge pull request #124 from Gerhut/fix-custom-props
Fix Custom.propTypes
2 parents d8946a3 + 06b9691 commit b5e1303

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/components/Custom.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Space } from "./Space";
44
import * as PropTypes from "prop-types";
55
import { IReactSpaceCommonProps } from "../core-react";
66
import { anchoredProps, IAnchorProps } from "./Anchored";
7+
import { omit } from '../core-utils';
78

89
type ICustomProps = Omit<IReactSpaceCommonProps & IAnchorProps, "size"> & {
910
type?: Type;
@@ -22,7 +23,7 @@ type ICustomProps = Omit<IReactSpaceCommonProps & IAnchorProps, "size"> & {
2223
resizeTypes?: ResizeType[];
2324
};
2425

25-
const customProps = {
26+
const customProps = omit({
2627
...anchoredProps,
2728
...{
2829
type: PropTypes.oneOf([Type.Positioned, Type.Fill, Type.Anchored]),
@@ -38,7 +39,7 @@ const customProps = {
3839
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
3940
resizeTypes: PropTypes.array,
4041
},
41-
};
42+
}, 'size');
4243

4344
export const Custom: React.FC<ICustomProps> = ({
4445
children,

src/core-utils.ts

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import { ISpaceDefinition, SizeUnit, ISize, ResizeHandlePlacement, Type } from "./core-types";
22

3+
export function omit<K extends string, T extends Record<K, unknown>>(object: T, ...keys: K[]): Omit<T, K> {
4+
const keySet = new Set<string>(keys)
5+
const result = Object.create(null) as Omit<T, K>
6+
for (const key in Object.keys(object)) {
7+
if (!keySet.has(key)) {
8+
result[key] = object[key]
9+
}
10+
}
11+
return result
12+
}
13+
314
export function shortuuid() {
415
let firstPart = (Math.random() * 46656) | 0;
516
let secondPart = (Math.random() * 46656) | 0;

0 commit comments

Comments
 (0)