sard-uniapp 1.11.2 → 1.12.0
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/CHANGELOG.md +25 -0
- package/README.md +3 -2
- package/components/action-sheet/action-sheet.vue +8 -2
- package/components/action-sheet/index.scss +1 -1
- package/components/back-top/back-top.d.ts +1 -1
- package/components/badge/badge.vue +1 -1
- package/components/button/button.d.ts +1 -0
- package/components/button/button.vue +2 -0
- package/components/button/common.d.ts +2 -0
- package/components/button/index.scss +6 -1
- package/components/calendar/calendar.d.ts +1 -1
- package/components/calendar/calendar.vue +49 -22
- package/components/calendar/index.scss +5 -5
- package/components/calendar/variables.scss +1 -1
- package/components/calendar-input/calendar-input.d.ts +1 -1
- package/components/calendar-month/index.scss +1 -0
- package/components/cascader/cascader.d.ts +6 -6
- package/components/cascader/cascader.vue +9 -4
- package/components/cascader/common.d.ts +3 -3
- package/components/cascader/index.scss +1 -0
- package/components/checkbox-input/checkbox-input.vue +59 -32
- package/components/checkbox-input/index.scss +4 -0
- package/components/config/index.d.ts +23 -0
- package/components/config/index.js +47 -18
- package/components/crop-image/common.d.ts +32 -0
- package/components/crop-image/common.js +2 -0
- package/components/crop-image/crop-image.d.ts +19 -0
- package/components/crop-image/crop-image.vue +671 -0
- package/components/crop-image/index.d.ts +1 -0
- package/components/crop-image/index.scss +81 -0
- package/components/crop-image-agent/common.d.ts +19 -0
- package/components/crop-image-agent/common.js +16 -0
- package/components/crop-image-agent/crop-image-agent.d.ts +9 -0
- package/components/crop-image-agent/crop-image-agent.vue +70 -0
- package/components/crop-image-agent/index.d.ts +1 -0
- package/components/crop-image-agent/index.js +1 -0
- package/components/datetime-picker-input/datetime-picker-input.vue +4 -4
- package/components/datetime-range-picker/datetime-range-picker.vue +4 -3
- package/components/datetime-range-picker-input/datetime-range-picker-input.vue +4 -4
- package/components/dialog/common.d.ts +2 -3
- package/components/dialog/dialog.d.ts +6 -13
- package/components/dialog/dialog.vue +15 -4
- package/components/dialog-agent/dialog-agent.d.ts +1 -1
- package/components/dropdown-item/dropdown-item.vue +6 -6
- package/components/fab/fab.d.ts +1 -1
- package/components/floating-bubble/floating-bubble.vue +14 -19
- package/components/form-item/form-item.vue +4 -3
- package/components/grid/common.d.ts +4 -0
- package/components/grid-item/grid-item.vue +33 -18
- package/components/grid-item/index.scss +12 -4
- package/components/icon/index.scss +1 -0
- package/components/icon/sari.scss +9 -1
- package/components/indexes/common.d.ts +3 -5
- package/components/indexes/indexes.d.ts +2 -0
- package/components/indexes/indexes.vue +45 -109
- package/components/indexes-anchor/indexes-anchor.vue +9 -9
- package/components/indexes-nav/indexes-nav.vue +26 -22
- package/components/input/input.d.ts +4 -4
- package/components/loading/index.scss +1 -1
- package/components/locale/lang/en-US.d.ts +9 -0
- package/components/locale/lang/en-US.js +9 -0
- package/components/locale/lang/zh-CN.d.ts +9 -0
- package/components/locale/lang/zh-CN.js +9 -0
- package/components/navbar/common.d.ts +12 -0
- package/components/navbar/index.scss +17 -10
- package/components/navbar/navbar.d.ts +5 -1
- package/components/navbar/navbar.vue +45 -15
- package/components/navbar/variables.scss +4 -1
- package/components/navbar-item/index.scss +10 -0
- package/components/navbar-item/navbar-item.vue +27 -4
- package/components/navbar-pit/navbar-pit.d.ts +2 -0
- package/components/navbar-pit/navbar-pit.vue +22 -0
- package/components/notify/common.d.ts +1 -0
- package/components/notify/index.scss +12 -7
- package/components/notify/notify.vue +9 -3
- package/components/notify-agent/notify-agent.vue +9 -11
- package/components/pagination/pagination.d.ts +1 -1
- package/components/picker-input/picker-input.vue +4 -4
- package/components/popout/common.d.ts +2 -3
- package/components/popout/popout.d.ts +5 -12
- package/components/popout/popout.vue +16 -5
- package/components/popover/utils.js +2 -4
- package/components/popover-reference/popover-reference.vue +3 -3
- package/components/popup/common.d.ts +5 -3
- package/components/popup/index.scss +25 -3
- package/components/popup/popup.d.ts +1 -1
- package/components/pull-down-refresh/pull-down-refresh.d.ts +1 -1
- package/components/qrcode/qrcode.d.ts +1 -1
- package/components/qrcode/qrcode.vue +4 -7
- package/components/radio-input/index.scss +5 -1
- package/components/radio-input/radio-input.vue +59 -32
- package/components/scroll-spy/common.d.ts +29 -0
- package/components/scroll-spy/common.js +1 -0
- package/components/scroll-spy/index.d.ts +1 -0
- package/components/scroll-spy/index.js +1 -0
- package/components/scroll-spy/scroll-spy.d.ts +28 -0
- package/components/scroll-spy/scroll-spy.vue +120 -0
- package/components/scroll-spy-anchor/common.d.ts +13 -0
- package/components/scroll-spy-anchor/index.d.ts +1 -0
- package/components/scroll-spy-anchor/index.js +1 -0
- package/components/scroll-spy-anchor/scroll-spy-anchor.d.ts +10 -0
- package/components/scroll-spy-anchor/scroll-spy-anchor.vue +50 -0
- package/components/search/search.vue +2 -0
- package/components/share-sheet/share-sheet.vue +3 -2
- package/components/sidebar/common.d.ts +28 -0
- package/components/sidebar/common.js +1 -0
- package/components/sidebar/index.d.ts +1 -0
- package/components/sidebar/index.js +1 -0
- package/components/sidebar/index.scss +15 -0
- package/components/sidebar/sidebar.d.ts +16 -0
- package/components/sidebar/sidebar.vue +136 -0
- package/components/sidebar/variables.scss +20 -0
- package/components/sidebar-item/common.d.ts +16 -0
- package/components/sidebar-item/common.js +1 -0
- package/components/sidebar-item/index.d.ts +1 -0
- package/components/sidebar-item/index.js +1 -0
- package/components/sidebar-item/index.scss +70 -0
- package/components/sidebar-item/sidebar-item.d.ts +14 -0
- package/components/sidebar-item/sidebar-item.vue +111 -0
- package/components/signature/common.d.ts +41 -0
- package/components/signature/common.js +2 -0
- package/components/signature/index.d.ts +1 -0
- package/components/signature/index.js +1 -0
- package/components/signature/index.scss +109 -0
- package/components/signature/signature.d.ts +32 -0
- package/components/signature/signature.vue +580 -0
- package/components/signature/variables-dark.scss +7 -0
- package/components/signature/variables.scss +9 -0
- package/components/status-bar/common.d.ts +17 -0
- package/components/status-bar/common.js +2 -0
- package/components/status-bar/index.d.ts +1 -0
- package/components/status-bar/index.js +1 -0
- package/components/status-bar/index.scss +7 -0
- package/components/status-bar/status-bar.d.ts +12 -0
- package/components/status-bar/status-bar.vue +56 -0
- package/components/style/mixins/ellipsis.scss +7 -0
- package/components/style/mixins/scroll-shadow.scss +40 -0
- package/components/style/mixins.scss +1 -0
- package/components/style/variables.scss +3 -0
- package/components/swiper-dot/swiper-dot.d.ts +1 -1
- package/components/tab/tab.vue +4 -3
- package/components/tabbar/common.d.ts +1 -0
- package/components/tabbar/tabbar.d.ts +2 -0
- package/components/tabbar/tabbar.vue +2 -1
- package/components/table-cell/index.scss +1 -2
- package/components/table-fixation/table-fixation.vue +16 -8
- package/components/tree-node/tree-node.vue +3 -3
- package/components/upload/upload.vue +3 -2
- package/dark.scss +1 -0
- package/global.d.ts +9 -0
- package/index.d.ts +8 -0
- package/index.js +8 -0
- package/index.scss +2 -0
- package/package.json +28 -24
- package/use/index.d.ts +4 -0
- package/use/index.js +4 -0
- package/use/useDragPinch.d.ts +15 -0
- package/use/useDragPinch.js +88 -0
- package/use/useImperative.js +1 -0
- package/use/useInitialVelocity.d.ts +13 -0
- package/use/useInitialVelocity.js +65 -0
- package/use/useMouseDown.js +3 -4
- package/use/useScrollSide.d.ts +6 -0
- package/use/useScrollSide.js +34 -0
- package/use/useScrollSpy.d.ts +19 -0
- package/use/useScrollSpy.js +99 -0
- package/use/useTimeoutLoading.d.ts +6 -0
- package/use/useTimeoutLoading.js +53 -0
- package/use/useZIndex.js +7 -3
- package/utils/bem.d.ts +8 -8
- package/utils/dom.d.ts +3 -69
- package/utils/dom.js +32 -109
- package/utils/file.d.ts +1 -0
- package/utils/file.js +14 -0
- package/utils/geometry.d.ts +67 -0
- package/utils/geometry.js +127 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -0
- package/utils/inertialAnimate.d.ts +10 -0
- package/utils/inertialAnimate.js +42 -0
- package/utils/is.d.ts +8 -0
- package/utils/is.js +8 -0
- package/utils/system.d.ts +2 -0
- package/utils/system.js +6 -3
- package/utils/utils.d.ts +7 -0
- package/utils/utils.js +13 -0
- package/components/_template/_template.d.ts +0 -16
- package/components/_template/_template.vue +0 -45
- package/components/_template/common.d.ts +0 -14
- package/components/_template/index.d.ts +0 -1
- package/components/_template/index.scss +0 -17
- package/components/_template/variables.scss +0 -5
- /package/components/{_template → crop-image}/index.js +0 -0
- /package/components/{_template → scroll-spy-anchor}/common.js +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type ScrollIntoViewPosition = 'start' | 'center' | 'end' | 'nearest';
|
|
2
|
+
export interface ScrollIntoViewValueOptions {
|
|
3
|
+
position?: ScrollIntoViewPosition;
|
|
4
|
+
startOffset?: number;
|
|
5
|
+
endOffset?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ScrollIntoViewOptions {
|
|
8
|
+
position?: ScrollIntoViewPosition;
|
|
9
|
+
startOffset?: number;
|
|
10
|
+
endOffset?: number;
|
|
11
|
+
duration?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
```
|
|
15
|
+
page
|
|
16
|
+
╱
|
|
17
|
+
╭───────────────╮ viewport
|
|
18
|
+
╭─│─ ─ ─ ─ ─ ─ ─ ─│─╮ ╱
|
|
19
|
+
│ │ ╭───────────╮ │ │
|
|
20
|
+
│ │ │ element │ │ │
|
|
21
|
+
│ │ ╰───────────╯ │ │
|
|
22
|
+
╰─│─ ─ ─ ─ ─ ─ ─ ─│─╯
|
|
23
|
+
│ │
|
|
24
|
+
│ │
|
|
25
|
+
╰───────────────╯
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
# 参数
|
|
29
|
+
- viewportHeight: viewport 高度
|
|
30
|
+
- viewportScrollTop: viewport 垂直滚动值
|
|
31
|
+
- elementHeight: element 高度
|
|
32
|
+
- elementOffsetTop: element 距离页面顶部距离
|
|
33
|
+
|
|
34
|
+
# 选项
|
|
35
|
+
- position: element 在视窗中的位置(start, center, end, nearest)
|
|
36
|
+
- startOffset: element 距离视窗顶部的偏移量
|
|
37
|
+
- endOffset: element 距离视窗底部的偏移量
|
|
38
|
+
|
|
39
|
+
# 结果值
|
|
40
|
+
- viewportScrollTop: viewport 新的垂直滚动值
|
|
41
|
+
|
|
42
|
+
*/
|
|
43
|
+
export declare function getScrollIntoViewValue(viewportHeight: number, viewportScrollTop: number, elementHeight: number, elementOffsetTop: number, options?: ScrollIntoViewValueOptions): number;
|
|
44
|
+
export interface NodeRect {
|
|
45
|
+
top: number;
|
|
46
|
+
right: number;
|
|
47
|
+
bottom: number;
|
|
48
|
+
left: number;
|
|
49
|
+
height: number;
|
|
50
|
+
width: number;
|
|
51
|
+
}
|
|
52
|
+
interface MatchScrollVisibleOptions {
|
|
53
|
+
offset?: number;
|
|
54
|
+
errorValue?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @description: 匹配元素列表中第一个位于滚动盒子可视区域的元素
|
|
58
|
+
*/
|
|
59
|
+
export declare function matchScrollVisible(rects: NodeRect[], callback: (index: number) => unknown, options?: MatchScrollVisibleOptions): Promise<unknown>;
|
|
60
|
+
export declare function getAspectFillSize(origWidth: number, origHeight: number, containerWidth: number, containerHeight: number): [number, number];
|
|
61
|
+
export declare function getAspectFitSize(origWidth: number, origHeight: number, containerWidth: number, containerHeight: number): [number, number];
|
|
62
|
+
interface Point {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
}
|
|
66
|
+
export declare function getTwoPointsDistance(p1: Point, p2: Point): number;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
```
|
|
3
|
+
page
|
|
4
|
+
╱
|
|
5
|
+
╭───────────────╮ viewport
|
|
6
|
+
╭─│─ ─ ─ ─ ─ ─ ─ ─│─╮ ╱
|
|
7
|
+
│ │ ╭───────────╮ │ │
|
|
8
|
+
│ │ │ element │ │ │
|
|
9
|
+
│ │ ╰───────────╯ │ │
|
|
10
|
+
╰─│─ ─ ─ ─ ─ ─ ─ ─│─╯
|
|
11
|
+
│ │
|
|
12
|
+
│ │
|
|
13
|
+
╰───────────────╯
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
# 参数
|
|
17
|
+
- viewportHeight: viewport 高度
|
|
18
|
+
- viewportScrollTop: viewport 垂直滚动值
|
|
19
|
+
- elementHeight: element 高度
|
|
20
|
+
- elementOffsetTop: element 距离页面顶部距离
|
|
21
|
+
|
|
22
|
+
# 选项
|
|
23
|
+
- position: element 在视窗中的位置(start, center, end, nearest)
|
|
24
|
+
- startOffset: element 距离视窗顶部的偏移量
|
|
25
|
+
- endOffset: element 距离视窗底部的偏移量
|
|
26
|
+
|
|
27
|
+
# 结果值
|
|
28
|
+
- viewportScrollTop: viewport 新的垂直滚动值
|
|
29
|
+
|
|
30
|
+
*/
|
|
31
|
+
export function getScrollIntoViewValue(viewportHeight, viewportScrollTop, elementHeight, elementOffsetTop, options = {}) {
|
|
32
|
+
const { startOffset = 0, endOffset = 0 } = options;
|
|
33
|
+
let position = options.position || 'nearest';
|
|
34
|
+
const elementToViewportTopOffset = elementOffsetTop - viewportScrollTop - startOffset;
|
|
35
|
+
const elementToViewportBottomOffset = elementOffsetTop +
|
|
36
|
+
elementHeight -
|
|
37
|
+
viewportScrollTop -
|
|
38
|
+
viewportHeight +
|
|
39
|
+
endOffset;
|
|
40
|
+
if (position === 'nearest') {
|
|
41
|
+
if (elementToViewportTopOffset >= 0 && elementToViewportBottomOffset <= 0) {
|
|
42
|
+
return viewportScrollTop;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
position =
|
|
46
|
+
Math.abs(elementToViewportTopOffset) >
|
|
47
|
+
Math.abs(elementToViewportBottomOffset)
|
|
48
|
+
? 'end'
|
|
49
|
+
: 'start';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let nextScrollTop = 0;
|
|
53
|
+
switch (position) {
|
|
54
|
+
case 'start':
|
|
55
|
+
nextScrollTop = elementOffsetTop - startOffset;
|
|
56
|
+
break;
|
|
57
|
+
case 'center':
|
|
58
|
+
nextScrollTop =
|
|
59
|
+
elementOffsetTop -
|
|
60
|
+
(viewportHeight - elementHeight - endOffset - startOffset) / 2 +
|
|
61
|
+
startOffset;
|
|
62
|
+
break;
|
|
63
|
+
case 'end':
|
|
64
|
+
nextScrollTop =
|
|
65
|
+
elementOffsetTop + elementHeight - viewportHeight + endOffset;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
return nextScrollTop;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @description: 匹配元素列表中第一个位于滚动盒子可视区域的元素
|
|
72
|
+
*/
|
|
73
|
+
export async function matchScrollVisible(rects, callback, options = {}) {
|
|
74
|
+
const { offset: optionOffset = 0, errorValue = 3 } = options;
|
|
75
|
+
const offset = optionOffset + errorValue;
|
|
76
|
+
const convertedRect = rects.map((rect, i) => {
|
|
77
|
+
return {
|
|
78
|
+
top: rect.top,
|
|
79
|
+
bottom: i < rects.length - 1 ? rects[i + 1].top : 0,
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
for (let i = 0, l = convertedRect.length; i < l; i++) {
|
|
83
|
+
const rect = convertedRect[i];
|
|
84
|
+
if (i === 0 && rect.top > offset) {
|
|
85
|
+
return callback(0);
|
|
86
|
+
}
|
|
87
|
+
if (rect.top <= offset && rect.bottom > offset) {
|
|
88
|
+
return callback(i);
|
|
89
|
+
}
|
|
90
|
+
if (i === l - 1 && rect.bottom <= offset) {
|
|
91
|
+
return callback(i);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function getAspectFillSize(origWidth, origHeight, containerWidth, containerHeight) {
|
|
96
|
+
let width = 0;
|
|
97
|
+
let height = 0;
|
|
98
|
+
if (origWidth > 0 && origHeight > 0) {
|
|
99
|
+
if (origWidth / origHeight > containerWidth / containerHeight) {
|
|
100
|
+
height = containerHeight;
|
|
101
|
+
width = (origWidth / origHeight) * containerHeight;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
width = containerWidth;
|
|
105
|
+
height = (origHeight / origWidth) * containerWidth;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return [width, height];
|
|
109
|
+
}
|
|
110
|
+
export function getAspectFitSize(origWidth, origHeight, containerWidth, containerHeight) {
|
|
111
|
+
let width = 0;
|
|
112
|
+
let height = 0;
|
|
113
|
+
if (origWidth > 0 && origHeight > 0) {
|
|
114
|
+
if (origWidth / origHeight > containerWidth / containerHeight) {
|
|
115
|
+
width = containerWidth;
|
|
116
|
+
height = (origHeight / origWidth) * containerWidth;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
height = containerHeight;
|
|
120
|
+
width = (origWidth / origHeight) * containerHeight;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return [width, height];
|
|
124
|
+
}
|
|
125
|
+
export function getTwoPointsDistance(p1, p2) {
|
|
126
|
+
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
|
|
127
|
+
}
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface InertialAnimateOptions {
|
|
2
|
+
update?: (value: number) => void;
|
|
3
|
+
complete?: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare function createInertialAnimate(v: number, options: InertialAnimateOptions): {
|
|
6
|
+
stop: () => void;
|
|
7
|
+
play: () => void;
|
|
8
|
+
isAnimating(): boolean;
|
|
9
|
+
};
|
|
10
|
+
export type InertialAnimate = ReturnType<typeof createInertialAnimate>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ticker } from './lwa.slim';
|
|
2
|
+
const friction = 0.95; // 摩擦系数
|
|
3
|
+
const minVelocity = 0.1; // 最小速度
|
|
4
|
+
export function createInertialAnimate(v, options) {
|
|
5
|
+
const initialVelocity = Math.abs(v);
|
|
6
|
+
let isAnimating = false;
|
|
7
|
+
const reversed = v < 0;
|
|
8
|
+
const { update, complete } = options;
|
|
9
|
+
let velocity = initialVelocity;
|
|
10
|
+
function animate() {
|
|
11
|
+
if (!isAnimating)
|
|
12
|
+
return;
|
|
13
|
+
velocity *= friction;
|
|
14
|
+
let displacement = velocity * 15;
|
|
15
|
+
displacement *= reversed ? -1 : 1;
|
|
16
|
+
update?.(displacement);
|
|
17
|
+
if (velocity < minVelocity) {
|
|
18
|
+
isAnimating = false;
|
|
19
|
+
ticker.remove(animate);
|
|
20
|
+
complete?.();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function play() {
|
|
24
|
+
if (!isAnimating) {
|
|
25
|
+
isAnimating = true;
|
|
26
|
+
ticker.add(animate);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function stop() {
|
|
30
|
+
if (isAnimating) {
|
|
31
|
+
isAnimating = false;
|
|
32
|
+
ticker.remove(animate);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
stop,
|
|
37
|
+
play,
|
|
38
|
+
isAnimating() {
|
|
39
|
+
return isAnimating;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
package/utils/is.d.ts
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* @return {boolean}
|
|
5
5
|
*/
|
|
6
6
|
export declare function isPlainObject(target: any): target is Record<PropertyKey, any>;
|
|
7
|
+
/**
|
|
8
|
+
* @description: 判断是否为对象
|
|
9
|
+
* @param {any} target
|
|
10
|
+
* @return {boolean}
|
|
11
|
+
*/
|
|
12
|
+
export declare function isObject(target: any): target is object & {
|
|
13
|
+
[key: PropertyKey]: any;
|
|
14
|
+
};
|
|
7
15
|
/**
|
|
8
16
|
* @description: 判断是否为函数
|
|
9
17
|
* @param {any} target
|
package/utils/is.js
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
export function isPlainObject(target) {
|
|
7
7
|
return Object.prototype.toString.call(target) === '[object Object]';
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @description: 判断是否为对象
|
|
11
|
+
* @param {any} target
|
|
12
|
+
* @return {boolean}
|
|
13
|
+
*/
|
|
14
|
+
export function isObject(target) {
|
|
15
|
+
return target !== null && typeof target === 'object';
|
|
16
|
+
}
|
|
9
17
|
/**
|
|
10
18
|
* @description: 判断是否为函数
|
|
11
19
|
* @param {any} target
|
package/utils/system.d.ts
CHANGED
package/utils/system.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export const systemInfo = uni.getSystemInfoSync();
|
|
2
|
-
|
|
3
|
-
export const
|
|
4
|
-
export const
|
|
2
|
+
const platform = systemInfo.uniPlatform;
|
|
3
|
+
export const isApp = platform === 'app';
|
|
4
|
+
export const isWeb = platform === 'web';
|
|
5
|
+
export const isMp = platform.startsWith('mp-');
|
|
6
|
+
export const isAlipay = platform === 'mp-alipay';
|
|
7
|
+
export const isWeixin = platform === 'mp-weixin';
|
package/utils/utils.d.ts
CHANGED
|
@@ -119,6 +119,12 @@ export declare function isEmptyValue(value: any, whitespace?: boolean): boolean;
|
|
|
119
119
|
* @return {boolean}
|
|
120
120
|
*/
|
|
121
121
|
export declare function isRenderVisible(value: any): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* @description: 判断是否绑定为空值
|
|
124
|
+
* @param {any} target
|
|
125
|
+
* @return {boolean}
|
|
126
|
+
*/
|
|
127
|
+
export declare function isEmptyBinding(target: any): target is '' | null | undefined;
|
|
122
128
|
export interface DebounceOptions {
|
|
123
129
|
leading?: boolean;
|
|
124
130
|
trailing?: boolean;
|
|
@@ -216,4 +222,5 @@ export declare function getDistanceBetweenTwoPoints(c1: Coord, c2: Coord): numbe
|
|
|
216
222
|
export declare function getMayPrimitiveOption(option: string | number | boolean | {
|
|
217
223
|
[key: PropertyKey]: any;
|
|
218
224
|
}, key: string): any;
|
|
225
|
+
export declare function sleep(time: number): Promise<unknown>;
|
|
219
226
|
export {};
|
package/utils/utils.js
CHANGED
|
@@ -253,6 +253,14 @@ export function isRenderVisible(value) {
|
|
|
253
253
|
value !== undefined &&
|
|
254
254
|
(typeof value !== 'string' || value.trim() !== ''));
|
|
255
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* @description: 判断是否绑定为空值
|
|
258
|
+
* @param {any} target
|
|
259
|
+
* @return {boolean}
|
|
260
|
+
*/
|
|
261
|
+
export function isEmptyBinding(target) {
|
|
262
|
+
return target === null || target === undefined || target === '';
|
|
263
|
+
}
|
|
256
264
|
export function debounce(func, wait, options = {}) {
|
|
257
265
|
let lastArgs, lastThis, maxWait, result, timerId, lastCallTime;
|
|
258
266
|
let lastInvokeTime = 0;
|
|
@@ -652,3 +660,8 @@ export function getDistanceBetweenTwoPoints(c1, c2) {
|
|
|
652
660
|
export function getMayPrimitiveOption(option, key) {
|
|
653
661
|
return isPrimitive(option) ? option : option[key];
|
|
654
662
|
}
|
|
663
|
+
export async function sleep(time) {
|
|
664
|
+
return new Promise((resolve) => {
|
|
665
|
+
setTimeout(resolve, time);
|
|
666
|
+
});
|
|
667
|
+
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type _TemplateProps, type _TemplateSlots } from './common';
|
|
2
|
-
declare function __VLS_template(): Readonly<_TemplateSlots> & _TemplateSlots;
|
|
3
|
-
declare const __VLS_component: import("vue").DefineComponent<_TemplateProps, {
|
|
4
|
-
reset: () => void;
|
|
5
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
6
|
-
click: (event: any) => any;
|
|
7
|
-
}, string, import("vue").PublicProps, Readonly<_TemplateProps> & Readonly<{
|
|
8
|
-
onClick?: ((event: any) => any) | undefined;
|
|
9
|
-
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
11
|
-
export default _default;
|
|
12
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
13
|
-
new (): {
|
|
14
|
-
$slots: S;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :class="_templateClass" :style="_templateStyle">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
import { defineComponent as _defineComponent } from "vue";
|
|
9
|
-
import { computed } from "vue";
|
|
10
|
-
import { classNames, stringifyStyle, createBem } from "../../utils";
|
|
11
|
-
export default _defineComponent({
|
|
12
|
-
...{
|
|
13
|
-
options: {
|
|
14
|
-
virtualHost: true,
|
|
15
|
-
styleIsolation: "shared"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
__name: "_template",
|
|
19
|
-
props: {
|
|
20
|
-
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
21
|
-
rootClass: { type: String, required: false }
|
|
22
|
-
},
|
|
23
|
-
emits: ["click"],
|
|
24
|
-
setup(__props, { expose: __expose }) {
|
|
25
|
-
const props = __props;
|
|
26
|
-
const bem = createBem("_template");
|
|
27
|
-
__expose({
|
|
28
|
-
reset: () => {
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const _templateClass = computed(() => {
|
|
32
|
-
return classNames(bem.b(), props.rootClass);
|
|
33
|
-
});
|
|
34
|
-
const _templateStyle = computed(() => {
|
|
35
|
-
return stringifyStyle(props.rootStyle);
|
|
36
|
-
});
|
|
37
|
-
const __returned__ = { props, bem, _templateClass, _templateStyle };
|
|
38
|
-
return __returned__;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<style lang="scss">
|
|
44
|
-
@import './index.scss';
|
|
45
|
-
</style>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type StyleValue } from 'vue';
|
|
2
|
-
export interface _TemplateProps {
|
|
3
|
-
rootStyle?: StyleValue;
|
|
4
|
-
rootClass?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface _TemplateSlots {
|
|
7
|
-
default?(props: Record<string, never>): any;
|
|
8
|
-
}
|
|
9
|
-
export interface _TemplateEmits {
|
|
10
|
-
(e: 'click', event: any): void;
|
|
11
|
-
}
|
|
12
|
-
export interface _TemplateExpose {
|
|
13
|
-
reset: () => void;
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { _TemplateProps, _TemplateSlots, _TemplateEmits, _TemplateExpose, } from './common';
|
|
File without changes
|
|
File without changes
|