@mpxjs/webpack-plugin 2.10.3-beta.6 → 2.10.4-beta.10

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.
Files changed (122) hide show
  1. package/lib/index.js +1 -1
  2. package/lib/platform/json/wx/index.js +0 -1
  3. package/lib/platform/style/wx/index.js +22 -21
  4. package/lib/platform/template/wx/component-config/button.js +1 -1
  5. package/lib/platform/template/wx/component-config/index.js +5 -1
  6. package/lib/platform/template/wx/component-config/input.js +2 -2
  7. package/lib/platform/template/wx/component-config/sticky-header.js +23 -0
  8. package/lib/platform/template/wx/component-config/sticky-section.js +23 -0
  9. package/lib/platform/template/wx/component-config/text.js +18 -3
  10. package/lib/platform/template/wx/component-config/view.js +0 -2
  11. package/lib/platform/template/wx/index.js +41 -93
  12. package/lib/react/processJSON.js +7 -6
  13. package/lib/react/processScript.js +1 -18
  14. package/lib/runtime/components/react/context.ts +12 -3
  15. package/lib/runtime/components/react/dist/context.js +4 -1
  16. package/lib/runtime/components/react/dist/event.config.js +0 -1
  17. package/lib/runtime/components/react/dist/getInnerListeners.js +127 -142
  18. package/lib/runtime/components/react/dist/mpx-button.jsx +4 -5
  19. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +4 -5
  20. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +2 -2
  21. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +2 -3
  22. package/lib/runtime/components/react/dist/mpx-form.jsx +2 -2
  23. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
  24. package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
  25. package/lib/runtime/components/react/dist/mpx-inline-text.jsx +11 -0
  26. package/lib/runtime/components/react/dist/mpx-input.jsx +6 -10
  27. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +2 -2
  28. package/lib/runtime/components/react/dist/mpx-label.jsx +2 -3
  29. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +2 -2
  30. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +1 -1
  31. package/lib/runtime/components/react/dist/mpx-navigator.jsx +11 -3
  32. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +194 -68
  33. package/lib/runtime/components/react/dist/mpx-picker/dateData.js +17 -0
  34. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +180 -98
  35. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +79 -139
  36. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +190 -90
  37. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +60 -75
  38. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +100 -228
  39. package/lib/runtime/components/react/dist/{mpx-picker-view.jsx → mpx-picker-view/index.jsx} +5 -6
  40. package/lib/runtime/components/react/dist/{mpx-picker-view-column.jsx → mpx-picker-view-column/index.jsx} +64 -16
  41. package/lib/runtime/components/react/dist/{mpx-picker-view-column-item.jsx → mpx-picker-view-column/pickerViewColumnItem.jsx} +8 -5
  42. package/lib/runtime/components/react/dist/{pickerFaces.js → mpx-picker-view-column/pickerViewFaces.js} +6 -0
  43. package/lib/runtime/components/react/dist/mpx-popup/index.jsx +61 -0
  44. package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +92 -0
  45. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +2 -2
  46. package/lib/runtime/components/react/dist/mpx-radio.jsx +2 -3
  47. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +2 -2
  48. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +207 -29
  49. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +7 -5
  50. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -15
  51. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +115 -0
  52. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +45 -0
  53. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -5
  54. package/lib/runtime/components/react/dist/mpx-swiper.jsx +11 -11
  55. package/lib/runtime/components/react/dist/mpx-switch.jsx +3 -5
  56. package/lib/runtime/components/react/dist/mpx-text.jsx +4 -7
  57. package/lib/runtime/components/react/dist/mpx-video.jsx +5 -5
  58. package/lib/runtime/components/react/dist/mpx-view.jsx +23 -9
  59. package/lib/runtime/components/react/dist/mpx-web-view.jsx +17 -17
  60. package/lib/runtime/components/react/dist/useAnimationHooks.js +26 -4
  61. package/lib/runtime/components/react/dist/utils.jsx +13 -2
  62. package/lib/runtime/components/react/event.config.ts +1 -6
  63. package/lib/runtime/components/react/getInnerListeners.ts +148 -191
  64. package/lib/runtime/components/react/mpx-button.tsx +7 -7
  65. package/lib/runtime/components/react/mpx-canvas/index.tsx +25 -17
  66. package/lib/runtime/components/react/mpx-checkbox-group.tsx +4 -3
  67. package/lib/runtime/components/react/mpx-checkbox.tsx +8 -9
  68. package/lib/runtime/components/react/mpx-form.tsx +25 -19
  69. package/lib/runtime/components/react/mpx-icon/index.tsx +4 -3
  70. package/lib/runtime/components/react/mpx-image.tsx +4 -3
  71. package/lib/runtime/components/react/mpx-inline-text.tsx +18 -0
  72. package/lib/runtime/components/react/mpx-input.tsx +8 -14
  73. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +2 -2
  74. package/lib/runtime/components/react/mpx-label.tsx +4 -5
  75. package/lib/runtime/components/react/mpx-movable-area.tsx +22 -13
  76. package/lib/runtime/components/react/mpx-movable-view.tsx +47 -40
  77. package/lib/runtime/components/react/mpx-navigator.tsx +4 -6
  78. package/lib/runtime/components/react/mpx-picker/date.tsx +226 -69
  79. package/lib/runtime/components/react/mpx-picker/dateData.ts +22 -0
  80. package/lib/runtime/components/react/mpx-picker/index.tsx +242 -118
  81. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +96 -139
  82. package/lib/runtime/components/react/mpx-picker/region.tsx +217 -89
  83. package/lib/runtime/components/react/mpx-picker/selector.tsx +75 -80
  84. package/lib/runtime/components/react/mpx-picker/time.tsx +119 -236
  85. package/lib/runtime/components/react/mpx-picker/type.ts +85 -71
  86. package/lib/runtime/components/react/{mpx-picker-view.tsx → mpx-picker-view/index.tsx} +24 -21
  87. package/lib/runtime/components/react/{mpx-picker-view-column.tsx → mpx-picker-view-column/index.tsx} +70 -19
  88. package/lib/runtime/components/react/{mpx-picker-view-column-item.tsx → mpx-picker-view-column/pickerViewColumnItem.tsx} +8 -5
  89. package/lib/runtime/components/react/{pickerFaces.ts → mpx-picker-view-column/pickerViewFaces.ts} +7 -0
  90. package/lib/runtime/components/react/mpx-popup/index.tsx +86 -0
  91. package/lib/runtime/components/react/mpx-popup/popupBase.tsx +130 -0
  92. package/lib/runtime/components/react/mpx-radio-group.tsx +4 -3
  93. package/lib/runtime/components/react/mpx-radio.tsx +8 -9
  94. package/lib/runtime/components/react/mpx-rich-text/index.tsx +15 -6
  95. package/lib/runtime/components/react/mpx-scroll-view.tsx +326 -96
  96. package/lib/runtime/components/react/mpx-simple-text.tsx +17 -8
  97. package/lib/runtime/components/react/mpx-simple-view.tsx +17 -16
  98. package/lib/runtime/components/react/mpx-sticky-header.tsx +179 -0
  99. package/lib/runtime/components/react/mpx-sticky-section.tsx +96 -0
  100. package/lib/runtime/components/react/mpx-swiper-item.tsx +31 -24
  101. package/lib/runtime/components/react/mpx-swiper.tsx +69 -65
  102. package/lib/runtime/components/react/mpx-switch.tsx +19 -14
  103. package/lib/runtime/components/react/mpx-text.tsx +16 -13
  104. package/lib/runtime/components/react/mpx-video.tsx +36 -35
  105. package/lib/runtime/components/react/mpx-view.tsx +41 -17
  106. package/lib/runtime/components/react/mpx-web-view.tsx +16 -16
  107. package/lib/runtime/components/react/types/getInnerListeners.d.ts +69 -35
  108. package/lib/runtime/components/react/useAnimationHooks.ts +29 -9
  109. package/lib/runtime/components/react/utils.tsx +13 -2
  110. package/lib/runtime/components/web/mpx-input.vue +1 -1
  111. package/lib/runtime/components/web/mpx-scroll-view.vue +21 -4
  112. package/lib/runtime/components/web/mpx-sticky-header.vue +91 -0
  113. package/lib/runtime/components/web/mpx-sticky-section.vue +15 -0
  114. package/lib/runtime/stringify.wxs +2 -2
  115. package/lib/template-compiler/compiler.js +7 -7
  116. package/package.json +3 -4
  117. /package/lib/runtime/components/react/dist/{pickerVIewContext.js → mpx-picker-view/pickerVIewContext.js} +0 -0
  118. /package/lib/runtime/components/react/dist/{pickerViewIndicator.jsx → mpx-picker-view-column/pickerViewIndicator.jsx} +0 -0
  119. /package/lib/runtime/components/react/dist/{pickerViewMask.jsx → mpx-picker-view-column/pickerViewMask.jsx} +0 -0
  120. /package/lib/runtime/components/react/{pickerVIewContext.ts → mpx-picker-view/pickerVIewContext.ts} +0 -0
  121. /package/lib/runtime/components/react/{pickerViewIndicator.tsx → mpx-picker-view-column/pickerViewIndicator.tsx} +0 -0
  122. /package/lib/runtime/components/react/{pickerViewMask.tsx → mpx-picker-view-column/pickerViewMask.tsx} +0 -0
