zs-mini-ali-ui
Version:
中视编译后版本 ali-ui
258 lines (228 loc) • 8.29 kB
JavaScript
;/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 13:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ fmtClass)
/* harmony export */ });
var hasOwn = {}.hasOwnProperty;
/* eslint-disable no-continue, prefer-spread */
function fmtClass() {
var classes = [];
for (var i = 0; i < arguments.length; i++) {
var arg = i < 0 || arguments.length <= i ? undefined : arguments[i];
if (!arg) continue;
var argType = typeof arg;
if (argType === 'string' || argType === 'number') {
classes.push(arg);
} else if (Array.isArray(arg) && arg.length) {
var inner = fmtClass.apply(null, arg);
if (inner) {
classes.push(inner);
}
} else if (argType === 'object') {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}
}
return classes.join(' ');
}
/***/ }),
/***/ 1:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ fmtEvent)
/* harmony export */ });
function fmtEvent(props, e) {
var dataset = {};
for (var key in props) {
if (/data-/gi.test(key)) {
dataset[key.replace(/data-/gi, '')] = props[key];
}
}
return Object.assign({}, e, {
currentTarget: {
dataset: dataset
},
target: {
dataset: dataset,
targetDataset: dataset
}
});
}
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _util_fmtClass__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
/* harmony import */ var _util_fmtEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
var SUPPORT_COMPONENT2 = my.canIUse('component2');
var prefixCls = 'am-button';
var noop = function noop() {};
Component({
mixins: [],
data: {
baseClass: prefixCls
},
props: {
className: '',
type: '',
dataName: '',
disabled: false,
subtitle: '',
onTap: noop,
capsuleMinWidth: false,
showLoading: false
},
onInit: function onInit() {
if (!this.props.hoverClass) {
this.props.hoverClass = 'am-button-active';
if (this.props.type === 'text') {
this.props.hoverClass = 'am-button-active-text';
}
}
this.setData({
baseClass: this.wrapBaseCls(this.props),
hoverClass: this.props.hoverClass
});
},
deriveDataFromProps: function deriveDataFromProps(nextProps) {
if (this.propsChange(this.props, nextProps)) {
this.setData({
baseClass: this.wrapBaseCls(nextProps)
});
}
},
didMount: function didMount() {
if (!SUPPORT_COMPONENT2) {
if (!this.props.hoverClass) {
this.props.hoverClass = 'am-button-active';
if (this.props.type === 'text') {
this.props.hoverClass = 'am-button-active-text';
}
}
this.setData({
baseClass: this.wrapBaseCls(this.props),
hoverClass: this.props.hoverClass
});
}
},
didUpdate: function didUpdate(prevProps) {
if (!SUPPORT_COMPONENT2 && this.propsChange(prevProps, this.props)) {
this.setData({
baseClass: this.wrapBaseCls(this.props)
});
}
},
didUnmount: function didUnmount() {},
methods: {
wrapBaseCls: function wrapBaseCls(props) {
var _fmtClass;
var type = props.type,
disabled = props.disabled,
subtitle = props.subtitle,
shape = props.shape,
_props$capsuleSize = props.capsuleSize,
capsuleSize = _props$capsuleSize === void 0 ? 'medium' : _props$capsuleSize,
capsuleMinWidth = props.capsuleMinWidth;
var capsuleMinWidthCls = '';
if (capsuleMinWidth) {
capsuleMinWidthCls = prefixCls + "-capsule-" + capsuleSize + "-minwidth";
}
var ret = (0,_util_fmtClass__WEBPACK_IMPORTED_MODULE_0__["default"])((_fmtClass = {}, _fmtClass["" + prefixCls] = true, _fmtClass[prefixCls + "-primary"] = type === 'primary', _fmtClass[prefixCls + "-ghost"] = type === 'ghost', _fmtClass[prefixCls + "-warn"] = type === 'warn', _fmtClass[prefixCls + "-warn-ghost"] = type === 'warn-ghost', _fmtClass[prefixCls + "-text"] = type === 'text', _fmtClass[prefixCls + "-light"] = type === 'light', _fmtClass[prefixCls + "-capsule " + prefixCls + "-capsule-" + capsuleSize + " " + capsuleMinWidthCls] = shape === 'capsule', _fmtClass[prefixCls + "-disabled"] = disabled, _fmtClass[prefixCls + "-subtitle"] = subtitle, _fmtClass));
return ret;
},
onButtonTap: function onButtonTap(e) {
var event = (0,_util_fmtEvent__WEBPACK_IMPORTED_MODULE_1__["default"])(this.props, e);
this.props.onTap(event);
},
onGetAuthorize: function onGetAuthorize(e) {
var event = (0,_util_fmtEvent__WEBPACK_IMPORTED_MODULE_1__["default"])(this.props, e);
this.props.onGetAuthorize(event);
},
onError: function onError(e) {
var event = (0,_util_fmtEvent__WEBPACK_IMPORTED_MODULE_1__["default"])(this.props, e);
this.props.onError(event);
},
propsChange: function propsChange(prevProps, nextProps) {
var pProps = Object.getOwnPropertyNames(prevProps);
var nProps = Object.getOwnPropertyNames(nextProps);
if (pProps.length !== nProps.length) {
return true;
}
for (var i = 0; i < pProps.length; i++) {
var propName = pProps[i];
if (prevProps[propName] !== nextProps[propName]) {
return true;
}
}
return false;
}
}
});
})();
/******/ })()
;