sard-uniapp 1.11.1 → 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.
Files changed (195) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +5 -3
  3. package/components/action-sheet/action-sheet.vue +8 -2
  4. package/components/action-sheet/index.scss +1 -1
  5. package/components/back-top/back-top.d.ts +1 -1
  6. package/components/badge/badge.vue +1 -1
  7. package/components/button/button.d.ts +1 -0
  8. package/components/button/button.vue +2 -0
  9. package/components/button/common.d.ts +2 -0
  10. package/components/button/index.scss +6 -1
  11. package/components/calendar/calendar.d.ts +1 -1
  12. package/components/calendar/calendar.vue +49 -22
  13. package/components/calendar/index.scss +5 -5
  14. package/components/calendar/variables.scss +1 -1
  15. package/components/calendar-input/calendar-input.d.ts +1 -1
  16. package/components/calendar-month/index.scss +1 -0
  17. package/components/cascader/cascader.d.ts +6 -6
  18. package/components/cascader/cascader.vue +9 -4
  19. package/components/cascader/common.d.ts +3 -3
  20. package/components/cascader/index.scss +1 -0
  21. package/components/checkbox-input/checkbox-input.vue +59 -32
  22. package/components/checkbox-input/index.scss +4 -0
  23. package/components/config/index.d.ts +23 -0
  24. package/components/config/index.js +47 -18
  25. package/components/crop-image/common.d.ts +32 -0
  26. package/components/crop-image/common.js +2 -0
  27. package/components/crop-image/crop-image.d.ts +19 -0
  28. package/components/crop-image/crop-image.vue +671 -0
  29. package/components/crop-image/index.d.ts +1 -0
  30. package/components/crop-image/index.scss +81 -0
  31. package/components/crop-image-agent/common.d.ts +19 -0
  32. package/components/crop-image-agent/common.js +16 -0
  33. package/components/crop-image-agent/crop-image-agent.d.ts +9 -0
  34. package/components/crop-image-agent/crop-image-agent.vue +70 -0
  35. package/components/crop-image-agent/index.d.ts +1 -0
  36. package/components/crop-image-agent/index.js +1 -0
  37. package/components/datetime-picker-input/datetime-picker-input.vue +4 -4
  38. package/components/datetime-range-picker/datetime-range-picker.vue +4 -3
  39. package/components/datetime-range-picker-input/datetime-range-picker-input.vue +4 -4
  40. package/components/dialog/common.d.ts +2 -3
  41. package/components/dialog/dialog.d.ts +6 -13
  42. package/components/dialog/dialog.vue +15 -4
  43. package/components/dialog-agent/dialog-agent.d.ts +1 -1
  44. package/components/dropdown-item/dropdown-item.vue +6 -6
  45. package/components/fab/fab.d.ts +1 -1
  46. package/components/floating-bubble/floating-bubble.vue +14 -19
  47. package/components/form-item/form-item.vue +4 -3
  48. package/components/grid/common.d.ts +4 -0
  49. package/components/grid-item/grid-item.vue +33 -18
  50. package/components/grid-item/index.scss +12 -4
  51. package/components/icon/index.scss +1 -0
  52. package/components/icon/sari.scss +9 -1
  53. package/components/indexes/common.d.ts +3 -5
  54. package/components/indexes/indexes.d.ts +2 -0
  55. package/components/indexes/indexes.vue +45 -109
  56. package/components/indexes-anchor/indexes-anchor.vue +9 -9
  57. package/components/indexes-nav/indexes-nav.vue +26 -22
  58. package/components/input/input.d.ts +4 -4
  59. package/components/loading/index.scss +1 -1
  60. package/components/locale/lang/en-US.d.ts +9 -0
  61. package/components/locale/lang/en-US.js +9 -0
  62. package/components/locale/lang/zh-CN.d.ts +9 -0
  63. package/components/locale/lang/zh-CN.js +9 -0
  64. package/components/navbar/common.d.ts +12 -0
  65. package/components/navbar/index.scss +17 -10
  66. package/components/navbar/navbar.d.ts +5 -1
  67. package/components/navbar/navbar.vue +45 -15
  68. package/components/navbar/variables.scss +4 -1
  69. package/components/navbar-item/index.scss +10 -0
  70. package/components/navbar-item/navbar-item.vue +27 -4
  71. package/components/navbar-pit/navbar-pit.d.ts +2 -0
  72. package/components/navbar-pit/navbar-pit.vue +22 -0
  73. package/components/notify/common.d.ts +1 -0
  74. package/components/notify/index.scss +12 -7
  75. package/components/notify/notify.vue +9 -3
  76. package/components/notify-agent/notify-agent.vue +9 -11
  77. package/components/pagination/pagination.d.ts +1 -1
  78. package/components/picker-input/picker-input.vue +4 -4
  79. package/components/popout/common.d.ts +2 -3
  80. package/components/popout/popout.d.ts +5 -12
  81. package/components/popout/popout.vue +16 -5
  82. package/components/popover/utils.js +2 -4
  83. package/components/popover-reference/popover-reference.vue +3 -3
  84. package/components/popup/common.d.ts +5 -3
  85. package/components/popup/index.scss +25 -3
  86. package/components/popup/popup.d.ts +1 -1
  87. package/components/pull-down-refresh/pull-down-refresh.d.ts +1 -1
  88. package/components/qrcode/qrcode.d.ts +1 -1
  89. package/components/qrcode/qrcode.vue +4 -7
  90. package/components/radio-input/index.scss +5 -1
  91. package/components/radio-input/radio-input.vue +59 -32
  92. package/components/scroll-spy/common.d.ts +29 -0
  93. package/components/scroll-spy/common.js +1 -0
  94. package/components/scroll-spy/index.d.ts +1 -0
  95. package/components/scroll-spy/index.js +1 -0
  96. package/components/scroll-spy/scroll-spy.d.ts +28 -0
  97. package/components/scroll-spy/scroll-spy.vue +120 -0
  98. package/components/scroll-spy-anchor/common.d.ts +13 -0
  99. package/components/scroll-spy-anchor/index.d.ts +1 -0
  100. package/components/scroll-spy-anchor/index.js +1 -0
  101. package/components/scroll-spy-anchor/scroll-spy-anchor.d.ts +10 -0
  102. package/components/scroll-spy-anchor/scroll-spy-anchor.vue +50 -0
  103. package/components/search/search.vue +2 -0
  104. package/components/share-sheet/share-sheet.vue +3 -2
  105. package/components/sidebar/common.d.ts +28 -0
  106. package/components/sidebar/common.js +1 -0
  107. package/components/sidebar/index.d.ts +1 -0
  108. package/components/sidebar/index.js +1 -0
  109. package/components/sidebar/index.scss +15 -0
  110. package/components/sidebar/sidebar.d.ts +16 -0
  111. package/components/sidebar/sidebar.vue +136 -0
  112. package/components/sidebar/variables.scss +20 -0
  113. package/components/sidebar-item/common.d.ts +16 -0
  114. package/components/sidebar-item/common.js +1 -0
  115. package/components/sidebar-item/index.d.ts +1 -0
  116. package/components/sidebar-item/index.js +1 -0
  117. package/components/sidebar-item/index.scss +70 -0
  118. package/components/sidebar-item/sidebar-item.d.ts +14 -0
  119. package/components/sidebar-item/sidebar-item.vue +111 -0
  120. package/components/signature/common.d.ts +41 -0
  121. package/components/signature/common.js +2 -0
  122. package/components/signature/index.d.ts +1 -0
  123. package/components/signature/index.js +1 -0
  124. package/components/signature/index.scss +109 -0
  125. package/components/signature/signature.d.ts +32 -0
  126. package/components/signature/signature.vue +580 -0
  127. package/components/signature/variables-dark.scss +7 -0
  128. package/components/signature/variables.scss +9 -0
  129. package/components/status-bar/common.d.ts +17 -0
  130. package/components/status-bar/common.js +2 -0
  131. package/components/status-bar/index.d.ts +1 -0
  132. package/components/status-bar/index.js +1 -0
  133. package/components/status-bar/index.scss +7 -0
  134. package/components/status-bar/status-bar.d.ts +12 -0
  135. package/components/status-bar/status-bar.vue +56 -0
  136. package/components/style/mixins/ellipsis.scss +7 -0
  137. package/components/style/mixins/scroll-shadow.scss +40 -0
  138. package/components/style/mixins.scss +1 -0
  139. package/components/style/variables.scss +3 -0
  140. package/components/swiper-dot/swiper-dot.d.ts +1 -1
  141. package/components/tab/tab.vue +4 -3
  142. package/components/tabbar/common.d.ts +1 -0
  143. package/components/tabbar/tabbar.d.ts +2 -0
  144. package/components/tabbar/tabbar.vue +2 -1
  145. package/components/table-cell/index.scss +1 -2
  146. package/components/table-fixation/table-fixation.vue +16 -8
  147. package/components/tree/tree.vue +6 -4
  148. package/components/tree-node/tree-node.vue +12 -10
  149. package/components/upload/upload.vue +3 -2
  150. package/dark.scss +1 -0
  151. package/global.d.ts +9 -0
  152. package/index.d.ts +8 -0
  153. package/index.js +8 -0
  154. package/index.scss +2 -0
  155. package/package.json +28 -24
  156. package/use/index.d.ts +4 -0
  157. package/use/index.js +4 -0
  158. package/use/useDragPinch.d.ts +15 -0
  159. package/use/useDragPinch.js +88 -0
  160. package/use/useImperative.js +1 -0
  161. package/use/useInitialVelocity.d.ts +13 -0
  162. package/use/useInitialVelocity.js +65 -0
  163. package/use/useMouseDown.js +3 -4
  164. package/use/useScrollSide.d.ts +6 -0
  165. package/use/useScrollSide.js +34 -0
  166. package/use/useScrollSpy.d.ts +19 -0
  167. package/use/useScrollSpy.js +99 -0
  168. package/use/useTimeoutLoading.d.ts +6 -0
  169. package/use/useTimeoutLoading.js +53 -0
  170. package/use/useZIndex.js +7 -3
  171. package/utils/bem.d.ts +8 -8
  172. package/utils/dom.d.ts +3 -69
  173. package/utils/dom.js +32 -109
  174. package/utils/file.d.ts +1 -0
  175. package/utils/file.js +14 -0
  176. package/utils/geometry.d.ts +67 -0
  177. package/utils/geometry.js +127 -0
  178. package/utils/index.d.ts +2 -0
  179. package/utils/index.js +2 -0
  180. package/utils/inertialAnimate.d.ts +10 -0
  181. package/utils/inertialAnimate.js +42 -0
  182. package/utils/is.d.ts +8 -0
  183. package/utils/is.js +8 -0
  184. package/utils/system.d.ts +2 -0
  185. package/utils/system.js +6 -3
  186. package/utils/utils.d.ts +7 -0
  187. package/utils/utils.js +13 -0
  188. package/components/_template/_template.d.ts +0 -16
  189. package/components/_template/_template.vue +0 -45
  190. package/components/_template/common.d.ts +0 -14
  191. package/components/_template/index.d.ts +0 -1
  192. package/components/_template/index.scss +0 -17
  193. package/components/_template/variables.scss +0 -5
  194. /package/components/{_template → crop-image}/index.js +0 -0
  195. /package/components/{_template → scroll-spy-anchor}/common.js +0 -0
