How to use the prop-types.oneOfType function in prop-types

To help you get started, we’ve selected a few prop-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mineral-ui / mineral-ui / src / library / Text / propTypes.ts View on Github external
/* @flow */
import { bool, node, number, oneOf, oneOfType, string } from 'prop-types';
import { enumToArray } from '../utils';
import { ALIGN, APPEARANCE, FONT_WEIGHT } from './constants';

export const textPropTypes = {
  align: oneOf(enumToArray(ALIGN)),
  appearance: oneOf(enumToArray(APPEARANCE)),
  children: node.isRequired,
  color: string,
  fontWeight: oneOfType([oneOf(enumToArray(FONT_WEIGHT)), number]),
  inherit: bool,
  noMargins: bool,
  parentAs: string,
  truncate: oneOfType([bool, number, string])
};
github mesosphere / reactjs-components / src / Dropdown / Dropdown.js View on Github external
// Notice: This property will override the initialID
  persistentID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
  // The items to display in the dropdown.
  items: PropTypes.arrayOf(
    PropTypes.shape({
      // An optional classname for the menu item.
      className: PropTypes.string,
      // A required ID for each item
      id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
      // The HTML (or text) to render for the list item.
      html: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
      // Whether or not the user can choose the item.
      selectable: PropTypes.bool,
      // The HTML (or text) to display when the option is selected. If this is
      // not provided, the value for the `html` property will be used.
      selectedHtml: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
    })
  ).isRequired,
  // The ID of the item that should be selected initially.
  initialID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
  // When true, the width of the dropdown will match the width of the button.
  matchButtonWidth: PropTypes.bool,
  // An optional callback when an item is selected. Will receive an argument
  // containing the selected item as it was supplied via the items array.
  onItemSelection: PropTypes.func,
  // The nearest scrolling DOMNode that contains the dropdown. Defaults to
  // window. Also accepts a string, treated as a selector for the node.
  scrollContainer: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
  // Will attach the scroll handler to the the direct parent of scrollContainer
  // if it matches this selector. Defaults to null.
  scrollContainerParentSelector: PropTypes.string,
  // Optional transition on the dropdown menu. Must be accompanied
