primevue 3.15.0 → 3.16.0
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 +633 -342
- package/autocomplete/autocomplete.cjs.js +742 -416
- package/autocomplete/autocomplete.cjs.min.js +1 -1
- package/autocomplete/autocomplete.esm.js +744 -418
- package/autocomplete/autocomplete.esm.min.js +1 -1
- package/autocomplete/autocomplete.js +742 -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 +258 -113
- package/calendar/calendar.cjs.js +412 -218
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +413 -219
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +412 -218
- 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 +7 -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 +1110 -781
- package/core/core.min.js +17 -14
- package/datatable/BodyCell.vue +11 -2
- package/datatable/DataTable.vue +22 -1
- package/datatable/datatable.cjs.js +33 -3
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.esm.js +33 -3
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +33 -3
- package/datatable/datatable.min.js +1 -1
- package/dialog/Dialog.d.ts +5 -1
- package/dropdown/Dropdown.d.ts +93 -39
- package/dropdown/Dropdown.vue +537 -398
- package/dropdown/dropdown.cjs.js +656 -485
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +658 -487
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +656 -485
- 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 +54 -21
- package/inputnumber/inputnumber.cjs.js +75 -30
- package/inputnumber/inputnumber.cjs.min.js +1 -1
- package/inputnumber/inputnumber.esm.js +76 -31
- package/inputnumber/inputnumber.esm.min.js +1 -1
- package/inputnumber/inputnumber.js +75 -30
- 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 +499 -134
- package/listbox/listbox.cjs.js +596 -192
- package/listbox/listbox.cjs.min.js +1 -1
- package/listbox/listbox.esm.js +598 -194
- package/listbox/listbox.esm.min.js +1 -1
- package/listbox/listbox.js +596 -192
- 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 +112 -52
- package/multiselect/MultiSelect.vue +622 -337
- package/multiselect/multiselect.cjs.js +740 -426
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +742 -428
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +740 -426
- package/multiselect/multiselect.min.js +1 -1
- package/overlaypanel/OverlayPanel.d.ts +1 -1
- package/overlaypanel/OverlayPanel.vue +13 -1
- package/overlaypanel/overlaypanel.cjs.js +13 -1
- package/overlaypanel/overlaypanel.cjs.min.js +1 -1
- package/overlaypanel/overlaypanel.esm.js +13 -1
- package/overlaypanel/overlaypanel.esm.min.js +1 -1
- package/overlaypanel/overlaypanel.js +13 -1
- package/overlaypanel/overlaypanel.min.js +1 -1
- package/package.json +1 -1
- 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/portal/Portal.vue +6 -13
- package/portal/portal.cjs.js +4 -9
- package/portal/portal.cjs.min.js +1 -1
- package/portal/portal.esm.js +4 -9
- package/portal/portal.esm.min.js +1 -1
- package/portal/portal.js +4 -9
- package/portal/portal.min.js +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 +18 -11
- package/tooltip/tooltip.cjs.min.js +1 -1
- package/tooltip/tooltip.esm.js +18 -11
- package/tooltip/tooltip.esm.min.js +1 -1
- package/tooltip/tooltip.js +18 -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 +220 -173
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.esm.js +220 -173
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +220 -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/dropdown/Dropdown.vue
CHANGED
|
@@ -1,65 +1,71 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div ref="container" :class="containerClass" @click="
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<slot name="value" :value="modelValue" :placeholder="placeholder">{{label||'empty'}}</slot>
|
|
2
|
+
<div ref="container" :id="id" :class="containerClass" @click="onContainerClick">
|
|
3
|
+
<input v-if="editable" ref="focusInput" :id="inputId" type="text" :style="inputStyle" :class="inputStyleClass" :value="editableInputValue" :placeholder="placeholder" :tabindex="!disabled ? tabindex : -1" :disabled="disabled" autocomplete="off"
|
|
4
|
+
role="combobox" :aria-label="ariaLabel" :aria-labelledby="ariaLabelledby" aria-haspopup="listbox" :aria-expanded="overlayVisible" :aria-controls="id + '_list'" :aria-activedescendant="focused ? focusedOptionId : undefined"
|
|
5
|
+
@focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @input="onEditableInput" v-bind="inputProps">
|
|
6
|
+
<span v-else ref="focusInput" :id="inputId" :style="inputStyle" :class="inputStyleClass" :tabindex="!disabled ? tabindex : -1" role="combobox" :aria-label="ariaLabel || (label === 'p-emptylabel' ? undefined : label)" :aria-labelledby="ariaLabelledby"
|
|
7
|
+
aria-haspopup="listbox" :aria-expanded="overlayVisible" :aria-controls="id + '_list'" :aria-activedescendant="focused ? focusedOptionId : undefined" :aria-disabled="disabled"
|
|
8
|
+
@focus="onFocus" @blur="onBlur" @keydown="onKeyDown" v-bind="inputProps">
|
|
9
|
+
<slot name="value" :value="modelValue" :placeholder="placeholder">{{label === 'p-emptylabel' ? ' ' : label || 'empty'}}</slot>
|
|
11
10
|
</span>
|
|
12
|
-
<i v-if="showClear && modelValue != null" class="p-dropdown-clear-icon pi pi-times" @click="onClearClick
|
|
13
|
-
<div class="p-dropdown-trigger"
|
|
11
|
+
<i v-if="showClear && modelValue != null" class="p-dropdown-clear-icon pi pi-times" @click="onClearClick" v-bind="clearIconProps"></i>
|
|
12
|
+
<div class="p-dropdown-trigger">
|
|
14
13
|
<slot name="indicator">
|
|
15
|
-
<span :class="dropdownIconClass"></span>
|
|
14
|
+
<span :class="dropdownIconClass" aria-hidden="true"></span>
|
|
16
15
|
</slot>
|
|
17
16
|
</div>
|
|
18
17
|
<Portal :appendTo="appendTo">
|
|
19
18
|
<transition name="p-connected-overlay" @enter="onOverlayEnter" @after-enter="onOverlayAfterEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave">
|
|
20
|
-
<div :ref="overlayRef" :
|
|
19
|
+
<div v-if="overlayVisible" :ref="overlayRef" :style="panelStyle" :class="panelStyleClass" @click="onOverlayClick" @keydown="onOverlayKeyDown" v-bind="panelProps">
|
|
20
|
+
<span ref="firstHiddenFocusableElementOnOverlay" role="presentation" aria-hidden="true" class="p-hidden-accessible p-hidden-focusable" :tabindex="0" @focus="onFirstHiddenFocus"></span>
|
|
21
21
|
<slot name="header" :value="modelValue" :options="visibleOptions"></slot>
|
|
22
|
-
<div class="p-dropdown-header"
|
|
23
|
-
<div
|
|
24
|
-
<input type="text" ref="filterInput" :value="filterValue" @vnode-updated="onFilterUpdated"
|
|
22
|
+
<div v-if="filter" class="p-dropdown-header">
|
|
23
|
+
<div class="p-dropdown-filter-container">
|
|
24
|
+
<input type="text" ref="filterInput" :value="filterValue" @vnode-updated="onFilterUpdated" class="p-dropdown-filter p-inputtext p-component" :placeholder="filterPlaceholder"
|
|
25
|
+
role="searchbox" autocomplete="off" :aria-owns="id + '_list'" :aria-activedescendant="focusedOptionId"
|
|
26
|
+
@keydown="onFilterKeyDown" @blur="onFilterBlur" @input="onFilterChange" v-bind="filterInputProps"/>
|
|
25
27
|
<span class="p-dropdown-filter-icon pi pi-search"></span>
|
|
26
28
|
</div>
|
|
29
|
+
<span role="status" aria-live="polite" class="p-hidden-accessible">
|
|
30
|
+
{{filterResultMessageText}}
|
|
31
|
+
</span>
|
|
27
32
|
</div>
|
|
28
|
-
<div
|
|
29
|
-
<VirtualScroller :ref="virtualScrollerRef" v-bind="virtualScrollerOptions" :items="visibleOptions" :style="{'height': scrollHeight}" :disabled="virtualScrollerDisabled">
|
|
30
|
-
<template v-slot:content="{ styleClass, contentRef, items, getItemOptions, contentStyle }">
|
|
31
|
-
<ul :ref="contentRef" :class="['p-dropdown-items', styleClass]" :style="contentStyle" role="listbox">
|
|
32
|
-
<template v-
|
|
33
|
-
<li v-
|
|
34
|
-
|
|
33
|
+
<div class="p-dropdown-items-wrapper" :style="{'max-height': virtualScrollerDisabled ? scrollHeight : ''}">
|
|
34
|
+
<VirtualScroller :ref="virtualScrollerRef" v-bind="virtualScrollerOptions" :items="visibleOptions" :style="{'height': scrollHeight}" :tabindex="-1" :disabled="virtualScrollerDisabled">
|
|
35
|
+
<template v-slot:content="{ styleClass, contentRef, items, getItemOptions, contentStyle, itemSize }">
|
|
36
|
+
<ul :ref="(el) => listRef(el, contentRef)" :id="id + '_list'" :class="['p-dropdown-items', styleClass]" :style="contentStyle" role="listbox">
|
|
37
|
+
<template v-for="(option, i) of items" :key="getOptionRenderKey(option, getOptionIndex(i, getItemOptions))">
|
|
38
|
+
<li v-if="isOptionGroup(option)" :id="id + '_' + getOptionIndex(i, getItemOptions)" :style="{height: itemSize ? itemSize + 'px' : undefined}" class="p-dropdown-item-group" role="option">
|
|
39
|
+
<slot name="optiongroup" :option="option.optionGroup" :index="getOptionIndex(i, getItemOptions)">{{getOptionGroupLabel(option.optionGroup)}}</slot>
|
|
40
|
+
</li>
|
|
41
|
+
<li v-else v-ripple :id="id + '_' + getOptionIndex(i, getItemOptions)" :style="{height: itemSize ? itemSize + 'px' : undefined}"
|
|
42
|
+
:class="['p-dropdown-item', {'p-highlight': isSelected(option), 'p-focus': focusedOptionIndex === getOptionIndex(i, getItemOptions), 'p-disabled': isOptionDisabled(option)}]"
|
|
43
|
+
role="option" :aria-label="getOptionLabel(option)" :aria-selected="isSelected(option)" :aria-disabled="isOptionDisabled(option)" :aria-setsize="ariaSetSize" :aria-posinset="getAriaPosInset(getOptionIndex(i, getItemOptions))"
|
|
44
|
+
@click="onOptionSelect($event, option)" @mousemove="onOptionMouseMove($event, getOptionIndex(i, getItemOptions))">
|
|
35
45
|
<slot name="option" :option="option" :index="getOptionIndex(i, getItemOptions)">{{getOptionLabel(option)}}</slot>
|
|
36
46
|
</li>
|
|
37
47
|
</template>
|
|
38
|
-
<
|
|
39
|
-
<template v-for="(optionGroup, i) of items" :key="getOptionGroupRenderKey(optionGroup)">
|
|
40
|
-
<li class="p-dropdown-item-group">
|
|
41
|
-
<slot name="optiongroup" :option="optionGroup" :index="getOptionIndex(i, getItemOptions)">{{getOptionGroupLabel(optionGroup)}}</slot>
|
|
42
|
-
</li>
|
|
43
|
-
<li v-for="(option, i) of getOptionGroupChildren(optionGroup)" :class="['p-dropdown-item', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option)}]" v-ripple
|
|
44
|
-
:key="getOptionRenderKey(option, i)" @click="onOptionSelect($event, option)" role="option" :aria-label="getOptionLabel(option)" :aria-selected="isSelected(option)">
|
|
45
|
-
<slot name="option" :option="option" :index="getOptionIndex(i, getItemOptions)">{{getOptionLabel(option)}}</slot>
|
|
46
|
-
</li>
|
|
47
|
-
</template>
|
|
48
|
-
</template>
|
|
49
|
-
<li v-if="filterValue && (!items || (items && items.length === 0))" class="p-dropdown-empty-message">
|
|
48
|
+
<li v-if="filterValue && (!items || (items && items.length === 0))" class="p-dropdown-empty-message" role="option">
|
|
50
49
|
<slot name="emptyfilter">{{emptyFilterMessageText}}</slot>
|
|
51
50
|
</li>
|
|
52
|
-
<li v-else-if="(!options || (options && options.length === 0))" class="p-dropdown-empty-message">
|
|
51
|
+
<li v-else-if="(!options || (options && options.length === 0))" class="p-dropdown-empty-message" role="option">
|
|
53
52
|
<slot name="empty">{{emptyMessageText}}</slot>
|
|
54
53
|
</li>
|
|
55
54
|
</ul>
|
|
55
|
+
<span v-if="(!options || (options && options.length === 0))" role="status" aria-live="polite" class="p-hidden-accessible">
|
|
56
|
+
{{emptyMessageText}}
|
|
57
|
+
</span>
|
|
58
|
+
<span role="status" aria-live="polite" class="p-hidden-accessible">
|
|
59
|
+
{{selectedMessageText}}
|
|
60
|
+
</span>
|
|
56
61
|
</template>
|
|
57
|
-
<template v-slot:loader="{ options }"
|
|
62
|
+
<template v-if="$slots.loader" v-slot:loader="{ options }">
|
|
58
63
|
<slot name="loader" :options="options"></slot>
|
|
59
64
|
</template>
|
|
60
65
|
</VirtualScroller>
|
|
61
66
|
</div>
|
|
62
67
|
<slot name="footer" :value="modelValue" :options="visibleOptions"></slot>
|
|
68
|
+
<span ref="lastHiddenFocusableElementOnOverlay" role="presentation" aria-hidden="true" class="p-hidden-accessible p-hidden-focusable" :tabindex="0" @focus="onLastHiddenFocus"></span>
|
|
63
69
|
</div>
|
|
64
70
|
</transition>
|
|
65
71
|
</Portal>
|
|
@@ -67,7 +73,7 @@
|
|
|
67
73
|
</template>
|
|
68
74
|
|
|
69
75
|
<script>
|
|
70
|
-
import {ConnectedOverlayScrollHandler,ObjectUtils,DomHandler,ZIndexUtils} from 'primevue/utils';
|
|
76
|
+
import {ConnectedOverlayScrollHandler,ObjectUtils,DomHandler,ZIndexUtils,UniqueComponentId} from 'primevue/utils';
|
|
71
77
|
import OverlayEventBus from 'primevue/overlayeventbus';
|
|
72
78
|
import {FilterService} from 'primevue/api';
|
|
73
79
|
import Ripple from 'primevue/ripple';
|
|
@@ -76,7 +82,7 @@ import Portal from 'primevue/portal';
|
|
|
76
82
|
|
|
77
83
|
export default {
|
|
78
84
|
name: 'Dropdown',
|
|
79
|
-
emits: ['update:modelValue', '
|
|
85
|
+
emits: ['update:modelValue', 'change', 'focus', 'blur', 'before-show', 'before-hide', 'show', 'hide', 'filter'],
|
|
80
86
|
props: {
|
|
81
87
|
modelValue: null,
|
|
82
88
|
options: Array,
|
|
@@ -106,12 +112,46 @@ export default {
|
|
|
106
112
|
dataKey: null,
|
|
107
113
|
showClear: Boolean,
|
|
108
114
|
inputId: String,
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
inputStyle: null,
|
|
116
|
+
inputClass: null,
|
|
117
|
+
inputProps: null,
|
|
118
|
+
panelStyle: null,
|
|
119
|
+
panelClass: null,
|
|
120
|
+
panelProps: null,
|
|
121
|
+
filterInputProps: null,
|
|
122
|
+
clearIconProps: null,
|
|
111
123
|
appendTo: {
|
|
112
124
|
type: String,
|
|
113
125
|
default: 'body'
|
|
114
126
|
},
|
|
127
|
+
loading: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: false
|
|
130
|
+
},
|
|
131
|
+
loadingIcon: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: 'pi pi-spinner pi-spin'
|
|
134
|
+
},
|
|
135
|
+
virtualScrollerOptions: {
|
|
136
|
+
type: Object,
|
|
137
|
+
default: null
|
|
138
|
+
},
|
|
139
|
+
autoOptionFocus: {
|
|
140
|
+
type: Boolean,
|
|
141
|
+
default: true
|
|
142
|
+
},
|
|
143
|
+
filterMessage: {
|
|
144
|
+
type: String,
|
|
145
|
+
default: null
|
|
146
|
+
},
|
|
147
|
+
selectionMessage: {
|
|
148
|
+
type: String,
|
|
149
|
+
default: null
|
|
150
|
+
},
|
|
151
|
+
emptySelectionMessage: {
|
|
152
|
+
type: String,
|
|
153
|
+
default: null
|
|
154
|
+
},
|
|
115
155
|
emptyFilterMessage: {
|
|
116
156
|
type: String,
|
|
117
157
|
default: null
|
|
@@ -120,46 +160,55 @@ export default {
|
|
|
120
160
|
type: String,
|
|
121
161
|
default: null
|
|
122
162
|
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
default: false
|
|
163
|
+
tabindex: {
|
|
164
|
+
type: Number,
|
|
165
|
+
default: 0
|
|
127
166
|
},
|
|
128
|
-
|
|
167
|
+
'aria-label': {
|
|
129
168
|
type: String,
|
|
130
|
-
default:
|
|
169
|
+
default: null
|
|
131
170
|
},
|
|
132
|
-
|
|
133
|
-
type:
|
|
171
|
+
'aria-labelledby': {
|
|
172
|
+
type: String,
|
|
134
173
|
default: null
|
|
135
174
|
}
|
|
136
175
|
},
|
|
176
|
+
outsideClickListener: null,
|
|
177
|
+
scrollHandler: null,
|
|
178
|
+
resizeListener: null,
|
|
179
|
+
overlay: null,
|
|
180
|
+
list: null,
|
|
181
|
+
virtualScroller: null,
|
|
182
|
+
searchTimeout: null,
|
|
183
|
+
searchValue: null,
|
|
184
|
+
isModelValueChanged: false,
|
|
185
|
+
selectOnFocus: false,
|
|
186
|
+
focusOnHover: false,
|
|
137
187
|
data() {
|
|
138
188
|
return {
|
|
189
|
+
id: UniqueComponentId(),
|
|
139
190
|
focused: false,
|
|
191
|
+
focusedOptionIndex: -1,
|
|
140
192
|
filterValue: null,
|
|
141
193
|
overlayVisible: false
|
|
142
|
-
}
|
|
194
|
+
}
|
|
143
195
|
},
|
|
144
196
|
watch: {
|
|
145
197
|
modelValue() {
|
|
146
198
|
this.isModelValueChanged = true;
|
|
199
|
+
},
|
|
200
|
+
options() {
|
|
201
|
+
this.autoUpdateModel();
|
|
147
202
|
}
|
|
148
203
|
},
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
previousSearchChar: null,
|
|
155
|
-
searchValue: null,
|
|
156
|
-
overlay: null,
|
|
157
|
-
itemsWrapper: null,
|
|
158
|
-
virtualScroller: null,
|
|
159
|
-
isModelValueChanged: false,
|
|
204
|
+
mounted() {
|
|
205
|
+
this.id = this.$attrs.id || this.id;
|
|
206
|
+
|
|
207
|
+
this.autoUpdateModel();
|
|
208
|
+
},
|
|
160
209
|
updated() {
|
|
161
210
|
if (this.overlayVisible && this.isModelValueChanged) {
|
|
162
|
-
this.
|
|
211
|
+
this.scrollInView(this.findSelectedOptionIndex());
|
|
163
212
|
}
|
|
164
213
|
|
|
165
214
|
this.isModelValueChanged = false;
|
|
@@ -173,8 +222,6 @@ export default {
|
|
|
173
222
|
this.scrollHandler = null;
|
|
174
223
|
}
|
|
175
224
|
|
|
176
|
-
this.itemsWrapper = null;
|
|
177
|
-
|
|
178
225
|
if (this.overlay) {
|
|
179
226
|
ZIndexUtils.clear(this.overlay);
|
|
180
227
|
this.overlay = null;
|
|
@@ -191,13 +238,13 @@ export default {
|
|
|
191
238
|
return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : option;
|
|
192
239
|
},
|
|
193
240
|
getOptionRenderKey(option, index) {
|
|
194
|
-
return this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : this.getOptionLabel(option) + '_' + index
|
|
241
|
+
return (this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : this.getOptionLabel(option)) + '_' + index;
|
|
195
242
|
},
|
|
196
243
|
isOptionDisabled(option) {
|
|
197
244
|
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
|
198
245
|
},
|
|
199
|
-
|
|
200
|
-
return
|
|
246
|
+
isOptionGroup(option) {
|
|
247
|
+
return this.optionGroupLabel && option.optionGroup && option.group;
|
|
201
248
|
},
|
|
202
249
|
getOptionGroupLabel(optionGroup) {
|
|
203
250
|
return ObjectUtils.resolveFieldData(optionGroup, this.optionGroupLabel);
|
|
@@ -205,257 +252,339 @@ export default {
|
|
|
205
252
|
getOptionGroupChildren(optionGroup) {
|
|
206
253
|
return ObjectUtils.resolveFieldData(optionGroup, this.optionGroupChildren);
|
|
207
254
|
},
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return index !== -1 ? (this.optionGroupLabel ? this.getOptionGroupChildren(this.visibleOptions[index.group])[index.option]: this.visibleOptions[index]) : null;
|
|
211
|
-
},
|
|
212
|
-
getSelectedOptionIndex() {
|
|
213
|
-
if (this.modelValue != null && this.visibleOptions) {
|
|
214
|
-
if (this.optionGroupLabel) {
|
|
215
|
-
for (let i = 0; i < this.visibleOptions.length; i++) {
|
|
216
|
-
let selectedOptionIndex = this.findOptionIndexInList(this.modelValue, this.getOptionGroupChildren(this.visibleOptions[i]));
|
|
217
|
-
if (selectedOptionIndex !== -1) {
|
|
218
|
-
return {group: i, option: selectedOptionIndex};
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
return this.findOptionIndexInList(this.modelValue, this.visibleOptions);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return -1;
|
|
228
|
-
},
|
|
229
|
-
findOptionIndexInList(value, list) {
|
|
230
|
-
for (let i = 0; i < list.length; i++) {
|
|
231
|
-
if ((ObjectUtils.equals(value, this.getOptionValue(list[i]), this.equalityKey))) {
|
|
232
|
-
return i;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
return -1;
|
|
237
|
-
},
|
|
238
|
-
isSelected(option) {
|
|
239
|
-
return ObjectUtils.equals(this.modelValue, this.getOptionValue(option), this.equalityKey);
|
|
255
|
+
getAriaPosInset(index) {
|
|
256
|
+
return (this.optionGroupLabel ? index - this.visibleOptions.slice(0, index).filter(option => this.isOptionGroup(option)).length : index) + 1;
|
|
240
257
|
},
|
|
241
258
|
show(isFocus) {
|
|
242
259
|
this.$emit('before-show');
|
|
243
260
|
this.overlayVisible = true;
|
|
261
|
+
this.focusedOptionIndex = this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : (this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1);
|
|
244
262
|
|
|
245
263
|
isFocus && this.$refs.focusInput.focus();
|
|
246
264
|
},
|
|
247
|
-
hide() {
|
|
248
|
-
|
|
249
|
-
|
|
265
|
+
hide(isFocus) {
|
|
266
|
+
const _hide = () => {
|
|
267
|
+
this.$emit('before-hide');
|
|
268
|
+
this.overlayVisible = false;
|
|
269
|
+
this.focusedOptionIndex = -1;
|
|
270
|
+
this.searchValue = '';
|
|
271
|
+
|
|
272
|
+
isFocus && this.$refs.focusInput.focus();
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
setTimeout(() => { _hide() }, 0); // For ScreenReaders
|
|
250
276
|
},
|
|
251
277
|
onFocus(event) {
|
|
252
278
|
this.focused = true;
|
|
279
|
+
this.focusedOptionIndex = this.overlayVisible && this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1;
|
|
280
|
+
this.overlayVisible && this.scrollInView(this.focusedOptionIndex);
|
|
253
281
|
this.$emit('focus', event);
|
|
254
282
|
},
|
|
255
283
|
onBlur(event) {
|
|
256
284
|
this.focused = false;
|
|
285
|
+
this.focusedOptionIndex = -1;
|
|
286
|
+
this.searchValue = '';
|
|
257
287
|
this.$emit('blur', event);
|
|
258
288
|
},
|
|
259
289
|
onKeyDown(event) {
|
|
260
|
-
switch(event.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
break;
|
|
265
|
-
|
|
266
|
-
//up
|
|
267
|
-
case 38:
|
|
268
|
-
this.onUpKey(event);
|
|
269
|
-
break;
|
|
270
|
-
|
|
271
|
-
//space
|
|
272
|
-
case 32:
|
|
273
|
-
if (!this.overlayVisible) {
|
|
274
|
-
this.show();
|
|
275
|
-
event.preventDefault();
|
|
276
|
-
}
|
|
277
|
-
break;
|
|
290
|
+
switch (event.code) {
|
|
291
|
+
case 'ArrowDown':
|
|
292
|
+
this.onArrowDownKey(event);
|
|
293
|
+
break;
|
|
278
294
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
295
|
+
case 'ArrowUp':
|
|
296
|
+
this.onArrowUpKey(event, this.editable);
|
|
297
|
+
break;
|
|
298
|
+
|
|
299
|
+
case 'ArrowLeft':
|
|
300
|
+
case 'ArrowRight':
|
|
301
|
+
this.onArrowLeftKey(event, this.editable);
|
|
302
|
+
break;
|
|
303
|
+
|
|
304
|
+
case 'Home':
|
|
305
|
+
this.onHomeKey(event, this.editable);
|
|
306
|
+
break;
|
|
307
|
+
|
|
308
|
+
case 'End':
|
|
309
|
+
this.onEndKey(event, this.editable);
|
|
310
|
+
break;
|
|
311
|
+
|
|
312
|
+
case 'PageDown':
|
|
313
|
+
this.onPageDownKey(event);
|
|
314
|
+
break;
|
|
315
|
+
|
|
316
|
+
case 'PageUp':
|
|
317
|
+
this.onPageUpKey(event);
|
|
318
|
+
break;
|
|
319
|
+
|
|
320
|
+
case 'Space':
|
|
321
|
+
this.onSpaceKey(event, this.editable);
|
|
322
|
+
break;
|
|
323
|
+
|
|
324
|
+
case 'Enter':
|
|
325
|
+
this.onEnterKey(event);
|
|
326
|
+
break;
|
|
327
|
+
|
|
328
|
+
case 'Escape':
|
|
329
|
+
this.onEscapeKey(event);
|
|
330
|
+
break;
|
|
331
|
+
|
|
332
|
+
case 'Tab':
|
|
333
|
+
this.onTabKey(event);
|
|
334
|
+
break;
|
|
287
335
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
336
|
+
case 'Backspace':
|
|
337
|
+
this.onBackspaceKey(event, this.editable);
|
|
338
|
+
break;
|
|
339
|
+
|
|
340
|
+
case 'ShiftLeft':
|
|
341
|
+
case 'ShiftRight':
|
|
342
|
+
//NOOP
|
|
343
|
+
break;
|
|
292
344
|
|
|
293
345
|
default:
|
|
294
|
-
|
|
295
|
-
|
|
346
|
+
if (ObjectUtils.isPrintableCharacter(event.key)) {
|
|
347
|
+
!this.overlayVisible && this.show();
|
|
348
|
+
!this.editable && this.searchOptions(event, event.key);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
break;
|
|
296
352
|
}
|
|
297
353
|
},
|
|
354
|
+
onEditableInput(event) {
|
|
355
|
+
const value = event.target.value;
|
|
356
|
+
|
|
357
|
+
this.searchValue = '';
|
|
358
|
+
const matched = this.searchOptions(event, value);
|
|
359
|
+
!matched && (this.focusedOptionIndex = -1);
|
|
360
|
+
|
|
361
|
+
this.$emit('update:modelValue', value);
|
|
362
|
+
},
|
|
363
|
+
onContainerClick(event) {
|
|
364
|
+
if (this.disabled || this.loading) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (DomHandler.hasClass(event.target, 'p-dropdown-clear-icon') || event.target.tagName === 'INPUT') {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
else if (!this.overlay || !this.overlay.contains(event.target)) {
|
|
372
|
+
this.overlayVisible ? this.hide(true) : this.show(true);
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
onClearClick(event) {
|
|
376
|
+
this.updateModel(event, null);
|
|
377
|
+
},
|
|
378
|
+
onFirstHiddenFocus(event) {
|
|
379
|
+
const relatedTarget = event.relatedTarget;
|
|
380
|
+
|
|
381
|
+
if (relatedTarget === this.$refs.focusInput) {
|
|
382
|
+
const firstFocusableEl = DomHandler.getFirstFocusableElement(this.overlay, ':not(.p-hidden-focusable)');
|
|
383
|
+
firstFocusableEl && firstFocusableEl.focus();
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
this.$refs.focusInput.focus();
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
onLastHiddenFocus() {
|
|
390
|
+
this.$refs.firstHiddenFocusableElementOnOverlay.focus();
|
|
391
|
+
},
|
|
392
|
+
onOptionSelect(event, option) {
|
|
393
|
+
const value = this.getOptionValue(option);
|
|
394
|
+
|
|
395
|
+
this.updateModel(event, value);
|
|
396
|
+
this.hide(true);
|
|
397
|
+
},
|
|
398
|
+
onOptionMouseMove(event, index) {
|
|
399
|
+
if (this.focusOnHover) {
|
|
400
|
+
this.changeFocusedOptionIndex(event, index);
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
onFilterChange(event) {
|
|
404
|
+
const value = event.target.value;
|
|
405
|
+
|
|
406
|
+
this.filterValue = value;
|
|
407
|
+
this.focusedOptionIndex = -1;
|
|
408
|
+
this.$emit('filter', { originalEvent: event, value });
|
|
409
|
+
|
|
410
|
+
!this.virtualScrollerDisabled && this.virtualScroller.scrollToIndex(0);
|
|
411
|
+
},
|
|
298
412
|
onFilterKeyDown(event) {
|
|
299
|
-
switch (event.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
this.onDownKey(event);
|
|
413
|
+
switch (event.code) {
|
|
414
|
+
case 'ArrowDown':
|
|
415
|
+
this.onArrowDownKey(event);
|
|
303
416
|
break;
|
|
304
417
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
this.onUpKey(event);
|
|
418
|
+
case 'ArrowUp':
|
|
419
|
+
this.onArrowUpKey(event, true);
|
|
308
420
|
break;
|
|
309
421
|
|
|
310
|
-
|
|
311
|
-
case
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
422
|
+
case 'ArrowLeft':
|
|
423
|
+
case 'ArrowRight':
|
|
424
|
+
this.onArrowLeftKey(event, true);
|
|
425
|
+
break;
|
|
426
|
+
|
|
427
|
+
case 'Home':
|
|
428
|
+
this.onHomeKey(event, true);
|
|
429
|
+
break;
|
|
430
|
+
|
|
431
|
+
case 'End':
|
|
432
|
+
this.onEndKey(event, true);
|
|
433
|
+
break;
|
|
434
|
+
|
|
435
|
+
case 'Enter':
|
|
436
|
+
this.onEnterKey(event);
|
|
437
|
+
break;
|
|
438
|
+
|
|
439
|
+
case 'Escape':
|
|
440
|
+
this.onEscapeKey(event);
|
|
441
|
+
break;
|
|
442
|
+
|
|
443
|
+
case 'Tab':
|
|
444
|
+
this.onTabKey(event, true);
|
|
445
|
+
break;
|
|
316
446
|
|
|
317
447
|
default:
|
|
318
|
-
|
|
448
|
+
break;
|
|
319
449
|
}
|
|
320
450
|
},
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
let nextOption = this.visibleOptions && this.visibleOptions.length > 0 ? this.findNextOption(this.getSelectedOptionIndex()) : null;
|
|
328
|
-
if (nextOption) {
|
|
329
|
-
this.updateModel(event, this.getOptionValue(nextOption));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
451
|
+
onFilterBlur() {
|
|
452
|
+
this.focusedOptionIndex = -1;
|
|
453
|
+
},
|
|
454
|
+
onFilterUpdated() {
|
|
455
|
+
if (this.overlayVisible) {
|
|
456
|
+
this.alignOverlay();
|
|
332
457
|
}
|
|
333
|
-
|
|
334
|
-
event.preventDefault();
|
|
335
458
|
},
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
459
|
+
onOverlayClick(event) {
|
|
460
|
+
OverlayEventBus.emit('overlay-click', {
|
|
461
|
+
originalEvent: event,
|
|
462
|
+
target: this.$el
|
|
463
|
+
});
|
|
464
|
+
},
|
|
465
|
+
onOverlayKeyDown(event) {
|
|
466
|
+
switch (event.code) {
|
|
467
|
+
case 'Escape':
|
|
468
|
+
this.onEscapeKey(event);
|
|
469
|
+
break;
|
|
470
|
+
|
|
471
|
+
default:
|
|
472
|
+
break;
|
|
342
473
|
}
|
|
474
|
+
},
|
|
475
|
+
onArrowDownKey(event) {
|
|
476
|
+
const optionIndex = this.focusedOptionIndex !== -1 ? this.findNextOptionIndex(this.focusedOptionIndex) : this.findFirstFocusedOptionIndex();
|
|
477
|
+
|
|
478
|
+
this.changeFocusedOptionIndex(event, optionIndex);
|
|
343
479
|
|
|
480
|
+
!this.overlayVisible && this.show();
|
|
344
481
|
event.preventDefault();
|
|
345
482
|
},
|
|
346
|
-
|
|
347
|
-
if (
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
483
|
+
onArrowUpKey(event, pressedInInputText = false) {
|
|
484
|
+
if (event.altKey && !pressedInInputText) {
|
|
485
|
+
if (this.focusedOptionIndex !== -1) {
|
|
486
|
+
this.onOptionSelect(event, this.visibleOptions[this.focusedOptionIndex]);
|
|
487
|
+
}
|
|
351
488
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
else if ((groupIndex + 1) !== this.visibleOptions.length)
|
|
355
|
-
return this.findNextOption({group: (groupIndex + 1), option: -1});
|
|
356
|
-
else
|
|
357
|
-
return null;
|
|
489
|
+
this.overlayVisible && this.hide();
|
|
490
|
+
event.preventDefault();
|
|
358
491
|
}
|
|
359
492
|
else {
|
|
360
|
-
|
|
493
|
+
const optionIndex = this.focusedOptionIndex !== -1 ? this.findPrevOptionIndex(this.focusedOptionIndex) : this.findLastFocusedOptionIndex();
|
|
494
|
+
|
|
495
|
+
this.changeFocusedOptionIndex(event, optionIndex);
|
|
496
|
+
|
|
497
|
+
!this.overlayVisible && this.show();
|
|
498
|
+
event.preventDefault();
|
|
361
499
|
}
|
|
362
500
|
},
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (i === list.length) {
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
let option = list[i];
|
|
370
|
-
if (this.isOptionDisabled(option))
|
|
371
|
-
return this.findNextOptionInList(i);
|
|
372
|
-
else
|
|
373
|
-
return option;
|
|
501
|
+
onArrowLeftKey(event, pressedInInputText = false) {
|
|
502
|
+
pressedInInputText && (this.focusedOptionIndex = -1);
|
|
374
503
|
},
|
|
375
|
-
|
|
376
|
-
if (
|
|
377
|
-
|
|
504
|
+
onHomeKey(event, pressedInInputText = false) {
|
|
505
|
+
if (pressedInInputText) {
|
|
506
|
+
event.currentTarget.setSelectionRange(0, 0);
|
|
507
|
+
this.focusedOptionIndex = -1;
|
|
378
508
|
}
|
|
509
|
+
else {
|
|
510
|
+
this.changeFocusedOptionIndex(event, this.findFirstOptionIndex());
|
|
379
511
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
let optionIndex = index.option;
|
|
383
|
-
let option = this.findPrevOptionInList(this.getOptionGroupChildren(this.visibleOptions[groupIndex]), optionIndex);
|
|
512
|
+
!this.overlayVisible && this.show();
|
|
513
|
+
}
|
|
384
514
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
515
|
+
event.preventDefault();
|
|
516
|
+
},
|
|
517
|
+
onEndKey(event, pressedInInputText = false) {
|
|
518
|
+
if (pressedInInputText) {
|
|
519
|
+
const target = event.currentTarget;
|
|
520
|
+
const len = target.value.length;
|
|
521
|
+
target.setSelectionRange(len, len);
|
|
522
|
+
this.focusedOptionIndex = -1;
|
|
391
523
|
}
|
|
392
524
|
else {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
findPrevOptionInList(list, index) {
|
|
397
|
-
let i = index - 1;
|
|
398
|
-
if (i < 0) {
|
|
399
|
-
return null;
|
|
525
|
+
this.changeFocusedOptionIndex(event, this.findLastOptionIndex());
|
|
526
|
+
|
|
527
|
+
!this.overlayVisible && this.show();
|
|
400
528
|
}
|
|
401
529
|
|
|
402
|
-
|
|
403
|
-
if (this.isOptionDisabled(option))
|
|
404
|
-
return this.findPrevOption(i);
|
|
405
|
-
else
|
|
406
|
-
return option;
|
|
530
|
+
event.preventDefault();
|
|
407
531
|
},
|
|
408
|
-
|
|
409
|
-
this.
|
|
532
|
+
onPageUpKey(event) {
|
|
533
|
+
this.scrollInView(0);
|
|
534
|
+
event.preventDefault();
|
|
410
535
|
},
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
536
|
+
onPageDownKey(event) {
|
|
537
|
+
this.scrollInView(this.visibleOptions.length - 1);
|
|
538
|
+
event.preventDefault();
|
|
539
|
+
},
|
|
540
|
+
onEnterKey(event) {
|
|
541
|
+
if (!this.overlayVisible) {
|
|
542
|
+
this.onArrowDownKey(event);
|
|
414
543
|
}
|
|
544
|
+
else {
|
|
545
|
+
if (this.focusedOptionIndex !== -1) {
|
|
546
|
+
this.onOptionSelect(event, this.visibleOptions[this.focusedOptionIndex]);
|
|
547
|
+
}
|
|
415
548
|
|
|
416
|
-
|
|
417
|
-
return;
|
|
549
|
+
this.hide();
|
|
418
550
|
}
|
|
419
|
-
else if (!this.overlay || !this.overlay.contains(event.target)) {
|
|
420
|
-
if (this.overlayVisible)
|
|
421
|
-
this.hide();
|
|
422
|
-
else
|
|
423
|
-
this.show();
|
|
424
551
|
|
|
425
|
-
|
|
426
|
-
}
|
|
552
|
+
event.preventDefault();
|
|
427
553
|
},
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
554
|
+
onSpaceKey(event, pressedInInputText = false) {
|
|
555
|
+
!pressedInInputText && this.onEnterKey(event);
|
|
556
|
+
},
|
|
557
|
+
onEscapeKey(event) {
|
|
558
|
+
this.overlayVisible && this.hide(true);
|
|
559
|
+
event.preventDefault();
|
|
560
|
+
},
|
|
561
|
+
onTabKey(event, pressedInInputText = false) {
|
|
562
|
+
if (!pressedInInputText) {
|
|
563
|
+
if (this.overlayVisible && this.hasFocusableElements()) {
|
|
564
|
+
this.$refs.firstHiddenFocusableElementOnOverlay.focus();
|
|
432
565
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
566
|
+
event.preventDefault();
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
if (this.focusedOptionIndex !== -1) {
|
|
570
|
+
this.onOptionSelect(event, this.visibleOptions[this.focusedOptionIndex]);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
this.overlayVisible && this.hide(this.filter);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
436
576
|
},
|
|
437
|
-
|
|
438
|
-
|
|
577
|
+
onBackspaceKey(event, pressedInInputText = false) {
|
|
578
|
+
if (pressedInInputText) {
|
|
579
|
+
!this.overlayVisible && this.show();
|
|
580
|
+
}
|
|
439
581
|
},
|
|
440
582
|
onOverlayEnter(el) {
|
|
441
583
|
ZIndexUtils.set('overlay', el, this.$primevue.config.zIndex.overlay);
|
|
442
584
|
this.alignOverlay();
|
|
443
|
-
this.
|
|
444
|
-
|
|
445
|
-
if (!this.virtualScrollerDisabled) {
|
|
446
|
-
const selectedIndex = this.getSelectedOptionIndex();
|
|
447
|
-
if (selectedIndex !== -1) {
|
|
448
|
-
setTimeout(() => {
|
|
449
|
-
this.virtualScroller && this.virtualScroller.scrollToIndex(selectedIndex)
|
|
450
|
-
}, 0);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
585
|
+
this.scrollInView();
|
|
453
586
|
},
|
|
454
587
|
onOverlayAfterEnter() {
|
|
455
|
-
if (this.filter) {
|
|
456
|
-
this.$refs.filterInput.focus();
|
|
457
|
-
}
|
|
458
|
-
|
|
459
588
|
this.bindOutsideClickListener();
|
|
460
589
|
this.bindScrollListener();
|
|
461
590
|
this.bindResizeListener();
|
|
@@ -466,8 +595,8 @@ export default {
|
|
|
466
595
|
this.unbindOutsideClickListener();
|
|
467
596
|
this.unbindScrollListener();
|
|
468
597
|
this.unbindResizeListener();
|
|
598
|
+
|
|
469
599
|
this.$emit('hide');
|
|
470
|
-
this.itemsWrapper = null;
|
|
471
600
|
this.overlay = null;
|
|
472
601
|
},
|
|
473
602
|
onOverlayAfterLeave(el) {
|
|
@@ -482,10 +611,6 @@ export default {
|
|
|
482
611
|
DomHandler.absolutePosition(this.overlay, this.$el);
|
|
483
612
|
}
|
|
484
613
|
},
|
|
485
|
-
updateModel(event, value) {
|
|
486
|
-
this.$emit('update:modelValue', value);
|
|
487
|
-
this.$emit('change', {originalEvent: event, value: value});
|
|
488
|
-
},
|
|
489
614
|
bindOutsideClickListener() {
|
|
490
615
|
if (!this.outsideClickListener) {
|
|
491
616
|
this.outsideClickListener = (event) => {
|
|
@@ -534,162 +659,153 @@ export default {
|
|
|
534
659
|
this.resizeListener = null;
|
|
535
660
|
}
|
|
536
661
|
},
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
662
|
+
hasFocusableElements() {
|
|
663
|
+
return DomHandler.getFocusableElements(this.overlay, ':not(.p-hidden-focusable)').length > 0;
|
|
664
|
+
},
|
|
665
|
+
isOptionMatched(option) {
|
|
666
|
+
return this.isValidOption(option) && this.getOptionLabel(option).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale));
|
|
667
|
+
},
|
|
668
|
+
isValidOption(option) {
|
|
669
|
+
return option && !(this.isOptionDisabled(option) || this.isOptionGroup(option));
|
|
670
|
+
},
|
|
671
|
+
isValidSelectedOption(option) {
|
|
672
|
+
return this.isValidOption(option) && this.isSelected(option);
|
|
673
|
+
},
|
|
674
|
+
isSelected(option) {
|
|
675
|
+
return ObjectUtils.equals(this.modelValue, this.getOptionValue(option), this.equalityKey);
|
|
676
|
+
},
|
|
677
|
+
findFirstOptionIndex() {
|
|
678
|
+
return this.visibleOptions.findIndex(option => this.isValidOption(option));
|
|
679
|
+
},
|
|
680
|
+
findLastOptionIndex() {
|
|
681
|
+
return this.visibleOptions.findLastIndex(option => this.isValidOption(option));
|
|
682
|
+
},
|
|
683
|
+
findNextOptionIndex(index) {
|
|
684
|
+
const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1;
|
|
685
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index;
|
|
686
|
+
},
|
|
687
|
+
findPrevOptionIndex(index) {
|
|
688
|
+
const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index).findLastIndex(option => this.isValidOption(option)) : -1;
|
|
689
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
|
|
690
|
+
},
|
|
691
|
+
findSelectedOptionIndex() {
|
|
692
|
+
return this.hasSelectedOption ? this.visibleOptions.findIndex(option => this.isValidSelectedOption(option)) : -1;
|
|
693
|
+
},
|
|
694
|
+
findFirstFocusedOptionIndex() {
|
|
695
|
+
const selectedIndex = this.findSelectedOptionIndex();
|
|
696
|
+
return selectedIndex < 0 ? this.findFirstOptionIndex() : selectedIndex;
|
|
697
|
+
},
|
|
698
|
+
findLastFocusedOptionIndex() {
|
|
699
|
+
const selectedIndex = this.findSelectedOptionIndex();
|
|
700
|
+
return selectedIndex < 0 ? this.findLastOptionIndex() : selectedIndex;
|
|
701
|
+
},
|
|
702
|
+
searchOptions(event, char) {
|
|
703
|
+
this.searchValue = (this.searchValue || '') + char;
|
|
704
|
+
|
|
705
|
+
let optionIndex = -1;
|
|
706
|
+
let matched = false;
|
|
707
|
+
|
|
708
|
+
if (this.focusedOptionIndex !== -1) {
|
|
709
|
+
optionIndex = this.visibleOptions.slice(this.focusedOptionIndex).findIndex(option => this.isOptionMatched(option));
|
|
710
|
+
optionIndex = optionIndex === -1 ? this.visibleOptions.slice(0, this.focusedOptionIndex).findIndex(option => this.isOptionMatched(option)) : optionIndex + this.focusedOptionIndex;
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
optionIndex = this.visibleOptions.findIndex(option => this.isOptionMatched(option));
|
|
540
714
|
}
|
|
541
715
|
|
|
542
|
-
if (
|
|
543
|
-
|
|
716
|
+
if (optionIndex !== -1) {
|
|
717
|
+
matched = true;
|
|
544
718
|
}
|
|
545
719
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
720
|
+
if (optionIndex === -1 && this.focusedOptionIndex === -1) {
|
|
721
|
+
optionIndex = this.findFirstFocusedOptionIndex();
|
|
722
|
+
}
|
|
549
723
|
|
|
550
|
-
if (
|
|
551
|
-
this.
|
|
552
|
-
|
|
553
|
-
this.searchValue = this.searchValue ? this.searchValue + char : char;
|
|
724
|
+
if (optionIndex !== -1) {
|
|
725
|
+
this.changeFocusedOptionIndex(event, optionIndex);
|
|
726
|
+
}
|
|
554
727
|
|
|
555
|
-
if (this.
|
|
556
|
-
|
|
557
|
-
let newOption = this.optionGroupLabel ? this.searchOptionInGroup(searchIndex) : this.searchOption(++searchIndex);
|
|
558
|
-
if (newOption) {
|
|
559
|
-
this.updateModel(event, this.getOptionValue(newOption));
|
|
560
|
-
}
|
|
728
|
+
if (this.searchTimeout) {
|
|
729
|
+
clearTimeout(this.searchTimeout);
|
|
561
730
|
}
|
|
562
731
|
|
|
563
732
|
this.searchTimeout = setTimeout(() => {
|
|
564
|
-
this.searchValue =
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
searchOption(index) {
|
|
568
|
-
let option;
|
|
569
|
-
|
|
570
|
-
if (this.searchValue) {
|
|
571
|
-
option = this.searchOptionInRange(index, this.visibleOptions.length);
|
|
572
|
-
|
|
573
|
-
if (!option) {
|
|
574
|
-
option = this.searchOptionInRange(0, index);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
733
|
+
this.searchValue = '';
|
|
734
|
+
this.searchTimeout = null;
|
|
735
|
+
}, 500);
|
|
577
736
|
|
|
578
|
-
return
|
|
737
|
+
return matched;
|
|
579
738
|
},
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
739
|
+
changeFocusedOptionIndex(event, index) {
|
|
740
|
+
if (this.focusedOptionIndex !== index) {
|
|
741
|
+
this.focusedOptionIndex = index;
|
|
742
|
+
this.scrollInView();
|
|
743
|
+
|
|
744
|
+
if (this.selectOnFocus) {
|
|
745
|
+
this.updateModel(event, this.getOptionValue(this.visibleOptions[index]));
|
|
585
746
|
}
|
|
586
747
|
}
|
|
587
|
-
|
|
588
|
-
return null;
|
|
589
748
|
},
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
for (let j = (searchIndex.group === i ? searchIndex.option + 1 : 0); j < groupOptions.length; j++) {
|
|
596
|
-
if (this.matchesSearchValue(groupOptions[j])) {
|
|
597
|
-
return groupOptions[j];
|
|
598
|
-
}
|
|
599
|
-
}
|
|
749
|
+
scrollInView(index = -1) {
|
|
750
|
+
const id = index !== -1 ? `${this.id}_${index}` : this.focusedOptionId;
|
|
751
|
+
const element = DomHandler.findSingle(this.list, `li[id="${id}"]`);
|
|
752
|
+
if (element) {
|
|
753
|
+
element.scrollIntoView && element.scrollIntoView({ block: 'nearest', inline: 'start' });
|
|
600
754
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
if (this.matchesSearchValue(groupOptions[j])) {
|
|
606
|
-
return groupOptions[j];
|
|
607
|
-
}
|
|
608
|
-
}
|
|
755
|
+
else if (!this.virtualScrollerDisabled) {
|
|
756
|
+
setTimeout(() => {
|
|
757
|
+
this.virtualScroller && this.virtualScroller.scrollToIndex(index !== -1 ? index : this.focusedOptionIndex);
|
|
758
|
+
}, 0);
|
|
609
759
|
}
|
|
610
|
-
|
|
611
|
-
return null;
|
|
612
760
|
},
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
761
|
+
autoUpdateModel() {
|
|
762
|
+
if (this.selectOnFocus && this.autoOptionFocus && !this.hasSelectedOption) {
|
|
763
|
+
this.focusedOptionIndex = this.findFirstFocusedOptionIndex();
|
|
764
|
+
const value = this.getOptionValue(this.visibleOptions[this.focusedOptionIndex]);
|
|
765
|
+
this.updateModel(null, value);
|
|
766
|
+
}
|
|
616
767
|
},
|
|
617
|
-
|
|
618
|
-
this
|
|
619
|
-
this.$emit('
|
|
768
|
+
updateModel(event, value) {
|
|
769
|
+
this.$emit('update:modelValue', value);
|
|
770
|
+
this.$emit('change', { originalEvent: event, value });
|
|
620
771
|
},
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
772
|
+
flatOptions(options) {
|
|
773
|
+
return (options || []).reduce((result, option, index) => {
|
|
774
|
+
result.push({ optionGroup: option, group: true, index });
|
|
775
|
+
|
|
776
|
+
const optionGroupChildren = this.getOptionGroupChildren(option);
|
|
777
|
+
optionGroupChildren && optionGroupChildren.forEach(o => result.push(o));
|
|
778
|
+
|
|
779
|
+
return result;
|
|
780
|
+
}, []);
|
|
625
781
|
},
|
|
626
782
|
overlayRef(el) {
|
|
627
783
|
this.overlay = el;
|
|
628
784
|
},
|
|
629
|
-
|
|
630
|
-
this.
|
|
785
|
+
listRef(el, contentRef) {
|
|
786
|
+
this.list = el;
|
|
787
|
+
contentRef && contentRef(el); // For VirtualScroller
|
|
631
788
|
},
|
|
632
789
|
virtualScrollerRef(el) {
|
|
633
790
|
this.virtualScroller = el;
|
|
634
|
-
},
|
|
635
|
-
scrollValueInView() {
|
|
636
|
-
if (this.overlay) {
|
|
637
|
-
let selectedItem = DomHandler.findSingle(this.overlay, 'li.p-highlight');
|
|
638
|
-
if (selectedItem) {
|
|
639
|
-
selectedItem.scrollIntoView({ block: 'nearest', inline: 'start' });
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
},
|
|
643
|
-
onOverlayClick(event) {
|
|
644
|
-
OverlayEventBus.emit('overlay-click', {
|
|
645
|
-
originalEvent: event,
|
|
646
|
-
target: this.$el
|
|
647
|
-
});
|
|
648
791
|
}
|
|
649
792
|
},
|
|
650
793
|
computed: {
|
|
651
|
-
visibleOptions() {
|
|
652
|
-
if (this.filterValue) {
|
|
653
|
-
if (this.optionGroupLabel) {
|
|
654
|
-
let filteredGroups = [];
|
|
655
|
-
for (let optgroup of this.options) {
|
|
656
|
-
let filteredSubOptions = FilterService.filter(this.getOptionGroupChildren(optgroup), this.searchFields, this.filterValue, this.filterMatchMode, this.filterLocale);
|
|
657
|
-
if (filteredSubOptions && filteredSubOptions.length) {
|
|
658
|
-
let filteredGroup = {...optgroup};
|
|
659
|
-
filteredGroup[this.optionGroupChildren] = filteredSubOptions;
|
|
660
|
-
filteredGroups.push(filteredGroup);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
return filteredGroups
|
|
664
|
-
}
|
|
665
|
-
else {
|
|
666
|
-
return FilterService.filter(this.options, this.searchFields, this.filterValue, this.filterMatchMode, this.filterLocale);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
else {
|
|
670
|
-
return this.options;
|
|
671
|
-
}
|
|
672
|
-
},
|
|
673
794
|
containerClass() {
|
|
674
|
-
return [
|
|
675
|
-
'p-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
{
|
|
689
|
-
'p-placeholder': this.label === this.placeholder,
|
|
690
|
-
'p-dropdown-label-empty': !this.$slots['value'] && (this.label === 'p-emptylabel' || this.label.length === 0)
|
|
691
|
-
}
|
|
692
|
-
];
|
|
795
|
+
return ['p-dropdown p-component p-inputwrapper', {
|
|
796
|
+
'p-disabled': this.disabled,
|
|
797
|
+
'p-dropdown-clearable': this.showClear && !this.disabled,
|
|
798
|
+
'p-focus': this.focused,
|
|
799
|
+
'p-inputwrapper-filled': this.modelValue,
|
|
800
|
+
'p-inputwrapper-focus': this.focused || this.overlayVisible,
|
|
801
|
+
'p-overlay-open': this.overlayVisible
|
|
802
|
+
}];
|
|
803
|
+
},
|
|
804
|
+
inputStyleClass() {
|
|
805
|
+
return ['p-dropdown-label p-inputtext', this.inputClass, {
|
|
806
|
+
'p-placeholder': !this.editable && this.label === this.placeholder,
|
|
807
|
+
'p-dropdown-label-empty': !this.editable && !this.$slots['value'] && (this.label === 'p-emptylabel' || this.label.length === 0)
|
|
808
|
+
}];
|
|
693
809
|
},
|
|
694
810
|
panelStyleClass() {
|
|
695
811
|
return ['p-dropdown-panel p-component', this.panelClass, {
|
|
@@ -697,19 +813,24 @@ export default {
|
|
|
697
813
|
'p-ripple-disabled': this.$primevue.config.ripple === false
|
|
698
814
|
}];
|
|
699
815
|
},
|
|
816
|
+
dropdownIconClass() {
|
|
817
|
+
return ['p-dropdown-trigger-icon', (this.loading ? this.loadingIcon : 'pi pi-chevron-down')];
|
|
818
|
+
},
|
|
819
|
+
visibleOptions() {
|
|
820
|
+
const options = this.optionGroupLabel ? this.flatOptions(this.options) : (this.options || []);
|
|
821
|
+
|
|
822
|
+
return this.filterValue ? FilterService.filter(options, this.searchFields, this.filterValue, this.filterMatchMode, this.filterLocale) : options;
|
|
823
|
+
},
|
|
824
|
+
hasSelectedOption() {
|
|
825
|
+
return ObjectUtils.isNotEmpty(this.modelValue);
|
|
826
|
+
},
|
|
700
827
|
label() {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
return this.getOptionLabel(selectedOption);
|
|
704
|
-
else
|
|
705
|
-
return this.placeholder||'p-emptylabel';
|
|
828
|
+
const selectedOptionIndex = this.findSelectedOptionIndex();
|
|
829
|
+
return selectedOptionIndex !== -1 ? this.getOptionLabel(this.visibleOptions[selectedOptionIndex]) : (this.placeholder || 'p-emptylabel');
|
|
706
830
|
},
|
|
707
831
|
editableInputValue() {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
return this.getOptionLabel(selectedOption);
|
|
711
|
-
else
|
|
712
|
-
return this.modelValue;
|
|
832
|
+
const selectedOptionIndex = this.findSelectedOptionIndex();
|
|
833
|
+
return selectedOptionIndex !== -1 ? this.getOptionLabel(this.visibleOptions[selectedOptionIndex]) : (this.modelValue || '');
|
|
713
834
|
},
|
|
714
835
|
equalityKey() {
|
|
715
836
|
return this.optionValue ? null : this.dataKey;
|
|
@@ -717,17 +838,35 @@ export default {
|
|
|
717
838
|
searchFields() {
|
|
718
839
|
return this.filterFields || [this.optionLabel];
|
|
719
840
|
},
|
|
841
|
+
filterResultMessageText() {
|
|
842
|
+
return ObjectUtils.isNotEmpty(this.visibleOptions) ? this.filterMessageText.replaceAll('{0}', this.visibleOptions.length) : this.emptyFilterMessageText;
|
|
843
|
+
},
|
|
844
|
+
filterMessageText() {
|
|
845
|
+
return this.filterMessage || this.$primevue.config.locale.searchMessage;
|
|
846
|
+
},
|
|
720
847
|
emptyFilterMessageText() {
|
|
721
|
-
return this.emptyFilterMessage || this.$primevue.config.locale.emptyFilterMessage;
|
|
848
|
+
return this.emptyFilterMessage || this.$primevue.config.locale.emptySearchMessage || this.$primevue.config.locale.emptyFilterMessage;
|
|
722
849
|
},
|
|
723
850
|
emptyMessageText() {
|
|
724
851
|
return this.emptyMessage || this.$primevue.config.locale.emptyMessage;
|
|
725
852
|
},
|
|
853
|
+
selectionMessageText() {
|
|
854
|
+
return this.selectionMessage || this.$primevue.config.locale.selectionMessage;
|
|
855
|
+
},
|
|
856
|
+
emptySelectionMessageText() {
|
|
857
|
+
return this.emptySelectionMessage || this.$primevue.config.locale.emptySelectionMessage;
|
|
858
|
+
},
|
|
859
|
+
selectedMessageText() {
|
|
860
|
+
return this.hasSelectedOption ? this.selectionMessageText.replaceAll('{0}', '1') : this.emptySelectionMessageText;
|
|
861
|
+
},
|
|
862
|
+
focusedOptionId() {
|
|
863
|
+
return this.focusedOptionIndex !== -1 ? `${this.id}_${this.focusedOptionIndex}` : null;
|
|
864
|
+
},
|
|
865
|
+
ariaSetSize() {
|
|
866
|
+
return this.visibleOptions.filter(option => !this.isOptionGroup(option)).length;
|
|
867
|
+
},
|
|
726
868
|
virtualScrollerDisabled() {
|
|
727
869
|
return !this.virtualScrollerOptions;
|
|
728
|
-
},
|
|
729
|
-
dropdownIconClass() {
|
|
730
|
-
return ['p-dropdown-trigger-icon', this.loading ? this.loadingIcon : 'pi pi-chevron-down'];
|
|
731
870
|
}
|
|
732
871
|
},
|
|
733
872
|
directives: {
|
|
@@ -773,7 +912,7 @@ export default {
|
|
|
773
912
|
|
|
774
913
|
.p-dropdown-label-empty {
|
|
775
914
|
overflow: hidden;
|
|
776
|
-
|
|
915
|
+
opacity: 0;
|
|
777
916
|
}
|
|
778
917
|
|
|
779
918
|
input.p-dropdown-label {
|