@@ -0,0 +1,88 @@
1
+ import { getTwoPointsDistance } from '../utils';
2
+ import { useInitialVelocity } from './useInitialVelocity';
3
+ import { useMouseDown } from './useMouseDown';
4
+ function getPoint(touch) {
5
+ return {
6
+ x: touch.clientX,
7
+ y: touch.clientY,
8
+ };
9
+ }
10
+ function getCenterPoint(touches) {
11
+ const points = Array.from(touches).map(getPoint);
12
+ const firstPoint = points[0];
13
+ if (points.length === 0) {
14
+ return firstPoint;
15
+ }
16
+ return points.slice(1).reduce((centerPoint, point) => {
17
+ return {
18
+ x: (point.x - centerPoint.x) / 2 + centerPoint.x,
19
+ y: (point.y - centerPoint.y) / 2 + centerPoint.y,
20
+ };
21
+ }, firstPoint);
22
+ }
23
+ function getScalePoints(touches) {
24
+ const points = Array.from(touches).map(getPoint);
25
+ if (points.length < 2) {
26
+ return null;
27
+ }
28
+ else if (points.length === 2) {
29
+ return points;
30
+ }
31
+ const centerPoint = points.slice(1, -1).reduce((centerPoint, point) => {
32
+ return {
33
+ x: (point.x - centerPoint.x) / 2 + centerPoint.x,
34
+ y: (point.y - centerPoint.y) / 2 + centerPoint.y,
35
+ };
36
+ }, points[0]);
37
+ return [centerPoint, points[points.length - 1]];
38
+ }
39
+ export function useDragPinch(options) {
40
+ const { onOffset, onScale, onCapture, onRelease } = options;
41
+ const initVelocity = useInitialVelocity();
42
+ let prevCenter = {
43
+ x: 0,
44
+ y: 0,
45
+ };
46
+ let prevScalePoints = null;
47
+ const onTouchStart = (event) => {
48
+ if (event.touches.length === 1) {
49
+ initVelocity.onStart(getPoint(event.touches[0]));
50
+ }
51
+ prevCenter = getCenterPoint(event.touches);
52
+ prevScalePoints = getScalePoints(event.touches);
53
+ onCapture?.();
54
+ };
55
+ const onTouchMove = (event) => {
56
+ const currCenterPoint = getCenterPoint(event.touches);
57
+ const offsetX = currCenterPoint.x - prevCenter.x;
58
+ const offsetY = currCenterPoint.y - prevCenter.y;
59
+ prevCenter = currCenterPoint;
60
+ onOffset?.(offsetX, offsetY);
61
+ const currScalePoints = getScalePoints(event.touches);
62
+ if (prevScalePoints && currScalePoints) {
63
+ const prevDistance = getTwoPointsDistance(...prevScalePoints);
64
+ const currDistance = getTwoPointsDistance(...currScalePoints);
65
+ const scale = (currDistance - prevDistance) / prevDistance;
66
+ onScale?.(currCenterPoint.x, currCenterPoint.y, scale);
67
+ }
68
+ prevScalePoints = currScalePoints;
69
+ if (event.touches.length === 1) {
70
+ initVelocity.onMove(getPoint(event.touches[0]));
71
+ }
72
+ };
73
+ const onTouchEnd = (event) => {
74
+ prevCenter = getCenterPoint(event.touches);
75
+ prevScalePoints = getScalePoints(event.touches);
76
+ if (event.touches.length === 0) {
77
+ const velocity = initVelocity.onEnd();
78
+ onRelease?.(velocity);
79
+ }
80
+ };
81
+ const onMouseDown = useMouseDown(onTouchStart, onTouchMove, onTouchEnd);
82
+ return {
83
+ onMouseDown,
84
+ onTouchStart,
85
+ onTouchMove,
86
+ onTouchEnd,
87
+ };
88
+ }
@@ -60,6 +60,7 @@ export function getAvailableImperative(name, id) {
60
60
  return imperativeItem.imperative;
61
61
  }