@@ -1,86 +1,243 @@
1
- import { View, TouchableWithoutFeedback } from 'react-native'
2
- import { DatePicker } from '@ant-design/react-native'
3
- import React, { forwardRef, useState, useRef, useEffect } from 'react'
4
- import useNodesRef, { HandlerRef } from '../useNodesRef' // 引入辅助函数
5
- import { DateProps, LayoutType } from './type'
6
-
7
- function formatTimeStr (time = ''): Date {
8
- let [year, month, day]: any = time.split('-')
9
- year = ~~year || 2000
10
- month = ~~month || 1
11
- day = ~~day || 1
12
- return new Date(year, month - 1, day)
1
+ import React, { forwardRef, useCallback, useMemo, useRef, useState, useEffect, useImperativeHandle } from 'react'
2
+ import { StyleSheet, Text, View } from 'react-native'
3
+ import MpxPickerView from '../mpx-picker-view'
4
+ import MpxPickerViewColumn from '../mpx-picker-view-column'
5
+ import { DateProps, TimeValue } from './type'
6
+ import { HandlerRef } from '../useNodesRef'
7
+ import { useUpdateEffect } from '../utils'
8
+ import { years, months, daysInMonth, wrapDate, daysInMonthLength, START_YEAR, END_YEAR } from './dateData'
9
+
10
+ type FormatObj = {
11
+ indexArr: number[]
12
+ rangeArr: string[][]
13
+ nameArr?: string[]
13
14
  }
14
15
 
15
- function dateToString (date: Date, fields: 'day' | 'month' | 'year' = 'day'): string {
16
- const yyyy: string = date.getFullYear() + ''
17
- const MM: string = ('0' + (date.getMonth() + 1)).slice(-2)
18
- const dd: string = ('0' + date.getDate()).slice(-2)
19
- let ret: string = yyyy
20
- if (fields === 'month' || fields === 'day') {
21
- ret += `-${MM}`
22
- if (fields === 'day') {
23
- ret += `-${dd}`
24
- }
16
+ const START_DATE: TimeValue = `${START_YEAR}-01-01`
17
+ const END_DATE: TimeValue = `${END_YEAR}-12-31`
18
+ const START_DATE_ARR = [START_YEAR, 1, 1]
19
+ const END_DATE_ARR = [END_YEAR, 12, 31]
20
+
21
+ const styles = StyleSheet.create({
22
+ pickerContainer: {
23
+ height: 240,
24
+ paddingHorizontal: 10,
25
+ borderTopLeftRadius: 10,
26
+ borderTopRightRadius: 10
27
+ },
28
+ pickerIndicator: {
29
+ height: 45
30
+ },
31
+ pickerItem: {
32
+ fontSize: 16,
33
+ lineHeight: 45,
34
+ textAlign: 'center'
35
+ }
36
+ })
37
+
38
+ const getColumnLength = (fields: DateProps['fields'] = 'day') => {
39
+ return fields === 'year' ? 1 : fields === 'month' ? 2 : 3
40
+ }
41
+
42
+ const compareDateStr = (date1: TimeValue | number[], date2: TimeValue | number[]) => {
43
+ const [y1 = START_YEAR, m1 = 0, d1 = 0] = typeof date1 === 'string' ? date1.split('-').map(Number) : date1
44
+ const [y2 = START_YEAR, m2 = 0, d2 = 0] = typeof date2 === 'string' ? date2.split('-').map(Number) : date2
45
+ const num1 = y1 * 10000 + m1 * 100 + d1
46
+ const num2 = y2 * 10000 + m2 * 100 + d2
47
+ if (num1 === num2) {
48
+ return 0
25
49
  }
26
- return ret
50
+ return num1 > num2 ? 1 : -1
27
51
  }
28
52
 
29
- const _DatePicker = forwardRef<HandlerRef<View, DateProps>, DateProps>((props: DateProps, ref): React.JSX.Element => {
30
- const { children, start = '1970-01-01', end = '2999-01-01', value, bindchange, bindcancel, disabled, fields, style } = props
31
- const [datevalue, setDateValue] = useState(value)
32
- // 存储layout布局信息
33
- const layoutRef = useRef({})
34
- const viewRef = useRef<View>(null)
35
- const nodeRef = useRef<View>(null)
36
- useNodesRef<View, DateProps>(props, ref, nodeRef, {
37
- style
38
- })
53
+ const getDateArr = (date: TimeValue | number[]): number[] => {
54
+ const [y, m, d] = typeof date === 'string' ? date.split('-').map(Number) : date
55
+ return [y || 0, m || 0, d || 0]
56
+ }
39
57
 
40
- useEffect(() => {
41
- value && setDateValue(value)
42
- }, [value])
43
-
44
- const onChange = (date: Date): void => {
45
- const { fields = 'day' } = props
46
- const ret = dateToString(date, fields)
47
- setDateValue(ret)
48
- bindchange && bindchange({ detail: { value: ret } })
58
+ const calibrateDate = (date: TimeValue | number[], start: TimeValue, end: TimeValue): number[] => {
59
+ let startArr = getDateArr(start)
60
+ let endArr = getDateArr(end)
61
+ let dateArr = getDateArr(date)
62
+ if (compareDateStr(startArr, endArr) > 0) {
63
+ startArr = START_DATE_ARR
64
+ }
65
+ if (compareDateStr(endArr, startArr) < 0) {
66
+ endArr = END_DATE_ARR
67
+ }
68
+ if (compareDateStr(start, end) > 0) {
69
+ startArr = START_DATE_ARR
70
+ endArr = END_DATE_ARR
49
71
  }
72
+ if (compareDateStr(dateArr, endArr) > 0) {
73
+ dateArr = endArr
74
+ }
75
+ if (compareDateStr(dateArr, startArr) < 0) {
76
+ dateArr = startArr
77
+ }
78
+ return dateArr
79
+ }
50
80
 
51
- const onDismiss = (): void => {
52
- bindcancel && bindcancel()
81
+ const initDateStr2Arr = (dateStr: TimeValue | number[], start: TimeValue, end: TimeValue): number[] => {
82
+ if (!dateStr) {
83
+ const today = new Date()
84
+ const todayYear = today.getFullYear()
85
+ const todayMonth = today.getMonth() + 1
86
+ const todayDay = today.getDate()
87
+ dateStr = [todayYear, todayMonth, todayDay]
53
88
  }
89
+ const [y, m, d] = getDateArr(dateStr)
90
+ const year = Math.min(Math.max(START_YEAR, y), END_YEAR)
91
+ const month = Math.min(Math.max(1, m), 12)
92
+ const day = Math.min(Math.max(1, d), daysInMonthLength(year, month))
93
+ const res = [year, month, day]
94
+ return calibrateDate(res, start, end)
95
+ }
54
96
 
55
- const onElementLayout = (layout: LayoutType) => {
56
- viewRef.current?.measure((x: number, y: number, width: number, height: number, offsetLeft: number, offsetTop: number) => {
57
- layoutRef.current = { x, y, width, height, offsetLeft, offsetTop }
58
- props.getInnerLayout && props.getInnerLayout(layoutRef)
59
- })
97
+ const valueStr2Obj = (
98
+ _value: TimeValue | number[] = '', // eg: 2025-2-12
99
+ limit: number,
100
+ start: TimeValue,
101
+ end: TimeValue
102
+ ): FormatObj => {
103
+ const [y, m, d] = initDateStr2Arr(_value, start, end)
104
+ const ans = {
105
+ indexArr: [y - START_YEAR],
106
+ rangeArr: [years]
107
+ }
108
+ if (limit === 2) {
109
+ ans.indexArr.push(m - 1)
110
+ ans.rangeArr.push(months)
111
+ } else if (limit === 3) {
112
+ const days = daysInMonth(y, m)
113
+ ans.indexArr.push(m - 1, d - 1)
114
+ ans.rangeArr.push(months, days)
60
115
  }
116
+ return ans
117
+ }
118
+
119
+ const valueChanged2Obj = (currentObj: FormatObj, value: number[], limit = 3) => {
120
+ const currentValue = currentObj.indexArr
121
+ const rangeArr = currentObj.rangeArr
61
122
 
62
- const dateProps = {
63
- ref: nodeRef,
64
- precision: fields,
65
- value: formatTimeStr(datevalue),
66
- minDate: formatTimeStr(start),
67
- maxDate: formatTimeStr(end),
68
- onChange,
69
- onDismiss,
70
- disabled
123
+ if (limit === 3 && (currentValue[0] !== value[0] || currentValue[1] !== value[1])) {
124
+ const days = daysInMonth(value[0], value[1] + 1)
125
+ rangeArr[2] = days
126
+ const maxIndex = days.length - 1
127
+ if (value[2] > maxIndex) {
128
+ value[2] = maxIndex
129
+ }
71
130
  }
72
- const touchProps = {
73
- onLayout: onElementLayout,
74
- ref: viewRef
131
+
132
+ return {
133
+ indexArr: value,
134
+ rangeArr
75
135
  }
136
+ }
137
+
138
+ const valueChanged2Obj2 = (value: number[], limit = 3, start: TimeValue, end: TimeValue) => {
139
+ const y = value[0] + START_YEAR
140
+ const m = value[1] + 1
141
+ const d = value[2] + 1
142
+ return valueStr2Obj([y, m, d], limit, start, end)
143
+ }
144
+
145
+ const valueNum2String = (value: number[]) => {
146
+ return value.map((item, index) => {
147
+ if (index === 0) {
148
+ return item + START_YEAR
149
+ } else {
150
+ return wrapDate()(item + 1)
151
+ }
152
+ }).join('-')
153
+ }
154
+
155
+ const hasDiff = (currentValue: number[], value: number[], limit = 3) => {
156
+ for (let i = 0; i < limit; i++) {
157
+ if (currentValue[i] !== value[i]) {
158
+ return true
159
+ }
160
+ }
161
+ return false
162
+ }
163
+
164
+ const PickerDate = forwardRef<
165
+ HandlerRef<View, DateProps>,
166
+ DateProps
167
+ >((props: DateProps, ref): React.JSX.Element => {
168
+ const { value = '', start = START_DATE, end = END_DATE, fields, bindchange } = props
169
+ const nodeRef = useRef(null)
170
+ const columnLength = useMemo(() => getColumnLength(fields), [fields])
171
+ const [formatObj, setFormatObj] = useState<FormatObj>(valueStr2Obj(value, columnLength, start, end))
172
+ const timerRef = useRef<NodeJS.Timeout | null>(null)
173
+
174
+ useEffect(() => {
175
+ return () => {
176
+ timerRef.current && clearTimeout(timerRef.current)
177
+ }
178
+ }, [])
179
+
180
+ useUpdateEffect(() => {
181
+ const calibratedValue = valueStr2Obj(value, columnLength, start, end)
182
+ setFormatObj(calibratedValue)
183
+ }, [value, columnLength, start, end])
184
+
185
+ const updateValue = useCallback((value: TimeValue = '') => {
186
+ const calibratedValue = valueStr2Obj(value, columnLength, start, end)
187
+ setFormatObj(calibratedValue)
188
+ }, [columnLength, start, end])
189
+
190
+ const _props = useRef(props)
191
+ _props.current = props
192
+ useImperativeHandle(ref, () => ({
193
+ updateValue,
194
+ getNodeInstance: () => ({
195
+ props: _props,
196
+ nodeRef,
197
+ instance: {
198
+ style: {}
199
+ }
200
+ })
201
+ }))
202
+
203
+ const onChange = useCallback((e: { detail: { value: number[] } }) => {
204
+ const { value } = e.detail
205
+ const currentValue = formatObj.indexArr
206
+ const newObj = valueChanged2Obj(formatObj, value, columnLength)
207
+ if (hasDiff(currentValue, value, columnLength)) {
208
+ setFormatObj(newObj)
209
+ const newObj2 = valueChanged2Obj2(value, columnLength, start, end)
210
+ if (hasDiff(newObj.indexArr, newObj2.indexArr, columnLength)) {
211
+ timerRef.current && clearTimeout(timerRef.current)
212
+ timerRef.current = setTimeout(() => setFormatObj(newObj2))
213
+ }
214
+ }
215
+ bindchange?.({ detail: { value: valueNum2String(newObj.indexArr) } })
216
+ }, [formatObj, columnLength, bindchange, start, end])
217
+
218
+ const renderColumn = () => {
219
+ return formatObj.rangeArr?.map((item, index) => (
220
+ // @ts-expect-error ignore
221
+ <MpxPickerViewColumn key={index}>
222
+ {item.map((item, index) => {
223
+ return <Text key={index} style={styles.pickerItem}>
224
+ {item}
225
+ </Text>
226
+ })}
227
+ </MpxPickerViewColumn>
228
+ ))
229
+ }
230
+
76
231
  return (
77
- <DatePicker {...dateProps}>
78
- <TouchableWithoutFeedback>
79
- <View {...touchProps}>{children}</View>
80
- </TouchableWithoutFeedback>
81
- </DatePicker>
82
- )
232
+ <MpxPickerView
233
+ style={styles.pickerContainer}
234
+ indicator-style={styles.pickerIndicator}
235
+ value={formatObj.indexArr}
236
+ bindchange={onChange}
237
+ >
238
+ {renderColumn()}
239
+ </MpxPickerView>)
83
240
  })
84
241
 
85
- _DatePicker.displayName = 'mpx-picker-date'
86
- export default _DatePicker
242
+ PickerDate.displayName = 'MpxPickerDate'
243
+ export default PickerDate
@@ -0,0 +1,22 @@
1
+ export const wrapDate = (union = '') => (num: number) => String(num).padStart(2, '0') + union
2
+
3
+ export const START_YEAR = 1900
4
+ export const END_YEAR = 2099
5
+
6
+ export const years = Array.from({ length: 200 }, (_, index) => index + START_YEAR + '年')
7
+
8
+ export const months = Array.from({ length: 12 }, (_, index) => index + 1).map(wrapDate('月'))
9
+
10
+ export const daysInMonthLength = (year: number, month: number) => {
11
+ return month === 2
12
+ ? year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)
13
+ ? 29
14
+ : 28
15
+ : [4, 6, 9, 11].includes(month)
16
+ ? 30
17
+ : 31
18
+ }
19
+
20
+ export const daysInMonth = (year: number, month: number) => {
21
+ return Array.from({ length: daysInMonthLength(year, month) }, (_, index) => index + 1).map(wrapDate('日'))
22
+ }