antd-mini
Advanced tools
Comparing version 0.0.4-beta.1 to 0.0.4
@@ -1,78 +0,104 @@ | ||
export var BaseStore = /*#__PURE__*/function () { | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
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 = {}; | ||
} | ||
var _proto = BaseStore.prototype; | ||
_proto.addItem = function addItem(uid, id, value) { | ||
this.addGroup(uid); | ||
this.setItem(uid, id, value); | ||
}; | ||
_proto.addGroup = 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() {} | ||
}; | ||
(0, _createClass2["default"])(BaseStore, [{ | ||
key: "addItem", | ||
value: function addItem(uid, id, value) { | ||
this.addGroup(uid); | ||
this.setItem(uid, id, value); | ||
} | ||
}; | ||
_proto.removeItem = function removeItem(uid, id) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items && this.getItem(uid, id)) { | ||
this.setItem(uid, id, null); | ||
}, { | ||
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() {} | ||
}; | ||
} | ||
} | ||
}; | ||
_proto.removeGroup = function removeGroup(uid) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid] = null; | ||
}, { | ||
key: "removeItem", | ||
value: function removeItem(uid, id) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items && this.getItem(uid, id)) { | ||
this.setItem(uid, id, null); | ||
} | ||
} | ||
}; | ||
_proto.updateGroupUID = function updateGroupUID(oldUID, newUID) { | ||
if (this.itemsMap[oldUID]) { | ||
this.itemsMap[newUID] = this.itemsMap[oldUID]; | ||
this.itemsMap[oldUID] = null; | ||
}, { | ||
key: "removeGroup", | ||
value: function removeGroup(uid) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid] = null; | ||
} | ||
} | ||
}; | ||
_proto.setGroupPropsVal = function setGroupPropsVal(uid, getGroupPropsVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].getGroupPropsVal = getGroupPropsVal; | ||
}, { | ||
key: "updateGroupUID", | ||
value: function updateGroupUID(oldUID, newUID) { | ||
if (this.itemsMap[oldUID]) { | ||
this.itemsMap[newUID] = this.itemsMap[oldUID]; | ||
this.itemsMap[oldUID] = null; | ||
} | ||
} | ||
}; | ||
_proto.setGroupDataVal = function setGroupDataVal(uid, _setGroupDataVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].setGroupDataVal = _setGroupDataVal; | ||
}, { | ||
key: "setGroupPropsVal", | ||
value: function setGroupPropsVal(uid, getGroupPropsVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].getGroupPropsVal = getGroupPropsVal; | ||
} | ||
} | ||
}; | ||
_proto.getGroupDataVal = function getGroupDataVal(uid, _getGroupDataVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].getGroupDataVal = _getGroupDataVal; | ||
}, { | ||
key: "setGroupDataVal", | ||
value: function setGroupDataVal(uid, _setGroupDataVal) { | ||
if (this.itemsMap[uid]) { | ||
this.itemsMap[uid].setGroupDataVal = _setGroupDataVal; | ||
} | ||
} | ||
}; | ||
_proto.getGroup = function getGroup(uid) { | ||
if (this.itemsMap[uid]) { | ||
return this.itemsMap[uid]; | ||
}, { | ||
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; | ||
}(); | ||
_proto.getItem = function getItem(uid, id) { | ||
return this.itemsMap[uid].items[id]; | ||
}; | ||
_proto.setItem = function setItem(uid, id, value) { | ||
this.itemsMap[uid].items[id] = value; | ||
}; | ||
return BaseStore; | ||
}(); | ||
exports.BaseStore = BaseStore; |
@@ -1,117 +0,164 @@ | ||
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; | ||
import { BaseStore } from './baseStore'; | ||
import { objectEntries } from './tools'; | ||
export var CheckBoxStore = /*#__PURE__*/function (_BaseStore) { | ||
_inheritsLoose(CheckBoxStore, _BaseStore); | ||
"use strict"; | ||
function CheckBoxStore() { | ||
return _BaseStore.apply(this, arguments) || this; | ||
} | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _proto = CheckBoxStore.prototype; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CheckBoxStore = void 0; | ||
_proto.checkControlledByUID = function checkControlledByUID(uid) { | ||
return this.itemsMap[uid].getGroupPropsVal('controlled'); | ||
}; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
_proto.updateGroup = function updateGroup(newUID, _ref, _ref2) { | ||
var isUIDChanged = _ref.isUIDChanged, | ||
isDisabledChanged = _ref.isDisabledChanged, | ||
isValueChange = _ref.isValueChange; | ||
var oldUID = _ref2.oldUID; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
if (isUIDChanged) { | ||
this.updateGroupUID(oldUID, newUID); | ||
} | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var group = this.getGroup(newUID); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
if (isDisabledChanged && group) { | ||
var groupDisabled = group.getGroupPropsVal('disabled'); | ||
this.updateGroupDisabled(newUID, groupDisabled); | ||
} | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
if (isValueChange) { | ||
this.updateGroupValue(newUID); | ||
} | ||
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); | ||
} | ||
/** | ||
* 修改 CheckboxGroup 的 value 以改变 CheckboxItem 的选中状态 | ||
* @param uid CheckboxGroup 与 其子 CheckboxItem 共同的 uid | ||
* @param value 外部传入的值 | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
; | ||
_proto.updateGroupValue = function updateGroupValue(uid, value) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
var groupValue = value || this.itemsMap[uid].getGroupPropsVal('value'); | ||
objectEntries(this.itemsMap[uid].items).forEach(function (_ref3) { | ||
var val = _ref3[1]; | ||
if (!val) return; | ||
(0, _createClass2["default"])(CheckBoxStore, [{ | ||
key: "checkControlledByUID", | ||
value: function checkControlledByUID(uid) { | ||
return this.itemsMap[uid].getGroupPropsVal('controlled'); | ||
} | ||
}, { | ||
key: "updateGroup", | ||
value: function updateGroup(newUID, _ref, _ref2) { | ||
var isUIDChanged = _ref.isUIDChanged, | ||
isDisabledChanged = _ref.isDisabledChanged, | ||
isValueChange = _ref.isValueChange; | ||
var oldUID = _ref2.oldUID; | ||
if (groupValue.indexOf(val.getItemPropsVal('value')) > -1) { | ||
val.setChecked(true); | ||
} else { | ||
val.setChecked(false); | ||
} | ||
}); | ||
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); | ||
} | ||
} | ||
}; | ||
/** | ||
* 修改 CheckboxGroup 的 value 以改变 CheckboxItem 的选中状态 | ||
* @param uid CheckboxGroup 与 其子 CheckboxItem 共同的 uid | ||
* @param value 外部传入的值 | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
_proto.updateGroupDisabled = function updateGroupDisabled(uid, disabled) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
objectEntries(this.itemsMap[uid].items).forEach(function (_ref4) { | ||
var val = _ref4[1]; | ||
if (!val) return; | ||
var finalDisbaled = disabled; | ||
val.setDisabled(finalDisbaled); | ||
}); | ||
}, { | ||
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]; | ||
_proto.updateItemDisabled = function updateItemDisabled(uid, disabled) { | ||
if (this.itemsMap[uid] && this.itemsMap[uid].items) { | ||
objectEntries(this.itemsMap[uid].items).forEach(function (_ref5) { | ||
var val = _ref5[1]; | ||
if (!val) return; | ||
var itemDsiabled = val; | ||
var finalDisbaled = itemDsiabled && disabled; | ||
val.setDisabled(finalDisbaled); | ||
}); | ||
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]; | ||
_proto.triggerItem = 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 = objectEntries(this.itemsMap[uid].items).filter(function (_ref6) { | ||
var val = _ref6[1]; | ||
return val && val.getChecked() === true; | ||
}).map(function (_ref7) { | ||
var val = _ref7[1]; | ||
return val.getItemPropsVal('value'); | ||
if (!val) return; | ||
var itemDsiabled = val; | ||
var finalDisbaled = itemDsiabled && disabled; | ||
val.setDisabled(finalDisbaled); | ||
}); | ||
onChange(value); | ||
} | ||
} | ||
}; | ||
}, { | ||
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'); | ||
_proto.updateItemValue = 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 (onChange) { | ||
var value = (0, _tools.objectEntries)(this.itemsMap[uid].items).filter(function (_ref9) { | ||
var _ref10 = (0, _slicedToArray2["default"])(_ref9, 2), | ||
val = _ref10[1]; | ||
if (groupValue.indexOf(itemValue) > -1) { | ||
this.getItem(uid, id).setChecked(true); | ||
} else { | ||
this.getItem(uid, id).setChecked(false); | ||
return val && val.getChecked() === true; | ||
}).map(function (_ref11) { | ||
var _ref12 = (0, _slicedToArray2["default"])(_ref11, 2), | ||
val = _ref12[1]; | ||
return val.getItemPropsVal('value'); | ||
}); | ||
onChange(value); | ||
} | ||
} | ||
} | ||
}; | ||
}, { | ||
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); | ||
} | ||
} | ||
} | ||
}]); | ||
return CheckBoxStore; | ||
}(BaseStore); | ||
}(_baseStore.BaseStore); | ||
exports.CheckBoxStore = CheckBoxStore; |
@@ -1,180 +0,227 @@ | ||
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; | ||
import { BaseStore } from './baseStore'; | ||
import { objectEntries } from '../_util/tools'; | ||
export var CollapseStore = /*#__PURE__*/function (_BaseStore) { | ||
_inheritsLoose(CollapseStore, _BaseStore); | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
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() { | ||
return _BaseStore.apply(this, arguments) || this; | ||
(0, _classCallCheck2["default"])(this, CollapseStore); | ||
return _super.apply(this, arguments); | ||
} | ||
var _proto = CollapseStore.prototype; | ||
(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]; | ||
_proto.setItemsAccordion = function setItemsAccordion(uid) { | ||
var accordion = !!this.itemsMap[uid].getGroupPropsVal('accordion'); | ||
objectEntries(this.itemsMap[uid].items).forEach(function (_ref) { | ||
var val = _ref[1]; | ||
val.setAccordion(accordion); | ||
}); | ||
}; | ||
val.setAccordion(accordion); | ||
}); | ||
} | ||
}, { | ||
key: "updateItemValue", | ||
value: function updateItemValue(uid, id) { | ||
var groupValue = this.itemsMap[uid].getGroupPropsVal('name'); | ||
_proto.updateItemValue = 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 (Array.isArray(groupValue)) { | ||
var val = this.itemsMap[uid].items[id]; | ||
var name = val.getItemPropsVal('name'); | ||
if (groupValue.includes(name)) { | ||
val.setActive(true); | ||
} | ||
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; | ||
_proto.updateGroup = function updateGroup(uid, _ref2, _ref3) { | ||
var isUIDChanged = _ref2.isUIDChanged, | ||
isNameChanged = _ref2.isNameChanged, | ||
isAccordionChanged = _ref2.isAccordionChanged; | ||
var oldUID = _ref3.oldUID; | ||
if (isUIDChanged) { | ||
this.updateGroupUID(oldUID, uid); | ||
} | ||
if (isUIDChanged) { | ||
this.updateGroupUID(oldUID, uid); | ||
} | ||
if (isNameChanged) { | ||
this.updateGroupValue(uid); | ||
} | ||
if (isNameChanged) { | ||
this.updateGroupValue(uid); | ||
} | ||
if (isAccordionChanged) { | ||
var _accordion = !!this.itemsMap[uid].getGroupPropsVal('accordion'); | ||
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]; | ||
objectEntries(this.itemsMap[uid].items).forEach(function (_ref4) { | ||
var val = _ref4[1]; | ||
val.setAccordion(_accordion); | ||
}); | ||
val.setAccordion(_accordion); | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* 修改 Collapse 的 name 以改变 CollapseItem 的展开/关闭 | ||
* @param uid Collapse 与 其子 CollapseItem 共同的 uid | ||
* @param uid didMount 首次传入值 | ||
* @param value 外部传入的值 | ||
*/ | ||
; | ||
/** | ||
* 修改 Collapse 的 name 以改变 CollapseItem 的展开/关闭 | ||
* @param uid Collapse 与 其子 CollapseItem 共同的 uid | ||
* @param uid didMount 首次传入值 | ||
* @param value 外部传入的值 | ||
*/ | ||
_proto.updateGroupValue = function updateGroupValue(uid, isFirst, value) { | ||
if (isFirst === void 0) { | ||
isFirst = false; | ||
} | ||
}, { | ||
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 (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)) { | ||
objectEntries(this.itemsMap[uid].items).forEach(function (_ref5) { | ||
var val = _ref5[1]; | ||
if (!val) return; // for 2.0 | ||
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.getSupportSjs()) { | ||
if (groupValue.indexOf(val.getItemPropsVal('name')) > -1) { | ||
val.setActive(true); | ||
} else { | ||
val.setActive(false); | ||
} | ||
if (!val) return; // for 2.0 | ||
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); | ||
if (val.getSupportSjs()) { | ||
if (groupValue.indexOf(val.getItemPropsVal('name')) > -1) { | ||
val.setActive(true); | ||
val.setFirst(); | ||
}); | ||
} else { | ||
val.setActive(false); | ||
} | ||
val.setLastAction('auto'); | ||
val.setFirst(); | ||
} else { | ||
// open -> close | ||
val.getContentHeight().then(function (height) { | ||
val.setContentHeight(height); | ||
val.setFirst(); | ||
setTimeout(function () { | ||
val.setActive(false); | ||
val.setContentHeight('0px'); | ||
}, 10); | ||
}); | ||
// 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(); | ||
}); | ||
} 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'); | ||
}); | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (typeof onChange === 'function' && !isFirst) { | ||
onChange(groupValue); | ||
} | ||
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]; | ||
_proto.triggerItem = function triggerItem(uid, id, status) { | ||
if (this.itemsMap[uid] && this.getItem(uid, id)) { | ||
if (this.itemsMap[uid].getGroupPropsVal('accordion') === true) { | ||
var name; | ||
objectEntries(this.itemsMap[uid].items).forEach(function (_ref6) { | ||
var val = _ref6[1]; | ||
if (!val) return; | ||
if (!val) return; | ||
if (val.getId() === id) { | ||
var active = val.getActive(); | ||
val.setActive(!active); | ||
if (val.getId() === id) { | ||
var active = val.getActive(); | ||
val.setActive(!active); | ||
if (!active) { | ||
name = val.getItemPropsVal('name'); | ||
if (!active) { | ||
name = val.getItemPropsVal('name'); | ||
} | ||
} else { | ||
val.setActive(false); | ||
} | ||
} else { | ||
val.setActive(false); | ||
val.setLastAction('onTap'); | ||
val.setFirst(); | ||
}); | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (typeof onChange === 'function') { | ||
var res = name ? [name] : []; | ||
onChange(res); | ||
} | ||
val.setLastAction('onTap'); | ||
val.setFirst(); | ||
}); | ||
var onChange = this.itemsMap[uid].getGroupPropsVal('onChange'); | ||
if (typeof onChange === 'function') { | ||
var res = name ? [name] : []; | ||
onChange(res); | ||
return; | ||
} | ||
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'); | ||
_proto.onChangeByTrigger = 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]; | ||
if (typeof onChange === 'function') { | ||
var value = objectEntries(this.itemsMap[uid].items).filter(function (_ref7) { | ||
var val = _ref7[1]; | ||
return val && val.getActive() === true; | ||
}).map(function (_ref8) { | ||
var val = _ref8[1]; | ||
return val.getItemPropsVal('name'); | ||
}); | ||
onChange(value); | ||
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); | ||
return CollapseStore; | ||
}(BaseStore); | ||
exports.CollapseStore = CollapseStore; |
@@ -0,3 +1,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.compareAntdMiniVersion = compareAntdMiniVersion; | ||
exports.compareVersion = compareVersion; | ||
exports.getCurrentVersion = getCurrentVersion; | ||
exports.isMoreThan106 = void 0; | ||
/* eslint-disable no-console */ | ||
export function compareVersion(v1, v2) { | ||
function compareVersion(v1, v2) { | ||
if (v1 === v2) return 0; | ||
@@ -20,4 +30,6 @@ var v1Arr = v1.split('.'); | ||
} | ||
var currentVersion; | ||
export function getCurrentVersion() { | ||
function getCurrentVersion() { | ||
if (typeof currentVersion === 'string') return currentVersion; | ||
@@ -41,5 +53,8 @@ | ||
export function compareAntdMiniVersion(version) { | ||
function compareAntdMiniVersion(version) { | ||
return compareVersion(getCurrentVersion(), version) > 0; | ||
} | ||
export var isMoreThan106 = compareAntdMiniVersion('1.0.6'); | ||
var isMoreThan106 = compareAntdMiniVersion('1.0.6'); | ||
exports.isMoreThan106 = isMoreThan106; |
@@ -0,3 +1,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.log = exports.EComponents = void 0; | ||
// eslint-disable-next-line no-shadow | ||
export var EComponents; | ||
var EComponents; | ||
exports.EComponents = EComponents; | ||
@@ -67,7 +74,7 @@ (function (EComponents) { | ||
EComponents["WhiteSpace"] = "WhiteSpace"; | ||
})(EComponents || (EComponents = {})); | ||
})(EComponents || (exports.EComponents = EComponents = {})); | ||
export var log = { | ||
var log = { | ||
warn: function warn(component, message) { | ||
var info = "[antd-mini: " + component + "] \uD83D\uDCE1 " + message; // eslint-disable-next-line no-console | ||
var info = "[antd-mini: ".concat(component, "] \uD83D\uDCE1 ").concat(message); // eslint-disable-next-line no-console | ||
@@ -77,6 +84,7 @@ console.warn(info); | ||
error: function error(component, message) { | ||
var info = "[antd-mini: " + component + "] \uD83D\uDCE1 " + message; // eslint-disable-next-line no-console | ||
var info = "[antd-mini: ".concat(component, "] \uD83D\uDCE1 ").concat(message); // eslint-disable-next-line no-console | ||
console.error(info); | ||
} | ||
}; | ||
}; | ||
exports.log = log; |
@@ -1,88 +0,119 @@ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export var ComponentContext = /*#__PURE__*/function () { | ||
function ComponentContext() { | ||
this.fns = []; | ||
} | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _proto = ComponentContext.prototype; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Context = exports.ComponentContext = void 0; | ||
_proto.get = function get() { | ||
return this.value; | ||
}; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
_proto.update = function update(value) { | ||
var _this$fns; | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
this.value = value; | ||
(_this$fns = this.fns) == null ? void 0 : _this$fns.forEach(function (fn) { | ||
fn(value); | ||
}); | ||
}; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
_proto.onUpdate = function onUpdate(fn) { | ||
this.fns.push(fn); | ||
}; | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
_proto.clearEvent = function clearEvent() { | ||
this.fns = []; | ||
}; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
var ComponentContext = /*#__PURE__*/function () { | ||
function ComponentContext() { | ||
(0, _classCallCheck2["default"])(this, ComponentContext); | ||
(0, _defineProperty2["default"])(this, "fns", []); | ||
} | ||
_proto.offUpdate = function offUpdate(fn) { | ||
this.fns = this.fns.filter(function (item) { | ||
return item !== fn; | ||
}); | ||
}; | ||
(0, _createClass2["default"])(ComponentContext, [{ | ||
key: "get", | ||
value: function get() { | ||
return this.value; | ||
} | ||
}, { | ||
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; | ||
}(); | ||
export var Context = /*#__PURE__*/function () { | ||
exports.ComponentContext = ComponentContext; | ||
var Context = /*#__PURE__*/function () { | ||
function Context() { | ||
this._values = {}; | ||
this._fns = {}; | ||
(0, _classCallCheck2["default"])(this, Context); | ||
(0, _defineProperty2["default"])(this, "_values", {}); | ||
(0, _defineProperty2["default"])(this, "_fns", {}); | ||
} | ||
var _proto2 = Context.prototype; | ||
(0, _createClass2["default"])(Context, [{ | ||
key: "get", | ||
value: function get(uid) { | ||
var _this$_values$uid; | ||
_proto2.get = function get(uid) { | ||
var _this$_values$uid; | ||
return (_this$_values$uid = this._values[uid]) != null ? _this$_values$uid : null; | ||
}; | ||
_proto2.update = function update(uid, value) { | ||
var _this$_fns$uid; | ||
this._values[uid] = value; | ||
(_this$_fns$uid = this._fns[uid]) == null ? void 0 : _this$_fns$uid.forEach(function (fn) { | ||
fn(value); | ||
}); | ||
}; | ||
_proto2.updateValue = function updateValue(uid, value) { | ||
this._values[uid] = value; | ||
}; | ||
_proto2.onUpdate = function onUpdate(uid, fn) { | ||
if (!this._fns[uid]) { | ||
this._fns[uid] = []; | ||
return (_this$_values$uid = this._values[uid]) !== null && _this$_values$uid !== void 0 ? _this$_values$uid : null; | ||
} | ||
}, { | ||
key: "update", | ||
value: function update(uid, value) { | ||
var _this$_fns$uid; | ||
this._fns[uid].push(fn); | ||
}; | ||
_proto2.clearEvent = function clearEvent(uid) { | ||
delete this._fns[uid]; | ||
}; | ||
_proto2.offUpdate = function offUpdate(uid, fn) { | ||
if (this._fns[uid]) { | ||
this._fns[uid] = this._fns[uid].filter(function (item) { | ||
return item !== fn; | ||
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; | ||
}); | ||
} | ||
} | ||
}]); | ||
return Context; | ||
}(); | ||
}(); | ||
exports.Context = Context; |
@@ -1,9 +0,23 @@ | ||
import dayjs from 'dayjs'; | ||
import isBetween from 'dayjs/plugin/isBetween'; | ||
dayjs.extend(isBetween); | ||
export function isBetweenDate(currentDate, startDate, endDate) { | ||
return dayjs(currentDate).isBetween(startDate, endDate); | ||
"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"]); | ||
function isBetweenDate(currentDate, startDate, endDate) { | ||
return (0, _dayjs["default"])(currentDate).isBetween(startDate, endDate); | ||
} | ||
export function isSameDate(currentDate, targetDate) { | ||
return dayjs(currentDate).isSame(targetDate); | ||
function isSameDate(currentDate, targetDate) { | ||
return (0, _dayjs["default"])(currentDate).isSame(targetDate); | ||
} |
@@ -1,41 +0,73 @@ | ||
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; | ||
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { BaseStore } from './baseStore'; | ||
import { objectEntries } from '../_util/tools'; | ||
export var FilterStore = /*#__PURE__*/function (_BaseStore) { | ||
_inheritsLoose(FilterStore, _BaseStore); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
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() { | ||
return _BaseStore.apply(this, arguments) || this; | ||
(0, _classCallCheck2["default"])(this, FilterStore); | ||
return _super.apply(this, arguments); | ||
} | ||
var _proto = FilterStore.prototype; | ||
(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; | ||
_proto.updateItemValue = 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() || []); | ||
setValue(getValue() || []); | ||
} | ||
} | ||
}; | ||
}, { | ||
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 | ||
_proto.updateGroupValue = function updateGroupValue(uid) { | ||
if (this.itemsMap[uid]) { | ||
var placeHolderArray = 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 | ||
}); | ||
prev[val.getid()] = val.getPlaceHolder(); | ||
return prev; | ||
}, {}); | ||
this.itemsMap[uid].setGroupDataVal({ | ||
key: 'placeHolderArray', | ||
val: placeHolderArray | ||
}); | ||
} | ||
} | ||
}; | ||
}]); | ||
return FilterStore; | ||
}(_baseStore.BaseStore); | ||
return FilterStore; | ||
}(BaseStore); | ||
exports.FilterStore = FilterStore; |
@@ -0,1 +1,12 @@ | ||
"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")); | ||
var hasOwn = {}.hasOwnProperty; | ||
@@ -5,3 +16,3 @@ /* eslint-disable no-continue, prefer-spread */ | ||
export default function fmtClass() { | ||
function fmtClass() { | ||
var classes = []; | ||
@@ -12,3 +23,3 @@ | ||
if (!arg) continue; | ||
var argType = typeof arg; | ||
var argType = (0, _typeof2["default"])(arg); | ||
@@ -15,0 +26,0 @@ if (argType === 'string' || argType === 'number') { |
@@ -0,3 +1,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = fmtEvent; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export default function fmtEvent(props, e) { | ||
function fmtEvent(props, e) { | ||
var dataset = {}; | ||
@@ -4,0 +11,0 @@ |
@@ -0,5 +1,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = fmtUnit; | ||
exports.fmtUnitNumber = void 0; | ||
var jsUnitRpx = 'false'; | ||
/* eslint-disable no-continue, prefer-spread */ | ||
export default function fmtUnit(oldUnit) { | ||
function fmtUnit(oldUnit) { | ||
var getUnit = oldUnit; | ||
@@ -11,3 +18,3 @@ | ||
} else if (typeof getUnit === 'string') { | ||
getUnit = parseInt(oldUnit.match(/(\d+|\d+\.\d+)(px)/)[1], 10) * 2 + "rpx"; | ||
getUnit = "".concat(parseInt(oldUnit.match(/(\d+|\d+\.\d+)(px)/)[1], 10) * 2, "rpx"); | ||
} | ||
@@ -18,3 +25,4 @@ } | ||
} | ||
export var fmtUnitNumber = function fmtUnitNumber(oldUnit) { | ||
var fmtUnitNumber = function fmtUnitNumber(oldUnit) { | ||
var getUnitNumber = oldUnit; | ||
@@ -27,2 +35,4 @@ | ||
return getUnitNumber; | ||
}; | ||
}; | ||
exports.fmtUnitNumber = fmtUnitNumber; |
@@ -1,11 +0,31 @@ | ||
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; | ||
import _extends from "@babel/runtime/helpers/extends"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
"use strict"; | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import Schema from 'async-validator'; | ||
export var Store = /*#__PURE__*/function () { | ||
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 = {}; | ||
@@ -17,329 +37,346 @@ this.formTree = {}; | ||
var _proto = Store.prototype; | ||
(0, _createClass2["default"])(Store, [{ | ||
key: "init", | ||
value: function init(form, initVal, onValuesChange, onFinish) { | ||
var _this = this; | ||
_proto.init = 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] = {}; | ||
} | ||
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]; | ||
} | ||
if (!_this.formTree[form][field]) { | ||
_this.formTree[form][field] = {}; | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
} | ||
_this.formTree[form][field].value = initVal[field]; | ||
}); | ||
if (!this.events[form]) { | ||
this.events[form] = [onValuesChange, onFinish]; | ||
setTimeout(function () { | ||
_this.initValidator(form); | ||
}, 0); | ||
} | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
}, { | ||
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] = {}; | ||
} | ||
setTimeout(function () { | ||
_this.initValidator(form); | ||
}, 0); | ||
}; | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
} | ||
_proto.getInitValByField = function getInitValByField(form, field) { | ||
return this.formTree[form][field].value; | ||
}; | ||
if (!this.formTree[form][field]) { | ||
this.formTree[form][field] = {}; | ||
} | ||
_proto.bootstrap = function bootstrap(form, field, rules, initialValue, required) { | ||
if (!this.formTree[form]) { | ||
this.formTree[form] = {}; | ||
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] = []; | ||
} | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
this.currentField[form].push(field); | ||
this.initValidator(form); | ||
} | ||
if (!this.formTree[form][field]) { | ||
this.formTree[form][field] = {}; | ||
}, { | ||
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; | ||
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; | ||
}; | ||
if (Array.isArray(updateFiledValueArr)) { | ||
updateFiledValueArr.push(updateFieldValue); | ||
} else { | ||
this.formTree[form][field].updateFieldValue = [updateFieldValue]; | ||
} | ||
} | ||
} // TODO update 数组--->需要解耦 | ||
_proto.addFieldSet = function addFieldSet(form, field) { | ||
if (!this.currentField[form]) { | ||
this.currentField[form] = []; | ||
}, { | ||
key: "setValueAfterUpdate", | ||
value: function setValueAfterUpdate(setData, form, next) { | ||
var val = this.formTree[form][next].value || ''; | ||
setData({ | ||
cValue: val | ||
}); | ||
} | ||
this.currentField[form].push(field); | ||
this.initValidator(form); | ||
}; | ||
_proto.updateFieldSet = 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); | ||
}; | ||
_proto.addUpdateFiledValue = 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]; | ||
} | ||
}, { | ||
key: "setFieldUpdateInfoFn", | ||
value: function setFieldUpdateInfoFn(form, field, fn) { | ||
this.formTree[form][field].updateErrorInfo = fn; | ||
} | ||
} // TODO update 数组--->需要解耦 | ||
; | ||
_proto.setValueAfterUpdate = function setValueAfterUpdate(setData, form, next) { | ||
var val = this.formTree[form][next].value || ''; | ||
setData({ | ||
cValue: val | ||
}); | ||
}; | ||
_proto.setFieldUpdateInfoFn = function setFieldUpdateInfoFn(form, field, fn) { | ||
this.formTree[form][field].updateErrorInfo = fn; | ||
}; | ||
_proto.setUpdateSubmitButtonStatusFn = function setUpdateSubmitButtonStatusFn(form, field, fn) { | ||
this.formTree[form][field].updateSubmitButtonStatus = fn; | ||
}; | ||
_proto.delFieldSet = 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; | ||
}, { | ||
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); | ||
this.initValidator(form); | ||
}; | ||
_proto.getTotalValue = 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; | ||
if (this.formTree[form] && this.formTree[form][field]) { | ||
this.formTree[form][field] = null; | ||
} | ||
return prev; | ||
}, {}); | ||
}; | ||
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; | ||
} | ||
_proto.getFields = 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]; | ||
} | ||
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]; | ||
} | ||
return prev; | ||
}, {}); | ||
}; | ||
return prev; | ||
}, {}); | ||
} | ||
}, { | ||
key: "trigger", | ||
value: function trigger(form, field, val) { | ||
var _this2 = this; | ||
_proto.trigger = function trigger(form, field, val) { | ||
var _extends2, | ||
_this2 = this, | ||
_handlers; | ||
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; | ||
this.formTree[form][field].value = val; | ||
var handlers = this.events[form][0]; | ||
var values = this.getTotalValue(form); | ||
this.formTree[form].validator.validate(_extends({}, values, (_extends2 = {}, _extends2[field] = val, _extends2)), 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; | ||
var updateErrorInfo = (_this2$formTree$form$ = _this2.formTree[form][field]) == null ? void 0 : _this2$formTree$form$.updateErrorInfo; | ||
var updateSubmitButtonStatus = (_this2$formTree$form$2 = _this2.formTree[form].submit) == null ? 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; | ||
} | ||
if (!errors) { | ||
updateErrorInfo == null ? void 0 : updateErrorInfo(null); | ||
updateSubmitButtonStatus == null ? void 0 : updateSubmitButtonStatus(null); | ||
return; | ||
} | ||
var error = errors.filter(function (item) { | ||
return item.field === field; | ||
})[0]; | ||
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 (error) { | ||
updateErrorInfo == null ? void 0 : updateErrorInfo(_extends({}, error)); | ||
} else { | ||
updateErrorInfo == null ? void 0 : updateErrorInfo(null); | ||
} | ||
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; | ||
updateSubmitButtonStatus == null ? void 0 : updateSubmitButtonStatus(!!errors.length); | ||
}); | ||
var totalVal = this.getTotalValue(form); | ||
handlers((_handlers = {}, _handlers[field] = val, _handlers), totalVal); | ||
}; | ||
return new Promise(function (resolve) { | ||
var values = _this3.getTotalValue(form); | ||
_proto.validateAll = function validateAll(form) { | ||
var _this3 = this; | ||
_this3.formTree[form].validator.validate(values, function (errors) { | ||
var _this3$formTree$form$3; | ||
return new Promise(function (resolve) { | ||
var values = _this3.getTotalValue(form); | ||
if (!errors) { | ||
return resolve(true); | ||
} | ||
_this3.formTree[form].validator.validate(values, function (errors) { | ||
var _this3$formTree$form$3; | ||
var errFields = errors.reduce(function (prev, cur) { | ||
prev[cur.field] = cur; | ||
return prev; | ||
}, {}); | ||
if (!errors) { | ||
return resolve(true); | ||
} | ||
var fields = _this3.getFields(form); | ||
var errFields = errors.reduce(function (prev, cur) { | ||
prev[cur.field] = cur; | ||
return prev; | ||
}, {}); | ||
if (!fields) return; | ||
Object.keys(fields).forEach(function (field) { | ||
if (!errFields[field]) { | ||
var _this3$formTree$form$; | ||
var fields = _this3.getFields(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; | ||
if (!fields) return; | ||
Object.keys(fields).forEach(function (field) { | ||
if (!errFields[field]) { | ||
var _this3$formTree$form$; | ||
(_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])); | ||
} | ||
}); | ||
var updateSubmitButtonStatus = (_this3$formTree$form$3 = _this3.formTree[form].submit) === null || _this3$formTree$form$3 === void 0 ? void 0 : _this3$formTree$form$3.updateSubmitButtonStatus; | ||
(_this3$formTree$form$ = _this3.formTree[form][field]) == null ? void 0 : _this3$formTree$form$.updateErrorInfo(null); | ||
} else { | ||
var _this3$formTree$form$2; | ||
if (errors.length) { | ||
// errors.forEach(err => { | ||
// this.formTree[form][err.field]?.updateErrorInfo({ ...err }); | ||
// }); | ||
my.alert({ | ||
title: errors[0].message | ||
}); | ||
} | ||
(_this3$formTree$form$2 = _this3.formTree[form][field]) == null ? void 0 : _this3$formTree$form$2.updateErrorInfo(_extends({}, errFields[field])); | ||
} | ||
updateSubmitButtonStatus === null || updateSubmitButtonStatus === void 0 ? void 0 : updateSubmitButtonStatus(!!errors.length); | ||
resolve(!errors.length); | ||
}); | ||
var updateSubmitButtonStatus = (_this3$formTree$form$3 = _this3.formTree[form].submit) == null ? void 0 : _this3$formTree$form$3.updateSubmitButtonStatus; | ||
}); | ||
} | ||
}, { | ||
key: "setFieldsValue", | ||
value: function setFieldsValue(form, value) { | ||
var _this4 = this; | ||
if (errors.length) { | ||
// errors.forEach(err => { | ||
// this.formTree[form][err.field]?.updateErrorInfo({ ...err }); | ||
// }); | ||
my.alert({ | ||
title: errors[0].message | ||
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]); | ||
} | ||
}); | ||
} | ||
updateSubmitButtonStatus == null ? void 0 : updateSubmitButtonStatus(!!errors.length); | ||
resolve(!errors.length); | ||
}); | ||
}); | ||
}; | ||
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; | ||
} | ||
_proto.setFieldsValue = function setFieldsValue(form, value) { | ||
var _this4 = this; | ||
return _context.abrupt("return"); | ||
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; | ||
case 2: | ||
_context.next = 4; | ||
return this.validateAll(form()); | ||
_this4.formTree[form][key].updateFieldValue.forEach(function (fn) { | ||
if (typeof fn === 'function') { | ||
_this4.formTree[form][key].value = value[key]; | ||
fn(value[key]); | ||
} | ||
}); | ||
} | ||
}); | ||
this.validateAll(form); | ||
}; | ||
case 4: | ||
success = _context.sent; | ||
_proto.onFinish = /*#__PURE__*/function () { | ||
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(form) { | ||
var success; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (form) { | ||
_context.next = 2; | ||
break; | ||
} | ||
if (success) { | ||
_context.next = 7; | ||
break; | ||
} | ||
return _context.abrupt("return"); | ||
return _context.abrupt("return"); | ||
case 2: | ||
_context.next = 4; | ||
return this.validateAll(form()); | ||
case 7: | ||
this.events[form()][1](this.getTotalValue(form())); | ||
case 4: | ||
success = _context.sent; | ||
case 8: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
if (success) { | ||
_context.next = 7; | ||
break; | ||
} | ||
function onFinish(_x) { | ||
return _onFinish.apply(this, arguments); | ||
} | ||
return _context.abrupt("return"); | ||
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; | ||
case 7: | ||
this.events[form()][1](this.getTotalValue(form())); | ||
if (Array.isArray(rules)) { | ||
descriptor[field] = (0, _toConsumableArray2["default"])(rules); | ||
} | ||
case 8: | ||
case "end": | ||
return _context.stop(); | ||
if (required) { | ||
var requiredItem = { | ||
required: required, | ||
message: label ? "\u8BF7\u8F93\u5165".concat(label) : '请输入必填项' | ||
}; | ||
if (descriptor[field]) { | ||
descriptor[field].unshift(requiredItem); | ||
} else { | ||
descriptor[field] = [requiredItem]; | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
function onFinish(_x) { | ||
return _onFinish.apply(this, arguments); | ||
}); | ||
this.formTree[form].validator = new _asyncValidator["default"](descriptor); | ||
} | ||
}]); | ||
return Store; | ||
}(); | ||
return onFinish; | ||
}(); | ||
_proto.tear = function tear(formName) { | ||
this.formTree[formName] = null; | ||
this.events[formName] = null; | ||
}; | ||
_proto.initValidator = 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] = [].concat(rules); | ||
} | ||
if (required) { | ||
var requiredItem = { | ||
required: required, | ||
message: label ? "\u8BF7\u8F93\u5165" + label : '请输入必填项' | ||
}; | ||
if (descriptor[field]) { | ||
descriptor[field].unshift(requiredItem); | ||
} else { | ||
descriptor[field] = [requiredItem]; | ||
} | ||
} | ||
}); | ||
this.formTree[form].validator = new Schema(descriptor); | ||
}; | ||
return Store; | ||
}(); | ||
exports.Store = Store; |
@@ -1,32 +0,68 @@ | ||
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; | ||
import { BaseStore } from './baseStore'; | ||
import { objectEntries } from './tools'; | ||
export var StepsStore = /*#__PURE__*/function (_BaseStore) { | ||
_inheritsLoose(StepsStore, _BaseStore); | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
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() { | ||
return _BaseStore.apply(this, arguments) || this; | ||
(0, _classCallCheck2["default"])(this, StepsStore); | ||
return _super.apply(this, arguments); | ||
} | ||
var _proto = StepsStore.prototype; | ||
(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]; | ||
_proto.updateItemIndex = function updateItemIndex(uid, index) { | ||
if (this.itemsMap[uid]) { | ||
objectEntries(this.itemsMap[uid].items).forEach(function (_ref) { | ||
var val = _ref[1]; | ||
val.setItemIndex(index); | ||
}); | ||
val.setItemIndex(index); | ||
}); | ||
} | ||
} | ||
}; | ||
}, { | ||
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]; | ||
_proto.updateItemDirection = function updateItemDirection(uid, direction) { | ||
if (this.itemsMap[uid]) { | ||
objectEntries(this.itemsMap[uid].items).forEach(function (_ref2) { | ||
var val = _ref2[1]; | ||
val.setItemDirection(direction); | ||
}); | ||
val.setItemDirection(direction); | ||
}); | ||
} | ||
} | ||
}; | ||
}]); | ||
return StepsStore; | ||
}(_baseStore.BaseStore); | ||
return StepsStore; | ||
}(BaseStore); | ||
exports.StepsStore = StepsStore; |
@@ -1,2 +0,10 @@ | ||
export function objectValues(obj) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.objectEntries = objectEntries; | ||
exports.objectValues = objectValues; | ||
function objectValues(obj) { | ||
if (obj !== Object(obj)) throw new TypeError('Object.values called on a non-object'); | ||
@@ -14,3 +22,4 @@ var val = []; | ||
} | ||
export function objectEntries(obj) { | ||
function objectEntries(obj) { | ||
var ownProps = Object.keys(obj); | ||
@@ -17,0 +26,0 @@ var i = ownProps.length; |
@@ -1,4 +0,7 @@ | ||
import { AvatarDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
Component({ | ||
props: AvatarDefaultProps | ||
props: _props.AvatarDefaultProps | ||
}); |
@@ -1,4 +0,11 @@ | ||
export const AvatarDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.AvatarDefaultProps = void 0; | ||
var 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; |
@@ -1,6 +0,12 @@ | ||
import { BadgeDefaultProps } from './props'; | ||
import computed from '../mixins/computed'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _computed = _interopRequireDefault(require("../mixins/computed")); | ||
Component({ | ||
mixins: [computed], | ||
props: BadgeDefaultProps, | ||
mixins: [_computed["default"]], | ||
props: _props.BadgeDefaultProps, | ||
methods: { | ||
@@ -7,0 +13,0 @@ computed: function computed(props) { |
@@ -1,6 +0,13 @@ | ||
export const BadgeDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.BadgeDefaultProps = void 0; | ||
var BadgeDefaultProps = { | ||
placement: 'top-right', | ||
stroke: false, | ||
type: 'dot', | ||
bgColor: '#FF411C', | ||
bgColor: '#FF411C' | ||
}; | ||
exports.BadgeDefaultProps = BadgeDefaultProps; |
@@ -1,7 +0,14 @@ | ||
import { ButtonDefaultProps } from './props'; | ||
import fmtEvent from '../_util/fmtEvent'; | ||
import htmlType from '../mixins/htmlType'; | ||
"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")); | ||
Component({ | ||
props: ButtonDefaultProps, | ||
mixins: [htmlType()], | ||
props: _props.ButtonDefaultProps, | ||
mixins: [(0, _htmlType["default"])()], | ||
methods: { | ||
@@ -20,3 +27,3 @@ onTap: function onTap(e) { | ||
if (onTap && !disabled && !loading) { | ||
var event = fmtEvent(this.props, e); | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onTap(event); | ||
@@ -23,0 +30,0 @@ } |
@@ -1,2 +0,8 @@ | ||
export const ButtonDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ButtonDefaultProps = void 0; | ||
var ButtonDefaultProps = { | ||
type: 'default', | ||
@@ -9,3 +15,4 @@ disabled: false, | ||
_submit: undefined, | ||
fill: 'solid', | ||
fill: 'solid' | ||
}; | ||
exports.ButtonDefaultProps = ButtonDefaultProps; |
@@ -1,7 +0,14 @@ | ||
import { CheckboxDefaultProps } from './props'; | ||
import controlled from '../mixins/controlled'; | ||
import formMixin from '../mixins/form'; | ||
"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")); | ||
Component({ | ||
props: CheckboxDefaultProps, | ||
mixins: [controlled('checked'), formMixin()], | ||
props: _props.CheckboxDefaultProps, | ||
mixins: [(0, _controlled["default"])('checked'), (0, _form["default"])()], | ||
methods: { | ||
@@ -8,0 +15,0 @@ onChange: function onChange(v) { |
@@ -1,3 +0,10 @@ | ||
export const CheckboxDefaultProps = { | ||
disabled: false, | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CheckboxDefaultProps = void 0; | ||
var CheckboxDefaultProps = { | ||
disabled: false | ||
}; | ||
exports.CheckboxDefaultProps = CheckboxDefaultProps; |
@@ -1,5 +0,9 @@ | ||
import { CheckboxItemDefaultProps } from './props'; | ||
import { store } from '../context'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
Component({ | ||
props: CheckboxItemDefaultProps, | ||
props: _props.CheckboxItemDefaultProps, | ||
data: { | ||
@@ -34,3 +38,3 @@ _checked: false, | ||
store.addItem(uid, "" + this.$id, { | ||
_context.store.addItem(uid, "".concat(this.$id), { | ||
setDisabled: setDisabled, | ||
@@ -42,4 +46,6 @@ getChecked: getChecked, | ||
try { | ||
store.updateItemValue(uid, "" + this.$id); // eslint-disable-next-line no-empty | ||
_context.store.updateItemValue(uid, "".concat(this.$id)); // eslint-disable-next-line no-empty | ||
} catch (err) {} | ||
@@ -55,3 +61,3 @@ }, | ||
// 考虑到a:for的情况 | ||
store.updateItemValue(uid, "" + this.$id); | ||
_context.store.updateItemValue(uid, "".concat(this.$id)); | ||
} | ||
@@ -61,3 +67,4 @@ }, | ||
var uid = this.props.uid; | ||
store.removeItem(uid, "" + this.$id); | ||
_context.store.removeItem(uid, "".concat(this.$id)); | ||
}, | ||
@@ -67,6 +74,7 @@ methods: { | ||
var uid = this.props.uid; | ||
if (store.checkControlledByUID(uid)) return; | ||
store.triggerItem(uid, "" + this.$id, value); | ||
if (_context.store.checkControlledByUID(uid)) return; | ||
_context.store.triggerItem(uid, "".concat(this.$id), value); | ||
} | ||
} | ||
}); |
@@ -1,4 +0,11 @@ | ||
export const CheckboxItemDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CheckboxItemDefaultProps = void 0; | ||
var CheckboxItemDefaultProps = { | ||
disabled: false, | ||
uid: 'CheckboxGroup', | ||
uid: 'CheckboxGroup' | ||
}; | ||
exports.CheckboxItemDefaultProps = CheckboxItemDefaultProps; |
@@ -1,2 +0,11 @@ | ||
import { CheckBoxStore } from '../_util/checkboxStore'; | ||
export var store = new CheckBoxStore(); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.store = void 0; | ||
var _checkboxStore = require("../_util/checkboxStore"); | ||
var store = new _checkboxStore.CheckBoxStore(); | ||
exports.store = store; |
@@ -1,8 +0,16 @@ | ||
import { CheckboxGroupDefaultProps } from './props'; | ||
import equal from 'fast-deep-equal'; | ||
import { store } from './context'; | ||
import formMixin from '../mixins/form'; | ||
"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")); | ||
Component({ | ||
props: CheckboxGroupDefaultProps, | ||
mixins: [formMixin()], | ||
props: _props.CheckboxGroupDefaultProps, | ||
mixins: [(0, _form["default"])()], | ||
didMount: function didMount() { | ||
@@ -36,6 +44,6 @@ var _this = this; | ||
store.setGroupPropsVal(this.props.uid, getGroupPropsVal); | ||
_context.store.setGroupPropsVal(this.props.uid, getGroupPropsVal); | ||
if (Array.isArray(value) && value.length > 0) { | ||
store.updateGroupValue(uid); | ||
_context.store.updateGroupValue(uid); | ||
} | ||
@@ -51,6 +59,7 @@ }, | ||
oldValue = prevProps.value; | ||
store.updateGroup(newUID, { | ||
_context.store.updateGroup(newUID, { | ||
isUIDChanged: newUID !== oldUID, | ||
isDisabledChanged: newDisabled !== oldDisabled, | ||
isValueChange: !equal(newValue, oldValue) | ||
isValueChange: !(0, _fastDeepEqual["default"])(newValue, oldValue) | ||
}, { | ||
@@ -62,3 +71,4 @@ oldUID: oldUID | ||
var uid = this.props.uid; | ||
store.removeGroup(uid); | ||
_context.store.removeGroup(uid); | ||
}, | ||
@@ -72,5 +82,5 @@ methods: { | ||
_updateFieldValue: function _updateFieldValue(v) { | ||
store.updateGroupValue(this.props.uid, v); | ||
_context.store.updateGroupValue(this.props.uid, v); | ||
} | ||
} | ||
}); |
@@ -1,2 +0,8 @@ | ||
export const CheckboxGroupDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CheckboxGroupDefaultProps = void 0; | ||
var CheckboxGroupDefaultProps = { | ||
disabled: false, | ||
@@ -6,3 +12,4 @@ radius: false, | ||
controlled: false, | ||
value: [], | ||
value: [] | ||
}; | ||
exports.CheckboxGroupDefaultProps = CheckboxGroupDefaultProps; |
@@ -1,7 +0,17 @@ | ||
import { CollapseItemDefaultProps } from './props'; | ||
import { context } from '../context'; | ||
import { log } from '../../_util/console'; | ||
import { objectEntries } from '../../_util/tools'; | ||
"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"); | ||
Component({ | ||
props: CollapseItemDefaultProps, | ||
props: _props.CollapseItemDefaultProps, | ||
data: { | ||
@@ -30,3 +40,3 @@ _isActive: false, | ||
if (typeof name !== 'string') { | ||
log.error('CollapseItem', 'name 作为唯一的标识,属必填字段,类型为 string。'); | ||
_console.log.error('CollapseItem', 'name 作为唯一的标识,属必填字段,类型为 string。'); | ||
} | ||
@@ -65,3 +75,3 @@ | ||
var getId = function getId() { | ||
return "" + _this.$id; | ||
return "".concat(_this.$id); | ||
}; | ||
@@ -99,3 +109,3 @@ | ||
context.addItem(uid, "" + this.$id, { | ||
_context.context.addItem(uid, "".concat(this.$id), { | ||
setActive: setActive, | ||
@@ -116,7 +126,8 @@ setAccordion: setAccordion, | ||
try { | ||
context.updateItemValue(uid, "" + this.$id); // eslint-disable-next-line no-empty | ||
_context.context.updateItemValue(uid, "".concat(this.$id)); // eslint-disable-next-line no-empty | ||
} catch (err) {} | ||
}, | ||
didUnmount: function didUnmount() { | ||
context.removeItem(this.props.uid, "" + this.$id); | ||
_context.context.removeItem(this.props.uid, "".concat(this.$id)); | ||
}, | ||
@@ -150,7 +161,8 @@ didUpdate: function didUpdate(prevProps) { | ||
// for 2.0 | ||
context.triggerItem(this.props.uid, "" + this.$id, !this.data._isActive); | ||
_context.context.triggerItem(this.props.uid, "".concat(this.$id), !this.data._isActive); | ||
return; | ||
} | ||
var group = context.getGroup(this.props.uid); | ||
var group = _context.context.getGroup(this.props.uid); | ||
@@ -162,7 +174,9 @@ if (group) { | ||
var onChange = group.getGroupPropsVal('onChange'); | ||
objectEntries(group.items).forEach(function (_ref) { | ||
var val = _ref[1]; | ||
(0, _tools.objectEntries)(group.items).forEach(function (_ref) { | ||
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2), | ||
val = _ref2[1]; | ||
if (!val) return; | ||
if (val.getId() === "" + _this2.$id) { | ||
if (val.getId() === "".concat(_this2.$id)) { | ||
if (_this2.data._isActive) { | ||
@@ -222,7 +236,7 @@ _this2.calcContentHeight().then(function (contentHeight) { | ||
return new Promise(function (resolve, reject) { | ||
my.createSelectorQuery().select(".amd-collapse-item-content-" + _this3.$id).boundingClientRect().exec(function (res) { | ||
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(res[0].height + "px"); | ||
resolve("".concat(res[0].height, "px")); | ||
} else { | ||
@@ -250,3 +264,3 @@ reject(res); | ||
}, function () { | ||
context.onChangeByTrigger(_this4.props.uid); | ||
_context.context.onChangeByTrigger(_this4.props.uid); | ||
}); | ||
@@ -263,3 +277,3 @@ }, 10); | ||
}, function () { | ||
context.onChangeByTrigger(_this4.props.uid); | ||
_context.context.onChangeByTrigger(_this4.props.uid); | ||
}); | ||
@@ -266,0 +280,0 @@ }); |
@@ -1,6 +0,13 @@ | ||
export const CollapseItemDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CollapseItemDefaultProps = void 0; | ||
var CollapseItemDefaultProps = { | ||
uid: 'Collapse', | ||
disabled: false, | ||
expandIcon: 'UpOutline', | ||
closeIcon: 'DownOutline', | ||
closeIcon: 'DownOutline' | ||
}; | ||
exports.CollapseItemDefaultProps = CollapseItemDefaultProps; |
@@ -1,2 +0,11 @@ | ||
import { CollapseStore } from '../_util/collapseStore'; | ||
export var context = new CollapseStore(); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.context = void 0; | ||
var _collapseStore = require("../_util/collapseStore"); | ||
var context = new _collapseStore.CollapseStore(); | ||
exports.context = context; |
@@ -1,6 +0,13 @@ | ||
import { CollapseDefaultProps } from './props'; | ||
import { context } from './context'; | ||
import equal from 'fast-deep-equal'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _context = require("./context"); | ||
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal")); | ||
Component({ | ||
props: CollapseDefaultProps, | ||
props: _props.CollapseDefaultProps, | ||
data: { | ||
@@ -37,12 +44,14 @@ supportSjs: my.canIUse('sjs.event') | ||
context.addGroup(uid); | ||
context.setGroupPropsVal(uid, getGroupPropsVal); | ||
context.setItemsAccordion(uid); | ||
_context.context.addGroup(uid); | ||
_context.context.setGroupPropsVal(uid, getGroupPropsVal); | ||
_context.context.setItemsAccordion(uid); | ||
if (Array.isArray(name)) { | ||
context.updateGroupValue(uid, true); | ||
_context.context.updateGroupValue(uid, true); | ||
} | ||
}, | ||
didUnmount: function didUnmount() { | ||
context.removeGroup(this.props.uid); | ||
_context.context.removeGroup(this.props.uid); | ||
}, | ||
@@ -61,4 +70,5 @@ didUpdate: function didUpdate(prevProps) { | ||
oldAccordion = _prevProps$accordion === void 0 ? false : _prevProps$accordion; | ||
context.updateGroup(newUID, { | ||
isNameChanged: !equal(newName, oldName), | ||
_context.context.updateGroup(newUID, { | ||
isNameChanged: !(0, _fastDeepEqual["default"])(newName, oldName), | ||
isUIDChanged: newUID !== oldUID, | ||
@@ -65,0 +75,0 @@ isAccordionChanged: newAccordion !== oldAccordion |
@@ -1,5 +0,12 @@ | ||
export const CollapseDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CollapseDefaultProps = void 0; | ||
var CollapseDefaultProps = { | ||
name: [], | ||
uid: 'Collapse', | ||
accordion: false, | ||
accordion: false | ||
}; | ||
exports.CollapseDefaultProps = CollapseDefaultProps; |
@@ -1,6 +0,13 @@ | ||
import { ContainerDefaultProps } from './props'; | ||
import fmtEvent from '../_util/fmtEvent'; | ||
import { log } from '../_util/console'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fmtEvent = _interopRequireDefault(require("../_util/fmtEvent")); | ||
var _console = require("../_util/console"); | ||
Component({ | ||
props: ContainerDefaultProps, | ||
props: _props.ContainerDefaultProps, | ||
didMount: function didMount() { | ||
@@ -12,3 +19,3 @@ var _this$props = this.props, | ||
if (!icon && onIconTap) { | ||
log.error('Container', '未设置 icon 属性值或者值为空,onIconTap 将无效。'); | ||
_console.log.error('Container', '未设置 icon 属性值或者值为空,onIconTap 将无效。'); | ||
} | ||
@@ -21,3 +28,3 @@ }, | ||
if (onIconTap) { | ||
var event = fmtEvent(this.props, e); | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onIconTap(event); | ||
@@ -24,0 +31,0 @@ } |
@@ -1,1 +0,8 @@ | ||
export const ContainerDefaultProps = {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ContainerDefaultProps = void 0; | ||
var ContainerDefaultProps = {}; | ||
exports.ContainerDefaultProps = ContainerDefaultProps; |
@@ -1,4 +0,7 @@ | ||
import { DialogDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
Component({ | ||
props: DialogDefaultProps, | ||
props: _props.DialogDefaultProps, | ||
methods: { | ||
@@ -5,0 +8,0 @@ onButtonTap: function onButtonTap(e) { |
@@ -1,6 +0,12 @@ | ||
export const DialogDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.DialogDefaultProps = void 0; | ||
var DialogDefaultProps = { | ||
direction: 'vertical', | ||
buttonText: ['主操作', '更多', '取消'], | ||
maskClosable: true, | ||
maskClosable: true | ||
}; | ||
exports.DialogDefaultProps = DialogDefaultProps; |
@@ -1,2 +0,11 @@ | ||
import { FilterStore } from '../_util/filterSotre'; | ||
export var context = new FilterStore(); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.context = void 0; | ||
var _filterSotre = require("../_util/filterSotre"); | ||
var context = new _filterSotre.FilterStore(); | ||
exports.context = context; |
@@ -0,6 +1,14 @@ | ||
"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 */ | ||
import { FilterItemDefaultProps } from './props'; | ||
import { context } from '../context'; | ||
Component({ | ||
props: FilterItemDefaultProps, | ||
props: _props.FilterItemDefaultProps, | ||
data: { | ||
@@ -54,6 +62,6 @@ _value: [], | ||
var getid = function getid() { | ||
return "" + _this.$id; | ||
return "".concat(_this.$id); | ||
}; | ||
context.addItem(this.props.uid, "" + this.$id, { | ||
_context.context.addItem(this.props.uid, "".concat(this.$id), { | ||
isMult: isMult, | ||
@@ -69,3 +77,5 @@ getValue: getValue, | ||
}); | ||
context.updateItemValue(this.props.uid, "" + this.$id); | ||
_context.context.updateItemValue(this.props.uid, "".concat(this.$id)); | ||
this.setData({ | ||
@@ -115,3 +125,3 @@ curValue: getValue() | ||
var group = context.getGroup(this.props.uid); | ||
var group = _context.context.getGroup(this.props.uid); | ||
@@ -140,3 +150,3 @@ if (group) { | ||
resetArrow: function resetArrow() { | ||
var group = context.getGroup(this.props.uid); | ||
var group = _context.context.getGroup(this.props.uid); | ||
@@ -156,8 +166,6 @@ if (group) { | ||
setActive: function setActive(active) { | ||
var group = context.getGroup(this.props.uid); | ||
var group = _context.context.getGroup(this.props.uid); | ||
if (group) { | ||
var _val; | ||
var val = (_val = {}, _val[this.$id] = active, _val); | ||
var val = (0, _defineProperty2["default"])({}, this.$id, active); | ||
group.setGroupDataVal({ | ||
@@ -164,0 +172,0 @@ key: 'activeArray', |
@@ -1,4 +0,11 @@ | ||
export const FilterItemDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.FilterItemDefaultProps = void 0; | ||
var FilterItemDefaultProps = { | ||
uid: 'filter', | ||
type: 'default', | ||
type: 'default' | ||
}; | ||
exports.FilterItemDefaultProps = FilterItemDefaultProps; |
@@ -1,9 +0,21 @@ | ||
import _extends from "@babel/runtime/helpers/extends"; | ||
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { FilterDefaultProps } from './props'; | ||
import { context } from './context'; | ||
import { objectEntries } from '../_util/tools'; | ||
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; } | ||
Component({ | ||
props: FilterDefaultProps, | ||
props: _props.FilterDefaultProps, | ||
data: { | ||
@@ -28,3 +40,3 @@ placeHolderObj: {}, | ||
_this.setData({ | ||
activeObj: _extends({}, _this.data.activeObj, val.val) | ||
activeObj: _objectSpread(_objectSpread({}, _this.data.activeObj), val.val) | ||
}); | ||
@@ -50,6 +62,9 @@ | ||
context.addGroup(this.props.uid); | ||
context.setGroupDataVal(this.props.uid, setGroupDataVal); | ||
context.getGroupDataVal(this.props.uid, getGroupDataVal); | ||
context.updateGroupValue(this.props.uid); | ||
_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); | ||
}, | ||
@@ -60,7 +75,8 @@ methods: { | ||
var group = context.getGroup(this.props.uid); | ||
var group = _context.context.getGroup(this.props.uid); | ||
if (group) { | ||
objectEntries(group.items).forEach(function (_ref) { | ||
var v = _ref[1]; | ||
(0, _tools.objectEntries)(group.items).forEach(function (_ref) { | ||
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2), | ||
v = _ref2[1]; | ||
@@ -78,3 +94,3 @@ if (v.getid() === e.currentTarget.dataset.filterItemId) { | ||
_this2.setData({ | ||
currentFilterItemId: "" + v.getid() | ||
currentFilterItemId: "".concat(v.getid()) | ||
}); | ||
@@ -81,0 +97,0 @@ |
@@ -1,3 +0,10 @@ | ||
export const FilterDefaultProps = { | ||
uid: 'filter', | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.FilterDefaultProps = void 0; | ||
var FilterDefaultProps = { | ||
uid: 'filter' | ||
}; | ||
exports.FilterDefaultProps = FilterDefaultProps; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Component({}); |
@@ -1,2 +0,5 @@ | ||
import { store } from '../store'; | ||
"use strict"; | ||
var _store = require("../store"); | ||
Component({ | ||
@@ -39,3 +42,3 @@ props: { | ||
store.bootstrap(form, field, rules, initialValue, required); | ||
_store.store.bootstrap(form, field, rules, initialValue, required); | ||
} | ||
@@ -53,7 +56,8 @@ }, | ||
if (form && field) { | ||
store.setValueAfterUpdate(this.data.setData, form, field); | ||
store.setFieldUpdateInfoFn(form, field, this.updateErrorInfo.bind(this)); | ||
_store.store.setValueAfterUpdate(this.data.setData, form, field); | ||
_store.store.setFieldUpdateInfoFn(form, field, this.updateErrorInfo.bind(this)); | ||
if (field === 'submit') { | ||
store.setUpdateSubmitButtonStatusFn(form, field, this.updateSubmitButtonStatus.bind(this)); | ||
_store.store.setUpdateSubmitButtonStatusFn(form, field, this.updateSubmitButtonStatus.bind(this)); | ||
} | ||
@@ -65,3 +69,3 @@ } | ||
_this2.setData({ | ||
defaultLabelWidth: ret[0].width + "px" | ||
defaultLabelWidth: "".concat(ret[0].width, "px") | ||
}); | ||
@@ -78,4 +82,5 @@ } | ||
if (currentField && nextField && currentField !== nextField) { | ||
store.setValueAfterUpdate(this.data.setData, form, nextField); | ||
store.updateFieldSet(form, currentField, nextField); | ||
_store.store.setValueAfterUpdate(this.data.setData, form, nextField); | ||
_store.store.updateFieldSet(form, currentField, nextField); | ||
} | ||
@@ -87,3 +92,4 @@ }, | ||
field = _this$props4.name; | ||
store.delFieldSet(form, field); | ||
_store.store.delFieldSet(form, field); | ||
}, | ||
@@ -90,0 +96,0 @@ methods: { |
@@ -1,2 +0,5 @@ | ||
import { store } from './store'; | ||
"use strict"; | ||
var _store = require("./store"); | ||
Component({ | ||
@@ -31,6 +34,6 @@ props: { | ||
store.init(form, initialValues, onValuesChange, onFinish); | ||
_store.store.init(form, initialValues, onValuesChange, onFinish); | ||
}, | ||
didUnmount: function didUnmount() { | ||
store.tear(this.props.form); | ||
_store.store.tear(this.props.form); | ||
}, | ||
@@ -45,3 +48,3 @@ ref: function ref() { | ||
setFieldsValue: function setFieldsValue(form, value) { | ||
return store.setFieldsValue(form, value); | ||
return _store.store.setFieldsValue(form, value); | ||
} | ||
@@ -48,0 +51,0 @@ }; |
@@ -1,5 +0,14 @@ | ||
import { Store } from '../_util/formStore'; // export function createEvent(id: string): EventEmit { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.store = void 0; | ||
var _formStore = require("../_util/formStore"); | ||
// export function createEvent(id: string): EventEmit { | ||
// return new EventEmit(id); | ||
// } | ||
export var store = new Store(); | ||
var store = new _formStore.Store(); | ||
exports.store = store; |
@@ -1,5 +0,11 @@ | ||
import { IconDefaultProps } from './props'; | ||
import fmtEvent from '../_util/fmtEvent'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fmtEvent = _interopRequireDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
props: IconDefaultProps, | ||
props: _props.IconDefaultProps, | ||
methods: { | ||
@@ -10,3 +16,3 @@ onTap: function onTap(e) { | ||
if (onTap) { | ||
var event = fmtEvent(this.props, e); | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onTap(event); | ||
@@ -13,0 +19,0 @@ } |
@@ -1,4 +0,11 @@ | ||
export const IconDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.IconDefaultProps = void 0; | ||
var IconDefaultProps = { | ||
type: '', | ||
size: 'medium', | ||
size: 'medium' | ||
}; | ||
exports.IconDefaultProps = IconDefaultProps; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Component({ | ||
@@ -2,0 +4,0 @@ props: { |
@@ -1,8 +0,16 @@ | ||
import { InputItemDefaultProps } from './props'; | ||
import controlled from '../mixins/controlled'; | ||
import formMixin from '../mixins/form'; | ||
import { store } from '../Form/store'; | ||
"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"); | ||
Component({ | ||
mixins: [controlled(), formMixin()], | ||
props: InputItemDefaultProps, | ||
mixins: [(0, _controlled["default"])(), (0, _form["default"])()], | ||
props: _props.InputItemDefaultProps, | ||
data: { | ||
@@ -70,3 +78,3 @@ showClear: false | ||
if (form && field) { | ||
store.trigger(form, field, ''); | ||
_store.store.trigger(form, field, ''); | ||
} | ||
@@ -73,0 +81,0 @@ }, |
@@ -1,2 +0,8 @@ | ||
export const InputItemDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.InputItemDefaultProps = void 0; | ||
var InputItemDefaultProps = { | ||
controlled: false, | ||
@@ -14,3 +20,4 @@ type: 'text', | ||
autoFocus: false, | ||
disabled: false, | ||
disabled: false | ||
}; | ||
exports.InputItemDefaultProps = InputItemDefaultProps; |
@@ -1,4 +0,7 @@ | ||
import { ListDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
Component({ | ||
props: ListDefaultProps | ||
props: _props.ListDefaultProps | ||
}); |
@@ -1,5 +0,11 @@ | ||
import { ListItemDefaultProps } from './props'; | ||
import fmtEvent from '../../_util/fmtEvent'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fmtEvent = _interopRequireDefault(require("../../_util/fmtEvent")); | ||
Component({ | ||
props: ListItemDefaultProps, | ||
props: _props.ListItemDefaultProps, | ||
data: { | ||
@@ -15,3 +21,3 @@ imageSize: '', | ||
if (onTap) { | ||
var event = fmtEvent(this.props, e); | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onTap(event); | ||
@@ -18,0 +24,0 @@ } |
@@ -1,4 +0,11 @@ | ||
export const ListItemDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ListItemDefaultProps = void 0; | ||
var ListItemDefaultProps = { | ||
imageSize: 'small', | ||
disabled: false, | ||
disabled: false | ||
}; | ||
exports.ListItemDefaultProps = ListItemDefaultProps; |
@@ -1,3 +0,10 @@ | ||
export const ListDefaultProps = { | ||
radius: false, | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ListDefaultProps = void 0; | ||
var ListDefaultProps = { | ||
radius: false | ||
}; | ||
exports.ListDefaultProps = ListDefaultProps; |
@@ -1,8 +0,10 @@ | ||
import { LoadingDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
/** | ||
* 注意,delay 的变更不能实时生效 | ||
*/ | ||
Component({ | ||
props: LoadingDefaultProps, | ||
props: _props.LoadingDefaultProps, | ||
data: { | ||
@@ -9,0 +11,0 @@ // 决定实际是否渲染加载中状态 |
@@ -1,2 +0,8 @@ | ||
export const LoadingDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.LoadingDefaultProps = void 0; | ||
var LoadingDefaultProps = { | ||
loading: true, | ||
@@ -9,3 +15,4 @@ size: 'medium', | ||
height: '', | ||
type: 'spin', | ||
type: 'spin' | ||
}; | ||
exports.LoadingDefaultProps = LoadingDefaultProps; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Component({ | ||
@@ -2,0 +4,0 @@ props: { |
@@ -1,5 +0,11 @@ | ||
import fmtEvent from '../_util/fmtEvent'; | ||
import { MaskDefaultProps } from "./props"; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _fmtEvent = _interopRequireDefault(require("../_util/fmtEvent")); | ||
var _props = require("./props"); | ||
Component({ | ||
props: MaskDefaultProps, | ||
props: _props.MaskDefaultProps, | ||
methods: { | ||
@@ -10,3 +16,3 @@ onMaskClick: function onMaskClick(e) { | ||
if (typeof onMaskTap === 'function') { | ||
var event = fmtEvent(this.props, e); | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
onMaskTap(event); | ||
@@ -13,0 +19,0 @@ } |
@@ -1,7 +0,13 @@ | ||
export const MaskDefaultProps = { | ||
maskZindex: '', | ||
type: 'product', | ||
show: true, | ||
fixMaskFull: false, | ||
}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.MaskDefaultProps = void 0; | ||
var MaskDefaultProps = { | ||
maskZindex: '', | ||
type: 'product', | ||
show: true, | ||
fixMaskFull: false | ||
}; | ||
exports.MaskDefaultProps = MaskDefaultProps; |
@@ -0,4 +1,13 @@ | ||
"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")); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import deepEqual from 'fast-deep-equal'; | ||
function computedData() { | ||
@@ -19,3 +28,3 @@ var _this = this; | ||
if (deepEqual(_this.data[item], nextData[item])) { | ||
if ((0, _fastDeepEqual["default"])(_this.data[item], nextData[item])) { | ||
return prev; | ||
@@ -36,3 +45,3 @@ } // eslint-disable-next-line no-param-reassign | ||
export default { | ||
var _default = { | ||
didMount: function didMount() { | ||
@@ -44,2 +53,3 @@ computedData.call(this); | ||
} | ||
}; | ||
}; | ||
exports["default"] = _default; |
@@ -0,3 +1,13 @@ | ||
"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")); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import equal from "fast-deep-equal"; | ||
@@ -31,7 +41,4 @@ /** | ||
*/ | ||
export default (function (propsValue) { | ||
if (propsValue === void 0) { | ||
propsValue = "value"; | ||
} | ||
var _default = function _default() { | ||
var propsValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "value"; | ||
return { | ||
@@ -55,3 +62,3 @@ data: { | ||
if (!equal(prevProps[propsValue], value)) { | ||
if (!(0, _fastDeepEqual["default"])(prevProps[propsValue], value)) { | ||
this.cTrigger(value); | ||
@@ -68,3 +75,3 @@ } | ||
(_this$props$onChange = (_this$props = this.props).onChange) == null ? void 0 : _this$props$onChange.call(_this$props, v, v1); | ||
(_this$props$onChange = (_this$props = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, v, v1); | ||
}, | ||
@@ -78,6 +85,8 @@ cOnInput: function cOnInput(v) { | ||
(_this$props$onInput = (_this$props2 = this.props).onInput) == null ? void 0 : _this$props$onInput.call(_this$props2, 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; |
@@ -0,1 +1,17 @@ | ||
"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 */ | ||
@@ -6,5 +22,3 @@ | ||
*/ | ||
import { store } from '../Form/store'; | ||
import { isMoreThan106 } from '../_util/compareVersion'; | ||
export default (function () { | ||
var _default = function _default() { | ||
return { | ||
@@ -24,3 +38,3 @@ props: { | ||
if (form && field) { | ||
store.trigger(form, field, e); | ||
_store.store.trigger(form, field, e); | ||
} | ||
@@ -46,3 +60,3 @@ }, | ||
if (isMoreThan106 && isNotFormMode(this.props.mode)) return; | ||
if (_compareVersion.isMoreThan106 && isNotFormMode(this.props.mode)) return; | ||
var getCurrentField = this.$page.data._getCurrentField; | ||
@@ -58,5 +72,8 @@ if (!getCurrentField) return; | ||
var field = fieldFn(); | ||
store.addFieldSet(form, field); // 初始值设定 | ||
var initVal = store.getInitValByField(form, field); | ||
_store.store.addFieldSet(form, field); // 初始值设定 | ||
var initVal = _store.store.getInitValByField(form, field); | ||
this.props.value = initVal; // terms组件 | ||
@@ -70,14 +87,13 @@ | ||
var commonUpdateFieldValue = function commonUpdateFieldValue(v) { | ||
var _this$setData; | ||
_this.props.value = v; | ||
_this.setData((_this$setData = {}, _this$setData[_this.props.valuePropName] = v, _this$setData)); | ||
_this.setData((0, _defineProperty2["default"])({}, _this.props.valuePropName, v)); | ||
}; | ||
var updateFieldValue = this._updateFieldValue || commonUpdateFieldValue; | ||
store.addUpdateFiledValue(form, field, updateFieldValue.bind(this)); | ||
_store.store.addUpdateFiledValue(form, field, updateFieldValue.bind(this)); | ||
}, | ||
didMount: function didMount() { | ||
if (isMoreThan106 && isNotFormMode(this.props.mode)) { | ||
if (_compareVersion.isMoreThan106 && isNotFormMode(this.props.mode)) { | ||
this.$page.data._currentSetData = null; | ||
@@ -89,3 +105,3 @@ } else { | ||
}; | ||
}); | ||
}; | ||
/** | ||
@@ -97,4 +113,7 @@ * 判断组件是否为表单模式 | ||
export function isNotFormMode(mode) { | ||
exports["default"] = _default; | ||
function isNotFormMode(mode) { | ||
return mode !== 'form'; | ||
} |
@@ -0,4 +1,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _store = require("../Form/store"); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
import { store } from '../Form/store'; | ||
export default (function () { | ||
var _default = function _default() { | ||
return { | ||
@@ -10,3 +18,3 @@ onInit: function onInit() { | ||
this.props._submit = function () { | ||
store.onFinish(function () { | ||
_store.store.onFinish(function () { | ||
return _this.props.form; | ||
@@ -20,2 +28,4 @@ }); | ||
}; | ||
}); | ||
}; | ||
exports["default"] = _default; |
@@ -1,4 +0,7 @@ | ||
import { ModalDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
Component({ | ||
props: ModalDefaultProps, | ||
props: _props.ModalDefaultProps, | ||
data: { | ||
@@ -5,0 +8,0 @@ isShowBtn: true |
@@ -1,2 +0,8 @@ | ||
export const ModalDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ModalDefaultProps = void 0; | ||
var ModalDefaultProps = { | ||
imageSize: 'medium', | ||
@@ -7,3 +13,4 @@ visible: false, | ||
addonButtonText: '辅助操作', | ||
maskClosable: true, | ||
maskClosable: true | ||
}; | ||
exports.ModalDefaultProps = ModalDefaultProps; |
@@ -1,4 +0,11 @@ | ||
import { NoticeBarDefaultProps } from './props'; | ||
import { log } from '../_util/console'; | ||
"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"); | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
@@ -10,3 +17,3 @@ var noop = function noop() {}; | ||
Component({ | ||
props: NoticeBarDefaultProps, | ||
props: _props.NoticeBarDefaultProps, | ||
data: { | ||
@@ -60,3 +67,3 @@ _show: true, | ||
if (!Array.isArray(actions) && typeof actions !== 'undefined') { | ||
log.warn('NoticeBar', "\u5F53\u524D\u5B9A\u4E49\u7684 actions \u7684\u7C7B\u578B\u4E3A " + typeof actions + "\uFF0C\u4E0D\u7B26\u5408\u5C5E\u6027\u5B9A\u4E49\uFF0C\u5E94\u8BE5\u4E3A\u6570\u7EC4\uFF0C\u5982\uFF1Aactions=\"{{['\u503C', '\u503C']}}"); | ||
_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']}}")); | ||
} | ||
@@ -87,3 +94,3 @@ }, | ||
} else { | ||
log.error('NoticeBar', '缺少 onActionTap 回调。'); | ||
_console.log.error('NoticeBar', '缺少 onActionTap 回调。'); | ||
} | ||
@@ -98,6 +105,6 @@ }, | ||
if (loop) { | ||
showMarqueeWidth = _viewWidth + "px"; | ||
showMarqueeWidth = "".concat(_viewWidth, "px"); | ||
} | ||
var _marqueeStyle = "transform: translate3d(" + showMarqueeWidth + ", 0, 0); transition: 0s all linear;"; | ||
var _marqueeStyle = "transform: translate3d(".concat(showMarqueeWidth, ", 0, 0); transition: 0s all linear;"); | ||
@@ -121,3 +128,3 @@ this.setData({ | ||
var _marqueeStyle = "transform: translate3d(" + -marqueeScrollWidth + "px, 0, 0); transition: " + _duration + "s all linear " + (typeof leading === 'number' ? leading / 1000 + "s" : '0s') + ";"; | ||
var _marqueeStyle = "transform: translate3d(".concat(-marqueeScrollWidth, "px, 0, 0); transition: ").concat(_duration, "s all linear ").concat(typeof leading === 'number' ? "".concat(leading / 1000, "s") : '0s', ";"); | ||
@@ -144,9 +151,6 @@ if (this.data._marqueeStyle !== _marqueeStyle) { | ||
}, | ||
_measureText: function _measureText(callback) { | ||
_measureText: function _measureText() { | ||
var _this2 = this; | ||
if (callback === void 0) { | ||
callback = noop; | ||
} | ||
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop; | ||
var fps = 40; | ||
@@ -156,3 +160,3 @@ var loop = this.props.loop; // 计算文本所占据的宽度,计算需要滚动的宽度 | ||
setTimeout(function () { | ||
my.createSelectorQuery().select(".amd-notice-bar-marquee-" + _this2.$id).boundingClientRect().select(".amd-notice-bar-content-" + _this2.$id).boundingClientRect().exec(function (ret) { | ||
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$; | ||
@@ -163,3 +167,3 @@ | ||
var _viewWidth = ((_ret$ = ret[1]) == null ? void 0 : _ret$.width) || 0; | ||
var _viewWidth = ((_ret$ = ret[1]) === null || _ret$ === void 0 ? void 0 : _ret$.width) || 0; | ||
@@ -166,0 +170,0 @@ var marqueeScrollWidth = _overflowWidth; |
@@ -1,6 +0,13 @@ | ||
export const NoticeBarDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.NoticeBarDefaultProps = void 0; | ||
var NoticeBarDefaultProps = { | ||
showIcon: false, | ||
enableMarquee: false, | ||
loop: false, | ||
type: 'default', | ||
type: 'default' | ||
}; | ||
exports.NoticeBarDefaultProps = NoticeBarDefaultProps; |
@@ -1,9 +0,19 @@ | ||
import { PickerDefaultProps } from './props'; | ||
import computed from '../mixins/computed'; | ||
import controlled from '../mixins/controlled'; | ||
import equal from 'fast-deep-equal'; | ||
import formMixin from '../mixins/form'; | ||
import _extends from '@babel/runtime/helpers/extends'; | ||
import { store } from '../Form/store'; | ||
"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) { | ||
@@ -14,6 +24,6 @@ return v.join(','); | ||
Component({ | ||
mixins: [computed, controlled(), formMixin()], | ||
props: _extends({}, { | ||
mixins: [_computed["default"], (0, _controlled["default"])(), (0, _form["default"])()], | ||
props: (0, _extends2["default"])({}, { | ||
onFormat: noop | ||
}, PickerDefaultProps), | ||
}, _props.PickerDefaultProps), | ||
data: { | ||
@@ -52,3 +62,4 @@ visible: false, | ||
var field = fieldFn(); | ||
store.addUpdateFiledValue(form, field, updatePickerFiledValue); | ||
_store.store.addUpdateFiledValue(form, field, updatePickerFiledValue); | ||
}, | ||
@@ -61,3 +72,3 @@ didMount: function didMount() { | ||
didUpdate: function didUpdate(prevProps) { | ||
if (!equal(prevProps.value, this.props.value)) { | ||
if (!(0, _fastDeepEqual["default"])(prevProps.value, this.props.value)) { | ||
var pValueIndex = []; | ||
@@ -115,3 +126,3 @@ | ||
cValue: value, | ||
showValue: (_this$props = this.props) == null ? void 0 : _this$props.onFormat(this.formatValue ? this.formatValue : []) | ||
showValue: (_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.onFormat(this.formatValue ? this.formatValue : []) | ||
}; | ||
@@ -188,3 +199,3 @@ }, | ||
if (changeValue != null && changeValue.length) { | ||
if (changeValue !== null && changeValue !== void 0 && changeValue.length) { | ||
for (var i = 0; i < changeValue.length; i++) { | ||
@@ -205,3 +216,3 @@ if (changeValue[i] !== this.data.valueIndex[i]) { | ||
}); | ||
onOk == null ? void 0 : onOk(changeValue); | ||
onOk === null || onOk === void 0 ? void 0 : onOk(changeValue); | ||
var _getCurrentField = this.props._getCurrentField; | ||
@@ -212,3 +223,3 @@ | ||
} else { | ||
onChange == null ? void 0 : onChange(changeValue); | ||
onChange === null || onChange === void 0 ? void 0 : onChange(changeValue); | ||
} | ||
@@ -215,0 +226,0 @@ |
@@ -1,2 +0,8 @@ | ||
export const PickerDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.PickerDefaultProps = void 0; | ||
var PickerDefaultProps = { | ||
controlled: false, | ||
@@ -6,3 +12,4 @@ cols: 1, | ||
dismissText: '取消', | ||
disabled: false, | ||
disabled: false | ||
}; | ||
exports.PickerDefaultProps = PickerDefaultProps; |
@@ -1,4 +0,7 @@ | ||
import { PopoverDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
Component({ | ||
props: PopoverDefaultProps, | ||
props: _props.PopoverDefaultProps, | ||
methods: { | ||
@@ -5,0 +8,0 @@ onVisibleChange: function onVisibleChange() { |
@@ -1,5 +0,11 @@ | ||
import { PopoverItemDefaultProps } from './props'; | ||
import fmtEvent from '../../_util/fmtEvent'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _fmtEvent = _interopRequireDefault(require("../../_util/fmtEvent")); | ||
Component({ | ||
props: PopoverItemDefaultProps, | ||
props: _props.PopoverItemDefaultProps, | ||
methods: { | ||
@@ -10,3 +16,3 @@ onTap: function onTap(e) { | ||
if (onTap) { | ||
var event = fmtEvent(this.props, e); | ||
var event = (0, _fmtEvent["default"])(this.props, e); | ||
return onTap(event); | ||
@@ -13,0 +19,0 @@ } |
@@ -1,1 +0,8 @@ | ||
export const PopoverItemDefaultProps = {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.PopoverItemDefaultProps = void 0; | ||
var PopoverItemDefaultProps = {}; | ||
exports.PopoverItemDefaultProps = PopoverItemDefaultProps; |
@@ -1,2 +0,8 @@ | ||
export const PopoverDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.PopoverDefaultProps = void 0; | ||
var PopoverDefaultProps = { | ||
visible: false, | ||
@@ -7,3 +13,4 @@ mask: false, | ||
mode: 'dark', | ||
fixMaskFull: false, | ||
fixMaskFull: false | ||
}; | ||
exports.PopoverDefaultProps = PopoverDefaultProps; |
@@ -1,4 +0,7 @@ | ||
import { PopupDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
Component({ | ||
props: PopupDefaultProps, | ||
props: _props.PopupDefaultProps, | ||
data: { | ||
@@ -21,3 +24,3 @@ classNames: '', | ||
if (maskClosable) { | ||
onClose == null ? void 0 : onClose(); | ||
onClose === null || onClose === void 0 ? void 0 : onClose(); | ||
} | ||
@@ -29,3 +32,3 @@ }, | ||
if (onClose) { | ||
onClose == null ? void 0 : onClose(); | ||
onClose === null || onClose === void 0 ? void 0 : onClose(); | ||
} | ||
@@ -32,0 +35,0 @@ } |
@@ -1,2 +0,8 @@ | ||
export const PopupDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.PopupDefaultProps = void 0; | ||
var PopupDefaultProps = { | ||
visible: false, | ||
@@ -13,3 +19,4 @@ maskClosable: false, | ||
disableScroll: true, | ||
showCloseIcon: false, | ||
showCloseIcon: false | ||
}; | ||
exports.PopupDefaultProps = PopupDefaultProps; |
@@ -1,7 +0,18 @@ | ||
import { Context } from '../_util/context'; | ||
export var componentContext = new Context(); | ||
export var componentDisabled = new Context(); // 该值区别于 componentContext 的地方在于, | ||
"use strict"; | ||
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 的地方在于, | ||
// componentContext 的值用于通知 controlled 更新, | ||
// 而 componentValue 用于 item.checked 更新 | ||
export var componentValue = new Context(); | ||
exports.componentDisabled = componentDisabled; | ||
var componentValue = new _context.Context(); | ||
exports.componentValue = componentValue; |
@@ -1,8 +0,16 @@ | ||
import { RadioGroupDefaultProps } from './props'; | ||
import { componentContext, componentDisabled, componentValue } from './context'; | ||
import controlled from '../mixins/controlled'; | ||
import formMixin from '../mixins/form'; | ||
"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")); | ||
Component({ | ||
props: RadioGroupDefaultProps, | ||
mixins: [controlled(), formMixin()], | ||
props: _props.RadioGroupDefaultProps, | ||
mixins: [(0, _controlled["default"])(), (0, _form["default"])()], | ||
didMount: function didMount() { | ||
@@ -16,6 +24,8 @@ var _this = this; | ||
componentValue.update(uid, value); // 用于触发 item.disabled 更新 | ||
_context.componentValue.update(uid, value); // 用于触发 item.disabled 更新 | ||
componentDisabled.update(uid, disabled); | ||
componentContext.onUpdate(uid, function (v) { | ||
_context.componentDisabled.update(uid, disabled); | ||
_context.componentContext.onUpdate(uid, function (v) { | ||
_this.cOnChange(v); | ||
@@ -30,13 +40,16 @@ }); | ||
if (disabled !== prevProps.disabled) { | ||
componentDisabled.update(uid, disabled); | ||
_context.componentDisabled.update(uid, disabled); | ||
} | ||
componentValue.update(uid, this.data.cValue); | ||
_context.componentValue.update(uid, this.data.cValue); | ||
}, | ||
didUnmount: function didUnmount() { | ||
var uid = this.props.uid; | ||
componentContext.clearEvent(uid); | ||
componentDisabled.clearEvent(uid); | ||
componentValue.clearEvent(uid); | ||
_context.componentContext.clearEvent(uid); | ||
_context.componentDisabled.clearEvent(uid); | ||
_context.componentValue.clearEvent(uid); | ||
} | ||
}); |
@@ -1,5 +0,12 @@ | ||
export const RadioGroupDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.RadioGroupDefaultProps = void 0; | ||
var RadioGroupDefaultProps = { | ||
disabled: false, | ||
radius: false, | ||
uid: 'RadioGroup', | ||
uid: 'RadioGroup' | ||
}; | ||
exports.RadioGroupDefaultProps = RadioGroupDefaultProps; |
@@ -1,5 +0,9 @@ | ||
import { RadioItemDefaultProps } from './props'; | ||
import { componentContext, componentDisabled, componentValue } from '../context'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
Component({ | ||
props: RadioItemDefaultProps, | ||
props: _props.RadioItemDefaultProps, | ||
data: { | ||
@@ -12,3 +16,3 @@ _checked: false, | ||
componentDisabled.onUpdate(this.props.uid, this.disabledListener = function (d) { | ||
_context.componentDisabled.onUpdate(this.props.uid, this.disabledListener = function (d) { | ||
_this.setData({ | ||
@@ -18,3 +22,4 @@ _disabled: _this.props.disabled || d | ||
}); | ||
componentValue.onUpdate(this.props.uid, this.checkedListener = function (v) { | ||
_context.componentValue.onUpdate(this.props.uid, this.checkedListener = function (v) { | ||
if (v) { | ||
@@ -34,4 +39,5 @@ if (v.indexOf(_this.props.value) !== -1) { | ||
didUnmount: function didUnmount() { | ||
componentValue.offUpdate(this.props.uid, this.checkedListener); | ||
componentDisabled.offUpdate(this.props.uid, this.disabledListener); | ||
_context.componentValue.offUpdate(this.props.uid, this.checkedListener); | ||
_context.componentDisabled.offUpdate(this.props.uid, this.disabledListener); | ||
}, | ||
@@ -43,3 +49,3 @@ methods: { | ||
if (value) { | ||
componentContext.update(this.props.uid, this.props.value); | ||
_context.componentContext.update(this.props.uid, this.props.value); | ||
} | ||
@@ -46,0 +52,0 @@ } |
@@ -1,4 +0,11 @@ | ||
export const RadioItemDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.RadioItemDefaultProps = void 0; | ||
var RadioItemDefaultProps = { | ||
disabled: false, | ||
uid: 'RadioGroup', | ||
uid: 'RadioGroup' | ||
}; | ||
exports.RadioItemDefaultProps = RadioItemDefaultProps; |
@@ -1,4 +0,7 @@ | ||
import { ResultDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
Component({ | ||
props: ResultDefaultProps, | ||
props: _props.ResultDefaultProps, | ||
methods: { | ||
@@ -5,0 +8,0 @@ onButtonTap: function onButtonTap(e) { |
@@ -1,1 +0,8 @@ | ||
export const ResultDefaultProps = {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ResultDefaultProps = void 0; | ||
var ResultDefaultProps = {}; | ||
exports.ResultDefaultProps = ResultDefaultProps; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Component({ | ||
@@ -2,0 +4,0 @@ props: { |
@@ -1,6 +0,12 @@ | ||
import { SearchBarDefaultProps } from './props'; | ||
import controlled from '../mixins/controlled'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _props = require("./props"); | ||
var _controlled = _interopRequireDefault(require("../mixins/controlled")); | ||
Component({ | ||
mixins: [controlled()], | ||
props: SearchBarDefaultProps, | ||
mixins: [(0, _controlled["default"])()], | ||
props: _props.SearchBarDefaultProps, | ||
data: { | ||
@@ -7,0 +13,0 @@ focus: false |
@@ -1,2 +0,8 @@ | ||
export const SearchBarDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SearchBarDefaultProps = void 0; | ||
var SearchBarDefaultProps = { | ||
controlled: false, | ||
@@ -9,3 +15,4 @@ showCancelButton: false, | ||
disabled: false, | ||
bizIconType: 'AudioOutline', | ||
bizIconType: 'AudioOutline' | ||
}; | ||
exports.SearchBarDefaultProps = SearchBarDefaultProps; |
@@ -1,5 +0,13 @@ | ||
import { SelectorDefaultProps } from './props'; | ||
import controlled from '../mixins/controlled'; | ||
import formMixin from '../mixins/form'; | ||
"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) { | ||
@@ -11,3 +19,3 @@ var fixedValue; | ||
} else { | ||
fixedValue = value == null ? void 0 : value.slice(0, 1); | ||
fixedValue = value === null || value === void 0 ? void 0 : value.slice(0, 1); | ||
} | ||
@@ -19,4 +27,4 @@ | ||
Component({ | ||
mixins: [controlled(), formMixin()], | ||
props: SelectorDefaultProps, | ||
mixins: [(0, _controlled["default"])(), (0, _form["default"])()], | ||
props: _props.SelectorDefaultProps, | ||
data: {}, | ||
@@ -39,4 +47,4 @@ methods: { | ||
// 之前已经选中,删除它 | ||
if ((fixedValue == null ? void 0 : fixedValue.indexOf(value)) !== -1) { | ||
nextValue = fixedValue == null ? void 0 : fixedValue.filter(function (item) { | ||
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; | ||
@@ -46,3 +54,3 @@ }); | ||
// 之前未选中,增加 | ||
nextValue = [].concat(fixedValue, [value]); | ||
nextValue = [].concat((0, _toConsumableArray2["default"])(fixedValue), [value]); | ||
} // 将 value 重新按 options 排序 | ||
@@ -65,3 +73,3 @@ | ||
// eslint-disable-next-line no-lonely-if | ||
if ((fixedValue == null ? void 0 : fixedValue[0]) === value) { | ||
if ((fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue[0]) === value) { | ||
nextValue = ''; | ||
@@ -68,0 +76,0 @@ } else { |
@@ -1,5 +0,12 @@ | ||
export const SelectorDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SelectorDefaultProps = void 0; | ||
var SelectorDefaultProps = { | ||
controlled: false, | ||
multiple: false, | ||
disabled: false, | ||
disabled: false | ||
}; | ||
exports.SelectorDefaultProps = SelectorDefaultProps; |
@@ -1,9 +0,18 @@ | ||
import { StepperDefaultProps } from './props'; | ||
import computed from '../mixins/computed'; | ||
import controlled from '../mixins/controlled'; | ||
import { upStep, downStep } from './utils'; | ||
import formMixin from '../mixins/form'; | ||
"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")); | ||
Component({ | ||
mixins: [computed, controlled(), formMixin()], | ||
props: StepperDefaultProps, | ||
mixins: [_computed["default"], (0, _controlled["default"])(), (0, _form["default"])()], | ||
props: _props.StepperDefaultProps, | ||
data: { | ||
@@ -73,3 +82,3 @@ confirm: false, | ||
var value = e.detail.value; | ||
(_this$props$onFocus = (_this$props2 = this.props).onFocus) == null ? void 0 : _this$props$onFocus.call(_this$props2, value); | ||
(_this$props$onFocus = (_this$props2 = this.props).onFocus) === null || _this$props$onFocus === void 0 ? void 0 : _this$props$onFocus.call(_this$props2, value); | ||
}, | ||
@@ -89,3 +98,3 @@ onBlur: function onBlur(e) { | ||
this.cOnChange(this.getInputValue(value)); | ||
(_this$props$onBlur = (_this$props3 = this.props).onBlur) == null ? void 0 : _this$props$onBlur.call(_this$props3, 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)); | ||
} | ||
@@ -134,7 +143,7 @@ }, | ||
// 【减】按钮的操作 | ||
var minusTemp = downStep(cValue, step, precision); | ||
var minusTemp = (0, _utils.downStep)(cValue, step, precision); | ||
this.cOnChange(Math.max(minusTemp, min)); | ||
} else if (mode === 'add') { | ||
// 【加】按钮的操作 | ||
var addTemp = upStep(cValue, step, precision); | ||
var addTemp = (0, _utils.upStep)(cValue, step, precision); | ||
this.cOnChange(Math.min(addTemp, max)); | ||
@@ -141,0 +150,0 @@ } |
@@ -1,2 +0,8 @@ | ||
export const StepperDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.StepperDefaultProps = void 0; | ||
var StepperDefaultProps = { | ||
controlled: false, | ||
@@ -6,3 +12,4 @@ step: 1, | ||
disabled: false, | ||
type: 'digit', | ||
type: 'digit' | ||
}; | ||
exports.StepperDefaultProps = StepperDefaultProps; |
@@ -0,1 +1,14 @@ | ||
"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; | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
@@ -5,6 +18,7 @@ | ||
// '1.' '1x' 'xx' '' => are not complete numbers | ||
export function isNotCompleteNumber(num) { | ||
function isNotCompleteNumber(num) { | ||
return isNaN(num) || num === '' || num === null || num && num.toString().indexOf('.') === num.toString().length - 1; | ||
} | ||
export function toNumber(num, precision) { | ||
function toNumber(num, precision) { | ||
// num.length > 16 => This is to prevent input of large numbers | ||
@@ -23,3 +37,4 @@ var numberIsTooLarge = num && num.length > 16; | ||
} | ||
export function getPrecision(value, precision) { | ||
function getPrecision(value, precision) { | ||
if (precision != null) { | ||
@@ -48,3 +63,4 @@ return precision; | ||
export function getMaxPrecision(currentValue, step, precision) { | ||
function getMaxPrecision(currentValue, step, precision) { | ||
if (precision != null) { | ||
@@ -63,7 +79,9 @@ return precision; | ||
} | ||
export function getPrecisionFactor(currentValue, precision) { | ||
function getPrecisionFactor(currentValue, precision) { | ||
var p = getMaxPrecision(currentValue, undefined, precision); | ||
return Math.pow(10, p); | ||
} | ||
export function upStep(val, step, precision) { | ||
function upStep(val, step, precision) { | ||
var precisionFactor = getPrecisionFactor(val, precision); | ||
@@ -74,3 +92,4 @@ var p = Math.abs(getMaxPrecision(val, step, precision)); | ||
} | ||
export function downStep(val, step, precision) { | ||
function downStep(val, step, precision) { | ||
var precisionFactor = getPrecisionFactor(val, precision); | ||
@@ -77,0 +96,0 @@ var p = Math.abs(getMaxPrecision(val, step, precision)); |
@@ -1,2 +0,11 @@ | ||
import { StepsStore } from '../_util/setpsStore'; | ||
export var context = new StepsStore(); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.context = void 0; | ||
var _setpsStore = require("../_util/setpsStore"); | ||
var context = new _setpsStore.StepsStore(); | ||
exports.context = context; |
@@ -1,5 +0,9 @@ | ||
import { StepsDefaultProps } from './props'; | ||
import { context } from './context'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("./context"); | ||
Component({ | ||
props: StepsDefaultProps, | ||
props: _props.StepsDefaultProps, | ||
didMount: function didMount() { | ||
@@ -12,3 +16,3 @@ this.updateItemData(); | ||
didUnmount: function didUnmount() { | ||
context.removeGroup(this.props.uid); | ||
_context.context.removeGroup(this.props.uid); | ||
}, | ||
@@ -21,6 +25,8 @@ methods: { | ||
uid = _this$props.uid; | ||
context.updateItemIndex(uid, index); | ||
context.updateItemDirection(uid, direction); | ||
_context.context.updateItemIndex(uid, index); | ||
_context.context.updateItemDirection(uid, direction); | ||
} | ||
} | ||
}); |
@@ -1,5 +0,12 @@ | ||
export const StepsDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.StepsDefaultProps = void 0; | ||
var StepsDefaultProps = { | ||
index: 0, | ||
direction: 'horizontal', | ||
uid: 'steps', | ||
uid: 'steps' | ||
}; | ||
exports.StepsDefaultProps = StepsDefaultProps; |
@@ -1,5 +0,9 @@ | ||
import { StepItemDefaultProps } from './props'; | ||
import { context } from '../context'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("../context"); | ||
Component({ | ||
props: StepItemDefaultProps, | ||
props: _props.StepItemDefaultProps, | ||
data: { | ||
@@ -26,3 +30,3 @@ _index: 0, | ||
context.addItem(uid, "" + this.$id, { | ||
_context.context.addItem(uid, "".concat(this.$id), { | ||
setItemIndex: setItemIndex, | ||
@@ -33,5 +37,5 @@ setItemDirection: setItemDirection | ||
didUnmount: function didUnmount() { | ||
context.removeItem(this.props.uid, "" + this.$id); | ||
_context.context.removeItem(this.props.uid, "".concat(this.$id)); | ||
}, | ||
methods: {} | ||
}); |
@@ -1,4 +0,11 @@ | ||
export const StepItemDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.StepItemDefaultProps = void 0; | ||
var StepItemDefaultProps = { | ||
fail: false, | ||
uid: 'steps', | ||
uid: 'steps' | ||
}; | ||
exports.StepItemDefaultProps = StepItemDefaultProps; |
@@ -1,6 +0,10 @@ | ||
import { SwipeActionDefaultProps } from './props'; | ||
import { ComponentContext } from '../_util/context'; | ||
var swipeIdContext = new ComponentContext(); | ||
"use strict"; | ||
var _props = require("./props"); | ||
var _context = require("../_util/context"); | ||
var swipeIdContext = new _context.ComponentContext(); | ||
Component({ | ||
props: SwipeActionDefaultProps, | ||
props: _props.SwipeActionDefaultProps, | ||
data: { | ||
@@ -35,6 +39,6 @@ itemPosition: 0, | ||
my.createSelectorQuery().select(".amd-swipe-action-right-" + this.$id).boundingClientRect().exec(function (ret) { | ||
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-" + this.$id).boundingClientRect().exec(function (ret) { | ||
my.createSelectorQuery().select(".amd-swipe-action-left-".concat(this.$id)).boundingClientRect().exec(function (ret) { | ||
_this2.leftBtnWidth = ret && ret[0] && ret[0].width || 0; | ||
@@ -41,0 +45,0 @@ }); |
@@ -1,5 +0,12 @@ | ||
export const SwipeActionDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SwipeActionDefaultProps = void 0; | ||
var SwipeActionDefaultProps = { | ||
autoClose: false, | ||
disabled: false, | ||
onGetRef:()=>{} | ||
onGetRef: function onGetRef() {} | ||
}; | ||
exports.SwipeActionDefaultProps = SwipeActionDefaultProps; |
@@ -1,7 +0,14 @@ | ||
import { SwitchDefaultProps } from './props'; | ||
import controlled from '../mixins/controlled'; | ||
import formMixin from '../mixins/form'; | ||
"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")); | ||
Component({ | ||
props: SwitchDefaultProps, | ||
mixins: [controlled('checked'), formMixin()], | ||
props: _props.SwitchDefaultProps, | ||
mixins: [(0, _controlled["default"])('checked'), (0, _form["default"])()], | ||
methods: { | ||
@@ -8,0 +15,0 @@ onChange: function onChange(v) { |
@@ -1,5 +0,12 @@ | ||
export const SwitchDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SwitchDefaultProps = void 0; | ||
var SwitchDefaultProps = { | ||
controlled: false, | ||
disabled: false, | ||
size: 'medium', | ||
size: 'medium' | ||
}; | ||
exports.SwitchDefaultProps = SwitchDefaultProps; |
@@ -1,4 +0,15 @@ | ||
import { ComponentContext } from '../_util/context'; | ||
export var componentContext = new ComponentContext(); | ||
export var componentContextFallback = new ComponentContext(); | ||
export var getTabArray = {}; | ||
"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; |
@@ -0,17 +1,28 @@ | ||
"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"); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { TabsDefaultProps } from './props'; | ||
import { getTabArray, componentContext, componentContextFallback } from './context'; | ||
import { log } from '../_util/console'; | ||
import { objectValues } from '../_util/tools'; | ||
import { compareVersion } from '../_util/compareVersion'; | ||
var canSwipeable = my.canIUse('swiper.disable-touch'); | ||
var component2 = my.canIUse('component2'); | ||
var hasTab = false; | ||
var isShouldNotCalHeight = component2 && compareVersion(my.SDKVersion, '2.6.4') >= 0; | ||
var isForceUpdate = compareVersion(my.SDKVersion, '2.6.4') >= 0 && compareVersion(my.SDKVersion, '2.7.5') === -1; | ||
var isMoreThan275 = compareVersion(my.SDKVersion, '2.7.5') >= 0; | ||
var isBaseSwiper = compareVersion(my.SDKVersion, '2.0.0') >= 0; | ||
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; | ||
Component({ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
props: TabsDefaultProps, | ||
props: _props.TabsDefaultProps, | ||
data: { | ||
@@ -37,7 +48,8 @@ _tabs: {}, | ||
if (hasTab) { | ||
log.error('Tabs', '目前仅支持在一个页面中使用一个 Tabs 组件。'); | ||
_console.log.error('Tabs', '目前仅支持在一个页面中使用一个 Tabs 组件。'); | ||
} | ||
hasTab = true; | ||
componentContext.onUpdate(function (value) { | ||
_context.componentContext.onUpdate(function (value) { | ||
_this.setData({ | ||
@@ -47,3 +59,5 @@ _tabs: value | ||
}); | ||
componentContextFallback.update(this.props.fallback); | ||
_context.componentContextFallback.update(this.props.fallback); | ||
var _this$props = this.props, | ||
@@ -53,3 +67,3 @@ index = _this$props.index, | ||
this.setData({ | ||
_tabs: objectValues(getTabArray), | ||
_tabs: (0, _tools.objectValues)(_context.getTabArray), | ||
currentIndex: index | ||
@@ -64,8 +78,9 @@ }); | ||
// 如果当前索引值的类型不对给警告提示 | ||
log.error('Tabs', "\u5F53\u524D\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u7C7B\u578B\u975E number \u7C7B\u578B\uFF0C\u4FEE\u6539\u5F53\u524D index \u7684 " + typeof index + " \u7C7B\u578B\uFF0C\u4EE5\u4FDD\u8BC1\u5C55\u793A\u7684\u6B63\u786E\u6027\u3002"); | ||
_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-" + index).boundingClientRect().exec(function (ret) { | ||
my.createSelectorQuery().select("#amd-tabs-bar-item-".concat(index)).boundingClientRect().exec(function (ret) { | ||
if (!ret || !ret[0]) { | ||
// 当获取到的索引值无法匹配时显示错误提示 | ||
log.error('Tabs', "\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u9519\u8BEF\uFF0C\u8BF7\u786E\u8BA4 " + index + " \u662F\u5426\u4E3A\u6B63\u786E\u7684\u7D22\u5F15\u503C\u3002"); | ||
_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; | ||
@@ -108,3 +123,3 @@ } | ||
if (prevProps.fallback !== fallback) { | ||
componentContextFallback.update(fallback); | ||
_context.componentContextFallback.update(fallback); | ||
} | ||
@@ -115,6 +130,7 @@ | ||
my.createSelectorQuery().select("#amd-tabs-bar-item-" + index).boundingClientRect().exec(function (ret) { | ||
my.createSelectorQuery().select("#amd-tabs-bar-item-".concat(index)).boundingClientRect().exec(function (ret) { | ||
if (!ret || !ret[0]) { | ||
// 当获取到的索引值无法匹配时显示错误提示 | ||
log.error('Tabs', "\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u9519\u8BEF\uFF0C\u8BF7\u786E\u8BA4 " + index + " \u662F\u5426\u4E3A\u6B63\u786E\u7684\u7D22\u5F15\u503C\u3002"); | ||
_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; | ||
@@ -159,3 +175,4 @@ } | ||
hasTab = false; | ||
componentContext.clearEvent(); | ||
_context.componentContext.clearEvent(); | ||
}, | ||
@@ -171,3 +188,3 @@ methods: { | ||
my.createSelectorQuery().selectAll("#amd-tabs-content-" + this.$id + " .amd-tabs-item-pane").boundingClientRect().exec(function (ret) { | ||
my.createSelectorQuery().selectAll("#amd-tabs-content-".concat(this.$id, " .amd-tabs-item-pane")).boundingClientRect().exec(function (ret) { | ||
if (ret && ret[0]) { | ||
@@ -177,3 +194,3 @@ var _tabIndex; | ||
_this3.setData({ | ||
_tabContentHeight: (_tabIndex = ret[0][tabIndex]) == null ? void 0 : _tabIndex.height | ||
_tabContentHeight: (_tabIndex = ret[0][tabIndex]) === null || _tabIndex === void 0 ? void 0 : _tabIndex.height | ||
}); | ||
@@ -190,8 +207,8 @@ } | ||
this.setData({ | ||
currentIndex: (_e$detail = e.detail) == null ? void 0 : _e$detail.current, | ||
_swipeableIndex: (_e$detail2 = e.detail) == null ? void 0 : _e$detail2.current, | ||
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 ? void 0 : _e$detail3.current); | ||
this._autoHeight((_e$detail3 = e.detail) === null || _e$detail3 === void 0 ? void 0 : _e$detail3.current); | ||
@@ -201,3 +218,3 @@ if (onChange) { | ||
return onChange((_e$detail4 = e.detail) == null ? void 0 : _e$detail4.current); | ||
return onChange((_e$detail4 = e.detail) === null || _e$detail4 === void 0 ? void 0 : _e$detail4.current); | ||
} | ||
@@ -209,3 +226,3 @@ }, | ||
if (!component2 && swipeable && !b) { | ||
log.error('Tabs', '未开启 component2 编译,swipeable 无法使用'); | ||
_console.log.error('Tabs', '未开启 component2 编译,swipeable 无法使用'); | ||
} // 如需使用 swipeable 属性,需要基础库版本 ≥ 1.15.0 | ||
@@ -220,3 +237,3 @@ | ||
if (!b) { | ||
log.error('Tabs', '基础库版本需要 1.15.0 及以上才可以使用 swipeable'); | ||
_console.log.error('Tabs', '基础库版本需要 1.15.0 及以上才可以使用 swipeable'); | ||
} | ||
@@ -233,3 +250,3 @@ } else { | ||
// 获取 tabs 可视区域的宽度 | ||
my.createSelectorQuery().select("#amd-tabs-bar-scroll-view-" + this.$id).boundingClientRect().exec(function (ret) { | ||
my.createSelectorQuery().select("#amd-tabs-bar-scroll-view-".concat(this.$id)).boundingClientRect().exec(function (ret) { | ||
if (ret && ret[0]) { | ||
@@ -246,5 +263,5 @@ _this4.setData({ | ||
var onChange = this.props.onChange; | ||
var index = parseInt(e == null ? void 0 : (_e$currentTarget = e.currentTarget) == null ? void 0 : (_e$currentTarget$data = _e$currentTarget.dataset) == null ? void 0 : _e$currentTarget$data.index, 10); | ||
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.disabled) { | ||
if ((_this$data$_tabs$inde = this.data._tabs[index]) !== null && _this$data$_tabs$inde !== void 0 && _this$data$_tabs$inde.disabled) { | ||
return; | ||
@@ -258,3 +275,3 @@ } | ||
this.currentLeft = e == null ? void 0 : (_e$currentTarget2 = e.currentTarget) == null ? void 0 : _e$currentTarget2.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); | ||
@@ -261,0 +278,0 @@ } |
@@ -1,2 +0,8 @@ | ||
export const TabsDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TabsDefaultProps = void 0; | ||
var TabsDefaultProps = { | ||
type: 'basis', | ||
@@ -8,5 +14,6 @@ index: 0, | ||
stickyTop: 0, | ||
fallback:false, | ||
fallback: false, | ||
touchAngle: 45, | ||
onGetRef: () => {}, | ||
onGetRef: function onGetRef() {} | ||
}; | ||
exports.TabsDefaultProps = TabsDefaultProps; |
@@ -1,10 +0,21 @@ | ||
import { TabItemDefaultProps } from './props'; | ||
import { getTabArray, componentContext, componentContextFallback } from '../context'; | ||
import { log } from '../../_util/console'; | ||
import { objectValues } from '../../_util/tools'; | ||
import { compareVersion } from '../../_util/compareVersion'; | ||
"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"); | ||
var n = 0; | ||
var isBaseSwiper = compareVersion(my.SDKVersion, '2.0.0'); | ||
var isBaseSwiper = (0, _compareVersion.compareVersion)(my.SDKVersion, '2.0.0'); | ||
Component({ | ||
props: TabItemDefaultProps, | ||
props: _props.TabItemDefaultProps, | ||
data: { | ||
@@ -19,3 +30,3 @@ isBaseSwiper: isBaseSwiper, | ||
componentContextFallback.onUpdate(function (v) { | ||
_context.componentContextFallback.onUpdate(function (v) { | ||
_this.setData({ | ||
@@ -30,5 +41,5 @@ fallback: v | ||
didUnmount: function didUnmount() { | ||
delete getTabArray[this.uid]; | ||
delete _context.getTabArray[this.uid]; | ||
setTimeout(function () { | ||
componentContext.update(objectValues(getTabArray)); | ||
_context.componentContext.update((0, _tools.objectValues)(_context.getTabArray)); | ||
}, 0); | ||
@@ -39,10 +50,10 @@ }, | ||
// 检测 tab-item 中的 tab 属性值正确性 | ||
if (!tab || typeof tab !== 'object') { | ||
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 " + typeof tab + "\uFF0C\u503C\uFF1A" + tab); | ||
} else if (!(tab != null && tab.title)) { | ||
log.error('TabItem', "tab \u7684\u503C\u4E2D\u7F3A\u5C11\u5173\u952E title \u503C\uFF0C\u5F53\u524D\u7684 tab \u503C\u4E3A " + JSON.stringify(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.badge && typeof (tab == null ? void 0 : tab.badge) !== 'number') { | ||
log.error('TabItem', "tab \u4E2D\u7684 badge \u7C7B\u578B\u4E0D\u5339\u914D\uFF0C\u5F53\u524D\u7684 badge \u503C\u4E3A " + (tab == null ? void 0 : tab.badge) + "\uFF0C \u7C7B\u578B\u4E3A " + typeof (tab == null ? void 0 : tab.badge)); | ||
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))); | ||
} | ||
@@ -61,5 +72,5 @@ }, | ||
getTabArray[this.uid] = tab; | ||
_context.getTabArray[this.uid] = tab; | ||
setTimeout(function () { | ||
componentContext.update(objectValues(getTabArray)); | ||
_context.componentContext.update((0, _tools.objectValues)(_context.getTabArray)); | ||
}, 0); | ||
@@ -66,0 +77,0 @@ } |
@@ -1,1 +0,8 @@ | ||
export const TabItemDefaultProps = {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TabItemDefaultProps = void 0; | ||
var TabItemDefaultProps = {}; | ||
exports.TabItemDefaultProps = TabItemDefaultProps; |
@@ -1,4 +0,7 @@ | ||
import { TagDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
Component({ | ||
props: TagDefaultProps | ||
props: _props.TagDefaultProps | ||
}); |
@@ -1,4 +0,11 @@ | ||
export const TagDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TagDefaultProps = void 0; | ||
var TagDefaultProps = { | ||
type: 'fill', | ||
color: 'primary', | ||
color: 'primary' | ||
}; | ||
exports.TagDefaultProps = TagDefaultProps; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Component({ | ||
@@ -2,0 +4,0 @@ props: { |
@@ -1,4 +0,7 @@ | ||
import { TermsDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
Component({ | ||
props: TermsDefaultProps, | ||
props: _props.TermsDefaultProps, | ||
data: { | ||
@@ -5,0 +8,0 @@ disabled: false |
@@ -1,5 +0,12 @@ | ||
export const TermsDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TermsDefaultProps = void 0; | ||
var TermsDefaultProps = { | ||
fixed: false, | ||
hasCheckbox: true, | ||
mainButtonText: '提交', | ||
mainButtonText: '提交' | ||
}; | ||
exports.TermsDefaultProps = TermsDefaultProps; |
@@ -1,24 +0,26 @@ | ||
import { TipsDefaultProps } from './props'; | ||
"use strict"; | ||
var _props = require("./props"); | ||
var _console = require("../_util/console"); | ||
Component({ | ||
props: TipsDefaultProps, | ||
props: _props.TipsDefaultProps, | ||
data: { | ||
_show: false | ||
_show: true | ||
}, | ||
didMount: function didMount() { | ||
this.setData({ | ||
_show: this.props.visible | ||
}); | ||
this.showError(); | ||
}, | ||
didUpdate: function didUpdate(prevProps) { | ||
if (prevProps.visible !== this.props.visible) { | ||
this.setData({ | ||
_show: this.props.visible | ||
}); | ||
didUpdate: function didUpdate() { | ||
this.showError(); | ||
}, | ||
methods: { | ||
showError: function showError() { | ||
var title = this.props.title; | ||
if (this.props.visible === false) { | ||
this.beforeClose(); | ||
if (!title) { | ||
_console.log.warn('Tips', '缺少 title 属性。'); | ||
} | ||
} | ||
}, | ||
methods: { | ||
}, | ||
onButtonTap: function onButtonTap() { | ||
@@ -35,10 +37,4 @@ var onButtonTap = this.props.onButtonTap; | ||
}); | ||
this.beforeClose(); | ||
}, | ||
beforeClose: function beforeClose() { | ||
if (typeof this.props.onClose === "function") { | ||
this.props.onClose(); | ||
} | ||
} | ||
} | ||
}); |
@@ -29,7 +29,2 @@ import { IBaseProps } from '../_base'; | ||
/** | ||
* @description 是否显示 Tips 组件 | ||
* @default true | ||
*/ | ||
visible?: boolean; | ||
/** | ||
* @description 关闭按钮位置 | ||
@@ -36,0 +31,0 @@ * @default right |
@@ -1,6 +0,11 @@ | ||
export const TipsDefaultProps = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TipsDefaultProps = void 0; | ||
var TipsDefaultProps = { | ||
showClose: false, | ||
buttonPosition: 'bottom', | ||
visible:true, | ||
onClose: () => {} | ||
buttonPosition: 'bottom' | ||
}; | ||
exports.TipsDefaultProps = TipsDefaultProps; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Component({ | ||
@@ -2,0 +4,0 @@ methods: { |
@@ -1,3 +0,13 @@ | ||
import { ComponentContext } from '../_util/context'; | ||
export var componentContext = new ComponentContext(); | ||
export var getTabArray = {}; | ||
"use strict"; | ||
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; |
@@ -1,8 +0,17 @@ | ||
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import { VTabsDefaultProps } from './props'; | ||
import { getTabArray, componentContext } from './context'; | ||
import { objectValues } from '../_util/tools'; | ||
"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"); | ||
Component({ | ||
props: VTabsDefaultProps, | ||
props: _props.VTabsDefaultProps, | ||
data: { | ||
@@ -18,5 +27,5 @@ tabTop: 0, | ||
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { | ||
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() { | ||
var index; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
@@ -32,3 +41,3 @@ switch (_context.prev = _context.next) { | ||
case 5: | ||
componentContext.onUpdate(function (value) { | ||
_context5.componentContext.onUpdate(function (value) { | ||
_this.setData({ | ||
@@ -38,6 +47,7 @@ _tabs: value | ||
}); | ||
index = _this.props.index; | ||
_this.setData({ | ||
_tabs: objectValues(getTabArray), | ||
_tabs: (0, _tools.objectValues)(_context5.getTabArray), | ||
wrapScrollHeight: _this.scrollWrapHeight | ||
@@ -72,3 +82,3 @@ }); // 初次加载时的情况 | ||
didUnmount: function didUnmount() { | ||
componentContext.clearEvent(); | ||
_context5.componentContext.clearEvent(); | ||
@@ -84,4 +94,4 @@ if (this.timerId) { | ||
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() { | ||
return _regenerator["default"].wrap(function _callee2$(_context2) { | ||
while (1) { | ||
@@ -104,6 +114,6 @@ switch (_context2.prev = _context2.next) { | ||
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { | ||
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() { | ||
var rects, prevHeight, i, height, _rects; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
return _regenerator["default"].wrap(function _callee3$(_context3) { | ||
while (1) { | ||
@@ -117,3 +127,3 @@ switch (_context3.prev = _context3.next) { | ||
return new Promise(function (resolve) { | ||
my.createSelectorQuery().select("#amd-vtabs-content-slides-" + _this3.$id).boundingClientRect().exec(function (ret) { | ||
my.createSelectorQuery().select("#amd-vtabs-content-slides-".concat(_this3.$id)).boundingClientRect().exec(function (ret) { | ||
resolve(ret[0].height); | ||
@@ -127,3 +137,3 @@ }); | ||
return new Promise(function (resolve) { | ||
my.createSelectorQuery().select("#amd-vtabs-content-slides-" + _this3.$id).scrollOffset().exec(function (ret) { | ||
my.createSelectorQuery().select("#amd-vtabs-content-slides-".concat(_this3.$id)).scrollOffset().exec(function (ret) { | ||
resolve(ret[0].scrollTop); | ||
@@ -137,3 +147,3 @@ }); | ||
return new Promise(function (resolve) { | ||
my.createSelectorQuery().selectAll("#amd-vtabs-content-slides-" + _this3.$id + " .amd-vtabs-item").boundingClientRect().exec(function (res) { | ||
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 | ||
@@ -158,3 +168,3 @@ resolve(res[0].sort(function (a, b) { | ||
} else { | ||
_this3.indexTop[i] = _this3.indexTop[i - 1] + ((_rects = rects[i - 1]) == null ? void 0 : _rects.height); | ||
_this3.indexTop[i] = _this3.indexTop[i - 1] + ((_rects = rects[i - 1]) === null || _rects === void 0 ? void 0 : _rects.height); | ||
} | ||
@@ -177,6 +187,6 @@ | ||
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() { | ||
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() { | ||
var index, _e$currentTarget, _e$currentTarget$data, _this4$data$_tabs$ind; | ||
return _regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
return _regenerator["default"].wrap(function _callee4$(_context4) { | ||
while (1) { | ||
@@ -206,5 +216,5 @@ switch (_context4.prev = _context4.next) { | ||
case 8: | ||
index = e == null ? void 0 : (_e$currentTarget = e.currentTarget) == null ? void 0 : (_e$currentTarget$data = _e$currentTarget.dataset) == null ? void 0 : _e$currentTarget$data.payload; | ||
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.disabled)) { | ||
if (!((_this4$data$_tabs$ind = _this4.data._tabs[index]) !== null && _this4$data$_tabs$ind !== void 0 && _this4$data$_tabs$ind.disabled)) { | ||
_context4.next = 11; | ||
@@ -211,0 +221,0 @@ break; |
@@ -1,3 +0,10 @@ | ||
export const VTabsDefaultProps = { | ||
index: 0, | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.VTabsDefaultProps = void 0; | ||
var VTabsDefaultProps = { | ||
index: 0 | ||
}; | ||
exports.VTabsDefaultProps = VTabsDefaultProps; |
@@ -1,8 +0,18 @@ | ||
import { VTabItemDefaultProps } from './props'; | ||
import { getTabArray, componentContext } from '../context'; | ||
import { log } from '../../_util/console'; | ||
import { objectValues } from '../../_util/tools'; | ||
"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 component2 = my.canIUse('component2'); | ||
Component({ | ||
props: VTabItemDefaultProps, | ||
props: _props.VTabItemDefaultProps, | ||
data: { | ||
@@ -18,3 +28,3 @@ component2: component2 | ||
didUnmount: function didUnmount() { | ||
delete getTabArray[this.$id]; | ||
delete _context.getTabArray[this.$id]; | ||
}, | ||
@@ -24,10 +34,10 @@ methods: { | ||
// 检测 tab-item 中的 tab 属性值正确性 | ||
if (!tab || typeof tab !== 'object') { | ||
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 " + typeof tab + "\uFF0C\u503C\uFF1A" + tab); | ||
} else if (!(tab != null && tab.title)) { | ||
log.error('VTabItem', "tab \u7684\u503C\u4E2D\u7F3A\u5C11\u5173\u952E title \u503C\uFF0C\u5F53\u524D\u7684 tab \u503C\u4E3A " + JSON.stringify(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.count && typeof (tab == null ? void 0 : tab.count) !== 'number') { | ||
log.error('VTabItem', "tab \u4E2D\u7684 count \u7C7B\u578B\u4E0D\u5339\u914D\uFF0C\u5F53\u524D\u7684 count \u503C\u4E3A " + (tab == null ? void 0 : tab.count) + "\uFF0C \u7C7B\u578B\u4E3A " + typeof (tab == null ? void 0 : tab.count)); | ||
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))); | ||
} | ||
@@ -42,5 +52,5 @@ }, | ||
getTabArray[this.$id] = tab; | ||
_context.getTabArray[this.$id] = tab; | ||
setTimeout(function () { | ||
componentContext.update(objectValues(getTabArray)); | ||
_context.componentContext.update((0, _tools.objectValues)(_context.getTabArray)); | ||
}, 0); | ||
@@ -47,0 +57,0 @@ } |
@@ -1,1 +0,8 @@ | ||
export const VTabItemDefaultProps = {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.VTabItemDefaultProps = void 0; | ||
var VTabItemDefaultProps = {}; | ||
exports.VTabItemDefaultProps = VTabItemDefaultProps; |
{ | ||
"name": "antd-mini", | ||
"version": "0.0.4-beta.1", | ||
"version": "0.0.4", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "minidev dev --less --typescript --no-source-map", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
353505
6693