瀏覽代碼

improve where certain types live

Adam Shaw 5 年之前
父節點
當前提交
0f0c5e9156

+ 1 - 1
packages/common/src/common/TableDateCell.tsx

@@ -9,7 +9,7 @@ import { BaseComponent } from '../vdom-util'
 import { RenderHook } from './render-hook'
 import { buildNavLinkData } from './nav-link'
 import { DateProfile } from '../DateProfileGenerator'
-import { DayHeaderHookProps } from '../options'
+import { DayHeaderHookProps } from '../render-hook-misc'
 
 
 export interface TableDateCellProps {

+ 4 - 1
packages/common/src/datelib/env.ts

@@ -13,12 +13,15 @@ import { buildIsoString } from './formatting-utils'
 import { parse } from './parsing'
 import { isInt } from '../util/misc'
 
+
+export type WeekNumberCalculation = 'local' | 'ISO' | ((m: Date) => number)
+
 export interface DateEnvSettings {
   timeZone: string
   namedTimeZoneImpl?: NamedTimeZoneImplClass
   calendarSystem: string
   locale: Locale
-  weekNumberCalculation?: any
+  weekNumberCalculation?: WeekNumberCalculation
   firstDay?: any,
   weekText?: string,
   cmdFormatter?: CmdFormatterFunc

+ 6 - 2
packages/common/src/main.ts

@@ -140,12 +140,16 @@ export { ElementDragging } from './interactions/ElementDragging'
 export { formatDate, formatRange } from './formatting-api'
 
 export {
-  RAW_BASE_DEFAULTS, identity, Identity, DayHeaderHookProps,
-  SlotLaneHookProps, SlotLabelHookProps, AllDayHookProps,
+  DayHeaderHookProps, SlotLaneHookProps, SlotLabelHookProps, AllDayHookProps,
+} from './render-hook-misc'
+
+export {
+  RAW_BASE_DEFAULTS, identity, Identity,
   BaseOptionRefiners, RawBaseOptions, RefinedBaseOptions,
   CalendarOptionRefiners, RawCalendarOptions, RefinedCalendarOptions,
   ViewOptionRefiners, RawViewOptions, RefinedViewOptions
 } from './options'
+
 export { config } from './global-config'
 
 export { RecurringType, ParsedRecurring } from './structs/recurring-event'

+ 3 - 64
packages/common/src/options.ts

@@ -1,7 +1,8 @@
 import { createDuration, Duration } from './datelib/duration'
 import { mergeProps } from './util/object'
-import { ToolbarInput } from './toolbar-parse'
+import { ToolbarInput, CustomButtonInput, ButtonIconsInput, ButtonTextCompoundInput } from './toolbar-parse'
 import { createFormatter, FormatterInput } from './datelib/formatting'
+import { WeekNumberCalculation } from './datelib/env'
 import { parseFieldSpecs } from './util/misc'
 import { CssDimValue } from './scrollgrid/util'
 import { DateInput } from './datelib/env'
@@ -19,7 +20,7 @@ import { EventMeta } from './component/event-rendering'
 import { ClassNameGenerator, CustomContentGenerator, DidMountHandler, WillUnmountHandler } from './common/render-hook'
 import { NowIndicatorHookProps } from './common/NowIndicatorRoot'
 import { WeekNumberHookProps } from './common/WeekNumberRoot'
-import { DateMeta } from './component/date-rendering'
+import { SlotLaneHookProps, SlotLabelHookProps, AllDayHookProps, DayHeaderHookProps } from './render-hook-misc'
 import { DayCellHookProps } from './common/DayCellRoot'
 import { ViewRootHookProps } from './common/ViewRoot'
 
@@ -429,65 +430,3 @@ export type Identity<T = any> = (raw: T) => T
 export function identity<T>(raw: T): T {
   return raw
 }
-
-
-
-// random crap we need to put into other files
-// -------------------------------------------
-
-export interface SlotLaneHookProps extends Partial<DateMeta> { // TODO: move?
-  time?: Duration
-  date?: Date
-  view: ViewApi
-  // this interface is for date-specific slots AND time-general slots. make an OR?
-}
-
-export interface SlotLabelHookProps { // TODO: move?
-  time: Duration
-  date: Date
-  view: ViewApi
-  text: string
-}
-
-export interface AllDayHookProps {
-  text: string
-  view: ViewApi
-}
-
-export interface CustomButtonInput {
-  text: string
-  icon?: string
-  themeIcon?: string
-  bootstrapFontAwesome?: string,
-  click(element: HTMLElement): void
-}
-
-export interface ButtonIconsInput {
-  prev?: string
-  next?: string
-  prevYear?: string
-  nextYear?: string
-}
-
-export interface ButtonTextCompoundInput {
-  prev?: string
-  next?: string
-  prevYear?: string // derive these somehow?
-  nextYear?: string
-  today?: string
-  month?: string
-  week?: string
-  day?: string
-  [viewId: string]: string | undefined // needed b/c of other optional types ... make extendable???
-}
-
-export type WeekNumberCalculation = 'local' | 'ISO' | ((m: Date) => number)
-
-export interface DayHeaderHookProps extends DateMeta {
-  date: Date
-  view: ViewApi
-  text: string
-  [otherProp: string]: any
-}
-
-// TODO: do rtl/ltr

+ 29 - 0
packages/common/src/render-hook-misc.ts

@@ -0,0 +1,29 @@
+import { DateMeta } from './component/date-rendering'
+import { Duration } from './datelib/duration'
+import { ViewApi } from './ViewApi'
+
+export interface SlotLaneHookProps extends Partial<DateMeta> { // TODO: move?
+  time?: Duration
+  date?: Date
+  view: ViewApi
+  // this interface is for date-specific slots AND time-general slots. make an OR?
+}
+
+export interface SlotLabelHookProps { // TODO: move?
+  time: Duration
+  date: Date
+  view: ViewApi
+  text: string
+}
+
+export interface AllDayHookProps {
+  text: string
+  view: ViewApi
+}
+
+export interface DayHeaderHookProps extends DateMeta {
+  date: Date
+  view: ViewApi
+  text: string
+  [otherProp: string]: any
+}

+ 27 - 0
packages/common/src/toolbar-parse.ts

@@ -23,6 +23,33 @@ export interface ToolbarInput {
   end?: string
 }
 
+export interface CustomButtonInput {
+  text: string
+  icon?: string
+  themeIcon?: string
+  bootstrapFontAwesome?: string,
+  click(element: HTMLElement): void
+}
+
+export interface ButtonIconsInput {
+  prev?: string
+  next?: string
+  prevYear?: string
+  nextYear?: string
+}
+
+export interface ButtonTextCompoundInput {
+  prev?: string
+  next?: string
+  prevYear?: string // derive these somehow?
+  nextYear?: string
+  today?: string
+  month?: string
+  week?: string
+  day?: string
+  [viewId: string]: string | undefined // needed b/c of other optional types ... make extendable???
+}
+
 
 export function parseToolbars(
   calendarOptions: RefinedCalendarOptions,