@jetlinks-web/components 2.0.2 → 2.0.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 (237) hide show
  1. package/es/AMap/Map.js +124 -0
  2. package/es/AMap/index.js +2 -0
  3. package/es/AMap/util.js +56 -0
  4. package/es/BadgeStatus/Badge.js +54 -0
  5. package/es/BadgeStatus/color.js +21 -0
  6. package/es/BadgeStatus/index.js +3 -0
  7. package/es/CardSelect/CardSelect.js +123 -0
  8. package/es/CardSelect/index.js +2 -0
  9. package/es/CheckButton/CheckButton.js +121 -0
  10. package/es/CheckButton/index.js +2 -0
  11. package/es/ConfigProvider/context.js +12 -0
  12. package/es/ConfigProvider/index.js +31 -0
  13. package/es/Echarts/Echarts.js +47 -0
  14. package/es/Echarts/index.js +2 -0
  15. package/es/Ellipsis/Ellipsis.js +189 -0
  16. package/es/Ellipsis/index.js +2 -0
  17. package/es/Empty/Empty.js +56 -0
  18. package/es/Empty/image.js +2 -0
  19. package/es/Empty/index.js +2 -0
  20. package/es/FullPage/FullPage.js +31 -0
  21. package/es/FullPage/index.js +2 -0
  22. package/es/Icon/icon.js +42 -0
  23. package/{src/Icon/index.ts → es/Icon/index.js} +2 -3
  24. package/es/MonacoEditor/Monaco.js +238 -0
  25. package/es/MonacoEditor/index.js +2 -0
  26. package/es/PermissionButton/index.js +117 -0
  27. package/es/ProLayout/Basic/BasicLayout.js +259 -0
  28. package/es/ProLayout/Basic/Header.js +97 -0
  29. package/es/ProLayout/PageContainer/index.js +324 -0
  30. package/es/ProLayout/PageContainer/typings.js +1 -0
  31. package/es/ProLayout/RouteContext.js +22 -0
  32. package/es/ProLayout/SiderMenu/BaseMenu.js +285 -0
  33. package/es/ProLayout/SiderMenu/SiderMenu.js +278 -0
  34. package/es/ProLayout/SiderMenu/index.js +2 -0
  35. package/es/ProLayout/SiderMenu/typings.js +1 -0
  36. package/es/ProLayout/TopHeader/index.js +163 -0
  37. package/es/ProLayout/defaultSettings.js +66 -0
  38. package/{src/ProLayout/index.ts → es/ProLayout/index.js} +4 -6
  39. package/{src → es}/ProLayout/style/default.less +4 -4
  40. package/es/ProLayout/style/index.js +1 -0
  41. package/es/ProLayout/typings.js +1 -0
  42. package/es/ProLayout/util.js +61 -0
  43. package/es/ProTable/index.js +411 -0
  44. package/es/ProTable/proTableTypes.js +11 -0
  45. package/es/ProTable/style/index.css +65 -0
  46. package/es/ProTable/style/index.js +1 -0
  47. package/es/Scrollbar/Bar.js +114 -0
  48. package/es/Scrollbar/Scrollbar.js +212 -0
  49. package/es/Scrollbar/Thumb.js +189 -0
  50. package/es/Scrollbar/constants.js +1 -0
  51. package/es/Scrollbar/index.js +2 -0
  52. package/es/Scrollbar/scrollbarProps.js +100 -0
  53. package/es/Scrollbar/thumbProps.js +10 -0
  54. package/es/Scrollbar/util.js +30 -0
  55. package/es/Search/Advanced/History.js +183 -0
  56. package/es/Search/Advanced/SaveHistory.js +153 -0
  57. package/es/Search/Advanced/index.js +520 -0
  58. package/es/Search/Item.js +497 -0
  59. package/es/Search/Search.js +249 -0
  60. package/es/Search/hooks/index.js +1 -0
  61. package/es/Search/hooks/useSearchItems.js +40 -0
  62. package/es/Search/index.js +4 -0
  63. package/es/Search/setting.js +91 -0
  64. package/es/Search/style/Item.less +33 -0
  65. package/es/Search/style/Search.less +179 -0
  66. package/es/Search/style/index.js +2 -0
  67. package/es/Search/typing.js +1 -0
  68. package/es/Search/util.js +234 -0
  69. package/es/ValueItem/ValueItem.js +233 -0
  70. package/es/ValueItem/index.js +2 -0
  71. package/es/ValueItem/util.js +16 -0
  72. package/es/index.js +24 -0
  73. package/es/style/index.js +3 -0
  74. package/es/style/variable.css +0 -0
  75. package/{src → es}/style/variable.less +0 -2
  76. package/es/style.js +3 -0
  77. package/lib/AMap/Map.js +124 -0
  78. package/lib/AMap/index.js +9 -0
  79. package/lib/AMap/util.js +62 -0
  80. package/lib/BadgeStatus/Badge.js +54 -0
  81. package/lib/BadgeStatus/color.js +27 -0
  82. package/lib/BadgeStatus/index.js +22 -0
  83. package/lib/CardSelect/CardSelect.js +123 -0
  84. package/lib/CardSelect/index.js +9 -0
  85. package/lib/CheckButton/CheckButton.js +121 -0
  86. package/lib/CheckButton/index.js +9 -0
  87. package/lib/ConfigProvider/context.js +19 -0
  88. package/lib/ConfigProvider/index.js +37 -0
  89. package/lib/Echarts/Echarts.js +47 -0
  90. package/lib/Echarts/index.js +9 -0
  91. package/lib/Ellipsis/Ellipsis.js +189 -0
  92. package/lib/Ellipsis/index.js +9 -0
  93. package/lib/Empty/Empty.js +56 -0
  94. package/lib/Empty/image.js +8 -0
  95. package/lib/Empty/index.js +9 -0
  96. package/lib/FullPage/FullPage.js +31 -0
  97. package/lib/FullPage/index.js +9 -0
  98. package/lib/Icon/icon.js +52 -0
  99. package/lib/Icon/index.js +9 -0
  100. package/lib/MonacoEditor/Monaco.js +238 -0
  101. package/lib/MonacoEditor/index.js +9 -0
  102. package/lib/PermissionButton/index.js +124 -0
  103. package/lib/ProLayout/Basic/BasicLayout.js +268 -0
  104. package/lib/ProLayout/Basic/BasicLayout.less +66 -0
  105. package/lib/ProLayout/Basic/Header.js +103 -0
  106. package/lib/ProLayout/Basic/Header.less +8 -0
  107. package/lib/ProLayout/PageContainer/index.js +327 -0
  108. package/lib/ProLayout/PageContainer/index.less +103 -0
  109. package/lib/ProLayout/PageContainer/typings.js +5 -0
  110. package/lib/ProLayout/RouteContext.js +28 -0
  111. package/lib/ProLayout/SiderMenu/BaseMenu.js +290 -0
  112. package/lib/ProLayout/SiderMenu/SiderMenu.js +287 -0
  113. package/lib/ProLayout/SiderMenu/index.js +20 -0
  114. package/lib/ProLayout/SiderMenu/index.less +212 -0
  115. package/lib/ProLayout/SiderMenu/typings.js +5 -0
  116. package/lib/ProLayout/TopHeader/index.js +168 -0
  117. package/lib/ProLayout/TopHeader/index.less +174 -0
  118. package/lib/ProLayout/defaultSettings.js +72 -0
  119. package/lib/ProLayout/index.js +16 -0
  120. package/lib/ProLayout/style/default.less +4 -0
  121. package/lib/ProLayout/style/index.js +3 -0
  122. package/lib/ProLayout/style/style.less +7 -0
  123. package/lib/ProLayout/typings.js +5 -0
  124. package/lib/ProLayout/util.js +72 -0
  125. package/lib/ProTable/index.js +417 -0
  126. package/lib/ProTable/proTableTypes.js +17 -0
  127. package/lib/ProTable/style/index.css +65 -0
  128. package/lib/ProTable/style/index.js +3 -0
  129. package/lib/ProTable/style/index.less +92 -0
  130. package/lib/Scrollbar/Bar.js +114 -0
  131. package/lib/Scrollbar/Scrollbar.js +212 -0
  132. package/lib/Scrollbar/Thumb.js +189 -0
  133. package/lib/Scrollbar/constants.js +7 -0
  134. package/lib/Scrollbar/index.js +9 -0
  135. package/{src/Scrollbar/scrollbar.ts → lib/Scrollbar/scrollbarProps.js} +106 -108
  136. package/lib/Scrollbar/thumbProps.js +16 -0
  137. package/lib/Scrollbar/util.js +37 -0
  138. package/lib/Search/Advanced/History.js +183 -0
  139. package/lib/Search/Advanced/SaveHistory.js +153 -0
  140. package/lib/Search/Advanced/index.js +520 -0
  141. package/lib/Search/Item.js +497 -0
  142. package/lib/Search/Search.js +249 -0
  143. package/lib/Search/hooks/index.js +16 -0
  144. package/lib/Search/hooks/useSearchItems.js +47 -0
  145. package/lib/Search/index.js +16 -0
  146. package/lib/Search/setting.js +97 -0
  147. package/lib/Search/style/Item.less +33 -0
  148. package/lib/Search/style/Search.less +179 -0
  149. package/lib/Search/style/index.js +4 -0
  150. package/lib/Search/typing.js +5 -0
  151. package/lib/Search/util.js +241 -0
  152. package/lib/ValueItem/ValueItem.js +233 -0
  153. package/lib/ValueItem/index.js +9 -0
  154. package/lib/ValueItem/util.js +22 -0
  155. package/lib/index.js +158 -0
  156. package/lib/style/components.less +1 -0
  157. package/lib/style/index.js +4 -0
  158. package/lib/style/variable.css +0 -0
  159. package/lib/style/variable.less +2 -0
  160. package/lib/style.js +5 -0
  161. package/package.json +122 -13
  162. package/index.ts +0 -64
  163. package/src/AMap/Map.vue +0 -110
  164. package/src/AMap/index.ts +0 -1
  165. package/src/AMap/util.ts +0 -56
  166. package/src/BadgeStatus/Badge.vue +0 -41
  167. package/src/BadgeStatus/color.ts +0 -25
  168. package/src/BadgeStatus/index.ts +0 -4
  169. package/src/CardSelect/CardSelect.vue +0 -136
  170. package/src/CardSelect/index.ts +0 -3
  171. package/src/CheckButton/CheckButton.vue +0 -146
  172. package/src/CheckButton/index.md +0 -27
  173. package/src/CheckButton/index.ts +0 -3
  174. package/src/ConfigProvider/context.ts +0 -17
  175. package/src/ConfigProvider/index.tsx +0 -42
  176. package/src/Echarts/Echarts.vue +0 -43
  177. package/src/Echarts/index.ts +0 -3
  178. package/src/Ellipsis/Ellipsis.vue +0 -182
  179. package/src/Ellipsis/index.ts +0 -3
  180. package/src/Empty/Empty.vue +0 -43
  181. package/src/Empty/image.ts +0 -3
  182. package/src/Empty/index.ts +0 -2
  183. package/src/FullPage/FullPage.vue +0 -30
  184. package/src/FullPage/index.ts +0 -3
  185. package/src/Icon/icon.tsx +0 -40
  186. package/src/MonacoEditor/Monaco.vue +0 -242
  187. package/src/MonacoEditor/index.md +0 -26
  188. package/src/MonacoEditor/index.ts +0 -2
  189. package/src/PermissionButton/index.tsx +0 -110
  190. package/src/ProLayout/Basic/BasicLayout.tsx +0 -392
  191. package/src/ProLayout/Basic/Header.tsx +0 -115
  192. package/src/ProLayout/PageContainer/index.tsx +0 -441
  193. package/src/ProLayout/PageContainer/typings.ts +0 -56
  194. package/src/ProLayout/RouteContext.ts +0 -87
  195. package/src/ProLayout/SiderMenu/BaseMenu.tsx +0 -296
  196. package/src/ProLayout/SiderMenu/SiderMenu.tsx +0 -320
  197. package/src/ProLayout/SiderMenu/index.ts +0 -2
  198. package/src/ProLayout/SiderMenu/typings.ts +0 -49
  199. package/src/ProLayout/TopHeader/index.tsx +0 -210
  200. package/src/ProLayout/defaultSettings.ts +0 -106
  201. package/src/ProLayout/style/index.ts +0 -1
  202. package/src/ProLayout/typings.ts +0 -87
  203. package/src/ProLayout/util.ts +0 -64
  204. package/src/ProTable/index.md +0 -53
  205. package/src/ProTable/index.tsx +0 -551
  206. package/src/ProTable/proTableTypes.ts +0 -70
  207. package/src/ProTable/style/index.ts +0 -1
  208. package/src/Scrollbar/Bar.vue +0 -75
  209. package/src/Scrollbar/Scrollbar.vue +0 -260
  210. package/src/Scrollbar/Thumb.vue +0 -163
  211. package/src/Scrollbar/constants.ts +0 -10
  212. package/src/Scrollbar/index.ts +0 -4
  213. package/src/Scrollbar/thumb.ts +0 -16
  214. package/src/Scrollbar/util.ts +0 -38
  215. package/src/Search/Advanced/History.vue +0 -140
  216. package/src/Search/Advanced/SaveHistory.vue +0 -108
  217. package/src/Search/Advanced/index.vue +0 -435
  218. package/src/Search/Item.vue +0 -525
  219. package/src/Search/Search.vue +0 -398
  220. package/src/Search/hooks/index.ts +0 -1
  221. package/src/Search/hooks/useSearchItems.ts +0 -68
  222. package/src/Search/index.md +0 -57
  223. package/src/Search/index.ts +0 -5
  224. package/src/Search/setting.ts +0 -55
  225. package/src/Search/typing.ts +0 -76
  226. package/src/Search/util.ts +0 -263
  227. package/src/ValueItem/ValueItem.vue +0 -192
  228. package/src/ValueItem/index.ts +0 -3
  229. package/src/ValueItem/util.ts +0 -16
  230. package/src/style/index.ts +0 -3
  231. /package/{src → es}/ProLayout/Basic/BasicLayout.less +0 -0
  232. /package/{src → es}/ProLayout/Basic/Header.less +0 -0
  233. /package/{src → es}/ProLayout/PageContainer/index.less +0 -0
  234. /package/{src → es}/ProLayout/SiderMenu/index.less +0 -0
  235. /package/{src → es}/ProLayout/TopHeader/index.less +0 -0
  236. /package/{src → es}/ProLayout/style/style.less +0 -0
  237. /package/{src → es}/ProTable/style/index.less +0 -0
