Implement changing year number. Added scroll support to numeric element.
This commit is contained in:
parent
271a41dd23
commit
47976eef88
@ -6,53 +6,20 @@ import {
|
|||||||
getLocaleWeekendDays,
|
getLocaleWeekendDays,
|
||||||
} from '@/utils/date'
|
} from '@/utils/date'
|
||||||
|
|
||||||
/**
|
|
||||||
* Calendar configuration can be overridden via window.calendarConfig:
|
|
||||||
*
|
|
||||||
* window.calendarConfig = {
|
|
||||||
* firstDay: 0, // 0=Sunday, 1=Monday, etc. (default: 1)
|
|
||||||
* firstDay: 'auto', // Use locale detection
|
|
||||||
* weekendDays: [true, false, false, false, false, false, true], // Custom weekend
|
|
||||||
* weekendDays: 'auto' // Use locale detection (default)
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
|
||||||
const MIN_YEAR = 1900
|
const MIN_YEAR = 1900
|
||||||
const MAX_YEAR = 2100
|
const MAX_YEAR = 2100
|
||||||
|
|
||||||
// Helper function to determine first day with config override support
|
|
||||||
function getConfiguredFirstDay() {
|
|
||||||
// Check for environment variable or global config
|
|
||||||
const configOverride = window?.calendarConfig?.firstDay
|
|
||||||
if (configOverride !== undefined) {
|
|
||||||
return configOverride === 'auto' ? getLocaleFirstDay() : Number(configOverride)
|
|
||||||
}
|
|
||||||
// Default to Monday (1) instead of locale
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function to determine weekend days with config override support
|
|
||||||
function getConfiguredWeekendDays() {
|
|
||||||
// Check for environment variable or global config
|
|
||||||
const configOverride = window?.calendarConfig?.weekendDays
|
|
||||||
if (configOverride !== undefined) {
|
|
||||||
return configOverride === 'auto' ? getLocaleWeekendDays() : configOverride
|
|
||||||
}
|
|
||||||
// Default to locale-based weekend days
|
|
||||||
return getLocaleWeekendDays()
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useCalendarStore = defineStore('calendar', {
|
export const useCalendarStore = defineStore('calendar', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
today: toLocalString(new Date()),
|
today: toLocalString(new Date()),
|
||||||
now: new Date(),
|
now: new Date(),
|
||||||
events: new Map(), // Map of date strings to arrays of events
|
events: new Map(), // Map of date strings to arrays of events
|
||||||
weekend: getConfiguredWeekendDays(),
|
weekend: getLocaleWeekendDays(),
|
||||||
config: {
|
config: {
|
||||||
select_days: 1000,
|
select_days: 1000,
|
||||||
min_year: MIN_YEAR,
|
min_year: MIN_YEAR,
|
||||||
max_year: MAX_YEAR,
|
max_year: MAX_YEAR,
|
||||||
first_day: getConfiguredFirstDay(),
|
first_day: getLocaleFirstDay(),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user