Refactor #3922 - For Listbox

This commit is contained in:
Tuğçe Küçükoğlu 2023-05-08 00:07:47 +03:00
parent 189dea4d51
commit a84c2587e3
4 changed files with 173 additions and 16 deletions

View file

@ -9,7 +9,18 @@
*/
import { InputHTMLAttributes, VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
import { VirtualScrollerItemOptions, VirtualScrollerProps } from '../virtualscroller';
import { VirtualScrollerItemOptions, VirtualScrollerPassThroughOptionType, VirtualScrollerProps } from '../virtualscroller';
export declare type ListboxPassThroughOptionType = ListboxPassThroughAttributes | ((options: ListboxPassThroughMethodOptions) => ListboxPassThroughAttributes) | null | undefined;
/**
* Custom passthrough(pt) option method.
*/
export interface ListboxPassThroughMethodOptions {
props: ListboxProps;
state: ListboxState;
context: ListboxContext;
}
/**
* Custom change event.
@ -41,6 +52,126 @@ export interface ListboxFilterEvent {
value: string;
}
/**
* Custom passthrough(pt) options.
* @see {@link ListboxProps.pt}
*/
export interface ListboxPassThroughOptions {
/**
* Uses to pass attributes to the root's DOM element.
*/
root?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the header's DOM element.
*/
header?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the filter container's DOM element.
*/
filterContainer?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the filter input's DOM element.
*/
filterInput?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the filter icon's DOM element.
*/
filterIcon?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the wrapper's DOM element.
*/
wrapper?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the VirtualScroller component.
* @see {@link VirtualScrollerPassThroughOptionType}
*/
virtualScroller?: VirtualScrollerPassThroughOptionType;
/**
* Uses to pass attributes to the list's DOM element.
*/
list?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the item group's DOM element.
*/
itemGroup?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the item's DOM element.
*/
item?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the emptyMessage's DOM element.
*/
emptyMessage?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the hidden first focusable element's DOM element.
*/
hiddenFirstFocusableEl?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the hidden filter result's DOM element.
*/
hiddenFilterResult?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the hidden selected message's DOM element.
*/
hiddenSelectedMessage?: ListboxPassThroughOptionType;
/**
* Uses to pass attributes to the hidden last focusable element's DOM element.
*/
hiddenLastFocusableEl?: ListboxPassThroughOptionType;
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface ListboxPassThroughAttributes {
[key: string]: any;
}
/**
* Defines current inline state in Listbox component.
*/
export interface ListboxState {
/**
* Current id state as a string.
*/
id: string;
/**
* Current focused state as a boolean.
* @defaultValue false
*/
focused: boolean;
/**
* Current filter value state as a string.
*/
filterValue: string;
/**
* Current focused item index as a number.
* @defaultValue -1
*/
focusedOptionIndex: number;
}
/**
* Defines current options in Listbox component.
*/
export interface ListboxContext {
/**
* Current selection state of the item as a boolean.
* @defaultValue false
*/
selected: boolean;
/**
* Current focus state of the item as a boolean.
* @defaultValue false
*/
focused: boolean;
/**
* Current disabled state of the item as a boolean.
* @defaultValue false
*/
disabled: boolean;
}
/**
* Defines valid properties in Listbox component.
*/
@ -180,6 +311,11 @@ export interface ListboxProps {
* Identifier of the underlying input element.
*/
'aria-labelledby'?: string | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {ListboxPassThroughOptions}
*/
pt?: ListboxPassThroughOptions;
}
/**