62
62
  }
63
+ return imperativeItems[imperativeItems.length - 1]?.imperative;
63
64
  }
64
65
  }
65
66
  export function getImperatives(name, id) {
@@ -0,0 +1,13 @@
1
+ interface Point {
2
+ x: number;
3
+ y: number;
4
+ }
5
+ export declare function useInitialVelocity(): {
6
+ onStart: (point: Point) => void;
7
+ onMove: (point: Point) => void;
8
+ onEnd: () => {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ };
13
+ export {};
@@ -0,0 +1,65 @@
1
+ export function useInitialVelocity() {
2
+ const touchInfo = {
3
+ x: 0,
4
+ y: 0,
5
+ historyX: [],
6
+ historyY: [],
7
+ historyTime: [],
8
+ };
9
+ function findDelta(point) {
10
+ return {
11
+ x: point.x - touchInfo.x,
12
+ y: point.y - touchInfo.y,
13
+ };
14
+ }
15
+ function onStart(point) {
16
+ touchInfo.x = point.x;
17
+ touchInfo.y = point.y;
18
+ touchInfo.historyX = [0];
19
+ touchInfo.historyY = [0];
20
+ touchInfo.historyTime = [Date.now()];
21
+ }
22
+ function onMove(point) {
23
+ const delta = findDelta(point);
24
+ touchInfo.historyX.push(delta.x);
25
+ touchInfo.historyY.push(delta.y);
26
+ touchInfo.historyTime.push(Date.now());
27
+ while (touchInfo.historyTime.length > 10) {
28
+ touchInfo.historyTime.shift();
29
+ touchInfo.historyX.shift();
30
+ touchInfo.historyY.shift();
31
+ }
32
+ }
33
+ function onEnd() {
34
+ const velocity = {
35
+ x: 0,
36
+ y: 0,
37
+ };
38
+ const length = touchInfo.historyTime.length;
39
+ if (length > 2) {
40
+ let i = length - 1;
41
+ const time1 = touchInfo.historyTime[i];
42
+ const x = touchInfo.historyX[i];
43
+ const y = touchInfo.historyY[i];
44
+ while (i > 0) {
45
+ i--;
46
+ const time0 = touchInfo.historyTime[i];
47
+ const time = time1 - time0;
48
+ if (time > 30 && time < 50) {
49
+ velocity.x = (x - touchInfo.historyX[i]) / time;
50
+ velocity.y = (y - touchInfo.historyY[i]) / time;
51
+ break;
52
+ }
53
+ }
54
+ }
55
+ touchInfo.historyTime = [];
56
+ touchInfo.historyX = [];
57
+ touchInfo.historyY = [];
58
+ return velocity;
59
+ }
60
+ return {
61
+ onStart,
62
+ onMove,
63
+ onEnd,
64
+ };
65
+ }
@@ -5,14 +5,13 @@ export function useMouseDown(startCallback, moveCallback, endCallback) {
5
5
  if ('ontouchstart' in document) {
6
6
  return;
7
7
  }
8
- const info = uni.getSystemInfoSync();
9
- startCallback?.(toTouchEvent(event, info.windowTop));
8
+ startCallback?.(toTouchEvent(event));
10
9
  const moveHandler = (event) => {
11
10
  event.preventDefault();
12
- moveCallback?.(toTouchEvent(event, info.windowTop));
11
+ moveCallback?.(toTouchEvent(event));
13
12
  };
14
13
  const upHandler = (event) => {
15
- endCallback?.(toTouchEvent(event, info.windowTop));
14
+ endCallback?.(toTouchEvent(event));
16
15
  document.removeEventListener('mousemove', moveHandler);
17
16
  document.removeEventListener('mouseup', upHandler);
18
17
  };
@@ -0,0 +1,6 @@
1
+ export declare function useScrollSide(): {
2
+ scrollSide: import("vue").Ref<"start" | "center" | "end" | null, "start" | "center" | "end" | null>;
3
+ onScroll: (event: any) => void;
4
+ onScrolltoupper: () => void;
5
+ onScrolltolower: () => void;
6
+ };
@@ -0,0 +1,34 @@
1
+ import { ref } from 'vue';
2
+ export function useScrollSide() {
3
+ const scrollSide = ref(null);
4
+ let prevScrollTop = 0;
5
+ const onScroll = (event) => {
6
+ const scrollTop = event.detail.scrollTop;
7
+ if (scrollTop === 0) {
8
+ scrollSide.value = 'start';
9
+ }
10
+ else {
11
+ // 支付宝 lower-threshold 设为0不会触发 scrolltolower
12
+ // 可设 trap-scroll 使到达边界时仍触发 scroll 来判断是否触底
13
+ if (prevScrollTop === scrollTop) {
14
+ scrollSide.value = 'end';
15
+ }
16
+ else {
17
+ scrollSide.value = 'center';
18
+ }
19
+ }
20
+ prevScrollTop = scrollTop;
21
+ };
22
+ const onScrolltoupper = () => {
23
+ scrollSide.value = 'start';
24
+ };
25
+ const onScrolltolower = () => {
26
+ scrollSide.value = 'end';
27
+ };
28
+ return {
29
+ scrollSide,
30
+ onScroll,
31
+ onScrolltoupper,
32
+ onScrolltolower,
33
+ };
34
+ }
@@ -0,0 +1,19 @@
1
+ import { type NodeRect } from '../utils';
2
+ export interface UseScrollSpyOptions {
3
+ defaultCurrent?: string | number;
4
+ getSpiedRect: () => Promise<NodeRect>;
5
+ initialScroll?: boolean;
6
+ startOffset?: number;
7
+ onChange?: (name: string | number) => void;
8
+ }
9
+ export declare function useScrollSpy(options: UseScrollSpyOptions): {
10
+ scrollTop: import("vue").Ref<number | undefined, number | undefined>;
11
+ innerCurrent: import("vue").Ref<string | number | undefined, string | number | undefined>;
12
+ anchorRectList: import("vue").ShallowRef<[string | number, NodeRect][], [string | number, NodeRect][]>;
13
+ register: (name: string | number, getRect: () => Promise<NodeRect>) => void;
14
+ unregister: (name: string | number) => void;
15
+ onScroll: (event: any) => void;
16
+ scrollTo: (name: string | number) => void;
17
+ update: () => Promise<void>;
18
+ initialize: () => Promise<void>;
19
+ };
@@ -0,0 +1,99 @@
1
+ import { computed, ref, shallowRef } from 'vue';
2
+ import { useSetTimeout } from './useSetTimeout';
3
+ import { isNullish, matchScrollVisible } from '../utils';
4
+ export function useScrollSpy(options) {
5
+ const { defaultCurrent, initialScroll, onChange, getSpiedRect } = options;
6
+ const startOffset = computed(() => options.startOffset || 0);
7
+ let memoScrollTop = 0;
8
+ const scrollTop = ref(0);
9
+ const innerCurrent = ref(defaultCurrent);
10
+ const anchorRectList = shallowRef([]);
11
+ const anchorMap = new Map();
12
+ let lockScroll = false;
13
+ const [unLockScrollLater] = useSetTimeout(() => {
14
+ lockScroll = false;
15
+ });
16
+ const register = (name, getRect) => {
17
+ anchorMap.set(name, getRect);
18
+ };
19
+ const unregister = (name) => {
20
+ anchorMap.delete(name);
21
+ };
22
+ const calcPosition = (offset) => {
23
+ matchScrollVisible(anchorRectList.value.map((item) => item[1]), (index) => {
24
+ const name = anchorRectList.value[index][0];
25
+ if (name !== innerCurrent.value) {
26
+ innerCurrent.value = name;
27
+ onChange?.(name);
28
+ }
29
+ }, {
30
+ offset,
31
+ });
32
+ };
33
+ const onScroll = (event) => {
34
+ memoScrollTop = event.detail.scrollTop;
35
+ if (lockScroll) {
36
+ return;
37
+ }
38
+ calcPosition(memoScrollTop + startOffset.value);
39
+ };
40
+ const scrollTo = (name) => {
41
+ if (anchorRectList.value.length > 0) {
42
+ const item = anchorRectList.value.find((item) => item[0] === name);
43
+ if (item) {
44
+ const offset = item[1].top;
45
+ scrollTop.value = offset - startOffset.value;
46
+ lockScroll = true;
47
+ unLockScrollLater(150);
48
+ }
49
+ }
50
+ };
51
+ const getAllAnchorRect = async () => {
52
+ const allRect = await Promise.all([...anchorMap].map(([name, getRect]) => {
53
+ return new Promise((resolve) => {
54
+ getRect().then((rect) => {
55
+ resolve([name, rect]);
56
+ });
57
+ });
58
+ }));
59
+ return allRect.sort((a, b) => {
60
+ return a[1].top - b[1].top;
61
+ });
62
+ };
63
+ const calcRect = async () => {
64
+ const spiedRect = await getSpiedRect();
65
+ anchorRectList.value = (await getAllAnchorRect()).map(([name, rect]) => {
66
+ return [
67
+ name,
68
+ {
69
+ ...rect,
70
+ top: rect.top - spiedRect.top + memoScrollTop,
71
+ bottom: rect.bottom - spiedRect.top + memoScrollTop,
72
+ },
73
+ ];
74
+ });
75
+ };
76
+ const update = async () => {
77
+ await calcRect();
78
+ };
79
+ const initialize = async () => {
80
+ await calcRect();
81
+ if (isNullish(innerCurrent.value)) {
82
+ innerCurrent.value = anchorRectList.value[0]?.[0];
83
+ }
84
+ if (initialScroll) {
85
+ scrollTo(innerCurrent.value);
86
+ }
87
+ };
88
+ return {
89
+ scrollTop,
90
+ innerCurrent,
91
+ anchorRectList,
92
+ register,
93
+ unregister,
94
+ onScroll,
95
+ scrollTo,
96
+ update,
97
+ initialize,
98
+ };
99
+ }
@@ -0,0 +1,6 @@
1
+ import { Ref } from 'vue';
2
+ export interface UseTimeoutLoadingOptions {
3
+ leading?: number;
4
+ trailing?: number;
5
+ }
6
+ export declare function useTimeoutLoading(loading: Ref<boolean>, options?: UseTimeoutLoadingOptions): import("vue").ComputedRef<boolean>;
@@ -0,0 +1,53 @@
1
+ import { computed, watch } from 'vue';
2
+ import { ref } from 'vue';
3
+ import { useSetTimeout } from './useSetTimeout';
4
+ export function useTimeoutLoading(loading, options = {}) {
5
+ const { leading = 150, trailing = 20000 } = options;
6
+ const status = ref('idle');
7
+ let startTime = 0;
8
+ const [waitTrailing, cancelTrailing] = useSetTimeout(() => {
9
+ status.value = 'idle';
10
+ });
11
+ const [waitLeading, cancelLeading] = useSetTimeout(() => {
12
+ status.value = 'loading';
13
+ startTime = Date.now();
14
+ });
15
+ watch(loading, () => {
16
+ cancelLeading();
17
+ cancelTrailing();
18
+ if (loading.value) {
19
+ switch (status.value) {
20
+ case 'idle':
21
+ status.value = 'leading';
22
+ waitLeading(leading);
23
+ break;
24
+ case 'trailing':
25
+ status.value = 'loading';
26
+ startTime = Date.now();
27
+ break;
28
+ }
29
+ }
30
+ else {
31
+ switch (status.value) {
32
+ case 'leading':
33
+ status.value = 'idle';
34
+ break;
35
+ case 'loading': {
36
+ const duration = Date.now() - startTime;
37
+ if (duration >= trailing) {
38
+ status.value = 'idle';
39
+ }
40
+ else {
41
+ status.value = 'trailing';
42
+ waitTrailing(trailing - duration);
43
+ }
44
+ break;
45
+ }
46
+ }
47
+ }
48
+ });
49
+ const timeoutLoading = computed(() => {
50
+ return status.value === 'loading' || status.value === 'trailing';
51
+ });
52
+ return timeoutLoading;
53
+ }
package/use/useZIndex.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { ref } from 'vue';
2
- let globalZIndex = 1000;
2
+ import { defaultConfig } from '../components/config';
3
+ let currentZIndex = 0;
3
4
  export function useZIndex() {
4
- const zIndex = ref(globalZIndex);
5
+ if (currentZIndex === 0) {
6
+ currentZIndex = defaultConfig.initialZIndex;
7
+ }
8
+ const zIndex = ref(currentZIndex);
5
9
  function increase() {
6
- zIndex.value = globalZIndex = globalZIndex + 1;
10
+ zIndex.value = currentZIndex = currentZIndex + 1;
7
11
  }
8
12
  return [zIndex, increase];
9
13
  }
package/utils/bem.d.ts CHANGED
@@ -7,17 +7,17 @@ export interface BemConfig {
7
7
  type IsType = boolean | number | string | null | undefined | object;
8
8
  export declare function createBemStruct(config: BemConfig): (block: string | number) => {
9
9
  b(): string;
10
- e(element: string | number | undefined, is?: IsType): string;
11
- m(modifier: string | number | undefined, is?: IsType): string;
12
- em(element: string | number, modifier: string | number | undefined, is?: IsType): string;
13
- bem(block: string | number, element?: string | number, modifier?: string | number, is?: boolean | number | string | null): string;
10
+ e(element: string | number | undefined | null, is?: IsType): string;
11
+ m(modifier: string | number | undefined | null, is?: IsType): string;
12
+ em(element: string | number, modifier: string | number | undefined | null, is?: IsType): string;
13
+ bem(block: string | number, element?: string | number, modifier?: string | number, is?: boolean | number | string | undefined | null): string;
14
14
  };
15
15
  export declare const createBem: (block: string | number) => {
16
16
  b(): string;
17
- e(element: string | number | undefined, is?: IsType): string;
18
- m(modifier: string | number | undefined, is?: IsType): string;
19
- em(element: string | number, modifier: string | number | undefined, is?: IsType): string;
20
- bem(block: string | number, element?: string | number, modifier?: string | number, is?: boolean | number | string | null): string;
17
+ e(element: string | number | undefined | null, is?: IsType): string;
18
+ m(modifier: string | number | undefined | null, is?: IsType): string;
19
+ em(element: string | number, modifier: string | number | undefined | null, is?: IsType): string;
20
+ bem(block: string | number, element?: string | number, modifier?: string | number, is?: boolean | number | string | undefined | null): string;
21
21
  };
22
22
  export type Bem = ReturnType<typeof createBem>;
23
23
  export {};
package/utils/dom.d.ts CHANGED
@@ -1,55 +1,5 @@
1
1
  import { ComponentInternalInstance } from 'vue';
2
- export type ScrollIntoViewPosition = 'start' | 'center' | 'end' | 'nearest';
3
- export interface ScrollIntoViewValueOptions {
4
- position?: ScrollIntoViewPosition;
5
- startOffset?: number;
6
- endOffset?: number;
7
- }
8
- export interface ScrollIntoViewOptions {
9
- position?: ScrollIntoViewPosition;
10
- startOffset?: number;
11
- endOffset?: number;
12
- duration?: number;
13
- }
14
- /**
15
- ```
16
- page
17
-
18
- ╭───────────────╮ viewport
19
- ╭─│─ ─ ─ ─ ─ ─ ─ ─│─╮ ╱
20
- │ │ ╭───────────╮ │ │
21
- │ │ │ element │ │ │
22
- │ │ ╰───────────╯ │ │
23
- ╰─│─ ─ ─ ─ ─ ─ ─ ─│─╯
24
- │ │
25
- │ │
26
- ╰───────────────╯
27
- ```
28
-
29
- # 参数
30
- - viewportHeight: viewport 高度
31
- - viewportScrollTop: viewport 垂直滚动值
32
- - elementHeight: element 高度
33
- - elementOffsetTop: element 距离页面顶部距离
34
-
35
- # 选项
36
- - position: element 在视窗中的位置(start, center, end, nearest)
37
- - startOffset: element 距离视窗顶部的偏移量
38
- - endOffset: element 距离视窗底部的偏移量
39
-
40
- # 结果值
41
- - viewportScrollTop: viewport 新的垂直滚动值
42
-
43
- */
44
- export declare function getScrollIntoViewValue(viewportHeight: number, viewportScrollTop: number, elementHeight: number, elementOffsetTop: number, options?: ScrollIntoViewValueOptions): number;
45
- export interface NodeRect {
46
- top: number;
47
- right: number;
48
- bottom: number;
49
- left: number;
50
- height: number;
51
- width: number;
52
- }
2
+ import { type NodeRect } from './geometry';
53
3
  /**
54
4
  * uni boundingClientRect的 Promise 版本
55
5
  * @param selector 组件选择器
@@ -59,16 +9,8 @@ export interface NodeRect {
59
9
  export declare function getBoundingClientRect(selector: string, instance: ComponentInternalInstance | null): Promise<NodeRect>;
60
10
  /**
61
11
  * 获取可使用窗口尺寸
62
- * @returns Promise<WindowInfo>
63
12
  */
64
- export declare function getWindowInfo(): Promise<WindowInfo>;
65
- export interface WindowInfo {
66
- windowWidth: number;
67
- windowHeight: number;
68
- windowTop: number;
69
- windowBottom: number;
70
- statusBarHeight: number;
71
- }
13
+ export declare function getWindowInfo(): UniNamespace.GetWindowInfoResult;
72
14
  export interface ViewportScrollInfo {
73
15
  scrollLeft: number;
74
16
  scrollTop: number;
@@ -77,13 +19,5 @@ export interface ViewportScrollInfo {
77
19
  * 获取可使用窗口尺寸、滚动信息
78
20
  */
79
21
  export declare function getViewportScrollInfo(): Promise<ViewportScrollInfo>;
80
- interface MatchScrollVisibleOptions {
81
- offset?: number;
82
- errorValue?: number;
83
- }
84
- /**
85
- * @description: 匹配元素列表中第一个位于滚动盒子可视区域的元素
86
- */
87
- export declare function matchScrollVisible(rects: NodeRect[], callback: (index: number) => unknown, options?: MatchScrollVisibleOptions): Promise<unknown>;
88
22
  export declare function toTouchEvent(event: MouseEvent | TouchEvent, windowTop?: number): TouchEvent;
89
- export {};
23
+ export declare function getNode<T = any>(selector: string, instance: ComponentInternalInstance | null): Promise<T>;