@gm-mobile/c-react 3.12.7-beta.1 → 3.12.7-beta.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 +5 -5
- package/src/component/calendar/base.tsx +2 -0
- package/src/component/calendar/types.ts +2 -0
- package/src/component/search/search.weapp.tsx +46 -3
- package/src/component/search/stories.tsx +11 -1
- package/src/component/search/style.less +56 -1
- package/src/component/search/type.ts +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-mobile/c-react",
|
|
3
|
-
"version": "3.12.7-beta.
|
|
3
|
+
"version": "3.12.7-beta.3",
|
|
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.12.7-beta.
|
|
25
|
-
"@gm-mobile/c-tool": "^3.12.7-beta.
|
|
26
|
-
"@gm-mobile/locales": "^3.12.7-beta.
|
|
24
|
+
"@gm-mobile/c-font": "^3.12.7-beta.3",
|
|
25
|
+
"@gm-mobile/c-tool": "^3.12.7-beta.3",
|
|
26
|
+
"@gm-mobile/locales": "^3.12.7-beta.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": "
|
|
37
|
+
"gitHead": "2febbe7e8c3f9c92143aecca92bea1dd35fab799"
|
|
38
38
|
}
|
|
@@ -31,6 +31,7 @@ const BaseCalendar: FC<BaseCalendarProps> = ({
|
|
|
31
31
|
height = 400,
|
|
32
32
|
className,
|
|
33
33
|
style,
|
|
34
|
+
canScrollWhenMaxOrMinChange = false,
|
|
34
35
|
...rest
|
|
35
36
|
}) => {
|
|
36
37
|
const [isSelectBegin, setIsSelectBegin] = useState(true)
|
|
@@ -101,6 +102,7 @@ const BaseCalendar: FC<BaseCalendarProps> = ({
|
|
|
101
102
|
))}
|
|
102
103
|
</Flex>
|
|
103
104
|
<MonthsList
|
|
105
|
+
canScrollWhenMaxOrMinChange={canScrollWhenMaxOrMinChange}
|
|
104
106
|
selected={selected}
|
|
105
107
|
type={type}
|
|
106
108
|
height={height - 40} // 固定展示星期头部高度40
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getLocale } from '@gm-mobile/locales'
|
|
2
|
-
import React, { ChangeEvent, FC, FormEvent, MouseEvent } from 'react'
|
|
2
|
+
import React, { ChangeEvent, FC, FormEvent, MouseEvent, useState } from 'react'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import _ from 'lodash'
|
|
5
5
|
import Input from '../input/input'
|
|
@@ -12,6 +12,9 @@ const Search: FC<SearchProps> = ({
|
|
|
12
12
|
value,
|
|
13
13
|
placeholder = getLocale('搜索'),
|
|
14
14
|
searchText,
|
|
15
|
+
searchType,
|
|
16
|
+
onSearchType,
|
|
17
|
+
searchOptions = [],
|
|
15
18
|
type = 'search',
|
|
16
19
|
onCancel = _.noop,
|
|
17
20
|
onSearch = _.noop,
|
|
@@ -20,6 +23,11 @@ const Search: FC<SearchProps> = ({
|
|
|
20
23
|
autoFocus,
|
|
21
24
|
...rest
|
|
22
25
|
}) => {
|
|
26
|
+
const [showSelect, setShowSelect] = useState(false)
|
|
27
|
+
const needSelect = searchOptions?.length > 0
|
|
28
|
+
const searchTypeText =
|
|
29
|
+
searchOptions?.find((item) => item.key === searchType)?.name || '请选择'
|
|
30
|
+
|
|
23
31
|
const handleSearch = (
|
|
24
32
|
e: FormEvent<HTMLFormElement> | MouseEvent<HTMLButtonElement>
|
|
25
33
|
) => {
|
|
@@ -41,13 +49,48 @@ const Search: FC<SearchProps> = ({
|
|
|
41
49
|
onChange('')
|
|
42
50
|
}
|
|
43
51
|
|
|
52
|
+
const handleSelect = (key: string) => {
|
|
53
|
+
// eslint-disable-next-line no-unused-expressions
|
|
54
|
+
onSearchType?.(key)
|
|
55
|
+
setShowSelect(false)
|
|
56
|
+
}
|
|
57
|
+
|
|
44
58
|
return (
|
|
45
59
|
<View
|
|
46
60
|
{...rest}
|
|
47
|
-
className={classNames('m-search m-flex m-flex-align-center', className
|
|
61
|
+
className={classNames('m-search m-flex m-flex-align-center', className, {
|
|
62
|
+
'm-search-select': needSelect,
|
|
63
|
+
})}
|
|
48
64
|
>
|
|
49
65
|
<View className='m-search-input m-flex m-flex-flex'>
|
|
50
|
-
|
|
66
|
+
{needSelect ? (
|
|
67
|
+
<View
|
|
68
|
+
className='m-search-select-text'
|
|
69
|
+
onClick={() => setShowSelect((prev) => !prev)}
|
|
70
|
+
>
|
|
71
|
+
<Text>{searchTypeText}</Text>
|
|
72
|
+
<Text className='m-font m-font-arrow-triangle' />
|
|
73
|
+
</View>
|
|
74
|
+
) : (
|
|
75
|
+
<Text className='m-font m-font-search m-search-icon-search' />
|
|
76
|
+
)}
|
|
77
|
+
{showSelect && (
|
|
78
|
+
<View className='m-search-select-content'>
|
|
79
|
+
{searchOptions.map((option) => {
|
|
80
|
+
return (
|
|
81
|
+
<View
|
|
82
|
+
key={option.key}
|
|
83
|
+
className={classNames('m-search-select-content-item', {
|
|
84
|
+
'm-search-select-active': searchType === option.key,
|
|
85
|
+
})}
|
|
86
|
+
onClick={() => handleSelect(option.key)}
|
|
87
|
+
>
|
|
88
|
+
<Text>{option.name}</Text>
|
|
89
|
+
</View>
|
|
90
|
+
)
|
|
91
|
+
})}
|
|
92
|
+
</View>
|
|
93
|
+
)}
|
|
51
94
|
<Input
|
|
52
95
|
type='text'
|
|
53
96
|
confirmType='search'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
2
|
import Search from './search'
|
|
3
3
|
import SearchPage from './page'
|
|
4
4
|
import FakeSearch from './fake_search'
|
|
@@ -40,14 +40,24 @@ export const normal = () => {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export const cancel = () => {
|
|
43
|
+
const [type, setType] = useState('1')
|
|
43
44
|
return (
|
|
44
45
|
<View>
|
|
45
46
|
<View>带取消按钮(点Header的搜索按钮)</View>
|
|
46
47
|
<View>
|
|
47
48
|
<Search
|
|
48
49
|
type='cancel'
|
|
50
|
+
searchType={type}
|
|
51
|
+
onSearchType={setType}
|
|
52
|
+
searchOptions={[
|
|
53
|
+
{ name: '供应商', key: '1' },
|
|
54
|
+
{ name: '商品', key: '2' },
|
|
55
|
+
]}
|
|
49
56
|
placeholder='在站内搜索'
|
|
50
57
|
value={store.value}
|
|
58
|
+
style={{
|
|
59
|
+
background: '#fff',
|
|
60
|
+
}}
|
|
51
61
|
onChange={(value) => store.setValue(value)}
|
|
52
62
|
onCancel={() => console.log('cancel')}
|
|
53
63
|
/>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
.m-search {
|
|
2
2
|
height: var(--m-size-header-height);
|
|
3
3
|
padding: 0 15px;
|
|
4
|
+
position: relative;
|
|
4
5
|
|
|
5
6
|
.m-search-input {
|
|
6
7
|
border-radius: var(--m-size-form-height-sm);
|
|
7
|
-
overflow: hidden;
|
|
8
8
|
position: relative;
|
|
9
9
|
|
|
10
10
|
.m-input {
|
|
11
|
+
border-radius: var(--m-size-form-height-sm);
|
|
11
12
|
height: var(--m-size-form-height-sm);
|
|
12
13
|
background: var(--m-color-bg-back);
|
|
13
14
|
padding: 0 25px 0 25px;
|
|
@@ -35,6 +36,60 @@
|
|
|
35
36
|
.m-btn {
|
|
36
37
|
margin-right: -15px;
|
|
37
38
|
}
|
|
39
|
+
|
|
40
|
+
&.m-search-select {
|
|
41
|
+
.m-search-select-text {
|
|
42
|
+
position: absolute;
|
|
43
|
+
display: flex;
|
|
44
|
+
width: 72px;
|
|
45
|
+
flex: 1;
|
|
46
|
+
height: 100%;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
|
|
50
|
+
.m-font-arrow-triangle {
|
|
51
|
+
font-size: 6px;
|
|
52
|
+
transform: scale(0.6);
|
|
53
|
+
margin-left: 4px;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.m-input {
|
|
58
|
+
padding-left: 72px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.m-search-select-content {
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 38px;
|
|
64
|
+
background: #fff;
|
|
65
|
+
border-radius: 4px;
|
|
66
|
+
padding: 6px 10px;
|
|
67
|
+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
|
|
68
|
+
|
|
69
|
+
&::before {
|
|
70
|
+
content: '';
|
|
71
|
+
position: absolute;
|
|
72
|
+
top: -8px;
|
|
73
|
+
left: calc(50% - 4px);
|
|
74
|
+
border: 4px solid transparent;
|
|
75
|
+
border-bottom: 4px solid #fff;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.m-search-select-content-item {
|
|
79
|
+
padding: 4px;
|
|
80
|
+
border-bottom: 1.5px solid #eee;
|
|
81
|
+
text-align: center;
|
|
82
|
+
|
|
83
|
+
&:last-child {
|
|
84
|
+
border-bottom: none;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.m-search-select-active {
|
|
89
|
+
color: var(--m-color-accent);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
38
93
|
}
|
|
39
94
|
|
|
40
95
|
.m-fake-search {
|
|
@@ -10,6 +10,11 @@ interface SearchPageProps extends Omit<PageProps, 'onChange'> {
|
|
|
10
10
|
onSearch?: () => void
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
interface SearchOption {
|
|
14
|
+
name?: string
|
|
15
|
+
key: string
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
interface SearchProps {
|
|
14
19
|
value: string
|
|
15
20
|
onChange: (value: string) => void
|
|
@@ -24,11 +29,16 @@ interface SearchProps {
|
|
|
24
29
|
searchText?: string
|
|
25
30
|
className?: string
|
|
26
31
|
style?: CSSProperties
|
|
32
|
+
/** options */
|
|
33
|
+
searchType?: string
|
|
34
|
+
searchOptions?: SearchOption[]
|
|
35
|
+
onSearchType?: (key: string) => void
|
|
27
36
|
}
|
|
37
|
+
|
|
28
38
|
interface FakeSearchProps extends HtmlHTMLAttributes<HTMLDivElement> {
|
|
29
39
|
placeholder?: string
|
|
30
40
|
center?: boolean
|
|
31
41
|
light?: boolean
|
|
32
42
|
}
|
|
33
43
|
|
|
34
|
-
export type { SearchPageProps, SearchProps, FakeSearchProps }
|
|
44
|
+
export type { SearchPageProps, SearchProps, SearchOption, FakeSearchProps }
|