UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

244 lines (211 loc) • 7.03 kB
/** * DevExtreme (ui/tag_box.d.ts) * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { UserDefinedElement, DxElement, } from '../core/element'; import { template, ApplyValueMode, SelectAllMode, } from '../common'; import { Cancelable, EventInfo, NativeEventInfo, InitializedEventInfo, ChangedOptionInfo, ItemInfo, } from '../common/core/events'; import { SelectionChangeInfo, } from './collection/ui.collection_widget.base'; import { DropDownButtonTemplateDataModel, } from './drop_down_editor/ui.drop_down_editor'; import { ValueChangedInfo, } from './editor/editor'; import dxSelectBox, { dxSelectBoxOptions, CustomItemCreatingInfo, } from './select_box'; /** * The type of the change event handler&apos;s argument. */ export type ChangeEvent = NativeEventInfo<dxTagBox, Event>; /** * The type of the closed event handler&apos;s argument. */ export type ClosedEvent = EventInfo<dxTagBox>; /** * The type of the contentReady event handler&apos;s argument. */ export type ContentReadyEvent = EventInfo<dxTagBox>; /** * The type of the customItemCreating event handler&apos;s argument. */ export type CustomItemCreatingEvent = EventInfo<dxTagBox> & CustomItemCreatingInfo; /** * The type of the disposing event handler&apos;s argument. */ export type DisposingEvent = EventInfo<dxTagBox>; /** * The type of the enterKey event handler&apos;s argument. */ export type EnterKeyEvent = NativeEventInfo<dxTagBox, KeyboardEvent>; /** * The type of the focusIn event handler&apos;s argument. */ export type FocusInEvent = NativeEventInfo<dxTagBox, FocusEvent>; /** * The type of the focusOut event handler&apos;s argument. */ export type FocusOutEvent = NativeEventInfo<dxTagBox, FocusEvent>; /** * The type of the initialized event handler&apos;s argument. */ export type InitializedEvent = InitializedEventInfo<dxTagBox>; /** * The type of the input event handler&apos;s argument. */ export type InputEvent = NativeEventInfo<dxTagBox, UIEvent & { target: HTMLInputElement }>; /** * The type of the itemClick event handler&apos;s argument. */ export type ItemClickEvent = NativeEventInfo<dxTagBox> & ItemInfo; /** * The type of the keyDown event handler&apos;s argument. */ export type KeyDownEvent = NativeEventInfo<dxTagBox, KeyboardEvent>; export type KeyPressEvent = NativeEventInfo<dxTagBox, KeyboardEvent>; /** * The type of the keyUp event handler&apos;s argument. */ export type KeyUpEvent = NativeEventInfo<dxTagBox, KeyboardEvent>; /** * The type of the multiTagPreparing event handler&apos;s argument. */ export type MultiTagPreparingEvent = Cancelable & EventInfo<dxTagBox> & { /** * */ readonly multiTagElement: DxElement; /** * */ readonly selectedItems?: Array<string | number | any>; /** * */ text?: string; }; /** * The type of the opened event handler&apos;s argument. */ export type OpenedEvent = EventInfo<dxTagBox>; /** * The type of the optionChanged event handler&apos;s argument. */ export type OptionChangedEvent = EventInfo<dxTagBox> & ChangedOptionInfo; /** * The type of the selectAllValueChanged event handler&apos;s argument. */ export type SelectAllValueChangedEvent = EventInfo<dxTagBox> & { /** * */ readonly value: boolean; }; /** * The type of the selectionChanged event handler&apos;s argument. */ export type SelectionChangedEvent = EventInfo<dxTagBox> & SelectionChangeInfo<string | number | any>; /** * The type of the valueChanged event handler&apos;s argument. */ export type ValueChangedEvent = NativeEventInfo<dxTagBox, KeyboardEvent | MouseEvent | PointerEvent | Event> & ValueChangedInfo; export type DropDownButtonTemplateData = DropDownButtonTemplateDataModel; /** * * @deprecated * @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution. */ export interface dxTagBoxOptions extends Pick<dxSelectBoxOptions<dxTagBox>, Exclude<keyof dxSelectBoxOptions<dxTagBox>, 'onSelectionChanged'>> { /** * Specifies how the UI component applies values. */ applyValueMode?: ApplyValueMode; /** * A Boolean value specifying whether or not to hide selected items. */ hideSelectedItems?: boolean; /** * Specifies the limit on displayed tags. On exceeding it, the UI component replaces all tags with a single multi-tag that displays the number of selected items. */ maxDisplayedTags?: number | undefined; /** * A Boolean value specifying whether or not the UI component is multiline. */ multiline?: boolean; /** * A function that is executed before the multi-tag is rendered. */ onMultiTagPreparing?: ((e: MultiTagPreparingEvent) => void); /** * A function that is executed when the &apos;Select All&apos; check box value is changed. Applies only if showSelectionControls is true. */ onSelectAllValueChanged?: ((e: SelectAllValueChangedEvent) => void); /** * A function that is executed when a list item is selected or selection is canceled. */ onSelectionChanged?: ((e: SelectionChangedEvent) => void); /** * Specifies the mode in which all items are selected. */ selectAllMode?: SelectAllMode; /** * Gets the currently selected items. */ selectedItems?: Array<string | number | any>; /** * Specifies the text displayed at the &apos;Select All&apos; check box. */ selectAllText?: string; /** * Specifies whether the drop-down button is visible. */ showDropDownButton?: boolean; /** * Specifies the maximum filter query length in characters. */ maxFilterQueryLength?: number; /** * Specifies whether the multi-tag is shown without ordinary tags. */ showMultiTagOnly?: boolean; /** * Specifies a custom template for tags. */ tagTemplate?: template | ((itemData: any, itemElement: DxElement) => string | UserDefinedElement); /** * Specifies the selected items. */ value?: Array<string | number | any>; } /** * The TagBox UI component is an editor that allows an end user to select multiple items from a drop-down list. */ export default class dxTagBox extends dxSelectBox<dxTagBoxOptions> { } export type Properties = dxTagBoxOptions; /** * @deprecated use Properties instead * @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution. */ export type Options = dxTagBoxOptions;