lupine.components 1.0.23 → 1.0.25
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
|
@@ -49,7 +49,7 @@ export const DragFresh = (props: DragRefreshProps) => {
|
|
|
49
49
|
if (!container || !pullDom || !spinnerDom) return;
|
|
50
50
|
let touchstartY = 0;
|
|
51
51
|
let touchstartX = 0;
|
|
52
|
-
let direction = '';
|
|
52
|
+
let direction: 'X' | 'Y' | '' = '';
|
|
53
53
|
let needRefresh = false;
|
|
54
54
|
const maxHeight = 150;
|
|
55
55
|
container.addEventListener('touchstart', (e: any) => {
|
|
@@ -59,23 +59,23 @@ export const DragFresh = (props: DragRefreshProps) => {
|
|
|
59
59
|
needRefresh = false;
|
|
60
60
|
});
|
|
61
61
|
container.addEventListener('touchmove', (e: any) => {
|
|
62
|
-
console.log(`window.scrollY: ${window.scrollY}`);
|
|
63
62
|
const touchY = e.touches[0].clientY;
|
|
64
63
|
const touchX = e.touches[0].clientX;
|
|
65
64
|
const movedY = touchY - touchstartY;
|
|
66
65
|
const movedX = touchX - touchstartX;
|
|
67
66
|
if (direction === '') {
|
|
68
|
-
if (movedY >
|
|
67
|
+
if (Math.abs(movedY) > Math.abs(movedX)) {
|
|
69
68
|
direction = 'Y';
|
|
70
|
-
} else
|
|
69
|
+
} else {
|
|
71
70
|
direction = 'X';
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
|
-
|
|
73
|
+
// console.log(`direction: ${direction}, movedX: ${movedX}, movedY: ${movedY}, container.scrollTop: ${container.scrollTop}`);
|
|
74
|
+
if (direction !== 'Y') {
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
-
if (
|
|
78
|
-
needRefresh = movedY >
|
|
77
|
+
if (container.scrollTop <= 0 && movedY > 5) {
|
|
78
|
+
needRefresh = movedY > 60;
|
|
79
79
|
if (movedY > 5) {
|
|
80
80
|
pullDom.classList.add('show');
|
|
81
81
|
spinnerDom.style.height = `${Math.min(maxHeight, movedY)}px`;
|
|
@@ -83,7 +83,7 @@ export const DragFresh = (props: DragRefreshProps) => {
|
|
|
83
83
|
pullDom.classList.remove('show');
|
|
84
84
|
spinnerDom.style.height = '0';
|
|
85
85
|
}
|
|
86
|
-
} else
|
|
86
|
+
} else {
|
|
87
87
|
pullDom.classList.remove('show');
|
|
88
88
|
spinnerDom.style.height = '0';
|
|
89
89
|
}
|
|
@@ -15,6 +15,7 @@ export type FloatWindowShowProps = {
|
|
|
15
15
|
handleClicked: (index: number, close: FloatWindowCloseProps) => void;
|
|
16
16
|
closeWhenClickOutside?: boolean; // default false
|
|
17
17
|
zIndex?: string;
|
|
18
|
+
contentOverflowY?: string;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
// because it's over a mask, so it can use primary colors
|
|
@@ -45,6 +46,7 @@ export class FloatWindow {
|
|
|
45
46
|
handleClicked,
|
|
46
47
|
closeWhenClickOutside = false,
|
|
47
48
|
zIndex,
|
|
49
|
+
contentOverflowY = 'auto', // set to unset for having popup menu inside
|
|
48
50
|
}: FloatWindowShowProps): Promise<FloatWindowCloseProps> {
|
|
49
51
|
const onClickContainer = (event: any) => {
|
|
50
52
|
if (closeWhenClickOutside !== false && event.target.className === 'fwin-box') {
|
|
@@ -143,7 +145,7 @@ export class FloatWindow {
|
|
|
143
145
|
'.fwin-content': {
|
|
144
146
|
padding: '15px',
|
|
145
147
|
maxHeight: contentMaxHeight ? `min(${contentMaxHeight}, calc(100% - 100px))` : 'calc(100% - 100px)',
|
|
146
|
-
overflowY:
|
|
148
|
+
overflowY: contentOverflowY,
|
|
147
149
|
},
|
|
148
150
|
'.fwin-bottom': {
|
|
149
151
|
display: 'flex',
|
package/src/components/modal.tsx
CHANGED
|
@@ -13,6 +13,7 @@ export class ModalWindow {
|
|
|
13
13
|
handleClicked,
|
|
14
14
|
closeWhenClickOutside = true,
|
|
15
15
|
zIndex,
|
|
16
|
+
contentOverflowY,
|
|
16
17
|
}: FloatWindowShowProps): Promise<FloatWindowCloseProps> {
|
|
17
18
|
return FloatWindow.show({
|
|
18
19
|
title,
|
|
@@ -26,6 +27,7 @@ export class ModalWindow {
|
|
|
26
27
|
handleClicked,
|
|
27
28
|
closeWhenClickOutside,
|
|
28
29
|
zIndex,
|
|
30
|
+
contentOverflowY,
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
}
|
|
@@ -1,99 +1,175 @@
|
|
|
1
|
-
import { CssProps, bindGlobalStyles, getRenderPageProps } from 'lupine.web';
|
|
1
|
+
import { CssProps, RefProps, bindGlobalStyles, getRenderPageProps } from 'lupine.web';
|
|
2
2
|
|
|
3
|
-
let _DEFAULT_PAGE_LIMIT =
|
|
3
|
+
let _DEFAULT_PAGE_LIMIT = 10;
|
|
4
4
|
export const getDefaultPageLimit = () => {
|
|
5
5
|
return _DEFAULT_PAGE_LIMIT;
|
|
6
6
|
};
|
|
7
7
|
export const setDefaultPageLimit = (limit: number) => {
|
|
8
8
|
_DEFAULT_PAGE_LIMIT = limit;
|
|
9
9
|
};
|
|
10
|
+
const pageLinkOptions = [10, 20, 50, 100, 200, 500];
|
|
10
11
|
export type PagingLinkProps = {
|
|
11
12
|
itemsCount: number;
|
|
12
13
|
pageLimit?: number;
|
|
13
14
|
pageIndex?: number;
|
|
14
15
|
baseLink: string;
|
|
15
16
|
onClick?: (index: number) => void; // if onClick is set then use it instead of href
|
|
17
|
+
textPerpage?: string;
|
|
18
|
+
textOk?: string;
|
|
19
|
+
textTo?: string;
|
|
20
|
+
textPage?: string;
|
|
21
|
+
showControl?: boolean;
|
|
16
22
|
};
|
|
17
23
|
|
|
18
|
-
export const PagingLink = (
|
|
24
|
+
export const PagingLink = ({
|
|
25
|
+
itemsCount,
|
|
26
|
+
pageLimit = getDefaultPageLimit(),
|
|
27
|
+
pageIndex = 0,
|
|
28
|
+
baseLink,
|
|
29
|
+
onClick,
|
|
30
|
+
textPerpage = '/Page',
|
|
31
|
+
textOk = 'Go',
|
|
32
|
+
textTo = 'To',
|
|
33
|
+
textPage = 'Page',
|
|
34
|
+
showControl,
|
|
35
|
+
}: PagingLinkProps) => {
|
|
19
36
|
const css: CssProps = {
|
|
37
|
+
display: 'flex',
|
|
38
|
+
justifyContent: 'end',
|
|
39
|
+
alignItems: 'center',
|
|
20
40
|
textAlign: 'right',
|
|
21
|
-
|
|
22
|
-
'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
a: {
|
|
41
|
+
padding: '6px 16px 6px 0',
|
|
42
|
+
fontSize: '14px',
|
|
43
|
+
'.paging-link-index a, .paging-link-index.current': {
|
|
44
|
+
padding: '2px 6px',
|
|
26
45
|
textDecoration: 'none',
|
|
27
46
|
},
|
|
47
|
+
'.paging-link-index.current': {
|
|
48
|
+
fontWeight: 'bold',
|
|
49
|
+
},
|
|
50
|
+
'span.paging-link-index a:hover, span.paging-link-go a:hover': {
|
|
51
|
+
textDecoration: 'underline',
|
|
52
|
+
},
|
|
53
|
+
'.paging-link-ctl-box': {
|
|
54
|
+
display: 'flex',
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
},
|
|
57
|
+
'.paging-link-ctl-box .paging-link-jump': {
|
|
58
|
+
width: '50px',
|
|
59
|
+
padding: '1px 3px',
|
|
60
|
+
margin: '0 3px',
|
|
61
|
+
textAlign: 'right',
|
|
62
|
+
},
|
|
63
|
+
'.paging-link-ctl-box .paging-link-limit': {
|
|
64
|
+
width: '90px',
|
|
65
|
+
padding: '1px 3px',
|
|
66
|
+
margin: '0 3px',
|
|
67
|
+
},
|
|
68
|
+
'.paging-link-ok': {
|
|
69
|
+
margin: '0 3px',
|
|
70
|
+
},
|
|
28
71
|
};
|
|
29
72
|
|
|
30
73
|
bindGlobalStyles('paging-link-box', '.paging-link-box', css);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
if (props.itemsCount % pageLimit !== 0) {
|
|
74
|
+
pageIndex = pageIndex ?? (Number.parseInt(getRenderPageProps().query['pg_i'] || '') || 0);
|
|
75
|
+
pageLimit = pageLimit || _DEFAULT_PAGE_LIMIT;
|
|
76
|
+
let maxPages = Math.floor(itemsCount / pageLimit);
|
|
77
|
+
if (itemsCount > 0 && pageLimit > 0) {
|
|
78
|
+
if (itemsCount % pageLimit !== 0) {
|
|
37
79
|
maxPages++;
|
|
38
80
|
}
|
|
39
81
|
if (pageIndex > maxPages) {
|
|
40
82
|
pageIndex = maxPages - 1;
|
|
41
83
|
}
|
|
42
|
-
|
|
43
|
-
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const onPageLimitChange = (e: Event) => {
|
|
87
|
+
const limit = Number((e.target as HTMLSelectElement).value || '0');
|
|
88
|
+
if (limit > 0) {
|
|
89
|
+
setDefaultPageLimit(limit);
|
|
90
|
+
onClick && onClick(pageIndex);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const onOkClick = () => {
|
|
95
|
+
let index = Number((ref.$('.paging-link-jump') as HTMLInputElement).value || '0');
|
|
96
|
+
if (index < 1) {
|
|
97
|
+
index = 1;
|
|
98
|
+
}
|
|
99
|
+
if (index > maxPages) {
|
|
100
|
+
index = maxPages;
|
|
101
|
+
}
|
|
102
|
+
onClick && onClick(index - 1);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const ref: RefProps = {};
|
|
106
|
+
return (
|
|
107
|
+
<div ref={ref} class='paging-link-box'>
|
|
108
|
+
{pageIndex > 0 ? (
|
|
44
109
|
<span class='paging-link-go'>
|
|
45
110
|
<a
|
|
46
|
-
href={
|
|
47
|
-
onClick={() =>
|
|
111
|
+
href={onClick ? 'javascript:void(0)' : baseLink + '?pg_i=' + (pageIndex - 1)}
|
|
112
|
+
onClick={() => onClick && onClick(pageIndex - 1)}
|
|
48
113
|
>
|
|
49
114
|
<
|
|
50
115
|
</a>
|
|
51
116
|
</span>
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
html.push(<span class='paging-link-skip'>...</span>);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (pageIndex < maxPages - 1) {
|
|
83
|
-
html.push(
|
|
117
|
+
) : (
|
|
118
|
+
<span class='paging-link-go disabled'><</span>
|
|
119
|
+
)}
|
|
120
|
+
|
|
121
|
+
{Array.from({ length: maxPages }, (_, i) => i).map((i) => (
|
|
122
|
+
<>
|
|
123
|
+
{i < 2 || i >= maxPages - 2 || (i > pageIndex - 3 && i < pageIndex + 3) ? (
|
|
124
|
+
i == pageIndex ? (
|
|
125
|
+
<span class='paging-link-index current'>{i + 1}</span>
|
|
126
|
+
) : (
|
|
127
|
+
<span class='paging-link-index'>
|
|
128
|
+
<a
|
|
129
|
+
href={onClick ? 'javascript:void(0)' : baseLink + '?pg_i=' + i}
|
|
130
|
+
onClick={() => onClick && onClick(i)}
|
|
131
|
+
>
|
|
132
|
+
{i + 1}
|
|
133
|
+
</a>
|
|
134
|
+
</span>
|
|
135
|
+
)
|
|
136
|
+
) : (
|
|
137
|
+
(i == pageIndex - 4 || i == pageIndex + 4) && <span class='paging-link-skip'>...</span>
|
|
138
|
+
)}
|
|
139
|
+
</>
|
|
140
|
+
))}
|
|
141
|
+
|
|
142
|
+
{pageIndex < maxPages - 1 ? (
|
|
84
143
|
<span class='paging-link-go'>
|
|
85
144
|
<a
|
|
86
|
-
href={
|
|
87
|
-
onClick={() =>
|
|
145
|
+
href={onClick ? 'javascript:void(0)' : baseLink + '?pg_i=' + (pageIndex + 1)}
|
|
146
|
+
onClick={() => onClick && onClick(pageIndex + 1)}
|
|
88
147
|
>
|
|
89
148
|
>
|
|
90
149
|
</a>
|
|
91
150
|
</span>
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
151
|
+
) : (
|
|
152
|
+
<span class='paging-link-go disabled'>></span>
|
|
153
|
+
)}
|
|
154
|
+
{showControl && (
|
|
155
|
+
<div class='paging-link-ctl-box'>
|
|
156
|
+
{textTo}
|
|
157
|
+
<input class='input-base paging-link-jump input-s' type='number' value={pageIndex + 1} /> / {maxPages}{' '}
|
|
158
|
+
{textPage}
|
|
159
|
+
<button class='button-base button-s paging-link-ok' onClick={onOkClick}>
|
|
160
|
+
{textOk}
|
|
161
|
+
</button>
|
|
162
|
+
<select class='input-base paging-link-limit input-s' onChange={onPageLimitChange}>
|
|
163
|
+
<option value=''> - </option>
|
|
164
|
+
{pageLinkOptions.map((page) => (
|
|
165
|
+
<option value={page}>
|
|
166
|
+
{page}
|
|
167
|
+
{textPerpage}
|
|
168
|
+
</option>
|
|
169
|
+
))}
|
|
170
|
+
</select>
|
|
171
|
+
</div>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
);
|
|
99
175
|
};
|
|
@@ -57,7 +57,7 @@ export const ResponsiveFrame = async (props: ResponsiveFrameProps) => {
|
|
|
57
57
|
padding: '0 16px',
|
|
58
58
|
},
|
|
59
59
|
[MediaQueryRange.TabletBelow]: {
|
|
60
|
-
'.frame-footer .footer-box, .frame-top-menu .desktop-menu-box': {
|
|
60
|
+
'.frame-footer .d-footer-box, .frame-top-menu .desktop-menu-box': {
|
|
61
61
|
display: 'none',
|
|
62
62
|
},
|
|
63
63
|
},
|