UNPKG

weex-nuke

Version:

基于 Rax 、Weex 的高性能组件体系 ~~

70 lines (59 loc) 1.38 kB
/** @jsx createElement */ 'use strict'; import { Component, createElement, PropTypes, render } from 'rax'; import defaultLocale from './locale'; const noop = () => {}; let nativePicker = require('@weex-module/picker'); let pickerInstance = null, container = null; let Picker = {}; function show(options = {}, onSelect, onCancel, onShow, onFail) { onSelect = onSelect || noop; onShow = onShow || noop; onCancel = onCancel || noop; onFail = onFail || noop; let { title, dataSource, selectedKey, maskClosable = true, visible, value, content, children, locale = {}, ...others } = options; if (!dataSource) { onFail({ err: 'empty dataSource' }); return; } if (!selectedKey) { selectedKey = 0; } const cancelTitle = locale.cancel || defaultLocale.cancel; const confirmTitle = locale.confirm || defaultLocale.confirm; nativePicker.pick( { items: dataSource, index: selectedKey, title: title, cancelTitle: cancelTitle, confirmTitle: confirmTitle }, e => { if (e.result === 'success') { onSelect(e); return; } else if (e.result === 'cancel') { onCancel(e); return; } else if (e.result === 'error') { onFail(e); return; } } ); } function hide() {} export default { show, hide };