How to use the san.DataTypes.oneOfType function in san

To help you get started, we’ve selected a few san 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 ecomfe / san-mui / src / Slider / Slider.js View on Github external
min: 0, // 最小值
            step: 1, // 最小步数
            value: 0, // 当前值

            // 内部状态数据
            dragRunning: false,
            dragging: false, // 正在拖拽
            active: 0, // 是否激活
            focus: 0, // 是否focus
            hover: 0 // 是否hover
        };
    },

    dataTypes: {
        max: DataTypes.oneOfType([DataTypes.number, DataTypes.string]), // 最大值
        min: DataTypes.oneOfType([DataTypes.number, DataTypes.string]), // 最小值
        step: DataTypes.oneOfType([DataTypes.number, DataTypes.string]), // 最小步数
        value: DataTypes.oneOfType([DataTypes.number, DataTypes.string]) // 当前值
    },

    computed: {
        percent() {
            let min = this.data.get('min');
            let max = this.data.get('max');
            let value = this.data.get('value');
            let range = max - min;
            let percentNum = range > 0
                ? (value - min) / range * 100
                : 0;

            return percentNum > 100
                ? 100
github ecomfe / san-mui / src / Slider / Slider.js View on Github external
max: 100, // 最大值
            min: 0, // 最小值
            step: 1, // 最小步数
            value: 0, // 当前值

            // 内部状态数据
            dragRunning: false,
            dragging: false, // 正在拖拽
            active: 0, // 是否激活
            focus: 0, // 是否focus
            hover: 0 // 是否hover
        };
    },

    dataTypes: {
        max: DataTypes.oneOfType([DataTypes.number, DataTypes.string]), // 最大值
        min: DataTypes.oneOfType([DataTypes.number, DataTypes.string]), // 最小值
        step: DataTypes.oneOfType([DataTypes.number, DataTypes.string]), // 最小步数
        value: DataTypes.oneOfType([DataTypes.number, DataTypes.string]) // 当前值
    },

    computed: {
        percent() {
            let min = this.data.get('min');
            let max = this.data.get('max');
            let value = this.data.get('value');
            let range = max - min;
            let percentNum = range > 0
                ? (value - min) / range * 100
                : 0;

            return percentNum > 100
github ecomfe / santd / src / select / Select.js View on Github external
offset: [0, 4],
        overflow: {
            adjustX: 0,
            adjustY: 1
        }
    },
    topLeft: {
        points: ['bl', 'tl'],
        offset: [0, -4],
        overflow: {
            adjustX: 0,
            adjustY: 1
        }
    }
};
const valueType = DataTypes.oneOfType([
    DataTypes.string,
    DataTypes.arrayOf(DataTypes.string),
    DataTypes.number,
    DataTypes.arrayOf(DataTypes.number)
]);

export default san.defineComponent({
    template: `
        <div class="{{wrapClass}}">
            </div>
github ecomfe / san-mui / src / Icon / Icon.js View on Github external
<i style="{{size | fontSize}}" class="sm-icon">
            
        </i>
    `,
    filters: {
        fontSize(size) {
            return size ? `font-size: ${size}px` : '';
        }
    },
    initData() {
        return {
            size: 24
        };
    },
    dataTypes: {
        size: DataTypes.oneOfType([DataTypes.string, DataTypes.number])
    }
});
github ecomfe / santd / src / input-number / index.js View on Github external
import {classCreator} from '../core/util';
import inputHandle from './inputHandler';
import './style/index.less';
const prefixCls = classCreator('input-number')();

