Skip to content

Commit dba8c92

Browse files
committed
fix(utils): 更新date, calendar,date-utils, type四个引用
1 parent 6e7aacd commit dba8c92

File tree

23 files changed

+466
-121
lines changed

23 files changed

+466
-121
lines changed

packages/renderless/src/calendar-bar/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { lastMonth, nextMonth } from '../common/calendar/calendar'
1+
import { lastMonth, nextMonth } from '@opentiny/utils'
22
import { getDirection } from '../common/deps/touch'
33

44
const normalConfig = (config, state) => {

packages/renderless/src/calendar-view/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { cloneDeep } from '../chart-core/deps/utils'
22
import { getDirection } from '../common/deps/touch'
3-
import { getDays, lastMonth, nextMonth, getCalendar, transformArray } from '../common/calendar/calendar'
3+
import { getDays, lastMonth, nextMonth, getCalendar, transformArray } from '@opentiny/utils'
44

55
const getTime = (date) => new Date(date).getTime()
66

packages/renderless/src/calendar/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import { copyArray } from '../common/object'
14-
import { lastMonth, nextMonth, getCalendar, transformArray, parseDate } from '../common/calendar/calendar'
14+
import { lastMonth, nextMonth, getCalendar, transformArray, parseDate } from '@opentiny/utils'
1515

1616
export const computedCalendar =
1717
({ state }) =>

packages/renderless/src/date-panel/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313
import { getWeekData } from '../picker'
1414
import debounce from '../common/deps/debounce'
1515
import {
16-
isDate,
17-
parseDate,
16+
isDate1,
17+
parseDate1,
1818
modifyDate,
1919
modifyTime,
2020
clearTime,
2121
prevYear,
2222
nextYear,
2323
prevMonth,
24-
nextMonth,
24+
nextMonth1,
2525
timeWithinRange,
2626
clearMilliseconds,
2727
modifyWithTimeString,
2828
changeYearMonthAndClampDate,
2929
formatDate,
3030
extractTimeFormat
31-
} from '../common/deps/date-util'
31+
} from '@opentiny/utils'
3232
import { DATEPICKER } from '../common'
3333
import { on, off } from '../common/deps/dom'
3434
import { getDateWithNewTimezone, getLocalTimezone } from '../common/date'
@@ -60,7 +60,7 @@ export const watchValue =
6060
return
6161
}
6262

