primevue 3.18.0 → 3.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/README.md +13 -2
  2. package/autocomplete/AutoComplete.vue +15 -2
  3. package/autocomplete/autocomplete.cjs.js +15 -2
  4. package/autocomplete/autocomplete.cjs.min.js +1 -1
  5. package/autocomplete/autocomplete.esm.js +15 -2
  6. package/autocomplete/autocomplete.esm.min.js +1 -1
  7. package/autocomplete/autocomplete.js +15 -2
  8. package/autocomplete/autocomplete.min.js +1 -1
  9. package/breadcrumb/BreadcrumbItem.vue +6 -6
  10. package/breadcrumb/breadcrumb.cjs.js +6 -6
  11. package/breadcrumb/breadcrumb.cjs.min.js +1 -1
  12. package/breadcrumb/breadcrumb.esm.js +6 -6
  13. package/breadcrumb/breadcrumb.esm.min.js +1 -1
  14. package/breadcrumb/breadcrumb.js +6 -6
  15. package/breadcrumb/breadcrumb.min.js +1 -1
  16. package/calendar/Calendar.d.ts +20 -0
  17. package/calendar/Calendar.vue +32 -14
  18. package/calendar/calendar.cjs.js +139 -121
  19. package/calendar/calendar.cjs.min.js +1 -1
  20. package/calendar/calendar.esm.js +139 -121
  21. package/calendar/calendar.esm.min.js +1 -1
  22. package/calendar/calendar.js +139 -121
  23. package/calendar/calendar.min.js +1 -1
  24. package/chips/Chips.d.ts +7 -2
  25. package/chips/Chips.vue +11 -3
  26. package/chips/chips.cjs.js +12 -4
  27. package/chips/chips.cjs.min.js +1 -1
  28. package/chips/chips.esm.js +12 -4
  29. package/chips/chips.esm.min.js +1 -1
  30. package/chips/chips.js +12 -4
  31. package/chips/chips.min.js +1 -1
  32. package/confirmdialog/ConfirmDialog.vue +6 -1
  33. package/confirmdialog/confirmdialog.cjs.js +7 -1
  34. package/confirmdialog/confirmdialog.cjs.min.js +1 -1
  35. package/confirmdialog/confirmdialog.esm.js +7 -1
  36. package/confirmdialog/confirmdialog.esm.min.js +1 -1
  37. package/confirmdialog/confirmdialog.js +7 -1
  38. package/confirmdialog/confirmdialog.min.js +1 -1
  39. package/confirmpopup/ConfirmPopup.vue +59 -5
  40. package/confirmpopup/confirmpopup.cjs.js +83 -19
  41. package/confirmpopup/confirmpopup.cjs.min.js +1 -1
  42. package/confirmpopup/confirmpopup.esm.js +82 -19
  43. package/confirmpopup/confirmpopup.esm.min.js +1 -1
  44. package/confirmpopup/confirmpopup.js +82 -19
  45. package/confirmpopup/confirmpopup.min.js +1 -1
  46. package/contextmenu/ContextMenu.vue +14 -16
  47. package/contextmenu/contextmenu.cjs.js +14 -16
  48. package/contextmenu/contextmenu.cjs.min.js +1 -1
  49. package/contextmenu/contextmenu.esm.js +14 -16
  50. package/contextmenu/contextmenu.esm.min.js +1 -1
  51. package/contextmenu/contextmenu.js +14 -16
  52. package/contextmenu/contextmenu.min.js +1 -1
  53. package/core/core.js +374 -94
  54. package/core/core.min.js +13 -9
  55. package/datatable/DataTable.d.ts +1 -1
  56. package/datatable/DataTable.vue +1 -1
  57. package/datatable/HeaderCell.vue +1 -1
  58. package/datatable/TableBody.vue +1 -1
  59. package/datatable/TableHeader.vue +1 -1
  60. package/datatable/datatable.cjs.js +4 -4
  61. package/datatable/datatable.cjs.min.js +1 -1
  62. package/datatable/datatable.esm.js +4 -4
  63. package/datatable/datatable.esm.min.js +1 -1
  64. package/datatable/datatable.js +4 -4
  65. package/datatable/datatable.min.js +1 -1
  66. package/dialog/Dialog.d.ts +19 -5
  67. package/dialog/Dialog.vue +114 -51
  68. package/dialog/dialog.cjs.js +145 -72
  69. package/dialog/dialog.cjs.min.js +1 -1
  70. package/dialog/dialog.esm.js +143 -71
  71. package/dialog/dialog.esm.min.js +1 -1
  72. package/dialog/dialog.js +143 -71
  73. package/dialog/dialog.min.js +1 -1
  74. package/dropdown/Dropdown.vue +20 -1
  75. package/dropdown/dropdown.cjs.js +20 -1
  76. package/dropdown/dropdown.cjs.min.js +1 -1
  77. package/dropdown/dropdown.esm.js +20 -1
  78. package/dropdown/dropdown.esm.min.js +1 -1
  79. package/dropdown/dropdown.js +20 -1
  80. package/dropdown/dropdown.min.js +1 -1
  81. package/fileupload/FileContent.vue +9 -2
  82. package/fileupload/fileupload.cjs.js +10 -4
  83. package/fileupload/fileupload.cjs.min.js +1 -1
  84. package/fileupload/fileupload.esm.js +9 -4
  85. package/fileupload/fileupload.esm.min.js +1 -1
  86. package/fileupload/fileupload.js +11 -6
  87. package/fileupload/fileupload.min.js +1 -1
  88. package/focustrap/FocusTrap.d.ts +5 -0
  89. package/focustrap/focustrap.cjs.js +94 -0
  90. package/focustrap/focustrap.cjs.min.js +1 -0
  91. package/focustrap/focustrap.esm.js +92 -0
  92. package/focustrap/focustrap.esm.min.js +1 -0
  93. package/focustrap/focustrap.js +96 -0
  94. package/focustrap/focustrap.min.js +1 -0
  95. package/focustrap/package.json +6 -0
  96. package/inplace/Inplace.d.ts +5 -0
  97. package/inplace/Inplace.vue +5 -1
  98. package/inplace/inplace.cjs.js +6 -2
  99. package/inplace/inplace.cjs.min.js +1 -1
  100. package/inplace/inplace.esm.js +6 -2
  101. package/inplace/inplace.esm.min.js +1 -1
  102. package/inplace/inplace.js +6 -2
  103. package/inplace/inplace.min.js +1 -1
  104. package/inputnumber/InputNumber.d.ts +5 -0
  105. package/inputnumber/InputNumber.vue +9 -0
  106. package/inputnumber/inputnumber.cjs.js +9 -0
  107. package/inputnumber/inputnumber.cjs.min.js +1 -1
  108. package/inputnumber/inputnumber.esm.js +9 -0
  109. package/inputnumber/inputnumber.esm.min.js +1 -1
  110. package/inputnumber/inputnumber.js +9 -0
  111. package/inputnumber/inputnumber.min.js +1 -1
  112. package/megamenu/MegaMenu.vue +3 -2
  113. package/megamenu/megamenu.cjs.js +3 -2
  114. package/megamenu/megamenu.cjs.min.js +1 -1
  115. package/megamenu/megamenu.esm.js +3 -2
  116. package/megamenu/megamenu.esm.min.js +1 -1
  117. package/megamenu/megamenu.js +3 -2
  118. package/megamenu/megamenu.min.js +1 -1
  119. package/menu/Menu.vue +7 -7
  120. package/menu/menu.cjs.js +7 -7
  121. package/menu/menu.cjs.min.js +1 -1
  122. package/menu/menu.esm.js +7 -7
  123. package/menu/menu.esm.min.js +1 -1
  124. package/menu/menu.js +7 -7
  125. package/menu/menu.min.js +1 -1
  126. package/menubar/Menubar.vue +5 -3
  127. package/menubar/MenubarSub.vue +1 -1
  128. package/menubar/menubar.cjs.js +22 -18
  129. package/menubar/menubar.cjs.min.js +1 -1
  130. package/menubar/menubar.esm.js +22 -18
  131. package/menubar/menubar.esm.min.js +1 -1
  132. package/menubar/menubar.js +22 -18
  133. package/menubar/menubar.min.js +1 -1
  134. package/message/Message.d.ts +5 -0
  135. package/message/Message.vue +5 -1
  136. package/message/message.cjs.js +9 -5
  137. package/message/message.cjs.min.js +1 -1
  138. package/message/message.esm.js +9 -5
  139. package/message/message.esm.min.js +1 -1
  140. package/message/message.js +9 -5
  141. package/message/message.min.js +1 -1
  142. package/multiselect/MultiSelect.vue +24 -3
  143. package/multiselect/multiselect.cjs.js +24 -3
  144. package/multiselect/multiselect.cjs.min.js +1 -1
  145. package/multiselect/multiselect.esm.js +24 -3
  146. package/multiselect/multiselect.esm.min.js +1 -1
  147. package/multiselect/multiselect.js +24 -3
  148. package/multiselect/multiselect.min.js +1 -1
  149. package/overlaypanel/OverlayPanel.d.ts +2 -1
  150. package/overlaypanel/OverlayPanel.vue +31 -5
  151. package/overlaypanel/overlaypanel.cjs.js +49 -17
  152. package/overlaypanel/overlaypanel.cjs.min.js +1 -1
  153. package/overlaypanel/overlaypanel.esm.js +48 -17
  154. package/overlaypanel/overlaypanel.esm.min.js +1 -1
  155. package/overlaypanel/overlaypanel.js +48 -17
  156. package/overlaypanel/overlaypanel.min.js +1 -1
  157. package/package.json +1 -1
  158. package/paginator/Paginator.vue +5 -3
  159. package/paginator/paginator.cjs.js +5 -3
  160. package/paginator/paginator.cjs.min.js +1 -1
  161. package/paginator/paginator.esm.js +5 -3
  162. package/paginator/paginator.esm.min.js +1 -1
  163. package/paginator/paginator.js +5 -3
  164. package/paginator/paginator.min.js +1 -1
  165. package/panelmenu/PanelMenuList.vue +1 -2
  166. package/panelmenu/panelmenu.cjs.js +4 -622
  167. package/panelmenu/panelmenu.cjs.min.js +1 -1
  168. package/panelmenu/panelmenu.esm.js +13 -631
  169. package/panelmenu/panelmenu.esm.min.js +1 -1
  170. package/panelmenu/panelmenu.js +4 -622
  171. package/panelmenu/panelmenu.min.js +1 -1
  172. package/resources/primevue.css +4 -2
  173. package/resources/primevue.min.css +1 -1
  174. package/scrollpanel/ScrollPanel.vue +5 -0
  175. package/scrollpanel/scrollpanel.cjs.js +1 -1
  176. package/scrollpanel/scrollpanel.cjs.min.js +1 -1
  177. package/scrollpanel/scrollpanel.esm.js +1 -1
  178. package/scrollpanel/scrollpanel.esm.min.js +1 -1
  179. package/scrollpanel/scrollpanel.js +1 -1
  180. package/scrollpanel/scrollpanel.min.js +1 -1
  181. package/sidebar/Sidebar.d.ts +5 -5
  182. package/sidebar/Sidebar.vue +46 -14
  183. package/sidebar/sidebar.cjs.js +73 -30
  184. package/sidebar/sidebar.cjs.min.js +1 -1
  185. package/sidebar/sidebar.esm.js +72 -30
  186. package/sidebar/sidebar.esm.min.js +1 -1
  187. package/sidebar/sidebar.js +72 -30
  188. package/sidebar/sidebar.min.js +1 -1
  189. package/slider/Slider.vue +21 -12
  190. package/slider/slider.cjs.js +21 -12
  191. package/slider/slider.cjs.min.js +1 -1
  192. package/slider/slider.esm.js +21 -12
  193. package/slider/slider.esm.min.js +1 -1
  194. package/slider/slider.js +21 -12
  195. package/slider/slider.min.js +1 -1
  196. package/splitter/Splitter.d.ts +16 -0
  197. package/splitter/Splitter.vue +2 -1
  198. package/splitter/splitter.cjs.js +2 -1
  199. package/splitter/splitter.cjs.min.js +1 -1
  200. package/splitter/splitter.esm.js +2 -1
  201. package/splitter/splitter.esm.min.js +1 -1
  202. package/splitter/splitter.js +2 -1
  203. package/splitter/splitter.min.js +1 -1
  204. package/tieredmenu/TieredMenu.vue +1 -2
  205. package/tieredmenu/tieredmenu.cjs.js +1 -2
  206. package/tieredmenu/tieredmenu.cjs.min.js +1 -1
  207. package/tieredmenu/tieredmenu.esm.js +1 -2
  208. package/tieredmenu/tieredmenu.esm.min.js +1 -1
  209. package/tieredmenu/tieredmenu.js +1 -2
  210. package/tieredmenu/tieredmenu.min.js +1 -1
  211. package/toast/Toast.d.ts +25 -0
  212. package/toast/Toast.vue +32 -1
  213. package/toast/ToastMessage.vue +12 -7
  214. package/toast/toast.cjs.js +44 -14
  215. package/toast/toast.cjs.min.js +1 -1
  216. package/toast/toast.esm.js +44 -14
  217. package/toast/toast.esm.min.js +1 -1
  218. package/toast/toast.js +44 -14
  219. package/toast/toast.min.js +1 -1
  220. package/tooltip/tooltip.cjs.js +28 -5
  221. package/tooltip/tooltip.cjs.min.js +1 -1
  222. package/tooltip/tooltip.esm.js +28 -5
  223. package/tooltip/tooltip.esm.min.js +1 -1
  224. package/tooltip/tooltip.js +28 -5
  225. package/tooltip/tooltip.min.js +1 -1
  226. package/utils/Utils.d.ts +1 -0
  227. package/utils/utils.cjs.js +6 -0
  228. package/utils/utils.cjs.min.js +1 -1
  229. package/utils/utils.esm.js +6 -0
  230. package/utils/utils.esm.min.js +1 -1
  231. package/utils/utils.js +6 -0
  232. package/utils/utils.min.js +1 -1
  233. package/vetur-attributes.json +75 -11
  234. package/vetur-tags.json +25 -8
  235. package/web-types.json +233 -21
