From f1ea8f9f9aac4d891c6ae533e6a8b829af39f672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Tue, 9 May 2023 19:03:01 +0300 Subject: [PATCH] Refactor #3924 - For OrderList --- api-generator/components/orderlist.js | 6 ++ components/lib/config/PrimeVue.d.ts | 2 + components/lib/orderlist/OrderList.d.ts | 106 ++++++++++++++++++++++++ components/lib/orderlist/OrderList.vue | 52 ++++++++---- 4 files changed, 150 insertions(+), 16 deletions(-) diff --git a/api-generator/components/orderlist.js b/api-generator/components/orderlist.js index 95fd8d805..f71b7a644 100644 --- a/api-generator/components/orderlist.js +++ b/api-generator/components/orderlist.js @@ -47,6 +47,12 @@ const OrderListProps = [ type: 'boolean', default: 'false', description: 'Whether to displays rows with alternating colors.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/config/PrimeVue.d.ts b/components/lib/config/PrimeVue.d.ts index c6ffba8a7..dd1756951 100644 --- a/components/lib/config/PrimeVue.d.ts +++ b/components/lib/config/PrimeVue.d.ts @@ -43,6 +43,7 @@ import { MenuPassThroughOptions } from '../menu'; import { MenubarPassThroughOptions } from '../menubar'; import { MessagePassThroughOptions } from '../message'; import { MultiSelectPassThroughOptions } from '../multiselect'; +import { OrderListPassThroughOptions } from '../orderlist'; import { OverlayPanelPassThroughOptions } from '../overlaypanel'; import { PaginatorPassThroughOptions } from '../paginator'; import { PanelPassThroughOptions } from '../panel'; @@ -134,6 +135,7 @@ interface PrimeVuePTOptions { menubar?: MenubarPassThroughOptions; message?: MessagePassThroughOptions; multiselect?: MultiSelectPassThroughOptions; + orderlist?: OrderListPassThroughOptions; overlaypanel?: OverlayPanelPassThroughOptions; paginator?: PaginatorPassThroughOptions; panel?: PanelPassThroughOptions; diff --git a/components/lib/orderlist/OrderList.d.ts b/components/lib/orderlist/OrderList.d.ts index c4f92c2fc..59f7f29a2 100755 --- a/components/lib/orderlist/OrderList.d.ts +++ b/components/lib/orderlist/OrderList.d.ts @@ -8,8 +8,20 @@ * */ import { ButtonHTMLAttributes, HTMLAttributes, VNode } from 'vue'; +import { ButtonPassThroughOptionType } from '../button'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type OrderListPassThroughOptionType = OrderListPassThroughAttributes | ((options: OrderListPassThroughMethodOptions) => OrderListPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface OrderListPassThroughMethodOptions { + props: OrderListProps; + state: OrderListState; + context: OrderListState; +} + /** * Custom reorder event * @see {@link OrderListEmits.reorder} @@ -44,6 +56,100 @@ export interface OrderListSelectionChangeEvent { value: any[]; } +/** + * Custom passthrough(pt) options. + * @see {@link OrderListProps.pt} + */ +export interface OrderListPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: OrderListPassThroughOptionType; + /** + * Uses to pass attributes to the controls' DOM element. + */ + controls?: OrderListPassThroughOptionType; + /** + * Uses to pass attributes to the Button component. + */ + moveUpButton?: ButtonPassThroughOptionType; + /** + * Uses to pass attributes to the Button component. + */ + moveTopButton?: ButtonPassThroughOptionType; + /** + * Uses to pass attributes to the Button component. + */ + moveDownButton?: ButtonPassThroughOptionType; + /** + * Uses to pass attributes to the Button component. + */ + moveBottomButton?: ButtonPassThroughOptionType; + /** + * Uses to pass attributes to the container's DOM element. + */ + container?: OrderListPassThroughOptionType; + /** + * Uses to pass attributes to the header's DOM element. + */ + header?: OrderListPassThroughOptionType; + /** + * Uses to pass attributes to the list's DOM element. + */ + list?: OrderListPassThroughOptionType; + /** + * Uses to pass attributes to the item's DOM element. + */ + item?: OrderListPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface OrderListPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in OrderList component. + */ +export interface OrderListState { + /** + * Current id state as a string. + */ + id: string; + /** + * Current id state as a string. + */ + d_selection: any[]; + /** + * Current focused state as a boolean. + * @defaultValue false + */ + focused: boolean; + /** + * Current focused item index as a number. + * @defaultvalue -1 + */ + focusedOptionIndex: number; +} + +/** + * Defines current inline state in OrderList component. + */ +export interface OrderListState { + /** + * Current active state of the item as a boolean. + * @defaultValue false + */ + active: boolean; + /** + * Current focus state of the item as a boolean. + * @defaultValue false + */ + focused: boolean; +} + /** * Defines valid properties in OrderList component. */ diff --git a/components/lib/orderlist/OrderList.vue b/components/lib/orderlist/OrderList.vue index ecd109db5..61c5f2c44 100755 --- a/components/lib/orderlist/OrderList.vue +++ b/components/lib/orderlist/OrderList.vue @@ -1,39 +1,39 @@