@gm-mobile/c-react 3.9.3-beta.3 → 3.9.3-beta.33
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 +5 -5
- package/src/component/button/button.tsx +3 -1
- package/src/component/calendar/index.ts +1 -0
- package/src/component/cell/cell.tsx +29 -27
- package/src/component/cell/style.less +8 -5
- package/src/component/custom_tabbar/custom_tabbar.weapp.tsx +6 -1
- package/src/component/dialog/common/base.less +3 -0
- package/src/component/dialog/common/base.tsx +8 -4
- package/src/component/dialog/common/choose.tsx +3 -0
- package/src/component/dialog/dialog.tsx +10 -2
- package/src/component/dialog/style.less +1 -1
- package/src/component/dialog/types.ts +11 -10
- package/src/component/digital_keyboard/Base.tsx +28 -21
- package/src/component/digital_keyboard/Btn.ts +3 -3
- package/src/component/digital_keyboard/base.less +36 -5
- package/src/component/digital_keyboard/index.tsx +30 -14
- package/src/component/digital_keyboard/stories.tsx +35 -41
- package/src/component/draggable/draggable.tsx +1 -0
- package/src/component/error/error.tsx +23 -0
- package/src/component/error/index.ts +1 -0
- package/src/component/error/style.less +42 -0
- package/src/component/error/types.ts +5 -0
- package/src/component/layout_root/layout_root.tsx +20 -4
- package/src/component/layout_root/layout_root_v1.tsx +18 -3
- package/src/component/page/style.less +8 -0
- package/src/component/popup/popup.tsx +4 -1
- package/src/component/popup/popup_v1.tsx +2 -1
- package/src/component/popup/style.less +1 -1
- package/src/component/popup/types.ts +4 -0
- package/src/component/text_field/TextField.tsx +25 -3
- package/src/component/text_field/stories.tsx +0 -1
- package/src/component/text_field/style.less +3 -0
- package/src/component/text_field/types.ts +3 -1
- package/src/component/v_list/v_list.tsx +1 -1
- package/src/index.less +4 -3
- package/src/index.ts +1 -0
- package/src/less/animation.less +9 -4
- package/src/less/bg.less +7 -0
- package/src/less/border.less +12 -3
- package/src/less/{btn.less → button.less} +3 -1
- package/src/less/distance.less +41 -45
- package/src/less/text.less +26 -24
- package/src/less/variable.less +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-mobile/c-react",
|
|
3
|
-
"version": "3.9.3-beta.
|
|
3
|
+
"version": "3.9.3-beta.33",
|
|
4
4
|
"description": "> TODO: 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-font": "^3.9.3-beta.
|
|
25
|
-
"@gm-mobile/c-tool": "^3.9.3-beta.
|
|
26
|
-
"@gm-mobile/locales": "^3.9.3-beta.
|
|
24
|
+
"@gm-mobile/c-font": "^3.9.3-beta.33",
|
|
25
|
+
"@gm-mobile/c-tool": "^3.9.3-beta.33",
|
|
26
|
+
"@gm-mobile/locales": "^3.9.3-beta.33"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@tarojs/components": "3.0.18",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"prop-types": "^15.7.2",
|
|
34
34
|
"react": "^16.13.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "038d343fd258aaa0c64146a958e6ed17baf3212d"
|
|
37
37
|
}
|
|
@@ -73,7 +73,9 @@ export const Button: FC<ButtonProps> = ({
|
|
|
73
73
|
onClick={handleClick}
|
|
74
74
|
>
|
|
75
75
|
{loadFlag && <Loading className='m-btn-loading' />}
|
|
76
|
-
<Flex alignCenter
|
|
76
|
+
<Flex alignCenter justifyCenter style={{ display: 'inline-flex' }}>
|
|
77
|
+
{children}
|
|
78
|
+
</Flex>
|
|
77
79
|
</BaseButton>
|
|
78
80
|
)
|
|
79
81
|
}
|
|
@@ -19,35 +19,37 @@ export const Cell: FC<CellProps> = ({
|
|
|
19
19
|
...rest
|
|
20
20
|
}) => {
|
|
21
21
|
return (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
onClick={onClick}
|
|
35
|
-
>
|
|
36
|
-
{icon && <View className='m-cell-icon'>{icon}</View>}
|
|
37
|
-
{left && <View className='m-cell-left'>{left}</View>}
|
|
38
|
-
<View className='m-cell-body'>{children}</View>
|
|
39
|
-
<Flex alignCenter>
|
|
40
|
-
{right &&
|
|
41
|
-
(_.isString(right) ? (
|
|
42
|
-
<View className='m-cell-right'>{right}</View>
|
|
43
|
-
) : (
|
|
44
|
-
right
|
|
45
|
-
))}
|
|
46
|
-
{access && (
|
|
47
|
-
<Text className='m-font m-font-angle-right m-cell-access-icon' />
|
|
22
|
+
<>
|
|
23
|
+
<Flex
|
|
24
|
+
{...rest}
|
|
25
|
+
alignCenter
|
|
26
|
+
className={classNames(
|
|
27
|
+
'm-cell',
|
|
28
|
+
{
|
|
29
|
+
'm-cell-access': access,
|
|
30
|
+
'm-cell-with-icon': icon,
|
|
31
|
+
'm-cell-no-active': noActive,
|
|
32
|
+
},
|
|
33
|
+
className
|
|
48
34
|
)}
|
|
35
|
+
onClick={onClick}
|
|
36
|
+
>
|
|
37
|
+
{icon && <View className='m-cell-icon'>{icon}</View>}
|
|
38
|
+
{left && <View className='m-cell-left'>{left}</View>}
|
|
39
|
+
<View className='m-cell-body'>{children}</View>
|
|
40
|
+
<Flex alignCenter>
|
|
41
|
+
{right &&
|
|
42
|
+
(_.isString(right) ? (
|
|
43
|
+
<View className='m-cell-right'>{right}</View>
|
|
44
|
+
) : (
|
|
45
|
+
right
|
|
46
|
+
))}
|
|
47
|
+
{access && (
|
|
48
|
+
<Text className='m-font m-font-angle-right m-cell-access-icon' />
|
|
49
|
+
)}
|
|
50
|
+
</Flex>
|
|
49
51
|
</Flex>
|
|
50
|
-
|
|
52
|
+
</>
|
|
51
53
|
)
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
background: var(--m-color-bg-white);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
.mCellBorderBottomAfter(15px, 0);
|
|
34
33
|
|
|
35
34
|
&.m-cell-access {
|
|
36
35
|
cursor: pointer;
|
|
@@ -41,10 +40,6 @@
|
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
&.m-cell-with-icon {
|
|
45
|
-
.mCellBorderBottomAfter(50px, 0);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
43
|
.m-cell-icon {
|
|
49
44
|
width: 35px;
|
|
50
45
|
}
|
|
@@ -105,4 +100,12 @@
|
|
|
105
100
|
.m-cell:not(.m-cell-form):last-child::after {
|
|
106
101
|
display: none;
|
|
107
102
|
}
|
|
103
|
+
|
|
104
|
+
.m-cell {
|
|
105
|
+
.mCellBorderBottomAfter(15px, 0);
|
|
106
|
+
|
|
107
|
+
&.m-cell-with-icon {
|
|
108
|
+
.mCellBorderBottomAfter(50px, 0);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
108
111
|
}
|
|
@@ -24,7 +24,12 @@ const CustomTabbar = () => {
|
|
|
24
24
|
return null
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
return
|
|
27
|
+
return (
|
|
28
|
+
<View
|
|
29
|
+
className='custom-tabbar-placeholder'
|
|
30
|
+
style={{ height: `${height}px` }}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
CustomTabbar.getCustomTabbarHeight = getCustomTabbarHeight
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react'
|
|
2
2
|
import { Flex, Popup, View, Button } from '../../..'
|
|
3
3
|
import { noop } from 'lodash'
|
|
4
|
+
import './base.less'
|
|
4
5
|
|
|
5
6
|
interface Option<T> {
|
|
6
7
|
title: ReactNode
|
|
@@ -54,7 +55,11 @@ export function showDialog<T>({
|
|
|
54
55
|
const Template = () => {
|
|
55
56
|
return (
|
|
56
57
|
<Flex column className='m-border-radius m-overflow-hidden m-bg-white'>
|
|
57
|
-
<Flex
|
|
58
|
+
<Flex
|
|
59
|
+
justifyBetween
|
|
60
|
+
alignCenter
|
|
61
|
+
className='m-customer-dialog-header m-padding-10'
|
|
62
|
+
>
|
|
58
63
|
<Flex flex>{left}</Flex>
|
|
59
64
|
<Flex
|
|
60
65
|
flex
|
|
@@ -68,7 +73,6 @@ export function showDialog<T>({
|
|
|
68
73
|
<Button
|
|
69
74
|
mini
|
|
70
75
|
plain
|
|
71
|
-
noRound
|
|
72
76
|
type='link'
|
|
73
77
|
className='m-text-desc m-margin-lr-0'
|
|
74
78
|
onClick={cancel}
|
|
@@ -81,7 +85,7 @@ export function showDialog<T>({
|
|
|
81
85
|
{children}
|
|
82
86
|
{bottom || (
|
|
83
87
|
<Flex className='m-padding-lr-10'>
|
|
84
|
-
<Button block
|
|
88
|
+
<Button block type='primary' onClick={() => ok()}>
|
|
85
89
|
{okText}
|
|
86
90
|
</Button>
|
|
87
91
|
</Flex>
|
|
@@ -94,7 +98,7 @@ export function showDialog<T>({
|
|
|
94
98
|
disabledHeader: true,
|
|
95
99
|
[direction]: true,
|
|
96
100
|
disabledAnimate: false,
|
|
97
|
-
onHide:
|
|
101
|
+
onHide: cancel,
|
|
98
102
|
children: <Template />,
|
|
99
103
|
})
|
|
100
104
|
})
|
|
@@ -24,6 +24,7 @@ export interface ChooseProps {
|
|
|
24
24
|
/** 搜索功能 */
|
|
25
25
|
// search?: boolean
|
|
26
26
|
maxHeight?: string
|
|
27
|
+
onCancel?: () => void
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
/** 底部弹出的选择界面 */
|
|
@@ -34,6 +35,7 @@ export default function ({
|
|
|
34
35
|
multiSelect = false,
|
|
35
36
|
defaultSelected = [],
|
|
36
37
|
maxHeight = '50vh',
|
|
38
|
+
onCancel,
|
|
37
39
|
}: ChooseProps) {
|
|
38
40
|
if (multiSelect) needConfirm = true
|
|
39
41
|
const selected = [...defaultSelected] as Item[]
|
|
@@ -93,6 +95,7 @@ export default function ({
|
|
|
93
95
|
title,
|
|
94
96
|
children: <Children />,
|
|
95
97
|
onOk: () => selected,
|
|
98
|
+
onCancel: onCancel,
|
|
96
99
|
bottom: needConfirm ? undefined : <View />,
|
|
97
100
|
})
|
|
98
101
|
return promise
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
DialogStaticsTypes,
|
|
13
13
|
RenderOptions,
|
|
14
14
|
} from './types'
|
|
15
|
+
import classNames from 'classnames'
|
|
15
16
|
|
|
16
17
|
const ErrorInput: FC<ErrorInputProps> = ({
|
|
17
18
|
getError,
|
|
@@ -44,6 +45,11 @@ const ErrorInput: FC<ErrorInputProps> = ({
|
|
|
44
45
|
|
|
45
46
|
const DialogStatics: DialogStaticsTypes<string | RenderOptions> = {
|
|
46
47
|
render(options, type) {
|
|
48
|
+
const autoHide = !(
|
|
49
|
+
typeof options === 'object' &&
|
|
50
|
+
options.onConfirm &&
|
|
51
|
+
typeof options.children === 'object'
|
|
52
|
+
)
|
|
47
53
|
if (typeof options === 'string') {
|
|
48
54
|
options = {
|
|
49
55
|
children: options as string,
|
|
@@ -92,7 +98,7 @@ const DialogStatics: DialogStaticsTypes<string | RenderOptions> = {
|
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
Promise.resolve(result).then(() => {
|
|
95
|
-
DialogStatics.hide()
|
|
101
|
+
if (autoHide) DialogStatics.hide()
|
|
96
102
|
|
|
97
103
|
return setTimeout(() => {
|
|
98
104
|
resolve(type === 'prompt' ? inputValue : undefined)
|
|
@@ -165,9 +171,11 @@ const DialogBase: FC<DialogBaseProps> = ({
|
|
|
165
171
|
onOther,
|
|
166
172
|
hideBottom,
|
|
167
173
|
children,
|
|
174
|
+
className,
|
|
175
|
+
...rest
|
|
168
176
|
}) => {
|
|
169
177
|
return (
|
|
170
|
-
<View className='m-dialog-container'>
|
|
178
|
+
<View className={classNames('m-dialog-container', className)} {...rest}>
|
|
171
179
|
<Mask
|
|
172
180
|
onClick={() => {
|
|
173
181
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { InputHTMLAttributes } from 'react'
|
|
1
|
+
import React, { HTMLAttributes, InputHTMLAttributes } from 'react'
|
|
2
2
|
import { InputProps as TaroInputProps } from '@tarojs/components/types/Input'
|
|
3
3
|
import { CommonEventFunction } from '@tarojs/components'
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ interface ErrorInputProps extends InputProps {
|
|
|
7
7
|
defaultValue?: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
interface DialogBaseProps {
|
|
10
|
+
interface DialogBaseProps extends HTMLAttributes<HTMLDivElement> {
|
|
11
11
|
onConfirm?: (value?: string) => Promise<void>
|
|
12
12
|
title?: string
|
|
13
13
|
confirmText?: string
|
|
@@ -23,22 +23,23 @@ interface DialogBaseProps {
|
|
|
23
23
|
promptGetError?: (value: string) => string | void
|
|
24
24
|
hideBottom?: boolean
|
|
25
25
|
}
|
|
26
|
-
interface RenderOptions extends PromptOptions {
|
|
27
|
-
children?: string | React.ReactNode
|
|
28
|
-
confirmText?: React.ReactNode
|
|
29
|
-
onCancel?: () => void
|
|
30
|
-
otherText?: string
|
|
31
|
-
onOther?: () => void
|
|
32
|
-
hideBottom?: boolean
|
|
33
|
-
}
|
|
34
26
|
|
|
35
27
|
interface PromptOptions {
|
|
28
|
+
title?: string
|
|
36
29
|
promptGetError?: (value: string) => string | void
|
|
37
30
|
promptText?: string
|
|
38
31
|
promptInputProps?: ErrorInputProps
|
|
39
32
|
onConfirm?: (value: string) => void | boolean
|
|
40
33
|
}
|
|
41
34
|
|
|
35
|
+
interface RenderOptions extends PromptOptions, HTMLAttributes<HTMLDivElement> {
|
|
36
|
+
children?: string | React.ReactNode
|
|
37
|
+
confirmText?: React.ReactNode
|
|
38
|
+
onCancel?: () => void
|
|
39
|
+
otherText?: string
|
|
40
|
+
onOther?: () => void
|
|
41
|
+
hideBottom?: boolean
|
|
42
|
+
}
|
|
42
43
|
interface DialogStaticsTypes<T> {
|
|
43
44
|
render: (options: T, type?: string) => Promise<void | string>
|
|
44
45
|
alert: (options: string | RenderOptions) => Promise<void | string>
|
|
@@ -2,7 +2,7 @@ import React, { FC, HTMLAttributes } from 'react'
|
|
|
2
2
|
// import { Flex, Popup, View } from '@gm-mobile/mp'
|
|
3
3
|
import _ from 'lodash'
|
|
4
4
|
import classNames from 'classnames'
|
|
5
|
-
import
|
|
5
|
+
import DKBtn from './Btn'
|
|
6
6
|
import './base.less'
|
|
7
7
|
import './font/iconfont.css'
|
|
8
8
|
import { View } from '../view'
|
|
@@ -11,11 +11,10 @@ import { Flex } from '../flex'
|
|
|
11
11
|
|
|
12
12
|
/** 数字按钮 */
|
|
13
13
|
export const defaultDigitalKeys = [
|
|
14
|
-
...['
|
|
15
|
-
...['4', '5', '6'].map((v, _) => new
|
|
16
|
-
...['
|
|
17
|
-
new
|
|
18
|
-
new Btn({
|
|
14
|
+
...['1', '2', '3'].map((v, _) => new DKBtn({ label: v })),
|
|
15
|
+
...['4', '5', '6'].map((v, _) => new DKBtn({ label: v })),
|
|
16
|
+
...['7', '8', '9'].map((v, _) => new DKBtn({ label: v })),
|
|
17
|
+
new DKBtn({
|
|
19
18
|
label: '.',
|
|
20
19
|
fn: (value = '') => {
|
|
21
20
|
if (value === '') {
|
|
@@ -28,20 +27,15 @@ export const defaultDigitalKeys = [
|
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
29
|
}),
|
|
31
|
-
new
|
|
32
|
-
|
|
33
|
-
fn: (value) => {
|
|
34
|
-
if (value.length === 0) return value
|
|
35
|
-
return value.slice(0, value.length - 1)
|
|
36
|
-
},
|
|
37
|
-
}),
|
|
30
|
+
new DKBtn({ label: '0' }),
|
|
31
|
+
new DKBtn({ label: '清零', className: 'btn-clear', fn: (_) => '' }),
|
|
38
32
|
]
|
|
39
33
|
|
|
40
34
|
/** 右侧功能按钮 */
|
|
41
35
|
export const defaultActionKeys = [
|
|
42
|
-
new
|
|
43
|
-
new
|
|
44
|
-
new
|
|
36
|
+
new DKBtn({ label: '取消', fn: (_) => '' }),
|
|
37
|
+
new DKBtn({ label: '完成', className: 'm-bg-primary' }),
|
|
38
|
+
new DKBtn({
|
|
45
39
|
label: '大按钮',
|
|
46
40
|
flex: 2,
|
|
47
41
|
className: 'm-bg-primary',
|
|
@@ -57,9 +51,9 @@ export interface KeyboardProps
|
|
|
57
51
|
/** 输入框当前值 */
|
|
58
52
|
value: string
|
|
59
53
|
/** 虚拟键盘的点击事件 */
|
|
60
|
-
onInput?: (value: string | undefined, key:
|
|
54
|
+
onInput?: (value: string | undefined, key: DKBtn) => void
|
|
61
55
|
/** 虚拟键盘的功能键(actionKeys)点击事件 */
|
|
62
|
-
onAction?: (key:
|
|
56
|
+
onAction?: (key: DKBtn) => void
|
|
63
57
|
/** 自定义功能键盘 */
|
|
64
58
|
actionKeys?: typeof defaultActionKeys
|
|
65
59
|
/** 自定义数字键盘 */
|
|
@@ -81,7 +75,7 @@ export const Keyboard: FC<KeyboardProps> = ({
|
|
|
81
75
|
int,
|
|
82
76
|
...rest
|
|
83
77
|
}) => {
|
|
84
|
-
const handleInput = (btn:
|
|
78
|
+
const handleInput = (btn: DKBtn) => {
|
|
85
79
|
if (!btn.fn) {
|
|
86
80
|
onInput && onInput(undefined, btn)
|
|
87
81
|
return
|
|
@@ -121,7 +115,7 @@ export const Keyboard: FC<KeyboardProps> = ({
|
|
|
121
115
|
>
|
|
122
116
|
<View
|
|
123
117
|
className={classNames(
|
|
124
|
-
'keyboard-button digital m-text-
|
|
118
|
+
'keyboard-button digital m-text-22',
|
|
125
119
|
btn.className
|
|
126
120
|
)}
|
|
127
121
|
onClick={() => handleInput(btn)}
|
|
@@ -150,7 +144,20 @@ export const Keyboard: FC<KeyboardProps> = ({
|
|
|
150
144
|
)}
|
|
151
145
|
onClick={() => handleInput(btn)}
|
|
152
146
|
>
|
|
153
|
-
{btn.label
|
|
147
|
+
{btn.label ? (
|
|
148
|
+
btn.label
|
|
149
|
+
) : (
|
|
150
|
+
<Flex alignCenter justifyCenter className='bt-delete'>
|
|
151
|
+
<View className='triangle' />
|
|
152
|
+
<Flex
|
|
153
|
+
alignCenter
|
|
154
|
+
justifyCenter
|
|
155
|
+
className='m-text-14 m-text-white square'
|
|
156
|
+
>
|
|
157
|
+
x
|
|
158
|
+
</Flex>
|
|
159
|
+
</Flex>
|
|
160
|
+
)}
|
|
154
161
|
</View>
|
|
155
162
|
</Flex>
|
|
156
163
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class DKBtn {
|
|
2
2
|
/** 按钮文本 */
|
|
3
3
|
label?: string
|
|
4
4
|
/** 按钮占位,默认1个位置 */
|
|
@@ -8,7 +8,7 @@ export class Btn {
|
|
|
8
8
|
/** 按钮功能,传入value为输入框当前值,返回一个按钮功能处理后的值 */
|
|
9
9
|
fn?: (value: string) => string
|
|
10
10
|
type?: 'digit' | 'action'
|
|
11
|
-
constructor({ label = '', flex = 0, className = '', fn }:
|
|
11
|
+
constructor({ label = '', flex = 0, className = '', fn }: DKBtn) {
|
|
12
12
|
this.type = /([0-9.])/.test(label) ? 'digit' : 'action'
|
|
13
13
|
if (!fn && this.type === 'digit') {
|
|
14
14
|
fn = (value = '') => value + label
|
|
@@ -17,4 +17,4 @@ export class Btn {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export default
|
|
20
|
+
export default DKBtn
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.keyboard {
|
|
2
|
-
@background: darken(white,
|
|
2
|
+
@background: darken(white, 8);
|
|
3
3
|
@btn: white;
|
|
4
4
|
@text: black;
|
|
5
5
|
background-color: @background;
|
|
@@ -13,17 +13,18 @@
|
|
|
13
13
|
top: 0;
|
|
14
14
|
}
|
|
15
15
|
.keyboard-item {
|
|
16
|
-
padding:
|
|
17
|
-
height:
|
|
16
|
+
padding: 3.5px;
|
|
17
|
+
height: 44px;
|
|
18
18
|
.keyboard-button {
|
|
19
19
|
display: flex;
|
|
20
|
+
font-family: DINPro-Medium, DINPro;
|
|
20
21
|
justify-content: center;
|
|
21
22
|
align-items: center;
|
|
22
23
|
width: 100%;
|
|
23
24
|
height: 100%;
|
|
24
25
|
color: @text;
|
|
25
|
-
|
|
26
|
-
border-radius:
|
|
26
|
+
font-weight: bold;
|
|
27
|
+
border-radius: 4px;
|
|
27
28
|
background-color: @btn;
|
|
28
29
|
overflow: hidden;
|
|
29
30
|
cursor: pointer;
|
|
@@ -45,5 +46,35 @@
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
}
|
|
49
|
+
|
|
50
|
+
.btn-ok {
|
|
51
|
+
background-color: #06C160;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.btn-clear {
|
|
55
|
+
font-size: 15px !important;
|
|
56
|
+
font-weight: 500;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.bt-delete {
|
|
60
|
+
padding-right: 10px;
|
|
61
|
+
.square {
|
|
62
|
+
width: 18px;
|
|
63
|
+
height: 18px;
|
|
64
|
+
background: #000000;
|
|
65
|
+
border-bottom-right-radius: 2px;
|
|
66
|
+
border-top-right-radius: 2px;
|
|
67
|
+
border-top-left-radius: 3px;
|
|
68
|
+
border-bottom-left-radius: 3px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.triangle {
|
|
72
|
+
width: 0;
|
|
73
|
+
height: 0;
|
|
74
|
+
border: 9px solid;
|
|
75
|
+
border-color: transparent #000000 transparent transparent;
|
|
76
|
+
margin-right: -2px;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
48
79
|
}
|
|
49
80
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { ReactNode, useEffect, useState } from 'react'
|
|
1
|
+
import React, { ReactNode, useEffect, useRef, useState } from 'react'
|
|
2
2
|
import { makeObservable } from 'mobx'
|
|
3
3
|
import { Keyboard, KeyboardProps } from './Base'
|
|
4
4
|
import { observer } from 'mobx-react'
|
|
5
5
|
import { clamp } from 'lodash'
|
|
6
6
|
import { View } from '../view'
|
|
7
|
-
import
|
|
7
|
+
import { DKBtn } from './Btn'
|
|
8
8
|
import { Popup } from '../popup'
|
|
9
9
|
|
|
10
10
|
/** 是否小程序端 */
|
|
@@ -30,6 +30,7 @@ export type DigitalKeyboardProps = Omit<KeyboardProps, 'value' | 'int'> & {
|
|
|
30
30
|
min?: number
|
|
31
31
|
/** 最大值 */
|
|
32
32
|
max?: number
|
|
33
|
+
withUseRef?: boolean
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export class DigitalKeyboard {
|
|
@@ -45,11 +46,12 @@ export class DigitalKeyboard {
|
|
|
45
46
|
min,
|
|
46
47
|
max,
|
|
47
48
|
style,
|
|
49
|
+
withUseRef = true,
|
|
48
50
|
...rest
|
|
49
51
|
}: DigitalKeyboardProps) {
|
|
50
52
|
this.form = form
|
|
51
53
|
this.active = active || Object.keys(form)[0]
|
|
52
|
-
const
|
|
54
|
+
const Node = observer(() => {
|
|
53
55
|
const sys = mp && wx.getSystemInfoSync()
|
|
54
56
|
const safeMargin =
|
|
55
57
|
withSafeArea && mp ? sys.screenHeight - sys.safeArea.bottom : 5
|
|
@@ -100,7 +102,12 @@ export class DigitalKeyboard {
|
|
|
100
102
|
|
|
101
103
|
if (btn.type === 'digit' && value && !value.endsWith('.')) {
|
|
102
104
|
const num = parseFloat(value)
|
|
103
|
-
if (
|
|
105
|
+
if (value.endsWith('.0')) {
|
|
106
|
+
// 处理特殊情况
|
|
107
|
+
if (fractionDigits === 0) {
|
|
108
|
+
value = value.replace(/\.0$/, '')
|
|
109
|
+
}
|
|
110
|
+
} else if (!isNaN(num as number)) {
|
|
104
111
|
value = clamp(
|
|
105
112
|
num,
|
|
106
113
|
min === undefined ? num : min,
|
|
@@ -125,7 +132,7 @@ export class DigitalKeyboard {
|
|
|
125
132
|
</View>
|
|
126
133
|
)
|
|
127
134
|
})
|
|
128
|
-
this.
|
|
135
|
+
this.node = <Node />
|
|
129
136
|
makeObservable(this, {
|
|
130
137
|
form: true,
|
|
131
138
|
active: true,
|
|
@@ -135,6 +142,8 @@ export class DigitalKeyboard {
|
|
|
135
142
|
int: true,
|
|
136
143
|
setInt: true,
|
|
137
144
|
})
|
|
145
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
146
|
+
return withUseRef ? useRef(this).current : this
|
|
138
147
|
}
|
|
139
148
|
|
|
140
149
|
active: string
|
|
@@ -144,7 +153,7 @@ export class DigitalKeyboard {
|
|
|
144
153
|
}
|
|
145
154
|
|
|
146
155
|
/** 键盘组件 */
|
|
147
|
-
readonly
|
|
156
|
+
readonly node: ReactNode
|
|
148
157
|
/** 整数型键盘 */
|
|
149
158
|
int = false
|
|
150
159
|
/** 设置为整数型键盘 */
|
|
@@ -156,19 +165,26 @@ export class DigitalKeyboard {
|
|
|
156
165
|
/** 自定义功能按钮 */
|
|
157
166
|
get actionKeys() {
|
|
158
167
|
return [
|
|
159
|
-
new
|
|
160
|
-
|
|
168
|
+
new DKBtn({
|
|
169
|
+
label: '',
|
|
170
|
+
// className: 'iconfont icon-backspace m-text-26',
|
|
171
|
+
fn: (value) => {
|
|
172
|
+
if (value.length === 0) return value
|
|
173
|
+
return value.slice(0, value.length - 1)
|
|
174
|
+
},
|
|
175
|
+
}),
|
|
176
|
+
new DKBtn({
|
|
161
177
|
label: '下一个',
|
|
162
|
-
className: 'm-
|
|
178
|
+
className: 'm-text-black btn-clear',
|
|
163
179
|
fn: (value) => {
|
|
164
180
|
this.next()
|
|
165
181
|
return this.form[this.active]
|
|
166
182
|
},
|
|
167
183
|
}),
|
|
168
|
-
new
|
|
169
|
-
label: '
|
|
184
|
+
new DKBtn({
|
|
185
|
+
label: '确定',
|
|
170
186
|
flex: 2,
|
|
171
|
-
className: '
|
|
187
|
+
className: 'btn-ok m-text-white',
|
|
172
188
|
fn: (value) => {
|
|
173
189
|
return this.form[this.active]
|
|
174
190
|
},
|
|
@@ -211,7 +227,7 @@ export class DigitalKeyboard {
|
|
|
211
227
|
disabledHeader: true,
|
|
212
228
|
disabledAnimate: false,
|
|
213
229
|
bottom: true,
|
|
214
|
-
children: this.
|
|
230
|
+
children: this.node,
|
|
215
231
|
})
|
|
216
232
|
mp && wx.hideKeyboard()
|
|
217
233
|
}
|
|
@@ -222,4 +238,4 @@ export class DigitalKeyboard {
|
|
|
222
238
|
}
|
|
223
239
|
export default DigitalKeyboard
|
|
224
240
|
|
|
225
|
-
export {
|
|
241
|
+
export { DKBtn } from './Btn'
|