import type { VueNode } from '../../_util/type'; import type { Components, RangeList, Locale } from '../interface'; export type RangesProps = { prefixCls: string; rangeList?: RangeList; components?: Components; needConfirmButton: boolean; onNow?: null | (() => void) | false; onOk?: null | (() => void) | false; okDisabled?: boolean; showNow?: boolean; locale: Locale; }; export default function getRanges({ prefixCls, rangeList = [], components = {}, needConfirmButton, onNow, onOk, okDisabled, showNow, locale, }: RangesProps) { let presetNode: VueNode; let okNode: VueNode; if (rangeList.length) { const Item = (components.rangeItem || 'span') as any; presetNode = ( <> {rangeList.map(({ label, onClick, onMouseenter, onMouseleave }) => (
  • {label}
  • ))} ); } if (needConfirmButton) { const Button = (components.button || 'button') as any; if (onNow && !presetNode && showNow !== false) { presetNode = (
  • {locale.now}
  • ); } okNode = needConfirmButton && (
  • ); } if (!presetNode && !okNode) { return null; } return ( ); }