antd-mini-rpx
Advanced tools
Comparing version 0.0.4 to 0.0.5-alpha.1
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseStore = void 0; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var BaseStore = /*#__PURE__*/function () { | ||
function BaseStore() { | ||
(0, _classCallCheck2["default"])(this, BaseStore); | ||
this.itemsMap = {}; | ||
} | ||
(0, _createClass2["default"])(BaseStore, [{ | ||
key: "addItem", | ||
value: function addItem(uid, id, value) { | ||
this.addGroup(uid); | ||
this.setItem(uid, id, value); | ||
var BaseStore = /** @class */ (function () { | ||
function BaseStore() { | ||
this.itemsMap = {}; | ||
} | ||
}, { | ||
key: "addGroup", | ||
value: function addGroup(uid) { | ||
if (!this.itemsMap[uid]) { | ||
this.itemsMap[uid] = { | ||
items: {}, | ||
onChange: null, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
getGroupPropsVal: function getGroupPropsVal() {}, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
setGroupDataVal: function setGroupDataVal() {} | ||
}; | ||
} | ||
} | ||
}, { | ||
key: "removeItem", | ||
value: function removeItem(uid, id) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items && this.getItem(uid, id)) { | ||
this.setItem(uid, id, null); | ||
} | ||
} | ||
}, { | ||
key: "removeGroup", | ||
value: function removeGroup(uid) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid] = null; | ||
} | ||
} | ||
}, { | ||
key: "updateGroupUID", | ||
value: function updateGroupUID(oldUID, newUID) { | ||
if (this.itemsMap[oldUID]) { | ||
this.itemsMap[newUID] = this.itemsMap[oldUID]; | ||
this.itemsMap[oldUID] = null; | ||
} | ||
} | ||
}, { | ||
key: "setGroupPropsVal", | ||
value: function setGroupPropsVal(uid, getGroupPropsVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].getGroupPropsVal = getGroupPropsVal; | ||
} | ||
} | ||
}, { | ||
key: "setGroupDataVal", | ||
value: function setGroupDataVal(uid, _setGroupDataVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].setGroupDataVal = _setGroupDataVal; | ||
} | ||
} | ||
}, { | ||
key: "getGroupDataVal", | ||
value: function getGroupDataVal(uid, _getGroupDataVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].getGroupDataVal = _getGroupDataVal; | ||
} | ||
} | ||
}, { | ||
key: "getGroup", | ||
value: function getGroup(uid) { | ||
if (this.itemsMap[uid]) { | ||
return this.itemsMap[uid]; | ||
} | ||
} | ||
}, { | ||
key: "getItem", | ||
value: function getItem(uid, id) { | ||
return this.itemsMap[uid].items[id]; | ||
} | ||
}, { | ||
key: "setItem", | ||
value: function setItem(uid, id, value) { | ||
this.itemsMap[uid].items[id] = value; | ||
} | ||
}]); | ||
return BaseStore; | ||
}(); | ||
BaseStore.prototype.addItem = function (uid, id, value) { | ||
this.addGroup(uid); | ||
this.setItem(uid, id, value); | ||
}; | ||
BaseStore.prototype.addGroup = function (uid) { | ||
if (!this.itemsMap[uid]) { | ||
this.itemsMap[uid] = { | ||
items: {}, | ||
onChange: null, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
getGroupPropsVal: function () { }, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
setGroupDataVal: function () { }, | ||
}; | ||
} | ||
}; | ||
BaseStore.prototype.removeItem = function (uid, id) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items && this.getItem(uid, id)) { | ||
this.setItem(uid, id, null); | ||
} | ||
}; | ||
BaseStore.prototype.removeGroup = function (uid) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid] = null; | ||
} | ||
}; | ||
BaseStore.prototype.updateGroupUID = function (oldUID, newUID) { | ||
if (this.itemsMap[oldUID]) { | ||
this.itemsMap[newUID] = this.itemsMap[oldUID]; | ||
this.itemsMap[oldUID] = null; | ||
} | ||
}; | ||
BaseStore.prototype.setGroupPropsVal = function (uid, getGroupPropsVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].getGroupPropsVal = getGroupPropsVal; | ||
} | ||
}; | ||
BaseStore.prototype.setGroupDataVal = function (uid, setGroupDataVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].setGroupDataVal = setGroupDataVal; | ||
} | ||
}; | ||
BaseStore.prototype.getGroupDataVal = function (uid, getGroupDataVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].getGroupDataVal = getGroupDataVal; | ||
} | ||
}; | ||
BaseStore.prototype.getGroup = function (uid) { | ||
if (this.itemsMap[uid]) { | ||
return this.itemsMap[uid]; | ||
} | ||
}; | ||
BaseStore.prototype.getItem = function (uid, id) { | ||
return this.itemsMap[uid].items[id]; | ||
}; | ||
BaseStore.prototype.setItem = function (uid, id, value) { | ||
this.itemsMap[uid].items[id] = value; | ||
}; | ||
return BaseStore; | ||
}()); | ||
exports.BaseStore = BaseStore; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CheckBoxStore = void 0; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _baseStore = require("./baseStore"); | ||
var _tools = require("./tools"); | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
var CheckBoxStore = /*#__PURE__*/function (_BaseStore) { | ||
(0, _inherits2["default"])(CheckBoxStore, _BaseStore); | ||
var _super = _createSuper(CheckBoxStore); | ||
function CheckBoxStore() { | ||
(0, _classCallCheck2["default"])(this, CheckBoxStore); | ||
return _super.apply(this, arguments); | ||
} | ||
(0, _createClass2["default"])(CheckBoxStore, [{ | ||
key: "checkControlledByUID", | ||
value: function checkControlledByUID(uid) { | ||
return this.itemsMap[uid].getGroupPropsVal('controlled'); | ||
var baseStore_1 = require("./baseStore"); | ||
var tools_1 = require("./tools"); | ||
var CheckBoxStore = /** @class */ (function (_super) { | ||
__extends(CheckBoxStore, _super); | ||
function CheckBoxStore() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
}, { | ||
key: "updateGroup", | ||
value: function updateGroup(newUID, _ref, _ref2) { | ||
var isUIDChanged = _ref.isUIDChanged, | ||
isDisabledChanged = _ref.isDisabledChanged, | ||
isValueChange = _ref.isValueChange; | ||
var oldUID = _ref2.oldUID; | ||
if (isUIDChanged) { | ||
this.updateGroupUID(oldUID, newUID); | ||
} | ||
var group = this.getGroup(newUID); | ||
if (isDisabledChanged && group) { | ||
var groupDisabled = group.getGroupPropsVal('disabled'); | ||
this.updateGroupDisabled(newUID, groupDisabled); | ||
} | ||
if (isValueChange) { | ||
this.updateGroupValue(newUID); | ||
} | ||
} | ||
CheckBoxStore.prototype.checkControlledByUID = function (uid) { | ||
return this.itemsMap[uid].getGroupPropsVal('controlled'); | ||
}; | ||
CheckBoxStore.prototype.updateGroup = function (newUID, _a, _b) { | ||
var isUIDChanged = _a.isUIDChanged, isDisabledChanged = _a.isDisabledChanged, isValueChange = _a.isValueChange; | ||
var oldUID = _b.oldUID; | ||
if (isUIDChanged) { | ||
this.updateGroupUID(oldUID, newUID); | ||
} | ||
var group = this.getGroup(newUID); | ||
if (isDisabledChanged && group) { | ||
var groupDisabled = group.getGroupPropsVal('disabled'); | ||
this.updateGroupDisabled(newUID, groupDisabled); | ||
} | ||
if (isValueChange) { | ||
this.updateGroupValue(newUID); | ||
} | ||
}; | ||
/** | ||
@@ -74,92 +50,73 @@ * 修改 CheckboxGroup 的 value 以改变 CheckboxItem 的选中状态 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
}, { | ||
key: "updateGroupValue", | ||
value: function updateGroupValue(uid, value) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
var groupValue = value || this.itemsMap[uid].getGroupPropsVal('value'); | ||
(0, _tools.objectEntries)(this.itemsMap[uid].items).forEach(function (_ref3) { | ||
var _ref4 = (0, _slicedToArray2["default"])(_ref3, 2), | ||
val = _ref4[1]; | ||
if (!val) return; | ||
if (groupValue.indexOf(val.getItemPropsVal('value')) > -1) { | ||
val.setChecked(true); | ||
} else { | ||
val.setChecked(false); | ||
} | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "updateGroupDisabled", | ||
value: function updateGroupDisabled(uid, disabled) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
(0, _tools.objectEntries)(this.itemsMap[uid].items).forEach(function (_ref5) { | ||
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2), | ||
val = _ref6[1]; | ||
if (!val) return; | ||
var finalDisbaled = disabled; | ||
val.setDisabled(finalDisbaled); | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "updateItemDisabled", | ||
value: function updateItemDisabled(uid, disabled) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
(0, _tools.objectEntries)(this.itemsMap[uid].items).forEach(function (_ref7) { | ||
var _ref8 = (0, _slicedToArray2["default"])(_ref7, 2), | ||
val = _ref8[1]; | ||
if (!val) return; | ||
var itemDsiabled = val; | ||
var finalDisbaled = itemDsiabled && disabled; | ||
val.setDisabled(finalDisbaled); | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "triggerItem", | ||
value: function triggerItem(uid, id, checked) { | ||
if (this.itemsMap[uid] && this.getItem(uid, id)) { | ||
this.getItem(uid, id).setChecked(checked); | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (onChange) { | ||
var value = (0, _tools.objectEntries)(this.itemsMap[uid].items).filter(function (_ref9) { | ||
var _ref10 = (0, _slicedToArray2["default"])(_ref9, 2), | ||
val = _ref10[1]; | ||
return val && val.getChecked() === true; | ||
}).map(function (_ref11) { | ||
var _ref12 = (0, _slicedToArray2["default"])(_ref11, 2), | ||
val = _ref12[1]; | ||
return val.getItemPropsVal('value'); | ||
}); | ||
onChange(value); | ||
CheckBoxStore.prototype.updateGroupValue = function (uid, value) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
var groupValue_1 = value || this.itemsMap[uid].getGroupPropsVal('value'); | ||
(0, tools_1.objectEntries)(this.itemsMap[uid].items).forEach(function (_a) { | ||
var val = _a[1]; | ||
if (!val) | ||
return; | ||
if (groupValue_1.indexOf(val.getItemPropsVal('value')) > -1) { | ||
val.setChecked(true); | ||
} | ||
else { | ||
val.setChecked(false); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "updateItemValue", | ||
value: function updateItemValue(uid, id) { | ||
if (this.itemsMap[uid] && this.getItem(uid, id)) { | ||
var groupValue = this.itemsMap[uid].getGroupPropsVal('value'); | ||
var itemValue = this.getItem(uid, id).getItemPropsVal('value'); | ||
if (groupValue.indexOf(itemValue) > -1) { | ||
this.getItem(uid, id).setChecked(true); | ||
} else { | ||
this.getItem(uid, id).setChecked(false); | ||
}; | ||
CheckBoxStore.prototype.updateGroupDisabled = function (uid, disabled) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
(0, tools_1.objectEntries)(this.itemsMap[uid].items).forEach(function (_a) { | ||
var val = _a[1]; | ||
if (!val) | ||
return; | ||
var finalDisbaled = disabled; | ||
val.setDisabled(finalDisbaled); | ||
}); | ||
} | ||
} | ||
} | ||
}]); | ||
return CheckBoxStore; | ||
}(_baseStore.BaseStore); | ||
}; | ||
CheckBoxStore.prototype.updateItemDisabled = function (uid, disabled) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
(0, tools_1.objectEntries)(this.itemsMap[uid].items).forEach(function (_a) { | ||
var val = _a[1]; | ||
if (!val) | ||
return; | ||
var itemDsiabled = val; | ||
var finalDisbaled = itemDsiabled && disabled; | ||
val.setDisabled(finalDisbaled); | ||
}); | ||
} | ||
}; | ||
CheckBoxStore.prototype.triggerItem = function (uid, id, checked) { | ||
if (this.itemsMap[uid] && this.getItem(uid, id)) { | ||
this.getItem(uid, id).setChecked(checked); | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (onChange) { | ||
var value = (0, tools_1.objectEntries)(this.itemsMap[uid].items) | ||
.filter(function (_a) { | ||
var val = _a[1]; | ||
return val && val.getChecked() === true; | ||
}) | ||
.map(function (_a) { | ||
var val = _a[1]; | ||
return val.getItemPropsVal('value'); | ||
}); | ||
onChange(value); | ||
} | ||
} | ||
}; | ||
CheckBoxStore.prototype.updateItemValue = function (uid, id) { | ||
if (this.itemsMap[uid] && this.getItem(uid, id)) { | ||
var groupValue = this.itemsMap[uid].getGroupPropsVal('value'); | ||
var itemValue = this.getItem(uid, id).getItemPropsVal('value'); | ||
if (groupValue.indexOf(itemValue) > -1) { | ||
this.getItem(uid, id).setChecked(true); | ||
} | ||
else { | ||
this.getItem(uid, id).setChecked(false); | ||
} | ||
} | ||
}; | ||
return CheckBoxStore; | ||
}(baseStore_1.BaseStore)); | ||
exports.CheckBoxStore = CheckBoxStore; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CollapseStore = void 0; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _baseStore = require("./baseStore"); | ||
var _tools = require("../_util/tools"); | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
var CollapseStore = /*#__PURE__*/function (_BaseStore) { | ||
(0, _inherits2["default"])(CollapseStore, _BaseStore); | ||
var _super = _createSuper(CollapseStore); | ||
function CollapseStore() { | ||
(0, _classCallCheck2["default"])(this, CollapseStore); | ||
return _super.apply(this, arguments); | ||
} | ||
(0, _createClass2["default"])(CollapseStore, [{ | ||
key: "setItemsAccordion", | ||
value: function setItemsAccordion(uid) { | ||
var accordion = !!this.itemsMap[uid].getGroupPropsVal('accordion'); | ||
(0, _tools.objectEntries)(this.itemsMap[uid].items).forEach(function (_ref) { | ||
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2), | ||
val = _ref2[1]; | ||
val.setAccordion(accordion); | ||
}); | ||
var baseStore_1 = require("./baseStore"); | ||
var tools_1 = require("../_util/tools"); | ||
var CollapseStore = /** @class */ (function (_super) { | ||
__extends(CollapseStore, _super); | ||
function CollapseStore() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
}, { | ||
key: "updateItemValue", | ||
value: function updateItemValue(uid, id) { | ||
var groupValue = this.itemsMap[uid].getGroupPropsVal('name'); | ||
if (Array.isArray(groupValue)) { | ||
var val = this.itemsMap[uid].items[id]; | ||
var name = val.getItemPropsVal('name'); | ||
if (groupValue.includes(name)) { | ||
val.setActive(true); | ||
CollapseStore.prototype.setItemsAccordion = function (uid) { | ||
var accordion = !!this.itemsMap[uid].getGroupPropsVal('accordion'); | ||
(0, tools_1.objectEntries)(this.itemsMap[uid].items).forEach(function (_a) { | ||
var val = _a[1]; | ||
val.setAccordion(accordion); | ||
}); | ||
}; | ||
CollapseStore.prototype.updateItemValue = function (uid, id) { | ||
var groupValue = this.itemsMap[uid].getGroupPropsVal('name'); | ||
if (Array.isArray(groupValue)) { | ||
var val = this.itemsMap[uid].items[id]; | ||
var name = val.getItemPropsVal('name'); | ||
if (groupValue.includes(name)) { | ||
val.setActive(true); | ||
} | ||
val.setLastAction('auto'); | ||
val.setFirst(); | ||
} | ||
val.setLastAction('auto'); | ||
val.setFirst(); | ||
} | ||
} | ||
}, { | ||
key: "updateGroup", | ||
value: function updateGroup(uid, _ref3, _ref4) { | ||
var isUIDChanged = _ref3.isUIDChanged, | ||
isNameChanged = _ref3.isNameChanged, | ||
isAccordionChanged = _ref3.isAccordionChanged; | ||
var oldUID = _ref4.oldUID; | ||
if (isUIDChanged) { | ||
this.updateGroupUID(oldUID, uid); | ||
} | ||
if (isNameChanged) { | ||
this.updateGroupValue(uid); | ||
} | ||
if (isAccordionChanged) { | ||
var _accordion = !!this.itemsMap[uid].getGroupPropsVal('accordion'); | ||
(0, _tools.objectEntries)(this.itemsMap[uid].items).forEach(function (_ref5) { | ||
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2), | ||
val = _ref6[1]; | ||
val.setAccordion(_accordion); | ||
}); | ||
} | ||
} | ||
}; | ||
CollapseStore.prototype.updateGroup = function (uid, _a, _b) { | ||
var isUIDChanged = _a.isUIDChanged, isNameChanged = _a.isNameChanged, isAccordionChanged = _a.isAccordionChanged; | ||
var oldUID = _b.oldUID; | ||
if (isUIDChanged) { | ||
this.updateGroupUID(oldUID, uid); | ||
} | ||
if (isNameChanged) { | ||
this.updateGroupValue(uid); | ||
} | ||
if (isAccordionChanged) { | ||
var accordion_1 = !!this.itemsMap[uid].getGroupPropsVal('accordion'); | ||
(0, tools_1.objectEntries)(this.itemsMap[uid].items).forEach(function (_a) { | ||
var val = _a[1]; | ||
val.setAccordion(accordion_1); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -101,128 +68,107 @@ * 修改 Collapse 的 name 以改变 CollapseItem 的展开/关闭 | ||
*/ | ||
}, { | ||
key: "updateGroupValue", | ||
value: function updateGroupValue(uid) { | ||
var isFirst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var value = arguments.length > 2 ? arguments[2] : undefined; | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
var originGroupValue = value || this.itemsMap[uid].getGroupPropsVal('name'); | ||
var groupValue = this.itemsMap[uid].getGroupPropsVal('accordion') ? [originGroupValue[0]] : originGroupValue; | ||
if (Array.isArray(groupValue)) { | ||
(0, _tools.objectEntries)(this.itemsMap[uid].items).forEach(function (_ref7) { | ||
var _ref8 = (0, _slicedToArray2["default"])(_ref7, 2), | ||
val = _ref8[1]; | ||
if (!val) return; // for 2.0 | ||
if (val.getSupportSjs()) { | ||
if (groupValue.indexOf(val.getItemPropsVal('name')) > -1) { | ||
val.setActive(true); | ||
} else { | ||
val.setActive(false); | ||
} | ||
val.setLastAction('auto'); | ||
val.setFirst(); | ||
} else { | ||
// for 1.0 | ||
if (groupValue.indexOf(val.getItemPropsVal('name')) > -1) { | ||
// close -> open | ||
val.getContentHeight().then(function (height) { | ||
val.setContentHeight(height); | ||
val.setActive(true); | ||
val.setFirst(); | ||
CollapseStore.prototype.updateGroupValue = function (uid, isFirst, value) { | ||
if (isFirst === void 0) { isFirst = false; } | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
var originGroupValue = value || this.itemsMap[uid].getGroupPropsVal('name'); | ||
var groupValue_1 = this.itemsMap[uid].getGroupPropsVal('accordion') | ||
? [originGroupValue[0]] | ||
: originGroupValue; | ||
if (Array.isArray(groupValue_1)) { | ||
(0, tools_1.objectEntries)(this.itemsMap[uid].items).forEach(function (_a) { | ||
var val = _a[1]; | ||
if (!val) | ||
return; | ||
// for 2.0 | ||
if (val.getSupportSjs()) { | ||
if (groupValue_1.indexOf(val.getItemPropsVal('name')) > -1) { | ||
val.setActive(true); | ||
} | ||
else { | ||
val.setActive(false); | ||
} | ||
val.setLastAction('auto'); | ||
val.setFirst(); | ||
} | ||
else { | ||
// for 1.0 | ||
if (groupValue_1.indexOf(val.getItemPropsVal('name')) > -1) { | ||
// close -> open | ||
val.getContentHeight().then(function (height) { | ||
val.setContentHeight(height); | ||
val.setActive(true); | ||
val.setFirst(); | ||
}); | ||
} | ||
else { | ||
// open -> close | ||
val.getContentHeight().then(function (height) { | ||
val.setContentHeight(height); | ||
val.setFirst(); | ||
setTimeout(function () { | ||
val.setActive(false); | ||
val.setContentHeight('0px'); | ||
}, 10); | ||
}); | ||
} | ||
val.setLastAction('auto'); | ||
} | ||
val.setLastAction('auto'); | ||
}); | ||
} else { | ||
// open -> close | ||
val.getContentHeight().then(function (height) { | ||
val.setContentHeight(height); | ||
val.setFirst(); | ||
setTimeout(function () { | ||
val.setActive(false); | ||
val.setContentHeight('0px'); | ||
}, 10); | ||
}); | ||
} | ||
val.setLastAction('auto'); | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (typeof onChange === 'function' && !isFirst) { | ||
onChange(groupValue_1); | ||
} | ||
} | ||
val.setLastAction('auto'); | ||
}); | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (typeof onChange === 'function' && !isFirst) { | ||
onChange(groupValue); | ||
} | ||
} | ||
} | ||
} | ||
}, { | ||
key: "triggerItem", | ||
value: function triggerItem(uid, id, status) { | ||
if (this.itemsMap[uid] && this.getItem(uid, id)) { | ||
if (this.itemsMap[uid].getGroupPropsVal('accordion') === true) { | ||
var name; | ||
(0, _tools.objectEntries)(this.itemsMap[uid].items).forEach(function (_ref9) { | ||
var _ref10 = (0, _slicedToArray2["default"])(_ref9, 2), | ||
val = _ref10[1]; | ||
if (!val) return; | ||
if (val.getId() === id) { | ||
var active = val.getActive(); | ||
val.setActive(!active); | ||
if (!active) { | ||
name = val.getItemPropsVal('name'); | ||
} | ||
} else { | ||
val.setActive(false); | ||
}; | ||
CollapseStore.prototype.triggerItem = function (uid, id, status) { | ||
if (this.itemsMap[uid] && this.getItem(uid, id)) { | ||
if (this.itemsMap[uid].getGroupPropsVal('accordion') === true) { | ||
var name_1; | ||
(0, tools_1.objectEntries)(this.itemsMap[uid].items).forEach(function (_a) { | ||
var val = _a[1]; | ||
if (!val) | ||
return; | ||
if (val.getId() === id) { | ||
var active = val.getActive(); | ||
val.setActive(!active); | ||
if (!active) { | ||
name_1 = val.getItemPropsVal('name'); | ||
} | ||
} | ||
else { | ||
val.setActive(false); | ||
} | ||
val.setLastAction('onTap'); | ||
val.setFirst(); | ||
}); | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (typeof onChange === 'function') { | ||
var res = name_1 ? [name_1] : []; | ||
onChange(res); | ||
} | ||
return; | ||
} | ||
val.setLastAction('onTap'); | ||
val.setFirst(); | ||
}); | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (typeof onChange === 'function') { | ||
var res = name ? [name] : []; | ||
onChange(res); | ||
} | ||
return; | ||
this.getItem(uid, id).setActive(status); | ||
this.itemsMap[uid].items[id].setLastAction('onTap'); | ||
this.onChangeByTrigger(uid); | ||
} | ||
this.getItem(uid, id).setActive(status); | ||
this.itemsMap[uid].items[id].setLastAction('onTap'); | ||
this.onChangeByTrigger(uid); | ||
} | ||
} | ||
}, { | ||
key: "onChangeByTrigger", | ||
value: function onChangeByTrigger(uid) { | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (typeof onChange === 'function') { | ||
var value = (0, _tools.objectEntries)(this.itemsMap[uid].items).filter(function (_ref11) { | ||
var _ref12 = (0, _slicedToArray2["default"])(_ref11, 2), | ||
val = _ref12[1]; | ||
return val && val.getActive() === true; | ||
}).map(function (_ref13) { | ||
var _ref14 = (0, _slicedToArray2["default"])(_ref13, 2), | ||
val = _ref14[1]; | ||
return val.getItemPropsVal('name'); | ||
}); | ||
onChange(value); | ||
} | ||
} | ||
}]); | ||
return CollapseStore; | ||
}(_baseStore.BaseStore); | ||
}; | ||
CollapseStore.prototype.onChangeByTrigger = function (uid) { | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (typeof onChange === 'function') { | ||
var value = (0, tools_1.objectEntries)(this.itemsMap[uid].items) | ||
.filter(function (_a) { | ||
var val = _a[1]; | ||
return val && val.getActive() === true; | ||
}) | ||
.map(function (_a) { | ||
var val = _a[1]; | ||
return val.getItemPropsVal('name'); | ||
}); | ||
onChange(value); | ||
} | ||
}; | ||
return CollapseStore; | ||
}(baseStore_1.BaseStore)); | ||
exports.CollapseStore = CollapseStore; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.compareAntdMiniVersion = compareAntdMiniVersion; | ||
exports.compareVersion = compareVersion; | ||
exports.getCurrentVersion = getCurrentVersion; | ||
exports.isMoreThan106 = void 0; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isMoreThan106 = exports.compareAntdMiniVersion = exports.getCurrentVersion = exports.compareVersion = void 0; | ||
/* eslint-disable no-console */ | ||
function compareVersion(v1, v2) { | ||
if (v1 === v2) return 0; | ||
var v1Arr = v1.split('.'); | ||
var v2Arr = v2.split('.'); | ||
var len = v1Arr.length < v2Arr.length ? v1Arr.length : v2Arr.length; | ||
var i = 0; | ||
while (i <= len) { | ||
if (v1Arr[i] === v2Arr[i]) { | ||
i++; | ||
} else if (!v1Arr[i] || !v2Arr[i]) { | ||
return v1Arr.length > v2Arr.length ? 1 : -1; | ||
} else { | ||
// eslint-disable-next-line no-nested-ternary | ||
return Number(v1Arr[i]) === Number(v2Arr[i]) ? 0 : Number(v1Arr[i]) > Number(v2Arr[i]) ? 1 : -1; | ||
if (v1 === v2) | ||
return 0; | ||
var v1Arr = v1.split('.'); | ||
var v2Arr = v2.split('.'); | ||
var len = v1Arr.length < v2Arr.length ? v1Arr.length : v2Arr.length; | ||
var i = 0; | ||
while (i <= len) { | ||
if (v1Arr[i] === v2Arr[i]) { | ||
i++; | ||
} | ||
else if (!v1Arr[i] || !v2Arr[i]) { | ||
return v1Arr.length > v2Arr.length ? 1 : -1; | ||
} | ||
else { | ||
// eslint-disable-next-line no-nested-ternary | ||
return Number(v1Arr[i]) === Number(v2Arr[i]) | ||
? 0 | ||
: Number(v1Arr[i]) > Number(v2Arr[i]) | ||
? 1 | ||
: -1; | ||
} | ||
} | ||
} | ||
} | ||
exports.compareVersion = compareVersion; | ||
var currentVersion; | ||
function getCurrentVersion() { | ||
if (typeof currentVersion === 'string') return currentVersion; | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var version = require('../../package.json').version; // 1.0.6 or 1.0.6-beat.1 | ||
currentVersion = version.split('-')[0]; | ||
return currentVersion; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
if (typeof currentVersion === 'string') | ||
return currentVersion; | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var version = require('../../package.json').version; | ||
// 1.0.6 or 1.0.6-beat.1 | ||
currentVersion = version.split('-')[0]; | ||
return currentVersion; | ||
} | ||
catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
exports.getCurrentVersion = getCurrentVersion; | ||
/** | ||
@@ -51,9 +50,6 @@ * 检测 antd-mini 版本是否高于特定版本 | ||
*/ | ||
function compareAntdMiniVersion(version) { | ||
return compareVersion(getCurrentVersion(), version) > 0; | ||
return compareVersion(getCurrentVersion(), version) > 0; | ||
} | ||
var isMoreThan106 = compareAntdMiniVersion('1.0.6'); | ||
exports.isMoreThan106 = isMoreThan106; | ||
exports.compareAntdMiniVersion = compareAntdMiniVersion; | ||
exports.isMoreThan106 = compareAntdMiniVersion('1.0.6'); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.log = exports.EComponents = void 0; | ||
// eslint-disable-next-line no-shadow | ||
var EComponents; | ||
exports.EComponents = EComponents; | ||
(function (EComponents) { | ||
EComponents["Alphabet"] = "Alphabet"; | ||
EComponents["AmountInput"] = "AmountInput"; | ||
EComponents["Badge"] = "Badge"; | ||
EComponents["Button"] = "Button"; | ||
EComponents["Calendar"] = "Calendar"; | ||
EComponents["Checkbox"] = "Checkbox"; | ||
EComponents["CheckboxGroup"] = "CheckboxGroup"; | ||
EComponents["CheckboxItem"] = "CheckboxItem"; | ||
EComponents["Collapse"] = "Collapse"; | ||
EComponents["CollapseItem"] = "CollapseItem"; | ||
EComponents["Container"] = "Container"; | ||
EComponents["DatePicker"] = "DatePicker"; | ||
EComponents["Filter"] = "Filter"; | ||
EComponents["Footer"] = "Footer"; | ||
EComponents["FooterEnd"] = "FooterEnd"; | ||
EComponents["FooterImage"] = "FooterImage"; | ||
EComponents["FooterLink"] = "FooterLink"; | ||
EComponents["FooterTag"] = "FooterTag"; | ||
EComponents["FooterText"] = "FooterText"; | ||
EComponents["Form"] = "Form"; | ||
EComponents["FormGroup"] = "FormGroup"; | ||
EComponents["FormItem"] = "FormItem"; | ||
EComponents["Grid"] = "Grid"; | ||
EComponents["GuideModal"] = "GuideModal"; | ||
EComponents["GuideItem"] = "GuideItem"; | ||
EComponents["HorizontalScrollbar"] = "HorizontalScrollbar"; | ||
EComponents["Icon"] = "Icon"; | ||
EComponents["InputItem"] = "InputItem"; | ||
EComponents["List"] = "List"; | ||
EComponents["ListItem"] = "ListItem"; | ||
EComponents["Loading"] = "Loading"; | ||
EComponents["Mask"] = "Mask"; | ||
EComponents["Modal"] = "Modal"; | ||
EComponents["NoticeBar"] = "NoticeBar"; | ||
EComponents["NoticeBarCapsule"] = "NoticeBarCapsule"; | ||
EComponents["Pagination"] = "Pagination"; | ||
EComponents["Picker"] = "Picker"; | ||
EComponents["Popover"] = "Popover"; | ||
EComponents["PopoverItem"] = "PopoverItem"; | ||
EComponents["Popup"] = "Popup"; | ||
EComponents["RadioGroup"] = "RadioGroup"; | ||
EComponents["RadioItem"] = "RadioItem"; | ||
EComponents["Result"] = "Result"; | ||
EComponents["SafeArea"] = "SafeArea"; | ||
EComponents["SearchBar"] = "SearchBar"; | ||
EComponents["Selector"] = "Selector"; | ||
EComponents["Stepper"] = "Stepper"; | ||
EComponents["Steps"] = "Steps"; | ||
EComponents["StepItem"] = "StepItem"; | ||
EComponents["SwipeAction"] = "SwipeAction"; | ||
EComponents["Switch"] = "Switch"; | ||
EComponents["Tabs"] = "Tabs"; | ||
EComponents["TabItem"] = "TabItem"; | ||
EComponents["Tag"] = "Tag"; | ||
EComponents["Terms"] = "Terms"; | ||
EComponents["Textarea"] = "Textarea"; | ||
EComponents["Tips"] = "Tips"; | ||
EComponents["Title"] = "Title"; | ||
EComponents["VerifyCode"] = "VerifyCode"; | ||
EComponents["Vtabs"] = "Vtabs"; | ||
EComponents["VTabItem"] = "VTabItem"; | ||
EComponents["WhiteSpace"] = "WhiteSpace"; | ||
})(EComponents || (exports.EComponents = EComponents = {})); | ||
var log = { | ||
warn: function warn(component, message) { | ||
var info = "[antd-mini: ".concat(component, "] \uD83D\uDCE1 ").concat(message); // eslint-disable-next-line no-console | ||
console.warn(info); | ||
}, | ||
error: function error(component, message) { | ||
var info = "[antd-mini: ".concat(component, "] \uD83D\uDCE1 ").concat(message); // eslint-disable-next-line no-console | ||
console.error(info); | ||
} | ||
}; | ||
exports.log = log; | ||
EComponents["Alphabet"] = "Alphabet"; | ||
EComponents["AmountInput"] = "AmountInput"; | ||
EComponents["Badge"] = "Badge"; | ||
EComponents["Button"] = "Button"; | ||
EComponents["Calendar"] = "Calendar"; | ||
EComponents["Checkbox"] = "Checkbox"; | ||
EComponents["CheckboxGroup"] = "CheckboxGroup"; | ||
EComponents["CheckboxItem"] = "CheckboxItem"; | ||
EComponents["Collapse"] = "Collapse"; | ||
EComponents["CollapseItem"] = "CollapseItem"; | ||
EComponents["Container"] = "Container"; | ||
EComponents["DatePicker"] = "DatePicker"; | ||
EComponents["Filter"] = "Filter"; | ||
EComponents["Footer"] = "Footer"; | ||
EComponents["FooterEnd"] = "FooterEnd"; | ||
EComponents["FooterImage"] = "FooterImage"; | ||
EComponents["FooterLink"] = "FooterLink"; | ||
EComponents["FooterTag"] = "FooterTag"; | ||
EComponents["FooterText"] = "FooterText"; | ||
EComponents["Form"] = "Form"; | ||
EComponents["FormGroup"] = "FormGroup"; | ||
EComponents["FormItem"] = "FormItem"; | ||
EComponents["Grid"] = "Grid"; | ||
EComponents["GuideModal"] = "GuideModal"; | ||
EComponents["GuideItem"] = "GuideItem"; | ||
EComponents["HorizontalScrollbar"] = "HorizontalScrollbar"; | ||
EComponents["Icon"] = "Icon"; | ||
EComponents["InputItem"] = "InputItem"; | ||
EComponents["List"] = "List"; | ||
EComponents["ListItem"] = "ListItem"; | ||
EComponents["Loading"] = "Loading"; | ||
EComponents["Mask"] = "Mask"; | ||
EComponents["Modal"] = "Modal"; | ||
EComponents["NoticeBar"] = "NoticeBar"; | ||
EComponents["NoticeBarCapsule"] = "NoticeBarCapsule"; | ||
EComponents["Pagination"] = "Pagination"; | ||
EComponents["Picker"] = "Picker"; | ||
EComponents["Popover"] = "Popover"; | ||
EComponents["PopoverItem"] = "PopoverItem"; | ||
EComponents["Popup"] = "Popup"; | ||
EComponents["RadioGroup"] = "RadioGroup"; | ||
EComponents["RadioItem"] = "RadioItem"; | ||
EComponents["Result"] = "Result"; | ||
EComponents["SafeArea"] = "SafeArea"; | ||
EComponents["SearchBar"] = "SearchBar"; | ||
EComponents["Selector"] = "Selector"; | ||
EComponents["Stepper"] = "Stepper"; | ||
EComponents["Steps"] = "Steps"; | ||
EComponents["StepItem"] = "StepItem"; | ||
EComponents["SwipeAction"] = "SwipeAction"; | ||
EComponents["Switch"] = "Switch"; | ||
EComponents["Tabs"] = "Tabs"; | ||
EComponents["TabItem"] = "TabItem"; | ||
EComponents["Tag"] = "Tag"; | ||
EComponents["Terms"] = "Terms"; | ||
EComponents["Textarea"] = "Textarea"; | ||
EComponents["Tips"] = "Tips"; | ||
EComponents["Title"] = "Title"; | ||
EComponents["VerifyCode"] = "VerifyCode"; | ||
EComponents["Vtabs"] = "Vtabs"; | ||
EComponents["VTabItem"] = "VTabItem"; | ||
EComponents["WhiteSpace"] = "WhiteSpace"; | ||
})(EComponents = exports.EComponents || (exports.EComponents = {})); | ||
exports.log = { | ||
warn: function (component, message) { | ||
var info = "[antd-mini: ".concat(component, "] \uD83D\uDCE1 ").concat(message); | ||
// eslint-disable-next-line no-console | ||
console.warn(info); | ||
}, | ||
error: function (component, message) { | ||
var info = "[antd-mini: ".concat(component, "] \uD83D\uDCE1 ").concat(message); | ||
// eslint-disable-next-line no-console | ||
console.error(info); | ||
}, | ||
}; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Context = exports.ComponentContext = void 0; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
var ComponentContext = /*#__PURE__*/function () { | ||
function ComponentContext() { | ||
(0, _classCallCheck2["default"])(this, ComponentContext); | ||
(0, _defineProperty2["default"])(this, "fns", []); | ||
} | ||
(0, _createClass2["default"])(ComponentContext, [{ | ||
key: "get", | ||
value: function get() { | ||
return this.value; | ||
var ComponentContext = /** @class */ (function () { | ||
function ComponentContext() { | ||
this.fns = []; | ||
} | ||
}, { | ||
key: "update", | ||
value: function update(value) { | ||
var _this$fns; | ||
this.value = value; | ||
(_this$fns = this.fns) === null || _this$fns === void 0 ? void 0 : _this$fns.forEach(function (fn) { | ||
fn(value); | ||
}); | ||
} | ||
}, { | ||
key: "onUpdate", | ||
value: function onUpdate(fn) { | ||
this.fns.push(fn); | ||
} | ||
}, { | ||
key: "clearEvent", | ||
value: function clearEvent() { | ||
this.fns = []; | ||
} | ||
}, { | ||
key: "offUpdate", | ||
value: function offUpdate(fn) { | ||
this.fns = this.fns.filter(function (item) { | ||
return item !== fn; | ||
}); | ||
} | ||
}]); | ||
return ComponentContext; | ||
}(); | ||
ComponentContext.prototype.get = function () { | ||
return this.value; | ||
}; | ||
ComponentContext.prototype.update = function (value) { | ||
var _a; | ||
this.value = value; | ||
(_a = this.fns) === null || _a === void 0 ? void 0 : _a.forEach(function (fn) { | ||
fn(value); | ||
}); | ||
}; | ||
ComponentContext.prototype.onUpdate = function (fn) { | ||
this.fns.push(fn); | ||
}; | ||
ComponentContext.prototype.clearEvent = function () { | ||
this.fns = []; | ||
}; | ||
ComponentContext.prototype.offUpdate = function (fn) { | ||
this.fns = this.fns.filter(function (item) { return item !== fn; }); | ||
}; | ||
return ComponentContext; | ||
}()); | ||
exports.ComponentContext = ComponentContext; | ||
var Context = /*#__PURE__*/function () { | ||
function Context() { | ||
(0, _classCallCheck2["default"])(this, Context); | ||
(0, _defineProperty2["default"])(this, "_values", {}); | ||
(0, _defineProperty2["default"])(this, "_fns", {}); | ||
} | ||
(0, _createClass2["default"])(Context, [{ | ||
key: "get", | ||
value: function get(uid) { | ||
var _this$_values$uid; | ||
return (_this$_values$uid = this._values[uid]) !== null && _this$_values$uid !== void 0 ? _this$_values$uid : null; | ||
var Context = /** @class */ (function () { | ||
function Context() { | ||
this._values = {}; | ||
this._fns = {}; | ||
} | ||
}, { | ||
key: "update", | ||
value: function update(uid, value) { | ||
var _this$_fns$uid; | ||
this._values[uid] = value; | ||
(_this$_fns$uid = this._fns[uid]) === null || _this$_fns$uid === void 0 ? void 0 : _this$_fns$uid.forEach(function (fn) { | ||
fn(value); | ||
}); | ||
} | ||
}, { | ||
key: "updateValue", | ||
value: function updateValue(uid, value) { | ||
this._values[uid] = value; | ||
} | ||
}, { | ||
key: "onUpdate", | ||
value: function onUpdate(uid, fn) { | ||
if (!this._fns[uid]) { | ||
this._fns[uid] = []; | ||
} | ||
this._fns[uid].push(fn); | ||
} | ||
}, { | ||
key: "clearEvent", | ||
value: function clearEvent(uid) { | ||
delete this._fns[uid]; | ||
} | ||
}, { | ||
key: "offUpdate", | ||
value: function offUpdate(uid, fn) { | ||
if (this._fns[uid]) { | ||
this._fns[uid] = this._fns[uid].filter(function (item) { | ||
return item !== fn; | ||
Context.prototype.get = function (uid) { | ||
var _a; | ||
return (_a = this._values[uid]) !== null && _a !== void 0 ? _a : null; | ||
}; | ||
Context.prototype.update = function (uid, value) { | ||
var _a; | ||
this._values[uid] = value; | ||
(_a = this._fns[uid]) === null || _a === void 0 ? void 0 : _a.forEach(function (fn) { | ||
fn(value); | ||
}); | ||
} | ||
} | ||
}]); | ||
return Context; | ||
}(); | ||
}; | ||
Context.prototype.updateValue = function (uid, value) { | ||
this._values[uid] = value; | ||
}; | ||
Context.prototype.onUpdate = function (uid, fn) { | ||
if (!this._fns[uid]) { | ||
this._fns[uid] = []; | ||
} | ||
this._fns[uid].push(fn); | ||
}; | ||
Context.prototype.clearEvent = function (uid) { | ||
delete this._fns[uid]; | ||
}; | ||
Context.prototype.offUpdate = function (uid, fn) { | ||
if (this._fns[uid]) { | ||
this._fns[uid] = this._fns[uid].filter(function (item) { return item !== fn; }); | ||
} | ||
}; | ||
return Context; | ||
}()); | ||
exports.Context = Context; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.isBetweenDate = isBetweenDate; | ||
exports.isSameDate = isSameDate; | ||
var _dayjs = _interopRequireDefault(require("dayjs")); | ||
var _isBetween = _interopRequireDefault(require("dayjs/plugin/isBetween")); | ||
_dayjs["default"].extend(_isBetween["default"]); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isSameDate = exports.isBetweenDate = void 0; | ||
var dayjs_1 = require("dayjs"); | ||
var isBetween_1 = require("dayjs/plugin/isBetween"); | ||
dayjs_1.default.extend(isBetween_1.default); | ||
function isBetweenDate(currentDate, startDate, endDate) { | ||
return (0, _dayjs["default"])(currentDate).isBetween(startDate, endDate); | ||
return (0, dayjs_1.default)(currentDate).isBetween(startDate, endDate); | ||
} | ||
exports.isBetweenDate = isBetweenDate; | ||
function isSameDate(currentDate, targetDate) { | ||
return (0, _dayjs["default"])(currentDate).isSame(targetDate); | ||
} | ||
return (0, dayjs_1.default)(currentDate).isSame(targetDate); | ||
} | ||
exports.isSameDate = isSameDate; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FilterStore = void 0; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _baseStore = require("./baseStore"); | ||
var _tools = require("../_util/tools"); | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
var FilterStore = /*#__PURE__*/function (_BaseStore) { | ||
(0, _inherits2["default"])(FilterStore, _BaseStore); | ||
var _super = _createSuper(FilterStore); | ||
function FilterStore() { | ||
(0, _classCallCheck2["default"])(this, FilterStore); | ||
return _super.apply(this, arguments); | ||
} | ||
(0, _createClass2["default"])(FilterStore, [{ | ||
key: "updateItemValue", | ||
value: function updateItemValue(uid, id) { | ||
if (this.itemsMap[uid] && this.getItem(uid, id)) { | ||
var _this$getItem = this.getItem(uid, id), | ||
getValue = _this$getItem.getValue, | ||
setValue = _this$getItem.setValue; | ||
setValue(getValue() || []); | ||
} | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
var baseStore_1 = require("./baseStore"); | ||
var tools_1 = require("../_util/tools"); | ||
var FilterStore = /** @class */ (function (_super) { | ||
__extends(FilterStore, _super); | ||
function FilterStore() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
}, { | ||
key: "updateGroupValue", | ||
value: function updateGroupValue(uid) { | ||
if (this.itemsMap[uid]) { | ||
var placeHolderArray = (0, _tools.objectEntries)(this.itemsMap[uid].items).reduce(function (prev, cur) { | ||
var _cur = (0, _slicedToArray2["default"])(cur, 2), | ||
val = _cur[1]; // eslint-disable-next-line no-param-reassign | ||
prev[val.getid()] = val.getPlaceHolder(); | ||
return prev; | ||
}, {}); | ||
this.itemsMap[uid].setGroupDataVal({ | ||
key: 'placeHolderArray', | ||
val: placeHolderArray | ||
}); | ||
} | ||
} | ||
}]); | ||
return FilterStore; | ||
}(_baseStore.BaseStore); | ||
FilterStore.prototype.updateItemValue = function (uid, id) { | ||
if (this.itemsMap[uid] && this.getItem(uid, id)) { | ||
var _a = this.getItem(uid, id), getValue = _a.getValue, setValue = _a.setValue; | ||
setValue(getValue() || []); | ||
} | ||
}; | ||
FilterStore.prototype.updateGroupValue = function (uid) { | ||
if (this.itemsMap[uid]) { | ||
var placeHolderArray = (0, tools_1.objectEntries)(this.itemsMap[uid].items).reduce(function (prev, cur) { | ||
var val = cur[1]; | ||
// eslint-disable-next-line no-param-reassign | ||
prev[val.getid()] = val.getPlaceHolder(); | ||
return prev; | ||
}, {}); | ||
this.itemsMap[uid].setGroupDataVal({ key: 'placeHolderArray', val: placeHolderArray }); | ||
} | ||
}; | ||
return FilterStore; | ||
}(baseStore_1.BaseStore)); | ||
exports.FilterStore = FilterStore; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = fmtClass; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var hasOwn = {}.hasOwnProperty; | ||
/* eslint-disable no-continue, prefer-spread */ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
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 = (0, _typeof2["default"])(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); | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var classes = []; | ||
for (var i = 0; i < args.length; i++) { | ||
var arg = args[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(' '); | ||
} | ||
return classes.join(' '); | ||
} | ||
exports.default = fmtClass; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = fmtEvent; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
function fmtEvent(props, e) { | ||
var dataset = {}; | ||
for (var key in props) { | ||
if (/data-/gi.test(key)) { | ||
dataset[key.replace(/data-/gi, '')] = props[key]; | ||
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 | ||
} | ||
}); | ||
} | ||
return Object.assign({}, e, { | ||
currentTarget: { dataset: dataset }, | ||
target: { dataset: dataset, targetDataset: dataset }, | ||
}); | ||
} | ||
exports.default = fmtEvent; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = fmtUnit; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fmtUnitNumber = void 0; | ||
var jsUnitRpx = 'false'; | ||
/* eslint-disable no-continue, prefer-spread */ | ||
function fmtUnit(oldUnit) { | ||
var getUnit = oldUnit; | ||
if (jsUnitRpx === 'true') { | ||
if (typeof getUnit === 'string' && getUnit === 'px') { | ||
getUnit = 'rpx'; | ||
} else if (typeof getUnit === 'string') { | ||
getUnit = "".concat(parseInt(oldUnit.match(/(\d+|\d+\.\d+)(px)/)[1], 10) * 2, "rpx"); | ||
var getUnit = oldUnit; | ||
if (jsUnitRpx === 'true') { | ||
if (typeof getUnit === 'string' && getUnit === 'px') { | ||
getUnit = 'rpx'; | ||
} | ||
else if (typeof getUnit === 'string') { | ||
getUnit = "".concat(parseInt(oldUnit.match(/(\d+|\d+\.\d+)(px)/)[1], 10) * 2, "rpx"); | ||
} | ||
} | ||
} | ||
return getUnit; | ||
return getUnit; | ||
} | ||
var fmtUnitNumber = function fmtUnitNumber(oldUnit) { | ||
var getUnitNumber = oldUnit; | ||
if (jsUnitRpx === 'true') { | ||
getUnitNumber *= 2; | ||
} | ||
return getUnitNumber; | ||
exports.default = fmtUnit; | ||
var fmtUnitNumber = function (oldUnit) { | ||
var getUnitNumber = oldUnit; | ||
if (jsUnitRpx === 'true') { | ||
getUnitNumber *= 2; | ||
} | ||
return getUnitNumber; | ||
}; | ||
exports.fmtUnitNumber = fmtUnitNumber; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Store = void 0; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _asyncValidator = _interopRequireDefault(require("async-validator")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
var Store = /*#__PURE__*/function () { | ||
function Store() { | ||
(0, _classCallCheck2["default"])(this, Store); | ||
this.events = {}; | ||
this.formTree = {}; | ||
this.currentField = {}; | ||
this.setFieldsValueTree = {}; | ||
} | ||
(0, _createClass2["default"])(Store, [{ | ||
key: "init", | ||
value: function init(form, initVal, onValuesChange, onFinish) { | ||
var _this = this; | ||
if (!initVal) return; | ||
Object.keys(initVal).forEach(function (field) { | ||
if (!_this.formTree[form]) { | ||
_this.formTree[form] = {}; | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
if (!_this.formTree[form][field]) { | ||
_this.formTree[form][field] = {}; | ||
} | ||
_this.formTree[form][field].value = initVal[field]; | ||
}); | ||
if (!this.events[form]) { | ||
this.events[form] = [onValuesChange, onFinish]; | ||
} | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
} | ||
setTimeout(function () { | ||
_this.initValidator(form); | ||
}, 0); | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}, { | ||
key: "getInitValByField", | ||
value: function getInitValByField(form, field) { | ||
return this.formTree[form][field].value; | ||
} | ||
}, { | ||
key: "bootstrap", | ||
value: function bootstrap(form, field, rules, initialValue, required) { | ||
if (!this.formTree[form]) { | ||
this.formTree[form] = {}; | ||
} | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
} | ||
if (!this.formTree[form][field]) { | ||
this.formTree[form][field] = {}; | ||
} | ||
var prevVal = this.formTree[form][field].value; | ||
this.formTree[form][field].value = prevVal || initialValue || ''; | ||
this.formTree[form][field].rules = rules; | ||
this.formTree[form][field].required = required; | ||
} | ||
}, { | ||
key: "addFieldSet", | ||
value: function addFieldSet(form, field) { | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
} | ||
this.currentField[form].push(field); | ||
this.initValidator(form); | ||
} | ||
}, { | ||
key: "updateFieldSet", | ||
value: function updateFieldSet(form, prev, cur) { | ||
var prevRealFieldIndex = this.currentField[form].find(function (item) { | ||
return item === prev; | ||
}); | ||
this.currentField[form].splice(prevRealFieldIndex, 1); | ||
this.currentField[form].push(cur); | ||
} | ||
}, { | ||
key: "addUpdateFiledValue", | ||
value: function addUpdateFiledValue(form, field, updateFieldValue) { | ||
if (this.formTree[form] && this.formTree[form][field]) { | ||
var updateFiledValueArr = this.formTree[form][field].updateFieldValue; | ||
if (Array.isArray(updateFiledValueArr)) { | ||
updateFiledValueArr.push(updateFieldValue); | ||
} else { | ||
this.formTree[form][field].updateFieldValue = [updateFieldValue]; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
} // TODO update 数组--->需要解耦 | ||
}, { | ||
key: "setValueAfterUpdate", | ||
value: function setValueAfterUpdate(setData, form, next) { | ||
var val = this.formTree[form][next].value || ''; | ||
setData({ | ||
cValue: val | ||
}); | ||
} | ||
}, { | ||
key: "setFieldUpdateInfoFn", | ||
value: function setFieldUpdateInfoFn(form, field, fn) { | ||
this.formTree[form][field].updateErrorInfo = fn; | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Store = void 0; | ||
var async_validator_1 = require("async-validator"); | ||
var Store = /** @class */ (function () { | ||
function Store() { | ||
this.events = {}; | ||
this.formTree = {}; | ||
this.currentField = {}; | ||
this.setFieldsValueTree = {}; | ||
} | ||
}, { | ||
key: "setUpdateSubmitButtonStatusFn", | ||
value: function setUpdateSubmitButtonStatusFn(form, field, fn) { | ||
this.formTree[form][field].updateSubmitButtonStatus = fn; | ||
} | ||
}, { | ||
key: "delFieldSet", | ||
value: function delFieldSet(form, field) { | ||
var realFieldIndex = this.currentField[form].findIndex(function (item) { | ||
return item === field; | ||
}); | ||
this.currentField[form].splice(realFieldIndex, 1); | ||
if (this.formTree[form] && this.formTree[form][field]) { | ||
this.formTree[form][field] = null; | ||
} | ||
this.initValidator(form); | ||
} | ||
}, { | ||
key: "getTotalValue", | ||
value: function getTotalValue(form) { | ||
var formData = this.formTree[form]; | ||
var currentField = this.currentField[form]; | ||
return Object.keys(formData).reduce(function (prev, cur) { | ||
if (currentField.indexOf(cur) > -1) { | ||
// eslint-disable-next-line no-param-reassign | ||
prev[cur] = formData[cur].value; | ||
Store.prototype.init = function (form, initVal, onValuesChange, onFinish) { | ||
var _this = this; | ||
if (!initVal) | ||
return; | ||
Object.keys(initVal).forEach(function (field) { | ||
if (!_this.formTree[form]) { | ||
_this.formTree[form] = {}; | ||
} | ||
if (!_this.formTree[form][field]) { | ||
_this.formTree[form][field] = {}; | ||
} | ||
_this.formTree[form][field].value = initVal[field]; | ||
}); | ||
if (!this.events[form]) { | ||
this.events[form] = [onValuesChange, onFinish]; | ||
} | ||
return prev; | ||
}, {}); | ||
} | ||
}, { | ||
key: "getFields", | ||
value: function getFields(form) { | ||
if (!this.formTree[form]) return; | ||
if (!this.currentField[form]) return; | ||
var formData = this.formTree[form]; | ||
var currentField = this.currentField[form]; | ||
return Object.keys(formData).reduce(function (prev, cur) { | ||
if (currentField.indexOf(cur) > -1) { | ||
// eslint-disable-next-line no-param-reassign | ||
prev[cur] = formData[cur]; | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
} | ||
return prev; | ||
}, {}); | ||
} | ||
}, { | ||
key: "trigger", | ||
value: function trigger(form, field, val) { | ||
var _this2 = this; | ||
this.formTree[form][field].value = val; | ||
var handlers = this.events[form][0]; | ||
var values = this.getTotalValue(form); | ||
this.formTree[form].validator.validate(_objectSpread(_objectSpread({}, values), {}, (0, _defineProperty2["default"])({}, field, val)), function (errors) { | ||
var _this2$formTree$form$, _this2$formTree$form$2; | ||
var updateErrorInfo = (_this2$formTree$form$ = _this2.formTree[form][field]) === null || _this2$formTree$form$ === void 0 ? void 0 : _this2$formTree$form$.updateErrorInfo; | ||
var updateSubmitButtonStatus = (_this2$formTree$form$2 = _this2.formTree[form].submit) === null || _this2$formTree$form$2 === void 0 ? void 0 : _this2$formTree$form$2.updateSubmitButtonStatus; | ||
if (!errors) { | ||
updateErrorInfo === null || updateErrorInfo === void 0 ? void 0 : updateErrorInfo(null); | ||
updateSubmitButtonStatus === null || updateSubmitButtonStatus === void 0 ? void 0 : updateSubmitButtonStatus(null); | ||
return; | ||
setTimeout(function () { | ||
_this.initValidator(form); | ||
}, 0); | ||
}; | ||
Store.prototype.getInitValByField = function (form, field) { | ||
return this.formTree[form][field].value; | ||
}; | ||
Store.prototype.bootstrap = function (form, field, rules, initialValue, required) { | ||
if (!this.formTree[form]) { | ||
this.formTree[form] = {}; | ||
} | ||
var error = errors.filter(function (item) { | ||
return item.field === field; | ||
})[0]; | ||
if (error) { | ||
updateErrorInfo === null || updateErrorInfo === void 0 ? void 0 : updateErrorInfo(_objectSpread({}, error)); | ||
} else { | ||
updateErrorInfo === null || updateErrorInfo === void 0 ? void 0 : updateErrorInfo(null); | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
} | ||
updateSubmitButtonStatus === null || updateSubmitButtonStatus === void 0 ? void 0 : updateSubmitButtonStatus(!!errors.length); | ||
}); | ||
var totalVal = this.getTotalValue(form); | ||
handlers((0, _defineProperty2["default"])({}, field, val), totalVal); | ||
} | ||
}, { | ||
key: "validateAll", | ||
value: function validateAll(form) { | ||
var _this3 = this; | ||
return new Promise(function (resolve) { | ||
var values = _this3.getTotalValue(form); | ||
_this3.formTree[form].validator.validate(values, function (errors) { | ||
var _this3$formTree$form$3; | ||
if (!errors) { | ||
return resolve(true); | ||
} | ||
var errFields = errors.reduce(function (prev, cur) { | ||
prev[cur.field] = cur; | ||
if (!this.formTree[form][field]) { | ||
this.formTree[form][field] = {}; | ||
} | ||
var prevVal = this.formTree[form][field].value; | ||
this.formTree[form][field].value = prevVal || initialValue || ''; | ||
this.formTree[form][field].rules = rules; | ||
this.formTree[form][field].required = required; | ||
}; | ||
Store.prototype.addFieldSet = function (form, field) { | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
} | ||
this.currentField[form].push(field); | ||
this.initValidator(form); | ||
}; | ||
Store.prototype.updateFieldSet = function (form, prev, cur) { | ||
var prevRealFieldIndex = this.currentField[form].find(function (item) { return item === prev; }); | ||
this.currentField[form].splice(prevRealFieldIndex, 1); | ||
this.currentField[form].push(cur); | ||
}; | ||
Store.prototype.addUpdateFiledValue = function (form, field, updateFieldValue) { | ||
if (this.formTree[form] && this.formTree[form][field]) { | ||
var updateFiledValueArr = this.formTree[form][field].updateFieldValue; | ||
if (Array.isArray(updateFiledValueArr)) { | ||
updateFiledValueArr.push(updateFieldValue); | ||
} | ||
else { | ||
this.formTree[form][field].updateFieldValue = [updateFieldValue]; | ||
} | ||
} | ||
}; | ||
// TODO update 数组--->需要解耦 | ||
Store.prototype.setValueAfterUpdate = function (setData, form, next) { | ||
var val = this.formTree[form][next].value || ''; | ||
setData({ | ||
cValue: val, | ||
}); | ||
}; | ||
Store.prototype.setFieldUpdateInfoFn = function (form, field, fn) { | ||
this.formTree[form][field].updateErrorInfo = fn; | ||
}; | ||
Store.prototype.setUpdateSubmitButtonStatusFn = function (form, field, fn) { | ||
this.formTree[form][field].updateSubmitButtonStatus = fn; | ||
}; | ||
Store.prototype.delFieldSet = function (form, field) { | ||
var realFieldIndex = this.currentField[form].findIndex(function (item) { return item === field; }); | ||
this.currentField[form].splice(realFieldIndex, 1); | ||
if (this.formTree[form] && this.formTree[form][field]) { | ||
this.formTree[form][field] = null; | ||
} | ||
this.initValidator(form); | ||
}; | ||
Store.prototype.getTotalValue = function (form) { | ||
var formData = this.formTree[form]; | ||
var currentField = this.currentField[form]; | ||
return Object.keys(formData).reduce(function (prev, cur) { | ||
if (currentField.indexOf(cur) > -1) { | ||
// eslint-disable-next-line no-param-reassign | ||
prev[cur] = formData[cur].value; | ||
} | ||
return prev; | ||
}, {}); | ||
var fields = _this3.getFields(form); | ||
if (!fields) return; | ||
Object.keys(fields).forEach(function (field) { | ||
if (!errFields[field]) { | ||
var _this3$formTree$form$; | ||
(_this3$formTree$form$ = _this3.formTree[form][field]) === null || _this3$formTree$form$ === void 0 ? void 0 : _this3$formTree$form$.updateErrorInfo(null); | ||
} else { | ||
var _this3$formTree$form$2; | ||
(_this3$formTree$form$2 = _this3.formTree[form][field]) === null || _this3$formTree$form$2 === void 0 ? void 0 : _this3$formTree$form$2.updateErrorInfo(_objectSpread({}, errFields[field])); | ||
}, {}); | ||
}; | ||
Store.prototype.getFields = function (form) { | ||
if (!this.formTree[form]) | ||
return; | ||
if (!this.currentField[form]) | ||
return; | ||
var formData = this.formTree[form]; | ||
var currentField = this.currentField[form]; | ||
return Object.keys(formData).reduce(function (prev, cur) { | ||
if (currentField.indexOf(cur) > -1) { | ||
// eslint-disable-next-line no-param-reassign | ||
prev[cur] = formData[cur]; | ||
} | ||
}); | ||
var updateSubmitButtonStatus = (_this3$formTree$form$3 = _this3.formTree[form].submit) === null || _this3$formTree$form$3 === void 0 ? void 0 : _this3$formTree$form$3.updateSubmitButtonStatus; | ||
if (errors.length) { | ||
// errors.forEach(err => { | ||
// this.formTree[form][err.field]?.updateErrorInfo({ ...err }); | ||
// }); | ||
my.alert({ | ||
title: errors[0].message | ||
return prev; | ||
}, {}); | ||
}; | ||
Store.prototype.trigger = function (form, field, val) { | ||
var _a, _b; | ||
var _this = this; | ||
this.formTree[form][field].value = val; | ||
var handlers = this.events[form][0]; | ||
var values = this.getTotalValue(form); | ||
this.formTree[form].validator.validate(__assign(__assign({}, values), (_a = {}, _a[field] = val, _a)), function (errors) { | ||
var _a, _b; | ||
var updateErrorInfo = (_a = _this.formTree[form][field]) === null || _a === void 0 ? void 0 : _a.updateErrorInfo; | ||
var updateSubmitButtonStatus = (_b = _this.formTree[form].submit) === null || _b === void 0 ? void 0 : _b.updateSubmitButtonStatus; | ||
if (!errors) { | ||
updateErrorInfo === null || updateErrorInfo === void 0 ? void 0 : updateErrorInfo(null); | ||
updateSubmitButtonStatus === null || updateSubmitButtonStatus === void 0 ? void 0 : updateSubmitButtonStatus(null); | ||
return; | ||
} | ||
var error = errors.filter(function (item) { return item.field === field; })[0]; | ||
if (error) { | ||
updateErrorInfo === null || updateErrorInfo === void 0 ? void 0 : updateErrorInfo(__assign({}, error)); | ||
} | ||
else { | ||
updateErrorInfo === null || updateErrorInfo === void 0 ? void 0 : updateErrorInfo(null); | ||
} | ||
updateSubmitButtonStatus === null || updateSubmitButtonStatus === void 0 ? void 0 : updateSubmitButtonStatus(!!errors.length); | ||
}); | ||
var totalVal = this.getTotalValue(form); | ||
handlers((_b = {}, _b[field] = val, _b), totalVal); | ||
}; | ||
Store.prototype.validateAll = function (form) { | ||
var _this = this; | ||
return new Promise(function (resolve) { | ||
var values = _this.getTotalValue(form); | ||
_this.formTree[form].validator.validate(values, function (errors) { | ||
var _a; | ||
if (!errors) { | ||
return resolve(true); | ||
} | ||
var errFields = errors.reduce(function (prev, cur) { | ||
prev[cur.field] = cur; | ||
return prev; | ||
}, {}); | ||
var fields = _this.getFields(form); | ||
if (!fields) | ||
return; | ||
Object.keys(fields).forEach(function (field) { | ||
var _a, _b; | ||
if (!errFields[field]) { | ||
(_a = _this.formTree[form][field]) === null || _a === void 0 ? void 0 : _a.updateErrorInfo(null); | ||
} | ||
else { | ||
(_b = _this.formTree[form][field]) === null || _b === void 0 ? void 0 : _b.updateErrorInfo(__assign({}, errFields[field])); | ||
} | ||
}); | ||
var updateSubmitButtonStatus = (_a = _this.formTree[form].submit) === null || _a === void 0 ? void 0 : _a.updateSubmitButtonStatus; | ||
if (errors.length) { | ||
// errors.forEach(err => { | ||
// this.formTree[form][err.field]?.updateErrorInfo({ ...err }); | ||
// }); | ||
my.alert({ title: errors[0].message }); | ||
} | ||
updateSubmitButtonStatus === null || updateSubmitButtonStatus === void 0 ? void 0 : updateSubmitButtonStatus(!!errors.length); | ||
resolve(!errors.length); | ||
}); | ||
} | ||
updateSubmitButtonStatus === null || updateSubmitButtonStatus === void 0 ? void 0 : updateSubmitButtonStatus(!!errors.length); | ||
resolve(!errors.length); | ||
}); | ||
}); | ||
} | ||
}, { | ||
key: "setFieldsValue", | ||
value: function setFieldsValue(form, value) { | ||
var _this4 = this; | ||
Object.keys(value).forEach(function (key) { | ||
if (_this4.currentField[form] && _this4.currentField[form].find(function (item) { | ||
return item === key; | ||
})) { | ||
if (!_this4.formTree[form][key] || !_this4.formTree[form][key].updateFieldValue) return; | ||
_this4.formTree[form][key].updateFieldValue.forEach(function (fn) { | ||
if (typeof fn === 'function') { | ||
_this4.formTree[form][key].value = value[key]; | ||
fn(value[key]); | ||
}; | ||
Store.prototype.setFieldsValue = function (form, value) { | ||
var _this = this; | ||
Object.keys(value).forEach(function (key) { | ||
if (_this.currentField[form] && _this.currentField[form].find(function (item) { return item === key; })) { | ||
if (!_this.formTree[form][key] || !_this.formTree[form][key].updateFieldValue) | ||
return; | ||
_this.formTree[form][key].updateFieldValue.forEach(function (fn) { | ||
if (typeof fn === 'function') { | ||
_this.formTree[form][key].value = value[key]; | ||
fn(value[key]); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
this.validateAll(form); | ||
} | ||
}, { | ||
key: "onFinish", | ||
value: function () { | ||
var _onFinish = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(form) { | ||
var success; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (form) { | ||
_context.next = 2; | ||
break; | ||
}); | ||
this.validateAll(form); | ||
}; | ||
Store.prototype.onFinish = function (form) { | ||
return __awaiter(this, void 0, Promise, function () { | ||
var success; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!form) | ||
return [2 /*return*/]; | ||
return [4 /*yield*/, this.validateAll(form())]; | ||
case 1: | ||
success = _a.sent(); | ||
if (!success) | ||
return [2 /*return*/]; | ||
this.events[form()][1](this.getTotalValue(form())); | ||
return [2 /*return*/]; | ||
} | ||
return _context.abrupt("return"); | ||
case 2: | ||
_context.next = 4; | ||
return this.validateAll(form()); | ||
case 4: | ||
success = _context.sent; | ||
if (success) { | ||
_context.next = 7; | ||
break; | ||
}); | ||
}); | ||
}; | ||
Store.prototype.tear = function (formName) { | ||
this.formTree[formName] = null; | ||
this.events[formName] = null; | ||
}; | ||
Store.prototype.initValidator = function (form) { | ||
var fields = this.getFields(form); | ||
if (!fields) | ||
return; | ||
var descriptor = {}; | ||
Object.keys(fields).forEach(function (field) { | ||
var _a = fields[field], rules = _a.rules, required = _a.required, label = _a.label; | ||
if (Array.isArray(rules)) { | ||
descriptor[field] = __spreadArray([], rules, true); | ||
} | ||
if (required) { | ||
var requiredItem = { required: required, message: label ? "\u8BF7\u8F93\u5165".concat(label) : '请输入必填项' }; | ||
if (descriptor[field]) { | ||
descriptor[field].unshift(requiredItem); | ||
} | ||
return _context.abrupt("return"); | ||
case 7: | ||
this.events[form()][1](this.getTotalValue(form())); | ||
case 8: | ||
case "end": | ||
return _context.stop(); | ||
else { | ||
descriptor[field] = [requiredItem]; | ||
} | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
function onFinish(_x) { | ||
return _onFinish.apply(this, arguments); | ||
} | ||
return onFinish; | ||
}() | ||
}, { | ||
key: "tear", | ||
value: function tear(formName) { | ||
this.formTree[formName] = null; | ||
this.events[formName] = null; | ||
} | ||
}, { | ||
key: "initValidator", | ||
value: function initValidator(form) { | ||
var fields = this.getFields(form); | ||
if (!fields) return; | ||
var descriptor = {}; | ||
Object.keys(fields).forEach(function (field) { | ||
var _fields$field = fields[field], | ||
rules = _fields$field.rules, | ||
required = _fields$field.required, | ||
label = _fields$field.label; | ||
if (Array.isArray(rules)) { | ||
descriptor[field] = (0, _toConsumableArray2["default"])(rules); | ||
} | ||
if (required) { | ||
var requiredItem = { | ||
required: required, | ||
message: label ? "\u8BF7\u8F93\u5165".concat(label) : '请输入必填项' | ||
}; | ||
if (descriptor[field]) { | ||
descriptor[field].unshift(requiredItem); | ||
} else { | ||
descriptor[field] = [requiredItem]; | ||
} | ||
} | ||
}); | ||
this.formTree[form].validator = new _asyncValidator["default"](descriptor); | ||
} | ||
}]); | ||
return Store; | ||
}(); | ||
}); | ||
this.formTree[form].validator = new async_validator_1.default(descriptor); | ||
}; | ||
return Store; | ||
}()); | ||
exports.Store = Store; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StepsStore = void 0; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _baseStore = require("./baseStore"); | ||
var _tools = require("./tools"); | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
var StepsStore = /*#__PURE__*/function (_BaseStore) { | ||
(0, _inherits2["default"])(StepsStore, _BaseStore); | ||
var _super = _createSuper(StepsStore); | ||
function StepsStore() { | ||
(0, _classCallCheck2["default"])(this, StepsStore); | ||
return _super.apply(this, arguments); | ||
} | ||
(0, _createClass2["default"])(StepsStore, [{ | ||
key: "updateItemIndex", | ||
value: function updateItemIndex(uid, index) { | ||
if (this.itemsMap[uid]) { | ||
(0, _tools.objectEntries)(this.itemsMap[uid].items).forEach(function (_ref) { | ||
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2), | ||
val = _ref2[1]; | ||
val.setItemIndex(index); | ||
}); | ||
} | ||
var baseStore_1 = require("./baseStore"); | ||
var tools_1 = require("./tools"); | ||
var StepsStore = /** @class */ (function (_super) { | ||
__extends(StepsStore, _super); | ||
function StepsStore() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
}, { | ||
key: "updateItemDirection", | ||
value: function updateItemDirection(uid, direction) { | ||
if (this.itemsMap[uid]) { | ||
(0, _tools.objectEntries)(this.itemsMap[uid].items).forEach(function (_ref3) { | ||
var _ref4 = (0, _slicedToArray2["default"])(_ref3, 2), | ||
val = _ref4[1]; | ||
val.setItemDirection(direction); | ||
}); | ||
} | ||
} | ||
}]); | ||
return StepsStore; | ||
}(_baseStore.BaseStore); | ||
StepsStore.prototype.updateItemIndex = function (uid, index) { | ||
if (this.itemsMap[uid]) { | ||
(0, tools_1.objectEntries)(this.itemsMap[uid].items).forEach(function (_a) { | ||
var val = _a[1]; | ||
val.setItemIndex(index); | ||
}); | ||
} | ||
}; | ||
StepsStore.prototype.updateItemDirection = function (uid, direction) { | ||
if (this.itemsMap[uid]) { | ||
(0, tools_1.objectEntries)(this.itemsMap[uid].items).forEach(function (_a) { | ||
var val = _a[1]; | ||
val.setItemDirection(direction); | ||
}); | ||
} | ||
}; | ||
return StepsStore; | ||
}(baseStore_1.BaseStore)); | ||
exports.StepsStore = StepsStore; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.objectEntries = objectEntries; | ||
exports.objectValues = objectValues; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.objectEntries = exports.objectValues = void 0; | ||
function objectValues(obj) { | ||
if (obj !== Object(obj)) throw new TypeError('Object.values called on a non-object'); | ||
var val = []; | ||
var key; | ||
for (key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
val.push(obj[key]); | ||
if (obj !== Object(obj)) | ||
throw new TypeError('Object.values called on a non-object'); | ||
var val = []; | ||
var key; | ||
for (key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
val.push(obj[key]); | ||
} | ||
} | ||
} | ||
return val; | ||
return val; | ||
} | ||
exports.objectValues = objectValues; | ||
function objectEntries(obj) { | ||
var ownProps = Object.keys(obj); | ||
var i = ownProps.length; | ||
var resArray = new Array(i); | ||
while (i--) { | ||
resArray[i] = [ownProps[i], obj[ownProps[i]]]; | ||
} | ||
return resArray; | ||
} | ||
var ownProps = Object.keys(obj); | ||
var i = ownProps.length; | ||
var resArray = new Array(i); | ||
while (i--) { | ||
resArray[i] = [ownProps[i], obj[ownProps[i]]]; | ||
} | ||
return resArray; | ||
} | ||
exports.objectEntries = objectEntries; |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.AvatarDefaultProps | ||
props: props_1.AvatarDefaultProps, | ||
}); |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.AvatarDefaultProps = void 0; | ||
var AvatarDefaultProps = { | ||
export const AvatarDefaultProps = { | ||
size: 'medium', | ||
src: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTIwcHgiIGhlaWdodD0iMTIwcHgiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPHRpdGxlPuS/oeaBr+Wxleekujo0MC/lpLTlg49BdmF0YXIv5Y2V5Zu+OjEv5bC65a+4OuWkpzwvdGl0bGU+CiAgICA8ZGVmcz4KICAgICAgICA8cGF0aCBkPSJNOCwwIEwxMTIsMCBDMTE2LjQxODI3OCwtOC4xMTYyNDUwMWUtMTYgMTIwLDMuNTgxNzIyIDEyMCw4IEwxMjAsMTEyIEMxMjAsMTE2LjQxODI3OCAxMTYuNDE4Mjc4LDEyMCAxMTIsMTIwIEw4LDEyMCBDMy41ODE3MjIsMTIwIDUuNDEwODMwMDFlLTE2LDExNi40MTgyNzggMCwxMTIgTDAsOCBDLTUuNDEwODMwMDFlLTE2LDMuNTgxNzIyIDMuNTgxNzIyLDguMTE2MjQ1MDFlLTE2IDgsMCBaIiBpZD0icGF0aC0xIj48L3BhdGg+CiAgICA8L2RlZnM+CiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0i5aS05YOPIj4KICAgICAgICAgICAgPG1hc2sgaWQ9Im1hc2stMiIgZmlsbD0id2hpdGUiPgogICAgICAgICAgICAgICAgPHVzZSB4bGluazpocmVmPSIjcGF0aC0xIj48L3VzZT4KICAgICAgICAgICAgPC9tYXNrPgogICAgICAgICAgICA8dXNlIGlkPSJNYXNrIiBmaWxsPSIjRUVFRUVFIiBmaWxsLXJ1bGU9Im5vbnplcm8iIHhsaW5rOmhyZWY9IiNwYXRoLTEiPjwvdXNlPgogICAgICAgICAgICA8cGF0aCBkPSJNNjAuNzc4Mjk5MywyMS44MTgxODE4IEw1OS4yMjE2NTIzLDIxLjgxODE4MTggTDU4LjU3ODQzNTksMjEuODI5OTY0MSBMNTguNTc4NDM1NywyMS44Mjk5NjQxIEM0OS44MDIxNTI3LDIyLjE3NDgzNiA0Mi44NjQ3OTEzLDI5LjQxMDY0NyA0Mi44NjUyMDQzLDM4LjIxOTE2MzMgTDQyLjg2NTIwNDMsNDcuNDI0MDc1MSBMNDIuODg1NzYzNyw0OC4yMzQxMDc0IEw0Mi44ODU3NjI3LDQ4LjIzNDA4NTYgQzQzLjA5MDQ4MjMsNTIuNTUwMjgwNCA0NC45MjExODc0LDU2LjYyNzYzNTUgNDguMDA3OTc5LDU5LjY0MjI3OTQgTDUyLjExMTA1ODEsNjMuNjUxMjA1MiBMNTIuMzc1MzkzNiw2My45NDI4MTY3IEM1Mi44NzQ2OTQ0LDY0LjU1MjU0OTcgNTMuMTQ3ODQxMSw2NS4zMTgzOTg0IDUzLjE0Nzg0MTEsNjYuMTEzNzA2NiBMNTMuMTQ3ODQxMSw2Ni42NzMzNjQ1IEw1My4xMjE0MDc2LDY3LjA3NjkwODEgTDUzLjEyMTQwNzYsNjcuMDc2OTA3OSBDNTIuOTg3ODc0NSw2OC4xNTYyNzIxIDUyLjMzMDE4ODEsNjkuMDk5MzI3MyA1MS4zNjUwNDk2LDY5LjU5NTM3MDUgTDI1LjU1MTE3Myw4Mi44MzI3NjM1IEwyNS4xMDQ3MzkzLDgzLjA4MzEzNjUgTDI1LjEwNDczOTUsODMuMDgzMTM2NCBDMjMuMDY0NzcxNSw4NC4zMjk4MTQgMjEuODE5NDYyMiw4Ni41NTIwMDEgMjEuODE4MTgxOCw4OC45NDc3ODUyIEwyMS44MTgxODE4LDkwLjA5NjU1NzcgTDIxLjgzNTgwNDIsOTAuNTM4MzkzMiBDMjIuMDU5MDIwNCw5My4yODk1NTEzIDI0LjM1NTgwMjcsOTUuNDU0NTQ1NSAyNy4xNTc3NTksOTUuNDU0NTQ1NSBMOTIuODQyMjQxLDk1LjQ1NDU0NTUgTDkyLjg0MjI0MSw5NS40NTQ1NDU1IEM5NS43OTAwNjM3LDk1LjQ1NDU0NTUgOTguMTgwMTkzNiw5My4wNTg4MDI3IDk4LjE4MTgxODIsOTAuMTAyNDM5NiBMOTguMTgxODE4Miw4OC45NTM2NjcyIEM5OC4xODE4MTgyLDg2LjM3MDQwNjYgOTYuNzQyNjYyOCw4NC4wMDUxMDkxIDk0LjQ0ODgwODgsODIuODMyNzY3NSBMNjguNjM0OTMyMyw2OS41OTUzNzQ1IEw2OC42MzQ5MzIsNjkuNTk1Mzc0NCBDNjcuNTM5NzExNSw2OS4wMzM5NjU3IDY2Ljg1MDk3MDIsNjcuOTAzOTcyNyA2Ni44NTIxNDA0LDY2LjY3MDQyMyBMNjYuODUyMTQwNCw2Ni4xMTA3NjUxIEM2Ni44NTIxNDA0LDY1LjE4NTg1NTYgNjcuMjI4MDg0Nyw2NC4yOTkyMzk0IDY3Ljg4ODkyMzUsNjMuNjUxMjE4NSBMNzEuOTkyMDAyNSw1OS42NDIyOTI3IEw3MS45OTIwMDI5LDU5LjY0MjI5MjQgQzc1LjI3ODYwMTksNTYuNDMxNjgwNiA3Ny4xMzIxODU3LDUyLjAyNTQyMDQgNzcuMTMxODU1Myw0Ny40MjQwNjIyIEw3Ny4xMzE4NTUzLDM4LjIxOTE1MDQgTDc3LjEzMTg1NTMsMzguMjE5MTUxIEM3Ny4xMzE4NTUzLDI5LjE2MTE2MzMgNjkuODEwMTE5OCwyMS44MTgxODE4IDYwLjc3ODI5ODcsMjEuODE4MTgxOCBMNjAuNzc4Mjk5MywyMS44MTgxODE4IFoiIGlkPSLlvaLnirYiIGZpbGw9IiNDQ0NDQ0MiIGZpbGwtcnVsZT0ibm9uemVybyIgbWFzaz0idXJsKCNtYXNrLTIpIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=' | ||
src: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTIwcHgiIGhlaWdodD0iMTIwcHgiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPHRpdGxlPuS/oeaBr+Wxleekujo0MC/lpLTlg49BdmF0YXIv5Y2V5Zu+OjEv5bC65a+4OuWkpzwvdGl0bGU+CiAgICA8ZGVmcz4KICAgICAgICA8cGF0aCBkPSJNOCwwIEwxMTIsMCBDMTE2LjQxODI3OCwtOC4xMTYyNDUwMWUtMTYgMTIwLDMuNTgxNzIyIDEyMCw4IEwxMjAsMTEyIEMxMjAsMTE2LjQxODI3OCAxMTYuNDE4Mjc4LDEyMCAxMTIsMTIwIEw4LDEyMCBDMy41ODE3MjIsMTIwIDUuNDEwODMwMDFlLTE2LDExNi40MTgyNzggMCwxMTIgTDAsOCBDLTUuNDEwODMwMDFlLTE2LDMuNTgxNzIyIDMuNTgxNzIyLDguMTE2MjQ1MDFlLTE2IDgsMCBaIiBpZD0icGF0aC0xIj48L3BhdGg+CiAgICA8L2RlZnM+CiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0i5aS05YOPIj4KICAgICAgICAgICAgPG1hc2sgaWQ9Im1hc2stMiIgZmlsbD0id2hpdGUiPgogICAgICAgICAgICAgICAgPHVzZSB4bGluazpocmVmPSIjcGF0aC0xIj48L3VzZT4KICAgICAgICAgICAgPC9tYXNrPgogICAgICAgICAgICA8dXNlIGlkPSJNYXNrIiBmaWxsPSIjRUVFRUVFIiBmaWxsLXJ1bGU9Im5vbnplcm8iIHhsaW5rOmhyZWY9IiNwYXRoLTEiPjwvdXNlPgogICAgICAgICAgICA8cGF0aCBkPSJNNjAuNzc4Mjk5MywyMS44MTgxODE4IEw1OS4yMjE2NTIzLDIxLjgxODE4MTggTDU4LjU3ODQzNTksMjEuODI5OTY0MSBMNTguNTc4NDM1NywyMS44Mjk5NjQxIEM0OS44MDIxNTI3LDIyLjE3NDgzNiA0Mi44NjQ3OTEzLDI5LjQxMDY0NyA0Mi44NjUyMDQzLDM4LjIxOTE2MzMgTDQyLjg2NTIwNDMsNDcuNDI0MDc1MSBMNDIuODg1NzYzNyw0OC4yMzQxMDc0IEw0Mi44ODU3NjI3LDQ4LjIzNDA4NTYgQzQzLjA5MDQ4MjMsNTIuNTUwMjgwNCA0NC45MjExODc0LDU2LjYyNzYzNTUgNDguMDA3OTc5LDU5LjY0MjI3OTQgTDUyLjExMTA1ODEsNjMuNjUxMjA1MiBMNTIuMzc1MzkzNiw2My45NDI4MTY3IEM1Mi44NzQ2OTQ0LDY0LjU1MjU0OTcgNTMuMTQ3ODQxMSw2NS4zMTgzOTg0IDUzLjE0Nzg0MTEsNjYuMTEzNzA2NiBMNTMuMTQ3ODQxMSw2Ni42NzMzNjQ1IEw1My4xMjE0MDc2LDY3LjA3NjkwODEgTDUzLjEyMTQwNzYsNjcuMDc2OTA3OSBDNTIuOTg3ODc0NSw2OC4xNTYyNzIxIDUyLjMzMDE4ODEsNjkuMDk5MzI3MyA1MS4zNjUwNDk2LDY5LjU5NTM3MDUgTDI1LjU1MTE3Myw4Mi44MzI3NjM1IEwyNS4xMDQ3MzkzLDgzLjA4MzEzNjUgTDI1LjEwNDczOTUsODMuMDgzMTM2NCBDMjMuMDY0NzcxNSw4NC4zMjk4MTQgMjEuODE5NDYyMiw4Ni41NTIwMDEgMjEuODE4MTgxOCw4OC45NDc3ODUyIEwyMS44MTgxODE4LDkwLjA5NjU1NzcgTDIxLjgzNTgwNDIsOTAuNTM4MzkzMiBDMjIuMDU5MDIwNCw5My4yODk1NTEzIDI0LjM1NTgwMjcsOTUuNDU0NTQ1NSAyNy4xNTc3NTksOTUuNDU0NTQ1NSBMOTIuODQyMjQxLDk1LjQ1NDU0NTUgTDkyLjg0MjI0MSw5NS40NTQ1NDU1IEM5NS43OTAwNjM3LDk1LjQ1NDU0NTUgOTguMTgwMTkzNiw5My4wNTg4MDI3IDk4LjE4MTgxODIsOTAuMTAyNDM5NiBMOTguMTgxODE4Miw4OC45NTM2NjcyIEM5OC4xODE4MTgyLDg2LjM3MDQwNjYgOTYuNzQyNjYyOCw4NC4wMDUxMDkxIDk0LjQ0ODgwODgsODIuODMyNzY3NSBMNjguNjM0OTMyMyw2OS41OTUzNzQ1IEw2OC42MzQ5MzIsNjkuNTk1Mzc0NCBDNjcuNTM5NzExNSw2OS4wMzM5NjU3IDY2Ljg1MDk3MDIsNjcuOTAzOTcyNyA2Ni44NTIxNDA0LDY2LjY3MDQyMyBMNjYuODUyMTQwNCw2Ni4xMTA3NjUxIEM2Ni44NTIxNDA0LDY1LjE4NTg1NTYgNjcuMjI4MDg0Nyw2NC4yOTkyMzk0IDY3Ljg4ODkyMzUsNjMuNjUxMjE4NSBMNzEuOTkyMDAyNSw1OS42NDIyOTI3IEw3MS45OTIwMDI5LDU5LjY0MjI5MjQgQzc1LjI3ODYwMTksNTYuNDMxNjgwNiA3Ny4xMzIxODU3LDUyLjAyNTQyMDQgNzcuMTMxODU1Myw0Ny40MjQwNjIyIEw3Ny4xMzE4NTUzLDM4LjIxOTE1MDQgTDc3LjEzMTg1NTMsMzguMjE5MTUxIEM3Ny4xMzE4NTUzLDI5LjE2MTE2MzMgNjkuODEwMTE5OCwyMS44MTgxODE4IDYwLjc3ODI5ODcsMjEuODE4MTgxOCBMNjAuNzc4Mjk5MywyMS44MTgxODE4IFoiIGlkPSLlvaLnirYiIGZpbGw9IiNDQ0NDQ0MiIGZpbGwtcnVsZT0ibm9uemVybyIgbWFzaz0idXJsKCNtYXNrLTIpIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=', | ||
}; | ||
exports.AvatarDefaultProps = AvatarDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _computed = _interopRequireDefault(require("../mixins/computed")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var computed_1 = require("../mixins/computed"); | ||
Component({ | ||
mixins: [_computed["default"]], | ||
props: _props.BadgeDefaultProps, | ||
methods: { | ||
computed: function computed(props) { | ||
var text = props.text; | ||
var overCount = false; | ||
if (typeof text === 'number') { | ||
if (text >= 100) { | ||
overCount = true; | ||
} | ||
} | ||
return { | ||
overCount: overCount | ||
}; | ||
} | ||
} | ||
mixins: [computed_1.default], | ||
props: props_1.BadgeDefaultProps, | ||
methods: { | ||
computed: function (props) { | ||
var text = props.text; | ||
var overCount = false; | ||
if (typeof text === 'number') { | ||
if (text >= 100) { | ||
overCount = true; | ||
} | ||
} | ||
return { overCount: overCount }; | ||
}, | ||
}, | ||
}); |
@@ -1,13 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.BadgeDefaultProps = void 0; | ||
var BadgeDefaultProps = { | ||
export const BadgeDefaultProps = { | ||
placement: 'top-right', | ||
stroke: false, | ||
type: 'dot', | ||
bgColor: '#FF411C' | ||
bgColor: '#FF411C', | ||
}; | ||
exports.BadgeDefaultProps = BadgeDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fmtEvent = _interopRequireDefault(require("../_util/fmtEvent")); | ||
var _htmlType = _interopRequireDefault(require("../mixins/htmlType")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var fmtEvent_1 = require("../_util/fmtEvent"); | ||
var htmlType_1 = require("../mixins/htmlType"); | ||
Component({ | ||
props: _props.ButtonDefaultProps, | ||
mixins: [(0, _htmlType["default"])()], | ||
methods: { | ||
onTap: function onTap(e) { | ||
var _this$props = this.props, | ||
onTap = _this$props.onTap, | ||
disabled = _this$props.disabled, | ||
loading = _this$props.loading, | ||
_submit = _this$props._submit; | ||
if (typeof _submit === 'function' && !disabled && !loading) { | ||
_submit(); | ||
} | ||
if (onTap && !disabled && !loading) { | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onTap(event); | ||
} | ||
} | ||
} | ||
props: props_1.ButtonDefaultProps, | ||
mixins: [(0, htmlType_1.default)()], | ||
methods: { | ||
onTap: function (e) { | ||
var _a = this.props, onTap = _a.onTap, disabled = _a.disabled, loading = _a.loading, _submit = _a._submit; | ||
if (typeof _submit === 'function' && !disabled && !loading) { | ||
_submit(); | ||
} | ||
if (onTap && !disabled && !loading) { | ||
var event = (0, fmtEvent_1.default)(this.props, e); | ||
return onTap(event); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ButtonDefaultProps = void 0; | ||
var ButtonDefaultProps = { | ||
export const ButtonDefaultProps = { | ||
type: 'default', | ||
@@ -15,4 +9,3 @@ disabled: false, | ||
_submit: undefined, | ||
fill: 'solid' | ||
fill: 'solid', | ||
}; | ||
exports.ButtonDefaultProps = ButtonDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _controlled = _interopRequireDefault(require("../mixins/controlled")); | ||
var _form = _interopRequireDefault(require("../mixins/form")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var controlled_1 = require("../mixins/controlled"); | ||
var form_1 = require("../mixins/form"); | ||
Component({ | ||
props: _props.CheckboxDefaultProps, | ||
mixins: [(0, _controlled["default"])('checked'), (0, _form["default"])()], | ||
methods: { | ||
onChange: function onChange(v) { | ||
var value = v.detail.value; | ||
this.cOnChange(value); | ||
} | ||
} | ||
props: props_1.CheckboxDefaultProps, | ||
mixins: [(0, controlled_1.default)('checked'), (0, form_1.default)()], | ||
methods: { | ||
onChange: function (v) { | ||
var value = v.detail.value; | ||
this.cOnChange(value); | ||
}, | ||
}, | ||
}); |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CheckboxDefaultProps = void 0; | ||
var CheckboxDefaultProps = { | ||
disabled: false | ||
export const CheckboxDefaultProps = { | ||
disabled: false, | ||
}; | ||
exports.CheckboxDefaultProps = CheckboxDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("../context"); | ||
Component({ | ||
props: _props.CheckboxItemDefaultProps, | ||
data: { | ||
_checked: false, | ||
_disabled: false | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
var uid = this.props.uid; | ||
var setDisabled = function setDisabled(_disabled) { | ||
return _this.setData({ | ||
_disabled: _disabled | ||
}); | ||
}; | ||
var setChecked = function setChecked(_checked) { | ||
return _this.setData({ | ||
_checked: _checked | ||
}); | ||
}; | ||
var getChecked = function getChecked() { | ||
return _this.data._checked; | ||
}; | ||
var getItemPropsVal = function getItemPropsVal(key) { | ||
return _this.props[key]; | ||
}; | ||
_context.store.addItem(uid, "".concat(this.$id), { | ||
setDisabled: setDisabled, | ||
getChecked: getChecked, | ||
setChecked: setChecked, | ||
getItemPropsVal: getItemPropsVal | ||
}); // 用户指定checkBoxItem的key,节点变更如下:123456 -> 78,节点不会复用,只能在创建节点的时候更新 | ||
try { | ||
_context.store.updateItemValue(uid, "".concat(this.$id)); // eslint-disable-next-line no-empty | ||
} catch (err) {} | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
var _this$props = this.props, | ||
uid = _this$props.uid, | ||
value = _this$props.value; | ||
var oldValue = prevProps.value; | ||
if (value !== oldValue) { | ||
// 考虑到a:for的情况 | ||
_context.store.updateItemValue(uid, "".concat(this.$id)); | ||
} | ||
}, | ||
didUnmount: function didUnmount() { | ||
var uid = this.props.uid; | ||
_context.store.removeItem(uid, "".concat(this.$id)); | ||
}, | ||
methods: { | ||
onItemChange: function onItemChange(value) { | ||
var uid = this.props.uid; | ||
if (_context.store.checkControlledByUID(uid)) return; | ||
_context.store.triggerItem(uid, "".concat(this.$id), value); | ||
} | ||
} | ||
props: props_1.CheckboxItemDefaultProps, | ||
data: { | ||
_checked: false, | ||
_disabled: false, | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
var uid = this.props.uid; | ||
var setDisabled = function (_disabled) { return _this.setData({ _disabled: _disabled }); }; | ||
var setChecked = function (_checked) { return _this.setData({ _checked: _checked }); }; | ||
var getChecked = function () { return _this.data._checked; }; | ||
var getItemPropsVal = function (key) { return _this.props[key]; }; | ||
context_1.store.addItem(uid, "".concat(this.$id), { setDisabled: setDisabled, getChecked: getChecked, setChecked: setChecked, getItemPropsVal: getItemPropsVal }); | ||
// 用户指定checkBoxItem的key,节点变更如下:123456 -> 78,节点不会复用,只能在创建节点的时候更新 | ||
try { | ||
context_1.store.updateItemValue(uid, "".concat(this.$id)); | ||
// eslint-disable-next-line no-empty | ||
} | ||
catch (err) { } | ||
}, | ||
didUpdate: function (prevProps) { | ||
var _a = this.props, uid = _a.uid, value = _a.value; | ||
var oldValue = prevProps.value; | ||
if (value !== oldValue) { | ||
// 考虑到a:for的情况 | ||
context_1.store.updateItemValue(uid, "".concat(this.$id)); | ||
} | ||
}, | ||
didUnmount: function () { | ||
var uid = this.props.uid; | ||
context_1.store.removeItem(uid, "".concat(this.$id)); | ||
}, | ||
methods: { | ||
onItemChange: function (value) { | ||
var uid = this.props.uid; | ||
if (context_1.store.checkControlledByUID(uid)) | ||
return; | ||
context_1.store.triggerItem(uid, "".concat(this.$id), value); | ||
}, | ||
}, | ||
}); |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CheckboxItemDefaultProps = void 0; | ||
var CheckboxItemDefaultProps = { | ||
export const CheckboxItemDefaultProps = { | ||
disabled: false, | ||
uid: 'CheckboxGroup' | ||
uid: 'CheckboxGroup', | ||
}; | ||
exports.CheckboxItemDefaultProps = CheckboxItemDefaultProps; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.store = void 0; | ||
var _checkboxStore = require("../_util/checkboxStore"); | ||
var store = new _checkboxStore.CheckBoxStore(); | ||
exports.store = store; | ||
var checkboxStore_1 = require("../_util/checkboxStore"); | ||
exports.store = new checkboxStore_1.CheckBoxStore(); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal")); | ||
var _context = require("./context"); | ||
var _form = _interopRequireDefault(require("../mixins/form")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var fast_deep_equal_1 = require("fast-deep-equal"); | ||
var context_1 = require("./context"); | ||
var form_1 = require("../mixins/form"); | ||
Component({ | ||
props: _props.CheckboxGroupDefaultProps, | ||
mixins: [(0, _form["default"])()], | ||
didMount: function didMount() { | ||
var _this = this; | ||
var _this$props = this.props, | ||
uid = _this$props.uid, | ||
value = _this$props.value; | ||
var getGroupPropsVal = function getGroupPropsVal(key) { | ||
switch (key) { | ||
case 'onChange': | ||
if (_this.onChange) { | ||
return _this.onChange.bind(_this); | ||
} | ||
return _this.props.onChange; | ||
case 'value': | ||
if (Array.isArray(_this.props.value)) { | ||
return _this.props.value; | ||
} | ||
return []; | ||
default: | ||
return _this.props[key]; | ||
} | ||
}; | ||
_context.store.setGroupPropsVal(this.props.uid, getGroupPropsVal); | ||
if (Array.isArray(value) && value.length > 0) { | ||
_context.store.updateGroupValue(uid); | ||
} | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
var _this$props2 = this.props, | ||
newUID = _this$props2.uid, | ||
newDisabled = _this$props2.disabled, | ||
newValue = _this$props2.value; | ||
var oldUID = prevProps.uid, | ||
oldDisabled = prevProps.disabled, | ||
oldValue = prevProps.value; | ||
_context.store.updateGroup(newUID, { | ||
isUIDChanged: newUID !== oldUID, | ||
isDisabledChanged: newDisabled !== oldDisabled, | ||
isValueChange: !(0, _fastDeepEqual["default"])(newValue, oldValue) | ||
}, { | ||
oldUID: oldUID | ||
}); | ||
}, | ||
didUnmount: function didUnmount() { | ||
var uid = this.props.uid; | ||
_context.store.removeGroup(uid); | ||
}, | ||
methods: { | ||
onChange: function onChange(val) { | ||
if (this.props.onChange) { | ||
this.props.onChange.call(this, val); | ||
} | ||
props: props_1.CheckboxGroupDefaultProps, | ||
mixins: [(0, form_1.default)()], | ||
didMount: function () { | ||
var _this = this; | ||
var _a = this.props, uid = _a.uid, value = _a.value; | ||
var getGroupPropsVal = function (key) { | ||
switch (key) { | ||
case 'onChange': | ||
if (_this.onChange) { | ||
return _this.onChange.bind(_this); | ||
} | ||
return _this.props.onChange; | ||
case 'value': | ||
if (Array.isArray(_this.props.value)) { | ||
return _this.props.value; | ||
} | ||
return []; | ||
default: | ||
return _this.props[key]; | ||
} | ||
}; | ||
context_1.store.setGroupPropsVal(this.props.uid, getGroupPropsVal); | ||
if (Array.isArray(value) && value.length > 0) { | ||
context_1.store.updateGroupValue(uid); | ||
} | ||
}, | ||
_updateFieldValue: function _updateFieldValue(v) { | ||
_context.store.updateGroupValue(this.props.uid, v); | ||
} | ||
} | ||
didUpdate: function (prevProps) { | ||
var _a = this.props, newUID = _a.uid, newDisabled = _a.disabled, newValue = _a.value; | ||
var oldUID = prevProps.uid, oldDisabled = prevProps.disabled, oldValue = prevProps.value; | ||
context_1.store.updateGroup(newUID, { | ||
isUIDChanged: newUID !== oldUID, | ||
isDisabledChanged: newDisabled !== oldDisabled, | ||
isValueChange: !(0, fast_deep_equal_1.default)(newValue, oldValue), | ||
}, { oldUID: oldUID }); | ||
}, | ||
didUnmount: function () { | ||
var uid = this.props.uid; | ||
context_1.store.removeGroup(uid); | ||
}, | ||
methods: { | ||
onChange: function (val) { | ||
if (this.props.onChange) { | ||
this.props.onChange.call(this, val); | ||
} | ||
}, | ||
_updateFieldValue: function (v) { | ||
context_1.store.updateGroupValue(this.props.uid, v); | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CheckboxGroupDefaultProps = void 0; | ||
var CheckboxGroupDefaultProps = { | ||
export const CheckboxGroupDefaultProps = { | ||
disabled: false, | ||
@@ -12,4 +6,3 @@ radius: false, | ||
controlled: false, | ||
value: [] | ||
value: [], | ||
}; | ||
exports.CheckboxGroupDefaultProps = CheckboxGroupDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
var _console = require("../../_util/console"); | ||
var _tools = require("../../_util/tools"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("../context"); | ||
var console_1 = require("../../_util/console"); | ||
var tools_1 = require("../../_util/tools"); | ||
Component({ | ||
props: _props.CollapseItemDefaultProps, | ||
data: { | ||
_isActive: false, | ||
contentHeight: '', | ||
lastAction: 'auto', | ||
supportSjs: my.canIUse('sjs.event'), | ||
// 避免appx1.0下首次页面加载出现过渡动画 | ||
_first: -1, | ||
accordion: false, | ||
disabled: false, | ||
expandIcon: '', | ||
closeIcon: '' | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
var _this$props = this.props, | ||
uid = _this$props.uid, | ||
name = _this$props.name, | ||
disabled = _this$props.disabled, | ||
expandIcon = _this$props.expandIcon, | ||
closeIcon = _this$props.closeIcon; | ||
if (typeof name !== 'string') { | ||
_console.log.error('CollapseItem', 'name 作为唯一的标识,属必填字段,类型为 string。'); | ||
} | ||
this.setData({ | ||
disabled: disabled, | ||
expandIcon: expandIcon, | ||
closeIcon: closeIcon | ||
}); | ||
var setActive = function setActive(_isActive) { | ||
return _this.setData({ | ||
_isActive: _isActive | ||
}); | ||
}; | ||
var getActive = function getActive() { | ||
return _this.data._isActive; | ||
}; | ||
var getItemPropsVal = function getItemPropsVal(key) { | ||
return _this.props[key]; | ||
}; | ||
var setFirst = function setFirst() { | ||
return _this.setData({ | ||
_first: _this.data._first + 1 | ||
}); | ||
}; | ||
var getFirst = function getFirst() { | ||
return _this.data._first; | ||
}; | ||
var getId = function getId() { | ||
return "".concat(_this.$id); | ||
}; | ||
var setLastAction = function setLastAction(lastAction) { | ||
return _this.setData({ | ||
lastAction: lastAction | ||
}); | ||
}; | ||
var setAccordion = function setAccordion(accordion) { | ||
return _this.setData({ | ||
accordion: accordion | ||
}); | ||
}; | ||
var setContentHeight = function setContentHeight(contentHeight) { | ||
return _this.setData({ | ||
contentHeight: contentHeight | ||
}); | ||
}; | ||
var getContentHeight = function getContentHeight() { | ||
return _this.calcContentHeight(); | ||
}; | ||
var getSupportSjs = function getSupportSjs() { | ||
return _this.data.supportSjs; | ||
}; | ||
var getDisabled = function getDisabled() { | ||
return _this.props.disabled; | ||
}; | ||
_context.context.addItem(uid, "".concat(this.$id), { | ||
setActive: setActive, | ||
setAccordion: setAccordion, | ||
getActive: getActive, | ||
setFirst: setFirst, | ||
getItemPropsVal: getItemPropsVal, | ||
setLastAction: setLastAction, | ||
getId: getId, | ||
getFirst: getFirst, | ||
setContentHeight: setContentHeight, | ||
getContentHeight: getContentHeight, | ||
getSupportSjs: getSupportSjs, | ||
getDisabled: getDisabled | ||
}); | ||
try { | ||
_context.context.updateItemValue(uid, "".concat(this.$id)); // eslint-disable-next-line no-empty | ||
} catch (err) {} | ||
}, | ||
didUnmount: function didUnmount() { | ||
_context.context.removeItem(this.props.uid, "".concat(this.$id)); | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
if (prevProps.disabled !== this.props.disabled) { | ||
this.setData({ | ||
disabled: this.props.disabled | ||
}); | ||
} | ||
if (prevProps.expandIcon !== this.props.expandIcon) { | ||
this.setData({ | ||
expandIcon: this.props.expandIcon | ||
}); | ||
} | ||
if (prevProps.closeIcon !== this.props.closeIcon) { | ||
this.setData({ | ||
closeIcon: this.props.closeIcon | ||
}); | ||
} | ||
}, | ||
methods: { | ||
_changeItem: function _changeItem() { | ||
var _this2 = this; | ||
if (this.props.disabled) return; | ||
if (this.data.supportSjs) { | ||
// for 2.0 | ||
_context.context.triggerItem(this.props.uid, "".concat(this.$id), !this.data._isActive); | ||
return; | ||
} | ||
var group = _context.context.getGroup(this.props.uid); | ||
if (group) { | ||
var accordion = group ? group.getGroupPropsVal('accordion') : false; | ||
if (accordion) { | ||
var onChange = group.getGroupPropsVal('onChange'); | ||
(0, _tools.objectEntries)(group.items).forEach(function (_ref) { | ||
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2), | ||
val = _ref2[1]; | ||
if (!val) return; | ||
if (val.getId() === "".concat(_this2.$id)) { | ||
if (_this2.data._isActive) { | ||
_this2.calcContentHeight().then(function (contentHeight) { | ||
_this2.setData({ | ||
contentHeight: contentHeight | ||
}); | ||
setTimeout(function () { | ||
_this2.setData({ | ||
_isActive: false, | ||
contentHeight: '0px', | ||
_first: _this2.data._first + 1 | ||
}, function () { | ||
onChange([]); | ||
props: props_1.CollapseItemDefaultProps, | ||
data: { | ||
_isActive: false, | ||
contentHeight: '', | ||
lastAction: 'auto', | ||
supportSjs: my.canIUse('sjs.event'), | ||
// 避免appx1.0下首次页面加载出现过渡动画 | ||
_first: -1, | ||
accordion: false, | ||
disabled: false, | ||
expandIcon: '', | ||
closeIcon: '', | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
var _a = this.props, uid = _a.uid, name = _a.name, disabled = _a.disabled, expandIcon = _a.expandIcon, closeIcon = _a.closeIcon; | ||
if (typeof name !== 'string') { | ||
console_1.log.error('CollapseItem', 'name 作为唯一的标识,属必填字段,类型为 string。'); | ||
} | ||
this.setData({ | ||
disabled: disabled, | ||
expandIcon: expandIcon, | ||
closeIcon: closeIcon, | ||
}); | ||
var setActive = function (_isActive) { return _this.setData({ _isActive: _isActive }); }; | ||
var getActive = function () { return _this.data._isActive; }; | ||
var getItemPropsVal = function (key) { return _this.props[key]; }; | ||
var setFirst = function () { return _this.setData({ _first: _this.data._first + 1 }); }; | ||
var getFirst = function () { return _this.data._first; }; | ||
var getId = function () { return "".concat(_this.$id); }; | ||
var setLastAction = function (lastAction) { return _this.setData({ lastAction: lastAction }); }; | ||
var setAccordion = function (accordion) { return _this.setData({ accordion: accordion }); }; | ||
var setContentHeight = function (contentHeight) { return _this.setData({ contentHeight: contentHeight }); }; | ||
var getContentHeight = function () { return _this.calcContentHeight(); }; | ||
var getSupportSjs = function () { return _this.data.supportSjs; }; | ||
var getDisabled = function () { return _this.props.disabled; }; | ||
context_1.context.addItem(uid, "".concat(this.$id), { | ||
setActive: setActive, | ||
setAccordion: setAccordion, | ||
getActive: getActive, | ||
setFirst: setFirst, | ||
getItemPropsVal: getItemPropsVal, | ||
setLastAction: setLastAction, | ||
getId: getId, | ||
getFirst: getFirst, | ||
setContentHeight: setContentHeight, | ||
getContentHeight: getContentHeight, | ||
getSupportSjs: getSupportSjs, | ||
getDisabled: getDisabled, | ||
}); | ||
try { | ||
context_1.context.updateItemValue(uid, "".concat(this.$id)); | ||
// eslint-disable-next-line no-empty | ||
} | ||
catch (err) { } | ||
}, | ||
didUnmount: function () { | ||
context_1.context.removeItem(this.props.uid, "".concat(this.$id)); | ||
}, | ||
didUpdate: function (prevProps) { | ||
if (prevProps.disabled !== this.props.disabled) { | ||
this.setData({ | ||
disabled: this.props.disabled, | ||
}); | ||
} | ||
if (prevProps.expandIcon !== this.props.expandIcon) { | ||
this.setData({ | ||
expandIcon: this.props.expandIcon, | ||
}); | ||
} | ||
if (prevProps.closeIcon !== this.props.closeIcon) { | ||
this.setData({ | ||
closeIcon: this.props.closeIcon, | ||
}); | ||
} | ||
}, | ||
methods: { | ||
_changeItem: function () { | ||
var _this = this; | ||
if (this.props.disabled) | ||
return; | ||
if (this.data.supportSjs) { | ||
// for 2.0 | ||
context_1.context.triggerItem(this.props.uid, "".concat(this.$id), !this.data._isActive); | ||
return; | ||
} | ||
var group = context_1.context.getGroup(this.props.uid); | ||
if (group) { | ||
var accordion = group ? group.getGroupPropsVal('accordion') : false; | ||
if (accordion) { | ||
var onChange_1 = group.getGroupPropsVal('onChange'); | ||
(0, tools_1.objectEntries)(group.items).forEach(function (_a) { | ||
var val = _a[1]; | ||
if (!val) | ||
return; | ||
if (val.getId() === "".concat(_this.$id)) { | ||
if (_this.data._isActive) { | ||
_this.calcContentHeight().then(function (contentHeight) { | ||
_this.setData({ | ||
contentHeight: contentHeight, | ||
}); | ||
setTimeout(function () { | ||
_this.setData({ | ||
_isActive: false, | ||
contentHeight: '0px', | ||
_first: _this.data._first + 1, | ||
}, function () { | ||
onChange_1([]); | ||
}); | ||
}, 10); | ||
}); | ||
} | ||
else { | ||
_this.calcContentHeight().then(function (contentHeight) { | ||
_this.setData({ | ||
contentHeight: '0px', | ||
}); | ||
setTimeout(function () { | ||
_this.setData({ | ||
_isActive: true, | ||
contentHeight: contentHeight, | ||
_first: _this.data._first + 1, | ||
}, function () { | ||
onChange_1([_this.props.name]); | ||
}); | ||
}, 10); | ||
}); | ||
} | ||
} | ||
else { | ||
if (val.getActive() === false) | ||
return; | ||
val.getContentHeight().then(function (contentHeight) { | ||
val.setContentHeight(contentHeight); | ||
val.setFirst(); | ||
setTimeout(function () { | ||
val.setActive(false); | ||
val.setContentHeight('0px'); | ||
}, 10); | ||
}); | ||
} | ||
}); | ||
}, 10); | ||
} | ||
else { | ||
this.fallbackCollapse(this.data._isActive); | ||
} | ||
} | ||
}, | ||
calcContentHeight: function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
my.createSelectorQuery() | ||
.select(".amd-collapse-item-content-".concat(_this.$id)) | ||
.boundingClientRect() | ||
.exec(function (res) { | ||
if (res && res[0]) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
resolve("".concat(res[0].height, "px")); | ||
} | ||
else { | ||
reject(res); | ||
} | ||
}); | ||
} else { | ||
_this2.calcContentHeight().then(function (contentHeight) { | ||
_this2.setData({ | ||
contentHeight: '0px' | ||
}); | ||
setTimeout(function () { | ||
_this2.setData({ | ||
_isActive: true, | ||
contentHeight: contentHeight, | ||
_first: _this2.data._first + 1 | ||
}); | ||
}, | ||
fallbackCollapse: function (isActive) { | ||
var _this = this; | ||
if (isActive) { | ||
// for 1.0 open -> close | ||
this.calcContentHeight().then(function (contentHeight) { | ||
_this.setData({ | ||
contentHeight: contentHeight, | ||
}); | ||
setTimeout(function () { | ||
_this.setData({ | ||
_isActive: false, | ||
contentHeight: '0px', | ||
_first: _this.data._first + 1, | ||
}, function () { | ||
context_1.context.onChangeByTrigger(_this.props.uid); | ||
}); | ||
}, 10); | ||
}); | ||
} | ||
else { | ||
// for 1.0 close -> open | ||
this.calcContentHeight().then(function (contentHeight) { | ||
_this.setData({ | ||
_isActive: true, | ||
contentHeight: contentHeight, | ||
_first: _this.data._first + 1, | ||
}, function () { | ||
onChange([_this2.props.name]); | ||
context_1.context.onChangeByTrigger(_this.props.uid); | ||
}); | ||
}, 10); | ||
}); | ||
} | ||
} else { | ||
if (val.getActive() === false) return; | ||
val.getContentHeight().then(function (contentHeight) { | ||
val.setContentHeight(contentHeight); | ||
val.setFirst(); | ||
} | ||
}, | ||
resetContentHeight: function () { | ||
var _this = this; | ||
if (this.data._isActive) { | ||
setTimeout(function () { | ||
val.setActive(false); | ||
val.setContentHeight('0px'); | ||
_this.setData({ | ||
contentHeight: 'auto', | ||
}); | ||
}, 10); | ||
}); | ||
} | ||
}); | ||
} else { | ||
this.fallbackCollapse(this.data._isActive); | ||
} | ||
} | ||
}, | ||
}, | ||
calcContentHeight: function calcContentHeight() { | ||
var _this3 = this; | ||
return new Promise(function (resolve, reject) { | ||
my.createSelectorQuery().select(".amd-collapse-item-content-".concat(_this3.$id)).boundingClientRect().exec(function (res) { | ||
if (res && res[0]) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
resolve("".concat(res[0].height, "px")); | ||
} else { | ||
reject(res); | ||
} | ||
}); | ||
}); | ||
}, | ||
fallbackCollapse: function fallbackCollapse(isActive) { | ||
var _this4 = this; | ||
if (isActive) { | ||
// for 1.0 open -> close | ||
this.calcContentHeight().then(function (contentHeight) { | ||
_this4.setData({ | ||
contentHeight: contentHeight | ||
}); | ||
setTimeout(function () { | ||
_this4.setData({ | ||
_isActive: false, | ||
contentHeight: '0px', | ||
_first: _this4.data._first + 1 | ||
}, function () { | ||
_context.context.onChangeByTrigger(_this4.props.uid); | ||
}); | ||
}, 10); | ||
}); | ||
} else { | ||
// for 1.0 close -> open | ||
this.calcContentHeight().then(function (contentHeight) { | ||
_this4.setData({ | ||
_isActive: true, | ||
contentHeight: contentHeight, | ||
_first: _this4.data._first + 1 | ||
}, function () { | ||
_context.context.onChangeByTrigger(_this4.props.uid); | ||
}); | ||
}); | ||
} | ||
}, | ||
resetContentHeight: function resetContentHeight() { | ||
var _this5 = this; | ||
if (this.data._isActive) { | ||
setTimeout(function () { | ||
_this5.setData({ | ||
contentHeight: 'auto' | ||
}); | ||
}, 10); | ||
} | ||
} | ||
} | ||
}); |
@@ -1,13 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CollapseItemDefaultProps = void 0; | ||
var CollapseItemDefaultProps = { | ||
export const CollapseItemDefaultProps = { | ||
uid: 'Collapse', | ||
disabled: false, | ||
expandIcon: 'UpOutline', | ||
closeIcon: 'DownOutline' | ||
closeIcon: 'DownOutline', | ||
}; | ||
exports.CollapseItemDefaultProps = CollapseItemDefaultProps; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.context = void 0; | ||
var _collapseStore = require("../_util/collapseStore"); | ||
var context = new _collapseStore.CollapseStore(); | ||
exports.context = context; | ||
var collapseStore_1 = require("../_util/collapseStore"); | ||
exports.context = new collapseStore_1.CollapseStore(); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _context = require("./context"); | ||
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("./context"); | ||
var fast_deep_equal_1 = require("fast-deep-equal"); | ||
Component({ | ||
props: _props.CollapseDefaultProps, | ||
data: { | ||
supportSjs: my.canIUse('sjs.event') | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
var _this$props = this.props, | ||
uid = _this$props.uid, | ||
name = _this$props.name; | ||
var getGroupPropsVal = function getGroupPropsVal(key) { | ||
switch (key) { | ||
case 'onChange': | ||
if (_this.onChange) { | ||
return _this.onChange.bind(_this); | ||
} | ||
return _this.props.onChange; | ||
case 'name': | ||
if (Array.isArray(_this.props.name)) { | ||
return _this.props.name; | ||
} | ||
return []; | ||
default: | ||
return _this.props[key]; | ||
} | ||
}; | ||
_context.context.addGroup(uid); | ||
_context.context.setGroupPropsVal(uid, getGroupPropsVal); | ||
_context.context.setItemsAccordion(uid); | ||
if (Array.isArray(name)) { | ||
_context.context.updateGroupValue(uid, true); | ||
} | ||
}, | ||
didUnmount: function didUnmount() { | ||
_context.context.removeGroup(this.props.uid); | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
var _this$props2 = this.props, | ||
newUID = _this$props2.uid, | ||
_this$props2$name = _this$props2.name, | ||
newName = _this$props2$name === void 0 ? [] : _this$props2$name, | ||
_this$props2$accordio = _this$props2.accordion, | ||
newAccordion = _this$props2$accordio === void 0 ? false : _this$props2$accordio; | ||
var oldUID = prevProps.uid, | ||
_prevProps$name = prevProps.name, | ||
oldName = _prevProps$name === void 0 ? [] : _prevProps$name, | ||
_prevProps$accordion = prevProps.accordion, | ||
oldAccordion = _prevProps$accordion === void 0 ? false : _prevProps$accordion; | ||
_context.context.updateGroup(newUID, { | ||
isNameChanged: !(0, _fastDeepEqual["default"])(newName, oldName), | ||
isUIDChanged: newUID !== oldUID, | ||
isAccordionChanged: newAccordion !== oldAccordion | ||
}, { | ||
oldUID: oldUID | ||
}); | ||
} | ||
props: props_1.CollapseDefaultProps, | ||
data: { | ||
supportSjs: my.canIUse('sjs.event'), | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
var _a = this.props, uid = _a.uid, name = _a.name; | ||
var getGroupPropsVal = function (key) { | ||
switch (key) { | ||
case 'onChange': | ||
if (_this.onChange) { | ||
return _this.onChange.bind(_this); | ||
} | ||
return _this.props.onChange; | ||
case 'name': | ||
if (Array.isArray(_this.props.name)) { | ||
return _this.props.name; | ||
} | ||
return []; | ||
default: | ||
return _this.props[key]; | ||
} | ||
}; | ||
context_1.context.addGroup(uid); | ||
context_1.context.setGroupPropsVal(uid, getGroupPropsVal); | ||
context_1.context.setItemsAccordion(uid); | ||
if (Array.isArray(name)) { | ||
context_1.context.updateGroupValue(uid, true); | ||
} | ||
}, | ||
didUnmount: function () { | ||
context_1.context.removeGroup(this.props.uid); | ||
}, | ||
didUpdate: function (prevProps) { | ||
var _a = this.props, newUID = _a.uid, _b = _a.name, newName = _b === void 0 ? [] : _b, _c = _a.accordion, newAccordion = _c === void 0 ? false : _c; | ||
var oldUID = prevProps.uid, _d = prevProps.name, oldName = _d === void 0 ? [] : _d, _e = prevProps.accordion, oldAccordion = _e === void 0 ? false : _e; | ||
context_1.context.updateGroup(newUID, { | ||
isNameChanged: !(0, fast_deep_equal_1.default)(newName, oldName), | ||
isUIDChanged: newUID !== oldUID, | ||
isAccordionChanged: newAccordion !== oldAccordion, | ||
}, { oldUID: oldUID }); | ||
}, | ||
}); |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CollapseDefaultProps = void 0; | ||
var CollapseDefaultProps = { | ||
export const CollapseDefaultProps = { | ||
name: [], | ||
uid: 'Collapse', | ||
accordion: false | ||
accordion: false, | ||
}; | ||
exports.CollapseDefaultProps = CollapseDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fmtEvent = _interopRequireDefault(require("../_util/fmtEvent")); | ||
var _console = require("../_util/console"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var fmtEvent_1 = require("../_util/fmtEvent"); | ||
var console_1 = require("../_util/console"); | ||
Component({ | ||
props: _props.ContainerDefaultProps, | ||
didMount: function didMount() { | ||
var _this$props = this.props, | ||
onIconTap = _this$props.onIconTap, | ||
icon = _this$props.icon; | ||
if (!icon && onIconTap) { | ||
_console.log.error('Container', '未设置 icon 属性值或者值为空,onIconTap 将无效。'); | ||
} | ||
}, | ||
methods: { | ||
onIconTap: function onIconTap(e) { | ||
var onIconTap = this.props.onIconTap; | ||
if (onIconTap) { | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onIconTap(event); | ||
} | ||
} | ||
} | ||
props: props_1.ContainerDefaultProps, | ||
didMount: function () { | ||
var _a = this.props, onIconTap = _a.onIconTap, icon = _a.icon; | ||
if (!icon && onIconTap) { | ||
console_1.log.error('Container', '未设置 icon 属性值或者值为空,onIconTap 将无效。'); | ||
} | ||
}, | ||
methods: { | ||
onIconTap: function (e) { | ||
var onIconTap = this.props.onIconTap; | ||
if (onIconTap) { | ||
var event = (0, fmtEvent_1.default)(this.props, e); | ||
return onIconTap(event); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ContainerDefaultProps = void 0; | ||
var ContainerDefaultProps = {}; | ||
exports.ContainerDefaultProps = ContainerDefaultProps; | ||
export const ContainerDefaultProps = {}; |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.DialogDefaultProps, | ||
methods: { | ||
onButtonTap: function onButtonTap(e) { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (typeof onButtonTap === 'function') { | ||
var index = e.currentTarget.dataset.index; | ||
return onButtonTap(index); | ||
} | ||
props: props_1.DialogDefaultProps, | ||
methods: { | ||
onButtonTap: function (e) { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (typeof onButtonTap === 'function') { | ||
var index = e.currentTarget.dataset.index; | ||
return onButtonTap(index); | ||
} | ||
}, | ||
onClose: function () { | ||
if (typeof this.props.onClose === 'function') { | ||
this.props.onClose(); | ||
} | ||
}, | ||
}, | ||
onClose: function onClose() { | ||
if (typeof this.props.onClose === 'function') { | ||
this.props.onClose(); | ||
} | ||
} | ||
} | ||
}); |
@@ -1,12 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.DialogDefaultProps = void 0; | ||
var DialogDefaultProps = { | ||
export const DialogDefaultProps = { | ||
direction: 'vertical', | ||
buttonText: ['主操作', '更多', '取消'], | ||
maskClosable: true | ||
maskClosable: true, | ||
}; | ||
exports.DialogDefaultProps = DialogDefaultProps; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.context = void 0; | ||
var _filterSotre = require("../_util/filterSotre"); | ||
var context = new _filterSotre.FilterStore(); | ||
exports.context = context; | ||
var filterSotre_1 = require("../_util/filterSotre"); | ||
exports.context = new filterSotre_1.FilterStore(); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ var props_1 = require("./props"); | ||
var context_1 = require("../context"); | ||
Component({ | ||
props: _props.FilterItemDefaultProps, | ||
data: { | ||
_value: [], | ||
show: false, | ||
curValue: [], | ||
prevValue: [] | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
var getValue = function getValue() { | ||
return _this.props.value; | ||
}; | ||
var isMult = function isMult() { | ||
return _this.props.type === 'multiple'; | ||
}; | ||
var setValue = function setValue(val) { | ||
return _this.setData({ | ||
_value: val | ||
}); | ||
}; | ||
var setShow = function setShow(show) { | ||
return _this.setData({ | ||
show: show | ||
}); | ||
}; | ||
var getShow = function getShow() { | ||
return _this.data.show; | ||
}; | ||
var setPrevValue = function setPrevValue(prevValue) { | ||
return _this.setData({ | ||
prevValue: prevValue | ||
}); | ||
}; | ||
var getCurValue = function getCurValue() { | ||
return _this.data.curValue; | ||
}; | ||
var getPlaceHolder = function getPlaceHolder() { | ||
return _this.props.placeholder || ''; | ||
}; | ||
var getid = function getid() { | ||
return "".concat(_this.$id); | ||
}; | ||
_context.context.addItem(this.props.uid, "".concat(this.$id), { | ||
isMult: isMult, | ||
getValue: getValue, | ||
setValue: setValue, | ||
getPlaceHolder: getPlaceHolder, | ||
setShow: setShow, | ||
getid: getid, | ||
getShow: getShow, | ||
setPrevValue: setPrevValue, | ||
getCurValue: getCurValue | ||
}); | ||
_context.context.updateItemValue(this.props.uid, "".concat(this.$id)); | ||
this.setData({ | ||
curValue: getValue() | ||
}); | ||
if (getValue()) { | ||
setTimeout(function () { | ||
_this.setActive(true); | ||
}); | ||
} | ||
}, | ||
ref: function ref() { | ||
var _this2 = this; | ||
return { | ||
getCompInstance: function getCompInstance() { | ||
return _this2; | ||
}, | ||
changeSelect: function changeSelect(v) { | ||
return _this2.onChange(v); | ||
} | ||
}; | ||
}, | ||
methods: { | ||
onChange: function onChange(v, label) { | ||
if (typeof this.props.onChange !== 'function') return; | ||
if (this.props.type === 'multiple') { | ||
props: props_1.FilterItemDefaultProps, | ||
data: { | ||
_value: [], | ||
show: false, | ||
curValue: [], | ||
prevValue: [], | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
var getValue = function () { return _this.props.value; }; | ||
var isMult = function () { return _this.props.type === 'multiple'; }; | ||
var setValue = function (val) { return _this.setData({ | ||
_value: val, | ||
}); }; | ||
var setShow = function (show) { return _this.setData({ | ||
show: show, | ||
}); }; | ||
var getShow = function () { return _this.data.show; }; | ||
var setPrevValue = function (prevValue) { return _this.setData({ | ||
prevValue: prevValue, | ||
}); }; | ||
var getCurValue = function () { return _this.data.curValue; }; | ||
var getPlaceHolder = function () { return _this.props.placeholder || ''; }; | ||
var getid = function () { return "".concat(_this.$id); }; | ||
context_1.context.addItem(this.props.uid, "".concat(this.$id), { isMult: isMult, getValue: getValue, setValue: setValue, getPlaceHolder: getPlaceHolder, setShow: setShow, getid: getid, getShow: getShow, setPrevValue: setPrevValue, getCurValue: getCurValue }); | ||
context_1.context.updateItemValue(this.props.uid, "".concat(this.$id)); | ||
this.setData({ | ||
curValue: v, | ||
_value: v | ||
curValue: getValue(), | ||
}); | ||
this.props.onChange(v); | ||
return; | ||
} | ||
this.setData({ | ||
show: false | ||
}); // 单选 | ||
this.props.onChange(v); | ||
this.setActive(v.length > 0); // 箭头动画 | ||
this.resetArrow(); // 更改占位符 | ||
var group = _context.context.getGroup(this.props.uid); | ||
if (group) { | ||
var placeHolderArray = group.getGroupDataVal(); | ||
placeHolderArray[this.$id] = label; | ||
group.setGroupDataVal({ | ||
key: 'placeHolderArray', | ||
val: placeHolderArray | ||
}); | ||
} | ||
if (getValue()) { | ||
setTimeout(function () { | ||
_this.setActive(true); | ||
}); | ||
} | ||
}, | ||
confirmSelector: function confirmSelector() { | ||
// 多选 | ||
if (typeof this.props.onChange !== 'function') return; | ||
this.setData({ | ||
prevValue: this.data.curValue, | ||
show: false | ||
}); | ||
this.props.onChange(this.data.curValue); | ||
this.setActive(this.data.curValue.length > 0); // 箭头动画 | ||
this.resetArrow(); | ||
ref: function () { | ||
var _this = this; | ||
return { | ||
getCompInstance: function () { return _this; }, | ||
changeSelect: function (v) { return _this.onChange(v); }, | ||
}; | ||
}, | ||
resetArrow: function resetArrow() { | ||
var group = _context.context.getGroup(this.props.uid); | ||
if (group) { | ||
group.setGroupDataVal({ | ||
key: 'currentFilterItemId', | ||
val: '' | ||
}); | ||
} | ||
methods: { | ||
onChange: function (v, label) { | ||
if (typeof this.props.onChange !== 'function') | ||
return; | ||
if (this.props.type === 'multiple') { | ||
this.setData({ | ||
curValue: v, | ||
_value: v, | ||
}); | ||
this.props.onChange(v); | ||
return; | ||
} | ||
this.setData({ | ||
show: false, | ||
}); | ||
// 单选 | ||
this.props.onChange(v); | ||
this.setActive(v.length > 0); | ||
// 箭头动画 | ||
this.resetArrow(); | ||
// 更改占位符 | ||
var group = context_1.context.getGroup(this.props.uid); | ||
if (group) { | ||
var placeHolderArray = group.getGroupDataVal(); | ||
placeHolderArray[this.$id] = label; | ||
group.setGroupDataVal({ key: 'placeHolderArray', val: placeHolderArray }); | ||
} | ||
}, | ||
confirmSelector: function () { | ||
// 多选 | ||
if (typeof this.props.onChange !== 'function') | ||
return; | ||
this.setData({ | ||
prevValue: this.data.curValue, | ||
show: false, | ||
}); | ||
this.props.onChange(this.data.curValue); | ||
this.setActive(this.data.curValue.length > 0); | ||
// 箭头动画 | ||
this.resetArrow(); | ||
}, | ||
resetArrow: function () { | ||
var group = context_1.context.getGroup(this.props.uid); | ||
if (group) { | ||
group.setGroupDataVal({ key: 'currentFilterItemId', val: '' }); | ||
} | ||
}, | ||
resetSelector: function () { | ||
this.setData({ | ||
_value: this.data.prevValue, | ||
}); | ||
}, | ||
setActive: function (active) { | ||
var _a; | ||
var group = context_1.context.getGroup(this.props.uid); | ||
if (group) { | ||
var val = (_a = {}, _a[this.$id] = active, _a); | ||
group.setGroupDataVal({ key: 'activeArray', val: val }); | ||
} | ||
}, | ||
}, | ||
resetSelector: function resetSelector() { | ||
this.setData({ | ||
_value: this.data.prevValue | ||
}); | ||
}, | ||
setActive: function setActive(active) { | ||
var group = _context.context.getGroup(this.props.uid); | ||
if (group) { | ||
var val = (0, _defineProperty2["default"])({}, this.$id, active); | ||
group.setGroupDataVal({ | ||
key: 'activeArray', | ||
val: val | ||
}); | ||
} | ||
} | ||
} | ||
}); |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.FilterItemDefaultProps = void 0; | ||
var FilterItemDefaultProps = { | ||
export const FilterItemDefaultProps = { | ||
uid: 'filter', | ||
type: 'default' | ||
type: 'default', | ||
}; | ||
exports.FilterItemDefaultProps = FilterItemDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _props = require("./props"); | ||
var _context = require("./context"); | ||
var _tools = require("../_util/tools"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
var props_1 = require("./props"); | ||
var context_1 = require("./context"); | ||
var tools_1 = require("../_util/tools"); | ||
Component({ | ||
props: _props.FilterDefaultProps, | ||
data: { | ||
placeHolderObj: {}, | ||
activeObj: {}, | ||
currentFilterItemId: '' | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
var setGroupDataVal = function setGroupDataVal(val) { | ||
switch (val.key) { | ||
case 'placeHolderArray': | ||
_this.setData({ | ||
placeHolderObj: val.val | ||
}); | ||
break; | ||
case 'activeArray': | ||
_this.setData({ | ||
activeObj: _objectSpread(_objectSpread({}, _this.data.activeObj), val.val) | ||
}); | ||
break; | ||
case 'currentFilterItemId': | ||
_this.setData({ | ||
currentFilterItemId: val.val | ||
}); | ||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
var getGroupDataVal = function getGroupDataVal() { | ||
return _this.data.placeHolderObj; | ||
}; | ||
_context.context.addGroup(this.props.uid); | ||
_context.context.setGroupDataVal(this.props.uid, setGroupDataVal); | ||
_context.context.getGroupDataVal(this.props.uid, getGroupDataVal); | ||
_context.context.updateGroupValue(this.props.uid); | ||
}, | ||
methods: { | ||
showFilterItem: function showFilterItem(e) { | ||
var _this2 = this; | ||
var group = _context.context.getGroup(this.props.uid); | ||
if (group) { | ||
(0, _tools.objectEntries)(group.items).forEach(function (_ref) { | ||
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2), | ||
v = _ref2[1]; | ||
if (v.getid() === e.currentTarget.dataset.filterItemId) { | ||
var show = v.getShow(); // 记录 filterItem 数据以重置 | ||
if (!show) { | ||
if (v.isMult()) { | ||
v.setPrevValue(v.getCurValue()); | ||
} | ||
v.setShow(!show); | ||
_this2.setData({ | ||
currentFilterItemId: "".concat(v.getid()) | ||
}); | ||
return; | ||
props: props_1.FilterDefaultProps, | ||
data: { | ||
placeHolderObj: {}, | ||
activeObj: {}, | ||
currentFilterItemId: '', | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
var setGroupDataVal = function (val) { | ||
switch (val.key) { | ||
case 'placeHolderArray': | ||
_this.setData({ | ||
placeHolderObj: val.val, | ||
}); | ||
break; | ||
case 'activeArray': | ||
_this.setData({ | ||
activeObj: __assign(__assign({}, _this.data.activeObj), val.val), | ||
}); | ||
break; | ||
case 'currentFilterItemId': | ||
_this.setData({ | ||
currentFilterItemId: val.val, | ||
}); | ||
break; | ||
default: | ||
break; | ||
} | ||
v.setShow(!show); | ||
_this2.setData({ | ||
currentFilterItemId: '' | ||
}); | ||
} else { | ||
v.getShow() && v.setShow(false); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
}; | ||
var getGroupDataVal = function () { return _this.data.placeHolderObj; }; | ||
context_1.context.addGroup(this.props.uid); | ||
context_1.context.setGroupDataVal(this.props.uid, setGroupDataVal); | ||
context_1.context.getGroupDataVal(this.props.uid, getGroupDataVal); | ||
context_1.context.updateGroupValue(this.props.uid); | ||
}, | ||
methods: { | ||
showFilterItem: function (e) { | ||
var _this = this; | ||
var group = context_1.context.getGroup(this.props.uid); | ||
if (group) { | ||
(0, tools_1.objectEntries)(group.items).forEach(function (_a) { | ||
var v = _a[1]; | ||
if (v.getid() === e.currentTarget.dataset.filterItemId) { | ||
var show = v.getShow(); | ||
// 记录 filterItem 数据以重置 | ||
if (!show) { | ||
if (v.isMult()) { | ||
v.setPrevValue(v.getCurValue()); | ||
} | ||
v.setShow(!show); | ||
_this.setData({ | ||
currentFilterItemId: "".concat(v.getid()), | ||
}); | ||
return; | ||
} | ||
v.setShow(!show); | ||
_this.setData({ | ||
currentFilterItemId: '', | ||
}); | ||
} | ||
else { | ||
v.getShow() && v.setShow(false); | ||
} | ||
}); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.FilterDefaultProps = void 0; | ||
var FilterDefaultProps = { | ||
uid: 'filter' | ||
export const FilterDefaultProps = { | ||
uid: 'filter', | ||
}; | ||
exports.FilterDefaultProps = FilterDefaultProps; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Component({}); |
"use strict"; | ||
var _store = require("../store"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var store_1 = require("../store"); | ||
Component({ | ||
props: { | ||
rules: [], | ||
name: 'default', | ||
form: 'default', | ||
initialValue: '', | ||
position: 'horizontal', | ||
required: false | ||
}, | ||
data: { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
setData: function setData() {}, | ||
errorInfo: null, | ||
defaultLabelWidth: '' | ||
}, | ||
onInit: function onInit() { | ||
var _this = this; | ||
var _this$props = this.props, | ||
form = _this$props.form, | ||
field = _this$props.name, | ||
rules = _this$props.rules, | ||
initialValue = _this$props.initialValue, | ||
required = _this$props.required; | ||
if (form && field) { | ||
this.$page.data._getCurrentField = function () { | ||
return { | ||
form: function form() { | ||
return _this.props.form; | ||
}, | ||
field: function field() { | ||
return _this.props.name; | ||
} | ||
}; | ||
}; | ||
_store.store.bootstrap(form, field, rules, initialValue, required); | ||
} | ||
}, | ||
didMount: function didMount() { | ||
var _this2 = this; | ||
this.data.setData = this.$page.data._currentSetData; | ||
if (!this.data.setData) return; | ||
var _this$props2 = this.props, | ||
form = _this$props2.form, | ||
field = _this$props2.name; | ||
if (form && field) { | ||
_store.store.setValueAfterUpdate(this.data.setData, form, field); | ||
_store.store.setFieldUpdateInfoFn(form, field, this.updateErrorInfo.bind(this)); | ||
if (field === 'submit') { | ||
_store.store.setUpdateSubmitButtonStatusFn(form, field, this.updateSubmitButtonStatus.bind(this)); | ||
} | ||
} | ||
my.createSelectorQuery().select('.amd-form-item-label-horizontal').boundingClientRect().exec(function (ret) { | ||
if (ret && ret[0] && ret[0].width) { | ||
_this2.setData({ | ||
defaultLabelWidth: "".concat(ret[0].width, "px") | ||
props: { | ||
rules: [], | ||
name: 'default', | ||
form: 'default', | ||
initialValue: '', | ||
position: 'horizontal', | ||
required: false, | ||
}, | ||
data: { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
setData: function () { }, | ||
errorInfo: null, | ||
defaultLabelWidth: '', | ||
}, | ||
onInit: function () { | ||
var _this = this; | ||
var _a = this.props, form = _a.form, field = _a.name, rules = _a.rules, initialValue = _a.initialValue, required = _a.required; | ||
if (form && field) { | ||
this.$page.data._getCurrentField = function () { | ||
return { form: function () { return _this.props.form; }, field: function () { return _this.props.name; } }; | ||
}; | ||
store_1.store.bootstrap(form, field, rules, initialValue, required); | ||
} | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
this.data.setData = this.$page.data._currentSetData; | ||
if (!this.data.setData) | ||
return; | ||
var _a = this.props, form = _a.form, field = _a.name; | ||
if (form && field) { | ||
store_1.store.setValueAfterUpdate(this.data.setData, form, field); | ||
store_1.store.setFieldUpdateInfoFn(form, field, this.updateErrorInfo.bind(this)); | ||
if (field === 'submit') { | ||
store_1.store.setUpdateSubmitButtonStatusFn(form, field, this.updateSubmitButtonStatus.bind(this)); | ||
} | ||
} | ||
my.createSelectorQuery() | ||
.select('.amd-form-item-label-horizontal') | ||
.boundingClientRect() | ||
.exec(function (ret) { | ||
if (ret && ret[0] && ret[0].width) { | ||
_this.setData({ | ||
defaultLabelWidth: "".concat(ret[0].width, "px"), | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
var currentField = prevProps.name; | ||
var _this$props3 = this.props, | ||
form = _this$props3.form, | ||
nextField = _this$props3.name; | ||
if (currentField && nextField && currentField !== nextField) { | ||
_store.store.setValueAfterUpdate(this.data.setData, form, nextField); | ||
_store.store.updateFieldSet(form, currentField, nextField); | ||
} | ||
}, | ||
didUnmount: function didUnmount() { | ||
var _this$props4 = this.props, | ||
form = _this$props4.form, | ||
field = _this$props4.name; | ||
_store.store.delFieldSet(form, field); | ||
}, | ||
methods: { | ||
updateErrorInfo: function updateErrorInfo(payload) { | ||
this.setData({ | ||
errorInfo: payload | ||
}); | ||
}, | ||
updateSubmitButtonStatus: function updateSubmitButtonStatus(payload) { | ||
this.setData({ | ||
submitDisable: !!payload | ||
}); | ||
} | ||
} | ||
didUpdate: function (prevProps) { | ||
var currentField = prevProps.name; | ||
var _a = this.props, form = _a.form, nextField = _a.name; | ||
if (currentField && nextField && currentField !== nextField) { | ||
store_1.store.setValueAfterUpdate(this.data.setData, form, nextField); | ||
store_1.store.updateFieldSet(form, currentField, nextField); | ||
} | ||
}, | ||
didUnmount: function () { | ||
var _a = this.props, form = _a.form, field = _a.name; | ||
store_1.store.delFieldSet(form, field); | ||
}, | ||
methods: { | ||
updateErrorInfo: function (payload) { | ||
this.setData({ errorInfo: payload }); | ||
}, | ||
updateSubmitButtonStatus: function (payload) { | ||
this.setData({ submitDisable: !!payload }); | ||
}, | ||
}, | ||
}); |
"use strict"; | ||
var _store = require("./store"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var store_1 = require("./store"); | ||
Component({ | ||
props: { | ||
onValuesChange: function onValuesChange(changedValues, totalValues) { | ||
return { | ||
changedValues: changedValues, | ||
totalValues: totalValues | ||
}; | ||
props: { | ||
onValuesChange: function onValuesChange(changedValues, totalValues) { | ||
return { | ||
changedValues: changedValues, | ||
totalValues: totalValues, | ||
}; | ||
}, | ||
onFinish: function onFinish(totalValues) { | ||
return totalValues; | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
onFinishFailed: function onFinishFailed() { }, | ||
className: '', | ||
form: 'default', | ||
initialValues: {}, | ||
}, | ||
onFinish: function onFinish(totalValues) { | ||
return totalValues; | ||
onInit: function () { | ||
var _a = this.props, form = _a.form, initialValues = _a.initialValues, onValuesChange = _a.onValuesChange, onFinish = _a.onFinish; | ||
if (!form) { | ||
throw new Error('no form name'); | ||
} // setup initval | ||
store_1.store.init(form, initialValues, onValuesChange, onFinish); | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
onFinishFailed: function onFinishFailed() {}, | ||
className: '', | ||
form: 'default', | ||
initialValues: {} | ||
}, | ||
onInit: function onInit() { | ||
var _this$props = this.props, | ||
form = _this$props.form, | ||
initialValues = _this$props.initialValues, | ||
onValuesChange = _this$props.onValuesChange, | ||
onFinish = _this$props.onFinish; | ||
if (!form) { | ||
throw new Error('no form name'); | ||
} // setup initval | ||
_store.store.init(form, initialValues, onValuesChange, onFinish); | ||
}, | ||
didUnmount: function didUnmount() { | ||
_store.store.tear(this.props.form); | ||
}, | ||
ref: function ref() { | ||
var _this = this; | ||
return { | ||
getCompInstance: function getCompInstance() { | ||
return _this; | ||
}, | ||
setFieldsValue: function setFieldsValue(form, value) { | ||
return _store.store.setFieldsValue(form, value); | ||
} | ||
}; | ||
} | ||
didUnmount: function didUnmount() { | ||
store_1.store.tear(this.props.form); | ||
}, | ||
ref: function () { | ||
var _this = this; | ||
return { | ||
getCompInstance: function () { return _this; }, | ||
setFieldsValue: function (form, value) { return store_1.store.setFieldsValue(form, value); }, | ||
}; | ||
}, | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.store = void 0; | ||
var _formStore = require("../_util/formStore"); | ||
var formStore_1 = require("../_util/formStore"); | ||
// export function createEvent(id: string): EventEmit { | ||
// return new EventEmit(id); | ||
// } | ||
var store = new _formStore.Store(); | ||
exports.store = store; | ||
exports.store = new formStore_1.Store(); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fmtEvent = _interopRequireDefault(require("../_util/fmtEvent")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var fmtEvent_1 = require("../_util/fmtEvent"); | ||
Component({ | ||
props: _props.IconDefaultProps, | ||
methods: { | ||
onTap: function onTap(e) { | ||
var onTap = this.props.onTap; | ||
if (onTap) { | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onTap(event); | ||
} | ||
} | ||
} | ||
props: props_1.IconDefaultProps, | ||
methods: { | ||
onTap: function (e) { | ||
var onTap = this.props.onTap; | ||
if (onTap) { | ||
var event = (0, fmtEvent_1.default)(this.props, e); | ||
return onTap(event); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.IconDefaultProps = void 0; | ||
var IconDefaultProps = { | ||
export const IconDefaultProps = { | ||
type: '', | ||
size: 'medium' | ||
size: 'medium', | ||
}; | ||
exports.IconDefaultProps = IconDefaultProps; |
@@ -1,8 +0,6 @@ | ||
"use strict"; | ||
Component({ | ||
props: { | ||
image: '', | ||
iconSize: 'small' | ||
} | ||
props: { | ||
image: '', | ||
iconSize: 'small', | ||
}, | ||
}); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _controlled = _interopRequireDefault(require("../mixins/controlled")); | ||
var _form = _interopRequireDefault(require("../mixins/form")); | ||
var _store = require("../Form/store"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var controlled_1 = require("../mixins/controlled"); | ||
var form_1 = require("../mixins/form"); | ||
var store_1 = require("../Form/store"); | ||
Component({ | ||
mixins: [(0, _controlled["default"])(), (0, _form["default"])()], | ||
props: _props.InputItemDefaultProps, | ||
data: { | ||
showClear: false | ||
}, | ||
methods: { | ||
hideClear: function hideClear() { | ||
this.setData({ | ||
showClear: false | ||
}); | ||
mixins: [(0, controlled_1.default)(), (0, form_1.default)()], | ||
props: props_1.InputItemDefaultProps, | ||
data: { | ||
showClear: false, | ||
}, | ||
showClear: function showClear() { | ||
this.setData({ | ||
showClear: true | ||
}); | ||
methods: { | ||
hideClear: function () { | ||
this.setData({ | ||
showClear: false, | ||
}); | ||
}, | ||
showClear: function () { | ||
this.setData({ | ||
showClear: true, | ||
}); | ||
}, | ||
// 按钮消失 | ||
onBlur: function (e) { | ||
this.hideClear(); | ||
var onBlur = this.props.onBlur; | ||
if (onBlur) { | ||
var value = e.detail.value; | ||
onBlur(value); | ||
} | ||
}, | ||
// 按钮消失 | ||
onConfirm: function (e) { | ||
this.hideClear(); | ||
var onConfirm = this.props.onConfirm; | ||
if (onConfirm) { | ||
var value = e.detail.value; | ||
onConfirm(value); | ||
} | ||
}, | ||
// 展示无需蒙层 | ||
onFocus: function (e) { | ||
this.showClear(); | ||
var onFocus = this.props.onFocus; | ||
if (onFocus) { | ||
var value = e.detail.value; | ||
onFocus(value); | ||
} | ||
}, | ||
onChange: function (e) { | ||
var onChange = this.props.onChange; | ||
if (onChange) { | ||
var value = e.detail.value; | ||
this.cOnChange(value); | ||
} | ||
}, | ||
triggerOnValuesChange: function () { | ||
// 触发 | ||
var _a = this.props._getCurrentField(), formFn = _a.form, fieldFn = _a.field; | ||
var form = formFn(); | ||
var field = fieldFn(); | ||
if (form && field) { | ||
store_1.store.trigger(form, field, ''); | ||
} | ||
}, | ||
onClear: function () { | ||
this.hideClear(); | ||
var _a = this.props, onClear = _a.onClear, controlled = _a.controlled; | ||
if (onClear) { | ||
onClear(''); | ||
} | ||
if (!controlled) { | ||
this.setData({ | ||
cValue: '', | ||
}); | ||
// 非受控模式下生效 | ||
this.triggerOnValuesChange(); | ||
} | ||
}, | ||
}, | ||
// 按钮消失 | ||
onBlur: function onBlur(e) { | ||
this.hideClear(); | ||
var onBlur = this.props.onBlur; | ||
if (onBlur) { | ||
var value = e.detail.value; | ||
onBlur(value); | ||
} | ||
}, | ||
// 按钮消失 | ||
onConfirm: function onConfirm(e) { | ||
this.hideClear(); | ||
var onConfirm = this.props.onConfirm; | ||
if (onConfirm) { | ||
var value = e.detail.value; | ||
onConfirm(value); | ||
} | ||
}, | ||
// 展示无需蒙层 | ||
onFocus: function onFocus(e) { | ||
this.showClear(); | ||
var onFocus = this.props.onFocus; | ||
if (onFocus) { | ||
var value = e.detail.value; | ||
onFocus(value); | ||
} | ||
}, | ||
onChange: function onChange(e) { | ||
var onChange = this.props.onChange; | ||
if (onChange) { | ||
var value = e.detail.value; | ||
this.cOnChange(value); | ||
} | ||
}, | ||
triggerOnValuesChange: function triggerOnValuesChange() { | ||
// 触发 | ||
var _this$props$_getCurre = this.props._getCurrentField(), | ||
formFn = _this$props$_getCurre.form, | ||
fieldFn = _this$props$_getCurre.field; | ||
var form = formFn(); | ||
var field = fieldFn(); | ||
if (form && field) { | ||
_store.store.trigger(form, field, ''); | ||
} | ||
}, | ||
onClear: function onClear() { | ||
this.hideClear(); | ||
var _this$props = this.props, | ||
onClear = _this$props.onClear, | ||
controlled = _this$props.controlled; | ||
if (onClear) { | ||
onClear(''); | ||
} | ||
if (!controlled) { | ||
this.setData({ | ||
cValue: '' | ||
}); // 非受控模式下生效 | ||
this.triggerOnValuesChange(); | ||
} | ||
} | ||
} | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.InputItemDefaultProps = void 0; | ||
var InputItemDefaultProps = { | ||
export const InputItemDefaultProps = { | ||
controlled: false, | ||
@@ -20,4 +14,3 @@ type: 'text', | ||
autoFocus: false, | ||
disabled: false | ||
disabled: false, | ||
}; | ||
exports.InputItemDefaultProps = InputItemDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.ListDefaultProps | ||
props: props_1.ListDefaultProps, | ||
}); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fmtEvent = _interopRequireDefault(require("../../_util/fmtEvent")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var fmtEvent_1 = require("../../_util/fmtEvent"); | ||
Component({ | ||
props: _props.ListItemDefaultProps, | ||
data: { | ||
imageSize: '', | ||
hide: false | ||
}, | ||
methods: { | ||
onTap: function onTap(e) { | ||
if (this.props.disabled) return; | ||
var onTap = this.props.onTap; | ||
if (onTap) { | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onTap(event); | ||
} | ||
} | ||
}, | ||
didMount: function didMount() { | ||
this.setData({ | ||
imageSize: this.props.imageSize | ||
}); | ||
} | ||
props: props_1.ListItemDefaultProps, | ||
data: { | ||
imageSize: '', | ||
hide: false, | ||
}, | ||
methods: { | ||
onTap: function (e) { | ||
if (this.props.disabled) | ||
return; | ||
var onTap = this.props.onTap; | ||
if (onTap) { | ||
var event = (0, fmtEvent_1.default)(this.props, e); | ||
return onTap(event); | ||
} | ||
}, | ||
}, | ||
didMount: function () { | ||
this.setData({ | ||
imageSize: this.props.imageSize, | ||
}); | ||
}, | ||
}); |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ListItemDefaultProps = void 0; | ||
var ListItemDefaultProps = { | ||
export const ListItemDefaultProps = { | ||
imageSize: 'small', | ||
disabled: false | ||
disabled: false, | ||
}; | ||
exports.ListItemDefaultProps = ListItemDefaultProps; |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ListDefaultProps = void 0; | ||
var ListDefaultProps = { | ||
radius: false | ||
export const ListDefaultProps = { | ||
radius: false, | ||
}; | ||
exports.ListDefaultProps = ListDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
/** | ||
@@ -9,41 +8,37 @@ * 注意,delay 的变更不能实时生效 | ||
Component({ | ||
props: _props.LoadingDefaultProps, | ||
data: { | ||
// 决定实际是否渲染加载中状态 | ||
_loading: false | ||
}, | ||
didMount: function didMount() { | ||
this.setLoading(); | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
if (prevProps.loading !== this.props.loading) { | ||
if (this.timeout) { | ||
clearTimeout(this.timeout); | ||
} | ||
this.setLoading(); | ||
} | ||
}, | ||
methods: { | ||
setLoading: function setLoading() { | ||
var _this = this; | ||
var _this$props = this.props, | ||
delay = _this$props.delay, | ||
loading = _this$props.loading; | ||
var realDelay = isNaN(delay) ? 0 : delay; | ||
if (loading && !this.data._loading) { | ||
this.timeout = setTimeout(function () { | ||
_this.setData({ | ||
_loading: true | ||
}); | ||
}, realDelay); | ||
} else if (!loading && this.data._loading) { | ||
this.setData({ | ||
_loading: false | ||
}); | ||
} | ||
} | ||
} | ||
props: props_1.LoadingDefaultProps, | ||
data: { | ||
// 决定实际是否渲染加载中状态 | ||
_loading: false, | ||
}, | ||
didMount: function () { | ||
this.setLoading(); | ||
}, | ||
didUpdate: function (prevProps) { | ||
if (prevProps.loading !== this.props.loading) { | ||
if (this.timeout) { | ||
clearTimeout(this.timeout); | ||
} | ||
this.setLoading(); | ||
} | ||
}, | ||
methods: { | ||
setLoading: function () { | ||
var _this = this; | ||
var _a = this.props, delay = _a.delay, loading = _a.loading; | ||
var realDelay = isNaN(delay) ? 0 : delay; | ||
if (loading && !this.data._loading) { | ||
this.timeout = setTimeout(function () { | ||
_this.setData({ | ||
_loading: true, | ||
}); | ||
}, realDelay); | ||
} | ||
else if (!loading && this.data._loading) { | ||
this.setData({ | ||
_loading: false, | ||
}); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.LoadingDefaultProps = void 0; | ||
var LoadingDefaultProps = { | ||
export const LoadingDefaultProps = { | ||
loading: true, | ||
@@ -15,4 +9,3 @@ size: 'medium', | ||
height: '', | ||
type: 'spin' | ||
type: 'spin', | ||
}; | ||
exports.LoadingDefaultProps = LoadingDefaultProps; |
@@ -1,16 +0,14 @@ | ||
"use strict"; | ||
Component({ | ||
props: { | ||
size: '200rpx', | ||
className: '', | ||
color: '#999', | ||
height: '' | ||
}, | ||
didUpdate: function didUpdate() { | ||
var color = this.props.color; | ||
this.setData({ | ||
color: color | ||
}); | ||
} | ||
props: { | ||
size: '200rpx', | ||
className: '', | ||
color: '#999', | ||
height: '', | ||
}, | ||
didUpdate: function () { | ||
var color = this.props.color; | ||
this.setData({ | ||
color: color, | ||
}); | ||
}, | ||
}); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _fmtEvent = _interopRequireDefault(require("../_util/fmtEvent")); | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fmtEvent_1 = require("../_util/fmtEvent"); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.MaskDefaultProps, | ||
methods: { | ||
onMaskClick: function onMaskClick(e) { | ||
var onMaskTap = this.props.onMaskTap; | ||
if (typeof onMaskTap === 'function') { | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
onMaskTap(event); | ||
} | ||
} | ||
} | ||
props: props_1.MaskDefaultProps, | ||
methods: { | ||
onMaskClick: function (e) { | ||
var onMaskTap = this.props.onMaskTap; | ||
if (typeof onMaskTap === 'function') { | ||
var event = (0, fmtEvent_1.default)(this.props, e); | ||
onMaskTap(event); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,13 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.MaskDefaultProps = void 0; | ||
var MaskDefaultProps = { | ||
maskZindex: '', | ||
type: 'product', | ||
show: true, | ||
fixMaskFull: false | ||
}; | ||
exports.MaskDefaultProps = MaskDefaultProps; | ||
export const MaskDefaultProps = { | ||
maskZindex: '', | ||
type: 'product', | ||
show: true, | ||
fixMaskFull: false, | ||
}; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
var fast_deep_equal_1 = require("fast-deep-equal"); | ||
function computedData() { | ||
var _this = this; | ||
var nextData = this.computed(this.props); // 浅比较就行了 | ||
var changedData = Object.keys(nextData).reduce(function (prev, item) { | ||
// 移除 _ $ 开头的保留 props | ||
if (item[0] === '_' || item[0] === '$') { | ||
return prev; | ||
var _this = this; | ||
var nextData = this.computed(this.props); | ||
// 浅比较就行了 | ||
var changedData = Object.keys(nextData).reduce(function (prev, item) { | ||
// 移除 _ $ 开头的保留 props | ||
if (item[0] === '_' || item[0] === '$') { | ||
return prev; | ||
} | ||
if (typeof nextData[item] === 'function') { | ||
return prev; | ||
} | ||
if ((0, fast_deep_equal_1.default)(_this.data[item], nextData[item])) { | ||
return prev; | ||
} | ||
// eslint-disable-next-line no-param-reassign | ||
prev[item] = nextData[item]; | ||
return prev; | ||
}, {}); | ||
if (Object.keys(changedData).length === 0) { | ||
return; | ||
} | ||
if (typeof nextData[item] === 'function') { | ||
return prev; | ||
} | ||
if ((0, _fastDeepEqual["default"])(_this.data[item], nextData[item])) { | ||
return prev; | ||
} // eslint-disable-next-line no-param-reassign | ||
prev[item] = nextData[item]; | ||
return prev; | ||
}, {}); | ||
if (Object.keys(changedData).length === 0) { | ||
return; | ||
} | ||
this.setData(changedData); | ||
this.setData(changedData); | ||
} | ||
var _default = { | ||
didMount: function didMount() { | ||
computedData.call(this); | ||
}, | ||
didUpdate: function didUpdate() { | ||
computedData.call(this); | ||
} | ||
}; | ||
exports["default"] = _default; | ||
exports.default = { | ||
didMount: function () { | ||
computedData.call(this); | ||
}, | ||
didUpdate: function () { | ||
computedData.call(this); | ||
}, | ||
}; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
var fast_deep_equal_1 = require("fast-deep-equal"); | ||
/** | ||
@@ -41,49 +32,40 @@ * @description 处理通用受控非受控模式 | ||
*/ | ||
var _default = function _default() { | ||
var propsValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "value"; | ||
return { | ||
data: { | ||
cValue: null | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
this.cTrigger = function (v) { | ||
_this.setData({ | ||
cValue: v | ||
}); | ||
}; | ||
this.cTrigger(this.props[propsValue]); | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
var value = this.props[propsValue]; | ||
if (!(0, _fastDeepEqual["default"])(prevProps[propsValue], value)) { | ||
this.cTrigger(value); | ||
} | ||
}, | ||
methods: { | ||
cOnChange: function cOnChange(v, v1) { | ||
var _this$props$onChange, _this$props; | ||
if (!this.props.controlled) { | ||
this.cTrigger(v); | ||
} | ||
(_this$props$onChange = (_this$props = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, v, v1); | ||
}, | ||
cOnInput: function cOnInput(v) { | ||
var _this$props$onInput, _this$props2; | ||
if (!this.props.controlled) { | ||
this.cTrigger(v); | ||
} | ||
(_this$props$onInput = (_this$props2 = this.props).onInput) === null || _this$props$onInput === void 0 ? void 0 : _this$props$onInput.call(_this$props2, v); | ||
} | ||
} | ||
}; | ||
}; | ||
exports["default"] = _default; | ||
exports.default = (function (propsValue) { | ||
if (propsValue === void 0) { propsValue = "value"; } | ||
return ({ | ||
data: { | ||
cValue: null, | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
this.cTrigger = function (v) { | ||
_this.setData({ | ||
cValue: v, | ||
}); | ||
}; | ||
this.cTrigger(this.props[propsValue]); | ||
}, | ||
didUpdate: function (prevProps) { | ||
var value = this.props[propsValue]; | ||
if (!(0, fast_deep_equal_1.default)(prevProps[propsValue], value)) { | ||
this.cTrigger(value); | ||
} | ||
}, | ||
methods: { | ||
cOnChange: function (v, v1) { | ||
var _a, _b; | ||
if (!this.props.controlled) { | ||
this.cTrigger(v); | ||
} | ||
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, v, v1); | ||
}, | ||
cOnInput: function (v) { | ||
var _a, _b; | ||
if (!this.props.controlled) { | ||
this.cTrigger(v); | ||
} | ||
(_b = (_a = this.props).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, v); | ||
}, | ||
}, | ||
}); | ||
}); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
exports.isNotFormMode = isNotFormMode; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _store = require("../Form/store"); | ||
var _compareVersion = require("../_util/compareVersion"); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/** | ||
* @description 表单组件绑定处理 | ||
*/ | ||
var _default = function _default() { | ||
return { | ||
props: { | ||
onChange: function onChange(e) { | ||
var getCurrentField = this._getCurrentField || this.props._getCurrentField; | ||
if (!getCurrentField) return; | ||
var _getCurrentField = getCurrentField(), | ||
formFn = _getCurrentField.form, | ||
fieldFn = _getCurrentField.field; | ||
var form = formFn(); | ||
var field = fieldFn(); | ||
if (form && field) { | ||
_store.store.trigger(form, field, e); | ||
} | ||
}, | ||
_getCurrentField: function _getCurrentField() { | ||
return { | ||
form: function form() { | ||
return ''; | ||
}, | ||
field: function field() { | ||
return ''; | ||
} | ||
}; | ||
}, | ||
value: '', | ||
checked: false, | ||
valuePropName: 'cValue', | ||
mode: 'normal' | ||
}, | ||
onInit: function onInit() { | ||
var _this = this; | ||
if (_compareVersion.isMoreThan106 && isNotFormMode(this.props.mode)) return; | ||
var getCurrentField = this.$page.data._getCurrentField; | ||
if (!getCurrentField) return; | ||
this.props._getCurrentField = getCurrentField; | ||
var _getCurrentField2 = getCurrentField(), | ||
formFn = _getCurrentField2.form, | ||
fieldFn = _getCurrentField2.field; | ||
var form = formFn(); | ||
var field = fieldFn(); | ||
_store.store.addFieldSet(form, field); // 初始值设定 | ||
var initVal = _store.store.getInitValByField(form, field); | ||
this.props.value = initVal; // terms组件 | ||
if (typeof initVal === 'boolean') { | ||
this.props.checked = initVal; | ||
} // 兼容一下 checkbox-group | ||
var commonUpdateFieldValue = function commonUpdateFieldValue(v) { | ||
_this.props.value = v; | ||
_this.setData((0, _defineProperty2["default"])({}, _this.props.valuePropName, v)); | ||
}; | ||
var updateFieldValue = this._updateFieldValue || commonUpdateFieldValue; | ||
_store.store.addUpdateFiledValue(form, field, updateFieldValue.bind(this)); | ||
}, | ||
didMount: function didMount() { | ||
if (_compareVersion.isMoreThan106 && isNotFormMode(this.props.mode)) { | ||
this.$page.data._currentSetData = null; | ||
} else { | ||
this.$page.data._currentSetData = this.setData; | ||
} | ||
} | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isNotFormMode = void 0; | ||
var store_1 = require("../Form/store"); | ||
var compareVersion_1 = require("../_util/compareVersion"); | ||
exports.default = (function () { | ||
return { | ||
props: { | ||
onChange: function (e) { | ||
var getCurrentField = this._getCurrentField || this.props._getCurrentField; | ||
if (!getCurrentField) | ||
return; | ||
var _a = getCurrentField(), formFn = _a.form, fieldFn = _a.field; | ||
var form = formFn(); | ||
var field = fieldFn(); | ||
if (form && field) { | ||
store_1.store.trigger(form, field, e); | ||
} | ||
}, | ||
_getCurrentField: function () { | ||
return { form: function () { return ''; }, field: function () { return ''; } }; | ||
}, | ||
value: '', | ||
checked: false, | ||
valuePropName: 'cValue', | ||
mode: 'normal', | ||
}, | ||
onInit: function () { | ||
var _this = this; | ||
if (compareVersion_1.isMoreThan106 && isNotFormMode(this.props.mode)) | ||
return; | ||
var getCurrentField = this.$page.data._getCurrentField; | ||
if (!getCurrentField) | ||
return; | ||
this.props._getCurrentField = getCurrentField; | ||
var _a = getCurrentField(), formFn = _a.form, fieldFn = _a.field; | ||
var form = formFn(); | ||
var field = fieldFn(); | ||
store_1.store.addFieldSet(form, field); | ||
// 初始值设定 | ||
var initVal = store_1.store.getInitValByField(form, field); | ||
this.props.value = initVal; | ||
// terms组件 | ||
if (typeof initVal === 'boolean') { | ||
this.props.checked = initVal; | ||
} | ||
// 兼容一下 checkbox-group | ||
var commonUpdateFieldValue = function (v) { | ||
var _a; | ||
_this.props.value = v; | ||
_this.setData((_a = {}, | ||
_a[_this.props.valuePropName] = v, | ||
_a)); | ||
}; | ||
var updateFieldValue = this._updateFieldValue || commonUpdateFieldValue; | ||
store_1.store.addUpdateFiledValue(form, field, updateFieldValue.bind(this)); | ||
}, | ||
didMount: function () { | ||
if (compareVersion_1.isMoreThan106 && isNotFormMode(this.props.mode)) { | ||
this.$page.data._currentSetData = null; | ||
} | ||
else { | ||
this.$page.data._currentSetData = this.setData; | ||
} | ||
}, | ||
}; | ||
}); | ||
/** | ||
@@ -106,8 +77,5 @@ * 判断组件是否为表单模式 | ||
*/ | ||
exports["default"] = _default; | ||
function isNotFormMode(mode) { | ||
return mode !== 'form'; | ||
} | ||
return mode !== 'form'; | ||
} | ||
exports.isNotFormMode = isNotFormMode; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _store = require("../Form/store"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var _default = function _default() { | ||
return { | ||
onInit: function onInit() { | ||
var _this = this; | ||
if (this.props.mode === 'form' && this.props.htmlType === 'submit') { | ||
this.props._submit = function () { | ||
_store.store.onFinish(function () { | ||
return _this.props.form; | ||
}); | ||
}; | ||
this.$page.data._getCurrentField = null; | ||
} | ||
} | ||
}; | ||
}; | ||
exports["default"] = _default; | ||
var store_1 = require("../Form/store"); | ||
exports.default = (function () { return ({ | ||
onInit: function () { | ||
var _this = this; | ||
if (this.props.mode === 'form' | ||
&& this.props.htmlType === 'submit') { | ||
this.props._submit = function () { | ||
store_1.store.onFinish(function () { return _this.props.form; }); | ||
}; | ||
this.$page.data._getCurrentField = null; | ||
} | ||
}, | ||
}); }); |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.ModalDefaultProps, | ||
data: { | ||
isShowBtn: true | ||
}, | ||
methods: { | ||
onClose: function onClose() { | ||
var onClose = this.props.onClose; | ||
if (typeof onClose === 'function') { | ||
return onClose(); | ||
} | ||
props: props_1.ModalDefaultProps, | ||
data: { | ||
isShowBtn: true, | ||
}, | ||
onButtonTap: function onButtonTap(e) { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (typeof onButtonTap === 'function') { | ||
var type = e.currentTarget.dataset.type; | ||
return onButtonTap(type); | ||
} | ||
} | ||
} | ||
methods: { | ||
onClose: function () { | ||
var onClose = this.props.onClose; | ||
if (typeof onClose === 'function') { | ||
return onClose(); | ||
} | ||
}, | ||
onButtonTap: function (e) { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (typeof onButtonTap === 'function') { | ||
var type = e.currentTarget.dataset.type; | ||
return onButtonTap(type); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ModalDefaultProps = void 0; | ||
var ModalDefaultProps = { | ||
export const ModalDefaultProps = { | ||
imageSize: 'medium', | ||
@@ -13,4 +7,3 @@ visible: false, | ||
addonButtonText: '辅助操作', | ||
maskClosable: true | ||
maskClosable: true, | ||
}; | ||
exports.ModalDefaultProps = ModalDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _props = require("./props"); | ||
var _console = require("../_util/console"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var console_1 = require("../_util/console"); | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
var noop = function noop() {}; | ||
var noop = function () { }; | ||
var _canIUseTransitionEnd = my.canIUse('view.onTransitionEnd'); | ||
Component({ | ||
props: _props.NoticeBarDefaultProps, | ||
data: { | ||
_show: true, | ||
_canIUseTransitionEnd: _canIUseTransitionEnd, | ||
_marqueeStyle: '', | ||
_animatedWidth: 0, | ||
_overflowWidth: 0, | ||
_duration: 0, | ||
_viewWidth: 0 | ||
}, | ||
didMount: function didMount() { | ||
var enableMarquee = this.props.enableMarquee; | ||
this.showError(); | ||
if (enableMarquee) { | ||
if (!_canIUseTransitionEnd) { | ||
this._measureText(); | ||
this._startAnimation(); | ||
} else { | ||
this._measureText(this.startMarquee.bind(this)); | ||
} | ||
} | ||
}, | ||
didUpdate: function didUpdate() { | ||
var enableMarquee = this.props.enableMarquee; | ||
this.showError(); // 这里更新处理的原因是防止notice内容在动画过程中发生改变。 | ||
if (enableMarquee) { | ||
if (!this._marqueeTimer && !_canIUseTransitionEnd) { | ||
this._measureText(); | ||
this._startAnimation(); | ||
} else { | ||
this._measureText(this.startMarquee.bind(this)); | ||
} | ||
} | ||
}, | ||
didUnmount: function didUnmount() { | ||
if (this._marqueeTimer) { | ||
clearTimeout(this._marqueeTimer); | ||
this._marqueeTimer = null; | ||
} | ||
}, | ||
methods: { | ||
showError: function showError() { | ||
var actions = this.props.actions; | ||
if (!Array.isArray(actions) && typeof actions !== 'undefined') { | ||
_console.log.warn('NoticeBar', "\u5F53\u524D\u5B9A\u4E49\u7684 actions \u7684\u7C7B\u578B\u4E3A ".concat((0, _typeof2["default"])(actions), "\uFF0C\u4E0D\u7B26\u5408\u5C5E\u6027\u5B9A\u4E49\uFF0C\u5E94\u8BE5\u4E3A\u6570\u7EC4\uFF0C\u5982\uFF1Aactions=\"{{['\u503C', '\u503C']}}")); | ||
} | ||
props: props_1.NoticeBarDefaultProps, | ||
data: { | ||
_show: true, | ||
_canIUseTransitionEnd: _canIUseTransitionEnd, | ||
_marqueeStyle: '', | ||
_animatedWidth: 0, | ||
_overflowWidth: 0, | ||
_duration: 0, | ||
_viewWidth: 0, | ||
}, | ||
onTap: function onTap() { | ||
var _this$props = this.props, | ||
mode = _this$props.mode, | ||
onTap = _this$props.onTap; | ||
if (mode === 'link' && typeof onTap === 'function') { | ||
return onTap(); | ||
} | ||
if (mode === 'closeable' && typeof onTap === 'function') { | ||
this.setData({ | ||
_show: false | ||
}); | ||
return onTap(); | ||
} | ||
didMount: function () { | ||
var enableMarquee = this.props.enableMarquee; | ||
this.showError(); | ||
if (enableMarquee) { | ||
if (!_canIUseTransitionEnd) { | ||
this._measureText(); | ||
this._startAnimation(); | ||
} | ||
else { | ||
this._measureText(this.startMarquee.bind(this)); | ||
} | ||
} | ||
}, | ||
onActionTap: function onActionTap(e) { | ||
var onActionTap = this.props.onActionTap; | ||
if (onActionTap) { | ||
var index = e.currentTarget.dataset.index; | ||
return onActionTap(index); | ||
} else { | ||
_console.log.error('NoticeBar', '缺少 onActionTap 回调。'); | ||
} | ||
didUpdate: function () { | ||
var enableMarquee = this.props.enableMarquee; | ||
this.showError(); | ||
// 这里更新处理的原因是防止notice内容在动画过程中发生改变。 | ||
if (enableMarquee) { | ||
if (!this._marqueeTimer && !_canIUseTransitionEnd) { | ||
this._measureText(); | ||
this._startAnimation(); | ||
} | ||
else { | ||
this._measureText(this.startMarquee.bind(this)); | ||
} | ||
} | ||
}, | ||
// 文本滚动的计算 | ||
resetMarquee: function resetMarquee() { | ||
var loop = this.props.loop; | ||
var _viewWidth = this.data._viewWidth; | ||
var showMarqueeWidth = '0px'; | ||
if (loop) { | ||
showMarqueeWidth = "".concat(_viewWidth, "px"); | ||
} | ||
var _marqueeStyle = "transform: translate3d(".concat(showMarqueeWidth, ", 0, 0); transition: 0s all linear;"); | ||
this.setData({ | ||
_marqueeStyle: _marqueeStyle | ||
}); | ||
didUnmount: function () { | ||
if (this._marqueeTimer) { | ||
clearTimeout(this._marqueeTimer); | ||
this._marqueeTimer = null; | ||
} | ||
}, | ||
startMarquee: function startMarquee() { | ||
var loop = this.props.loop; | ||
var leading = 500; | ||
var _this$data = this.data, | ||
_duration = _this$data._duration, | ||
_overflowWidth = _this$data._overflowWidth, | ||
_viewWidth = _this$data._viewWidth; | ||
var marqueeScrollWidth = _overflowWidth; | ||
if (loop) { | ||
marqueeScrollWidth = _overflowWidth + _viewWidth; | ||
} | ||
var _marqueeStyle = "transform: translate3d(".concat(-marqueeScrollWidth, "px, 0, 0); transition: ").concat(_duration, "s all linear ").concat(typeof leading === 'number' ? "".concat(leading / 1000, "s") : '0s', ";"); | ||
if (this.data._marqueeStyle !== _marqueeStyle) { | ||
this.setData({ | ||
_marqueeStyle: _marqueeStyle | ||
}); | ||
} | ||
}, | ||
onTransitionEnd: function onTransitionEnd() { | ||
var _this = this; | ||
var loop = this.props.loop; | ||
var trailing = 800; | ||
if (loop) { | ||
setTimeout(function () { | ||
_this.resetMarquee(); | ||
_this._measureText(_this.startMarquee.bind(_this)); | ||
}, typeof trailing === 'number' ? trailing : 0); | ||
} | ||
}, | ||
_measureText: function _measureText() { | ||
var _this2 = this; | ||
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop; | ||
var fps = 40; | ||
var loop = this.props.loop; // 计算文本所占据的宽度,计算需要滚动的宽度 | ||
setTimeout(function () { | ||
my.createSelectorQuery().select(".amd-notice-bar-marquee-".concat(_this2.$id)).boundingClientRect().select(".amd-notice-bar-content-".concat(_this2.$id)).boundingClientRect().exec(function (ret) { | ||
var _ret$; | ||
// eslint-disable-next-line max-len | ||
var _overflowWidth = ret && ret[0] && ret[1] && ret[0].width - ret[1].width || 0; | ||
var _viewWidth = ((_ret$ = ret[1]) === null || _ret$ === void 0 ? void 0 : _ret$.width) || 0; | ||
var marqueeScrollWidth = _overflowWidth; | ||
if (loop) { | ||
marqueeScrollWidth = _overflowWidth + _viewWidth; | ||
} | ||
if (_overflowWidth > 0) { | ||
_this2.setData({ | ||
_overflowWidth: _overflowWidth, | ||
_viewWidth: _viewWidth, | ||
_duration: marqueeScrollWidth / fps | ||
methods: { | ||
showError: function () { | ||
var actions = this.props.actions; | ||
if (!Array.isArray(actions) && typeof actions !== 'undefined') { | ||
console_1.log.warn('NoticeBar', "\u5F53\u524D\u5B9A\u4E49\u7684 actions \u7684\u7C7B\u578B\u4E3A ".concat(typeof actions, "\uFF0C\u4E0D\u7B26\u5408\u5C5E\u6027\u5B9A\u4E49\uFF0C\u5E94\u8BE5\u4E3A\u6570\u7EC4\uFF0C\u5982\uFF1Aactions=\"{{['\u503C', '\u503C']}}")); | ||
} | ||
}, | ||
onTap: function () { | ||
var _a = this.props, mode = _a.mode, onTap = _a.onTap; | ||
if (mode === 'link' && typeof onTap === 'function') { | ||
return onTap(); | ||
} | ||
if (mode === 'closeable' && typeof onTap === 'function') { | ||
this.setData({ | ||
_show: false, | ||
}); | ||
return onTap(); | ||
} | ||
}, | ||
onActionTap: function (e) { | ||
var onActionTap = this.props.onActionTap; | ||
if (onActionTap) { | ||
var index = e.currentTarget.dataset.index; | ||
return onActionTap(index); | ||
} | ||
else { | ||
console_1.log.error('NoticeBar', '缺少 onActionTap 回调。'); | ||
} | ||
}, | ||
// 文本滚动的计算 | ||
resetMarquee: function () { | ||
var loop = this.props.loop; | ||
var _viewWidth = this.data._viewWidth; | ||
var showMarqueeWidth = '0px'; | ||
if (loop) { | ||
showMarqueeWidth = "".concat(_viewWidth, "px"); | ||
} | ||
var _marqueeStyle = "transform: translate3d(".concat(showMarqueeWidth, ", 0, 0); transition: 0s all linear;"); | ||
this.setData({ | ||
_marqueeStyle: _marqueeStyle, | ||
}); | ||
callback(); | ||
} | ||
}); | ||
}, 0); | ||
}, | ||
startMarquee: function () { | ||
var loop = this.props.loop; | ||
var leading = 500; | ||
var _a = this.data, _duration = _a._duration, _overflowWidth = _a._overflowWidth, _viewWidth = _a._viewWidth; | ||
var marqueeScrollWidth = _overflowWidth; | ||
if (loop) { | ||
marqueeScrollWidth = _overflowWidth + _viewWidth; | ||
} | ||
var _marqueeStyle = "transform: translate3d(".concat(-marqueeScrollWidth, "px, 0, 0); transition: ").concat(_duration, "s all linear ").concat(typeof leading === 'number' ? "".concat(leading / 1000, "s") : '0s', ";"); | ||
if (this.data._marqueeStyle !== _marqueeStyle) { | ||
this.setData({ | ||
_marqueeStyle: _marqueeStyle, | ||
}); | ||
} | ||
}, | ||
onTransitionEnd: function () { | ||
var _this = this; | ||
var loop = this.props.loop; | ||
var trailing = 800; | ||
if (loop) { | ||
setTimeout(function () { | ||
_this.resetMarquee(); | ||
_this._measureText(_this.startMarquee.bind(_this)); | ||
}, typeof trailing === 'number' ? trailing : 0); | ||
} | ||
}, | ||
_measureText: function (callback) { | ||
var _this = this; | ||
if (callback === void 0) { callback = noop; } | ||
var fps = 40; | ||
var loop = this.props.loop; | ||
// 计算文本所占据的宽度,计算需要滚动的宽度 | ||
setTimeout(function () { | ||
my.createSelectorQuery() | ||
.select(".amd-notice-bar-marquee-".concat(_this.$id)) | ||
.boundingClientRect() | ||
.select(".amd-notice-bar-content-".concat(_this.$id)) | ||
.boundingClientRect() | ||
.exec(function (ret) { | ||
var _a; | ||
// eslint-disable-next-line max-len | ||
var _overflowWidth = (ret && ret[0] && ret[1] && (ret[0].width - ret[1].width)) || 0; | ||
var _viewWidth = ((_a = ret[1]) === null || _a === void 0 ? void 0 : _a.width) || 0; | ||
var marqueeScrollWidth = _overflowWidth; | ||
if (loop) { | ||
marqueeScrollWidth = _overflowWidth + _viewWidth; | ||
} | ||
if (_overflowWidth > 0) { | ||
_this.setData({ | ||
_overflowWidth: _overflowWidth, | ||
_viewWidth: _viewWidth, | ||
_duration: (marqueeScrollWidth / fps), | ||
}); | ||
callback(); | ||
} | ||
}); | ||
}, 0); | ||
}, | ||
_startAnimation: function () { | ||
var _this = this; | ||
if (this._marqueeTimer) { | ||
clearTimeout(this._marqueeTimer); | ||
} | ||
var loop = false; | ||
var leading = 500; | ||
var trailing = 800; | ||
var fps = 40; | ||
var TIMEOUT = 1 / fps * 1000; | ||
var isLeading = this.data._animatedWidth === 0; | ||
var timeout = isLeading ? leading : TIMEOUT; | ||
var animate = function () { | ||
var _overflowWidth = _this.data._overflowWidth; | ||
var _animatedWidth = _this.data._animatedWidth + 1; | ||
var isRoundOver = _animatedWidth > _overflowWidth; | ||
if (isRoundOver) { | ||
if (loop) { | ||
_animatedWidth = 0; | ||
} | ||
else { | ||
return; | ||
} | ||
} | ||
if (isRoundOver && trailing) { | ||
_this._marqueeTimer = setTimeout(function () { | ||
_this.setData({ | ||
_animatedWidth: _animatedWidth, | ||
}); | ||
_this._marqueeTimer = setTimeout(animate, TIMEOUT); | ||
}, trailing); | ||
} | ||
else { | ||
_this.setData({ | ||
_animatedWidth: _animatedWidth, | ||
}); | ||
_this._marqueeTimer = setTimeout(animate, TIMEOUT); | ||
} | ||
}; | ||
if (this.data._overflowWidth !== 0) { | ||
this._marqueeTimer = setTimeout(animate, timeout); | ||
} | ||
}, | ||
}, | ||
_startAnimation: function _startAnimation() { | ||
var _this3 = this; | ||
if (this._marqueeTimer) { | ||
clearTimeout(this._marqueeTimer); | ||
} | ||
var loop = false; | ||
var leading = 500; | ||
var trailing = 800; | ||
var fps = 40; | ||
var TIMEOUT = 1 / fps * 1000; | ||
var isLeading = this.data._animatedWidth === 0; | ||
var timeout = isLeading ? leading : TIMEOUT; | ||
var animate = function animate() { | ||
var _overflowWidth = _this3.data._overflowWidth; | ||
var _animatedWidth = _this3.data._animatedWidth + 1; | ||
var isRoundOver = _animatedWidth > _overflowWidth; | ||
if (isRoundOver) { | ||
if (loop) { | ||
_animatedWidth = 0; | ||
} else { | ||
return; | ||
} | ||
} | ||
if (isRoundOver && trailing) { | ||
_this3._marqueeTimer = setTimeout(function () { | ||
_this3.setData({ | ||
_animatedWidth: _animatedWidth | ||
}); | ||
_this3._marqueeTimer = setTimeout(animate, TIMEOUT); | ||
}, trailing); | ||
} else { | ||
_this3.setData({ | ||
_animatedWidth: _animatedWidth | ||
}); | ||
_this3._marqueeTimer = setTimeout(animate, TIMEOUT); | ||
} | ||
}; | ||
if (this.data._overflowWidth !== 0) { | ||
this._marqueeTimer = setTimeout(animate, timeout); | ||
} | ||
} | ||
} | ||
}); |
@@ -1,13 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.NoticeBarDefaultProps = void 0; | ||
var NoticeBarDefaultProps = { | ||
export const NoticeBarDefaultProps = { | ||
showIcon: false, | ||
enableMarquee: false, | ||
loop: false, | ||
type: 'default' | ||
type: 'default', | ||
}; | ||
exports.NoticeBarDefaultProps = NoticeBarDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _computed = _interopRequireDefault(require("../mixins/computed")); | ||
var _controlled = _interopRequireDefault(require("../mixins/controlled")); | ||
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal")); | ||
var _form = _interopRequireDefault(require("../mixins/form")); | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _store = require("../Form/store"); | ||
var noop = function noop(v) { | ||
return v.join(','); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var computed_1 = require("../mixins/computed"); | ||
var controlled_1 = require("../mixins/controlled"); | ||
var fast_deep_equal_1 = require("fast-deep-equal"); | ||
var form_1 = require("../mixins/form"); | ||
var extends_1 = require("@babel/runtime/helpers/extends"); | ||
var store_1 = require("../Form/store"); | ||
var noop = function (v) { | ||
return v.join(','); | ||
}; | ||
Component({ | ||
mixins: [_computed["default"], (0, _controlled["default"])(), (0, _form["default"])()], | ||
props: (0, _extends2["default"])({}, { | ||
onFormat: noop | ||
}, _props.PickerDefaultProps), | ||
data: { | ||
visible: false, | ||
cValue: [], | ||
showValue: [], | ||
valueIndex: [], | ||
changeValue: [] | ||
}, | ||
onInit: function onInit() { | ||
var _this = this; | ||
var updatePickerFiledValue = function updatePickerFiledValue(v) { | ||
var changeValue = v.map(function (item, index) { | ||
return _this.props.data[index].findIndex(function (target) { | ||
return item === target; | ||
}); | ||
}); | ||
_this.formatValue = v; | ||
var showValue = _this.props.onFormat ? _this.props.onFormat(v) : noop(v); | ||
_this.setData({ | ||
showValue: showValue, | ||
valueIndex: changeValue | ||
}); | ||
}; | ||
if (!this.$page.data._getCurrentField) return; | ||
var _this$$page$data$_get = this.$page.data._getCurrentField(), | ||
formFn = _this$$page$data$_get.form, | ||
fieldFn = _this$$page$data$_get.field; | ||
var form = formFn(); | ||
var field = fieldFn(); | ||
_store.store.addUpdateFiledValue(form, field, updatePickerFiledValue); | ||
}, | ||
didMount: function didMount() { | ||
var data = this.props.data; | ||
this.dataList = data; | ||
this.transferValue(); | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
if (!(0, _fastDeepEqual["default"])(prevProps.value, this.props.value)) { | ||
var pValueIndex = []; | ||
for (var i = 0; i < this.props.value.length; i++) { | ||
pValueIndex.push(this.dataList[i].indexOf(this.props.value[i])); | ||
} | ||
this.formatValueFn(pValueIndex); | ||
this.setData({ | ||
valueIndex: pValueIndex | ||
}); | ||
} | ||
this.correctChangeValue(prevProps.data, this.props.data); | ||
}, | ||
methods: { | ||
correctChangeValue: function correctChangeValue(prevData, curData) { | ||
var shouldCorrectChangeIndex = prevData.some(function (col, index) { | ||
return col.length !== curData[index].length; | ||
}); | ||
if (shouldCorrectChangeIndex) { | ||
var newChangedValue = this.data.changeValue.map(function (colIndex, index) { | ||
// 长度 大 -> 小 取小 | ||
if (prevData[index].length > curData[index].length) { | ||
return curData[index].length - 1; | ||
} | ||
return colIndex; | ||
}); | ||
this.setData({ | ||
changeValue: newChangedValue | ||
}); | ||
} | ||
mixins: [computed_1.default, (0, controlled_1.default)(), (0, form_1.default)()], | ||
props: (0, extends_1.default)({}, { onFormat: noop }, props_1.PickerDefaultProps), | ||
data: { | ||
visible: false, | ||
cValue: [], | ||
showValue: [], | ||
valueIndex: [], | ||
changeValue: [], | ||
}, | ||
transferValue: function transferValue() { | ||
var cValue = this.data.cValue; | ||
var newValue = []; | ||
if (this.dataList && cValue) { | ||
for (var i = 0; i < cValue.length; i++) { | ||
newValue.push(this.dataList[i].indexOf(cValue[i])); | ||
} | ||
} | ||
this.formatValueFn(newValue); | ||
onInit: function () { | ||
var _this = this; | ||
var updatePickerFiledValue = function (v) { | ||
var changeValue = v.map(function (item, index) { | ||
return _this.props.data[index].findIndex(function (target) { return item === target; }); | ||
}); | ||
_this.formatValue = v; | ||
var showValue = _this.props.onFormat ? _this.props.onFormat(v) : noop(v); | ||
_this.setData({ | ||
showValue: showValue, | ||
valueIndex: changeValue, | ||
}); | ||
}; | ||
if (!this.$page.data._getCurrentField) | ||
return; | ||
var _a = this.$page.data._getCurrentField(), formFn = _a.form, fieldFn = _a.field; | ||
var form = formFn(); | ||
var field = fieldFn(); | ||
store_1.store.addUpdateFiledValue(form, field, updatePickerFiledValue); | ||
}, | ||
computed: function computed(props) { | ||
var _this$props; | ||
var value = props.value; | ||
return { | ||
cValue: value, | ||
showValue: (_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.onFormat(this.formatValue ? this.formatValue : []) | ||
}; | ||
didMount: function () { | ||
var data = this.props.data; | ||
this.dataList = data; | ||
this.transferValue(); | ||
}, | ||
triggerPicker: function triggerPicker() { | ||
var _this$props2 = this.props, | ||
disabled = _this$props2.disabled, | ||
onTriggerPicker = _this$props2.onTriggerPicker; | ||
var _this$data = this.data, | ||
valueIndex = _this$data.valueIndex, | ||
cValue = _this$data.cValue; | ||
if (this.dataList && valueIndex.length <= 0) { | ||
var vIndex = []; | ||
for (var i = 0; i < cValue.length; i++) { | ||
vIndex.push(this.dataList[i].indexOf(cValue[i])); | ||
didUpdate: function (prevProps) { | ||
if (!(0, fast_deep_equal_1.default)(prevProps.value, this.props.value)) { | ||
var pValueIndex = []; | ||
for (var i = 0; i < this.props.value.length; i++) { | ||
pValueIndex.push(this.dataList[i].indexOf(this.props.value[i])); | ||
} | ||
this.formatValueFn(pValueIndex); | ||
this.setData({ | ||
valueIndex: pValueIndex, | ||
}); | ||
} | ||
this.setData({ | ||
valueIndex: vIndex | ||
}); | ||
} | ||
if (!disabled) { | ||
this.setData({ | ||
visible: true | ||
}); | ||
} | ||
if (onTriggerPicker) { | ||
onTriggerPicker.call(this.props); | ||
} | ||
this.correctChangeValue(prevProps.data, this.props.data); | ||
}, | ||
onDismiss: function onDismiss() { | ||
var onDismiss = this.props.onDismiss; | ||
if (onDismiss) { | ||
this.setData({ | ||
changeValue: this.data.valueIndex, | ||
visible: false | ||
}); | ||
return onDismiss(); | ||
} | ||
methods: { | ||
correctChangeValue: function (prevData, curData) { | ||
var shouldCorrectChangeIndex = prevData.some(function (col, index) { return col.length !== curData[index].length; }); | ||
if (shouldCorrectChangeIndex) { | ||
var newChangedValue = this.data.changeValue.map(function (colIndex, index) { | ||
// 长度 大 -> 小 取小 | ||
if (prevData[index].length > curData[index].length) { | ||
return curData[index].length - 1; | ||
} | ||
return colIndex; | ||
}); | ||
this.setData({ | ||
changeValue: newChangedValue, | ||
}); | ||
} | ||
}, | ||
transferValue: function () { | ||
var cValue = this.data.cValue; | ||
var newValue = []; | ||
if (this.dataList && cValue) { | ||
for (var i = 0; i < cValue.length; i++) { | ||
newValue.push(this.dataList[i].indexOf(cValue[i])); | ||
} | ||
} | ||
this.formatValueFn(newValue); | ||
}, | ||
computed: function (props) { | ||
var _a; | ||
var value = props.value; | ||
return { | ||
cValue: value, | ||
showValue: (_a = this.props) === null || _a === void 0 ? void 0 : _a.onFormat(this.formatValue ? this.formatValue : []), | ||
}; | ||
}, | ||
triggerPicker: function () { | ||
var _a = this.props, disabled = _a.disabled, onTriggerPicker = _a.onTriggerPicker; | ||
var _b = this.data, valueIndex = _b.valueIndex, cValue = _b.cValue; | ||
if (this.dataList && valueIndex.length <= 0) { | ||
var vIndex = []; | ||
for (var i = 0; i < cValue.length; i++) { | ||
vIndex.push(this.dataList[i].indexOf(cValue[i])); | ||
} | ||
this.setData({ | ||
valueIndex: vIndex, | ||
}); | ||
} | ||
if (!disabled) { | ||
this.setData({ | ||
visible: true, | ||
}); | ||
} | ||
if (onTriggerPicker) { | ||
onTriggerPicker.call(this.props); | ||
} | ||
}, | ||
onDismiss: function () { | ||
var onDismiss = this.props.onDismiss; | ||
if (onDismiss) { | ||
this.setData({ | ||
changeValue: this.data.valueIndex, | ||
visible: false, | ||
}); | ||
return onDismiss(); | ||
} | ||
}, | ||
onChange: function (v) { | ||
var onChange = this.props.onChange; | ||
if (onChange) { | ||
var value = v.detail.value; | ||
var valueTemp = []; | ||
if (this.dataList) { | ||
for (var i = 0; i < value.length; i++) { | ||
valueTemp.push(this.dataList[i][value[i]]); | ||
} | ||
} | ||
this.setData({ | ||
changeValue: value, | ||
cValue: valueTemp, | ||
}); | ||
onChange.call(this.props, valueTemp); | ||
} | ||
}, | ||
onOk: function () { | ||
var _a = this.props, onOk = _a.onOk, isDatePicker = _a.isDatePicker, onChange = _a.onChange; | ||
var changeValue = this.data.changeValue; | ||
var pickerValueChanged = false; | ||
if (changeValue === null || changeValue === void 0 ? void 0 : changeValue.length) { | ||
for (var i = 0; i < changeValue.length; i++) { | ||
if (changeValue[i] !== this.data.valueIndex[i]) { | ||
pickerValueChanged = true; | ||
} | ||
} | ||
} | ||
if (pickerValueChanged || isDatePicker) { | ||
this.formatValueFn(changeValue); | ||
this.setData({ | ||
cValue: this.formatValue, | ||
showValue: this.props.onFormat(this.formatValue), | ||
valueIndex: changeValue, | ||
visible: false, | ||
}); | ||
onOk === null || onOk === void 0 ? void 0 : onOk(changeValue); | ||
var _getCurrentField = this.props._getCurrentField; | ||
if (_getCurrentField) { | ||
onChange.call(this.props, this.formatValue); | ||
} | ||
else { | ||
onChange === null || onChange === void 0 ? void 0 : onChange(changeValue); | ||
} | ||
pickerValueChanged = false; | ||
} | ||
else { | ||
this.setData({ | ||
visible: false, | ||
}); | ||
} | ||
}, | ||
formatValueFn: function (nv) { | ||
this.formatValue = []; | ||
for (var i = 0; i < nv.length; i++) { | ||
this.formatValue.push(this.dataList[i][nv[i]]); | ||
} | ||
}, | ||
}, | ||
onChange: function onChange(v) { | ||
var onChange = this.props.onChange; | ||
if (onChange) { | ||
var value = v.detail.value; | ||
var valueTemp = []; | ||
if (this.dataList) { | ||
for (var i = 0; i < value.length; i++) { | ||
valueTemp.push(this.dataList[i][value[i]]); | ||
} | ||
} | ||
this.setData({ | ||
changeValue: value, | ||
cValue: valueTemp | ||
}); | ||
onChange.call(this.props, valueTemp); | ||
} | ||
}, | ||
onOk: function onOk() { | ||
var _this$props3 = this.props, | ||
onOk = _this$props3.onOk, | ||
isDatePicker = _this$props3.isDatePicker, | ||
onChange = _this$props3.onChange; | ||
var changeValue = this.data.changeValue; | ||
var pickerValueChanged = false; | ||
if (changeValue !== null && changeValue !== void 0 && changeValue.length) { | ||
for (var i = 0; i < changeValue.length; i++) { | ||
if (changeValue[i] !== this.data.valueIndex[i]) { | ||
pickerValueChanged = true; | ||
} | ||
} | ||
} | ||
if (pickerValueChanged || isDatePicker) { | ||
this.formatValueFn(changeValue); | ||
this.setData({ | ||
cValue: this.formatValue, | ||
showValue: this.props.onFormat(this.formatValue), | ||
valueIndex: changeValue, | ||
visible: false | ||
}); | ||
onOk === null || onOk === void 0 ? void 0 : onOk(changeValue); | ||
var _getCurrentField = this.props._getCurrentField; | ||
if (_getCurrentField) { | ||
onChange.call(this.props, this.formatValue); | ||
} else { | ||
onChange === null || onChange === void 0 ? void 0 : onChange(changeValue); | ||
} | ||
pickerValueChanged = false; | ||
} else { | ||
this.setData({ | ||
visible: false | ||
}); | ||
} | ||
}, | ||
formatValueFn: function formatValueFn(nv) { | ||
this.formatValue = []; | ||
for (var i = 0; i < nv.length; i++) { | ||
this.formatValue.push(this.dataList[i][nv[i]]); | ||
} | ||
} | ||
} | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.PickerDefaultProps = void 0; | ||
var PickerDefaultProps = { | ||
export const PickerDefaultProps = { | ||
controlled: false, | ||
@@ -12,4 +6,3 @@ cols: 1, | ||
dismissText: '取消', | ||
disabled: false | ||
disabled: false, | ||
}; | ||
exports.PickerDefaultProps = PickerDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.PopoverDefaultProps, | ||
methods: { | ||
onVisibleChange: function onVisibleChange() { | ||
var _this$props = this.props, | ||
onVisibleChange = _this$props.onVisibleChange, | ||
visible = _this$props.visible; | ||
if (onVisibleChange) { | ||
return onVisibleChange(!visible, 'component'); | ||
} | ||
props: props_1.PopoverDefaultProps, | ||
methods: { | ||
onVisibleChange: function () { | ||
var _a = this.props, onVisibleChange = _a.onVisibleChange, visible = _a.visible; | ||
if (onVisibleChange) { | ||
return onVisibleChange(!visible, 'component'); | ||
} | ||
}, | ||
onMaskTap: function () { | ||
var _a = this.props, maskClosable = _a.maskClosable, onVisibleChange = _a.onVisibleChange; | ||
if (maskClosable && onVisibleChange) { | ||
onVisibleChange(false, 'mask'); | ||
} | ||
else { | ||
return false; | ||
} | ||
}, | ||
}, | ||
onMaskTap: function onMaskTap() { | ||
var _this$props2 = this.props, | ||
maskClosable = _this$props2.maskClosable, | ||
onVisibleChange = _this$props2.onVisibleChange; | ||
if (maskClosable && onVisibleChange) { | ||
onVisibleChange(false, 'mask'); | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
}); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fmtEvent = _interopRequireDefault(require("../../_util/fmtEvent")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var fmtEvent_1 = require("../../_util/fmtEvent"); | ||
Component({ | ||
props: _props.PopoverItemDefaultProps, | ||
methods: { | ||
onTap: function onTap(e) { | ||
var onTap = this.props.onTap; | ||
if (onTap) { | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onTap(event); | ||
} | ||
} | ||
} | ||
props: props_1.PopoverItemDefaultProps, | ||
methods: { | ||
onTap: function (e) { | ||
var onTap = this.props.onTap; | ||
if (onTap) { | ||
var event = (0, fmtEvent_1.default)(this.props, e); | ||
return onTap(event); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.PopoverItemDefaultProps = void 0; | ||
var PopoverItemDefaultProps = {}; | ||
exports.PopoverItemDefaultProps = PopoverItemDefaultProps; | ||
export const PopoverItemDefaultProps = {}; |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.PopoverDefaultProps = void 0; | ||
var PopoverDefaultProps = { | ||
export const PopoverDefaultProps = { | ||
visible: false, | ||
@@ -13,4 +7,3 @@ mask: false, | ||
mode: 'dark', | ||
fixMaskFull: false | ||
fixMaskFull: false, | ||
}; | ||
exports.PopoverDefaultProps = PopoverDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.PopupDefaultProps, | ||
data: { | ||
classNames: '', | ||
supportSjs: my.canIUse('sjs.event') | ||
}, | ||
deriveDataFromProps: function deriveDataFromProps(nextProps) { | ||
var classNames = [nextProps.className || '', nextProps.disableScroll ? 'amd-popup-disable-scroll' : '', nextProps.animation ? 'amd-popup-animation' : '']; | ||
this.setData({ | ||
classNames: classNames.join(' ').trim() | ||
}); | ||
}, | ||
methods: { | ||
onMaskClose: function onMaskClose() { | ||
var _this$props = this.props, | ||
onClose = _this$props.onClose, | ||
maskClosable = _this$props.maskClosable; | ||
if (maskClosable) { | ||
onClose === null || onClose === void 0 ? void 0 : onClose(); | ||
} | ||
props: props_1.PopupDefaultProps, | ||
data: { | ||
classNames: '', | ||
supportSjs: my.canIUse('sjs.event'), | ||
}, | ||
onClose: function onClose() { | ||
var onClose = this.props.onClose; | ||
if (onClose) { | ||
onClose === null || onClose === void 0 ? void 0 : onClose(); | ||
} | ||
} | ||
} | ||
deriveDataFromProps: function (nextProps) { | ||
var classNames = [ | ||
nextProps.className || '', | ||
nextProps.disableScroll ? 'amd-popup-disable-scroll' : '', | ||
nextProps.animation ? 'amd-popup-animation' : '', | ||
]; | ||
this.setData({ | ||
classNames: classNames.join(' ').trim(), | ||
}); | ||
}, | ||
methods: { | ||
onMaskClose: function () { | ||
var _a = this.props, onClose = _a.onClose, maskClosable = _a.maskClosable; | ||
if (maskClosable) { | ||
onClose === null || onClose === void 0 ? void 0 : onClose(); | ||
} | ||
}, | ||
onClose: function () { | ||
var onClose = this.props.onClose; | ||
if (onClose) { | ||
onClose === null || onClose === void 0 ? void 0 : onClose(); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.PopupDefaultProps = void 0; | ||
var PopupDefaultProps = { | ||
export const PopupDefaultProps = { | ||
visible: false, | ||
@@ -19,4 +13,3 @@ maskClosable: false, | ||
disableScroll: true, | ||
showCloseIcon: false | ||
showCloseIcon: false, | ||
}; | ||
exports.PopupDefaultProps = PopupDefaultProps; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.componentValue = exports.componentDisabled = exports.componentContext = void 0; | ||
var _context = require("../_util/context"); | ||
var componentContext = new _context.Context(); | ||
exports.componentContext = componentContext; | ||
var componentDisabled = new _context.Context(); // 该值区别于 componentContext 的地方在于, | ||
var context_1 = require("../_util/context"); | ||
exports.componentContext = new context_1.Context(); | ||
exports.componentDisabled = new context_1.Context(); | ||
// 该值区别于 componentContext 的地方在于, | ||
// componentContext 的值用于通知 controlled 更新, | ||
// 而 componentValue 用于 item.checked 更新 | ||
exports.componentDisabled = componentDisabled; | ||
var componentValue = new _context.Context(); | ||
exports.componentValue = componentValue; | ||
exports.componentValue = new context_1.Context(); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _context = require("./context"); | ||
var _controlled = _interopRequireDefault(require("../mixins/controlled")); | ||
var _form = _interopRequireDefault(require("../mixins/form")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("./context"); | ||
var controlled_1 = require("../mixins/controlled"); | ||
var form_1 = require("../mixins/form"); | ||
Component({ | ||
props: _props.RadioGroupDefaultProps, | ||
mixins: [(0, _controlled["default"])(), (0, _form["default"])()], | ||
didMount: function didMount() { | ||
var _this = this; | ||
var _this$props = this.props, | ||
uid = _this$props.uid, | ||
value = _this$props.value, | ||
disabled = _this$props.disabled; // 用于触发 item.checked 更新 | ||
_context.componentValue.update(uid, value); // 用于触发 item.disabled 更新 | ||
_context.componentDisabled.update(uid, disabled); | ||
_context.componentContext.onUpdate(uid, function (v) { | ||
_this.cOnChange(v); | ||
}); | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
var _this$props2 = this.props, | ||
disabled = _this$props2.disabled, | ||
uid = _this$props2.uid; | ||
if (disabled !== prevProps.disabled) { | ||
_context.componentDisabled.update(uid, disabled); | ||
} | ||
_context.componentValue.update(uid, this.data.cValue); | ||
}, | ||
didUnmount: function didUnmount() { | ||
var uid = this.props.uid; | ||
_context.componentContext.clearEvent(uid); | ||
_context.componentDisabled.clearEvent(uid); | ||
_context.componentValue.clearEvent(uid); | ||
} | ||
props: props_1.RadioGroupDefaultProps, | ||
mixins: [(0, controlled_1.default)(), (0, form_1.default)()], | ||
didMount: function () { | ||
var _this = this; | ||
var _a = this.props, uid = _a.uid, value = _a.value, disabled = _a.disabled; | ||
// 用于触发 item.checked 更新 | ||
context_1.componentValue.update(uid, value); | ||
// 用于触发 item.disabled 更新 | ||
context_1.componentDisabled.update(uid, disabled); | ||
context_1.componentContext.onUpdate(uid, function (v) { | ||
_this.cOnChange(v); | ||
}); | ||
}, | ||
didUpdate: function (prevProps) { | ||
var _a = this.props, disabled = _a.disabled, uid = _a.uid; | ||
if (disabled !== prevProps.disabled) { | ||
context_1.componentDisabled.update(uid, disabled); | ||
} | ||
context_1.componentValue.update(uid, this.data.cValue); | ||
}, | ||
didUnmount: function () { | ||
var uid = this.props.uid; | ||
context_1.componentContext.clearEvent(uid); | ||
context_1.componentDisabled.clearEvent(uid); | ||
context_1.componentValue.clearEvent(uid); | ||
}, | ||
}); |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.RadioGroupDefaultProps = void 0; | ||
var RadioGroupDefaultProps = { | ||
export const RadioGroupDefaultProps = { | ||
disabled: false, | ||
radius: false, | ||
uid: 'RadioGroup' | ||
uid: 'RadioGroup', | ||
}; | ||
exports.RadioGroupDefaultProps = RadioGroupDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("../context"); | ||
Component({ | ||
props: _props.RadioItemDefaultProps, | ||
data: { | ||
_checked: false, | ||
_disabled: false | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
_context.componentDisabled.onUpdate(this.props.uid, this.disabledListener = function (d) { | ||
_this.setData({ | ||
_disabled: _this.props.disabled || d | ||
}); | ||
}); | ||
_context.componentValue.onUpdate(this.props.uid, this.checkedListener = function (v) { | ||
if (v) { | ||
if (v.indexOf(_this.props.value) !== -1) { | ||
_this.setData({ | ||
_checked: true | ||
}); | ||
} else { | ||
_this.setData({ | ||
_checked: false | ||
}); | ||
} | ||
} | ||
}); | ||
}, | ||
didUnmount: function didUnmount() { | ||
_context.componentValue.offUpdate(this.props.uid, this.checkedListener); | ||
_context.componentDisabled.offUpdate(this.props.uid, this.disabledListener); | ||
}, | ||
methods: { | ||
onItemChange: function onItemChange(v) { | ||
var value = v.detail.value; | ||
if (value) { | ||
_context.componentContext.update(this.props.uid, this.props.value); | ||
} | ||
} | ||
} | ||
props: props_1.RadioItemDefaultProps, | ||
data: { | ||
_checked: false, | ||
_disabled: false, | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
context_1.componentDisabled.onUpdate(this.props.uid, (this.disabledListener = function (d) { | ||
_this.setData({ | ||
_disabled: _this.props.disabled || d, | ||
}); | ||
})); | ||
context_1.componentValue.onUpdate(this.props.uid, (this.checkedListener = function (v) { | ||
if (v) { | ||
if (v.indexOf(_this.props.value) !== -1) { | ||
_this.setData({ | ||
_checked: true, | ||
}); | ||
} | ||
else { | ||
_this.setData({ | ||
_checked: false, | ||
}); | ||
} | ||
} | ||
})); | ||
}, | ||
didUnmount: function () { | ||
context_1.componentValue.offUpdate(this.props.uid, this.checkedListener); | ||
context_1.componentDisabled.offUpdate(this.props.uid, this.disabledListener); | ||
}, | ||
methods: { | ||
onItemChange: function (v) { | ||
var value = v.detail.value; | ||
if (value) { | ||
context_1.componentContext.update(this.props.uid, this.props.value); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.RadioItemDefaultProps = void 0; | ||
var RadioItemDefaultProps = { | ||
export const RadioItemDefaultProps = { | ||
disabled: false, | ||
uid: 'RadioGroup' | ||
uid: 'RadioGroup', | ||
}; | ||
exports.RadioItemDefaultProps = RadioItemDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.ResultDefaultProps, | ||
methods: { | ||
onButtonTap: function onButtonTap(e) { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (onButtonTap) { | ||
var index = e.currentTarget.dataset.index; | ||
return onButtonTap(index); | ||
} | ||
} | ||
} | ||
props: props_1.ResultDefaultProps, | ||
methods: { | ||
onButtonTap: function (e) { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (onButtonTap) { | ||
var index = e.currentTarget.dataset.index; | ||
return onButtonTap(index); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ResultDefaultProps = void 0; | ||
var ResultDefaultProps = {}; | ||
exports.ResultDefaultProps = ResultDefaultProps; | ||
export const ResultDefaultProps = {}; |
@@ -1,8 +0,3 @@ | ||
"use strict"; | ||
Component({ | ||
props: { | ||
className: '', | ||
position: 'both' | ||
} | ||
props: { className: '', position: 'both' }, | ||
}); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _controlled = _interopRequireDefault(require("../mixins/controlled")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var controlled_1 = require("../mixins/controlled"); | ||
Component({ | ||
mixins: [(0, _controlled["default"])()], | ||
props: _props.SearchBarDefaultProps, | ||
data: { | ||
focus: false | ||
}, | ||
methods: { | ||
onSubmit: function onSubmit(e) { | ||
var onSubmit = this.props.onSubmit; | ||
if (onSubmit) { | ||
var value = e.detail.value; | ||
onSubmit(value); | ||
} | ||
mixins: [(0, controlled_1.default)()], | ||
props: props_1.SearchBarDefaultProps, | ||
data: { | ||
focus: false, | ||
}, | ||
onInput: function onInput(e) { | ||
var onInput = this.props.onInput; | ||
if (onInput) { | ||
var value = e.detail.value; | ||
this.cOnInput(value); | ||
} | ||
methods: { | ||
onSubmit: function (e) { | ||
var onSubmit = this.props.onSubmit; | ||
if (onSubmit) { | ||
var value = e.detail.value; | ||
onSubmit(value); | ||
} | ||
}, | ||
onInput: function (e) { | ||
var onInput = this.props.onInput; | ||
if (onInput) { | ||
var value = e.detail.value; | ||
this.cOnInput(value); | ||
} | ||
}, | ||
onClear: function () { | ||
var onClear = this.props.onClear; | ||
if (onClear) { | ||
onClear(''); | ||
} | ||
this.clearcValue(); | ||
}, | ||
clearcValue: function () { | ||
var propsControlled = this.props.controlled; | ||
if (!propsControlled) { | ||
this.setData({ | ||
cValue: '', | ||
}); | ||
} | ||
}, | ||
onCancel: function () { | ||
var onCancel = this.props.onCancel; | ||
if (onCancel) { | ||
onCancel(''); | ||
} | ||
this.clearcValue(); | ||
}, | ||
onBizIconTap: function () { | ||
if (typeof this.props.onBizIconTap === 'function') { | ||
this.props.onBizIconTap(); | ||
} | ||
else if (typeof this.props.onVoiceTap === 'function') { | ||
this.props.onVoiceTap(); | ||
} | ||
}, | ||
onFocus: function (e) { | ||
this.setData({ | ||
focus: true, | ||
}); | ||
var onFocus = this.props.onFocus; | ||
if (onFocus) { | ||
var value = e.detail.value; | ||
onFocus(value); | ||
} | ||
}, | ||
onBlur: function (e) { | ||
this.setData({ | ||
focus: false, | ||
}); | ||
var onBlur = this.props.onBlur; | ||
if (onBlur) { | ||
var value = e.detail.value; | ||
onBlur(value); | ||
} | ||
}, | ||
}, | ||
onClear: function onClear() { | ||
var onClear = this.props.onClear; | ||
if (onClear) { | ||
onClear(''); | ||
} | ||
this.clearcValue(); | ||
}, | ||
clearcValue: function clearcValue() { | ||
var propsControlled = this.props.controlled; | ||
if (!propsControlled) { | ||
this.setData({ | ||
cValue: '' | ||
}); | ||
} | ||
}, | ||
onCancel: function onCancel() { | ||
var onCancel = this.props.onCancel; | ||
if (onCancel) { | ||
onCancel(''); | ||
} | ||
this.clearcValue(); | ||
}, | ||
onBizIconTap: function onBizIconTap() { | ||
if (typeof this.props.onBizIconTap === 'function') { | ||
this.props.onBizIconTap(); | ||
} else if (typeof this.props.onVoiceTap === 'function') { | ||
this.props.onVoiceTap(); | ||
} | ||
}, | ||
onFocus: function onFocus(e) { | ||
this.setData({ | ||
focus: true | ||
}); | ||
var onFocus = this.props.onFocus; | ||
if (onFocus) { | ||
var value = e.detail.value; | ||
onFocus(value); | ||
} | ||
}, | ||
onBlur: function onBlur(e) { | ||
this.setData({ | ||
focus: false | ||
}); | ||
var onBlur = this.props.onBlur; | ||
if (onBlur) { | ||
var value = e.detail.value; | ||
onBlur(value); | ||
} | ||
} | ||
} | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SearchBarDefaultProps = void 0; | ||
var SearchBarDefaultProps = { | ||
export const SearchBarDefaultProps = { | ||
controlled: false, | ||
@@ -15,4 +9,3 @@ showCancelButton: false, | ||
disabled: false, | ||
bizIconType: 'AudioOutline' | ||
bizIconType: 'AudioOutline', | ||
}; | ||
exports.SearchBarDefaultProps = SearchBarDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _props = require("./props"); | ||
var _controlled = _interopRequireDefault(require("../mixins/controlled")); | ||
var _form = _interopRequireDefault(require("../mixins/form")); | ||
var getFixedValue = function getFixedValue(value, multiple) { | ||
var fixedValue; | ||
if (multiple) { | ||
fixedValue = value; | ||
} else { | ||
fixedValue = value === null || value === void 0 ? void 0 : value.slice(0, 1); | ||
} | ||
return fixedValue; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var controlled_1 = require("../mixins/controlled"); | ||
var form_1 = require("../mixins/form"); | ||
var getFixedValue = function (value, multiple) { | ||
var fixedValue; | ||
if (multiple) { | ||
fixedValue = value; | ||
} | ||
else { | ||
fixedValue = value === null || value === void 0 ? void 0 : value.slice(0, 1); | ||
} | ||
return fixedValue; | ||
}; | ||
Component({ | ||
mixins: [(0, _controlled["default"])(), (0, _form["default"])()], | ||
props: _props.SelectorDefaultProps, | ||
data: {}, | ||
methods: { | ||
onChange: function onChange(e) { | ||
var _e$currentTarget$data = e.currentTarget.dataset, | ||
disabled = _e$currentTarget$data.disabled, | ||
value = _e$currentTarget$data.value, | ||
text = _e$currentTarget$data.text; | ||
var _this$props = this.props, | ||
multiple = _this$props.multiple, | ||
items = _this$props.items; | ||
if (!disabled && !this.props.disabled) { | ||
var nextValue; | ||
var fixedValue = getFixedValue(this.data.cValue, multiple); | ||
if (multiple) { | ||
// 之前已经选中,删除它 | ||
if ((fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue.indexOf(value)) !== -1) { | ||
nextValue = fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue.filter(function (item) { | ||
return item !== value; | ||
}); | ||
} else { | ||
// 之前未选中,增加 | ||
nextValue = [].concat((0, _toConsumableArray2["default"])(fixedValue), [value]); | ||
} // 将 value 重新按 options 排序 | ||
var sortValue = function sortValue(v) { | ||
return items.map(function (item) { | ||
return item.value; | ||
}).filter(function (item) { | ||
return v.indexOf(item) !== -1; | ||
}); | ||
}; | ||
nextValue = sortValue(nextValue); | ||
this.cOnChange(nextValue); | ||
} else { | ||
// 单选 | ||
// 取消选中 | ||
// eslint-disable-next-line no-lonely-if | ||
if ((fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue[0]) === value) { | ||
nextValue = ''; | ||
} else { | ||
// 选中 | ||
nextValue = value; | ||
} | ||
this.cOnChange(nextValue, text); | ||
} | ||
} | ||
} | ||
} | ||
mixins: [(0, controlled_1.default)(), (0, form_1.default)()], | ||
props: props_1.SelectorDefaultProps, | ||
data: {}, | ||
methods: { | ||
onChange: function (e) { | ||
var _a = e.currentTarget.dataset, disabled = _a.disabled, value = _a.value, text = _a.text; | ||
var _b = this.props, multiple = _b.multiple, items = _b.items; | ||
if (!disabled && !this.props.disabled) { | ||
var nextValue = void 0; | ||
var fixedValue = getFixedValue(this.data.cValue, multiple); | ||
if (multiple) { | ||
// 之前已经选中,删除它 | ||
if ((fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue.indexOf(value)) !== -1) { | ||
nextValue = fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue.filter(function (item) { | ||
return item !== value; | ||
}); | ||
} | ||
else { | ||
// 之前未选中,增加 | ||
nextValue = __spreadArray(__spreadArray([], fixedValue, true), [value], false); | ||
} | ||
// 将 value 重新按 options 排序 | ||
var sortValue = function (v) { | ||
return items.map(function (item) { return item.value; }).filter(function (item) { return v.indexOf(item) !== -1; }); | ||
}; | ||
nextValue = sortValue(nextValue); | ||
this.cOnChange(nextValue); | ||
} | ||
else { | ||
// 单选 | ||
// 取消选中 | ||
// eslint-disable-next-line no-lonely-if | ||
if ((fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue[0]) === value) { | ||
nextValue = ''; | ||
} | ||
else { | ||
// 选中 | ||
nextValue = value; | ||
} | ||
this.cOnChange(nextValue, text); | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SelectorDefaultProps = void 0; | ||
var SelectorDefaultProps = { | ||
export const SelectorDefaultProps = { | ||
controlled: false, | ||
multiple: false, | ||
disabled: false | ||
disabled: false, | ||
}; | ||
exports.SelectorDefaultProps = SelectorDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _computed = _interopRequireDefault(require("../mixins/computed")); | ||
var _controlled = _interopRequireDefault(require("../mixins/controlled")); | ||
var _utils = require("./utils"); | ||
var _form = _interopRequireDefault(require("../mixins/form")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var computed_1 = require("../mixins/computed"); | ||
var controlled_1 = require("../mixins/controlled"); | ||
var utils_1 = require("./utils"); | ||
var form_1 = require("../mixins/form"); | ||
Component({ | ||
mixins: [_computed["default"], (0, _controlled["default"])(), (0, _form["default"])()], | ||
props: _props.StepperDefaultProps, | ||
data: { | ||
confirm: false, | ||
_value: null | ||
}, | ||
didMount: function didMount() { | ||
var _this$data = this.data, | ||
min = _this$data.min, | ||
max = _this$data.max, | ||
cValue = _this$data.cValue; | ||
if (cValue < min) { | ||
this.setData({ | ||
cValue: min | ||
}); | ||
} | ||
if (cValue > max) { | ||
this.setData({ | ||
cValue: max | ||
}); | ||
} | ||
}, | ||
methods: { | ||
computed: function computed() { | ||
var _this$props = this.props, | ||
min = _this$props.min, | ||
max = _this$props.max; | ||
var cValue = this.data.cValue; | ||
if (max === undefined) { | ||
max = Number.MAX_SAFE_INTEGER; | ||
} | ||
if (min === undefined) { | ||
min = 0; | ||
} | ||
if (cValue === undefined) { | ||
cValue = min; | ||
} | ||
return { | ||
min: min, | ||
max: max, | ||
cValue: cValue | ||
}; | ||
}, | ||
onInput: function onInput(e) { | ||
var value = e.detail.value; | ||
if (value === '') { | ||
this.setData({ | ||
_value: '0' | ||
}); | ||
} else { | ||
this.setData({ | ||
_value: value | ||
}); | ||
} | ||
}, | ||
onFocus: function onFocus(e) { | ||
var _this$props$onFocus, _this$props2; | ||
var value = e.detail.value; | ||
(_this$props$onFocus = (_this$props2 = this.props).onFocus) === null || _this$props$onFocus === void 0 ? void 0 : _this$props$onFocus.call(_this$props2, value); | ||
}, | ||
onBlur: function onBlur(e) { | ||
if (this.data.confirm) { | ||
this.setData({ | ||
confirm: false | ||
}); | ||
} else { | ||
var _this$props$onBlur, _this$props3; | ||
var value = e.detail.value; | ||
this.setData({ | ||
_value: null | ||
}); | ||
this.cOnChange(this.getInputValue(value)); | ||
(_this$props$onBlur = (_this$props3 = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props3, this.getInputValue(value)); | ||
} | ||
}, | ||
onConfirm: function onConfirm(e) { | ||
var value = e.detail.value; | ||
this.setData({ | ||
mixins: [computed_1.default, (0, controlled_1.default)(), (0, form_1.default)()], | ||
props: props_1.StepperDefaultProps, | ||
data: { | ||
confirm: false, | ||
_value: null, | ||
confirm: true | ||
}); | ||
this.cOnChange(this.getInputValue(value)); | ||
}, | ||
getInputValue: function getInputValue(inputValue) { | ||
var _this$props4 = this.props, | ||
min = _this$props4.min, | ||
max = _this$props4.max; | ||
var inputValueTemp = null; | ||
if (!isNaN(Number(inputValue))) { | ||
if (Number(inputValue) <= min) { | ||
inputValueTemp = min; | ||
} else if (Number(inputValue) >= max) { | ||
inputValueTemp = max; | ||
} else { | ||
inputValueTemp = Number(inputValue); | ||
didMount: function () { | ||
var _a = this.data, min = _a.min, max = _a.max, cValue = _a.cValue; | ||
if (cValue < min) { | ||
this.setData({ | ||
cValue: min, | ||
}); | ||
} | ||
return inputValueTemp; | ||
} | ||
if (cValue > max) { | ||
this.setData({ | ||
cValue: max, | ||
}); | ||
} | ||
}, | ||
onChange: function onChange(e) { | ||
var _this$props5 = this.props, | ||
step = _this$props5.step, | ||
disabled = _this$props5.disabled, | ||
precision = _this$props5.precision; | ||
var _this$data2 = this.data, | ||
min = _this$data2.min, | ||
max = _this$data2.max, | ||
cValue = _this$data2.cValue; | ||
if (!disabled) { | ||
var mode = e.currentTarget.dataset.mode; | ||
if (mode === 'minus') { | ||
// 【减】按钮的操作 | ||
var minusTemp = (0, _utils.downStep)(cValue, step, precision); | ||
this.cOnChange(Math.max(minusTemp, min)); | ||
} else if (mode === 'add') { | ||
// 【加】按钮的操作 | ||
var addTemp = (0, _utils.upStep)(cValue, step, precision); | ||
this.cOnChange(Math.min(addTemp, max)); | ||
} | ||
} | ||
} | ||
} | ||
methods: { | ||
computed: function () { | ||
var _a = this.props, min = _a.min, max = _a.max; | ||
var cValue = this.data.cValue; | ||
if (max === undefined) { | ||
max = Number.MAX_SAFE_INTEGER; | ||
} | ||
if (min === undefined) { | ||
min = 0; | ||
} | ||
if (cValue === undefined) { | ||
cValue = min; | ||
} | ||
return { min: min, max: max, cValue: cValue }; | ||
}, | ||
onInput: function (e) { | ||
var value = e.detail.value; | ||
if (value === '') { | ||
this.setData({ | ||
_value: '0', | ||
}); | ||
} | ||
else { | ||
this.setData({ | ||
_value: value, | ||
}); | ||
} | ||
}, | ||
onFocus: function (e) { | ||
var _a, _b; | ||
var value = e.detail.value; | ||
(_b = (_a = this.props).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, value); | ||
}, | ||
onBlur: function (e) { | ||
var _a, _b; | ||
if (this.data.confirm) { | ||
this.setData({ | ||
confirm: false, | ||
}); | ||
} | ||
else { | ||
var value = e.detail.value; | ||
this.setData({ | ||
_value: null, | ||
}); | ||
this.cOnChange(this.getInputValue(value)); | ||
(_b = (_a = this.props).onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, this.getInputValue(value)); | ||
} | ||
}, | ||
onConfirm: function (e) { | ||
var value = e.detail.value; | ||
this.setData({ | ||
_value: null, | ||
confirm: true, | ||
}); | ||
this.cOnChange(this.getInputValue(value)); | ||
}, | ||
getInputValue: function (inputValue) { | ||
var _a = this.props, min = _a.min, max = _a.max; | ||
var inputValueTemp = null; | ||
if (!isNaN(Number(inputValue))) { | ||
if (Number(inputValue) <= min) { | ||
inputValueTemp = min; | ||
} | ||
else if (Number(inputValue) >= max) { | ||
inputValueTemp = max; | ||
} | ||
else { | ||
inputValueTemp = Number(inputValue); | ||
} | ||
return inputValueTemp; | ||
} | ||
}, | ||
onChange: function (e) { | ||
var _a = this.props, step = _a.step, disabled = _a.disabled, precision = _a.precision; | ||
var _b = this.data, min = _b.min, max = _b.max, cValue = _b.cValue; | ||
if (!disabled) { | ||
var mode = e.currentTarget.dataset.mode; | ||
if (mode === 'minus') { | ||
// 【减】按钮的操作 | ||
var minusTemp = (0, utils_1.downStep)(cValue, step, precision); | ||
this.cOnChange(Math.max(minusTemp, min)); | ||
} | ||
else if (mode === 'add') { | ||
// 【加】按钮的操作 | ||
var addTemp = (0, utils_1.upStep)(cValue, step, precision); | ||
this.cOnChange(Math.min(addTemp, max)); | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.StepperDefaultProps = void 0; | ||
var StepperDefaultProps = { | ||
export const StepperDefaultProps = { | ||
controlled: false, | ||
@@ -12,4 +6,3 @@ step: 1, | ||
disabled: false, | ||
type: 'digit' | ||
type: 'digit', | ||
}; | ||
exports.StepperDefaultProps = StepperDefaultProps; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.downStep = downStep; | ||
exports.getMaxPrecision = getMaxPrecision; | ||
exports.getPrecision = getPrecision; | ||
exports.getPrecisionFactor = getPrecisionFactor; | ||
exports.isNotCompleteNumber = isNotCompleteNumber; | ||
exports.toNumber = toNumber; | ||
exports.upStep = upStep; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.downStep = exports.upStep = exports.getPrecisionFactor = exports.getMaxPrecision = exports.getPrecision = exports.toNumber = exports.isNotCompleteNumber = void 0; | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
// '1.' '1x' 'xx' '' => are not complete numbers | ||
function isNotCompleteNumber(num) { | ||
return isNaN(num) || num === '' || num === null || num && num.toString().indexOf('.') === num.toString().length - 1; | ||
return (isNaN(num) || | ||
num === '' || | ||
num === null || | ||
(num && num.toString().indexOf('.') === num.toString().length - 1)); | ||
} | ||
exports.isNotCompleteNumber = isNotCompleteNumber; | ||
function toNumber(num, precision) { | ||
// num.length > 16 => This is to prevent input of large numbers | ||
var numberIsTooLarge = num && num.length > 16; | ||
if (isNotCompleteNumber(num) || numberIsTooLarge) { | ||
return undefined; | ||
} | ||
if (precision != null) { | ||
return Math.round(+num * Math.pow(10, precision) / Math.pow(10, precision)); | ||
} | ||
return Number(num); | ||
// num.length > 16 => This is to prevent input of large numbers | ||
var numberIsTooLarge = num && num.length > 16; | ||
if (isNotCompleteNumber(num) || numberIsTooLarge) { | ||
return undefined; | ||
} | ||
if (precision != null) { | ||
return Math.round(+num * Math.pow(10, precision) / Math.pow(10, precision)); | ||
} | ||
return Number(num); | ||
} | ||
exports.toNumber = toNumber; | ||
function getPrecision(value, precision) { | ||
if (precision != null) { | ||
return precision; | ||
} | ||
var valueString = String(value); | ||
if (valueString.indexOf('e-') >= 0) { | ||
return parseInt(valueString.slice(valueString.indexOf('e-') + 2), 10); | ||
} | ||
var p = 0; | ||
if (valueString.indexOf('.') >= 0) { | ||
p = valueString.length - valueString.indexOf('.') - 1; | ||
} | ||
return p; | ||
} // step={1.0} value={1.51} | ||
if (precision != null) { | ||
return precision; | ||
} | ||
var valueString = String(value); | ||
if (valueString.indexOf('e-') >= 0) { | ||
return parseInt(valueString.slice(valueString.indexOf('e-') + 2), 10); | ||
} | ||
var p = 0; | ||
if (valueString.indexOf('.') >= 0) { | ||
p = valueString.length - valueString.indexOf('.') - 1; | ||
} | ||
return p; | ||
} | ||
exports.getPrecision = getPrecision; | ||
// step={1.0} value={1.51} | ||
// press + | ||
@@ -60,36 +46,34 @@ // then value should be 2.51, rather than 2.5 | ||
// https://github.com/react-component/input-number/issues/39 | ||
function getMaxPrecision(currentValue, step, precision) { | ||
if (precision != null) { | ||
return precision; | ||
} | ||
var stepPrecision = getPrecision(step, precision); | ||
var currentValuePrecision = getPrecision(currentValue, precision); | ||
if (!currentValue) { | ||
return stepPrecision; | ||
} | ||
return Math.max(currentValuePrecision, stepPrecision); | ||
if (precision != null) { | ||
return precision; | ||
} | ||
var stepPrecision = getPrecision(step, precision); | ||
var currentValuePrecision = getPrecision(currentValue, precision); | ||
if (!currentValue) { | ||
return stepPrecision; | ||
} | ||
return Math.max(currentValuePrecision, stepPrecision); | ||
} | ||
exports.getMaxPrecision = getMaxPrecision; | ||
function getPrecisionFactor(currentValue, precision) { | ||
var p = getMaxPrecision(currentValue, undefined, precision); | ||
return Math.pow(10, p); | ||
var p = getMaxPrecision(currentValue, undefined, precision); | ||
return Math.pow(10, p); | ||
} | ||
exports.getPrecisionFactor = getPrecisionFactor; | ||
function upStep(val, step, precision) { | ||
var precisionFactor = getPrecisionFactor(val, precision); | ||
var p = Math.abs(getMaxPrecision(val, step, precision)); | ||
var result = ((precisionFactor * val + precisionFactor * step) / precisionFactor).toFixed(p); | ||
return toNumber(result, precision); | ||
var precisionFactor = getPrecisionFactor(val, precision); | ||
var p = Math.abs(getMaxPrecision(val, step, precision)); | ||
var result = ((precisionFactor * val + precisionFactor * step) / | ||
precisionFactor).toFixed(p); | ||
return toNumber(result, precision); | ||
} | ||
exports.upStep = upStep; | ||
function downStep(val, step, precision) { | ||
var precisionFactor = getPrecisionFactor(val, precision); | ||
var p = Math.abs(getMaxPrecision(val, step, precision)); | ||
var result = ((precisionFactor * val - precisionFactor * step) / precisionFactor).toFixed(p); | ||
return toNumber(result); | ||
} | ||
var precisionFactor = getPrecisionFactor(val, precision); | ||
var p = Math.abs(getMaxPrecision(val, step, precision)); | ||
var result = ((precisionFactor * val - precisionFactor * step) / | ||
precisionFactor).toFixed(p); | ||
return toNumber(result); | ||
} | ||
exports.downStep = downStep; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.context = void 0; | ||
var _setpsStore = require("../_util/setpsStore"); | ||
var context = new _setpsStore.StepsStore(); | ||
exports.context = context; | ||
var setpsStore_1 = require("../_util/setpsStore"); | ||
exports.context = new setpsStore_1.StepsStore(); |
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("./context"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("./context"); | ||
Component({ | ||
props: _props.StepsDefaultProps, | ||
didMount: function didMount() { | ||
this.updateItemData(); | ||
}, | ||
didUpdate: function didUpdate() { | ||
this.updateItemData(); | ||
}, | ||
didUnmount: function didUnmount() { | ||
_context.context.removeGroup(this.props.uid); | ||
}, | ||
methods: { | ||
updateItemData: function updateItemData() { | ||
var _this$props = this.props, | ||
index = _this$props.index, | ||
direction = _this$props.direction, | ||
uid = _this$props.uid; | ||
_context.context.updateItemIndex(uid, index); | ||
_context.context.updateItemDirection(uid, direction); | ||
} | ||
} | ||
props: props_1.StepsDefaultProps, | ||
didMount: function () { | ||
this.updateItemData(); | ||
}, | ||
didUpdate: function () { | ||
this.updateItemData(); | ||
}, | ||
didUnmount: function () { | ||
context_1.context.removeGroup(this.props.uid); | ||
}, | ||
methods: { | ||
updateItemData: function () { | ||
var _a = this.props, index = _a.index, direction = _a.direction, uid = _a.uid; | ||
context_1.context.updateItemIndex(uid, index); | ||
context_1.context.updateItemDirection(uid, direction); | ||
}, | ||
}, | ||
}); |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.StepsDefaultProps = void 0; | ||
var StepsDefaultProps = { | ||
export const StepsDefaultProps = { | ||
index: 0, | ||
direction: 'horizontal', | ||
uid: 'steps' | ||
uid: 'steps', | ||
}; | ||
exports.StepsDefaultProps = StepsDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("../context"); | ||
Component({ | ||
props: _props.StepItemDefaultProps, | ||
data: { | ||
_index: 0, | ||
_direction: 'horizontal' | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
var uid = this.props.uid; | ||
var setItemIndex = function setItemIndex(index) { | ||
return _this.setData({ | ||
_index: index | ||
}); | ||
}; | ||
var setItemDirection = function setItemDirection(direction) { | ||
return _this.setData({ | ||
_direction: direction | ||
}); | ||
}; | ||
_context.context.addItem(uid, "".concat(this.$id), { | ||
setItemIndex: setItemIndex, | ||
setItemDirection: setItemDirection | ||
}); | ||
}, | ||
didUnmount: function didUnmount() { | ||
_context.context.removeItem(this.props.uid, "".concat(this.$id)); | ||
}, | ||
methods: {} | ||
props: props_1.StepItemDefaultProps, | ||
data: { | ||
_index: 0, | ||
_direction: 'horizontal', | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
var uid = this.props.uid; | ||
var setItemIndex = function (index) { return _this.setData({ | ||
_index: index, | ||
}); }; | ||
var setItemDirection = function (direction) { return _this.setData({ | ||
_direction: direction, | ||
}); }; | ||
context_1.context.addItem(uid, "".concat(this.$id), { | ||
setItemIndex: setItemIndex, | ||
setItemDirection: setItemDirection, | ||
}); | ||
}, | ||
didUnmount: function () { | ||
context_1.context.removeItem(this.props.uid, "".concat(this.$id)); | ||
}, | ||
methods: {}, | ||
}); |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.StepItemDefaultProps = void 0; | ||
var StepItemDefaultProps = { | ||
export const StepItemDefaultProps = { | ||
fail: false, | ||
uid: 'steps' | ||
uid: 'steps', | ||
}; | ||
exports.StepItemDefaultProps = StepItemDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("../_util/context"); | ||
var swipeIdContext = new _context.ComponentContext(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("../_util/context"); | ||
var swipeIdContext = new context_1.ComponentContext(); | ||
Component({ | ||
props: _props.SwipeActionDefaultProps, | ||
data: { | ||
itemPosition: 0, | ||
leftBtn: false, | ||
rightBtn: false, | ||
prevId: null | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
this.setBtnWidth(); | ||
this.swipeActionItemId = function (value) { | ||
if (value !== _this.$id && _this.data.itemPosition !== 0) { | ||
_this.setData({ | ||
itemPosition: 0 | ||
}); | ||
} | ||
}; | ||
swipeIdContext.onUpdate(this.swipeActionItemId); | ||
this.props.onGetRef(this.getRef()); | ||
}, | ||
didUnmount: function didUnmount() { | ||
swipeIdContext.offUpdate(this.swipeActionItemId); | ||
}, | ||
methods: { | ||
setBtnWidth: function setBtnWidth() { | ||
var _this2 = this; | ||
my.createSelectorQuery().select(".amd-swipe-action-right-".concat(this.$id)).boundingClientRect().exec(function (ret) { | ||
_this2.rightBtnWidth = ret && ret[0] && ret[0].width || 0; | ||
}); | ||
my.createSelectorQuery().select(".amd-swipe-action-left-".concat(this.$id)).boundingClientRect().exec(function (ret) { | ||
_this2.leftBtnWidth = ret && ret[0] && ret[0].width || 0; | ||
}); | ||
props: props_1.SwipeActionDefaultProps, | ||
data: { | ||
itemPosition: 0, | ||
leftBtn: false, | ||
rightBtn: false, | ||
prevId: null, | ||
}, | ||
onSwipeTap: function onSwipeTap() { | ||
if (this.data.itemPosition !== 0) { | ||
this.setData({ | ||
itemPosition: 0 | ||
}); | ||
} | ||
}, | ||
onSwipeStart: function onSwipeStart(e) { | ||
swipeIdContext.update(this.$id); | ||
var disabled = this.props.disabled; | ||
if (this.data.itemPosition !== 0 || disabled) { | ||
this.setData({ | ||
itemPosition: 0 | ||
}); | ||
this.touchObject = { | ||
startX: 0, | ||
startY: 0 | ||
didMount: function () { | ||
var _this = this; | ||
this.setBtnWidth(); | ||
this.swipeActionItemId = function (value) { | ||
if (value !== _this.$id && _this.data.itemPosition !== 0) { | ||
_this.setData({ | ||
itemPosition: 0, | ||
}); | ||
} | ||
}; | ||
} else { | ||
this.touchObject = { | ||
startX: e.touches[0].pageX, | ||
startY: e.touches[0].pageY | ||
}; | ||
} | ||
swipeIdContext.onUpdate(this.swipeActionItemId); | ||
this.props.onGetRef(this.getRef()); | ||
}, | ||
onSwipeMove: function onSwipeMove(e) { | ||
var touchObject = this.touchObject; | ||
var touchePoint = e.touches[0]; | ||
var itemPosition = this.data.itemPosition; | ||
if (touchObject) { | ||
touchObject.endX = touchePoint.pageX; // 首次触发时,计算滑动角度 | ||
if (touchObject.direction === undefined) { | ||
var direction = 0; | ||
var xDist = touchObject.startX - touchePoint.pageX || 0; | ||
var yDist = touchObject.startY - touchePoint.pageY || 0; | ||
var r = Math.atan2(yDist, xDist); | ||
var swipeAngle = Math.round(r * 180 / Math.PI); | ||
if (swipeAngle < 0) { | ||
swipeAngle = 360 - Math.abs(swipeAngle); | ||
} | ||
if (swipeAngle <= 30 && swipeAngle >= 0) { | ||
direction = 1; | ||
} | ||
if (swipeAngle <= 360 && swipeAngle >= 330) { | ||
direction = 1; | ||
} | ||
if (swipeAngle >= 170 && swipeAngle <= 190) { | ||
direction = -1; | ||
} | ||
touchObject.direction = direction; | ||
} // 通过角度判断是左右方向 | ||
if (touchObject.direction !== 0) { | ||
var newPoisiton = itemPosition; // 滑动距离 | ||
var distance = touchObject.endX - touchObject.startX; // 左划 | ||
if (distance < 0) { | ||
newPoisiton = Math.max(distance, -this.rightBtnWidth); | ||
this.setData({ | ||
rightBtn: true, | ||
leftBtn: false | ||
}); // 右划 | ||
} else { | ||
newPoisiton = Math.min(distance, this.leftBtnWidth); | ||
this.setData({ | ||
rightBtn: false, | ||
leftBtn: true | ||
didUnmount: function () { | ||
swipeIdContext.offUpdate(this.swipeActionItemId); | ||
}, | ||
methods: { | ||
setBtnWidth: function () { | ||
var _this = this; | ||
my.createSelectorQuery() | ||
.select(".amd-swipe-action-right-".concat(this.$id)) | ||
.boundingClientRect() | ||
.exec(function (ret) { | ||
_this.rightBtnWidth = (ret && ret[0] && ret[0].width) || 0; | ||
}); | ||
} | ||
if (Math.abs(distance) > 10) { | ||
this.setData({ | ||
itemPosition: newPoisiton | ||
my.createSelectorQuery() | ||
.select(".amd-swipe-action-left-".concat(this.$id)) | ||
.boundingClientRect() | ||
.exec(function (ret) { | ||
_this.leftBtnWidth = (ret && ret[0] && ret[0].width) || 0; | ||
}); | ||
} | ||
} | ||
} | ||
}, | ||
onSwipeTap: function () { | ||
if (this.data.itemPosition !== 0) { | ||
this.setData({ | ||
itemPosition: 0, | ||
}); | ||
} | ||
}, | ||
onSwipeStart: function (e) { | ||
swipeIdContext.update(this.$id); | ||
var disabled = this.props.disabled; | ||
if (this.data.itemPosition !== 0 || disabled) { | ||
this.setData({ | ||
itemPosition: 0, | ||
}); | ||
this.touchObject = { | ||
startX: 0, | ||
startY: 0, | ||
}; | ||
} | ||
else { | ||
this.touchObject = { | ||
startX: e.touches[0].pageX, | ||
startY: e.touches[0].pageY, | ||
}; | ||
} | ||
}, | ||
onSwipeMove: function (e) { | ||
var touchObject = this.touchObject; | ||
var touchePoint = e.touches[0]; | ||
var itemPosition = this.data.itemPosition; | ||
if (touchObject) { | ||
touchObject.endX = touchePoint.pageX; | ||
// 首次触发时,计算滑动角度 | ||
if (touchObject.direction === undefined) { | ||
var direction = 0; | ||
var xDist = touchObject.startX - touchePoint.pageX || 0; | ||
var yDist = touchObject.startY - touchePoint.pageY || 0; | ||
var r = Math.atan2(yDist, xDist); | ||
var swipeAngle = Math.round((r * 180) / Math.PI); | ||
if (swipeAngle < 0) { | ||
swipeAngle = 360 - Math.abs(swipeAngle); | ||
} | ||
if (swipeAngle <= 30 && swipeAngle >= 0) { | ||
direction = 1; | ||
} | ||
if (swipeAngle <= 360 && swipeAngle >= 330) { | ||
direction = 1; | ||
} | ||
if (swipeAngle >= 170 && swipeAngle <= 190) { | ||
direction = -1; | ||
} | ||
touchObject.direction = direction; | ||
} | ||
// 通过角度判断是左右方向 | ||
if (touchObject.direction !== 0) { | ||
var newPoisiton = itemPosition; | ||
// 滑动距离 | ||
var distance = touchObject.endX - touchObject.startX; | ||
// 左划 | ||
if (distance < 0) { | ||
newPoisiton = Math.max(distance, -this.rightBtnWidth); | ||
this.setData({ | ||
rightBtn: true, | ||
leftBtn: false, | ||
}); | ||
// 右划 | ||
} | ||
else { | ||
newPoisiton = Math.min(distance, this.leftBtnWidth); | ||
this.setData({ | ||
rightBtn: false, | ||
leftBtn: true, | ||
}); | ||
} | ||
if (Math.abs(distance) > 10) { | ||
this.setData({ | ||
itemPosition: newPoisiton, | ||
}); | ||
} | ||
} | ||
} | ||
}, | ||
onSwipeEnd: function (e) { | ||
var touchObject = this.touchObject; | ||
if (touchObject.direction !== 0) { | ||
var touchePoint = e.changedTouches[0]; | ||
touchObject.endX = touchePoint.pageX; | ||
var itemPosition = this.data.itemPosition; | ||
var distance = touchObject.endX - touchObject.startX; | ||
var newPoisiton = itemPosition; | ||
if (distance < 0) { | ||
if (Math.abs(distance + itemPosition) > this.rightBtnWidth * 0.7) { | ||
newPoisiton = (-this.rightBtnWidth); | ||
} | ||
else { | ||
newPoisiton = 0; | ||
} | ||
} | ||
else if (Math.abs(distance + itemPosition) > this.leftBtnWidth * 0.7) { | ||
newPoisiton = this.leftBtnWidth; | ||
} | ||
else { | ||
newPoisiton = 0; | ||
} | ||
this.setData({ | ||
itemPosition: newPoisiton, | ||
}); | ||
} | ||
}, | ||
onLeftButtonTap: function (e) { | ||
var _a = e.currentTarget.dataset, index = _a.index, text = _a.text, type = _a.type; | ||
var _b = this.props, autoClose = _b.autoClose, onLeftButtonTap = _b.onLeftButtonTap, extraInfo = _b.extraInfo; | ||
if (autoClose) { | ||
this.setData({ | ||
itemPosition: 0, | ||
}); | ||
} | ||
if (onLeftButtonTap) { | ||
return onLeftButtonTap(index, text, type, extraInfo); | ||
} | ||
}, | ||
onRightButtonTap: function (e) { | ||
var _a = e.currentTarget.dataset, index = _a.index, text = _a.text, type = _a.type; | ||
var _b = this.props, autoClose = _b.autoClose, onRightButtonTap = _b.onRightButtonTap, extraInfo = _b.extraInfo; | ||
if (autoClose) { | ||
this.setData({ | ||
itemPosition: 0, | ||
}); | ||
} | ||
if (onRightButtonTap) { | ||
return onRightButtonTap(index, text, type, extraInfo); | ||
} | ||
}, | ||
getRef: function () { | ||
var _this = this; | ||
return { | ||
getCompInstance: function () { return _this; }, | ||
setItemPosition: function (idx) { | ||
_this.setData({ | ||
itemPosition: idx, | ||
}); | ||
} | ||
}; | ||
}, | ||
}, | ||
onSwipeEnd: function onSwipeEnd(e) { | ||
var touchObject = this.touchObject; | ||
if (touchObject.direction !== 0) { | ||
var touchePoint = e.changedTouches[0]; | ||
touchObject.endX = touchePoint.pageX; | ||
var itemPosition = this.data.itemPosition; | ||
var distance = touchObject.endX - touchObject.startX; | ||
var newPoisiton = itemPosition; | ||
if (distance < 0) { | ||
if (Math.abs(distance + itemPosition) > this.rightBtnWidth * 0.7) { | ||
newPoisiton = -this.rightBtnWidth; | ||
} else { | ||
newPoisiton = 0; | ||
} | ||
} else if (Math.abs(distance + itemPosition) > this.leftBtnWidth * 0.7) { | ||
newPoisiton = this.leftBtnWidth; | ||
} else { | ||
newPoisiton = 0; | ||
} | ||
this.setData({ | ||
itemPosition: newPoisiton | ||
}); | ||
} | ||
ref: function () { | ||
var _this = this; | ||
return { | ||
getCompInstance: function () { return _this; }, | ||
setItemPosition: function (idx) { | ||
_this.setData({ | ||
itemPosition: idx, | ||
}); | ||
} | ||
}; | ||
}, | ||
onLeftButtonTap: function onLeftButtonTap(e) { | ||
var _e$currentTarget$data = e.currentTarget.dataset, | ||
index = _e$currentTarget$data.index, | ||
text = _e$currentTarget$data.text, | ||
type = _e$currentTarget$data.type; | ||
var _this$props = this.props, | ||
autoClose = _this$props.autoClose, | ||
onLeftButtonTap = _this$props.onLeftButtonTap, | ||
extraInfo = _this$props.extraInfo; | ||
if (autoClose) { | ||
this.setData({ | ||
itemPosition: 0 | ||
}); | ||
} | ||
if (onLeftButtonTap) { | ||
return onLeftButtonTap(index, text, type, extraInfo); | ||
} | ||
}, | ||
onRightButtonTap: function onRightButtonTap(e) { | ||
var _e$currentTarget$data2 = e.currentTarget.dataset, | ||
index = _e$currentTarget$data2.index, | ||
text = _e$currentTarget$data2.text, | ||
type = _e$currentTarget$data2.type; | ||
var _this$props2 = this.props, | ||
autoClose = _this$props2.autoClose, | ||
onRightButtonTap = _this$props2.onRightButtonTap, | ||
extraInfo = _this$props2.extraInfo; | ||
if (autoClose) { | ||
this.setData({ | ||
itemPosition: 0 | ||
}); | ||
} | ||
if (onRightButtonTap) { | ||
return onRightButtonTap(index, text, type, extraInfo); | ||
} | ||
}, | ||
getRef: function getRef() { | ||
var _this3 = this; | ||
return { | ||
getCompInstance: function getCompInstance() { | ||
return _this3; | ||
}, | ||
setItemPosition: function setItemPosition(idx) { | ||
_this3.setData({ | ||
itemPosition: idx | ||
}); | ||
} | ||
}; | ||
} | ||
}, | ||
ref: function ref() { | ||
var _this4 = this; | ||
return { | ||
getCompInstance: function getCompInstance() { | ||
return _this4; | ||
}, | ||
setItemPosition: function setItemPosition(idx) { | ||
_this4.setData({ | ||
itemPosition: idx | ||
}); | ||
} | ||
}; | ||
} | ||
}); |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SwipeActionDefaultProps = void 0; | ||
var SwipeActionDefaultProps = { | ||
export const SwipeActionDefaultProps = { | ||
autoClose: false, | ||
disabled: false, | ||
onGetRef: function onGetRef() {} | ||
onGetRef:()=>{} | ||
}; | ||
exports.SwipeActionDefaultProps = SwipeActionDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _controlled = _interopRequireDefault(require("../mixins/controlled")); | ||
var _form = _interopRequireDefault(require("../mixins/form")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var controlled_1 = require("../mixins/controlled"); | ||
var form_1 = require("../mixins/form"); | ||
Component({ | ||
props: _props.SwitchDefaultProps, | ||
mixins: [(0, _controlled["default"])('checked'), (0, _form["default"])()], | ||
methods: { | ||
onChange: function onChange(v) { | ||
var value = v.detail.value; | ||
this.cOnChange(value); | ||
} | ||
} | ||
props: props_1.SwitchDefaultProps, | ||
mixins: [(0, controlled_1.default)('checked'), (0, form_1.default)()], | ||
methods: { | ||
onChange: function (v) { | ||
var value = v.detail.value; | ||
this.cOnChange(value); | ||
}, | ||
}, | ||
}); |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SwitchDefaultProps = void 0; | ||
var SwitchDefaultProps = { | ||
export const SwitchDefaultProps = { | ||
controlled: false, | ||
disabled: false, | ||
size: 'medium' | ||
size: 'medium', | ||
}; | ||
exports.SwitchDefaultProps = SwitchDefaultProps; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getTabArray = exports.componentContextFallback = exports.componentContext = void 0; | ||
var _context = require("../_util/context"); | ||
var componentContext = new _context.ComponentContext(); | ||
exports.componentContext = componentContext; | ||
var componentContextFallback = new _context.ComponentContext(); | ||
exports.componentContextFallback = componentContextFallback; | ||
var getTabArray = {}; | ||
exports.getTabArray = getTabArray; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTabArray = exports.componentContext = void 0; | ||
var context_1 = require("../_util/context"); | ||
exports.componentContext = new context_1.ComponentContext(); | ||
exports.getTabArray = {}; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _props = require("./props"); | ||
var _context = require("./context"); | ||
var _console = require("../_util/console"); | ||
var _tools = require("../_util/tools"); | ||
var _compareVersion = require("../_util/compareVersion"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
var props_1 = require("./props"); | ||
var context_1 = require("./context"); | ||
var console_1 = require("../_util/console"); | ||
var tools_1 = require("../_util/tools"); | ||
var compareVersion_1 = require("../_util/compareVersion"); | ||
var canSwipeable = my.canIUse('swiper.disable-touch'); | ||
var component2 = my.canIUse('component2'); | ||
var hasTab = false; | ||
var isShouldNotCalHeight = component2 && (0, _compareVersion.compareVersion)(my.SDKVersion, '2.6.4') >= 0; | ||
var isForceUpdate = (0, _compareVersion.compareVersion)(my.SDKVersion, '2.6.4') >= 0 && (0, _compareVersion.compareVersion)(my.SDKVersion, '2.7.5') === -1; | ||
var isMoreThan275 = (0, _compareVersion.compareVersion)(my.SDKVersion, '2.7.5') >= 0; | ||
var isBaseSwiper = (0, _compareVersion.compareVersion)(my.SDKVersion, '2.0.0') >= 0; | ||
var isShouldNotCalHeight = component2 && (0, compareVersion_1.compareVersion)(my.SDKVersion, '2.6.4') >= 0; | ||
var isForceUpdate = (0, compareVersion_1.compareVersion)(my.SDKVersion, '2.6.4') >= 0 && (0, compareVersion_1.compareVersion)(my.SDKVersion, '2.7.5') === -1; | ||
var isMoreThan275 = (0, compareVersion_1.compareVersion)(my.SDKVersion, '2.7.5') >= 0; | ||
Component({ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
props: _props.TabsDefaultProps, | ||
data: { | ||
_tabs: {}, | ||
_leftFade: true, | ||
_rightFade: true, | ||
_tabsViewportWidth: 0, | ||
_scrollLeft: 0, | ||
_swipeable: false, | ||
_swipeableIndex: 0, | ||
_swipeableAnimation: false, | ||
_tabContentHeight: 0, | ||
currentIndex: 0, | ||
component2: component2, | ||
isBaseSwiper: isBaseSwiper, | ||
_forceRefreshSwiper: 0, | ||
_isForceUpdate: isForceUpdate | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
if (hasTab) { | ||
_console.log.error('Tabs', '目前仅支持在一个页面中使用一个 Tabs 组件。'); | ||
} | ||
hasTab = true; | ||
_context.componentContext.onUpdate(function (value) { | ||
_this.setData({ | ||
_tabs: value | ||
}); | ||
}); | ||
_context.componentContextFallback.update(this.props.fallback); | ||
var _this$props = this.props, | ||
index = _this$props.index, | ||
animation = _this$props.animation; | ||
this.setData({ | ||
_tabs: (0, _tools.objectValues)(_context.getTabArray), | ||
currentIndex: index | ||
}); | ||
this._getTabsWidth(); | ||
this._useSwipeable(this.props.swipeable); | ||
if (typeof index !== 'number') { | ||
// 如果当前索引值的类型不对给警告提示 | ||
_console.log.error('Tabs', "\u5F53\u524D\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u7C7B\u578B\u975E number \u7C7B\u578B\uFF0C\u4FEE\u6539\u5F53\u524D index \u7684 ".concat((0, _typeof2["default"])(index), " \u7C7B\u578B\uFF0C\u4EE5\u4FDD\u8BC1\u5C55\u793A\u7684\u6B63\u786E\u6027\u3002")); | ||
} else { | ||
my.createSelectorQuery().select("#amd-tabs-bar-item-".concat(index)).boundingClientRect().exec(function (ret) { | ||
if (!ret || !ret[0]) { | ||
// 当获取到的索引值无法匹配时显示错误提示 | ||
_console.log.error('Tabs', "\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u9519\u8BEF\uFF0C\u8BF7\u786E\u8BA4 ".concat(index, " \u662F\u5426\u4E3A\u6B63\u786E\u7684\u7D22\u5F15\u503C\u3002")); | ||
return; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
props: props_1.TabsDefaultProps, | ||
data: { | ||
_tabs: {}, | ||
_leftFade: true, | ||
_rightFade: true, | ||
_tabsViewportWidth: 0, | ||
_scrollLeft: 0, | ||
_swipeable: false, | ||
_swipeableIndex: 0, | ||
_swipeableAnimation: false, | ||
_tabContentHeight: 0, | ||
currentIndex: 0, | ||
component2: component2, | ||
_forceRefreshSwiper: 0, | ||
_isForceUpdate: isForceUpdate, | ||
}, | ||
didMount: function () { | ||
var _this = this; | ||
if (hasTab) { | ||
console_1.log.error('Tabs', '目前仅支持在一个页面中使用一个 Tabs 组件。'); | ||
} | ||
var _tabsViewportWidth = _this.data._tabsViewportWidth; // 正确的索引值在初次加载时高亮展示当前 tab | ||
// eslint-disable-next-line no-lonely-if | ||
if (ret[0].left > _tabsViewportWidth / 2) { | ||
_this.setData({ | ||
_scrollLeft: ret[0].left - _tabsViewportWidth / 2 + ret[0].width / 2, | ||
_leftFade: true, | ||
_swipeableAnimation: animation | ||
}); | ||
} else { | ||
_this.setData({ | ||
_scrollLeft: 0, | ||
_leftFade: false, | ||
_swipeableAnimation: animation | ||
}); | ||
} | ||
}); | ||
this._autoHeight(index); | ||
} | ||
if (!component2) { | ||
this.props.onGetRef(this.getRef()); | ||
} | ||
}, | ||
didUpdate: function didUpdate(prevProps, prevData) { | ||
var _this2 = this; | ||
var _this$props2 = this.props, | ||
index = _this$props2.index, | ||
animation = _this$props2.animation, | ||
fallback = _this$props2.fallback; | ||
if (prevProps.fallback !== fallback) { | ||
_context.componentContextFallback.update(fallback); | ||
} | ||
if (prevProps.index !== index && prevData.currentIndex === this.data.currentIndex) { | ||
this._getTabsWidth(); | ||
my.createSelectorQuery().select("#amd-tabs-bar-item-".concat(index)).boundingClientRect().exec(function (ret) { | ||
if (!ret || !ret[0]) { | ||
// 当获取到的索引值无法匹配时显示错误提示 | ||
_console.log.error('Tabs', "\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u9519\u8BEF\uFF0C\u8BF7\u786E\u8BA4 ".concat(index, " \u662F\u5426\u4E3A\u6B63\u786E\u7684\u7D22\u5F15\u503C\u3002")); | ||
return; | ||
} | ||
var _tabsViewportWidth = _this2.data._tabsViewportWidth; | ||
_tabsViewportWidth = Math.floor(_tabsViewportWidth); | ||
var left = Math.floor(ret[0].left) + _this2.data._scrollLeft; | ||
var width = Math.floor(ret[0].width); // 正确的索引值在初次加载时高亮展示当前 tab | ||
if (_this2.changeTap) { | ||
left = _this2.currentLeft; | ||
_this2.changeTap = false; | ||
} | ||
if (left > _tabsViewportWidth / 2) { | ||
_this2.setData({ | ||
_scrollLeft: left - _tabsViewportWidth / 2 + width / 2, | ||
_leftFade: true, | ||
hasTab = true; | ||
context_1.componentContext.onUpdate(function (value) { | ||
_this.setData({ | ||
_tabs: value, | ||
}); | ||
}); | ||
var _a = this.props, index = _a.index, animation = _a.animation; | ||
this.setData({ | ||
_tabs: (0, tools_1.objectValues)(context_1.getTabArray), | ||
currentIndex: index, | ||
_swipeableAnimation: animation | ||
}); | ||
} else { | ||
_this2.setData({ | ||
_scrollLeft: 0, | ||
_leftFade: false, | ||
currentIndex: index, | ||
_swipeableAnimation: animation | ||
}); | ||
}); | ||
this._getTabsWidth(); | ||
this._useSwipeable(this.props.swipeable); | ||
if (typeof index !== 'number') { | ||
// 如果当前索引值的类型不对给警告提示 | ||
console_1.log.error('Tabs', "\u5F53\u524D\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u7C7B\u578B\u975E number \u7C7B\u578B\uFF0C\u4FEE\u6539\u5F53\u524D index \u7684 ".concat(typeof index, " \u7C7B\u578B\uFF0C\u4EE5\u4FDD\u8BC1\u5C55\u793A\u7684\u6B63\u786E\u6027\u3002")); | ||
} | ||
}); | ||
this._autoHeight(index); | ||
} | ||
this._useSwipeable(this.props.swipeable); | ||
}, | ||
didUnmount: function didUnmount() { | ||
hasTab = false; | ||
_context.componentContext.clearEvent(); | ||
}, | ||
methods: { | ||
_autoHeight: function _autoHeight(tabIndex) { | ||
var _this3 = this; | ||
if (isShouldNotCalHeight) return; | ||
if (this.props.fallback) return; // tabItem 自适应高度的处理 | ||
// 获取每个 item-pane 的高度,通过传入当前 tab 的 index 值 | ||
// 动态修改 _tabContentHeight 后在 axml 中插入修改 | ||
my.createSelectorQuery().selectAll("#amd-tabs-content-".concat(this.$id, " .amd-tabs-item-pane")).boundingClientRect().exec(function (ret) { | ||
if (ret && ret[0]) { | ||
var _tabIndex; | ||
_this3.setData({ | ||
_tabContentHeight: (_tabIndex = ret[0][tabIndex]) === null || _tabIndex === void 0 ? void 0 : _tabIndex.height | ||
}); | ||
else { | ||
my.createSelectorQuery() | ||
.select("#amd-tabs-bar-item-".concat(index)) | ||
.boundingClientRect() | ||
.exec(function (ret) { | ||
var _tabsViewportWidth = _this.data._tabsViewportWidth; | ||
if (!ret[0]) { | ||
// 当获取到的索引值无法匹配时显示错误提示 | ||
console_1.log.error('Tabs', "\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u9519\u8BEF\uFF0C\u8BF7\u786E\u8BA4 ".concat(index, " \u662F\u5426\u4E3A\u6B63\u786E\u7684\u7D22\u5F15\u503C\u3002")); | ||
} | ||
else { | ||
// 正确的索引值在初次加载时高亮展示当前 tab | ||
// eslint-disable-next-line no-lonely-if | ||
if (ret[0].left > _tabsViewportWidth / 2) { | ||
_this.setData({ | ||
_scrollLeft: ret[0].left - | ||
_tabsViewportWidth / 2 + | ||
ret[0].width / 2, | ||
_leftFade: true, | ||
_swipeableAnimation: animation, | ||
}); | ||
} | ||
else { | ||
_this.setData({ | ||
_scrollLeft: 0, | ||
_leftFade: false, | ||
_swipeableAnimation: animation, | ||
}); | ||
} | ||
} | ||
}); | ||
this._autoHeight(index); | ||
} | ||
}); | ||
}, | ||
handleSwiperChange: function handleSwiperChange(e) { | ||
var _e$detail, _e$detail2, _e$detail3; | ||
var onChange = this.props.onChange; // tab-item 滑动时获取当前的 item 元素 | ||
// 并修改 swiper 的高度以自适应展示 | ||
this.setData({ | ||
currentIndex: (_e$detail = e.detail) === null || _e$detail === void 0 ? void 0 : _e$detail.current, | ||
_swipeableIndex: (_e$detail2 = e.detail) === null || _e$detail2 === void 0 ? void 0 : _e$detail2.current, | ||
_swipeableAnimation: true | ||
}); | ||
this._autoHeight((_e$detail3 = e.detail) === null || _e$detail3 === void 0 ? void 0 : _e$detail3.current); | ||
if (onChange) { | ||
var _e$detail4; | ||
return onChange((_e$detail4 = e.detail) === null || _e$detail4 === void 0 ? void 0 : _e$detail4.current); | ||
} | ||
}, | ||
_useSwipeable: function _useSwipeable(b) { | ||
var swipeable = this.props.swipeable; | ||
if (!component2 && swipeable && !b) { | ||
_console.log.error('Tabs', '未开启 component2 编译,swipeable 无法使用'); | ||
} // 如需使用 swipeable 属性,需要基础库版本 ≥ 1.15.0 | ||
if (!canSwipeable) { | ||
this.setData({ | ||
_swipeable: true | ||
}); | ||
if (!b) { | ||
_console.log.error('Tabs', '基础库版本需要 1.15.0 及以上才可以使用 swipeable'); | ||
if (!component2) { | ||
this.props.onGetRef(this.getRef()); | ||
} | ||
} else { | ||
this.setData({ | ||
_swipeable: !this.props.swipeable | ||
}); | ||
} | ||
}, | ||
_getTabsWidth: function _getTabsWidth() { | ||
var _this4 = this; | ||
// 获取 tabs 可视区域的宽度 | ||
my.createSelectorQuery().select("#amd-tabs-bar-scroll-view-".concat(this.$id)).boundingClientRect().exec(function (ret) { | ||
if (ret && ret[0]) { | ||
_this4.setData({ | ||
_tabsViewportWidth: ret[0].width | ||
}); | ||
didUpdate: function (prevProps, prevData) { | ||
var _this = this; | ||
var _a = this.props, index = _a.index, animation = _a.animation; | ||
if (prevProps.index !== index && prevData.currentIndex === this.data.currentIndex) { | ||
this._getTabsWidth(); | ||
my.createSelectorQuery() | ||
.select("#amd-tabs-bar-item-".concat(index)) | ||
.boundingClientRect() | ||
.exec(function (ret) { | ||
var _tabsViewportWidth = _this.data._tabsViewportWidth; | ||
_tabsViewportWidth = Math.floor(_tabsViewportWidth); | ||
var left = Math.floor(ret[0].left) + _this.data._scrollLeft; | ||
var width = Math.floor(ret[0].width); | ||
if (!ret[0]) { | ||
// 当获取到的索引值无法匹配时显示错误提示 | ||
console_1.log.error('Tabs', "\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u9519\u8BEF\uFF0C\u8BF7\u786E\u8BA4 ".concat(index, " \u662F\u5426\u4E3A\u6B63\u786E\u7684\u7D22\u5F15\u503C\u3002")); | ||
} | ||
else { | ||
// 正确的索引值在初次加载时高亮展示当前 tab | ||
if (_this.changeTap) { | ||
left = _this.currentLeft; | ||
_this.changeTap = false; | ||
} | ||
if (left > _tabsViewportWidth / 2) { | ||
_this.setData({ | ||
_scrollLeft: left - _tabsViewportWidth / 2 + width / 2, | ||
_leftFade: true, | ||
currentIndex: index, | ||
_swipeableAnimation: animation, | ||
}); | ||
} | ||
else { | ||
_this.setData({ | ||
_scrollLeft: 0, | ||
_leftFade: false, | ||
currentIndex: index, | ||
_swipeableAnimation: animation, | ||
}); | ||
} | ||
} | ||
}); | ||
this._autoHeight(index); | ||
} | ||
}); | ||
this._useSwipeable(this.props.swipeable); | ||
}, | ||
onChange: function onChange(e) { | ||
var _e$currentTarget, _e$currentTarget$data, _this$data$_tabs$inde; | ||
var onChange = this.props.onChange; | ||
var index = parseInt(e === null || e === void 0 ? void 0 : (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : (_e$currentTarget$data = _e$currentTarget.dataset) === null || _e$currentTarget$data === void 0 ? void 0 : _e$currentTarget$data.index, 10); | ||
if ((_this$data$_tabs$inde = this.data._tabs[index]) !== null && _this$data$_tabs$inde !== void 0 && _this$data$_tabs$inde.disabled) { | ||
return; | ||
} | ||
if (onChange && index !== this.data.currentIndex) { | ||
var _e$currentTarget2; | ||
this.changeTap = true; // 获取当前元素的 offsetLeft 值 | ||
this.currentLeft = e === null || e === void 0 ? void 0 : (_e$currentTarget2 = e.currentTarget) === null || _e$currentTarget2 === void 0 ? void 0 : _e$currentTarget2.offsetLeft; | ||
return onChange(index); | ||
} | ||
didUnmount: function () { | ||
hasTab = false; | ||
context_1.componentContext.clearEvent(); | ||
}, | ||
handleSwiperTouchStart: function handleSwiperTouchStart(e) { | ||
var onTouchStart = this.props.onTouchStart; | ||
if (typeof onTouchStart === "function") { | ||
onTouchStart(e); | ||
} | ||
methods: { | ||
_autoHeight: function (tabIndex) { | ||
var _this = this; | ||
if (isShouldNotCalHeight) | ||
return; | ||
// tabItem 自适应高度的处理 | ||
// 获取每个 item-pane 的高度,通过传入当前 tab 的 index 值 | ||
// 动态修改 _tabContentHeight 后在 axml 中插入修改 | ||
my.createSelectorQuery() | ||
.selectAll("#amd-tabs-content-".concat(this.$id, " .amd-tabs-item-pane")) | ||
.boundingClientRect() | ||
.exec(function (ret) { | ||
var _a; | ||
_this.setData({ | ||
_tabContentHeight: (_a = ret[0][tabIndex]) === null || _a === void 0 ? void 0 : _a.height, | ||
}); | ||
}); | ||
}, | ||
handleSwiperChange: function (e) { | ||
var _a, _b, _c, _d; | ||
var onChange = this.props.onChange; | ||
// tab-item 滑动时获取当前的 item 元素 | ||
// 并修改 swiper 的高度以自适应展示 | ||
this.setData({ | ||
currentIndex: (_a = e.detail) === null || _a === void 0 ? void 0 : _a.current, | ||
_swipeableIndex: (_b = e.detail) === null || _b === void 0 ? void 0 : _b.current, | ||
_swipeableAnimation: true, | ||
}); | ||
this._autoHeight((_c = e.detail) === null || _c === void 0 ? void 0 : _c.current); | ||
if (onChange) { | ||
return onChange((_d = e.detail) === null || _d === void 0 ? void 0 : _d.current); | ||
} | ||
}, | ||
_useSwipeable: function (b) { | ||
var swipeable = this.props.swipeable; | ||
if (!component2 && swipeable && !b) { | ||
console_1.log.error('Tabs', '未开启 component2 编译,swipeable 无法使用'); | ||
} | ||
// 如需使用 swipeable 属性,需要基础库版本 ≥ 1.15.0 | ||
if (!canSwipeable) { | ||
this.setData({ | ||
_swipeable: true, | ||
}); | ||
if (!b) { | ||
console_1.log.error('Tabs', '基础库版本需要 1.15.0 及以上才可以使用 swipeable'); | ||
} | ||
} | ||
else { | ||
this.setData({ | ||
_swipeable: !this.props.swipeable, | ||
}); | ||
} | ||
}, | ||
_getTabsWidth: function () { | ||
var _this = this; | ||
// 获取 tabs 可视区域的宽度 | ||
my.createSelectorQuery() | ||
.select("#amd-tabs-bar-scroll-view-".concat(this.$id)) | ||
.boundingClientRect() | ||
.exec(function (ret) { | ||
_this.setData({ | ||
_tabsViewportWidth: ret[0].width, | ||
}); | ||
}); | ||
}, | ||
onChange: function (e) { | ||
var _a, _b, _c, _d; | ||
var onChange = this.props.onChange; | ||
var index = parseInt((_b = (_a = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.index, 10); | ||
if ((_c = this.data._tabs[index]) === null || _c === void 0 ? void 0 : _c.disabled) { | ||
return; | ||
} | ||
if (onChange && index !== this.data.currentIndex) { | ||
this.changeTap = true; | ||
// 获取当前元素的 offsetLeft 值 | ||
this.currentLeft = (_d = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _d === void 0 ? void 0 : _d.offsetLeft; | ||
return onChange(index); | ||
} | ||
}, | ||
appearLeft: function () { | ||
this.setData({ | ||
_leftFade: false, | ||
}); | ||
}, | ||
disappearLeft: function () { | ||
this.setData({ | ||
_leftFade: true, | ||
}); | ||
}, | ||
appearRight: function () { | ||
this.setData({ | ||
_rightFade: false, | ||
}); | ||
}, | ||
disappearRight: function () { | ||
this.setData({ | ||
_rightFade: true, | ||
}); | ||
}, | ||
getRef: function () { | ||
var _this = this; | ||
return { | ||
getCompInstance: function () { return _this; }, | ||
updateHeight: function (idx) { return _this._autoHeight(idx); }, | ||
}; | ||
}, | ||
}, | ||
handleSwiperTransition: function handleSwiperTransition(e) { | ||
var onTransition = this.props.onTransition; | ||
if (typeof onTransition === "function") { | ||
onTransition(e); | ||
} | ||
ref: function () { | ||
var _this = this; | ||
var updateHeight = isForceUpdate | ||
? function () { return _this.setData({ _forceRefreshSwiper: Math.random() }); } | ||
: function (idx) { return _this._autoHeight(idx); }; | ||
return isMoreThan275 ? | ||
{ getCompInstance: function () { return _this; } } | ||
: | ||
{ getCompInstance: function () { return _this; }, updateHeight: updateHeight, | ||
}; | ||
}, | ||
appearLeft: function appearLeft() { | ||
this.setData({ | ||
_leftFade: false | ||
}); | ||
}, | ||
disappearLeft: function disappearLeft() { | ||
this.setData({ | ||
_leftFade: true | ||
}); | ||
}, | ||
appearRight: function appearRight() { | ||
this.setData({ | ||
_rightFade: false | ||
}); | ||
}, | ||
disappearRight: function disappearRight() { | ||
this.setData({ | ||
_rightFade: true | ||
}); | ||
}, | ||
getRef: function getRef() { | ||
var _this5 = this; | ||
return { | ||
getCompInstance: function getCompInstance() { | ||
return _this5; | ||
}, | ||
updateHeight: function updateHeight(idx) { | ||
return _this5._autoHeight(idx); | ||
} | ||
}; | ||
} | ||
}, | ||
ref: function ref() { | ||
var _this6 = this; | ||
var updateHeight = isForceUpdate ? function () { | ||
return _this6.setData({ | ||
_forceRefreshSwiper: Math.random() | ||
}); | ||
} : function (idx) { | ||
return _this6._autoHeight(idx); | ||
}; | ||
return isMoreThan275 ? { | ||
getCompInstance: function getCompInstance() { | ||
return _this6; | ||
} | ||
} : { | ||
getCompInstance: function getCompInstance() { | ||
return _this6; | ||
}, | ||
updateHeight: updateHeight | ||
}; | ||
} | ||
}); |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TabsDefaultProps = void 0; | ||
var TabsDefaultProps = { | ||
export const TabsDefaultProps = { | ||
type: 'basis', | ||
@@ -13,7 +7,3 @@ index: 0, | ||
sticky: false, | ||
stickyTop: 0, | ||
fallback: false, | ||
touchAngle: 45, | ||
onGetRef: function onGetRef() {} | ||
onGetRef: () => {}, | ||
}; | ||
exports.TabsDefaultProps = TabsDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
var _console = require("../../_util/console"); | ||
var _tools = require("../../_util/tools"); | ||
var _compareVersion = require("../../_util/compareVersion"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("../context"); | ||
var console_1 = require("../../_util/console"); | ||
var tools_1 = require("../../_util/tools"); | ||
var n = 0; | ||
var isBaseSwiper = (0, _compareVersion.compareVersion)(my.SDKVersion, '2.0.0'); | ||
var component2 = my.canIUse('component2'); | ||
Component({ | ||
props: _props.TabItemDefaultProps, | ||
data: { | ||
isBaseSwiper: isBaseSwiper, | ||
fallback: false | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
this._getTabInfo('didMount'); | ||
_context.componentContextFallback.onUpdate(function (v) { | ||
_this.setData({ | ||
fallback: v | ||
}); | ||
}); | ||
}, | ||
didUpdate: function didUpdate() { | ||
this._getTabInfo(); | ||
}, | ||
didUnmount: function didUnmount() { | ||
delete _context.getTabArray[this.uid]; | ||
setTimeout(function () { | ||
_context.componentContext.update((0, _tools.objectValues)(_context.getTabArray)); | ||
}, 0); | ||
}, | ||
methods: { | ||
_tabError: function _tabError(tab) { | ||
// 检测 tab-item 中的 tab 属性值正确性 | ||
if (!tab || (0, _typeof2["default"])(tab) !== 'object') { | ||
_console.log.error('TabItem', "tab \u4E2D\u5B58\u6709\u6570\u636E\u7C7B\u578B\u9519\u8BEF\uFF0C\u5E94\u4E3A object\uFF0C\u5F53\u524D\u7684 tab \u5C5E\u6027\u503C\u7C7B\u578B\u4E3A ".concat((0, _typeof2["default"])(tab), "\uFF0C\u503C\uFF1A").concat(tab)); | ||
} else if (!(tab !== null && tab !== void 0 && tab.title)) { | ||
_console.log.error('TabItem', "tab \u7684\u503C\u4E2D\u7F3A\u5C11\u5173\u952E title \u503C\uFF0C\u5F53\u524D\u7684 tab \u503C\u4E3A ".concat(JSON.stringify(tab))); | ||
} | ||
if (tab !== null && tab !== void 0 && tab.badge && typeof (tab === null || tab === void 0 ? void 0 : tab.badge) !== 'number') { | ||
_console.log.error('TabItem', "tab \u4E2D\u7684 badge \u7C7B\u578B\u4E0D\u5339\u914D\uFF0C\u5F53\u524D\u7684 badge \u503C\u4E3A ".concat(tab === null || tab === void 0 ? void 0 : tab.badge, "\uFF0C \u7C7B\u578B\u4E3A ").concat((0, _typeof2["default"])(tab === null || tab === void 0 ? void 0 : tab.badge))); | ||
} | ||
props: props_1.TabItemDefaultProps, | ||
data: { | ||
component2: component2, | ||
}, | ||
_getTabInfo: function _getTabInfo(lifeCycle) { | ||
// 获取每个 tab-item 中的 tab 值 | ||
// 如果是 didMount 时对 uid 的值做累加处理 | ||
if (lifeCycle === 'didMount') { | ||
this.uid = n++; | ||
} | ||
var tab = this.props.tab; | ||
this._tabError(tab); | ||
_context.getTabArray[this.uid] = tab; | ||
setTimeout(function () { | ||
_context.componentContext.update((0, _tools.objectValues)(_context.getTabArray)); | ||
}, 0); | ||
} | ||
} | ||
didMount: function () { | ||
this._getTabInfo('didMount'); | ||
}, | ||
didUpdate: function () { | ||
this._getTabInfo(); | ||
}, | ||
didUnmount: function () { | ||
delete context_1.getTabArray[this.uid]; | ||
setTimeout(function () { | ||
context_1.componentContext.update((0, tools_1.objectValues)(context_1.getTabArray)); | ||
}, 0); | ||
}, | ||
methods: { | ||
_tabError: function (tab) { | ||
// 检测 tab-item 中的 tab 属性值正确性 | ||
if (!tab || typeof tab !== 'object') { | ||
console_1.log.error('TabItem', "tab \u4E2D\u5B58\u6709\u6570\u636E\u7C7B\u578B\u9519\u8BEF\uFF0C\u5E94\u4E3A object\uFF0C\u5F53\u524D\u7684 tab \u5C5E\u6027\u503C\u7C7B\u578B\u4E3A ".concat(typeof tab, "\uFF0C\u503C\uFF1A").concat(tab)); | ||
} | ||
else if (!(tab === null || tab === void 0 ? void 0 : tab.title)) { | ||
console_1.log.error('TabItem', "tab \u7684\u503C\u4E2D\u7F3A\u5C11\u5173\u952E title \u503C\uFF0C\u5F53\u524D\u7684 tab \u503C\u4E3A ".concat(JSON.stringify(tab))); | ||
} | ||
if ((tab === null || tab === void 0 ? void 0 : tab.badge) && typeof (tab === null || tab === void 0 ? void 0 : tab.badge) !== 'number') { | ||
console_1.log.error('TabItem', "tab \u4E2D\u7684 badge \u7C7B\u578B\u4E0D\u5339\u914D\uFF0C\u5F53\u524D\u7684 badge \u503C\u4E3A ".concat(tab === null || tab === void 0 ? void 0 : tab.badge, "\uFF0C \u7C7B\u578B\u4E3A ").concat(typeof (tab === null || tab === void 0 ? void 0 : tab.badge))); | ||
} | ||
}, | ||
_getTabInfo: function (lifeCycle) { | ||
// 获取每个 tab-item 中的 tab 值 | ||
// 如果是 didMount 时对 uid 的值做累加处理 | ||
if (lifeCycle === 'didMount') { | ||
this.uid = n++; | ||
} | ||
var tab = this.props.tab; | ||
this._tabError(tab); | ||
context_1.getTabArray[this.uid] = tab; | ||
setTimeout(function () { | ||
context_1.componentContext.update((0, tools_1.objectValues)(context_1.getTabArray)); | ||
}, 0); | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TabItemDefaultProps = void 0; | ||
var TabItemDefaultProps = {}; | ||
exports.TabItemDefaultProps = TabItemDefaultProps; | ||
export const TabItemDefaultProps = {}; |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.TagDefaultProps | ||
props: props_1.TagDefaultProps, | ||
}); |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TagDefaultProps = void 0; | ||
var TagDefaultProps = { | ||
export const TagDefaultProps = { | ||
type: 'fill', | ||
color: 'primary' | ||
color: 'primary', | ||
}; | ||
exports.TagDefaultProps = TagDefaultProps; |
@@ -1,16 +0,14 @@ | ||
"use strict"; | ||
Component({ | ||
props: { | ||
className: '', | ||
payload: '', | ||
disabled: false | ||
}, | ||
methods: { | ||
onTap: function onTap(e) { | ||
if (typeof this.props.onTap === 'function') { | ||
this.props.onTap(e); | ||
} | ||
} | ||
} | ||
props: { | ||
className: '', | ||
payload: '', | ||
disabled: false, | ||
}, | ||
methods: { | ||
onTap: function (e) { | ||
if (typeof this.props.onTap === 'function') { | ||
this.props.onTap(e); | ||
} | ||
}, | ||
}, | ||
}); |
"use strict"; | ||
var _props = require("./props"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
Component({ | ||
props: _props.TermsDefaultProps, | ||
data: { | ||
disabled: false | ||
}, | ||
didMount: function didMount() { | ||
this.updateDisabled(false); | ||
}, | ||
methods: { | ||
updateDisabled: function updateDisabled(v) { | ||
if (this.props.hasCheckbox) { | ||
this.setData({ | ||
disabled: !v | ||
}); | ||
} | ||
props: props_1.TermsDefaultProps, | ||
data: { | ||
disabled: false, | ||
}, | ||
onChange: function onChange(v) { | ||
var _this$props = this.props, | ||
onChange = _this$props.onChange, | ||
_getCurrentField = _this$props._getCurrentField; | ||
this.updateDisabled(v); | ||
if (onChange) { | ||
if (_getCurrentField) { | ||
return onChange.call(this.props, v); | ||
} else { | ||
return onChange(v); | ||
} | ||
} | ||
didMount: function () { | ||
this.updateDisabled(false); | ||
}, | ||
onMainBtnTap: function onMainBtnTap() { | ||
if (typeof this.props.onMainBtnTap === 'function') { | ||
this.props.onMainBtnTap(); | ||
} | ||
methods: { | ||
updateDisabled: function (v) { | ||
if (this.props.hasCheckbox) { | ||
this.setData({ | ||
disabled: !v, | ||
}); | ||
} | ||
}, | ||
onChange: function (v) { | ||
var _a = this.props, onChange = _a.onChange, _getCurrentField = _a._getCurrentField; | ||
this.updateDisabled(v); | ||
if (onChange) { | ||
if (_getCurrentField) { | ||
return onChange.call(this.props, v); | ||
} | ||
else { | ||
return onChange(v); | ||
} | ||
} | ||
}, | ||
onMainBtnTap: function () { | ||
if (typeof this.props.onMainBtnTap === 'function') { | ||
this.props.onMainBtnTap(); | ||
} | ||
}, | ||
onSubBtnTap: function () { | ||
if (typeof this.props.onSubBtnTap === 'function') { | ||
this.props.onSubBtnTap(); | ||
} | ||
}, | ||
}, | ||
onSubBtnTap: function onSubBtnTap() { | ||
if (typeof this.props.onSubBtnTap === 'function') { | ||
this.props.onSubBtnTap(); | ||
} | ||
} | ||
} | ||
}); |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TermsDefaultProps = void 0; | ||
var TermsDefaultProps = { | ||
export const TermsDefaultProps = { | ||
fixed: false, | ||
hasCheckbox: true, | ||
mainButtonText: '提交' | ||
mainButtonText: '提交', | ||
}; | ||
exports.TermsDefaultProps = TermsDefaultProps; |
"use strict"; | ||
var _props = require("./props"); | ||
var _console = require("../_util/console"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var console_1 = require("../_util/console"); | ||
Component({ | ||
props: _props.TipsDefaultProps, | ||
data: { | ||
_show: true | ||
}, | ||
didMount: function didMount() { | ||
this.showError(); | ||
}, | ||
didUpdate: function didUpdate() { | ||
this.showError(); | ||
}, | ||
methods: { | ||
showError: function showError() { | ||
var title = this.props.title; | ||
if (!title) { | ||
_console.log.warn('Tips', '缺少 title 属性。'); | ||
} | ||
props: props_1.TipsDefaultProps, | ||
data: { | ||
_show: true, | ||
}, | ||
onButtonTap: function onButtonTap() { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (onButtonTap) { | ||
return onButtonTap(); | ||
} | ||
didMount: function () { | ||
this.showError(); | ||
}, | ||
onHideTips: function onHideTips(t) { | ||
this.setData({ | ||
_show: t | ||
}); | ||
} | ||
} | ||
didUpdate: function () { | ||
this.showError(); | ||
}, | ||
methods: { | ||
showError: function () { | ||
var title = this.props.title; | ||
if (!title) { | ||
console_1.log.warn('Tips', '缺少 title 属性。'); | ||
} | ||
}, | ||
onButtonTap: function () { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (onButtonTap) { | ||
return onButtonTap(); | ||
} | ||
}, | ||
onHideTips: function (t) { | ||
this.setData({ | ||
_show: t, | ||
}); | ||
}, | ||
}, | ||
}); |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TipsDefaultProps = void 0; | ||
var TipsDefaultProps = { | ||
export const TipsDefaultProps = { | ||
showClose: false, | ||
buttonPosition: 'bottom' | ||
buttonPosition: 'bottom', | ||
}; | ||
exports.TipsDefaultProps = TipsDefaultProps; |
@@ -1,20 +0,16 @@ | ||
"use strict"; | ||
Component({ | ||
methods: { | ||
onButtonTap: function onButtonTap() { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (typeof onButtonTap === 'function') { | ||
return onButtonTap(); | ||
} | ||
methods: { | ||
onButtonTap: function () { | ||
var onButtonTap = this.props.onButtonTap; | ||
if (typeof onButtonTap === 'function') { | ||
return onButtonTap(); | ||
} | ||
}, | ||
onHideTips: function () { | ||
var onHideTips = this.props.onHideTips; | ||
if (typeof onHideTips === 'function') { | ||
return onHideTips(false); | ||
} | ||
}, | ||
}, | ||
onHideTips: function onHideTips() { | ||
var onHideTips = this.props.onHideTips; | ||
if (typeof onHideTips === 'function') { | ||
return onHideTips(false); | ||
} | ||
} | ||
} | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTabArray = exports.componentContext = void 0; | ||
var _context = require("../_util/context"); | ||
var componentContext = new _context.ComponentContext(); | ||
exports.componentContext = componentContext; | ||
var getTabArray = {}; | ||
exports.getTabArray = getTabArray; | ||
var context_1 = require("../_util/context"); | ||
exports.componentContext = new context_1.ComponentContext(); | ||
exports.getTabArray = {}; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _props = require("./props"); | ||
var _context5 = require("./context"); | ||
var _tools = require("../_util/tools"); | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("./context"); | ||
var tools_1 = require("../_util/tools"); | ||
Component({ | ||
props: _props.VTabsDefaultProps, | ||
data: { | ||
tabTop: 0, | ||
_tabs: {}, | ||
_index: 0, | ||
wrapScrollTop: null, | ||
wrapScrollHeight: null | ||
}, | ||
didMount: function didMount() { | ||
var _this = this; | ||
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() { | ||
var index; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_this.isScrolling = false; | ||
_this.onlyChangeTab = false; | ||
_this.timerId = null; | ||
_context.next = 5; | ||
return _this.calcHeight(); | ||
case 5: | ||
_context5.componentContext.onUpdate(function (value) { | ||
_this.setData({ | ||
_tabs: value | ||
}); | ||
}); | ||
index = _this.props.index; | ||
_this.setData({ | ||
_tabs: (0, _tools.objectValues)(_context5.getTabArray), | ||
wrapScrollHeight: _this.scrollWrapHeight | ||
}); // 初次加载时的情况 | ||
if (_this.data._index !== index) { | ||
_this.onChange(index); | ||
_this.setData({ | ||
_index: index | ||
}); | ||
} | ||
case 9: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
props: props_1.VTabsDefaultProps, | ||
data: { | ||
tabTop: 0, | ||
_tabs: {}, | ||
_index: 0, | ||
wrapScrollTop: null, | ||
wrapScrollHeight: null, | ||
}, | ||
didMount: function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var index; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
this.isScrolling = false; | ||
this.onlyChangeTab = false; | ||
this.timerId = null; | ||
return [4 /*yield*/, this.calcHeight()]; | ||
case 1: | ||
_a.sent(); | ||
context_1.componentContext.onUpdate(function (value) { | ||
_this.setData({ | ||
_tabs: value, | ||
}); | ||
}); | ||
index = this.props.index; | ||
this.setData({ | ||
_tabs: (0, tools_1.objectValues)(context_1.getTabArray), | ||
wrapScrollHeight: this.scrollWrapHeight, | ||
}); | ||
// 初次加载时的情况 | ||
if (this.data._index !== index) { | ||
this.onChange(index); | ||
this.setData({ | ||
_index: index, | ||
}); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}, | ||
didUpdate: function (prevProps, prevData) { | ||
var index = this.props.index; | ||
var _index = this.data._index; | ||
if (prevProps.index !== index && prevData._index === _index) { | ||
this.onChange(index); | ||
} | ||
}, _callee); | ||
}))(); | ||
}, | ||
didUpdate: function didUpdate(prevProps, prevData) { | ||
var index = this.props.index; | ||
var _index = this.data._index; | ||
if (prevProps.index !== index && prevData._index === _index) { | ||
this.onChange(index); | ||
} | ||
}, | ||
didUnmount: function didUnmount() { | ||
_context5.componentContext.clearEvent(); | ||
if (this.timerId) { | ||
clearTimeout(this.timerId); | ||
this.timerId = null; | ||
} | ||
}, | ||
methods: { | ||
onWrapTouchStart: function onWrapTouchStart() { | ||
var _this2 = this; | ||
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() { | ||
return _regenerator["default"].wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
_context2.next = 2; | ||
return _this2.calcHeight(); | ||
case 2: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2); | ||
}))(); | ||
}, | ||
calcHeight: function calcHeight() { | ||
var _this3 = this; | ||
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() { | ||
var rects, prevHeight, i, height, _rects; | ||
return _regenerator["default"].wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
_this3.anchorMap = {}; | ||
_this3.indexTop = {}; | ||
_this3.indexMap = {}; | ||
_context3.next = 5; | ||
return new Promise(function (resolve) { | ||
my.createSelectorQuery().select("#amd-vtabs-content-slides-".concat(_this3.$id)).boundingClientRect().exec(function (ret) { | ||
resolve(ret[0].height); | ||
}); | ||
didUnmount: function () { | ||
context_1.componentContext.clearEvent(); | ||
if (this.timerId) { | ||
clearTimeout(this.timerId); | ||
this.timerId = null; | ||
} | ||
}, | ||
methods: { | ||
onWrapTouchStart: function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.calcHeight()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
case 5: | ||
_this3.wrapHeight = _context3.sent; | ||
_context3.next = 8; | ||
return new Promise(function (resolve) { | ||
my.createSelectorQuery().select("#amd-vtabs-content-slides-".concat(_this3.$id)).scrollOffset().exec(function (ret) { | ||
resolve(ret[0].scrollTop); | ||
}); | ||
}); | ||
}, | ||
calcHeight: function () { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _b, _c, rects, prevHeight, i, height; | ||
var _this = this; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
this.anchorMap = {}; | ||
this.indexTop = {}; | ||
this.indexMap = {}; | ||
_b = this; | ||
return [4 /*yield*/, new Promise(function (resolve) { | ||
my.createSelectorQuery() | ||
.select("#amd-vtabs-content-slides-".concat(_this.$id)) | ||
.boundingClientRect() | ||
.exec(function (ret) { | ||
resolve(ret[0].height); | ||
}); | ||
})]; | ||
case 1: | ||
_b.wrapHeight = _d.sent(); | ||
_c = this; | ||
return [4 /*yield*/, new Promise(function (resolve) { | ||
my.createSelectorQuery() | ||
.select("#amd-vtabs-content-slides-".concat(_this.$id)) | ||
.scrollOffset() | ||
.exec(function (ret) { | ||
resolve(ret[0].scrollTop); | ||
}); | ||
})]; | ||
case 2: | ||
_c.wrapTop = _d.sent(); | ||
return [4 /*yield*/, new Promise(function (resolve) { | ||
my.createSelectorQuery() | ||
.selectAll("#amd-vtabs-content-slides-".concat(_this.$id, " .amd-vtabs-item")) | ||
.boundingClientRect() | ||
.exec(function (res) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
resolve(res[0].sort(function (a, b) { return a.top - b.top; })); | ||
}); | ||
})]; | ||
case 3: | ||
rects = _d.sent(); | ||
prevHeight = 0; | ||
for (i = 0; i < rects.length; i += 1) { | ||
height = rects[i].height; | ||
this.anchorMap[i] = Math.floor(prevHeight); | ||
this.indexMap[i] = Math.floor(height); | ||
if (i === 0) { | ||
this.indexTop[0] = 0; | ||
} | ||
else { | ||
this.indexTop[i] = this.indexTop[i - 1] + ((_a = rects[i - 1]) === null || _a === void 0 ? void 0 : _a.height); | ||
} | ||
prevHeight += height; | ||
this.scrollWrapHeight = prevHeight; | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
case 8: | ||
_this3.wrapTop = _context3.sent; | ||
_context3.next = 11; | ||
return new Promise(function (resolve) { | ||
my.createSelectorQuery().selectAll("#amd-vtabs-content-slides-".concat(_this3.$id, " .amd-vtabs-item")).boundingClientRect().exec(function (res) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
resolve(res[0].sort(function (a, b) { | ||
return a.top - b.top; | ||
})); | ||
}); | ||
}); | ||
}, | ||
onChange: function (e) { | ||
var _a, _b, _c; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var index; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: return [4 /*yield*/, this.calcHeight()]; | ||
case 1: | ||
_d.sent(); | ||
if (typeof e === 'number' && !isNaN(e)) { | ||
index = e; | ||
this.setData({ | ||
_index: index, | ||
}); | ||
this.moveScrollBar(index); | ||
} | ||
else { | ||
index = (_b = (_a = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.payload; | ||
if ((_c = this.data._tabs[index]) === null || _c === void 0 ? void 0 : _c.disabled) { | ||
return [2 /*return*/]; | ||
} | ||
} | ||
if (!this.isScrolling || this.onlyChangeTab) { | ||
this.setData({ | ||
wrapScrollTop: { _v: this.indexTop[index] }, | ||
}); | ||
this.moveScrollBar(index); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
case 11: | ||
rects = _context3.sent; | ||
prevHeight = 0; | ||
for (i = 0; i < rects.length; i += 1) { | ||
height = rects[i].height; | ||
_this3.anchorMap[i] = Math.floor(prevHeight); | ||
_this3.indexMap[i] = Math.floor(height); | ||
if (i === 0) { | ||
_this3.indexTop[0] = 0; | ||
} else { | ||
_this3.indexTop[i] = _this3.indexTop[i - 1] + ((_rects = rects[i - 1]) === null || _rects === void 0 ? void 0 : _rects.height); | ||
} | ||
prevHeight += height; | ||
_this3.scrollWrapHeight = prevHeight; | ||
} | ||
case 14: | ||
case "end": | ||
return _context3.stop(); | ||
}); | ||
}, | ||
moveScrollBar: function (current) { | ||
var onChange = this.props.onChange; | ||
var tabTop; | ||
// tabTop 用来控制侧边 tab 的 scroll-view 滚动位置 | ||
if (current < 6) { | ||
tabTop = 0; | ||
} | ||
} | ||
}, _callee3); | ||
}))(); | ||
}, | ||
onChange: function onChange(e) { | ||
var _this4 = this; | ||
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() { | ||
var index, _e$currentTarget, _e$currentTarget$data, _this4$data$_tabs$ind; | ||
return _regenerator["default"].wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
_context4.next = 2; | ||
return _this4.calcHeight(); | ||
case 2: | ||
if (!(typeof e === 'number' && !isNaN(e))) { | ||
_context4.next = 8; | ||
break; | ||
else { | ||
tabTop = (current - 5) * 55; | ||
} | ||
// vtabItem 滚动时,对侧边 tab 的影响 | ||
if (this.data._index !== current) { | ||
if (onChange) { | ||
onChange(current); | ||
} | ||
index = e; | ||
_this4.setData({ | ||
_index: index | ||
this.setData({ | ||
_index: current, | ||
}); | ||
_this4.moveScrollBar(index); | ||
_context4.next = 11; | ||
break; | ||
case 8: | ||
index = e === null || e === void 0 ? void 0 : (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : (_e$currentTarget$data = _e$currentTarget.dataset) === null || _e$currentTarget$data === void 0 ? void 0 : _e$currentTarget$data.payload; | ||
if (!((_this4$data$_tabs$ind = _this4.data._tabs[index]) !== null && _this4$data$_tabs$ind !== void 0 && _this4$data$_tabs$ind.disabled)) { | ||
_context4.next = 11; | ||
break; | ||
} | ||
this.setData({ | ||
tabTop: tabTop, | ||
}); | ||
}, | ||
onScroll: function (e) { | ||
var _this = this; | ||
var scrollTop = e.detail.scrollTop; | ||
var keys = Object.keys(this.anchorMap); | ||
if (this.timerId) { | ||
clearTimeout(this.timerId); | ||
this.timerId = null; | ||
} | ||
this.timerId = setTimeout(function () { | ||
_this.isScrolling = false; | ||
}, 100); | ||
var anchorLength = keys.length; | ||
for (var i = 0; i < anchorLength; i++) { | ||
if (i === anchorLength - 1) { | ||
// 如果是最后一个只需满足 scrollTop 高于当前 vtabItem 的高度 | ||
if (scrollTop >= this.anchorMap[keys[i]]) { | ||
this.moveScrollBar(i); | ||
break; | ||
} | ||
} | ||
return _context4.abrupt("return"); | ||
case 11: | ||
if (!_this4.isScrolling || _this4.onlyChangeTab) { | ||
_this4.setData({ | ||
wrapScrollTop: { | ||
_v: _this4.indexTop[index] | ||
if (scrollTop >= this.anchorMap[keys[i]] && | ||
scrollTop < this.anchorMap[keys[i + 1]]) { | ||
// 如果每个 vtabItem 高度小于 scroll-view 高度,到达底部后就不需要根据 scrollTop 再去判断左侧的选择项 | ||
if (scrollTop + this.wrapHeight < this.scrollWrapHeight) { | ||
this.moveScrollBar(i); | ||
} | ||
}); | ||
_this4.moveScrollBar(index); | ||
break; | ||
} | ||
case 12: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4); | ||
}))(); | ||
}, | ||
onWrapTouchMove: function () { | ||
this.isScrolling = true; | ||
this.onlyChangeTab = true; | ||
}, | ||
}, | ||
moveScrollBar: function moveScrollBar(current) { | ||
var onChange = this.props.onChange; | ||
var tabTop; // tabTop 用来控制侧边 tab 的 scroll-view 滚动位置 | ||
if (current < 6) { | ||
tabTop = 0; | ||
} else { | ||
tabTop = (current - 5) * 55; | ||
} // vtabItem 滚动时,对侧边 tab 的影响 | ||
if (this.data._index !== current) { | ||
if (onChange) { | ||
onChange(current); | ||
} | ||
this.setData({ | ||
_index: current | ||
}); | ||
} | ||
this.setData({ | ||
tabTop: tabTop | ||
}); | ||
}, | ||
onScroll: function onScroll(e) { | ||
var _this5 = this; | ||
var scrollTop = e.detail.scrollTop; | ||
var keys = Object.keys(this.anchorMap); | ||
if (this.timerId) { | ||
clearTimeout(this.timerId); | ||
this.timerId = null; | ||
} | ||
this.timerId = setTimeout(function () { | ||
_this5.isScrolling = false; | ||
}, 100); | ||
var anchorLength = keys.length; | ||
for (var i = 0; i < anchorLength; i++) { | ||
if (i === anchorLength - 1) { | ||
// 如果是最后一个只需满足 scrollTop 高于当前 vtabItem 的高度 | ||
if (scrollTop >= this.anchorMap[keys[i]]) { | ||
this.moveScrollBar(i); | ||
break; | ||
} | ||
} | ||
if (scrollTop >= this.anchorMap[keys[i]] && scrollTop < this.anchorMap[keys[i + 1]]) { | ||
// 如果每个 vtabItem 高度小于 scroll-view 高度,到达底部后就不需要根据 scrollTop 再去判断左侧的选择项 | ||
if (scrollTop + this.wrapHeight < this.scrollWrapHeight) { | ||
this.moveScrollBar(i); | ||
} | ||
break; | ||
} | ||
} | ||
}, | ||
onWrapTouchMove: function onWrapTouchMove() { | ||
this.isScrolling = true; | ||
this.onlyChangeTab = true; | ||
} | ||
} | ||
}); |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.VTabsDefaultProps = void 0; | ||
var VTabsDefaultProps = { | ||
index: 0 | ||
export const VTabsDefaultProps = { | ||
index: 0, | ||
}; | ||
exports.VTabsDefaultProps = VTabsDefaultProps; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
var _console = require("../../_util/console"); | ||
var _tools = require("../../_util/tools"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("../context"); | ||
var console_1 = require("../../_util/console"); | ||
var tools_1 = require("../../_util/tools"); | ||
var component2 = my.canIUse('component2'); | ||
Component({ | ||
props: _props.VTabItemDefaultProps, | ||
data: { | ||
component2: component2 | ||
}, | ||
didMount: function didMount() { | ||
this._getTabInfo(); | ||
}, | ||
didUpdate: function didUpdate() { | ||
this._getTabInfo(); | ||
}, | ||
didUnmount: function didUnmount() { | ||
delete _context.getTabArray[this.$id]; | ||
}, | ||
methods: { | ||
_tabError: function _tabError(tab) { | ||
// 检测 tab-item 中的 tab 属性值正确性 | ||
if (!tab || (0, _typeof2["default"])(tab) !== 'object') { | ||
_console.log.error('VTabItem', "tab \u4E2D\u5B58\u6709\u6570\u636E\u7C7B\u578B\u9519\u8BEF\uFF0C\u5E94\u4E3A object\uFF0C\u5F53\u524D\u7684 tab \u5C5E\u6027\u503C\u7C7B\u578B\u4E3A ".concat((0, _typeof2["default"])(tab), "\uFF0C\u503C\uFF1A").concat(tab)); | ||
} else if (!(tab !== null && tab !== void 0 && tab.title)) { | ||
_console.log.error('VTabItem', "tab \u7684\u503C\u4E2D\u7F3A\u5C11\u5173\u952E title \u503C\uFF0C\u5F53\u524D\u7684 tab \u503C\u4E3A ".concat(JSON.stringify(tab))); | ||
} | ||
if (tab !== null && tab !== void 0 && tab.count && typeof (tab === null || tab === void 0 ? void 0 : tab.count) !== 'number') { | ||
_console.log.error('VTabItem', "tab \u4E2D\u7684 count \u7C7B\u578B\u4E0D\u5339\u914D\uFF0C\u5F53\u524D\u7684 count \u503C\u4E3A ".concat(tab === null || tab === void 0 ? void 0 : tab.count, "\uFF0C \u7C7B\u578B\u4E3A ").concat((0, _typeof2["default"])(tab === null || tab === void 0 ? void 0 : tab.count))); | ||
} | ||
props: props_1.VTabItemDefaultProps, | ||
data: { | ||
component2: component2, | ||
}, | ||
_getTabInfo: function _getTabInfo() { | ||
// 获取每个 tab-item 中的 tab 值 | ||
// 如果是 didMount 时对 uid 的值做累加处理 | ||
var tab = this.props.tab; | ||
this._tabError(tab); | ||
_context.getTabArray[this.$id] = tab; | ||
setTimeout(function () { | ||
_context.componentContext.update((0, _tools.objectValues)(_context.getTabArray)); | ||
}, 0); | ||
} | ||
} | ||
didMount: function () { | ||
this._getTabInfo(); | ||
}, | ||
didUpdate: function () { | ||
this._getTabInfo(); | ||
}, | ||
didUnmount: function () { | ||
delete context_1.getTabArray[this.$id]; | ||
}, | ||
methods: { | ||
_tabError: function (tab) { | ||
// 检测 tab-item 中的 tab 属性值正确性 | ||
if (!tab || typeof tab !== 'object') { | ||
console_1.log.error('VTabItem', "tab \u4E2D\u5B58\u6709\u6570\u636E\u7C7B\u578B\u9519\u8BEF\uFF0C\u5E94\u4E3A object\uFF0C\u5F53\u524D\u7684 tab \u5C5E\u6027\u503C\u7C7B\u578B\u4E3A ".concat(typeof tab, "\uFF0C\u503C\uFF1A").concat(tab)); | ||
} | ||
else if (!(tab === null || tab === void 0 ? void 0 : tab.title)) { | ||
console_1.log.error('VTabItem', "tab \u7684\u503C\u4E2D\u7F3A\u5C11\u5173\u952E title \u503C\uFF0C\u5F53\u524D\u7684 tab \u503C\u4E3A ".concat(JSON.stringify(tab))); | ||
} | ||
if ((tab === null || tab === void 0 ? void 0 : tab.count) && typeof (tab === null || tab === void 0 ? void 0 : tab.count) !== 'number') { | ||
console_1.log.error('VTabItem', "tab \u4E2D\u7684 count \u7C7B\u578B\u4E0D\u5339\u914D\uFF0C\u5F53\u524D\u7684 count \u503C\u4E3A ".concat(tab === null || tab === void 0 ? void 0 : tab.count, "\uFF0C \u7C7B\u578B\u4E3A ").concat(typeof (tab === null || tab === void 0 ? void 0 : tab.count))); | ||
} | ||
}, | ||
_getTabInfo: function () { | ||
// 获取每个 tab-item 中的 tab 值 | ||
// 如果是 didMount 时对 uid 的值做累加处理 | ||
var tab = this.props.tab; | ||
this._tabError(tab); | ||
context_1.getTabArray[this.$id] = tab; | ||
setTimeout(function () { | ||
context_1.componentContext.update((0, tools_1.objectValues)(context_1.getTabArray)); | ||
}, 0); | ||
}, | ||
}, | ||
}); |
@@ -1,8 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.VTabItemDefaultProps = void 0; | ||
var VTabItemDefaultProps = {}; | ||
exports.VTabItemDefaultProps = VTabItemDefaultProps; | ||
export const VTabItemDefaultProps = {}; |
{ | ||
"name": "antd-mini-rpx", | ||
"version": "0.0.4", | ||
"version": "0.0.5-alpha.1", | ||
"scripts": { | ||
@@ -37,3 +37,4 @@ "dev": "minidev dev --less --typescript --no-source-map", | ||
"async-validator": "^4.0.7", | ||
"fast-deep-equal": "3.1.3" | ||
"fast-deep-equal": "3.1.3", | ||
"tslib": "^2.3.1" | ||
}, | ||
@@ -51,2 +52,3 @@ "devDependencies": { | ||
"@babel/types": "^7.0.0", | ||
"@mini-types/alipay": "^1.0.8", | ||
"@types/acorn": "^4.0.6", | ||
@@ -62,3 +64,2 @@ "@types/babel__code-frame": "^7.0.0", | ||
"@types/marked": "^4.0.2", | ||
"@mini-types/alipay": "^1.0.8", | ||
"@typescript-eslint/eslint-plugin": "^5.6.0", | ||
@@ -89,2 +90,3 @@ "@typescript-eslint/parser": "^5.6.0", | ||
"gulp-rename": "^1.2.3", | ||
"gulp-typescript": "^6.0.0-alpha.1", | ||
"inquirer": "^8.2.1", | ||
@@ -96,2 +98,4 @@ "jest": "^27.5.1", | ||
"minidev": "^1.0.7", | ||
"monaco-editor": "^0.33.0", | ||
"monaco-editor-webpack-plugin": "^7.0.1", | ||
"path": "^0.12.7", | ||
@@ -107,2 +111,3 @@ "postcss-less": "^6.0.0", | ||
"typescript": "^4.0.0", | ||
"webpack-chain": "^6.5.1", | ||
"yorkie": "^2.0.0" | ||
@@ -109,0 +114,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
313736
4
67
276
4672
1
+ Addedtslib@^2.3.1
+ Addedtslib@2.8.1(transitive)