@gmfe/react 2.15.7-alpha.0 → 2.15.8-alpha.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmfe/react",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.8-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "liyatang <liyatang@qq.com>",
|
|
6
6
|
"homepage": "https://github.com/gmfe/gmfe#readme",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@gm-common/tool": "^1.0.0",
|
|
30
|
-
"@gmfe/locales": "^2.15.
|
|
30
|
+
"@gmfe/locales": "^2.15.8-alpha.0",
|
|
31
31
|
"big.js": "^5.2.2",
|
|
32
32
|
"classnames": "^2.2.5",
|
|
33
33
|
"lodash": "^4.17.14",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"prop-types": "^15.7.2",
|
|
36
36
|
"react-window": "^1.8.5"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "7fa7c0fcf7f3c5097ad61af3b78a30af65ad386e"
|
|
39
39
|
}
|
package/src/component/box/box.js
CHANGED
|
@@ -26,10 +26,7 @@ const BoxHeader = StickyLayout(props => {
|
|
|
26
26
|
return (
|
|
27
27
|
<Flex
|
|
28
28
|
{...headerProps}
|
|
29
|
-
className={classNames(
|
|
30
|
-
'gm-box-table-header common-sticky-header',
|
|
31
|
-
headerClassName
|
|
32
|
-
)}
|
|
29
|
+
className={classNames('gm-box-table-header', headerClassName)}
|
|
33
30
|
alignCenter
|
|
34
31
|
>
|
|
35
32
|
<Flex>{info}</Flex>
|
|
@@ -13,6 +13,7 @@ const BoxPanel = ({
|
|
|
13
13
|
right,
|
|
14
14
|
summary,
|
|
15
15
|
className,
|
|
16
|
+
headerProps = {},
|
|
16
17
|
children,
|
|
17
18
|
...rest
|
|
18
19
|
}) => {
|
|
@@ -26,7 +27,15 @@ const BoxPanel = ({
|
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
29
|
<div {...rest} className={classNames('gm-box gm-box-panel', className)}>
|
|
29
|
-
<Flex
|
|
30
|
+
<Flex
|
|
31
|
+
flex
|
|
32
|
+
justifyBetween
|
|
33
|
+
alignCenter
|
|
34
|
+
className={classNames(
|
|
35
|
+
'gm-box-panel-header',
|
|
36
|
+
headerProps.className || ''
|
|
37
|
+
)}
|
|
38
|
+
>
|
|
30
39
|
<Flex alignCenter>
|
|
31
40
|
{hasCollapse && (
|
|
32
41
|
<a
|
|
@@ -85,6 +94,7 @@ BoxPanel.propTypes = {
|
|
|
85
94
|
summary: PropTypes.oneOfType([PropTypes.array, PropTypes.element]),
|
|
86
95
|
right: PropTypes.element,
|
|
87
96
|
className: PropTypes.string,
|
|
97
|
+
headerProps: PropTypes.object,
|
|
88
98
|
style: PropTypes.object
|
|
89
99
|
}
|
|
90
100
|
|
|
@@ -2,7 +2,6 @@ import React from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import Flex from '../flex'
|
|
5
|
-
import StickyLayout from '../../hoc/sticky_layout'
|
|
6
5
|
|
|
7
6
|
// 暂时没什么用
|
|
8
7
|
const Info = props => {
|
|
@@ -19,32 +18,21 @@ Info.propTypes = {
|
|
|
19
18
|
style: PropTypes.object
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
const BoxHeader = StickyLayout(props => {
|
|
23
|
-
const { info, action, headerProps = {} } = props
|
|
24
|
-
const { className: headerClassName } = headerProps
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<Flex
|
|
28
|
-
{...headerProps}
|
|
29
|
-
className={classNames(
|
|
30
|
-
'gm-box-table-header common-sticky-header',
|
|
31
|
-
headerClassName
|
|
32
|
-
)}
|
|
33
|
-
alignCenter
|
|
34
|
-
>
|
|
35
|
-
<Flex>{info}</Flex>
|
|
36
|
-
<Flex flex />
|
|
37
|
-
<Flex>{action}</Flex>
|
|
38
|
-
</Flex>
|
|
39
|
-
)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
21
|
const BoxTable = props => {
|
|
43
|
-
const { children, className, ...rest } = props
|
|
22
|
+
const { info, action, headerProps = {}, children, className, ...rest } = props
|
|
23
|
+
const { className: headerClassName } = headerProps
|
|
44
24
|
|
|
45
25
|
return (
|
|
46
26
|
<div {...rest} className={classNames('gm-box gm-box-table', className)}>
|
|
47
|
-
<
|
|
27
|
+
<Flex
|
|
28
|
+
{...headerProps}
|
|
29
|
+
className={classNames('gm-box-table-header', headerClassName)}
|
|
30
|
+
alignCenter
|
|
31
|
+
>
|
|
32
|
+
<Flex>{info}</Flex>
|
|
33
|
+
<Flex flex />
|
|
34
|
+
<Flex>{action}</Flex>
|
|
35
|
+
</Flex>
|
|
48
36
|
<div>{children}</div>
|
|
49
37
|
</div>
|
|
50
38
|
)
|
package/src/hoc/sticky_layout.js
CHANGED
|
@@ -141,82 +141,111 @@ const handleTopSentinelLeave = currentStickyRef => {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
() => ({ ...SENTINEL_STYLE, bottom: '0' }),
|
|
158
|
-
[]
|
|
159
|
-
)
|
|
144
|
+
/**
|
|
145
|
+
* 粘性布局包装器组件
|
|
146
|
+
* 负责管理哨兵元素和 IntersectionObserver
|
|
147
|
+
*/
|
|
148
|
+
const StickyWrapper = ({
|
|
149
|
+
children,
|
|
150
|
+
onTopSentinelEnter,
|
|
151
|
+
onTopSentinelLeave
|
|
152
|
+
}) => {
|
|
153
|
+
const wrapperRef = useRef(null)
|
|
154
|
+
const topSentinelRef = useRef(null)
|
|
155
|
+
const bottomSentinelRef = useRef(null)
|
|
156
|
+
const observerRef = useRef(null)
|
|
160
157
|
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
// 哨兵元素样式
|
|
159
|
+
const topSentinelStyle = useMemo(() => ({ ...SENTINEL_STYLE, top: '0' }), [])
|
|
160
|
+
const bottomSentinelStyle = useMemo(
|
|
161
|
+
() => ({ ...SENTINEL_STYLE, bottom: '0' }),
|
|
162
|
+
[]
|
|
163
|
+
)
|
|
163
164
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
if (!wrapperRef.current) {
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (typeof window.IntersectionObserver === 'undefined') {
|
|
171
|
+
return
|
|
172
|
+
}
|
|
167
173
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
174
|
+
observerRef.current = new window.IntersectionObserver(entries => {
|
|
175
|
+
entries.forEach(entry => {
|
|
176
|
+
const target = entry.target
|
|
171
177
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
if (target === topSentinelRef.current) {
|
|
179
|
+
if (entry.isIntersecting) {
|
|
180
|
+
if (onTopSentinelEnter) {
|
|
181
|
+
onTopSentinelEnter(wrapperRef)
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
if (onTopSentinelLeave) {
|
|
185
|
+
onTopSentinelLeave(wrapperRef)
|
|
177
186
|
}
|
|
178
187
|
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
}, OBSERVER_OPTIONS)
|
|
181
191
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
192
|
+
// 观察哨兵元素
|
|
193
|
+
if (topSentinelRef.current) {
|
|
194
|
+
observerRef.current.observe(topSentinelRef.current)
|
|
195
|
+
}
|
|
196
|
+
if (bottomSentinelRef.current) {
|
|
197
|
+
observerRef.current.observe(bottomSentinelRef.current)
|
|
198
|
+
}
|
|
189
199
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
200
|
+
return () => {
|
|
201
|
+
if (observerRef.current) {
|
|
202
|
+
observerRef.current.disconnect()
|
|
194
203
|
}
|
|
195
|
-
}
|
|
204
|
+
}
|
|
205
|
+
}, [onTopSentinelEnter, onTopSentinelLeave])
|
|
196
206
|
|
|
207
|
+
return (
|
|
208
|
+
<div ref={wrapperRef} className='common-sticky-layout'>
|
|
209
|
+
<div
|
|
210
|
+
ref={topSentinelRef}
|
|
211
|
+
data-sentinel='topSentinel'
|
|
212
|
+
style={topSentinelStyle}
|
|
213
|
+
/>
|
|
214
|
+
{children}
|
|
215
|
+
<div
|
|
216
|
+
ref={bottomSentinelRef}
|
|
217
|
+
data-sentinel='bottomSentinel'
|
|
218
|
+
style={bottomSentinelStyle}
|
|
219
|
+
/>
|
|
220
|
+
</div>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
StickyWrapper.propTypes = {
|
|
225
|
+
children: PropTypes.node.isRequired,
|
|
226
|
+
onTopSentinelEnter: PropTypes.func,
|
|
227
|
+
onTopSentinelLeave: PropTypes.func
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function StickyLayout(Component) {
|
|
231
|
+
const _StickyLayout = ({ sticky, ...rest }) => {
|
|
232
|
+
// 如果不需要粘性布局,直接返回原组件
|
|
197
233
|
if (!sticky) {
|
|
198
234
|
return <Component {...rest} />
|
|
199
235
|
}
|
|
200
236
|
|
|
201
237
|
return (
|
|
202
|
-
<
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
style={topSentinelStyle}
|
|
207
|
-
/>
|
|
238
|
+
<StickyWrapper
|
|
239
|
+
onTopSentinelEnter={handleTopSentinelEnter}
|
|
240
|
+
onTopSentinelLeave={handleTopSentinelLeave}
|
|
241
|
+
>
|
|
208
242
|
<Component {...rest} />
|
|
209
|
-
|
|
210
|
-
ref={bottomSentinelRef}
|
|
211
|
-
data-sentinel='bottomSentinel'
|
|
212
|
-
style={bottomSentinelStyle}
|
|
213
|
-
/>
|
|
214
|
-
</div>
|
|
243
|
+
</StickyWrapper>
|
|
215
244
|
)
|
|
216
245
|
}
|
|
217
246
|
|
|
218
247
|
_StickyLayout.defaultProps = {
|
|
219
|
-
sticky:
|
|
248
|
+
sticky: false
|
|
220
249
|
}
|
|
221
250
|
|
|
222
251
|
_StickyLayout.propTypes = {
|