@sanguo-dev/calendar-ui 0.0.0-stage → 0.0.3

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.
@@ -0,0 +1,286 @@
1
+ /**
2
+ * 语言包
3
+ *
4
+ * 只负责日历自身的界面文字;农历、节气、节日等业务文案由适配器提供。
5
+ */
6
+ interface CalendarLocale {
7
+ /** 语言标签,例如 "zh-CN",仅用于调试与覆盖 */
8
+ name: string;
9
+ /** 一周七天的短名,下标 0 为周日 */
10
+ weekdays: readonly string[];
11
+ /** 一周七天的全名,下标 0 为周日,用于 title 提示 */
12
+ weekdaysLong: readonly string[];
13
+ /** 头部年月标题 */
14
+ monthTitle(year: number, month: number): string;
15
+ /** 上个月按钮的无障碍名称 */
16
+ prevMonth: string;
17
+ /** 下个月按钮的无障碍名称 */
18
+ nextMonth: string;
19
+ /** 折叠按钮的无障碍名称;不传时使用内置文案 */
20
+ collapse?: string;
21
+ /** 展开按钮的无障碍名称;不传时使用内置文案 */
22
+ expand?: string;
23
+ }
24
+ /** 内置语言包的名称,可直接传给 CalendarOptions.locale */
25
+ type CalendarLocaleName = "zh-CN" | "en-US";
26
+ /** 一周从哪天开始:0 为周日,1 为周一 */
27
+ type WeekStartsOn = 0 | 1;
28
+ /** 主题:light / dark 显式指定,auto 跟随最近的 data-theme 或系统偏好 */
29
+ type CalendarTheme = "light" | "dark" | "auto";
30
+ /**
31
+ * 外部传入的日期
32
+ *
33
+ * 支持 Date,或本地日期字符串:
34
+ * `2026-10-01`、`2026-10-1`、`2026/10/01`、`2026/10/1`。
35
+ */
36
+ type CalendarDateInput = Date | string;
37
+ /** 选择模式:单选 / 范围 */
38
+ type CalendarMode = "single" | "range";
39
+ /** 范围选择结果,start/end 为 null 表示还没选完 */
40
+ interface CalendarRange {
41
+ start: Date | null;
42
+ end: Date | null;
43
+ }
44
+ /** 自定义副标题:返回 null/undefined 时回退到 adapter 的 subtitle */
45
+ type SubtitleRenderer = (day: CalendarDate) => string | null | undefined;
46
+ /** 翻月滑动动画;传了 slide 就开启,不传就是直接切换 */
47
+ interface SlideAnimationOptions {
48
+ /** 动画时长,单位 ms,默认 220 */
49
+ duration?: number;
50
+ /** 缓动函数,默认 "ease" */
51
+ easing?: string;
52
+ }
53
+ /** 折叠配置;传了 collapse 就显示底部折叠箭头并开启过渡 */
54
+ interface CollapseAnimationOptions {
55
+ /** 折叠时长,单位 ms,默认 200 */
56
+ duration?: number;
57
+ /** 缓动函数,默认 "ease" */
58
+ easing?: string;
59
+ /** 初始是否折叠,默认 false(展开) */
60
+ defaultCollapsed?: boolean;
61
+ }
62
+ /** 动画配置;整块不传时不做任何动画,也不显示折叠箭头 */
63
+ interface CalendarAnimationOptions {
64
+ /** 翻月滑动;`{}` 表示用默认时长和缓动 */
65
+ slide?: SlideAnimationOptions;
66
+ /** 折叠;`{}` 表示启用折叠并默认展开 */
67
+ collapse?: CollapseAnimationOptions;
68
+ }
69
+ /** 规范后的年月 */
70
+ interface YearMonth {
71
+ year: number;
72
+ /** 1-12 */
73
+ month: number;
74
+ }
75
+ /** 日历格的公历日期部分 */
76
+ interface CalendarDate {
77
+ /** 公历年 */
78
+ year: number;
79
+ /** 公历月,1-12 */
80
+ month: number;
81
+ /** 公历日 */
82
+ day: number;
83
+ /** 该格对应的日期对象(本地时区) */
84
+ date: Date;
85
+ /** 是否属于当前展示的月份(false 表示上一月/下一月的补位格) */
86
+ inCurrentMonth: boolean;
87
+ }
88
+ /** 格子左上角的小标记,例如「休」「班」 */
89
+ interface CalendarBadge {
90
+ /** 显示文字 */
91
+ text: string;
92
+ /** 传给样式的 data-tone,核心不解释具体含义 */
93
+ tone?: string;
94
+ }
95
+ /** 适配器对单个格子的装饰 */
96
+ interface DayDecoration<TData = unknown> {
97
+ /** 格子副标题,例如节气、节日、农历日 */
98
+ subtitle?: string;
99
+ /** 左上角小标记;不传则不显示 */
100
+ badge?: CalendarBadge;
101
+ /** 透传给 onSelect 的数据,核心不解释 */
102
+ data?: TData;
103
+ /** 覆盖默认 aria-label;不传时由日期、标记、副标题拼接 */
104
+ ariaLabel?: string;
105
+ }
106
+ /** 每次渲染月视图时传给适配器的上下文 */
107
+ interface MonthInput {
108
+ /** 公历年 */
109
+ year: number;
110
+ /** 公历月,1-12 */
111
+ month: number;
112
+ /** 一周从哪天开始 */
113
+ weekStartsOn: WeekStartsOn;
114
+ /** 今天 */
115
+ today: Date;
116
+ /** 当前界面语言 */
117
+ locale: CalendarLocale;
118
+ /** 固定 42 个日期,包含上下月补位格 */
119
+ days: readonly CalendarDate[];
120
+ }
121
+ /**
122
+ * 日历适配器
123
+ *
124
+ * 核心只认识这个接口,不依赖任何具体的农历/节假日实现。
125
+ * 第三方可以实现它接入自己的日历数据。
126
+ */
127
+ interface CalendarAdapter<TData = unknown> {
128
+ /** 适配器标识,用于调试和排查 */
129
+ readonly id: string;
130
+ /**
131
+ * 生成当前月的 42 个格子的装饰
132
+ *
133
+ * 返回数组按索引和 input.days 对齐;没有装饰的位置返回 null。
134
+ * 每次换月、选中、重新渲染都会调用,适配器应自行缓存重计算。
135
+ */
136
+ decorateMonth(input: MonthInput): ReadonlyArray<DayDecoration<TData> | null>;
137
+ }
138
+ /** 日历中的一格 */
139
+ interface CalendarDay<TData = null> extends CalendarDate {
140
+ /** 是否今天 */
141
+ isToday: boolean;
142
+ /** 是否当前选中 */
143
+ isSelected: boolean;
144
+ /** 是否被 minDate / maxDate / disabledDates 禁止 */
145
+ isDisabled: boolean;
146
+ /** 是否范围起点 */
147
+ isRangeStart: boolean;
148
+ /** 是否范围终点 */
149
+ isRangeEnd: boolean;
150
+ /** 是否在已选范围内(含起终点) */
151
+ isInRange: boolean;
152
+ /** 格子副标题,例如节气、节日、农历日 */
153
+ subtitle: string;
154
+ /** 左上角小标记 */
155
+ badge: CalendarBadge | null;
156
+ /** 适配器透传的数据 */
157
+ data: TData | null;
158
+ /** 无障碍名称 */
159
+ ariaLabel: string;
160
+ }
161
+ /** 自定义头部能拿到的上下文 */
162
+ interface HeaderRenderContext {
163
+ /** 当前展示的年 */
164
+ year: number;
165
+ /** 当前展示的月,1-12 */
166
+ month: number;
167
+ /** 当前语言包 */
168
+ locale: CalendarLocale;
169
+ /** 切到上个月 */
170
+ prevMonth(): void;
171
+ /** 切到下个月 */
172
+ nextMonth(): void;
173
+ }
174
+ /** 自定义头部渲染函数:返回要放进头部的元素,每次换月都会重新调用 */
175
+ type HeaderRenderer = (context: HeaderRenderContext) => HTMLElement;
176
+ /** 创建日历时的配置 */
177
+ interface CalendarOptions<TData = null> {
178
+ /** 初始日期,默认今天;超出约束时夹到最近的可选日期 */
179
+ initialDate?: CalendarDateInput;
180
+ /** 最小可选日期(包含) */
181
+ minDate?: CalendarDateInput;
182
+ /** 最大可选日期(包含) */
183
+ maxDate?: CalendarDateInput;
184
+ /** 禁止选中的日期,按本地年月日比较 */
185
+ disabledDates?: readonly CalendarDateInput[];
186
+ /** 选择模式,默认 "single" */
187
+ mode?: CalendarMode;
188
+ /** 范围模式下显示的月数,默认 1;设为 2 时显示相邻两个月 */
189
+ months?: 1 | 2;
190
+ /** 范围变化时触发 */
191
+ onRangeChange?: (range: CalendarRange) => void;
192
+ /** 一周从哪天开始,默认 1(周一) */
193
+ weekStartsOn?: WeekStartsOn;
194
+ /** 界面语言:内置 "zh-CN"(默认)/ "en-US",也可直接传自定义语言包 */
195
+ locale?: CalendarLocale | CalendarLocaleName;
196
+ /** 主题,默认 "auto":跟随最近的 data-theme,没有则跟随系统 */
197
+ theme?: CalendarTheme;
198
+ /**
199
+ * 动画配置
200
+ *
201
+ * 不传时翻月直接切换、不显示折叠箭头。传了 `slide` 才开启滑动,
202
+ * 传了 `collapse` 才显示折叠箭头。
203
+ */
204
+ animation?: CalendarAnimationOptions;
205
+ /** 自定义副标题;优先于 adapter.subtitle,返回 null/undefined 时回退 */
206
+ subtitle?: SubtitleRenderer;
207
+ /** 是否显示头部,默认 true */
208
+ header?: boolean;
209
+ /** 自定义头部,替换默认的 ‹ 标题 › */
210
+ renderHeader?: HeaderRenderer;
211
+ /** 选中某一天时触发 */
212
+ onSelect?: (day: CalendarDay<TData>) => void;
213
+ /** 切换月份时触发 */
214
+ onMonthChange?: (year: number, month: number) => void;
215
+ /** 日历适配器;不传时就是纯公历 */
216
+ adapter?: CalendarAdapter<TData>;
217
+ }
218
+ /** 返回的实例 */
219
+ interface CalendarInstance {
220
+ /** 日历根元素,方便外部定位或再挂样式 */
221
+ readonly el: HTMLElement;
222
+ /** 跳到某年某月 */
223
+ setMonth(year: number, month: number): void;
224
+ /** 当前展示的年月 */
225
+ getMonth(): YearMonth;
226
+ /** 切到上个月 */
227
+ prevMonth(): void;
228
+ /** 切到下个月 */
229
+ nextMonth(): void;
230
+ /** 选中某个日期 */
231
+ select(date: CalendarDateInput): void;
232
+ /** 当前已选范围;单选模式返回 { start: null, end: null } */
233
+ getRange(): CalendarRange;
234
+ /** 设置范围;start 为空时清空,end 省略表示只选了起点 */
235
+ setRange(start: CalendarDateInput | null, end?: CalendarDateInput | null): void;
236
+ /** 清空范围 */
237
+ clearRange(): void;
238
+ /** 当前选中的日期 */
239
+ getSelected(): Date | null;
240
+ /** 显示整个日历 */
241
+ show(): void;
242
+ /** 隐藏整个日历 */
243
+ hide(): void;
244
+ /** 切换整个日历的显示状态 */
245
+ toggle(): void;
246
+ /** 整个日历当前是否可见 */
247
+ isVisible(): boolean;
248
+ /** 显示头部 */
249
+ showHeader(): void;
250
+ /** 隐藏头部 */
251
+ hideHeader(): void;
252
+ /** 切换头部的显示状态 */
253
+ toggleHeader(): void;
254
+ /** 头部当前是否可见 */
255
+ isHeaderVisible(): boolean;
256
+ /** 当前最小可选日期,未设置时为 null */
257
+ getMinDate(): Date | null;
258
+ /** 设置最小可选日期,传 null 取消 */
259
+ setMinDate(date: CalendarDateInput | null): void;
260
+ /** 当前最大可选日期,未设置时为 null */
261
+ getMaxDate(): Date | null;
262
+ /** 设置最大可选日期,传 null 取消 */
263
+ setMaxDate(date: CalendarDateInput | null): void;
264
+ /** 当前主题 */
265
+ getTheme(): CalendarTheme;
266
+ /** 切换主题,只改 data-theme,不重建 DOM */
267
+ setTheme(theme: CalendarTheme): void;
268
+ /** 移除 DOM 与事件监听 */
269
+ destroy(): void;
270
+ }
271
+ /**
272
+ * 在容器里创建一个日历
273
+ *
274
+ * 只依赖 DOM,不依赖任何框架;重复调用 createCalendarUI 会各自独立。
275
+ * 不传 adapter 时就是纯公历,适配器负责提供副标题、标记和透传数据。
276
+ */
277
+ export declare function createCalendarUI<TData = null>(container: HTMLElement, options?: CalendarOptions<TData>): CalendarInstance;
278
+ /** 英文 */
279
+ export declare const enUS: CalendarLocale;
280
+ /** 简体中文:默认语言 */
281
+ export declare const zhCN: CalendarLocale;
282
+ /** 内置语言包,key 可直接传给 createCalendarUI 的 locale 选项 */
283
+ export declare const locales: Record<CalendarLocaleName, CalendarLocale>;
284
+ /** 把 "zh-CN" 这类名称或自定义语言包,统一解析成语言包对象 */
285
+ export declare const resolveLocale: (locale?: CalendarLocale | CalendarLocaleName) => CalendarLocale;
286
+ export type { CalendarAdapter, CalendarAnimationOptions, CalendarBadge, CalendarDate, CalendarDateInput, CalendarDay, CalendarInstance, CalendarLocale, CalendarLocaleName, CalendarMode, CalendarOptions, CalendarRange, CalendarTheme, CollapseAnimationOptions, DayDecoration, HeaderRenderContext, HeaderRenderer, MonthInput, SlideAnimationOptions, SubtitleRenderer, WeekStartsOn, YearMonth };
@@ -0,0 +1,286 @@
1
+ /**
2
+ * 语言包
3
+ *
4
+ * 只负责日历自身的界面文字;农历、节气、节日等业务文案由适配器提供。
5
+ */
6
+ interface CalendarLocale {
7
+ /** 语言标签,例如 "zh-CN",仅用于调试与覆盖 */
8
+ name: string;
9
+ /** 一周七天的短名,下标 0 为周日 */
10
+ weekdays: readonly string[];
11
+ /** 一周七天的全名,下标 0 为周日,用于 title 提示 */
12
+ weekdaysLong: readonly string[];
13
+ /** 头部年月标题 */
14
+ monthTitle(year: number, month: number): string;
15
+ /** 上个月按钮的无障碍名称 */
16
+ prevMonth: string;
17
+ /** 下个月按钮的无障碍名称 */
18
+ nextMonth: string;
19
+ /** 折叠按钮的无障碍名称;不传时使用内置文案 */
20
+ collapse?: string;
21
+ /** 展开按钮的无障碍名称;不传时使用内置文案 */
22
+ expand?: string;
23
+ }
24
+ /** 内置语言包的名称,可直接传给 CalendarOptions.locale */
25
+ type CalendarLocaleName = "zh-CN" | "en-US";
26
+ /** 一周从哪天开始:0 为周日,1 为周一 */
27
+ type WeekStartsOn = 0 | 1;
28
+ /** 主题:light / dark 显式指定,auto 跟随最近的 data-theme 或系统偏好 */
29
+ type CalendarTheme = "light" | "dark" | "auto";
30
+ /**
31
+ * 外部传入的日期
32
+ *
33
+ * 支持 Date,或本地日期字符串:
34
+ * `2026-10-01`、`2026-10-1`、`2026/10/01`、`2026/10/1`。
35
+ */
36
+ type CalendarDateInput = Date | string;
37
+ /** 选择模式:单选 / 范围 */
38
+ type CalendarMode = "single" | "range";
39
+ /** 范围选择结果,start/end 为 null 表示还没选完 */
40
+ interface CalendarRange {
41
+ start: Date | null;
42
+ end: Date | null;
43
+ }
44
+ /** 自定义副标题:返回 null/undefined 时回退到 adapter 的 subtitle */
45
+ type SubtitleRenderer = (day: CalendarDate) => string | null | undefined;
46
+ /** 翻月滑动动画;传了 slide 就开启,不传就是直接切换 */
47
+ interface SlideAnimationOptions {
48
+ /** 动画时长,单位 ms,默认 220 */
49
+ duration?: number;
50
+ /** 缓动函数,默认 "ease" */
51
+ easing?: string;
52
+ }
53
+ /** 折叠配置;传了 collapse 就显示底部折叠箭头并开启过渡 */
54
+ interface CollapseAnimationOptions {
55
+ /** 折叠时长,单位 ms,默认 200 */
56
+ duration?: number;
57
+ /** 缓动函数,默认 "ease" */
58
+ easing?: string;
59
+ /** 初始是否折叠,默认 false(展开) */
60
+ defaultCollapsed?: boolean;
61
+ }
62
+ /** 动画配置;整块不传时不做任何动画,也不显示折叠箭头 */
63
+ interface CalendarAnimationOptions {
64
+ /** 翻月滑动;`{}` 表示用默认时长和缓动 */
65
+ slide?: SlideAnimationOptions;
66
+ /** 折叠;`{}` 表示启用折叠并默认展开 */
67
+ collapse?: CollapseAnimationOptions;
68
+ }
69
+ /** 规范后的年月 */
70
+ interface YearMonth {
71
+ year: number;
72
+ /** 1-12 */
73
+ month: number;
74
+ }
75
+ /** 日历格的公历日期部分 */
76
+ interface CalendarDate {
77
+ /** 公历年 */
78
+ year: number;
79
+ /** 公历月,1-12 */
80
+ month: number;
81
+ /** 公历日 */
82
+ day: number;
83
+ /** 该格对应的日期对象(本地时区) */
84
+ date: Date;
85
+ /** 是否属于当前展示的月份(false 表示上一月/下一月的补位格) */
86
+ inCurrentMonth: boolean;
87
+ }
88
+ /** 格子左上角的小标记,例如「休」「班」 */
89
+ interface CalendarBadge {
90
+ /** 显示文字 */
91
+ text: string;
92
+ /** 传给样式的 data-tone,核心不解释具体含义 */
93
+ tone?: string;
94
+ }
95
+ /** 适配器对单个格子的装饰 */
96
+ interface DayDecoration<TData = unknown> {
97
+ /** 格子副标题,例如节气、节日、农历日 */
98
+ subtitle?: string;
99
+ /** 左上角小标记;不传则不显示 */
100
+ badge?: CalendarBadge;
101
+ /** 透传给 onSelect 的数据,核心不解释 */
102
+ data?: TData;
103
+ /** 覆盖默认 aria-label;不传时由日期、标记、副标题拼接 */
104
+ ariaLabel?: string;
105
+ }
106
+ /** 每次渲染月视图时传给适配器的上下文 */
107
+ interface MonthInput {
108
+ /** 公历年 */
109
+ year: number;
110
+ /** 公历月,1-12 */
111
+ month: number;
112
+ /** 一周从哪天开始 */
113
+ weekStartsOn: WeekStartsOn;
114
+ /** 今天 */
115
+ today: Date;
116
+ /** 当前界面语言 */
117
+ locale: CalendarLocale;
118
+ /** 固定 42 个日期,包含上下月补位格 */
119
+ days: readonly CalendarDate[];
120
+ }
121
+ /**
122
+ * 日历适配器
123
+ *
124
+ * 核心只认识这个接口,不依赖任何具体的农历/节假日实现。
125
+ * 第三方可以实现它接入自己的日历数据。
126
+ */
127
+ interface CalendarAdapter<TData = unknown> {
128
+ /** 适配器标识,用于调试和排查 */
129
+ readonly id: string;
130
+ /**
131
+ * 生成当前月的 42 个格子的装饰
132
+ *
133
+ * 返回数组按索引和 input.days 对齐;没有装饰的位置返回 null。
134
+ * 每次换月、选中、重新渲染都会调用,适配器应自行缓存重计算。
135
+ */
136
+ decorateMonth(input: MonthInput): ReadonlyArray<DayDecoration<TData> | null>;
137
+ }
138
+ /** 日历中的一格 */
139
+ interface CalendarDay<TData = null> extends CalendarDate {
140
+ /** 是否今天 */
141
+ isToday: boolean;
142
+ /** 是否当前选中 */
143
+ isSelected: boolean;
144
+ /** 是否被 minDate / maxDate / disabledDates 禁止 */
145
+ isDisabled: boolean;
146
+ /** 是否范围起点 */
147
+ isRangeStart: boolean;
148
+ /** 是否范围终点 */
149
+ isRangeEnd: boolean;
150
+ /** 是否在已选范围内(含起终点) */
151
+ isInRange: boolean;
152
+ /** 格子副标题,例如节气、节日、农历日 */
153
+ subtitle: string;
154
+ /** 左上角小标记 */
155
+ badge: CalendarBadge | null;
156
+ /** 适配器透传的数据 */
157
+ data: TData | null;
158
+ /** 无障碍名称 */
159
+ ariaLabel: string;
160
+ }
161
+ /** 自定义头部能拿到的上下文 */
162
+ interface HeaderRenderContext {
163
+ /** 当前展示的年 */
164
+ year: number;
165
+ /** 当前展示的月,1-12 */
166
+ month: number;
167
+ /** 当前语言包 */
168
+ locale: CalendarLocale;
169
+ /** 切到上个月 */
170
+ prevMonth(): void;
171
+ /** 切到下个月 */
172
+ nextMonth(): void;
173
+ }
174
+ /** 自定义头部渲染函数:返回要放进头部的元素,每次换月都会重新调用 */
175
+ type HeaderRenderer = (context: HeaderRenderContext) => HTMLElement;
176
+ /** 创建日历时的配置 */
177
+ interface CalendarOptions<TData = null> {
178
+ /** 初始日期,默认今天;超出约束时夹到最近的可选日期 */
179
+ initialDate?: CalendarDateInput;
180
+ /** 最小可选日期(包含) */
181
+ minDate?: CalendarDateInput;
182
+ /** 最大可选日期(包含) */
183
+ maxDate?: CalendarDateInput;
184
+ /** 禁止选中的日期,按本地年月日比较 */
185
+ disabledDates?: readonly CalendarDateInput[];
186
+ /** 选择模式,默认 "single" */
187
+ mode?: CalendarMode;
188
+ /** 范围模式下显示的月数,默认 1;设为 2 时显示相邻两个月 */
189
+ months?: 1 | 2;
190
+ /** 范围变化时触发 */
191
+ onRangeChange?: (range: CalendarRange) => void;
192
+ /** 一周从哪天开始,默认 1(周一) */
193
+ weekStartsOn?: WeekStartsOn;
194
+ /** 界面语言:内置 "zh-CN"(默认)/ "en-US",也可直接传自定义语言包 */
195
+ locale?: CalendarLocale | CalendarLocaleName;
196
+ /** 主题,默认 "auto":跟随最近的 data-theme,没有则跟随系统 */
197
+ theme?: CalendarTheme;
198
+ /**
199
+ * 动画配置
200
+ *
201
+ * 不传时翻月直接切换、不显示折叠箭头。传了 `slide` 才开启滑动,
202
+ * 传了 `collapse` 才显示折叠箭头。
203
+ */
204
+ animation?: CalendarAnimationOptions;
205
+ /** 自定义副标题;优先于 adapter.subtitle,返回 null/undefined 时回退 */
206
+ subtitle?: SubtitleRenderer;
207
+ /** 是否显示头部,默认 true */
208
+ header?: boolean;
209
+ /** 自定义头部,替换默认的 ‹ 标题 › */
210
+ renderHeader?: HeaderRenderer;
211
+ /** 选中某一天时触发 */
212
+ onSelect?: (day: CalendarDay<TData>) => void;
213
+ /** 切换月份时触发 */
214
+ onMonthChange?: (year: number, month: number) => void;
215
+ /** 日历适配器;不传时就是纯公历 */
216
+ adapter?: CalendarAdapter<TData>;
217
+ }
218
+ /** 返回的实例 */
219
+ interface CalendarInstance {
220
+ /** 日历根元素,方便外部定位或再挂样式 */
221
+ readonly el: HTMLElement;
222
+ /** 跳到某年某月 */
223
+ setMonth(year: number, month: number): void;
224
+ /** 当前展示的年月 */
225
+ getMonth(): YearMonth;
226
+ /** 切到上个月 */
227
+ prevMonth(): void;
228
+ /** 切到下个月 */
229
+ nextMonth(): void;
230
+ /** 选中某个日期 */
231
+ select(date: CalendarDateInput): void;
232
+ /** 当前已选范围;单选模式返回 { start: null, end: null } */
233
+ getRange(): CalendarRange;
234
+ /** 设置范围;start 为空时清空,end 省略表示只选了起点 */
235
+ setRange(start: CalendarDateInput | null, end?: CalendarDateInput | null): void;
236
+ /** 清空范围 */
237
+ clearRange(): void;
238
+ /** 当前选中的日期 */
239
+ getSelected(): Date | null;
240
+ /** 显示整个日历 */
241
+ show(): void;
242
+ /** 隐藏整个日历 */
243
+ hide(): void;
244
+ /** 切换整个日历的显示状态 */
245
+ toggle(): void;
246
+ /** 整个日历当前是否可见 */
247
+ isVisible(): boolean;
248
+ /** 显示头部 */
249
+ showHeader(): void;
250
+ /** 隐藏头部 */
251
+ hideHeader(): void;
252
+ /** 切换头部的显示状态 */
253
+ toggleHeader(): void;
254
+ /** 头部当前是否可见 */
255
+ isHeaderVisible(): boolean;
256
+ /** 当前最小可选日期,未设置时为 null */
257
+ getMinDate(): Date | null;
258
+ /** 设置最小可选日期,传 null 取消 */
259
+ setMinDate(date: CalendarDateInput | null): void;
260
+ /** 当前最大可选日期,未设置时为 null */
261
+ getMaxDate(): Date | null;
262
+ /** 设置最大可选日期,传 null 取消 */
263
+ setMaxDate(date: CalendarDateInput | null): void;
264
+ /** 当前主题 */
265
+ getTheme(): CalendarTheme;
266
+ /** 切换主题,只改 data-theme,不重建 DOM */
267
+ setTheme(theme: CalendarTheme): void;
268
+ /** 移除 DOM 与事件监听 */
269
+ destroy(): void;
270
+ }
271
+ /**
272
+ * 在容器里创建一个日历
273
+ *
274
+ * 只依赖 DOM,不依赖任何框架;重复调用 createCalendarUI 会各自独立。
275
+ * 不传 adapter 时就是纯公历,适配器负责提供副标题、标记和透传数据。
276
+ */
277
+ export declare function createCalendarUI<TData = null>(container: HTMLElement, options?: CalendarOptions<TData>): CalendarInstance;
278
+ /** 英文 */
279
+ export declare const enUS: CalendarLocale;
280
+ /** 简体中文:默认语言 */
281
+ export declare const zhCN: CalendarLocale;
282
+ /** 内置语言包,key 可直接传给 createCalendarUI 的 locale 选项 */
283
+ export declare const locales: Record<CalendarLocaleName, CalendarLocale>;
284
+ /** 把 "zh-CN" 这类名称或自定义语言包,统一解析成语言包对象 */
285
+ export declare const resolveLocale: (locale?: CalendarLocale | CalendarLocaleName) => CalendarLocale;
286
+ export type { CalendarAdapter, CalendarAnimationOptions, CalendarBadge, CalendarDate, CalendarDateInput, CalendarDay, CalendarInstance, CalendarLocale, CalendarLocaleName, CalendarMode, CalendarOptions, CalendarRange, CalendarTheme, CollapseAnimationOptions, DayDecoration, HeaderRenderContext, HeaderRenderer, MonthInput, SlideAnimationOptions, SubtitleRenderer, WeekStartsOn, YearMonth };