How to use the prop-types.oneOf 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 caicloud / cyclone / web / src / components / workflow / component / resource / ResourceArray.js View on Github external
import { Button, Row, Col, Form } from 'antd';
import { FieldArray, FastField } from 'formik';
import { drawerFormItemLayout } from '@/lib/const';
import Resource from './Form';
import PropTypes from 'prop-types';
import style from '@/components/workflow/component/index.module.less';

const FormItem = Form.Item;
const Fragment = React.Fragment;

class ResourceArray extends React.Component {
  static propTypes = {
    resourcesField: PropTypes.string,
    type: PropTypes.oneOf(['inputs', 'outputs']),
    update: PropTypes.bool,
    projectName: PropTypes.string,
    resources: PropTypes.array,
  };

  state = {
    visible: false,
  };

  getIntegrationName = _argument => {
    const reg = /^\$\.+/;
    const item = _.find(_argument, o => reg.test(o.value));
    // NOTE: get integration name from $.${namespace}.${integration}/data.integration/sonarQube.server
    if (item) {
      const value = _.get(item, 'value').split('/data.integration');
      const integration = value[0].split('.')[2];
github Khan / react-components / js / tooltip.jsx View on Github external
tooltipLeft: "-100%",
        arrowLeft: (arrowSize) => -arrowSize - 2,
    },
};


const Tooltip = createReactClass({
    propTypes: {
        show: PropTypes.bool.isRequired,
        className: PropTypes.string,
        arrowSize: PropTypes.number,
        borderColor: PropTypes.string,
        verticalPosition: PropTypes.oneOf(
            Object.keys(VERTICAL_CORNERS)
        ),
        horizontalPosition: PropTypes.oneOf(
            Object.keys(HORIZONTAL_CORNERS)
        ),
        horizontalAlign: PropTypes.oneOf(
            Object.keys(HORIZONTAL_ALIGNMNENTS)
        ),
        children: PropTypes.arrayOf(
            PropTypes.element
        ).isRequired,
        targetContainerStyle: PropTypes.any,  // style object
    },

    getDefaultProps: function() {
        return {
            className: "",
            arrowSize: 10,
            borderColor: "#ccc",
github alcedo-ui / alcedo-ui / src / Guide / Guide.js View on Github external
/**
     * The CSS class name of the content element.
     */
    contentClassName: PropTypes.string,

    modalClassName: PropTypes.string,

    /**
     * Override the styles of the root element.
     */
    style: PropTypes.object,

    /**
     * The type of notification.
     */
    type: PropTypes.oneOf(Util.enumerateValue(MsgType)),

    parentEl: PropTypes.object,

    /**
     * This is the DOM element that will be used to set the position of the popover.
     */
    triggerEl: PropTypes.object,

    /**
     * If true,the popover is visible.
     */
    visible: PropTypes.bool,

    /**
     * If true,the popover will have a triangle on the top of the DOM element.
     */
github wix / react-native-ui-lib / src / commons / SelectableComponent.js View on Github external
/**
     * should this component treat as selectable
     */
    selectable: PropTypes.bool,
    /**
     * selected state of the component
     */
    selected: PropTypes.bool,
    /**
     * selectable indicator size
     */
    selectableIndicatorSize: PropTypes.number,
    /**
     * selectable indicator look (circle, clean)
     */
    selectableIndicatorType: PropTypes.oneOf([INDICATOR_TYPES.CIRCLE, INDICATOR_TYPES.CLEAN]),
    /**
     * color of selectable indicator
     */
    selectableIndicatorColor: PropTypes.string,
  };

  static defaultProps = {
    selectableIndicatorSize: 36,
    selectableIndicatorType: INDICATOR_TYPES.CIRCLE,
    selectableIndicatorColor: Colors.blue30,
  };

  static indicatorTypes = INDICATOR_TYPES;

  constructor(props) {
    super(props);
github alcedo-ui / alcedo-ui / src / MaterialMonthPicker / MaterialMonthPicker.js View on Github external
/**
     * If true,hide date display.
     */
    autoClose: PropTypes.bool,

    /**
     * If true,materialMonthPicker textField is readOnly.
     */
    readOnly: PropTypes.bool,
    /**
     * If true,materialMonthPicker textField is disabled.
     */
    disabled: PropTypes.bool,

    position: PropTypes.oneOf(Util.enumerateValue(Position)),
    rightIconCls: PropTypes.string,
    previousYearIconCls: PropTypes.string,
    previousMonthIconCls: PropTypes.string,
    nextYearIconCls: PropTypes.string,
    nextMonthIconCls: PropTypes.string,
    parentEl: PropTypes.object,

    /**
     * Callback function that is fired when the date value changes.
     */
    onChange: PropTypes.func

};

MaterialMonthPicker.defaultProps = {
    name: '',
github plouc / nivo / packages / scales / src / timeScale.js View on Github external
maxValue = values.max
    } else if (format !== 'native') {
        maxValue = normalize(values.max)
    }

    const scale = useUTC ? scaleUtc() : scaleTime()
    scale.domain([minValue, maxValue]).range([0, size])

    scale.type = 'time'
    scale.useUTC = useUTC

    return scale
}

export const timeScalePropTypes = {
    type: PropTypes.oneOf(['time']).isRequired,
    format: PropTypes.string,
    precision: PropTypes.oneOf(timePrecisions),
}
github esnet / react-network-diagrams / packages / react-network-diagrams / src / components / PatchPanel.js View on Github external
style={circuitContainer}
                onClick={this._deselect}
            >
                <svg preserveAspectRatio="xMinYMin">
                    {this.renderPanels(panelMap)}
                </svg>
            
        );
    }
}

PatchPanel.propTypes = {
    /** The blank margin around the diagram drawing */
    margin: PropTypes.number,

    labelPosition: PropTypes.oneOf([
        "left",
        "right",
        "center",
        "top",
        "topright",
        "topleft",
        "bottom",
        "bottomright",
        "bottomleft",
        "bottomleftangled",
        "bottomrightangled",
        "topleftangled",
        "toprightangled"
    ]),

    /** The width of the circuit diagram */
github LoicMahieu / react-styled-flexboxgrid / src / components / Row.js View on Github external
import PropTypes from 'prop-types'
import styled from 'styled-components'

import config, { DIMENSION_NAMES } from '../config'

const ModificatorType = PropTypes.oneOf(DIMENSION_NAMES)

const Row = styled.div`
  box-sizing: border-box;
  display: flex;
  flex: 0 1 auto;
  flex-direction: row;
  flex-wrap: wrap;
  margin-right: ${p => config(p).gutterWidth / 2 * -1}rem;
  margin-left: ${p => config(p).gutterWidth / 2 * -1}rem;

  ${p => p.reverse && `
    flex-direction: row-reverse;
  `}

  ${p => p.start && config(p).media[p.start]`
    justify-content: flex-start;