@visactor/vtable-calendar 1.14.4-alpha.4 → 1.14.4-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,6 +33,7 @@ class Calendar extends vtable_1.EventTarget {
33
33
  const tableInstance = new vtable_1.ListTable(option);
34
34
  this.table = tableInstance, tableInstance.addEventListener("scroll", (() => {
35
35
  const record = this.getYearAndMonth();
36
+ if (!record) return;
36
37
  if (!record.Sun) return void this._updateMonthCustomStyle(this.startDate.getFullYear(), this.startDate.getMonth());
37
38
  const firstDateInWeek = new Date(record.year, record.month, record.Sun), lastDateInNextWeek = (0,
38
39
  date_fns_1.add)(firstDateInWeek, {
@@ -1 +1 @@
1
- {"version":3,"sources":["month-calendar.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAE1D,2CAA+E;AAE/E,uCAA6E;AAC7E,mCAAmD;AAEnD,uDAAyD;AAEzD,4DAA6D;AAM7D,uCAAmD;AAEnD,6CAA2C;AAgB3C,MAAa,QAAS,SAAQ,oBAAW;IAoBvC,YAAY,SAAsB,EAAE,OAAoC;QACtE,KAAK,EAAE,CAAC;QAJV,WAAM,GAAW,CAAC,CAAC;QAKjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;QAC7B,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAEpE,IAAI,CAAC,WAAW,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,IAAI,IAAI,EAAE,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC;QACjC,IAAI,SAAS,IAAI,OAAO,EAAE;YACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;YAC3B,IAAI,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AW,EAAE,GAAW;QACnD,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAClE,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAvTD,4BAuTC","file":"month-calendar.js","sourcesContent":["import { ListTable, EventTarget } from '@visactor/vtable';\nimport type { DateRecord, DateRecordKeys } from './date-util';\nimport { defaultDayTitles, getRecords, getStartAndEndDate } from './date-util';\nimport { bindDebugTool } from '../../vtable/src/scenegraph/debug-tool';\nimport { add, differenceInDays, previousSunday, startOfDay } from 'date-fns';\nimport { getMonthCustomStyleRange } from './style';\nimport type { TYPES, ListTableConstructorOptions } from '@visactor/vtable';\nimport { createTableOption } from './table/table-option';\nimport type { ICustomEvent, ICustomEventOptions, IEventData } from './custom/custom-handler';\nimport { CustomEventHandler } from './custom/custom-handler';\nimport type {\n CalendarEventHandlersEventArgumentMap,\n CalendarEventHandlersReturnMap,\n CalendarEventListener\n} from './event/type';\nimport { CALENDAR_EVENT_TYPE } from './event/type';\nimport type { EventListenerId } from '@visactor/vtable/es/ts-types';\nimport { isArray } from '@visactor/vutils';\n\nexport interface CalendarConstructorOptions {\n startDate?: Date;\n endDate?: Date;\n currentDate?: Date;\n rangeDays?: number;\n\n dayTitles?: [string, string, string, string, string, string, string];\n\n tableOptions?: ListTableConstructorOptions;\n\n customEvents?: ICustomEvent[];\n customEventOptions?: ICustomEventOptions;\n}\n\nexport class Calendar extends EventTarget {\n container: HTMLElement;\n options: CalendarConstructorOptions;\n table: ListTable;\n startDate: Date;\n endDate: Date;\n currentDate: Date;\n rangeDays: number;\n tableStartDate: Date;\n records: DateRecord[];\n currentMonthCellRanges: { range: TYPES.CellRange }[];\n currentMonth: number;\n currentYear: number;\n\n titleClickHandler: () => void;\n\n maxCol: number;\n minCol: number = 0;\n customHandler: CustomEventHandler;\n\n constructor(container: HTMLElement, options?: CalendarConstructorOptions) {\n super();\n this.container = container;\n this.options = options ?? {};\n const { startDate, endDate, currentDate, rangeDays } = this.options;\n\n this.currentDate = currentDate ?? new Date();\n this.rangeDays = rangeDays ?? 90;\n if (startDate && endDate) {\n this.startDate = startDate;\n this.endDate = endDate;\n } else {\n const { startDate: computedStartDate, endDate: computedEndDate } = getStartAndEndDate(\n this.currentDate,\n this.rangeDays\n );\n this.startDate = startDate ?? computedStartDate;\n this.endDate = endDate ?? computedEndDate;\n }\n this.tableStartDate = this.startDate.getDay() === 0 ? this.startDate : previousSunday(this.startDate);\n\n this.customHandler = new CustomEventHandler(this, options?.customEventOptions);\n\n this._createTable();\n\n this._bindEvent();\n\n if (this.options.customEvents) {\n this.addCustomEvents(this.options.customEvents);\n }\n }\n\n _createTable() {\n const { dayTitles } = this.options;\n\n const records = getRecords(this.startDate, this.endDate);\n this.records = records;\n\n const week = (dayTitles ?? defaultDayTitles) as DateRecordKeys[];\n this.maxCol = week.length - 1;\n const option = createTableOption(week, this.currentDate, {\n tableOptions: this.options.tableOptions,\n containerWidth: this.container.clientWidth,\n containerHeight: this.container.clientHeight\n });\n option.records = records;\n option.container = this.container;\n (option as any)._calendar = this;\n\n const tableInstance = new ListTable(option);\n this.table = tableInstance;\n\n tableInstance.addEventListener('scroll', () => {\n const record: DateRecord = this.getYearAndMonth();\n if (!record.Sun) {\n // top\n this._updateMonthCustomStyle(this.startDate.getFullYear(), this.startDate.getMonth());\n return;\n }\n const firstDateInWeek = new Date(record.year, record.month, record.Sun);\n const lastDateInNextWeek = add(firstDateInWeek, {\n days: 13\n });\n this._updateMonthCustomStyle(lastDateInNextWeek.getFullYear(), lastDateInNextWeek.getMonth());\n });\n\n tableInstance.addEventListener('scroll_vertical_end', () => {\n this._updateMonthCustomStyle(this.endDate.getFullYear(), this.endDate.getMonth());\n });\n\n this.jumpToCurrentMonth();\n\n // bindDebugTool(tableInstance.scenegraph.stage as any, {\n // customGrapicKeys: ['col', 'row']\n // });\n }\n\n getYearAndMonth() {\n const x = this.table.tableX + 10; // buffer\n const y = this.table.tableY + this.table.getFrozenRowsHeight() + 10; // buffer\n const topRow = this.table.getCellAtRelativePosition(x, y);\n const { row } = topRow;\n const record = this.table.getCellRawRecord(0, row);\n return record;\n }\n\n jumpToDate(date: Date, animation?: boolean | TYPES.ITableAnimationOption) {\n date = startOfDay(date);\n const dataIndex = Math.floor((differenceInDays(date, this.tableStartDate) + 1) / 7);\n this.table.scrollToCell(\n {\n col: 0,\n row: dataIndex + 1\n },\n animation\n );\n\n this._updateMonthCustomStyle(date.getFullYear(), date.getMonth());\n }\n\n jumpToCurrentMonth(animation?: boolean | TYPES.ITableAnimationOption) {\n // scroll to current month\n const topDate = new Date(this.currentDate.getTime());\n topDate.setDate(1);\n this.jumpToDate(topDate, animation);\n }\n\n _updateMonthCustomStyle(year: number, month: number) {\n if (this.currentMonth === month && this.currentYear === year) {\n return;\n }\n\n // clear current\n this.currentMonthCellRanges?.forEach(range => {\n this.table.arrangeCustomCellStyle(range, null);\n });\n\n this.currentMonth = month;\n this.currentYear = year;\n this.currentMonthCellRanges = getMonthCustomStyleRange(year, month, this.tableStartDate, this.records);\n this.currentMonthCellRanges.forEach(range => {\n this.table.arrangeCustomCellStyle(range, 'current-month');\n });\n }\n\n // @ts-ignore\n fireListeners<TYPE extends keyof CalendarEventHandlersEventArgumentMap>(\n type: TYPE,\n event: CalendarEventHandlersEventArgumentMap[TYPE]\n ): CalendarEventHandlersReturnMap[TYPE][] {\n // 调用父类的方法\n return super.fireListeners(type as any, event as any);\n }\n\n // @ts-ignore\n on<TYPE extends keyof CalendarEventHandlersEventArgumentMap>(\n type: TYPE,\n listener: CalendarEventListener<TYPE>\n ): EventListenerId {\n // 调用父类的方法\n return super.on(type as any, listener as any);\n }\n\n _bindEvent() {\n // click title jump to current month\n const titleComponent = this.table.internalProps.title.getComponentGraphic();\n titleComponent.setAttributes({\n cursor: 'pointer',\n // hack for cursor\n childrenPickable: false\n });\n this.titleClickHandler = (() => {\n this.jumpToCurrentMonth({\n duration: 500\n });\n }).bind(this);\n titleComponent.addEventListener('click', this.titleClickHandler);\n\n this.table.on('click_cell', e => {\n const { target } = e;\n if ((target as any)._role === 'calendar-custom-event') {\n this.fireListeners(CALENDAR_EVENT_TYPE.CALENDAR_CUSTOM_EVENT_CLICK, {\n tableEvent: e,\n date: this.getCellDate(e.col, e.row),\n customEvent: (target as any)._customEvent\n });\n } else if (!this.table.isHeader(e.col, e.row)) {\n this.fireListeners(CALENDAR_EVENT_TYPE.CALENDAR_DATE_CLICK, {\n tableEvent: e,\n date: this.getCellDate(e.col, e.row)\n });\n }\n });\n\n this.table.on('selected_cell', e => {\n if (!this.table.isHeader(e.col, e.row)) {\n this.fireListeners(CALENDAR_EVENT_TYPE.SELECTED_DATE, {\n tableEvent: e,\n date: this.getCellDate(e.col, e.row)\n });\n }\n });\n\n this.table.on('selected_clear', () => {\n this.fireListeners(CALENDAR_EVENT_TYPE.SELECTED_DATE_CLEAR, undefined);\n });\n\n this.table.on('drag_select_end', e => {\n const { cells } = e;\n const dates: Date[] = [];\n cells.map(row => {\n row.map(cell => {\n if (!this.table.isHeader(cell.col, cell.row)) {\n dates.push(this.getCellDate(cell.col, cell.row));\n }\n });\n });\n this.fireListeners(CALENDAR_EVENT_TYPE.DRAG_SELECT_DATE_END, {\n tableEvent: e,\n dates\n });\n });\n }\n\n release() {\n this.table.release();\n }\n\n getCellLocation(date: Date) {\n date = startOfDay(date);\n const dataIndex = Math.floor((differenceInDays(date, this.tableStartDate) + 1) / 7);\n const row = dataIndex + 1;\n const col = date.getDay();\n\n return {\n row,\n col\n };\n }\n\n getCellDate(col: number, row: number) {\n const startDate = add(this.tableStartDate, {\n days: (row - 1) * 7 + col\n });\n return startDate;\n }\n\n get selectedDate(): { date: Date; col: number; row: number }[] {\n const cells = this.table.getSelectedCellInfos();\n if (!isArray(cells) || cells.length === 0) {\n return [];\n }\n const dates: { date: Date; col: number; row: number }[] = [];\n cells.map(row => {\n row.map(cell => {\n if (!this.table.isHeader(cell.col, cell.row)) {\n dates.push({\n date: this.getCellDate(cell.col, cell.row),\n col: cell.col,\n row: cell.row\n });\n }\n });\n });\n\n return dates;\n }\n\n addCustomEvent(event: ICustomEvent) {\n this.customHandler.addEvent(event);\n this.table.scenegraph.updateNextFrame();\n }\n\n removeCustomEvent(id: string) {\n this.customHandler.removeEvents([id]);\n this.table.scenegraph.updateNextFrame();\n }\n\n updateCustomEvent(event: ICustomEvent) {\n this.customHandler.updateEvents([event]);\n this.table.scenegraph.updateNextFrame();\n }\n\n addCustomEvents(events: ICustomEvent[]) {\n this.customHandler.addEvents(events);\n this.table.scenegraph.updateNextFrame();\n }\n\n removeCustomEvents(ids: string[]) {\n this.customHandler.removeEvents(ids);\n this.table.scenegraph.updateNextFrame();\n }\n\n updateCustomEvents(events: ICustomEvent[]) {\n this.customHandler.updateEvents(events);\n this.table.scenegraph.updateNextFrame();\n }\n\n getCellCustomEventByDate(date: Date) {\n const location = this.getCellLocation(date);\n return this.getCellCustomEventByLocation(location.col, location.row);\n }\n\n getCellCustomEventByLocation(col: number, row: number) {\n const cellEvent = this.customHandler.getCellCustomEvent(col, row);\n const events: IEventData[] = [];\n cellEvent?.keys.forEach(key => {\n events.push(cellEvent.values[key]);\n });\n return events;\n }\n}\n"]}
1
+ {"version":3,"sources":["month-calendar.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAE1D,2CAA+E;AAE/E,uCAA6E;AAC7E,mCAAmD;AAEnD,uDAAyD;AAEzD,4DAA6D;AAM7D,uCAAmD;AAEnD,6CAA2C;AAgB3C,MAAa,QAAS,SAAQ,oBAAW;IAoBvC,YAAY,SAAsB,EAAE,OAAoC;QACtE,KA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eAAe,EAAE,CAAC;IAC1C,CAAC;IAED,kBAAkB,CAAC,GAAa;QAC9B,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;IAC1C,CAAC;IAED,kBAAkB,CAAC,MAAsB;QACvC,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;IAC1C,CAAC;IAED,wBAAwB,CAAC,IAAU;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,4BAA4B,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvE,CAAC;IAED,4BAA4B,CAAC,GAAW,EAAE,GAAW;QACnD,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAClE,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA1TD,4BA0TC","file":"month-calendar.js","sourcesContent":["import { ListTable, EventTarget } from '@visactor/vtable';\nimport type { DateRecord, DateRecordKeys } from './date-util';\nimport { defaultDayTitles, getRecords, getStartAndEndDate } from './date-util';\nimport { bindDebugTool } from '../../vtable/src/scenegraph/debug-tool';\nimport { add, differenceInDays, previousSunday, startOfDay } from 'date-fns';\nimport { getMonthCustomStyleRange } from './style';\nimport type { TYPES, ListTableConstructorOptions } from '@visactor/vtable';\nimport { createTableOption } from './table/table-option';\nimport type { ICustomEvent, ICustomEventOptions, IEventData } from './custom/custom-handler';\nimport { CustomEventHandler } from './custom/custom-handler';\nimport type {\n CalendarEventHandlersEventArgumentMap,\n CalendarEventHandlersReturnMap,\n CalendarEventListener\n} from './event/type';\nimport { CALENDAR_EVENT_TYPE } from './event/type';\nimport type { EventListenerId } from '@visactor/vtable/es/ts-types';\nimport { isArray } from '@visactor/vutils';\n\nexport interface CalendarConstructorOptions {\n startDate?: Date;\n endDate?: Date;\n currentDate?: Date;\n rangeDays?: number;\n\n dayTitles?: [string, string, string, string, string, string, string];\n\n tableOptions?: ListTableConstructorOptions;\n\n customEvents?: ICustomEvent[];\n customEventOptions?: ICustomEventOptions;\n}\n\nexport class Calendar extends EventTarget {\n container: HTMLElement;\n options: CalendarConstructorOptions;\n table: ListTable;\n startDate: Date;\n endDate: Date;\n currentDate: Date;\n rangeDays: number;\n tableStartDate: Date;\n records: DateRecord[];\n currentMonthCellRanges: { range: TYPES.CellRange }[];\n currentMonth: number;\n currentYear: number;\n\n titleClickHandler: () => void;\n\n maxCol: number;\n minCol: number = 0;\n customHandler: CustomEventHandler;\n\n constructor(container: HTMLElement, options?: CalendarConstructorOptions) {\n super();\n this.container = container;\n this.options = options ?? {};\n const { startDate, endDate, currentDate, rangeDays } = this.options;\n\n this.currentDate = currentDate ?? new Date();\n this.rangeDays = rangeDays ?? 90;\n if (startDate && endDate) {\n this.startDate = startDate;\n this.endDate = endDate;\n } else {\n const { startDate: computedStartDate, endDate: computedEndDate } = getStartAndEndDate(\n this.currentDate,\n this.rangeDays\n );\n this.startDate = startDate ?? computedStartDate;\n this.endDate = endDate ?? computedEndDate;\n }\n this.tableStartDate = this.startDate.getDay() === 0 ? this.startDate : previousSunday(this.startDate);\n\n this.customHandler = new CustomEventHandler(this, options?.customEventOptions);\n\n this._createTable();\n\n this._bindEvent();\n\n if (this.options.customEvents) {\n this.addCustomEvents(this.options.customEvents);\n }\n }\n\n _createTable() {\n const { dayTitles } = this.options;\n\n const records = getRecords(this.startDate, this.endDate);\n this.records = records;\n\n const week = (dayTitles ?? defaultDayTitles) as DateRecordKeys[];\n this.maxCol = week.length - 1;\n const option = createTableOption(week, this.currentDate, {\n tableOptions: this.options.tableOptions,\n containerWidth: this.container.clientWidth,\n containerHeight: this.container.clientHeight\n });\n option.records = records;\n option.container = this.container;\n (option as any)._calendar = this;\n\n const tableInstance = new ListTable(option);\n this.table = tableInstance;\n\n tableInstance.addEventListener('scroll', () => {\n const record: DateRecord = this.getYearAndMonth();\n if (!record) {\n return;\n }\n if (!record.Sun) {\n // top\n this._updateMonthCustomStyle(this.startDate.getFullYear(), this.startDate.getMonth());\n return;\n }\n const firstDateInWeek = new Date(record.year, record.month, record.Sun);\n const lastDateInNextWeek = add(firstDateInWeek, {\n days: 13\n });\n this._updateMonthCustomStyle(lastDateInNextWeek.getFullYear(), lastDateInNextWeek.getMonth());\n });\n\n tableInstance.addEventListener('scroll_vertical_end', () => {\n this._updateMonthCustomStyle(this.endDate.getFullYear(), this.endDate.getMonth());\n });\n\n this.jumpToCurrentMonth();\n\n // bindDebugTool(tableInstance.scenegraph.stage as any, {\n // customGrapicKeys: ['col', 'row']\n // });\n }\n\n getYearAndMonth() {\n const x = this.table.tableX + 10; // buffer\n const y = this.table.tableY + this.table.getFrozenRowsHeight() + 10; // buffer\n const topRow = this.table.getCellAtRelativePosition(x, y);\n const { row } = topRow;\n const record = this.table.getCellRawRecord(0, row);\n return record;\n }\n\n jumpToDate(date: Date, animation?: boolean | TYPES.ITableAnimationOption) {\n date = startOfDay(date);\n const dataIndex = Math.floor((differenceInDays(date, this.tableStartDate) + 1) / 7);\n this.table.scrollToCell(\n {\n col: 0,\n row: dataIndex + 1\n },\n animation\n );\n\n this._updateMonthCustomStyle(date.getFullYear(), date.getMonth());\n }\n\n jumpToCurrentMonth(animation?: boolean | TYPES.ITableAnimationOption) {\n // scroll to current month\n const topDate = new Date(this.currentDate.getTime());\n topDate.setDate(1);\n this.jumpToDate(topDate, animation);\n }\n\n _updateMonthCustomStyle(year: number, month: number) {\n if (this.currentMonth === month && this.currentYear === year) {\n return;\n }\n\n // clear current\n this.currentMonthCellRanges?.forEach(range => {\n this.table.arrangeCustomCellStyle(range, null);\n });\n\n this.currentMonth = month;\n this.currentYear = year;\n this.currentMonthCellRanges = getMonthCustomStyleRange(year, month, this.tableStartDate, this.records);\n this.currentMonthCellRanges.forEach(range => {\n this.table.arrangeCustomCellStyle(range, 'current-month');\n });\n }\n\n // @ts-ignore\n fireListeners<TYPE extends keyof CalendarEventHandlersEventArgumentMap>(\n type: TYPE,\n event: CalendarEventHandlersEventArgumentMap[TYPE]\n ): CalendarEventHandlersReturnMap[TYPE][] {\n // 调用父类的方法\n return super.fireListeners(type as any, event as any);\n }\n\n // @ts-ignore\n on<TYPE extends keyof CalendarEventHandlersEventArgumentMap>(\n type: TYPE,\n listener: CalendarEventListener<TYPE>\n ): EventListenerId {\n // 调用父类的方法\n return super.on(type as any, listener as any);\n }\n\n _bindEvent() {\n // click title jump to current month\n const titleComponent = this.table.internalProps.title.getComponentGraphic();\n titleComponent.setAttributes({\n cursor: 'pointer',\n // hack for cursor\n childrenPickable: false\n });\n this.titleClickHandler = (() => {\n this.jumpToCurrentMonth({\n duration: 500\n });\n }).bind(this);\n titleComponent.addEventListener('click', this.titleClickHandler);\n\n this.table.on('click_cell', e => {\n const { target } = e;\n if ((target as any)._role === 'calendar-custom-event') {\n this.fireListeners(CALENDAR_EVENT_TYPE.CALENDAR_CUSTOM_EVENT_CLICK, {\n tableEvent: e,\n date: this.getCellDate(e.col, e.row),\n customEvent: (target as any)._customEvent\n });\n } else if (!this.table.isHeader(e.col, e.row)) {\n this.fireListeners(CALENDAR_EVENT_TYPE.CALENDAR_DATE_CLICK, {\n tableEvent: e,\n date: this.getCellDate(e.col, e.row)\n });\n }\n });\n\n this.table.on('selected_cell', e => {\n if (!this.table.isHeader(e.col, e.row)) {\n this.fireListeners(CALENDAR_EVENT_TYPE.SELECTED_DATE, {\n tableEvent: e,\n date: this.getCellDate(e.col, e.row)\n });\n }\n });\n\n this.table.on('selected_clear', () => {\n this.fireListeners(CALENDAR_EVENT_TYPE.SELECTED_DATE_CLEAR, undefined);\n });\n\n this.table.on('drag_select_end', e => {\n const { cells } = e;\n const dates: Date[] = [];\n cells.map(row => {\n row.map(cell => {\n if (!this.table.isHeader(cell.col, cell.row)) {\n dates.push(this.getCellDate(cell.col, cell.row));\n }\n });\n });\n this.fireListeners(CALENDAR_EVENT_TYPE.DRAG_SELECT_DATE_END, {\n tableEvent: e,\n dates\n });\n });\n }\n\n release() {\n this.table.release();\n }\n\n getCellLocation(date: Date) {\n date = startOfDay(date);\n const dataIndex = Math.floor((differenceInDays(date, this.tableStartDate) + 1) / 7);\n const row = dataIndex + 1;\n const col = date.getDay();\n\n return {\n row,\n col\n };\n }\n\n getCellDate(col: number, row: number) {\n const startDate = add(this.tableStartDate, {\n days: (row - 1) * 7 + col\n });\n return startDate;\n }\n\n get selectedDate(): { date: Date; col: number; row: number }[] {\n const cells = this.table.getSelectedCellInfos();\n if (!isArray(cells) || cells.length === 0) {\n return [];\n }\n const dates: { date: Date; col: number; row: number }[] = [];\n cells.map(row => {\n row.map(cell => {\n if (!this.table.isHeader(cell.col, cell.row)) {\n dates.push({\n date: this.getCellDate(cell.col, cell.row),\n col: cell.col,\n row: cell.row\n });\n }\n });\n });\n\n return dates;\n }\n\n addCustomEvent(event: ICustomEvent) {\n this.customHandler.addEvent(event);\n this.table.scenegraph.updateNextFrame();\n }\n\n removeCustomEvent(id: string) {\n this.customHandler.removeEvents([id]);\n this.table.scenegraph.updateNextFrame();\n }\n\n updateCustomEvent(event: ICustomEvent) {\n this.customHandler.updateEvents([event]);\n this.table.scenegraph.updateNextFrame();\n }\n\n addCustomEvents(events: ICustomEvent[]) {\n this.customHandler.addEvents(events);\n this.table.scenegraph.updateNextFrame();\n }\n\n removeCustomEvents(ids: string[]) {\n this.customHandler.removeEvents(ids);\n this.table.scenegraph.updateNextFrame();\n }\n\n updateCustomEvents(events: ICustomEvent[]) {\n this.customHandler.updateEvents(events);\n this.table.scenegraph.updateNextFrame();\n }\n\n getCellCustomEventByDate(date: Date) {\n const location = this.getCellLocation(date);\n return this.getCellCustomEventByLocation(location.col, location.row);\n }\n\n getCellCustomEventByLocation(col: number, row: number) {\n const cellEvent = this.customHandler.getCellCustomEvent(col, row);\n const events: IEventData[] = [];\n cellEvent?.keys.forEach(key => {\n events.push(cellEvent.values[key]);\n });\n return events;\n }\n}\n"]}
@@ -4,24 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.createTableOption = void 0;
6
6
 
7
- const vtable_1 = require("@visactor/vtable"), date_util_1 = require("../date-util"), custom_layout_1 = require("../custom/custom-layout"), vutils_1 = require("@visactor/vutils");
7
+ const vtable_1 = require("@visactor/vtable"), date_util_1 = require("../date-util"), custom_layout_1 = require("../custom/custom-layout"), vutils_1 = require("@visactor/vutils"), date_fns_1 = require("date-fns");
8
8
 
9
9
  function createTableOption(week, currentDate, config) {
10
10
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
11
- const columns = week.map(((item, index) => ({
12
- field: date_util_1.defaultDayTitles[index],
13
- title: item,
14
- fieldFormat: record => {
15
- if (record.year === currentDate.getFullYear() && record.month === currentDate.getMonth() && record[item] === currentDate.getDate()) return `${record[item]}\nToday`;
16
- if (1 === record[item]) {
17
- const monthIndex = "Sun" === item ? record.month : record.month + 1, mouthStr = (0,
18
- date_util_1.getMonthString)(monthIndex);
19
- return `${record[item]}\n${mouthStr}`;
20
- }
21
- return record[item];
22
- },
23
- customLayout: custom_layout_1.calendarCustomLayout
24
- }))), rowHeight = Math.floor((config.containerHeight - ((null !== (_d = null === (_c = null === (_b = null === (_a = config.tableOptions) || void 0 === _a ? void 0 : _a.title) || void 0 === _b ? void 0 : _b.textStyle) || void 0 === _c ? void 0 : _c.fontSize) && void 0 !== _d ? _d : 20) + (null !== (_h = null === (_g = null === (_f = null === (_e = config.tableOptions) || void 0 === _e ? void 0 : _e.title) || void 0 === _f ? void 0 : _f.subtextStyle) || void 0 === _g ? void 0 : _g.fontSize) && void 0 !== _h ? _h : 16) + 1) - (null !== (_k = null === (_j = config.tableOptions) || void 0 === _j ? void 0 : _j.defaultHeaderRowHeight) && void 0 !== _k ? _k : 40)) / 5);
11
+ const columns = week.map(((item, index) => {
12
+ var _a, _b;
13
+ return {
14
+ field: date_util_1.defaultDayTitles[index],
15
+ title: item,
16
+ fieldFormat: record => {
17
+ if ((0, date_fns_1.isSameDay)((0, date_fns_1.addDays)(new Date(record.year, record.month, record.Sun), index), currentDate)) return `${record[item]}\nToday`;
18
+ if (1 === record[item]) {
19
+ const monthIndex = "Sun" === item ? record.month : record.month + 1, mouthStr = (0,
20
+ date_util_1.getMonthString)(monthIndex);
21
+ return `${record[item]}\n${mouthStr}`;
22
+ }
23
+ return record[item];
24
+ },
25
+ customLayout: null !== (_b = null === (_a = config.tableOptions) || void 0 === _a ? void 0 : _a.customLayout) && void 0 !== _b ? _b : custom_layout_1.calendarCustomLayout
26
+ };
27
+ })), rowHeight = Math.floor((config.containerHeight - ((null !== (_d = null === (_c = null === (_b = null === (_a = config.tableOptions) || void 0 === _a ? void 0 : _a.title) || void 0 === _b ? void 0 : _b.textStyle) || void 0 === _c ? void 0 : _c.fontSize) && void 0 !== _d ? _d : 20) + (null !== (_h = null === (_g = null === (_f = null === (_e = config.tableOptions) || void 0 === _e ? void 0 : _e.title) || void 0 === _f ? void 0 : _f.subtextStyle) || void 0 === _g ? void 0 : _g.fontSize) && void 0 !== _h ? _h : 16) + 1) - (null !== (_k = null === (_j = config.tableOptions) || void 0 === _j ? void 0 : _j.defaultHeaderRowHeight) && void 0 !== _k ? _k : 40)) / 5);
25
28
  return Object.assign(Object.assign({}, null !== (_l = config.tableOptions) && void 0 !== _l ? _l : {}), {
26
29
  columns: columns,
27
30
  defaultRowHeight: null != rowHeight ? rowHeight : 120,
@@ -34,8 +37,9 @@ function createTableOption(week, currentDate, config) {
34
37
  },
35
38
  bodyStyle: {
36
39
  bgColor: args => {
37
- const {col: col, row: row, dataValue: dataValue, table: table} = args, record = table.getCellRawRecord(col, row), date = dataValue, month = record.Sun > dataValue ? record.month + 1 : record.month;
38
- return (11 === record.month && record.Sun > dataValue ? record.year + 1 : record.year) === currentDate.getFullYear() && month === currentDate.getMonth() && date === currentDate.getDate() ? "#f0f0f0" : "#fff";
40
+ const {col: col, row: row, dataValue: dataValue, table: table} = args, record = table.getCellRawRecord(col, row);
41
+ record.Sun, record.month, 11 === record.month && record.Sun, record.year;
42
+ return (0, date_fns_1.isSameDay)((0, date_fns_1.addDays)(new Date(record.year, record.month, record.Sun), col), currentDate) ? "#f0f0f0" : "#fff";
39
43
  },
40
44
  textAlign: "right",
41
45
  textBaseline: "top",
@@ -1 +1 @@
1
- {"version":3,"sources":["table/table-option.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAE1C,4CAAkF;AAClF,2DAA+D;AAC/D,6CAAyC;AAEzC,SAAgB,iBAAiB,CAC/B,IAAsB,EACtB,WAAiB,EACjB,MAAuG;;IAEvG,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAoB,EAAE,KAAa,EAAE,EAAE;QAC/D,OAAO;YACL,KAAK,EAAE,4BAAgB,CAAC,KAAK,CAAC;YAC9B,KAAK,EAAE,IAAI;YAEX,WAAW,EAAE,CAAC,MAAkB,EAAE,EAAE;gBAClC,IACE,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,WAAW,EAAE;oBACzC,MAAM,CAAC,KAAK,KAAK,WAAW,CAAC,QAAQ,EAAE;oBACvC,MAAM,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,OAAO,EAAE,EACtC;oBACA,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;iBACjC;qBAAM,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK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AE,WAAW,CAAC,WAAW,EAAE,KAEpC,eAAe,EAAE,IAAI,EACrB,eAAe,EAAE;YACf;gBACE,EAAE,EAAE,eAAe;gBACnB,KAAK,EAAE;oBACL,KAAK,EAAE,MAAM;iBACd;aACF;SACF,GACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAhGD,8CAgGC","file":"table-option.js","sourcesContent":["import type { ListTableConstructorOptions, TYPES } from '@visactor/vtable';\nimport { themes } from '@visactor/vtable';\nimport type { DateRecord, DateRecordKeys } from '../date-util';\nimport { defaultDayTitles, getMonthString, getWeekdayString } from '../date-util';\nimport { calendarCustomLayout } from '../custom/custom-layout';\nimport { merge } from '@visactor/vutils';\n\nexport function createTableOption(\n week: DateRecordKeys[],\n currentDate: Date,\n config: { tableOptions?: ListTableConstructorOptions; containerWidth: number; containerHeight: number }\n) {\n const columns = week.map((item: DateRecordKeys, index: number) => {\n return {\n field: defaultDayTitles[index],\n title: item,\n // width: columnWidth ?? 140,\n fieldFormat: (record: DateRecord) => {\n if (\n record.year === currentDate.getFullYear() &&\n record.month === currentDate.getMonth() &&\n record[item] === currentDate.getDate()\n ) {\n return `${record[item]}\\nToday`;\n } else if (record[item] === 1) {\n const monthIndex = item === 'Sun' ? record.month : record.month + 1;\n const mouthStr = getMonthString(monthIndex);\n return `${record[item]}\\n${mouthStr}`;\n }\n return record[item];\n },\n customLayout: calendarCustomLayout\n };\n });\n\n const rowHeight = Math.floor(\n (config.containerHeight -\n ((config.tableOptions?.title?.textStyle?.fontSize ?? 20) +\n (config.tableOptions?.title?.subtextStyle?.fontSize ?? 16) +\n 1) -\n ((config.tableOptions?.defaultHeaderRowHeight as number) ?? 40)) /\n 5\n ); // height - title - header\n const option: TYPES.ListTableConstructorOptions = {\n ...(config.tableOptions ?? {}),\n\n columns,\n defaultRowHeight: rowHeight ?? 120,\n defaultHeaderRowHeight: config.tableOptions?.defaultHeaderRowHeight ?? 40,\n widthMode: 'adaptive',\n columnResizeMode: 'none',\n theme: themes.DEFAULT.extends(\n merge(\n {\n headerStyle: {\n textAlign: 'center'\n },\n bodyStyle: {\n bgColor: args => {\n const { col, row, dataValue, table } = args;\n const record = table.getCellRawRecord(col, row);\n const date = dataValue;\n const month = record.Sun > dataValue ? record.month + 1 : record.month;\n const year = record.month === 11 && record.Sun > dataValue ? record.year + 1 : record.year;\n if (\n year === currentDate.getFullYear() &&\n month === currentDate.getMonth() &&\n date === currentDate.getDate()\n ) {\n return '#f0f0f0';\n }\n return '#fff';\n },\n textAlign: 'right',\n textBaseline: 'top',\n color: '#999'\n }\n },\n config.tableOptions?.theme\n )\n ),\n title: {\n ...(config.tableOptions?.title ?? {}),\n\n orient: 'top',\n // text: 'Thu, Aug 22',\n text: `${getWeekdayString(currentDate.getDay())}, ${getMonthString(\n currentDate.getMonth()\n )} ${currentDate.getDate()}`,\n subtext: currentDate.getFullYear()\n },\n enableLineBreak: true,\n customCellStyle: [\n {\n id: 'current-month',\n style: {\n color: '#000'\n }\n }\n ]\n };\n\n return option;\n}\n"]}
1
+ {"version":3,"sources":["table/table-option.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAE1C,4CAAkF;AAClF,2DAA+D;AAC/D,6CAAyC;AACzC,uCAA8C;AAE9C,SAAgB,iBAAiB,CAC/B,IAAsB,EACtB,WAAiB,EACjB,MAAuG;;IAEvG,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAoB,EAAE,KAAa,EAAE,EAAE;;QAC/D,OAAO;YACL,KAAK,EAAE,4BAAgB,CAAC,KAAK,CAAC;YAC9B,KAAK,EAAE,IAAI;YAEX,WAAW,EAAE,CAAC,MAAkB,EAAE,EAAE;gBAClC,IAAI,IAAA,oBAAS,EAAC,IAAA,kBAAO,EAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,EAAE;oBAC3F,O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AAK,EAEb,IAAI,EAAE,GAAG,IAAA,4BAAgB,EAAC,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,IAAA,0BAAc,EAChE,WAAW,CAAC,QAAQ,EAAE,CACvB,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,EAC5B,OAAO,EAAE,WAAW,CAAC,WAAW,EAAE,KAEpC,eAAe,EAAE,IAAI,EACrB,eAAe,EAAE;YACf;gBACE,EAAE,EAAE,eAAe;gBACnB,KAAK,EAAE;oBACL,KAAK,EAAE,MAAM;iBACd;aACF;SACF,GACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AA7FD,8CA6FC","file":"table-option.js","sourcesContent":["import type { ListTableConstructorOptions, TYPES } from '@visactor/vtable';\nimport { themes } from '@visactor/vtable';\nimport type { DateRecord, DateRecordKeys } from '../date-util';\nimport { defaultDayTitles, getMonthString, getWeekdayString } from '../date-util';\nimport { calendarCustomLayout } from '../custom/custom-layout';\nimport { merge } from '@visactor/vutils';\nimport { addDays, isSameDay } from 'date-fns';\n\nexport function createTableOption(\n week: DateRecordKeys[],\n currentDate: Date,\n config: { tableOptions?: ListTableConstructorOptions; containerWidth: number; containerHeight: number }\n) {\n const columns = week.map((item: DateRecordKeys, index: number) => {\n return {\n field: defaultDayTitles[index],\n title: item,\n // width: columnWidth ?? 140,\n fieldFormat: (record: DateRecord) => {\n if (isSameDay(addDays(new Date(record.year, record.month, record.Sun), index), currentDate)) {\n return `${record[item]}\\nToday`;\n } else if (record[item] === 1) {\n const monthIndex = item === 'Sun' ? record.month : record.month + 1;\n const mouthStr = getMonthString(monthIndex);\n return `${record[item]}\\n${mouthStr}`;\n }\n return record[item];\n },\n customLayout: config.tableOptions?.customLayout ?? calendarCustomLayout\n };\n });\n\n const rowHeight = Math.floor(\n (config.containerHeight -\n ((config.tableOptions?.title?.textStyle?.fontSize ?? 20) +\n (config.tableOptions?.title?.subtextStyle?.fontSize ?? 16) +\n 1) -\n ((config.tableOptions?.defaultHeaderRowHeight as number) ?? 40)) /\n 5\n ); // height - title - header\n const option: TYPES.ListTableConstructorOptions = {\n ...(config.tableOptions ?? {}),\n\n columns,\n defaultRowHeight: rowHeight ?? 120,\n defaultHeaderRowHeight: config.tableOptions?.defaultHeaderRowHeight ?? 40,\n widthMode: 'adaptive',\n columnResizeMode: 'none',\n theme: themes.DEFAULT.extends(\n merge(\n {\n headerStyle: {\n textAlign: 'center'\n },\n bodyStyle: {\n bgColor: args => {\n const { col, row, dataValue, table } = args;\n const record = table.getCellRawRecord(col, row);\n const date = dataValue;\n const month = record.Sun > dataValue ? record.month + 1 : record.month;\n const year = record.month === 11 && record.Sun > dataValue ? record.year + 1 : record.year;\n if (\n // year === currentDate.getFullYear() &&\n // month === currentDate.getMonth() &&\n // date === currentDate.getDate()\n isSameDay(addDays(new Date(record.year, record.month, record.Sun), col), currentDate)\n ) {\n return '#f0f0f0';\n }\n return '#fff';\n },\n textAlign: 'right',\n textBaseline: 'top',\n color: '#999'\n }\n },\n config.tableOptions?.theme\n )\n ),\n title: {\n ...(config.tableOptions?.title ?? {}),\n\n orient: 'top',\n // text: 'Thu, Aug 22',\n text: `${getWeekdayString(currentDate.getDay())}, ${getMonthString(\n currentDate.getMonth()\n )} ${currentDate.getDate()}`,\n subtext: currentDate.getFullYear()\n },\n enableLineBreak: true,\n customCellStyle: [\n {\n id: 'current-month',\n style: {\n color: '#000'\n }\n }\n ]\n };\n\n return option;\n}\n"]}