Refactor #3922 - For Chips

This commit is contained in:
Tuğçe Küçükoğlu 2023-05-05 12:36:30 +03:00
parent 7db93eb073
commit 38a8f2c3e7
4 changed files with 97 additions and 5 deletions

View file

@ -10,6 +10,16 @@
import { InputHTMLAttributes, VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
export declare type ChipsPassThroughOptionType = ChipsPassThroughAttributes | ((options: ChipsPassThroughMethodOptions) => ChipsPassThroughAttributes) | null | undefined;
/**
* Custom passthrough(pt) option method.
*/
export interface ChipsPassThroughMethodOptions {
props: ChipsProps;
state: ChipsState;
}
/**
* Custom add event.
* @see {@link ChipsEmits.add}
@ -32,6 +42,71 @@ export interface ChipsAddEvent {
*/
export interface ChipsRemoveEvent extends ChipsAddEvent {}
/**
* Custom passthrough(pt) options.
* @see {@link ChipsProps.pt}
*/
export interface ChipsPassThroughOptions {
/**
* Uses to pass attributes to the root's DOM element.
*/
root?: ChipsPassThroughOptionType;
/**
* Uses to pass attributes to the container's DOM element.
*/
container?: ChipsPassThroughOptionType;
/**
* Uses to pass attributes to the token's DOM element.
*/
token?: ChipsPassThroughOptionType;
/**
* Uses to pass attributes to the label's DOM element.
*/
label?: ChipsPassThroughOptionType;
/**
* Uses to pass attributes to the remove token icon's DOM element.
*/
removeTokenIcon?: ChipsPassThroughOptionType;
/**
* Uses to pass attributes to the input token's DOM element.
*/
inputToken?: ChipsPassThroughOptionType;
/**
* Uses to pass attributes to the input's DOM element.
*/
input?: ChipsPassThroughOptionType;
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface ChipsPassThroughAttributes {
[key: string]: any;
}
/**
* Defines current inline state in Chips component.
*/
export interface ChipsState {
/**
* Current id state as a string.
*/
id: string;
/**
* Current input value as a string.
*/
inputValue: string;
/**
* Current focused state as a boolean.
* @defaultValue false
*/
focused: boolean;
/**
* Current focused item index state as a number.
*/
focusedIndex: number;
}
/**
* Defines valid properties in Chips component.
*/
@ -96,6 +171,11 @@ export interface ChipsProps {
* Establishes a string value that labels the component.
*/
'aria-label'?: string | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {ChipsPassThroughOptions}
*/
pt?: ChipsPassThroughOptions;
}
/**
* Defines valid slots in Chips slots.