@gmfe/react 2.14.26-beta.0 → 2.14.30-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/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2020-present, gmfe contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmfe/react",
3
- "version": "2.14.26-beta.0",
3
+ "version": "2.14.30-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.14.26-beta.0",
30
+ "@gmfe/locales": "^2.14.30-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": "536b1cbe2600f51dc308f1aba4e97743e0222d98"
38
+ "gitHead": "f7da14010d37550f0a19949fe4a5b3d65301545a"
39
39
  }
@@ -2,6 +2,7 @@ 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'
5
6
 
6
7
  // 暂时没什么用
7
8
  const Info = props => {
@@ -18,21 +19,27 @@ Info.propTypes = {
18
19
  style: PropTypes.object
19
20
  }
20
21
 
21
- const BoxTable = props => {
22
- const { info, action, children, className, headerProps = {}, ...rest } = props
22
+ const BoxHeader = StickyLayout((props) => {
23
+ const { info, action, headerProps = {} } = props
23
24
  const { className: headerClassName } = headerProps
24
25
 
26
+ return <Flex
27
+ {...headerProps}
28
+ className={classNames('gm-box-table-header common-sticky-header', headerClassName)}
29
+ alignCenter
30
+ >
31
+ <Flex>{info}</Flex>
32
+ <Flex flex />
33
+ <Flex>{action}</Flex>
34
+ </Flex>
35
+ });
36
+
37
+ const BoxTable = props => {
38
+ const { children, className, ...rest } = props
39
+
25
40
  return (
26
41
  <div {...rest} className={classNames('gm-box gm-box-table', className)}>
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>
42
+ <BoxHeader {...props} />
36
43
  <div>{children}</div>
37
44
  </div>
38
45
  )
@@ -109,7 +109,7 @@ const Overlay = ({
109
109
  id={v.value}
110
110
  >
111
111
  {v.name}&nbsp;
112
- {Array.isArray(v.children) && v.children.length > 0 && (
112
+ {v.children && v.children.length && (
113
113
  <i className={classNames('gm-arrow-right')} />
114
114
  )}
115
115
  </Flex>
@@ -183,6 +183,7 @@ class Cascader extends React.Component {
183
183
  }
184
184
  }
185
185
  })
186
+
186
187
  return result
187
188
  }
188
189
 
@@ -340,6 +341,7 @@ class Cascader extends React.Component {
340
341
  const { data } = this.state
341
342
  const inputValue = this.inputValueRender()
342
343
  let { inputProps } = this.props
344
+
343
345
  const selected = this.props.value || this.state.selected
344
346
  const value = []
345
347
  if (selected.length > 0) {
@@ -61,24 +61,13 @@ const FormItem = withWrapContext(
61
61
  style,
62
62
  disabledCol ? {} : { width: _cw * col }
63
63
  )
64
- // TODO 以前的判断逻辑有问题
65
- // if (canValidate && validate !== undefined) {
66
- // if (required) {
67
- // help = validate(function(value) {
68
- // return Validator.validate(Validator.TYPE.required, value)
69
- // })
70
- // } else {
71
- // help = validate()
72
- // }
73
- // error = !!help
74
- // }
75
-
76
64
  if (canValidate && validate !== undefined) {
77
- help = validate()
78
- if (required && !help) {
65
+ if (required) {
79
66
  help = validate(function(value) {
80
67
  return Validator.validate(Validator.TYPE.required, value)
81
68
  })
69
+ } else {
70
+ help = validate()
82
71
  }
83
72
  error = !!help
84
73
  }
@@ -78,7 +78,9 @@ class InputNumberV2 extends React.Component {
78
78
  // 一旦不一致就应该改,要比较 number 形式
79
79
  if (props.value !== text2Number(state.value)) {
80
80
  return {
81
- value: processPropsValue(props.value)
81
+ value: processPropsValue(
82
+ props.forceInnerValue ? state.value : props.value
83
+ )
82
84
  }
83
85
  }
84
86
 
@@ -147,12 +149,14 @@ InputNumberV2.propTypes = {
147
149
  onChange: PropTypes.func.isRequired,
148
150
  precision: PropTypes.number, // 精确度,保留几位小数
149
151
  className: PropTypes.string,
150
- style: PropTypes.object
152
+ style: PropTypes.object,
153
+ forceInnerValue: PropTypes.bool // 修复场景:删除1.09会将 .0 一起删除
151
154
  }
152
155
 
153
156
  InputNumberV2.defaultProps = {
154
157
  value: null,
155
- precision: 2
158
+ precision: 2,
159
+ forceInnerValue: false
156
160
  }
157
161
 
158
162
  export default InputNumberV2
@@ -0,0 +1,157 @@
1
+ /**
2
+ * @author: stanfer
3
+ * @description:
4
+ * @createDate: 2025/11/24 10:05
5
+ * @Version: 1.0
6
+ * @last modify time:
7
+ **/
8
+ import React, { useRef, useEffect } from 'react'
9
+
10
+ function stickyLayout(Component) {
11
+ const StickyLayout = ({ sticky, ...rest }) => {
12
+ if (!sticky) { // 不传的话直接返回上个组件
13
+ return <Component {...rest} />
14
+ }
15
+
16
+ const currentStickyRef = useRef(null);
17
+ const topSentinelRef = useRef(null);
18
+ const bottomSentinelRef = useRef(null);
19
+ // 统一管理
20
+ const observerRef = useRef(null);
21
+
22
+ useEffect(() => {
23
+ if (!currentStickyRef.current) return;
24
+
25
+ const options = {
26
+ root: null, // 相对于浏览器视口
27
+ rootMargin: '0px',
28
+ threshold: 0, // 只要有一个像素进入/离开视口就触发
29
+ };
30
+
31
+ observerRef.current = new IntersectionObserver((entries) => {
32
+ entries.forEach((entry) => {
33
+ const target = entry.target;
34
+
35
+ if (target === topSentinelRef.current) {
36
+ if (entry.isIntersecting) {
37
+ // console.log('=======> 顶部进入');
38
+ let heightSum = 0, tableRoot;
39
+ const fullTab = document.querySelectorAll('.gm-framework-full-tabs')
40
+ const commonStickyHeader = document.querySelectorAll('.common-sticky-header')
41
+ const rtTable = document.querySelectorAll('.rt-table')
42
+ const rtTheadHeader = document.querySelectorAll('.rt-thead')
43
+ rtTheadHeader.forEach((el) => {
44
+ el.style.position = 'sticky';
45
+ el.style.top = 0;
46
+ el.style.zIndex = 10;
47
+ heightSum += el.offsetHeight + 10; // 元素本身高 + 上下 10 padding
48
+ })
49
+
50
+ commonStickyHeader.forEach((item, idx) => {
51
+ if (fullTab.length) {
52
+ currentStickyRef.current.style.zIndex = 101;
53
+ }
54
+ // console.log(item.className);
55
+ if (item.className.includes('gm-box-table-header')) { // 表格筛选项
56
+ heightSum += item.offsetHeight + 10; // 元素本身高 + 上 10 padding
57
+ // console.log(idx, item.getBoundingClientRect(), 'gm-box-table-header: ', item.getBoundingClientRect().height + 20);
58
+ }
59
+ if (item.className.includes('gm-table-x-thead')) { //
60
+ heightSum += item.offsetHeight + 8; // 元素本身高 + 上 8 padding
61
+ tableRoot = item.parentElement.parentElement;
62
+ // console.log(idx, item.getBoundingClientRect(), 'gm-table-x-thead: ', item.getBoundingClientRect().height + 16);
63
+ }
64
+ })
65
+
66
+ if (rtTable.length) {
67
+ rtTable.forEach((el) => {
68
+ if (fullTab.length) {
69
+ el.style.maxHeight = `calc(100vh - ${heightSum + (fullTab.length * 40) + 50}px)`; // +50 顶部导航栏
70
+ return;
71
+ }
72
+ el.style.maxHeight = `calc(100vh - ${heightSum + 50}px)`; // +50 顶部导航栏
73
+ })
74
+ }
75
+ if (tableRoot) {
76
+ if (fullTab.length) {
77
+ tableRoot.style.maxHeight = `calc(100vh - ${heightSum + (fullTab.length * 40) + 50}px)`; // +50 顶部导航栏
78
+ return;
79
+ }
80
+ tableRoot.style.maxHeight = `calc(100vh - ${heightSum + 50}px)`; // +50 顶部导航栏
81
+ }
82
+ // currentStickyRef.current.style.maxHeight = 'unset';
83
+ // console.log('currentStickyRef 实例:', currentStickyRef.current.style);
84
+ return
85
+ }
86
+ currentStickyRef.current.style.maxHeight = '50%';
87
+ // console.log('顶部离开 <========');
88
+ return;
89
+ }
90
+ if (target === bottomSentinelRef.current) {
91
+ if (entry.isIntersecting) {
92
+ // console.log('=======> 底部进入');
93
+ return;
94
+ }
95
+ // console.log('底部离开 <========');
96
+ }
97
+ });
98
+ }, options);
99
+
100
+ if (topSentinelRef.current) {
101
+ observerRef.current.observe(topSentinelRef.current);
102
+ }
103
+ if (bottomSentinelRef.current) {
104
+ observerRef.current.observe(bottomSentinelRef.current);
105
+ }
106
+
107
+ return () => {
108
+ if (observerRef.current) {
109
+ observerRef.current.disconnect();
110
+ }
111
+ };
112
+ }, [])
113
+
114
+ return (
115
+ <div ref={currentStickyRef} className='common-sticky-layout'>
116
+ <div
117
+ ref={topSentinelRef}
118
+ sentinel="topSentinel"
119
+ style={{
120
+ position: 'absolute',
121
+ top: '0',
122
+ left: '0',
123
+ width: '100%',
124
+ height: '1px',
125
+ pointerEvents: 'none',
126
+ backgroundColor: 'transparent',
127
+ }}
128
+ />
129
+ <Component {...rest} />
130
+ <div
131
+ ref={bottomSentinelRef}
132
+ sentinel="bottomSentinel"
133
+ style={{
134
+ position: 'absolute',
135
+ bottom: '0',
136
+ left: '0',
137
+ width: '100%',
138
+ height: '1px',
139
+ pointerEvents: 'none',
140
+ backgroundColor: 'transparent',
141
+ }}
142
+ />
143
+ </div>
144
+ )
145
+ }
146
+
147
+ StickyLayout.defaultProps = {
148
+ // sticky: {
149
+ // offsetHeight: 0,
150
+ // },
151
+ sticky: false
152
+ }
153
+
154
+ return StickyLayout
155
+ }
156
+
157
+ export default stickyLayout
package/src/index.js CHANGED
@@ -103,6 +103,7 @@ import Selection from './component/selection'
103
103
  import TreeV2 from './component/tree_v2'
104
104
  import RecommendInput from './component/recommend_input'
105
105
  import PicturePreview from './component/picture_preview'
106
+ import StickyLayout from './hoc/sticky_layout'
106
107
 
107
108
  Object.assign(Sheet, {
108
109
  SheetColumn,
@@ -233,5 +234,6 @@ export {
233
234
  Selection,
234
235
  TreeV2,
235
236
  RecommendInput,
236
- PicturePreview
237
+ PicturePreview,
238
+ StickyLayout
237
239
  }
package/LICENSE.md DELETED
@@ -1,4 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 GMFE
4
-