"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/common/src/common/MoreLinkRoot.tsx" between
fullcalendar-5.9.0.tar.gz and fullcalendar-5.10.0.tar.gz

About: FullCalendar is a full-sized drag & drop JavaScript event calendar.

MoreLinkRoot.tsx  (fullcalendar-5.9.0):MoreLinkRoot.tsx  (fullcalendar-5.10.0)
import { EventApi } from '../api/EventApi' import { EventApi } from '../api/EventApi'
import { Seg } from '../component/DateComponent' import { Seg } from '../component/DateComponent'
import { DateRange } from '../datelib/date-range' import { DateRange } from '../datelib/date-range'
import { addDays, DateMarker } from '../datelib/marker' import { addDays, DateMarker } from '../datelib/marker'
import { DateProfile } from '../DateProfileGenerator' import { DateProfile } from '../DateProfileGenerator'
import { Dictionary } from '../options' import { Dictionary } from '../options'
import { elementClosest } from '../util/dom-manip' import { elementClosest, getUniqueDomId } from '../util/dom-manip'
import { formatWithOrdinals } from '../util/misc'
import { ComponentChildren, createElement, createRef, Fragment, Ref, RefObject, VNode } from '../vdom' import { ComponentChildren, createElement, createRef, Fragment, Ref, RefObject, VNode } from '../vdom'
import { BaseComponent } from '../vdom-util' import { BaseComponent } from '../vdom-util'
import { ViewApi } from '../ViewApi' import { ViewApi } from '../ViewApi'
import { ViewContext, ViewContextType } from '../ViewContext' import { ViewContext, ViewContextType } from '../ViewContext'
import { MorePopover } from './MorePopover' import { MorePopover } from './MorePopover'
import { MountArg, RenderHook } from './render-hook' import { MountArg, RenderHook } from './render-hook'
export type MoreLinkChildren = ( export type MoreLinkChildren = (
rootElRef: Ref<any>, rootElRef: Ref<any>,
classNames: string[], classNames: string[],
innerElRef: Ref<any>, innerElRef: Ref<any>,
innerContent: ComponentChildren, innerContent: ComponentChildren,
handleClick: (ev: MouseEvent) => void, handleClick: (ev: MouseEvent) => void,
title: string, // for a11y
isExpanded: boolean,
popoverId: string,
) => ComponentChildren ) => ComponentChildren
export interface MoreLinkRootProps { // what the MoreLinkRoot component receives export interface MoreLinkRootProps { // what the MoreLinkRoot component receives
dateProfile: DateProfile dateProfile: DateProfile
todayRange: DateRange todayRange: DateRange
allDayDate: DateMarker | null allDayDate: DateMarker | null
moreCnt: number // can't always derive from hiddenSegs. some hiddenSegs might be due to lack of dimensions moreCnt: number // can't always derive from hiddenSegs. some hiddenSegs might be due to lack of dimensions
allSegs: Seg[] allSegs: Seg[]
hiddenSegs: Seg[] hiddenSegs: Seg[]
extraDateSpan?: Dictionary extraDateSpan?: Dictionary
skipping to change at line 50 skipping to change at line 54
num: number num: number
text: string text: string
shortText: string shortText: string
view: ViewApi view: ViewApi
} }
export type MoreLinkMountArg = MountArg<MoreLinkContentArg> export type MoreLinkMountArg = MountArg<MoreLinkContentArg>
interface MoreLinkRootState { interface MoreLinkRootState {
isPopoverOpen: boolean isPopoverOpen: boolean
popoverId: string
} }
export class MoreLinkRoot extends BaseComponent<MoreLinkRootProps, MoreLinkRootS tate> { export class MoreLinkRoot extends BaseComponent<MoreLinkRootProps, MoreLinkRootS tate> {
private linkElRef = createRef<HTMLElement>() private linkElRef = createRef<HTMLElement>()
private parentEl: HTMLElement private parentEl: HTMLElement
state = { state = {
isPopoverOpen: false, isPopoverOpen: false,
popoverId: getUniqueDomId(),
} }
render() { render() {
let { props } = this let { props, state } = this
return ( return (
<ViewContextType.Consumer> <ViewContextType.Consumer>
{(context: ViewContext) => { {(context: ViewContext) => {
let { viewApi, options, calendarApi } = context let { viewApi, options, calendarApi } = context
let { moreLinkText } = options let { moreLinkText } = options
let { moreCnt } = props let { moreCnt } = props
let range = computeRange(props) let range = computeRange(props)
let text = typeof moreLinkText === 'function' // TODO: eventually use
formatWithOrdinals
? moreLinkText.call(calendarApi, moreCnt)
: `+${moreCnt} ${moreLinkText}`
let title = formatWithOrdinals(options.moreLinkHint, [moreCnt], text)
let hookProps: MoreLinkContentArg = { let hookProps: MoreLinkContentArg = {
num: moreCnt, num: moreCnt,
shortText: `+${moreCnt}`, // TODO: offer hook or i18n? shortText: `+${moreCnt}`, // TODO: offer hook or i18n?
text: typeof moreLinkText === 'function' text,
? moreLinkText.call(calendarApi, moreCnt)
: `+${moreCnt} ${moreLinkText}`,
view: viewApi, view: viewApi,
} }
return ( return (
<Fragment> <Fragment>
{Boolean(props.moreCnt) && ( {Boolean(props.moreCnt) && (
<RenderHook<MoreLinkContentArg> <RenderHook<MoreLinkContentArg>
elRef={this.linkElRef} elRef={this.linkElRef}
hookProps={hookProps} hookProps={hookProps}
classNames={options.moreLinkClassNames} classNames={options.moreLinkClassNames}
content={options.moreLinkContent} content={options.moreLinkContent}
defaultContent={props.defaultContent || renderMoreLinkInner} defaultContent={props.defaultContent || renderMoreLinkInner}
didMount={options.moreLinkDidMount} didMount={options.moreLinkDidMount}
willUnmount={options.moreLinkWillUnmount} willUnmount={options.moreLinkWillUnmount}
> >
{(rootElRef, customClassNames, innerElRef, innerContent) => pr ops.children( {(rootElRef, customClassNames, innerElRef, innerContent) => pr ops.children(
rootElRef, ['fc-more-link'].concat(customClassNames), innerE rootElRef,
lRef, innerContent, this.handleClick, ['fc-more-link'].concat(customClassNames),
innerElRef,
innerContent,
this.handleClick,
title,
state.isPopoverOpen,
state.isPopoverOpen ? state.popoverId : '',
)} )}
</RenderHook> </RenderHook>
)} )}
{this.state.isPopoverOpen && ( {state.isPopoverOpen && (
<MorePopover <MorePopover
id={state.popoverId}
startDate={range.start} startDate={range.start}
endDate={range.end} endDate={range.end}
dateProfile={props.dateProfile} dateProfile={props.dateProfile}
todayRange={props.todayRange} todayRange={props.todayRange}
extraDateSpan={props.extraDateSpan} extraDateSpan={props.extraDateSpan}
parentEl={this.parentEl} parentEl={this.parentEl}
alignmentEl={props.alignmentElRef.current} alignmentEl={props.alignmentElRef.current}
alignGridTop={props.alignGridTop} alignGridTop={props.alignGridTop}
onClose={this.handlePopoverClose} onClose={this.handlePopoverClose}
> >
 End of changes. 10 change blocks. 
8 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)