@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
|
@@ -3,7 +3,7 @@ import { Story } from '@storybook/react'
|
|
|
3
3
|
import { TextField } from '../text_field'
|
|
4
4
|
import { DigitalKeyboard, DigitalKeyboardProps } from '.'
|
|
5
5
|
import { Text } from '../text'
|
|
6
|
-
import {
|
|
6
|
+
import { DKBtn } from './Btn'
|
|
7
7
|
import { View } from '../view'
|
|
8
8
|
import { Toast } from '../toast'
|
|
9
9
|
import { Page } from '../page'
|
|
@@ -19,19 +19,17 @@ const Template: Story<DigitalKeyboardProps> = (args) => {
|
|
|
19
19
|
apple: '1.00',
|
|
20
20
|
peach: '0.50',
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
)
|
|
22
|
+
const keyboard = new DigitalKeyboard({
|
|
23
|
+
...args,
|
|
24
|
+
form: form,
|
|
25
|
+
active: '',
|
|
26
|
+
async onAction(btn) {
|
|
27
|
+
if (btn.label === '确认') {
|
|
28
|
+
console.log('result:', 'apple', keyboard.get('apple'))
|
|
29
|
+
keyboard.hide()
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
})
|
|
35
33
|
|
|
36
34
|
return (
|
|
37
35
|
<View style={{ height: '300px' }}>
|
|
@@ -60,7 +58,7 @@ const Template: Story<DigitalKeyboardProps> = (args) => {
|
|
|
60
58
|
export const Usage = Template.bind({})
|
|
61
59
|
Usage.argTypes = {
|
|
62
60
|
form: {
|
|
63
|
-
description: '`Object`
|
|
61
|
+
description: '`Object` 表单的字段键值对,可以通过.set增改,通过.get读取',
|
|
64
62
|
type: {
|
|
65
63
|
required: true,
|
|
66
64
|
},
|
|
@@ -122,13 +120,13 @@ Usage.argTypes = {
|
|
|
122
120
|
},
|
|
123
121
|
onInput: {
|
|
124
122
|
description:
|
|
125
|
-
'`(value: string | undefined, key:
|
|
123
|
+
'`(value: string | undefined, key: DKBtn) => void` 虚拟键盘的点击事件',
|
|
126
124
|
control: false,
|
|
127
125
|
type: {},
|
|
128
126
|
},
|
|
129
127
|
onAction: {
|
|
130
128
|
description:
|
|
131
|
-
'`(value: string | undefined, key:
|
|
129
|
+
'`(value: string | undefined, key: DKBtn) => void` 虚拟键盘的功能键(actionKeys)点击事件',
|
|
132
130
|
control: false,
|
|
133
131
|
type: {},
|
|
134
132
|
},
|
|
@@ -154,7 +152,7 @@ Usage.argTypes = {
|
|
|
154
152
|
name: 'function',
|
|
155
153
|
},
|
|
156
154
|
},
|
|
157
|
-
'.
|
|
155
|
+
'.node': {
|
|
158
156
|
description: '`ReactComponent` 键盘组件节点',
|
|
159
157
|
type: {
|
|
160
158
|
name: 'function',
|
|
@@ -210,12 +208,10 @@ export const CustomLayout = () => {
|
|
|
210
208
|
apple: '1.00',
|
|
211
209
|
peach: '0.50',
|
|
212
210
|
}
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
})
|
|
218
|
-
)
|
|
211
|
+
const keyboard = new DigitalKeyboard({
|
|
212
|
+
form: form,
|
|
213
|
+
active: '',
|
|
214
|
+
})
|
|
219
215
|
|
|
220
216
|
return (
|
|
221
217
|
<Page style={{ width: '100%' }}>
|
|
@@ -228,7 +224,7 @@ export const CustomLayout = () => {
|
|
|
228
224
|
头部
|
|
229
225
|
</Flex>
|
|
230
226
|
<View>显示在指定位置</View>
|
|
231
|
-
<View>{keyboard.
|
|
227
|
+
<View>{keyboard.node}</View>
|
|
232
228
|
<Flex
|
|
233
229
|
height='100px'
|
|
234
230
|
className='m-bg-accent m-margin-tb-10'
|
|
@@ -246,7 +242,7 @@ export const CustomActions = () => {
|
|
|
246
242
|
class Keyboard extends DigitalKeyboard {
|
|
247
243
|
get actionKeys() {
|
|
248
244
|
return [
|
|
249
|
-
new
|
|
245
|
+
new DKBtn({
|
|
250
246
|
className: 'm-bg-accent m-text-white',
|
|
251
247
|
label: '自定义',
|
|
252
248
|
fn: (value) => {
|
|
@@ -254,7 +250,7 @@ export const CustomActions = () => {
|
|
|
254
250
|
return '一键输入自定义内容'
|
|
255
251
|
},
|
|
256
252
|
}),
|
|
257
|
-
new
|
|
253
|
+
new DKBtn({
|
|
258
254
|
label: '确认',
|
|
259
255
|
flex: 3,
|
|
260
256
|
className: 'm-bg-primary m-text-white',
|
|
@@ -267,20 +263,18 @@ export const CustomActions = () => {
|
|
|
267
263
|
}
|
|
268
264
|
}
|
|
269
265
|
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
})
|
|
283
|
-
)
|
|
266
|
+
const keyboard = new Keyboard({
|
|
267
|
+
rewriteMode: true,
|
|
268
|
+
fractionDigits: 2,
|
|
269
|
+
min: 0,
|
|
270
|
+
max: 9999.99,
|
|
271
|
+
// 也可以通过这里自定义keys
|
|
272
|
+
// digitalKeys: [],
|
|
273
|
+
// actionKeys: [],
|
|
274
|
+
form: {
|
|
275
|
+
input: '',
|
|
276
|
+
},
|
|
277
|
+
})
|
|
284
278
|
return (
|
|
285
279
|
<View style={{ height: '300px' }}>
|
|
286
280
|
<TextField
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { FC } from 'react'
|
|
2
|
+
import classNames from 'classnames'
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
import { View } from '../view'
|
|
5
|
+
import { ErrorProps } from './types'
|
|
6
|
+
import { Text } from '../text'
|
|
7
|
+
|
|
8
|
+
export const Error: FC<ErrorProps> = ({ className, topLine, children }) => {
|
|
9
|
+
return children ? (
|
|
10
|
+
<View
|
|
11
|
+
className={classNames('error', className, {
|
|
12
|
+
'm-border-1px-top-before': topLine,
|
|
13
|
+
'has-error': !!children,
|
|
14
|
+
})}
|
|
15
|
+
>
|
|
16
|
+
<View className='error-message'>{children}</View>
|
|
17
|
+
</View>
|
|
18
|
+
) : (
|
|
19
|
+
<></>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default Error
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Error } from './error'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.error {
|
|
2
|
+
@red: fade(red, 50);
|
|
3
|
+
color: @red;
|
|
4
|
+
font-size: 10px;
|
|
5
|
+
width: 100%;
|
|
6
|
+
padding: 5px 0;
|
|
7
|
+
&.m-border-1px-top-before::before {
|
|
8
|
+
border-color: @red;
|
|
9
|
+
}
|
|
10
|
+
.error-message {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
animation-name: headShake;
|
|
13
|
+
animation-timing-function: ease;
|
|
14
|
+
animation-duration: 0.75s;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@keyframes headShake {
|
|
19
|
+
0% {
|
|
20
|
+
transform: translateX(0);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
6.5% {
|
|
24
|
+
transform: translateX(-6px) rotateY(-9deg);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
18.5% {
|
|
28
|
+
transform: translateX(5px) rotateY(7deg);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
31.5% {
|
|
32
|
+
transform: translateX(-3px) rotateY(-5deg);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
43.5% {
|
|
36
|
+
transform: translateX(2px) rotateY(3deg);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
50% {
|
|
40
|
+
transform: translateX(0);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
FC,
|
|
3
|
+
useState,
|
|
4
|
+
ReactNode,
|
|
5
|
+
useEffect,
|
|
6
|
+
HTMLAttributes,
|
|
7
|
+
} from 'react'
|
|
2
8
|
import _ from 'lodash'
|
|
3
9
|
import { is } from '@gm-mobile/c-tool'
|
|
4
10
|
|
|
@@ -13,7 +19,10 @@ import {
|
|
|
13
19
|
|
|
14
20
|
const cbMap: CBMapType = {}
|
|
15
21
|
|
|
16
|
-
const LayoutRoot: FC & LayoutRootStatic = (
|
|
22
|
+
const LayoutRoot: FC<HTMLAttributes<HTMLDivElement>> & LayoutRootStatic = ({
|
|
23
|
+
style,
|
|
24
|
+
...rest
|
|
25
|
+
}) => {
|
|
17
26
|
const [state, setState] = useState<LayoutRootState>({})
|
|
18
27
|
const path: string = getPath()
|
|
19
28
|
|
|
@@ -24,7 +33,6 @@ const LayoutRoot: FC & LayoutRootStatic = () => {
|
|
|
24
33
|
[type]: component,
|
|
25
34
|
}))
|
|
26
35
|
}
|
|
27
|
-
|
|
28
36
|
return () => {
|
|
29
37
|
delete cbMap[path]
|
|
30
38
|
}
|
|
@@ -32,7 +40,15 @@ const LayoutRoot: FC & LayoutRootStatic = () => {
|
|
|
32
40
|
|
|
33
41
|
// 有层级关系
|
|
34
42
|
return (
|
|
35
|
-
<View
|
|
43
|
+
<View
|
|
44
|
+
style={{
|
|
45
|
+
...style,
|
|
46
|
+
display: Object.keys(state).find((k) => !!state[k as 'popup'])
|
|
47
|
+
? 'block'
|
|
48
|
+
: 'none',
|
|
49
|
+
}}
|
|
50
|
+
{...rest}
|
|
51
|
+
>
|
|
36
52
|
{state.innerLayer}
|
|
37
53
|
{state.popup}
|
|
38
54
|
{state.picker}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
FC,
|
|
3
|
+
useState,
|
|
4
|
+
ReactNode,
|
|
5
|
+
useEffect,
|
|
6
|
+
HTMLAttributes,
|
|
7
|
+
} from 'react'
|
|
2
8
|
import _ from 'lodash'
|
|
3
9
|
import { is } from '@gm-mobile/c-tool'
|
|
4
10
|
|
|
@@ -16,7 +22,10 @@ const cbMap: CBMapV1Type = {}
|
|
|
16
22
|
/**
|
|
17
23
|
* @description: 目前仅用于Popup的多层弹窗
|
|
18
24
|
*/
|
|
19
|
-
const LayoutRootV1: FC & LayoutV1RootStatic = (
|
|
25
|
+
const LayoutRootV1: FC<HTMLAttributes<HTMLDivElement>> & LayoutV1RootStatic = ({
|
|
26
|
+
style,
|
|
27
|
+
...rest
|
|
28
|
+
}) => {
|
|
20
29
|
const path = getPath()
|
|
21
30
|
const [state, setState] = useState<LayoutRootState>({})
|
|
22
31
|
|
|
@@ -52,7 +61,13 @@ const LayoutRootV1: FC & LayoutV1RootStatic = () => {
|
|
|
52
61
|
|
|
53
62
|
// 有层级关系
|
|
54
63
|
return (
|
|
55
|
-
<View
|
|
64
|
+
<View
|
|
65
|
+
style={{
|
|
66
|
+
...style,
|
|
67
|
+
display: state.popup && state.popup.length > 0 ? 'block' : 'none',
|
|
68
|
+
}}
|
|
69
|
+
{...rest}
|
|
70
|
+
>
|
|
56
71
|
{/* {state.innerLayer} */}
|
|
57
72
|
{state.popup}
|
|
58
73
|
{/* {state.modal}
|
|
@@ -38,6 +38,8 @@ const PopupBase: FC<PopupProps> = ({
|
|
|
38
38
|
/** 动画有卡顿现象,先禁用 */
|
|
39
39
|
disabledAnimate = true,
|
|
40
40
|
children,
|
|
41
|
+
hasCustomTab = true,
|
|
42
|
+
disableBottomSafeArea,
|
|
41
43
|
...rest
|
|
42
44
|
}) => {
|
|
43
45
|
devWarnForHook(() => {
|
|
@@ -57,6 +59,7 @@ const PopupBase: FC<PopupProps> = ({
|
|
|
57
59
|
'm-animated-slide-in-left': left,
|
|
58
60
|
'm-animated-slide-in-right': right,
|
|
59
61
|
'm-animated-slide-in-bottom': bottom,
|
|
62
|
+
'm-bottom-safe-area': !disableBottomSafeArea,
|
|
60
63
|
},
|
|
61
64
|
className
|
|
62
65
|
)
|
|
@@ -90,7 +93,7 @@ const PopupBase: FC<PopupProps> = ({
|
|
|
90
93
|
</Flex>
|
|
91
94
|
)}
|
|
92
95
|
<View className='m-popup-content'>{children}</View>
|
|
93
|
-
<CustomTabbar />
|
|
96
|
+
{hasCustomTab && <CustomTabbar />}
|
|
94
97
|
</View>
|
|
95
98
|
</View>
|
|
96
99
|
)
|
|
@@ -51,6 +51,7 @@ const PopupBase: FC<PopupV1Props> = ({
|
|
|
51
51
|
titleClassName,
|
|
52
52
|
titleCenter,
|
|
53
53
|
clickMaskClose = true,
|
|
54
|
+
disableBottomSafeArea,
|
|
54
55
|
...rest
|
|
55
56
|
}) => {
|
|
56
57
|
devWarnForHook(() => {
|
|
@@ -128,7 +129,7 @@ const PopupBase: FC<PopupV1Props> = ({
|
|
|
128
129
|
</Flex>
|
|
129
130
|
)}
|
|
130
131
|
<View className='m-popup-content'>{children}</View>
|
|
131
|
-
<CustomTabbar />
|
|
132
|
+
{!disableBottomSafeArea && <CustomTabbar />}
|
|
132
133
|
</View>
|
|
133
134
|
</View>
|
|
134
135
|
)
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
|
|
66
66
|
@supports (bottom: constant(safe-area-inset-bottom)) or
|
|
67
67
|
(bottom: env(safe-area-inset-bottom)) {
|
|
68
|
-
.m-popup {
|
|
68
|
+
.m-popup.m-bottom-safe-area {
|
|
69
69
|
padding-bottom: constant(safe-area-inset-bottom); /* 兼容 iOS < 11.2 */
|
|
70
70
|
padding-bottom: env(safe-area-inset-bottom); /* 兼容 iOS >= 11.2 */
|
|
71
71
|
}
|
|
@@ -19,6 +19,10 @@ interface PopupProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
19
19
|
disabledAnimate?: boolean
|
|
20
20
|
/** 内部用 */
|
|
21
21
|
isPickPopup?: boolean
|
|
22
|
+
/** 禁用下方安全边距,默认为false */
|
|
23
|
+
disableBottomSafeArea?: boolean
|
|
24
|
+
/** 预留底部自定义导航高度,默认为true */
|
|
25
|
+
hasCustomTab?: boolean
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
interface PopupStaticsTypes {
|
|
@@ -17,6 +17,8 @@ const ios = mp && wx.getSystemInfoSync().platform === 'ios'
|
|
|
17
17
|
interface TextFieldState {
|
|
18
18
|
/** 是否输入状态 */
|
|
19
19
|
active: boolean
|
|
20
|
+
/** 是否需要清空 */
|
|
21
|
+
needClear: boolean
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
const store = observable({ active: '' })
|
|
@@ -43,6 +45,7 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
43
45
|
|
|
44
46
|
state = {
|
|
45
47
|
active: false,
|
|
48
|
+
needClear: false,
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
id = uniqueId('textField-')
|
|
@@ -82,12 +85,17 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
82
85
|
})
|
|
83
86
|
}
|
|
84
87
|
this.props.onClick && this.props.onClick(e)
|
|
88
|
+
this.setState({ ...this.state, needClear: !!this.props.rewriteMode })
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
onInput(e: any) {
|
|
88
92
|
if (this.props.disabled) return
|
|
89
93
|
if (!mp) e.persist()
|
|
90
94
|
let value = mp ? e.detail.value : e.target.value
|
|
95
|
+
if (this.state.needClear) {
|
|
96
|
+
value = value.slice(-1)
|
|
97
|
+
this.setState({ ...this.state, needClear: false })
|
|
98
|
+
}
|
|
91
99
|
const { min, max } = this.props
|
|
92
100
|
if (
|
|
93
101
|
value &&
|
|
@@ -97,6 +105,11 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
97
105
|
const float = parseFloat(value.replace(/\D\./g, ''))
|
|
98
106
|
if (isNaN(float)) {
|
|
99
107
|
value = ''
|
|
108
|
+
} else if (value.endsWith('.0')) {
|
|
109
|
+
// 处理特殊情况
|
|
110
|
+
if (this.props.fractionDigits === 0) {
|
|
111
|
+
value = value.replace(/\.0$/, '')
|
|
112
|
+
}
|
|
100
113
|
} else {
|
|
101
114
|
value = clamp(
|
|
102
115
|
float,
|
|
@@ -159,7 +172,7 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
159
172
|
disabled,
|
|
160
173
|
highlight,
|
|
161
174
|
cursorSpacing = 30,
|
|
162
|
-
maxLength,
|
|
175
|
+
maxLength = -1,
|
|
163
176
|
confirmType,
|
|
164
177
|
adjustPosition,
|
|
165
178
|
block,
|
|
@@ -170,6 +183,7 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
170
183
|
onClick,
|
|
171
184
|
onConfirm,
|
|
172
185
|
fractionDigits,
|
|
186
|
+
alwaysEmbed = true,
|
|
173
187
|
...rest
|
|
174
188
|
// 注意,不用传给input或area的props要在此列出来,不然rest会带过去
|
|
175
189
|
} = this.props
|
|
@@ -179,7 +193,7 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
179
193
|
|
|
180
194
|
const common = {
|
|
181
195
|
disabled: disabled,
|
|
182
|
-
onInput: this.onInput.bind(this),
|
|
196
|
+
// onInput: this.onInput.bind(this),
|
|
183
197
|
onChange: this.onInput.bind(this),
|
|
184
198
|
onClick: this.onClick.bind(this),
|
|
185
199
|
onBlur: () => {
|
|
@@ -207,6 +221,7 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
207
221
|
focus,
|
|
208
222
|
password,
|
|
209
223
|
placeholderClass: 'text-field-placeholder',
|
|
224
|
+
alwaysEmbed: alwaysEmbed,
|
|
210
225
|
onConfirm,
|
|
211
226
|
})
|
|
212
227
|
} else {
|
|
@@ -224,6 +239,7 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
224
239
|
active: highlight || active,
|
|
225
240
|
highlight,
|
|
226
241
|
disabled,
|
|
242
|
+
block,
|
|
227
243
|
})}
|
|
228
244
|
width={width}
|
|
229
245
|
style={style}
|
|
@@ -300,7 +316,9 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
300
316
|
</Flex>
|
|
301
317
|
)}
|
|
302
318
|
<View
|
|
303
|
-
className={classNames('text-field-error-message', errClassName
|
|
319
|
+
className={classNames('text-field-error-message', errClassName, {
|
|
320
|
+
'has-error': err,
|
|
321
|
+
})}
|
|
304
322
|
>
|
|
305
323
|
{err}
|
|
306
324
|
</View>
|
|
@@ -311,3 +329,7 @@ export class TextField extends Component<TextFieldProps, TextFieldState> {
|
|
|
311
329
|
}
|
|
312
330
|
|
|
313
331
|
export default TextField
|
|
332
|
+
|
|
333
|
+
export function AutoPreview_TextField() {
|
|
334
|
+
return <TextField value='test' onChange={() => {}} />
|
|
335
|
+
}
|
|
@@ -7,7 +7,7 @@ interface TextFieldProps
|
|
|
7
7
|
'style' | 'onBlur' | 'onFocus' | 'onClick' | 'onChange' | 'type'
|
|
8
8
|
> {
|
|
9
9
|
value: string
|
|
10
|
-
/** 输入事件, e在web中为ChangeEvent,在小程序中为onInputEventDetail */
|
|
10
|
+
/** 输入事件, e在web中为ChangeEvent(value为e.target.value),在小程序中为onInputEventDetail(value为e.detail.value) */
|
|
11
11
|
onChange?: (e: any) => void
|
|
12
12
|
/** 输入框类型, web端和小程序端取值有差异 */
|
|
13
13
|
type?: InputProps['type']
|
|
@@ -63,6 +63,8 @@ interface TextFieldProps
|
|
|
63
63
|
errClassName?: string
|
|
64
64
|
/** 键盘和输入框距离,小程序特有 */
|
|
65
65
|
cursorSpacing?: number
|
|
66
|
+
/** 重新获得焦点后,输入前清空现有内容 */
|
|
67
|
+
rewriteMode?: boolean
|
|
66
68
|
onBlur?: () => void
|
|
67
69
|
onFocus?: () => void
|
|
68
70
|
/** e在web中和小程序中不一样 */
|
|
@@ -32,7 +32,7 @@ const Item: FC<VListItemProps> = memo(
|
|
|
32
32
|
const doLazy = (event: CustomEvent<{ scrollTop: number }>): void => {
|
|
33
33
|
const { scrollTop } = event.detail
|
|
34
34
|
if (
|
|
35
|
-
(itemIndex +
|
|
35
|
+
(itemIndex + 2) * itemHeight < scrollTop - distance ||
|
|
36
36
|
itemIndex * itemHeight > scrollTop + listHeight + distance
|
|
37
37
|
) {
|
|
38
38
|
// unshow
|
package/src/index.less
CHANGED
|
@@ -37,11 +37,13 @@
|
|
|
37
37
|
@import './component/picker/style.less';
|
|
38
38
|
@import './component/nav/style.less';
|
|
39
39
|
@import './component/date_selector/style.less';
|
|
40
|
-
@import './component
|
|
40
|
+
@import './component/text_field/style.less';
|
|
41
|
+
@import './component/error/style.less';
|
|
41
42
|
|
|
42
43
|
// 公共
|
|
43
44
|
@import './less/mixin';
|
|
44
45
|
@import './less/base';
|
|
46
|
+
@import './less/button';
|
|
45
47
|
@import './less/distance';
|
|
46
48
|
@import './less/bg';
|
|
47
49
|
@import './less/display';
|
|
@@ -51,7 +53,6 @@
|
|
|
51
53
|
@import './less/border';
|
|
52
54
|
@import './less/animation';
|
|
53
55
|
@import './less/shadow';
|
|
54
|
-
@import './less/btn';
|
|
55
56
|
@import './less/ellipsis';
|
|
56
57
|
@import './less/lineheight';
|
|
57
|
-
@import './less/opacity';
|
|
58
|
+
@import './less/opacity';
|
package/src/index.ts
CHANGED
package/src/less/animation.less
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
.m-animated {
|
|
2
|
-
animation-duration: 0.2s;
|
|
3
|
-
animation-fill-mode: none;
|
|
2
|
+
// animation-duration: 0.2s;
|
|
3
|
+
// animation-fill-mode: none;
|
|
4
|
+
transition: all 0.2s;
|
|
4
5
|
}
|
|
5
6
|
|
|
6
7
|
.m-animated-fade-in {
|
|
@@ -153,10 +154,14 @@
|
|
|
153
154
|
|
|
154
155
|
@keyframes slide-in-bottom {
|
|
155
156
|
from {
|
|
156
|
-
transform: translate3d(0, 100%, 0);
|
|
157
|
+
// transform: translate3d(0, 100%, 0);
|
|
158
|
+
max-height: 0%;
|
|
159
|
+
overflow: hidden;
|
|
157
160
|
}
|
|
158
161
|
|
|
159
162
|
to {
|
|
160
|
-
transform: translate3d(0, 0, 0);
|
|
163
|
+
// transform: translate3d(0, 0, 0);
|
|
164
|
+
max-height: 100%;
|
|
165
|
+
overflow: hidden;
|
|
161
166
|
}
|
|
162
167
|
}
|
package/src/less/bg.less
CHANGED
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
background: var(--m-color-bg-accent-light) !important;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
.m-bg-transparent {
|
|
30
|
+
background: transparent !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
.m-bg-white-active-with {
|
|
30
34
|
.mBgWhiteActiveWith();
|
|
31
35
|
}
|
|
@@ -61,4 +65,7 @@ each(@colors,.(@color,@colorKey,@index){
|
|
|
61
65
|
.generate-colors(@opacity+1);
|
|
62
66
|
}
|
|
63
67
|
.generate-colors(0);
|
|
68
|
+
.m-bg-@{colorKey}{
|
|
69
|
+
background-color: @color!important;
|
|
70
|
+
}
|
|
64
71
|
});
|
package/src/less/border.less
CHANGED
|
@@ -98,13 +98,22 @@
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
.m-border-radius-circle {
|
|
101
|
-
border-radius: 50
|
|
101
|
+
border-radius: 50% !important;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
.m-border-radius-chip {
|
|
105
|
-
border-radius: 100px;
|
|
105
|
+
border-radius: 100px !important;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
.m-border-radius-5 {
|
|
109
|
-
border-radius: 5px;
|
|
109
|
+
border-radius: 5px !important;
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
// 生成圆角, .m-border-radius-{1-10}
|
|
113
|
+
.generate-size(@size) when (@size<=10) {
|
|
114
|
+
.m-border-radius-@{size} {
|
|
115
|
+
border-radius: @size * 1px !important;
|
|
116
|
+
}
|
|
117
|
+
.generate-size(@size + 1);
|
|
118
|
+
}
|
|
119
|
+
.generate-size(0);
|