• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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 * The type of alignment between entry and calendar.
18 * @enum {number}
19 * @syscap SystemCapability.ArkUI.ArkUI.Full
20 * @crossplatform
21 * @since 10
22 */
23declare enum CalendarAlign {
24  /**
25   * The value of calendar align type start.
26   * @syscap SystemCapability.ArkUI.ArkUI.Full
27   * @crossplatform
28   * @since 10
29   */
30  START = 0,
31  /**
32   * The value of calendar align type center.
33   * @syscap SystemCapability.ArkUI.ArkUI.Full
34   * @crossplatform
35   * @since 10
36   */
37  CENTER = 1,
38  /**
39   * The value of calendar align type end.
40   * @syscap SystemCapability.ArkUI.ArkUI.Full
41   * @crossplatform
42   * @since 10
43   */
44  END = 2
45}
46
47/**
48 * Defines the options of CalendarPicker.
49 * @interface CalendarOptions
50 * @syscap SystemCapability.ArkUI.ArkUI.Full
51 * @crossplatform
52 * @since 10
53 */
54declare interface CalendarOptions {
55  /**
56   * Specifies the radius of the background of the day in calendar.
57   * @type { ?(number | Resource) }
58   * @syscap SystemCapability.ArkUI.ArkUI.Full
59   * @crossplatform
60   * @since 10
61   */
62  hintRadius?: number | Resource;
63
64  /**
65   * Specifies the date selector check date.
66   * @type { ?Date }
67   * @syscap SystemCapability.ArkUI.ArkUI.Full
68   * @crossplatform
69   * @since 10
70   */
71  selected?: Date;
72}
73
74/**
75 * Defines the CalendarPicker Component.
76 * @interface CalendarPickerInterface
77 * @syscap SystemCapability.ArkUI.ArkUI.Full
78 * @crossplatform
79 * @since 10
80 */
81interface CalendarPickerInterface {
82  /**
83   * Defines the CalendarPicker constructor.
84   * @param { CalendarOptions } options - the option of th calendarPicker.
85   * @returns { CalendarPickerAttribute } the attribute of the CalendarPicker.
86   * @syscap SystemCapability.ArkUI.ArkUI.Full
87   * @crossplatform
88   * @since 10
89   */
90  (options?: CalendarOptions): CalendarPickerAttribute;
91}
92
93/**
94 * Defines the CalendarPicker attribute functions.
95 * @extends CommonMethod
96 * @syscap SystemCapability.ArkUI.ArkUI.Full
97 * @crossplatform
98 * @since 10
99 */
100declare class CalendarPickerAttribute extends CommonMethod<CalendarPickerAttribute> {
101  /**
102   * Set the alignment between entry and calendar dialog.
103   * @param { CalendarAlign } alignType - The type of alignment between entry and calendar dialog.
104   * @param { Offset } offset - The offset between entry and calendar dialog.
105   * @returns { CalendarPickerAttribute } the attribute of the CalendarPicker.
106   * @syscap SystemCapability.ArkUI.ArkUI.Full
107   * @crossplatform
108   * @since 10
109   */
110  edgeAlign(alignType: CalendarAlign, offset?: Offset): CalendarPickerAttribute;
111
112  /**
113   * Sets the text style of entry
114   * @param { PickerTextStyle } value - indicates the text style of entry.
115   * @returns { CalendarPickerAttribute } the attribute of the CalendarPicker.
116   * @syscap SystemCapability.ArkUI.ArkUI.Full
117   * @crossplatform
118   * @since 10
119   */
120  textStyle(value: PickerTextStyle): CalendarPickerAttribute;
121
122  /**
123   * Callback for selected date changed.
124   * @param { function } callback - Callback for selected date changed.
125   * @returns { CalendarPickerAttribute } the attribute of the CalendarPicker.
126   * @syscap SystemCapability.ArkUI.ArkUI.Full
127   * @crossplatform
128   * @since 10
129   */
130  onChange(callback: (value: Date) => void): CalendarPickerAttribute;
131}
132
133/**
134 * Defines the DatePickerDialogOptions for Calendar Picker Dialog.
135 * @interface CalendarDialogOptions
136 * @syscap SystemCapability.ArkUI.ArkUI.Full
137 * @crossplatform
138 * @since 10
139 */
140declare interface CalendarDialogOptions extends CalendarOptions {
141  /**
142   * Called when the OK button in the dialog is clicked.
143   * @type { ?function }
144   * @syscap SystemCapability.ArkUI.ArkUI.Full
145   * @crossplatform
146   * @since 10
147   */
148  onAccept?: (value: Date) => void;
149
150  /**
151   * Called when the Cancel button in the dialog is clicked.
152   * @type { ?function }
153   * @syscap SystemCapability.ArkUI.ArkUI.Full
154   * @crossplatform
155   * @since 10
156   */
157  onCancel?: () => void;
158
159  /**
160   * This event is triggered when a date is selected in dialog.
161   * @type { ?function }
162   * @syscap SystemCapability.ArkUI.ArkUI.Full
163   * @crossplatform
164   * @since 10
165   */
166  onChange?: (value: Date) => void;
167}
168
169/**
170 * Defines CalendarPickerDialog which uses show method to show CalendarPicker dialog.
171 * @syscap SystemCapability.ArkUI.ArkUI.Full
172 * @crossplatform
173 * @since 10
174 */
175declare class CalendarPickerDialog {
176  /**
177   * Invoking method display.
178   * @param { CalendarDialogOptions } options - the option of th calendarPicker.
179   * @syscap SystemCapability.ArkUI.ArkUI.Full
180   * @crossplatform
181   * @since 10
182   */
183  static show(options?: CalendarDialogOptions): void;
184}
185
186/**
187 * Defines CalendarPicker Component.
188 * @syscap SystemCapability.ArkUI.ArkUI.Full
189 * @crossplatform
190 * @since 10
191 */
192declare const CalendarPicker: CalendarPickerInterface;
193
194/**
195 * Defines CalendarPicker Component instance.
196 * @syscap SystemCapability.ArkUI.ArkUI.Full
197 * @crossplatform
198 * @since 10
199 */
200declare const CalendarPickerInstance: CalendarPickerAttribute;
201