@nutui/nutui-react-taro 3.0.1 → 3.0.2
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/cjs/hooks/use-client-rect.js +1 -0
- package/dist/cjs/packages/datepicker/style/style.css +70 -0
- package/dist/cjs/packages/datepickerview/style/index.js +1 -0
- package/dist/cjs/packages/datepickerview/style/style.css +70 -0
- package/dist/cjs/packages/fixednav/fixednav.js +20 -14
- package/dist/cjs/packages/fixednav/style/fixednav.scss +0 -15
- package/dist/cjs/packages/fixednav/style/style.css +0 -14
- package/dist/cjs/packages/fixednav/style/style.harmony.css +0 -14
- package/dist/cjs/packages/form/form.d.ts +2 -0
- package/dist/cjs/packages/form/form.js +11 -2
- package/dist/cjs/packages/form/index.d.ts +2 -1
- package/dist/cjs/packages/form/index.js +1 -0
- package/dist/cjs/packages/form/style/form.scss +0 -66
- package/dist/cjs/packages/form/style/style.css +31 -21
- package/dist/cjs/packages/form/style/style.harmony.css +1 -67
- package/dist/cjs/packages/form/types.d.ts +2 -1
- package/dist/cjs/packages/form/useform.d.ts +2 -1
- package/dist/cjs/packages/form/useform.js +338 -247
- package/dist/cjs/packages/formitem/formitem.d.ts +1 -0
- package/dist/cjs/packages/formitem/formitem.js +57 -45
- package/dist/cjs/packages/formitem/style/formitem.scss +101 -21
- package/dist/cjs/packages/formitem/style/style.css +89 -12
- package/dist/cjs/packages/formitem/style/style.harmony.css +89 -12
- package/dist/cjs/packages/input/input.js +3 -1
- package/dist/cjs/packages/picker/style/index.js +1 -0
- package/dist/cjs/packages/picker/style/style.css +70 -0
- package/dist/cjs/packages/signature/signature.js +1 -1
- package/dist/cjs/packages/swipe/style/style.css +3 -3
- package/dist/cjs/packages/swipe/style/style.harmony.css +3 -3
- package/dist/cjs/packages/swipe/style/swipe.scss +7 -3
- package/dist/cjs/packages/swipe/swipe.js +14 -15
- package/dist/cjs/utils/get-rect-by-taro.d.ts +1 -1
- package/dist/cjs/utils/get-rect-by-taro.js +4 -1
- package/dist/cjs/utils/get-system-info.js +4 -5
- package/dist/cjs/utils/merge.d.ts +14 -0
- package/dist/cjs/utils/merge.js +98 -0
- package/dist/cjs/utils/platform-taro.js +4 -5
- package/dist/cjs/utils/to-array.d.ts +1 -0
- package/dist/cjs/utils/to-array.js +18 -0
- package/dist/es/hooks/use-client-rect.js +1 -0
- package/dist/es/packages/datepicker/style/style.css +70 -0
- package/dist/es/packages/datepickerview/style/index.js +1 -0
- package/dist/es/packages/datepickerview/style/style.css +70 -0
- package/dist/es/packages/fixednav/fixednav.js +20 -14
- package/dist/es/packages/fixednav/style/fixednav.scss +0 -15
- package/dist/es/packages/fixednav/style/style.css +0 -14
- package/dist/es/packages/fixednav/style/style.harmony.css +0 -14
- package/dist/es/packages/form/form.d.ts +10 -0
- package/dist/es/packages/form/form.js +11 -2
- package/dist/es/packages/form/index.d.ts +2 -1
- package/dist/es/packages/form/index.js +2 -1
- package/dist/es/packages/form/style/form.scss +0 -66
- package/dist/es/packages/form/style/style.css +31 -21
- package/dist/es/packages/form/style/style.harmony.css +1 -67
- package/dist/es/packages/form/types.d.ts +2 -1
- package/dist/es/packages/form/useform.d.ts +2 -1
- package/dist/es/packages/form/useform.js +336 -248
- package/dist/es/packages/formitem/formitem.d.ts +1 -0
- package/dist/es/packages/formitem/formitem.js +58 -46
- package/dist/es/packages/formitem/style/formitem.scss +101 -21
- package/dist/es/packages/formitem/style/style.css +89 -12
- package/dist/es/packages/formitem/style/style.harmony.css +89 -12
- package/dist/es/packages/input/input.js +3 -1
- package/dist/es/packages/picker/style/index.js +1 -0
- package/dist/es/packages/picker/style/style.css +70 -0
- package/dist/es/packages/signature/signature.js +2 -2
- package/dist/es/packages/swipe/style/style.css +3 -3
- package/dist/es/packages/swipe/style/style.harmony.css +3 -3
- package/dist/es/packages/swipe/style/swipe.scss +7 -3
- package/dist/es/packages/swipe/swipe.js +14 -15
- package/dist/es/utils/get-rect-by-taro.d.ts +1 -1
- package/dist/es/utils/get-rect-by-taro.js +4 -1
- package/dist/es/utils/get-system-info.js +4 -4
- package/dist/es/utils/merge.d.ts +14 -0
- package/dist/es/utils/merge.js +68 -0
- package/dist/es/utils/platform-taro.js +4 -4
- package/dist/es/utils/to-array.d.ts +1 -0
- package/dist/es/utils/to-array.js +8 -0
- package/dist/nutui.react.umd.js +4301 -4084
- package/dist/style.css +1 -1
- package/dist/style.scss +34 -34
- package/package.json +1 -1
|
@@ -383,6 +383,76 @@
|
|
|
383
383
|
right: 0;
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
+
.nut-pickerview {
|
|
387
|
+
--nutui-picker-item-height: 36px;
|
|
388
|
+
position: relative;
|
|
389
|
+
display: flex;
|
|
390
|
+
width: 100%;
|
|
391
|
+
height: calc(var(--nutui-picker-item-height, 36px) * 7);
|
|
392
|
+
overflow: hidden;
|
|
393
|
+
}
|
|
394
|
+
.nut-pickerview-mask, .nut-pickerview-indicator {
|
|
395
|
+
position: absolute;
|
|
396
|
+
left: 0;
|
|
397
|
+
right: 0;
|
|
398
|
+
z-index: 3;
|
|
399
|
+
pointer-events: none;
|
|
400
|
+
}
|
|
401
|
+
.nut-pickerview-mask {
|
|
402
|
+
top: 0;
|
|
403
|
+
bottom: 0;
|
|
404
|
+
background-image: var(--picker-mask-background, linear-gradient(180deg, var(--nutui-white-12), var(--nutui-white-7)), linear-gradient(0deg, var(--nutui-white-12), var(--nutui-white-7)));
|
|
405
|
+
background-position: top, bottom;
|
|
406
|
+
background-size: 100% calc((var(--nutui-picker-item-height, 36px) * 7 - var(--nutui-picker-item-height, 36px)) / 2);
|
|
407
|
+
background-repeat: no-repeat;
|
|
408
|
+
transform: translateZ(0);
|
|
409
|
+
}
|
|
410
|
+
.nut-pickerview-indicator {
|
|
411
|
+
top: calc((var(--nutui-picker-item-height, 36px) * 7 - var(--nutui-picker-item-height, 36px)) / 2);
|
|
412
|
+
height: var(--nutui-picker-item-height, 36px);
|
|
413
|
+
border: var(--nutui-picker-item-active-line-border, 1px solid var(--nutui-color-border, rgba(0, 0, 0, 0.06)));
|
|
414
|
+
border-left: 0;
|
|
415
|
+
border-right: 0;
|
|
416
|
+
box-sizing: border-box;
|
|
417
|
+
}
|
|
418
|
+
.nut-pickerview-list {
|
|
419
|
+
position: relative;
|
|
420
|
+
flex: 1;
|
|
421
|
+
height: calc(var(--nutui-picker-item-height, 36px) * 7);
|
|
422
|
+
overflow: hidden;
|
|
423
|
+
touch-action: none;
|
|
424
|
+
}
|
|
425
|
+
.nut-pickerview-roller {
|
|
426
|
+
position: absolute;
|
|
427
|
+
top: calc((var(--nutui-picker-item-height, 36px) * 7 - var(--nutui-picker-item-height, 36px)) / 2);
|
|
428
|
+
width: 100%;
|
|
429
|
+
height: var(--nutui-picker-item-height, 36px);
|
|
430
|
+
z-index: 1;
|
|
431
|
+
transform-style: preserve-3d;
|
|
432
|
+
}
|
|
433
|
+
.nut-pickerview-roller-item {
|
|
434
|
+
position: absolute;
|
|
435
|
+
top: 0;
|
|
436
|
+
backface-visibility: hidden;
|
|
437
|
+
-moz-backface-visibility: hidden;
|
|
438
|
+
-webkit-backface-visibility: hidden;
|
|
439
|
+
}
|
|
440
|
+
.nut-pickerview-roller-item-hidden {
|
|
441
|
+
visibility: hidden;
|
|
442
|
+
opacity: 0;
|
|
443
|
+
}
|
|
444
|
+
.nut-pickerview-roller-item, .nut-pickerview-roller-item-tiled {
|
|
445
|
+
width: 100%;
|
|
446
|
+
height: var(--nutui-picker-item-height, 36px);
|
|
447
|
+
line-height: var(--nutui-picker-item-height, 36px);
|
|
448
|
+
color: var(--nutui-picker-item-text-color, var(--nutui-color-title, #1a1a1a));
|
|
449
|
+
font-size: var(--nutui-picker-item-text-font-size, var(--nutui-font-size-base, 14px));
|
|
450
|
+
text-align: center;
|
|
451
|
+
overflow: hidden;
|
|
452
|
+
text-overflow: ellipsis;
|
|
453
|
+
white-space: nowrap;
|
|
454
|
+
}
|
|
455
|
+
|
|
386
456
|
.nut-picker {
|
|
387
457
|
background-color: var(--nutui-color-background-overlay, #ffffff);
|
|
388
458
|
width: 100%;
|
|
@@ -4,7 +4,7 @@ import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_
|
|
|
4
4
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
5
5
|
import React, { useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
6
6
|
import { getEnv, nextTick, createSelectorQuery, canvasToTempFilePath } from "@tarojs/taro";
|
|
7
|
-
import { View } from "@tarojs/components";
|
|
7
|
+
import { Canvas, View } from "@tarojs/components";
|
|
8
8
|
import { ComponentDefaults } from "../../utils/typings";
|
|
9
9
|
var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
|
|
10
10
|
canvasId: 'spcanvas',
|
|
@@ -153,7 +153,7 @@ var InternalSignature = function(props, ref) {
|
|
|
153
153
|
onTouchStart: startEventHandler,
|
|
154
154
|
onTouchMove: moveEventHandler,
|
|
155
155
|
onTouchEnd: endEventHandler
|
|
156
|
-
}) : /*#__PURE__*/ React.createElement(
|
|
156
|
+
}) : /*#__PURE__*/ React.createElement(Canvas, {
|
|
157
157
|
id: canvasId,
|
|
158
158
|
ref: canvasRef,
|
|
159
159
|
"canvas-id": canvasId,
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
.nut-swipe-left, .nut-swipe-right {
|
|
23
23
|
position: absolute;
|
|
24
24
|
top: 0;
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-direction: row;
|
|
27
25
|
}
|
|
28
26
|
.nut-swipe-left {
|
|
29
27
|
left: 0;
|
|
28
|
+
transform: translate(-100%, 0px);
|
|
30
29
|
}
|
|
31
30
|
.nut-swipe-right {
|
|
32
|
-
|
|
31
|
+
right: 0px;
|
|
32
|
+
transform: translate(100%, 0px);
|
|
33
33
|
}
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
.nut-swipe-left, .nut-swipe-right {
|
|
23
23
|
position: absolute;
|
|
24
24
|
top: 0;
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-direction: row;
|
|
27
25
|
}
|
|
28
26
|
.nut-swipe-left {
|
|
29
27
|
left: 0;
|
|
28
|
+
transform: translate(-100%, 0px);
|
|
30
29
|
}
|
|
31
30
|
.nut-swipe-right {
|
|
32
|
-
|
|
31
|
+
right: 0px;
|
|
32
|
+
transform: translate(100%, 0px);
|
|
33
33
|
}
|
|
@@ -20,15 +20,19 @@
|
|
|
20
20
|
&-right {
|
|
21
21
|
position: absolute;
|
|
22
22
|
top: 0;
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: row;
|
|
23
|
+
//display: flex;
|
|
24
|
+
//flex-direction: row;
|
|
25
|
+
//flex-shrink: 0;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
&-left {
|
|
28
29
|
left: 0;
|
|
30
|
+
transform: translate(-100%, 0px);
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
&-right {
|
|
32
|
-
left: 100%;
|
|
34
|
+
//left: 100%;
|
|
35
|
+
right: 0px;
|
|
36
|
+
transform: translate(100%, 0px);
|
|
33
37
|
}
|
|
34
38
|
}
|
|
@@ -6,12 +6,13 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
6
6
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
7
7
|
import classNames from "classnames";
|
|
8
8
|
import { View } from "@tarojs/components";
|
|
9
|
+
import { useReady } from "@tarojs/taro";
|
|
9
10
|
import { useTouch } from "../../hooks/use-touch";
|
|
10
11
|
import { getRectByTaro } from "../../utils/get-rect-by-taro";
|
|
11
12
|
import { ComponentDefaults } from "../../utils/typings";
|
|
12
13
|
import { harmony } from "../../utils/platform-taro";
|
|
13
|
-
import pxTransform from "../../utils/px-transform";
|
|
14
14
|
import { useRefState } from "../../hooks/use-ref-state";
|
|
15
|
+
import useUuid from "../../hooks/use-uuid";
|
|
15
16
|
function preventDefault(event, isStopPropagation) {
|
|
16
17
|
if (typeof event.cancelable !== 'boolean' || event.cancelable) {
|
|
17
18
|
event.preventDefault();
|
|
@@ -26,8 +27,11 @@ var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
|
|
|
26
27
|
export var Swipe = /*#__PURE__*/ forwardRef(function(props, instanceRef) {
|
|
27
28
|
var classPrefix = 'nut-swipe';
|
|
28
29
|
var touch = useTouch();
|
|
30
|
+
var uid = useUuid();
|
|
31
|
+
var leftId = "swipe-left-".concat(uid);
|
|
32
|
+
var rightId = "swipe-right-".concat(uid);
|
|
29
33
|
// 获取元素的时候要在页面 onReady 后,需要参考小程序的事件周期
|
|
30
|
-
|
|
34
|
+
useReady(function() {
|
|
31
35
|
var getWidth = /*#__PURE__*/ function() {
|
|
32
36
|
var _ref = _async_to_generator(function() {
|
|
33
37
|
var leftRect, rightRect;
|
|
@@ -40,7 +44,7 @@ export var Swipe = /*#__PURE__*/ forwardRef(function(props, instanceRef) {
|
|
|
40
44
|
];
|
|
41
45
|
return [
|
|
42
46
|
4,
|
|
43
|
-
getRectByTaro(leftWrapper.current)
|
|
47
|
+
getRectByTaro(leftWrapper.current, leftId)
|
|
44
48
|
];
|
|
45
49
|
case 1:
|
|
46
50
|
leftRect = _state.sent();
|
|
@@ -57,11 +61,10 @@ export var Swipe = /*#__PURE__*/ forwardRef(function(props, instanceRef) {
|
|
|
57
61
|
];
|
|
58
62
|
return [
|
|
59
63
|
4,
|
|
60
|
-
getRectByTaro(rightWrapper.current)
|
|
64
|
+
getRectByTaro(rightWrapper.current, rightId)
|
|
61
65
|
];
|
|
62
66
|
case 3:
|
|
63
67
|
rightRect = _state.sent();
|
|
64
|
-
console.log('actionWidth.current.left', rightRect.width);
|
|
65
68
|
rightRect && setActionWidth(function(v) {
|
|
66
69
|
return _object_spread_props(_object_spread({}, v), {
|
|
67
70
|
right: rightRect.width
|
|
@@ -82,7 +85,7 @@ export var Swipe = /*#__PURE__*/ forwardRef(function(props, instanceRef) {
|
|
|
82
85
|
setTimeout(function() {
|
|
83
86
|
return getWidth();
|
|
84
87
|
});
|
|
85
|
-
}
|
|
88
|
+
});
|
|
86
89
|
var _$_object_spread = _object_spread({}, defaultProps, props), children = _$_object_spread.children, className = _$_object_spread.className, style = _$_object_spread.style;
|
|
87
90
|
var root = useRef();
|
|
88
91
|
var opened = useRef(false);
|
|
@@ -110,7 +113,7 @@ export var Swipe = /*#__PURE__*/ forwardRef(function(props, instanceRef) {
|
|
|
110
113
|
}
|
|
111
114
|
};
|
|
112
115
|
var wrapperStyle = {
|
|
113
|
-
transform: "translate(".concat(state.offset, "
|
|
116
|
+
transform: "translate(".concat(state.offset).concat(!harmony() ? 'px' : '', ", 0)"),
|
|
114
117
|
transitionDuration: state.dragging ? '0s' : '.6s'
|
|
115
118
|
};
|
|
116
119
|
var onTouchStart = /*#__PURE__*/ function() {
|
|
@@ -119,14 +122,13 @@ export var Swipe = /*#__PURE__*/ forwardRef(function(props, instanceRef) {
|
|
|
119
122
|
return _ts_generator(this, function(_state) {
|
|
120
123
|
switch(_state.label){
|
|
121
124
|
case 0:
|
|
122
|
-
console.log('ontouchstart');
|
|
123
125
|
if (!leftWrapper.current) return [
|
|
124
126
|
3,
|
|
125
127
|
2
|
|
126
128
|
];
|
|
127
129
|
return [
|
|
128
130
|
4,
|
|
129
|
-
getRectByTaro(leftWrapper.current)
|
|
131
|
+
getRectByTaro(leftWrapper.current, leftId)
|
|
130
132
|
];
|
|
131
133
|
case 1:
|
|
132
134
|
leftRect = _state.sent();
|
|
@@ -143,7 +145,7 @@ export var Swipe = /*#__PURE__*/ forwardRef(function(props, instanceRef) {
|
|
|
143
145
|
];
|
|
144
146
|
return [
|
|
145
147
|
4,
|
|
146
|
-
getRectByTaro(rightWrapper.current)
|
|
148
|
+
getRectByTaro(rightWrapper.current, rightId)
|
|
147
149
|
];
|
|
148
150
|
case 3:
|
|
149
151
|
rightRect = _state.sent();
|
|
@@ -186,7 +188,7 @@ export var Swipe = /*#__PURE__*/ forwardRef(function(props, instanceRef) {
|
|
|
186
188
|
if (isEdge) {
|
|
187
189
|
preventDefault(event, true);
|
|
188
190
|
}
|
|
189
|
-
newState.offset = rangeCalculation(
|
|
191
|
+
newState.offset = rangeCalculation(touch.deltaX.current + startOffset.current, -actionWidth.current.right || 0, actionWidth.current.left || 0);
|
|
190
192
|
setState(newState);
|
|
191
193
|
}
|
|
192
194
|
};
|
|
@@ -253,13 +255,10 @@ export var Swipe = /*#__PURE__*/ forwardRef(function(props, instanceRef) {
|
|
|
253
255
|
var rightWrapper = useRef(null);
|
|
254
256
|
var renderActionContent = function(side) {
|
|
255
257
|
if (props["".concat(side, "Action")]) {
|
|
256
|
-
console.log('actionWidth xxx', actionWidth.current.left);
|
|
257
258
|
return /*#__PURE__*/ React.createElement(View, {
|
|
258
259
|
ref: side === 'left' ? leftWrapper : rightWrapper,
|
|
259
260
|
className: "".concat(classPrefix, "-").concat(side),
|
|
260
|
-
|
|
261
|
-
left: Number("".concat(-actionWidth.current.left))
|
|
262
|
-
} : {}),
|
|
261
|
+
id: side === 'left' ? leftId : rightId,
|
|
263
262
|
onClick: function(e) {
|
|
264
263
|
return handleOperate(e, side);
|
|
265
264
|
}
|
|
@@ -9,4 +9,4 @@ export interface Rect {
|
|
|
9
9
|
height: number;
|
|
10
10
|
}
|
|
11
11
|
export declare function makeRect(width: number, height: number): Rect;
|
|
12
|
-
export declare const getRectByTaro: (element: any) => Promise<Rect>;
|
|
12
|
+
export declare const getRectByTaro: (element: any, harmonyId?: string) => Promise<Rect>;
|
|
@@ -15,7 +15,10 @@ export function makeRect(width, height) {
|
|
|
15
15
|
}
|
|
16
16
|
export var getRectByTaro = /*#__PURE__*/ function() {
|
|
17
17
|
var _ref = _async_to_generator(function(element) {
|
|
18
|
+
var harmonyId;
|
|
19
|
+
var _arguments = arguments;
|
|
18
20
|
return _ts_generator(this, function(_state) {
|
|
21
|
+
harmonyId = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : '';
|
|
19
22
|
if (element) {
|
|
20
23
|
if (inBrowser) {
|
|
21
24
|
return [
|
|
@@ -27,7 +30,7 @@ export var getRectByTaro = /*#__PURE__*/ function() {
|
|
|
27
30
|
return [
|
|
28
31
|
2,
|
|
29
32
|
new Promise(function(resolve, reject) {
|
|
30
|
-
createSelectorQuery().select("#".concat(element.uid)).boundingClientRect().exec(function(param) {
|
|
33
|
+
createSelectorQuery().select("#".concat(harmonyId || element.uid)).boundingClientRect().exec(function(param) {
|
|
31
34
|
var _param = _sliced_to_array(param, 1), rects = _param[0];
|
|
32
35
|
resolve(rects);
|
|
33
36
|
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { canIUse, getAppBaseInfo as taroGetAppBaseInfo, getDeviceInfo as taroGetDeviceInfo, getSystemInfoSync, getWindowInfo as taroGetWindowInfo } from "@tarojs/taro";
|
|
2
2
|
/**
|
|
3
3
|
* 获取设备基础信息,兼容新旧 API
|
|
4
4
|
* @returns {IDeviceInfo} 设备基础信息
|
|
5
5
|
*/ export var getDeviceInfo = function() {
|
|
6
|
-
return
|
|
6
|
+
return canIUse('getDeviceInfo') ? taroGetDeviceInfo() : getSystemInfoSync();
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* 获取窗口信息,兼容新旧 API
|
|
10
10
|
* @returns {Taro.getWindowInfo.Result} 窗口信息
|
|
11
11
|
*/ export var getWindowInfo = function() {
|
|
12
|
-
return
|
|
12
|
+
return canIUse('getWindowInfo') ? taroGetWindowInfo() : getSystemInfoSync();
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* 获取应用基础信息,兼容新旧 API
|
|
16
16
|
* @returns {Taro.getAppBaseInfo.Result} 应用基础信息
|
|
17
17
|
*/ export var getAppBaseInfo = function() {
|
|
18
|
-
return
|
|
18
|
+
return canIUse('getAppBaseInfo') ? taroGetAppBaseInfo() : getSystemInfoSync();
|
|
19
19
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default main;
|
|
2
|
+
export declare function main(clone: boolean, ...items: any[]): any;
|
|
3
|
+
export declare function main(...items: any[]): any;
|
|
4
|
+
export declare namespace main {
|
|
5
|
+
var clone: typeof import("./merge").clone;
|
|
6
|
+
var isPlainObject: typeof import("./merge").isPlainObject;
|
|
7
|
+
var recursive: typeof import("./merge").recursive;
|
|
8
|
+
}
|
|
9
|
+
export declare function merge(clone: boolean, ...items: any[]): any;
|
|
10
|
+
export declare function merge(...items: any[]): any;
|
|
11
|
+
export declare function recursive(clone: boolean, ...items: any[]): any;
|
|
12
|
+
export declare function recursive(...items: any[]): any;
|
|
13
|
+
export declare function clone<T>(input: T): T;
|
|
14
|
+
export declare function isPlainObject(input: unknown): input is NonNullable<any>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
2
|
+
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
3
|
+
export default main;
|
|
4
|
+
export function main() {
|
|
5
|
+
for(var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++){
|
|
6
|
+
items[_key] = arguments[_key];
|
|
7
|
+
}
|
|
8
|
+
return merge.apply(void 0, _to_consumable_array(items));
|
|
9
|
+
}
|
|
10
|
+
main.clone = clone;
|
|
11
|
+
main.isPlainObject = isPlainObject;
|
|
12
|
+
main.recursive = recursive;
|
|
13
|
+
export function merge() {
|
|
14
|
+
for(var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++){
|
|
15
|
+
items[_key] = arguments[_key];
|
|
16
|
+
}
|
|
17
|
+
return _merge(items[0] === true, false, items);
|
|
18
|
+
}
|
|
19
|
+
export function recursive() {
|
|
20
|
+
for(var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++){
|
|
21
|
+
items[_key] = arguments[_key];
|
|
22
|
+
}
|
|
23
|
+
return _merge(items[0] === true, true, items);
|
|
24
|
+
}
|
|
25
|
+
export function clone(input) {
|
|
26
|
+
if (Array.isArray(input)) {
|
|
27
|
+
var output = [];
|
|
28
|
+
for(var index = 0; index < input.length; ++index)output.push(clone(input[index]));
|
|
29
|
+
return output;
|
|
30
|
+
}
|
|
31
|
+
if (isPlainObject(input)) {
|
|
32
|
+
var output1 = {};
|
|
33
|
+
// eslint-disable-next-line guard-for-in
|
|
34
|
+
for(var index1 in input)output1[index1] = clone(input[index1]);
|
|
35
|
+
return output1;
|
|
36
|
+
}
|
|
37
|
+
return input;
|
|
38
|
+
}
|
|
39
|
+
export function isPlainObject(input) {
|
|
40
|
+
if (input === null || (typeof input === "undefined" ? "undefined" : _type_of(input)) !== 'object') return false;
|
|
41
|
+
if (Object.getPrototypeOf(input) === null) return true;
|
|
42
|
+
var ref = input;
|
|
43
|
+
while(Object.getPrototypeOf(ref) !== null)ref = Object.getPrototypeOf(ref);
|
|
44
|
+
return Object.getPrototypeOf(input) === ref;
|
|
45
|
+
}
|
|
46
|
+
function _recursiveMerge(base, extend) {
|
|
47
|
+
if (!isPlainObject(base) || !isPlainObject(extend)) return extend;
|
|
48
|
+
for(var key in extend){
|
|
49
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
|
|
50
|
+
base[key] = isPlainObject(base[key]) && isPlainObject(extend[key]) ? _recursiveMerge(base[key], extend[key]) : extend[key];
|
|
51
|
+
}
|
|
52
|
+
return base;
|
|
53
|
+
}
|
|
54
|
+
function _merge(isClone, isRecursive, items) {
|
|
55
|
+
var result;
|
|
56
|
+
if (isClone || !isPlainObject(result = items.shift())) result = {};
|
|
57
|
+
for(var index = 0; index < items.length; ++index){
|
|
58
|
+
var item = items[index];
|
|
59
|
+
// eslint-disable-next-line no-continue
|
|
60
|
+
if (!isPlainObject(item)) continue;
|
|
61
|
+
for(var key in item){
|
|
62
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
|
|
63
|
+
var value = isClone ? clone(item[key]) : item[key];
|
|
64
|
+
result[key] = isRecursive ? _recursiveMerge(result[key], value) : value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getEnv } from "@tarojs/taro";
|
|
2
2
|
export var harmony = function() {
|
|
3
3
|
return [
|
|
4
4
|
'harmony',
|
|
5
5
|
'harmonyhybrid',
|
|
6
6
|
'jdharmony'
|
|
7
|
-
].includes(
|
|
7
|
+
].includes(getEnv().toLowerCase());
|
|
8
8
|
};
|
|
9
9
|
export var web = function() {
|
|
10
10
|
return [
|
|
11
11
|
'web'
|
|
12
|
-
].includes(
|
|
12
|
+
].includes(getEnv().toLowerCase());
|
|
13
13
|
};
|
|
14
14
|
export var miniprogram = function() {
|
|
15
15
|
return [
|
|
16
16
|
'mini'
|
|
17
|
-
].includes(
|
|
17
|
+
].includes(getEnv().toLowerCase());
|
|
18
18
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toArray<T>(value?: T | T[] | null): T[];
|