Refactor #5426 - For Listbox
parent
586936fd95
commit
d79ef6767d
|
@ -9,8 +9,9 @@
|
||||||
*/
|
*/
|
||||||
import { InputHTMLAttributes, VNode } from 'vue';
|
import { InputHTMLAttributes, VNode } from 'vue';
|
||||||
import { ComponentHooks } from '../basecomponent';
|
import { ComponentHooks } from '../basecomponent';
|
||||||
|
import { InputTextPassThroughOptions } from '../inputtext';
|
||||||
import { PassThroughOptions } from '../passthrough';
|
import { PassThroughOptions } from '../passthrough';
|
||||||
import { ClassComponent, GlobalComponentConstructor, PassThrough, HintedString } from '../ts-helpers';
|
import { ClassComponent, GlobalComponentConstructor, HintedString, PassThrough } from '../ts-helpers';
|
||||||
import { VirtualScrollerItemOptions, VirtualScrollerPassThroughOptionType, VirtualScrollerProps } from '../virtualscroller';
|
import { VirtualScrollerItemOptions, VirtualScrollerPassThroughOptionType, VirtualScrollerProps } from '../virtualscroller';
|
||||||
|
|
||||||
export declare type ListboxPassThroughOptionType = ListboxPassThroughAttributes | ((options: ListboxPassThroughMethodOptions) => ListboxPassThroughAttributes | string) | string | null | undefined;
|
export declare type ListboxPassThroughOptionType = ListboxPassThroughAttributes | ((options: ListboxPassThroughMethodOptions) => ListboxPassThroughAttributes | string) | string | null | undefined;
|
||||||
|
@ -49,6 +50,20 @@ export interface ListboxPassThroughMethodOptions {
|
||||||
global: object | undefined;
|
global: object | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom shared passthrough(pt) option method.
|
||||||
|
*/
|
||||||
|
export interface ListboxSharedPassThroughMethodOptions {
|
||||||
|
/**
|
||||||
|
* Defines valid properties.
|
||||||
|
*/
|
||||||
|
props: ListboxProps;
|
||||||
|
/**
|
||||||
|
* Defines current inline state.
|
||||||
|
*/
|
||||||
|
state: ListboxState;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom change event.
|
* Custom change event.
|
||||||
* @see {@link ListboxEmits.change}
|
* @see {@link ListboxEmits.change}
|
||||||
|
@ -97,9 +112,10 @@ export interface ListboxPassThroughOptions {
|
||||||
*/
|
*/
|
||||||
filterContainer?: ListboxPassThroughOptionType;
|
filterContainer?: ListboxPassThroughOptionType;
|
||||||
/**
|
/**
|
||||||
* Used to pass attributes to the filter input's DOM element.
|
* Used to pass attributes to the InputText component.
|
||||||
|
* @see {@link InputTextPassThroughOptions}
|
||||||
*/
|
*/
|
||||||
filterInput?: ListboxPassThroughOptionType;
|
filterInput?: InputTextPassThroughOptions<ListboxSharedPassThroughMethodOptions>;
|
||||||
/**
|
/**
|
||||||
* Used to pass attributes to the filter icon's DOM element.
|
* Used to pass attributes to the filter icon's DOM element.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -14,21 +14,24 @@
|
||||||
<slot name="header" :value="modelValue" :options="visibleOptions"></slot>
|
<slot name="header" :value="modelValue" :options="visibleOptions"></slot>
|
||||||
<div v-if="filter" :class="cx('header')" v-bind="ptm('header')">
|
<div v-if="filter" :class="cx('header')" v-bind="ptm('header')">
|
||||||
<div :class="cx('filterContainer')" v-bind="ptm('filterContainer')">
|
<div :class="cx('filterContainer')" v-bind="ptm('filterContainer')">
|
||||||
<input
|
<LInputText
|
||||||
ref="filterInput"
|
|
||||||
v-model="filterValue"
|
v-model="filterValue"
|
||||||
type="text"
|
type="text"
|
||||||
:class="cx('filterInput')"
|
:class="cx('filterInput')"
|
||||||
:placeholder="filterPlaceholder"
|
:placeholder="filterPlaceholder"
|
||||||
role="searchbox"
|
role="searchbox"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
|
:invalid="invalid"
|
||||||
|
:disabled="disabled"
|
||||||
|
:unstyled="unstyled"
|
||||||
:aria-owns="id + '_list'"
|
:aria-owns="id + '_list'"
|
||||||
:aria-activedescendant="focusedOptionId"
|
:aria-activedescendant="focusedOptionId"
|
||||||
:tabindex="!disabled && !focused ? tabindex : -1"
|
:tabindex="!disabled && !focused ? tabindex : -1"
|
||||||
@input="onFilterChange"
|
@input="onFilterChange"
|
||||||
@blur="onFilterBlur"
|
@blur="onFilterBlur"
|
||||||
@keydown="onFilterKeyDown"
|
@keydown="onFilterKeyDown"
|
||||||
v-bind="{ ...filterInputProps, ...ptm('filterInput') }"
|
v-bind="filterInputProps"
|
||||||
|
:pt="ptm('filterInput')"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<slot name="filtericon" :class="cx('filterIcon')">
|
<slot name="filtericon" :class="cx('filterIcon')">
|
||||||
|
@ -124,6 +127,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { FilterService } from 'primevue/api';
|
import { FilterService } from 'primevue/api';
|
||||||
import SearchIcon from 'primevue/icons/search';
|
import SearchIcon from 'primevue/icons/search';
|
||||||
|
import InputText from 'primevue/inputtext';
|
||||||
import Ripple from 'primevue/ripple';
|
import Ripple from 'primevue/ripple';
|
||||||
import { DomHandler, ObjectUtils, UniqueComponentId } from 'primevue/utils';
|
import { DomHandler, ObjectUtils, UniqueComponentId } from 'primevue/utils';
|
||||||
import VirtualScroller from 'primevue/virtualscroller';
|
import VirtualScroller from 'primevue/virtualscroller';
|
||||||
|
@ -733,6 +737,7 @@ export default {
|
||||||
ripple: Ripple
|
ripple: Ripple
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
LInputText: InputText,
|
||||||
VirtualScroller: VirtualScroller,
|
VirtualScroller: VirtualScroller,
|
||||||
SearchIcon: SearchIcon
|
SearchIcon: SearchIcon
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import BaseStyle from 'primevue/base/style';
|
import BaseStyle from 'primevue/base/style';
|
||||||
|
|
||||||
const classes = {
|
const classes = {
|
||||||
root: ({ instance, props }) => [
|
root: ({ props }) => [
|
||||||
'p-listbox p-component',
|
'p-listbox p-component',
|
||||||
{
|
{
|
||||||
'p-disabled': props.disabled,
|
'p-disabled': props.disabled,
|
||||||
|
@ -10,7 +10,7 @@ const classes = {
|
||||||
],
|
],
|
||||||
header: 'p-listbox-header',
|
header: 'p-listbox-header',
|
||||||
filterContainer: 'p-listbox-filter-container',
|
filterContainer: 'p-listbox-filter-container',
|
||||||
filterInput: 'p-listbox-filter p-inputtext p-component',
|
filterInput: 'p-listbox-filter',
|
||||||
filterIcon: 'p-listbox-filter-icon',
|
filterIcon: 'p-listbox-filter-icon',
|
||||||
wrapper: 'p-listbox-list-wrapper',
|
wrapper: 'p-listbox-list-wrapper',
|
||||||
list: 'p-listbox-list',
|
list: 'p-listbox-list',
|
||||||
|
|
Loading…
Reference in New Issue