@titaui/pc 1.11.4-0 → 1.11.4-1

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 (292) hide show
  1. package/es/components/cascader/time.js +31 -0
  2. package/es/components/common-share/request-apis.js +56 -0
  3. package/es/components/confidence/heart.js +66 -0
  4. package/es/components/create-okr-modal/fields/index.js +17 -0
  5. package/es/components/create-okr-modal/utils/getCreateOkrSurpassPercent.js +154 -0
  6. package/es/components/date-picker/BodyItem.js +121 -0
  7. package/es/components/date-picker/CalendarBody.js +157 -0
  8. package/es/components/date-picker/CalendarHeader.js +187 -0
  9. package/es/components/date-picker/index.js +157 -0
  10. package/es/components/date-range-picker/index.js +210 -0
  11. package/es/components/dialog/index.js +119 -0
  12. package/es/components/dialog-confirm/index.js +154 -0
  13. package/es/components/drop-selector/icon-item.js +40 -0
  14. package/es/components/drop-selector/index.js +179 -0
  15. package/es/components/dynamic/dynamic-like-ranking/mock.js +84 -0
  16. package/es/components/dynamic/dynamic-liking/mock.js +83 -0
  17. package/es/components/dynamic/dynamic-topping/request-api.js +36 -0
  18. package/es/components/e-priority/index.js +88 -0
  19. package/es/components/e-status-dropdown/index.js +94 -0
  20. package/es/components/grid-layout/commen-components/index.js +73 -0
  21. package/es/components/grid-layout/image/could.js +8 -0
  22. package/es/components/grid-layout/image/lv.js +8 -0
  23. package/es/components/grid-layout/image/tita-mask.js +8 -0
  24. package/es/components/help-card/request-api.js +35 -0
  25. package/es/components/icon-button-list/index.js +65 -0
  26. package/es/components/menus/context.js +18 -0
  27. package/es/components/menus/precls.js +8 -0
  28. package/es/components/okr-detail/auth.js +197 -0
  29. package/es/components/okr-detail/components/ao-nice/index.js +245 -0
  30. package/es/components/okr-detail/components/block-line/index.js +20 -0
  31. package/es/components/okr-detail/components/header/index.js +211 -0
  32. package/es/components/okr-detail/components/icon-text/index.js +116 -0
  33. package/es/components/okr-detail/components/okr-tree/index.js +48 -0
  34. package/es/components/okr-detail/components/okr-tree/precls.js +8 -0
  35. package/es/components/okr-detail/components/okr-tree/tree-node/default-node.js +22 -0
  36. package/es/components/okr-detail/components/okr-tree/tree-node/e-node/e-priority-dropdown.js +88 -0
  37. package/es/components/okr-detail/components/okr-tree/tree-node/e-node/e-project.js +200 -0
  38. package/es/components/okr-detail/components/okr-tree/tree-node/e-node/e-status-dropdown.js +98 -0
  39. package/es/components/okr-detail/components/okr-tree/tree-node/e-node/e-task-level2.js +412 -0
  40. package/es/components/okr-detail/components/okr-tree/tree-node/get-process-color.js +62 -0
  41. package/es/components/okr-detail/components/okr-tree/tree-node/index.js +90 -0
  42. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/get-process-color.js +46 -0
  43. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/index.js +421 -0
  44. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/kr-score-editor/index.js +54 -0
  45. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/kr-score-editor/style.js +62 -0
  46. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/range-picker-pop.js +94 -0
  47. package/es/components/okr-detail/components/okr-tree/tree-node/kr-parent-node/index.js +273 -0
  48. package/es/components/okr-detail/components/okr-tree/tree-node/o-child-node/index.js +207 -0
  49. package/es/components/okr-detail/components/okr-tree/tree-node/o-parent-node/index.js +236 -0
  50. package/es/components/okr-detail/components/padding-layout.js +22 -0
  51. package/es/components/okr-detail/components/tab-panel-content/index.js +27 -0
  52. package/es/components/okr-detail/context.js +30 -0
  53. package/es/components/okr-detail/e-list/index.js +243 -0
  54. package/es/components/okr-detail/e-list/precls.js +8 -0
  55. package/es/components/okr-detail/e-list/search-form/fields/e-order.js +172 -0
  56. package/es/components/okr-detail/e-list/search-form/fields/e-status.js +99 -0
  57. package/es/components/okr-detail/e-list/search-form/fields/e-user.js +49 -0
  58. package/es/components/okr-detail/e-list/search-form/index.js +143 -0
  59. package/es/components/okr-detail/error-page/index.js +33 -0
  60. package/es/components/okr-detail/index.js +428 -0
  61. package/es/components/okr-detail/loading/index.js +28 -0
  62. package/es/components/okr-detail/okr-list/add-parent-okr.js +37 -0
  63. package/es/components/okr-detail/okr-list/create-kr-item/heart.js +38 -0
  64. package/es/components/okr-detail/okr-list/drag-order-kr.js +62 -0
  65. package/es/components/okr-detail/okr-list/empty/index.js +48 -0
  66. package/es/components/okr-detail/okr-list/index.js +524 -0
  67. package/es/components/okr-detail/okr-list/warp-parent-okr.js +21 -0
  68. package/es/components/okr-detail/store.js +1 -0
  69. package/es/components/okr-flow/child-node/fields/creator.js +175 -0
  70. package/es/components/okr-flow/child-node/fields/okrClassify.js +31 -0
  71. package/es/components/okr-flow/child-node/fields/okrType.js +21 -0
  72. package/es/components/okr-flow/child-node/helper.js +35 -0
  73. package/es/components/okr-flow/child-node/index.js +110 -0
  74. package/es/components/okr-flow/child-node/kr-node.js +75 -0
  75. package/es/components/okr-flow/child-node/work-node.js +242 -0
  76. package/es/components/okr-flow/context.js +14 -0
  77. package/es/components/okr-flow/empty/index.js +29 -0
  78. package/es/components/okr-flow/export-modules/okr-search-panel/index.js +394 -0
  79. package/es/components/okr-flow/index.js +24 -0
  80. package/es/components/okr-flow/mini-map/index.js +112 -0
  81. package/es/components/okr-flow/mini-map/map.js +145 -0
  82. package/es/components/okr-flow/mini-map/mini-node.js +57 -0
  83. package/es/components/okr-flow/mini-map/utils.js +79 -0
  84. package/es/components/okr-flow/okr-map/index.js +192 -0
  85. package/es/components/okr-flow/open-data/index.js +115 -0
  86. package/es/components/okr-flow/precls.js +8 -0
  87. package/es/components/okr-flow/request-apis.js +118 -0
  88. package/es/components/okr-flow/root-node/index.js +229 -0
  89. package/es/components/okr-flow/utils/config.js +18 -0
  90. package/es/components/okr-flow/utils/helper.js +36 -0
  91. package/es/components/okr-flow/utils/index.js +66 -0
  92. package/es/components/okr-flow/utils/tree-handler.js +323 -0
  93. package/es/components/okr-progress-modal/helper.js +156 -0
  94. package/es/components/okr-progress-modal/request-apis.js +34 -0
  95. package/es/components/okr-share/request-apis.js +56 -0
  96. package/es/components/okrcase-library/server/network.js +407 -0
  97. package/es/components/pagination/locale/en_US.js +22 -0
  98. package/es/components/pagination/locale/zh_CN.js +22 -0
  99. package/es/components/point-demo/drop-down-box/index.js +159 -0
  100. package/es/components/point-demo/index.js +533 -0
  101. package/es/components/point-demo/input/index.js +176 -0
  102. package/es/components/point-demo/point-demo.js +75 -0
  103. package/es/components/point-demo/popup/index.js +113 -0
  104. package/es/components/point-demo/popup/placement.js +44 -0
  105. package/es/components/range-picker-pop/index.js +273 -0
  106. package/es/components/scrollbar/simplebar/helpers.js +59 -0
  107. package/es/components/scrollbar/simplebar/index.js +91 -0
  108. package/es/components/scrollbar/simplebar/scrollbar-width.js +47 -0
  109. package/es/components/scrollbar/simplebar/simplebar.js +852 -0
  110. package/es/components/scrollbar/simplebar-react.js +163 -0
  111. package/es/components/search-dropdown/index.js +40 -0
  112. package/es/components/search-input/index.js +126 -0
  113. package/es/components/select/Option.js +94 -0
  114. package/es/components/select/index.js +330 -0
  115. package/es/components/selector-input/debounce.js +36 -0
  116. package/es/components/selector-input/index.js +109 -0
  117. package/es/components/slider-input/index.js +119 -0
  118. package/es/components/switch/index.js +39 -0
  119. package/es/components/table/index.js +275 -0
  120. package/es/components/tabs/index.js +63 -0
  121. package/es/components/task-relation-modal/tree-node/index.js +58 -0
  122. package/es/components/tita-chart/charts/img/could.js +8 -0
  123. package/es/components/tooltip/error-tip.js +24 -0
  124. package/es/components/tooltip/index.js +21 -0
  125. package/es/components/tree/index.js +79 -0
  126. package/es/components/tree/precls.js +8 -0
  127. package/es/components/upvote/request-apis.js +45 -0
  128. package/es/components/user-selector/action-btns/btn-cancel.js +21 -0
  129. package/es/components/user-selector/action-btns/btn-ok.js +21 -0
  130. package/es/components/user-selector/action-btns/index.js +27 -0
  131. package/es/components/user-selector/context.js +18 -0
  132. package/es/components/user-selector/empty/group.js +55 -0
  133. package/es/components/user-selector/empty/index.js +28 -0
  134. package/es/components/user-selector/export-modules/depart-search-selector/result-part.js +41 -0
  135. package/es/components/user-selector/export-modules/group-selector/index.js +170 -0
  136. package/es/components/user-selector/export-modules/group-selector/searched-panel.js +68 -0
  137. package/es/components/user-selector/export-modules/multiple-user-selector--bak/index.js +246 -0
  138. package/es/components/user-selector/index.js +25 -0
  139. package/es/components/user-selector/layout/index.js +25 -0
  140. package/es/components/user-selector/loading/index.js +18 -0
  141. package/es/components/user-selector/request-apis.js +180 -0
  142. package/es/components/user-selector/searched-panel/index.js +139 -0
  143. package/es/components/user-selector/searched-panel/result-part.js +43 -0
  144. package/es/components/user-selector/select-tree/selected-tree/index.js +91 -0
  145. package/es/components/user-selector/select-tree/tree-nodes/tree-depart-node/index.js +48 -0
  146. package/es/components/user-selector/select-tree/tree-nodes/tree-duties-node/index.js +27 -0
  147. package/es/components/user-selector/select-tree/tree-nodes/tree-group-node/index.js +57 -0
  148. package/es/components/user-selector/select-tree/tree-nodes/tree-person-node/index.js +93 -0
  149. package/es/components/user-selector/utils.js +139 -0
  150. package/es/components/viewer/ImageListRender.js +143 -0
  151. package/es/components/viewer/index.js +168 -0
  152. package/es/components/word-cloud/index.js +109 -0
  153. package/es/components/word-cloud/request-apis.js +26 -0
  154. package/es/components-v1/animate/AnimateChild.js +76 -0
  155. package/es/components-v1/animate/animate.js +148 -0
  156. package/es/components-v1/animate/index.js +13 -0
  157. package/es/components-v1/dom/index.js +30 -0
  158. package/es/components-v1/placement/index.js +13 -0
  159. package/es/components-v1/placement/placement.js +111 -0
  160. package/es/components-v1/placement/placementInner.js +139 -0
  161. package/es/components-v1/pop/Pop.js +246 -0
  162. package/es/components-v1/pop/PopInner.js +163 -0
  163. package/es/components-v1/pop/index.js +13 -0
  164. package/es/components-v1/progress/CircleProgress.js +152 -0
  165. package/es/components-v1/progress/LineProgress.js +83 -0
  166. package/es/components-v1/progress/index.js +80 -0
  167. package/es/components-v1/select/Option.js +94 -0
  168. package/es/components-v1/select/index.js +330 -0
  169. package/es/components-v1/utils/animate/animate.js +103 -0
  170. package/es/components-v1/utils/animate/event.js +79 -0
  171. package/es/components-v1/utils/dom/index.js +30 -0
  172. package/es/components-v1/utils/placement/autoAdjustPlacement.js +93 -0
  173. package/es/components-v1/utils/placement/getContainerVisibleArea.js +22 -0
  174. package/es/components-v1/utils/placement/getExpectPlacement.js +49 -0
  175. package/es/components-v1/utils/placement/getPlacementInContainer.js +26 -0
  176. package/es/components-v1/utils/placement/placement.js +76 -0
  177. package/es/index.js +777 -0
  178. package/es/pages/appointment-demo/drop-down-box/index.js +159 -0
  179. package/es/pages/appointment-demo/index.js +649 -0
  180. package/es/pages/appointment-demo/input/index.js +176 -0
  181. package/es/pages/appointment-demo/popup/index.js +113 -0
  182. package/es/pages/appointment-demo/popup/placement.js +44 -0
  183. package/es/pages/group-management/components/checkbox/index.js +28 -0
  184. package/es/pages/group-management/components/input-form/index.js +174 -0
  185. package/es/pages/group-management/components/radio/index.js +21 -0
  186. package/es/pages/group-management/components/table/index.js +174 -0
  187. package/es/pages/group-management/groupInterface.js +293 -0
  188. package/es/pages/group-management/index.js +13 -0
  189. package/es/pages/group-management/page-view/empty.js +111 -0
  190. package/es/pages/group-management/page-view/group-empty.js +66 -0
  191. package/es/pages/group-management/page-view/importGroupStaff/index.js +208 -0
  192. package/es/pages/group-management/page-view/index.js +412 -0
  193. package/es/pages/group-management/page-view/loading/index.js +32 -0
  194. package/es/pages/group-management/table/index.js +104 -0
  195. package/es/pages/group-management/tree/add-group-dialog/index.js +153 -0
  196. package/es/pages/group-management/tree/delete-group-dialog/index.js +82 -0
  197. package/es/pages/group-management/tree/edit-group-dialog/index.js +155 -0
  198. package/es/pages/group-management/tree/group-form/index.js +207 -0
  199. package/es/pages/group-management/tree/index.js +168 -0
  200. package/es/pages/group-management/tree/operation-panel.js +41 -0
  201. package/es/pages/group-management/tree/trigger-render.js +99 -0
  202. package/es/pages/like-ranking/mock.js +366 -0
  203. package/es/pages/okr-map/export-modules/index.js +1 -0
  204. package/es/pages/okr-map/export-modules/okr-map/header/index.js +182 -0
  205. package/es/pages/okr-map/export-modules/okr-map/header/show-kr-confirm.js +47 -0
  206. package/es/pages/okr-map/export-modules/okr-map/okr-map.js +497 -0
  207. package/es/pages/okr-map/export-modules/share-okr-page/header/index.js +69 -0
  208. package/es/pages/okr-map/export-modules/share-okr-page/share-okr-map.js +168 -0
  209. package/es/pages/okr-map/hooks/useStorage.js +96 -0
  210. package/es/pages/okr-map/index.js +18 -0
  211. package/es/pages/okr-map/level2-search/depart.js +53 -0
  212. package/es/pages/okr-map/level2-search/group.js +69 -0
  213. package/es/pages/okr-map/level2-search/index.js +51 -0
  214. package/es/pages/okr-map/level2-search/level2-input.js +46 -0
  215. package/es/pages/okr-map/level2-search/user.js +54 -0
  216. package/es/pages/okr-map/no-okr/index.js +24 -0
  217. package/es/pages/okr-map/number-select/index.js +81 -0
  218. package/es/pages/okr-map/open-data/index.js +115 -0
  219. package/es/pages/okr-map/precls.js +8 -0
  220. package/es/pages/okr-map/request-apis.js +76 -0
  221. package/es/pages/okr-map/share-dialog/index.js +122 -0
  222. package/es/pages/okr-map/unsupport-ie/index.js +83 -0
  223. package/es/pages/okr-map/utils.js +51 -0
  224. package/es/utils/auth.js +294 -0
  225. package/es/utils/bs-global.js +114 -0
  226. package/es/utils/local-storage.js +42 -0
  227. package/es/utils/mblog.js +33 -0
  228. package/es/utils/mock-bsglobal.js +1837 -0
  229. package/es/utils/open-data.js +341 -0
  230. package/es/utils/request-v1.js +115 -0
  231. package/es/utils/request.js +183 -0
  232. package/es/utils/tools.js +286 -0
  233. package/lib/components/date-picker/BodyItem.js +3 -3
  234. package/lib/components/date-picker/CalendarHeader.js +3 -3
  235. package/lib/components/delete-confirm-pop/ConfirmPop.js +3 -3
  236. package/lib/components/dynamic/constant.js +31 -31
  237. package/lib/components/dynamic/dynamic-item/dynamic-interview/img/wifi.svg +24 -0
  238. package/lib/components/dynamic/dynamic-item/dynamic-interview/index.css +36 -0
  239. package/lib/components/dynamic/dynamic-item/dynamic-interview/index.js +51 -0
  240. package/lib/components/dynamic/dynamic-item/dynamic-interview/interview-content.js +53 -0
  241. package/lib/components/dynamic/dynamic-item/index.js +40 -32
  242. package/lib/components/eReport/eReportLists/reportList.js +3 -3
  243. package/lib/components/emotions-selector/selector-pop.js +3 -3
  244. package/lib/components/ereport-list/index.js +3 -3
  245. package/lib/components/form/form-fields/date/index.css +24 -0
  246. package/lib/components/form/form-fields/date/index.js +98 -0
  247. package/lib/components/form/form-fields/user/index.css +1 -1
  248. package/lib/components/form/index.js +10 -3
  249. package/lib/components/mblog/components/MblogAction.js +3 -3
  250. package/lib/components/menus/export-modules/interview-menus/constant.js +23 -17
  251. package/lib/components/menus/export-modules/interview-menus/handle-highlight.js +5 -5
  252. package/lib/components/menus/export-modules/interview-menus/index.js +1 -2
  253. package/lib/components/okr-detail/components/okr-tree/tree-node/kr-node/kr-score-editor/edit-pop.js +3 -3
  254. package/lib/components/okr-review/components/ReviewItem/index.js +3 -3
  255. package/lib/components/okr-review/components/confirm-pop/ConfirmPop.js +3 -3
  256. package/lib/components/picker/components/picker-trigger/index.css +16 -0
  257. package/lib/components/picker/components/picker-trigger/index.js +18 -9
  258. package/lib/components/picker/picker-panels.js +1 -1
  259. package/lib/components/picker/picker.js +12 -13
  260. package/lib/components/range-selector-pop/RangeSelectorPop.js +3 -3
  261. package/lib/components/rich-editor/models/schema.js +6 -6
  262. package/lib/components/rich-editor/plugins/block/block-quote/index.js +8 -8
  263. package/lib/components/rich-editor/plugins/block/heading/index.js +8 -8
  264. package/lib/components/rich-editor/plugins/block/lists/index.js +14 -14
  265. package/lib/components/rich-editor/plugins/block/paragraph/index.js +5 -5
  266. package/lib/components/rich-editor/plugins/core/index.js +4 -4
  267. package/lib/components/rich-editor/plugins/extension/alignment/index.js +5 -5
  268. package/lib/components/rich-editor/plugins/extension/placeholder/index.js +4 -4
  269. package/lib/components/rich-editor/plugins/inline/color/index.js +11 -11
  270. package/lib/components/rich-editor/plugins/inline/delete-line/index.js +8 -8
  271. package/lib/components/rich-editor/plugins/inline/em/index.js +5 -5
  272. package/lib/components/rich-editor/plugins/inline/link/index.js +8 -8
  273. package/lib/components/rich-editor/plugins/inline/strong/index.js +8 -8
  274. package/lib/components/rich-editor/plugins/inline/under-line/index.js +8 -8
  275. package/lib/components/rich-editor/react/uiProvider.js +3 -3
  276. package/lib/components/rich-editor/ui/Popup/index.js +3 -3
  277. package/lib/components/select/Option.js +3 -3
  278. package/lib/components/time-picker/index.css +18 -0
  279. package/lib/components/time-picker/time-picker-selector.js +8 -12
  280. package/lib/components/time-picker/time-picker.js +117 -100
  281. package/lib/components/time-picker/utils.js +13 -2
  282. package/lib/components/tita-chart/errorBoundary/index.js +3 -3
  283. package/lib/components-v1/animate/AnimateChild.js +3 -3
  284. package/lib/components-v1/avatar/index.js +3 -3
  285. package/lib/components-v1/dropDownSelector/StatelessDropdown.js +3 -3
  286. package/lib/components-v1/progress/CircleProgress.js +3 -3
  287. package/lib/components-v1/select/Option.js +3 -3
  288. package/lib/components-v1/userSelector/UserSelectorPop.js +3 -3
  289. package/lib/components-v1/userSelector/components/MultiMode/index.js +3 -3
  290. package/lib/components-v1/userSelector/components/UserItem.js +3 -3
  291. package/package.json +1 -1
  292. package/yarn-error.log +5424 -6356
