• 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 * @file
18 * @kit ArkUI
19 */
20
21/**
22 * Enum for the counter type.
23 *
24 * @enum { number }
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @crossplatform
27 * @since 11
28 */
29declare enum CounterType {
30    /**
31     * List counter.
32     * @syscap SystemCapability.ArkUI.ArkUI.Full
33     * @crossplatform
34     * @since 11
35     */
36    LIST = 0,
37
38    /**
39     * Compact counter.
40     * @syscap SystemCapability.ArkUI.ArkUI.Full
41     * @crossplatform
42     * @since 11
43     */
44    COMPACT = 1,
45
46    /**
47     * Inline counter.
48     * @syscap SystemCapability.ArkUI.ArkUI.Full
49     * @crossplatform
50     * @since 11
51     */
52    INLINE = 2,
53
54    /**
55     * Date inline counter.
56     * @syscap SystemCapability.ArkUI.ArkUI.Full
57     * @crossplatform
58     * @since 11
59     */
60    INLINE_DATE = 3
61}
62
63/**
64 * Defines the common options.
65 *
66 * @syscap SystemCapability.ArkUI.ArkUI.Full
67 * @crossplatform
68 * @since 11
69 */
70declare class CommonOptions {
71    /**
72     * Set the focusable of the counter component.
73     * @type { ?boolean }
74     * @default true
75     * @syscap SystemCapability.ArkUI.ArkUI.Full
76     * @crossplatform
77     * @since 11
78     */
79    focusable?: boolean;
80
81    /**
82     * Set the step of the couter component, ranges greater than or equal to 1
83     *
84     * @type { ?number }
85     * @default 1
86     * @syscap SystemCapability.ArkUI.ArkUI.Full
87     * @crossplatform
88     * @since 11
89     */
90    step?: number;
91
92    /**
93     * Trigger a mouse hover event at the increased button.
94     *
95     * @type { ?function }
96     * @syscap SystemCapability.ArkUI.ArkUI.Full
97     * @crossplatform
98     * @since 11
99     */
100    onHoverIncrease?: (isHover: boolean) => void;
101
102    /**
103     * Trigger a mouse hover event at the decreased button.
104     *
105     * @type { ?function }
106     * @syscap SystemCapability.ArkUI.ArkUI.Full
107     * @crossplatform
108     * @since 11
109     */
110    onHoverDecrease?: (isHover: boolean) => void;
111}
112
113/**
114 * Defines the inline style options.
115 *
116 * @syscap SystemCapability.ArkUI.ArkUI.Full
117 * @crossplatform
118 * @since 11
119 */
120declare class InlineStyleOptions extends CommonOptions {
121    /**
122     * Set initial value of the counter component, ranges from min to max.
123     *
124     * @type { ?number }
125     * @default 0
126     * @syscap SystemCapability.ArkUI.ArkUI.Full
127     * @crossplatform
128     * @since 11
129     */
130    value?: number;
131
132    /**
133     * Set minimum value of the counter component
134     *
135     * @type { ?number }
136     * @default 0
137     * @syscap SystemCapability.ArkUI.ArkUI.Full
138     * @crossplatform
139     * @since 11
140     */
141    min?: number;
142
143    /**
144     * Set maximum value of the counter component
145     *
146     * @type { ?number }
147     * @default 999
148     * @syscap SystemCapability.ArkUI.ArkUI.Full
149     * @crossplatform
150     * @since 11
151     */
152    max?: number;
153
154    /**
155     * Set text width  of the counter component,  ranges greater than or equal to 0
156     *
157     * @type { ?number }
158     * @default 0
159     * @syscap SystemCapability.ArkUI.ArkUI.Full
160     * @crossplatform
161     * @since 11
162     */
163    textWidth?: number;
164
165    /**
166     * Trigger a event when the value of the counter has been changed.
167     *
168     * @type { ?function }
169     * @syscap SystemCapability.ArkUI.ArkUI.Full
170     * @crossplatform
171     * @since 11
172     */
173    onChange?: (value: number) => void;
174}
175
176/**
177 * Defines the number style options.
178 *
179 * @syscap SystemCapability.ArkUI.ArkUI.Full
180 * @crossplatform
181 * @since 11
182 */
183declare class NumberStyleOptions extends InlineStyleOptions {
184    /**
185     * Set the label of the counter component.
186     *
187     * @type { ?ResourceStr }
188     * @syscap SystemCapability.ArkUI.ArkUI.Full
189     * @crossplatform
190     * @since 11
191     */
192    label?: ResourceStr;
193
194    /**
195     * Trigger a event when the increased button got focus.
196     *
197     * @type { ?function }
198     * @syscap SystemCapability.ArkUI.ArkUI.Full
199     * @crossplatform
200     * @since 11
201     */
202    onFocusIncrease?: () => void;
203
204    /**
205     * Trigger a event when the decreased button got focus.
206     *
207     * @type { ?function }
208     * @syscap SystemCapability.ArkUI.ArkUI.Full
209     * @crossplatform
210     * @since 11
211     */
212    onFocusDecrease?: () => void;
213
214    /**
215     * Trigger a event when the increased button lose focus.
216     *
217     * @type { ?function }
218     * @syscap SystemCapability.ArkUI.ArkUI.Full
219     * @crossplatform
220     * @since 11
221     */
222    onBlurIncrease?: () => void;
223
224    /**
225     * Trigger a event when the decreased button lose focus.
226     *
227     * @type { ?function }
228     * @syscap SystemCapability.ArkUI.ArkUI.Full
229     * @crossplatform
230     * @since 11
231     */
232    onBlurDecrease?: () => void;
233}
234
235/**
236 * Defines the date data.
237 *
238 * @syscap SystemCapability.ArkUI.ArkUI.Full
239 * @crossplatform
240 * @since 11
241 */
242declare class DateData {
243    /**
244     * The year of the DateData, ranges from 1 to 5000.
245     *
246     * @type { number }
247     * @syscap SystemCapability.ArkUI.ArkUI.Full
248     * @crossplatform
249     * @since 11
250     */
251    year: number;
252
253    /**
254     * The month of the DateData.
255     *
256     * @type { number }
257     * @syscap SystemCapability.ArkUI.ArkUI.Full
258     * @crossplatform
259     * @since 11
260     */
261    month: number;
262
263    /**
264     * The day of the DateData.
265     *
266     * @type { number }
267     * @syscap SystemCapability.ArkUI.ArkUI.Full
268     * @crossplatform
269     * @since 11
270     */
271    day: number;
272
273    /**
274     * Constructor of the DateData.
275     *
276     * @param { number } year - set the year of the DateData.
277     * @param { number } month - set the month of the DateData.
278     * @param { number } day - set the day of the DateData.
279     * @syscap SystemCapability.ArkUI.ArkUI.Full
280     * @crossplatform
281     * @since 11
282     */
283    constructor(year: number, month: number, day: number);
284
285    /**
286     * Convert the date data to string.
287     *
288     * @returns { string } date data in string form.
289     * @syscap SystemCapability.ArkUI.ArkUI.Full
290     * @crossplatform
291     * @since 11
292     */
293    toString(): string;
294}
295
296/**
297 * Defines the date style options.
298 *
299 * @syscap SystemCapability.ArkUI.ArkUI.Full
300 * @crossplatform
301 * @since 11
302 */
303declare class DateStyleOptions extends CommonOptions {
304    /**
305     * Set the year of the counter component, ranges from 1 to 5000.
306     *
307     * @type { ?number }
308     * @default 1
309     * @syscap SystemCapability.ArkUI.ArkUI.Full
310     * @crossplatform
311     * @since 11
312     */
313    year?: number;
314
315    /**
316     * Set the month of the counter component.
317     *
318     * @type { ?number }
319     * @default 1
320     * @syscap SystemCapability.ArkUI.ArkUI.Full
321     * @crossplatform
322     * @since 11
323     */
324    month?: number;
325
326    /**
327     * Set the day of the counter component.
328     *
329     * @type { ?number }
330     * @default 1
331     * @syscap SystemCapability.ArkUI.ArkUI.Full
332     * @crossplatform
333     * @since 11
334     */
335    day?: number;
336
337    /**
338     * Trigger a event when the date of the counter has been changed.
339     *
340     * @type { ?function }
341     * @syscap SystemCapability.ArkUI.ArkUI.Full
342     * @crossplatform
343     * @since 11
344     */
345    onDateChange?: (date: DateData) => void;
346}
347
348
349/**
350 * Defines the counter options.
351 *
352 * @syscap SystemCapability.ArkUI.ArkUI.Full
353 * @crossplatform
354 * @since 11
355 */
356declare class CounterOptions {
357    /**
358     * Set the type of the counter component.
359     *
360     * @type { CounterType }
361     * @syscap SystemCapability.ArkUI.ArkUI.Full
362     * @crossplatform
363     * @since 11
364     */
365    type: CounterType;
366
367    /**
368     * Set the counter attribute of the LIST or COMPACT counter component.
369     *
370     * @type { ?NumberStyleOptions }
371     * @syscap SystemCapability.ArkUI.ArkUI.Full
372     * @crossplatform
373     * @since 11
374     */
375    numberOptions?: NumberStyleOptions;
376
377    /**
378     * Set the counter attribute of the INLINE counter component.
379     *
380     * @type { ?InlineStyleOptions }
381     * @syscap SystemCapability.ArkUI.ArkUI.Full
382     * @crossplatform
383     * @since 11
384     */
385    inlineOptions?: InlineStyleOptions;
386
387    /**
388     * Set the counter attribute of the INLINE_DATE counter component.
389     *
390     * @type { ?DateStyleOptions }
391     * @syscap SystemCapability.ArkUI.ArkUI.Full
392     * @crossplatform
393     * @since 11
394     */
395    dateOptions?: DateStyleOptions;
396}
397
398/**
399 * Defines Counter Component.
400 *
401 * @syscap SystemCapability.ArkUI.ArkUI.Full
402 * @crossplatform
403 * @since 11
404 */
405@Component
406declare struct CounterComponent {
407    /**
408     * The options of a counter component.
409     *
410     * @type { CounterOptions }
411     * @syscap SystemCapability.ArkUI.ArkUI.Full
412     * @crossplatform
413     * @since 11
414     */
415    @Prop
416    options: CounterOptions;
417}
418
419export {CounterComponent, CounterOptions, DateData, CounterType}
420