zs-mini-ali-ui
Version:
中视编译后版本 ali-ui
237 lines (216 loc) • 7.24 kB
JavaScript
;/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 54:
/***/ ((module) => {
function _extends() {
module.exports = _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
module.exports = _extends;
/***/ })
/******/ });
/************************************************************************/
/******/ // 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/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* 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 in strict mode.
(() => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(54);
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
var noop = function noop() {};
function collectArr(arr, ele) {
var resArr = arr;
if (arr instanceof Array) {
resArr.push(ele);
} else {
resArr = [ele];
}
return resArr;
}
var prefixKey = function prefixKey(prefix) {
return function (key) {
return prefix + "-" + key;
};
};
var collapsePrefix = prefixKey('am-collapse');
Component({
data: {
isActive: false,
contentHeight: 0,
contentId: '',
id: '',
activeKey: []
},
props: {
itemKey: '',
// 默认随机数
header: '',
isOpen: false,
showArrow: true,
activeClass: '',
className: '',
titleClass: '',
contentClass: '',
defaultContentHeight: 0,
disabled: false,
collapseKey: ''
},
didMount: function didMount() {
this.initItems();
},
methods: {
initItems: function initItems() {
var _this$props = this.props,
itemKey = _this$props.itemKey,
isOpen = _this$props.isOpen,
defaultContentHeight = _this$props.defaultContentHeight,
collapseKey = _this$props.collapseKey;
this.setData({
isActive: isOpen,
contentHeight: defaultContentHeight,
contentId: this.$id,
id: itemKey || this.$id
});
this.updateStyle({
isActive: isOpen
});
var bindedMethod = this.handleItemDataUpdate.bind(this);
this.$page[collapsePrefix("updates-" + collapseKey)] = collectArr(this.$page[collapsePrefix("updates-" + collapseKey)], bindedMethod);
this.$page[collapsePrefix("ids-" + collapseKey)] = collectArr(this.$page[collapsePrefix("ids-" + collapseKey)], this.data.id);
},
handleItemDataUpdate: function handleItemDataUpdate(data) {
this.setData(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, data));
var _this$data = this.data,
activeKey = _this$data.activeKey,
id = _this$data.id;
var isActive = activeKey.indexOf(id) !== -1;
this.setData({
isActive: isActive
});
this.updateStyle({
isActive: isActive
});
},
onCollapseTap: function onCollapseTap(evt) {
var collapseKey = this.props.collapseKey;
if (!this.props.disabled) {
var dataset = evt.currentTarget.dataset;
this.$page[collapsePrefix("handleItemTap-" + collapseKey)](dataset.key);
}
},
updateStyle: function updateStyle(_ref) {
var _this = this;
var isActive = _ref.isActive,
_ref$callback = _ref.callback,
callback = _ref$callback === void 0 ? noop : _ref$callback;
if (!isActive) {
this.setData({
isActive: isActive,
contentHeight: 0
});
callback();
} else {
this.calcContentHeight(".am-collapse-item-content." + ("am-collapse-item-content-" + this.$id)).then(function (height) {
_this.setData({
isActive: isActive,
contentHeight: height
});
callback();
});
}
},
calcContentHeight: function calcContentHeight(selector) {
if (selector === void 0) {
selector = '';
}
return new Promise(function (resolve, reject) {
my.createSelectorQuery().select(selector).boundingClientRect().exec(function (res) {
if (res && res[0]) {
resolve(res[0].height);
} else {
reject(res);
}
});
});
}
}
});
})();
/******/ })()
;