UNPKG

weex-nuke

Version:

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

85 lines (68 loc) 2.44 kB
/** @jsx createElement */ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _rax = require('rax'); var _locale = require('./locale.js'); var _locale2 = _interopRequireDefault(_locale); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } var noop = function noop() {}; var nativePicker = require('@weex-module/picker'); var pickerInstance = null, container = null; var Picker = {}; function show() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var onSelect = arguments[1]; var onCancel = arguments[2]; var onShow = arguments[3]; var onFail = arguments[4]; onSelect = onSelect || noop; onShow = onShow || noop; onCancel = onCancel || noop; onFail = onFail || noop; var title = options.title, dataSource = options.dataSource, selectedKey = options.selectedKey, _options$maskClosable = options.maskClosable, maskClosable = _options$maskClosable === undefined ? true : _options$maskClosable, visible = options.visible, value = options.value, content = options.content, children = options.children, _options$locale = options.locale, locale = _options$locale === undefined ? {} : _options$locale, others = _objectWithoutProperties(options, ['title', 'dataSource', 'selectedKey', 'maskClosable', 'visible', 'value', 'content', 'children', 'locale']); if (!dataSource) { onFail({ err: 'empty dataSource' }); return; } if (!selectedKey) { selectedKey = 0; } var cancelTitle = locale.cancel || _locale2.default.cancel; var confirmTitle = locale.confirm || _locale2.default.confirm; nativePicker.pick({ items: dataSource, index: selectedKey, title: title, cancelTitle: cancelTitle, confirmTitle: confirmTitle }, function (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() {} exports.default = { show: show, hide: hide }; module.exports = exports['default'];