@@ -0,0 +1,411 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+ import { createVNode as _createVNode, isVNode as _isVNode, createTextVNode as _createTextVNode, resolveDirective as _resolveDirective } from "vue";
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
7
+ import { Empty, AIcon } from '../index';
8
+ import { Table, Pagination, Button, Alert, Spin, RadioGroup, RadioButton } from 'ant-design-vue';
9
+ import { tableProps as _tableProps } from 'ant-design-vue/es/table';
10
+ import { defineComponent, onMounted, onUnmounted, ref, watch } from 'vue';
11
+ import { ModelEnum } from './proTableTypes';
12
+ import { get, debounce, isArray } from 'lodash-es';
13
+ function _isSlot(s) {
14
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
15
+ }
16
+ var tableProps = function tableProps() {
17
+ return _objectSpread(_objectSpread({}, _tableProps()), {}, {
18
+ loading: {
19
+ type: Boolean,
20
+ default: undefined
21
+ },
22
+ request: {
23
+ type: Function,
24
+ default: undefined
25
+ },
26
+ cardBodyClass: {
27
+ type: String,
28
+ default: ''
29
+ },
30
+ bodyStyle: {
31
+ type: Object,
32
+ default: {}
33
+ },
34
+ columns: {
35
+ type: Array,
36
+ default: function _default() {
37
+ return [];
38
+ }
39
+ },
40
+ model: {
41
+ type: [String, undefined],
42
+ default: undefined
43
+ },
44
+ modelValue: {
45
+ type: String,
46
+ default: undefined
47
+ },
48
+ noPagination: {
49
+ type: Boolean,
50
+ default: false
51
+ },
52
+ rowSelection: {
53
+ type: Object,
54
+ default: function _default() {
55
+ return undefined;
56
+ }
57
+ },
58
+ dataSource: {
59
+ type: Array,
60
+ default: function _default() {
61
+ return [];
62
+ }
63
+ },
64
+ gridColumns: {
65
+ type: Array,
66
+ default: function _default() {
67
+ return [];
68
+ }
69
+ },
70
+ gridColumn: {
71
+ type: Number,
72
+ default: 4
73
+ },
74
+ alertRender: {
75
+ type: Boolean,
76
+ default: true
77
+ },
78
+ params: {
79
+ type: Object,
80
+ default: function _default() {}
81
+ },
82
+ type: {
83
+ type: String,
84
+ default: 'PAGE'
85
+ },
86
+ scroll: {
87
+ type: Object,
88
+ default: function _default() {
89
+ x: 1366;
90
+ }
91
+ },
92
+ defaultParams: {
93
+ type: Object,
94
+ default: function _default() {}
95
+ },
96
+ rowKey: {
97
+ type: [String, Function],
98
+ default: 'id'
99
+ },
100
+ pagination: {
101
+ type: Object,
102
+ default: function _default() {
103
+ return {
104
+ showSizeChanger: true,
105
+ showQuickJumper: false,
106
+ size: 'size',
107
+ pageSizeOptions: ['12', '24', '48', '96']
108
+ };
109
+ }
110
+ }
111
+ });
112
+ };
113
+ var ProTable = defineComponent({
114
+ name: 'ProTable',
115
+ slots: ['headerTitle', 'card', 'rightExtraRender', 'paginationRender' // 分页
116
+ ],
117
+ props: tableProps(),
118
+ emits: ['update:modelValue', 'modelChange'],
119
+ setup: function setup(props, _ref) {
120
+ var _props$pagination;
121
+ var slots = _ref.slots,
122
+ expose = _ref.expose,
123
+ emit = _ref.emit;
124
+ var _model = ref(props.model ? props.model : ModelEnum.CARD); // 模式切换
125
+ var _dataSource = ref([]);
126
+ var pageIndex = ref(0);
127
+ var pageSize = ref(12);
128
+ var total = ref(0);
129
+ var _loading = ref(false);
130
+ var column = ref(props.gridColumn || 4);
131
+ if (!props.noPagination && props.pagination && isArray((_props$pagination = props.pagination) === null || _props$pagination === void 0 ? void 0 : _props$pagination.pageSizeOptions)) {
132
+ pageSize.value = props.pagination.pageSizeOptions[0];
133
+ }
134
+ /**
135
+ * 监听宽度,计算显示卡片个数
136
+ */
137
+ var windowChange = function windowChange() {
138
+ if (window.innerWidth <= 1440) {
139
+ var _props$gridColumns;
140
+ var _column = props.gridColumn && props.gridColumn < 2 ? props.gridColumn : 2;
141
+ column.value = ((_props$gridColumns = props.gridColumns) === null || _props$gridColumns === void 0 ? void 0 : _props$gridColumns[0]) ? props.gridColumns[0] : _column;
142
+ } else if (window.innerWidth > 1440 && window.innerWidth <= 1600) {
143
+ var _props$gridColumns2;
144
+ var _column2 = props.gridColumn && props.gridColumn < 3 ? props.gridColumn : 3;
145
+ column.value = ((_props$gridColumns2 = props.gridColumns) === null || _props$gridColumns2 === void 0 ? void 0 : _props$gridColumns2[1]) ? props.gridColumns[1] : _column2;
146
+ } else if (window.innerWidth > 1600) {
147
+ var _props$gridColumns3;
148
+ var _column3 = props.gridColumn && props.gridColumn < 4 ? props.gridColumn : 4;
149
+ column.value = ((_props$gridColumns3 = props.gridColumns) === null || _props$gridColumns3 === void 0 ? void 0 : _props$gridColumns3[2]) ? props.gridColumns[2] : _column3;
150
+ }
151
+ };
152
+ var handleSearch = /*#__PURE__*/function () {
153
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_params) {
154
+ var _props$defaultParams, resp, _resp$result, _resp$result2, _resp$result3, _resp$result4, _resp$result4$data, _resp$result5, _resp$result6, _resp$result7, _resp$result8;
155
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
156
+ while (1) switch (_context.prev = _context.next) {
157
+ case 0:
158
+ _loading.value = props.loading !== undefined ? props.loading : true;
159
+ if (!props.request) {
160
+ _context.next = 9;
161
+ break;
162
+ }
163
+ console.log(_params);
164
+ _context.next = 5;
165
+ return props.request(_objectSpread(_objectSpread(_objectSpread({
166
+ pageIndex: 0,
167
+ pageSize: Number(pageSize.value)
168
+ }, props.defaultParams), _params), {}, {
169
+ terms: [].concat(_toConsumableArray(((_props$defaultParams = props.defaultParams) === null || _props$defaultParams === void 0 ? void 0 : _props$defaultParams.terms) || []), _toConsumableArray((_params === null || _params === void 0 ? void 0 : _params.terms) || []))
170
+ })).catch(function () {
171
+ _loading.value = props.loading !== undefined ? props.loading : false;
172
+ });
173
+ case 5:
174
+ resp = _context.sent;
175
+ if (resp.status === 200) {
176
+ if (props.type === 'PAGE') {
177
+ // 判断如果是最后一页且最后一页为空,就跳转到前一页
178
+ if ((resp === null || resp === void 0 ? void 0 : (_resp$result = resp.result) === null || _resp$result === void 0 ? void 0 : _resp$result.total) && (resp === null || resp === void 0 ? void 0 : (_resp$result2 = resp.result) === null || _resp$result2 === void 0 ? void 0 : _resp$result2.pageSize) && (resp === null || resp === void 0 ? void 0 : (_resp$result3 = resp.result) === null || _resp$result3 === void 0 ? void 0 : _resp$result3.pageIndex) && (resp === null || resp === void 0 ? void 0 : (_resp$result4 = resp.result) === null || _resp$result4 === void 0 ? void 0 : (_resp$result4$data = _resp$result4.data) === null || _resp$result4$data === void 0 ? void 0 : _resp$result4$data.length) === 0) {
179
+ pageIndex.value = pageIndex.value > 0 ? pageIndex.value - 1 : 0;
180
+ handleSearch(_objectSpread(_objectSpread({}, _params), {}, {
181
+ pageSize: pageSize.value,
182
+ pageIndex: pageIndex.value
183
+ }));
184
+ } else {
185
+ _dataSource.value = (resp === null || resp === void 0 ? void 0 : (_resp$result5 = resp.result) === null || _resp$result5 === void 0 ? void 0 : _resp$result5.data) || [];
186
+ pageIndex.value = (resp === null || resp === void 0 ? void 0 : (_resp$result6 = resp.result) === null || _resp$result6 === void 0 ? void 0 : _resp$result6.pageIndex) || 0;
187
+ pageSize.value = (resp === null || resp === void 0 ? void 0 : (_resp$result7 = resp.result) === null || _resp$result7 === void 0 ? void 0 : _resp$result7.pageSize) || 12;
188
+ total.value = (resp === null || resp === void 0 ? void 0 : (_resp$result8 = resp.result) === null || _resp$result8 === void 0 ? void 0 : _resp$result8.total) || 0;
189
+ }
190
+ } else {
191
+ _dataSource.value = (resp === null || resp === void 0 ? void 0 : resp.result) || [];
192
+ }
193
+ } else {
194
+ _dataSource.value = [];
195
+ }
196
+ _context.next = 10;
197
+ break;
198
+ case 9:
199
+ _dataSource.value = (props === null || props === void 0 ? void 0 : props.dataSource) || [];
200
+ case 10:
201
+ _loading.value = props.loading !== undefined ? props.loading : false;
202
+ case 11:
203
+ case "end":
204
+ return _context.stop();
205
+ }
206
+ }, _callee);
207
+ }));
208
+ return function handleSearch(_x) {
209
+ return _ref2.apply(this, arguments);
210
+ };
211
+ }();
212
+ var _debounceFn = debounce(handleSearch, 300);
213
+ watch(function () {
214
+ return props.params;
215
+ }, function (newValue) {
216
+ _debounceFn(newValue || {});
217
+ }, {
218
+ deep: true,
219
+ immediate: true
220
+ });
221
+ watch(function () {
222
+ return props.dataSource;
223
+ }, function (newVal) {
224
+ if (newVal && !props.request) {
225
+ handleSearch(props.params);
226
+ }
227
+ }, {
228
+ deep: true,
229
+ immediate: true
230
+ });
231
+ watch(function () {
232
+ return props.modelValue;
233
+ }, function () {
234
+ if (props.modelValue) {
235
+ _model.value = props.modelValue;
236
+ }
237
+ }, {
238
+ immediate: true
239
+ });
240
+ /**
241
+ * 刷新数据
242
+ * @param _params
243
+ */
244
+ var reload = function reload(_params) {
245
+ handleSearch(_objectSpread(_objectSpread(_objectSpread({}, props.params), _params), {}, {
246
+ pageSize: pageSize.value || 12,
247
+ pageIndex: pageIndex.value || 0
248
+ }));
249
+ };
250
+ onMounted(function () {
251
+ windowChange(); // 初始化
252
+ window.onresize = function () {
253
+ windowChange();
254
+ };
255
+ });
256
+ onUnmounted(function () {
257
+ window.onresize = null;
258
+ });
259
+ /**
260
+ * 导出方法
261
+ */
262
+ expose({
263
+ reload: reload,
264
+ _dataSource: _dataSource
265
+ });
266
+ return function () {
267
+ var _props$rowSelection, _props$rowSelection$s, _props$rowSelection2, _props$rowSelection2$;
268
+ var _slot, _slot2, _slot3;
269
+ return _createVNode("div", {
270
+ "class": "jtable-body-spin",
271
+ "style": _objectSpread({}, props.bodyStyle)
272
+ }, [_createVNode(Spin, {
273
+ "spinning": _loading.value
274
+ }, _isSlot(_slot3 = _createVNode("div", {
275
+ "class": 'jtable-body'
276
+ }, [_createVNode("div", {
277
+ "class": 'jtable-body-header'
278
+ }, [_createVNode("div", {
279
+ "class": 'jtable-body-header-left'
280
+ }, [slots.headerTitle && slots.headerTitle()]), _createVNode("div", {
281
+ "class": 'jtable-body-header-right'
282
+ }, [slots.rightExtraRender && slots.rightExtraRender(), !props.model && _createVNode("div", {
283
+ "class": 'jtable-body-header-right-button'
284
+ }, [_createVNode(RadioGroup, {
285
+ "class": "jtable-body-header-right-button",
286
+ "value": _model.value,
287
+ "onChange": function onChange(e) {
288
+ _model.value = e.target.value;
289
+ emit('update:modelValue', e.target.value);
290
+ emit('modelChange', e.target.value);
291
+ }
292
+ }, {
293
+ default: function _default() {
294
+ return [_createVNode(RadioButton, {
295
+ "value": ModelEnum.TABLE
296
+ }, _isSlot(_slot = _createVNode(AIcon, {
297
+ "class": 'right-button-icon',
298
+ "type": "UnorderedListOutlined"
299
+ }, null)) ? _slot : {
300
+ default: function _default() {
301
+ return [_slot];
302
+ }
303
+ }), _createVNode(RadioButton, {
304
+ "value": ModelEnum.CARD
305
+ }, _isSlot(_slot2 = _createVNode(AIcon, {
306
+ "class": 'right-button-icon',
307
+ "type": "AppstoreOutlined"
308
+ }, null)) ? _slot2 : {
309
+ default: function _default() {
310
+ return [_slot2];
311
+ }
312
+ })];
313
+ }
314
+ })])])]), _createVNode("div", {
315
+ "class": 'jtable-content'
316
+ }, [props.alertRender && (props === null || props === void 0 ? void 0 : props.rowSelection) && (props === null || props === void 0 ? void 0 : (_props$rowSelection = props.rowSelection) === null || _props$rowSelection === void 0 ? void 0 : _props$rowSelection.selectedRowKeys) && ((_props$rowSelection$s = props.rowSelection.selectedRowKeys) === null || _props$rowSelection$s === void 0 ? void 0 : _props$rowSelection$s.length) ? _createVNode("div", {
317
+ "class": 'jtable-alert'
318
+ }, [_createVNode(Alert, {
319
+ "message": '已选择' + (props === null || props === void 0 ? void 0 : (_props$rowSelection2 = props.rowSelection) === null || _props$rowSelection2 === void 0 ? void 0 : (_props$rowSelection2$ = _props$rowSelection2.selectedRowKeys) === null || _props$rowSelection2$ === void 0 ? void 0 : _props$rowSelection2$.length) + '项',
320
+ "type": "info",
321
+ "onClose": function onClose() {
322
+ var _props$rowSelection3, _props$rowSelection3$, _props$rowSelection4, _props$rowSelection4$;
323
+ // if (props.rowSelection?.onSelectNone) {
324
+ // // 取消选择清空被选数据
325
+ // }
326
+ (_props$rowSelection3 = props.rowSelection) === null || _props$rowSelection3 === void 0 ? void 0 : (_props$rowSelection3$ = _props$rowSelection3.onChange) === null || _props$rowSelection3$ === void 0 ? void 0 : _props$rowSelection3$.call(_props$rowSelection3, [], []);
327
+ (_props$rowSelection4 = props.rowSelection) === null || _props$rowSelection4 === void 0 ? void 0 : (_props$rowSelection4$ = _props$rowSelection4.onSelectNone) === null || _props$rowSelection4$ === void 0 ? void 0 : _props$rowSelection4$.call(_props$rowSelection4);
328
+ },
329
+ "closeText": _createVNode(Button, {
330
+ "type": "link"
331
+ }, {
332
+ default: function _default() {
333
+ return [_createTextVNode("\u53D6\u6D88\u9009\u62E9")];
334
+ }
335
+ })
336
+ }, null)]) : null, _model.value === ModelEnum.CARD ? _createVNode("div", {
337
+ "class": 'jtable-card',
338
+ "style": props.scroll && props.scroll.y ? {
339
+ maxHeight: props.scroll.y + 'px',
340
+ overflow: 'auto'
341
+ } : undefined
342
+ }, [_dataSource.value.length ? _createVNode("div", {
343
+ "class": 'jtable-card-items',
344
+ "style": {
345
+ gridTemplateColumns: "repeat(".concat(column.value, ", 1fr)")
346
+ }
347
+ }, [_dataSource.value.map(function (item) {
348
+ return slots.card ? _createVNode("div", {
349
+ "class": ['jtable-card-item', props.cardBodyClass]
350
+ }, [slots.card(item)]) : null;
351
+ })]) : _createVNode("div", {
352
+ "class": "j-table-empty"
353
+ }, [_createVNode(Empty, null, null)])]) : _createVNode("div", null, [_createVNode(Table, _objectSpread(_objectSpread({}, props), {}, {
354
+ "dataSource": _dataSource.value,
355
+ "columns": props.columns.filter(function (i) {
356
+ return !(i === null || i === void 0 ? void 0 : i.hideInTable);
357
+ }),
358
+ "pagination": false,
359
+ "rowSelection": props.rowSelection,
360
+ "scroll": props.scroll
361
+ }), {
362
+ headerCell: function headerCell(dt) {
363
+ var column = dt.column,
364
+ title = dt.title;
365
+ if (column === null || column === void 0 ? void 0 : column.headerCell) {
366
+ return slots === null || slots === void 0 ? void 0 : slots[column === null || column === void 0 ? void 0 : column.headerCell](column.title);
367
+ } else {
368
+ return title || '';
369
+ }
370
+ },
371
+ bodyCell: function bodyCell(dt) {
372
+ var column = dt.column,
373
+ record = dt.record;
374
+ if (((column === null || column === void 0 ? void 0 : column.key) || (column === null || column === void 0 ? void 0 : column.dataIndex)) && (column === null || column === void 0 ? void 0 : column.scopedSlots) && ((slots === null || slots === void 0 ? void 0 : slots[column === null || column === void 0 ? void 0 : column.dataIndex]) || (slots === null || slots === void 0 ? void 0 : slots[column === null || column === void 0 ? void 0 : column.key]))) {
375
+ var _key = (column === null || column === void 0 ? void 0 : column.key) || (column === null || column === void 0 ? void 0 : column.dataIndex);
376
+ return slots === null || slots === void 0 ? void 0 : slots[_key](record);
377
+ } else {
378
+ var _value = get(record, column === null || column === void 0 ? void 0 : column.dataIndex);
379
+ // 获取数据
380
+ return _value;
381
+ }
382
+ },
383
+ emptyText: function emptyText() {
384
+ return _createVNode(Empty, null, null);
385
+ }
386
+ })])]), !!_dataSource.value.length && !props.noPagination && props.type === 'PAGE' && _createVNode("div", {
387
+ "class": 'jtable-pagination'
388
+ }, [(slots === null || slots === void 0 ? void 0 : slots.paginationRender) ? slots.paginationRender() : _createVNode(Pagination, _objectSpread(_objectSpread({}, props.pagination), {}, {
389
+ "total": total.value,
390
+ "current": pageIndex.value + 1,
391
+ "pageSize": pageSize.value,
392
+ "showTotal": function showTotal(num) {
393
+ var minSize = pageIndex.value * pageSize.value + 1;
394
+ var MaxSize = (pageIndex.value + 1) * pageSize.value;
395
+ return "\u7B2C ".concat(minSize, " - ").concat(MaxSize > num ? num : MaxSize, " \u6761/\u603B\u5171 ").concat(num, " \u6761");
396
+ },
397
+ "onChange": function onChange(page, size) {
398
+ handleSearch(_objectSpread(_objectSpread({}, props.params), {}, {
399
+ pageSize: size,
400
+ pageIndex: pageSize.value === size ? page ? page - 1 : 0 : 0
401
+ }));
402
+ }
403
+ }), null)])])) ? _slot3 : {
404
+ default: function _default() {
405
+ return [_slot3];
406
+ }
407
+ })]);
408
+ };
409
+ }
410
+ });
411
+ export default ProTable;
@@ -0,0 +1,11 @@
1
+ import 'vue';
2
+ export var TypeEnum;
3
+ (function (TypeEnum) {
4
+ TypeEnum["TREE"] = "TREE";
5
+ TypeEnum["PAGE"] = "PAGE";
6
+ })(TypeEnum || (TypeEnum = {}));
7
+ export var ModelEnum;
8
+ (function (ModelEnum) {
9
+ ModelEnum["TABLE"] = "TABLE";
10
+ ModelEnum["CARD"] = "CARD";
11
+ })(ModelEnum || (ModelEnum = {}));
@@ -0,0 +1,65 @@
1
+ .jtable-body-spin {
2
+ min-height: 100%;
3
+ width: 100%;
4
+ padding: 16px 24px 24px;
5
+ background-color: #fff;
6
+ }
7
+ .jtable-body-spin .ant-spin-nested-loading {
8
+ height: 100%;
9
+ }
10
+ .jtable-body-spin .ant-spin-nested-loading .ant-spin-container {
11
+ height: 100%;
12
+ }
13
+ .jtable-body-spin .jtable-body {
14
+ width: 100%;
15
+ box-sizing: border-box;
16
+ height: 100%;
17
+ display: flex;
18
+ flex-direction: column;
19
+ }
20
+ .jtable-body-spin .jtable-body .jtable-body-header {
21
+ display: flex;
22
+ justify-content: space-between;
23
+ align-items: center;
24
+ }
25
+ .jtable-body-spin .jtable-body .jtable-body-header .jtable-body-header-right {
26
+ display: flex;
27
+ gap: 8px;
28
+ align-items: center;
29
+ }
30
+ .jtable-body-spin .jtable-body .jtable-body-header .jtable-body-header-right .jtable-body-header-right-button .right-button-icon {
31
+ font-size: 16px;
32
+ color: #d9d9d9;
33
+ }
34
+ .jtable-body-spin .jtable-body .jtable-body-header .jtable-body-header-right .jtable-body-header-right-button .ant-radio-button-wrapper {
35
+ padding: 0 8px;
36
+ }
37
+ .jtable-body-spin .jtable-body .jtable-body-header .jtable-body-header-right .jtable-body-header-right-button .ant-radio-button-wrapper-checked .right-button-icon {
38
+ color: #315EFB;
39
+ }
40
+ .jtable-body-spin .jtable-body .jtable-content {
41
+ flex: 1;
42
+ padding: 16px 0;
43
+ }
44
+ .jtable-body-spin .jtable-body .jtable-content .jtable-alert {
45
+ margin-bottom: 16px;
46
+ }
47
+ .jtable-body-spin .jtable-body .jtable-content .jtable-card .jtable-card-items {
48
+ display: grid;
49
+ grid-gap: 26px;
50
+ }
51
+ .jtable-body-spin .jtable-body .jtable-content .jtable-card .jtable-card-items .jtable-card-item {
52
+ display: flex;
53
+ min-width: 0;
54
+ }
55
+ .jtable-body-spin .jtable-body .jtable-pagination {
56
+ width: 100%;
57
+ display: flex;
58
+ justify-content: flex-end;
59
+ }
60
+ .jtable-body-spin .jtable-body .j-table-empty {
61
+ display: flex;
62
+ justify-content: center;
63
+ align-items: center;
64
+ margin: 10% 0;
65
+ }
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,114 @@
1
+ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
2
+ const op = ops[i];
3
+ const fn = ops[i + 1];
4
+ i += 2;
5
+ if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
6
+ return undefined;
7
+ }
8
+ if (op === 'access' || op === 'optionalAccess') {
9
+ lastAccessLHS = value;
10
+ value = fn(value);
11
+ }
12
+ else if (op === 'call' || op === 'optionalCall') {
13
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
14
+ lastAccessLHS = undefined;
15
+ }
16
+ } return value; }
17
+ /* Analyzed bindings: {
18
+ "always": "props",
19
+ "minSize": "props",
20
+ "inject": "setup-const",
21
+ "ref": "setup-const",
22
+ "GAP": "setup-maybe-ref",
23
+ "Thumb": "setup-const",
24
+ "scrollbarContextKey": "setup-maybe-ref",
25
+ "props": "setup-reactive-const",
26
+ "scrollbar": "setup-maybe-ref",
27
+ "moveX": "setup-ref",
28
+ "moveY": "setup-ref",
29
+ "sizeWidth": "setup-ref",
30
+ "sizeHeight": "setup-ref",
31
+ "ratioY": "setup-ref",
32
+ "ratioX": "setup-ref",
33
+ "handleScroll": "setup-const",
34
+ "update": "setup-const"
35
+ } */
36
+ import { defineComponent as _defineComponent } from 'vue';
37
+ import { createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
38
+ import { inject, ref } from 'vue';
39
+ import { GAP } from './util';
40
+ import Thumb from './Thumb.js';
41
+ import { scrollbarContextKey } from './constants';
42
+ const __sfc_main__ = _defineComponent({
43
+ props: {
44
+ always: {
45
+ type: Boolean,
46
+ default: true,
47
+ },
48
+ minSize: {
49
+ type: Number,
50
+ required: true,
51
+ }
52
+ },
53
+ setup(__props, { expose: __expose }) {
54
+ const props = __props;
55
+ const scrollbar = inject(scrollbarContextKey);
56
+ const moveX = ref(0);
57
+ const moveY = ref(0);
58
+ const sizeWidth = ref('');
59
+ const sizeHeight = ref('');
60
+ const ratioY = ref(1);
61
+ const ratioX = ref(1);
62
+ const handleScroll = (wrap) => {
63
+ if (wrap) {
64
+ const offsetHeight = wrap.offsetHeight - GAP;
65
+ const offsetWidth = wrap.offsetWidth - GAP;
66
+ moveY.value = ((wrap.scrollTop * 100) / offsetHeight) * ratioY.value;
67
+ moveX.value = ((wrap.scrollLeft * 100) / offsetWidth) * ratioX.value;
68
+ }
69
+ };
70
+ const update = () => {
71
+ const wrap = _optionalChain([scrollbar, 'optionalAccess', _ => _.wrapElement]);
72
+ if (!wrap)
73
+ return;
74
+ const offsetHeight = wrap.offsetHeight - GAP;
75
+ const offsetWidth = wrap.offsetWidth - GAP;
76
+ const originalHeight = offsetHeight ** 2 / wrap.scrollHeight;
77
+ const originalWidth = offsetWidth ** 2 / wrap.scrollWidth;
78
+ const height = Math.max(originalHeight, props.minSize);
79
+ const width = Math.max(originalWidth, props.minSize);
80
+ ratioY.value =
81
+ originalHeight /
82
+ (offsetHeight - originalHeight) /
83
+ (height / (offsetHeight - height));
84
+ ratioX.value =
85
+ originalWidth /
86
+ (offsetWidth - originalWidth) /
87
+ (width / (offsetWidth - width));
88
+ sizeHeight.value = height + GAP < offsetHeight ? `${height}px` : '';
89
+ sizeWidth.value = width + GAP < offsetWidth ? `${width}px` : '';
90
+ };
91
+ __expose({
92
+ handleScroll,
93
+ update,
94
+ });
95
+ return (_ctx, _cache) => {
96
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
97
+ _createVNode(Thumb, {
98
+ move: moveX.value,
99
+ ratio: ratioX.value,
100
+ size: sizeWidth.value,
101
+ always: __props.always
102
+ }, null, 8 /* PROPS */, ["move", "ratio", "size", "always"]),
103
+ _createVNode(Thumb, {
104
+ move: moveY.value,
105
+ ratio: ratioY.value,
106
+ size: sizeHeight.value,
107
+ vertical: "",
108
+ always: __props.always
109
+ }, null, 8 /* PROPS */, ["move", "ratio", "size", "always"])
110
+ ], 64 /* STABLE_FRAGMENT */));
111
+ };
112
+ }
113
+ });
114
+ export default __sfc_main__;