63-
if (isDate(value)) {
63+
if (isDate1(value)) {
6464
state.date = state.selectionMode === 'week' ? getWeekData(value) : new Date(value)
6565
} else {
6666
state.date = api.getDefaultValue()
@@ -70,7 +70,7 @@ export const watchValue =
7070
export const watchDefaultValue =
7171
({ state }) =>
7272
(value) => {
73-
if (!isDate(state.value)) {
73+
if (!isDate1(state.value)) {
7474
state.date = value ? new Date(value) : new Date()
7575
}
7676
}
@@ -192,7 +192,7 @@ export const cusPrevMonth =
192192
export const cusNextMonth =
193193
({ state }) =>
194194
() =>
195-
(state.date = nextMonth(state.date))
195+
(state.date = nextMonth1(state.date))
196196

197197
export const cusPrevYear =
198198
({ state }) =>
@@ -238,7 +238,7 @@ export const doPick = (emit) => (date) => {
238238
export const handleTimePick =
239239
({ api, state, t }) =>
240240
(value, visible, first) => {
241-
if (isDate(value)) {
241+
if (isDate1(value)) {
242242
const newDate = state.value
243243
? modifyTime(state.value, value.getHours(), value.getMinutes(), value.getSeconds())
244244
: modifyWithTimeString(api.getDefaultValue(), state.defaultTime, t)
@@ -487,7 +487,7 @@ export const handleKeyControl =
487487
export const handleVisibleTimeChange =
488488
({ api, vm, state, t }) =>
489489
(value) => {
490-
const time = parseDate(value, state.timeFormat, t)
490+
const time = parseDate1(value, state.timeFormat, t)
491491

492492
if (time && api.checkDateWithinRange(time)) {
493493
state.date = modifyDate(time, state.year, state.month, state.monthDate)
@@ -505,7 +505,7 @@ export const handleVisibleTimeChange =
505505
export const handleVisibleDateChange =
506506
({ api, state, t }) =>
507507
(value) => {
508-
const date = parseDate(value, state.dateFormat, t)
508+
const date = parseDate1(value, state.dateFormat, t)
509509

510510
if (date) {
511511
if (typeof state.disabledDate === 'function' && state.disabledDate(date)) {

packages/renderless/src/date-panel/vue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import {
5858
getDisabledConfirm,
5959
getNowTime
6060
} from './index'
61-
import { toDate, getWeekNumber, modifyDate, extractDateFormat } from '../common/deps/date-util'
61+
import { toDate1, getWeekNumber, modifyDate, extractDateFormat } from '@opentiny/utils'
6262
import { DATEPICKER, DATE } from '../common'
6363

6464
export const api = [
@@ -146,7 +146,7 @@ const initWatch = ({ watch, state, api, nextTick, props }) => {
146146
watch(
147147
() => props.modelValue,
148148
(value) => {
149-
let newVal = toDate(value)
149+
let newVal = toDate1(value)
150150
if (newVal) {
151151
const newDate = modifyDate(newVal, newVal.getFullYear(), newVal.getMonth(), newVal.getUTCDate())
152152
state.date = newDate

packages/renderless/src/date-range/index.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
*/
1212

1313
import {
14-
isDate,
14+
toDate1,
1515
nextDate,
16-
parseDate,
16+
parseDate1,
1717
formatDate,
1818
modifyDate,
1919
modifyTime,
2020
nextYear,
2121
prevYear,
22-
nextMonth,
22+
nextMonth1,
2323
prevMonth,
2424
modifyWithTimeString
25-
} from '../common/deps/date-util'
25+
} from '@opentiny/utils'
2626

2727
export const calcDefaultValue = (defaultVal) => {
2828
if (Array.isArray(defaultVal)) {
@@ -115,7 +115,7 @@ export const watchMinDate =
115115
const format = 'HH:mm:ss'
116116

117117
minTimePicker.state.selectableRange = [
118-
[parseDate(formatDate(state.minDate, format, t), format, t), parseDate('23:59:59', format, t)]
118+
[parseDate1(formatDate(state.minDate, format, t), format, t), parseDate1('23:59:59', format, t)]
119119
]
120120
}
121121

@@ -164,8 +164,8 @@ export const watchValue =
164164
state.minDate = null
165165
state.maxDate = null
166166
} else if (Array.isArray(value)) {
167-
state.minDate = isDate(value[0]) ? new Date(value[0]) : null
168-
state.maxDate = isDate(value[1]) ? new Date(value[1]) : null
167+
state.minDate = toDate1(value[0]) ? new Date(value[0]) : null
168+
state.maxDate = toDate1(value[1]) ? new Date(value[1]) : null
169169

170170
if (state.minDate) {
171171
state.leftDate = state.minDate
@@ -177,13 +177,13 @@ export const watchValue =
177177
const maxDateMonth = state.maxDate.getMonth()
178178

179179
state.rightDate =
180-
minDateYear === maxDateYear && minDateMonth === maxDateMonth ? nextMonth(state.maxDate) : state.maxDate
180+
minDateYear === maxDateYear && minDateMonth === maxDateMonth ? nextMonth1(state.maxDate) : state.maxDate
181181
} else {
182-
state.rightDate = nextMonth(state.leftDate)
182+
state.rightDate = nextMonth1(state.leftDate)
183183
}
184184
} else {
185185
state.leftDate = calcDefaultValue(state.defaultValue)[0]
186-
state.rightDate = nextMonth(state.leftDate)
186+
state.rightDate = nextMonth1(state.leftDate)
187187
}
188188
}
189189
}
@@ -195,7 +195,7 @@ export const watchDefault =
195195
const [left, right] = calcDefaultValue(value)
196196

197197
state.leftDate = left
198-
state.rightDate = value && value[1] && state.unlinkPanels ? right : nextMonth(state.leftDate)
198+
state.rightDate = value && value[1] && state.unlinkPanels ? right : nextMonth1(state.leftDate)
199199
}
200200
}
201201

@@ -205,7 +205,7 @@ export const handleClear =
205205
state.minDate = null
206206
state.maxDate = null
207207
state.leftDate = calcDefaultValue(state.defaultValue)[0]
208-
state.rightDate = nextMonth(state.leftDate)
208+
state.rightDate = nextMonth1(state.leftDate)
209209
state.rangeState.selecting = false
210210
// tiny 新增下面行
211211
state.rangeState.endDate = null
@@ -228,7 +228,7 @@ export const handleDateInput =
228228
return
229229
}
230230

231-
const parsedValue = parseDate(value, state.dateFormat, t)
231+
const parsedValue = parseDate1(value, state.dateFormat, t)
232232

233233
if (parsedValue) {
234234
if (typeof state.disabledDate === 'function' && state.disabledDate(new Date(parsedValue))) {
@@ -246,7 +246,7 @@ export const handleDateInput =
246246
state.leftDate = new Date(parsedValue)
247247

248248
if (!state.unlinkPanels) {
249-
state.rightDate = nextMonth(state.leftDate)
249+
state.rightDate = nextMonth1(state.leftDate)
250250
}
251251
} else {
252252
state.maxDate = modifyDate(
@@ -268,7 +268,7 @@ export const handleDateInput =
268268
export const handleDateChange =
269269
({ state, t }) =>
270270
(value, type) => {
271-
const parsedValue = parseDate(value, state.dateFormat, t)
271+
const parsedValue = parseDate1(value, state.dateFormat, t)
272272

273273
if (parsedValue) {
274274
if (type === 'min') {
@@ -306,7 +306,7 @@ export const handleTimeInput =
306306
return
307307
}
308308

309-
const parsedValue = parseDate(value, state.timeFormat, t)
309+
const parsedValue = parseDate1(value, state.timeFormat, t)
310310

311311
if (parsedValue) {
312312
if (type === 'min') {
@@ -330,7 +330,7 @@ export const handleTimeInput =
330330
export const handleTimeChange =
331331
({ state, t, vm }) =>
332332
(value, type) => {
333-
const parsedValue = parseDate(value, state.timeFormat, t)
333+
const parsedValue = parseDate1(value, state.timeFormat, t)
334334

335335
if (parsedValue) {
336336
if (type === 'min') {
@@ -410,10 +410,10 @@ export const handleShortcutClick = (state, api) => (shortcut) => {
410410
state.shortcutType = shortcut.type
411411
state.shortcutText = shortcut.text
412412

413-
if (shortcut.type === 'startFrom' && shortcut.endDate && isDate(shortcut.endDate)) {
413+
if (shortcut.type === 'startFrom' && shortcut.endDate && toDate1(shortcut.endDate)) {
414414
state.maxRangeDate = shortcut.endDate
415415
}
416-
if (shortcut.type === 'endAt' && shortcut.startDate && isDate(shortcut.startDate)) {
416+
if (shortcut.type === 'endAt' && shortcut.startDate && toDate1(shortcut.startDate)) {
417417
state.minRangeDate = shortcut.startDate
418418
}
419419

@@ -480,7 +480,7 @@ export const leftPrevYear =
480480
state.leftDate = prevYear(state.leftDate)
481481

482482
if (!state.unlinkPanels) {
483-
state.rightDate = nextMonth(state.leftDate)
483+
state.rightDate = nextMonth1(state.leftDate)
484484
}
485485
}
486486

@@ -490,7 +490,7 @@ export const leftPrevMonth =
490490
state.leftDate = prevMonth(state.leftDate)
491491

492492
if (!state.unlinkPanels) {
493-
state.rightDate = nextMonth(state.leftDate)
493+
state.rightDate = nextMonth1(state.leftDate)
494494
}
495495
}
496496

@@ -501,7 +501,7 @@ export const rightNextYear =
501501

502502
if (!unlinkPanels) {
503503
state.leftDate = nextYear(leftDate)
504-
state.rightDate = nextMonth(state.leftDate)
504+
state.rightDate = nextMonth1(state.leftDate)
505505
} else {
506506
state.rightDate = nextYear(rightDate)
507507
}
@@ -511,10 +511,10 @@ export const rightNextMonth =
511511
({ state }) =>
512512
() => {
513513
if (!state.unlinkPanels) {
514-
state.leftDate = nextMonth(state.leftDate)
515-
state.rightDate = nextMonth(state.leftDate)
514+
state.leftDate = nextMonth1(state.leftDate)
515+
state.rightDate = nextMonth1(state.leftDate)
516516
} else {
517-
state.rightDate = nextMonth(state.rightDate)
517+
state.rightDate = nextMonth1(state.rightDate)
518518
}
519519
}
520520

@@ -526,7 +526,7 @@ export const leftNextYear =
526526
export const leftNextMonth =
527527
({ state }) =>
528528
() =>
529-
(state.leftDate = nextMonth(state.leftDate))
529+
(state.leftDate = nextMonth1(state.leftDate))
530530

531531
export const rightPrevYear =
532532
({ state }) =>
@@ -553,16 +553,16 @@ export const isValidValue =
553553
value &&
554554
value[0] &&
555555
value[1] &&
556-
isDate(value[0]) &&
557-
isDate(value[1]) &&
556+
toDate1(value[0]) &&
557+
toDate1(value[1]) &&
558558
value[0].getTime() <= value[1].getTime() &&
559559
(typeof state.disabledDate === 'function' ? !state.disabledDate(value[0]) && !state.disabledDate(value[1]) : true)
560560

561561
export const resetView =
562562
({ state }) =>
563563
() => {
564-
state.minDate = state.value && isDate(state.value[0]) ? new Date(state.value[0]) : null
565-
state.maxDate = state.value && isDate(state.value[0]) ? new Date(state.value[1]) : null
564+
state.minDate = state.value && toDate1(state.value[0]) ? new Date(state.value[0]) : null
565+
state.maxDate = state.value && toDate1(state.value[0]) ? new Date(state.value[1]) : null
566566
}
567567

568568
export const setTimeFormat =

packages/renderless/src/date-range/vue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import {
5252
computerEnableYearArrow,
5353
watchPickerVisible
5454
} from './index'
55-
import { nextMonth, extractDateFormat, extractTimeFormat } from '../common/deps/date-util'
55+
import { nextMonth1, extractDateFormat, extractTimeFormat } from '@opentiny/utils'
5656

5757
export const api = [
5858
'state',
@@ -95,7 +95,7 @@ const initState = ({ reactive, computed, api, constants, designConfig }) => {
9595
minRangeDate: constants.startDate,
9696
maxRangeDate: constants.endDate,
9797
leftDate: new Date(),
98-
rightDate: nextMonth(new Date()),
98+
rightDate: nextMonth1(new Date()),
9999
rangeState: { endDate: null, selecting: false, row: null, column: null },
100100
showTime: false,
101101
format: '',

0 commit comments

Comments
 (0)