@gm-mobile/c-react 3.9.7-beta.1 → 3.9.7-beta.5

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/c-react",
3
- "version": "3.9.7-beta.1",
3
+ "version": "3.9.7-beta.5",
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.7-beta.1",
25
- "@gm-mobile/c-tool": "^3.9.7-beta.1",
26
- "@gm-mobile/locales": "^3.9.7-beta.1"
24
+ "@gm-mobile/c-font": "^3.9.7-beta.5",
25
+ "@gm-mobile/c-tool": "^3.9.7-beta.5",
26
+ "@gm-mobile/locales": "^3.9.7-beta.5"
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": "8d9525acaf27467649b1ead173a12b0e23772d83"
36
+ "gitHead": "f0db16421e2dd7a2e94aef989f76db07a99dfc87"
37
37
  }
@@ -1,6 +1,6 @@
1
1
  import React, { FC, useState } from 'react'
2
2
  import { getLocale } from '@gm-mobile/locales'
3
- import moment from 'moment'
3
+ import moment from 'dayjs'
4
4
  import classNames from 'classnames'
5
5
  import _ from 'lodash'
6
6
 
@@ -1,5 +1,5 @@
1
1
  import React, { FC } from 'react'
2
- import moment from 'moment'
2
+ import moment from 'dayjs'
3
3
  import _ from 'lodash'
4
4
 
5
5
  import BaseCalendar from './base'
@@ -1,6 +1,6 @@
1
1
  import { getLocale } from '@gm-mobile/locales'
2
2
  import React, { FC, memo } from 'react'
3
- import moment from 'moment'
3
+ import moment from 'dayjs'
4
4
  import classNames from 'classnames'
5
5
  import _ from 'lodash'
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { getLocale } from '@gm-mobile/locales'
2
2
  import React, { FC } from 'react'
3
3
  import _ from 'lodash'
4
- import moment, { Moment } from 'moment'
4
+ import moment, { Dayjs } from 'dayjs'
5
5
 
6
6
  import { Flex } from '../flex'
7
7
  import Day from './day'
