primevue 3.22.3 → 3.22.4

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.
Files changed (194) hide show
  1. package/accordion/Accordion.vue +7 -3
  2. package/accordion/accordion.cjs.js +7 -3
  3. package/accordion/accordion.cjs.min.js +1 -1
  4. package/accordion/accordion.esm.js +8 -4
  5. package/accordion/accordion.esm.min.js +1 -1
  6. package/accordion/accordion.js +7 -3
  7. package/accordion/accordion.min.js +1 -1
  8. package/autocomplete/AutoComplete.vue +6 -3
  9. package/autocomplete/autocomplete.cjs.js +12 -9
  10. package/autocomplete/autocomplete.cjs.min.js +1 -1
  11. package/autocomplete/autocomplete.esm.js +13 -10
  12. package/autocomplete/autocomplete.esm.min.js +1 -1
  13. package/autocomplete/autocomplete.js +12 -9
  14. package/autocomplete/autocomplete.min.js +1 -1
  15. package/breadcrumb/Breadcrumb.vue +2 -2
  16. package/breadcrumb/breadcrumb.cjs.js +17 -10
  17. package/breadcrumb/breadcrumb.cjs.min.js +1 -1
  18. package/breadcrumb/breadcrumb.esm.js +17 -10
  19. package/breadcrumb/breadcrumb.esm.min.js +1 -1
  20. package/breadcrumb/breadcrumb.js +17 -10
  21. package/breadcrumb/breadcrumb.min.js +1 -1
  22. package/cascadeselect/CascadeSelect.vue +6 -3
  23. package/cascadeselect/cascadeselect.cjs.js +9 -6
  24. package/cascadeselect/cascadeselect.cjs.min.js +1 -1
  25. package/cascadeselect/cascadeselect.esm.js +10 -7
  26. package/cascadeselect/cascadeselect.esm.min.js +1 -1
  27. package/cascadeselect/cascadeselect.js +9 -6
  28. package/cascadeselect/cascadeselect.min.js +1 -1
  29. package/contextmenu/ContextMenu.vue +6 -3
  30. package/contextmenu/contextmenu.cjs.js +8 -5
  31. package/contextmenu/contextmenu.cjs.min.js +1 -1
  32. package/contextmenu/contextmenu.esm.js +9 -6
  33. package/contextmenu/contextmenu.esm.min.js +1 -1
  34. package/contextmenu/contextmenu.js +8 -5
  35. package/contextmenu/contextmenu.min.js +1 -1
  36. package/core/core.js +45 -33
  37. package/core/core.min.js +4 -4
  38. package/datatable/BodyCell.vue +4 -2
  39. package/datatable/datatable.cjs.js +4 -2
  40. package/datatable/datatable.cjs.min.js +1 -1
  41. package/datatable/datatable.esm.js +4 -2
  42. package/datatable/datatable.esm.min.js +1 -1
  43. package/datatable/datatable.js +4 -2
  44. package/datatable/datatable.min.js +1 -1
  45. package/dock/DockSub.vue +9 -3
  46. package/dock/dock.cjs.js +10 -4
  47. package/dock/dock.cjs.min.js +1 -1
  48. package/dock/dock.esm.js +11 -5
  49. package/dock/dock.esm.min.js +1 -1
  50. package/dock/dock.js +10 -4
  51. package/dock/dock.min.js +1 -1
  52. package/dropdown/Dropdown.vue +6 -3
  53. package/dropdown/dropdown.cjs.js +13 -10
  54. package/dropdown/dropdown.cjs.min.js +1 -1
  55. package/dropdown/dropdown.esm.js +14 -11
  56. package/dropdown/dropdown.esm.min.js +1 -1
  57. package/dropdown/dropdown.js +13 -10
  58. package/dropdown/dropdown.min.js +1 -1
  59. package/listbox/Listbox.vue +6 -3
  60. package/listbox/listbox.cjs.js +11 -8
  61. package/listbox/listbox.cjs.min.js +1 -1
  62. package/listbox/listbox.esm.js +12 -9
  63. package/listbox/listbox.esm.min.js +1 -1
  64. package/listbox/listbox.js +11 -8
  65. package/listbox/listbox.min.js +1 -1
  66. package/megamenu/MegaMenu.vue +7 -3
  67. package/megamenu/megamenu.cjs.js +10 -6
  68. package/megamenu/megamenu.cjs.min.js +1 -1
  69. package/megamenu/megamenu.esm.js +11 -7
  70. package/megamenu/megamenu.esm.min.js +1 -1
  71. package/megamenu/megamenu.js +10 -6
  72. package/megamenu/megamenu.min.js +1 -1
  73. package/menu/Menu.vue +8 -3
  74. package/menu/menu.cjs.js +13 -8
  75. package/menu/menu.cjs.min.js +1 -1
  76. package/menu/menu.esm.js +14 -9
  77. package/menu/menu.esm.min.js +1 -1
  78. package/menu/menu.js +13 -8
  79. package/menu/menu.min.js +1 -1
  80. package/menubar/Menubar.vue +7 -3
  81. package/menubar/menubar.cjs.js +10 -6
  82. package/menubar/menubar.cjs.min.js +1 -1
  83. package/menubar/menubar.esm.js +11 -7
  84. package/menubar/menubar.esm.min.js +1 -1
  85. package/menubar/menubar.js +10 -6
  86. package/menubar/menubar.min.js +1 -1
  87. package/multiselect/MultiSelect.vue +6 -3
  88. package/multiselect/multiselect.cjs.js +11 -8
  89. package/multiselect/multiselect.cjs.min.js +1 -1
  90. package/multiselect/multiselect.esm.js +12 -9
  91. package/multiselect/multiselect.esm.min.js +1 -1
  92. package/multiselect/multiselect.js +11 -8
  93. package/multiselect/multiselect.min.js +1 -1
  94. package/orderlist/OrderList.vue +8 -3
  95. package/orderlist/orderlist.cjs.js +11 -6
  96. package/orderlist/orderlist.cjs.min.js +1 -1
  97. package/orderlist/orderlist.esm.js +12 -7
  98. package/orderlist/orderlist.esm.min.js +1 -1
  99. package/orderlist/orderlist.js +11 -6
  100. package/orderlist/orderlist.min.js +1 -1
  101. package/package.json +1 -1
  102. package/panelmenu/PanelMenu.vue +9 -6
  103. package/panelmenu/PanelMenuList.vue +1 -1
  104. package/panelmenu/panelmenu.cjs.js +11 -8
  105. package/panelmenu/panelmenu.cjs.min.js +1 -1
  106. package/panelmenu/panelmenu.esm.js +11 -8
  107. package/panelmenu/panelmenu.esm.min.js +1 -1
  108. package/panelmenu/panelmenu.js +11 -8
  109. package/panelmenu/panelmenu.min.js +1 -1
  110. package/picklist/PickList.vue +8 -2
  111. package/picklist/picklist.cjs.js +8 -2
  112. package/picklist/picklist.cjs.min.js +1 -1
  113. package/picklist/picklist.esm.js +9 -3
  114. package/picklist/picklist.esm.min.js +1 -1
  115. package/picklist/picklist.js +8 -2
  116. package/picklist/picklist.min.js +1 -1
  117. package/rating/Rating.vue +9 -3
  118. package/rating/rating.cjs.js +11 -5
  119. package/rating/rating.cjs.min.js +1 -1
  120. package/rating/rating.esm.js +12 -6
  121. package/rating/rating.esm.min.js +1 -1
  122. package/rating/rating.js +11 -5
  123. package/rating/rating.min.js +1 -1
  124. package/resources/themes/arya-blue/theme.css +7 -0
  125. package/resources/themes/arya-green/theme.css +7 -0
  126. package/resources/themes/arya-orange/theme.css +7 -0
  127. package/resources/themes/arya-purple/theme.css +7 -0
  128. package/resources/themes/bootstrap4-dark-blue/theme.css +7 -0
  129. package/resources/themes/bootstrap4-dark-purple/theme.css +7 -0
  130. package/resources/themes/bootstrap4-light-blue/theme.css +7 -0
  131. package/resources/themes/bootstrap4-light-purple/theme.css +7 -0
  132. package/resources/themes/fluent-light/theme.css +7 -0
  133. package/resources/themes/lara-dark-blue/theme.css +7 -0
  134. package/resources/themes/lara-dark-indigo/theme.css +7 -0
  135. package/resources/themes/lara-dark-purple/theme.css +7 -0
  136. package/resources/themes/lara-dark-teal/theme.css +7 -0
  137. package/resources/themes/lara-light-blue/theme.css +7 -0
  138. package/resources/themes/lara-light-indigo/theme.css +7 -0
  139. package/resources/themes/lara-light-purple/theme.css +7 -0
  140. package/resources/themes/lara-light-teal/theme.css +7 -0
  141. package/resources/themes/luna-amber/theme.css +7 -0
  142. package/resources/themes/luna-blue/theme.css +7 -0
  143. package/resources/themes/luna-green/theme.css +7 -0
  144. package/resources/themes/luna-pink/theme.css +7 -0
  145. package/resources/themes/md-dark-deeppurple/theme.css +10 -2
  146. package/resources/themes/md-dark-indigo/theme.css +10 -2
  147. package/resources/themes/md-light-deeppurple/theme.css +10 -2
  148. package/resources/themes/md-light-indigo/theme.css +10 -2
  149. package/resources/themes/mdc-dark-deeppurple/theme.css +10 -2
  150. package/resources/themes/mdc-dark-indigo/theme.css +10 -2
  151. package/resources/themes/mdc-light-deeppurple/theme.css +10 -2
  152. package/resources/themes/mdc-light-indigo/theme.css +10 -2
  153. package/resources/themes/nova/theme.css +7 -0
  154. package/resources/themes/nova-accent/theme.css +7 -0
  155. package/resources/themes/nova-alt/theme.css +7 -0
  156. package/resources/themes/nova-vue/theme.css +7 -0
  157. package/resources/themes/rhea/theme.css +7 -0
  158. package/resources/themes/saga-blue/theme.css +7 -0
  159. package/resources/themes/saga-green/theme.css +7 -0
  160. package/resources/themes/saga-orange/theme.css +7 -0
  161. package/resources/themes/saga-purple/theme.css +7 -0
  162. package/resources/themes/tailwind-light/theme.css +7 -0
  163. package/resources/themes/vela-blue/theme.css +7 -0
  164. package/resources/themes/vela-green/theme.css +7 -0
  165. package/resources/themes/vela-orange/theme.css +7 -0
  166. package/resources/themes/vela-purple/theme.css +7 -0
  167. package/speeddial/SpeedDial.vue +6 -3
  168. package/speeddial/speeddial.cjs.js +11 -8
  169. package/speeddial/speeddial.cjs.min.js +1 -1
  170. package/speeddial/speeddial.esm.js +12 -9
  171. package/speeddial/speeddial.esm.min.js +1 -1
  172. package/speeddial/speeddial.js +11 -8
  173. package/speeddial/speeddial.min.js +1 -1
  174. package/tabview/TabView.vue +6 -3
  175. package/tabview/tabview.cjs.js +6 -3
  176. package/tabview/tabview.cjs.min.js +1 -1
  177. package/tabview/tabview.esm.js +7 -4
  178. package/tabview/tabview.esm.min.js +1 -1
  179. package/tabview/tabview.js +6 -3
  180. package/tabview/tabview.min.js +1 -1
  181. package/tieredmenu/TieredMenu.vue +7 -3
  182. package/tieredmenu/tieredmenu.cjs.js +10 -6
  183. package/tieredmenu/tieredmenu.cjs.min.js +1 -1
  184. package/tieredmenu/tieredmenu.esm.js +11 -7
  185. package/tieredmenu/tieredmenu.esm.min.js +1 -1
  186. package/tieredmenu/tieredmenu.js +10 -6
  187. package/tieredmenu/tieredmenu.min.js +1 -1
  188. package/utils/utils.cjs.js +9 -9
  189. package/utils/utils.cjs.min.js +1 -1
  190. package/utils/utils.esm.js +9 -9
  191. package/utils/utils.esm.min.js +1 -1
  192. package/utils/utils.js +9 -9
  193. package/utils/utils.min.js +1 -1
  194. package/web-types.json +1 -1
