import { ComponentType } from 'react';
declare const Children: {
/**
* Validate that the children of a component are one of the specified types.
*
* ```js
* import { Children } from '@instructure/ui-prop-types'
*
* class Example extends Component {
* static propTypes = {
* children: Children.oneOf([Foo, Bar, Baz])
* }
*
* render () {
* return
{this.props.children}
* }
* }
* ```
*
* This will allow children such as:
*
* ```jsx
*
*
*
* ```
*
* OR
*
* ```jsx
*
*
*
*
* ```
*
* But will fail on something like:
*
* ```jsx
*
* Example
*
*
* ```
* @returns {function} A validator function that returns Error if validation failed
*/
oneOf(validTypes: (string | ComponentType | null)[]): {
(props: Record, propName: string, componentName: string): Error | null;
isRequired: (props: Record, propName: string, componentName: string, location?: string, propFullName?: string) => Error | null;
};
/**
* Ensures that there is exactly one of each specified child
*
* ```js
* import { Children } from '@instructure/ui-prop-types'
*
* class Example extends Component {
* static propTypes = {
* children: Children.oneOfEach([Foo, Bar, Baz])
* }
*
* render () {
* return {this.props.children}
* }
* }
* ```
*
* This will enforce the following:
*
* ```jsx
*
*
*
*
*
* ```
* An error will be thrown
* - If any of the children are not provided (ex. Foo, Bar, but missing Baz)
* - If multiple children of the same type are provided (ex. Foo, Foo, Bar, and Baz)
*
* @param {Array} validTypes - Array of child types
* @returns {function} A validator function that returns error if validation
* failed, null otherwise
*/
oneOfEach(validTypes: (string | ComponentType)[]): (props: Record, propName: string, componentName: string) => Error | null;
/**
* Validate the type and order of children for a component.
*
* ```js
* import { Children } from '@instructure/ui-prop-types'
*
* class Example extends Component {
* static propTypes = {
* children: Children.enforceOrder([Foo, Bar, Baz])
* }
*
* render () {
* return {this.props.children}
* }
* }
* ```
*
* This will enforce the following:
*
* ```jsx
*
*
*
*
*
* ```
*
* This validator will also allow various permutations of the order.
*
* ```js
* import { Children } from '@instructure/ui-prop-types'
*
* class Example extends Component {
* static propTypes = {
* children: Children.enforceOrder(
* [Foo, Bar, Baz],
* [Foo, Bar],
* [Bar, Baz],
* )
* }
*
* render () {
* return {this.props.children}
* }
* }
* ```
*
* This will enforce one of the following:
*
* ```jsx
*
*
*
*
*
* ```
*
* OR
*
* ```jsx
*
*
*
*
* ```
*
* OR
*
* ```jsx
*
*
*
*
* ```
*
* @param {...Array} validTypeGroups One or more Arrays of valid types
* @returns {function} A validator function that returns error if validation
* failed, null otherwise
*/
enforceOrder(...validTypeGroups: (string | ComponentType)[][]): {
(props: Record, propName: string, componentName: string): Error | null;
isRequired: (props: Record, propName: string, componentName: string, location?: string, propFullName?: string) => Error | null;
};
};
export default Children;
export { Children };
//# sourceMappingURL=Children.d.ts.map