primevue 3.15.0 → 3.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autocomplete/AutoComplete.d.ts +182 -38
- package/autocomplete/AutoComplete.vue +636 -342
- package/autocomplete/autocomplete.cjs.js +745 -416
- package/autocomplete/autocomplete.cjs.min.js +1 -1
- package/autocomplete/autocomplete.esm.js +747 -418
- package/autocomplete/autocomplete.esm.min.js +1 -1
- package/autocomplete/autocomplete.js +745 -416
- package/autocomplete/autocomplete.min.js +1 -1
- package/button/Button.vue +4 -1
- package/button/button.cjs.js +5 -1
- package/button/button.cjs.min.js +1 -1
- package/button/button.esm.js +5 -1
- package/button/button.esm.min.js +1 -1
- package/button/button.js +5 -1
- package/button/button.min.js +1 -1
- package/calendar/Calendar.d.ts +51 -12
- package/calendar/Calendar.vue +259 -114
- package/calendar/calendar.cjs.js +414 -220
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +415 -221
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +414 -220
- package/calendar/calendar.min.js +1 -1
- package/carousel/Carousel.vue +25 -0
- package/carousel/carousel.cjs.js +25 -0
- package/carousel/carousel.cjs.min.js +1 -1
- package/carousel/carousel.esm.js +25 -0
- package/carousel/carousel.esm.min.js +1 -1
- package/carousel/carousel.js +25 -0
- package/carousel/carousel.min.js +1 -1
- package/cascadeselect/CascadeSelect.d.ts +97 -17
- package/cascadeselect/CascadeSelect.vue +560 -135
- package/cascadeselect/CascadeSelectSub.vue +48 -129
- package/cascadeselect/cascadeselect.cjs.js +670 -306
- package/cascadeselect/cascadeselect.cjs.min.js +1 -1
- package/cascadeselect/cascadeselect.esm.js +672 -308
- package/cascadeselect/cascadeselect.esm.min.js +1 -1
- package/cascadeselect/cascadeselect.js +670 -306
- package/cascadeselect/cascadeselect.min.js +1 -1
- package/checkbox/Checkbox.d.ts +40 -4
- package/checkbox/Checkbox.vue +50 -13
- package/checkbox/checkbox.cjs.js +64 -23
- package/checkbox/checkbox.cjs.min.js +1 -1
- package/checkbox/checkbox.esm.js +65 -24
- package/checkbox/checkbox.esm.min.js +1 -1
- package/checkbox/checkbox.js +64 -23
- package/checkbox/checkbox.min.js +1 -1
- package/chips/Chips.d.ts +36 -12
- package/chips/Chips.vue +116 -22
- package/chips/chips.cjs.js +149 -37
- package/chips/chips.cjs.min.js +1 -1
- package/chips/chips.esm.js +150 -38
- package/chips/chips.esm.min.js +1 -1
- package/chips/chips.js +150 -39
- package/chips/chips.min.js +1 -1
- package/colorpicker/ColorPicker.d.ts +3 -6
- package/colorpicker/ColorPicker.vue +1 -5
- package/colorpicker/colorpicker.cjs.js +2 -7
- package/colorpicker/colorpicker.cjs.min.js +1 -1
- package/colorpicker/colorpicker.esm.js +2 -7
- package/colorpicker/colorpicker.esm.min.js +1 -1
- package/colorpicker/colorpicker.js +2 -7
- package/colorpicker/colorpicker.min.js +1 -1
- package/column/Column.d.ts +4 -0
- package/column/Column.vue +4 -0
- package/column/column.cjs.js +4 -0
- package/column/column.cjs.min.js +1 -1
- package/column/column.esm.js +4 -0
- package/column/column.esm.min.js +1 -1
- package/column/column.js +4 -0
- package/column/column.min.js +1 -1
- package/config/PrimeVue.d.ts +42 -0
- package/config/config.cjs.js +35 -4
- package/config/config.cjs.min.js +1 -1
- package/config/config.esm.js +35 -4
- package/config/config.esm.min.js +1 -1
- package/config/config.js +35 -4
- package/config/config.min.js +1 -1
- package/confirmdialog/ConfirmDialog.vue +4 -1
- package/confirmdialog/confirmdialog.cjs.js +6 -2
- package/confirmdialog/confirmdialog.cjs.min.js +1 -1
- package/confirmdialog/confirmdialog.esm.js +6 -2
- package/confirmdialog/confirmdialog.esm.min.js +1 -1
- package/confirmdialog/confirmdialog.js +6 -2
- package/confirmdialog/confirmdialog.min.js +1 -1
- package/contextmenu/ContextMenu.d.ts +1 -1
- package/contextmenu/ContextMenuSub.vue +3 -3
- package/contextmenu/contextmenu.cjs.js +14 -8
- package/contextmenu/contextmenu.cjs.min.js +1 -1
- package/contextmenu/contextmenu.esm.js +15 -9
- package/contextmenu/contextmenu.esm.min.js +1 -1
- package/contextmenu/contextmenu.js +14 -8
- package/contextmenu/contextmenu.min.js +1 -1
- package/core/core.js +1128 -772
- package/core/core.min.js +12 -12
- package/datatable/BodyCell.vue +11 -2
- package/datatable/DataTable.vue +23 -2
- package/datatable/datatable.cjs.js +34 -4
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.esm.js +34 -4
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +34 -4
- package/datatable/datatable.min.js +1 -1
- package/dialog/Dialog.d.ts +5 -1
- package/dropdown/Dropdown.d.ts +92 -38
- package/dropdown/Dropdown.vue +538 -399
- package/dropdown/dropdown.cjs.js +657 -486
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +659 -488
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +657 -486
- package/dropdown/dropdown.min.js +1 -1
- package/editor/Editor.d.ts +32 -0
- package/editor/Editor.vue +15 -1
- package/editor/editor.cjs.js +15 -1
- package/editor/editor.cjs.min.js +1 -1
- package/editor/editor.esm.js +15 -1
- package/editor/editor.esm.min.js +1 -1
- package/editor/editor.js +15 -1
- package/editor/editor.min.js +1 -1
- package/inputmask/InputMask.vue +9 -6
- package/inputmask/inputmask.cjs.js +14 -6
- package/inputmask/inputmask.cjs.min.js +1 -1
- package/inputmask/inputmask.esm.js +15 -7
- package/inputmask/inputmask.esm.min.js +1 -1
- package/inputmask/inputmask.js +14 -6
- package/inputmask/inputmask.min.js +1 -1
- package/inputnumber/InputNumber.d.ts +31 -7
- package/inputnumber/InputNumber.vue +53 -20
- package/inputnumber/inputnumber.cjs.js +75 -29
- package/inputnumber/inputnumber.cjs.min.js +1 -1
- package/inputnumber/inputnumber.esm.js +76 -30
- package/inputnumber/inputnumber.esm.min.js +1 -1
- package/inputnumber/inputnumber.js +75 -29
- package/inputnumber/inputnumber.min.js +1 -1
- package/inputswitch/InputSwitch.d.ts +24 -8
- package/inputswitch/InputSwitch.vue +27 -12
- package/inputswitch/inputswitch.cjs.js +38 -20
- package/inputswitch/inputswitch.cjs.min.js +1 -1
- package/inputswitch/inputswitch.esm.js +39 -21
- package/inputswitch/inputswitch.esm.min.js +1 -1
- package/inputswitch/inputswitch.js +38 -20
- package/inputswitch/inputswitch.min.js +1 -1
- package/inputtext/InputText.vue +1 -2
- package/inputtext/inputtext.cjs.js +3 -4
- package/inputtext/inputtext.cjs.min.js +1 -1
- package/inputtext/inputtext.esm.js +4 -5
- package/inputtext/inputtext.esm.min.js +1 -1
- package/inputtext/inputtext.js +3 -4
- package/inputtext/inputtext.min.js +1 -1
- package/knob/Knob.d.ts +12 -0
- package/knob/Knob.vue +62 -2
- package/knob/knob.cjs.js +73 -5
- package/knob/knob.cjs.min.js +1 -1
- package/knob/knob.esm.js +73 -5
- package/knob/knob.esm.min.js +1 -1
- package/knob/knob.js +73 -5
- package/knob/knob.min.js +1 -1
- package/listbox/Listbox.d.ts +53 -7
- package/listbox/Listbox.vue +500 -135
- package/listbox/listbox.cjs.js +597 -193
- package/listbox/listbox.cjs.min.js +1 -1
- package/listbox/listbox.esm.js +599 -195
- package/listbox/listbox.esm.min.js +1 -1
- package/listbox/listbox.js +597 -193
- package/listbox/listbox.min.js +1 -1
- package/menu/Menu.d.ts +1 -1
- package/menu/Menuitem.vue +2 -2
- package/menu/menu.cjs.js +12 -6
- package/menu/menu.cjs.min.js +1 -1
- package/menu/menu.esm.js +13 -7
- package/menu/menu.esm.min.js +1 -1
- package/menu/menu.js +12 -6
- package/menu/menu.min.js +1 -1
- package/menubar/MenubarSub.vue +3 -3
- package/menubar/menubar.cjs.js +14 -8
- package/menubar/menubar.cjs.min.js +1 -1
- package/menubar/menubar.esm.js +15 -9
- package/menubar/menubar.esm.min.js +1 -1
- package/menubar/menubar.js +14 -8
- package/menubar/menubar.min.js +1 -1
- package/menuitem/MenuItem.d.ts +1 -1
- package/multiselect/MultiSelect.d.ts +111 -51
- package/multiselect/MultiSelect.vue +629 -338
- package/multiselect/multiselect.cjs.js +748 -428
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +750 -430
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +748 -428
- package/multiselect/multiselect.min.js +1 -1
- package/overlaypanel/OverlayPanel.d.ts +1 -1
- package/overlaypanel/OverlayPanel.vue +14 -2
- package/overlaypanel/overlaypanel.cjs.js +14 -2
- package/overlaypanel/overlaypanel.cjs.min.js +1 -1
- package/overlaypanel/overlaypanel.esm.js +14 -2
- package/overlaypanel/overlaypanel.esm.min.js +1 -1
- package/overlaypanel/overlaypanel.js +14 -2
- package/overlaypanel/overlaypanel.min.js +1 -1
- package/package.json +2 -2
- package/paginator/Paginator.d.ts +2 -2
- package/password/Password.d.ts +36 -8
- package/password/Password.vue +50 -14
- package/password/password.cjs.js +69 -24
- package/password/password.cjs.min.js +1 -1
- package/password/password.esm.js +71 -26
- package/password/password.esm.min.js +1 -1
- package/password/password.js +69 -24
- package/password/password.min.js +1 -1
- package/picklist/PickList.d.ts +8 -0
- package/picklist/PickList.vue +10 -2
- package/picklist/picklist.cjs.js +68 -50
- package/picklist/picklist.cjs.min.js +1 -1
- package/picklist/picklist.esm.js +69 -51
- package/picklist/picklist.esm.min.js +1 -1
- package/picklist/picklist.js +68 -50
- package/picklist/picklist.min.js +1 -1
- package/portal/Portal.d.ts +1 -1
- package/radiobutton/RadioButton.d.ts +28 -4
- package/radiobutton/RadioButton.vue +36 -11
- package/radiobutton/radiobutton.cjs.js +49 -23
- package/radiobutton/radiobutton.cjs.min.js +1 -1
- package/radiobutton/radiobutton.esm.js +50 -24
- package/radiobutton/radiobutton.esm.min.js +1 -1
- package/radiobutton/radiobutton.js +49 -23
- package/radiobutton/radiobutton.min.js +1 -1
- package/rating/Rating.d.ts +4 -0
- package/rating/Rating.vue +61 -7
- package/rating/rating.cjs.js +90 -16
- package/rating/rating.cjs.min.js +1 -1
- package/rating/rating.esm.js +91 -17
- package/rating/rating.esm.min.js +1 -1
- package/rating/rating.js +90 -16
- package/rating/rating.min.js +1 -1
- package/resources/primevue.css +8 -0
- package/resources/primevue.min.css +1 -1
- package/resources/themes/arya-blue/theme.css +82 -40
- package/resources/themes/arya-green/theme.css +82 -40
- package/resources/themes/arya-orange/theme.css +82 -40
- package/resources/themes/arya-purple/theme.css +82 -40
- package/resources/themes/bootstrap4-dark-blue/theme.css +82 -40
- package/resources/themes/bootstrap4-dark-purple/theme.css +82 -40
- package/resources/themes/bootstrap4-light-blue/theme.css +82 -40
- package/resources/themes/bootstrap4-light-purple/theme.css +82 -40
- package/resources/themes/fluent-light/theme.css +82 -40
- package/resources/themes/lara-dark-blue/theme.css +82 -40
- package/resources/themes/lara-dark-indigo/theme.css +82 -40
- package/resources/themes/lara-dark-purple/theme.css +82 -40
- package/resources/themes/lara-dark-teal/theme.css +82 -40
- package/resources/themes/lara-light-blue/theme.css +82 -40
- package/resources/themes/lara-light-indigo/theme.css +82 -40
- package/resources/themes/lara-light-purple/theme.css +82 -40
- package/resources/themes/lara-light-teal/theme.css +82 -40
- package/resources/themes/luna-amber/theme.css +82 -40
- package/resources/themes/luna-blue/theme.css +82 -40
- package/resources/themes/luna-green/theme.css +82 -40
- package/resources/themes/luna-pink/theme.css +82 -40
- package/resources/themes/md-dark-deeppurple/theme.css +82 -40
- package/resources/themes/md-dark-indigo/theme.css +82 -40
- package/resources/themes/md-light-deeppurple/theme.css +82 -40
- package/resources/themes/md-light-indigo/theme.css +82 -40
- package/resources/themes/mdc-dark-deeppurple/theme.css +82 -40
- package/resources/themes/mdc-dark-indigo/theme.css +82 -40
- package/resources/themes/mdc-light-deeppurple/theme.css +82 -40
- package/resources/themes/mdc-light-indigo/theme.css +82 -40
- package/resources/themes/nova/theme.css +82 -40
- package/resources/themes/nova-accent/theme.css +82 -40
- package/resources/themes/nova-alt/theme.css +82 -40
- package/resources/themes/nova-vue/theme.css +82 -40
- package/resources/themes/rhea/theme.css +82 -40
- package/resources/themes/saga-blue/theme.css +82 -40
- package/resources/themes/saga-green/theme.css +82 -40
- package/resources/themes/saga-orange/theme.css +82 -40
- package/resources/themes/saga-purple/theme.css +82 -40
- package/resources/themes/tailwind-light/theme.css +82 -40
- package/resources/themes/vela-blue/theme.css +82 -40
- package/resources/themes/vela-green/theme.css +82 -40
- package/resources/themes/vela-orange/theme.css +82 -40
- package/resources/themes/vela-purple/theme.css +82 -40
- package/ripple/ripple.cjs.js +1 -0
- package/ripple/ripple.cjs.min.js +1 -1
- package/ripple/ripple.esm.js +1 -0
- package/ripple/ripple.esm.min.js +1 -1
- package/ripple/ripple.js +1 -0
- package/ripple/ripple.min.js +1 -1
- package/selectbutton/SelectButton.d.ts +6 -2
- package/selectbutton/SelectButton.vue +89 -12
- package/selectbutton/selectbutton.cjs.js +97 -22
- package/selectbutton/selectbutton.cjs.min.js +1 -1
- package/selectbutton/selectbutton.esm.js +99 -24
- package/selectbutton/selectbutton.esm.min.js +1 -1
- package/selectbutton/selectbutton.js +97 -22
- package/selectbutton/selectbutton.min.js +1 -1
- package/slider/Slider.d.ts +9 -1
- package/slider/Slider.vue +50 -34
- package/slider/slider.cjs.js +59 -38
- package/slider/slider.cjs.min.js +1 -1
- package/slider/slider.esm.js +59 -38
- package/slider/slider.esm.min.js +1 -1
- package/slider/slider.js +59 -38
- package/slider/slider.min.js +1 -1
- package/splitbutton/SplitButton.d.ts +1 -1
- package/splitter/Splitter.vue +30 -1
- package/splitter/splitter.cjs.js +30 -1
- package/splitter/splitter.cjs.min.js +1 -1
- package/splitter/splitter.esm.js +30 -1
- package/splitter/splitter.esm.min.js +1 -1
- package/splitter/splitter.js +30 -1
- package/splitter/splitter.min.js +1 -1
- package/textarea/Textarea.vue +1 -2
- package/textarea/textarea.cjs.js +3 -5
- package/textarea/textarea.cjs.min.js +1 -1
- package/textarea/textarea.esm.js +4 -6
- package/textarea/textarea.esm.min.js +1 -1
- package/textarea/textarea.js +3 -5
- package/textarea/textarea.min.js +1 -1
- package/tieredmenu/TieredMenu.d.ts +1 -1
- package/tieredmenu/TieredMenuSub.vue +3 -3
- package/tieredmenu/tieredmenu.cjs.js +14 -8
- package/tieredmenu/tieredmenu.cjs.min.js +1 -1
- package/tieredmenu/tieredmenu.esm.js +15 -9
- package/tieredmenu/tieredmenu.esm.min.js +1 -1
- package/tieredmenu/tieredmenu.js +14 -8
- package/tieredmenu/tieredmenu.min.js +1 -1
- package/timeline/Timeline.d.ts +10 -1
- package/timeline/Timeline.vue +1 -1
- package/timeline/timeline.cjs.js +5 -1
- package/timeline/timeline.cjs.min.js +1 -1
- package/timeline/timeline.esm.js +5 -1
- package/timeline/timeline.esm.min.js +1 -1
- package/timeline/timeline.js +5 -1
- package/timeline/timeline.min.js +1 -1
- package/togglebutton/ToggleButton.d.ts +42 -0
- package/togglebutton/ToggleButton.vue +44 -7
- package/togglebutton/togglebutton.cjs.js +59 -13
- package/togglebutton/togglebutton.cjs.min.js +1 -1
- package/togglebutton/togglebutton.esm.js +60 -14
- package/togglebutton/togglebutton.esm.min.js +1 -1
- package/togglebutton/togglebutton.js +59 -13
- package/togglebutton/togglebutton.min.js +1 -1
- package/tooltip/tooltip.cjs.js +20 -11
- package/tooltip/tooltip.cjs.min.js +1 -1
- package/tooltip/tooltip.esm.js +21 -12
- package/tooltip/tooltip.esm.min.js +1 -1
- package/tooltip/tooltip.js +20 -11
- package/tooltip/tooltip.min.js +1 -1
- package/tree/Tree.vue +5 -1
- package/tree/TreeNode.vue +20 -19
- package/tree/tree.cjs.js +47 -32
- package/tree/tree.cjs.min.js +1 -1
- package/tree/tree.esm.js +47 -32
- package/tree/tree.esm.min.js +1 -1
- package/tree/tree.js +47 -32
- package/tree/tree.min.js +1 -1
- package/treeselect/TreeSelect.d.ts +26 -10
- package/treeselect/TreeSelect.vue +52 -29
- package/treeselect/treeselect.cjs.js +74 -41
- package/treeselect/treeselect.cjs.min.js +1 -1
- package/treeselect/treeselect.esm.js +76 -43
- package/treeselect/treeselect.esm.min.js +1 -1
- package/treeselect/treeselect.js +74 -41
- package/treeselect/treeselect.min.js +1 -1
- package/tristatecheckbox/TriStateCheckbox.d.ts +20 -4
- package/tristatecheckbox/TriStateCheckbox.vue +52 -15
- package/tristatecheckbox/tristatecheckbox.cjs.js +67 -26
- package/tristatecheckbox/tristatecheckbox.cjs.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.esm.js +68 -27
- package/tristatecheckbox/tristatecheckbox.esm.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.js +67 -26
- package/tristatecheckbox/tristatecheckbox.min.js +1 -1
- package/utils/Utils.d.ts +3 -2
- package/utils/utils.cjs.js +239 -173
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.esm.js +239 -173
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +239 -173
- package/utils/utils.min.js +1 -1
- package/vetur-attributes.json +612 -136
- package/vetur-tags.json +180 -59
- package/virtualscroller/VirtualScroller.d.ts +10 -0
- package/virtualscroller/VirtualScroller.vue +18 -17
- package/virtualscroller/virtualscroller.cjs.js +22 -20
- package/virtualscroller/virtualscroller.cjs.min.js +1 -1
- package/virtualscroller/virtualscroller.esm.js +22 -20
- package/virtualscroller/virtualscroller.esm.min.js +1 -1
- package/virtualscroller/virtualscroller.js +22 -20
- package/virtualscroller/virtualscroller.min.js +1 -1
- package/web-types.json +1745 -338
package/listbox/Listbox.vue
CHANGED
|
@@ -1,60 +1,68 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="
|
|
2
|
+
<div :id="id" :class="containerClass" @focusout="onFocusout">
|
|
3
|
+
<span ref="firstHiddenFocusableElement" role="presentation" aria-hidden="true" class="p-hidden-accessible p-hidden-focusable" :tabindex="!disabled ? tabindex : -1" @focus="onFirstHiddenFocus"></span>
|
|
3
4
|
<slot name="header" :value="modelValue" :options="visibleOptions"></slot>
|
|
4
|
-
<div class="p-listbox-header"
|
|
5
|
+
<div v-if="filter" class="p-listbox-header">
|
|
5
6
|
<div class="p-listbox-filter-container">
|
|
6
|
-
<input type="text" class="p-listbox-filter p-inputtext p-component" v-model="filterValue" :placeholder="filterPlaceholder"
|
|
7
|
+
<input ref="filterInput" type="text" class="p-listbox-filter p-inputtext p-component" v-model="filterValue" :placeholder="filterPlaceholder"
|
|
8
|
+
role="searchbox" autocomplete="off" :aria-owns="id + '_list'" :aria-activedescendant="focusedOptionId" :tabindex="!disabled && !focused ? tabindex : -1"
|
|
9
|
+
@input="onFilterChange" @blur="onFilterBlur" @keydown="onFilterKeyDown" v-bind="filterInputProps">
|
|
7
10
|
<span class="p-listbox-filter-icon pi pi-search"></span>
|
|
8
11
|
</div>
|
|
12
|
+
<span role="status" aria-live="polite" class="p-hidden-accessible">
|
|
13
|
+
{{filterResultMessageText}}
|
|
14
|
+
</span>
|
|
9
15
|
</div>
|
|
10
|
-
<div class="p-listbox-list-wrapper" :style="listStyle">
|
|
11
|
-
<VirtualScroller :ref="virtualScrollerRef" v-bind="virtualScrollerOptions" :style="listStyle" :items="visibleOptions" :disabled="virtualScrollerDisabled">
|
|
12
|
-
<template v-slot:content="{ styleClass, contentRef, items, getItemOptions, contentStyle }">
|
|
13
|
-
<ul :ref="contentRef" :class="['p-listbox-list', styleClass]" :style="contentStyle"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
<div ref="listWrapper" class="p-listbox-list-wrapper" :style="listStyle">
|
|
17
|
+
<VirtualScroller :ref="virtualScrollerRef" v-bind="virtualScrollerOptions" :style="listStyle" :items="visibleOptions" :tabindex="-1" :disabled="virtualScrollerDisabled">
|
|
18
|
+
<template v-slot:content="{ styleClass, contentRef, items, getItemOptions, contentStyle, itemSize }">
|
|
19
|
+
<ul :ref="(el) => listRef(el, contentRef)" :id="id + '_list'" :class="['p-listbox-list', styleClass]" :style="contentStyle" :tabindex="-1" role="listbox"
|
|
20
|
+
:aria-multiselectable="multiple" :aria-label="ariaLabel" :aria-labelledby="ariaLabelledby" :aria-activedescendant="focused ? focusedOptionId : undefined" :aria-disabled="disabled"
|
|
21
|
+
@focus="onListFocus" @blur="onListBlur" @keydown="onListKeyDown">
|
|
22
|
+
<template v-for="(option, i) of items" :key="getOptionRenderKey(option, getOptionIndex(i, getItemOptions))">
|
|
23
|
+
<li v-if="isOptionGroup(option)" :id="id + '_' + getOptionIndex(i, getItemOptions)" :style="{height: itemSize ? itemSize + 'px' : undefined}" class="p-listbox-item-group" role="option">
|
|
24
|
+
<slot name="optiongroup" :option="option.optionGroup" :index="getOptionIndex(i, getItemOptions)">{{getOptionGroupLabel(option.optionGroup)}}</slot>
|
|
25
|
+
</li>
|
|
26
|
+
<li v-else v-ripple :id="id + '_' + getOptionIndex(i, getItemOptions)" :style="{height: itemSize ? itemSize + 'px' : undefined}"
|
|
27
|
+
:class="['p-listbox-item', {'p-highlight': isSelected(option), 'p-focus': focusedOptionIndex === getOptionIndex(i, getItemOptions), 'p-disabled': isOptionDisabled(option)}]"
|
|
28
|
+
role="option" :aria-label="getOptionLabel(option)" :aria-selected="isSelected(option)" :aria-disabled="isOptionDisabled(option)" :aria-setsize="ariaSetSize" :aria-posinset="getAriaPosInset(getOptionIndex(i, getItemOptions))"
|
|
29
|
+
@click="onOptionSelect($event, option, getOptionIndex(i, getItemOptions))" @mousemove="onOptionMouseMove($event, getOptionIndex(i, getItemOptions))" @touchend="onOptionTouchEnd()">
|
|
30
|
+
<slot name="option" :option="option" :index="getOptionIndex(i, getItemOptions)">{{getOptionLabel(option)}}</slot>
|
|
18
31
|
</li>
|
|
19
32
|
</template>
|
|
20
|
-
<
|
|
21
|
-
<template v-for="(optionGroup, i) of items" :key="getOptionGroupRenderKey(optionGroup)">
|
|
22
|
-
<li class="p-listbox-item-group">
|
|
23
|
-
<slot name="optiongroup" :option="optionGroup" :index="getOptionIndex(i, getItemOptions)">{{getOptionGroupLabel(optionGroup)}}</slot>
|
|
24
|
-
</li>
|
|
25
|
-
<li v-for="(option, i) of getOptionGroupChildren(optionGroup)" :tabindex="isOptionDisabled(option) ? null : '0'" :class="['p-listbox-item', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option)}]" v-ripple
|
|
26
|
-
:key="getOptionRenderKey(option)" @click="onOptionSelect($event, option)" @touchend="onOptionTouchEnd()" @keydown="onOptionKeyDown($event, option)" role="option" :aria-label="getOptionLabel(option)" :aria-selected="isSelected(option)" >
|
|
27
|
-
<slot name="option" :option="option" :index="getOptionIndex(i, getItemOptions)">{{getOptionLabel(option)}}</slot>
|
|
28
|
-
</li>
|
|
29
|
-
</template>
|
|
30
|
-
</template>
|
|
31
|
-
<li v-if="filterValue && (!items || (items && items.length === 0))" class="p-listbox-empty-message">
|
|
33
|
+
<li v-if="filterValue && (!items || (items && items.length === 0))" class="p-listbox-empty-message" role="option">
|
|
32
34
|
<slot name="emptyfilter">{{emptyFilterMessageText}}</slot>
|
|
33
35
|
</li>
|
|
34
|
-
<li v-else-if="(!options || (options && options.length === 0))" class="p-listbox-empty-message">
|
|
36
|
+
<li v-else-if="(!options || (options && options.length === 0))" class="p-listbox-empty-message" role="option">
|
|
35
37
|
<slot name="empty">{{emptyMessageText}}</slot>
|
|
36
38
|
</li>
|
|
37
39
|
</ul>
|
|
40
|
+
<span v-if="(!options || (options && options.length === 0))" role="status" aria-live="polite" class="p-hidden-accessible">
|
|
41
|
+
{{emptyMessageText}}
|
|
42
|
+
</span>
|
|
43
|
+
<span role="status" aria-live="polite" class="p-hidden-accessible">
|
|
44
|
+
{{selectedMessageText}}
|
|
45
|
+
</span>
|
|
38
46
|
</template>
|
|
39
|
-
<template v-slot:loader="{ options }"
|
|
47
|
+
<template v-if="$slots.loader" v-slot:loader="{ options }">
|
|
40
48
|
<slot name="loader" :options="options"></slot>
|
|
41
49
|
</template>
|
|
42
50
|
</VirtualScroller>
|
|
43
51
|
</div>
|
|
44
52
|
<slot name="footer" :value="modelValue" :options="visibleOptions"></slot>
|
|
53
|
+
<span ref="lastHiddenFocusableElement" role="presentation" aria-hidden="true" class="p-hidden-accessible p-hidden-focusable" :tabindex="!disabled ? tabindex : -1" @focus="onLastHiddenFocus"></span>
|
|
45
54
|
</div>
|
|
46
55
|
</template>
|
|
47
56
|
|
|
48
57
|
<script>
|
|
49
|
-
import {ObjectUtils} from 'primevue/utils';
|
|
50
|
-
import {DomHandler} from 'primevue/utils';
|
|
58
|
+
import {DomHandler,ObjectUtils,UniqueComponentId} from 'primevue/utils';
|
|
51
59
|
import {FilterService} from 'primevue/api';
|
|
52
60
|
import Ripple from 'primevue/ripple';
|
|
53
61
|
import VirtualScroller from 'primevue/virtualscroller';
|
|
54
62
|
|
|
55
63
|
export default {
|
|
56
64
|
name: 'Listbox',
|
|
57
|
-
emits: ['update:modelValue', 'change', 'filter'],
|
|
65
|
+
emits: ['update:modelValue', 'change', 'focus', 'blur', 'filter'],
|
|
58
66
|
props: {
|
|
59
67
|
modelValue: null,
|
|
60
68
|
options: Array,
|
|
@@ -79,6 +87,27 @@ export default {
|
|
|
79
87
|
type: Array,
|
|
80
88
|
default: null
|
|
81
89
|
},
|
|
90
|
+
filterInputProps: null,
|
|
91
|
+
virtualScrollerOptions: {
|
|
92
|
+
type: Object,
|
|
93
|
+
default: null
|
|
94
|
+
},
|
|
95
|
+
autoOptionFocus: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: true
|
|
98
|
+
},
|
|
99
|
+
filterMessage: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: null
|
|
102
|
+
},
|
|
103
|
+
selectionMessage: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: null
|
|
106
|
+
},
|
|
107
|
+
emptySelectionMessage: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: null
|
|
110
|
+
},
|
|
82
111
|
emptyFilterMessage: {
|
|
83
112
|
type: String,
|
|
84
113
|
default: null
|
|
@@ -87,17 +116,44 @@ export default {
|
|
|
87
116
|
type: String,
|
|
88
117
|
default: null
|
|
89
118
|
},
|
|
90
|
-
|
|
91
|
-
type:
|
|
119
|
+
tabindex: {
|
|
120
|
+
type: Number,
|
|
121
|
+
default: 0
|
|
122
|
+
},
|
|
123
|
+
'aria-label': {
|
|
124
|
+
type: String,
|
|
125
|
+
default: null
|
|
126
|
+
},
|
|
127
|
+
'aria-labelledby': {
|
|
128
|
+
type: String,
|
|
92
129
|
default: null
|
|
93
130
|
}
|
|
94
131
|
},
|
|
95
|
-
|
|
132
|
+
list: null,
|
|
96
133
|
virtualScroller: null,
|
|
134
|
+
optionTouched: false,
|
|
135
|
+
startRangeIndex: -1,
|
|
136
|
+
searchTimeout: null,
|
|
137
|
+
searchValue: '',
|
|
138
|
+
selectOnFocus: false,
|
|
139
|
+
focusOnHover: false,
|
|
97
140
|
data() {
|
|
98
141
|
return {
|
|
99
|
-
|
|
100
|
-
|
|
142
|
+
id: UniqueComponentId(),
|
|
143
|
+
filterValue: null,
|
|
144
|
+
focused: false,
|
|
145
|
+
focusedOptionIndex: -1
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
watch: {
|
|
149
|
+
options() {
|
|
150
|
+
this.autoUpdateModel();
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
mounted() {
|
|
154
|
+
this.id = this.$attrs.id || this.id;
|
|
155
|
+
|
|
156
|
+
this.autoUpdateModel();
|
|
101
157
|
},
|
|
102
158
|
methods: {
|
|
103
159
|
getOptionIndex(index, fn) {
|
|
@@ -109,14 +165,14 @@ export default {
|
|
|
109
165
|
getOptionValue(option) {
|
|
110
166
|
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
|
111
167
|
},
|
|
112
|
-
getOptionRenderKey(option) {
|
|
113
|
-
return this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : this.getOptionLabel(option);
|
|
168
|
+
getOptionRenderKey(option, index) {
|
|
169
|
+
return (this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : this.getOptionLabel(option)) + '_' + index;
|
|
114
170
|
},
|
|
115
171
|
isOptionDisabled(option) {
|
|
116
172
|
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
|
117
173
|
},
|
|
118
|
-
|
|
119
|
-
return
|
|
174
|
+
isOptionGroup(option) {
|
|
175
|
+
return this.optionGroupLabel && option.optionGroup && option.group;
|
|
120
176
|
},
|
|
121
177
|
getOptionGroupLabel(optionGroup) {
|
|
122
178
|
return ObjectUtils.resolveFieldData(optionGroup, this.optionGroupLabel);
|
|
@@ -124,17 +180,116 @@ export default {
|
|
|
124
180
|
getOptionGroupChildren(optionGroup) {
|
|
125
181
|
return ObjectUtils.resolveFieldData(optionGroup, this.optionGroupChildren);
|
|
126
182
|
},
|
|
127
|
-
|
|
183
|
+
getAriaPosInset(index) {
|
|
184
|
+
return (this.optionGroupLabel ? index - this.visibleOptions.slice(0, index).filter(option => this.isOptionGroup(option)).length : index) + 1;
|
|
185
|
+
},
|
|
186
|
+
onFirstHiddenFocus() {
|
|
187
|
+
this.list.focus();
|
|
188
|
+
|
|
189
|
+
const firstFocusableEl = DomHandler.getFirstFocusableElement(this.$el, ':not(.p-hidden-focusable)');
|
|
190
|
+
this.$refs.lastHiddenFocusableElement.tabIndex = ObjectUtils.isEmpty(firstFocusableEl) ? -1 : undefined;
|
|
191
|
+
this.$refs.firstHiddenFocusableElement.tabIndex = -1;
|
|
192
|
+
},
|
|
193
|
+
onLastHiddenFocus(event) {
|
|
194
|
+
const relatedTarget = event.relatedTarget;
|
|
195
|
+
|
|
196
|
+
if (relatedTarget === this.list) {
|
|
197
|
+
const firstFocusableEl = DomHandler.getFirstFocusableElement(this.$el, ':not(.p-hidden-focusable)');
|
|
198
|
+
firstFocusableEl && firstFocusableEl.focus();
|
|
199
|
+
this.$refs.firstHiddenFocusableElement.tabIndex = undefined;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
this.$refs.firstHiddenFocusableElement.focus();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this.$refs.lastHiddenFocusableElement.tabIndex = -1;
|
|
206
|
+
},
|
|
207
|
+
onFocusout(event) {
|
|
208
|
+
if (!this.$el.contains(event.relatedTarget) && this.$refs.lastHiddenFocusableElement && this.$refs.firstHiddenFocusableElement) {
|
|
209
|
+
this.$refs.lastHiddenFocusableElement.tabIndex = this.$refs.firstHiddenFocusableElement.tabIndex = undefined;
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
onListFocus(event) {
|
|
213
|
+
this.focused = true;
|
|
214
|
+
this.focusedOptionIndex = this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1;
|
|
215
|
+
this.$emit('focus', event);
|
|
216
|
+
},
|
|
217
|
+
onListBlur(event) {
|
|
218
|
+
this.focused = false;
|
|
219
|
+
this.focusedOptionIndex = this.startRangeIndex = -1;
|
|
220
|
+
this.searchValue = '';
|
|
221
|
+
this.$emit('blur', event);
|
|
222
|
+
},
|
|
223
|
+
onListKeyDown(event) {
|
|
224
|
+
switch (event.code) {
|
|
225
|
+
case 'ArrowDown':
|
|
226
|
+
this.onArrowDownKey(event);
|
|
227
|
+
break;
|
|
228
|
+
|
|
229
|
+
case 'ArrowUp':
|
|
230
|
+
this.onArrowUpKey(event);
|
|
231
|
+
break;
|
|
232
|
+
|
|
233
|
+
case 'Home':
|
|
234
|
+
this.onHomeKey(event);
|
|
235
|
+
break;
|
|
236
|
+
|
|
237
|
+
case 'End':
|
|
238
|
+
this.onEndKey(event);
|
|
239
|
+
break;
|
|
240
|
+
|
|
241
|
+
case 'PageDown':
|
|
242
|
+
this.onPageDownKey(event);
|
|
243
|
+
break;
|
|
244
|
+
|
|
245
|
+
case 'PageUp':
|
|
246
|
+
this.onPageUpKey(event);
|
|
247
|
+
break;
|
|
248
|
+
|
|
249
|
+
case 'Enter':
|
|
250
|
+
case 'Space':
|
|
251
|
+
this.onSpaceKey(event);
|
|
252
|
+
break;
|
|
253
|
+
|
|
254
|
+
case 'Tab':
|
|
255
|
+
//NOOP
|
|
256
|
+
break;
|
|
257
|
+
|
|
258
|
+
case 'ShiftLeft':
|
|
259
|
+
case 'ShiftRight':
|
|
260
|
+
this.onShiftKey(event);
|
|
261
|
+
break;
|
|
262
|
+
|
|
263
|
+
default:
|
|
264
|
+
if (event.code === 'KeyA' && this.multiple && (event.metaKey || event.ctrlKey)) {
|
|
265
|
+
const value = this.visibleOptions.filter(option => this.isValidOption(option)).map(option => this.getOptionValue(option));
|
|
266
|
+
this.updateModel(event, value);
|
|
267
|
+
|
|
268
|
+
event.preventDefault();
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (ObjectUtils.isPrintableCharacter(event.key)) {
|
|
273
|
+
this.searchOptions(event, event.key);
|
|
274
|
+
event.preventDefault();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
onOptionSelect(event, option, index = -1) {
|
|
128
281
|
if (this.disabled || this.isOptionDisabled(option)) {
|
|
129
282
|
return;
|
|
130
283
|
}
|
|
131
284
|
|
|
132
|
-
|
|
133
|
-
this.onOptionSelectMultiple(event, option);
|
|
134
|
-
else
|
|
135
|
-
this.onOptionSelectSingle(event, option);
|
|
136
|
-
|
|
285
|
+
this.multiple ? this.onOptionSelectMultiple(event, option) : this.onOptionSelectSingle(event, option);
|
|
137
286
|
this.optionTouched = false;
|
|
287
|
+
index !== -1 && (this.focusedOptionIndex = index);
|
|
288
|
+
},
|
|
289
|
+
onOptionMouseMove(event, index) {
|
|
290
|
+
if (this.focusOnHover) {
|
|
291
|
+
this.changeFocusedOptionIndex(event, index);
|
|
292
|
+
}
|
|
138
293
|
},
|
|
139
294
|
onOptionTouchEnd() {
|
|
140
295
|
if (this.disabled) {
|
|
@@ -174,7 +329,6 @@ export default {
|
|
|
174
329
|
},
|
|
175
330
|
onOptionSelectMultiple(event, option) {
|
|
176
331
|
let selected = this.isSelected(option);
|
|
177
|
-
let valueChanged = false;
|
|
178
332
|
let value = null;
|
|
179
333
|
let metaSelection = this.optionTouched ? false : this.metaKeySelection;
|
|
180
334
|
|
|
@@ -182,133 +336,323 @@ export default {
|
|
|
182
336
|
let metaKey = (event.metaKey || event.ctrlKey);
|
|
183
337
|
|
|
184
338
|
if (selected) {
|
|
185
|
-
|
|
186
|
-
value = this.removeOption(option);
|
|
187
|
-
else
|
|
188
|
-
value = [this.getOptionValue(option)];
|
|
189
|
-
|
|
190
|
-
valueChanged = true;
|
|
339
|
+
value = metaKey ? this.removeOption(option) : [this.getOptionValue(option)];
|
|
191
340
|
}
|
|
192
341
|
else {
|
|
193
342
|
value = (metaKey) ? this.modelValue || [] : [];
|
|
194
343
|
value = [...value, this.getOptionValue(option)];
|
|
195
|
-
valueChanged = true;
|
|
196
344
|
}
|
|
197
345
|
}
|
|
198
346
|
else {
|
|
199
|
-
|
|
200
|
-
value = this.removeOption(option);
|
|
201
|
-
else
|
|
202
|
-
value = [...this.modelValue || [], this.getOptionValue(option)];
|
|
203
|
-
|
|
204
|
-
valueChanged = true;
|
|
347
|
+
value = selected ? this.removeOption(option) : [...this.modelValue || [], this.getOptionValue(option)];
|
|
205
348
|
}
|
|
206
349
|
|
|
207
|
-
|
|
350
|
+
this.updateModel(event, value);
|
|
351
|
+
},
|
|
352
|
+
onOptionSelectRange(event, start = -1, end = -1) {
|
|
353
|
+
start === -1 && (start = this.findNearestSelectedOptionIndex(end, true));
|
|
354
|
+
end === -1 && (end = this.findNearestSelectedOptionIndex(start));
|
|
355
|
+
|
|
356
|
+
if (start !== -1 && end !== -1) {
|
|
357
|
+
const rangeStart = Math.min(start, end);
|
|
358
|
+
const rangeEnd = Math.max(start, end);
|
|
359
|
+
const value = this.visibleOptions.slice(rangeStart, rangeEnd + 1).filter(option => this.isValidOption(option)).map(option => this.getOptionValue(option));
|
|
360
|
+
|
|
208
361
|
this.updateModel(event, value);
|
|
209
362
|
}
|
|
210
363
|
},
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
364
|
+
onFilterChange(event) {
|
|
365
|
+
this.$emit('filter', {originalEvent: event, value: event.target.value});
|
|
366
|
+
this.focusedOptionIndex = this.startRangeIndex = -1;
|
|
367
|
+
},
|
|
368
|
+
onFilterBlur() {
|
|
369
|
+
this.focusedOptionIndex = this.startRangeIndex = -1;
|
|
370
|
+
},
|
|
371
|
+
onFilterKeyDown(event) {
|
|
372
|
+
switch (event.code) {
|
|
373
|
+
case 'ArrowDown':
|
|
374
|
+
this.onArrowDownKey(event);
|
|
375
|
+
break;
|
|
376
|
+
|
|
377
|
+
case 'ArrowUp':
|
|
378
|
+
this.onArrowUpKey(event);
|
|
379
|
+
break;
|
|
380
|
+
|
|
381
|
+
case 'ArrowLeft':
|
|
382
|
+
case 'ArrowRight':
|
|
383
|
+
this.onArrowLeftKey(event, true);
|
|
384
|
+
break;
|
|
385
|
+
|
|
386
|
+
case 'Home':
|
|
387
|
+
this.onHomeKey(event, true);
|
|
388
|
+
break;
|
|
389
|
+
|
|
390
|
+
case 'End':
|
|
391
|
+
this.onEndKey(event, true);
|
|
392
|
+
break;
|
|
393
|
+
|
|
394
|
+
case 'Enter':
|
|
395
|
+
this.onEnterKey(event);
|
|
396
|
+
break;
|
|
397
|
+
|
|
398
|
+
case 'ShiftLeft':
|
|
399
|
+
case 'ShiftRight':
|
|
400
|
+
this.onShiftKey(event);
|
|
401
|
+
break;
|
|
402
|
+
|
|
403
|
+
default:
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
onArrowDownKey(event) {
|
|
408
|
+
const optionIndex = this.focusedOptionIndex !== -1 ? this.findNextOptionIndex(this.focusedOptionIndex) : this.findFirstFocusedOptionIndex();
|
|
409
|
+
|
|
410
|
+
if (this.multiple && event.shiftKey) {
|
|
411
|
+
this.onOptionSelectRange(event, this.startRangeIndex, optionIndex);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
this.changeFocusedOptionIndex(event, optionIndex);
|
|
415
|
+
event.preventDefault();
|
|
416
|
+
},
|
|
417
|
+
onArrowUpKey(event) {
|
|
418
|
+
const optionIndex = this.focusedOptionIndex !== -1 ? this.findPrevOptionIndex(this.focusedOptionIndex) : this.findLastFocusedOptionIndex();
|
|
419
|
+
|
|
420
|
+
if (this.multiple && event.shiftKey) {
|
|
421
|
+
this.onOptionSelectRange(event, optionIndex, this.startRangeIndex);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
this.changeFocusedOptionIndex(event, optionIndex);
|
|
425
|
+
event.preventDefault();
|
|
426
|
+
},
|
|
427
|
+
onArrowLeftKey(event, pressedInInputText = false) {
|
|
428
|
+
pressedInInputText && (this.focusedOptionIndex = -1);
|
|
429
|
+
},
|
|
430
|
+
onHomeKey(event, pressedInInputText = false) {
|
|
431
|
+
if (pressedInInputText) {
|
|
432
|
+
event.currentTarget.setSelectionRange(0, 0);
|
|
433
|
+
this.focusedOptionIndex = -1;
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
let metaKey = event.metaKey || event.ctrlKey;
|
|
437
|
+
let optionIndex = this.findFirstOptionIndex();
|
|
438
|
+
|
|
439
|
+
if (this.multiple && event.shiftKey && metaKey) {
|
|
440
|
+
this.onOptionSelectRange(event, optionIndex, this.startRangeIndex);
|
|
223
441
|
}
|
|
442
|
+
|
|
443
|
+
this.changeFocusedOptionIndex(event, optionIndex);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
event.preventDefault();
|
|
447
|
+
},
|
|
448
|
+
onEndKey(event, pressedInInputText = false) {
|
|
449
|
+
if (pressedInInputText) {
|
|
450
|
+
const target = event.currentTarget;
|
|
451
|
+
const len = target.value.length;
|
|
452
|
+
target.setSelectionRange(len, len);
|
|
453
|
+
this.focusedOptionIndex = -1;
|
|
224
454
|
}
|
|
225
455
|
else {
|
|
226
|
-
|
|
456
|
+
let metaKey = event.metaKey || event.ctrlKey;
|
|
457
|
+
let optionIndex = this.findLastOptionIndex();
|
|
458
|
+
|
|
459
|
+
if (this.multiple && event.shiftKey && metaKey) {
|
|
460
|
+
this.onOptionSelectRange(event, this.startRangeIndex, optionIndex);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
this.changeFocusedOptionIndex(event, optionIndex);
|
|
227
464
|
}
|
|
228
465
|
|
|
229
|
-
|
|
466
|
+
event.preventDefault();
|
|
230
467
|
},
|
|
231
|
-
|
|
232
|
-
|
|
468
|
+
onPageUpKey(event) {
|
|
469
|
+
this.scrollInView(0);
|
|
470
|
+
event.preventDefault();
|
|
233
471
|
},
|
|
234
|
-
|
|
235
|
-
this
|
|
236
|
-
|
|
472
|
+
onPageDownKey(event) {
|
|
473
|
+
this.scrollInView(this.visibleOptions.length - 1);
|
|
474
|
+
event.preventDefault();
|
|
237
475
|
},
|
|
238
|
-
|
|
239
|
-
|
|
476
|
+
onEnterKey(event) {
|
|
477
|
+
if (this.focusedOptionIndex !== -1) {
|
|
478
|
+
if (this.multiple && event.shiftKey)
|
|
479
|
+
this.onOptionSelectRange(event, this.focusedOptionIndex);
|
|
480
|
+
else
|
|
481
|
+
this.onOptionSelect(event, this.visibleOptions[this.focusedOptionIndex]);
|
|
482
|
+
}
|
|
240
483
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
484
|
+
event.preventDefault();
|
|
485
|
+
},
|
|
486
|
+
onSpaceKey(event) {
|
|
487
|
+
this.onEnterKey(event);
|
|
488
|
+
},
|
|
489
|
+
onShiftKey() {
|
|
490
|
+
this.startRangeIndex = this.focusedOptionIndex;
|
|
491
|
+
},
|
|
492
|
+
isOptionMatched(option) {
|
|
493
|
+
return this.isValidOption(option) && this.getOptionLabel(option).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale));
|
|
494
|
+
},
|
|
495
|
+
isValidOption(option) {
|
|
496
|
+
return option && !(this.isOptionDisabled(option) || this.isOptionGroup(option));
|
|
497
|
+
},
|
|
498
|
+
isValidSelectedOption(option) {
|
|
499
|
+
return this.isValidOption(option) && this.isSelected(option);
|
|
500
|
+
},
|
|
501
|
+
isSelected(option) {
|
|
502
|
+
const optionValue = this.getOptionValue(option);
|
|
248
503
|
|
|
249
|
-
|
|
250
|
-
|
|
504
|
+
if (this.multiple)
|
|
505
|
+
return (this.modelValue || []).some(value => ObjectUtils.equals(value, optionValue, this.equalityKey));
|
|
506
|
+
else
|
|
507
|
+
return ObjectUtils.equals(this.modelValue, optionValue, this.equalityKey);
|
|
508
|
+
},
|
|
509
|
+
findFirstOptionIndex() {
|
|
510
|
+
return this.visibleOptions.findIndex(option => this.isValidOption(option));
|
|
511
|
+
},
|
|
512
|
+
findLastOptionIndex() {
|
|
513
|
+
return ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidOption(option));
|
|
514
|
+
},
|
|
515
|
+
findNextOptionIndex(index) {
|
|
516
|
+
const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1;
|
|
517
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index;
|
|
518
|
+
},
|
|
519
|
+
findPrevOptionIndex(index) {
|
|
520
|
+
const matchedOptionIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidOption(option)) : -1;
|
|
521
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
|
|
522
|
+
},
|
|
523
|
+
findFirstSelectedOptionIndex() {
|
|
524
|
+
return this.hasSelectedOption ? this.visibleOptions.findIndex(option => this.isValidSelectedOption(option)) : -1;
|
|
525
|
+
},
|
|
526
|
+
findLastSelectedOptionIndex() {
|
|
527
|
+
return this.hasSelectedOption ? ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidSelectedOption(option)) : -1;
|
|
528
|
+
},
|
|
529
|
+
findNextSelectedOptionIndex(index) {
|
|
530
|
+
const matchedOptionIndex = this.hasSelectedOption && index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidSelectedOption(option)) : -1;
|
|
531
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : -1;
|
|
532
|
+
},
|
|
533
|
+
findPrevSelectedOptionIndex(index) {
|
|
534
|
+
const matchedOptionIndex = this.hasSelectedOption && index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidSelectedOption(option)) : -1;
|
|
535
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex : -1;
|
|
536
|
+
},
|
|
537
|
+
findNearestSelectedOptionIndex(index, firstCheckUp = false) {
|
|
538
|
+
let matchedOptionIndex = -1;
|
|
251
539
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
540
|
+
if (this.hasSelectedOption) {
|
|
541
|
+
if (firstCheckUp) {
|
|
542
|
+
matchedOptionIndex = this.findPrevSelectedOptionIndex(index);
|
|
543
|
+
matchedOptionIndex = matchedOptionIndex === -1 ? this.findNextSelectedOptionIndex(index) : matchedOptionIndex;
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
matchedOptionIndex = this.findNextSelectedOptionIndex(index);
|
|
547
|
+
matchedOptionIndex = matchedOptionIndex === -1 ? this.findPrevSelectedOptionIndex(index) : matchedOptionIndex;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
|
|
552
|
+
},
|
|
553
|
+
findFirstFocusedOptionIndex() {
|
|
554
|
+
const selectedIndex = this.findFirstSelectedOptionIndex();
|
|
555
|
+
return selectedIndex < 0 ? this.findFirstOptionIndex() : selectedIndex;
|
|
556
|
+
},
|
|
557
|
+
findLastFocusedOptionIndex() {
|
|
558
|
+
const selectedIndex = this.findLastSelectedOptionIndex();
|
|
559
|
+
return selectedIndex < 0 ? this.findLastOptionIndex() : selectedIndex;
|
|
560
|
+
},
|
|
561
|
+
searchOptions(event, char) {
|
|
562
|
+
this.searchValue = (this.searchValue || '') + char;
|
|
563
|
+
|
|
564
|
+
let optionIndex = -1;
|
|
565
|
+
if (this.focusedOptionIndex !== -1) {
|
|
566
|
+
optionIndex = this.visibleOptions.slice(this.focusedOptionIndex).findIndex(option => this.isOptionMatched(option));
|
|
567
|
+
optionIndex = optionIndex === -1 ? this.visibleOptions.slice(0, this.focusedOptionIndex).findIndex(option => this.isOptionMatched(option)) : optionIndex + this.focusedOptionIndex;
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
optionIndex = this.visibleOptions.findIndex(option => this.isOptionMatched(option));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
if (optionIndex === -1 && this.focusedOptionIndex === -1) {
|
|
574
|
+
optionIndex = this.findFirstFocusedOptionIndex();
|
|
575
|
+
}
|
|
258
576
|
|
|
259
|
-
|
|
260
|
-
|
|
577
|
+
if (optionIndex !== -1) {
|
|
578
|
+
this.changeFocusedOptionIndex(event, optionIndex);
|
|
579
|
+
}
|
|
261
580
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
this.onOptionSelect(event, option);
|
|
265
|
-
event.preventDefault();
|
|
266
|
-
break;
|
|
581
|
+
if (this.searchTimeout) {
|
|
582
|
+
clearTimeout(this.searchTimeout);
|
|
267
583
|
}
|
|
584
|
+
|
|
585
|
+
this.searchTimeout = setTimeout(() => {
|
|
586
|
+
this.searchValue = '';
|
|
587
|
+
this.searchTimeout = null;
|
|
588
|
+
}, 500);
|
|
268
589
|
},
|
|
269
|
-
|
|
270
|
-
|
|
590
|
+
removeOption(option) {
|
|
591
|
+
return this.modelValue.filter(val => !ObjectUtils.equals(val, this.getOptionValue(option), this.equalityKey));
|
|
592
|
+
},
|
|
593
|
+
changeFocusedOptionIndex(event, index) {
|
|
594
|
+
if (this.focusedOptionIndex !== index) {
|
|
595
|
+
this.focusedOptionIndex = index;
|
|
596
|
+
this.scrollInView();
|
|
271
597
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
598
|
+
if (this.selectOnFocus && !this.multiple) {
|
|
599
|
+
this.updateModel(event, this.getOptionValue(this.visibleOptions[index]));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
scrollInView(index = -1) {
|
|
604
|
+
const id = index !== -1 ? `${this.id}_${index}` : this.focusedOptionId;
|
|
605
|
+
const element = DomHandler.findSingle(this.list, `li[id="${id}"]`);
|
|
606
|
+
if (element) {
|
|
607
|
+
element.scrollIntoView && element.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
608
|
+
}
|
|
609
|
+
else if (!this.virtualScrollerDisabled) {
|
|
610
|
+
this.virtualScroller && this.virtualScroller.scrollToIndex(index !== -1 ? index : this.focusedOptionIndex);
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
autoUpdateModel() {
|
|
614
|
+
if (this.selectOnFocus && this.autoOptionFocus && !this.hasSelectedOption) {
|
|
615
|
+
this.focusedOptionIndex = this.findFirstFocusedOptionIndex();
|
|
616
|
+
const value = this.getOptionValue(this.visibleOptions[this.focusedOptionIndex]);
|
|
617
|
+
this.updateModel(null, this.multiple ? [value] : value);
|
|
618
|
+
}
|
|
619
|
+
},
|
|
620
|
+
updateModel(event, value) {
|
|
621
|
+
this.$emit('update:modelValue', value);
|
|
622
|
+
this.$emit('change', { originalEvent: event, value });
|
|
276
623
|
},
|
|
277
|
-
|
|
278
|
-
|
|
624
|
+
flatOptions(options) {
|
|
625
|
+
return (options || []).reduce((result, option, index) => {
|
|
626
|
+
result.push({ optionGroup: option, group: true, index });
|
|
279
627
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
return
|
|
628
|
+
const optionGroupChildren = this.getOptionGroupChildren(option);
|
|
629
|
+
optionGroupChildren && optionGroupChildren.forEach(o => result.push(o));
|
|
630
|
+
|
|
631
|
+
return result;
|
|
632
|
+
}, []);
|
|
284
633
|
},
|
|
285
|
-
|
|
286
|
-
this
|
|
634
|
+
listRef(el, contentRef) {
|
|
635
|
+
this.list = el;
|
|
636
|
+
contentRef && contentRef(el); // For VirtualScroller
|
|
287
637
|
},
|
|
288
638
|
virtualScrollerRef(el) {
|
|
289
639
|
this.virtualScroller = el;
|
|
290
640
|
}
|
|
291
641
|
},
|
|
292
642
|
computed: {
|
|
643
|
+
containerClass() {
|
|
644
|
+
return ['p-listbox p-component', {
|
|
645
|
+
'p-focus': this.focused,
|
|
646
|
+
'p-disabled': this.disabled
|
|
647
|
+
}];
|
|
648
|
+
},
|
|
293
649
|
visibleOptions() {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
filteredGroups.push({...optgroup, ...{items: filteredSubOptions}});
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return filteredGroups
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
return FilterService.filter(this.options, this.searchFields, this.filterValue, 'contains', this.filterLocale);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
return this.options;
|
|
311
|
-
}
|
|
650
|
+
const options = this.optionGroupLabel ? this.flatOptions(this.options) : (this.options || []);
|
|
651
|
+
|
|
652
|
+
return this.filterValue ? FilterService.filter(options, this.searchFields, this.filterValue, this.filterMatchMode, this.filterLocale) : options;
|
|
653
|
+
},
|
|
654
|
+
hasSelectedOption() {
|
|
655
|
+
return ObjectUtils.isNotEmpty(this.modelValue);
|
|
312
656
|
},
|
|
313
657
|
equalityKey() {
|
|
314
658
|
return this.optionValue ? null : this.dataKey;
|
|
@@ -316,11 +660,32 @@ export default {
|
|
|
316
660
|
searchFields() {
|
|
317
661
|
return this.filterFields || [this.optionLabel];
|
|
318
662
|
},
|
|
663
|
+
filterResultMessageText() {
|
|
664
|
+
return ObjectUtils.isNotEmpty(this.visibleOptions) ? this.filterMessageText.replaceAll('{0}', this.visibleOptions.length) : this.emptyFilterMessageText;
|
|
665
|
+
},
|
|
666
|
+
filterMessageText() {
|
|
667
|
+
return this.filterMessage || this.$primevue.config.locale.searchMessage || '';
|
|
668
|
+
},
|
|
319
669
|
emptyFilterMessageText() {
|
|
320
|
-
return this.emptyFilterMessage || this.$primevue.config.locale.emptyFilterMessage;
|
|
670
|
+
return this.emptyFilterMessage || this.$primevue.config.locale.emptySearchMessage || this.$primevue.config.locale.emptyFilterMessage || '';
|
|
321
671
|
},
|
|
322
672
|
emptyMessageText() {
|
|
323
|
-
return this.emptyMessage || this.$primevue.config.locale.emptyMessage;
|
|
673
|
+
return this.emptyMessage || this.$primevue.config.locale.emptyMessage || '';
|
|
674
|
+
},
|
|
675
|
+
selectionMessageText() {
|
|
676
|
+
return this.selectionMessage || this.$primevue.config.locale.selectionMessage || '';
|
|
677
|
+
},
|
|
678
|
+
emptySelectionMessageText() {
|
|
679
|
+
return this.emptySelectionMessage || this.$primevue.config.locale.emptySelectionMessage || '';
|
|
680
|
+
},
|
|
681
|
+
selectedMessageText() {
|
|
682
|
+
return this.hasSelectedOption ? this.selectionMessageText.replaceAll('{0}', this.multiple ? this.modelValue.length : '1') : this.emptySelectionMessageText;
|
|
683
|
+
},
|
|
684
|
+
focusedOptionId() {
|
|
685
|
+
return this.focusedOptionIndex !== -1 ? `${this.id}_${this.focusedOptionIndex}` : null;
|
|
686
|
+
},
|
|
687
|
+
ariaSetSize() {
|
|
688
|
+
return this.visibleOptions.filter(option => !this.isOptionGroup(option)).length;
|
|
324
689
|
},
|
|
325
690
|
virtualScrollerDisabled() {
|
|
326
691
|
return !this.virtualScrollerOptions;
|