@@ -32,7 +32,7 @@ const Month: FC<MonthProps> = ({
32
32
  currentMoment,
33
33
  showDateLabel,
34
34
  }) => {
35
- const getDayRowOfMonth = (currentMoment: Moment) => {
35
+ const getDayRowOfMonth = (currentMoment: Dayjs) => {
36
36
  if (
37
37
  moment(currentMoment).day(0).add(35, 'day').month() !==
38
38
  currentMoment.month()
@@ -64,7 +64,7 @@ const Month: FC<MonthProps> = ({
64
64
  return disabled
65
65
  }
66
66
 
67
- const lastDay = moment(currentMoment).day(0).add(-1, 'day')
67
+ let lastDay = moment(currentMoment).day(0).add(-1, 'day')
68
68
  const month = currentMoment.month()
69
69
  const dayGroup = getDayRowOfMonth(currentMoment)
70
70
 
@@ -83,8 +83,8 @@ const Month: FC<MonthProps> = ({
83
83
  style={{ padding: _.size(dayGroup) > 5 ? '5px 0' : '9px 0' }}
84
84
  >
85
85
  {_.map(v, (value, index) => {
86
- const day = moment(lastDay.add(1, 'day'))
87
-
86
+ lastDay = lastDay.add(1, 'day')
87
+ const day = moment(lastDay)
88
88
  return (
89
89
  <Day
90
90
  key={`${value}${index}`}
@@ -1,5 +1,5 @@
1
1
  import React, { FC, useRef, useEffect } from 'react'
2
- import moment, { Moment } from 'moment'
2
+ import moment, { Dayjs } from 'dayjs'
3
3
  import _ from 'lodash'
4
4
 
5
5
  import { VList, VListRef } from '../v_list'
@@ -43,7 +43,7 @@ const MonthsList: FC<MonthListProps> = ({
43
43
  // eslint-disable-next-line
44
44
  while (mMin <= mMax) {
45
45
  arr.push(moment(mMin))
46
- mMin.add(1, 'month')
46
+ mMin = mMin.add(1, 'month')
47
47
  }
48
48
 
49
49
  return arr
@@ -74,7 +74,7 @@ const MonthsList: FC<MonthListProps> = ({
74
74
  height={height}
75
75
  itemHeight={MONTH_HEIGHT}
76
76
  distance={0}
77
- renderItem={(month: { item: Moment; index: number }) => {
77
+ renderItem={(month: { item: Dayjs; index: number }) => {
78
78
  return (
79
79
  <Month
80
80
  key={month.index}
@@ -1,5 +1,5 @@
1
1
  import { HTMLAttributes } from 'react'
2
- import { Moment } from 'moment'
2
+ import { Dayjs } from 'dayjs'
3
3
 
4
4
  type CalendarType = 'single' | 'range' | 'multiple'
5
5
 
@@ -9,7 +9,7 @@ interface DayProps {
9
9
  type: CalendarType
10
10
  onClick: (date: Date) => void
11
11
  /** 日期,可能是该月 / 上月 / 下月 */
12
- value: Moment
12
+ value: Dayjs
13
13
  /** 当前日历所在月份 */
14
14
  currentMonth: number
15
15
  disabled: boolean
@@ -19,7 +19,7 @@ interface DayProps {
19
19
  }
20
20
 
21
21
  interface MonthProps {
22
- currentMoment: Moment
22
+ currentMoment: Dayjs
23
23
  selected: Date[]
24
24
  type: CalendarType
25
25
  onSelectDay: (date: Date) => void
@@ -1,12 +1,13 @@
1
1
  import React, { FC } from 'react'
2
2
  import { View } from '../view'
3
3
  import { Flex } from '../flex'
4
- import moment from 'moment'
4
+ import moment, { extend } from 'dayjs'
5
5
  import _ from 'lodash'
6
6
 
7
+ import weekday from 'dayjs/plugin/weekday'
7
8
  import { ContainerProps } from './types'
8
9
  import Day from './day'
9
-
10
+ extend(weekday)
10
11
  const WEEK_COUNT = 7
11
12
 
12
13
  const Container: FC<ContainerProps> = ({ min, max, selected, ...rest }) => {
@@ -2,7 +2,7 @@ import { getLocale } from '@gm-mobile/locales'
2
2
  import React, { FC } from 'react'
3
3
  import { View } from '../view'
4
4
  import _ from 'lodash'
5
- import moment from 'moment'
5
+ import moment from 'dayjs'
6
6
 
7
7
  import { DateSelectorProps } from './types'
8
8
  import Container from './container'
@@ -1,13 +1,13 @@
1
1
  import React, { FC, memo } from 'react'
2
2
  import { getLocale } from '@gm-mobile/locales'
3
3
  import classNames from 'classnames'
4
- import moment, { Moment } from 'moment'
4
+ import moment, { Dayjs } from 'dayjs'
5
5
  import { View } from '../view'
6
6
  import _ from 'lodash'
7
7
 
8
8
  import { DayProps } from './types'
9
9
 
10
- const formatDay = (day: Date, span = 0): Moment => {
10
+ const formatDay = (day: Date, span = 0): Dayjs => {
11
11
  return moment(day).add(span, 'day').startOf('day')
12
12
  }
13
13
 
@@ -2,7 +2,8 @@ import React from 'react'
2
2
  import { View } from '../view'
3
3
  import _ from 'lodash'
4
4
  import { observable } from 'mobx'
5
- import moment from 'moment'
5
+ import moment from 'dayjs'
6
+
6
7
  import { DateSelector } from './date_selector'
7
8
 
8
9
  const store = observable({
@@ -11,9 +11,10 @@ import { Flex } from '../flex'
11
11
 
12
12
  /** 数字按钮 */
13
13
  export const defaultDigitalKeys = [
14
- ...['7', '8', '9'].map((v, _) => new DKBtn({ label: v })),
15
- ...['4', '5', '6'].map((v, _) => new DKBtn({ label: v })),
16
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({ label: '0' }),
17
18
  new DKBtn({
18
19
  label: '.',
19
20
  fn: (value = '') => {
@@ -27,7 +28,6 @@ export const defaultDigitalKeys = [
27
28
  }
28
29
  },
29
30
  }),
30
- new DKBtn({ label: '0' }),
31
31
  new DKBtn({ label: '清零', className: 'btn-clear', fn: (_) => '' }),
32
32
  ]
33
33
 
@@ -62,6 +62,7 @@ export interface KeyboardProps
62
62
  show?: boolean
63
63
  /** 整数类型键盘 */
64
64
  int?: boolean
65
+ isClearBtn?: boolean
65
66
  }
66
67
 
67
68
  export const Keyboard: FC<KeyboardProps> = ({
@@ -72,6 +73,7 @@ export const Keyboard: FC<KeyboardProps> = ({
72
73
  digitalKeys = defaultDigitalKeys,
73
74
  show = true,
74
75
  className,
76
+ isClearBtn = true,
75
77
  int,
76
78
  ...rest
77
79
  }) => {
@@ -104,27 +106,33 @@ export const Keyboard: FC<KeyboardProps> = ({
104
106
  >
105
107
  <Flex>
106
108
  <Flex flex={3} wrap>
107
- {digitalKeys.map((btn, i) => {
108
- return (
109
- <Flex
110
- key={i}
111
- width='33.33333%'
112
- alignCenter
113
- justifyCenter
114
- className='keyboard-item'
115
- >
116
- <View
117
- className={classNames(
118
- 'keyboard-button digital m-text-22',
119
- btn.className
120
- )}
121
- onClick={() => handleInput(btn)}
109
+ {digitalKeys
110
+ .filter((f) => (isClearBtn ? f : f.label !== '清零'))
111
+ .map((btn, i) => {
112
+ return (
113
+ <Flex
114
+ key={i}
115
+ width={
116
+ !isClearBtn && btn.label === '0'
117
+ ? '66.666666%'
118
+ : '33.33333%'
119
+ }
120
+ alignCenter
121
+ justifyCenter
122
+ className='keyboard-item'
122
123
  >
123
- {btn.label}
124
- </View>
125
- </Flex>
126
- )
127
- })}
124
+ <View
125
+ className={classNames(
126
+ 'keyboard-button digital m-text-22',
127
+ btn.className
128
+ )}
129
+ onClick={() => handleInput(btn)}
130
+ >
131
+ {btn.label}
132
+ </View>
133
+ </Flex>
134
+ )
135
+ })}
128
136
  </Flex>
129
137
  <Flex flex={1} column>
130
138
  {actionKeys.map((btn, keyIndex) => {