pxd 0.0.61 → 0.0.62
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/LICENSE +21 -0
- package/dist/components/_internal/dismiss-container.d.vue.ts +28 -0
- package/dist/components/_internal/dismiss-container.vue +162 -0
- package/dist/components/_internal/popover-arrow.d.vue.ts +9 -0
- package/dist/components/_internal/popover-arrow.vue +38 -0
- package/dist/components/active-graph/index.vue +4 -4
- package/dist/components/avatar/index.vue +5 -7
- package/dist/components/avatar-group/index.d.vue.ts +0 -1
- package/dist/components/avatar-group/index.vue +1 -1
- package/dist/components/backtop/index.vue +1 -1
- package/dist/components/badge/index.d.vue.ts +6 -2
- package/dist/components/badge/index.vue +18 -4
- package/dist/components/badge/types.d.ts +5 -0
- package/dist/components/book/index.vue +1 -1
- package/dist/components/browser/index.vue +1 -1
- package/dist/components/bubble/index.d.vue.ts +22 -0
- package/dist/components/bubble/index.vue +59 -0
- package/dist/components/bubble/types.d.ts +6 -0
- package/dist/components/button/index.d.vue.ts +0 -2
- package/dist/components/button/index.vue +30 -21
- package/dist/components/button/types.d.ts +3 -2
- package/dist/components/button-group/index.d.vue.ts +14 -0
- package/dist/components/button-group/index.vue +26 -0
- package/dist/components/button-group/types.d.ts +9 -0
- package/dist/components/carousel/index.d.vue.ts +3 -3
- package/dist/components/carousel/index.vue +146 -113
- package/dist/components/carousel/types.d.ts +1 -1
- package/dist/components/carousel-item/index.vue +22 -17
- package/dist/components/checkbox/index.vue +6 -6
- package/dist/components/checkbox-group/index.d.vue.ts +1 -1
- package/dist/components/chip/index.d.vue.ts +1 -5
- package/dist/components/chip/index.vue +4 -4
- package/dist/components/color-selector/index.d.vue.ts +12 -0
- package/dist/components/color-selector/index.vue +64 -0
- package/dist/components/color-selector/types.d.ts +12 -0
- package/dist/components/command-menu/index.d.vue.ts +6 -6
- package/dist/components/command-menu/index.vue +23 -32
- package/dist/components/command-menu/types.d.ts +1 -1
- package/dist/components/command-menu-group/index.vue +15 -6
- package/dist/components/command-menu-group/types.d.ts +1 -1
- package/dist/components/countdown/index.d.vue.ts +11 -11
- package/dist/components/drawer/index.d.vue.ts +8 -8
- package/dist/components/drawer/index.vue +13 -10
- package/dist/components/drawer/types.d.ts +4 -3
- package/dist/components/ellipsis-text/index.d.vue.ts +4 -1
- package/dist/components/ellipsis-text/index.vue +84 -107
- package/dist/components/ellipsis-text/types.d.ts +2 -1
- package/dist/components/error/index.vue +1 -1
- package/dist/components/fader/index.vue +5 -9
- package/dist/components/gauge/index.vue +34 -29
- package/dist/components/grid/index.vue +1 -1
- package/dist/components/grid-item/index.vue +1 -1
- package/dist/components/hold-button/index.d.vue.ts +8 -10
- package/dist/components/hold-button/index.vue +20 -29
- package/dist/components/hold-button/types.d.ts +5 -6
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +7 -0
- package/dist/components/input/index.d.vue.ts +8 -8
- package/dist/components/input/index.vue +5 -4
- package/dist/components/intersection-observer/index.vue +4 -4
- package/dist/components/kbd/index.vue +1 -1
- package/dist/components/link-button/index.d.vue.ts +4 -4
- package/dist/components/link-button/index.vue +9 -8
- package/dist/components/link-button/types.d.ts +0 -3
- package/dist/components/list/index.d.vue.ts +10 -15
- package/dist/components/list/index.vue +58 -131
- package/dist/components/list/types.d.ts +4 -4
- package/dist/components/list-item/index.d.vue.ts +2 -2
- package/dist/components/list-item/index.vue +44 -39
- package/dist/components/loading-bar/index.vue +8 -7
- package/dist/components/material/index.vue +24 -46
- package/dist/components/menu/index.d.vue.ts +6 -8
- package/dist/components/menu/index.vue +18 -24
- package/dist/components/menu/types.d.ts +1 -2
- package/dist/components/message/composables/use-group-expand.d.ts +13 -0
- package/dist/components/message/composables/use-group-expand.js +50 -0
- package/dist/components/message/composables/use-message-timer.d.ts +9 -0
- package/dist/components/message/composables/use-message-timer.js +61 -0
- package/dist/components/message/composables/use-promise-message.d.ts +4 -0
- package/dist/components/message/composables/use-promise-message.js +49 -0
- package/dist/components/message/index.d.vue.ts +6 -33
- package/dist/components/message/index.vue +33 -185
- package/dist/components/message/types.d.ts +2 -2
- package/dist/components/message-item/index.vue +26 -2
- package/dist/components/modal/index.d.vue.ts +7 -7
- package/dist/components/modal/index.vue +7 -3
- package/dist/components/modal/types.d.ts +7 -3
- package/dist/components/note/index.vue +2 -2
- package/dist/components/number-input/index.d.vue.ts +5 -4
- package/dist/components/number-input/index.vue +3 -0
- package/dist/components/number-input/types.d.ts +1 -0
- package/dist/components/overlay/index.d.vue.ts +6 -3
- package/dist/components/overlay/index.vue +63 -68
- package/dist/components/overlay/types.d.ts +5 -4
- package/dist/components/pagination/index.vue +2 -2
- package/dist/components/pin-input/index.d.vue.ts +1 -1
- package/dist/components/pin-input/index.vue +7 -6
- package/dist/components/placeholder/index.vue +1 -1
- package/dist/components/popover/index.d.vue.ts +7 -8
- package/dist/components/popover/index.vue +149 -239
- package/dist/components/popover/types.d.ts +5 -5
- package/dist/components/progress/index.vue +1 -1
- package/dist/components/radio/index.vue +2 -2
- package/dist/components/resizable/index.vue +43 -51
- package/dist/components/resizable/types.d.ts +1 -1
- package/dist/components/resizable-handle/index.d.vue.ts +4 -1
- package/dist/components/resizable-handle/index.vue +29 -3
- package/dist/components/resizable-panel/index.vue +3 -7
- package/dist/components/scalable-text/index.d.vue.ts +9 -0
- package/dist/components/scalable-text/index.vue +147 -0
- package/dist/components/scalable-text/types.d.ts +12 -0
- package/dist/components/scrollable/index.d.vue.ts +2 -2
- package/dist/components/scrollable/index.vue +4 -3
- package/dist/components/separator/index.d.vue.ts +6 -0
- package/dist/components/separator/index.vue +18 -0
- package/dist/components/separator/types.d.ts +5 -0
- package/dist/components/skeleton/index.d.vue.ts +1 -1
- package/dist/components/slider/index.d.vue.ts +1 -1
- package/dist/components/slider/index.vue +39 -7
- package/dist/components/snippet/index.vue +16 -13
- package/dist/components/spinner/index.vue +3 -1
- package/dist/components/stack/index.d.vue.ts +1 -1
- package/dist/components/stack/index.vue +1 -1
- package/dist/components/switch/index.d.vue.ts +1 -1
- package/dist/components/switch/index.vue +4 -3
- package/dist/components/switch-item/index.vue +1 -1
- package/dist/components/tabs/index.d.vue.ts +12 -0
- package/dist/components/tabs/index.vue +270 -0
- package/dist/components/tabs/types.d.ts +12 -0
- package/dist/components/tabs-item/index.d.vue.ts +4 -0
- package/dist/components/tabs-item/index.vue +16 -0
- package/dist/components/tabs-item/types.d.ts +10 -0
- package/dist/components/text/index.vue +1 -1
- package/dist/components/textarea/index.d.vue.ts +2 -2
- package/dist/components/textarea/index.vue +1 -1
- package/dist/components/time-picker/index.d.vue.ts +3 -5
- package/dist/components/time-picker/index.vue +53 -45
- package/dist/components/time-picker/types.d.ts +1 -2
- package/dist/components/toggle/index.d.vue.ts +0 -2
- package/dist/components/toggle/index.vue +6 -6
- package/dist/components/toggle-button/index.vue +8 -6
- package/dist/components/tooltip/index.d.vue.ts +1 -1
- package/dist/components/tooltip/index.vue +19 -11
- package/dist/components/tooltip/types.d.ts +2 -2
- package/dist/components/virtual-list/index.d.vue.ts +8 -8
- package/dist/components/virtual-list/index.vue +27 -5
- package/dist/components/virtual-list/types.d.ts +3 -0
- package/dist/composables/index.d.ts +4 -1
- package/dist/composables/index.js +4 -1
- package/dist/composables/use-browser-observer.js +2 -2
- package/dist/composables/use-client-online.js +2 -2
- package/dist/composables/use-color-scheme.js +2 -2
- package/dist/composables/use-countdown.js +3 -2
- package/dist/composables/use-deferred-value.js +2 -2
- package/dist/composables/use-delay-destroy.js +11 -6
- package/dist/composables/use-document-hidden.js +2 -2
- package/dist/composables/use-focus-trap.js +2 -2
- package/dist/composables/use-list-filter.d.ts +11 -0
- package/dist/composables/use-list-filter.js +56 -0
- package/dist/composables/use-list-navigation.d.ts +27 -0
- package/dist/composables/use-list-navigation.js +159 -0
- package/dist/composables/use-lock-scroll.js +12 -12
- package/dist/composables/use-media-query.js +2 -2
- package/dist/composables/use-outside-click.d.ts +1 -1
- package/dist/composables/use-outside-click.js +8 -11
- package/dist/composables/use-overlay-manager.d.ts +18 -0
- package/dist/composables/use-overlay-manager.js +80 -0
- package/dist/composables/use-popover-responsive.d.ts +6 -8
- package/dist/composables/use-popover-responsive.js +9 -12
- package/dist/composables/use-repeat-action.js +2 -2
- package/dist/composables/use-swipe-gesture.d.ts +65 -0
- package/dist/composables/use-swipe-gesture.js +99 -0
- package/dist/composables/use-virtual-list.d.ts +5 -3
- package/dist/composables/use-virtual-list.js +25 -14
- package/dist/composables/use-window-size.js +2 -2
- package/dist/constants/size.d.ts +12 -0
- package/dist/constants/size.js +12 -0
- package/dist/contexts/button.d.ts +5 -0
- package/dist/contexts/button.js +5 -0
- package/dist/contexts/carousel.d.ts +2 -1
- package/dist/contexts/list.d.ts +23 -3
- package/dist/contexts/list.js +6 -2
- package/dist/contexts/resizable.d.ts +3 -11
- package/dist/contexts/tabs.d.ts +15 -0
- package/dist/contexts/tabs.js +2 -0
- package/dist/locales/en-us.d.ts +4 -4
- package/dist/locales/en-us.js +4 -4
- package/dist/locales/zh-cn.d.ts +4 -4
- package/dist/locales/zh-cn.js +4 -4
- package/dist/plugins/dayjs-millisecond-token.js +1 -1
- package/dist/styles/source.css +133 -128
- package/dist/styles/styles.css +2 -2
- package/dist/styles/tw.css +133 -128
- package/dist/types/shared/props.d.ts +1 -0
- package/dist/types/shared/utils.d.ts +1 -4
- package/dist/utils/date.d.ts +3 -3
- package/dist/utils/dom.d.ts +1 -0
- package/dist/utils/dom.js +4 -0
- package/dist/utils/event.d.ts +2 -1
- package/dist/utils/event.js +7 -1
- package/dist/utils/format.d.ts +3 -3
- package/dist/utils/format.js +5 -4
- package/dist/utils/fuzzy-search.d.ts +7 -0
- package/dist/utils/fuzzy-search.js +61 -0
- package/dist/utils/get.d.ts +2 -0
- package/dist/utils/get.js +15 -1
- package/dist/utils/index.d.ts +10 -11
- package/dist/utils/index.js +2 -3
- package/dist/utils/ref.d.ts +2 -2
- package/dist/utils/{throttle.d.ts → timing.d.ts} +1 -0
- package/dist/utils/{throttle.js → timing.js} +4 -2
- package/package.json +67 -63
- package/volar.d.ts +7 -0
- package/dist/components/overlay/overlay-stack.d.ts +0 -3
- package/dist/components/overlay/overlay-stack.js +0 -17
- package/dist/composables/use-pointer-gesture.d.ts +0 -180
- package/dist/composables/use-pointer-gesture.js +0 -406
- package/dist/utils/debounce.d.ts +0 -1
- package/dist/utils/debounce.js +0 -1
- package/dist/utils/regexp.d.ts +0 -8
- package/dist/utils/regexp.js +0 -8
- package/dist/utils/responsive.d.ts +0 -3
- package/dist/utils/responsive.js +0 -14
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
import { onBeforeUnmount, shallowRef, watch } from "vue";
|
|
2
|
-
import { getScrollContainer, getScrollElByContainer } from "../utils/dom.js";
|
|
3
|
-
import { toValue } from "../utils/ref.js";
|
|
4
|
-
const OPTIONS_DEFAULTS = {
|
|
5
|
-
rtl: false,
|
|
6
|
-
axis: "both",
|
|
7
|
-
startThreshold: 6,
|
|
8
|
-
triggerThreshold: 80,
|
|
9
|
-
velocityThreshold: 1e3,
|
|
10
|
-
longPressMs: 300,
|
|
11
|
-
longPressMoveTolerance: 4,
|
|
12
|
-
lockDirectionOnStart: true,
|
|
13
|
-
allowScrollUntilEdge: true,
|
|
14
|
-
preventScrollOnDrag: true,
|
|
15
|
-
usePointerCapture: true
|
|
16
|
-
};
|
|
17
|
-
export function usePointerGesture(container, options = {}) {
|
|
18
|
-
const isActive = shallowRef(false);
|
|
19
|
-
const isDragging = shallowRef(false);
|
|
20
|
-
const isLongPressing = shallowRef(false);
|
|
21
|
-
const direction = shallowRef(null);
|
|
22
|
-
const delta = shallowRef({ x: 0, y: 0 });
|
|
23
|
-
const progress = shallowRef(0);
|
|
24
|
-
const velocity = shallowRef({ x: 0, y: 0, v: 0 });
|
|
25
|
-
let captured = false;
|
|
26
|
-
let start = null;
|
|
27
|
-
let last = null;
|
|
28
|
-
let lockedAxis = null;
|
|
29
|
-
let activePointerId = null;
|
|
30
|
-
let longPressTimer;
|
|
31
|
-
let mayTriggerKind = null;
|
|
32
|
-
let boundEl = null;
|
|
33
|
-
let boundScrollEl = null;
|
|
34
|
-
let didClearSelectionOnDragStart = false;
|
|
35
|
-
const now = () => performance.now();
|
|
36
|
-
function resolveHorizontalDir(dx) {
|
|
37
|
-
const r = options.rtl ?? OPTIONS_DEFAULTS.rtl;
|
|
38
|
-
if (typeof r === "function") {
|
|
39
|
-
return r(dx);
|
|
40
|
-
}
|
|
41
|
-
if (r === true) {
|
|
42
|
-
return dx > 0 ? "left" : "right";
|
|
43
|
-
}
|
|
44
|
-
return dx > 0 ? "right" : "left";
|
|
45
|
-
}
|
|
46
|
-
function computeDir(dx, dy) {
|
|
47
|
-
if (Math.abs(dx) >= Math.abs(dy)) {
|
|
48
|
-
return dx === 0 ? null : resolveHorizontalDir(dx);
|
|
49
|
-
}
|
|
50
|
-
return dy === 0 ? null : dy > 0 ? "down" : "up";
|
|
51
|
-
}
|
|
52
|
-
function updateVelocity(curr, prev) {
|
|
53
|
-
if (!prev) {
|
|
54
|
-
velocity.value = { x: 0, y: 0, v: 0 };
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const dt = Math.max(1, curr.t - prev.t);
|
|
58
|
-
const vx = (curr.x - prev.x) / dt * 1e3;
|
|
59
|
-
const vy = (curr.y - prev.y) / dt * 1e3;
|
|
60
|
-
velocity.value = { x: vx, y: vy, v: Math.hypot(vx, vy) };
|
|
61
|
-
}
|
|
62
|
-
function axisAllowed(dx, dy) {
|
|
63
|
-
const axis = options.axis?.() || OPTIONS_DEFAULTS.axis;
|
|
64
|
-
if (axis === "both") {
|
|
65
|
-
return true;
|
|
66
|
-
} else if (axis === "x") {
|
|
67
|
-
return Math.abs(dx) >= Math.abs(dy);
|
|
68
|
-
} else if (axis === "y") {
|
|
69
|
-
return Math.abs(dy) >= Math.abs(dx);
|
|
70
|
-
}
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
function updateProgress(dx, dy) {
|
|
74
|
-
const triggerThreshold = options.triggerThreshold ?? OPTIONS_DEFAULTS.triggerThreshold;
|
|
75
|
-
let primary;
|
|
76
|
-
if (lockedAxis === "y") {
|
|
77
|
-
primary = Math.abs(dy);
|
|
78
|
-
} else if (lockedAxis === "x") {
|
|
79
|
-
primary = Math.abs(dx);
|
|
80
|
-
} else {
|
|
81
|
-
primary = Math.abs(Math.abs(dx) >= Math.abs(dy) ? dx : dy);
|
|
82
|
-
}
|
|
83
|
-
progress.value = Math.max(0, Math.min(1, primary / triggerThreshold));
|
|
84
|
-
}
|
|
85
|
-
function getScrollEl() {
|
|
86
|
-
if (typeof options.getScrollable === "function") {
|
|
87
|
-
return options.getScrollable();
|
|
88
|
-
}
|
|
89
|
-
const el = boundEl ? getScrollContainer(boundEl) : toValue(container) && getScrollContainer(toValue(container));
|
|
90
|
-
if (!el) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
return getScrollElByContainer(el);
|
|
94
|
-
}
|
|
95
|
-
function canScrollFurther(scrollEl, dx, dy) {
|
|
96
|
-
const { scrollTop, scrollHeight, clientHeight, scrollLeft, scrollWidth, clientWidth } = scrollEl;
|
|
97
|
-
const atTop = scrollTop <= 0;
|
|
98
|
-
const atBottom = scrollTop + clientHeight >= scrollHeight;
|
|
99
|
-
const atLeft = scrollLeft <= 0;
|
|
100
|
-
const atRight = scrollLeft + clientWidth >= scrollWidth;
|
|
101
|
-
const horizontal = Math.abs(dx) >= Math.abs(dy);
|
|
102
|
-
if (horizontal) {
|
|
103
|
-
if (dx < 0) {
|
|
104
|
-
return !atRight;
|
|
105
|
-
}
|
|
106
|
-
if (dx > 0) {
|
|
107
|
-
return !atLeft;
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
if (dy < 0) {
|
|
111
|
-
return !atBottom;
|
|
112
|
-
}
|
|
113
|
-
if (dy > 0) {
|
|
114
|
-
return !atTop;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
function clearTextSelection() {
|
|
120
|
-
try {
|
|
121
|
-
const sel = window.getSelection?.();
|
|
122
|
-
sel?.removeAllRanges?.();
|
|
123
|
-
} catch {
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function clearLongPress() {
|
|
127
|
-
if (longPressTimer != null) {
|
|
128
|
-
clearTimeout(longPressTimer);
|
|
129
|
-
longPressTimer = null;
|
|
130
|
-
}
|
|
131
|
-
clearTextSelection();
|
|
132
|
-
}
|
|
133
|
-
function startLongPress() {
|
|
134
|
-
clearLongPress();
|
|
135
|
-
const lp = options.longPressMs ?? OPTIONS_DEFAULTS.longPressMs;
|
|
136
|
-
if (lp <= 0) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
longPressTimer = setTimeout(() => {
|
|
140
|
-
isLongPressing.value = true;
|
|
141
|
-
options.onLongPress?.(publicState());
|
|
142
|
-
}, lp);
|
|
143
|
-
}
|
|
144
|
-
function publicState() {
|
|
145
|
-
return {
|
|
146
|
-
isActive: isActive.value,
|
|
147
|
-
isDragging: isDragging.value,
|
|
148
|
-
isLongPressing: isLongPressing.value,
|
|
149
|
-
direction: direction.value,
|
|
150
|
-
delta: { ...delta.value },
|
|
151
|
-
velocity: { ...velocity.value },
|
|
152
|
-
progress: progress.value
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function resetInternal() {
|
|
156
|
-
clearLongPress();
|
|
157
|
-
if (captured && boundEl && activePointerId != null) {
|
|
158
|
-
try {
|
|
159
|
-
boundEl.releasePointerCapture(activePointerId);
|
|
160
|
-
} catch {
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
captured = false;
|
|
164
|
-
isActive.value = false;
|
|
165
|
-
isDragging.value = false;
|
|
166
|
-
isLongPressing.value = false;
|
|
167
|
-
direction.value = null;
|
|
168
|
-
delta.value = { x: 0, y: 0 };
|
|
169
|
-
velocity.value = { x: 0, y: 0, v: 0 };
|
|
170
|
-
progress.value = 0;
|
|
171
|
-
start = null;
|
|
172
|
-
last = null;
|
|
173
|
-
lockedAxis = null;
|
|
174
|
-
activePointerId = null;
|
|
175
|
-
mayTriggerKind = null;
|
|
176
|
-
boundScrollEl = null;
|
|
177
|
-
didClearSelectionOnDragStart = false;
|
|
178
|
-
}
|
|
179
|
-
function markTrigger(kind) {
|
|
180
|
-
const dir = direction.value;
|
|
181
|
-
if (!dir) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (options.directionGuard && !options.directionGuard(dir, publicState())) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
mayTriggerKind = kind;
|
|
188
|
-
}
|
|
189
|
-
function onPointerDown(e) {
|
|
190
|
-
const usePointerCapture = options.usePointerCapture ?? OPTIONS_DEFAULTS.usePointerCapture;
|
|
191
|
-
if (e.button != null && e.button !== 0) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (typeof options.pointerGuard === "function" && !options.pointerGuard(e)) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
activePointerId = e.pointerId;
|
|
198
|
-
isActive.value = true;
|
|
199
|
-
const t = now();
|
|
200
|
-
start = last = { x: e.clientX, y: e.clientY, t };
|
|
201
|
-
direction.value = null;
|
|
202
|
-
delta.value = { x: 0, y: 0 };
|
|
203
|
-
velocity.value = { x: 0, y: 0, v: 0 };
|
|
204
|
-
progress.value = 0;
|
|
205
|
-
lockedAxis = null;
|
|
206
|
-
isLongPressing.value = false;
|
|
207
|
-
mayTriggerKind = null;
|
|
208
|
-
didClearSelectionOnDragStart = false;
|
|
209
|
-
startLongPress();
|
|
210
|
-
options.onStart?.(e, publicState());
|
|
211
|
-
boundEl = toValue(container);
|
|
212
|
-
if (usePointerCapture && boundEl) {
|
|
213
|
-
try {
|
|
214
|
-
boundEl.setPointerCapture(e.pointerId);
|
|
215
|
-
captured = true;
|
|
216
|
-
} catch {
|
|
217
|
-
captured = false;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
const el = boundEl;
|
|
221
|
-
el.addEventListener("pointermove", onPointerMove, { passive: false, capture: true });
|
|
222
|
-
el.addEventListener("pointerup", onPointerUp, { passive: true, once: true, capture: true });
|
|
223
|
-
el.addEventListener("pointercancel", onPointerCancel, {
|
|
224
|
-
passive: true,
|
|
225
|
-
once: true,
|
|
226
|
-
capture: true
|
|
227
|
-
});
|
|
228
|
-
boundScrollEl = getScrollEl();
|
|
229
|
-
}
|
|
230
|
-
function onPointerMove(e) {
|
|
231
|
-
const longPressMoveTolerance = options.longPressMoveTolerance ?? OPTIONS_DEFAULTS.longPressMoveTolerance;
|
|
232
|
-
const allowScrollUntilEdge = options.allowScrollUntilEdge ?? OPTIONS_DEFAULTS.allowScrollUntilEdge;
|
|
233
|
-
const preventScrollOnDrag = options.preventScrollOnDrag ?? OPTIONS_DEFAULTS.preventScrollOnDrag;
|
|
234
|
-
const velocityThreshold = options.velocityThreshold ?? OPTIONS_DEFAULTS.velocityThreshold;
|
|
235
|
-
if (!start) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const curr = { x: e.clientX, y: e.clientY, t: now() };
|
|
239
|
-
const dx = curr.x - start.x;
|
|
240
|
-
const dy = curr.y - start.y;
|
|
241
|
-
if (!isDragging.value && Math.hypot(dx, dy) > longPressMoveTolerance) {
|
|
242
|
-
clearLongPress();
|
|
243
|
-
}
|
|
244
|
-
if (allowScrollUntilEdge) {
|
|
245
|
-
const sc = boundScrollEl ?? (boundScrollEl = getScrollEl());
|
|
246
|
-
if (sc && canScrollFurther(sc, dx, dy)) {
|
|
247
|
-
const prev = last;
|
|
248
|
-
last = curr;
|
|
249
|
-
updateVelocity(curr, prev ?? last);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if (!isDragging.value) {
|
|
254
|
-
const st = options.startThreshold ?? OPTIONS_DEFAULTS.startThreshold;
|
|
255
|
-
const lck = options.lockDirectionOnStart ?? OPTIONS_DEFAULTS.lockDirectionOnStart;
|
|
256
|
-
if (Math.hypot(dx, dy) >= st && axisAllowed(dx, dy)) {
|
|
257
|
-
isDragging.value = true;
|
|
258
|
-
if (lck) {
|
|
259
|
-
lockedAxis = Math.abs(dx) >= Math.abs(dy) ? "x" : "y";
|
|
260
|
-
}
|
|
261
|
-
if (preventScrollOnDrag) {
|
|
262
|
-
try {
|
|
263
|
-
e.preventDefault();
|
|
264
|
-
} catch {
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (!didClearSelectionOnDragStart) {
|
|
268
|
-
clearTextSelection();
|
|
269
|
-
didClearSelectionOnDragStart = true;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (isDragging.value) {
|
|
274
|
-
if (preventScrollOnDrag) {
|
|
275
|
-
e.preventDefault();
|
|
276
|
-
}
|
|
277
|
-
const prev = last;
|
|
278
|
-
delta.value = { x: dx, y: dy };
|
|
279
|
-
direction.value = computeDir(dx, dy);
|
|
280
|
-
updateVelocity(curr, prev);
|
|
281
|
-
updateProgress(dx, dy);
|
|
282
|
-
if (velocity.value.v >= velocityThreshold) {
|
|
283
|
-
markTrigger("fling");
|
|
284
|
-
}
|
|
285
|
-
options.onMove?.(e, publicState());
|
|
286
|
-
}
|
|
287
|
-
last = curr;
|
|
288
|
-
}
|
|
289
|
-
function onPointerUp(e) {
|
|
290
|
-
const triggerThreshold = options.triggerThreshold ?? OPTIONS_DEFAULTS.triggerThreshold;
|
|
291
|
-
const requiresMoveForLongPress = options.longPressRequiresMovement ?? OPTIONS_DEFAULTS.longPressRequiresMovement;
|
|
292
|
-
const curr = { x: e.clientX, y: e.clientY, t: now() };
|
|
293
|
-
let hit = false;
|
|
294
|
-
let kind = mayTriggerKind;
|
|
295
|
-
const state = publicState();
|
|
296
|
-
if (start) {
|
|
297
|
-
const dx = curr.x - start.x;
|
|
298
|
-
const dy = curr.y - start.y;
|
|
299
|
-
const distanceHit = Math.hypot(dx, dy) >= triggerThreshold;
|
|
300
|
-
const longPressHit = isLongPressing.value && (requiresMoveForLongPress ? distanceHit : true);
|
|
301
|
-
if (longPressHit) {
|
|
302
|
-
direction.value = computeDir(dx, dy);
|
|
303
|
-
kind = "longpress";
|
|
304
|
-
hit = true;
|
|
305
|
-
} else if (distanceHit) {
|
|
306
|
-
direction.value = computeDir(dx, dy);
|
|
307
|
-
kind = "threshold";
|
|
308
|
-
hit = true;
|
|
309
|
-
} else if (kind === "fling") {
|
|
310
|
-
hit = true;
|
|
311
|
-
}
|
|
312
|
-
if (hit && direction.value && options.directionGuard && !options.directionGuard(direction.value, state)) {
|
|
313
|
-
hit = false;
|
|
314
|
-
kind = null;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
options.onEnd?.(e, state);
|
|
318
|
-
options.onRelease?.(hit, hit ? direction.value : null, hit ? kind : null, state);
|
|
319
|
-
if (!hit) {
|
|
320
|
-
options.onReset?.(state);
|
|
321
|
-
}
|
|
322
|
-
const el = boundEl;
|
|
323
|
-
if (el) {
|
|
324
|
-
removePointerEvents(el);
|
|
325
|
-
}
|
|
326
|
-
resetInternal();
|
|
327
|
-
}
|
|
328
|
-
function onPointerCancel(e) {
|
|
329
|
-
const state = publicState();
|
|
330
|
-
options.onCancel?.(e, state);
|
|
331
|
-
options.onReset?.(state);
|
|
332
|
-
const el = boundEl;
|
|
333
|
-
if (el) {
|
|
334
|
-
removePointerEvents(el);
|
|
335
|
-
}
|
|
336
|
-
resetInternal();
|
|
337
|
-
}
|
|
338
|
-
function onContextMenu(e) {
|
|
339
|
-
if (isActive.value) {
|
|
340
|
-
e.preventDefault();
|
|
341
|
-
e.stopPropagation();
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
function removePointerEvents(el) {
|
|
345
|
-
el.removeEventListener("pointermove", onPointerMove, true);
|
|
346
|
-
el.removeEventListener("pointerup", onPointerUp, true);
|
|
347
|
-
el.removeEventListener("pointercancel", onPointerCancel, true);
|
|
348
|
-
}
|
|
349
|
-
function bind(el) {
|
|
350
|
-
unbind(el);
|
|
351
|
-
if (!el) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
el.addEventListener("contextmenu", onContextMenu);
|
|
355
|
-
el.addEventListener("pointerdown", onPointerDown);
|
|
356
|
-
}
|
|
357
|
-
function unbind(el) {
|
|
358
|
-
const _el = el ?? toValue(container);
|
|
359
|
-
if (!_el) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
removePointerEvents(_el);
|
|
363
|
-
_el.removeEventListener("pointerdown", onPointerDown);
|
|
364
|
-
_el.removeEventListener("contextmenu", onContextMenu);
|
|
365
|
-
}
|
|
366
|
-
function reset() {
|
|
367
|
-
options.onReset?.(publicState());
|
|
368
|
-
resetInternal();
|
|
369
|
-
}
|
|
370
|
-
function cancel() {
|
|
371
|
-
const state = publicState();
|
|
372
|
-
options.onCancel?.(null, state);
|
|
373
|
-
options.onReset?.(state);
|
|
374
|
-
resetInternal();
|
|
375
|
-
}
|
|
376
|
-
const unwatchContainer = watch(
|
|
377
|
-
() => toValue(container),
|
|
378
|
-
(el, prev) => {
|
|
379
|
-
if (el === prev) {
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
bind(el);
|
|
383
|
-
},
|
|
384
|
-
{ immediate: true }
|
|
385
|
-
);
|
|
386
|
-
function stop() {
|
|
387
|
-
unwatchContainer();
|
|
388
|
-
resetInternal();
|
|
389
|
-
unbind();
|
|
390
|
-
}
|
|
391
|
-
onBeforeUnmount(() => {
|
|
392
|
-
stop();
|
|
393
|
-
});
|
|
394
|
-
return {
|
|
395
|
-
isActive,
|
|
396
|
-
isDragging,
|
|
397
|
-
isLongPressing,
|
|
398
|
-
direction,
|
|
399
|
-
delta,
|
|
400
|
-
velocity,
|
|
401
|
-
progress,
|
|
402
|
-
reset,
|
|
403
|
-
cancel,
|
|
404
|
-
stop
|
|
405
|
-
};
|
|
406
|
-
}
|
package/dist/utils/debounce.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { debounce } from 'es-toolkit/function';
|
package/dist/utils/debounce.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { debounce } from "es-toolkit/function";
|
package/dist/utils/regexp.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const INTEGER_REGEX: RegExp;
|
|
2
|
-
export declare const FLOATING_REGEX: RegExp;
|
|
3
|
-
export declare const POSITIVE_INTEGER_REGEX: RegExp;
|
|
4
|
-
export declare const SCIENCE_NUMERIC_REGEX: RegExp;
|
|
5
|
-
export declare const DATE_REGEX: RegExp;
|
|
6
|
-
export declare const TIME_REGEX: RegExp;
|
|
7
|
-
export declare const DATE_TIME_REGEX: RegExp;
|
|
8
|
-
export declare const TIME_REGEX_WITH_MILLISECONDS: RegExp;
|
package/dist/utils/regexp.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const INTEGER_REGEX = /^-?\d+$/;
|
|
2
|
-
export const FLOATING_REGEX = /^-?\d+\.?\d*/;
|
|
3
|
-
export const POSITIVE_INTEGER_REGEX = /^\d+$/;
|
|
4
|
-
export const SCIENCE_NUMERIC_REGEX = /^-?\d+(?:\.\d*)?(e-?\d+)?$/i;
|
|
5
|
-
export const DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
6
|
-
export const TIME_REGEX = /^(\d{2}):(\d{2}):(\d{2})$/;
|
|
7
|
-
export const DATE_TIME_REGEX = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/;
|
|
8
|
-
export const TIME_REGEX_WITH_MILLISECONDS = /^(\d{2}):(\d{2}):(\d{2})\.(\d{1,3})$/;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ResponsiveValue } from '../types/shared/props';
|
|
2
|
-
import type { Nullable } from '../types/shared/utils';
|
|
3
|
-
export declare function getResponsiveValue<V extends string | number>(prop: ResponsiveValue<V> | undefined, xsValue: Nullable<V>, valueSetter: (acc: Record<string, V>, bp: any, v: V) => void): Record<string, V>;
|
package/dist/utils/responsive.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { isNil } from "es-toolkit";
|
|
2
|
-
export function getResponsiveValue(prop, xsValue, valueSetter) {
|
|
3
|
-
const formatted = Object.assign(
|
|
4
|
-
isNil(xsValue) ? {} : { xs: xsValue },
|
|
5
|
-
typeof prop === "object" ? prop : {}
|
|
6
|
-
);
|
|
7
|
-
return Object.entries(formatted).reduce(
|
|
8
|
-
(acc, [bp, value]) => {
|
|
9
|
-
valueSetter(acc, bp, value);
|
|
10
|
-
return acc;
|
|
11
|
-
},
|
|
12
|
-
{}
|
|
13
|
-
);
|
|
14
|
-
}
|