Adam Shaw 7 lat temu
rodzic
commit
57a2183beb

+ 7 - 7
src/Calendar.ts

@@ -813,9 +813,9 @@ export default class Calendar {
 
 
   // this public method receives start/end dates in any format, with any timezone
-  select(zonedStartInput: DateInput, zonedEndInput?: DateInput) {
+  select(zonedStartInput: DateInput, zonedEndInput?: DateInput, otherProps: any = {}) {
     this.view.select(
-      this.buildSelectFootprint.apply(this, arguments)
+      this.buildSelectFootprint.call(this, zonedStartInput, zonedEndInput, otherProps)
     )
   }
 
@@ -828,7 +828,7 @@ export default class Calendar {
 
 
   // Given arguments to the select method in the API, returns a span (unzoned start/end and other info)
-  buildSelectFootprint(zonedStartInput: DateInput, zonedEndInput?: DateInput): ComponentFootprint {
+  buildSelectFootprint(zonedStartInput: DateInput, zonedEndInput?: DateInput, otherProps?): ComponentFootprint {
     let startMeta = this.dateEnv.createMarkerMeta(zonedStartInput)
     let start = startMeta.marker
     let end
@@ -843,7 +843,7 @@ export default class Calendar {
 
     return new ComponentFootprint(
       new UnzonedRange(start, end),
-      startMeta.isTimeUnspecified
+      otherProps.isAllDay != null ? otherProps.isAllDay : startMeta.isTimeUnspecified
     )
   }
 
@@ -884,15 +884,15 @@ export default class Calendar {
     this.defaultTimedEventDuration = createDuration(this.opt('defaultTimedEventDuration'))
 
     this.optionsManager.watch('buildDateEnv', [
-      '?locale', '?timezone',
-      '?firstDay', '?weekNumberCalculation'
+      '?locale', '?timezone', '?firstDay', '?weekNumberCalculation', '?weekLabel'
     ], (opts) => {
       this.dateEnv = new DateEnv({
         calendarSystem: 'gregory',
         timeZone: opts.timezone,
         locale: getLocale(opts.locale),
         weekNumberCalculation: opts.weekNumberCalculation,
-        firstDay: opts.firstDay
+        firstDay: opts.firstDay,
+        weekLabel: opts.weekLabel
       })
     })
   }

+ 1 - 1
src/basic/BasicView.ts

@@ -283,7 +283,7 @@ function makeDayGridSubclass(SuperClass) {
         return '' +
           '<th class="fc-week-number ' + view.calendar.theme.getClass('widgetHeader') + '" ' + view.weekNumberStyleAttr() + '>' +
             '<span>' + // needed for matchCellWidths
-              htmlEscape(this.opt('weekNumberTitle')) +
+              htmlEscape(this.opt('weekLabel')) +
             '</span>' +
           '</th>'
       }

+ 5 - 1
src/datelib/env.ts

@@ -18,7 +18,8 @@ export interface DateEnvSettings {
   calendarSystem: string
   locale: Locale
   weekNumberCalculation?: any
-  firstDay?: any
+  firstDay?: any,
+  weekLabel: string
 }
 
 export type DateInput = Date | string | number | number[]
@@ -35,6 +36,7 @@ export class DateEnv {
   weekDow: number
   weekDoy: number
   weekNumberFunc: any
+  weekLabel: string // DON'T LIKE how options are confused with local
 
 
   constructor(settings: DateEnvSettings) {
@@ -62,6 +64,8 @@ export class DateEnv {
     if (typeof settings.weekNumberCalculation === 'function') {
       this.weekNumberFunc = settings.weekNumberCalculation
     }
+
+    this.weekLabel = settings.weekLabel != null ? settings.weekLabel : settings.locale.options.weekLabel
   }
 
 

+ 4 - 3
src/datelib/formatting-native.ts

@@ -72,6 +72,7 @@ export class NativeFormatter implements DateFormatter {
     if (this.standardDatePropCnt === 0 && extendedSettings.week) {
       return formatWeekNumber(
         context.computeWeekNumber(date.marker),
+        context.weekLabel,
         context.locale,
         extendedSettings.week
       )
@@ -186,13 +187,13 @@ export class NativeFormatter implements DateFormatter {
 }
 
 
-function formatWeekNumber(num: number, locale: Locale, display?: 'numeric' | 'narrow' | 'short'): string {
+function formatWeekNumber(num: number, weekLabel: string, locale: Locale, display?: 'numeric' | 'narrow' | 'short'): string {
   let parts = []
 
   if (display === 'narrow') {
-    parts.push(locale.options.weekHeader)
+    parts.push(weekLabel)
   } else if (display === 'short') {
-    parts.push(locale.options.weekHeader, ' ')
+    parts.push(weekLabel, ' ')
   }
   // otherwise, considered 'numeric'
 

+ 1 - 0
src/datelib/formatting.ts

@@ -35,6 +35,7 @@ export interface DateFormattingContext {
   locale: Locale,
   calendarSystem: CalendarSystem
   computeWeekNumber: (d: DateMarker) => number
+  weekLabel: string
 }
 
 export interface DateFormatter {

+ 1 - 1
src/datelib/locale.ts

@@ -28,7 +28,7 @@ const RAW_EN_LOCALE = {
     day: 'day',
     list: 'list',
   },
-  weekHeader: 'Wk',
+  weekLabel: 'W',
   allDayText: 'all-day',
   eventLimitText: 'more',
   noEventsMessage: 'No events to display'

+ 0 - 2
src/options.ts

@@ -21,8 +21,6 @@ export const globalDefaults = {
   },
   weekends: true,
   weekNumbers: false,
-
-  weekNumberTitle: 'W',
   weekNumberCalculation: 'local',
 
   // editable: false,

+ 1 - 1
src/types/input-types.ts

@@ -191,7 +191,7 @@ export interface OptionsInputBase {
   monthNamesShort?: string[]
   dayNames?: string[]
   dayNamesShort?: string[]
-  weekNumberTitle?: string
+  weekLabel?: string
   displayEventTime?: boolean
   displayEventEnd?: boolean
   eventLimitText?: string | ((eventCnt: number) => string)