quasar 1.16.3 → 1.17.3

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 (308) hide show
  1. package/dist/api/BottomSheet.json +2 -2
  2. package/dist/api/Loading.json +0 -2
  3. package/dist/api/LoadingBar.json +1 -1
  4. package/dist/api/Notify.json +25 -25
  5. package/dist/api/QAjaxBar.json +23 -4
  6. package/dist/api/QAvatar.json +1 -1
  7. package/dist/api/QBreadcrumbsEl.json +32 -11
  8. package/dist/api/QBtn.json +35 -14
  9. package/dist/api/QBtnDropdown.json +36 -15
  10. package/dist/api/QBtnToggle.json +1 -1
  11. package/dist/api/QCarousel.json +7 -7
  12. package/dist/api/QCarouselSlide.json +2 -2
  13. package/dist/api/QChatMessage.json +1 -5
  14. package/dist/api/QChip.json +4 -4
  15. package/dist/api/QColor.json +6 -0
  16. package/dist/api/QDialog.json +7 -1
  17. package/dist/api/QExpansionItem.json +34 -13
  18. package/dist/api/QFab.json +34 -2
  19. package/dist/api/QFabAction.json +9 -1
  20. package/dist/api/QField.json +80 -6
  21. package/dist/api/QFile.json +80 -6
  22. package/dist/api/QImg.json +2 -2
  23. package/dist/api/QInnerLoading.json +32 -0
  24. package/dist/api/QInput.json +82 -6
  25. package/dist/api/QItem.json +31 -10
  26. package/dist/api/QOptionGroup.json +58 -1
  27. package/dist/api/QPagination.json +4 -4
  28. package/dist/api/QParallax.json +1 -1
  29. package/dist/api/QPopupEdit.json +14 -7
  30. package/dist/api/QPullToRefresh.json +1 -1
  31. package/dist/api/QRange.json +581 -96
  32. package/dist/api/QRating.json +3 -3
  33. package/dist/api/QRouteTab.json +32 -12
  34. package/dist/api/QScrollArea.json +188 -20
  35. package/dist/api/QSelect.json +82 -10
  36. package/dist/api/QSeparator.json +1 -1
  37. package/dist/api/QSlider.json +499 -34
  38. package/dist/api/QStep.json +4 -4
  39. package/dist/api/QStepper.json +4 -4
  40. package/dist/api/QTab.json +1 -1
  41. package/dist/api/QTable.json +4 -4
  42. package/dist/api/QTabs.json +9 -0
  43. package/dist/api/QTimelineEntry.json +2 -2
  44. package/dist/api/QToggle.json +1 -1
  45. package/dist/api/QTree.json +7 -1
  46. package/dist/api/QVideo.json +10 -0
  47. package/dist/icon-set/bootstrap-icons.umd.min.js +1 -1
  48. package/dist/icon-set/eva-icons.umd.min.js +1 -1
  49. package/dist/icon-set/fontawesome-v5-pro.umd.min.js +1 -1
  50. package/dist/icon-set/fontawesome-v5.umd.min.js +1 -1
  51. package/dist/icon-set/ionicons-v4.umd.min.js +1 -1
  52. package/dist/icon-set/line-awesome.umd.min.js +1 -1
  53. package/dist/icon-set/material-icons-outlined.umd.min.js +1 -1
  54. package/dist/icon-set/material-icons-round.umd.min.js +1 -1
  55. package/dist/icon-set/material-icons-sharp.umd.min.js +1 -1
  56. package/dist/icon-set/material-icons.umd.min.js +1 -1
  57. package/dist/icon-set/mdi-v3.umd.min.js +1 -1
  58. package/dist/icon-set/mdi-v4.umd.min.js +1 -1
  59. package/dist/icon-set/mdi-v5.umd.min.js +1 -1
  60. package/dist/icon-set/mdi-v6.umd.min.js +1 -1
  61. package/dist/icon-set/svg-bootstrap-icons.umd.min.js +1 -1
  62. package/dist/icon-set/svg-eva-icons.umd.min.js +1 -1
  63. package/dist/icon-set/svg-fontawesome-v5.umd.min.js +1 -1
  64. package/dist/icon-set/svg-ionicons-v4.umd.min.js +1 -1
  65. package/dist/icon-set/svg-ionicons-v5.umd.min.js +1 -1
  66. package/dist/icon-set/svg-ionicons-v6.umd.min.js +6 -0
  67. package/dist/icon-set/svg-line-awesome.umd.min.js +1 -1
  68. package/dist/icon-set/svg-material-icons-outlined.umd.min.js +1 -1
  69. package/dist/icon-set/svg-material-icons-round.umd.min.js +1 -1
  70. package/dist/icon-set/svg-material-icons-sharp.umd.min.js +1 -1
  71. package/dist/icon-set/svg-material-icons.umd.min.js +1 -1
  72. package/dist/icon-set/svg-mdi-v4.umd.min.js +1 -1
  73. package/dist/icon-set/svg-mdi-v5.umd.min.js +1 -1
  74. package/dist/icon-set/svg-mdi-v6.umd.min.js +1 -1
  75. package/dist/icon-set/svg-themify.umd.min.js +1 -1
  76. package/dist/icon-set/themify.umd.min.js +1 -1
  77. package/dist/lang/ar.umd.min.js +2 -2
  78. package/dist/lang/az-latn.umd.min.js +1 -1
  79. package/dist/lang/bg.umd.min.js +1 -1
  80. package/dist/lang/ca.umd.min.js +1 -1
  81. package/dist/lang/cs.umd.min.js +1 -1
  82. package/dist/lang/da.umd.min.js +1 -1
  83. package/dist/lang/de.umd.min.js +1 -1
  84. package/dist/lang/el.umd.min.js +1 -1
  85. package/dist/lang/en-gb.umd.min.js +1 -1
  86. package/dist/lang/en-us.umd.min.js +1 -1
  87. package/dist/lang/eo.umd.min.js +1 -1
  88. package/dist/lang/es.umd.min.js +1 -1
  89. package/dist/lang/et.umd.min.js +1 -1
  90. package/dist/lang/fa-ir.umd.min.js +1 -1
  91. package/dist/lang/fa.umd.min.js +1 -1
  92. package/dist/lang/fi.umd.min.js +1 -1
  93. package/dist/lang/fr.umd.min.js +2 -2
  94. package/dist/lang/gn.umd.min.js +1 -1
  95. package/dist/lang/he.umd.min.js +1 -1
  96. package/dist/lang/hr.umd.min.js +1 -1
  97. package/dist/lang/hu.umd.min.js +1 -1
  98. package/dist/lang/id.umd.min.js +1 -1
  99. package/dist/lang/is.umd.min.js +1 -1
  100. package/dist/lang/it.umd.min.js +1 -1
  101. package/dist/lang/ja.umd.min.js +1 -1
  102. package/dist/lang/km.umd.min.js +1 -1
  103. package/dist/lang/ko-kr.umd.min.js +1 -1
  104. package/dist/lang/kur-ckb.umd.min.js +1 -1
  105. package/dist/lang/lu.umd.min.js +1 -1
  106. package/dist/lang/lv.umd.min.js +1 -1
  107. package/dist/lang/ml.umd.min.js +1 -1
  108. package/dist/lang/ms.umd.min.js +1 -1
  109. package/dist/lang/nb-no.umd.min.js +1 -1
  110. package/dist/lang/nl.umd.min.js +1 -1
  111. package/dist/lang/pl.umd.min.js +1 -1
  112. package/dist/lang/pt-br.umd.min.js +1 -1
  113. package/dist/lang/pt.umd.min.js +1 -1
  114. package/dist/lang/ro.umd.min.js +1 -1
  115. package/dist/lang/ru.umd.min.js +1 -1
  116. package/dist/lang/sk.umd.min.js +1 -1
  117. package/dist/lang/sl.umd.min.js +1 -1
  118. package/dist/lang/sr.umd.min.js +2 -2
  119. package/dist/lang/sv.umd.min.js +1 -1
  120. package/dist/lang/ta.umd.min.js +1 -1
  121. package/dist/lang/th.umd.min.js +1 -1
  122. package/dist/lang/tr.umd.min.js +1 -1
  123. package/dist/lang/ug.umd.min.js +2 -2
  124. package/dist/lang/uk.umd.min.js +1 -1
  125. package/dist/lang/vi.umd.min.js +1 -1
  126. package/dist/lang/zh-hans.umd.min.js +2 -2
  127. package/dist/lang/zh-hant.umd.min.js +2 -2
  128. package/dist/quasar.addon.css +1 -1
  129. package/dist/quasar.addon.rtl.css +1 -1
  130. package/dist/quasar.common.js +2 -2
  131. package/dist/quasar.css +380 -227
  132. package/dist/quasar.esm.js +2 -2
  133. package/dist/quasar.ie.polyfills.js +1 -1
  134. package/dist/quasar.ie.polyfills.umd.min.js +1 -1
  135. package/dist/quasar.min.css +1 -1
  136. package/dist/quasar.rtl.css +512 -303
  137. package/dist/quasar.rtl.min.css +1 -1
  138. package/dist/quasar.sass +328 -210
  139. package/dist/quasar.styl +328 -210
  140. package/dist/quasar.umd.js +3244 -1894
  141. package/dist/quasar.umd.min.js +2 -2
  142. package/dist/quasar.umd.modern.js +3199 -1875
  143. package/dist/quasar.umd.modern.min.js +2 -2
  144. package/dist/transform-asset-urls.json +20 -0
  145. package/dist/types/index.d.ts +427 -105
  146. package/dist/types/utils/scroll.d.ts +1 -0
  147. package/dist/vetur/quasar-attributes.json +320 -92
  148. package/dist/vetur/quasar-tags.json +76 -19
  149. package/dist/web-types/web-types.json +1296 -257
  150. package/icon-set/svg-ionicons-v6.js +225 -0
  151. package/lang/ar.js +1 -1
  152. package/lang/fa-ir.js +3 -1
  153. package/lang/fa.js +3 -1
  154. package/lang/fr.js +1 -1
  155. package/lang/index.json +1 -1
  156. package/lang/kur-ckb.js +2 -2
  157. package/lang/sr.js +4 -4
  158. package/lang/ug.js +48 -46
  159. package/lang/zh-hans.js +1 -1
  160. package/lang/zh-hant.js +18 -18
  161. package/package.json +1 -1
  162. package/src/api.extends.json +1 -2
  163. package/src/components/ajax-bar/QAjaxBar.js +48 -26
  164. package/src/components/ajax-bar/QAjaxBar.json +22 -4
  165. package/src/components/breadcrumbs/QBreadcrumbs.js +15 -11
  166. package/src/components/breadcrumbs/QBreadcrumbs.sass +0 -3
  167. package/src/components/breadcrumbs/QBreadcrumbs.styl +0 -3
  168. package/src/components/breadcrumbs/QBreadcrumbsEl.js +25 -9
  169. package/src/components/btn/QBtn.js +3 -3
  170. package/src/components/btn-dropdown/QBtnDropdown.sass +2 -0
  171. package/src/components/btn-dropdown/QBtnDropdown.styl +2 -0
  172. package/src/components/btn-toggle/QBtnToggle.js +4 -1
  173. package/src/components/carousel/QCarousel.js +6 -2
  174. package/src/components/carousel/QCarousel.json +9 -1
  175. package/src/components/carousel/QCarouselSlide.json +2 -2
  176. package/src/components/chat/QChatMessage.json +1 -1
  177. package/src/components/color/QColor.js +100 -85
  178. package/src/components/color/QColor.json +7 -0
  179. package/src/components/color/QColor.sass +14 -24
  180. package/src/components/color/QColor.styl +14 -24
  181. package/src/components/date/QDate.js +7 -1
  182. package/src/components/date/QDate.sass +2 -0
  183. package/src/components/date/QDate.styl +2 -0
  184. package/src/components/dialog/QDialog.js +8 -4
  185. package/src/components/dialog/QDialog.json +8 -1
  186. package/src/components/drawer/QDrawer.js +16 -15
  187. package/src/components/editor/QEditor.js +2 -2
  188. package/src/components/editor/QEditor.sass +13 -1
  189. package/src/components/editor/QEditor.styl +13 -1
  190. package/src/components/expansion-item/QExpansionItem.js +13 -11
  191. package/src/components/fab/QFab.js +20 -11
  192. package/src/components/fab/QFab.json +35 -0
  193. package/src/components/fab/QFabAction.js +16 -9
  194. package/src/components/fab/QFabAction.json +10 -0
  195. package/src/components/field/QField.js +28 -23
  196. package/src/components/field/__QField.json +72 -8
  197. package/src/components/file/QFile.js +12 -4
  198. package/src/components/file/QFile.sass +4 -3
  199. package/src/components/file/QFile.styl +4 -3
  200. package/src/components/footer/QFooter.js +1 -1
  201. package/src/components/form/QForm.js +1 -1
  202. package/src/components/header/QHeader.js +1 -1
  203. package/src/components/icon/QIcon.js +89 -75
  204. package/src/components/icon/QIcon.sass +2 -2
  205. package/src/components/icon/QIcon.styl +2 -2
  206. package/src/components/img/QImg.json +2 -2
  207. package/src/components/infinite-scroll/QInfiniteScroll.js +49 -36
  208. package/src/components/inner-loading/QInnerLoading.js +54 -22
  209. package/src/components/inner-loading/QInnerLoading.json +29 -0
  210. package/src/components/inner-loading/QInnerLoading.sass +3 -0
  211. package/src/components/inner-loading/QInnerLoading.styl +3 -0
  212. package/src/components/item/QItem.js +9 -15
  213. package/src/components/layout/QLayout.js +49 -0
  214. package/src/components/linear-progress/QLinearProgress.js +6 -2
  215. package/src/components/menu/QMenu.js +5 -1
  216. package/src/components/option-group/QOptionGroup.js +32 -22
  217. package/src/components/option-group/QOptionGroup.json +50 -1
  218. package/src/components/parallax/QParallax.js +3 -0
  219. package/src/components/parallax/QParallax.json +1 -1
  220. package/src/components/popup-edit/QPopupEdit.js +41 -16
  221. package/src/components/popup-edit/QPopupEdit.json +15 -8
  222. package/src/components/range/QRange.js +223 -278
  223. package/src/components/range/QRange.json +11 -122
  224. package/src/components/rating/QRating.js +56 -38
  225. package/src/components/rating/QRating.json +3 -3
  226. package/src/components/rating/QRating.sass +8 -6
  227. package/src/components/rating/QRating.styl +8 -6
  228. package/src/components/resize-observer/QResizeObserver.js +15 -10
  229. package/src/components/scroll-area/QScrollArea.js +342 -126
  230. package/src/components/scroll-area/QScrollArea.json +164 -20
  231. package/src/components/scroll-area/QScrollArea.sass +5 -0
  232. package/src/components/scroll-area/QScrollArea.styl +5 -0
  233. package/src/components/scroll-observer/QScrollObserver.js +12 -7
  234. package/src/components/select/QSelect.js +8 -2
  235. package/src/components/select/QSelect.json +1 -1
  236. package/src/components/separator/QSeparator.js +0 -1
  237. package/src/components/separator/QSeparator.json +1 -1
  238. package/src/components/slider/QSlider.js +97 -140
  239. package/src/components/slider/QSlider.json +1 -122
  240. package/src/components/slider/QSlider.sass +205 -139
  241. package/src/components/slider/QSlider.styl +205 -139
  242. package/src/components/slider/slider-utils.js +468 -123
  243. package/src/components/slider/slider-utils.json +546 -0
  244. package/src/components/stepper/QStepper.js +1 -1
  245. package/src/components/stepper/QStepper.sass +25 -26
  246. package/src/components/stepper/QStepper.styl +25 -26
  247. package/src/components/table/QTable.sass +3 -0
  248. package/src/components/table/QTable.styl +3 -0
  249. package/src/components/tabs/QRouteTab.js +13 -13
  250. package/src/components/tabs/QRouteTab.json +0 -7
  251. package/src/components/tabs/QTab.js +71 -20
  252. package/src/components/tabs/QTabs.js +237 -52
  253. package/src/components/tabs/QTabs.json +8 -0
  254. package/src/components/tabs/QTabs.sass +6 -6
  255. package/src/components/tabs/QTabs.styl +6 -6
  256. package/src/components/time/QTime.js +6 -2
  257. package/src/components/timeline/QTimeline.sass +1 -2
  258. package/src/components/timeline/QTimeline.styl +1 -2
  259. package/src/components/timeline/QTimelineEntry.json +1 -1
  260. package/src/components/tree/QTree.js +10 -6
  261. package/src/components/tree/QTree.json +5 -0
  262. package/src/components/tree/QTree.sass +58 -4
  263. package/src/components/tree/QTree.styl +58 -4
  264. package/src/components/uploader/QUploaderBase.js +15 -19
  265. package/src/components/video/QVideo.js +4 -1
  266. package/src/components/video/QVideo.json +11 -0
  267. package/src/components/virtual-scroll/QVirtualScroll.sass +1 -0
  268. package/src/components/virtual-scroll/QVirtualScroll.styl +1 -0
  269. package/src/css/core/helpers.sass +3 -0
  270. package/src/css/core/helpers.styl +3 -0
  271. package/src/css/core/positioning.sass +5 -0
  272. package/src/css/core/positioning.styl +5 -0
  273. package/src/css/variables.sass +4 -6
  274. package/src/css/variables.styl +4 -6
  275. package/src/directives/Scroll.js +2 -2
  276. package/src/directives/ScrollFire.js +1 -0
  277. package/src/ie-compat/ie.js +13 -13
  278. package/src/install.js +1 -1
  279. package/src/lang.js +7 -4
  280. package/src/mixins/anchor.js +3 -13
  281. package/src/mixins/btn.js +33 -38
  282. package/src/mixins/btn.json +26 -11
  283. package/src/mixins/file.js +27 -5
  284. package/src/mixins/fullscreen.js +16 -4
  285. package/src/mixins/portal.js +10 -10
  286. package/src/mixins/router-link.js +88 -14
  287. package/src/mixins/router-link.json +26 -10
  288. package/src/mixins/validate.js +33 -15
  289. package/src/mixins/virtual-scroll.js +40 -42
  290. package/src/plugins/AppFullscreen.js +41 -16
  291. package/src/plugins/BottomSheet.json +1 -1
  292. package/src/plugins/Cookies.js +1 -1
  293. package/src/plugins/Loading.js +8 -0
  294. package/src/plugins/LoadingBar.js +9 -0
  295. package/src/plugins/LoadingBar.json +1 -1
  296. package/src/plugins/Notify.js +351 -333
  297. package/src/plugins/Notify.json +20 -20
  298. package/src/plugins/Notify.sass +9 -3
  299. package/src/plugins/Notify.styl +9 -3
  300. package/src/utils/clone.js +53 -4
  301. package/src/utils/date.js +134 -69
  302. package/src/utils/dom.js +28 -9
  303. package/src/utils/extend.js +2 -2
  304. package/src/utils/focus-manager.js +8 -10
  305. package/src/utils/global-dialog.js +18 -1
  306. package/src/utils/is.js +2 -2
  307. package/src/utils/morph.js +2 -12
  308. package/src/utils/scroll.js +71 -35
