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
|
@@ -18,11 +18,36 @@ var script = {
|
|
|
18
18
|
optionValue: null,
|
|
19
19
|
optionDisabled: null,
|
|
20
20
|
multiple: Boolean,
|
|
21
|
+
unselectable: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: true
|
|
24
|
+
},
|
|
21
25
|
disabled: Boolean,
|
|
22
26
|
dataKey: null,
|
|
23
|
-
|
|
27
|
+
'aria-labelledby': {
|
|
28
|
+
type: String,
|
|
29
|
+
default: null
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
focusedIndex: 0
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
mounted() {
|
|
38
|
+
this.defaultTabIndexes();
|
|
24
39
|
},
|
|
25
40
|
methods: {
|
|
41
|
+
defaultTabIndexes() {
|
|
42
|
+
let opts = utils.DomHandler.find(this.$refs.container, '.p-button');
|
|
43
|
+
let firstHighlight = utils.DomHandler.findSingle(this.$refs.container, '.p-highlight');
|
|
44
|
+
|
|
45
|
+
for (let i = 0; i < opts.length; i++) {
|
|
46
|
+
if ((utils.DomHandler.hasClass(opts[i], 'p-highlight') && utils.ObjectUtils.equals(opts[i], firstHighlight)) || (firstHighlight === null && i == 0)) {
|
|
47
|
+
this.focusedIndex = i;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
26
51
|
getOptionLabel(option) {
|
|
27
52
|
return this.optionLabel ? utils.ObjectUtils.resolveFieldData(option, this.optionLabel) : option;
|
|
28
53
|
},
|
|
@@ -35,25 +60,30 @@ var script = {
|
|
|
35
60
|
isOptionDisabled(option) {
|
|
36
61
|
return this.optionDisabled ? utils.ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
|
37
62
|
},
|
|
38
|
-
onOptionSelect(event, option) {
|
|
63
|
+
onOptionSelect(event, option, index) {
|
|
39
64
|
if (this.disabled || this.isOptionDisabled(option)) {
|
|
40
65
|
return;
|
|
41
66
|
}
|
|
42
67
|
|
|
43
68
|
let selected = this.isSelected(option);
|
|
69
|
+
if (selected && !this.unselectable) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
44
73
|
let optionValue = this.getOptionValue(option);
|
|
45
74
|
let newValue;
|
|
46
75
|
|
|
47
|
-
if(this.multiple) {
|
|
76
|
+
if (this.multiple) {
|
|
48
77
|
if (selected)
|
|
49
78
|
newValue = this.modelValue.filter(val => !utils.ObjectUtils.equals(val, optionValue, this.equalityKey));
|
|
50
79
|
else
|
|
51
80
|
newValue = this.modelValue ? [...this.modelValue, optionValue]: [optionValue];
|
|
52
81
|
}
|
|
53
82
|
else {
|
|
54
|
-
newValue = optionValue;
|
|
83
|
+
newValue = selected ? null : optionValue;
|
|
55
84
|
}
|
|
56
85
|
|
|
86
|
+
this.focusedIndex = index;
|
|
57
87
|
this.$emit('update:modelValue', newValue);
|
|
58
88
|
this.$emit('change', {event: event, value: newValue});
|
|
59
89
|
},
|
|
@@ -77,11 +107,56 @@ var script = {
|
|
|
77
107
|
|
|
78
108
|
return selected;
|
|
79
109
|
},
|
|
110
|
+
onKeydown(event, option, index) {
|
|
111
|
+
switch (event.code) {
|
|
112
|
+
case 'Space': {
|
|
113
|
+
this.onOptionSelect(event, option, index);
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case 'ArrowDown':
|
|
119
|
+
case 'ArrowRight': {
|
|
120
|
+
this.changeTabIndexes(event, 'next');
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
case 'ArrowUp':
|
|
126
|
+
case 'ArrowLeft': {
|
|
127
|
+
this.changeTabIndexes(event, 'prev');
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
changeTabIndexes(event, direction) {
|
|
134
|
+
let firstTabableChild, index;
|
|
135
|
+
for (let i = 0; i <= this.$refs.container.children.length - 1; i++) {
|
|
136
|
+
if (this.$refs.container.children[i].getAttribute('tabindex') === '0')
|
|
137
|
+
firstTabableChild = {elem: this.$refs.container.children[i], index: i};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (direction === 'prev') {
|
|
141
|
+
if (firstTabableChild.index === 0) index = this.$refs.container.children.length - 1;
|
|
142
|
+
else index = firstTabableChild.index - 1;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
if (firstTabableChild.index === this.$refs.container.children.length - 1) index = 0;
|
|
146
|
+
else index = firstTabableChild.index + 1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
this.focusedIndex = index;
|
|
150
|
+
this.$refs.container.children[index].focus();
|
|
151
|
+
},
|
|
80
152
|
onFocus(event) {
|
|
81
153
|
this.$emit('focus', event);
|
|
82
154
|
},
|
|
83
|
-
onBlur(event) {
|
|
84
|
-
|
|
155
|
+
onBlur(event, option) {
|
|
156
|
+
if (event.target && event.relatedTarget && event.target.parentElement !== event.relatedTarget.parentElement) {
|
|
157
|
+
this.defaultTabIndexes();
|
|
158
|
+
}
|
|
159
|
+
this.$emit('blur', event, option);
|
|
85
160
|
},
|
|
86
161
|
getButtonClass(option) {
|
|
87
162
|
return ['p-button p-component', {
|
|
@@ -105,44 +180,44 @@ var script = {
|
|
|
105
180
|
}
|
|
106
181
|
};
|
|
107
182
|
|
|
108
|
-
const _hoisted_1 = ["aria-
|
|
109
|
-
const _hoisted_2 =
|
|
183
|
+
const _hoisted_1 = ["aria-labelledby"];
|
|
184
|
+
const _hoisted_2 = ["tabindex", "aria-label", "role", "aria-checked", "aria-disabled", "onClick", "onKeydown", "onBlur"];
|
|
185
|
+
const _hoisted_3 = { class: "p-button-label" };
|
|
110
186
|
|
|
111
187
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
112
188
|
const _directive_ripple = vue.resolveDirective("ripple");
|
|
113
189
|
|
|
114
190
|
return (vue.openBlock(), vue.createElementBlock("div", {
|
|
191
|
+
ref: "container",
|
|
115
192
|
class: vue.normalizeClass($options.containerClass),
|
|
116
|
-
role: "group"
|
|
193
|
+
role: "group",
|
|
194
|
+
"aria-labelledby": _ctx.ariaLabelledby
|
|
117
195
|
}, [
|
|
118
196
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList($props.options, (option, i) => {
|
|
119
197
|
return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
|
|
120
198
|
key: $options.getOptionRenderKey(option),
|
|
199
|
+
tabindex: i === $data.focusedIndex ? '0' : '-1',
|
|
121
200
|
"aria-label": $options.getOptionLabel(option),
|
|
122
|
-
role:
|
|
123
|
-
"aria-
|
|
201
|
+
role: $props.multiple ? 'checkbox' : 'radio',
|
|
202
|
+
"aria-checked": $options.isSelected(option),
|
|
203
|
+
"aria-disabled": $props.optionDisabled,
|
|
204
|
+
class: vue.normalizeClass($options.getButtonClass(option, i)),
|
|
124
205
|
onClick: $event => ($options.onOptionSelect($event, option, i)),
|
|
125
|
-
onKeydown:
|
|
126
|
-
vue.withKeys(vue.withModifiers($event => ($options.onOptionSelect($event, option, i)), ["prevent"]), ["enter"]),
|
|
127
|
-
vue.withKeys(vue.withModifiers($event => ($options.onOptionSelect($event, option)), ["prevent"]), ["space"])
|
|
128
|
-
],
|
|
129
|
-
tabindex: $options.isOptionDisabled(option) ? null : '0',
|
|
206
|
+
onKeydown: $event => ($options.onKeydown($event, option, i)),
|
|
130
207
|
onFocus: _cache[0] || (_cache[0] = $event => ($options.onFocus($event))),
|
|
131
|
-
onBlur:
|
|
132
|
-
"aria-labelledby": $props.ariaLabelledBy,
|
|
133
|
-
class: vue.normalizeClass($options.getButtonClass(option))
|
|
208
|
+
onBlur: $event => ($options.onBlur($event, option))
|
|
134
209
|
}, [
|
|
135
210
|
vue.renderSlot(_ctx.$slots, "option", {
|
|
136
211
|
option: option,
|
|
137
212
|
index: i
|
|
138
213
|
}, () => [
|
|
139
|
-
vue.createElementVNode("span",
|
|
214
|
+
vue.createElementVNode("span", _hoisted_3, vue.toDisplayString($options.getOptionLabel(option)), 1)
|
|
140
215
|
])
|
|
141
|
-
], 42,
|
|
216
|
+
], 42, _hoisted_2)), [
|
|
142
217
|
[_directive_ripple]
|
|
143
218
|
])
|
|
144
219
|
}), 128))
|
|
145
|
-
],
|
|
220
|
+
], 10, _hoisted_1))
|
|
146
221
|
}
|
|
147
222
|
|
|
148
223
|
script.render = render;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("primevue/utils"),t=require("primevue/ripple"),l=require("vue");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var
|
|
1
|
+
"use strict";var e=require("primevue/utils"),t=require("primevue/ripple"),l=require("vue");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n={name:"SelectButton",emits:["update:modelValue","focus","blur","change"],props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,multiple:Boolean,unselectable:{type:Boolean,default:!0},disabled:Boolean,dataKey:null,"aria-labelledby":{type:String,default:null}},data:()=>({focusedIndex:0}),mounted(){this.defaultTabIndexes()},methods:{defaultTabIndexes(){let t=e.DomHandler.find(this.$refs.container,".p-button"),l=e.DomHandler.findSingle(this.$refs.container,".p-highlight");for(let i=0;i<t.length;i++)(e.DomHandler.hasClass(t[i],"p-highlight")&&e.ObjectUtils.equals(t[i],l)||null===l&&0==i)&&(this.focusedIndex=i)},getOptionLabel(t){return this.optionLabel?e.ObjectUtils.resolveFieldData(t,this.optionLabel):t},getOptionValue(t){return this.optionValue?e.ObjectUtils.resolveFieldData(t,this.optionValue):t},getOptionRenderKey(t){return this.dataKey?e.ObjectUtils.resolveFieldData(t,this.dataKey):this.getOptionLabel(t)},isOptionDisabled(t){return!!this.optionDisabled&&e.ObjectUtils.resolveFieldData(t,this.optionDisabled)},onOptionSelect(t,l,i){if(this.disabled||this.isOptionDisabled(l))return;let n=this.isSelected(l);if(n&&!this.unselectable)return;let a,o=this.getOptionValue(l);a=this.multiple?n?this.modelValue.filter((t=>!e.ObjectUtils.equals(t,o,this.equalityKey))):this.modelValue?[...this.modelValue,o]:[o]:n?null:o,this.focusedIndex=i,this.$emit("update:modelValue",a),this.$emit("change",{event:t,value:a})},isSelected(t){let l=!1,i=this.getOptionValue(t);if(this.multiple){if(this.modelValue)for(let t of this.modelValue)if(e.ObjectUtils.equals(t,i,this.equalityKey)){l=!0;break}}else l=e.ObjectUtils.equals(this.modelValue,i,this.equalityKey);return l},onKeydown(e,t,l){switch(e.code){case"Space":this.onOptionSelect(e,t,l),e.preventDefault();break;case"ArrowDown":case"ArrowRight":this.changeTabIndexes(e,"next"),e.preventDefault();break;case"ArrowUp":case"ArrowLeft":this.changeTabIndexes(e,"prev"),e.preventDefault()}},changeTabIndexes(e,t){let l,i;for(let e=0;e<=this.$refs.container.children.length-1;e++)"0"===this.$refs.container.children[e].getAttribute("tabindex")&&(l={elem:this.$refs.container.children[e],index:e});i="prev"===t?0===l.index?this.$refs.container.children.length-1:l.index-1:l.index===this.$refs.container.children.length-1?0:l.index+1,this.focusedIndex=i,this.$refs.container.children[i].focus()},onFocus(e){this.$emit("focus",e)},onBlur(e,t){e.target&&e.relatedTarget&&e.target.parentElement!==e.relatedTarget.parentElement&&this.defaultTabIndexes(),this.$emit("blur",e,t)},getButtonClass(e){return["p-button p-component",{"p-highlight":this.isSelected(e),"p-disabled":this.isOptionDisabled(e)}]}},computed:{containerClass(){return["p-selectbutton p-buttonset p-component",{"p-disabled":this.disabled}]},equalityKey(){return this.optionValue?null:this.dataKey}},directives:{ripple:i(t).default}};const a=["aria-labelledby"],o=["tabindex","aria-label","role","aria-checked","aria-disabled","onClick","onKeydown","onBlur"],s={class:"p-button-label"};n.render=function(e,t,i,n,r,d){const u=l.resolveDirective("ripple");return l.openBlock(),l.createElementBlock("div",{ref:"container",class:l.normalizeClass(d.containerClass),role:"group","aria-labelledby":e.ariaLabelledby},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(i.options,((n,a)=>l.withDirectives((l.openBlock(),l.createElementBlock("div",{key:d.getOptionRenderKey(n),tabindex:a===r.focusedIndex?"0":"-1","aria-label":d.getOptionLabel(n),role:i.multiple?"checkbox":"radio","aria-checked":d.isSelected(n),"aria-disabled":i.optionDisabled,class:l.normalizeClass(d.getButtonClass(n,a)),onClick:e=>d.onOptionSelect(e,n,a),onKeydown:e=>d.onKeydown(e,n,a),onFocus:t[0]||(t[0]=e=>d.onFocus(e)),onBlur:e=>d.onBlur(e,n)},[l.renderSlot(e.$slots,"option",{option:n,index:a},(()=>[l.createElementVNode("span",s,l.toDisplayString(d.getOptionLabel(n)),1)]))],42,o)),[[u]]))),128))],10,a)},module.exports=n;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ObjectUtils } from 'primevue/utils';
|
|
1
|
+
import { DomHandler, ObjectUtils } from 'primevue/utils';
|
|
2
2
|
import Ripple from 'primevue/ripple';
|
|
3
|
-
import { resolveDirective, openBlock, createElementBlock, normalizeClass, Fragment, renderList, withDirectives,
|
|
3
|
+
import { resolveDirective, openBlock, createElementBlock, normalizeClass, Fragment, renderList, withDirectives, renderSlot, createElementVNode, toDisplayString } from 'vue';
|
|
4
4
|
|
|
5
5
|
var script = {
|
|
6
6
|
name: 'SelectButton',
|
|
@@ -12,11 +12,36 @@ var script = {
|
|
|
12
12
|
optionValue: null,
|
|
13
13
|
optionDisabled: null,
|
|
14
14
|
multiple: Boolean,
|
|
15
|
+
unselectable: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: true
|
|
18
|
+
},
|
|
15
19
|
disabled: Boolean,
|
|
16
20
|
dataKey: null,
|
|
17
|
-
|
|
21
|
+
'aria-labelledby': {
|
|
22
|
+
type: String,
|
|
23
|
+
default: null
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
data() {
|
|
27
|
+
return {
|
|
28
|
+
focusedIndex: 0
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
mounted() {
|
|
32
|
+
this.defaultTabIndexes();
|
|
18
33
|
},
|
|
19
34
|
methods: {
|
|
35
|
+
defaultTabIndexes() {
|
|
36
|
+
let opts = DomHandler.find(this.$refs.container, '.p-button');
|
|
37
|
+
let firstHighlight = DomHandler.findSingle(this.$refs.container, '.p-highlight');
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < opts.length; i++) {
|
|
40
|
+
if ((DomHandler.hasClass(opts[i], 'p-highlight') && ObjectUtils.equals(opts[i], firstHighlight)) || (firstHighlight === null && i == 0)) {
|
|
41
|
+
this.focusedIndex = i;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
20
45
|
getOptionLabel(option) {
|
|
21
46
|
return this.optionLabel ? ObjectUtils.resolveFieldData(option, this.optionLabel) : option;
|
|
22
47
|
},
|
|
@@ -29,25 +54,30 @@ var script = {
|
|
|
29
54
|
isOptionDisabled(option) {
|
|
30
55
|
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
|
31
56
|
},
|
|
32
|
-
onOptionSelect(event, option) {
|
|
57
|
+
onOptionSelect(event, option, index) {
|
|
33
58
|
if (this.disabled || this.isOptionDisabled(option)) {
|
|
34
59
|
return;
|
|
35
60
|
}
|
|
36
61
|
|
|
37
62
|
let selected = this.isSelected(option);
|
|
63
|
+
if (selected && !this.unselectable) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
38
67
|
let optionValue = this.getOptionValue(option);
|
|
39
68
|
let newValue;
|
|
40
69
|
|
|
41
|
-
if(this.multiple) {
|
|
70
|
+
if (this.multiple) {
|
|
42
71
|
if (selected)
|
|
43
72
|
newValue = this.modelValue.filter(val => !ObjectUtils.equals(val, optionValue, this.equalityKey));
|
|
44
73
|
else
|
|
45
74
|
newValue = this.modelValue ? [...this.modelValue, optionValue]: [optionValue];
|
|
46
75
|
}
|
|
47
76
|
else {
|
|
48
|
-
newValue = optionValue;
|
|
77
|
+
newValue = selected ? null : optionValue;
|
|
49
78
|
}
|
|
50
79
|
|
|
80
|
+
this.focusedIndex = index;
|
|
51
81
|
this.$emit('update:modelValue', newValue);
|
|
52
82
|
this.$emit('change', {event: event, value: newValue});
|
|
53
83
|
},
|
|
@@ -71,11 +101,56 @@ var script = {
|
|
|
71
101
|
|
|
72
102
|
return selected;
|
|
73
103
|
},
|
|
104
|
+
onKeydown(event, option, index) {
|
|
105
|
+
switch (event.code) {
|
|
106
|
+
case 'Space': {
|
|
107
|
+
this.onOptionSelect(event, option, index);
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
case 'ArrowDown':
|
|
113
|
+
case 'ArrowRight': {
|
|
114
|
+
this.changeTabIndexes(event, 'next');
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
case 'ArrowUp':
|
|
120
|
+
case 'ArrowLeft': {
|
|
121
|
+
this.changeTabIndexes(event, 'prev');
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
changeTabIndexes(event, direction) {
|
|
128
|
+
let firstTabableChild, index;
|
|
129
|
+
for (let i = 0; i <= this.$refs.container.children.length - 1; i++) {
|
|
130
|
+
if (this.$refs.container.children[i].getAttribute('tabindex') === '0')
|
|
131
|
+
firstTabableChild = {elem: this.$refs.container.children[i], index: i};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (direction === 'prev') {
|
|
135
|
+
if (firstTabableChild.index === 0) index = this.$refs.container.children.length - 1;
|
|
136
|
+
else index = firstTabableChild.index - 1;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
if (firstTabableChild.index === this.$refs.container.children.length - 1) index = 0;
|
|
140
|
+
else index = firstTabableChild.index + 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
this.focusedIndex = index;
|
|
144
|
+
this.$refs.container.children[index].focus();
|
|
145
|
+
},
|
|
74
146
|
onFocus(event) {
|
|
75
147
|
this.$emit('focus', event);
|
|
76
148
|
},
|
|
77
|
-
onBlur(event) {
|
|
78
|
-
|
|
149
|
+
onBlur(event, option) {
|
|
150
|
+
if (event.target && event.relatedTarget && event.target.parentElement !== event.relatedTarget.parentElement) {
|
|
151
|
+
this.defaultTabIndexes();
|
|
152
|
+
}
|
|
153
|
+
this.$emit('blur', event, option);
|
|
79
154
|
},
|
|
80
155
|
getButtonClass(option) {
|
|
81
156
|
return ['p-button p-component', {
|
|
@@ -99,44 +174,44 @@ var script = {
|
|
|
99
174
|
}
|
|
100
175
|
};
|
|
101
176
|
|
|
102
|
-
const _hoisted_1 = ["aria-
|
|
103
|
-
const _hoisted_2 =
|
|
177
|
+
const _hoisted_1 = ["aria-labelledby"];
|
|
178
|
+
const _hoisted_2 = ["tabindex", "aria-label", "role", "aria-checked", "aria-disabled", "onClick", "onKeydown", "onBlur"];
|
|
179
|
+
const _hoisted_3 = { class: "p-button-label" };
|
|
104
180
|
|
|
105
181
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
106
182
|
const _directive_ripple = resolveDirective("ripple");
|
|
107
183
|
|
|
108
184
|
return (openBlock(), createElementBlock("div", {
|
|
185
|
+
ref: "container",
|
|
109
186
|
class: normalizeClass($options.containerClass),
|
|
110
|
-
role: "group"
|
|
187
|
+
role: "group",
|
|
188
|
+
"aria-labelledby": _ctx.ariaLabelledby
|
|
111
189
|
}, [
|
|
112
190
|
(openBlock(true), createElementBlock(Fragment, null, renderList($props.options, (option, i) => {
|
|
113
191
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
114
192
|
key: $options.getOptionRenderKey(option),
|
|
193
|
+
tabindex: i === $data.focusedIndex ? '0' : '-1',
|
|
115
194
|
"aria-label": $options.getOptionLabel(option),
|
|
116
|
-
role:
|
|
117
|
-
"aria-
|
|
195
|
+
role: $props.multiple ? 'checkbox' : 'radio',
|
|
196
|
+
"aria-checked": $options.isSelected(option),
|
|
197
|
+
"aria-disabled": $props.optionDisabled,
|
|
198
|
+
class: normalizeClass($options.getButtonClass(option, i)),
|
|
118
199
|
onClick: $event => ($options.onOptionSelect($event, option, i)),
|
|
119
|
-
onKeydown:
|
|
120
|
-
withKeys(withModifiers($event => ($options.onOptionSelect($event, option, i)), ["prevent"]), ["enter"]),
|
|
121
|
-
withKeys(withModifiers($event => ($options.onOptionSelect($event, option)), ["prevent"]), ["space"])
|
|
122
|
-
],
|
|
123
|
-
tabindex: $options.isOptionDisabled(option) ? null : '0',
|
|
200
|
+
onKeydown: $event => ($options.onKeydown($event, option, i)),
|
|
124
201
|
onFocus: _cache[0] || (_cache[0] = $event => ($options.onFocus($event))),
|
|
125
|
-
onBlur:
|
|
126
|
-
"aria-labelledby": $props.ariaLabelledBy,
|
|
127
|
-
class: normalizeClass($options.getButtonClass(option))
|
|
202
|
+
onBlur: $event => ($options.onBlur($event, option))
|
|
128
203
|
}, [
|
|
129
204
|
renderSlot(_ctx.$slots, "option", {
|
|
130
205
|
option: option,
|
|
131
206
|
index: i
|
|
132
207
|
}, () => [
|
|
133
|
-
createElementVNode("span",
|
|
208
|
+
createElementVNode("span", _hoisted_3, toDisplayString($options.getOptionLabel(option)), 1)
|
|
134
209
|
])
|
|
135
|
-
], 42,
|
|
210
|
+
], 42, _hoisted_2)), [
|
|
136
211
|
[_directive_ripple]
|
|
137
212
|
])
|
|
138
213
|
}), 128))
|
|
139
|
-
],
|
|
214
|
+
], 10, _hoisted_1))
|
|
140
215
|
}
|
|
141
216
|
|
|
142
217
|
script.render = render;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ObjectUtils as
|
|
1
|
+
import{DomHandler as e,ObjectUtils as t}from"primevue/utils";import i from"primevue/ripple";import{resolveDirective as l,openBlock as n,createElementBlock as a,normalizeClass as o,Fragment as s,renderList as r,withDirectives as d,renderSlot as u,createElementVNode as h,toDisplayString as p}from"vue";var c={name:"SelectButton",emits:["update:modelValue","focus","blur","change"],props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,multiple:Boolean,unselectable:{type:Boolean,default:!0},disabled:Boolean,dataKey:null,"aria-labelledby":{type:String,default:null}},data:()=>({focusedIndex:0}),mounted(){this.defaultTabIndexes()},methods:{defaultTabIndexes(){let i=e.find(this.$refs.container,".p-button"),l=e.findSingle(this.$refs.container,".p-highlight");for(let n=0;n<i.length;n++)(e.hasClass(i[n],"p-highlight")&&t.equals(i[n],l)||null===l&&0==n)&&(this.focusedIndex=n)},getOptionLabel(e){return this.optionLabel?t.resolveFieldData(e,this.optionLabel):e},getOptionValue(e){return this.optionValue?t.resolveFieldData(e,this.optionValue):e},getOptionRenderKey(e){return this.dataKey?t.resolveFieldData(e,this.dataKey):this.getOptionLabel(e)},isOptionDisabled(e){return!!this.optionDisabled&&t.resolveFieldData(e,this.optionDisabled)},onOptionSelect(e,i,l){if(this.disabled||this.isOptionDisabled(i))return;let n=this.isSelected(i);if(n&&!this.unselectable)return;let a,o=this.getOptionValue(i);a=this.multiple?n?this.modelValue.filter((e=>!t.equals(e,o,this.equalityKey))):this.modelValue?[...this.modelValue,o]:[o]:n?null:o,this.focusedIndex=l,this.$emit("update:modelValue",a),this.$emit("change",{event:e,value:a})},isSelected(e){let i=!1,l=this.getOptionValue(e);if(this.multiple){if(this.modelValue)for(let e of this.modelValue)if(t.equals(e,l,this.equalityKey)){i=!0;break}}else i=t.equals(this.modelValue,l,this.equalityKey);return i},onKeydown(e,t,i){switch(e.code){case"Space":this.onOptionSelect(e,t,i),e.preventDefault();break;case"ArrowDown":case"ArrowRight":this.changeTabIndexes(e,"next"),e.preventDefault();break;case"ArrowUp":case"ArrowLeft":this.changeTabIndexes(e,"prev"),e.preventDefault()}},changeTabIndexes(e,t){let i,l;for(let e=0;e<=this.$refs.container.children.length-1;e++)"0"===this.$refs.container.children[e].getAttribute("tabindex")&&(i={elem:this.$refs.container.children[e],index:e});l="prev"===t?0===i.index?this.$refs.container.children.length-1:i.index-1:i.index===this.$refs.container.children.length-1?0:i.index+1,this.focusedIndex=l,this.$refs.container.children[l].focus()},onFocus(e){this.$emit("focus",e)},onBlur(e,t){e.target&&e.relatedTarget&&e.target.parentElement!==e.relatedTarget.parentElement&&this.defaultTabIndexes(),this.$emit("blur",e,t)},getButtonClass(e){return["p-button p-component",{"p-highlight":this.isSelected(e),"p-disabled":this.isOptionDisabled(e)}]}},computed:{containerClass(){return["p-selectbutton p-buttonset p-component",{"p-disabled":this.disabled}]},equalityKey(){return this.optionValue?null:this.dataKey}},directives:{ripple:i}};const b=["aria-labelledby"],f=["tabindex","aria-label","role","aria-checked","aria-disabled","onClick","onKeydown","onBlur"],g={class:"p-button-label"};c.render=function(e,t,i,c,m,y){const x=l("ripple");return n(),a("div",{ref:"container",class:o(y.containerClass),role:"group","aria-labelledby":e.ariaLabelledby},[(n(!0),a(s,null,r(i.options,((l,s)=>d((n(),a("div",{key:y.getOptionRenderKey(l),tabindex:s===m.focusedIndex?"0":"-1","aria-label":y.getOptionLabel(l),role:i.multiple?"checkbox":"radio","aria-checked":y.isSelected(l),"aria-disabled":i.optionDisabled,class:o(y.getButtonClass(l,s)),onClick:e=>y.onOptionSelect(e,l,s),onKeydown:e=>y.onKeydown(e,l,s),onFocus:t[0]||(t[0]=e=>y.onFocus(e)),onBlur:e=>y.onBlur(e,l)},[u(e.$slots,"option",{option:l,index:s},(()=>[h("span",g,p(y.getOptionLabel(l)),1)]))],42,f)),[[x]]))),128))],10,b)};export{c as default};
|
|
@@ -16,11 +16,36 @@ this.primevue.selectbutton = (function (utils, Ripple, vue) {
|
|
|
16
16
|
optionValue: null,
|
|
17
17
|
optionDisabled: null,
|
|
18
18
|
multiple: Boolean,
|
|
19
|
+
unselectable: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: true
|
|
22
|
+
},
|
|
19
23
|
disabled: Boolean,
|
|
20
24
|
dataKey: null,
|
|
21
|
-
|
|
25
|
+
'aria-labelledby': {
|
|
26
|
+
type: String,
|
|
27
|
+
default: null
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
data() {
|
|
31
|
+
return {
|
|
32
|
+
focusedIndex: 0
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
mounted() {
|
|
36
|
+
this.defaultTabIndexes();
|
|
22
37
|
},
|
|
23
38
|
methods: {
|
|
39
|
+
defaultTabIndexes() {
|
|
40
|
+
let opts = utils.DomHandler.find(this.$refs.container, '.p-button');
|
|
41
|
+
let firstHighlight = utils.DomHandler.findSingle(this.$refs.container, '.p-highlight');
|
|
42
|
+
|
|
43
|
+
for (let i = 0; i < opts.length; i++) {
|
|
44
|
+
if ((utils.DomHandler.hasClass(opts[i], 'p-highlight') && utils.ObjectUtils.equals(opts[i], firstHighlight)) || (firstHighlight === null && i == 0)) {
|
|
45
|
+
this.focusedIndex = i;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
24
49
|
getOptionLabel(option) {
|
|
25
50
|
return this.optionLabel ? utils.ObjectUtils.resolveFieldData(option, this.optionLabel) : option;
|
|
26
51
|
},
|
|
@@ -33,25 +58,30 @@ this.primevue.selectbutton = (function (utils, Ripple, vue) {
|
|
|
33
58
|
isOptionDisabled(option) {
|
|
34
59
|
return this.optionDisabled ? utils.ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
|
|
35
60
|
},
|
|
36
|
-
onOptionSelect(event, option) {
|
|
61
|
+
onOptionSelect(event, option, index) {
|
|
37
62
|
if (this.disabled || this.isOptionDisabled(option)) {
|
|
38
63
|
return;
|
|
39
64
|
}
|
|
40
65
|
|
|
41
66
|
let selected = this.isSelected(option);
|
|
67
|
+
if (selected && !this.unselectable) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
42
71
|
let optionValue = this.getOptionValue(option);
|
|
43
72
|
let newValue;
|
|
44
73
|
|
|
45
|
-
if(this.multiple) {
|
|
74
|
+
if (this.multiple) {
|
|
46
75
|
if (selected)
|
|
47
76
|
newValue = this.modelValue.filter(val => !utils.ObjectUtils.equals(val, optionValue, this.equalityKey));
|
|
48
77
|
else
|
|
49
78
|
newValue = this.modelValue ? [...this.modelValue, optionValue]: [optionValue];
|
|
50
79
|
}
|
|
51
80
|
else {
|
|
52
|
-
newValue = optionValue;
|
|
81
|
+
newValue = selected ? null : optionValue;
|
|
53
82
|
}
|
|
54
83
|
|
|
84
|
+
this.focusedIndex = index;
|
|
55
85
|
this.$emit('update:modelValue', newValue);
|
|
56
86
|
this.$emit('change', {event: event, value: newValue});
|
|
57
87
|
},
|
|
@@ -75,11 +105,56 @@ this.primevue.selectbutton = (function (utils, Ripple, vue) {
|
|
|
75
105
|
|
|
76
106
|
return selected;
|
|
77
107
|
},
|
|
108
|
+
onKeydown(event, option, index) {
|
|
109
|
+
switch (event.code) {
|
|
110
|
+
case 'Space': {
|
|
111
|
+
this.onOptionSelect(event, option, index);
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
case 'ArrowDown':
|
|
117
|
+
case 'ArrowRight': {
|
|
118
|
+
this.changeTabIndexes(event, 'next');
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
case 'ArrowUp':
|
|
124
|
+
case 'ArrowLeft': {
|
|
125
|
+
this.changeTabIndexes(event, 'prev');
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
changeTabIndexes(event, direction) {
|
|
132
|
+
let firstTabableChild, index;
|
|
133
|
+
for (let i = 0; i <= this.$refs.container.children.length - 1; i++) {
|
|
134
|
+
if (this.$refs.container.children[i].getAttribute('tabindex') === '0')
|
|
135
|
+
firstTabableChild = {elem: this.$refs.container.children[i], index: i};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (direction === 'prev') {
|
|
139
|
+
if (firstTabableChild.index === 0) index = this.$refs.container.children.length - 1;
|
|
140
|
+
else index = firstTabableChild.index - 1;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
if (firstTabableChild.index === this.$refs.container.children.length - 1) index = 0;
|
|
144
|
+
else index = firstTabableChild.index + 1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.focusedIndex = index;
|
|
148
|
+
this.$refs.container.children[index].focus();
|
|
149
|
+
},
|
|
78
150
|
onFocus(event) {
|
|
79
151
|
this.$emit('focus', event);
|
|
80
152
|
},
|
|
81
|
-
onBlur(event) {
|
|
82
|
-
|
|
153
|
+
onBlur(event, option) {
|
|
154
|
+
if (event.target && event.relatedTarget && event.target.parentElement !== event.relatedTarget.parentElement) {
|
|
155
|
+
this.defaultTabIndexes();
|
|
156
|
+
}
|
|
157
|
+
this.$emit('blur', event, option);
|
|
83
158
|
},
|
|
84
159
|
getButtonClass(option) {
|
|
85
160
|
return ['p-button p-component', {
|
|
@@ -103,44 +178,44 @@ this.primevue.selectbutton = (function (utils, Ripple, vue) {
|
|
|
103
178
|
}
|
|
104
179
|
};
|
|
105
180
|
|
|
106
|
-
const _hoisted_1 = ["aria-
|
|
107
|
-
const _hoisted_2 =
|
|
181
|
+
const _hoisted_1 = ["aria-labelledby"];
|
|
182
|
+
const _hoisted_2 = ["tabindex", "aria-label", "role", "aria-checked", "aria-disabled", "onClick", "onKeydown", "onBlur"];
|
|
183
|
+
const _hoisted_3 = { class: "p-button-label" };
|
|
108
184
|
|
|
109
185
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
110
186
|
const _directive_ripple = vue.resolveDirective("ripple");
|
|
111
187
|
|
|
112
188
|
return (vue.openBlock(), vue.createElementBlock("div", {
|
|
189
|
+
ref: "container",
|
|
113
190
|
class: vue.normalizeClass($options.containerClass),
|
|
114
|
-
role: "group"
|
|
191
|
+
role: "group",
|
|
192
|
+
"aria-labelledby": _ctx.ariaLabelledby
|
|
115
193
|
}, [
|
|
116
194
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList($props.options, (option, i) => {
|
|
117
195
|
return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
|
|
118
196
|
key: $options.getOptionRenderKey(option),
|
|
197
|
+
tabindex: i === $data.focusedIndex ? '0' : '-1',
|
|
119
198
|
"aria-label": $options.getOptionLabel(option),
|
|
120
|
-
role:
|
|
121
|
-
"aria-
|
|
199
|
+
role: $props.multiple ? 'checkbox' : 'radio',
|
|
200
|
+
"aria-checked": $options.isSelected(option),
|
|
201
|
+
"aria-disabled": $props.optionDisabled,
|
|
202
|
+
class: vue.normalizeClass($options.getButtonClass(option, i)),
|
|
122
203
|
onClick: $event => ($options.onOptionSelect($event, option, i)),
|
|
123
|
-
onKeydown:
|
|
124
|
-
vue.withKeys(vue.withModifiers($event => ($options.onOptionSelect($event, option, i)), ["prevent"]), ["enter"]),
|
|
125
|
-
vue.withKeys(vue.withModifiers($event => ($options.onOptionSelect($event, option)), ["prevent"]), ["space"])
|
|
126
|
-
],
|
|
127
|
-
tabindex: $options.isOptionDisabled(option) ? null : '0',
|
|
204
|
+
onKeydown: $event => ($options.onKeydown($event, option, i)),
|
|
128
205
|
onFocus: _cache[0] || (_cache[0] = $event => ($options.onFocus($event))),
|
|
129
|
-
onBlur:
|
|
130
|
-
"aria-labelledby": $props.ariaLabelledBy,
|
|
131
|
-
class: vue.normalizeClass($options.getButtonClass(option))
|
|
206
|
+
onBlur: $event => ($options.onBlur($event, option))
|
|
132
207
|
}, [
|
|
133
208
|
vue.renderSlot(_ctx.$slots, "option", {
|
|
134
209
|
option: option,
|
|
135
210
|
index: i
|
|
136
211
|
}, () => [
|
|
137
|
-
vue.createElementVNode("span",
|
|
212
|
+
vue.createElementVNode("span", _hoisted_3, vue.toDisplayString($options.getOptionLabel(option)), 1)
|
|
138
213
|
])
|
|
139
|
-
], 42,
|
|
214
|
+
], 42, _hoisted_2)), [
|
|
140
215
|
[_directive_ripple]
|
|
141
216
|
])
|
|
142
217
|
}), 128))
|
|
143
|
-
],
|
|
218
|
+
], 10, _hoisted_1))
|
|
144
219
|
}
|
|
145
220
|
|
|
146
221
|
script.render = render;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
this.primevue=this.primevue||{},this.primevue.selectbutton=function(e,t,
|
|
1
|
+
this.primevue=this.primevue||{},this.primevue.selectbutton=function(e,t,l){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n={name:"SelectButton",emits:["update:modelValue","focus","blur","change"],props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,multiple:Boolean,unselectable:{type:Boolean,default:!0},disabled:Boolean,dataKey:null,"aria-labelledby":{type:String,default:null}},data:()=>({focusedIndex:0}),mounted(){this.defaultTabIndexes()},methods:{defaultTabIndexes(){let t=e.DomHandler.find(this.$refs.container,".p-button"),l=e.DomHandler.findSingle(this.$refs.container,".p-highlight");for(let i=0;i<t.length;i++)(e.DomHandler.hasClass(t[i],"p-highlight")&&e.ObjectUtils.equals(t[i],l)||null===l&&0==i)&&(this.focusedIndex=i)},getOptionLabel(t){return this.optionLabel?e.ObjectUtils.resolveFieldData(t,this.optionLabel):t},getOptionValue(t){return this.optionValue?e.ObjectUtils.resolveFieldData(t,this.optionValue):t},getOptionRenderKey(t){return this.dataKey?e.ObjectUtils.resolveFieldData(t,this.dataKey):this.getOptionLabel(t)},isOptionDisabled(t){return!!this.optionDisabled&&e.ObjectUtils.resolveFieldData(t,this.optionDisabled)},onOptionSelect(t,l,i){if(this.disabled||this.isOptionDisabled(l))return;let n=this.isSelected(l);if(n&&!this.unselectable)return;let a,s=this.getOptionValue(l);a=this.multiple?n?this.modelValue.filter((t=>!e.ObjectUtils.equals(t,s,this.equalityKey))):this.modelValue?[...this.modelValue,s]:[s]:n?null:s,this.focusedIndex=i,this.$emit("update:modelValue",a),this.$emit("change",{event:t,value:a})},isSelected(t){let l=!1,i=this.getOptionValue(t);if(this.multiple){if(this.modelValue)for(let t of this.modelValue)if(e.ObjectUtils.equals(t,i,this.equalityKey)){l=!0;break}}else l=e.ObjectUtils.equals(this.modelValue,i,this.equalityKey);return l},onKeydown(e,t,l){switch(e.code){case"Space":this.onOptionSelect(e,t,l),e.preventDefault();break;case"ArrowDown":case"ArrowRight":this.changeTabIndexes(e,"next"),e.preventDefault();break;case"ArrowUp":case"ArrowLeft":this.changeTabIndexes(e,"prev"),e.preventDefault()}},changeTabIndexes(e,t){let l,i;for(let e=0;e<=this.$refs.container.children.length-1;e++)"0"===this.$refs.container.children[e].getAttribute("tabindex")&&(l={elem:this.$refs.container.children[e],index:e});i="prev"===t?0===l.index?this.$refs.container.children.length-1:l.index-1:l.index===this.$refs.container.children.length-1?0:l.index+1,this.focusedIndex=i,this.$refs.container.children[i].focus()},onFocus(e){this.$emit("focus",e)},onBlur(e,t){e.target&&e.relatedTarget&&e.target.parentElement!==e.relatedTarget.parentElement&&this.defaultTabIndexes(),this.$emit("blur",e,t)},getButtonClass(e){return["p-button p-component",{"p-highlight":this.isSelected(e),"p-disabled":this.isOptionDisabled(e)}]}},computed:{containerClass(){return["p-selectbutton p-buttonset p-component",{"p-disabled":this.disabled}]},equalityKey(){return this.optionValue?null:this.dataKey}},directives:{ripple:i(t).default}};const a=["aria-labelledby"],s=["tabindex","aria-label","role","aria-checked","aria-disabled","onClick","onKeydown","onBlur"],o={class:"p-button-label"};return n.render=function(e,t,i,n,r,d){const u=l.resolveDirective("ripple");return l.openBlock(),l.createElementBlock("div",{ref:"container",class:l.normalizeClass(d.containerClass),role:"group","aria-labelledby":e.ariaLabelledby},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(i.options,((n,a)=>l.withDirectives((l.openBlock(),l.createElementBlock("div",{key:d.getOptionRenderKey(n),tabindex:a===r.focusedIndex?"0":"-1","aria-label":d.getOptionLabel(n),role:i.multiple?"checkbox":"radio","aria-checked":d.isSelected(n),"aria-disabled":i.optionDisabled,class:l.normalizeClass(d.getButtonClass(n,a)),onClick:e=>d.onOptionSelect(e,n,a),onKeydown:e=>d.onKeydown(e,n,a),onFocus:t[0]||(t[0]=e=>d.onFocus(e)),onBlur:e=>d.onBlur(e,n)},[l.renderSlot(e.$slots,"option",{option:n,index:a},(()=>[l.createElementVNode("span",o,l.toDisplayString(d.getOptionLabel(n)),1)]))],42,s)),[[u]]))),128))],10,a)},n}(primevue.utils,primevue.ripple,Vue);
|