@@ -1 +1 @@
1
- "use strict";var e=require("primevue/button"),t=require("primevue/ripple"),i=require("primevue/utils"),o=require("vue");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=l(e),s=l(t),r={name:"PickList",emits:["update:modelValue","reorder","update:selection","selection-change","move-to-target","move-to-source","move-all-to-target","move-all-to-source","focus","blur"],props:{modelValue:{type:Array,default:()=>[[],[]]},selection:{type:Array,default:()=>[[],[]]},dataKey:{type:String,default:null},listStyle:{type:null,default:null},metaKeySelection:{type:Boolean,default:!0},responsive:{type:Boolean,default:!0},breakpoint:{type:String,default:"960px"},stripedRows:{type:Boolean,default:!1},showSourceControls:{type:Boolean,default:!0},showTargetControls:{type:Boolean,default:!0},targetListProps:{type:null,default:null},sourceListProps:{type:null,default:null},moveUpButtonProps:{type:null,default:null},moveTopButtonProps:{type:null,default:null},moveDownButtonProps:{type:null,default:null},moveBottomButtonProps:{type:null,default:null},moveToTargetProps:{type:null,default:null},moveAllToTargetProps:{type:null,default:null},moveToSourceProps:{type:null,default:null},moveAllToSourceProps:{type:null,default:null},tabindex:{type:Number,default:0}},itemTouched:!1,reorderDirection:null,styleElement:null,data(){return{d_selection:this.selection,focused:{sourceList:!1,targetList:!1},focusedOptionIndex:-1}},watch:{selection(e){this.d_selection=e}},updated(){this.reorderDirection&&(this.updateListScroll(this.$refs.sourceList.$el),this.updateListScroll(this.$refs.targetList.$el),this.reorderDirection=null)},beforeUnmount(){this.destroyStyle()},mounted(){this.responsive&&this.createStyle()},methods:{getItemKey(e,t){return this.dataKey?i.ObjectUtils.resolveFieldData(e,this.dataKey):t},isSelected(e,t){return-1!=i.ObjectUtils.findIndexInList(e,this.d_selection[t])},onListFocus(e,t){const o=i.DomHandler.findSingle(this.$refs[t].$el,"li.p-picklist-item.p-highlight"),l=i.ObjectUtils.findIndexInList(o,this.$refs[t].$el.children);this.focused[t]=!0;const n=-1!==this.focusedOptionIndex?this.focusedOptionIndex:o?l:-1;this.changeFocusedOptionIndex(n,t),this.$emit("focus",e)},onListBlur(e,t){this.focused[t]=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onOptionMouseDown(e,t){this.focused[t]=!0,this.focusedOptionIndex=e},moveUp(e,t){if(this.d_selection&&this.d_selection[t]){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=0;e<l.length;e++){let t=l[e],n=i.ObjectUtils.findIndexInList(t,o);if(0===n)break;{let e=o[n],t=o[n-1];o[n-1]=e,o[n]=t}}let n=[...this.modelValue];n[t]=o,this.reorderDirection="up",this.$emit("update:modelValue",n),this.$emit("reorder",{originalEvent:e,value:n,direction:this.reorderDirection,listIndex:t})}},moveTop(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=0;e<l.length;e++){let t=l[e],n=i.ObjectUtils.findIndexInList(t,o);if(0===n)break;{let e=o.splice(n,1)[0];o.unshift(e)}}let n=[...this.modelValue];n[t]=o,this.reorderDirection="top",this.$emit("update:modelValue",n),this.$emit("reorder",{originalEvent:e,value:n,direction:this.reorderDirection,listIndex:t})}},moveDown(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=l.length-1;e>=0;e--){let t=l[e],n=i.ObjectUtils.findIndexInList(t,o);if(n===o.length-1)break;{let e=o[n],t=o[n+1];o[n+1]=e,o[n]=t}}let n=[...this.modelValue];n[t]=o,this.reorderDirection="down",this.$emit("update:modelValue",n),this.$emit("reorder",{originalEvent:e,value:n,direction:this.reorderDirection,listIndex:t})}},moveBottom(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=l.length-1;e>=0;e--){let t=l[e],n=i.ObjectUtils.findIndexInList(t,o);if(n===o.length-1)break;{let e=o.splice(n,1)[0];o.push(e)}}let n=[...this.modelValue];n[t]=o,this.reorderDirection="bottom",this.$emit("update:modelValue",n),this.$emit("reorder",{originalEvent:e,value:n,direction:this.reorderDirection,listIndex:t})}},moveToTarget(e){let t=this.d_selection&&this.d_selection[0]?this.d_selection[0]:null,o=[...this.modelValue[0]],l=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let n=t[e];-1==i.ObjectUtils.findIndexInList(n,l)&&l.push(o.splice(i.ObjectUtils.findIndexInList(n,o),1)[0])}let n=[...this.modelValue];n[0]=o,n[1]=l,this.$emit("update:modelValue",n),this.$emit("move-to-target",{originalEvent:e,items:t}),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToTarget(e){if(this.modelValue[0]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-target",{originalEvent:e,items:t}),i=[...i,...t],t=[];let o=[...this.modelValue];o[0]=t,o[1]=i,this.$emit("update:modelValue",o),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveToSource(e){let t=this.d_selection&&this.d_selection[1]?this.d_selection[1]:null,o=[...this.modelValue[0]],l=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let n=t[e];-1==i.ObjectUtils.findIndexInList(n,o)&&o.push(l.splice(i.ObjectUtils.findIndexInList(n,l),1)[0])}let n=[...this.modelValue];n[0]=o,n[1]=l,this.$emit("update:modelValue",n),this.$emit("move-to-source",{originalEvent:e,items:t}),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToSource(e){if(this.modelValue[1]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-source",{originalEvent:e,items:i}),t=[...t,...i],i=[];let o=[...this.modelValue];o[0]=t,o[1]=i,this.$emit("update:modelValue",o),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},onItemClick(e,t,o,l){const n=0===l?"sourceList":"targetList";this.itemTouched=!1;const s=this.d_selection[l],r=i.ObjectUtils.findIndexInList(t,this.d_selection),a=-1!=r,d=!this.itemTouched&&this.metaKeySelection,c=i.DomHandler.find(this.$refs[n].$el,".p-picklist-item")[o].getAttribute("id");let u;if(this.focusedOptionIndex=c,d){let i=e.metaKey||e.ctrlKey;a&&i?u=s.filter(((e,t)=>t!==r)):(u=i&&s?[...s]:[],u.push(t))}else a?u=s.filter(((e,t)=>t!==r)):(u=s?[...s]:[],u.push(t));let p=[...this.d_selection];p[l]=u,this.d_selection=p,this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})},onItemDblClick(e,t,i){0===i?this.moveToTarget(e):1===i&&this.moveToSource(e)},onItemTouchEnd(){this.itemTouched=!0},onItemKeyDown(e,t){switch(e.code){case"ArrowDown":this.onArrowDownKey(e,t);break;case"ArrowUp":this.onArrowUpKey(e,t);break;case"Home":this.onHomeKey(e,t);break;case"End":this.onEndKey(e,t);break;case"Enter":this.onEnterKey(e,t);break;case"Space":this.onSpaceKey(e,t);break;case"KeyA":e.ctrlKey&&(this.d_selection=[...this.modelValue],this.$emit("update:selection",this.d_selection))}},onArrowDownKey(e,t){const i=this.findNextOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onArrowUpKey(e,t){const i=this.findPrevOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onEnterKey(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),n=[...o].findIndex((e=>e===l)),s="sourceList"===t?0:1;this.onItemClick(e,this.modelValue[s][n],n,s),e.preventDefault()},onSpaceKey(e,t){if(e.preventDefault(),e.shiftKey){const e="sourceList"===t?0:1,o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.ObjectUtils.findIndexInList(this.d_selection[e][0],[...this.modelValue[e]]),n=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...o].findIndex((e=>e===n));this.d_selection[e]=[...this.modelValue[e]].slice(Math.min(l,s),Math.max(l,s)+1),this.$emit("update:selection",this.d_selection)}else this.onEnterKey(e,t)},onHomeKey(e,t){if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),n=[...o].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(0,n+1),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(0,t);e.preventDefault()},onEndKey(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item");if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),n=[...o].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(n,o.length),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(o.length-1,t);e.preventDefault()},findNextOptionIndex(e,t){const o=[...i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return o>-1?o+1:0},findPrevOptionIndex(e,t){const o=[...i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return o>-1?o-1:0},changeFocusedOptionIndex(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item");let l=e>=o.length?o.length-1:e<0?0:e;this.focusedOptionIndex=o[l].getAttribute("id"),this.scrollInView(o[l].getAttribute("id"),t)},scrollInView(e,t){const o=i.DomHandler.findSingle(this.$refs[t].$el,`li[id="${e}"]`);o&&o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"start"})},updateListScroll(e){const t=i.DomHandler.find(e,".p-picklist-item.p-highlight");if(t&&t.length)switch(this.reorderDirection){case"up":i.DomHandler.scrollInView(e,t[0]);break;case"top":e.scrollTop=0;break;case"down":i.DomHandler.scrollInView(e,t[t.length-1]);break;case"bottom":e.scrollTop=e.scrollHeight}},createStyle(){if(!this.styleElement){this.$el.setAttribute(this.attributeSelector,""),this.styleElement=document.createElement("style"),this.styleElement.type="text/css",document.head.appendChild(this.styleElement);let e=`\n@media screen and (max-width: ${this.breakpoint}) {\n .p-picklist[${this.attributeSelector}] {\n flex-direction: column;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons {\n padding: var(--content-padding);\n flex-direction: row;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button {\n margin-right: var(--inline-spacing);\n margin-bottom: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button:last-child {\n margin-right: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-right:before {\n content: "\\e930"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-right:before {\n content: "\\e92c"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-left:before {\n content: "\\e933"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-left:before {\n content: "\\e92f"\n }\n}\n`;this.styleElement.innerHTML=e}},destroyStyle(){this.styleElement&&(document.head.removeChild(this.styleElement),this.styleElement=null)},moveDisabled(e){if(!this.d_selection[e]||!this.d_selection[e].length)return!0},moveAllDisabled(e){return i.ObjectUtils.isEmpty(this[e])},moveSourceDisabled(){return i.ObjectUtils.isEmpty(this.targetList)},itemClass(e,t,i){return["p-picklist-item",{"p-highlight":this.isSelected(e,i),"p-focus":t===this.focusedOptionId}]}},computed:{idSource(){return this.$attrs.id||i.UniqueComponentId()},idTarget(){return this.$attrs.id||i.UniqueComponentId()},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null},containerClass(){return["p-picklist p-component",{"p-picklist-striped":this.stripedRows}]},sourceList(){return this.modelValue&&this.modelValue[0]?this.modelValue[0]:null},targetList(){return this.modelValue&&this.modelValue[1]?this.modelValue[1]:null},attributeSelector:()=>i.UniqueComponentId(),moveUpAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveUp:void 0},moveTopAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveTop:void 0},moveDownAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveDown:void 0},moveBottomAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveBottom:void 0},moveToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToTarget:void 0},moveAllToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToTarget:void 0},moveToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToSource:void 0},moveAllToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToSource:void 0}},components:{PLButton:n.default},directives:{ripple:s.default}};const a={key:0,class:"p-picklist-buttons p-picklist-source-controls"},d={class:"p-picklist-list-wrapper p-picklist-source-wrapper"},c={key:0,class:"p-picklist-header"},u=["id","onClick","onDblclick","onMousedown","aria-selected"],p={class:"p-picklist-buttons p-picklist-transfer-buttons"},m={class:"p-picklist-list-wrapper p-picklist-target-wrapper"},h={key:0,class:"p-picklist-header"},f=["id","onClick","onDblclick","onMousedown","aria-selected"],v={key:1,class:"p-picklist-buttons p-picklist-target-controls"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===i&&o.firstChild?o.insertBefore(l,o.firstChild):o.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}("\n.p-picklist {\n display: flex;\n}\n.p-picklist-buttons {\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n.p-picklist-list-wrapper {\n flex: 1 1 50%;\n}\n.p-picklist-list {\n list-style-type: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n min-height: 12rem;\n max-height: 24rem;\n}\n.p-picklist-item {\n cursor: pointer;\n overflow: hidden;\n position: relative;\n}\n.p-picklist-item.p-picklist-flip-enter-active.p-picklist-flip-enter-to,\n.p-picklist-item.p-picklist-flip-leave-active.p-picklist-flip-leave-to {\n transition: none !important;\n}\n"),r.render=function(e,t,i,l,n,s){const r=o.resolveComponent("PLButton"),b=o.resolveDirective("ripple");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(s.containerClass)},[i.showSourceControls?(o.openBlock(),o.createElementBlock("div",a,[o.renderSlot(e.$slots,"sourcecontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":s.moveUpAriaLabel,disabled:s.moveDisabled(0)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[0]||(t[0]=e=>s.moveUp(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveTopAriaLabel,disabled:s.moveDisabled(0)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[1]||(t[1]=e=>s.moveTop(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveDownAriaLabel,disabled:s.moveDisabled(0)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[2]||(t[2]=e=>s.moveDown(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveBottomAriaLabel,disabled:s.moveDisabled(0)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[3]||(t[3]=e=>s.moveBottom(e,0))}),null,16,["aria-label","disabled"]),o.renderSlot(e.$slots,"sourcecontrolsend")])):o.createCommentVNode("",!0),o.createElementVNode("div",d,[e.$slots.sourceheader?(o.openBlock(),o.createElementBlock("div",c,[o.renderSlot(e.$slots,"sourceheader")])):o.createCommentVNode("",!0),o.createVNode(o.TransitionGroup,o.mergeProps({ref:"sourceList",id:s.idSource+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-source",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":n.focused.sourceList?s.focusedOptionId:void 0,tabindex:s.sourceList&&s.sourceList.length>0?i.tabindex:-1,onFocus:t[5]||(t[5]=e=>s.onListFocus(e,"sourceList")),onBlur:t[6]||(t[6]=e=>s.onListBlur(e,"sourceList")),onKeydown:t[7]||(t[7]=e=>s.onItemKeyDown(e,"sourceList"))},i.sourceListProps),{default:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(s.sourceList,((i,l)=>o.withDirectives((o.openBlock(),o.createElementBlock("li",{key:s.getItemKey(i,l),id:s.idSource+"_"+l,class:o.normalizeClass(s.itemClass(i,`${s.idSource}_${l}`,0)),onClick:e=>s.onItemClick(e,i,l,0),onDblclick:e=>s.onItemDblClick(e,i,0),onTouchend:t[4]||(t[4]=(...e)=>s.onItemTouchEnd&&s.onItemTouchEnd(...e)),onMousedown:e=>s.onOptionMouseDown(l,"sourceList"),role:"option","aria-selected":s.isSelected(i,0)},[o.renderSlot(e.$slots,"item",{item:i,index:l})],42,u)),[[b]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),o.createElementVNode("div",p,[o.renderSlot(e.$slots,"movecontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":s.moveToTargetAriaLabel,type:"button",icon:"pi pi-angle-right",onClick:s.moveToTarget,disabled:s.moveDisabled(0)},i.moveToTargetProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveAllToTargetAriaLabel,type:"button",icon:"pi pi-angle-double-right",onClick:s.moveAllToTarget,disabled:s.moveAllDisabled("sourceList")},i.moveAllToTargetProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveToSourceAriaLabel,type:"button",icon:"pi pi-angle-left",onClick:s.moveToSource,disabled:s.moveDisabled(1)},i.moveToSourceProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveAllToSourceAriaLabel,type:"button",icon:"pi pi-angle-double-left",onClick:s.moveAllToSource,disabled:s.moveSourceDisabled("targetList")},i.moveAllToSourceProps),null,16,["aria-label","onClick","disabled"]),o.renderSlot(e.$slots,"movecontrolsend")]),o.createElementVNode("div",m,[e.$slots.targetheader?(o.openBlock(),o.createElementBlock("div",h,[o.renderSlot(e.$slots,"targetheader")])):o.createCommentVNode("",!0),o.createVNode(o.TransitionGroup,o.mergeProps({ref:"targetList",id:s.idTarget+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-target",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":n.focused.targetList?s.focusedOptionId:void 0,tabindex:s.targetList&&s.targetList.length>0?i.tabindex:-1,onFocus:t[10]||(t[10]=e=>s.onListFocus(e,"targetList")),onBlur:t[11]||(t[11]=e=>s.onListBlur(e,"targetList")),onKeydown:t[12]||(t[12]=e=>s.onItemKeyDown(e,"targetList"))},i.targetListProps),{default:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(s.targetList,((i,l)=>o.withDirectives((o.openBlock(),o.createElementBlock("li",{key:s.getItemKey(i,l),id:s.idTarget+"_"+l,class:o.normalizeClass(s.itemClass(i,`${s.idTarget}_${l}`,1)),onClick:e=>s.onItemClick(e,i,l,1),onDblclick:e=>s.onItemDblClick(e,i,1),onKeydown:t[8]||(t[8]=e=>s.onItemKeyDown(e,"targetList")),onMousedown:e=>s.onOptionMouseDown(l,"targetList"),onTouchend:t[9]||(t[9]=(...e)=>s.onItemTouchEnd&&s.onItemTouchEnd(...e)),role:"option","aria-selected":s.isSelected(i,1)},[o.renderSlot(e.$slots,"item",{item:i,index:l})],42,f)),[[b]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),i.showTargetControls?(o.openBlock(),o.createElementBlock("div",v,[o.renderSlot(e.$slots,"targetcontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":s.moveUpAriaLabel,disabled:s.moveDisabled(1)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[13]||(t[13]=e=>s.moveUp(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveTopAriaLabel,disabled:s.moveDisabled(1)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[14]||(t[14]=e=>s.moveTop(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveDownAriaLabel,disabled:s.moveDisabled(1)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[15]||(t[15]=e=>s.moveDown(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveBottomAriaLabel,disabled:s.moveDisabled(1)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[16]||(t[16]=e=>s.moveBottom(e,1))}),null,16,["aria-label","disabled"]),o.renderSlot(e.$slots,"targetcontrolsend")])):o.createCommentVNode("",!0)],2)},module.exports=r;
1
+ "use strict";var e=require("primevue/button"),t=require("primevue/ripple"),i=require("primevue/utils"),o=require("vue");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=l(e),n=l(t),r={name:"PickList",emits:["update:modelValue","reorder","update:selection","selection-change","move-to-target","move-to-source","move-all-to-target","move-all-to-source","focus","blur"],props:{modelValue:{type:Array,default:()=>[[],[]]},selection:{type:Array,default:()=>[[],[]]},dataKey:{type:String,default:null},listStyle:{type:null,default:null},metaKeySelection:{type:Boolean,default:!0},responsive:{type:Boolean,default:!0},breakpoint:{type:String,default:"960px"},stripedRows:{type:Boolean,default:!1},showSourceControls:{type:Boolean,default:!0},showTargetControls:{type:Boolean,default:!0},targetListProps:{type:null,default:null},sourceListProps:{type:null,default:null},moveUpButtonProps:{type:null,default:null},moveTopButtonProps:{type:null,default:null},moveDownButtonProps:{type:null,default:null},moveBottomButtonProps:{type:null,default:null},moveToTargetProps:{type:null,default:null},moveAllToTargetProps:{type:null,default:null},moveToSourceProps:{type:null,default:null},moveAllToSourceProps:{type:null,default:null},tabindex:{type:Number,default:0}},itemTouched:!1,reorderDirection:null,styleElement:null,data(){return{id:this.$attrs.id,d_selection:this.selection,focused:{sourceList:!1,targetList:!1},focusedOptionIndex:-1}},watch:{"$attrs.id":function(e){this.id=e||i.UniqueComponentId()},selection(e){this.d_selection=e}},updated(){this.reorderDirection&&(this.updateListScroll(this.$refs.sourceList.$el),this.updateListScroll(this.$refs.targetList.$el),this.reorderDirection=null)},beforeUnmount(){this.destroyStyle()},mounted(){this.id=this.id||i.UniqueComponentId(),this.responsive&&this.createStyle()},methods:{getItemKey(e,t){return this.dataKey?i.ObjectUtils.resolveFieldData(e,this.dataKey):t},isSelected(e,t){return-1!=i.ObjectUtils.findIndexInList(e,this.d_selection[t])},onListFocus(e,t){const o=i.DomHandler.findSingle(this.$refs[t].$el,"li.p-picklist-item.p-highlight"),l=i.ObjectUtils.findIndexInList(o,this.$refs[t].$el.children);this.focused[t]=!0;const s=-1!==this.focusedOptionIndex?this.focusedOptionIndex:o?l:-1;this.changeFocusedOptionIndex(s,t),this.$emit("focus",e)},onListBlur(e,t){this.focused[t]=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onOptionMouseDown(e,t){this.focused[t]=!0,this.focusedOptionIndex=e},moveUp(e,t){if(this.d_selection&&this.d_selection[t]){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=0;e<l.length;e++){let t=l[e],s=i.ObjectUtils.findIndexInList(t,o);if(0===s)break;{let e=o[s],t=o[s-1];o[s-1]=e,o[s]=t}}let s=[...this.modelValue];s[t]=o,this.reorderDirection="up",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveTop(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=0;e<l.length;e++){let t=l[e],s=i.ObjectUtils.findIndexInList(t,o);if(0===s)break;{let e=o.splice(s,1)[0];o.unshift(e)}}let s=[...this.modelValue];s[t]=o,this.reorderDirection="top",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveDown(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=l.length-1;e>=0;e--){let t=l[e],s=i.ObjectUtils.findIndexInList(t,o);if(s===o.length-1)break;{let e=o[s],t=o[s+1];o[s+1]=e,o[s]=t}}let s=[...this.modelValue];s[t]=o,this.reorderDirection="down",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveBottom(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=l.length-1;e>=0;e--){let t=l[e],s=i.ObjectUtils.findIndexInList(t,o);if(s===o.length-1)break;{let e=o.splice(s,1)[0];o.push(e)}}let s=[...this.modelValue];s[t]=o,this.reorderDirection="bottom",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveToTarget(e){let t=this.d_selection&&this.d_selection[0]?this.d_selection[0]:null,o=[...this.modelValue[0]],l=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let s=t[e];-1==i.ObjectUtils.findIndexInList(s,l)&&l.push(o.splice(i.ObjectUtils.findIndexInList(s,o),1)[0])}let s=[...this.modelValue];s[0]=o,s[1]=l,this.$emit("update:modelValue",s),this.$emit("move-to-target",{originalEvent:e,items:t}),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToTarget(e){if(this.modelValue[0]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-target",{originalEvent:e,items:t}),i=[...i,...t],t=[];let o=[...this.modelValue];o[0]=t,o[1]=i,this.$emit("update:modelValue",o),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveToSource(e){let t=this.d_selection&&this.d_selection[1]?this.d_selection[1]:null,o=[...this.modelValue[0]],l=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let s=t[e];-1==i.ObjectUtils.findIndexInList(s,o)&&o.push(l.splice(i.ObjectUtils.findIndexInList(s,l),1)[0])}let s=[...this.modelValue];s[0]=o,s[1]=l,this.$emit("update:modelValue",s),this.$emit("move-to-source",{originalEvent:e,items:t}),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToSource(e){if(this.modelValue[1]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-source",{originalEvent:e,items:i}),t=[...t,...i],i=[];let o=[...this.modelValue];o[0]=t,o[1]=i,this.$emit("update:modelValue",o),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},onItemClick(e,t,o,l){const s=0===l?"sourceList":"targetList";this.itemTouched=!1;const n=this.d_selection[l],r=i.ObjectUtils.findIndexInList(t,this.d_selection),a=-1!=r,d=!this.itemTouched&&this.metaKeySelection,c=i.DomHandler.find(this.$refs[s].$el,".p-picklist-item")[o].getAttribute("id");let u;if(this.focusedOptionIndex=c,d){let i=e.metaKey||e.ctrlKey;a&&i?u=n.filter(((e,t)=>t!==r)):(u=i&&n?[...n]:[],u.push(t))}else a?u=n.filter(((e,t)=>t!==r)):(u=n?[...n]:[],u.push(t));let p=[...this.d_selection];p[l]=u,this.d_selection=p,this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})},onItemDblClick(e,t,i){0===i?this.moveToTarget(e):1===i&&this.moveToSource(e)},onItemTouchEnd(){this.itemTouched=!0},onItemKeyDown(e,t){switch(e.code){case"ArrowDown":this.onArrowDownKey(e,t);break;case"ArrowUp":this.onArrowUpKey(e,t);break;case"Home":this.onHomeKey(e,t);break;case"End":this.onEndKey(e,t);break;case"Enter":this.onEnterKey(e,t);break;case"Space":this.onSpaceKey(e,t);break;case"KeyA":e.ctrlKey&&(this.d_selection=[...this.modelValue],this.$emit("update:selection",this.d_selection))}},onArrowDownKey(e,t){const i=this.findNextOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onArrowUpKey(e,t){const i=this.findPrevOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onEnterKey(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...o].findIndex((e=>e===l)),n="sourceList"===t?0:1;this.onItemClick(e,this.modelValue[n][s],s,n),e.preventDefault()},onSpaceKey(e,t){if(e.preventDefault(),e.shiftKey){const e="sourceList"===t?0:1,o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.ObjectUtils.findIndexInList(this.d_selection[e][0],[...this.modelValue[e]]),s=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),n=[...o].findIndex((e=>e===s));this.d_selection[e]=[...this.modelValue[e]].slice(Math.min(l,n),Math.max(l,n)+1),this.$emit("update:selection",this.d_selection)}else this.onEnterKey(e,t)},onHomeKey(e,t){if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...o].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(0,s+1),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(0,t);e.preventDefault()},onEndKey(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item");if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...o].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(s,o.length),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(o.length-1,t);e.preventDefault()},findNextOptionIndex(e,t){const o=[...i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return o>-1?o+1:0},findPrevOptionIndex(e,t){const o=[...i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return o>-1?o-1:0},changeFocusedOptionIndex(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item");let l=e>=o.length?o.length-1:e<0?0:e;this.focusedOptionIndex=o[l].getAttribute("id"),this.scrollInView(o[l].getAttribute("id"),t)},scrollInView(e,t){const o=i.DomHandler.findSingle(this.$refs[t].$el,`li[id="${e}"]`);o&&o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"start"})},updateListScroll(e){const t=i.DomHandler.find(e,".p-picklist-item.p-highlight");if(t&&t.length)switch(this.reorderDirection){case"up":i.DomHandler.scrollInView(e,t[0]);break;case"top":e.scrollTop=0;break;case"down":i.DomHandler.scrollInView(e,t[t.length-1]);break;case"bottom":e.scrollTop=e.scrollHeight}},createStyle(){if(!this.styleElement){this.$el.setAttribute(this.attributeSelector,""),this.styleElement=document.createElement("style"),this.styleElement.type="text/css",document.head.appendChild(this.styleElement);let e=`\n@media screen and (max-width: ${this.breakpoint}) {\n .p-picklist[${this.attributeSelector}] {\n flex-direction: column;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons {\n padding: var(--content-padding);\n flex-direction: row;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button {\n margin-right: var(--inline-spacing);\n margin-bottom: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button:last-child {\n margin-right: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-right:before {\n content: "\\e930"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-right:before {\n content: "\\e92c"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-left:before {\n content: "\\e933"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-left:before {\n content: "\\e92f"\n }\n}\n`;this.styleElement.innerHTML=e}},destroyStyle(){this.styleElement&&(document.head.removeChild(this.styleElement),this.styleElement=null)},moveDisabled(e){if(!this.d_selection[e]||!this.d_selection[e].length)return!0},moveAllDisabled(e){return i.ObjectUtils.isEmpty(this[e])},moveSourceDisabled(){return i.ObjectUtils.isEmpty(this.targetList)},itemClass(e,t,i){return["p-picklist-item",{"p-highlight":this.isSelected(e,i),"p-focus":t===this.focusedOptionId}]}},computed:{idSource(){return`${this.id}_source`},idTarget(){return`${this.id}_target`},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null},containerClass(){return["p-picklist p-component",{"p-picklist-striped":this.stripedRows}]},sourceList(){return this.modelValue&&this.modelValue[0]?this.modelValue[0]:null},targetList(){return this.modelValue&&this.modelValue[1]?this.modelValue[1]:null},attributeSelector:()=>i.UniqueComponentId(),moveUpAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveUp:void 0},moveTopAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveTop:void 0},moveDownAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveDown:void 0},moveBottomAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveBottom:void 0},moveToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToTarget:void 0},moveAllToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToTarget:void 0},moveToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToSource:void 0},moveAllToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToSource:void 0}},components:{PLButton:s.default},directives:{ripple:n.default}};const a={key:0,class:"p-picklist-buttons p-picklist-source-controls"},d={class:"p-picklist-list-wrapper p-picklist-source-wrapper"},c={key:0,class:"p-picklist-header"},u=["id","onClick","onDblclick","onMousedown","aria-selected"],p={class:"p-picklist-buttons p-picklist-transfer-buttons"},m={class:"p-picklist-list-wrapper p-picklist-target-wrapper"},h={key:0,class:"p-picklist-header"},f=["id","onClick","onDblclick","onMousedown","aria-selected"],v={key:1,class:"p-picklist-buttons p-picklist-target-controls"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===i&&o.firstChild?o.insertBefore(l,o.firstChild):o.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}("\n.p-picklist {\n display: flex;\n}\n.p-picklist-buttons {\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n.p-picklist-list-wrapper {\n flex: 1 1 50%;\n}\n.p-picklist-list {\n list-style-type: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n min-height: 12rem;\n max-height: 24rem;\n}\n.p-picklist-item {\n cursor: pointer;\n overflow: hidden;\n position: relative;\n}\n.p-picklist-item.p-picklist-flip-enter-active.p-picklist-flip-enter-to,\n.p-picklist-item.p-picklist-flip-leave-active.p-picklist-flip-leave-to {\n transition: none !important;\n}\n"),r.render=function(e,t,i,l,s,n){const r=o.resolveComponent("PLButton"),b=o.resolveDirective("ripple");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(n.containerClass)},[i.showSourceControls?(o.openBlock(),o.createElementBlock("div",a,[o.renderSlot(e.$slots,"sourcecontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":n.moveUpAriaLabel,disabled:n.moveDisabled(0)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[0]||(t[0]=e=>n.moveUp(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveTopAriaLabel,disabled:n.moveDisabled(0)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[1]||(t[1]=e=>n.moveTop(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveDownAriaLabel,disabled:n.moveDisabled(0)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[2]||(t[2]=e=>n.moveDown(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveBottomAriaLabel,disabled:n.moveDisabled(0)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[3]||(t[3]=e=>n.moveBottom(e,0))}),null,16,["aria-label","disabled"]),o.renderSlot(e.$slots,"sourcecontrolsend")])):o.createCommentVNode("",!0),o.createElementVNode("div",d,[e.$slots.sourceheader?(o.openBlock(),o.createElementBlock("div",c,[o.renderSlot(e.$slots,"sourceheader")])):o.createCommentVNode("",!0),o.createVNode(o.TransitionGroup,o.mergeProps({ref:"sourceList",id:n.idSource+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-source",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":s.focused.sourceList?n.focusedOptionId:void 0,tabindex:n.sourceList&&n.sourceList.length>0?i.tabindex:-1,onFocus:t[5]||(t[5]=e=>n.onListFocus(e,"sourceList")),onBlur:t[6]||(t[6]=e=>n.onListBlur(e,"sourceList")),onKeydown:t[7]||(t[7]=e=>n.onItemKeyDown(e,"sourceList"))},i.sourceListProps),{default:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(n.sourceList,((i,l)=>o.withDirectives((o.openBlock(),o.createElementBlock("li",{key:n.getItemKey(i,l),id:n.idSource+"_"+l,class:o.normalizeClass(n.itemClass(i,`${n.idSource}_${l}`,0)),onClick:e=>n.onItemClick(e,i,l,0),onDblclick:e=>n.onItemDblClick(e,i,0),onTouchend:t[4]||(t[4]=(...e)=>n.onItemTouchEnd&&n.onItemTouchEnd(...e)),onMousedown:e=>n.onOptionMouseDown(l,"sourceList"),role:"option","aria-selected":n.isSelected(i,0)},[o.renderSlot(e.$slots,"item",{item:i,index:l})],42,u)),[[b]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),o.createElementVNode("div",p,[o.renderSlot(e.$slots,"movecontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":n.moveToTargetAriaLabel,type:"button",icon:"pi pi-angle-right",onClick:n.moveToTarget,disabled:n.moveDisabled(0)},i.moveToTargetProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveAllToTargetAriaLabel,type:"button",icon:"pi pi-angle-double-right",onClick:n.moveAllToTarget,disabled:n.moveAllDisabled("sourceList")},i.moveAllToTargetProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveToSourceAriaLabel,type:"button",icon:"pi pi-angle-left",onClick:n.moveToSource,disabled:n.moveDisabled(1)},i.moveToSourceProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveAllToSourceAriaLabel,type:"button",icon:"pi pi-angle-double-left",onClick:n.moveAllToSource,disabled:n.moveSourceDisabled("targetList")},i.moveAllToSourceProps),null,16,["aria-label","onClick","disabled"]),o.renderSlot(e.$slots,"movecontrolsend")]),o.createElementVNode("div",m,[e.$slots.targetheader?(o.openBlock(),o.createElementBlock("div",h,[o.renderSlot(e.$slots,"targetheader")])):o.createCommentVNode("",!0),o.createVNode(o.TransitionGroup,o.mergeProps({ref:"targetList",id:n.idTarget+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-target",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":s.focused.targetList?n.focusedOptionId:void 0,tabindex:n.targetList&&n.targetList.length>0?i.tabindex:-1,onFocus:t[10]||(t[10]=e=>n.onListFocus(e,"targetList")),onBlur:t[11]||(t[11]=e=>n.onListBlur(e,"targetList")),onKeydown:t[12]||(t[12]=e=>n.onItemKeyDown(e,"targetList"))},i.targetListProps),{default:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(n.targetList,((i,l)=>o.withDirectives((o.openBlock(),o.createElementBlock("li",{key:n.getItemKey(i,l),id:n.idTarget+"_"+l,class:o.normalizeClass(n.itemClass(i,`${n.idTarget}_${l}`,1)),onClick:e=>n.onItemClick(e,i,l,1),onDblclick:e=>n.onItemDblClick(e,i,1),onKeydown:t[8]||(t[8]=e=>n.onItemKeyDown(e,"targetList")),onMousedown:e=>n.onOptionMouseDown(l,"targetList"),onTouchend:t[9]||(t[9]=(...e)=>n.onItemTouchEnd&&n.onItemTouchEnd(...e)),role:"option","aria-selected":n.isSelected(i,1)},[o.renderSlot(e.$slots,"item",{item:i,index:l})],42,f)),[[b]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),i.showTargetControls?(o.openBlock(),o.createElementBlock("div",v,[o.renderSlot(e.$slots,"targetcontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":n.moveUpAriaLabel,disabled:n.moveDisabled(1)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[13]||(t[13]=e=>n.moveUp(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveTopAriaLabel,disabled:n.moveDisabled(1)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[14]||(t[14]=e=>n.moveTop(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveDownAriaLabel,disabled:n.moveDisabled(1)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[15]||(t[15]=e=>n.moveDown(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveBottomAriaLabel,disabled:n.moveDisabled(1)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[16]||(t[16]=e=>n.moveBottom(e,1))}),null,16,["aria-label","disabled"]),o.renderSlot(e.$slots,"targetcontrolsend")])):o.createCommentVNode("",!0)],2)},module.exports=r;
@@ -1,6 +1,6 @@
1
1
  import Button from 'primevue/button';
2
2
  import Ripple from 'primevue/ripple';
3
- import { ObjectUtils, DomHandler, UniqueComponentId } from 'primevue/utils';
3
+ import { UniqueComponentId, ObjectUtils, DomHandler } from 'primevue/utils';
4
4
  import { resolveComponent, resolveDirective, openBlock, createElementBlock, normalizeClass, renderSlot, createVNode, mergeProps, createCommentVNode, createElementVNode, TransitionGroup, withCtx, Fragment, renderList, withDirectives } from 'vue';
5
5
 
6
6
  var script = {
@@ -97,6 +97,7 @@ var script = {
97
97
  styleElement: null,
98
98
  data() {
99
99
  return {
100
+ id: this.$attrs.id,
100
101
  d_selection: this.selection,
101
102
  focused: {
102
103
  sourceList: false,
@@ -106,6 +107,9 @@ var script = {
106
107
  };
107
108
  },
108
109
  watch: {
110
+ '$attrs.id': function (newValue) {
111
+ this.id = newValue || UniqueComponentId();
112
+ },
109
113
  selection(newValue) {
110
114
  this.d_selection = newValue;
111
115
  }
@@ -121,6 +125,8 @@ var script = {
121
125
  this.destroyStyle();
122
126
  },
123
127
  mounted() {
128
+ this.id = this.id || UniqueComponentId();
129
+
124
130
  if (this.responsive) {
125
131
  this.createStyle();
126
132
  }
@@ -687,10 +693,10 @@ var script = {
687
693
  },
688
694
  computed: {
689
695
  idSource() {
690
- return this.$attrs.id || UniqueComponentId();
696
+ return `${this.id}_source`;
691
697
  },
692
698
  idTarget() {
693
- return this.$attrs.id || UniqueComponentId();
699
+ return `${this.id}_target`;
694
700
  },
695
701
  focusedOptionId() {
696
702
  return this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : null;
@@ -1 +1 @@
1
- import e from"primevue/button";import t from"primevue/ripple";import{ObjectUtils as i,DomHandler as l,UniqueComponentId as o}from"primevue/utils";import{resolveComponent as s,resolveDirective as n,openBlock as r,createElementBlock as a,normalizeClass as d,renderSlot as c,createVNode as u,mergeProps as p,createCommentVNode as h,createElementVNode as m,TransitionGroup as f,withCtx as v,Fragment as b,renderList as g,withDirectives as y}from"vue";var $={name:"PickList",emits:["update:modelValue","reorder","update:selection","selection-change","move-to-target","move-to-source","move-all-to-target","move-all-to-source","focus","blur"],props:{modelValue:{type:Array,default:()=>[[],[]]},selection:{type:Array,default:()=>[[],[]]},dataKey:{type:String,default:null},listStyle:{type:null,default:null},metaKeySelection:{type:Boolean,default:!0},responsive:{type:Boolean,default:!0},breakpoint:{type:String,default:"960px"},stripedRows:{type:Boolean,default:!1},showSourceControls:{type:Boolean,default:!0},showTargetControls:{type:Boolean,default:!0},targetListProps:{type:null,default:null},sourceListProps:{type:null,default:null},moveUpButtonProps:{type:null,default:null},moveTopButtonProps:{type:null,default:null},moveDownButtonProps:{type:null,default:null},moveBottomButtonProps:{type:null,default:null},moveToTargetProps:{type:null,default:null},moveAllToTargetProps:{type:null,default:null},moveToSourceProps:{type:null,default:null},moveAllToSourceProps:{type:null,default:null},tabindex:{type:Number,default:0}},itemTouched:!1,reorderDirection:null,styleElement:null,data(){return{d_selection:this.selection,focused:{sourceList:!1,targetList:!1},focusedOptionIndex:-1}},watch:{selection(e){this.d_selection=e}},updated(){this.reorderDirection&&(this.updateListScroll(this.$refs.sourceList.$el),this.updateListScroll(this.$refs.targetList.$el),this.reorderDirection=null)},beforeUnmount(){this.destroyStyle()},mounted(){this.responsive&&this.createStyle()},methods:{getItemKey(e,t){return this.dataKey?i.resolveFieldData(e,this.dataKey):t},isSelected(e,t){return-1!=i.findIndexInList(e,this.d_selection[t])},onListFocus(e,t){const o=l.findSingle(this.$refs[t].$el,"li.p-picklist-item.p-highlight"),s=i.findIndexInList(o,this.$refs[t].$el.children);this.focused[t]=!0;const n=-1!==this.focusedOptionIndex?this.focusedOptionIndex:o?s:-1;this.changeFocusedOptionIndex(n,t),this.$emit("focus",e)},onListBlur(e,t){this.focused[t]=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onOptionMouseDown(e,t){this.focused[t]=!0,this.focusedOptionIndex=e},moveUp(e,t){if(this.d_selection&&this.d_selection[t]){let l=[...this.modelValue[t]],o=this.d_selection[t];for(let e=0;e<o.length;e++){let t=o[e],s=i.findIndexInList(t,l);if(0===s)break;{let e=l[s],t=l[s-1];l[s-1]=e,l[s]=t}}let s=[...this.modelValue];s[t]=l,this.reorderDirection="up",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveTop(e,t){if(this.d_selection){let l=[...this.modelValue[t]],o=this.d_selection[t];for(let e=0;e<o.length;e++){let t=o[e],s=i.findIndexInList(t,l);if(0===s)break;{let e=l.splice(s,1)[0];l.unshift(e)}}let s=[...this.modelValue];s[t]=l,this.reorderDirection="top",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveDown(e,t){if(this.d_selection){let l=[...this.modelValue[t]],o=this.d_selection[t];for(let e=o.length-1;e>=0;e--){let t=o[e],s=i.findIndexInList(t,l);if(s===l.length-1)break;{let e=l[s],t=l[s+1];l[s+1]=e,l[s]=t}}let s=[...this.modelValue];s[t]=l,this.reorderDirection="down",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveBottom(e,t){if(this.d_selection){let l=[...this.modelValue[t]],o=this.d_selection[t];for(let e=o.length-1;e>=0;e--){let t=o[e],s=i.findIndexInList(t,l);if(s===l.length-1)break;{let e=l.splice(s,1)[0];l.push(e)}}let s=[...this.modelValue];s[t]=l,this.reorderDirection="bottom",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveToTarget(e){let t=this.d_selection&&this.d_selection[0]?this.d_selection[0]:null,l=[...this.modelValue[0]],o=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let s=t[e];-1==i.findIndexInList(s,o)&&o.push(l.splice(i.findIndexInList(s,l),1)[0])}let s=[...this.modelValue];s[0]=l,s[1]=o,this.$emit("update:modelValue",s),this.$emit("move-to-target",{originalEvent:e,items:t}),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToTarget(e){if(this.modelValue[0]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-target",{originalEvent:e,items:t}),i=[...i,...t],t=[];let l=[...this.modelValue];l[0]=t,l[1]=i,this.$emit("update:modelValue",l),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveToSource(e){let t=this.d_selection&&this.d_selection[1]?this.d_selection[1]:null,l=[...this.modelValue[0]],o=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let s=t[e];-1==i.findIndexInList(s,l)&&l.push(o.splice(i.findIndexInList(s,o),1)[0])}let s=[...this.modelValue];s[0]=l,s[1]=o,this.$emit("update:modelValue",s),this.$emit("move-to-source",{originalEvent:e,items:t}),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToSource(e){if(this.modelValue[1]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-source",{originalEvent:e,items:i}),t=[...t,...i],i=[];let l=[...this.modelValue];l[0]=t,l[1]=i,this.$emit("update:modelValue",l),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},onItemClick(e,t,o,s){const n=0===s?"sourceList":"targetList";this.itemTouched=!1;const r=this.d_selection[s],a=i.findIndexInList(t,this.d_selection),d=-1!=a,c=!this.itemTouched&&this.metaKeySelection,u=l.find(this.$refs[n].$el,".p-picklist-item")[o].getAttribute("id");let p;if(this.focusedOptionIndex=u,c){let i=e.metaKey||e.ctrlKey;d&&i?p=r.filter(((e,t)=>t!==a)):(p=i&&r?[...r]:[],p.push(t))}else d?p=r.filter(((e,t)=>t!==a)):(p=r?[...r]:[],p.push(t));let h=[...this.d_selection];h[s]=p,this.d_selection=h,this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})},onItemDblClick(e,t,i){0===i?this.moveToTarget(e):1===i&&this.moveToSource(e)},onItemTouchEnd(){this.itemTouched=!0},onItemKeyDown(e,t){switch(e.code){case"ArrowDown":this.onArrowDownKey(e,t);break;case"ArrowUp":this.onArrowUpKey(e,t);break;case"Home":this.onHomeKey(e,t);break;case"End":this.onEndKey(e,t);break;case"Enter":this.onEnterKey(e,t);break;case"Space":this.onSpaceKey(e,t);break;case"KeyA":e.ctrlKey&&(this.d_selection=[...this.modelValue],this.$emit("update:selection",this.d_selection))}},onArrowDownKey(e,t){const i=this.findNextOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onArrowUpKey(e,t){const i=this.findPrevOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onEnterKey(e,t){const i=l.find(this.$refs[t].$el,"li.p-picklist-item"),o=l.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...i].findIndex((e=>e===o)),n="sourceList"===t?0:1;this.onItemClick(e,this.modelValue[n][s],s,n),e.preventDefault()},onSpaceKey(e,t){if(e.preventDefault(),e.shiftKey){const e="sourceList"===t?0:1,o=l.find(this.$refs[t].$el,"li.p-picklist-item"),s=i.findIndexInList(this.d_selection[e][0],[...this.modelValue[e]]),n=l.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),r=[...o].findIndex((e=>e===n));this.d_selection[e]=[...this.modelValue[e]].slice(Math.min(s,r),Math.max(s,r)+1),this.$emit("update:selection",this.d_selection)}else this.onEnterKey(e,t)},onHomeKey(e,t){if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,i=l.find(this.$refs[t].$el,"li.p-picklist-item"),o=l.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...i].findIndex((e=>e===o));this.d_selection[e]=[...this.modelValue[e]].slice(0,s+1),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(0,t);e.preventDefault()},onEndKey(e,t){const i=l.find(this.$refs[t].$el,"li.p-picklist-item");if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,o=l.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...i].findIndex((e=>e===o));this.d_selection[e]=[...this.modelValue[e]].slice(s,i.length),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(i.length-1,t);e.preventDefault()},findNextOptionIndex(e,t){const i=[...l.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return i>-1?i+1:0},findPrevOptionIndex(e,t){const i=[...l.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return i>-1?i-1:0},changeFocusedOptionIndex(e,t){const i=l.find(this.$refs[t].$el,"li.p-picklist-item");let o=e>=i.length?i.length-1:e<0?0:e;this.focusedOptionIndex=i[o].getAttribute("id"),this.scrollInView(i[o].getAttribute("id"),t)},scrollInView(e,t){const i=l.findSingle(this.$refs[t].$el,`li[id="${e}"]`);i&&i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"start"})},updateListScroll(e){const t=l.find(e,".p-picklist-item.p-highlight");if(t&&t.length)switch(this.reorderDirection){case"up":l.scrollInView(e,t[0]);break;case"top":e.scrollTop=0;break;case"down":l.scrollInView(e,t[t.length-1]);break;case"bottom":e.scrollTop=e.scrollHeight}},createStyle(){if(!this.styleElement){this.$el.setAttribute(this.attributeSelector,""),this.styleElement=document.createElement("style"),this.styleElement.type="text/css",document.head.appendChild(this.styleElement);let e=`\n@media screen and (max-width: ${this.breakpoint}) {\n .p-picklist[${this.attributeSelector}] {\n flex-direction: column;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons {\n padding: var(--content-padding);\n flex-direction: row;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button {\n margin-right: var(--inline-spacing);\n margin-bottom: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button:last-child {\n margin-right: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-right:before {\n content: "\\e930"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-right:before {\n content: "\\e92c"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-left:before {\n content: "\\e933"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-left:before {\n content: "\\e92f"\n }\n}\n`;this.styleElement.innerHTML=e}},destroyStyle(){this.styleElement&&(document.head.removeChild(this.styleElement),this.styleElement=null)},moveDisabled(e){if(!this.d_selection[e]||!this.d_selection[e].length)return!0},moveAllDisabled(e){return i.isEmpty(this[e])},moveSourceDisabled(){return i.isEmpty(this.targetList)},itemClass(e,t,i){return["p-picklist-item",{"p-highlight":this.isSelected(e,i),"p-focus":t===this.focusedOptionId}]}},computed:{idSource(){return this.$attrs.id||o()},idTarget(){return this.$attrs.id||o()},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null},containerClass(){return["p-picklist p-component",{"p-picklist-striped":this.stripedRows}]},sourceList(){return this.modelValue&&this.modelValue[0]?this.modelValue[0]:null},targetList(){return this.modelValue&&this.modelValue[1]?this.modelValue[1]:null},attributeSelector:()=>o(),moveUpAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveUp:void 0},moveTopAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveTop:void 0},moveDownAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveDown:void 0},moveBottomAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveBottom:void 0},moveToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToTarget:void 0},moveAllToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToTarget:void 0},moveToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToSource:void 0},moveAllToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToSource:void 0}},components:{PLButton:e},directives:{ripple:t}};const k={key:0,class:"p-picklist-buttons p-picklist-source-controls"},I={class:"p-picklist-list-wrapper p-picklist-source-wrapper"},L={key:0,class:"p-picklist-header"},T=["id","onClick","onDblclick","onMousedown","aria-selected"],x={class:"p-picklist-buttons p-picklist-transfer-buttons"},w={class:"p-picklist-list-wrapper p-picklist-target-wrapper"},S={key:0,class:"p-picklist-header"},D=["id","onClick","onDblclick","onMousedown","aria-selected"],_={key:1,class:"p-picklist-buttons p-picklist-target-controls"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var l=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&l.firstChild?l.insertBefore(o,l.firstChild):l.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("\n.p-picklist {\n display: flex;\n}\n.p-picklist-buttons {\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n.p-picklist-list-wrapper {\n flex: 1 1 50%;\n}\n.p-picklist-list {\n list-style-type: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n min-height: 12rem;\n max-height: 24rem;\n}\n.p-picklist-item {\n cursor: pointer;\n overflow: hidden;\n position: relative;\n}\n.p-picklist-item.p-picklist-flip-enter-active.p-picklist-flip-enter-to,\n.p-picklist-item.p-picklist-flip-leave-active.p-picklist-flip-leave-to {\n transition: none !important;\n}\n"),$.render=function(e,t,i,l,o,$){const A=s("PLButton"),V=n("ripple");return r(),a("div",{class:d($.containerClass)},[i.showSourceControls?(r(),a("div",k,[c(e.$slots,"sourcecontrolsstart"),u(A,p({"aria-label":$.moveUpAriaLabel,disabled:$.moveDisabled(0)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[0]||(t[0]=e=>$.moveUp(e,0))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveTopAriaLabel,disabled:$.moveDisabled(0)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[1]||(t[1]=e=>$.moveTop(e,0))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveDownAriaLabel,disabled:$.moveDisabled(0)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[2]||(t[2]=e=>$.moveDown(e,0))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveBottomAriaLabel,disabled:$.moveDisabled(0)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[3]||(t[3]=e=>$.moveBottom(e,0))}),null,16,["aria-label","disabled"]),c(e.$slots,"sourcecontrolsend")])):h("",!0),m("div",I,[e.$slots.sourceheader?(r(),a("div",L,[c(e.$slots,"sourceheader")])):h("",!0),u(f,p({ref:"sourceList",id:$.idSource+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-source",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":o.focused.sourceList?$.focusedOptionId:void 0,tabindex:$.sourceList&&$.sourceList.length>0?i.tabindex:-1,onFocus:t[5]||(t[5]=e=>$.onListFocus(e,"sourceList")),onBlur:t[6]||(t[6]=e=>$.onListBlur(e,"sourceList")),onKeydown:t[7]||(t[7]=e=>$.onItemKeyDown(e,"sourceList"))},i.sourceListProps),{default:v((()=>[(r(!0),a(b,null,g($.sourceList,((i,l)=>y((r(),a("li",{key:$.getItemKey(i,l),id:$.idSource+"_"+l,class:d($.itemClass(i,`${$.idSource}_${l}`,0)),onClick:e=>$.onItemClick(e,i,l,0),onDblclick:e=>$.onItemDblClick(e,i,0),onTouchend:t[4]||(t[4]=(...e)=>$.onItemTouchEnd&&$.onItemTouchEnd(...e)),onMousedown:e=>$.onOptionMouseDown(l,"sourceList"),role:"option","aria-selected":$.isSelected(i,0)},[c(e.$slots,"item",{item:i,index:l})],42,T)),[[V]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),m("div",x,[c(e.$slots,"movecontrolsstart"),u(A,p({"aria-label":$.moveToTargetAriaLabel,type:"button",icon:"pi pi-angle-right",onClick:$.moveToTarget,disabled:$.moveDisabled(0)},i.moveToTargetProps),null,16,["aria-label","onClick","disabled"]),u(A,p({"aria-label":$.moveAllToTargetAriaLabel,type:"button",icon:"pi pi-angle-double-right",onClick:$.moveAllToTarget,disabled:$.moveAllDisabled("sourceList")},i.moveAllToTargetProps),null,16,["aria-label","onClick","disabled"]),u(A,p({"aria-label":$.moveToSourceAriaLabel,type:"button",icon:"pi pi-angle-left",onClick:$.moveToSource,disabled:$.moveDisabled(1)},i.moveToSourceProps),null,16,["aria-label","onClick","disabled"]),u(A,p({"aria-label":$.moveAllToSourceAriaLabel,type:"button",icon:"pi pi-angle-double-left",onClick:$.moveAllToSource,disabled:$.moveSourceDisabled("targetList")},i.moveAllToSourceProps),null,16,["aria-label","onClick","disabled"]),c(e.$slots,"movecontrolsend")]),m("div",w,[e.$slots.targetheader?(r(),a("div",S,[c(e.$slots,"targetheader")])):h("",!0),u(f,p({ref:"targetList",id:$.idTarget+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-target",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":o.focused.targetList?$.focusedOptionId:void 0,tabindex:$.targetList&&$.targetList.length>0?i.tabindex:-1,onFocus:t[10]||(t[10]=e=>$.onListFocus(e,"targetList")),onBlur:t[11]||(t[11]=e=>$.onListBlur(e,"targetList")),onKeydown:t[12]||(t[12]=e=>$.onItemKeyDown(e,"targetList"))},i.targetListProps),{default:v((()=>[(r(!0),a(b,null,g($.targetList,((i,l)=>y((r(),a("li",{key:$.getItemKey(i,l),id:$.idTarget+"_"+l,class:d($.itemClass(i,`${$.idTarget}_${l}`,1)),onClick:e=>$.onItemClick(e,i,l,1),onDblclick:e=>$.onItemDblClick(e,i,1),onKeydown:t[8]||(t[8]=e=>$.onItemKeyDown(e,"targetList")),onMousedown:e=>$.onOptionMouseDown(l,"targetList"),onTouchend:t[9]||(t[9]=(...e)=>$.onItemTouchEnd&&$.onItemTouchEnd(...e)),role:"option","aria-selected":$.isSelected(i,1)},[c(e.$slots,"item",{item:i,index:l})],42,D)),[[V]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),i.showTargetControls?(r(),a("div",_,[c(e.$slots,"targetcontrolsstart"),u(A,p({"aria-label":$.moveUpAriaLabel,disabled:$.moveDisabled(1)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[13]||(t[13]=e=>$.moveUp(e,1))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveTopAriaLabel,disabled:$.moveDisabled(1)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[14]||(t[14]=e=>$.moveTop(e,1))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveDownAriaLabel,disabled:$.moveDisabled(1)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[15]||(t[15]=e=>$.moveDown(e,1))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveBottomAriaLabel,disabled:$.moveDisabled(1)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[16]||(t[16]=e=>$.moveBottom(e,1))}),null,16,["aria-label","disabled"]),c(e.$slots,"targetcontrolsend")])):h("",!0)],2)};export{$ as default};
1
+ import e from"primevue/button";import t from"primevue/ripple";import{UniqueComponentId as i,ObjectUtils as l,DomHandler as o}from"primevue/utils";import{resolveComponent as s,resolveDirective as n,openBlock as r,createElementBlock as a,normalizeClass as d,renderSlot as c,createVNode as u,mergeProps as p,createCommentVNode as h,createElementVNode as m,TransitionGroup as f,withCtx as v,Fragment as b,renderList as g,withDirectives as y}from"vue";var $={name:"PickList",emits:["update:modelValue","reorder","update:selection","selection-change","move-to-target","move-to-source","move-all-to-target","move-all-to-source","focus","blur"],props:{modelValue:{type:Array,default:()=>[[],[]]},selection:{type:Array,default:()=>[[],[]]},dataKey:{type:String,default:null},listStyle:{type:null,default:null},metaKeySelection:{type:Boolean,default:!0},responsive:{type:Boolean,default:!0},breakpoint:{type:String,default:"960px"},stripedRows:{type:Boolean,default:!1},showSourceControls:{type:Boolean,default:!0},showTargetControls:{type:Boolean,default:!0},targetListProps:{type:null,default:null},sourceListProps:{type:null,default:null},moveUpButtonProps:{type:null,default:null},moveTopButtonProps:{type:null,default:null},moveDownButtonProps:{type:null,default:null},moveBottomButtonProps:{type:null,default:null},moveToTargetProps:{type:null,default:null},moveAllToTargetProps:{type:null,default:null},moveToSourceProps:{type:null,default:null},moveAllToSourceProps:{type:null,default:null},tabindex:{type:Number,default:0}},itemTouched:!1,reorderDirection:null,styleElement:null,data(){return{id:this.$attrs.id,d_selection:this.selection,focused:{sourceList:!1,targetList:!1},focusedOptionIndex:-1}},watch:{"$attrs.id":function(e){this.id=e||i()},selection(e){this.d_selection=e}},updated(){this.reorderDirection&&(this.updateListScroll(this.$refs.sourceList.$el),this.updateListScroll(this.$refs.targetList.$el),this.reorderDirection=null)},beforeUnmount(){this.destroyStyle()},mounted(){this.id=this.id||i(),this.responsive&&this.createStyle()},methods:{getItemKey(e,t){return this.dataKey?l.resolveFieldData(e,this.dataKey):t},isSelected(e,t){return-1!=l.findIndexInList(e,this.d_selection[t])},onListFocus(e,t){const i=o.findSingle(this.$refs[t].$el,"li.p-picklist-item.p-highlight"),s=l.findIndexInList(i,this.$refs[t].$el.children);this.focused[t]=!0;const n=-1!==this.focusedOptionIndex?this.focusedOptionIndex:i?s:-1;this.changeFocusedOptionIndex(n,t),this.$emit("focus",e)},onListBlur(e,t){this.focused[t]=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onOptionMouseDown(e,t){this.focused[t]=!0,this.focusedOptionIndex=e},moveUp(e,t){if(this.d_selection&&this.d_selection[t]){let i=[...this.modelValue[t]],o=this.d_selection[t];for(let e=0;e<o.length;e++){let t=o[e],s=l.findIndexInList(t,i);if(0===s)break;{let e=i[s],t=i[s-1];i[s-1]=e,i[s]=t}}let s=[...this.modelValue];s[t]=i,this.reorderDirection="up",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveTop(e,t){if(this.d_selection){let i=[...this.modelValue[t]],o=this.d_selection[t];for(let e=0;e<o.length;e++){let t=o[e],s=l.findIndexInList(t,i);if(0===s)break;{let e=i.splice(s,1)[0];i.unshift(e)}}let s=[...this.modelValue];s[t]=i,this.reorderDirection="top",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveDown(e,t){if(this.d_selection){let i=[...this.modelValue[t]],o=this.d_selection[t];for(let e=o.length-1;e>=0;e--){let t=o[e],s=l.findIndexInList(t,i);if(s===i.length-1)break;{let e=i[s],t=i[s+1];i[s+1]=e,i[s]=t}}let s=[...this.modelValue];s[t]=i,this.reorderDirection="down",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveBottom(e,t){if(this.d_selection){let i=[...this.modelValue[t]],o=this.d_selection[t];for(let e=o.length-1;e>=0;e--){let t=o[e],s=l.findIndexInList(t,i);if(s===i.length-1)break;{let e=i.splice(s,1)[0];i.push(e)}}let s=[...this.modelValue];s[t]=i,this.reorderDirection="bottom",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveToTarget(e){let t=this.d_selection&&this.d_selection[0]?this.d_selection[0]:null,i=[...this.modelValue[0]],o=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let s=t[e];-1==l.findIndexInList(s,o)&&o.push(i.splice(l.findIndexInList(s,i),1)[0])}let s=[...this.modelValue];s[0]=i,s[1]=o,this.$emit("update:modelValue",s),this.$emit("move-to-target",{originalEvent:e,items:t}),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToTarget(e){if(this.modelValue[0]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-target",{originalEvent:e,items:t}),i=[...i,...t],t=[];let l=[...this.modelValue];l[0]=t,l[1]=i,this.$emit("update:modelValue",l),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveToSource(e){let t=this.d_selection&&this.d_selection[1]?this.d_selection[1]:null,i=[...this.modelValue[0]],o=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let s=t[e];-1==l.findIndexInList(s,i)&&i.push(o.splice(l.findIndexInList(s,o),1)[0])}let s=[...this.modelValue];s[0]=i,s[1]=o,this.$emit("update:modelValue",s),this.$emit("move-to-source",{originalEvent:e,items:t}),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToSource(e){if(this.modelValue[1]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-source",{originalEvent:e,items:i}),t=[...t,...i],i=[];let l=[...this.modelValue];l[0]=t,l[1]=i,this.$emit("update:modelValue",l),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},onItemClick(e,t,i,s){const n=0===s?"sourceList":"targetList";this.itemTouched=!1;const r=this.d_selection[s],a=l.findIndexInList(t,this.d_selection),d=-1!=a,c=!this.itemTouched&&this.metaKeySelection,u=o.find(this.$refs[n].$el,".p-picklist-item")[i].getAttribute("id");let p;if(this.focusedOptionIndex=u,c){let i=e.metaKey||e.ctrlKey;d&&i?p=r.filter(((e,t)=>t!==a)):(p=i&&r?[...r]:[],p.push(t))}else d?p=r.filter(((e,t)=>t!==a)):(p=r?[...r]:[],p.push(t));let h=[...this.d_selection];h[s]=p,this.d_selection=h,this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})},onItemDblClick(e,t,i){0===i?this.moveToTarget(e):1===i&&this.moveToSource(e)},onItemTouchEnd(){this.itemTouched=!0},onItemKeyDown(e,t){switch(e.code){case"ArrowDown":this.onArrowDownKey(e,t);break;case"ArrowUp":this.onArrowUpKey(e,t);break;case"Home":this.onHomeKey(e,t);break;case"End":this.onEndKey(e,t);break;case"Enter":this.onEnterKey(e,t);break;case"Space":this.onSpaceKey(e,t);break;case"KeyA":e.ctrlKey&&(this.d_selection=[...this.modelValue],this.$emit("update:selection",this.d_selection))}},onArrowDownKey(e,t){const i=this.findNextOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onArrowUpKey(e,t){const i=this.findPrevOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onEnterKey(e,t){const i=o.find(this.$refs[t].$el,"li.p-picklist-item"),l=o.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...i].findIndex((e=>e===l)),n="sourceList"===t?0:1;this.onItemClick(e,this.modelValue[n][s],s,n),e.preventDefault()},onSpaceKey(e,t){if(e.preventDefault(),e.shiftKey){const e="sourceList"===t?0:1,i=o.find(this.$refs[t].$el,"li.p-picklist-item"),s=l.findIndexInList(this.d_selection[e][0],[...this.modelValue[e]]),n=o.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),r=[...i].findIndex((e=>e===n));this.d_selection[e]=[...this.modelValue[e]].slice(Math.min(s,r),Math.max(s,r)+1),this.$emit("update:selection",this.d_selection)}else this.onEnterKey(e,t)},onHomeKey(e,t){if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,i=o.find(this.$refs[t].$el,"li.p-picklist-item"),l=o.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...i].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(0,s+1),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(0,t);e.preventDefault()},onEndKey(e,t){const i=o.find(this.$refs[t].$el,"li.p-picklist-item");if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,l=o.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...i].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(s,i.length),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(i.length-1,t);e.preventDefault()},findNextOptionIndex(e,t){const i=[...o.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return i>-1?i+1:0},findPrevOptionIndex(e,t){const i=[...o.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return i>-1?i-1:0},changeFocusedOptionIndex(e,t){const i=o.find(this.$refs[t].$el,"li.p-picklist-item");let l=e>=i.length?i.length-1:e<0?0:e;this.focusedOptionIndex=i[l].getAttribute("id"),this.scrollInView(i[l].getAttribute("id"),t)},scrollInView(e,t){const i=o.findSingle(this.$refs[t].$el,`li[id="${e}"]`);i&&i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"start"})},updateListScroll(e){const t=o.find(e,".p-picklist-item.p-highlight");if(t&&t.length)switch(this.reorderDirection){case"up":o.scrollInView(e,t[0]);break;case"top":e.scrollTop=0;break;case"down":o.scrollInView(e,t[t.length-1]);break;case"bottom":e.scrollTop=e.scrollHeight}},createStyle(){if(!this.styleElement){this.$el.setAttribute(this.attributeSelector,""),this.styleElement=document.createElement("style"),this.styleElement.type="text/css",document.head.appendChild(this.styleElement);let e=`\n@media screen and (max-width: ${this.breakpoint}) {\n .p-picklist[${this.attributeSelector}] {\n flex-direction: column;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons {\n padding: var(--content-padding);\n flex-direction: row;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button {\n margin-right: var(--inline-spacing);\n margin-bottom: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button:last-child {\n margin-right: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-right:before {\n content: "\\e930"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-right:before {\n content: "\\e92c"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-left:before {\n content: "\\e933"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-left:before {\n content: "\\e92f"\n }\n}\n`;this.styleElement.innerHTML=e}},destroyStyle(){this.styleElement&&(document.head.removeChild(this.styleElement),this.styleElement=null)},moveDisabled(e){if(!this.d_selection[e]||!this.d_selection[e].length)return!0},moveAllDisabled(e){return l.isEmpty(this[e])},moveSourceDisabled(){return l.isEmpty(this.targetList)},itemClass(e,t,i){return["p-picklist-item",{"p-highlight":this.isSelected(e,i),"p-focus":t===this.focusedOptionId}]}},computed:{idSource(){return`${this.id}_source`},idTarget(){return`${this.id}_target`},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null},containerClass(){return["p-picklist p-component",{"p-picklist-striped":this.stripedRows}]},sourceList(){return this.modelValue&&this.modelValue[0]?this.modelValue[0]:null},targetList(){return this.modelValue&&this.modelValue[1]?this.modelValue[1]:null},attributeSelector:()=>i(),moveUpAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveUp:void 0},moveTopAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveTop:void 0},moveDownAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveDown:void 0},moveBottomAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveBottom:void 0},moveToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToTarget:void 0},moveAllToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToTarget:void 0},moveToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToSource:void 0},moveAllToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToSource:void 0}},components:{PLButton:e},directives:{ripple:t}};const k={key:0,class:"p-picklist-buttons p-picklist-source-controls"},I={class:"p-picklist-list-wrapper p-picklist-source-wrapper"},L={key:0,class:"p-picklist-header"},T=["id","onClick","onDblclick","onMousedown","aria-selected"],x={class:"p-picklist-buttons p-picklist-transfer-buttons"},w={class:"p-picklist-list-wrapper p-picklist-target-wrapper"},S={key:0,class:"p-picklist-header"},D=["id","onClick","onDblclick","onMousedown","aria-selected"],_={key:1,class:"p-picklist-buttons p-picklist-target-controls"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var l=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&l.firstChild?l.insertBefore(o,l.firstChild):l.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("\n.p-picklist {\n display: flex;\n}\n.p-picklist-buttons {\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n.p-picklist-list-wrapper {\n flex: 1 1 50%;\n}\n.p-picklist-list {\n list-style-type: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n min-height: 12rem;\n max-height: 24rem;\n}\n.p-picklist-item {\n cursor: pointer;\n overflow: hidden;\n position: relative;\n}\n.p-picklist-item.p-picklist-flip-enter-active.p-picklist-flip-enter-to,\n.p-picklist-item.p-picklist-flip-leave-active.p-picklist-flip-leave-to {\n transition: none !important;\n}\n"),$.render=function(e,t,i,l,o,$){const A=s("PLButton"),V=n("ripple");return r(),a("div",{class:d($.containerClass)},[i.showSourceControls?(r(),a("div",k,[c(e.$slots,"sourcecontrolsstart"),u(A,p({"aria-label":$.moveUpAriaLabel,disabled:$.moveDisabled(0)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[0]||(t[0]=e=>$.moveUp(e,0))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveTopAriaLabel,disabled:$.moveDisabled(0)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[1]||(t[1]=e=>$.moveTop(e,0))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveDownAriaLabel,disabled:$.moveDisabled(0)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[2]||(t[2]=e=>$.moveDown(e,0))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveBottomAriaLabel,disabled:$.moveDisabled(0)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[3]||(t[3]=e=>$.moveBottom(e,0))}),null,16,["aria-label","disabled"]),c(e.$slots,"sourcecontrolsend")])):h("",!0),m("div",I,[e.$slots.sourceheader?(r(),a("div",L,[c(e.$slots,"sourceheader")])):h("",!0),u(f,p({ref:"sourceList",id:$.idSource+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-source",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":o.focused.sourceList?$.focusedOptionId:void 0,tabindex:$.sourceList&&$.sourceList.length>0?i.tabindex:-1,onFocus:t[5]||(t[5]=e=>$.onListFocus(e,"sourceList")),onBlur:t[6]||(t[6]=e=>$.onListBlur(e,"sourceList")),onKeydown:t[7]||(t[7]=e=>$.onItemKeyDown(e,"sourceList"))},i.sourceListProps),{default:v((()=>[(r(!0),a(b,null,g($.sourceList,((i,l)=>y((r(),a("li",{key:$.getItemKey(i,l),id:$.idSource+"_"+l,class:d($.itemClass(i,`${$.idSource}_${l}`,0)),onClick:e=>$.onItemClick(e,i,l,0),onDblclick:e=>$.onItemDblClick(e,i,0),onTouchend:t[4]||(t[4]=(...e)=>$.onItemTouchEnd&&$.onItemTouchEnd(...e)),onMousedown:e=>$.onOptionMouseDown(l,"sourceList"),role:"option","aria-selected":$.isSelected(i,0)},[c(e.$slots,"item",{item:i,index:l})],42,T)),[[V]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),m("div",x,[c(e.$slots,"movecontrolsstart"),u(A,p({"aria-label":$.moveToTargetAriaLabel,type:"button",icon:"pi pi-angle-right",onClick:$.moveToTarget,disabled:$.moveDisabled(0)},i.moveToTargetProps),null,16,["aria-label","onClick","disabled"]),u(A,p({"aria-label":$.moveAllToTargetAriaLabel,type:"button",icon:"pi pi-angle-double-right",onClick:$.moveAllToTarget,disabled:$.moveAllDisabled("sourceList")},i.moveAllToTargetProps),null,16,["aria-label","onClick","disabled"]),u(A,p({"aria-label":$.moveToSourceAriaLabel,type:"button",icon:"pi pi-angle-left",onClick:$.moveToSource,disabled:$.moveDisabled(1)},i.moveToSourceProps),null,16,["aria-label","onClick","disabled"]),u(A,p({"aria-label":$.moveAllToSourceAriaLabel,type:"button",icon:"pi pi-angle-double-left",onClick:$.moveAllToSource,disabled:$.moveSourceDisabled("targetList")},i.moveAllToSourceProps),null,16,["aria-label","onClick","disabled"]),c(e.$slots,"movecontrolsend")]),m("div",w,[e.$slots.targetheader?(r(),a("div",S,[c(e.$slots,"targetheader")])):h("",!0),u(f,p({ref:"targetList",id:$.idTarget+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-target",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":o.focused.targetList?$.focusedOptionId:void 0,tabindex:$.targetList&&$.targetList.length>0?i.tabindex:-1,onFocus:t[10]||(t[10]=e=>$.onListFocus(e,"targetList")),onBlur:t[11]||(t[11]=e=>$.onListBlur(e,"targetList")),onKeydown:t[12]||(t[12]=e=>$.onItemKeyDown(e,"targetList"))},i.targetListProps),{default:v((()=>[(r(!0),a(b,null,g($.targetList,((i,l)=>y((r(),a("li",{key:$.getItemKey(i,l),id:$.idTarget+"_"+l,class:d($.itemClass(i,`${$.idTarget}_${l}`,1)),onClick:e=>$.onItemClick(e,i,l,1),onDblclick:e=>$.onItemDblClick(e,i,1),onKeydown:t[8]||(t[8]=e=>$.onItemKeyDown(e,"targetList")),onMousedown:e=>$.onOptionMouseDown(l,"targetList"),onTouchend:t[9]||(t[9]=(...e)=>$.onItemTouchEnd&&$.onItemTouchEnd(...e)),role:"option","aria-selected":$.isSelected(i,1)},[c(e.$slots,"item",{item:i,index:l})],42,D)),[[V]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),i.showTargetControls?(r(),a("div",_,[c(e.$slots,"targetcontrolsstart"),u(A,p({"aria-label":$.moveUpAriaLabel,disabled:$.moveDisabled(1)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[13]||(t[13]=e=>$.moveUp(e,1))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveTopAriaLabel,disabled:$.moveDisabled(1)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[14]||(t[14]=e=>$.moveTop(e,1))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveDownAriaLabel,disabled:$.moveDisabled(1)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[15]||(t[15]=e=>$.moveDown(e,1))}),null,16,["aria-label","disabled"]),u(A,p({"aria-label":$.moveBottomAriaLabel,disabled:$.moveDisabled(1)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[16]||(t[16]=e=>$.moveBottom(e,1))}),null,16,["aria-label","disabled"]),c(e.$slots,"targetcontrolsend")])):h("",!0)],2)};export{$ as default};
@@ -101,6 +101,7 @@ this.primevue.picklist = (function (Button, Ripple, utils, vue) {
101
101
  styleElement: null,
102
102
  data() {
103
103
  return {
104
+ id: this.$attrs.id,
104
105
  d_selection: this.selection,
105
106
  focused: {
106
107
  sourceList: false,
@@ -110,6 +111,9 @@ this.primevue.picklist = (function (Button, Ripple, utils, vue) {
110
111
  };
111
112
  },
112
113
  watch: {
114
+ '$attrs.id': function (newValue) {
115
+ this.id = newValue || utils.UniqueComponentId();
116
+ },
113
117
  selection(newValue) {
114
118
  this.d_selection = newValue;
115
119
  }
@@ -125,6 +129,8 @@ this.primevue.picklist = (function (Button, Ripple, utils, vue) {
125
129
  this.destroyStyle();
126
130
  },
127
131
  mounted() {
132
+ this.id = this.id || utils.UniqueComponentId();
133
+
128
134
  if (this.responsive) {
129
135
  this.createStyle();
130
136
  }
@@ -691,10 +697,10 @@ this.primevue.picklist = (function (Button, Ripple, utils, vue) {
691
697
  },
692
698
  computed: {
693
699
  idSource() {
694
- return this.$attrs.id || utils.UniqueComponentId();
700
+ return `${this.id}_source`;
695
701
  },
696
702
  idTarget() {
697
- return this.$attrs.id || utils.UniqueComponentId();
703
+ return `${this.id}_target`;
698
704
  },
699
705
  focusedOptionId() {
700
706
  return this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : null;
@@ -1 +1 @@
1
- this.primevue=this.primevue||{},this.primevue.picklist=function(e,t,i,o){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=l(e),s=l(t),r={name:"PickList",emits:["update:modelValue","reorder","update:selection","selection-change","move-to-target","move-to-source","move-all-to-target","move-all-to-source","focus","blur"],props:{modelValue:{type:Array,default:()=>[[],[]]},selection:{type:Array,default:()=>[[],[]]},dataKey:{type:String,default:null},listStyle:{type:null,default:null},metaKeySelection:{type:Boolean,default:!0},responsive:{type:Boolean,default:!0},breakpoint:{type:String,default:"960px"},stripedRows:{type:Boolean,default:!1},showSourceControls:{type:Boolean,default:!0},showTargetControls:{type:Boolean,default:!0},targetListProps:{type:null,default:null},sourceListProps:{type:null,default:null},moveUpButtonProps:{type:null,default:null},moveTopButtonProps:{type:null,default:null},moveDownButtonProps:{type:null,default:null},moveBottomButtonProps:{type:null,default:null},moveToTargetProps:{type:null,default:null},moveAllToTargetProps:{type:null,default:null},moveToSourceProps:{type:null,default:null},moveAllToSourceProps:{type:null,default:null},tabindex:{type:Number,default:0}},itemTouched:!1,reorderDirection:null,styleElement:null,data(){return{d_selection:this.selection,focused:{sourceList:!1,targetList:!1},focusedOptionIndex:-1}},watch:{selection(e){this.d_selection=e}},updated(){this.reorderDirection&&(this.updateListScroll(this.$refs.sourceList.$el),this.updateListScroll(this.$refs.targetList.$el),this.reorderDirection=null)},beforeUnmount(){this.destroyStyle()},mounted(){this.responsive&&this.createStyle()},methods:{getItemKey(e,t){return this.dataKey?i.ObjectUtils.resolveFieldData(e,this.dataKey):t},isSelected(e,t){return-1!=i.ObjectUtils.findIndexInList(e,this.d_selection[t])},onListFocus(e,t){const o=i.DomHandler.findSingle(this.$refs[t].$el,"li.p-picklist-item.p-highlight"),l=i.ObjectUtils.findIndexInList(o,this.$refs[t].$el.children);this.focused[t]=!0;const n=-1!==this.focusedOptionIndex?this.focusedOptionIndex:o?l:-1;this.changeFocusedOptionIndex(n,t),this.$emit("focus",e)},onListBlur(e,t){this.focused[t]=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onOptionMouseDown(e,t){this.focused[t]=!0,this.focusedOptionIndex=e},moveUp(e,t){if(this.d_selection&&this.d_selection[t]){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=0;e<l.length;e++){let t=l[e],n=i.ObjectUtils.findIndexInList(t,o);if(0===n)break;{let e=o[n],t=o[n-1];o[n-1]=e,o[n]=t}}let n=[...this.modelValue];n[t]=o,this.reorderDirection="up",this.$emit("update:modelValue",n),this.$emit("reorder",{originalEvent:e,value:n,direction:this.reorderDirection,listIndex:t})}},moveTop(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=0;e<l.length;e++){let t=l[e],n=i.ObjectUtils.findIndexInList(t,o);if(0===n)break;{let e=o.splice(n,1)[0];o.unshift(e)}}let n=[...this.modelValue];n[t]=o,this.reorderDirection="top",this.$emit("update:modelValue",n),this.$emit("reorder",{originalEvent:e,value:n,direction:this.reorderDirection,listIndex:t})}},moveDown(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=l.length-1;e>=0;e--){let t=l[e],n=i.ObjectUtils.findIndexInList(t,o);if(n===o.length-1)break;{let e=o[n],t=o[n+1];o[n+1]=e,o[n]=t}}let n=[...this.modelValue];n[t]=o,this.reorderDirection="down",this.$emit("update:modelValue",n),this.$emit("reorder",{originalEvent:e,value:n,direction:this.reorderDirection,listIndex:t})}},moveBottom(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=l.length-1;e>=0;e--){let t=l[e],n=i.ObjectUtils.findIndexInList(t,o);if(n===o.length-1)break;{let e=o.splice(n,1)[0];o.push(e)}}let n=[...this.modelValue];n[t]=o,this.reorderDirection="bottom",this.$emit("update:modelValue",n),this.$emit("reorder",{originalEvent:e,value:n,direction:this.reorderDirection,listIndex:t})}},moveToTarget(e){let t=this.d_selection&&this.d_selection[0]?this.d_selection[0]:null,o=[...this.modelValue[0]],l=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let n=t[e];-1==i.ObjectUtils.findIndexInList(n,l)&&l.push(o.splice(i.ObjectUtils.findIndexInList(n,o),1)[0])}let n=[...this.modelValue];n[0]=o,n[1]=l,this.$emit("update:modelValue",n),this.$emit("move-to-target",{originalEvent:e,items:t}),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToTarget(e){if(this.modelValue[0]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-target",{originalEvent:e,items:t}),i=[...i,...t],t=[];let o=[...this.modelValue];o[0]=t,o[1]=i,this.$emit("update:modelValue",o),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveToSource(e){let t=this.d_selection&&this.d_selection[1]?this.d_selection[1]:null,o=[...this.modelValue[0]],l=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let n=t[e];-1==i.ObjectUtils.findIndexInList(n,o)&&o.push(l.splice(i.ObjectUtils.findIndexInList(n,l),1)[0])}let n=[...this.modelValue];n[0]=o,n[1]=l,this.$emit("update:modelValue",n),this.$emit("move-to-source",{originalEvent:e,items:t}),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToSource(e){if(this.modelValue[1]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-source",{originalEvent:e,items:i}),t=[...t,...i],i=[];let o=[...this.modelValue];o[0]=t,o[1]=i,this.$emit("update:modelValue",o),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},onItemClick(e,t,o,l){const n=0===l?"sourceList":"targetList";this.itemTouched=!1;const s=this.d_selection[l],r=i.ObjectUtils.findIndexInList(t,this.d_selection),a=-1!=r,d=!this.itemTouched&&this.metaKeySelection,c=i.DomHandler.find(this.$refs[n].$el,".p-picklist-item")[o].getAttribute("id");let u;if(this.focusedOptionIndex=c,d){let i=e.metaKey||e.ctrlKey;a&&i?u=s.filter(((e,t)=>t!==r)):(u=i&&s?[...s]:[],u.push(t))}else a?u=s.filter(((e,t)=>t!==r)):(u=s?[...s]:[],u.push(t));let p=[...this.d_selection];p[l]=u,this.d_selection=p,this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})},onItemDblClick(e,t,i){0===i?this.moveToTarget(e):1===i&&this.moveToSource(e)},onItemTouchEnd(){this.itemTouched=!0},onItemKeyDown(e,t){switch(e.code){case"ArrowDown":this.onArrowDownKey(e,t);break;case"ArrowUp":this.onArrowUpKey(e,t);break;case"Home":this.onHomeKey(e,t);break;case"End":this.onEndKey(e,t);break;case"Enter":this.onEnterKey(e,t);break;case"Space":this.onSpaceKey(e,t);break;case"KeyA":e.ctrlKey&&(this.d_selection=[...this.modelValue],this.$emit("update:selection",this.d_selection))}},onArrowDownKey(e,t){const i=this.findNextOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onArrowUpKey(e,t){const i=this.findPrevOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onEnterKey(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),n=[...o].findIndex((e=>e===l)),s="sourceList"===t?0:1;this.onItemClick(e,this.modelValue[s][n],n,s),e.preventDefault()},onSpaceKey(e,t){if(e.preventDefault(),e.shiftKey){const e="sourceList"===t?0:1,o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.ObjectUtils.findIndexInList(this.d_selection[e][0],[...this.modelValue[e]]),n=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...o].findIndex((e=>e===n));this.d_selection[e]=[...this.modelValue[e]].slice(Math.min(l,s),Math.max(l,s)+1),this.$emit("update:selection",this.d_selection)}else this.onEnterKey(e,t)},onHomeKey(e,t){if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),n=[...o].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(0,n+1),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(0,t);e.preventDefault()},onEndKey(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item");if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),n=[...o].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(n,o.length),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(o.length-1,t);e.preventDefault()},findNextOptionIndex(e,t){const o=[...i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return o>-1?o+1:0},findPrevOptionIndex(e,t){const o=[...i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return o>-1?o-1:0},changeFocusedOptionIndex(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item");let l=e>=o.length?o.length-1:e<0?0:e;this.focusedOptionIndex=o[l].getAttribute("id"),this.scrollInView(o[l].getAttribute("id"),t)},scrollInView(e,t){const o=i.DomHandler.findSingle(this.$refs[t].$el,`li[id="${e}"]`);o&&o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"start"})},updateListScroll(e){const t=i.DomHandler.find(e,".p-picklist-item.p-highlight");if(t&&t.length)switch(this.reorderDirection){case"up":i.DomHandler.scrollInView(e,t[0]);break;case"top":e.scrollTop=0;break;case"down":i.DomHandler.scrollInView(e,t[t.length-1]);break;case"bottom":e.scrollTop=e.scrollHeight}},createStyle(){if(!this.styleElement){this.$el.setAttribute(this.attributeSelector,""),this.styleElement=document.createElement("style"),this.styleElement.type="text/css",document.head.appendChild(this.styleElement);let e=`\n@media screen and (max-width: ${this.breakpoint}) {\n .p-picklist[${this.attributeSelector}] {\n flex-direction: column;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons {\n padding: var(--content-padding);\n flex-direction: row;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button {\n margin-right: var(--inline-spacing);\n margin-bottom: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button:last-child {\n margin-right: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-right:before {\n content: "\\e930"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-right:before {\n content: "\\e92c"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-left:before {\n content: "\\e933"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-left:before {\n content: "\\e92f"\n }\n}\n`;this.styleElement.innerHTML=e}},destroyStyle(){this.styleElement&&(document.head.removeChild(this.styleElement),this.styleElement=null)},moveDisabled(e){if(!this.d_selection[e]||!this.d_selection[e].length)return!0},moveAllDisabled(e){return i.ObjectUtils.isEmpty(this[e])},moveSourceDisabled(){return i.ObjectUtils.isEmpty(this.targetList)},itemClass(e,t,i){return["p-picklist-item",{"p-highlight":this.isSelected(e,i),"p-focus":t===this.focusedOptionId}]}},computed:{idSource(){return this.$attrs.id||i.UniqueComponentId()},idTarget(){return this.$attrs.id||i.UniqueComponentId()},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null},containerClass(){return["p-picklist p-component",{"p-picklist-striped":this.stripedRows}]},sourceList(){return this.modelValue&&this.modelValue[0]?this.modelValue[0]:null},targetList(){return this.modelValue&&this.modelValue[1]?this.modelValue[1]:null},attributeSelector:()=>i.UniqueComponentId(),moveUpAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveUp:void 0},moveTopAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveTop:void 0},moveDownAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveDown:void 0},moveBottomAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveBottom:void 0},moveToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToTarget:void 0},moveAllToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToTarget:void 0},moveToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToSource:void 0},moveAllToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToSource:void 0}},components:{PLButton:n.default},directives:{ripple:s.default}};const a={key:0,class:"p-picklist-buttons p-picklist-source-controls"},d={class:"p-picklist-list-wrapper p-picklist-source-wrapper"},c={key:0,class:"p-picklist-header"},u=["id","onClick","onDblclick","onMousedown","aria-selected"],p={class:"p-picklist-buttons p-picklist-transfer-buttons"},m={class:"p-picklist-list-wrapper p-picklist-target-wrapper"},h={key:0,class:"p-picklist-header"},f=["id","onClick","onDblclick","onMousedown","aria-selected"],v={key:1,class:"p-picklist-buttons p-picklist-target-controls"};return function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===i&&o.firstChild?o.insertBefore(l,o.firstChild):o.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}("\n.p-picklist {\n display: flex;\n}\n.p-picklist-buttons {\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n.p-picklist-list-wrapper {\n flex: 1 1 50%;\n}\n.p-picklist-list {\n list-style-type: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n min-height: 12rem;\n max-height: 24rem;\n}\n.p-picklist-item {\n cursor: pointer;\n overflow: hidden;\n position: relative;\n}\n.p-picklist-item.p-picklist-flip-enter-active.p-picklist-flip-enter-to,\n.p-picklist-item.p-picklist-flip-leave-active.p-picklist-flip-leave-to {\n transition: none !important;\n}\n"),r.render=function(e,t,i,l,n,s){const r=o.resolveComponent("PLButton"),b=o.resolveDirective("ripple");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(s.containerClass)},[i.showSourceControls?(o.openBlock(),o.createElementBlock("div",a,[o.renderSlot(e.$slots,"sourcecontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":s.moveUpAriaLabel,disabled:s.moveDisabled(0)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[0]||(t[0]=e=>s.moveUp(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveTopAriaLabel,disabled:s.moveDisabled(0)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[1]||(t[1]=e=>s.moveTop(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveDownAriaLabel,disabled:s.moveDisabled(0)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[2]||(t[2]=e=>s.moveDown(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveBottomAriaLabel,disabled:s.moveDisabled(0)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[3]||(t[3]=e=>s.moveBottom(e,0))}),null,16,["aria-label","disabled"]),o.renderSlot(e.$slots,"sourcecontrolsend")])):o.createCommentVNode("",!0),o.createElementVNode("div",d,[e.$slots.sourceheader?(o.openBlock(),o.createElementBlock("div",c,[o.renderSlot(e.$slots,"sourceheader")])):o.createCommentVNode("",!0),o.createVNode(o.TransitionGroup,o.mergeProps({ref:"sourceList",id:s.idSource+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-source",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":n.focused.sourceList?s.focusedOptionId:void 0,tabindex:s.sourceList&&s.sourceList.length>0?i.tabindex:-1,onFocus:t[5]||(t[5]=e=>s.onListFocus(e,"sourceList")),onBlur:t[6]||(t[6]=e=>s.onListBlur(e,"sourceList")),onKeydown:t[7]||(t[7]=e=>s.onItemKeyDown(e,"sourceList"))},i.sourceListProps),{default:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(s.sourceList,((i,l)=>o.withDirectives((o.openBlock(),o.createElementBlock("li",{key:s.getItemKey(i,l),id:s.idSource+"_"+l,class:o.normalizeClass(s.itemClass(i,`${s.idSource}_${l}`,0)),onClick:e=>s.onItemClick(e,i,l,0),onDblclick:e=>s.onItemDblClick(e,i,0),onTouchend:t[4]||(t[4]=(...e)=>s.onItemTouchEnd&&s.onItemTouchEnd(...e)),onMousedown:e=>s.onOptionMouseDown(l,"sourceList"),role:"option","aria-selected":s.isSelected(i,0)},[o.renderSlot(e.$slots,"item",{item:i,index:l})],42,u)),[[b]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),o.createElementVNode("div",p,[o.renderSlot(e.$slots,"movecontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":s.moveToTargetAriaLabel,type:"button",icon:"pi pi-angle-right",onClick:s.moveToTarget,disabled:s.moveDisabled(0)},i.moveToTargetProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveAllToTargetAriaLabel,type:"button",icon:"pi pi-angle-double-right",onClick:s.moveAllToTarget,disabled:s.moveAllDisabled("sourceList")},i.moveAllToTargetProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveToSourceAriaLabel,type:"button",icon:"pi pi-angle-left",onClick:s.moveToSource,disabled:s.moveDisabled(1)},i.moveToSourceProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveAllToSourceAriaLabel,type:"button",icon:"pi pi-angle-double-left",onClick:s.moveAllToSource,disabled:s.moveSourceDisabled("targetList")},i.moveAllToSourceProps),null,16,["aria-label","onClick","disabled"]),o.renderSlot(e.$slots,"movecontrolsend")]),o.createElementVNode("div",m,[e.$slots.targetheader?(o.openBlock(),o.createElementBlock("div",h,[o.renderSlot(e.$slots,"targetheader")])):o.createCommentVNode("",!0),o.createVNode(o.TransitionGroup,o.mergeProps({ref:"targetList",id:s.idTarget+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-target",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":n.focused.targetList?s.focusedOptionId:void 0,tabindex:s.targetList&&s.targetList.length>0?i.tabindex:-1,onFocus:t[10]||(t[10]=e=>s.onListFocus(e,"targetList")),onBlur:t[11]||(t[11]=e=>s.onListBlur(e,"targetList")),onKeydown:t[12]||(t[12]=e=>s.onItemKeyDown(e,"targetList"))},i.targetListProps),{default:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(s.targetList,((i,l)=>o.withDirectives((o.openBlock(),o.createElementBlock("li",{key:s.getItemKey(i,l),id:s.idTarget+"_"+l,class:o.normalizeClass(s.itemClass(i,`${s.idTarget}_${l}`,1)),onClick:e=>s.onItemClick(e,i,l,1),onDblclick:e=>s.onItemDblClick(e,i,1),onKeydown:t[8]||(t[8]=e=>s.onItemKeyDown(e,"targetList")),onMousedown:e=>s.onOptionMouseDown(l,"targetList"),onTouchend:t[9]||(t[9]=(...e)=>s.onItemTouchEnd&&s.onItemTouchEnd(...e)),role:"option","aria-selected":s.isSelected(i,1)},[o.renderSlot(e.$slots,"item",{item:i,index:l})],42,f)),[[b]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),i.showTargetControls?(o.openBlock(),o.createElementBlock("div",v,[o.renderSlot(e.$slots,"targetcontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":s.moveUpAriaLabel,disabled:s.moveDisabled(1)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[13]||(t[13]=e=>s.moveUp(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveTopAriaLabel,disabled:s.moveDisabled(1)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[14]||(t[14]=e=>s.moveTop(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveDownAriaLabel,disabled:s.moveDisabled(1)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[15]||(t[15]=e=>s.moveDown(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":s.moveBottomAriaLabel,disabled:s.moveDisabled(1)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[16]||(t[16]=e=>s.moveBottom(e,1))}),null,16,["aria-label","disabled"]),o.renderSlot(e.$slots,"targetcontrolsend")])):o.createCommentVNode("",!0)],2)},r}(primevue.button,primevue.ripple,primevue.utils,Vue);
1
+ this.primevue=this.primevue||{},this.primevue.picklist=function(e,t,i,o){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=l(e),n=l(t),r={name:"PickList",emits:["update:modelValue","reorder","update:selection","selection-change","move-to-target","move-to-source","move-all-to-target","move-all-to-source","focus","blur"],props:{modelValue:{type:Array,default:()=>[[],[]]},selection:{type:Array,default:()=>[[],[]]},dataKey:{type:String,default:null},listStyle:{type:null,default:null},metaKeySelection:{type:Boolean,default:!0},responsive:{type:Boolean,default:!0},breakpoint:{type:String,default:"960px"},stripedRows:{type:Boolean,default:!1},showSourceControls:{type:Boolean,default:!0},showTargetControls:{type:Boolean,default:!0},targetListProps:{type:null,default:null},sourceListProps:{type:null,default:null},moveUpButtonProps:{type:null,default:null},moveTopButtonProps:{type:null,default:null},moveDownButtonProps:{type:null,default:null},moveBottomButtonProps:{type:null,default:null},moveToTargetProps:{type:null,default:null},moveAllToTargetProps:{type:null,default:null},moveToSourceProps:{type:null,default:null},moveAllToSourceProps:{type:null,default:null},tabindex:{type:Number,default:0}},itemTouched:!1,reorderDirection:null,styleElement:null,data(){return{id:this.$attrs.id,d_selection:this.selection,focused:{sourceList:!1,targetList:!1},focusedOptionIndex:-1}},watch:{"$attrs.id":function(e){this.id=e||i.UniqueComponentId()},selection(e){this.d_selection=e}},updated(){this.reorderDirection&&(this.updateListScroll(this.$refs.sourceList.$el),this.updateListScroll(this.$refs.targetList.$el),this.reorderDirection=null)},beforeUnmount(){this.destroyStyle()},mounted(){this.id=this.id||i.UniqueComponentId(),this.responsive&&this.createStyle()},methods:{getItemKey(e,t){return this.dataKey?i.ObjectUtils.resolveFieldData(e,this.dataKey):t},isSelected(e,t){return-1!=i.ObjectUtils.findIndexInList(e,this.d_selection[t])},onListFocus(e,t){const o=i.DomHandler.findSingle(this.$refs[t].$el,"li.p-picklist-item.p-highlight"),l=i.ObjectUtils.findIndexInList(o,this.$refs[t].$el.children);this.focused[t]=!0;const s=-1!==this.focusedOptionIndex?this.focusedOptionIndex:o?l:-1;this.changeFocusedOptionIndex(s,t),this.$emit("focus",e)},onListBlur(e,t){this.focused[t]=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onOptionMouseDown(e,t){this.focused[t]=!0,this.focusedOptionIndex=e},moveUp(e,t){if(this.d_selection&&this.d_selection[t]){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=0;e<l.length;e++){let t=l[e],s=i.ObjectUtils.findIndexInList(t,o);if(0===s)break;{let e=o[s],t=o[s-1];o[s-1]=e,o[s]=t}}let s=[...this.modelValue];s[t]=o,this.reorderDirection="up",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveTop(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=0;e<l.length;e++){let t=l[e],s=i.ObjectUtils.findIndexInList(t,o);if(0===s)break;{let e=o.splice(s,1)[0];o.unshift(e)}}let s=[...this.modelValue];s[t]=o,this.reorderDirection="top",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveDown(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=l.length-1;e>=0;e--){let t=l[e],s=i.ObjectUtils.findIndexInList(t,o);if(s===o.length-1)break;{let e=o[s],t=o[s+1];o[s+1]=e,o[s]=t}}let s=[...this.modelValue];s[t]=o,this.reorderDirection="down",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveBottom(e,t){if(this.d_selection){let o=[...this.modelValue[t]],l=this.d_selection[t];for(let e=l.length-1;e>=0;e--){let t=l[e],s=i.ObjectUtils.findIndexInList(t,o);if(s===o.length-1)break;{let e=o.splice(s,1)[0];o.push(e)}}let s=[...this.modelValue];s[t]=o,this.reorderDirection="bottom",this.$emit("update:modelValue",s),this.$emit("reorder",{originalEvent:e,value:s,direction:this.reorderDirection,listIndex:t})}},moveToTarget(e){let t=this.d_selection&&this.d_selection[0]?this.d_selection[0]:null,o=[...this.modelValue[0]],l=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let s=t[e];-1==i.ObjectUtils.findIndexInList(s,l)&&l.push(o.splice(i.ObjectUtils.findIndexInList(s,o),1)[0])}let s=[...this.modelValue];s[0]=o,s[1]=l,this.$emit("update:modelValue",s),this.$emit("move-to-target",{originalEvent:e,items:t}),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToTarget(e){if(this.modelValue[0]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-target",{originalEvent:e,items:t}),i=[...i,...t],t=[];let o=[...this.modelValue];o[0]=t,o[1]=i,this.$emit("update:modelValue",o),this.d_selection[0]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveToSource(e){let t=this.d_selection&&this.d_selection[1]?this.d_selection[1]:null,o=[...this.modelValue[0]],l=[...this.modelValue[1]];if(t){for(let e=0;e<t.length;e++){let s=t[e];-1==i.ObjectUtils.findIndexInList(s,o)&&o.push(l.splice(i.ObjectUtils.findIndexInList(s,l),1)[0])}let s=[...this.modelValue];s[0]=o,s[1]=l,this.$emit("update:modelValue",s),this.$emit("move-to-source",{originalEvent:e,items:t}),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},moveAllToSource(e){if(this.modelValue[1]){let t=[...this.modelValue[0]],i=[...this.modelValue[1]];this.$emit("move-all-to-source",{originalEvent:e,items:i}),t=[...t,...i],i=[];let o=[...this.modelValue];o[0]=t,o[1]=i,this.$emit("update:modelValue",o),this.d_selection[1]=[],this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})}},onItemClick(e,t,o,l){const s=0===l?"sourceList":"targetList";this.itemTouched=!1;const n=this.d_selection[l],r=i.ObjectUtils.findIndexInList(t,this.d_selection),a=-1!=r,d=!this.itemTouched&&this.metaKeySelection,c=i.DomHandler.find(this.$refs[s].$el,".p-picklist-item")[o].getAttribute("id");let u;if(this.focusedOptionIndex=c,d){let i=e.metaKey||e.ctrlKey;a&&i?u=n.filter(((e,t)=>t!==r)):(u=i&&n?[...n]:[],u.push(t))}else a?u=n.filter(((e,t)=>t!==r)):(u=n?[...n]:[],u.push(t));let p=[...this.d_selection];p[l]=u,this.d_selection=p,this.$emit("update:selection",this.d_selection),this.$emit("selection-change",{originalEvent:e,value:this.d_selection})},onItemDblClick(e,t,i){0===i?this.moveToTarget(e):1===i&&this.moveToSource(e)},onItemTouchEnd(){this.itemTouched=!0},onItemKeyDown(e,t){switch(e.code){case"ArrowDown":this.onArrowDownKey(e,t);break;case"ArrowUp":this.onArrowUpKey(e,t);break;case"Home":this.onHomeKey(e,t);break;case"End":this.onEndKey(e,t);break;case"Enter":this.onEnterKey(e,t);break;case"Space":this.onSpaceKey(e,t);break;case"KeyA":e.ctrlKey&&(this.d_selection=[...this.modelValue],this.$emit("update:selection",this.d_selection))}},onArrowDownKey(e,t){const i=this.findNextOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onArrowUpKey(e,t){const i=this.findPrevOptionIndex(this.focusedOptionIndex,t);this.changeFocusedOptionIndex(i,t),e.shiftKey&&this.onEnterKey(e,t),e.preventDefault()},onEnterKey(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...o].findIndex((e=>e===l)),n="sourceList"===t?0:1;this.onItemClick(e,this.modelValue[n][s],s,n),e.preventDefault()},onSpaceKey(e,t){if(e.preventDefault(),e.shiftKey){const e="sourceList"===t?0:1,o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.ObjectUtils.findIndexInList(this.d_selection[e][0],[...this.modelValue[e]]),s=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),n=[...o].findIndex((e=>e===s));this.d_selection[e]=[...this.modelValue[e]].slice(Math.min(l,n),Math.max(l,n)+1),this.$emit("update:selection",this.d_selection)}else this.onEnterKey(e,t)},onHomeKey(e,t){if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item"),l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...o].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(0,s+1),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(0,t);e.preventDefault()},onEndKey(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item");if(e.ctrlKey&&e.shiftKey){const e="sourceList"===t?0:1,l=i.DomHandler.findSingle(this.$refs[t].$el,`li.p-picklist-item[id=${this.focusedOptionIndex}]`),s=[...o].findIndex((e=>e===l));this.d_selection[e]=[...this.modelValue[e]].slice(s,o.length),this.$emit("update:selection",this.d_selection)}else this.changeFocusedOptionIndex(o.length-1,t);e.preventDefault()},findNextOptionIndex(e,t){const o=[...i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return o>-1?o+1:0},findPrevOptionIndex(e,t){const o=[...i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item")].findIndex((t=>t.id===e));return o>-1?o-1:0},changeFocusedOptionIndex(e,t){const o=i.DomHandler.find(this.$refs[t].$el,"li.p-picklist-item");let l=e>=o.length?o.length-1:e<0?0:e;this.focusedOptionIndex=o[l].getAttribute("id"),this.scrollInView(o[l].getAttribute("id"),t)},scrollInView(e,t){const o=i.DomHandler.findSingle(this.$refs[t].$el,`li[id="${e}"]`);o&&o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"start"})},updateListScroll(e){const t=i.DomHandler.find(e,".p-picklist-item.p-highlight");if(t&&t.length)switch(this.reorderDirection){case"up":i.DomHandler.scrollInView(e,t[0]);break;case"top":e.scrollTop=0;break;case"down":i.DomHandler.scrollInView(e,t[t.length-1]);break;case"bottom":e.scrollTop=e.scrollHeight}},createStyle(){if(!this.styleElement){this.$el.setAttribute(this.attributeSelector,""),this.styleElement=document.createElement("style"),this.styleElement.type="text/css",document.head.appendChild(this.styleElement);let e=`\n@media screen and (max-width: ${this.breakpoint}) {\n .p-picklist[${this.attributeSelector}] {\n flex-direction: column;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons {\n padding: var(--content-padding);\n flex-direction: row;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button {\n margin-right: var(--inline-spacing);\n margin-bottom: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button:last-child {\n margin-right: 0;\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-right:before {\n content: "\\e930"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-right:before {\n content: "\\e92c"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-left:before {\n content: "\\e933"\n }\n\n .p-picklist[${this.attributeSelector}] .pi-angle-double-left:before {\n content: "\\e92f"\n }\n}\n`;this.styleElement.innerHTML=e}},destroyStyle(){this.styleElement&&(document.head.removeChild(this.styleElement),this.styleElement=null)},moveDisabled(e){if(!this.d_selection[e]||!this.d_selection[e].length)return!0},moveAllDisabled(e){return i.ObjectUtils.isEmpty(this[e])},moveSourceDisabled(){return i.ObjectUtils.isEmpty(this.targetList)},itemClass(e,t,i){return["p-picklist-item",{"p-highlight":this.isSelected(e,i),"p-focus":t===this.focusedOptionId}]}},computed:{idSource(){return`${this.id}_source`},idTarget(){return`${this.id}_target`},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null},containerClass(){return["p-picklist p-component",{"p-picklist-striped":this.stripedRows}]},sourceList(){return this.modelValue&&this.modelValue[0]?this.modelValue[0]:null},targetList(){return this.modelValue&&this.modelValue[1]?this.modelValue[1]:null},attributeSelector:()=>i.UniqueComponentId(),moveUpAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveUp:void 0},moveTopAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveTop:void 0},moveDownAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveDown:void 0},moveBottomAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveBottom:void 0},moveToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToTarget:void 0},moveAllToTargetAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToTarget:void 0},moveToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveToSource:void 0},moveAllToSourceAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.moveAllToSource:void 0}},components:{PLButton:s.default},directives:{ripple:n.default}};const a={key:0,class:"p-picklist-buttons p-picklist-source-controls"},d={class:"p-picklist-list-wrapper p-picklist-source-wrapper"},c={key:0,class:"p-picklist-header"},u=["id","onClick","onDblclick","onMousedown","aria-selected"],p={class:"p-picklist-buttons p-picklist-transfer-buttons"},m={class:"p-picklist-list-wrapper p-picklist-target-wrapper"},h={key:0,class:"p-picklist-header"},f=["id","onClick","onDblclick","onMousedown","aria-selected"],v={key:1,class:"p-picklist-buttons p-picklist-target-controls"};return function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===i&&o.firstChild?o.insertBefore(l,o.firstChild):o.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}("\n.p-picklist {\n display: flex;\n}\n.p-picklist-buttons {\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n.p-picklist-list-wrapper {\n flex: 1 1 50%;\n}\n.p-picklist-list {\n list-style-type: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n min-height: 12rem;\n max-height: 24rem;\n}\n.p-picklist-item {\n cursor: pointer;\n overflow: hidden;\n position: relative;\n}\n.p-picklist-item.p-picklist-flip-enter-active.p-picklist-flip-enter-to,\n.p-picklist-item.p-picklist-flip-leave-active.p-picklist-flip-leave-to {\n transition: none !important;\n}\n"),r.render=function(e,t,i,l,s,n){const r=o.resolveComponent("PLButton"),b=o.resolveDirective("ripple");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(n.containerClass)},[i.showSourceControls?(o.openBlock(),o.createElementBlock("div",a,[o.renderSlot(e.$slots,"sourcecontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":n.moveUpAriaLabel,disabled:n.moveDisabled(0)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[0]||(t[0]=e=>n.moveUp(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveTopAriaLabel,disabled:n.moveDisabled(0)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[1]||(t[1]=e=>n.moveTop(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveDownAriaLabel,disabled:n.moveDisabled(0)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[2]||(t[2]=e=>n.moveDown(e,0))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveBottomAriaLabel,disabled:n.moveDisabled(0)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[3]||(t[3]=e=>n.moveBottom(e,0))}),null,16,["aria-label","disabled"]),o.renderSlot(e.$slots,"sourcecontrolsend")])):o.createCommentVNode("",!0),o.createElementVNode("div",d,[e.$slots.sourceheader?(o.openBlock(),o.createElementBlock("div",c,[o.renderSlot(e.$slots,"sourceheader")])):o.createCommentVNode("",!0),o.createVNode(o.TransitionGroup,o.mergeProps({ref:"sourceList",id:n.idSource+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-source",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":s.focused.sourceList?n.focusedOptionId:void 0,tabindex:n.sourceList&&n.sourceList.length>0?i.tabindex:-1,onFocus:t[5]||(t[5]=e=>n.onListFocus(e,"sourceList")),onBlur:t[6]||(t[6]=e=>n.onListBlur(e,"sourceList")),onKeydown:t[7]||(t[7]=e=>n.onItemKeyDown(e,"sourceList"))},i.sourceListProps),{default:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(n.sourceList,((i,l)=>o.withDirectives((o.openBlock(),o.createElementBlock("li",{key:n.getItemKey(i,l),id:n.idSource+"_"+l,class:o.normalizeClass(n.itemClass(i,`${n.idSource}_${l}`,0)),onClick:e=>n.onItemClick(e,i,l,0),onDblclick:e=>n.onItemDblClick(e,i,0),onTouchend:t[4]||(t[4]=(...e)=>n.onItemTouchEnd&&n.onItemTouchEnd(...e)),onMousedown:e=>n.onOptionMouseDown(l,"sourceList"),role:"option","aria-selected":n.isSelected(i,0)},[o.renderSlot(e.$slots,"item",{item:i,index:l})],42,u)),[[b]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),o.createElementVNode("div",p,[o.renderSlot(e.$slots,"movecontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":n.moveToTargetAriaLabel,type:"button",icon:"pi pi-angle-right",onClick:n.moveToTarget,disabled:n.moveDisabled(0)},i.moveToTargetProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveAllToTargetAriaLabel,type:"button",icon:"pi pi-angle-double-right",onClick:n.moveAllToTarget,disabled:n.moveAllDisabled("sourceList")},i.moveAllToTargetProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveToSourceAriaLabel,type:"button",icon:"pi pi-angle-left",onClick:n.moveToSource,disabled:n.moveDisabled(1)},i.moveToSourceProps),null,16,["aria-label","onClick","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveAllToSourceAriaLabel,type:"button",icon:"pi pi-angle-double-left",onClick:n.moveAllToSource,disabled:n.moveSourceDisabled("targetList")},i.moveAllToSourceProps),null,16,["aria-label","onClick","disabled"]),o.renderSlot(e.$slots,"movecontrolsend")]),o.createElementVNode("div",m,[e.$slots.targetheader?(o.openBlock(),o.createElementBlock("div",h,[o.renderSlot(e.$slots,"targetheader")])):o.createCommentVNode("",!0),o.createVNode(o.TransitionGroup,o.mergeProps({ref:"targetList",id:n.idTarget+"_list",name:"p-picklist-flip",tag:"ul",class:"p-picklist-list p-picklist-target",style:i.listStyle,role:"listbox","aria-multiselectable":"true","aria-activedescendant":s.focused.targetList?n.focusedOptionId:void 0,tabindex:n.targetList&&n.targetList.length>0?i.tabindex:-1,onFocus:t[10]||(t[10]=e=>n.onListFocus(e,"targetList")),onBlur:t[11]||(t[11]=e=>n.onListBlur(e,"targetList")),onKeydown:t[12]||(t[12]=e=>n.onItemKeyDown(e,"targetList"))},i.targetListProps),{default:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(n.targetList,((i,l)=>o.withDirectives((o.openBlock(),o.createElementBlock("li",{key:n.getItemKey(i,l),id:n.idTarget+"_"+l,class:o.normalizeClass(n.itemClass(i,`${n.idTarget}_${l}`,1)),onClick:e=>n.onItemClick(e,i,l,1),onDblclick:e=>n.onItemDblClick(e,i,1),onKeydown:t[8]||(t[8]=e=>n.onItemKeyDown(e,"targetList")),onMousedown:e=>n.onOptionMouseDown(l,"targetList"),onTouchend:t[9]||(t[9]=(...e)=>n.onItemTouchEnd&&n.onItemTouchEnd(...e)),role:"option","aria-selected":n.isSelected(i,1)},[o.renderSlot(e.$slots,"item",{item:i,index:l})],42,f)),[[b]]))),128))])),_:3},16,["id","style","aria-activedescendant","tabindex"])]),i.showTargetControls?(o.openBlock(),o.createElementBlock("div",v,[o.renderSlot(e.$slots,"targetcontrolsstart"),o.createVNode(r,o.mergeProps({"aria-label":n.moveUpAriaLabel,disabled:n.moveDisabled(1)},i.moveUpButtonProps,{type:"button",icon:"pi pi-angle-up",onClick:t[13]||(t[13]=e=>n.moveUp(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveTopAriaLabel,disabled:n.moveDisabled(1)},i.moveTopButtonProps,{type:"button",icon:"pi pi-angle-double-up",onClick:t[14]||(t[14]=e=>n.moveTop(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveDownAriaLabel,disabled:n.moveDisabled(1)},i.moveDownButtonProps,{type:"button",icon:"pi pi-angle-down",onClick:t[15]||(t[15]=e=>n.moveDown(e,1))}),null,16,["aria-label","disabled"]),o.createVNode(r,o.mergeProps({"aria-label":n.moveBottomAriaLabel,disabled:n.moveDisabled(1)},i.moveBottomButtonProps,{type:"button",icon:"pi pi-angle-double-down",onClick:t[16]||(t[16]=e=>n.moveBottom(e,1))}),null,16,["aria-label","disabled"]),o.renderSlot(e.$slots,"targetcontrolsend")])):o.createCommentVNode("",!0)],2)},r}(primevue.button,primevue.ripple,primevue.utils,Vue);
package/rating/Rating.vue CHANGED
@@ -77,9 +77,18 @@ export default {
77
77
  },
78
78
  data() {
79
79
  return {
80
+ name: this.$attrs.name,
80
81
  focusedOptionIndex: -1
81
82
  };
82
83
  },
84
+ watch: {
85
+ '$attrs.name': function (newValue) {
86
+ this.name = newValue || UniqueComponentId();
87
+ }
88
+ },
89
+ mounted() {
90
+ this.name = this.name || UniqueComponentId();
91
+ },
83
92
  methods: {
84
93
  onOptionClick(event, value) {
85
94
  if (!this.readonly && !this.disabled) {
@@ -133,9 +142,6 @@ export default {
133
142
  },
134
143
  offIconClass() {
135
144
  return ['p-rating-icon', this.offIcon];
136
- },
137
- name() {
138
- return this.$attrs.name || UniqueComponentId();
139
145
  }
140
146
  }
141
147
  };
@@ -42,9 +42,18 @@ var script = {
42
42
  },
43
43
  data() {
44
44
  return {
45
+ name: this.$attrs.name,
45
46
  focusedOptionIndex: -1
46
47
  };
47
48
  },
49
+ watch: {
50
+ '$attrs.name': function (newValue) {
51
+ this.name = newValue || utils.UniqueComponentId();
52
+ }
53
+ },
54
+ mounted() {
55
+ this.name = this.name || utils.UniqueComponentId();
56
+ },
48
57
  methods: {
49
58
  onOptionClick(event, value) {
50
59
  if (!this.readonly && !this.disabled) {
@@ -98,9 +107,6 @@ var script = {
98
107
  },
99
108
  offIconClass() {
100
109
  return ['p-rating-icon', this.offIcon];
101
- },
102
- name() {
103
- return this.$attrs.name || utils.UniqueComponentId();
104
110
  }
105
111
  }
106
112
  };
@@ -125,7 +131,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
125
131
  vue.createElementVNode("input", {
126
132
  type: "radio",
127
133
  value: "0",
128
- name: $options.name,
134
+ name: $data.name,
129
135
  checked: $props.modelValue === 0,
130
136
  disabled: $props.disabled,
131
137
  readonly: $props.readonly,
@@ -152,7 +158,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
152
158
  vue.createElementVNode("input", {
153
159
  type: "radio",
154
160
  value: value,
155
- name: $options.name,
161
+ name: $data.name,
156
162
  checked: $props.modelValue === value,
157
163
  disabled: $props.disabled,
158
164
  readonly: $props.readonly,
@@ -1 +1 @@
1
- "use strict";var e=require("primevue/utils"),n=require("vue"),a={name:"Rating",emits:["update:modelValue","change","focus","blur"],props:{modelValue:{type:Number,default:null},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},stars:{type:Number,default:5},cancel:{type:Boolean,default:!0},onIcon:{type:String,default:"pi pi-star-fill"},offIcon:{type:String,default:"pi pi-star"},cancelIcon:{type:String,default:"pi pi-ban"}},data:()=>({focusedOptionIndex:-1}),methods:{onOptionClick(n,a){if(!this.readonly&&!this.disabled){this.onOptionSelect(n,a);const l=e.DomHandler.getFirstFocusableElement(n.currentTarget);l&&e.DomHandler.focus(l)}},onFocus(e,n){this.focusedOptionIndex=n,this.$emit("focus",e)},onBlur(e){this.focusedOptionIndex=-1,this.$emit("blur",e)},onChange(e,n){this.onOptionSelect(e,n)},onOptionSelect(e,n){this.focusedOptionIndex=n,this.updateModel(e,n||null)},updateModel(e,n){this.$emit("update:modelValue",n),this.$emit("change",{originalEvent:e,value:n})},cancelAriaLabel(){return this.$primevue.config.locale.clear},starAriaLabel(e){return 1===e?this.$primevue.config.locale.aria.star:this.$primevue.config.locale.aria.stars.replace(/{star}/g,e)}},computed:{containerClass(){return["p-rating",{"p-readonly":this.readonly,"p-disabled":this.disabled}]},cancelIconClass(){return["p-rating-icon p-rating-cancel",this.cancelIcon]},onIconClass(){return["p-rating-icon",this.onIcon]},offIconClass(){return["p-rating-icon",this.offIcon]},name(){return this.$attrs.name||e.UniqueComponentId()}}};const l={class:"p-hidden-accessible"},t=["name","checked","disabled","readonly","aria-label"],o=["onClick"],i={class:"p-hidden-accessible"},s=["value","name","checked","disabled","readonly","aria-label","onFocus","onChange"];!function(e,n){void 0===n&&(n={});var a=n.insertAt;if(e&&"undefined"!=typeof document){var l=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css","top"===a&&l.firstChild?l.insertBefore(t,l.firstChild):l.appendChild(t),t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}}("\n.p-rating {\n position: relative;\n display: flex;\n align-items: center;\n}\n.p-rating-item {\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n}\n.p-rating.p-readonly .p-rating-item {\n cursor: default;\n}\n"),a.render=function(e,a,r,c,d,u){return n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(u.containerClass)},[r.cancel?(n.openBlock(),n.createElementBlock("div",{key:0,class:n.normalizeClass(["p-rating-item p-rating-cancel-item",{"p-focus":0===d.focusedOptionIndex}]),onClick:a[3]||(a[3]=e=>u.onOptionClick(e,0))},[n.createElementVNode("span",l,[n.createElementVNode("input",{type:"radio",value:"0",name:u.name,checked:0===r.modelValue,disabled:r.disabled,readonly:r.readonly,"aria-label":u.cancelAriaLabel(),onFocus:a[0]||(a[0]=e=>u.onFocus(e,0)),onBlur:a[1]||(a[1]=(...e)=>u.onBlur&&u.onBlur(...e)),onChange:a[2]||(a[2]=e=>u.onChange(e,0))},null,40,t)]),n.renderSlot(e.$slots,"cancelicon",{},(()=>[n.createElementVNode("span",{class:n.normalizeClass(u.cancelIconClass)},null,2)]))],2)):n.createCommentVNode("",!0),(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(r.stars,(l=>(n.openBlock(),n.createElementBlock("div",{key:l,class:n.normalizeClass(["p-rating-item",{"p-rating-item-active":l<=r.modelValue,"p-focus":l===d.focusedOptionIndex}]),onClick:e=>u.onOptionClick(e,l)},[n.createElementVNode("span",i,[n.createElementVNode("input",{type:"radio",value:l,name:u.name,checked:r.modelValue===l,disabled:r.disabled,readonly:r.readonly,"aria-label":u.starAriaLabel(l),onFocus:e=>u.onFocus(e,l),onBlur:a[4]||(a[4]=(...e)=>u.onBlur&&u.onBlur(...e)),onChange:e=>u.onChange(e,l)},null,40,s)]),l<=r.modelValue?n.renderSlot(e.$slots,"onicon",{key:0,value:l},(()=>[n.createElementVNode("span",{class:n.normalizeClass(u.onIconClass)},null,2)])):n.renderSlot(e.$slots,"officon",{key:1,value:l},(()=>[n.createElementVNode("span",{class:n.normalizeClass(u.offIconClass)},null,2)]))],10,o)))),128))],2)},module.exports=a;
1
+ "use strict";var e=require("primevue/utils"),n=require("vue"),a={name:"Rating",emits:["update:modelValue","change","focus","blur"],props:{modelValue:{type:Number,default:null},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},stars:{type:Number,default:5},cancel:{type:Boolean,default:!0},onIcon:{type:String,default:"pi pi-star-fill"},offIcon:{type:String,default:"pi pi-star"},cancelIcon:{type:String,default:"pi pi-ban"}},data(){return{name:this.$attrs.name,focusedOptionIndex:-1}},watch:{"$attrs.name":function(n){this.name=n||e.UniqueComponentId()}},mounted(){this.name=this.name||e.UniqueComponentId()},methods:{onOptionClick(n,a){if(!this.readonly&&!this.disabled){this.onOptionSelect(n,a);const t=e.DomHandler.getFirstFocusableElement(n.currentTarget);t&&e.DomHandler.focus(t)}},onFocus(e,n){this.focusedOptionIndex=n,this.$emit("focus",e)},onBlur(e){this.focusedOptionIndex=-1,this.$emit("blur",e)},onChange(e,n){this.onOptionSelect(e,n)},onOptionSelect(e,n){this.focusedOptionIndex=n,this.updateModel(e,n||null)},updateModel(e,n){this.$emit("update:modelValue",n),this.$emit("change",{originalEvent:e,value:n})},cancelAriaLabel(){return this.$primevue.config.locale.clear},starAriaLabel(e){return 1===e?this.$primevue.config.locale.aria.star:this.$primevue.config.locale.aria.stars.replace(/{star}/g,e)}},computed:{containerClass(){return["p-rating",{"p-readonly":this.readonly,"p-disabled":this.disabled}]},cancelIconClass(){return["p-rating-icon p-rating-cancel",this.cancelIcon]},onIconClass(){return["p-rating-icon",this.onIcon]},offIconClass(){return["p-rating-icon",this.offIcon]}}};const t={class:"p-hidden-accessible"},l=["name","checked","disabled","readonly","aria-label"],o=["onClick"],i={class:"p-hidden-accessible"},s=["value","name","checked","disabled","readonly","aria-label","onFocus","onChange"];!function(e,n){void 0===n&&(n={});var a=n.insertAt;if(e&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===a&&t.firstChild?t.insertBefore(l,t.firstChild):t.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}("\n.p-rating {\n position: relative;\n display: flex;\n align-items: center;\n}\n.p-rating-item {\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n}\n.p-rating.p-readonly .p-rating-item {\n cursor: default;\n}\n"),a.render=function(e,a,r,c,d,u){return n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(u.containerClass)},[r.cancel?(n.openBlock(),n.createElementBlock("div",{key:0,class:n.normalizeClass(["p-rating-item p-rating-cancel-item",{"p-focus":0===d.focusedOptionIndex}]),onClick:a[3]||(a[3]=e=>u.onOptionClick(e,0))},[n.createElementVNode("span",t,[n.createElementVNode("input",{type:"radio",value:"0",name:d.name,checked:0===r.modelValue,disabled:r.disabled,readonly:r.readonly,"aria-label":u.cancelAriaLabel(),onFocus:a[0]||(a[0]=e=>u.onFocus(e,0)),onBlur:a[1]||(a[1]=(...e)=>u.onBlur&&u.onBlur(...e)),onChange:a[2]||(a[2]=e=>u.onChange(e,0))},null,40,l)]),n.renderSlot(e.$slots,"cancelicon",{},(()=>[n.createElementVNode("span",{class:n.normalizeClass(u.cancelIconClass)},null,2)]))],2)):n.createCommentVNode("",!0),(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(r.stars,(t=>(n.openBlock(),n.createElementBlock("div",{key:t,class:n.normalizeClass(["p-rating-item",{"p-rating-item-active":t<=r.modelValue,"p-focus":t===d.focusedOptionIndex}]),onClick:e=>u.onOptionClick(e,t)},[n.createElementVNode("span",i,[n.createElementVNode("input",{type:"radio",value:t,name:d.name,checked:r.modelValue===t,disabled:r.disabled,readonly:r.readonly,"aria-label":u.starAriaLabel(t),onFocus:e=>u.onFocus(e,t),onBlur:a[4]||(a[4]=(...e)=>u.onBlur&&u.onBlur(...e)),onChange:e=>u.onChange(e,t)},null,40,s)]),t<=r.modelValue?n.renderSlot(e.$slots,"onicon",{key:0,value:t},(()=>[n.createElementVNode("span",{class:n.normalizeClass(u.onIconClass)},null,2)])):n.renderSlot(e.$slots,"officon",{key:1,value:t},(()=>[n.createElementVNode("span",{class:n.normalizeClass(u.offIconClass)},null,2)]))],10,o)))),128))],2)},module.exports=a;
@@ -1,4 +1,4 @@
1
- import { DomHandler, UniqueComponentId } from 'primevue/utils';
1
+ import { UniqueComponentId, DomHandler } from 'primevue/utils';
2
2
  import { openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createCommentVNode, Fragment, renderList } from 'vue';
3
3
 
4
4
  var script = {
@@ -40,9 +40,18 @@ var script = {
40
40
  },
41
41
  data() {
42
42
  return {
43
+ name: this.$attrs.name,
43
44
  focusedOptionIndex: -1
44
45
  };
45
46
  },
47
+ watch: {
48
+ '$attrs.name': function (newValue) {
49
+ this.name = newValue || UniqueComponentId();
50
+ }
51
+ },
52
+ mounted() {
53
+ this.name = this.name || UniqueComponentId();
54
+ },
46
55
  methods: {
47
56
  onOptionClick(event, value) {
48
57
  if (!this.readonly && !this.disabled) {
@@ -96,9 +105,6 @@ var script = {
96
105
  },
97
106
  offIconClass() {
98
107
  return ['p-rating-icon', this.offIcon];
99
- },
100
- name() {
101
- return this.$attrs.name || UniqueComponentId();
102
108
  }
103
109
  }
104
110
  };
@@ -123,7 +129,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
123
129
  createElementVNode("input", {
124
130
  type: "radio",
125
131
  value: "0",
126
- name: $options.name,
132
+ name: $data.name,
127
133
  checked: $props.modelValue === 0,
128
134
  disabled: $props.disabled,
129
135
  readonly: $props.readonly,
@@ -150,7 +156,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
150
156
  createElementVNode("input", {
151
157
  type: "radio",
152
158
  value: value,
153
- name: $options.name,
159
+ name: $data.name,
154
160
  checked: $props.modelValue === value,
155
161
  disabled: $props.disabled,
156
162
  readonly: $props.readonly,
@@ -1 +1 @@
1
- import{DomHandler as e,UniqueComponentId as n}from"primevue/utils";import{openBlock as a,createElementBlock as t,normalizeClass as l,createElementVNode as i,renderSlot as o,createCommentVNode as s,Fragment as c,renderList as r}from"vue";var d={name:"Rating",emits:["update:modelValue","change","focus","blur"],props:{modelValue:{type:Number,default:null},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},stars:{type:Number,default:5},cancel:{type:Boolean,default:!0},onIcon:{type:String,default:"pi pi-star-fill"},offIcon:{type:String,default:"pi pi-star"},cancelIcon:{type:String,default:"pi pi-ban"}},data:()=>({focusedOptionIndex:-1}),methods:{onOptionClick(n,a){if(!this.readonly&&!this.disabled){this.onOptionSelect(n,a);const t=e.getFirstFocusableElement(n.currentTarget);t&&e.focus(t)}},onFocus(e,n){this.focusedOptionIndex=n,this.$emit("focus",e)},onBlur(e){this.focusedOptionIndex=-1,this.$emit("blur",e)},onChange(e,n){this.onOptionSelect(e,n)},onOptionSelect(e,n){this.focusedOptionIndex=n,this.updateModel(e,n||null)},updateModel(e,n){this.$emit("update:modelValue",n),this.$emit("change",{originalEvent:e,value:n})},cancelAriaLabel(){return this.$primevue.config.locale.clear},starAriaLabel(e){return 1===e?this.$primevue.config.locale.aria.star:this.$primevue.config.locale.aria.stars.replace(/{star}/g,e)}},computed:{containerClass(){return["p-rating",{"p-readonly":this.readonly,"p-disabled":this.disabled}]},cancelIconClass(){return["p-rating-icon p-rating-cancel",this.cancelIcon]},onIconClass(){return["p-rating-icon",this.onIcon]},offIconClass(){return["p-rating-icon",this.offIcon]},name(){return this.$attrs.name||n()}}};const u={class:"p-hidden-accessible"},p=["name","checked","disabled","readonly","aria-label"],m=["onClick"],f={class:"p-hidden-accessible"},h=["value","name","checked","disabled","readonly","aria-label","onFocus","onChange"];!function(e,n){void 0===n&&(n={});var a=n.insertAt;if(e&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===a&&t.firstChild?t.insertBefore(l,t.firstChild):t.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}("\n.p-rating {\n position: relative;\n display: flex;\n align-items: center;\n}\n.p-rating-item {\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n}\n.p-rating.p-readonly .p-rating-item {\n cursor: default;\n}\n"),d.render=function(e,n,d,g,y,b){return a(),t("div",{class:l(b.containerClass)},[d.cancel?(a(),t("div",{key:0,class:l(["p-rating-item p-rating-cancel-item",{"p-focus":0===y.focusedOptionIndex}]),onClick:n[3]||(n[3]=e=>b.onOptionClick(e,0))},[i("span",u,[i("input",{type:"radio",value:"0",name:b.name,checked:0===d.modelValue,disabled:d.disabled,readonly:d.readonly,"aria-label":b.cancelAriaLabel(),onFocus:n[0]||(n[0]=e=>b.onFocus(e,0)),onBlur:n[1]||(n[1]=(...e)=>b.onBlur&&b.onBlur(...e)),onChange:n[2]||(n[2]=e=>b.onChange(e,0))},null,40,p)]),o(e.$slots,"cancelicon",{},(()=>[i("span",{class:l(b.cancelIconClass)},null,2)]))],2)):s("",!0),(a(!0),t(c,null,r(d.stars,(s=>(a(),t("div",{key:s,class:l(["p-rating-item",{"p-rating-item-active":s<=d.modelValue,"p-focus":s===y.focusedOptionIndex}]),onClick:e=>b.onOptionClick(e,s)},[i("span",f,[i("input",{type:"radio",value:s,name:b.name,checked:d.modelValue===s,disabled:d.disabled,readonly:d.readonly,"aria-label":b.starAriaLabel(s),onFocus:e=>b.onFocus(e,s),onBlur:n[4]||(n[4]=(...e)=>b.onBlur&&b.onBlur(...e)),onChange:e=>b.onChange(e,s)},null,40,h)]),s<=d.modelValue?o(e.$slots,"onicon",{key:0,value:s},(()=>[i("span",{class:l(b.onIconClass)},null,2)])):o(e.$slots,"officon",{key:1,value:s},(()=>[i("span",{class:l(b.offIconClass)},null,2)]))],10,m)))),128))],2)};export{d as default};
1
+ import{UniqueComponentId as e,DomHandler as n}from"primevue/utils";import{openBlock as a,createElementBlock as t,normalizeClass as l,createElementVNode as i,renderSlot as o,createCommentVNode as s,Fragment as c,renderList as r}from"vue";var d={name:"Rating",emits:["update:modelValue","change","focus","blur"],props:{modelValue:{type:Number,default:null},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},stars:{type:Number,default:5},cancel:{type:Boolean,default:!0},onIcon:{type:String,default:"pi pi-star-fill"},offIcon:{type:String,default:"pi pi-star"},cancelIcon:{type:String,default:"pi pi-ban"}},data(){return{name:this.$attrs.name,focusedOptionIndex:-1}},watch:{"$attrs.name":function(n){this.name=n||e()}},mounted(){this.name=this.name||e()},methods:{onOptionClick(e,a){if(!this.readonly&&!this.disabled){this.onOptionSelect(e,a);const t=n.getFirstFocusableElement(e.currentTarget);t&&n.focus(t)}},onFocus(e,n){this.focusedOptionIndex=n,this.$emit("focus",e)},onBlur(e){this.focusedOptionIndex=-1,this.$emit("blur",e)},onChange(e,n){this.onOptionSelect(e,n)},onOptionSelect(e,n){this.focusedOptionIndex=n,this.updateModel(e,n||null)},updateModel(e,n){this.$emit("update:modelValue",n),this.$emit("change",{originalEvent:e,value:n})},cancelAriaLabel(){return this.$primevue.config.locale.clear},starAriaLabel(e){return 1===e?this.$primevue.config.locale.aria.star:this.$primevue.config.locale.aria.stars.replace(/{star}/g,e)}},computed:{containerClass(){return["p-rating",{"p-readonly":this.readonly,"p-disabled":this.disabled}]},cancelIconClass(){return["p-rating-icon p-rating-cancel",this.cancelIcon]},onIconClass(){return["p-rating-icon",this.onIcon]},offIconClass(){return["p-rating-icon",this.offIcon]}}};const u={class:"p-hidden-accessible"},p=["name","checked","disabled","readonly","aria-label"],m=["onClick"],f={class:"p-hidden-accessible"},h=["value","name","checked","disabled","readonly","aria-label","onFocus","onChange"];!function(e,n){void 0===n&&(n={});var a=n.insertAt;if(e&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===a&&t.firstChild?t.insertBefore(l,t.firstChild):t.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}("\n.p-rating {\n position: relative;\n display: flex;\n align-items: center;\n}\n.p-rating-item {\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n}\n.p-rating.p-readonly .p-rating-item {\n cursor: default;\n}\n"),d.render=function(e,n,d,g,y,b){return a(),t("div",{class:l(b.containerClass)},[d.cancel?(a(),t("div",{key:0,class:l(["p-rating-item p-rating-cancel-item",{"p-focus":0===y.focusedOptionIndex}]),onClick:n[3]||(n[3]=e=>b.onOptionClick(e,0))},[i("span",u,[i("input",{type:"radio",value:"0",name:y.name,checked:0===d.modelValue,disabled:d.disabled,readonly:d.readonly,"aria-label":b.cancelAriaLabel(),onFocus:n[0]||(n[0]=e=>b.onFocus(e,0)),onBlur:n[1]||(n[1]=(...e)=>b.onBlur&&b.onBlur(...e)),onChange:n[2]||(n[2]=e=>b.onChange(e,0))},null,40,p)]),o(e.$slots,"cancelicon",{},(()=>[i("span",{class:l(b.cancelIconClass)},null,2)]))],2)):s("",!0),(a(!0),t(c,null,r(d.stars,(s=>(a(),t("div",{key:s,class:l(["p-rating-item",{"p-rating-item-active":s<=d.modelValue,"p-focus":s===y.focusedOptionIndex}]),onClick:e=>b.onOptionClick(e,s)},[i("span",f,[i("input",{type:"radio",value:s,name:y.name,checked:d.modelValue===s,disabled:d.disabled,readonly:d.readonly,"aria-label":b.starAriaLabel(s),onFocus:e=>b.onFocus(e,s),onBlur:n[4]||(n[4]=(...e)=>b.onBlur&&b.onBlur(...e)),onChange:e=>b.onChange(e,s)},null,40,h)]),s<=d.modelValue?o(e.$slots,"onicon",{key:0,value:s},(()=>[i("span",{class:l(b.onIconClass)},null,2)])):o(e.$slots,"officon",{key:1,value:s},(()=>[i("span",{class:l(b.offIconClass)},null,2)]))],10,m)))),128))],2)};export{d as default};