export default san.defineComponent({
    dataTypes: {
        autoFocus: DataTypes.bool,
        defaultValue: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        disabled: DataTypes.bool,
        max: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        min: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        precision: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        size: DataTypes.oneOf(['default', 'small', 'large']),
        step: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        value: DataTypes.oneOfType([DataTypes.string, DataTypes.number])
    },

    components: {
        'input-handler': inputHandle
    },

    computed: {
        outClasses() {
            const focused = this.data.get('autoFocus');
            const disabled = this.data.get('disabled');
            const size = this.data.get('size');
            let classArr = [prefixCls];

            focused && classArr.push(`${prefixCls}-focused`);
            disabled && classArr.push(`${prefixCls}-disabled`);
            size === 'large' && classArr.push(`${prefixCls}-lg`);
github ecomfe / santd / santd / table / src / TableRow.js View on Github external
/**
 * @file santd Table TableRow
 * @author mayihui@baidu.com
 **/

import san, {DataTypes} from 'san';
import TableCell from './TableCell';

export default san.defineComponent({
    dataTypes: {
        fixed: DataTypes.oneOfType([
            DataTypes.string,
            DataTypes.bool
        ]),
        columns: DataTypes.array,
        bodyRowHeight: DataTypes.object
    },
    computed: {
        classes() {
            const prefixCls = this.data.get('prefixCls');
            return [`${prefixCls}-thead`];
        },
        cells() {
            const columns = this.data.get('columns');
            const index = this.data.get('index');
            const expandedRowRender = this.data.get('expandedRowRender');
            return columns.map(column => {
github ecomfe / santd / santd / grid / Col.js View on Github external
import Row from './Row';

const cc = classCreator('col');
const SUPPORT_PROPS = ['order', 'offset', 'pull', 'push'];
const SUPPORT_SCREENS = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];

export default san.defineComponent({

    dataTypes: {
        span: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        order: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        offset: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        push: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        pull: DataTypes.oneOfType([DataTypes.string, DataTypes.number]),
        xs: DataTypes.oneOfType([DataTypes.number, DataTypes.string, DataTypes.object]),
        sm: DataTypes.oneOfType([DataTypes.number, DataTypes.string, DataTypes.object]),
        md: DataTypes.oneOfType([DataTypes.number, DataTypes.string, DataTypes.object]),
        lg: DataTypes.oneOfType([DataTypes.number, DataTypes.string, DataTypes.object]),
        xl: DataTypes.oneOfType([DataTypes.number, DataTypes.string, DataTypes.object]),
        xxl: DataTypes.oneOfType([DataTypes.number, DataTypes.string, DataTypes.object])
    },
    computed: {
        styleClass() {
            let arr = [];
            let data = this.data;
            let span = data.get('span');
            arr.push(cc());
            if (span !== undefined) {
                arr.push(cc(span + ''));
            }

            SUPPORT_PROPS.forEach(key => {
github ecomfe / santd / santd / table / src / BodyTable.js View on Github external
if (isVertical) {
        size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
        scrollbarVerticalSize = size;
    }
    else {
        size = scrollDiv.offsetHeight - scrollDiv.clientHeight;
        scrollbarHorizontalSize = size;
    }

    document.body.removeChild(scrollDiv);
    return size;
};

export default san.defineComponent({
    dataTypes: {
        fixed: DataTypes.oneOfType([
            DataTypes.string,
            DataTypes.bool
        ]),
        columns: DataTypes.array,
        tableClassName: DataTypes.string
    },
    computed: {
        prefixCls() {
            const table = this.data.get('table');
            return table && table.data.get('prefixCls');
        },
        classes() {
            const fixed = this.data.get('fixed');
            const columns = this.data.get('columns');
            const prefixCls = this.data.get('prefixCls');
github ecomfe / santd / src / select / select.js View on Github external
}
    }
};

export default san.defineComponent({
    dataTypes: {
        showArrow: DataTypes.bool,
        loading: DataTypes.bool,
        defaultActiveFirstOption: DataTypes.bool,
        disabled: DataTypes.bool,
        maxTagCount: DataTypes.number,
        autoClearSearchValue: DataTypes.bool,
        dropdownClassName: DataTypes.string,
        maxTagPlaceholder: DataTypes.any,
        mode: DataTypes.string,
        notFoundContent: DataTypes.oneOfType([DataTypes.string, DataTypes.func]),
        labelInValue: DataTypes.bool,
        dropdownStyle: DataTypes.object,
        disabled: DataTypes.bool,
        defaultValue: DataTypes.any,
        autoFocus: DataTypes.bool,
        dropdownMatchSelectWidth: DataTypes.bool,
        optionFilterProp: DataTypes.string,
        placeholder: DataTypes.string,
        showSearch: DataTypes.bool,
        size: DataTypes.oneOf(['default', 'small', 'large']),
        clearIcon: DataTypes.func,
        suffixIcon: DataTypes.func,
        tokenSeparators: DataTypes.array,
        defaultOpen: DataTypes.bool,
        open: DataTypes.bool
    },
github ecomfe / santd / src / badge / ScrollNumber.js View on Github external
* @file 组件 ScrollNumber
 * @author chenkai13 
 */

import './style/index.less';
import san, {DataTypes} from 'san';

let numberList = [];
for (let i = 0; i &lt; 30; i++) {
    numberList.push(i % 10);
}

export default san.defineComponent({
    dataTypes: {
        prefixCls: DataTypes.string,
        count: DataTypes.oneOfType([DataTypes.string, DataTypes.object, DataTypes.number]),
        title: DataTypes.oneOfType([DataTypes.string, DataTypes.object, DataTypes.number])
    },

    template: `
        <sup title="{{title}}" class="{{prefixCls}}">
            <template>
                {{count}}
            </template>
            <span style="{{styleArr[idx]}};" class="{{prefixCls}}-only">
                <p>{{item}}</p>
            </span></sup>