github keplergl / kepler.gl / src / components / common / item-selector / item-selector.js View on Github external
selectedItems: PropTypes.oneOfType([
      PropTypes.array,
      PropTypes.string,
      PropTypes.number,
      PropTypes.bool,
      PropTypes.object
    ]),
    onChange: PropTypes.func.isRequired,
    options: PropTypes.arrayOf(PropTypes.any).isRequired,

    // optional properties
    fixedOptions: PropTypes.arrayOf(PropTypes.any),
    erasable: PropTypes.bool,
    displayOption: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    getOptionValue: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    filterOption: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    placement: PropTypes.string,
    disabled: PropTypes.bool,
    isError: PropTypes.bool,
    multiSelect: PropTypes.bool,
    inputTheme: PropTypes.string,
    onBlur: PropTypes.func,
    placeholder: PropTypes.string,
    closeOnSelect: PropTypes.bool,
    DropdownHeaderComponent: PropTypes.func,
    DropDownRenderComponent: PropTypes.func,
    DropDownLineItemRenderComponent: PropTypes.func
  };

  static defaultProps = {
    erasable: false,
    placement: 'bottom',
github CraveFood / farmblocks / packages / icon / src / jsx / LgProfile.js View on Github external
height={size}
    viewBox="6 6 88 88"
    ref={ref}
    aria-hidden={!props["aria-label"]}
    {...props}
  >
github alfa-laboratory / arui-feather / src / page / page.jsx View on Github external
* и компонентами `AppTitle`, `AppMenu` и `AppContent`.
 */
@deprecated('arui-private')
@cn('page')
class Page extends React.Component {
    static propTypes = {
        /** Шапка страницы */
        header: Type.node,
        /** Дочерние элементы `Page` */
        children: Type.oneOfType([Type.arrayOf(Type.node), Type.node]),
        /** Футер страницы */
        footer: Type.node,
        /** Тема компонента */
        theme: Type.oneOf(['alfa-on-color', 'alfa-on-white']),
        /** Дополнительный класс */
        className: Type.oneOfType([Type.func, Type.string]),
        /** Идентификатор компонента в DOM */
        id: Type.string
    };

    state = {
        innerMargin: null,
        contentPadding: null
    };

    render(cn) {
        let header;
        if (this.props.header) {
            header = React.cloneElement(this.props.header,
                {
                    onResize: this.handleHeaderResize
                }
github securingsincity / react-ace / src / split.tsx View on Github external
tabSize: PropTypes.number,
    showPrintMargin: PropTypes.bool,
    cursorStart: PropTypes.number,
    editorProps: PropTypes.object,
    setOptions: PropTypes.object,
    style: PropTypes.object,
    scrollMargin: PropTypes.array,
    annotations: PropTypes.array,
    markers: PropTypes.array,
    keyboardHandler: PropTypes.string,
    wrapEnabled: PropTypes.bool,
    enableBasicAutocompletion: PropTypes.oneOfType([
      PropTypes.bool,
      PropTypes.array
    ]),
    enableLiveAutocompletion: PropTypes.oneOfType([
      PropTypes.bool,
      PropTypes.array
    ]),
    commands: PropTypes.array
  };
  public static defaultProps: Partial = {
    name: "brace-editor",
    focus: false,
    orientation: "beside",
    splits: 2,
    mode: "",
    theme: "",
    height: "500px",
    width: "500px",
    value: [],
    fontSize: 12,
github alibaba / nopage / packages / form / src / component / FormItem.jsx View on Github external
const getDefaultValue = (jsxProps) => {
    const hasDefaultVal = ('defaultValue' in jsxProps);
    if (hasDefaultVal) {
        return jsxProps.defaultValue;
    }
    return null;
};

const isReactComponent = (com) => {
    const { $$typeof, type } = com || {};
    return !!$$typeof && !!type;
};

class BaseFormItem extends React.Component {
    static propTypes = {
        name: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
        value: PropTypes.any,
        children: PropTypes.any,
        onBlur: PropTypes.func,
        onFocus: PropTypes.func,
        render: PropTypes.func,
        inset: PropTypes.bool,
        listenKeys: PropTypes.array,
    }

    static defaultProps = {
        name: '',
        children: null,
        onBlur: noop,
        onFocus: noop,
        listenKeys: [],
    }
github EleanorMao / asumi-ui / src / component / table / index.js View on Github external
uid: PropTypes.string,
    isTree: PropTypes.bool,
    hashKey: PropTypes.bool,
    expandAll: PropTypes.bool,
    arrowRender: PropTypes.func,
    onArrowClick: PropTypes.func,
    stretchable: PropTypes.bool,
    isKey: PropTypes.string,
    nestedHead: PropTypes.arrayOf(PropTypes.array),
    expandRowKeys: PropTypes.array,
    startArrowCol: PropTypes.number,
    clickToCloseAll: PropTypes.bool,
    childrenPropertyName: PropTypes.string,
    lineWrap: PropTypes.oneOf(['ellipsis', 'break']),
    width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
    height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
    title: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node, PropTypes.func, PropTypes.element]),
    footer: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node, PropTypes.func, PropTypes.element]),
    noDataText: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node, PropTypes.func, PropTypes.element]),
    selectRow: PropTypes.shape({
        mode: PropTypes.oneOf([
            'none',
            'radio',
            'checkbox'
        ]),
        onSelect: PropTypes.func,
        bgColor: PropTypes.string,
        selected: PropTypes.array,
        onSelectAll: PropTypes.func,
        hideSelectColumn: PropTypes.bool
    }),
    options: PropTypes.shape({
github ticketmaster / aurora / src / components / Tooltip / SeatTooltip.js View on Github external
size={size}
            row={row}
            section={section}
            seat={seat}
            variant={variant}
          >
            {children}
          
        )}
      
    );
  }
}

SeatTooltip.propTypes = {
  section: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
  row: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
  seat: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
  size: PropTypes.oneOf(SIZES_SL),
  children: PropTypes.node,
  variant: PropTypes.oneOf(VARIANTS)
};

SeatTooltip.defaultProps = {
  size: LARGE,
  children: null,
  variant: LIGHT
};

SeatTooltip.displayName = "SeatTooltip";

export default SeatTooltip;