@@ -1,38 +1,18 @@
1
+ import TouchPan from '../../directives/TouchPan.js'
2
+
3
+ import DarkMixin from '../../mixins/dark.js'
4
+ import FormMixin from '../../mixins/form.js'
5
+
1
6
  import { between } from '../../utils/format.js'
2
7
  import { position } from '../../utils/event.js'
8
+ import { isNumber } from '../../utils/is.js'
3
9
 
4
- import FormMixin from '../../mixins/form.js'
5
- import DarkMixin from '../../mixins/dark.js'
6
- import TouchPan from '../../directives/TouchPan.js'
10
+ const markerPrefixClass = 'q-slider__marker-labels'
11
+ const defaultMarkerConvertFn = v => ({ value: v })
7
12
 
8
13
  // PGDOWN, LEFT, DOWN, PGUP, RIGHT, UP
9
14
  export const keyCodes = [ 34, 37, 40, 33, 39, 38 ]
10
15
 
11
- export function getRatio (evt, dragging, reverse, vertical) {
12
- const
13
- pos = position(evt),
14
- val = vertical === true
15
- ? between((pos.top - dragging.top) / dragging.height, 0, 1)
16
- : between((pos.left - dragging.left) / dragging.width, 0, 1)
17
-
18
- return reverse === true ? 1.0 - val : val
19
- }
20
-
21
- export function getModel (ratio, min, max, step, decimals) {
22
- let model = min + ratio * (max - min)
23
-
24
- if (step > 0) {
25
- const modulo = (model - min) % step
26
- model += (Math.abs(modulo) >= step / 2 ? (modulo < 0 ? -1 : 1) * step : 0) - modulo
27
- }
28
-
29
- if (decimals > 0) {
30
- model = parseFloat(model.toFixed(decimals))
31
- }
32
-
33
- return between(model, min, max)
34
- }
35
-
36
16
  export const SliderMixin = {
37
17
  mixins: [ DarkMixin, FormMixin ],
38
18
 
@@ -49,30 +29,58 @@ export const SliderMixin = {
49
29
  type: Number,
50
30
  default: 100
51
31
  },
32
+ innerMin: Number,
33
+ innerMax: Number,
34
+
52
35
  step: {
53
36
  type: Number,
54
37
  default: 1,
55
38
  validator: v => v >= 0
56
39
  },
57
40
 
41
+ snap: Boolean,
42
+
43
+ vertical: Boolean,
44
+ reverse: Boolean,
45
+
46
+ hideSelection: Boolean,
47
+
58
48
  color: String,
49
+ markerLabelsClass: String,
59
50
 
51
+ label: Boolean,
60
52
  labelColor: String,
61
53
  labelTextColor: String,
62
- dense: Boolean,
63
-
64
- label: Boolean,
65
54
  labelAlways: Boolean,
66
- markers: Boolean,
67
- snap: Boolean,
55
+ switchLabelSide: Boolean,
68
56
 
69
- vertical: Boolean,
70
- reverse: Boolean,
57
+ markers: [ Boolean, Number ],
58
+ markerLabels: [ Boolean, Array, Object, Function ],
59
+ switchMarkerLabelsSide: Boolean,
60
+
61
+ trackImg: String,
62
+ trackColor: String,
63
+ innerTrackImg: String,
64
+ innerTrackColor: String,
65
+ selectionColor: String,
66
+ selectionImg: String,
67
+
68
+ thumbSize: {
69
+ type: String,
70
+ default: '20px'
71
+ },
72
+ trackSize: {
73
+ type: String,
74
+ default: '4px'
75
+ },
71
76
 
72
77
  disable: Boolean,
73
78
  readonly: Boolean,
79
+ dense: Boolean,
80
+
74
81
  tabindex: [ String, Number ],
75
82
 
83
+ thumbColor: String,
76
84
  thumbPath: {
77
85
  type: String,
78
86
  default: 'M 4, 10 a 6,6 0 1,0 12,0 a 6,6 0 1,0 -12,0'
@@ -83,7 +91,8 @@ export const SliderMixin = {
83
91
  return {
84
92
  active: false,
85
93
  preventFocus: false,
86
- focus: false
94
+ focus: false,
95
+ dragging: false
87
96
  }
88
97
  },
89
98
 
@@ -92,95 +101,239 @@ export const SliderMixin = {
92
101
  return this.vertical === true ? '--v' : '--h'
93
102
  },
94
103
 
95
- classes () {
96
- return `q-slider q-slider${this.axis} q-slider--${this.active === true ? '' : 'in'}active` +
97
- (this.isReversed === true ? ' q-slider--reversed' : '') +
98
- (this.color !== void 0 ? ` text-${this.color}` : '') +
99
- (this.disable === true ? ' disabled' : ' q-slider--enabled' + (this.editable === true ? ' q-slider--editable' : '')) +
100
- (this.focus === 'both' ? ' q-slider--focus' : '') +
101
- (this.label || this.labelAlways === true ? ' q-slider--label' : '') +
102
- (this.labelAlways === true ? ' q-slider--label-always' : '') +
103
- (this.isDark === true ? ' q-slider--dark' : '') +
104
- (this.dense === true ? ' q-slider--dense q-slider--dense' + this.axis : '')
104
+ labelSide () {
105
+ return '-' + (this.switchLabelSide === true ? 'switched' : 'standard')
106
+ },
107
+
108
+ isReversed () {
109
+ return this.vertical === true
110
+ ? this.reverse === true
111
+ : this.reverse !== (this.$q.lang.rtl === true)
112
+ },
113
+
114
+ computedInnerMin () {
115
+ return this.__getInnerMin(this.innerMin)
116
+ },
117
+
118
+ computedInnerMax () {
119
+ return this.__getInnerMax(this.innerMax)
105
120
  },
106
121
 
107
122
  editable () {
108
- return this.disable !== true && this.readonly !== true && this.min < this.max
123
+ return this.disable !== true && this.readonly !== true &&
124
+ this.computedInnerMin < this.computedInnerMax
109
125
  },
110
126
 
111
- decimals () {
112
- return (String(this.step).trim('0').split('.')[1] || '').length
127
+ computedDecimals () {
128
+ return (String(this.step).trim('0').split('.')[ 1 ] || '').length
113
129
  },
114
130
 
115
131
  computedStep () {
116
132
  return this.step === 0 ? 1 : this.step
117
133
  },
118
134
 
119
- minMaxDiff () {
120
- return this.max - this.min
135
+ computedTabindex () {
136
+ return this.editable === true ? this.tabindex || 0 : -1
121
137
  },
122
138
 
123
- markerStyle () {
124
- if (this.minMaxDiff !== 0) {
125
- const size = 100 * this.computedStep / this.minMaxDiff
139
+ trackLen () {
140
+ return this.max - this.min
141
+ },
126
142
 
127
- return {
128
- backgroundSize: this.vertical === true
129
- ? '2px ' + size + '%'
130
- : size + '% 2px'
131
- }
132
- }
143
+ innerBarLen () {
144
+ return this.computedInnerMax - this.computedInnerMin
133
145
  },
134
146
 
135
- computedTabindex () {
136
- return this.editable === true ? this.tabindex || 0 : -1
147
+ innerMinRatio () {
148
+ return this.__convertModelToRatio(this.computedInnerMin)
137
149
  },
138
150
 
139
- isReversed () {
140
- return this.vertical === true
141
- ? this.reverse === true
142
- : this.reverse !== (this.$q.lang.rtl === true)
151
+ innerMaxRatio () {
152
+ return this.__convertModelToRatio(this.computedInnerMax)
143
153
  },
144
154
 
145
155
  positionProp () {
146
- if (this.vertical === true) {
147
- return this.isReversed === true ? 'bottom' : 'top'
148
- }
149
- return this.isReversed === true ? 'right' : 'left'
156
+ return this.vertical === true
157
+ ? (this.isReversed === true ? 'bottom' : 'top')
158
+ : (this.isReversed === true ? 'right' : 'left')
150
159
  },
151
160
 
152
161
  sizeProp () {
153
162
  return this.vertical === true ? 'height' : 'width'
154
163
  },
155
164
 
165
+ thicknessProp () {
166
+ return this.vertical === true ? 'width' : 'height'
167
+ },
168
+
156
169
  orientation () {
157
170
  return this.vertical === true ? 'vertical' : 'horizontal'
158
171
  },
159
172
 
160
- attrs () {
161
- const attrs = {
173
+ attributes () {
174
+ const acc = {
162
175
  role: 'slider',
163
- 'aria-valuemin': this.min,
164
- 'aria-valuemax': this.max,
176
+ 'aria-valuemin': this.computedInnerMin,
177
+ 'aria-valuemax': this.computedInnerMax,
165
178
  'aria-orientation': this.orientation,
166
179
  'data-step': this.step
167
180
  }
168
181
 
169
182
  if (this.disable === true) {
170
- attrs['aria-disabled'] = 'true'
183
+ acc[ 'aria-disabled' ] = 'true'
171
184
  }
172
185
  else if (this.readonly === true) {
173
- attrs['aria-readonly'] = 'true'
186
+ acc[ 'aria-readonly' ] = 'true'
174
187
  }
175
188
 
176
- return attrs
189
+ return acc
190
+ },
191
+
192
+ classes () {
193
+ return `q-slider q-slider${this.axis} q-slider--${this.active === true ? '' : 'in'}active inline no-wrap ` +
194
+ (this.vertical === true ? 'row' : 'column') +
195
+ (this.disable === true ? ' disabled' : ' q-slider--enabled' + (this.editable === true ? ' q-slider--editable' : '')) +
196
+ (this.focus === 'both' ? ' q-slider--focus' : '') +
197
+ (this.label || this.labelAlways === true ? ' q-slider--label' : '') +
198
+ (this.labelAlways === true ? ' q-slider--label-always' : '') +
199
+ (this.isDark === true ? ' q-slider--dark' : '') +
200
+ (this.dense === true ? ' q-slider--dense q-slider--dense' + this.axis : '')
201
+ },
202
+
203
+ selectionBarClass () {
204
+ const color = this.selectionColor || this.color
205
+ return 'q-slider__selection absolute' +
206
+ (color !== void 0 ? ` text-${color}` : '')
207
+ },
208
+
209
+ markerClass () {
210
+ return this.__getAxisClass('markers') + ' absolute overflow-hidden'
211
+ },
212
+ trackContainerClass () {
213
+ return this.__getAxisClass('track-container')
214
+ },
215
+ pinClass () {
216
+ return this.__getPositionClass('pin')
217
+ },
218
+ labelClass () {
219
+ return this.__getPositionClass('label')
220
+ },
221
+ textContainerClass () {
222
+ return this.__getPositionClass('text-container')
223
+ },
224
+ markerLabelsContainerClass () {
225
+ return this.__getPositionClass('marker-labels-container') +
226
+ (this.markerLabelsClass !== void 0 ? ` ${this.markerLabelsClass}` : '')
227
+ },
228
+
229
+ trackClass () {
230
+ return 'q-slider__track relative-position no-outline' +
231
+ (this.trackColor !== void 0 ? ` bg-${this.trackColor}` : '')
232
+ },
233
+ trackStyle () {
234
+ const acc = { [ this.thicknessProp ]: this.trackSize }
235
+ if (this.trackImg !== void 0) {
236
+ acc.backgroundImage = `url(${this.trackImg}) !important`
237
+ }
238
+ return acc
239
+ },
240
+
241
+ innerBarClass () {
242
+ return 'q-slider__inner absolute' +
243
+ (this.innerTrackColor !== void 0 ? ` bg-${this.innerTrackColor}` : '')
244
+ },
245
+
246
+ innerBarStyle () {
247
+ const acc = {
248
+ [ this.positionProp ]: `${100 * this.innerMinRatio}%`,
249
+ [ this.sizeProp ]: `${100 * (this.innerMaxRatio - this.innerMinRatio)}%`
250
+ }
251
+ if (this.innerTrackImg !== void 0) {
252
+ acc.backgroundImage = `url(${this.innerTrackImg}) !important`
253
+ }
254
+ return acc
255
+ },
256
+
257
+ markerStep () {
258
+ return isNumber(this.markers) === true ? this.markers : this.computedStep
259
+ },
260
+
261
+ markerTicks () {
262
+ const acc = []
263
+ const step = this.markerStep
264
+
265
+ let value = this.min
266
+ do {
267
+ acc.push(value)
268
+ value += step
269
+ } while (value < this.max)
270
+
271
+ acc.push(this.max)
272
+ return acc
273
+ },
274
+
275
+ markerLabelClass () {
276
+ const prefix = ` ${markerPrefixClass}${this.axis}-`
277
+ return markerPrefixClass +
278
+ `${prefix}${this.switchMarkerLabelsSide === true ? 'switched' : 'standard'}` +
279
+ `${prefix}${this.isReversed === true ? 'rtl' : 'ltr'}`
280
+ },
281
+
282
+ markerLabelsList () {
283
+ if (this.markerLabels === false) { return null }
284
+
285
+ return this.__getMarkerList(this.markerLabels).map((entry, index) => ({
286
+ index,
287
+ value: entry.value,
288
+ label: entry.label || entry.value,
289
+ classes: this.markerLabelClass +
290
+ (entry.classes !== void 0 ? ' ' + entry.classes : ''),
291
+ style: {
292
+ ...this.__getMarkerLabelStyle(entry.value),
293
+ ...(entry.style || {})
294
+ }
295
+ }))
296
+ },
297
+
298
+ markerScope () {
299
+ return {
300
+ markerList: this.markerLabelsList,
301
+ markerMap: this.markerLabelsMap,
302
+ classes: this.markerLabelClass,
303
+ getStyle: this.__getMarkerLabelStyle
304
+ }
305
+ },
306
+
307
+ markerStyle () {
308
+ if (this.innerBarLen !== 0) {
309
+ const size = 100 * this.markerStep / this.innerBarLen
310
+
311
+ return {
312
+ ...this.innerBarStyle,
313
+ backgroundSize: this.vertical === true
314
+ ? `2px ${size}%`
315
+ : `${size}% 2px`
316
+ }
317
+ }
318
+
319
+ return null
320
+ },
321
+
322
+ markerLabelsMap () {
323
+ if (this.markerLabels === false) { return null }
324
+
325
+ const acc = {}
326
+ this.markerLabelsList.forEach(entry => {
327
+ acc[ entry.value ] = entry
328
+ })
329
+ return acc
177
330
  },
178
331
 
179
332
  panDirectives () {
180
333
  return this.editable === true
181
334
  ? [{
182
335
  name: 'touch-pan',
183
- value: this.__pan,
336
+ value: this.__onPan,
184
337
  modifiers: {
185
338
  [ this.orientation ]: true,
186
339
  prevent: true,
@@ -194,45 +347,118 @@ export const SliderMixin = {
194
347
  },
195
348
 
196
349
  methods: {
197
- __getThumbSvg (h) {
198
- return h('svg', {
199
- staticClass: 'q-slider__thumb absolute',
200
- attrs: {
201
- focusable: 'false', /* needed for IE11 */
202
- viewBox: '0 0 20 20',
203
- width: '20',
204
- height: '20',
205
- 'aria-hidden': 'true'
206
- }
207
- }, [
208
- h('path', {
209
- attrs: {
210
- d: this.thumbPath
211
- }
212
- })
213
- ])
350
+ __getInnerMin (val) {
351
+ return isNaN(val) === true || this.innerMin < this.min
352
+ ? this.min
353
+ : this.innerMin
354
+ },
355
+
356
+ __getInnerMax (val) {
357
+ return isNaN(val) === true || val > this.max
358
+ ? this.max
359
+ : this.innerMax
360
+ },
361
+
362
+ __getPositionClass (name) {
363
+ const cls = 'q-slider__' + name
364
+ return `${cls} ${cls}${this.axis} ${cls}${this.axis}${this.labelSide}`
365
+ },
366
+
367
+ __getAxisClass (name) {
368
+ const cls = 'q-slider__' + name
369
+ return `${cls} ${cls}${this.axis}`
214
370
  },
215
371
 
216
- __getPinStyle (percent, ratio) {
217
- if (this.vertical === true) {
218
- return {}
372
+ __convertRatioToModel (ratio) {
373
+ let model = this.min + ratio * (this.max - this.min)
374
+
375
+ if (this.step > 0) {
376
+ const modulo = (model - this.min) % this.step
377
+ model += (Math.abs(modulo) >= this.step / 2 ? (modulo < 0 ? -1 : 1) * this.step : 0) - modulo
219
378
  }
220
379
 
221
- const offset = `${Math.ceil(20 * Math.abs(0.5 - ratio))}px`
222
- return {
223
- pin: {
224
- transformOrigin: `${this.$q.lang.rtl === true ? offset : (this.$q.platform.is.ie === true ? '100%' : `calc(100% - ${offset})`)} 50%`
225
- },
380
+ if (this.computedDecimals > 0) {
381
+ model = parseFloat(model.toFixed(this.computedDecimals))
382
+ }
226
383
 
227
- pinTextContainer: {
228
- [this.$q.lang.rtl === true ? 'left' : 'right']: `${percent * 100}%`,
229
- transform: `translateX(${Math.ceil((this.$q.lang.rtl === true ? -1 : 1) * 20 * percent)}px)`
230
- }
384
+ return between(model, this.computedInnerMin, this.computedInnerMax)
385
+ },
386
+
387
+ __convertModelToRatio (model) {
388
+ return this.trackLen === 0
389
+ ? 0
390
+ : (model - this.min) / this.trackLen
391
+ },
392
+
393
+ __getDraggingRatio (evt, dragging) {
394
+ const
395
+ pos = position(evt),
396
+ val = this.vertical === true
397
+ ? between((pos.top - dragging.top) / dragging.height, 0, 1)
398
+ : between((pos.left - dragging.left) / dragging.width, 0, 1)
399
+
400
+ return between(
401
+ this.isReversed === true ? 1.0 - val : val,
402
+ this.innerMinRatio,
403
+ this.innerMaxRatio
404
+ )
405
+ },
406
+
407
+ __getMarkerList (def) {
408
+ if (def === false) { return null }
409
+
410
+ if (def === true) {
411
+ return this.markerTicks.map(defaultMarkerConvertFn)
412
+ }
413
+
414
+ if (typeof def === 'function') {
415
+ return this.markerTicks.map(value => {
416
+ const item = def(value)
417
+ return Object(item) === item ? { ...item, value } : { value, label: item }
418
+ })
419
+ }
420
+
421
+ const filterFn = ({ value }) => value >= this.min && value <= this.max
422
+
423
+ if (Array.isArray(def) === true) {
424
+ return def
425
+ .map(item => (Object(item) === item ? item : { value: item }))
426
+ .filter(filterFn)
427
+ }
428
+
429
+ return Object.keys(def).map(key => {
430
+ const item = def[ key ]
431
+ const value = Number(key)
432
+ return Object(item) === item ? { ...item, value } : { value, label: item }
433
+ }).filter(filterFn)
434
+ },
435
+
436
+ __getMarkerLabelStyle (val) {
437
+ return { [ this.positionProp ]: `${100 * (val - this.min) / this.trackLen}%` }
438
+ },
439
+
440
+ __getMarkerLabelsContent (h) {
441
+ if (this.$scopedSlots[ 'marker-label-group' ] !== void 0) {
442
+ return this.$scopedSlots[ 'marker-label-group' ](this.markerScope)
443
+ }
444
+
445
+ const fn = this.$scopedSlots[ 'marker-label' ]
446
+ if (fn !== void 0) {
447
+ return this.markerLabelsList.map(marker => fn({
448
+ marker,
449
+ ...this.markerScope
450
+ }))
231
451
  }
452
+
453
+ return this.markerLabelsList.map(marker => h('div', {
454
+ key: marker.value,
455
+ style: marker.style,
456
+ class: marker.classes
457
+ }, marker.label))
232
458
  },
233
459
 
234
- __pan (event) {
235
- if (event.isFinal) {
460
+ __onPan (event) {
461
+ if (event.isFinal === true) {
236
462
  if (this.dragging !== void 0) {
237
463
  this.__updatePosition(event.evt)
238
464
  // only if touch, because we also have mousedown/up:
@@ -241,8 +467,9 @@ export const SliderMixin = {
241
467
  this.$emit('pan', 'end')
242
468
  }
243
469
  this.active = false
470
+ this.focus = false
244
471
  }
245
- else if (event.isFirst) {
472
+ else if (event.isFirst === true) {
246
473
  this.dragging = this.__getDragging(event.evt)
247
474
  this.__updatePosition(event.evt)
248
475
  this.__updateValue()
@@ -255,46 +482,164 @@ export const SliderMixin = {
255
482
  }
256
483
  },
257
484
 
258
- __blur () {
485
+ __onBlur () {
259
486
  this.focus = false
260
487
  },
261
488
 
262
- __activate (evt) {
489
+ __onActivate (evt) {
263
490
  this.__updatePosition(evt, this.__getDragging(evt))
264
491
  this.__updateValue()
265
492
 
266
493
  this.preventFocus = true
267
494
  this.active = true
268
495
 
269
- document.addEventListener('mouseup', this.__deactivate, true)
496
+ document.addEventListener('mouseup', this.__onDeactivate, true)
270
497
  },
271
498
 
272
- __deactivate () {
499
+ __onDeactivate () {
273
500
  this.preventFocus = false
274
-
275
- if (this.dragging === void 0) {
276
- this.active = false
277
- }
501
+ this.active = false
278
502
 
279
503
  this.__updateValue(true)
280
- this.__blur()
504
+ this.__onBlur()
281
505
 
282
- document.removeEventListener('mouseup', this.__deactivate, true)
506
+ document.removeEventListener('mouseup', this.__onDeactivate, true)
283
507
  },
284
508
 
285
- __mobileClick (evt) {
509
+ __onMobileClick (evt) {
286
510
  this.__updatePosition(evt, this.__getDragging(evt))
287
511
  this.__updateValue(true)
288
512
  },
289
513
 
290
- __keyup (evt) {
514
+ __onKeyup (evt) {
291
515
  if (keyCodes.includes(evt.keyCode)) {
292
516
  this.__updateValue(true)
293
517
  }
518
+ },
519
+
520
+ __getTextContainerStyle (ratio) {
521
+ if (this.vertical === true) { return null }
522
+
523
+ const p = this.$q.lang.rtl !== this.reverse ? 1 - ratio : ratio
524
+ return {
525
+ transform: `translateX(calc(${2 * p - 1} * ${this.thumbSize} / 2 + ${50 - 100 * p}%))`
526
+ }
527
+ },
528
+
529
+ __getThumb (h, thumb) {
530
+ const thumbContent = [
531
+ h('svg', {
532
+ class: 'q-slider__thumb-shape absolute-full',
533
+ attrs: {
534
+ viewBox: '0 0 20 20',
535
+ 'aria-hidden': 'true'
536
+ }
537
+ }, [
538
+ h('path', {
539
+ attrs: { d: this.thumbPath }
540
+ })
541
+ ]),
542
+
543
+ h('div', { class: 'q-slider__focus-ring fit' })
544
+ ]
545
+
546
+ if (this.label === true || this.labelAlways === true) {
547
+ thumbContent.push(
548
+ h('div', {
549
+ class: this.pinClass + ' absolute fit no-pointer-events' + thumb.pinColor
550
+ }, [
551
+ h('div', {
552
+ class: this.labelClass,
553
+ style: { minWidth: this.thumbSize }
554
+ }, [
555
+ h('div', {
556
+ class: this.textContainerClass,
557
+ style: thumb.textContainerStyle
558
+ }, [
559
+ h('span', { class: thumb.textClass }, thumb.label)
560
+ ])
561
+ ])
562
+ ])
563
+ )
564
+
565
+ if (this.name !== void 0 && this.disable !== true) {
566
+ this.__injectFormInput(thumbContent, 'push')
567
+ }
568
+ }
569
+
570
+ return h('div', {
571
+ class: thumb.classes,
572
+ style: thumb.style,
573
+ ...thumb.nodeData
574
+ }, thumbContent)
575
+ },
576
+
577
+ __getContent (h, injectThumb) {
578
+ const trackContent = []
579
+
580
+ this.innerTrackColor !== 'transparent' && trackContent.push(
581
+ h('div', {
582
+ key: 'inner',
583
+ class: this.innerBarClass,
584
+ style: this.innerBarStyle
585
+ })
586
+ )
587
+
588
+ this.selectionColor !== 'transparent' && trackContent.push(
589
+ h('div', {
590
+ key: 'selection',
591
+ class: this.selectionBarClass,
592
+ style: this.selectionBarStyle
593
+ })
594
+ )
595
+
596
+ this.markers !== false && trackContent.push(
597
+ h('div', {
598
+ key: 'marker',
599
+ class: this.markerClass,
600
+ style: this.markerStyle
601
+ })
602
+ )
603
+
604
+ injectThumb(trackContent)
605
+
606
+ const content = [
607
+ h(
608
+ 'div',
609
+ {
610
+ key: 'trackC',
611
+ class: this.trackContainerClass,
612
+ attrs: this.trackContainerAttrs,
613
+ on: this.trackContainerEvents,
614
+ directives: this.panDirectives
615
+ },
616
+ [
617
+ h('div', {
618
+ class: this.trackClass,
619
+ style: this.trackStyle
620
+ }, trackContent)
621
+ ]
622
+ )
623
+ ]
624
+
625
+ if (this.markerLabels !== false) {
626
+ const action = this.switchMarkerLabelsSide === true
627
+ ? 'unshift'
628
+ : 'push'
629
+
630
+ content[ action ](
631
+ h('div', {
632
+ key: 'markerL',
633
+ class: this.markerLabelsContainerClass
634
+ }, this.__getMarkerLabelsContent(h))
635
+ )
636
+ }
637
+
638
+ return content
294
639
  }
295
640
  },
296
641
 
297
642
  beforeDestroy () {
298
- document.removeEventListener('mouseup', this.__deactivate, true)
643
+ document.removeEventListener('mouseup', this.__onDeactivate, true)
299
644
  }
300
645
  }