fix(build): fix dependencies packaging (#3665)

* Revert "fix(components): [el-date-picker] dayjs props not extended (#3662)"

This reverts commit fb8446709f.

* fix(build): fix rollup externals
This commit is contained in:
三咲智子 2021-09-27 00:23:27 +08:00 committed by GitHub
parent fb8446709f
commit 6447feb505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 50 deletions

View File

@ -1,4 +1,4 @@
import { compPackage } from './paths'
import { epPackage } from './paths'
import { getWorkspacePackages, getPackageDependencies } from './pkg'
import type { OutputOptions, RollupBuild } from 'rollup'
@ -12,7 +12,7 @@ export const generateExternal = async (options: { full: boolean }) => {
return (id: string) => {
const packages: string[] = ['vue']
if (!options.full) {
const depPackages = getPackageDependencies(compPackage)
const depPackages = getPackageDependencies(epPackage)
packages.push('@vue', ...monoPackages, ...depPackages)
}

View File

@ -91,13 +91,9 @@ export default defineComponent({
const lastColumn = ref(null)
const tableRows = ref([[], [], [], [], [], []])
const propsDate = computed(() => dayjs(props.date))
const propsMinDate = computed(() => dayjs(props.minDate))
const propsMaxDate = computed(() => dayjs(props.maxDate))
// todo better way to get Day.js locale object
const firstDayOfWeek = (propsDate.value as any).$locale().weekStart || 7
const WEEKS_CONSTANT = propsDate.value
const firstDayOfWeek = (props.date as any).$locale().weekStart || 7
const WEEKS_CONSTANT = props.date
.locale('en')
.localeData()
.weekdaysShort()
@ -109,7 +105,7 @@ export default defineComponent({
})
const startDate = computed(() => {
const startDayOfMonth = propsDate.value.startOf('month')
const startDayOfMonth = props.date.startOf('month')
return startDayOfMonth.subtract(startDayOfMonth.day() || 7, 'day')
})
@ -122,7 +118,7 @@ export default defineComponent({
const rows = computed(() => {
// TODO: refactory rows / getCellClasses
const startOfMonth = propsDate.value.startOf('month')
const startOfMonth = props.date.startOf('month')
const startOfMonthDay = startOfMonth.day() || 7 // day of first day
const dateCountOfMonth = startOfMonth.daysInMonth()
const dateCountOfLastMonth = startOfMonth
@ -170,26 +166,24 @@ export default defineComponent({
const calEndDate =
props.rangeState.endDate ||
propsMaxDate.value ||
(props.rangeState.selecting && propsMinDate.value)
props.maxDate ||
(props.rangeState.selecting && props.minDate)
cell.inRange =
(propsMinDate.value &&
calTime.isSameOrAfter(propsMinDate.value, 'day') &&
(props.minDate &&
calTime.isSameOrAfter(props.minDate, 'day') &&
calEndDate &&
calTime.isSameOrBefore(calEndDate, 'day')) ||
(propsMinDate.value &&
calTime.isSameOrBefore(propsMinDate.value, 'day') &&
(props.minDate &&
calTime.isSameOrBefore(props.minDate, 'day') &&
calEndDate &&
calTime.isSameOrAfter(calEndDate, 'day'))
if (propsMinDate.value?.isSameOrAfter(calEndDate)) {
if (props.minDate?.isSameOrAfter(calEndDate)) {
cell.start = calEndDate && calTime.isSame(calEndDate, 'day')
cell.end =
propsMinDate.value && calTime.isSame(propsMinDate.value, 'day')
cell.end = props.minDate && calTime.isSame(props.minDate, 'day')
} else {
cell.start =
propsMinDate.value && calTime.isSame(propsMinDate.value, 'day')
cell.start = props.minDate && calTime.isSame(props.minDate, 'day')
cell.end = calEndDate && calTime.isSame(calEndDate, 'day')
}
@ -251,7 +245,7 @@ export default defineComponent({
if (!date) return false
return dayjs(date)
.locale(lang.value)
.isSame(propsDate.value.date(Number(cell.text)), 'day')
.isSame(props.date.date(Number(cell.text)), 'day')
}
const getCellClasses = (cell) => {
@ -365,10 +359,10 @@ export default defineComponent({
ctx.emit('pick', { minDate: newDate, maxDate: null })
ctx.emit('select', true)
} else {
if (newDate >= propsMinDate.value) {
ctx.emit('pick', { minDate: propsMinDate.value, maxDate: newDate })
if (newDate >= props.minDate) {
ctx.emit('pick', { minDate: props.minDate, maxDate: newDate })
} else {
ctx.emit('pick', { minDate: newDate, maxDate: propsMinDate.value })
ctx.emit('pick', { minDate: newDate, maxDate: props.minDate })
}
ctx.emit('select', false)
}
@ -395,7 +389,7 @@ export default defineComponent({
const isWeekActive = (cell) => {
if (props.selectionMode !== 'week') return false
let newDate = propsDate.value.startOf('day')
let newDate = props.date.startOf('day')
if (cell.type === 'prev-month') {
newDate = newDate.subtract(1, 'month')

View File

@ -69,13 +69,8 @@ export default defineComponent({
setup(props, ctx) {
const { t, lang } = useLocaleInject()
const propsDate = computed(() => dayjs(props.date))
const propsMinDate = computed(() => dayjs(props.minDate))
const propsMaxDate = computed(() => dayjs(props.maxDate))
const months = ref(
propsDate.value
props.date
.locale('en')
.localeData()
.monthsShort()
@ -107,30 +102,28 @@ export default defineComponent({
cell.type = 'normal'
const index = i * 4 + j
const calTime = propsDate.value.startOf('year').month(index)
const calTime = props.date.startOf('year').month(index)
const calEndDate =
props.rangeState.endDate ||
propsMaxDate.value ||
(props.rangeState.selecting && propsMinDate.value)
props.maxDate ||
(props.rangeState.selecting && props.minDate)
cell.inRange =
(propsMinDate.value &&
calTime.isSameOrAfter(propsMinDate.value, 'month') &&
(props.minDate &&
calTime.isSameOrAfter(props.minDate, 'month') &&
calEndDate &&
calTime.isSameOrBefore(calEndDate, 'month')) ||
(propsMinDate.value &&
calTime.isSameOrBefore(propsMinDate.value, 'month') &&
(props.minDate &&
calTime.isSameOrBefore(props.minDate, 'month') &&
calEndDate &&
calTime.isSameOrAfter(calEndDate, 'month'))
if (propsMinDate.value?.isSameOrAfter(calEndDate)) {
if (props.minDate?.isSameOrAfter(calEndDate)) {
cell.start = calEndDate && calTime.isSame(calEndDate, 'month')
cell.end =
propsMinDate.value && calTime.isSame(propsMinDate.value, 'month')
cell.end = props.minDate && calTime.isSame(props.minDate, 'month')
} else {
cell.start =
propsMinDate.value && calTime.isSame(propsMinDate.value, 'month')
cell.start = props.minDate && calTime.isSame(props.minDate, 'month')
cell.end = calEndDate && calTime.isSame(calEndDate, 'month')
}
@ -149,7 +142,7 @@ export default defineComponent({
})
const getCellStyle = (cell) => {
const style = {} as any
const year = propsDate.value.year()
const year = props.date.year()
const today = new Date()
const month = cell.text
@ -200,7 +193,7 @@ export default defineComponent({
lastColumn.value = column
ctx.emit('changerange', {
selecting: true,
endDate: propsDate.value.startOf('year').month(row * 4 + column),
endDate: props.date.startOf('year').month(row * 4 + column),
})
}
}
@ -217,16 +210,16 @@ export default defineComponent({
const column = target.cellIndex
const row = target.parentNode.rowIndex
const month = row * 4 + column
const newDate = propsDate.value.startOf('year').month(month)
const newDate = props.date.startOf('year').month(month)
if (props.selectionMode === 'range') {
if (!props.rangeState.selecting) {
ctx.emit('pick', { minDate: newDate, maxDate: null })
ctx.emit('select', true)
} else {
if (newDate >= propsMinDate.value) {
ctx.emit('pick', { minDate: propsMinDate.value, maxDate: newDate })
if (newDate >= props.minDate) {
ctx.emit('pick', { minDate: props.minDate, maxDate: newDate })
} else {
ctx.emit('pick', { minDate: newDate, maxDate: propsMinDate.value })
ctx.emit('pick', { minDate: newDate, maxDate: props.minDate })
}
ctx.emit('select', false)
}