2023-03-01 13:12:09 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Chip represents people using icons, labels and images.
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/chip)
|
|
|
|
*
|
|
|
|
* @module chip
|
|
|
|
*
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
import { VNode } from 'vue';
|
2023-07-06 11:17:08 +00:00
|
|
|
import { ComponentHooks } from '../basecomponent';
|
2023-09-05 08:50:46 +00:00
|
|
|
import { PassThroughOptions } from '../passthrough';
|
2024-05-16 10:50:43 +00:00
|
|
|
import { DefineComponent, DesignToken, EmitFn, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2024-04-08 12:20:42 +00:00
|
|
|
export declare type ChipPassThroughOptionType<T = any> = ChipPassThroughAttributes | ((options: ChipPassThroughMethodOptions<T>) => ChipPassThroughAttributes | string) | string | null | undefined;
|
2023-04-21 13:24:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) option method.
|
|
|
|
*/
|
2024-04-08 12:20:42 +00:00
|
|
|
export interface ChipPassThroughMethodOptions<T> {
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines instance.
|
|
|
|
*/
|
2023-07-06 12:01:33 +00:00
|
|
|
instance: any;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties.
|
|
|
|
*/
|
2023-04-21 13:24:22 +00:00
|
|
|
props: ChipProps;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines current inline state.
|
|
|
|
*/
|
2023-04-21 13:24:22 +00:00
|
|
|
state: ChipState;
|
2023-12-10 21:41:17 +00:00
|
|
|
/**
|
|
|
|
* Defines valid attributes.
|
|
|
|
*/
|
|
|
|
attrs: any;
|
2023-12-05 11:06:32 +00:00
|
|
|
/**
|
|
|
|
* Defines parent options.
|
|
|
|
*/
|
2024-04-08 12:20:42 +00:00
|
|
|
parent: T;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Defines passthrough(pt) options in global config.
|
|
|
|
*/
|
|
|
|
global: object | undefined;
|
2023-04-21 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) options.
|
|
|
|
* @see {@link ChipProps.pt}
|
|
|
|
*/
|
2024-04-08 12:20:42 +00:00
|
|
|
export interface ChipPassThroughOptions<T = any> {
|
2023-04-21 13:24:22 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the root's DOM element.
|
2023-04-21 13:24:22 +00:00
|
|
|
*/
|
2024-04-08 12:20:42 +00:00
|
|
|
root?: ChipPassThroughOptionType<T>;
|
2023-04-21 13:24:22 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the image's DOM element.
|
2023-04-21 13:24:22 +00:00
|
|
|
*/
|
2024-04-08 12:20:42 +00:00
|
|
|
image?: ChipPassThroughOptionType<T>;
|
2023-04-21 13:24:22 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the icon's DOM element.
|
2023-04-21 13:24:22 +00:00
|
|
|
*/
|
2024-04-08 12:20:42 +00:00
|
|
|
icon?: ChipPassThroughOptionType<T>;
|
2023-04-21 13:24:22 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the label' DOM element.
|
2023-04-21 13:24:22 +00:00
|
|
|
*/
|
2024-04-08 12:20:42 +00:00
|
|
|
label?: ChipPassThroughOptionType<T>;
|
2023-04-21 13:24:22 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the removeIcon's DOM element.
|
2023-04-21 13:24:22 +00:00
|
|
|
*/
|
2024-04-08 12:20:42 +00:00
|
|
|
removeIcon?: ChipPassThroughOptionType<T>;
|
2023-07-06 11:09:01 +00:00
|
|
|
/**
|
2023-11-07 06:16:39 +00:00
|
|
|
* Used to manage all lifecycle hooks.
|
2023-07-06 11:09:01 +00:00
|
|
|
* @see {@link BaseComponent.ComponentHooks}
|
|
|
|
*/
|
|
|
|
hooks?: ComponentHooks;
|
2023-04-21 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough attributes for each DOM elements
|
|
|
|
*/
|
|
|
|
export interface ChipPassThroughAttributes {
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines current inline state in Chip component.
|
|
|
|
*/
|
|
|
|
export interface ChipState {
|
|
|
|
/**
|
|
|
|
* Current visible state as a boolean.
|
|
|
|
* @defaultValue true
|
|
|
|
*/
|
|
|
|
visible: boolean;
|
|
|
|
}
|
|
|
|
|
2023-03-01 13:12:09 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties in Chip component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface ChipProps {
|
|
|
|
/**
|
|
|
|
* Defines the text to display.
|
|
|
|
*/
|
|
|
|
label?: string;
|
|
|
|
/**
|
|
|
|
* Defines the icon to display.
|
|
|
|
*/
|
|
|
|
icon?: string;
|
|
|
|
/**
|
|
|
|
* Defines the image to display.
|
|
|
|
*/
|
|
|
|
image?: string;
|
|
|
|
/**
|
|
|
|
* Whether to display a remove icon.
|
2023-03-01 13:12:09 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
removable?: boolean;
|
|
|
|
/**
|
|
|
|
* Icon of the remove element.
|
|
|
|
*/
|
|
|
|
removeIcon?: string;
|
2024-04-02 08:24:31 +00:00
|
|
|
/**
|
|
|
|
* It generates scoped CSS variables using design tokens for the component.
|
|
|
|
*/
|
|
|
|
dt?: DesignToken<any>;
|
2023-04-21 13:24:22 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to DOM elements inside the component.
|
2023-04-21 13:24:22 +00:00
|
|
|
* @type {ChipPassThroughOptions}
|
|
|
|
*/
|
2023-09-05 11:28:04 +00:00
|
|
|
pt?: PassThrough<ChipPassThroughOptions>;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Used to configure passthrough(pt) options of the component.
|
|
|
|
* @type {PassThroughOptions}
|
|
|
|
*/
|
|
|
|
ptOptions?: PassThroughOptions;
|
2023-05-24 07:39:02 +00:00
|
|
|
/**
|
|
|
|
* When enabled, it removes component related styles in the core.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
unstyled?: boolean;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 13:12:09 +00:00
|
|
|
/**
|
|
|
|
* Defines valid slots in Chip component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface ChipSlots {
|
|
|
|
/**
|
|
|
|
* Content can easily be customized with the default slot instead of using the built-in modes.
|
|
|
|
*/
|
2023-03-01 13:12:09 +00:00
|
|
|
default(): VNode[];
|
2023-04-18 07:37:05 +00:00
|
|
|
/**
|
|
|
|
* Custom icon template.
|
|
|
|
*/
|
|
|
|
icon(): VNode[];
|
2023-04-10 19:42:57 +00:00
|
|
|
/**
|
|
|
|
* Custom remove icon template of chip component.
|
|
|
|
* @param {Object} scope - remove icon slot's params.
|
|
|
|
*/
|
|
|
|
removeicon(scope: {
|
2023-10-31 17:21:47 +00:00
|
|
|
/**
|
|
|
|
* Remove icon click event
|
|
|
|
* @param {Event} event - Browser event
|
|
|
|
*/
|
|
|
|
removeCallback: (event: Event) => void;
|
|
|
|
/**
|
|
|
|
* Remove icon keydown event
|
|
|
|
* @param {Event} event - Browser event
|
|
|
|
*/
|
|
|
|
keydownCallback: (event: Event) => void;
|
2023-04-10 19:42:57 +00:00
|
|
|
}): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 13:12:09 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties in Chip component.
|
|
|
|
*/
|
2024-05-16 14:05:43 +00:00
|
|
|
export interface ChipEmitsOptions {
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when a chip is removed.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*/
|
2023-03-01 13:12:09 +00:00
|
|
|
remove(event: Event): void;
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2024-05-16 10:50:43 +00:00
|
|
|
export declare type ChipEmits = EmitFn<ChipEmitsOptions>;
|
|
|
|
|
2023-03-01 13:12:09 +00:00
|
|
|
/**
|
|
|
|
* **PrimeVue - Chip**
|
|
|
|
*
|
|
|
|
* _Chip represents people using icons, labels and images._
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/chip/)
|
|
|
|
* --- ---
|
|
|
|
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
|
|
|
|
*
|
|
|
|
* @group Component
|
2024-05-16 10:50:43 +00:00
|
|
|
*
|
2023-03-01 13:12:09 +00:00
|
|
|
*/
|
2024-05-16 10:50:43 +00:00
|
|
|
declare const Chip: DefineComponent<ChipProps, ChipSlots, ChipEmits>;
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2024-03-14 22:58:11 +00:00
|
|
|
declare module 'vue' {
|
|
|
|
export interface GlobalComponents {
|
2024-05-16 10:50:43 +00:00
|
|
|
Chip: GlobalComponentConstructor<ChipProps, ChipSlots, ChipEmits>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Chip;
|