@@ -1,11 +1,12 @@
1
1
  this.primevue = this.primevue || {};
2
- this.primevue.sidebar = (function (utils, Ripple, Portal, vue) {
2
+ this.primevue.sidebar = (function (FocusTrap, Portal, Ripple, utils, vue) {
3
3
  'use strict';
4
4
 
5
5
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
6
6
 
7
- var Ripple__default = /*#__PURE__*/_interopDefaultLegacy(Ripple);
7
+ var FocusTrap__default = /*#__PURE__*/_interopDefaultLegacy(FocusTrap);
8
8
  var Portal__default = /*#__PURE__*/_interopDefaultLegacy(Portal);
9
+ var Ripple__default = /*#__PURE__*/_interopDefaultLegacy(Ripple);
9
10
 
10
11
  var script = {
11
12
  name: 'Sidebar',
@@ -36,18 +37,21 @@ this.primevue.sidebar = (function (utils, Ripple, Portal, vue) {
36
37
  type: Boolean,
37
38
  default: true
38
39
  },
40
+ closeIcon: {
41
+ type: String,
42
+ default: 'pi pi-times'
43
+ },
39
44
  modal: {
40
45
  type: Boolean,
41
46
  default: true
42
- },
43
- ariaCloseLabel: {
44
- type: String,
45
- default: 'close'
46
47
  }
47
48
  },
48
49
  mask: null,
49
50
  maskClickListener: null,
50
51
  container: null,
52
+ content: null,
53
+ headerContainer: null,
54
+ closeButton: null,
51
55
  beforeUnmount() {
52
56
  this.destroyModal();
53
57
 
@@ -87,11 +91,21 @@ this.primevue.sidebar = (function (utils, Ripple, Portal, vue) {
87
91
  }
88
92
  },
89
93
  focus() {
90
- let focusable = utils.DomHandler.findSingle(this.container, 'input,button');
94
+ const findFocusableElement = (container) => {
95
+ return container.querySelector('[autofocus]');
96
+ };
97
+
98
+ let focusTarget = this.$slots.default && findFocusableElement(this.content);
99
+
100
+ if (!focusTarget) {
101
+ focusTarget = this.$slots.header && findFocusableElement(this.headerContainer);
91
102
 
92
- if (focusable) {
93
- focusable.focus();
103
+ if (!focusTarget) {
104
+ focusTarget = findFocusableElement(this.container);
105
+ }
94
106
  }
107
+
108
+ focusTarget && focusTarget.focus();
95
109
  },
96
110
  enableModality() {
97
111
  if (!this.mask) {
@@ -124,6 +138,11 @@ this.primevue.sidebar = (function (utils, Ripple, Portal, vue) {
124
138
  this.mask.addEventListener('click', this.maskClickListener);
125
139
  }
126
140
  },
141
+ onKeydown(event) {
142
+ if (event.code === 'Escape') {
143
+ this.hide();
144
+ }
145
+ },
127
146
  unbindMaskClickListener() {
128
147
  if (this.maskClickListener) {
129
148
  this.mask.removeEventListener('click', this.maskClickListener);
@@ -140,6 +159,15 @@ this.primevue.sidebar = (function (utils, Ripple, Portal, vue) {
140
159
  },
141
160
  containerRef(el) {
142
161
  this.container = el;
162
+ },
163
+ contentRef(el) {
164
+ this.content = el;
165
+ },
166
+ headerContainerRef(el) {
167
+ this.headerContainer = el;
168
+ },
169
+ closeButtonRef(el) {
170
+ this.closeButton = el;
143
171
  }
144
172
  },
145
173
  computed: {
@@ -155,9 +183,13 @@ this.primevue.sidebar = (function (utils, Ripple, Portal, vue) {
155
183
  },
156
184
  fullScreen() {
157
185
  return this.position === 'full';
186
+ },
187
+ closeAriaLabel() {
188
+ return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.close : undefined;
158
189
  }
159
190
  },
160
191
  directives: {
192
+ focustrap: FocusTrap__default["default"],
161
193
  ripple: Ripple__default["default"]
162
194
  },
163
195
  components: {
@@ -166,21 +198,16 @@ this.primevue.sidebar = (function (utils, Ripple, Portal, vue) {
166
198
  };
167
199
 
168
200
  const _hoisted_1 = ["aria-modal"];
169
- const _hoisted_2 = { class: "p-sidebar-header" };
170
- const _hoisted_3 = {
201
+ const _hoisted_2 = {
171
202
  key: 0,
172
203
  class: "p-sidebar-header-content"
173
204
  };
174
- const _hoisted_4 = ["aria-label"];
175
- const _hoisted_5 = /*#__PURE__*/vue.createElementVNode("span", { class: "p-sidebar-close-icon pi pi-times" }, null, -1);
176
- const _hoisted_6 = [
177
- _hoisted_5
178
- ];
179
- const _hoisted_7 = { class: "p-sidebar-content" };
205
+ const _hoisted_3 = ["aria-label"];
180
206
 
181
207
  function render(_ctx, _cache, $props, $setup, $data, $options) {
182
208
  const _component_Portal = vue.resolveComponent("Portal");
183
209
  const _directive_ripple = vue.resolveDirective("ripple");
210
+ const _directive_focustrap = vue.resolveDirective("focustrap");
184
211
 
185
212
  return (vue.openBlock(), vue.createBlock(_component_Portal, null, {
186
213
  default: vue.withCtx(() => [
@@ -193,35 +220,50 @@ this.primevue.sidebar = (function (utils, Ripple, Portal, vue) {
193
220
  }, {
194
221
  default: vue.withCtx(() => [
195
222
  ($props.visible)
196
- ? (vue.openBlock(), vue.createElementBlock("div", vue.mergeProps({
223
+ ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", vue.mergeProps({
197
224
  key: 0,
198
225
  ref: $options.containerRef,
199
226
  class: $options.containerClass,
200
227
  role: "complementary",
201
- "aria-modal": $props.modal
228
+ "aria-modal": $props.modal,
229
+ onKeydown: _cache[1] || (_cache[1] = (...args) => ($options.onKeydown && $options.onKeydown(...args)))
202
230
  }, _ctx.$attrs), [
203
- vue.createElementVNode("div", _hoisted_2, [
231
+ vue.createElementVNode("div", {
232
+ ref: $options.headerContainerRef,
233
+ class: "p-sidebar-header"
234
+ }, [
204
235
  (_ctx.$slots.header)
205
- ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, [
236
+ ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [
206
237
  vue.renderSlot(_ctx.$slots, "header")
207
238
  ]))
208
239
  : vue.createCommentVNode("", true),
209
240
  ($props.showCloseIcon)
210
241
  ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("button", {
211
242
  key: 1,
243
+ ref: $options.closeButtonRef,
244
+ autofocus: "",
245
+ type: "button",
212
246
  class: "p-sidebar-close p-sidebar-icon p-link",
213
- onClick: _cache[0] || (_cache[0] = (...args) => ($options.hide && $options.hide(...args))),
214
- "aria-label": $props.ariaCloseLabel,
215
- type: "button"
216
- }, _hoisted_6, 8, _hoisted_4)), [
247
+ "aria-label": $options.closeAriaLabel,
248
+ onClick: _cache[0] || (_cache[0] = (...args) => ($options.hide && $options.hide(...args)))
249
+ }, [
250
+ vue.createElementVNode("span", {
251
+ class: vue.normalizeClass(['p-sidebar-close-icon', $props.closeIcon])
252
+ }, null, 2)
253
+ ], 8, _hoisted_3)), [
217
254
  [_directive_ripple]
218
255
  ])
219
256
  : vue.createCommentVNode("", true)
220
- ]),
221
- vue.createElementVNode("div", _hoisted_7, [
257
+ ], 512),
258
+ vue.createElementVNode("div", {
259
+ ref: $options.contentRef,
260
+ class: "p-sidebar-content"
261
+ }, [
222
262
  vue.renderSlot(_ctx.$slots, "default")
223
- ])
224
- ], 16, _hoisted_1))
263
+ ], 512)
264
+ ], 16, _hoisted_1)), [
265
+ [_directive_focustrap]
266
+ ])
225
267
  : vue.createCommentVNode("", true)
226
268
  ]),
227
269
  _: 3
@@ -265,4 +307,4 @@ this.primevue.sidebar = (function (utils, Ripple, Portal, vue) {
265
307
 
266
308
  return script;
267
309
 
268
- })(primevue.utils, primevue.ripple, primevue.portal, Vue);
310
+ })(primevue.focustrap, primevue.portal, primevue.ripple, primevue.utils, Vue);
@@ -1 +1 @@
1
- this.primevue=this.primevue||{},this.primevue.sidebar=function(e,t,n,i){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=s(t),r=s(n),o={name:"Sidebar",inheritAttrs:!1,emits:["update:visible","show","hide"],props:{visible:{type:Boolean,default:!1},position:{type:String,default:"left"},baseZIndex:{type:Number,default:0},autoZIndex:{type:Boolean,default:!0},dismissable:{type:Boolean,default:!0},showCloseIcon:{type:Boolean,default:!0},modal:{type:Boolean,default:!0},ariaCloseLabel:{type:String,default:"close"}},mask:null,maskClickListener:null,container:null,beforeUnmount(){this.destroyModal(),this.container&&this.autoZIndex&&e.ZIndexUtils.clear(this.container),this.container=null},methods:{hide(){this.$emit("update:visible",!1)},onEnter(t){this.$emit("show"),this.autoZIndex&&e.ZIndexUtils.set("modal",t,this.baseZIndex||this.$primevue.config.zIndex.modal),this.focus(),this.modal&&!this.fullScreen&&this.enableModality()},onLeave(){this.$emit("hide"),this.modal&&!this.fullScreen&&this.disableModality()},onAfterLeave(t){this.autoZIndex&&e.ZIndexUtils.clear(t)},focus(){let t=e.DomHandler.findSingle(this.container,"input,button");t&&t.focus()},enableModality(){this.mask||(this.mask=document.createElement("div"),this.mask.setAttribute("class","p-sidebar-mask p-component-overlay p-component-overlay-enter"),this.mask.style.zIndex=String(parseInt(this.container.style.zIndex,10)-1),this.dismissable&&this.bindMaskClickListener(),document.body.appendChild(this.mask),e.DomHandler.addClass(document.body,"p-overflow-hidden"))},disableModality(){this.mask&&(e.DomHandler.addClass(this.mask,"p-component-overlay-leave"),this.mask.addEventListener("animationend",(()=>{this.destroyModal()})))},bindMaskClickListener(){this.maskClickListener||(this.maskClickListener=()=>{this.hide()},this.mask.addEventListener("click",this.maskClickListener))},unbindMaskClickListener(){this.maskClickListener&&(this.mask.removeEventListener("click",this.maskClickListener),this.maskClickListener=null)},destroyModal(){this.mask&&(this.unbindMaskClickListener(),document.body.removeChild(this.mask),e.DomHandler.removeClass(document.body,"p-overflow-hidden"),this.mask=null)},containerRef(e){this.container=e}},computed:{containerClass(){return["p-sidebar p-component p-sidebar-"+this.position,{"p-sidebar-active":this.visible,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},fullScreen(){return"full"===this.position}},directives:{ripple:a.default},components:{Portal:r.default}};const l=["aria-modal"],d={class:"p-sidebar-header"},p={key:0,class:"p-sidebar-header-content"},m=["aria-label"],b=[i.createElementVNode("span",{class:"p-sidebar-close-icon pi pi-times"},null,-1)],c={class:"p-sidebar-content"};return function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===n&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-sidebar {\n position: fixed;\n -webkit-transition: -webkit-transform 0.3s;\n transition: -webkit-transform 0.3s;\n transition: transform 0.3s;\n transition: transform 0.3s, -webkit-transform 0.3s;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-sidebar-content {\n position: relative;\n overflow-y: auto;\n}\n.p-sidebar-header {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: end;\n -ms-flex-pack: end;\n justify-content: flex-end;\n}\n.p-sidebar-icon {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n position: relative;\n overflow: hidden;\n}\n.p-sidebar-left {\n top: 0;\n left: 0;\n width: 20rem;\n height: 100%;\n}\n.p-sidebar-right {\n top: 0;\n right: 0;\n width: 20rem;\n height: 100%;\n}\n.p-sidebar-top {\n top: 0;\n left: 0;\n width: 100%;\n height: 10rem;\n}\n.p-sidebar-bottom {\n bottom: 0;\n left: 0;\n width: 100%;\n height: 10rem;\n}\n.p-sidebar-full {\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n -webkit-transition: none;\n transition: none;\n}\n.p-sidebar-left.p-sidebar-enter-from,\n.p-sidebar-left.p-sidebar-leave-to {\n -webkit-transform: translateX(-100%);\n transform: translateX(-100%);\n}\n.p-sidebar-right.p-sidebar-enter-from,\n.p-sidebar-right.p-sidebar-leave-to {\n -webkit-transform: translateX(100%);\n transform: translateX(100%);\n}\n.p-sidebar-top.p-sidebar-enter-from,\n.p-sidebar-top.p-sidebar-leave-to {\n -webkit-transform: translateY(-100%);\n transform: translateY(-100%);\n}\n.p-sidebar-bottom.p-sidebar-enter-from,\n.p-sidebar-bottom.p-sidebar-leave-to {\n -webkit-transform: translateY(100%);\n transform: translateY(100%);\n}\n.p-sidebar-full.p-sidebar-enter-from,\n.p-sidebar-full.p-sidebar-leave-to {\n opacity: 0;\n}\n.p-sidebar-full.p-sidebar-enter-active,\n.p-sidebar-full.p-sidebar-leave-active {\n -webkit-transition: opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1);\n transition: opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1);\n}\n.p-sidebar-left.p-sidebar-sm,\n.p-sidebar-right.p-sidebar-sm {\n width: 20rem;\n}\n.p-sidebar-left.p-sidebar-md,\n.p-sidebar-right.p-sidebar-md {\n width: 40rem;\n}\n.p-sidebar-left.p-sidebar-lg,\n.p-sidebar-right.p-sidebar-lg {\n width: 60rem;\n}\n.p-sidebar-top.p-sidebar-sm,\n.p-sidebar-bottom.p-sidebar-sm {\n height: 10rem;\n}\n.p-sidebar-top.p-sidebar-md,\n.p-sidebar-bottom.p-sidebar-md {\n height: 20rem;\n}\n.p-sidebar-top.p-sidebar-lg,\n.p-sidebar-bottom.p-sidebar-lg {\n height: 30rem;\n}\n@media screen and (max-width: 64em) {\n.p-sidebar-left.p-sidebar-lg,\n .p-sidebar-left.p-sidebar-md,\n .p-sidebar-right.p-sidebar-lg,\n .p-sidebar-right.p-sidebar-md {\n width: 20rem;\n}\n}\n"),o.render=function(e,t,n,s,a,r){const o=i.resolveComponent("Portal"),h=i.resolveDirective("ripple");return i.openBlock(),i.createBlock(o,null,{default:i.withCtx((()=>[i.createVNode(i.Transition,{name:"p-sidebar",onEnter:r.onEnter,onLeave:r.onLeave,onAfterLeave:r.onAfterLeave,appear:""},{default:i.withCtx((()=>[n.visible?(i.openBlock(),i.createElementBlock("div",i.mergeProps({key:0,ref:r.containerRef,class:r.containerClass,role:"complementary","aria-modal":n.modal},e.$attrs),[i.createElementVNode("div",d,[e.$slots.header?(i.openBlock(),i.createElementBlock("div",p,[i.renderSlot(e.$slots,"header")])):i.createCommentVNode("",!0),n.showCloseIcon?i.withDirectives((i.openBlock(),i.createElementBlock("button",{key:1,class:"p-sidebar-close p-sidebar-icon p-link",onClick:t[0]||(t[0]=(...e)=>r.hide&&r.hide(...e)),"aria-label":n.ariaCloseLabel,type:"button"},b,8,m)),[[h]]):i.createCommentVNode("",!0)]),i.createElementVNode("div",c,[i.renderSlot(e.$slots,"default")])],16,l)):i.createCommentVNode("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3})},o}(primevue.utils,primevue.ripple,primevue.portal,Vue);
1
+ this.primevue=this.primevue||{},this.primevue.sidebar=function(e,t,n,i,s){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=a(e),o=a(t),l=a(n),d={name:"Sidebar",inheritAttrs:!1,emits:["update:visible","show","hide"],props:{visible:{type:Boolean,default:!1},position:{type:String,default:"left"},baseZIndex:{type:Number,default:0},autoZIndex:{type:Boolean,default:!0},dismissable:{type:Boolean,default:!0},showCloseIcon:{type:Boolean,default:!0},closeIcon:{type:String,default:"pi pi-times"},modal:{type:Boolean,default:!0}},mask:null,maskClickListener:null,container:null,content:null,headerContainer:null,closeButton:null,beforeUnmount(){this.destroyModal(),this.container&&this.autoZIndex&&i.ZIndexUtils.clear(this.container),this.container=null},methods:{hide(){this.$emit("update:visible",!1)},onEnter(e){this.$emit("show"),this.autoZIndex&&i.ZIndexUtils.set("modal",e,this.baseZIndex||this.$primevue.config.zIndex.modal),this.focus(),this.modal&&!this.fullScreen&&this.enableModality()},onLeave(){this.$emit("hide"),this.modal&&!this.fullScreen&&this.disableModality()},onAfterLeave(e){this.autoZIndex&&i.ZIndexUtils.clear(e)},focus(){const e=e=>e.querySelector("[autofocus]");let t=this.$slots.default&&e(this.content);t||(t=this.$slots.header&&e(this.headerContainer),t||(t=e(this.container))),t&&t.focus()},enableModality(){this.mask||(this.mask=document.createElement("div"),this.mask.setAttribute("class","p-sidebar-mask p-component-overlay p-component-overlay-enter"),this.mask.style.zIndex=String(parseInt(this.container.style.zIndex,10)-1),this.dismissable&&this.bindMaskClickListener(),document.body.appendChild(this.mask),i.DomHandler.addClass(document.body,"p-overflow-hidden"))},disableModality(){this.mask&&(i.DomHandler.addClass(this.mask,"p-component-overlay-leave"),this.mask.addEventListener("animationend",(()=>{this.destroyModal()})))},bindMaskClickListener(){this.maskClickListener||(this.maskClickListener=()=>{this.hide()},this.mask.addEventListener("click",this.maskClickListener))},onKeydown(e){"Escape"===e.code&&this.hide()},unbindMaskClickListener(){this.maskClickListener&&(this.mask.removeEventListener("click",this.maskClickListener),this.maskClickListener=null)},destroyModal(){this.mask&&(this.unbindMaskClickListener(),document.body.removeChild(this.mask),i.DomHandler.removeClass(document.body,"p-overflow-hidden"),this.mask=null)},containerRef(e){this.container=e},contentRef(e){this.content=e},headerContainerRef(e){this.headerContainer=e},closeButtonRef(e){this.closeButton=e}},computed:{containerClass(){return["p-sidebar p-component p-sidebar-"+this.position,{"p-sidebar-active":this.visible,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},fullScreen(){return"full"===this.position},closeAriaLabel(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.close:void 0}},directives:{focustrap:r.default,ripple:l.default},components:{Portal:o.default}};const p=["aria-modal"],c={key:0,class:"p-sidebar-header-content"},m=["aria-label"];return function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===n&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-sidebar {\n position: fixed;\n -webkit-transition: -webkit-transform 0.3s;\n transition: -webkit-transform 0.3s;\n transition: transform 0.3s;\n transition: transform 0.3s, -webkit-transform 0.3s;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-sidebar-content {\n position: relative;\n overflow-y: auto;\n}\n.p-sidebar-header {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: end;\n -ms-flex-pack: end;\n justify-content: flex-end;\n}\n.p-sidebar-icon {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n position: relative;\n overflow: hidden;\n}\n.p-sidebar-left {\n top: 0;\n left: 0;\n width: 20rem;\n height: 100%;\n}\n.p-sidebar-right {\n top: 0;\n right: 0;\n width: 20rem;\n height: 100%;\n}\n.p-sidebar-top {\n top: 0;\n left: 0;\n width: 100%;\n height: 10rem;\n}\n.p-sidebar-bottom {\n bottom: 0;\n left: 0;\n width: 100%;\n height: 10rem;\n}\n.p-sidebar-full {\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n -webkit-transition: none;\n transition: none;\n}\n.p-sidebar-left.p-sidebar-enter-from,\n.p-sidebar-left.p-sidebar-leave-to {\n -webkit-transform: translateX(-100%);\n transform: translateX(-100%);\n}\n.p-sidebar-right.p-sidebar-enter-from,\n.p-sidebar-right.p-sidebar-leave-to {\n -webkit-transform: translateX(100%);\n transform: translateX(100%);\n}\n.p-sidebar-top.p-sidebar-enter-from,\n.p-sidebar-top.p-sidebar-leave-to {\n -webkit-transform: translateY(-100%);\n transform: translateY(-100%);\n}\n.p-sidebar-bottom.p-sidebar-enter-from,\n.p-sidebar-bottom.p-sidebar-leave-to {\n -webkit-transform: translateY(100%);\n transform: translateY(100%);\n}\n.p-sidebar-full.p-sidebar-enter-from,\n.p-sidebar-full.p-sidebar-leave-to {\n opacity: 0;\n}\n.p-sidebar-full.p-sidebar-enter-active,\n.p-sidebar-full.p-sidebar-leave-active {\n -webkit-transition: opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1);\n transition: opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1);\n}\n.p-sidebar-left.p-sidebar-sm,\n.p-sidebar-right.p-sidebar-sm {\n width: 20rem;\n}\n.p-sidebar-left.p-sidebar-md,\n.p-sidebar-right.p-sidebar-md {\n width: 40rem;\n}\n.p-sidebar-left.p-sidebar-lg,\n.p-sidebar-right.p-sidebar-lg {\n width: 60rem;\n}\n.p-sidebar-top.p-sidebar-sm,\n.p-sidebar-bottom.p-sidebar-sm {\n height: 10rem;\n}\n.p-sidebar-top.p-sidebar-md,\n.p-sidebar-bottom.p-sidebar-md {\n height: 20rem;\n}\n.p-sidebar-top.p-sidebar-lg,\n.p-sidebar-bottom.p-sidebar-lg {\n height: 30rem;\n}\n@media screen and (max-width: 64em) {\n.p-sidebar-left.p-sidebar-lg,\n .p-sidebar-left.p-sidebar-md,\n .p-sidebar-right.p-sidebar-lg,\n .p-sidebar-right.p-sidebar-md {\n width: 20rem;\n}\n}\n"),d.render=function(e,t,n,i,a,r){const o=s.resolveComponent("Portal"),l=s.resolveDirective("ripple"),d=s.resolveDirective("focustrap");return s.openBlock(),s.createBlock(o,null,{default:s.withCtx((()=>[s.createVNode(s.Transition,{name:"p-sidebar",onEnter:r.onEnter,onLeave:r.onLeave,onAfterLeave:r.onAfterLeave,appear:""},{default:s.withCtx((()=>[n.visible?s.withDirectives((s.openBlock(),s.createElementBlock("div",s.mergeProps({key:0,ref:r.containerRef,class:r.containerClass,role:"complementary","aria-modal":n.modal,onKeydown:t[1]||(t[1]=(...e)=>r.onKeydown&&r.onKeydown(...e))},e.$attrs),[s.createElementVNode("div",{ref:r.headerContainerRef,class:"p-sidebar-header"},[e.$slots.header?(s.openBlock(),s.createElementBlock("div",c,[s.renderSlot(e.$slots,"header")])):s.createCommentVNode("",!0),n.showCloseIcon?s.withDirectives((s.openBlock(),s.createElementBlock("button",{key:1,ref:r.closeButtonRef,autofocus:"",type:"button",class:"p-sidebar-close p-sidebar-icon p-link","aria-label":r.closeAriaLabel,onClick:t[0]||(t[0]=(...e)=>r.hide&&r.hide(...e))},[s.createElementVNode("span",{class:s.normalizeClass(["p-sidebar-close-icon",n.closeIcon])},null,2)],8,m)),[[l]]):s.createCommentVNode("",!0)],512),s.createElementVNode("div",{ref:r.contentRef,class:"p-sidebar-content"},[s.renderSlot(e.$slots,"default")],512)],16,p)),[[d]]):s.createCommentVNode("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3})},d}(primevue.focustrap,primevue.portal,primevue.ripple,primevue.utils,Vue);
package/slider/Slider.vue CHANGED
@@ -152,21 +152,27 @@ export default {
152
152
  modelValue = this.modelValue ? [...this.modelValue] : [];
153
153
 
154
154
  if (this.handleIndex == 0) {
155
- let maxValue = this.modelValue ? this.modelValue[1] : this.max;
156
-
157
155
  if (newValue < this.min) newValue = this.min;
158
- else if (newValue >= maxValue) newValue = maxValue;
156
+ else if (newValue >= this.max) newValue = this.max;
159
157
 
160
- modelValue[0] = newValue;
161
- modelValue[1] = modelValue[1] || this.max;
162
- } else {
163
- let minValue = this.modelValue ? this.modelValue[0] : this.min;
158
+ if (newValue > modelValue[1]) {
159
+ modelValue[1] = newValue;
164
160
 
161
+ this.handleIndex = 1;
162
+ } else {
163
+ modelValue[0] = newValue;
164
+ }
165
+ } else {
165
166
  if (newValue > this.max) newValue = this.max;
166
- else if (newValue <= minValue) newValue = minValue;
167
+ else if (newValue <= this.min) newValue = this.min;
167
168
 
168
- modelValue[0] = modelValue[0] || this.min;
169
- modelValue[1] = newValue;
169
+ if (newValue < modelValue[0]) {
170
+ modelValue[0] = newValue;
171
+
172
+ this.handleIndex = 0;
173
+ } else {
174
+ modelValue[1] = newValue;
175
+ }
170
176
  }
171
177
  } else {
172
178
  if (newValue < this.min) newValue = this.min;
@@ -334,8 +340,11 @@ export default {
334
340
  },
335
341
  rangeStyle() {
336
342
  if (this.range) {
337
- if (this.horizontal) return { left: this.rangeStartPosition + '%', width: this.rangeEndPosition - this.rangeStartPosition + '%' };
338
- else return { bottom: this.rangeStartPosition + '%', height: this.rangeEndPosition - this.rangeStartHandlePosition + '%' };
343
+ const rangeSliderWidth = this.rangeEndPosition > this.rangeStartPosition ? this.rangeEndPosition - this.rangeStartPosition : this.rangeStartPosition - this.rangeEndPosition;
344
+ const rangeSliderPosition = this.rangeEndPosition > this.rangeStartPosition ? this.rangeStartPosition : this.rangeEndPosition;
345
+
346
+ if (this.horizontal) return { left: rangeSliderPosition + '%', width: rangeSliderWidth + '%' };
347
+ else return { bottom: rangeSliderPosition + '%', height: rangeSliderWidth + '%' };
339
348
  } else {
340
349
  if (this.horizontal) return { width: this.handlePosition + '%' };
341
350
  else return { height: this.handlePosition + '%' };
@@ -94,21 +94,27 @@ var script = {
94
94
  modelValue = this.modelValue ? [...this.modelValue] : [];
95
95
 
96
96
  if (this.handleIndex == 0) {
97
- let maxValue = this.modelValue ? this.modelValue[1] : this.max;
98
-
99
97
  if (newValue < this.min) newValue = this.min;
100
- else if (newValue >= maxValue) newValue = maxValue;
98
+ else if (newValue >= this.max) newValue = this.max;
101
99
 
102
- modelValue[0] = newValue;
103
- modelValue[1] = modelValue[1] || this.max;
104
- } else {
105
- let minValue = this.modelValue ? this.modelValue[0] : this.min;
100
+ if (newValue > modelValue[1]) {
101
+ modelValue[1] = newValue;
106
102
 
103
+ this.handleIndex = 1;
104
+ } else {
105
+ modelValue[0] = newValue;
106
+ }
107
+ } else {
107
108
  if (newValue > this.max) newValue = this.max;
108
- else if (newValue <= minValue) newValue = minValue;
109
+ else if (newValue <= this.min) newValue = this.min;
109
110
 
110
- modelValue[0] = modelValue[0] || this.min;
111
- modelValue[1] = newValue;
111
+ if (newValue < modelValue[0]) {
112
+ modelValue[0] = newValue;
113
+
114
+ this.handleIndex = 0;
115
+ } else {
116
+ modelValue[1] = newValue;
117
+ }
112
118
  }
113
119
  } else {
114
120
  if (newValue < this.min) newValue = this.min;
@@ -273,8 +279,11 @@ var script = {
273
279
  },
274
280
  rangeStyle() {
275
281
  if (this.range) {
276
- if (this.horizontal) return { left: this.rangeStartPosition + '%', width: this.rangeEndPosition - this.rangeStartPosition + '%' };
277
- else return { bottom: this.rangeStartPosition + '%', height: this.rangeEndPosition - this.rangeStartHandlePosition + '%' };
282
+ const rangeSliderWidth = this.rangeEndPosition > this.rangeStartPosition ? this.rangeEndPosition - this.rangeStartPosition : this.rangeStartPosition - this.rangeEndPosition;
283
+ const rangeSliderPosition = this.rangeEndPosition > this.rangeStartPosition ? this.rangeStartPosition : this.rangeEndPosition;
284
+
285
+ if (this.horizontal) return { left: rangeSliderPosition + '%', width: rangeSliderWidth + '%' };
286
+ else return { bottom: rangeSliderPosition + '%', height: rangeSliderWidth + '%' };
278
287
  } else {
279
288
  if (this.horizontal) return { width: this.handlePosition + '%' };
280
289
  else return { height: this.handlePosition + '%' };
@@ -1 +1 @@
1
- "use strict";var e=require("primevue/utils"),t=require("vue"),i={name:"Slider",emits:["update:modelValue","change","slideend"],props:{modelValue:[Number,Array],min:{type:Number,default:0},max:{type:Number,default:100},orientation:{type:String,default:"horizontal"},step:{type:Number,default:null},range:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},tabindex:{type:Number,default:0},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},dragging:!1,handleIndex:null,initX:null,initY:null,barWidth:null,barHeight:null,dragListener:null,dragEndListener:null,beforeUnmount(){this.unbindDragListeners()},methods:{updateDomData(){let t=this.$el.getBoundingClientRect();this.initX=t.left+e.DomHandler.getWindowScrollLeft(),this.initY=t.top+e.DomHandler.getWindowScrollTop(),this.barWidth=this.$el.offsetWidth,this.barHeight=this.$el.offsetHeight},setValue(e){let t,i=e.touches?e.touches[0].pageX:e.pageX,a=e.touches?e.touches[0].pageY:e.pageY;t="horizontal"===this.orientation?100*(i-this.initX)/this.barWidth:100*(this.initY+this.barHeight-a)/this.barHeight;let n=(this.max-this.min)*(t/100)+this.min;if(this.step){const e=this.range?this.modelValue[this.handleIndex]:this.modelValue,t=n-e;t<0?n=e+Math.ceil(n/this.step-e/this.step)*this.step:t>0&&(n=e+Math.floor(n/this.step-e/this.step)*this.step)}else n=Math.floor(n);this.updateModel(e,n)},updateModel(e,t){let i,a=parseFloat(t.toFixed(10));if(this.range)if(i=this.modelValue?[...this.modelValue]:[],0==this.handleIndex){let e=this.modelValue?this.modelValue[1]:this.max;a<this.min?a=this.min:a>=e&&(a=e),i[0]=a,i[1]=i[1]||this.max}else{let e=this.modelValue?this.modelValue[0]:this.min;a>this.max?a=this.max:a<=e&&(a=e),i[0]=i[0]||this.min,i[1]=a}else a<this.min?a=this.min:a>this.max&&(a=this.max),i=a;this.$emit("update:modelValue",i),this.$emit("change",i)},onDragStart(t,i){this.disabled||(e.DomHandler.addClass(this.$el,"p-slider-sliding"),this.dragging=!0,this.updateDomData(),this.range&&this.modelValue[0]===this.max?this.handleIndex=0:this.handleIndex=i,t.preventDefault())},onDrag(e){this.dragging&&(this.setValue(e),e.preventDefault())},onDragEnd(t){this.dragging&&(this.dragging=!1,e.DomHandler.removeClass(this.$el,"p-slider-sliding"),this.$emit("slideend",{originalEvent:t,value:this.modelValue}))},onBarClick(t){this.disabled||e.DomHandler.hasClass(t.target,"p-slider-handle")||(this.updateDomData(),this.setValue(t))},onMouseDown(e,t){this.bindDragListeners(),this.onDragStart(e,t)},onKeyDown(e,t){switch(this.handleIndex=t,e.code){case"ArrowDown":case"ArrowLeft":this.decrementValue(e,t),e.preventDefault();break;case"ArrowUp":case"ArrowRight":this.incrementValue(e,t),e.preventDefault();break;case"PageDown":this.decrementValue(e,t,!0),e.preventDefault();break;case"PageUp":this.incrementValue(e,t,!0),e.preventDefault();break;case"Home":this.updateModel(e,this.min),e.preventDefault();break;case"End":this.updateModel(e,this.max),e.preventDefault()}},decrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]-this.step:this.modelValue[t]-1:this.step?this.modelValue-this.step:!this.step&&i?this.modelValue-10:this.modelValue-1,this.updateModel(e,a),e.preventDefault()},incrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]+this.step:this.modelValue[t]+1:this.step?this.modelValue+this.step:!this.step&&i?this.modelValue+10:this.modelValue+1,this.updateModel(e,a),e.preventDefault()},bindDragListeners(){this.dragListener||(this.dragListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.dragListener)),this.dragEndListener||(this.dragEndListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.dragEndListener))},unbindDragListeners(){this.dragListener&&(document.removeEventListener("mousemove",this.dragListener),this.dragListener=null),this.dragEndListener&&(document.removeEventListener("mouseup",this.dragEndListener),this.dragEndListener=null)}},computed:{containerClass(){return["p-slider p-component",{"p-disabled":this.disabled,"p-slider-horizontal":"horizontal"===this.orientation,"p-slider-vertical":"vertical"===this.orientation}]},horizontal(){return"horizontal"===this.orientation},vertical(){return"vertical"===this.orientation},rangeStyle(){return this.range?this.horizontal?{left:this.rangeStartPosition+"%",width:this.rangeEndPosition-this.rangeStartPosition+"%"}:{bottom:this.rangeStartPosition+"%",height:this.rangeEndPosition-this.rangeStartHandlePosition+"%"}:this.horizontal?{width:this.handlePosition+"%"}:{height:this.handlePosition+"%"}},handleStyle(){return this.horizontal?{left:this.handlePosition+"%"}:{bottom:this.handlePosition+"%"}},handlePosition(){return this.modelValue<this.min?0:this.modelValue>this.max?100:100*(this.modelValue-this.min)/(this.max-this.min)},rangeStartPosition(){return this.modelValue&&this.modelValue[0]?100*(this.modelValue[0]<this.min?0:this.modelValue[0]-this.min)/(this.max-this.min):0},rangeEndPosition(){return this.modelValue&&2===this.modelValue.length?100*(this.modelValue[1]>this.max?100:this.modelValue[1]-this.min)/(this.max-this.min):100},rangeStartHandleStyle(){return this.horizontal?{left:this.rangeStartPosition+"%"}:{bottom:this.rangeStartPosition+"%"}},rangeEndHandleStyle(){return this.horizontal?{left:this.rangeEndPosition+"%"}:{bottom:this.rangeEndPosition+"%"}}}};const a=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],n=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],l=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"];!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&a.firstChild?a.insertBefore(n,a.firstChild):a.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-slider {\n position: relative;\n}\n.p-slider .p-slider-handle {\n position: absolute;\n cursor: -webkit-grab;\n cursor: grab;\n -ms-touch-action: none;\n touch-action: none;\n display: block;\n}\n.p-slider-range {\n position: absolute;\n display: block;\n}\n.p-slider-horizontal .p-slider-range {\n top: 0;\n left: 0;\n height: 100%;\n}\n.p-slider-horizontal .p-slider-handle {\n top: 50%;\n}\n.p-slider-vertical {\n height: 100px;\n}\n.p-slider-vertical .p-slider-handle {\n left: 50%;\n}\n.p-slider-vertical .p-slider-range {\n bottom: 0;\n left: 0;\n width: 100%;\n}\n"),i.render=function(e,i,s,o,r,d){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(d.containerClass),onClick:i[15]||(i[15]=(...e)=>d.onBarClick&&d.onBarClick(...e))},[t.createElementVNode("span",{class:"p-slider-range",style:t.normalizeStyle(d.rangeStyle)},null,4),s.range?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"p-slider-handle",style:t.normalizeStyle(d.handleStyle),onTouchstart:i[0]||(i[0]=e=>d.onDragStart(e)),onTouchmove:i[1]||(i[1]=e=>d.onDrag(e)),onTouchend:i[2]||(i[2]=e=>d.onDragEnd(e)),onMousedown:i[3]||(i[3]=e=>d.onMouseDown(e)),onKeydown:i[4]||(i[4]=e=>d.onKeyDown(e)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,a)),s.range?(t.openBlock(),t.createElementBlock("span",{key:1,class:"p-slider-handle",style:t.normalizeStyle(d.rangeStartHandleStyle),onTouchstart:i[5]||(i[5]=e=>d.onDragStart(e,0)),onTouchmove:i[6]||(i[6]=e=>d.onDrag(e)),onTouchend:i[7]||(i[7]=e=>d.onDragEnd(e)),onMousedown:i[8]||(i[8]=e=>d.onMouseDown(e,0)),onKeydown:i[9]||(i[9]=e=>d.onKeyDown(e,0)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue?s.modelValue[0]:null,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,n)):t.createCommentVNode("",!0),s.range?(t.openBlock(),t.createElementBlock("span",{key:2,class:"p-slider-handle",style:t.normalizeStyle(d.rangeEndHandleStyle),onTouchstart:i[10]||(i[10]=e=>d.onDragStart(e,1)),onTouchmove:i[11]||(i[11]=e=>d.onDrag(e)),onTouchend:i[12]||(i[12]=e=>d.onDragEnd(e)),onMousedown:i[13]||(i[13]=e=>d.onMouseDown(e,1)),onKeydown:i[14]||(i[14]=e=>d.onKeyDown(e,1)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue?s.modelValue[1]:null,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,l)):t.createCommentVNode("",!0)],2)},module.exports=i;
1
+ "use strict";var e=require("primevue/utils"),t=require("vue"),i={name:"Slider",emits:["update:modelValue","change","slideend"],props:{modelValue:[Number,Array],min:{type:Number,default:0},max:{type:Number,default:100},orientation:{type:String,default:"horizontal"},step:{type:Number,default:null},range:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},tabindex:{type:Number,default:0},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},dragging:!1,handleIndex:null,initX:null,initY:null,barWidth:null,barHeight:null,dragListener:null,dragEndListener:null,beforeUnmount(){this.unbindDragListeners()},methods:{updateDomData(){let t=this.$el.getBoundingClientRect();this.initX=t.left+e.DomHandler.getWindowScrollLeft(),this.initY=t.top+e.DomHandler.getWindowScrollTop(),this.barWidth=this.$el.offsetWidth,this.barHeight=this.$el.offsetHeight},setValue(e){let t,i=e.touches?e.touches[0].pageX:e.pageX,a=e.touches?e.touches[0].pageY:e.pageY;t="horizontal"===this.orientation?100*(i-this.initX)/this.barWidth:100*(this.initY+this.barHeight-a)/this.barHeight;let n=(this.max-this.min)*(t/100)+this.min;if(this.step){const e=this.range?this.modelValue[this.handleIndex]:this.modelValue,t=n-e;t<0?n=e+Math.ceil(n/this.step-e/this.step)*this.step:t>0&&(n=e+Math.floor(n/this.step-e/this.step)*this.step)}else n=Math.floor(n);this.updateModel(e,n)},updateModel(e,t){let i,a=parseFloat(t.toFixed(10));this.range?(i=this.modelValue?[...this.modelValue]:[],0==this.handleIndex?(a<this.min?a=this.min:a>=this.max&&(a=this.max),a>i[1]?(i[1]=a,this.handleIndex=1):i[0]=a):(a>this.max?a=this.max:a<=this.min&&(a=this.min),a<i[0]?(i[0]=a,this.handleIndex=0):i[1]=a)):(a<this.min?a=this.min:a>this.max&&(a=this.max),i=a),this.$emit("update:modelValue",i),this.$emit("change",i)},onDragStart(t,i){this.disabled||(e.DomHandler.addClass(this.$el,"p-slider-sliding"),this.dragging=!0,this.updateDomData(),this.range&&this.modelValue[0]===this.max?this.handleIndex=0:this.handleIndex=i,t.preventDefault())},onDrag(e){this.dragging&&(this.setValue(e),e.preventDefault())},onDragEnd(t){this.dragging&&(this.dragging=!1,e.DomHandler.removeClass(this.$el,"p-slider-sliding"),this.$emit("slideend",{originalEvent:t,value:this.modelValue}))},onBarClick(t){this.disabled||e.DomHandler.hasClass(t.target,"p-slider-handle")||(this.updateDomData(),this.setValue(t))},onMouseDown(e,t){this.bindDragListeners(),this.onDragStart(e,t)},onKeyDown(e,t){switch(this.handleIndex=t,e.code){case"ArrowDown":case"ArrowLeft":this.decrementValue(e,t),e.preventDefault();break;case"ArrowUp":case"ArrowRight":this.incrementValue(e,t),e.preventDefault();break;case"PageDown":this.decrementValue(e,t,!0),e.preventDefault();break;case"PageUp":this.incrementValue(e,t,!0),e.preventDefault();break;case"Home":this.updateModel(e,this.min),e.preventDefault();break;case"End":this.updateModel(e,this.max),e.preventDefault()}},decrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]-this.step:this.modelValue[t]-1:this.step?this.modelValue-this.step:!this.step&&i?this.modelValue-10:this.modelValue-1,this.updateModel(e,a),e.preventDefault()},incrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]+this.step:this.modelValue[t]+1:this.step?this.modelValue+this.step:!this.step&&i?this.modelValue+10:this.modelValue+1,this.updateModel(e,a),e.preventDefault()},bindDragListeners(){this.dragListener||(this.dragListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.dragListener)),this.dragEndListener||(this.dragEndListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.dragEndListener))},unbindDragListeners(){this.dragListener&&(document.removeEventListener("mousemove",this.dragListener),this.dragListener=null),this.dragEndListener&&(document.removeEventListener("mouseup",this.dragEndListener),this.dragEndListener=null)}},computed:{containerClass(){return["p-slider p-component",{"p-disabled":this.disabled,"p-slider-horizontal":"horizontal"===this.orientation,"p-slider-vertical":"vertical"===this.orientation}]},horizontal(){return"horizontal"===this.orientation},vertical(){return"vertical"===this.orientation},rangeStyle(){if(this.range){const e=this.rangeEndPosition>this.rangeStartPosition?this.rangeEndPosition-this.rangeStartPosition:this.rangeStartPosition-this.rangeEndPosition,t=this.rangeEndPosition>this.rangeStartPosition?this.rangeStartPosition:this.rangeEndPosition;return this.horizontal?{left:t+"%",width:e+"%"}:{bottom:t+"%",height:e+"%"}}return this.horizontal?{width:this.handlePosition+"%"}:{height:this.handlePosition+"%"}},handleStyle(){return this.horizontal?{left:this.handlePosition+"%"}:{bottom:this.handlePosition+"%"}},handlePosition(){return this.modelValue<this.min?0:this.modelValue>this.max?100:100*(this.modelValue-this.min)/(this.max-this.min)},rangeStartPosition(){return this.modelValue&&this.modelValue[0]?100*(this.modelValue[0]<this.min?0:this.modelValue[0]-this.min)/(this.max-this.min):0},rangeEndPosition(){return this.modelValue&&2===this.modelValue.length?100*(this.modelValue[1]>this.max?100:this.modelValue[1]-this.min)/(this.max-this.min):100},rangeStartHandleStyle(){return this.horizontal?{left:this.rangeStartPosition+"%"}:{bottom:this.rangeStartPosition+"%"}},rangeEndHandleStyle(){return this.horizontal?{left:this.rangeEndPosition+"%"}:{bottom:this.rangeEndPosition+"%"}}}};const a=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],n=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],l=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"];!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&a.firstChild?a.insertBefore(n,a.firstChild):a.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-slider {\n position: relative;\n}\n.p-slider .p-slider-handle {\n position: absolute;\n cursor: -webkit-grab;\n cursor: grab;\n -ms-touch-action: none;\n touch-action: none;\n display: block;\n}\n.p-slider-range {\n position: absolute;\n display: block;\n}\n.p-slider-horizontal .p-slider-range {\n top: 0;\n left: 0;\n height: 100%;\n}\n.p-slider-horizontal .p-slider-handle {\n top: 50%;\n}\n.p-slider-vertical {\n height: 100px;\n}\n.p-slider-vertical .p-slider-handle {\n left: 50%;\n}\n.p-slider-vertical .p-slider-range {\n bottom: 0;\n left: 0;\n width: 100%;\n}\n"),i.render=function(e,i,s,o,r,d){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(d.containerClass),onClick:i[15]||(i[15]=(...e)=>d.onBarClick&&d.onBarClick(...e))},[t.createElementVNode("span",{class:"p-slider-range",style:t.normalizeStyle(d.rangeStyle)},null,4),s.range?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"p-slider-handle",style:t.normalizeStyle(d.handleStyle),onTouchstart:i[0]||(i[0]=e=>d.onDragStart(e)),onTouchmove:i[1]||(i[1]=e=>d.onDrag(e)),onTouchend:i[2]||(i[2]=e=>d.onDragEnd(e)),onMousedown:i[3]||(i[3]=e=>d.onMouseDown(e)),onKeydown:i[4]||(i[4]=e=>d.onKeyDown(e)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,a)),s.range?(t.openBlock(),t.createElementBlock("span",{key:1,class:"p-slider-handle",style:t.normalizeStyle(d.rangeStartHandleStyle),onTouchstart:i[5]||(i[5]=e=>d.onDragStart(e,0)),onTouchmove:i[6]||(i[6]=e=>d.onDrag(e)),onTouchend:i[7]||(i[7]=e=>d.onDragEnd(e)),onMousedown:i[8]||(i[8]=e=>d.onMouseDown(e,0)),onKeydown:i[9]||(i[9]=e=>d.onKeyDown(e,0)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue?s.modelValue[0]:null,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,n)):t.createCommentVNode("",!0),s.range?(t.openBlock(),t.createElementBlock("span",{key:2,class:"p-slider-handle",style:t.normalizeStyle(d.rangeEndHandleStyle),onTouchstart:i[10]||(i[10]=e=>d.onDragStart(e,1)),onTouchmove:i[11]||(i[11]=e=>d.onDrag(e)),onTouchend:i[12]||(i[12]=e=>d.onDragEnd(e)),onMousedown:i[13]||(i[13]=e=>d.onMouseDown(e,1)),onKeydown:i[14]||(i[14]=e=>d.onKeyDown(e,1)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue?s.modelValue[1]:null,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,l)):t.createCommentVNode("",!0)],2)},module.exports=i;
@@ -92,21 +92,27 @@ var script = {
92
92
  modelValue = this.modelValue ? [...this.modelValue] : [];
93
93
 
94
94
  if (this.handleIndex == 0) {
95
- let maxValue = this.modelValue ? this.modelValue[1] : this.max;
96
-
97
95
  if (newValue < this.min) newValue = this.min;
98
- else if (newValue >= maxValue) newValue = maxValue;
96
+ else if (newValue >= this.max) newValue = this.max;
99
97
 
100
- modelValue[0] = newValue;
101
- modelValue[1] = modelValue[1] || this.max;
102
- } else {
103
- let minValue = this.modelValue ? this.modelValue[0] : this.min;
98
+ if (newValue > modelValue[1]) {
99
+ modelValue[1] = newValue;
104
100
 
101
+ this.handleIndex = 1;
102
+ } else {
103
+ modelValue[0] = newValue;
104
+ }
105
+ } else {
105
106
  if (newValue > this.max) newValue = this.max;
106
- else if (newValue <= minValue) newValue = minValue;
107
+ else if (newValue <= this.min) newValue = this.min;
107
108
 
108
- modelValue[0] = modelValue[0] || this.min;
109
- modelValue[1] = newValue;
109
+ if (newValue < modelValue[0]) {
110
+ modelValue[0] = newValue;
111
+
112
+ this.handleIndex = 0;
113
+ } else {
114
+ modelValue[1] = newValue;
115
+ }
110
116
  }
111
117
  } else {
112
118
  if (newValue < this.min) newValue = this.min;
@@ -271,8 +277,11 @@ var script = {
271
277
  },
272
278
  rangeStyle() {
273
279
  if (this.range) {
274
- if (this.horizontal) return { left: this.rangeStartPosition + '%', width: this.rangeEndPosition - this.rangeStartPosition + '%' };
275
- else return { bottom: this.rangeStartPosition + '%', height: this.rangeEndPosition - this.rangeStartHandlePosition + '%' };
280
+ const rangeSliderWidth = this.rangeEndPosition > this.rangeStartPosition ? this.rangeEndPosition - this.rangeStartPosition : this.rangeStartPosition - this.rangeEndPosition;
281
+ const rangeSliderPosition = this.rangeEndPosition > this.rangeStartPosition ? this.rangeStartPosition : this.rangeEndPosition;
282
+
283
+ if (this.horizontal) return { left: rangeSliderPosition + '%', width: rangeSliderWidth + '%' };
284
+ else return { bottom: rangeSliderPosition + '%', height: rangeSliderWidth + '%' };
276
285
  } else {
277
286
  if (this.horizontal) return { width: this.handlePosition + '%' };
278
287
  else return { height: this.handlePosition + '%' };
@@ -1 +1 @@
1
- import{DomHandler as e}from"primevue/utils";import{openBlock as t,createElementBlock as i,normalizeClass as a,createElementVNode as n,normalizeStyle as l,createCommentVNode as s}from"vue";var r={name:"Slider",emits:["update:modelValue","change","slideend"],props:{modelValue:[Number,Array],min:{type:Number,default:0},max:{type:Number,default:100},orientation:{type:String,default:"horizontal"},step:{type:Number,default:null},range:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},tabindex:{type:Number,default:0},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},dragging:!1,handleIndex:null,initX:null,initY:null,barWidth:null,barHeight:null,dragListener:null,dragEndListener:null,beforeUnmount(){this.unbindDragListeners()},methods:{updateDomData(){let t=this.$el.getBoundingClientRect();this.initX=t.left+e.getWindowScrollLeft(),this.initY=t.top+e.getWindowScrollTop(),this.barWidth=this.$el.offsetWidth,this.barHeight=this.$el.offsetHeight},setValue(e){let t,i=e.touches?e.touches[0].pageX:e.pageX,a=e.touches?e.touches[0].pageY:e.pageY;t="horizontal"===this.orientation?100*(i-this.initX)/this.barWidth:100*(this.initY+this.barHeight-a)/this.barHeight;let n=(this.max-this.min)*(t/100)+this.min;if(this.step){const e=this.range?this.modelValue[this.handleIndex]:this.modelValue,t=n-e;t<0?n=e+Math.ceil(n/this.step-e/this.step)*this.step:t>0&&(n=e+Math.floor(n/this.step-e/this.step)*this.step)}else n=Math.floor(n);this.updateModel(e,n)},updateModel(e,t){let i,a=parseFloat(t.toFixed(10));if(this.range)if(i=this.modelValue?[...this.modelValue]:[],0==this.handleIndex){let e=this.modelValue?this.modelValue[1]:this.max;a<this.min?a=this.min:a>=e&&(a=e),i[0]=a,i[1]=i[1]||this.max}else{let e=this.modelValue?this.modelValue[0]:this.min;a>this.max?a=this.max:a<=e&&(a=e),i[0]=i[0]||this.min,i[1]=a}else a<this.min?a=this.min:a>this.max&&(a=this.max),i=a;this.$emit("update:modelValue",i),this.$emit("change",i)},onDragStart(t,i){this.disabled||(e.addClass(this.$el,"p-slider-sliding"),this.dragging=!0,this.updateDomData(),this.range&&this.modelValue[0]===this.max?this.handleIndex=0:this.handleIndex=i,t.preventDefault())},onDrag(e){this.dragging&&(this.setValue(e),e.preventDefault())},onDragEnd(t){this.dragging&&(this.dragging=!1,e.removeClass(this.$el,"p-slider-sliding"),this.$emit("slideend",{originalEvent:t,value:this.modelValue}))},onBarClick(t){this.disabled||e.hasClass(t.target,"p-slider-handle")||(this.updateDomData(),this.setValue(t))},onMouseDown(e,t){this.bindDragListeners(),this.onDragStart(e,t)},onKeyDown(e,t){switch(this.handleIndex=t,e.code){case"ArrowDown":case"ArrowLeft":this.decrementValue(e,t),e.preventDefault();break;case"ArrowUp":case"ArrowRight":this.incrementValue(e,t),e.preventDefault();break;case"PageDown":this.decrementValue(e,t,!0),e.preventDefault();break;case"PageUp":this.incrementValue(e,t,!0),e.preventDefault();break;case"Home":this.updateModel(e,this.min),e.preventDefault();break;case"End":this.updateModel(e,this.max),e.preventDefault()}},decrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]-this.step:this.modelValue[t]-1:this.step?this.modelValue-this.step:!this.step&&i?this.modelValue-10:this.modelValue-1,this.updateModel(e,a),e.preventDefault()},incrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]+this.step:this.modelValue[t]+1:this.step?this.modelValue+this.step:!this.step&&i?this.modelValue+10:this.modelValue+1,this.updateModel(e,a),e.preventDefault()},bindDragListeners(){this.dragListener||(this.dragListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.dragListener)),this.dragEndListener||(this.dragEndListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.dragEndListener))},unbindDragListeners(){this.dragListener&&(document.removeEventListener("mousemove",this.dragListener),this.dragListener=null),this.dragEndListener&&(document.removeEventListener("mouseup",this.dragEndListener),this.dragEndListener=null)}},computed:{containerClass(){return["p-slider p-component",{"p-disabled":this.disabled,"p-slider-horizontal":"horizontal"===this.orientation,"p-slider-vertical":"vertical"===this.orientation}]},horizontal(){return"horizontal"===this.orientation},vertical(){return"vertical"===this.orientation},rangeStyle(){return this.range?this.horizontal?{left:this.rangeStartPosition+"%",width:this.rangeEndPosition-this.rangeStartPosition+"%"}:{bottom:this.rangeStartPosition+"%",height:this.rangeEndPosition-this.rangeStartHandlePosition+"%"}:this.horizontal?{width:this.handlePosition+"%"}:{height:this.handlePosition+"%"}},handleStyle(){return this.horizontal?{left:this.handlePosition+"%"}:{bottom:this.handlePosition+"%"}},handlePosition(){return this.modelValue<this.min?0:this.modelValue>this.max?100:100*(this.modelValue-this.min)/(this.max-this.min)},rangeStartPosition(){return this.modelValue&&this.modelValue[0]?100*(this.modelValue[0]<this.min?0:this.modelValue[0]-this.min)/(this.max-this.min):0},rangeEndPosition(){return this.modelValue&&2===this.modelValue.length?100*(this.modelValue[1]>this.max?100:this.modelValue[1]-this.min)/(this.max-this.min):100},rangeStartHandleStyle(){return this.horizontal?{left:this.rangeStartPosition+"%"}:{bottom:this.rangeStartPosition+"%"}},rangeEndHandleStyle(){return this.horizontal?{left:this.rangeEndPosition+"%"}:{bottom:this.rangeEndPosition+"%"}}}};const o=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],d=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],h=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"];!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&a.firstChild?a.insertBefore(n,a.firstChild):a.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-slider {\n position: relative;\n}\n.p-slider .p-slider-handle {\n position: absolute;\n cursor: -webkit-grab;\n cursor: grab;\n -ms-touch-action: none;\n touch-action: none;\n display: block;\n}\n.p-slider-range {\n position: absolute;\n display: block;\n}\n.p-slider-horizontal .p-slider-range {\n top: 0;\n left: 0;\n height: 100%;\n}\n.p-slider-horizontal .p-slider-handle {\n top: 50%;\n}\n.p-slider-vertical {\n height: 100px;\n}\n.p-slider-vertical .p-slider-handle {\n left: 50%;\n}\n.p-slider-vertical .p-slider-range {\n bottom: 0;\n left: 0;\n width: 100%;\n}\n"),r.render=function(e,r,u,m,g,p){return t(),i("div",{class:a(p.containerClass),onClick:r[15]||(r[15]=(...e)=>p.onBarClick&&p.onBarClick(...e))},[n("span",{class:"p-slider-range",style:l(p.rangeStyle)},null,4),u.range?s("",!0):(t(),i("span",{key:0,class:"p-slider-handle",style:l(p.handleStyle),onTouchstart:r[0]||(r[0]=e=>p.onDragStart(e)),onTouchmove:r[1]||(r[1]=e=>p.onDrag(e)),onTouchend:r[2]||(r[2]=e=>p.onDragEnd(e)),onMousedown:r[3]||(r[3]=e=>p.onMouseDown(e)),onKeydown:r[4]||(r[4]=e=>p.onKeyDown(e)),tabindex:u.tabindex,role:"slider","aria-valuemin":u.min,"aria-valuenow":u.modelValue,"aria-valuemax":u.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":u.orientation},null,44,o)),u.range?(t(),i("span",{key:1,class:"p-slider-handle",style:l(p.rangeStartHandleStyle),onTouchstart:r[5]||(r[5]=e=>p.onDragStart(e,0)),onTouchmove:r[6]||(r[6]=e=>p.onDrag(e)),onTouchend:r[7]||(r[7]=e=>p.onDragEnd(e)),onMousedown:r[8]||(r[8]=e=>p.onMouseDown(e,0)),onKeydown:r[9]||(r[9]=e=>p.onKeyDown(e,0)),tabindex:u.tabindex,role:"slider","aria-valuemin":u.min,"aria-valuenow":u.modelValue?u.modelValue[0]:null,"aria-valuemax":u.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":u.orientation},null,44,d)):s("",!0),u.range?(t(),i("span",{key:2,class:"p-slider-handle",style:l(p.rangeEndHandleStyle),onTouchstart:r[10]||(r[10]=e=>p.onDragStart(e,1)),onTouchmove:r[11]||(r[11]=e=>p.onDrag(e)),onTouchend:r[12]||(r[12]=e=>p.onDragEnd(e)),onMousedown:r[13]||(r[13]=e=>p.onMouseDown(e,1)),onKeydown:r[14]||(r[14]=e=>p.onKeyDown(e,1)),tabindex:u.tabindex,role:"slider","aria-valuemin":u.min,"aria-valuenow":u.modelValue?u.modelValue[1]:null,"aria-valuemax":u.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":u.orientation},null,44,h)):s("",!0)],2)};export{r as default};
1
+ import{DomHandler as e}from"primevue/utils";import{openBlock as t,createElementBlock as i,normalizeClass as a,createElementVNode as n,normalizeStyle as l,createCommentVNode as s}from"vue";var r={name:"Slider",emits:["update:modelValue","change","slideend"],props:{modelValue:[Number,Array],min:{type:Number,default:0},max:{type:Number,default:100},orientation:{type:String,default:"horizontal"},step:{type:Number,default:null},range:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},tabindex:{type:Number,default:0},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},dragging:!1,handleIndex:null,initX:null,initY:null,barWidth:null,barHeight:null,dragListener:null,dragEndListener:null,beforeUnmount(){this.unbindDragListeners()},methods:{updateDomData(){let t=this.$el.getBoundingClientRect();this.initX=t.left+e.getWindowScrollLeft(),this.initY=t.top+e.getWindowScrollTop(),this.barWidth=this.$el.offsetWidth,this.barHeight=this.$el.offsetHeight},setValue(e){let t,i=e.touches?e.touches[0].pageX:e.pageX,a=e.touches?e.touches[0].pageY:e.pageY;t="horizontal"===this.orientation?100*(i-this.initX)/this.barWidth:100*(this.initY+this.barHeight-a)/this.barHeight;let n=(this.max-this.min)*(t/100)+this.min;if(this.step){const e=this.range?this.modelValue[this.handleIndex]:this.modelValue,t=n-e;t<0?n=e+Math.ceil(n/this.step-e/this.step)*this.step:t>0&&(n=e+Math.floor(n/this.step-e/this.step)*this.step)}else n=Math.floor(n);this.updateModel(e,n)},updateModel(e,t){let i,a=parseFloat(t.toFixed(10));this.range?(i=this.modelValue?[...this.modelValue]:[],0==this.handleIndex?(a<this.min?a=this.min:a>=this.max&&(a=this.max),a>i[1]?(i[1]=a,this.handleIndex=1):i[0]=a):(a>this.max?a=this.max:a<=this.min&&(a=this.min),a<i[0]?(i[0]=a,this.handleIndex=0):i[1]=a)):(a<this.min?a=this.min:a>this.max&&(a=this.max),i=a),this.$emit("update:modelValue",i),this.$emit("change",i)},onDragStart(t,i){this.disabled||(e.addClass(this.$el,"p-slider-sliding"),this.dragging=!0,this.updateDomData(),this.range&&this.modelValue[0]===this.max?this.handleIndex=0:this.handleIndex=i,t.preventDefault())},onDrag(e){this.dragging&&(this.setValue(e),e.preventDefault())},onDragEnd(t){this.dragging&&(this.dragging=!1,e.removeClass(this.$el,"p-slider-sliding"),this.$emit("slideend",{originalEvent:t,value:this.modelValue}))},onBarClick(t){this.disabled||e.hasClass(t.target,"p-slider-handle")||(this.updateDomData(),this.setValue(t))},onMouseDown(e,t){this.bindDragListeners(),this.onDragStart(e,t)},onKeyDown(e,t){switch(this.handleIndex=t,e.code){case"ArrowDown":case"ArrowLeft":this.decrementValue(e,t),e.preventDefault();break;case"ArrowUp":case"ArrowRight":this.incrementValue(e,t),e.preventDefault();break;case"PageDown":this.decrementValue(e,t,!0),e.preventDefault();break;case"PageUp":this.incrementValue(e,t,!0),e.preventDefault();break;case"Home":this.updateModel(e,this.min),e.preventDefault();break;case"End":this.updateModel(e,this.max),e.preventDefault()}},decrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]-this.step:this.modelValue[t]-1:this.step?this.modelValue-this.step:!this.step&&i?this.modelValue-10:this.modelValue-1,this.updateModel(e,a),e.preventDefault()},incrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]+this.step:this.modelValue[t]+1:this.step?this.modelValue+this.step:!this.step&&i?this.modelValue+10:this.modelValue+1,this.updateModel(e,a),e.preventDefault()},bindDragListeners(){this.dragListener||(this.dragListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.dragListener)),this.dragEndListener||(this.dragEndListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.dragEndListener))},unbindDragListeners(){this.dragListener&&(document.removeEventListener("mousemove",this.dragListener),this.dragListener=null),this.dragEndListener&&(document.removeEventListener("mouseup",this.dragEndListener),this.dragEndListener=null)}},computed:{containerClass(){return["p-slider p-component",{"p-disabled":this.disabled,"p-slider-horizontal":"horizontal"===this.orientation,"p-slider-vertical":"vertical"===this.orientation}]},horizontal(){return"horizontal"===this.orientation},vertical(){return"vertical"===this.orientation},rangeStyle(){if(this.range){const e=this.rangeEndPosition>this.rangeStartPosition?this.rangeEndPosition-this.rangeStartPosition:this.rangeStartPosition-this.rangeEndPosition,t=this.rangeEndPosition>this.rangeStartPosition?this.rangeStartPosition:this.rangeEndPosition;return this.horizontal?{left:t+"%",width:e+"%"}:{bottom:t+"%",height:e+"%"}}return this.horizontal?{width:this.handlePosition+"%"}:{height:this.handlePosition+"%"}},handleStyle(){return this.horizontal?{left:this.handlePosition+"%"}:{bottom:this.handlePosition+"%"}},handlePosition(){return this.modelValue<this.min?0:this.modelValue>this.max?100:100*(this.modelValue-this.min)/(this.max-this.min)},rangeStartPosition(){return this.modelValue&&this.modelValue[0]?100*(this.modelValue[0]<this.min?0:this.modelValue[0]-this.min)/(this.max-this.min):0},rangeEndPosition(){return this.modelValue&&2===this.modelValue.length?100*(this.modelValue[1]>this.max?100:this.modelValue[1]-this.min)/(this.max-this.min):100},rangeStartHandleStyle(){return this.horizontal?{left:this.rangeStartPosition+"%"}:{bottom:this.rangeStartPosition+"%"}},rangeEndHandleStyle(){return this.horizontal?{left:this.rangeEndPosition+"%"}:{bottom:this.rangeEndPosition+"%"}}}};const o=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],d=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],h=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"];!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&a.firstChild?a.insertBefore(n,a.firstChild):a.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-slider {\n position: relative;\n}\n.p-slider .p-slider-handle {\n position: absolute;\n cursor: -webkit-grab;\n cursor: grab;\n -ms-touch-action: none;\n touch-action: none;\n display: block;\n}\n.p-slider-range {\n position: absolute;\n display: block;\n}\n.p-slider-horizontal .p-slider-range {\n top: 0;\n left: 0;\n height: 100%;\n}\n.p-slider-horizontal .p-slider-handle {\n top: 50%;\n}\n.p-slider-vertical {\n height: 100px;\n}\n.p-slider-vertical .p-slider-handle {\n left: 50%;\n}\n.p-slider-vertical .p-slider-range {\n bottom: 0;\n left: 0;\n width: 100%;\n}\n"),r.render=function(e,r,u,m,g,p){return t(),i("div",{class:a(p.containerClass),onClick:r[15]||(r[15]=(...e)=>p.onBarClick&&p.onBarClick(...e))},[n("span",{class:"p-slider-range",style:l(p.rangeStyle)},null,4),u.range?s("",!0):(t(),i("span",{key:0,class:"p-slider-handle",style:l(p.handleStyle),onTouchstart:r[0]||(r[0]=e=>p.onDragStart(e)),onTouchmove:r[1]||(r[1]=e=>p.onDrag(e)),onTouchend:r[2]||(r[2]=e=>p.onDragEnd(e)),onMousedown:r[3]||(r[3]=e=>p.onMouseDown(e)),onKeydown:r[4]||(r[4]=e=>p.onKeyDown(e)),tabindex:u.tabindex,role:"slider","aria-valuemin":u.min,"aria-valuenow":u.modelValue,"aria-valuemax":u.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":u.orientation},null,44,o)),u.range?(t(),i("span",{key:1,class:"p-slider-handle",style:l(p.rangeStartHandleStyle),onTouchstart:r[5]||(r[5]=e=>p.onDragStart(e,0)),onTouchmove:r[6]||(r[6]=e=>p.onDrag(e)),onTouchend:r[7]||(r[7]=e=>p.onDragEnd(e)),onMousedown:r[8]||(r[8]=e=>p.onMouseDown(e,0)),onKeydown:r[9]||(r[9]=e=>p.onKeyDown(e,0)),tabindex:u.tabindex,role:"slider","aria-valuemin":u.min,"aria-valuenow":u.modelValue?u.modelValue[0]:null,"aria-valuemax":u.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":u.orientation},null,44,d)):s("",!0),u.range?(t(),i("span",{key:2,class:"p-slider-handle",style:l(p.rangeEndHandleStyle),onTouchstart:r[10]||(r[10]=e=>p.onDragStart(e,1)),onTouchmove:r[11]||(r[11]=e=>p.onDrag(e)),onTouchend:r[12]||(r[12]=e=>p.onDragEnd(e)),onMousedown:r[13]||(r[13]=e=>p.onMouseDown(e,1)),onKeydown:r[14]||(r[14]=e=>p.onKeyDown(e,1)),tabindex:u.tabindex,role:"slider","aria-valuemin":u.min,"aria-valuenow":u.modelValue?u.modelValue[1]:null,"aria-valuemax":u.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":u.orientation},null,44,h)):s("",!0)],2)};export{r as default};
package/slider/slider.js CHANGED
@@ -93,21 +93,27 @@ this.primevue.slider = (function (utils, vue) {
93
93
  modelValue = this.modelValue ? [...this.modelValue] : [];
94
94
 
95
95
  if (this.handleIndex == 0) {
96
- let maxValue = this.modelValue ? this.modelValue[1] : this.max;
97
-
98
96
  if (newValue < this.min) newValue = this.min;
99
- else if (newValue >= maxValue) newValue = maxValue;
97
+ else if (newValue >= this.max) newValue = this.max;
100
98
 
101
- modelValue[0] = newValue;
102
- modelValue[1] = modelValue[1] || this.max;
103
- } else {
104
- let minValue = this.modelValue ? this.modelValue[0] : this.min;
99
+ if (newValue > modelValue[1]) {
100
+ modelValue[1] = newValue;
105
101
 
102
+ this.handleIndex = 1;
103
+ } else {
104
+ modelValue[0] = newValue;
105
+ }
106
+ } else {
106
107
  if (newValue > this.max) newValue = this.max;
107
- else if (newValue <= minValue) newValue = minValue;
108
+ else if (newValue <= this.min) newValue = this.min;
108
109
 
109
- modelValue[0] = modelValue[0] || this.min;
110
- modelValue[1] = newValue;
110
+ if (newValue < modelValue[0]) {
111
+ modelValue[0] = newValue;
112
+
113
+ this.handleIndex = 0;
114
+ } else {
115
+ modelValue[1] = newValue;
116
+ }
111
117
  }
112
118
  } else {
113
119
  if (newValue < this.min) newValue = this.min;
@@ -272,8 +278,11 @@ this.primevue.slider = (function (utils, vue) {
272
278
  },
273
279
  rangeStyle() {
274
280
  if (this.range) {
275
- if (this.horizontal) return { left: this.rangeStartPosition + '%', width: this.rangeEndPosition - this.rangeStartPosition + '%' };
276
- else return { bottom: this.rangeStartPosition + '%', height: this.rangeEndPosition - this.rangeStartHandlePosition + '%' };
281
+ const rangeSliderWidth = this.rangeEndPosition > this.rangeStartPosition ? this.rangeEndPosition - this.rangeStartPosition : this.rangeStartPosition - this.rangeEndPosition;
282
+ const rangeSliderPosition = this.rangeEndPosition > this.rangeStartPosition ? this.rangeStartPosition : this.rangeEndPosition;
283
+
284
+ if (this.horizontal) return { left: rangeSliderPosition + '%', width: rangeSliderWidth + '%' };
285
+ else return { bottom: rangeSliderPosition + '%', height: rangeSliderWidth + '%' };
277
286
  } else {
278
287
  if (this.horizontal) return { width: this.handlePosition + '%' };
279
288
  else return { height: this.handlePosition + '%' };
@@ -1 +1 @@
1
- this.primevue=this.primevue||{},this.primevue.slider=function(e,t){"use strict";var i={name:"Slider",emits:["update:modelValue","change","slideend"],props:{modelValue:[Number,Array],min:{type:Number,default:0},max:{type:Number,default:100},orientation:{type:String,default:"horizontal"},step:{type:Number,default:null},range:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},tabindex:{type:Number,default:0},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},dragging:!1,handleIndex:null,initX:null,initY:null,barWidth:null,barHeight:null,dragListener:null,dragEndListener:null,beforeUnmount(){this.unbindDragListeners()},methods:{updateDomData(){let t=this.$el.getBoundingClientRect();this.initX=t.left+e.DomHandler.getWindowScrollLeft(),this.initY=t.top+e.DomHandler.getWindowScrollTop(),this.barWidth=this.$el.offsetWidth,this.barHeight=this.$el.offsetHeight},setValue(e){let t,i=e.touches?e.touches[0].pageX:e.pageX,a=e.touches?e.touches[0].pageY:e.pageY;t="horizontal"===this.orientation?100*(i-this.initX)/this.barWidth:100*(this.initY+this.barHeight-a)/this.barHeight;let n=(this.max-this.min)*(t/100)+this.min;if(this.step){const e=this.range?this.modelValue[this.handleIndex]:this.modelValue,t=n-e;t<0?n=e+Math.ceil(n/this.step-e/this.step)*this.step:t>0&&(n=e+Math.floor(n/this.step-e/this.step)*this.step)}else n=Math.floor(n);this.updateModel(e,n)},updateModel(e,t){let i,a=parseFloat(t.toFixed(10));if(this.range)if(i=this.modelValue?[...this.modelValue]:[],0==this.handleIndex){let e=this.modelValue?this.modelValue[1]:this.max;a<this.min?a=this.min:a>=e&&(a=e),i[0]=a,i[1]=i[1]||this.max}else{let e=this.modelValue?this.modelValue[0]:this.min;a>this.max?a=this.max:a<=e&&(a=e),i[0]=i[0]||this.min,i[1]=a}else a<this.min?a=this.min:a>this.max&&(a=this.max),i=a;this.$emit("update:modelValue",i),this.$emit("change",i)},onDragStart(t,i){this.disabled||(e.DomHandler.addClass(this.$el,"p-slider-sliding"),this.dragging=!0,this.updateDomData(),this.range&&this.modelValue[0]===this.max?this.handleIndex=0:this.handleIndex=i,t.preventDefault())},onDrag(e){this.dragging&&(this.setValue(e),e.preventDefault())},onDragEnd(t){this.dragging&&(this.dragging=!1,e.DomHandler.removeClass(this.$el,"p-slider-sliding"),this.$emit("slideend",{originalEvent:t,value:this.modelValue}))},onBarClick(t){this.disabled||e.DomHandler.hasClass(t.target,"p-slider-handle")||(this.updateDomData(),this.setValue(t))},onMouseDown(e,t){this.bindDragListeners(),this.onDragStart(e,t)},onKeyDown(e,t){switch(this.handleIndex=t,e.code){case"ArrowDown":case"ArrowLeft":this.decrementValue(e,t),e.preventDefault();break;case"ArrowUp":case"ArrowRight":this.incrementValue(e,t),e.preventDefault();break;case"PageDown":this.decrementValue(e,t,!0),e.preventDefault();break;case"PageUp":this.incrementValue(e,t,!0),e.preventDefault();break;case"Home":this.updateModel(e,this.min),e.preventDefault();break;case"End":this.updateModel(e,this.max),e.preventDefault()}},decrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]-this.step:this.modelValue[t]-1:this.step?this.modelValue-this.step:!this.step&&i?this.modelValue-10:this.modelValue-1,this.updateModel(e,a),e.preventDefault()},incrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]+this.step:this.modelValue[t]+1:this.step?this.modelValue+this.step:!this.step&&i?this.modelValue+10:this.modelValue+1,this.updateModel(e,a),e.preventDefault()},bindDragListeners(){this.dragListener||(this.dragListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.dragListener)),this.dragEndListener||(this.dragEndListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.dragEndListener))},unbindDragListeners(){this.dragListener&&(document.removeEventListener("mousemove",this.dragListener),this.dragListener=null),this.dragEndListener&&(document.removeEventListener("mouseup",this.dragEndListener),this.dragEndListener=null)}},computed:{containerClass(){return["p-slider p-component",{"p-disabled":this.disabled,"p-slider-horizontal":"horizontal"===this.orientation,"p-slider-vertical":"vertical"===this.orientation}]},horizontal(){return"horizontal"===this.orientation},vertical(){return"vertical"===this.orientation},rangeStyle(){return this.range?this.horizontal?{left:this.rangeStartPosition+"%",width:this.rangeEndPosition-this.rangeStartPosition+"%"}:{bottom:this.rangeStartPosition+"%",height:this.rangeEndPosition-this.rangeStartHandlePosition+"%"}:this.horizontal?{width:this.handlePosition+"%"}:{height:this.handlePosition+"%"}},handleStyle(){return this.horizontal?{left:this.handlePosition+"%"}:{bottom:this.handlePosition+"%"}},handlePosition(){return this.modelValue<this.min?0:this.modelValue>this.max?100:100*(this.modelValue-this.min)/(this.max-this.min)},rangeStartPosition(){return this.modelValue&&this.modelValue[0]?100*(this.modelValue[0]<this.min?0:this.modelValue[0]-this.min)/(this.max-this.min):0},rangeEndPosition(){return this.modelValue&&2===this.modelValue.length?100*(this.modelValue[1]>this.max?100:this.modelValue[1]-this.min)/(this.max-this.min):100},rangeStartHandleStyle(){return this.horizontal?{left:this.rangeStartPosition+"%"}:{bottom:this.rangeStartPosition+"%"}},rangeEndHandleStyle(){return this.horizontal?{left:this.rangeEndPosition+"%"}:{bottom:this.rangeEndPosition+"%"}}}};const a=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],n=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],l=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"];return function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&a.firstChild?a.insertBefore(n,a.firstChild):a.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-slider {\n position: relative;\n}\n.p-slider .p-slider-handle {\n position: absolute;\n cursor: -webkit-grab;\n cursor: grab;\n -ms-touch-action: none;\n touch-action: none;\n display: block;\n}\n.p-slider-range {\n position: absolute;\n display: block;\n}\n.p-slider-horizontal .p-slider-range {\n top: 0;\n left: 0;\n height: 100%;\n}\n.p-slider-horizontal .p-slider-handle {\n top: 50%;\n}\n.p-slider-vertical {\n height: 100px;\n}\n.p-slider-vertical .p-slider-handle {\n left: 50%;\n}\n.p-slider-vertical .p-slider-range {\n bottom: 0;\n left: 0;\n width: 100%;\n}\n"),i.render=function(e,i,s,o,r,d){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(d.containerClass),onClick:i[15]||(i[15]=(...e)=>d.onBarClick&&d.onBarClick(...e))},[t.createElementVNode("span",{class:"p-slider-range",style:t.normalizeStyle(d.rangeStyle)},null,4),s.range?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"p-slider-handle",style:t.normalizeStyle(d.handleStyle),onTouchstart:i[0]||(i[0]=e=>d.onDragStart(e)),onTouchmove:i[1]||(i[1]=e=>d.onDrag(e)),onTouchend:i[2]||(i[2]=e=>d.onDragEnd(e)),onMousedown:i[3]||(i[3]=e=>d.onMouseDown(e)),onKeydown:i[4]||(i[4]=e=>d.onKeyDown(e)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,a)),s.range?(t.openBlock(),t.createElementBlock("span",{key:1,class:"p-slider-handle",style:t.normalizeStyle(d.rangeStartHandleStyle),onTouchstart:i[5]||(i[5]=e=>d.onDragStart(e,0)),onTouchmove:i[6]||(i[6]=e=>d.onDrag(e)),onTouchend:i[7]||(i[7]=e=>d.onDragEnd(e)),onMousedown:i[8]||(i[8]=e=>d.onMouseDown(e,0)),onKeydown:i[9]||(i[9]=e=>d.onKeyDown(e,0)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue?s.modelValue[0]:null,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,n)):t.createCommentVNode("",!0),s.range?(t.openBlock(),t.createElementBlock("span",{key:2,class:"p-slider-handle",style:t.normalizeStyle(d.rangeEndHandleStyle),onTouchstart:i[10]||(i[10]=e=>d.onDragStart(e,1)),onTouchmove:i[11]||(i[11]=e=>d.onDrag(e)),onTouchend:i[12]||(i[12]=e=>d.onDragEnd(e)),onMousedown:i[13]||(i[13]=e=>d.onMouseDown(e,1)),onKeydown:i[14]||(i[14]=e=>d.onKeyDown(e,1)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue?s.modelValue[1]:null,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,l)):t.createCommentVNode("",!0)],2)},i}(primevue.utils,Vue);
1
+ this.primevue=this.primevue||{},this.primevue.slider=function(e,t){"use strict";var i={name:"Slider",emits:["update:modelValue","change","slideend"],props:{modelValue:[Number,Array],min:{type:Number,default:0},max:{type:Number,default:100},orientation:{type:String,default:"horizontal"},step:{type:Number,default:null},range:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},tabindex:{type:Number,default:0},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},dragging:!1,handleIndex:null,initX:null,initY:null,barWidth:null,barHeight:null,dragListener:null,dragEndListener:null,beforeUnmount(){this.unbindDragListeners()},methods:{updateDomData(){let t=this.$el.getBoundingClientRect();this.initX=t.left+e.DomHandler.getWindowScrollLeft(),this.initY=t.top+e.DomHandler.getWindowScrollTop(),this.barWidth=this.$el.offsetWidth,this.barHeight=this.$el.offsetHeight},setValue(e){let t,i=e.touches?e.touches[0].pageX:e.pageX,a=e.touches?e.touches[0].pageY:e.pageY;t="horizontal"===this.orientation?100*(i-this.initX)/this.barWidth:100*(this.initY+this.barHeight-a)/this.barHeight;let n=(this.max-this.min)*(t/100)+this.min;if(this.step){const e=this.range?this.modelValue[this.handleIndex]:this.modelValue,t=n-e;t<0?n=e+Math.ceil(n/this.step-e/this.step)*this.step:t>0&&(n=e+Math.floor(n/this.step-e/this.step)*this.step)}else n=Math.floor(n);this.updateModel(e,n)},updateModel(e,t){let i,a=parseFloat(t.toFixed(10));this.range?(i=this.modelValue?[...this.modelValue]:[],0==this.handleIndex?(a<this.min?a=this.min:a>=this.max&&(a=this.max),a>i[1]?(i[1]=a,this.handleIndex=1):i[0]=a):(a>this.max?a=this.max:a<=this.min&&(a=this.min),a<i[0]?(i[0]=a,this.handleIndex=0):i[1]=a)):(a<this.min?a=this.min:a>this.max&&(a=this.max),i=a),this.$emit("update:modelValue",i),this.$emit("change",i)},onDragStart(t,i){this.disabled||(e.DomHandler.addClass(this.$el,"p-slider-sliding"),this.dragging=!0,this.updateDomData(),this.range&&this.modelValue[0]===this.max?this.handleIndex=0:this.handleIndex=i,t.preventDefault())},onDrag(e){this.dragging&&(this.setValue(e),e.preventDefault())},onDragEnd(t){this.dragging&&(this.dragging=!1,e.DomHandler.removeClass(this.$el,"p-slider-sliding"),this.$emit("slideend",{originalEvent:t,value:this.modelValue}))},onBarClick(t){this.disabled||e.DomHandler.hasClass(t.target,"p-slider-handle")||(this.updateDomData(),this.setValue(t))},onMouseDown(e,t){this.bindDragListeners(),this.onDragStart(e,t)},onKeyDown(e,t){switch(this.handleIndex=t,e.code){case"ArrowDown":case"ArrowLeft":this.decrementValue(e,t),e.preventDefault();break;case"ArrowUp":case"ArrowRight":this.incrementValue(e,t),e.preventDefault();break;case"PageDown":this.decrementValue(e,t,!0),e.preventDefault();break;case"PageUp":this.incrementValue(e,t,!0),e.preventDefault();break;case"Home":this.updateModel(e,this.min),e.preventDefault();break;case"End":this.updateModel(e,this.max),e.preventDefault()}},decrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]-this.step:this.modelValue[t]-1:this.step?this.modelValue-this.step:!this.step&&i?this.modelValue-10:this.modelValue-1,this.updateModel(e,a),e.preventDefault()},incrementValue(e,t,i=!1){let a;a=this.range?this.step?this.modelValue[t]+this.step:this.modelValue[t]+1:this.step?this.modelValue+this.step:!this.step&&i?this.modelValue+10:this.modelValue+1,this.updateModel(e,a),e.preventDefault()},bindDragListeners(){this.dragListener||(this.dragListener=this.onDrag.bind(this),document.addEventListener("mousemove",this.dragListener)),this.dragEndListener||(this.dragEndListener=this.onDragEnd.bind(this),document.addEventListener("mouseup",this.dragEndListener))},unbindDragListeners(){this.dragListener&&(document.removeEventListener("mousemove",this.dragListener),this.dragListener=null),this.dragEndListener&&(document.removeEventListener("mouseup",this.dragEndListener),this.dragEndListener=null)}},computed:{containerClass(){return["p-slider p-component",{"p-disabled":this.disabled,"p-slider-horizontal":"horizontal"===this.orientation,"p-slider-vertical":"vertical"===this.orientation}]},horizontal(){return"horizontal"===this.orientation},vertical(){return"vertical"===this.orientation},rangeStyle(){if(this.range){const e=this.rangeEndPosition>this.rangeStartPosition?this.rangeEndPosition-this.rangeStartPosition:this.rangeStartPosition-this.rangeEndPosition,t=this.rangeEndPosition>this.rangeStartPosition?this.rangeStartPosition:this.rangeEndPosition;return this.horizontal?{left:t+"%",width:e+"%"}:{bottom:t+"%",height:e+"%"}}return this.horizontal?{width:this.handlePosition+"%"}:{height:this.handlePosition+"%"}},handleStyle(){return this.horizontal?{left:this.handlePosition+"%"}:{bottom:this.handlePosition+"%"}},handlePosition(){return this.modelValue<this.min?0:this.modelValue>this.max?100:100*(this.modelValue-this.min)/(this.max-this.min)},rangeStartPosition(){return this.modelValue&&this.modelValue[0]?100*(this.modelValue[0]<this.min?0:this.modelValue[0]-this.min)/(this.max-this.min):0},rangeEndPosition(){return this.modelValue&&2===this.modelValue.length?100*(this.modelValue[1]>this.max?100:this.modelValue[1]-this.min)/(this.max-this.min):100},rangeStartHandleStyle(){return this.horizontal?{left:this.rangeStartPosition+"%"}:{bottom:this.rangeStartPosition+"%"}},rangeEndHandleStyle(){return this.horizontal?{left:this.rangeEndPosition+"%"}:{bottom:this.rangeEndPosition+"%"}}}};const a=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],n=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"],l=["tabindex","aria-valuemin","aria-valuenow","aria-valuemax","aria-labelledby","aria-label","aria-orientation"];return function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&a.firstChild?a.insertBefore(n,a.firstChild):a.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-slider {\n position: relative;\n}\n.p-slider .p-slider-handle {\n position: absolute;\n cursor: -webkit-grab;\n cursor: grab;\n -ms-touch-action: none;\n touch-action: none;\n display: block;\n}\n.p-slider-range {\n position: absolute;\n display: block;\n}\n.p-slider-horizontal .p-slider-range {\n top: 0;\n left: 0;\n height: 100%;\n}\n.p-slider-horizontal .p-slider-handle {\n top: 50%;\n}\n.p-slider-vertical {\n height: 100px;\n}\n.p-slider-vertical .p-slider-handle {\n left: 50%;\n}\n.p-slider-vertical .p-slider-range {\n bottom: 0;\n left: 0;\n width: 100%;\n}\n"),i.render=function(e,i,s,o,r,d){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(d.containerClass),onClick:i[15]||(i[15]=(...e)=>d.onBarClick&&d.onBarClick(...e))},[t.createElementVNode("span",{class:"p-slider-range",style:t.normalizeStyle(d.rangeStyle)},null,4),s.range?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"p-slider-handle",style:t.normalizeStyle(d.handleStyle),onTouchstart:i[0]||(i[0]=e=>d.onDragStart(e)),onTouchmove:i[1]||(i[1]=e=>d.onDrag(e)),onTouchend:i[2]||(i[2]=e=>d.onDragEnd(e)),onMousedown:i[3]||(i[3]=e=>d.onMouseDown(e)),onKeydown:i[4]||(i[4]=e=>d.onKeyDown(e)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,a)),s.range?(t.openBlock(),t.createElementBlock("span",{key:1,class:"p-slider-handle",style:t.normalizeStyle(d.rangeStartHandleStyle),onTouchstart:i[5]||(i[5]=e=>d.onDragStart(e,0)),onTouchmove:i[6]||(i[6]=e=>d.onDrag(e)),onTouchend:i[7]||(i[7]=e=>d.onDragEnd(e)),onMousedown:i[8]||(i[8]=e=>d.onMouseDown(e,0)),onKeydown:i[9]||(i[9]=e=>d.onKeyDown(e,0)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue?s.modelValue[0]:null,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,n)):t.createCommentVNode("",!0),s.range?(t.openBlock(),t.createElementBlock("span",{key:2,class:"p-slider-handle",style:t.normalizeStyle(d.rangeEndHandleStyle),onTouchstart:i[10]||(i[10]=e=>d.onDragStart(e,1)),onTouchmove:i[11]||(i[11]=e=>d.onDrag(e)),onTouchend:i[12]||(i[12]=e=>d.onDragEnd(e)),onMousedown:i[13]||(i[13]=e=>d.onMouseDown(e,1)),onKeydown:i[14]||(i[14]=e=>d.onKeyDown(e,1)),tabindex:s.tabindex,role:"slider","aria-valuemin":s.min,"aria-valuenow":s.modelValue?s.modelValue[1]:null,"aria-valuemax":s.max,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,"aria-orientation":s.orientation},null,44,l)):t.createCommentVNode("",!0)],2)},i}(primevue.utils,Vue);