import React, { Component, HTMLAttributes, RefCallback } from 'react';
import { getClassName } from '../../helpers/getClassName';
import { classNames } from '../../lib/classNames';
import Touch from '../Touch/Touch';
import { withPlatform } from '../../hoc/withPlatform';
import { HasPlatform, HasRootRef } from '../../types';
import { withAdaptivity, AdaptivityProps } from '../../hoc/withAdaptivity';
import { PanelContext, PanelContextProps } from './PanelContext';
import { IOS } from '../../lib/platform';
import { setRef } from '../../lib/utils';
export interface PanelProps extends HTMLAttributes, HasPlatform, HasRootRef, AdaptivityProps {
id: string;
centered?: boolean;
}
class Panel extends Component {
constructor(props: PanelProps) {
super(props);
this.childContext = {
panel: props.id,
};
}
private readonly childContext: PanelContextProps;
static defaultProps: Partial = {
children: '',
centered: false,
};
container: HTMLDivElement;
getRef: RefCallback = (container) => {
this.container = container;
setRef(container, this.props.getRootRef);
};
render() {
const { className, centered, children, platform, getRootRef, sizeX, ...restProps } = this.props;
return (
{platform === IOS && }
{centered ? {children}
: children}
);
}
}
export default withAdaptivity(withPlatform(Panel), {
sizeX: true,
});