• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * Defines the struct of DatePickerResult.
18 * @since 8
19 */
20declare interface DatePickerResult {
21  /**
22   * Application year
23   * @since 8
24   */
25  year?: number;
26
27  /**
28   * Application month
29   * @since 8
30   */
31  month?: number;
32
33  /**
34   * Application day
35   * @since 8
36   */
37  day?: number;
38}
39
40/**
41 * Defines the options of DatePicker.
42 * @since 8
43 */
44declare interface DatePickerOptions {
45  /**
46   * Specifies the start date of the date selector.
47   * @since 8
48   */
49  start?: Date;
50  /**
51   * Specifies the end date for the date selector.
52   * @since 8
53   */
54  end?: Date;
55
56  /**
57   * Specifies the date selector check date or time selector check time.
58   * @since 8
59   */
60  selected?: Date;
61}
62
63/**
64 * Defines the DatePicker Component.
65 * @since 8
66 */
67interface DatePickerInterface {
68  /**
69   * Defines the DatePicker constructor.
70   * @since 8
71   */
72  (options?: DatePickerOptions): DatePickerAttribute;
73}
74
75/**
76 * Defines the DatePicker attribute functions.
77 * @since 8
78 */
79declare class DatePickerAttribute extends CommonMethod<DatePickerAttribute> {
80  /**
81   * Date selector: true: displays the lunar calendar. false: The lunar calendar is not displayed.
82   * @since 8
83   */
84  lunar(value: boolean): DatePickerAttribute;
85
86  /**
87   * This event is triggered when a DatePicker date or time is selected.
88   * @since 8
89   */
90  onChange(callback: (value: DatePickerResult) => void): DatePickerAttribute;
91}
92
93/**
94 * Defines the DatePickerDialogOptions for Data Picker Dialog.
95 * @since 8
96 */
97declare interface DatePickerDialogOptions extends DatePickerOptions {
98  /**
99   * Date selector: true: displays the lunar calendar. false: The lunar calendar is not displayed.
100   * @since 8
101   */
102  lunar?: boolean;
103
104  /**
105   * Called when the OK button in the dialog is clicked.
106   * @since 8
107   */
108  onAccept?: (value: DatePickerResult) => void;
109  /**
110   * Called when the Cancel button in the dialog is clicked.
111   * @since 8
112   */
113  onCancel?: () => void;
114  /**
115   * This event is triggered when a DatePicker date or time is selected in dialog.
116   * @since 8
117   */
118  onChange?: (value: DatePickerResult) => void;
119}
120
121/**
122 * Defines DatePickerDialog which uses show method to show DatePicker dialog.
123 * @since 8
124 */
125declare class DatePickerDialog {
126  /**
127   * Invoking method display.
128   * @since 8
129   */
130  static show(options?: DatePickerDialogOptions);
131}
132
133/**
134 * Defines DatePicker Component.
135 * @since 8
136 */
137declare const DatePicker: DatePickerInterface;
138
139/**
140 * Defines DatePicker Component instance.
141 * @since 8
142 */
143declare const DatePickerInstance: DatePickerAttribute;
144