@@ -0,0 +1,852 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _lodash = _interopRequireDefault(require("lodash.throttle"));
9
+
10
+ var _lodash2 = _interopRequireDefault(require("lodash.debounce"));
11
+
12
+ var _lodash3 = _interopRequireDefault(require("lodash.memoize"));
13
+
14
+ var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
15
+
16
+ var _canUseDom = _interopRequireDefault(require("can-use-dom"));
17
+
18
+ var _scrollbarWidth = _interopRequireDefault(require("./scrollbar-width"));
19
+
20
+ var _helpers = require("./helpers");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
+
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
+
28
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
+
30
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
+
32
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
33
+
34
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
35
+
36
+ var SimpleBar = /*#__PURE__*/function () {
37
+ function SimpleBar(element, options) {
38
+ var _this = this;
39
+
40
+ _classCallCheck(this, SimpleBar);
41
+
42
+ this.onScroll = function () {
43
+ var elWindow = (0, _helpers.getElementWindow)(_this.el);
44
+
45
+ if (!_this.scrollXTicking) {
46
+ elWindow.requestAnimationFrame(_this.scrollX);
47
+ _this.scrollXTicking = true;
48
+ }
49
+
50
+ if (!_this.scrollYTicking) {
51
+ elWindow.requestAnimationFrame(_this.scrollY);
52
+ _this.scrollYTicking = true;
53
+ }
54
+ };
55
+
56
+ this.scrollX = function () {
57
+ if (_this.axis.x.isOverflowing) {
58
+ _this.showScrollbar("x");
59
+
60
+ _this.positionScrollbar("x");
61
+ }
62
+
63
+ _this.scrollXTicking = false;
64
+ };
65
+
66
+ this.scrollY = function () {
67
+ if (_this.axis.y.isOverflowing) {
68
+ _this.showScrollbar("y");
69
+
70
+ _this.positionScrollbar("y");
71
+ }
72
+
73
+ _this.scrollYTicking = false;
74
+ };
75
+
76
+ this.onMouseEnter = function () {
77
+ _this.showScrollbar("x");
78
+
79
+ _this.showScrollbar("y");
80
+ };
81
+
82
+ this.onMouseMove = function (e) {
83
+ _this.mouseX = e.clientX;
84
+ _this.mouseY = e.clientY;
85
+
86
+ if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
87
+ _this.onMouseMoveForAxis("x");
88
+ }
89
+
90
+ if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
91
+ _this.onMouseMoveForAxis("y");
92
+ }
93
+ };
94
+
95
+ this.onMouseLeave = function () {
96
+ _this.onMouseMove.cancel();
97
+
98
+ if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
99
+ _this.onMouseLeaveForAxis("x");
100
+ }
101
+
102
+ if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
103
+ _this.onMouseLeaveForAxis("y");
104
+ }
105
+
106
+ _this.mouseX = -1;
107
+ _this.mouseY = -1;
108
+ };
109
+
110
+ this.onWindowResize = function () {
111
+ // Recalculate scrollbarWidth in case it's a zoom
112
+ _this.scrollbarWidth = _this.getScrollbarWidth();
113
+
114
+ _this.hideNativeScrollbar();
115
+ };
116
+
117
+ this.hideScrollbars = function () {
118
+ _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
119
+ _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
120
+
121
+ if (!_this.isWithinBounds(_this.axis.y.track.rect)) {
122
+ _this.axis.y.scrollbar.el.classList.remove(_this.classNames.visible);
123
+
124
+ _this.axis.y.isVisible = false;
125
+ }
126
+
127
+ if (!_this.isWithinBounds(_this.axis.x.track.rect)) {
128
+ _this.axis.x.scrollbar.el.classList.remove(_this.classNames.visible);
129
+
130
+ _this.axis.x.isVisible = false;
131
+ }
132
+ };
133
+
134
+ this.onPointerEvent = function (e) {
135
+ var isWithinTrackXBounds;
136
+ var isWithinTrackYBounds;
137
+ _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
138
+ _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
139
+
140
+ if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
141
+ isWithinTrackXBounds = _this.isWithinBounds(_this.axis.x.track.rect);
142
+ }
143
+
144
+ if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
145
+ isWithinTrackYBounds = _this.isWithinBounds(_this.axis.y.track.rect);
146
+ } // If any pointer event is called on the scrollbar
147
+
148
+
149
+ if (isWithinTrackXBounds || isWithinTrackYBounds) {
150
+ // Preventing the event's default action stops text being
151
+ // selectable during the drag.
152
+ e.preventDefault(); // Prevent event leaking
153
+
154
+ e.stopPropagation();
155
+
156
+ if (e.type === "mousedown") {
157
+ if (isWithinTrackXBounds) {
158
+ _this.axis.x.scrollbar.rect = _this.axis.x.scrollbar.el.getBoundingClientRect();
159
+
160
+ if (_this.isWithinBounds(_this.axis.x.scrollbar.rect)) {
161
+ _this.onDragStart(e, "x");
162
+ } else {
163
+ _this.onTrackClick(e, "x");
164
+ }
165
+ }
166
+
167
+ if (isWithinTrackYBounds) {
168
+ _this.axis.y.scrollbar.rect = _this.axis.y.scrollbar.el.getBoundingClientRect();
169
+
170
+ if (_this.isWithinBounds(_this.axis.y.scrollbar.rect)) {
171
+ _this.onDragStart(e, "y");
172
+ } else {
173
+ _this.onTrackClick(e, "y");
174
+ }
175
+ }
176
+ }
177
+ }
178
+ };
179
+
180
+ this.drag = function (e) {
181
+ var eventOffset;
182
+ var track = _this.axis[_this.draggedAxis].track;
183
+ var trackSize = track.rect[_this.axis[_this.draggedAxis].sizeAttr];
184
+ var scrollbar = _this.axis[_this.draggedAxis].scrollbar;
185
+ var contentSize = _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollSizeAttr];
186
+ var hostSize = parseInt(_this.elStyles[_this.axis[_this.draggedAxis].sizeAttr], 10);
187
+ e.preventDefault();
188
+ e.stopPropagation();
189
+
190
+ if (_this.draggedAxis === "y") {
191
+ eventOffset = e.pageY;
192
+ } else {
193
+ eventOffset = e.pageX;
194
+ } // Calculate how far the user's mouse is from the top/left of the scrollbar (minus the dragOffset).
195
+
196
+
197
+ var dragPos = eventOffset - track.rect[_this.axis[_this.draggedAxis].offsetAttr] - _this.axis[_this.draggedAxis].dragOffset; // Convert the mouse position into a percentage of the scrollbar height/width.
198
+
199
+ var dragPerc = dragPos / (trackSize - scrollbar.size); // Scroll the content by the same percentage.
200
+
201
+ var scrollPos = dragPerc * (contentSize - hostSize); // Fix browsers inconsistency on RTL
202
+
203
+ if (_this.draggedAxis === "x") {
204
+ scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
205
+ scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
206
+ }
207
+
208
+ _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollOffsetAttr] = scrollPos;
209
+ };
210
+
211
+ this.onEndDrag = function (e) {
212
+ var elDocument = (0, _helpers.getElementDocument)(_this.el);
213
+ var elWindow = (0, _helpers.getElementWindow)(_this.el);
214
+ e.preventDefault();
215
+ e.stopPropagation();
216
+
217
+ _this.el.classList.remove(_this.classNames.dragging);
218
+
219
+ elDocument.removeEventListener("mousemove", _this.drag, true);
220
+ elDocument.removeEventListener("mouseup", _this.onEndDrag, true);
221
+ _this.removePreventClickId = elWindow.setTimeout(function () {
222
+ // Remove these asynchronously so we still suppress click events
223
+ // generated simultaneously with mouseup.
224
+ elDocument.removeEventListener("click", _this.preventClick, true);
225
+ elDocument.removeEventListener("dblclick", _this.preventClick, true);
226
+ _this.removePreventClickId = null;
227
+ });
228
+ };
229
+
230
+ this.preventClick = function (e) {
231
+ e.preventDefault();
232
+ e.stopPropagation();
233
+ };
234
+
235
+ this.el = element;
236
+ this.minScrollbarWidth = 20;
237
+ this.options = _objectSpread(_objectSpread({}, SimpleBar.defaultOptions), options);
238
+ this.classNames = _objectSpread(_objectSpread({}, SimpleBar.defaultOptions.classNames), this.options.classNames);
239
+ this.axis = {
240
+ x: {
241
+ scrollOffsetAttr: "scrollLeft",
242
+ sizeAttr: "width",
243
+ scrollSizeAttr: "scrollWidth",
244
+ offsetSizeAttr: "offsetWidth",
245
+ offsetAttr: "left",
246
+ overflowAttr: "overflowX",
247
+ dragOffset: 0,
248
+ isOverflowing: true,
249
+ isVisible: false,
250
+ forceVisible: false,
251
+ track: {},
252
+ scrollbar: {}
253
+ },
254
+ y: {
255
+ scrollOffsetAttr: "scrollTop",
256
+ sizeAttr: "height",
257
+ scrollSizeAttr: "scrollHeight",
258
+ offsetSizeAttr: "offsetHeight",
259
+ offsetAttr: "top",
260
+ overflowAttr: "overflowY",
261
+ dragOffset: 0,
262
+ isOverflowing: true,
263
+ isVisible: false,
264
+ forceVisible: false,
265
+ track: {},
266
+ scrollbar: {}
267
+ }
268
+ };
269
+ this.removePreventClickId = null; // Don't re-instantiate over an existing one
270
+
271
+ if (SimpleBar.instances.has(this.el)) {
272
+ return;
273
+ } // Tita TODO: 修改 64 到 1,解决卡顿问题
274
+
275
+
276
+ this.recalculate = (0, _lodash["default"])(this.recalculate.bind(this), 1);
277
+ this.onMouseMove = (0, _lodash["default"])(this.onMouseMove.bind(this), 64);
278
+ this.hideScrollbars = (0, _lodash2["default"])(this.hideScrollbars.bind(this), this.options.timeout);
279
+ this.onWindowResize = (0, _lodash2["default"])(this.onWindowResize.bind(this), 64, {
280
+ leading: true
281
+ });
282
+ SimpleBar.getRtlHelpers = (0, _lodash3["default"])(SimpleBar.getRtlHelpers);
283
+ this.init();
284
+ }
285
+ /**
286
+ * Static properties
287
+ */
288
+
289
+ /**
290
+ * Helper to fix browsers inconsistency on RTL:
291
+ * - Firefox inverts the scrollbar initial position
292
+ * - IE11 inverts both scrollbar position and scrolling offset
293
+ * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
294
+ */
295
+
296
+
297
+ _createClass(SimpleBar, [{
298
+ key: "init",
299
+ value: function init() {
300
+ // Save a reference to the instance, so we know this DOM node has already been instancied
301
+ SimpleBar.instances.set(this.el, this); // We stop here on server-side
302
+
303
+ if (_canUseDom["default"]) {
304
+ this.initDOM();
305
+ this.setAccessibilityAttributes();
306
+ this.scrollbarWidth = this.getScrollbarWidth();
307
+ this.recalculate();
308
+ this.initListeners();
309
+ }
310
+ }
311
+ }, {
312
+ key: "initDOM",
313
+ value: function initDOM() {
314
+ var _this2 = this;
315
+
316
+ // make sure this element doesn't have the elements yet
317
+ if (Array.prototype.filter.call(this.el.children, function (child) {
318
+ return child.classList.contains(_this2.classNames.wrapper);
319
+ }).length) {
320
+ // assume that element has his DOM already initiated
321
+ this.wrapperEl = this.el.querySelector(".".concat(this.classNames.wrapper));
322
+ this.contentWrapperEl = this.options.scrollableNode || this.el.querySelector(".".concat(this.classNames.contentWrapper));
323
+ this.contentEl = this.options.contentNode || this.el.querySelector(".".concat(this.classNames.contentEl));
324
+ this.offsetEl = this.el.querySelector(".".concat(this.classNames.offset));
325
+ this.maskEl = this.el.querySelector(".".concat(this.classNames.mask));
326
+ this.placeholderEl = this.findChild(this.wrapperEl, ".".concat(this.classNames.placeholder));
327
+ this.heightAutoObserverWrapperEl = this.el.querySelector(".".concat(this.classNames.heightAutoObserverWrapperEl));
328
+ this.heightAutoObserverEl = this.el.querySelector(".".concat(this.classNames.heightAutoObserverEl));
329
+ this.axis.x.track.el = this.findChild(this.el, ".".concat(this.classNames.track, ".").concat(this.classNames.horizontal));
330
+ this.axis.y.track.el = this.findChild(this.el, ".".concat(this.classNames.track, ".").concat(this.classNames.vertical));
331
+ } else {
332
+ // Prepare DOM
333
+ this.wrapperEl = document.createElement("div");
334
+ this.contentWrapperEl = document.createElement("div");
335
+ this.offsetEl = document.createElement("div");
336
+ this.maskEl = document.createElement("div");
337
+ this.contentEl = document.createElement("div");
338
+ this.placeholderEl = document.createElement("div");
339
+ this.heightAutoObserverWrapperEl = document.createElement("div");
340
+ this.heightAutoObserverEl = document.createElement("div");
341
+ this.wrapperEl.classList.add(this.classNames.wrapper);
342
+ this.contentWrapperEl.classList.add(this.classNames.contentWrapper);
343
+ this.offsetEl.classList.add(this.classNames.offset);
344
+ this.maskEl.classList.add(this.classNames.mask);
345
+ this.contentEl.classList.add(this.classNames.contentEl);
346
+ this.placeholderEl.classList.add(this.classNames.placeholder);
347
+ this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl);
348
+ this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);
349
+
350
+ while (this.el.firstChild) {
351
+ this.contentEl.appendChild(this.el.firstChild);
352
+ }
353
+
354
+ this.contentWrapperEl.appendChild(this.contentEl);
355
+ this.offsetEl.appendChild(this.contentWrapperEl);
356
+ this.maskEl.appendChild(this.offsetEl);
357
+ this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl);
358
+ this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl);
359
+ this.wrapperEl.appendChild(this.maskEl);
360
+ this.wrapperEl.appendChild(this.placeholderEl);
361
+ this.el.appendChild(this.wrapperEl);
362
+ }
363
+
364
+ if (!this.axis.x.track.el || !this.axis.y.track.el) {
365
+ var track = document.createElement("div");
366
+ var scrollbar = document.createElement("div");
367
+ track.classList.add(this.classNames.track);
368
+ scrollbar.classList.add(this.classNames.scrollbar);
369
+ track.appendChild(scrollbar);
370
+ this.axis.x.track.el = track.cloneNode(true);
371
+ this.axis.x.track.el.classList.add(this.classNames.horizontal);
372
+ this.axis.y.track.el = track.cloneNode(true);
373
+ this.axis.y.track.el.classList.add(this.classNames.vertical);
374
+ this.el.appendChild(this.axis.x.track.el);
375
+ this.el.appendChild(this.axis.y.track.el);
376
+ }
377
+
378
+ this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector(".".concat(this.classNames.scrollbar));
379
+ this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector(".".concat(this.classNames.scrollbar));
380
+
381
+ if (!this.options.autoHide) {
382
+ this.axis.x.scrollbar.el.classList.add(this.classNames.visible);
383
+ this.axis.y.scrollbar.el.classList.add(this.classNames.visible);
384
+ }
385
+
386
+ this.el.setAttribute("data-simplebar", "init");
387
+ }
388
+ }, {
389
+ key: "setAccessibilityAttributes",
390
+ value: function setAccessibilityAttributes() {
391
+ var ariaLabel = this.options.ariaLabel || "scrollable content";
392
+ this.contentWrapperEl.setAttribute("tabindex", "0");
393
+ this.contentWrapperEl.setAttribute("role", "region");
394
+ this.contentWrapperEl.setAttribute("aria-label", ariaLabel);
395
+ }
396
+ }, {
397
+ key: "initListeners",
398
+ value: function initListeners() {
399
+ var _this3 = this;
400
+
401
+ var elWindow = (0, _helpers.getElementWindow)(this.el); // Event listeners
402
+
403
+ if (this.options.autoHide) {
404
+ this.el.addEventListener("mouseenter", this.onMouseEnter);
405
+ }
406
+
407
+ ["mousedown", "click", "dblclick"].forEach(function (e) {
408
+ _this3.el.addEventListener(e, _this3.onPointerEvent, true);
409
+ });
410
+ ["touchstart", "touchend", "touchmove"].forEach(function (e) {
411
+ _this3.el.addEventListener(e, _this3.onPointerEvent, {
412
+ capture: true,
413
+ passive: true
414
+ });
415
+ });
416
+ this.el.addEventListener("mousemove", this.onMouseMove);
417
+ this.el.addEventListener("mouseleave", this.onMouseLeave);
418
+ this.contentWrapperEl.addEventListener("scroll", this.onScroll); // Browser zoom triggers a window resize
419
+
420
+ elWindow.addEventListener("resize", this.onWindowResize); // Hack for https://github.com/WICG/ResizeObserver/issues/38
421
+
422
+ var resizeObserverStarted = false;
423
+ var resizeObserver = elWindow.ResizeObserver || _resizeObserverPolyfill["default"];
424
+ this.resizeObserver = new resizeObserver(function () {
425
+ if (!resizeObserverStarted) return;
426
+
427
+ _this3.recalculate();
428
+ });
429
+ this.resizeObserver.observe(this.el);
430
+ this.resizeObserver.observe(this.contentEl);
431
+ elWindow.requestAnimationFrame(function () {
432
+ resizeObserverStarted = true;
433
+ }); // This is required to detect horizontal scroll. Vertical scroll only needs the resizeObserver.
434
+
435
+ this.mutationObserver = new elWindow.MutationObserver(this.recalculate);
436
+ this.mutationObserver.observe(this.contentEl, {
437
+ childList: true,
438
+ subtree: true,
439
+ characterData: true
440
+ });
441
+ }
442
+ }, {
443
+ key: "recalculate",
444
+ value: function recalculate() {
445
+ var elWindow = (0, _helpers.getElementWindow)(this.el);
446
+ this.elStyles = elWindow.getComputedStyle(this.el);
447
+ this.isRtl = this.elStyles.direction === "rtl";
448
+ var isHeightAuto = this.heightAutoObserverEl.offsetHeight <= 1;
449
+ var isWidthAuto = this.heightAutoObserverEl.offsetWidth <= 1;
450
+ var contentElOffsetWidth = this.contentEl.offsetWidth;
451
+ var contentWrapperElOffsetWidth = this.contentWrapperEl.offsetWidth;
452
+ var elOverflowX = this.elStyles.overflowX;
453
+ var elOverflowY = this.elStyles.overflowY;
454
+ this.contentEl.style.padding = "".concat(this.elStyles.paddingTop, " ").concat(this.elStyles.paddingRight, " ").concat(this.elStyles.paddingBottom, " ").concat(this.elStyles.paddingLeft);
455
+ this.wrapperEl.style.margin = "-".concat(this.elStyles.paddingTop, " -").concat(this.elStyles.paddingRight, " -").concat(this.elStyles.paddingBottom, " -").concat(this.elStyles.paddingLeft);
456
+ var contentElScrollHeight = this.contentEl.scrollHeight;
457
+ var contentElScrollWidth = this.contentEl.scrollWidth;
458
+ this.contentWrapperEl.style.height = isHeightAuto ? "auto" : "100%"; // Determine placeholder size
459
+
460
+ this.placeholderEl.style.width = isWidthAuto ? "".concat(contentElOffsetWidth, "px") : "auto";
461
+ this.placeholderEl.style.height = "".concat(contentElScrollHeight, "px");
462
+ var contentWrapperElOffsetHeight = this.contentWrapperEl.offsetHeight;
463
+ this.axis.x.isOverflowing = contentElScrollWidth > contentElOffsetWidth;
464
+ this.axis.y.isOverflowing = contentElScrollHeight > contentWrapperElOffsetHeight; // Set isOverflowing to false if user explicitely set hidden overflow
465
+
466
+ this.axis.x.isOverflowing = elOverflowX === "hidden" ? false : this.axis.x.isOverflowing;
467
+ this.axis.y.isOverflowing = elOverflowY === "hidden" ? false : this.axis.y.isOverflowing;
468
+ this.axis.x.forceVisible = this.options.forceVisible === "x" || this.options.forceVisible === true;
469
+ this.axis.y.forceVisible = this.options.forceVisible === "y" || this.options.forceVisible === true;
470
+ this.hideNativeScrollbar(); // Set isOverflowing to false if scrollbar is not necessary (content is shorter than offset)
471
+
472
+ var offsetForXScrollbar = this.axis.x.isOverflowing ? this.scrollbarWidth : 0;
473
+ var offsetForYScrollbar = this.axis.y.isOverflowing ? this.scrollbarWidth : 0;
474
+ this.axis.x.isOverflowing = this.axis.x.isOverflowing && contentElScrollWidth > contentWrapperElOffsetWidth - offsetForYScrollbar;
475
+ this.axis.y.isOverflowing = this.axis.y.isOverflowing && contentElScrollHeight > contentWrapperElOffsetHeight - offsetForXScrollbar;
476
+ this.axis.x.scrollbar.size = this.getScrollbarSize("x");
477
+ this.axis.y.scrollbar.size = this.getScrollbarSize("y");
478
+ this.axis.x.scrollbar.el.style.width = "".concat(this.axis.x.scrollbar.size, "px");
479
+ this.axis.y.scrollbar.el.style.height = "".concat(this.axis.y.scrollbar.size, "px");
480
+ this.positionScrollbar("x");
481
+ this.positionScrollbar("y");
482
+ this.toggleTrackVisibility("x");
483
+ this.toggleTrackVisibility("y");
484
+ }
485
+ /**
486
+ * Calculate scrollbar size
487
+ */
488
+
489
+ }, {
490
+ key: "getScrollbarSize",
491
+ value: function getScrollbarSize() {
492
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
493
+
494
+ if (!this.axis[axis].isOverflowing) {
495
+ return 0;
496
+ }
497
+
498
+ var contentSize = this.contentEl[this.axis[axis].scrollSizeAttr];
499
+ var trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
500
+ var scrollbarSize;
501
+ var scrollbarRatio = trackSize / contentSize; // Calculate new height/position of drag handle.
502
+
503
+ scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
504
+
505
+ if (this.options.scrollbarMaxSize) {
506
+ scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
507
+ }
508
+
509
+ return scrollbarSize;
510
+ }
511
+ }, {
512
+ key: "positionScrollbar",
513
+ value: function positionScrollbar() {
514
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
515
+
516
+ if (!this.axis[axis].isOverflowing) {
517
+ return;
518
+ }
519
+
520
+ var contentSize = this.contentWrapperEl[this.axis[axis].scrollSizeAttr];
521
+ var trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
522
+ var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
523
+ var scrollbar = this.axis[axis].scrollbar;
524
+ var scrollOffset = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
525
+ scrollOffset = axis === "x" && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
526
+ var scrollPourcent = scrollOffset / (contentSize - hostSize);
527
+ var handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
528
+ handleOffset = axis === "x" && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
529
+ scrollbar.el.style.transform = axis === "x" ? "translate3d(".concat(handleOffset, "px, 0, 0)") : "translate3d(0, ".concat(handleOffset, "px, 0)");
530
+ }
531
+ }, {
532
+ key: "toggleTrackVisibility",
533
+ value: function toggleTrackVisibility() {
534
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
535
+ var track = this.axis[axis].track.el;
536
+ var scrollbar = this.axis[axis].scrollbar.el;
537
+
538
+ if (this.axis[axis].isOverflowing || this.axis[axis].forceVisible) {
539
+ track.style.visibility = "visible";
540
+ this.contentWrapperEl.style[this.axis[axis].overflowAttr] = "scroll";
541
+ } else {
542
+ track.style.visibility = "hidden";
543
+ this.contentWrapperEl.style[this.axis[axis].overflowAttr] = "hidden";
544
+ } // Even if forceVisible is enabled, scrollbar itself should be hidden
545
+
546
+
547
+ if (this.axis[axis].isOverflowing) {
548
+ scrollbar.style.display = "block";
549
+ } else {
550
+ scrollbar.style.display = "none";
551
+ }
552
+ }
553
+ }, {
554
+ key: "hideNativeScrollbar",
555
+ value: function hideNativeScrollbar() {
556
+ this.offsetEl.style[this.isRtl ? "left" : "right"] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? "-".concat(this.scrollbarWidth, "px") : 0;
557
+ this.offsetEl.style.bottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? "-".concat(this.scrollbarWidth, "px") : 0;
558
+ }
559
+ /**
560
+ * On scroll event handling
561
+ */
562
+
563
+ }, {
564
+ key: "onMouseMoveForAxis",
565
+ value: function onMouseMoveForAxis() {
566
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
567
+ this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
568
+ this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
569
+ var isWithinScrollbarBoundsX = this.isWithinBounds(this.axis[axis].scrollbar.rect);
570
+
571
+ if (isWithinScrollbarBoundsX) {
572
+ this.axis[axis].scrollbar.el.classList.add(this.classNames.hover);
573
+ } else {
574
+ this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
575
+ }
576
+
577
+ if (this.isWithinBounds(this.axis[axis].track.rect)) {
578
+ this.showScrollbar(axis);
579
+ this.axis[axis].track.el.classList.add(this.classNames.hover);
580
+ } else {
581
+ this.axis[axis].track.el.classList.remove(this.classNames.hover);
582
+ }
583
+ }
584
+ }, {
585
+ key: "onMouseLeaveForAxis",
586
+ value: function onMouseLeaveForAxis() {
587
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
588
+ this.axis[axis].track.el.classList.remove(this.classNames.hover);
589
+ this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
590
+ }
591
+ }, {
592
+ key: "showScrollbar",
593
+ value:
594
+ /**
595
+ * Show scrollbar
596
+ */
597
+ function showScrollbar() {
598
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
599
+ var scrollbar = this.axis[axis].scrollbar.el;
600
+
601
+ if (!this.axis[axis].isVisible) {
602
+ scrollbar.classList.add(this.classNames.visible);
603
+ this.axis[axis].isVisible = true;
604
+ }
605
+
606
+ if (this.options.autoHide) {
607
+ this.hideScrollbars();
608
+ }
609
+ }
610
+ /**
611
+ * Hide Scrollbar
612
+ */
613
+
614
+ }, {
615
+ key: "onDragStart",
616
+ value:
617
+ /**
618
+ * on scrollbar handle drag movement starts
619
+ */
620
+ function onDragStart(e) {
621
+ var axis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "y";
622
+ var elDocument = (0, _helpers.getElementDocument)(this.el);
623
+ var elWindow = (0, _helpers.getElementWindow)(this.el);
624
+ var scrollbar = this.axis[axis].scrollbar; // Measure how far the user's mouse is from the top of the scrollbar drag handle.
625
+
626
+ var eventOffset = axis === "y" ? e.pageY : e.pageX;
627
+ this.axis[axis].dragOffset = eventOffset - scrollbar.rect[this.axis[axis].offsetAttr];
628
+ this.draggedAxis = axis;
629
+ this.el.classList.add(this.classNames.dragging);
630
+ elDocument.addEventListener("mousemove", this.drag, true);
631
+ elDocument.addEventListener("mouseup", this.onEndDrag, true);
632
+
633
+ if (this.removePreventClickId === null) {
634
+ elDocument.addEventListener("click", this.preventClick, true);
635
+ elDocument.addEventListener("dblclick", this.preventClick, true);
636
+ } else {
637
+ elWindow.clearTimeout(this.removePreventClickId);
638
+ this.removePreventClickId = null;
639
+ }
640
+ }
641
+ /**
642
+ * Drag scrollbar handle
643
+ */
644
+
645
+ }, {
646
+ key: "onTrackClick",
647
+ value: function onTrackClick(e) {
648
+ var _this4 = this;
649
+
650
+ var axis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "y";
651
+ if (!this.options.clickOnTrack) return;
652
+ var elWindow = (0, _helpers.getElementWindow)(this.el);
653
+ this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
654
+ var scrollbar = this.axis[axis].scrollbar;
655
+ var scrollbarOffset = scrollbar.rect[this.axis[axis].offsetAttr];
656
+ var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
657
+ var scrolled = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
658
+ var t = axis === "y" ? this.mouseY - scrollbarOffset : this.mouseX - scrollbarOffset;
659
+ var dir = t < 0 ? -1 : 1;
660
+ var scrollSize = dir === -1 ? scrolled - hostSize : scrolled + hostSize;
661
+
662
+ var scrollTo = function scrollTo() {
663
+ if (dir === -1) {
664
+ if (scrolled > scrollSize) {
665
+ scrolled -= _this4.options.clickOnTrackSpeed;
666
+
667
+ _this4.contentWrapperEl.scrollTo(_defineProperty({}, _this4.axis[axis].offsetAttr, scrolled));
668
+
669
+ elWindow.requestAnimationFrame(scrollTo);
670
+ }
671
+ } else if (scrolled < scrollSize) {
672
+ scrolled += _this4.options.clickOnTrackSpeed;
673
+
674
+ _this4.contentWrapperEl.scrollTo(_defineProperty({}, _this4.axis[axis].offsetAttr, scrolled));
675
+
676
+ elWindow.requestAnimationFrame(scrollTo);
677
+ }
678
+ };
679
+
680
+ scrollTo();
681
+ }
682
+ /**
683
+ * Getter for content element
684
+ */
685
+
686
+ }, {
687
+ key: "getContentElement",
688
+ value: function getContentElement() {
689
+ return this.contentEl;
690
+ }
691
+ /**
692
+ * Getter for original scrolling element
693
+ */
694
+
695
+ }, {
696
+ key: "getScrollElement",
697
+ value: function getScrollElement() {
698
+ return this.contentWrapperEl;
699
+ }
700
+ }, {
701
+ key: "getScrollbarWidth",
702
+ value: function getScrollbarWidth() {
703
+ // Try/catch for FF 56 throwing on undefined computedStyles
704
+ try {
705
+ // Detect browsers supporting CSS scrollbar styling and do not calculate
706
+ if (getComputedStyle(this.contentWrapperEl, "::-webkit-scrollbar").display === "none" || "scrollbarWidth" in document.documentElement.style || "-ms-overflow-style" in document.documentElement.style) {
707
+ return 0;
708
+ }
709
+
710
+ return (0, _scrollbarWidth["default"])(this.el);
711
+ } catch (e) {
712
+ return (0, _scrollbarWidth["default"])(this.el);
713
+ }
714
+ }
715
+ }, {
716
+ key: "removeListeners",
717
+ value: function removeListeners() {
718
+ var _this5 = this;
719
+
720
+ var elWindow = (0, _helpers.getElementWindow)(this.el); // Event listeners
721
+
722
+ if (this.options.autoHide) {
723
+ this.el.removeEventListener("mouseenter", this.onMouseEnter);
724
+ }
725
+
726
+ ["mousedown", "click", "dblclick"].forEach(function (e) {
727
+ _this5.el.removeEventListener(e, _this5.onPointerEvent, true);
728
+ });
729
+ ["touchstart", "touchend", "touchmove"].forEach(function (e) {
730
+ _this5.el.removeEventListener(e, _this5.onPointerEvent, {
731
+ capture: true,
732
+ passive: true
733
+ });
734
+ });
735
+ this.el.removeEventListener("mousemove", this.onMouseMove);
736
+ this.el.removeEventListener("mouseleave", this.onMouseLeave);
737
+
738
+ if (this.contentWrapperEl) {
739
+ this.contentWrapperEl.removeEventListener("scroll", this.onScroll);
740
+ }
741
+
742
+ elWindow.removeEventListener("resize", this.onWindowResize);
743
+
744
+ if (this.mutationObserver) {
745
+ this.mutationObserver.disconnect();
746
+ }
747
+
748
+ if (this.resizeObserver) {
749
+ this.resizeObserver.disconnect();
750
+ } // Cancel all debounced functions
751
+
752
+
753
+ this.recalculate.cancel();
754
+ this.onMouseMove.cancel();
755
+ this.hideScrollbars.cancel();
756
+ this.onWindowResize.cancel();
757
+ }
758
+ /**
759
+ * UnMount mutation observer and delete SimpleBar instance from DOM element
760
+ */
761
+
762
+ }, {
763
+ key: "unMount",
764
+ value: function unMount() {
765
+ this.removeListeners();
766
+ SimpleBar.instances["delete"](this.el);
767
+ }
768
+ /**
769
+ * Check if mouse is within bounds
770
+ */
771
+
772
+ }, {
773
+ key: "isWithinBounds",
774
+ value: function isWithinBounds(bbox) {
775
+ return this.mouseX >= bbox.left && this.mouseX <= bbox.left + bbox.width && this.mouseY >= bbox.top && this.mouseY <= bbox.top + bbox.height;
776
+ }
777
+ /**
778
+ * Find element children matches query
779
+ */
780
+
781
+ }, {
782
+ key: "findChild",
783
+ value: function findChild(el, query) {
784
+ var matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
785
+ return Array.prototype.filter.call(el.children, function (child) {
786
+ return matches.call(child, query);
787
+ })[0];
788
+ }
789
+ }], [{
790
+ key: "getRtlHelpers",
791
+ value: function getRtlHelpers() {
792
+ var dummyDiv = document.createElement("div");
793
+ dummyDiv.innerHTML = "<div class=\"hs-dummy-scrollbar-size\"><div style=\"height: 200%; width: 200%; margin: 10px 0;\"></div></div>";
794
+ var scrollbarDummyEl = dummyDiv.firstElementChild;
795
+ document.body.appendChild(scrollbarDummyEl);
796
+ var dummyContainerChild = scrollbarDummyEl.firstElementChild;
797
+ scrollbarDummyEl.scrollLeft = 0;
798
+ var dummyContainerOffset = SimpleBar.getOffset(scrollbarDummyEl);
799
+ var dummyContainerChildOffset = SimpleBar.getOffset(dummyContainerChild);
800
+ scrollbarDummyEl.scrollLeft = 999;
801
+ var dummyContainerScrollOffsetAfterScroll = SimpleBar.getOffset(dummyContainerChild);
802
+ return {
803
+ // determines if the scrolling is responding with negative values
804
+ isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
805
+ // determines if the origin scrollbar position is inverted or not (positioned on left or right)
806
+ isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
807
+ };
808
+ }
809
+ }, {
810
+ key: "getOffset",
811
+ value: function getOffset(el) {
812
+ var rect = el.getBoundingClientRect();
813
+ var elDocument = (0, _helpers.getElementDocument)(el);
814
+ var elWindow = (0, _helpers.getElementWindow)(el);
815
+ return {
816
+ top: rect.top + (elWindow.pageYOffset || elDocument.documentElement.scrollTop),
817
+ left: rect.left + (elWindow.pageXOffset || elDocument.documentElement.scrollLeft)
818
+ };
819
+ }
820
+ }]);
821
+
822
+ return SimpleBar;
823
+ }();
824
+
825
+ exports["default"] = SimpleBar;
826
+ SimpleBar.defaultOptions = {
827
+ autoHide: true,
828
+ forceVisible: false,
829
+ clickOnTrack: true,
830
+ clickOnTrackSpeed: 40,
831
+ classNames: {
832
+ contentEl: "simplebar-content",
833
+ contentWrapper: "simplebar-content-wrapper",
834
+ offset: "simplebar-offset",
835
+ mask: "simplebar-mask",
836
+ wrapper: "simplebar-wrapper",
837
+ placeholder: "simplebar-placeholder",
838
+ scrollbar: "simplebar-scrollbar",
839
+ track: "simplebar-track",
840
+ heightAutoObserverWrapperEl: "simplebar-height-auto-observer-wrapper",
841
+ heightAutoObserverEl: "simplebar-height-auto-observer",
842
+ visible: "simplebar-visible",
843
+ horizontal: "simplebar-horizontal",
844
+ vertical: "simplebar-vertical",
845
+ hover: "simplebar-hover",
846
+ dragging: "simplebar-dragging"
847
+ },
848
+ scrollbarMinSize: 25,
849
+ scrollbarMaxSize: 0,
850
+ timeout: 1000
851
+ };
852
+ SimpleBar.instances = new WeakMap();