@gm-mobile/mp 3.12.1 → 3.12.3

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": "@gm-mobile/mp",
3
- "version": "3.12.1",
3
+ "version": "3.12.3",
4
4
  "description": "",
5
5
  "author": "liyatang <liyatang@qq.com>",
6
6
  "homepage": "https://github.com/gmfe/gm-mobile#readme",
@@ -21,9 +21,9 @@
21
21
  "url": "https://github.com/gmfe/gm-mobile/issues"
22
22
  },
23
23
  "dependencies": {
24
- "@gm-mobile/c-react": "^3.12.1",
25
- "@gm-mobile/c-tool": "^3.12.1",
26
- "@gm-mobile/locales": "^3.12.1",
24
+ "@gm-mobile/c-react": "^3.12.3",
25
+ "@gm-mobile/c-tool": "^3.12.3",
26
+ "@gm-mobile/locales": "^3.12.3",
27
27
  "dayjs": "^1.11.6"
28
28
  },
29
29
  "peerDependencies": {
@@ -34,5 +34,5 @@
34
34
  "prop-types": "^15.7.2",
35
35
  "react": "^16.13.1"
36
36
  },
37
- "gitHead": "ca8b30b9c7a0826a6fc09bf88c82db0630b7d599"
37
+ "gitHead": "7ac852d577d0bae9ad16fb3438ad86146d23d991"
38
38
  }
@@ -2,26 +2,34 @@ import React, { memo, FC } from 'react'
2
2
  import { View } from '@tarojs/components'
3
3
  import classNames from 'classnames'
4
4
  import { ViewProps } from '@tarojs/components/types/View'
5
+ import _ from 'lodash'
5
6
 
6
7
  type SafeBottomMPProps = ViewProps
7
8
 
8
- const SafeBottomMP: FC<SafeBottomMPProps> = memo(
9
- ({ className, children, ...rest }) => {
9
+ const SafeBottomMP: FC<SafeBottomMPProps> = ({
10
+ className,
11
+ children,
12
+ ...rest
13
+ }) => {
14
+ const getPaddingBottom = () => {
10
15
  const { safeArea, screenHeight } = wx.getSystemInfoSync()
11
- const paddingBottom = screenHeight - safeArea.bottom
12
-
13
- return (
14
- <View className={classNames(className)} {...rest}>
15
- {React.cloneElement((children as React.ReactElement) || <View />, {
16
- style: {
17
- paddingBottom:
18
- paddingBottom > 0 ? `${paddingBottom}px!important` : undefined,
19
- },
20
- })}
21
- </View>
22
- )
16
+ const paddingBottom = 0 || Number(screenHeight || 0) - safeArea.bottom
17
+ /** 控制区间,禁止大于34 */
18
+ return _.clamp(paddingBottom, 0, 34)
23
19
  }
24
- )
20
+ return (
21
+ <View className={classNames(className)} {...rest}>
22
+ {React.cloneElement((children as React.ReactElement) || <View />, {
23
+ style: {
24
+ paddingBottom:
25
+ getPaddingBottom() > 0
26
+ ? `${getPaddingBottom()}px!important`
27
+ : undefined,
28
+ },
29
+ })}
30
+ </View>
31
+ )
32
+ }
25
33
 
26
34
  export default SafeBottomMP
27
35
  export type { SafeBottomMPProps }