taro-ui 3.1.0-beta.5 → 3.1.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +133 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +133 -28
- package/dist/index.js.map +1 -1
- package/dist/style/components/list.scss +1 -0
- package/lib/components/calendar/common/plugins.js +9 -8
- package/lib/components/calendar/common/plugins.js.map +1 -1
- package/lib/components/modal/index.js +1 -1
- package/lib/components/modal/index.js.map +1 -1
- package/lib/components/swipe-action/index.js +52 -20
- package/lib/components/swipe-action/index.js.map +1 -1
- package/package.json +4 -4
- package/rn/components/toast/index.tsx +1 -1
- package/types/swipe-action.d.ts +6 -2
- package/CHANGELOG.md +0 -1176
- package/LICENSE +0 -21
package/dist/index.esm.js
CHANGED
|
@@ -44,6 +44,44 @@ var __assign = function() {
|
|
|
44
44
|
return __assign.apply(this, arguments);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
48
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
49
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
51
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
52
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
53
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function __generator(thisArg, body) {
|
|
58
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
59
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
60
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
61
|
+
function step(op) {
|
|
62
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
63
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
64
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
65
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
66
|
+
switch (op[0]) {
|
|
67
|
+
case 0: case 1: t = op; break;
|
|
68
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
69
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
70
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
71
|
+
default:
|
|
72
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
73
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
74
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
75
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
76
|
+
if (t[2]) _.ops.pop();
|
|
77
|
+
_.trys.pop(); continue;
|
|
78
|
+
}
|
|
79
|
+
op = body.call(thisArg, _);
|
|
80
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
81
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
47
85
|
function __read(o, n) {
|
|
48
86
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49
87
|
if (!m) return o;
|
|
@@ -1426,6 +1464,20 @@ function delayQuerySelector(selectorStr, delayTime) {
|
|
|
1426
1464
|
});
|
|
1427
1465
|
});
|
|
1428
1466
|
}
|
|
1467
|
+
function delayGetClientRect(_a) {
|
|
1468
|
+
var selectorStr = _a.selectorStr, _b = _a.delayTime, delayTime = _b === void 0 ? 500 : _b;
|
|
1469
|
+
var selector = Taro.createSelectorQuery();
|
|
1470
|
+
return new Promise(function (resolve) {
|
|
1471
|
+
delay(delayTime).then(function () {
|
|
1472
|
+
selector
|
|
1473
|
+
.select(selectorStr)
|
|
1474
|
+
.boundingClientRect()
|
|
1475
|
+
.exec(function (res) {
|
|
1476
|
+
resolve(res);
|
|
1477
|
+
});
|
|
1478
|
+
});
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1429
1481
|
function uuid(len, radix) {
|
|
1430
1482
|
if (len === void 0) { len = 8; }
|
|
1431
1483
|
if (radix === void 0) { radix = 16; }
|
|
@@ -3634,7 +3686,7 @@ var AtModal = /** @class */ (function (_super) {
|
|
|
3634
3686
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
3635
3687
|
// @ts-ignore
|
|
3636
3688
|
dangerouslySetInnerHTML: {
|
|
3637
|
-
__html: content.replace(
|
|
3689
|
+
__html: content.replace(/\\n/g, '<br/>')
|
|
3638
3690
|
} })) : (React.createElement(Text, null, content))))),
|
|
3639
3691
|
isRenderAction && (React.createElement(AtModalAction, { isSimple: true },
|
|
3640
3692
|
cancelText && (React.createElement(Button, { onClick: this.handleCancel }, cancelText)),
|
|
@@ -5179,7 +5231,8 @@ var AtSwipeAction = /** @class */ (function (_super) {
|
|
|
5179
5231
|
}
|
|
5180
5232
|
};
|
|
5181
5233
|
_this.onTouchEnd = function (e) {
|
|
5182
|
-
|
|
5234
|
+
var maxOffsetSize = _this.state.maxOffsetSize;
|
|
5235
|
+
if (_this.moveX === -maxOffsetSize) {
|
|
5183
5236
|
_this._reset(true);
|
|
5184
5237
|
_this.handleOpened(e);
|
|
5185
5238
|
return;
|
|
@@ -5194,7 +5247,7 @@ var AtSwipeAction = /** @class */ (function (_super) {
|
|
|
5194
5247
|
_this.handleClosed(e);
|
|
5195
5248
|
return;
|
|
5196
5249
|
}
|
|
5197
|
-
if (Math.abs(_this.moveX) <
|
|
5250
|
+
if (Math.abs(_this.moveX) < maxOffsetSize * _this.moveRatio) {
|
|
5198
5251
|
_this._reset(false);
|
|
5199
5252
|
_this.handleClosed(e);
|
|
5200
5253
|
}
|
|
@@ -5206,41 +5259,95 @@ var AtSwipeAction = /** @class */ (function (_super) {
|
|
|
5206
5259
|
_this.onChange = function (e) {
|
|
5207
5260
|
_this.moveX = e.detail.x;
|
|
5208
5261
|
};
|
|
5209
|
-
var isOpened = props.isOpened,
|
|
5210
|
-
_this.maxOffsetSize = maxDistance;
|
|
5262
|
+
var isOpened = props.isOpened, moveRatio = props.moveRatio;
|
|
5211
5263
|
_this.state = {
|
|
5212
5264
|
componentId: uuid(),
|
|
5213
5265
|
// eslint-disable-next-line no-extra-boolean-cast
|
|
5214
|
-
offsetSize:
|
|
5266
|
+
offsetSize: 0,
|
|
5215
5267
|
_isOpened: !!isOpened,
|
|
5216
|
-
needAnimation: false
|
|
5268
|
+
needAnimation: false,
|
|
5269
|
+
eleWidth: 0,
|
|
5270
|
+
maxOffsetSize: 0
|
|
5217
5271
|
};
|
|
5218
5272
|
_this.moveX = _this.state.offsetSize;
|
|
5219
|
-
_this.eleWidth = areaWidth;
|
|
5220
5273
|
_this.moveRatio = moveRatio || 0.5;
|
|
5221
5274
|
return _this;
|
|
5222
5275
|
}
|
|
5276
|
+
AtSwipeAction.prototype.componentDidMount = function () {
|
|
5277
|
+
this.getAreaWidth();
|
|
5278
|
+
};
|
|
5279
|
+
// 当 eleWidth 发生变化时,需要重新计算 maxOffsetSize
|
|
5280
|
+
AtSwipeAction.prototype.componentDidUpdate = function (_, prevState) {
|
|
5281
|
+
var eleWidth = this.state.eleWidth;
|
|
5282
|
+
if (prevState.eleWidth !== eleWidth) {
|
|
5283
|
+
this.getMaxOffsetSize();
|
|
5284
|
+
}
|
|
5285
|
+
};
|
|
5223
5286
|
AtSwipeAction.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
|
|
5224
5287
|
var isOpened = nextProps.isOpened;
|
|
5225
|
-
var
|
|
5288
|
+
var _a = this.state, _isOpened = _a._isOpened, maxOffsetSize = _a.maxOffsetSize;
|
|
5226
5289
|
if (isOpened !== _isOpened) {
|
|
5227
|
-
this.moveX = isOpened ? 0 :
|
|
5290
|
+
this.moveX = isOpened ? 0 : maxOffsetSize;
|
|
5228
5291
|
this._reset(!!isOpened); // TODO: Check behavior
|
|
5229
5292
|
}
|
|
5230
5293
|
};
|
|
5294
|
+
/**
|
|
5295
|
+
* 获取滑动区域宽度
|
|
5296
|
+
*/
|
|
5297
|
+
AtSwipeAction.prototype.getAreaWidth = function () {
|
|
5298
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5299
|
+
var systemInfo;
|
|
5300
|
+
return __generator(this, function (_a) {
|
|
5301
|
+
switch (_a.label) {
|
|
5302
|
+
case 0: return [4 /*yield*/, Taro.getSystemInfo()];
|
|
5303
|
+
case 1:
|
|
5304
|
+
systemInfo = _a.sent();
|
|
5305
|
+
this.setState({
|
|
5306
|
+
eleWidth: systemInfo.windowWidth
|
|
5307
|
+
});
|
|
5308
|
+
return [2 /*return*/];
|
|
5309
|
+
}
|
|
5310
|
+
});
|
|
5311
|
+
});
|
|
5312
|
+
};
|
|
5313
|
+
/**
|
|
5314
|
+
* 获取最大偏移量
|
|
5315
|
+
*/
|
|
5316
|
+
AtSwipeAction.prototype.getMaxOffsetSize = function () {
|
|
5317
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5318
|
+
var componentId, actionOptionsRect, maxOffsetSize;
|
|
5319
|
+
return __generator(this, function (_a) {
|
|
5320
|
+
switch (_a.label) {
|
|
5321
|
+
case 0:
|
|
5322
|
+
componentId = this.state.componentId;
|
|
5323
|
+
return [4 /*yield*/, delayGetClientRect({
|
|
5324
|
+
selectorStr: "#swipeActionOptions-" + componentId
|
|
5325
|
+
})];
|
|
5326
|
+
case 1:
|
|
5327
|
+
actionOptionsRect = _a.sent();
|
|
5328
|
+
maxOffsetSize = actionOptionsRect[0].width;
|
|
5329
|
+
this.setState({
|
|
5330
|
+
maxOffsetSize: maxOffsetSize
|
|
5331
|
+
});
|
|
5332
|
+
return [2 /*return*/];
|
|
5333
|
+
}
|
|
5334
|
+
});
|
|
5335
|
+
});
|
|
5336
|
+
};
|
|
5231
5337
|
AtSwipeAction.prototype._reset = function (isOpened) {
|
|
5232
5338
|
var _this = this;
|
|
5233
5339
|
if (isOpened) {
|
|
5340
|
+
var maxOffsetSize = this.state.maxOffsetSize;
|
|
5234
5341
|
if (process.env.TARO_ENV === 'jd') {
|
|
5235
5342
|
this.setState({
|
|
5236
5343
|
_isOpened: true,
|
|
5237
|
-
offsetSize: -
|
|
5344
|
+
offsetSize: -maxOffsetSize + 0.01
|
|
5238
5345
|
});
|
|
5239
5346
|
}
|
|
5240
5347
|
else {
|
|
5241
5348
|
this.setState({
|
|
5242
5349
|
_isOpened: true,
|
|
5243
|
-
offsetSize: -
|
|
5350
|
+
offsetSize: -maxOffsetSize
|
|
5244
5351
|
});
|
|
5245
5352
|
}
|
|
5246
5353
|
}
|
|
@@ -5257,24 +5364,21 @@ var AtSwipeAction = /** @class */ (function (_super) {
|
|
|
5257
5364
|
};
|
|
5258
5365
|
AtSwipeAction.prototype.render = function () {
|
|
5259
5366
|
var _this = this;
|
|
5260
|
-
var _a = this.state, componentId = _a.componentId, offsetSize = _a.offsetSize;
|
|
5367
|
+
var _a = this.state, componentId = _a.componentId, maxOffsetSize = _a.maxOffsetSize, eleWidth = _a.eleWidth, offsetSize = _a.offsetSize;
|
|
5261
5368
|
var _b = this.props, options = _b.options, disabled = _b.disabled;
|
|
5262
5369
|
var rootClass = classnames('at-swipe-action', this.props.className);
|
|
5263
5370
|
return (React.createElement(View, { id: "swipeAction-" + componentId, className: rootClass, style: {
|
|
5264
|
-
width:
|
|
5371
|
+
width: eleWidth + "px"
|
|
5265
5372
|
} },
|
|
5266
5373
|
React.createElement(MovableArea, { className: 'at-swipe-action__area', style: {
|
|
5267
|
-
width:
|
|
5268
|
-
transform: "translate(-" + this.maxOffsetSize + "px, 0)"
|
|
5374
|
+
width: eleWidth + "px"
|
|
5269
5375
|
} },
|
|
5270
5376
|
React.createElement(MovableView, { className: 'at-swipe-action__content', direction: 'horizontal', damping: 50, x: offsetSize, onTouchEnd: this.onTouchEnd, onChange: this.onChange, disabled: disabled, style: {
|
|
5271
|
-
width:
|
|
5272
|
-
left: this.maxOffsetSize + "px"
|
|
5377
|
+
width: eleWidth + maxOffsetSize + "px"
|
|
5273
5378
|
} },
|
|
5274
5379
|
this.props.children,
|
|
5275
5380
|
Array.isArray(options) && options.length > 0 ? (React.createElement(AtSwipeActionOptions, { options: options, componentId: componentId, customStyle: {
|
|
5276
|
-
|
|
5277
|
-
opacity: 1
|
|
5381
|
+
opacity: maxOffsetSize ? 1 : 0
|
|
5278
5382
|
} }, options.map(function (item, key) { return (React.createElement(View, { key: item.text + "-" + key, style: item.style, onClick: function (e) { return _this.handleClick(item, key, e); }, className: classnames('at-swipe-action__option', item.className) },
|
|
5279
5383
|
React.createElement(Text, { className: 'option__text' }, item.text))); }))) : null))));
|
|
5280
5384
|
};
|
|
@@ -7639,11 +7743,12 @@ function handleActive(args, item) {
|
|
|
7639
7743
|
var dayjsEnd = dayjs_min(end);
|
|
7640
7744
|
var dayjsStart = start ? dayjs_min(start) : dayjsEnd;
|
|
7641
7745
|
item.isSelected =
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
item.
|
|
7646
|
-
item.
|
|
7746
|
+
_value.isSame(dayjsEnd) ||
|
|
7747
|
+
_value.isSame(dayjsStart) ||
|
|
7748
|
+
(_value.isAfter(dayjsStart) && _value.isBefore(dayjsEnd));
|
|
7749
|
+
item.isSelectedHead = _value.isSame(dayjsStart);
|
|
7750
|
+
item.isSelectedTail = _value.isSame(dayjsEnd);
|
|
7751
|
+
item.isToday = _value.diff(dayjs_min(Date.now()).startOf('day'), 'day') === 0;
|
|
7647
7752
|
return item;
|
|
7648
7753
|
}
|
|
7649
7754
|
function handleMarks(args, item) {
|
|
@@ -7685,8 +7790,8 @@ function handleDisabled(args, item) {
|
|
|
7685
7790
|
var dayjsMinDate = dayjs_min(minDate);
|
|
7686
7791
|
var dayjsMaxDate = dayjs_min(maxDate);
|
|
7687
7792
|
item.isDisabled =
|
|
7688
|
-
!!(minDate &&
|
|
7689
|
-
!!(maxDate &&
|
|
7793
|
+
!!(minDate && _value.isBefore(dayjsMinDate)) ||
|
|
7794
|
+
!!(maxDate && _value.isAfter(dayjsMaxDate));
|
|
7690
7795
|
return item;
|
|
7691
7796
|
}
|
|
7692
7797
|
function handleValid(args, item) {
|
|
@@ -7699,7 +7804,7 @@ function handleValid(args, item) {
|
|
|
7699
7804
|
});
|
|
7700
7805
|
item.isDisabled = !isInclude;
|
|
7701
7806
|
}
|
|
7702
|
-
delete item._value
|
|
7807
|
+
// delete item._value
|
|
7703
7808
|
return item;
|
|
7704
7809
|
}
|
|
7705
7810
|
var plugins = [handleActive, handleMarks, handleDisabled, handleValid];
|