lupine.components 1.1.18 → 1.1.20
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lupine.components",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "uuware.com",
|
|
6
6
|
"homepage": "https://github.com/uuware/lupine.js",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">= 20"
|
|
18
18
|
},
|
|
19
|
+
"sideEffects": false,
|
|
19
20
|
"exports": {
|
|
20
21
|
".": {
|
|
21
22
|
"types": "./src/index.ts",
|
|
@@ -2,15 +2,18 @@ import { CssProps, RefProps } from 'lupine.web';
|
|
|
2
2
|
import { Spinner02, SpinnerSize } from './spinner';
|
|
3
3
|
|
|
4
4
|
export type DragRefreshCloseProps = () => void;
|
|
5
|
+
export type DragRefreshHookCheckProps = () => boolean;
|
|
6
|
+
export type DragRefreshHookFreshProps = (close: DragRefreshCloseProps) => Promise<void>;
|
|
5
7
|
|
|
6
8
|
export type DragRefreshHookProps = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
setCheckEnabled?: (checkEnabled: DragRefreshHookCheckProps) => void;
|
|
10
|
+
setOnDragRefresh?: (onDragRefresh: DragRefreshHookFreshProps) => void;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
export type DragRefreshProps = {
|
|
12
14
|
container: string;
|
|
13
|
-
|
|
15
|
+
checkEnabled?: DragRefreshHookCheckProps;
|
|
16
|
+
onDragRefresh?: DragRefreshHookFreshProps;
|
|
14
17
|
hook?: DragRefreshHookProps;
|
|
15
18
|
};
|
|
16
19
|
|
|
@@ -39,12 +42,12 @@ export const DragFresh = (props: DragRefreshProps) => {
|
|
|
39
42
|
},
|
|
40
43
|
};
|
|
41
44
|
|
|
42
|
-
let isEnabled =
|
|
45
|
+
let isEnabled = false;
|
|
43
46
|
if (props.hook) {
|
|
44
|
-
props.hook.
|
|
45
|
-
|
|
47
|
+
props.hook.setCheckEnabled = (checkEnabled: DragRefreshHookCheckProps) => {
|
|
48
|
+
props.checkEnabled = checkEnabled;
|
|
46
49
|
};
|
|
47
|
-
props.hook.
|
|
50
|
+
props.hook.setOnDragRefresh = (onDragRefresh: (close: DragRefreshCloseProps) => Promise<void>) => {
|
|
48
51
|
props.onDragRefresh = onDragRefresh;
|
|
49
52
|
};
|
|
50
53
|
}
|
|
@@ -69,6 +72,7 @@ export const DragFresh = (props: DragRefreshProps) => {
|
|
|
69
72
|
let needRefresh = false;
|
|
70
73
|
const maxHeight = 150;
|
|
71
74
|
container.addEventListener('touchstart', (e: any) => {
|
|
75
|
+
isEnabled = props.checkEnabled && props.onDragRefresh ? props.checkEnabled() : false;
|
|
72
76
|
if (!isEnabled) return;
|
|
73
77
|
touchstartY = e.touches[0].clientY;
|
|
74
78
|
touchstartX = e.touches[0].clientX;
|
|
@@ -110,7 +114,7 @@ export const DragFresh = (props: DragRefreshProps) => {
|
|
|
110
114
|
if (!isEnabled) return;
|
|
111
115
|
if (direction === 'Y') {
|
|
112
116
|
if (needRefresh) {
|
|
113
|
-
props.onDragRefresh(closeSpin);
|
|
117
|
+
props.onDragRefresh?.(closeSpin);
|
|
114
118
|
} else {
|
|
115
119
|
closeSpin();
|
|
116
120
|
}
|
|
@@ -18,7 +18,7 @@ export interface ResponsiveFrameProps {
|
|
|
18
18
|
desktopTopMenu: IconMenuItemProps[];
|
|
19
19
|
mobileBottomMenu: IconMenuItemProps[];
|
|
20
20
|
mobileSideMenuContent: VNode<any>;
|
|
21
|
-
|
|
21
|
+
sharedContents: VNode<any>;
|
|
22
22
|
}
|
|
23
23
|
export const ResponsiveFrame = async (props: ResponsiveFrameProps) => {
|
|
24
24
|
const cssContainer: CssProps = {
|
|
@@ -65,7 +65,7 @@ export const ResponsiveFrame = async (props: ResponsiveFrameProps) => {
|
|
|
65
65
|
|
|
66
66
|
return (
|
|
67
67
|
<div css={cssContainer} class='responsive-frame'>
|
|
68
|
-
|
|
68
|
+
{props.sharedContents}
|
|
69
69
|
<div class='frame-top-menu'>
|
|
70
70
|
<DesktopHeader title={props.desktopHeaderTitle} items={props.desktopTopMenu}></DesktopHeader>
|
|
71
71
|
<MobileHeaderComponent></MobileHeaderComponent>
|
|
@@ -19,6 +19,7 @@ export type SliderFrameHookProps = {
|
|
|
19
19
|
load?: (children: VNode<any>) => void;
|
|
20
20
|
close?: (event: Event) => void;
|
|
21
21
|
addClass?: (className: SliderFramePosition) => void;
|
|
22
|
+
isOpened?: () => boolean;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
export type SliderFrameProps = {
|
|
@@ -50,6 +51,9 @@ export const SliderFrame = (props: SliderFrameProps) => {
|
|
|
50
51
|
props.hook.addClass = (className) => {
|
|
51
52
|
ref.current?.classList.add(className);
|
|
52
53
|
};
|
|
54
|
+
props.hook.isOpened = () => {
|
|
55
|
+
return ref.current?.classList.contains('show');
|
|
56
|
+
};
|
|
53
57
|
}
|
|
54
58
|
const dom = new HtmlVar(<div class='slider-frame-default'>{props.defaultContent || '(No Content)'}</div>);
|
|
55
59
|
const ref: RefProps = {};
|
package/src/lib/drag-util.ts
CHANGED
|
@@ -27,6 +27,7 @@ export const createDragUtil = () => {
|
|
|
27
27
|
let initialY = 0;
|
|
28
28
|
let draggingDom: HTMLDivElement | null = null;
|
|
29
29
|
let onMoveCallback: (clientX: number, clientY: number, movedX: number, movedY: number) => void = () => {};
|
|
30
|
+
let onMoveEndCallback: () => void = () => {};
|
|
30
31
|
let onScaleCallback: (scale: number) => void = () => {};
|
|
31
32
|
|
|
32
33
|
let isZooming = false;
|
|
@@ -37,10 +38,19 @@ export const createDragUtil = () => {
|
|
|
37
38
|
const dy = t2.clientY - t1.clientY;
|
|
38
39
|
return Math.sqrt(dx * dx + dy * dy);
|
|
39
40
|
};
|
|
41
|
+
const onMoveEnd = () => {
|
|
42
|
+
onMoveEndCallback();
|
|
43
|
+
isDragging = false;
|
|
44
|
+
isZooming = false;
|
|
45
|
+
draggingDom = null;
|
|
46
|
+
};
|
|
40
47
|
return {
|
|
41
48
|
setOnMoveCallback: (callback: (clientX: number, clientY: number, movedX: number, movedY: number) => void) => {
|
|
42
49
|
onMoveCallback = callback;
|
|
43
50
|
},
|
|
51
|
+
setOnMoveEndCallback: (callback: () => void) => {
|
|
52
|
+
onMoveEndCallback = callback;
|
|
53
|
+
},
|
|
44
54
|
setOnScaleCallback: (callback: (scale: number) => void) => {
|
|
45
55
|
onScaleCallback = callback;
|
|
46
56
|
},
|
|
@@ -54,11 +64,15 @@ export const createDragUtil = () => {
|
|
|
54
64
|
return;
|
|
55
65
|
}
|
|
56
66
|
isDragging = true;
|
|
67
|
+
isZooming = false;
|
|
57
68
|
draggingDom = event.currentTarget as HTMLDivElement;
|
|
58
69
|
initialX = event.clientX;
|
|
59
70
|
initialY = event.clientY;
|
|
60
71
|
},
|
|
61
72
|
onMouseMove: (event: MouseEvent) => {
|
|
73
|
+
if (event.buttons === 0 && isDragging) {
|
|
74
|
+
onMoveEnd();
|
|
75
|
+
}
|
|
62
76
|
if (event.buttons === 0 || !draggingDom) {
|
|
63
77
|
isDragging = false;
|
|
64
78
|
draggingDom = null;
|
|
@@ -66,20 +80,18 @@ export const createDragUtil = () => {
|
|
|
66
80
|
}
|
|
67
81
|
onMoveCallback(event.clientX, event.clientY, event.clientX - initialX, event.clientY - initialY);
|
|
68
82
|
},
|
|
69
|
-
onMouseUp:
|
|
70
|
-
isDragging = false;
|
|
71
|
-
isZooming = false;
|
|
72
|
-
draggingDom = null;
|
|
73
|
-
},
|
|
83
|
+
onMouseUp: onMoveEnd,
|
|
74
84
|
|
|
75
85
|
onTouchStart: (event: TouchEvent) => {
|
|
76
86
|
if (event.touches.length === 1) {
|
|
77
87
|
isDragging = true;
|
|
88
|
+
isZooming = false;
|
|
78
89
|
draggingDom = event.currentTarget as HTMLDivElement;
|
|
79
90
|
initialX = event.touches[0].clientX;
|
|
80
91
|
initialY = event.touches[0].clientY;
|
|
81
92
|
} else if (event.touches.length === 2) {
|
|
82
93
|
initialDistance = getDistance(event.touches[0], event.touches[1]);
|
|
94
|
+
isDragging = false;
|
|
83
95
|
isZooming = true;
|
|
84
96
|
} else {
|
|
85
97
|
isDragging = false;
|
|
@@ -94,10 +106,15 @@ export const createDragUtil = () => {
|
|
|
94
106
|
const delta = newDistance / initialDistance;
|
|
95
107
|
// const newScale = Math.min(Math.max(1, scale * delta), 4); // 限制缩放范围
|
|
96
108
|
onScaleCallback(delta);
|
|
97
|
-
|
|
109
|
+
} else {
|
|
110
|
+
onMoveEnd();
|
|
98
111
|
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (event.touches.length === 0 && isDragging) {
|
|
115
|
+
onMoveEnd();
|
|
99
116
|
}
|
|
100
|
-
if (
|
|
117
|
+
if (event.touches.length === 0 || !draggingDom) {
|
|
101
118
|
isDragging = false;
|
|
102
119
|
draggingDom = null;
|
|
103
120
|
return;
|
|
@@ -109,10 +126,6 @@ export const createDragUtil = () => {
|
|
|
109
126
|
event.touches[0].clientY - initialY
|
|
110
127
|
);
|
|
111
128
|
},
|
|
112
|
-
onTouchEnd:
|
|
113
|
-
isDragging = false;
|
|
114
|
-
isZooming = false;
|
|
115
|
-
draggingDom = null;
|
|
116
|
-
},
|
|
129
|
+
onTouchEnd: onMoveEnd,
|
|
117
130
|
};
|
|
118
131
|
};
|