UNPKG

@gez/date-time-kit

Version:

115 lines (114 loc) 4.64 kB
import { type DateTimeGranularity } from '../../utils'; import { type Weeks, weekKey } from '../calendar'; import type { Ele as PeriodSelectorEle } from '../period-selector'; import { Ele as PopoverEle } from '../popover'; import { type reExportPopoverAttrs } from '../popover/attr-sync-helper'; import { type BaseAttrs, type BaseEmits, type Emit2EventMap, UiBase } from '../web-component-base'; import { type DataLimit, type GenPeriodTimesOptions, type PeriodTimeInfo, type QuickGenPeriodTimesOptions, type QuickKey, UTCInfo2LocaleInfo, genPeriodTimes, localeInfo2UTCInfo, quickGenPeriodTime, quickGenPeriodTimeInfo, quickGenPeriodTimes, quickKeys } from './quick-key'; export { type QuickKey, type DataLimit, type GenPeriodTimesOptions, type QuickGenPeriodTimesOptions, type PeriodTimeInfo, type Weeks, genPeriodTimes, quickGenPeriodTime, quickGenPeriodTimes, quickGenPeriodTimeInfo, localeInfo2UTCInfo, UTCInfo2LocaleInfo, quickKeys, weekKey }; export declare const granularityList: readonly ["millisecond", "second", "minute", "hour", "day", "month", "year"]; export type Granularity = DateTimeGranularity; export type Attrs = BaseAttrs & reExportPopoverAttrs & { /** * Timezone in minutes. For example: UTC+05:45 => `-345`, UTC-01:00 => `60`. * * @default * new Date().getTimezoneOffset() // locale timezone in minutes */ 'tz-offset'?: number; /** * Set which day of the week is the first day. * @type `'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'` * @default 'sun' */ 'week-start-at'?: Weeks; /** * Quick selection key. * * @default 'all' */ 'quick-key'?: QuickKey; /** * Start locale time of the quick selection. Only works in custom mode. */ 'start-time'?: string | number | ''; /** * End locale time of the quick selection. Only works in custom mode. */ 'end-time'?: string | number | ''; /** * 选择器的粒度,表示最小可选的时间单位。默认为 millisecond。 * 例如设置为 'minute',则表示只能选择到分钟,秒和毫秒将被忽略。忽略的时间单位视情况重置为 0 或 23 或 59 或 999。 */ 'min-granularity'?: Granularity; /** * Exclude some quick selection options. * * @example * ```ts * exclude-field="last7Days, last30Days, timezone" * ``` */ 'exclude-field'?: (QuickKey | 'timezone')[]; }; export interface Emits extends BaseEmits { 'time-changed': PeriodTimeInfo; 'open-change': boolean; } export type EventMap = Emit2EventMap<Emits>; /** * 快速选择下拉选项 */ export declare class Ele extends UiBase<Attrs, Emits> { static readonly tagName: "dt-quick-selector"; protected static _style: string; protected static _template: string; static get observedAttributes(): string[]; get tzOffset(): number; set tzOffset(v: number); get quickKey(): QuickKey; set quickKey(val: QuickKey); get weekStartAt(): Weeks; set weekStartAt(val: Weeks); get startTime(): number | string | Date; set startTime(val: number | string | Date); get endTime(): number | string | Date; set endTime(val: number | string | Date); get minGranularity(): Granularity; set minGranularity(val: Granularity); get excludeField(): (QuickKey | "timezone")[]; set excludeField(v: (QuickKey | 'timezone')[]); get _staticEls(): { readonly periodSelector: PeriodSelectorEle; readonly popover: PopoverEle; }; connectedCallback(): void; disconnectedCallback(): boolean | void; protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void; private _updatePeriodSelector; private _renderTz; private _updateRadio; private _onPopoverChange; private _showMenu; private _onTzTriggerClick; private _onCustomTriggerClick; private _onBackBtnClick; private _dispatchTimeChangeEvent; private _onRadioChange; private _onDoneBtnClick; readonly genPeriodTimes: (options: GenPeriodTimesOptions) => { start: Date; end: Date; }; readonly quickGenPeriodTimes: <T extends DataLimit = DataLimit>(periods: T[]) => Record<Exclude<T, "all">, { start: Date; end: Date; }> & ("all" extends T ? { all: null; } : {}); readonly quickGenPeriodTime: <T extends DataLimit = DataLimit>(period: T) => T extends "all" ? null : { start: Date; end: Date; }; readonly quickGenPeriodTimeInfo: <T extends DataLimit = DataLimit>(type: T) => PeriodTimeInfo<T, Date>; }