From 2442622e9d9883defd0d714d15982c9bb6bc905a Mon Sep 17 00:00:00 2001 From: l00517909 Date: Tue, 29 Apr 2025 14:20:31 +0800 Subject: [PATCH] add new picker Signed-off-by: l00517909 luoying19@huawei.com --- api/@internal/component/ets/index-full.d.ts | 1 + api/@internal/component/ets/picker.d.ts | 299 ++++++++++++++++++ api/arkui/PickerModifier.d.ts | 42 +++ .../collect_application_api/tsconfig.json | 8 +- build-tools/dts_parser/kit.json | 2 + .../dts_parser/src/config/tsconfig.json | 8 +- 6 files changed, 358 insertions(+), 2 deletions(-) create mode 100644 api/@internal/component/ets/picker.d.ts create mode 100644 api/arkui/PickerModifier.d.ts diff --git a/api/@internal/component/ets/index-full.d.ts b/api/@internal/component/ets/index-full.d.ts index 76ab07278c..30b4f13198 100644 --- a/api/@internal/component/ets/index-full.d.ts +++ b/api/@internal/component/ets/index-full.d.ts @@ -125,6 +125,7 @@ /// /// /// +/// /// /// /// diff --git a/api/@internal/component/ets/picker.d.ts b/api/@internal/component/ets/picker.d.ts new file mode 100644 index 0000000000..2509820380 --- /dev/null +++ b/api/@internal/component/ets/picker.d.ts @@ -0,0 +1,299 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @kit ArkUI + */ + +/** + * Defines the options of Picker. + * + * @interface PickerOptions + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ +declare interface PickerOptions { + /** + * Current selected subscript. + * + * @type { ?number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + selectedIndex?: number; +} + +/** + * PickerInterface + * + * @interface PickerInterface + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ +interface PickerInterface { + /** + * Defines the Picker constructor. + * + * @param { PickerOptions } options + * @returns { PickerAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + (options?: PickerOptions): PickerAttribute; +} + +/** + * Callback of Picker item is selected event. + * + * @typedef {function} OnPickerChangeCallback + * @param { number } selectedIndex - Index of the selected item. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ +declare type OnPickerChangeCallback = (selectedIndex: number) => void; + +/** + * IndicatorType + * + * @enum { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ +declare enum IndicatorType { + /** + * Divider marks the selected item. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + DIVIDER = 0, + + /** + * Background marks the selected item. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + BACKGROUND = 1, +} + +/** + * Defines the options of Indicator style. + * + * @interface PickerIndicatorStyle + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ +declare interface PickerIndicatorStyle { + /** + * The type of indicator. + * + * @type { IndicatorType } type + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + type: IndicatorType; + + /** + * The width of Divider. + * + * @type { ?LengthMetrics } dividerWidth + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + dividerWidth?: LengthMetrics; + + /** + * The color of Divider. + * + * @type { ?ResourceColor } dividerColor + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + dividerColor?: ResourceColor; + + /** + * The startMargin of Divider. + * + * @type { ?LengthMetrics } startMargin + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + startMargin?: LengthMetrics; + + /** + * The endMargin of Divider. + * + * @type { ?LengthMetrics } endMargin + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + endMargin?: LengthMetrics; + + /** + * Define the background color of selected item. + * + * @type { ?ResourceColor } backgroundColor + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + backgroundColor?: ResourceColor; + + /** + * Defines the border radius of selected items. + * + * @type { ?(LengthMetrics | BorderRadiuses | LocalizedBorderRadiuses) } borderRadius + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + borderRadius?: LengthMetrics | BorderRadiuses | LocalizedBorderRadiuses; +} + +/** + * Style the picker. + * + * @extends CommonMethod + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ +declare class PickerAttribute extends CommonMethod { + /** + * This event is triggered when a Picker item is selected. + * + * @param { Optional } callback - the callback of onChange. + * @returns { PickerAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + onChange(callback: Optional): PickerAttribute; + + /** + * This event is triggered when a Picker item is selected and scrolling has stopped. + * + * @param { Optional } callback - the callback of onScrollStop. + * @returns { PickerAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + onScrollStop(callback: Optional): PickerAttribute; + + /** + * Can scroll loop if true is set, on the contrary it can not. + * + * @param { Optional } isLoop + * @returns { PickerAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + canLoop(isLoop: Optional): PickerAttribute; + + /** + * Enable or disable haptic feedback. + * + * @param { Optional } enable - Default value is true, set false to disable haptic feedback. + * @returns { PickerAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 20 + */ + enableHapticFeedback(enable: Optional): PickerAttribute; + + /** + * Sets the text style of selected items + * + * @param { Optional } style - indicates the text style of selected items. + * @returns { PickerAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + selectedTextStyle(style: Optional): PickerAttribute; + + /** + * Sets the indicator's type and style. + * + * @param { Optional } style + * @returns { PickerAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + selectionIndicator(style: Optional): PickerAttribute; +} + +/** + * Defines Picker Component. + * + * @type { PickerInterface } Picker + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ +declare const Picker: PickerInterface; + +/** + * Defines Picker Component instance. + * + * @type { PickerAttribute } PickerInstance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ +declare const PickerInstance: PickerAttribute; diff --git a/api/arkui/PickerModifier.d.ts b/api/arkui/PickerModifier.d.ts new file mode 100644 index 0000000000..4ef7fc204b --- /dev/null +++ b/api/arkui/PickerModifier.d.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @kit ArkUI + */ + +/** + * Defines Picker Modifier + * + * @extends PickerAttribute + * @implements AttributeModifier + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 20 +*/ +export declare class PickerModifier extends PickerAttribute implements AttributeModifier { + + /** + * Defines the normal update attribute function. + * + * @param { PickerAttribute } instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + applyNormalAttribute?(instance: PickerAttribute): void; +} diff --git a/build-tools/collect_application_api/tsconfig.json b/build-tools/collect_application_api/tsconfig.json index 2ec2a323ff..43c2287ef0 100644 --- a/build-tools/collect_application_api/tsconfig.json +++ b/build-tools/collect_application_api/tsconfig.json @@ -63,6 +63,7 @@ "Particle", "Path", "PatternLock", + "Picker", "Piece", "PluginComponent", "Polygon", @@ -393,6 +394,11 @@ "type": "PatternLockAttribute", "instance": "PatternLockInstance" }, + { + "name": "Picker", + "type": "PickerAttribute", + "instance": "PickerInterface" + }, { "name": "Piece", "type": "PieceAttribute", @@ -663,4 +669,4 @@ "exclude": [ "node_modules" ] -} \ No newline at end of file +} diff --git a/build-tools/dts_parser/kit.json b/build-tools/dts_parser/kit.json index 0baee0c4ac..e0690d2e8b 100644 --- a/build-tools/dts_parser/kit.json +++ b/build-tools/dts_parser/kit.json @@ -76,6 +76,7 @@ { "filePath": "@internal/component/ets/paste_button.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "@internal/component/ets/path.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "@internal/component/ets/pattern_lock.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, + { "filePath": "@internal/component/ets/picker.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "@internal/component/ets/plugin_component.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "@internal/component/ets/polygon.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "@internal/component/ets/polyline.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, @@ -784,6 +785,7 @@ { "filePath": "arkui/PanelModifier.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "arkui/PathModifier.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "arkui/PatternLockModifier.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, + { "filePath": "arkui/PickerModifier.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "arkui/PolygonModifier.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "arkui/PolylineModifier.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, { "filePath": "arkui/ProgressModifier.d.ts", "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, diff --git a/build-tools/dts_parser/src/config/tsconfig.json b/build-tools/dts_parser/src/config/tsconfig.json index df048744d3..521e72d763 100644 --- a/build-tools/dts_parser/src/config/tsconfig.json +++ b/build-tools/dts_parser/src/config/tsconfig.json @@ -62,6 +62,7 @@ "Particle", "Path", "PatternLock", + "Picker", "Piece", "PluginComponent", "Polygon", @@ -387,6 +388,11 @@ "type": "PatternLockAttribute", "instance": "PatternLockInstance" }, + { + "name": "Picker", + "type": "PickerAttribute", + "instance": "PickerInterface" + }, { "name": "Piece", "type": "PieceAttribute", @@ -657,4 +663,4 @@ "exclude": [ "node_modules" ] -} \ No newline at end of file +} -- Gitee