orion-design 0.1.29 → 0.1.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. package/dist/Throne/index.js +30 -14
  2. package/dist/Throne/index.js.map +1 -1
  3. package/dist/_commonjsHelpers-DWwsNxpa.js +9 -0
  4. package/dist/_commonjsHelpers-DWwsNxpa.js.map +1 -0
  5. package/dist/components/Button/index.js +40 -33
  6. package/dist/components/Button/index.js.map +1 -1
  7. package/dist/components/Flex/index.js +122 -89
  8. package/dist/components/Flex/index.js.map +1 -1
  9. package/dist/components/Form/Form.js +2 -2
  10. package/dist/components/Form/Form.js.map +1 -1
  11. package/dist/components/Form/LovInput/LovInput.js +2 -2
  12. package/dist/components/Form/LovInput/LovInput.js.map +1 -1
  13. package/dist/components/Form/LovInput/hooks/useLov.js +5 -5
  14. package/dist/components/Form/LovInput/hooks/useLov.js.map +1 -1
  15. package/dist/components/Form/LovInput/index.js +4 -4
  16. package/dist/components/Form/hooks/FormItemValidateTrigger.js +2 -2
  17. package/dist/components/Form/hooks/FormItemValidateTrigger.js.map +1 -1
  18. package/dist/components/Form/hooks/index.js +128 -66
  19. package/dist/components/Form/hooks/index.js.map +1 -1
  20. package/dist/components/Form/index.js +836 -656
  21. package/dist/components/Form/index.js.map +1 -1
  22. package/dist/components/Form/utils/index.js +30 -18
  23. package/dist/components/Form/utils/index.js.map +1 -1
  24. package/dist/components/LovTable/LovPagetable.vue.d.ts +28 -0
  25. package/dist/components/LovTable/index.d.ts +14 -0
  26. package/dist/components/LovTable/index.js +179 -105
  27. package/dist/components/LovTable/index.js.map +1 -1
  28. package/dist/components/Modal/Modal.d.ts +2 -0
  29. package/dist/components/Modal/ModalLocator.vue.d.ts +20 -0
  30. package/dist/components/Modal/index.d.ts +4 -1
  31. package/dist/components/Modal/index.js +127 -0
  32. package/dist/components/Modal/index.js.map +1 -0
  33. package/dist/components/Modal/types.d.ts +18 -0
  34. package/dist/components/Modal/types.js +7 -0
  35. package/dist/components/Modal/types.js.map +1 -0
  36. package/dist/components/Modal/useModal.d.ts +1 -3
  37. package/dist/components/Modal/useModal.js +5 -4
  38. package/dist/components/Modal/useModal.js.map +1 -1
  39. package/dist/components/Pagetable/Pagetable.d.ts +13 -0
  40. package/dist/components/Pagetable/columns/PagetableColumnButtongroup.d.ts +13 -0
  41. package/dist/components/Pagetable/columns/PagetableColumnDate.d.ts +13 -0
  42. package/dist/components/Pagetable/columns/PagetableColumnDiy.d.ts +13 -0
  43. package/dist/components/Pagetable/columns/PagetableColumnLink.d.ts +13 -0
  44. package/dist/components/Pagetable/columns/PagetableColumnMultiselect.d.ts +13 -0
  45. package/dist/components/Pagetable/columns/PagetableColumnNumber.d.ts +13 -0
  46. package/dist/components/Pagetable/columns/PagetableColumnSingleselect.d.ts +13 -0
  47. package/dist/components/Pagetable/columns/PagetableColumnString.d.ts +13 -0
  48. package/dist/components/Pagetable/hooks/useColumns.js +88 -74
  49. package/dist/components/Pagetable/hooks/useColumns.js.map +1 -1
  50. package/dist/components/Pagetable/index.d.ts +9 -0
  51. package/dist/components/Pagetable/index.js +697 -491
  52. package/dist/components/Pagetable/index.js.map +1 -1
  53. package/dist/components/Pagetable/utils/index.js +92 -54
  54. package/dist/components/Pagetable/utils/index.js.map +1 -1
  55. package/dist/components/Querytable/hooks/useColumns.js +82 -74
  56. package/dist/components/Querytable/hooks/useColumns.js.map +1 -1
  57. package/dist/components/Querytable/index.js +579 -469
  58. package/dist/components/Querytable/index.js.map +1 -1
  59. package/dist/components/Querytable/utils/index.js +92 -54
  60. package/dist/components/Querytable/utils/index.js.map +1 -1
  61. package/dist/components/RichTextEditor/index.js +100 -74
  62. package/dist/components/RichTextEditor/index.js.map +1 -1
  63. package/dist/components/Tabs/constants.js +2 -2
  64. package/dist/components/Tabs/constants.js.map +1 -1
  65. package/dist/components/Tabs/index.js +603 -358
  66. package/dist/components/Tabs/index.js.map +1 -1
  67. package/dist/components/Tabs/tab-bar.js +6 -6
  68. package/dist/components/Tabs/tab-bar.js.map +1 -1
  69. package/dist/components/Tabs/tab-pane.js +3 -3
  70. package/dist/components/Tabs/tab-pane.js.map +1 -1
  71. package/dist/components/_constants/aria.js +2 -2
  72. package/dist/components/_constants/aria.js.map +1 -1
  73. package/dist/components/_constants/event.js +6 -4
  74. package/dist/components/_constants/event.js.map +1 -1
  75. package/dist/components/_constants/index.js +6 -6
  76. package/dist/components/_hooks/index.js +7 -7
  77. package/dist/components/_hooks/use-namespace/index.js +74 -39
  78. package/dist/components/_hooks/use-namespace/index.js.map +1 -1
  79. package/dist/components/_hooks/use-ordered-children/index.js +29 -19
  80. package/dist/components/_hooks/use-ordered-children/index.js.map +1 -1
  81. package/dist/components/_util/arrays.js +9 -5
  82. package/dist/components/_util/arrays.js.map +1 -1
  83. package/dist/components/_util/browser.js +6 -6
  84. package/dist/components/_util/browser.js.map +1 -1
  85. package/dist/components/_util/classNames.js +22 -17
  86. package/dist/components/_util/classNames.js.map +1 -1
  87. package/dist/components/_util/dom/aria.js +74 -39
  88. package/dist/components/_util/dom/aria.js.map +1 -1
  89. package/dist/components/_util/dom/element.js +9 -8
  90. package/dist/components/_util/dom/element.js.map +1 -1
  91. package/dist/components/_util/dom/event.js +14 -7
  92. package/dist/components/_util/dom/event.js.map +1 -1
  93. package/dist/components/_util/dom/index.js +36 -36
  94. package/dist/components/_util/dom/position.js +49 -25
  95. package/dist/components/_util/dom/position.js.map +1 -1
  96. package/dist/components/_util/dom/scroll.js +103 -61
  97. package/dist/components/_util/dom/scroll.js.map +1 -1
  98. package/dist/components/_util/dom/style.js +65 -50
  99. package/dist/components/_util/dom/style.js.map +1 -1
  100. package/dist/components/_util/easings.js +8 -4
  101. package/dist/components/_util/easings.js.map +1 -1
  102. package/dist/components/_util/error.js +12 -11
  103. package/dist/components/_util/error.js.map +1 -1
  104. package/dist/components/_util/functions.js +3 -3
  105. package/dist/components/_util/i18n.js +2 -2
  106. package/dist/components/_util/i18n.js.map +1 -1
  107. package/dist/components/_util/index.js +137 -137
  108. package/dist/components/_util/isValid.js +4 -2
  109. package/dist/components/_util/isValid.js.map +1 -1
  110. package/dist/components/_util/objects.js +18 -14
  111. package/dist/components/_util/objects.js.map +1 -1
  112. package/dist/components/_util/props-util/index.js +46 -20
  113. package/dist/components/_util/props-util/index.js.map +1 -1
  114. package/dist/components/_util/props-util/initDefaultProps.js +18 -10
  115. package/dist/components/_util/props-util/initDefaultProps.js.map +1 -1
  116. package/dist/components/_util/raf.js +5 -4
  117. package/dist/components/_util/raf.js.map +1 -1
  118. package/dist/components/_util/rand.js +4 -3
  119. package/dist/components/_util/rand.js.map +1 -1
  120. package/dist/components/_util/strings.js +9 -8
  121. package/dist/components/_util/strings.js.map +1 -1
  122. package/dist/components/_util/throttleByRaf.js +16 -10
  123. package/dist/components/_util/throttleByRaf.js.map +1 -1
  124. package/dist/components/_util/type.js +41 -38
  125. package/dist/components/_util/type.js.map +1 -1
  126. package/dist/components/_util/types.js +41 -22
  127. package/dist/components/_util/types.js.map +1 -1
  128. package/dist/components/_util/typescript.js +2 -2
  129. package/dist/components/_util/typescript.js.map +1 -1
  130. package/dist/components/_util/util.js +85 -43
  131. package/dist/components/_util/util.js.map +1 -1
  132. package/dist/components/_util/vue/global-node.js +27 -15
  133. package/dist/components/_util/vue/global-node.js.map +1 -1
  134. package/dist/components/_util/vue/icon.js +29 -25
  135. package/dist/components/_util/vue/icon.js.map +1 -1
  136. package/dist/components/_util/vue/index.js +41 -41
  137. package/dist/components/_util/vue/install.js +35 -18
  138. package/dist/components/_util/vue/install.js.map +1 -1
  139. package/dist/components/_util/vue/props/index.js +6 -6
  140. package/dist/components/_util/vue/props/runtime.js +46 -30
  141. package/dist/components/_util/vue/props/runtime.js.map +1 -1
  142. package/dist/components/_util/vue/refs.js +12 -6
  143. package/dist/components/_util/vue/refs.js.map +1 -1
  144. package/dist/components/_util/vue/size.js +5 -3
  145. package/dist/components/_util/vue/size.js.map +1 -1
  146. package/dist/components/_util/vue/validator.js +5 -4
  147. package/dist/components/_util/vue/validator.js.map +1 -1
  148. package/dist/components/_util/vue/vnode.js +100 -54
  149. package/dist/components/_util/vue/vnode.js.map +1 -1
  150. package/dist/components/_util/vue-types/index.js +231 -220
  151. package/dist/components/_util/vue-types/index.js.map +1 -1
  152. package/dist/components/components.js +20 -20
  153. package/dist/components/index.js +38 -35
  154. package/dist/components/index.js.map +1 -1
  155. package/dist/components-8oZ2kpUC.js +27 -0
  156. package/dist/components-8oZ2kpUC.js.map +1 -0
  157. package/dist/components-B3d9m_tn.js +27 -0
  158. package/dist/components-B3d9m_tn.js.map +1 -0
  159. package/dist/error/OrionError.js +8 -4
  160. package/dist/error/OrionError.js.map +1 -1
  161. package/dist/functions-BeMkokbY.js +63 -0
  162. package/dist/functions-BeMkokbY.js.map +1 -0
  163. package/dist/index-BOKLZnqH.js +54 -0
  164. package/dist/index-BOKLZnqH.js.map +1 -0
  165. package/dist/index-D1m0KTpK.js +69 -0
  166. package/dist/index-D1m0KTpK.js.map +1 -0
  167. package/dist/index-DR5ZP7mD.js +160 -0
  168. package/dist/index-DR5ZP7mD.js.map +1 -0
  169. package/dist/index-DkwIULcN.js +200 -0
  170. package/dist/index-DkwIULcN.js.map +1 -0
  171. package/dist/index.css +797 -1
  172. package/dist/index.js +36 -36
  173. package/dist/print/LodopFuncs.js +101 -43
  174. package/dist/print/LodopFuncs.js.map +1 -1
  175. package/dist/print/index.js +200 -108
  176. package/dist/print/index.js.map +1 -1
  177. package/dist/request/ErrorHandlerChain.js +17 -14
  178. package/dist/request/ErrorHandlerChain.js.map +1 -1
  179. package/dist/request/RequestFilterChain.js +16 -13
  180. package/dist/request/RequestFilterChain.js.map +1 -1
  181. package/dist/request/ResponseParserChain.js +17 -14
  182. package/dist/request/ResponseParserChain.js.map +1 -1
  183. package/dist/request/disivion/DateSerializer.js +47 -22
  184. package/dist/request/disivion/DateSerializer.js.map +1 -1
  185. package/dist/request/disivion/DivisionErrorHandler.js +40 -25
  186. package/dist/request/disivion/DivisionErrorHandler.js.map +1 -1
  187. package/dist/request/disivion/DivisionResponseParser.js +16 -10
  188. package/dist/request/disivion/DivisionResponseParser.js.map +1 -1
  189. package/dist/request/disivion/index.js +305 -201
  190. package/dist/request/disivion/index.js.map +1 -1
  191. package/dist/request/error/BizExceptionResponseError.js +11 -5
  192. package/dist/request/error/BizExceptionResponseError.js.map +1 -1
  193. package/dist/request/error/ExceptionResponseError.js +11 -5
  194. package/dist/request/error/ExceptionResponseError.js.map +1 -1
  195. package/dist/request/error/ResponseError.js +9 -4
  196. package/dist/request/error/ResponseError.js.map +1 -1
  197. package/dist/request/error/SessionExceptionResponseError.js +11 -5
  198. package/dist/request/error/SessionExceptionResponseError.js.map +1 -1
  199. package/dist/request/index.js +11 -11
  200. package/dist/utils/DateUtil.js +48 -33
  201. package/dist/utils/DateUtil.js.map +1 -1
  202. package/dist/utils/NumberUtil.js +6 -6
  203. package/dist/utils/NumberUtil.js.map +1 -1
  204. package/dist/utils/cloneDeep.js +2 -2
  205. package/dist/utils/delay.js +3 -3
  206. package/dist/utils/delay.js.map +1 -1
  207. package/dist/utils/functions.js +3 -3
  208. package/dist/utils/index.js +12 -12
  209. package/dist/utils/md5.js +191 -93
  210. package/dist/utils/md5.js.map +1 -1
  211. package/dist/utils/uuid.js +35 -25
  212. package/dist/utils/uuid.js.map +1 -1
  213. package/dist/version/index.js +2 -2
  214. package/dist/version/version.d.ts +1 -1
  215. package/dist/version/version.js +2 -2
  216. package/dist/version/version.js.map +1 -1
  217. package/package.json +1 -1
  218. package/dist/components-J6-qau6Y.js +0 -73
  219. package/dist/components-J6-qau6Y.js.map +0 -1
@@ -1,93 +1,156 @@
1
1
  import "lodash-es";
2
- import { ref as h, watch as B, defineComponent as M, getCurrentInstance as D, inject as H, nextTick as K, onBeforeUnmount as Pe, openBlock as ue, createElementBlock as fe, normalizeClass as de, unref as k, normalizeStyle as Ne, computed as F, onMounted as ve, onUpdated as Ee, createVNode as O, provide as we, renderSlot as L, useSlots as Te, reactive as Se, onUnmounted as xe, withDirectives as $e, vShow as Ce, createCommentVNode as Ie } from "vue";
3
- import { withInstall as Be } from "../_util/vue/install.js";
4
- import { ElIcon as J } from "element-plus";
5
- import { isNumber as ke, isUndefined as ze } from "../_util/types.js";
6
- import { e as Re } from "../../functions-DzLqXvGt.js";
7
- import { buildProps as be, definePropType as pe } from "../_util/vue/props/runtime.js";
8
- import { UPDATE_MODEL_EVENT as me } from "../_constants/event.js";
9
- import { useNamespace as V } from "../_hooks/use-namespace/index.js";
10
- import { useOrderedChildren as Ae } from "../_hooks/use-ordered-children/index.js";
11
- import { tabsRootContextKey as Q } from "./constants.js";
12
- import { t as he, r as ye, i as Oe, b as Le, n as Fe, c as Me, d as Ve, e as Z } from "../../index-C9tCD90X.js";
13
- import { capitalize as I } from "../_util/strings.js";
14
- import { throwError as q } from "../_util/error.js";
15
- import { e as Qe, f as Ue } from "../../index-C6P_0wAy.js";
16
- import { mutable as We } from "../_util/typescript.js";
17
- import { EVENT_CODE as je } from "../_constants/aria.js";
18
- import { tabBarProps as De } from "./tab-bar.js";
19
- import { tabPaneProps as He } from "./tab-pane.js";
20
- function ge(e) {
21
- var t;
22
- const a = ye(e);
23
- return (t = a == null ? void 0 : a.$el) != null ? t : a;
2
+ import { ref, watch, defineComponent, getCurrentInstance, inject, nextTick, onBeforeUnmount, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, computed, onMounted, onUpdated, createVNode, provide, renderSlot, useSlots, reactive, onUnmounted, withDirectives, vShow, createCommentVNode } from "vue";
3
+ import { withInstall } from "../_util/vue/install.js";
4
+ import { ElIcon } from "element-plus";
5
+ import { isNumber, isUndefined } from "../_util/types.js";
6
+ import { e as isString$1 } from "../../functions-BeMkokbY.js";
7
+ import { buildProps, definePropType } from "../_util/vue/props/runtime.js";
8
+ import { UPDATE_MODEL_EVENT } from "../_constants/event.js";
9
+ import { useNamespace } from "../_hooks/use-namespace/index.js";
10
+ import { useOrderedChildren } from "../_hooks/use-ordered-children/index.js";
11
+ import { tabsRootContextKey } from "./constants.js";
12
+ import { t as tryOnScopeDispose, r as resolveUnref, i as isClient, b as isString, n as noop, c as tryOnMounted, d as identity, e as computedEager } from "../../index-D1m0KTpK.js";
13
+ import { capitalize } from "../_util/strings.js";
14
+ import { throwError } from "../_util/error.js";
15
+ import { e as arrow_left_default, f as arrow_right_default } from "../../index-DkwIULcN.js";
16
+ import { mutable } from "../_util/typescript.js";
17
+ import { EVENT_CODE } from "../_constants/aria.js";
18
+ import { tabBarProps } from "./tab-bar.js";
19
+ import { tabPaneProps } from "./tab-pane.js";
20
+ function unrefElement(elRef) {
21
+ var _a;
22
+ const plain = resolveUnref(elRef);
23
+ return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
24
24
  }
25
- const G = Oe ? window : void 0, Ke = Oe ? window.document : void 0;
26
- function W(...e) {
27
- let t, a, s, n;
28
- if (Le(e[0]) || Array.isArray(e[0]) ? ([a, s, n] = e, t = G) : [t, a, s, n] = e, !t)
29
- return Fe;
30
- Array.isArray(a) || (a = [a]), Array.isArray(s) || (s = [s]);
31
- const P = [], d = () => {
32
- P.forEach((r) => r()), P.length = 0;
33
- }, u = (r, i, f, b) => (r.addEventListener(i, f, b), () => r.removeEventListener(i, f, b)), y = B(() => [ge(t), ye(n)], ([r, i]) => {
34
- d(), r && P.push(...a.flatMap((f) => s.map((b) => u(r, f, b, i))));
35
- }, { immediate: !0, flush: "post" }), v = () => {
36
- y(), d();
25
+ const defaultWindow = isClient ? window : void 0;
26
+ const defaultDocument = isClient ? window.document : void 0;
27
+ function useEventListener(...args) {
28
+ let target;
29
+ let events;
30
+ let listeners;
31
+ let options;
32
+ if (isString(args[0]) || Array.isArray(args[0])) {
33
+ [events, listeners, options] = args;
34
+ target = defaultWindow;
35
+ } else {
36
+ [target, events, listeners, options] = args;
37
+ }
38
+ if (!target)
39
+ return noop;
40
+ if (!Array.isArray(events))
41
+ events = [events];
42
+ if (!Array.isArray(listeners))
43
+ listeners = [listeners];
44
+ const cleanups = [];
45
+ const cleanup = () => {
46
+ cleanups.forEach((fn) => fn());
47
+ cleanups.length = 0;
48
+ };
49
+ const register = (el, event, listener, options2) => {
50
+ el.addEventListener(event, listener, options2);
51
+ return () => el.removeEventListener(event, listener, options2);
37
52
  };
38
- return he(v), v;
53
+ const stopWatch = watch(() => [unrefElement(target), resolveUnref(options)], ([el, options2]) => {
54
+ cleanup();
55
+ if (!el)
56
+ return;
57
+ cleanups.push(...events.flatMap((event) => {
58
+ return listeners.map((listener) => register(el, event, listener, options2));
59
+ }));
60
+ }, { immediate: true, flush: "post" });
61
+ const stop = () => {
62
+ stopWatch();
63
+ cleanup();
64
+ };
65
+ tryOnScopeDispose(stop);
66
+ return stop;
39
67
  }
40
- function qe(e, t = !1) {
41
- const a = h(), s = () => a.value = !!e();
42
- return s(), Me(s, t), a;
68
+ function useSupported(callback, sync = false) {
69
+ const isSupported = ref();
70
+ const update = () => isSupported.value = Boolean(callback());
71
+ update();
72
+ tryOnMounted(update, sync);
73
+ return isSupported;
43
74
  }
44
- const ee = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, te = "__vueuse_ssr_handlers__";
45
- ee[te] = ee[te] || {};
46
- function Ge({ document: e = Ke } = {}) {
47
- if (!e)
48
- return h("visible");
49
- const t = h(e.visibilityState);
50
- return W(e, "visibilitychange", () => {
51
- t.value = e.visibilityState;
52
- }), t;
75
+ const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
76
+ const globalKey = "__vueuse_ssr_handlers__";
77
+ _global[globalKey] = _global[globalKey] || {};
78
+ function useDocumentVisibility({ document = defaultDocument } = {}) {
79
+ if (!document)
80
+ return ref("visible");
81
+ const visibility = ref(document.visibilityState);
82
+ useEventListener(document, "visibilitychange", () => {
83
+ visibility.value = document.visibilityState;
84
+ });
85
+ return visibility;
53
86
  }
54
- var ae = Object.getOwnPropertySymbols, Xe = Object.prototype.hasOwnProperty, Ye = Object.prototype.propertyIsEnumerable, Je = (e, t) => {
55
- var a = {};
56
- for (var s in e)
57
- Xe.call(e, s) && t.indexOf(s) < 0 && (a[s] = e[s]);
58
- if (e != null && ae)
59
- for (var s of ae(e))
60
- t.indexOf(s) < 0 && Ye.call(e, s) && (a[s] = e[s]);
61
- return a;
87
+ var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
88
+ var __hasOwnProp$g = Object.prototype.hasOwnProperty;
89
+ var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
90
+ var __objRest$2 = (source, exclude) => {
91
+ var target = {};
92
+ for (var prop in source)
93
+ if (__hasOwnProp$g.call(source, prop) && exclude.indexOf(prop) < 0)
94
+ target[prop] = source[prop];
95
+ if (source != null && __getOwnPropSymbols$g)
96
+ for (var prop of __getOwnPropSymbols$g(source)) {
97
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$g.call(source, prop))
98
+ target[prop] = source[prop];
99
+ }
100
+ return target;
62
101
  };
63
- function j(e, t, a = {}) {
64
- const s = a, { window: n = G } = s, P = Je(s, ["window"]);
65
- let d;
66
- const u = qe(() => n && "ResizeObserver" in n), y = () => {
67
- d && (d.disconnect(), d = void 0);
68
- }, v = B(() => ge(e), (i) => {
69
- y(), u.value && n && i && (d = new ResizeObserver(t), d.observe(i, P));
70
- }, { immediate: !0, flush: "post" }), r = () => {
71
- y(), v();
102
+ function useResizeObserver(target, callback, options = {}) {
103
+ const _a = options, { window: window2 = defaultWindow } = _a, observerOptions = __objRest$2(_a, ["window"]);
104
+ let observer;
105
+ const isSupported = useSupported(() => window2 && "ResizeObserver" in window2);
106
+ const cleanup = () => {
107
+ if (observer) {
108
+ observer.disconnect();
109
+ observer = void 0;
110
+ }
72
111
  };
73
- return he(r), {
74
- isSupported: u,
75
- stop: r
112
+ const stopWatch = watch(() => unrefElement(target), (el) => {
113
+ cleanup();
114
+ if (isSupported.value && window2 && el) {
115
+ observer = new ResizeObserver(callback);
116
+ observer.observe(el, observerOptions);
117
+ }
118
+ }, { immediate: true, flush: "post" });
119
+ const stop = () => {
120
+ cleanup();
121
+ stopWatch();
122
+ };
123
+ tryOnScopeDispose(stop);
124
+ return {
125
+ isSupported,
126
+ stop
76
127
  };
77
128
  }
78
- var ne;
79
- (function(e) {
80
- e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
81
- })(ne || (ne = {}));
82
- var Ze = Object.defineProperty, se = Object.getOwnPropertySymbols, et = Object.prototype.hasOwnProperty, tt = Object.prototype.propertyIsEnumerable, oe = (e, t, a) => t in e ? Ze(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a, at = (e, t) => {
83
- for (var a in t || (t = {}))
84
- et.call(t, a) && oe(e, a, t[a]);
85
- if (se)
86
- for (var a of se(t))
87
- tt.call(t, a) && oe(e, a, t[a]);
88
- return e;
129
+ var SwipeDirection;
130
+ (function(SwipeDirection2) {
131
+ SwipeDirection2["UP"] = "UP";
132
+ SwipeDirection2["RIGHT"] = "RIGHT";
133
+ SwipeDirection2["DOWN"] = "DOWN";
134
+ SwipeDirection2["LEFT"] = "LEFT";
135
+ SwipeDirection2["NONE"] = "NONE";
136
+ })(SwipeDirection || (SwipeDirection = {}));
137
+ var __defProp = Object.defineProperty;
138
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
139
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
140
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
141
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
142
+ var __spreadValues = (a, b) => {
143
+ for (var prop in b || (b = {}))
144
+ if (__hasOwnProp.call(b, prop))
145
+ __defNormalProp(a, prop, b[prop]);
146
+ if (__getOwnPropSymbols)
147
+ for (var prop of __getOwnPropSymbols(b)) {
148
+ if (__propIsEnum.call(b, prop))
149
+ __defNormalProp(a, prop, b[prop]);
150
+ }
151
+ return a;
89
152
  };
90
- const nt = {
153
+ const _TransitionPresets = {
91
154
  easeInSine: [0.12, 0, 0.39, 0],
92
155
  easeOutSine: [0.61, 1, 0.88, 1],
93
156
  easeInOutSine: [0.37, 0, 0.63, 1],
@@ -113,80 +176,115 @@ const nt = {
113
176
  easeOutBack: [0.34, 1.56, 0.64, 1],
114
177
  easeInOutBack: [0.68, -0.6, 0.32, 1.6]
115
178
  };
116
- at({
117
- linear: Ve
118
- }, nt);
119
- function st({ window: e = G } = {}) {
120
- if (!e)
121
- return h(!1);
122
- const t = h(e.document.hasFocus());
123
- return W(e, "blur", () => {
124
- t.value = !1;
125
- }), W(e, "focus", () => {
126
- t.value = !0;
127
- }), t;
179
+ __spreadValues({
180
+ linear: identity
181
+ }, _TransitionPresets);
182
+ function useWindowFocus({ window: window2 = defaultWindow } = {}) {
183
+ if (!window2)
184
+ return ref(false);
185
+ const focused = ref(window2.document.hasFocus());
186
+ useEventListener(window2, "blur", () => {
187
+ focused.value = false;
188
+ });
189
+ useEventListener(window2, "focus", () => {
190
+ focused.value = true;
191
+ });
192
+ return focused;
128
193
  }
129
- const re = "OTabBar", ot = /* @__PURE__ */ M({
130
- name: re,
194
+ const COMPONENT_NAME$2 = "OTabBar";
195
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
196
+ ...{
197
+ name: COMPONENT_NAME$2
198
+ },
131
199
  __name: "tab-bar",
132
- props: De,
133
- setup(e, { expose: t }) {
134
- const a = e, s = D(), n = H(Q);
135
- n || q(re, "<o-tabs><o-tab-bar /></p-tabs>");
136
- const P = V("tabs"), d = h(), u = h(), y = () => {
137
- let b = 0, o = 0;
138
- const p = ["top", "bottom"].includes(n.props.tabPosition) ? "width" : "height", N = p === "width" ? "x" : "y", x = N === "x" ? "left" : "top";
139
- return a.tabs.every((C) => {
140
- var A, R;
141
- const $ = (R = (A = s.parent) == null ? void 0 : A.refs) == null ? void 0 : R[`tab-${C.uid}`];
142
- if (!$) return !1;
143
- if (!C.active)
144
- return !0;
145
- b = $[`offset${I(x)}`], o = $[`client${I(p)}`];
146
- const z = window.getComputedStyle($);
147
- return p === "width" && (o -= Number.parseFloat(z.paddingLeft) + Number.parseFloat(z.paddingRight), b += Number.parseFloat(z.paddingLeft)), !1;
148
- }), {
149
- [p]: `${o}px`,
150
- transform: `translate${I(N)}(${b}px)`
200
+ props: tabBarProps,
201
+ setup(__props, { expose: __expose }) {
202
+ const props = __props;
203
+ const instance = getCurrentInstance();
204
+ const rootTabs = inject(tabsRootContextKey);
205
+ if (!rootTabs) throwError(COMPONENT_NAME$2, "<o-tabs><o-tab-bar /></p-tabs>");
206
+ const ns = useNamespace("tabs");
207
+ const barRef = ref();
208
+ const barStyle = ref();
209
+ const getBarStyle = () => {
210
+ let offset = 0;
211
+ let tabSize = 0;
212
+ const sizeName = ["top", "bottom"].includes(rootTabs.props.tabPosition) ? "width" : "height";
213
+ const sizeDir = sizeName === "width" ? "x" : "y";
214
+ const position = sizeDir === "x" ? "left" : "top";
215
+ props.tabs.every((tab) => {
216
+ var _a, _b;
217
+ const $el = (_b = (_a = instance.parent) == null ? void 0 : _a.refs) == null ? void 0 : _b[`tab-${tab.uid}`];
218
+ if (!$el) return false;
219
+ if (!tab.active) {
220
+ return true;
221
+ }
222
+ offset = $el[`offset${capitalize(position)}`];
223
+ tabSize = $el[`client${capitalize(sizeName)}`];
224
+ const tabStyles = window.getComputedStyle($el);
225
+ if (sizeName === "width") {
226
+ tabSize -= Number.parseFloat(tabStyles.paddingLeft) + Number.parseFloat(tabStyles.paddingRight);
227
+ offset += Number.parseFloat(tabStyles.paddingLeft);
228
+ }
229
+ return false;
230
+ });
231
+ return {
232
+ [sizeName]: `${tabSize}px`,
233
+ transform: `translate${capitalize(sizeDir)}(${offset}px)`
151
234
  };
152
- }, v = () => u.value = y(), r = [], i = () => {
153
- var o;
154
- r.forEach((p) => p.stop()), r.length = 0;
155
- const b = (o = s.parent) == null ? void 0 : o.refs;
156
- if (b) {
157
- for (const p in b)
158
- if (p.startsWith("tab-")) {
159
- const N = b[p];
160
- N && r.push(j(N, v));
235
+ };
236
+ const update = () => barStyle.value = getBarStyle();
237
+ const saveObserver = [];
238
+ const observerTabs = () => {
239
+ var _a;
240
+ saveObserver.forEach((observer) => observer.stop());
241
+ saveObserver.length = 0;
242
+ const list = (_a = instance.parent) == null ? void 0 : _a.refs;
243
+ if (!list) return;
244
+ for (const key in list) {
245
+ if (key.startsWith("tab-")) {
246
+ const _el = list[key];
247
+ if (_el) {
248
+ saveObserver.push(useResizeObserver(_el, update));
161
249
  }
250
+ }
162
251
  }
163
252
  };
164
- B(
165
- () => a.tabs,
253
+ watch(
254
+ () => props.tabs,
166
255
  async () => {
167
- await K(), v(), i();
256
+ await nextTick();
257
+ update();
258
+ observerTabs();
168
259
  },
169
- { immediate: !0 }
260
+ { immediate: true }
170
261
  );
171
- const f = j(d, () => v());
172
- return Pe(() => {
173
- r.forEach((b) => b.stop()), r.length = 0, f.stop();
174
- }), t({
262
+ const barObserever = useResizeObserver(barRef, () => update());
263
+ onBeforeUnmount(() => {
264
+ saveObserver.forEach((observer) => observer.stop());
265
+ saveObserver.length = 0;
266
+ barObserever.stop();
267
+ });
268
+ __expose({
175
269
  /** @description tab root html element */
176
- ref: d,
270
+ ref: barRef,
177
271
  /** @description method to manually update tab bar style */
178
- update: v
179
- }), (b, o) => (ue(), fe("div", {
180
- ref_key: "barRef",
181
- ref: d,
182
- class: de([k(P).e("active-bar"), k(P).is(k(n).props.tabPosition)]),
183
- style: Ne(u.value)
184
- }, null, 6));
272
+ update
273
+ });
274
+ return (_ctx, _cache) => {
275
+ return openBlock(), createElementBlock("div", {
276
+ ref_key: "barRef",
277
+ ref: barRef,
278
+ class: normalizeClass([unref(ns).e("active-bar"), unref(ns).is(unref(rootTabs).props.tabPosition)]),
279
+ style: normalizeStyle(barStyle.value)
280
+ }, null, 6);
281
+ };
185
282
  }
186
- }), rt = be({
283
+ });
284
+ const tabNavProps = buildProps({
187
285
  panes: {
188
- type: pe(Array),
189
- default: () => We([])
286
+ type: definePropType(Array),
287
+ default: () => mutable([])
190
288
  },
191
289
  currentName: {
192
290
  type: [String, Number],
@@ -198,122 +296,222 @@ const re = "OTabBar", ot = /* @__PURE__ */ M({
198
296
  default: "card"
199
297
  },
200
298
  stretch: Boolean
201
- }), it = {
202
- tabClick: (e, t, a) => a instanceof Event,
203
- tabRemove: (e, t) => t instanceof Event
204
- }, ie = "OTabNav", lt = /* @__PURE__ */ M({
205
- name: ie,
206
- props: rt,
207
- emits: it,
208
- setup(e, {
209
- expose: t,
210
- emit: a
299
+ });
300
+ const tabNavEmits = {
301
+ tabClick: (tab, tabName, ev) => ev instanceof Event,
302
+ tabRemove: (tab, ev) => ev instanceof Event
303
+ };
304
+ const COMPONENT_NAME$1 = "OTabNav";
305
+ const TabNav = /* @__PURE__ */ defineComponent({
306
+ name: COMPONENT_NAME$1,
307
+ props: tabNavProps,
308
+ emits: tabNavEmits,
309
+ setup(props, {
310
+ expose,
311
+ emit
211
312
  }) {
212
- const s = H(Q);
213
- s || q(ie, "<o-tabs><o-tab-nav /></o-tabs>");
214
- const n = V("tabs"), P = Ge(), d = st(), u = h(), y = h(), v = h(), r = h(), i = h(!1), f = h(0), b = h(!1), o = h(!0), p = F(() => ["top", "bottom"].includes(s.props.tabPosition) ? "width" : "height"), N = F(() => ({
215
- transform: `translate${p.value === "width" ? "X" : "Y"}(-${f.value}px)`
216
- })), x = () => {
217
- if (!u.value) return;
218
- const l = u.value[`offset${I(p.value)}`], m = f.value;
219
- if (!m) return;
220
- const c = m > l ? m - l : 0;
221
- f.value = c;
222
- }, C = () => {
223
- if (!u.value || !y.value) return;
224
- const l = y.value[`offset${I(p.value)}`], m = u.value[`offset${I(p.value)}`], c = f.value;
225
- if (l - c <= m) return;
226
- const w = l - c > m * 2 ? c + m : l - m;
227
- f.value = w;
228
- }, $ = async () => {
229
- const l = y.value;
230
- if (!i.value || !v.value || !u.value || !l) return;
231
- await K();
232
- const m = v.value.querySelector(".is-active");
233
- if (!m) return;
234
- const c = u.value, w = ["top", "bottom"].includes(s.props.tabPosition), E = m.getBoundingClientRect(), _ = c.getBoundingClientRect(), S = w ? l.offsetWidth - _.width : l.offsetHeight - _.height, T = f.value;
235
- let g = T;
236
- w ? (E.left < _.left && (g = T - (_.left - E.left)), E.right > _.right && (g = T + E.right - _.right)) : (E.top < _.top && (g = T - (_.top - E.top)), E.bottom > _.bottom && (g = T + (E.bottom - _.bottom))), g = Math.max(g, 0), f.value = Math.min(g, S);
237
- }, z = () => {
238
- var w;
239
- if (!y.value || !u.value) return;
240
- e.stretch && ((w = r.value) == null || w.update());
241
- const l = y.value[`offset${I(p.value)}`], m = u.value[`offset${I(p.value)}`], c = f.value;
242
- m < l ? (i.value = i.value || {}, i.value.prev = c, i.value.next = c + m < l, l - c < m && (f.value = l - m)) : (i.value = !1, c > 0 && (f.value = 0));
243
- }, A = (l) => {
244
- const m = l.code, {
245
- up: c,
246
- down: w,
247
- left: E,
248
- right: _
249
- } = je;
250
- if (![c, w, E, _].includes(m)) return;
251
- const S = Array.from(l.currentTarget.querySelectorAll("[role=tab]:not(.is-disabled)")), T = S.indexOf(l.target);
252
- let g;
253
- m === E || m === c ? T === 0 ? g = S.length - 1 : g = T - 1 : T < S.length - 1 ? g = T + 1 : g = 0, S[g].focus({
254
- preventScroll: !0
255
- }), S[g].click(), R();
256
- }, R = () => {
257
- o.value && (b.value = !0);
258
- }, U = () => b.value = !1;
259
- return B(P, (l) => {
260
- l === "hidden" ? o.value = !1 : l === "visible" && setTimeout(() => o.value = !0, 50);
261
- }), B(d, (l) => {
262
- l ? setTimeout(() => o.value = !0, 50) : o.value = !1;
263
- }), j(v, z), ve(() => setTimeout(() => $(), 0)), Ee(() => z()), t({
264
- scrollToActiveTab: $,
265
- removeFocus: U
266
- }), () => {
267
- const l = i.value ? [O("span", {
268
- class: [n.e("nav-prev"), n.is("disabled", !i.value.prev)],
269
- onClick: x
270
- }, [O(J, null, {
271
- default: () => [O(Qe, null, null)]
272
- })]), O("span", {
273
- class: [n.e("nav-next"), n.is("disabled", !i.value.next)],
274
- onClick: C
275
- }, [O(J, null, {
276
- default: () => [O(Ue, null, null)]
277
- })])] : null, m = e.panes.map((c, w) => {
278
- var X, Y;
279
- const E = c.uid, _ = c.props.disabled, S = c.props.name ?? c.index ?? `${w}`;
280
- c.index = `${w}`;
281
- const T = ((Y = (X = c.slots).label) == null ? void 0 : Y.call(X)) || c.props.label, g = !_ && c.active ? 0 : -1;
282
- return O("div", {
283
- ref: `tab-${E}`,
284
- class: [n.e("item"), n.is(s.props.tabPosition), n.is("active", c.active), n.is("disabled", _), n.is("focus", b.value)],
285
- id: `tab-${S}`,
286
- key: `tab-${E}`,
287
- "aria-controls": `pane-${S}`,
288
- role: "tab",
289
- "aria-selected": c.active,
290
- tabindex: g,
291
- onFocus: () => R(),
292
- onBlur: () => U(),
293
- onClick: (_e) => {
294
- U(), a("tabClick", c, S, _e);
313
+ const rootTabs = inject(tabsRootContextKey);
314
+ if (!rootTabs) throwError(COMPONENT_NAME$1, `<o-tabs><o-tab-nav /></o-tabs>`);
315
+ const ns = useNamespace("tabs");
316
+ const visibility = useDocumentVisibility();
317
+ const focused = useWindowFocus();
318
+ const navScroll$ = ref();
319
+ const nav$ = ref();
320
+ const el$ = ref();
321
+ const tabBarRef = ref();
322
+ const scrollable = ref(false);
323
+ const navOffset = ref(0);
324
+ const isFocus = ref(false);
325
+ const focusable = ref(true);
326
+ const sizeName = computed(() => ["top", "bottom"].includes(rootTabs.props.tabPosition) ? "width" : "height");
327
+ const navStyle = computed(() => {
328
+ const dir = sizeName.value === "width" ? "X" : "Y";
329
+ return {
330
+ transform: `translate${dir}(-${navOffset.value}px)`
331
+ };
332
+ });
333
+ const scrollPrev = () => {
334
+ if (!navScroll$.value) return;
335
+ const containerSize = navScroll$.value[`offset${capitalize(sizeName.value)}`];
336
+ const currentOffset = navOffset.value;
337
+ if (!currentOffset) return;
338
+ const newOffset = currentOffset > containerSize ? currentOffset - containerSize : 0;
339
+ navOffset.value = newOffset;
340
+ };
341
+ const scrollNext = () => {
342
+ if (!navScroll$.value || !nav$.value) return;
343
+ const navSize = nav$.value[`offset${capitalize(sizeName.value)}`];
344
+ const containerSize = navScroll$.value[`offset${capitalize(sizeName.value)}`];
345
+ const currentOffset = navOffset.value;
346
+ if (navSize - currentOffset <= containerSize) return;
347
+ const newOffset = navSize - currentOffset > containerSize * 2 ? currentOffset + containerSize : navSize - containerSize;
348
+ navOffset.value = newOffset;
349
+ };
350
+ const scrollToActiveTab = async () => {
351
+ const nav = nav$.value;
352
+ if (!scrollable.value || !el$.value || !navScroll$.value || !nav) return;
353
+ await nextTick();
354
+ const activeTab = el$.value.querySelector(".is-active");
355
+ if (!activeTab) return;
356
+ const navScroll = navScroll$.value;
357
+ const isHorizontal = ["top", "bottom"].includes(rootTabs.props.tabPosition);
358
+ const activeTabBounding = activeTab.getBoundingClientRect();
359
+ const navScrollBounding = navScroll.getBoundingClientRect();
360
+ const maxOffset = isHorizontal ? nav.offsetWidth - navScrollBounding.width : nav.offsetHeight - navScrollBounding.height;
361
+ const currentOffset = navOffset.value;
362
+ let newOffset = currentOffset;
363
+ if (isHorizontal) {
364
+ if (activeTabBounding.left < navScrollBounding.left) {
365
+ newOffset = currentOffset - (navScrollBounding.left - activeTabBounding.left);
366
+ }
367
+ if (activeTabBounding.right > navScrollBounding.right) {
368
+ newOffset = currentOffset + activeTabBounding.right - navScrollBounding.right;
369
+ }
370
+ } else {
371
+ if (activeTabBounding.top < navScrollBounding.top) {
372
+ newOffset = currentOffset - (navScrollBounding.top - activeTabBounding.top);
373
+ }
374
+ if (activeTabBounding.bottom > navScrollBounding.bottom) {
375
+ newOffset = currentOffset + (activeTabBounding.bottom - navScrollBounding.bottom);
376
+ }
377
+ }
378
+ newOffset = Math.max(newOffset, 0);
379
+ navOffset.value = Math.min(newOffset, maxOffset);
380
+ };
381
+ const update = () => {
382
+ var _a;
383
+ if (!nav$.value || !navScroll$.value) return;
384
+ props.stretch && ((_a = tabBarRef.value) == null ? void 0 : _a.update());
385
+ const navSize = nav$.value[`offset${capitalize(sizeName.value)}`];
386
+ const containerSize = navScroll$.value[`offset${capitalize(sizeName.value)}`];
387
+ const currentOffset = navOffset.value;
388
+ if (containerSize < navSize) {
389
+ scrollable.value = scrollable.value || {};
390
+ scrollable.value.prev = currentOffset;
391
+ scrollable.value.next = currentOffset + containerSize < navSize;
392
+ if (navSize - currentOffset < containerSize) {
393
+ navOffset.value = navSize - containerSize;
394
+ }
395
+ } else {
396
+ scrollable.value = false;
397
+ if (currentOffset > 0) {
398
+ navOffset.value = 0;
399
+ }
400
+ }
401
+ };
402
+ const changeTab = (e) => {
403
+ const code = e.code;
404
+ const {
405
+ up,
406
+ down,
407
+ left,
408
+ right
409
+ } = EVENT_CODE;
410
+ if (![up, down, left, right].includes(code)) return;
411
+ const tabList = Array.from(e.currentTarget.querySelectorAll("[role=tab]:not(.is-disabled)"));
412
+ const currentIndex = tabList.indexOf(e.target);
413
+ let nextIndex;
414
+ if (code === left || code === up) {
415
+ if (currentIndex === 0) {
416
+ nextIndex = tabList.length - 1;
417
+ } else {
418
+ nextIndex = currentIndex - 1;
419
+ }
420
+ } else {
421
+ if (currentIndex < tabList.length - 1) {
422
+ nextIndex = currentIndex + 1;
423
+ } else {
424
+ nextIndex = 0;
425
+ }
426
+ }
427
+ tabList[nextIndex].focus({
428
+ preventScroll: true
429
+ });
430
+ tabList[nextIndex].click();
431
+ setFocus();
432
+ };
433
+ const setFocus = () => {
434
+ if (focusable.value) isFocus.value = true;
435
+ };
436
+ const removeFocus = () => isFocus.value = false;
437
+ watch(visibility, (visibility2) => {
438
+ if (visibility2 === "hidden") {
439
+ focusable.value = false;
440
+ } else if (visibility2 === "visible") {
441
+ setTimeout(() => focusable.value = true, 50);
442
+ }
443
+ });
444
+ watch(focused, (focused2) => {
445
+ if (focused2) {
446
+ setTimeout(() => focusable.value = true, 50);
447
+ } else {
448
+ focusable.value = false;
449
+ }
450
+ });
451
+ useResizeObserver(el$, update);
452
+ onMounted(() => setTimeout(() => scrollToActiveTab(), 0));
453
+ onUpdated(() => update());
454
+ expose({
455
+ scrollToActiveTab,
456
+ removeFocus
457
+ });
458
+ return () => {
459
+ const scrollBtn = scrollable.value ? [createVNode("span", {
460
+ "class": [ns.e("nav-prev"), ns.is("disabled", !scrollable.value.prev)],
461
+ "onClick": scrollPrev
462
+ }, [createVNode(ElIcon, null, {
463
+ default: () => [createVNode(arrow_left_default, null, null)]
464
+ })]), createVNode("span", {
465
+ "class": [ns.e("nav-next"), ns.is("disabled", !scrollable.value.next)],
466
+ "onClick": scrollNext
467
+ }, [createVNode(ElIcon, null, {
468
+ default: () => [createVNode(arrow_right_default, null, null)]
469
+ })])] : null;
470
+ const tabs = props.panes.map((pane, index2) => {
471
+ var _a, _b;
472
+ const uid = pane.uid;
473
+ const disabled = pane.props.disabled;
474
+ const tabName = pane.props.name ?? pane.index ?? `${index2}`;
475
+ pane.index = `${index2}`;
476
+ const tabLabelContent = ((_b = (_a = pane.slots).label) == null ? void 0 : _b.call(_a)) || pane.props.label;
477
+ const tabindex = !disabled && pane.active ? 0 : -1;
478
+ return createVNode("div", {
479
+ "ref": `tab-${uid}`,
480
+ "class": [ns.e("item"), ns.is(rootTabs.props.tabPosition), ns.is("active", pane.active), ns.is("disabled", disabled), ns.is("focus", isFocus.value)],
481
+ "id": `tab-${tabName}`,
482
+ "key": `tab-${uid}`,
483
+ "aria-controls": `pane-${tabName}`,
484
+ "role": "tab",
485
+ "aria-selected": pane.active,
486
+ "tabindex": tabindex,
487
+ "onFocus": () => setFocus(),
488
+ "onBlur": () => removeFocus(),
489
+ "onClick": (ev) => {
490
+ removeFocus();
491
+ emit("tabClick", pane, tabName, ev);
295
492
  }
296
- }, [T]);
493
+ }, [...[tabLabelContent]]);
297
494
  });
298
- return O("div", {
299
- ref: v,
300
- class: [n.e("nav-wrap"), n.is("scrollable", !!i.value), n.is(s.props.tabPosition)]
301
- }, [l, O("div", {
302
- class: n.e("nav-scroll"),
303
- ref: u
304
- }, [O("div", {
305
- class: [n.e("nav"), n.is(s.props.tabPosition), n.is("stretch", e.stretch && ["top", "bottom"].includes(s.props.tabPosition))],
306
- ref: y,
307
- style: N.value,
308
- role: "tablist",
309
- onKeydown: A
310
- }, [e.type ? null : O(ot, {
311
- ref: r,
312
- tabs: [...e.panes]
313
- }, null), m])])]);
495
+ return createVNode("div", {
496
+ "ref": el$,
497
+ "class": [ns.e("nav-wrap"), ns.is("scrollable", !!scrollable.value), ns.is(rootTabs.props.tabPosition)]
498
+ }, [scrollBtn, createVNode("div", {
499
+ "class": ns.e("nav-scroll"),
500
+ "ref": navScroll$
501
+ }, [createVNode("div", {
502
+ "class": [ns.e("nav"), ns.is(rootTabs.props.tabPosition), ns.is("stretch", props.stretch && ["top", "bottom"].includes(rootTabs.props.tabPosition))],
503
+ "ref": nav$,
504
+ "style": navStyle.value,
505
+ "role": "tablist",
506
+ "onKeydown": changeTab
507
+ }, [...[!props.type ? createVNode(_sfc_main$1, {
508
+ "ref": tabBarRef,
509
+ "tabs": [...props.panes]
510
+ }, null) : null, tabs]])])]);
314
511
  };
315
512
  }
316
- }), ct = be({
513
+ });
514
+ const tabsProps = buildProps({
317
515
  /**
318
516
  * @description type of Tab
319
517
  */
@@ -340,136 +538,183 @@ const re = "OTabBar", ot = /* @__PURE__ */ M({
340
538
  * @description hook function before switching tab. If `false` is returned or a `Promise` is returned and then is rejected, switching will be prevented
341
539
  */
342
540
  beforeLeave: {
343
- type: pe(Function),
344
- default: () => !0
541
+ type: definePropType(Function),
542
+ default: () => true
345
543
  },
346
544
  /**
347
545
  * @description whether width of tab automatically fits its container
348
546
  */
349
547
  stretch: Boolean
350
- }), le = (e) => Re(e) || ke(e), ut = {
351
- [me]: (e) => le(e),
352
- tabClick: (e, t) => t instanceof Event,
353
- tabChange: (e) => le(e)
354
- }, ft = /* @__PURE__ */ M({
548
+ });
549
+ const isPaneName = (value) => isString$1(value) || isNumber(value);
550
+ const tabsEmits = {
551
+ [UPDATE_MODEL_EVENT]: (name) => isPaneName(name),
552
+ tabClick: (pane, ev) => ev instanceof Event,
553
+ tabChange: (name) => isPaneName(name)
554
+ };
555
+ const Tabs = /* @__PURE__ */ defineComponent({
355
556
  name: "OTabs",
356
- props: ct,
357
- emits: ut,
358
- setup(e, {
359
- emit: t,
360
- slots: a,
361
- expose: s
557
+ props: tabsProps,
558
+ emits: tabsEmits,
559
+ setup(props, {
560
+ emit,
561
+ slots,
562
+ expose
362
563
  }) {
363
- const n = V("tabs"), P = F(() => ["left", "right"].includes(e.tabPosition)), {
364
- children: d,
365
- addChild: u,
366
- removeChild: y
367
- } = Ae(D(), "OTabPane"), v = h(), r = h(e.modelValue ?? "0"), i = async (o, p = !1) => {
368
- var N, x, C;
369
- if (!(r.value === o || ze(o)))
370
- try {
371
- await ((N = e.beforeLeave) == null ? void 0 : N.call(e, o, r.value)) !== !1 && (r.value = o, p && (t(me, o), t("tabChange", o)), (C = (x = v.value) == null ? void 0 : x.removeFocus) == null || C.call(x));
372
- } catch {
564
+ const ns = useNamespace("tabs");
565
+ const isVertical = computed(() => ["left", "right"].includes(props.tabPosition));
566
+ const {
567
+ children: panes,
568
+ addChild: sortPane,
569
+ removeChild: unregisterPane
570
+ } = useOrderedChildren(getCurrentInstance(), "OTabPane");
571
+ const nav$ = ref();
572
+ const currentName = ref(props.modelValue ?? "0");
573
+ const setCurrentName = async (value, trigger = false) => {
574
+ var _a, _b, _c;
575
+ if (currentName.value === value || isUndefined(value)) return;
576
+ try {
577
+ const canLeave = await ((_a = props.beforeLeave) == null ? void 0 : _a.call(props, value, currentName.value));
578
+ if (canLeave !== false) {
579
+ currentName.value = value;
580
+ if (trigger) {
581
+ emit(UPDATE_MODEL_EVENT, value);
582
+ emit("tabChange", value);
583
+ }
584
+ (_c = (_b = nav$.value) == null ? void 0 : _b.removeFocus) == null ? void 0 : _c.call(_b);
373
585
  }
374
- }, f = (o, p, N) => {
375
- o.props.disabled || (i(p, !0), t("tabClick", o, N));
586
+ } catch {
587
+ }
376
588
  };
377
- B(() => e.modelValue, (o) => i(o)), B(r, async () => {
378
- var o;
379
- await K(), (o = v.value) == null || o.scrollToActiveTab();
380
- }), we(Q, {
381
- props: e,
382
- currentName: r,
383
- registerPane: (o) => {
384
- d.value.push(o);
589
+ const handleTabClick = (tab, tabName, event) => {
590
+ if (tab.props.disabled) return;
591
+ setCurrentName(tabName, true);
592
+ emit("tabClick", tab, event);
593
+ };
594
+ watch(() => props.modelValue, (modelValue) => setCurrentName(modelValue));
595
+ watch(currentName, async () => {
596
+ var _a;
597
+ await nextTick();
598
+ (_a = nav$.value) == null ? void 0 : _a.scrollToActiveTab();
599
+ });
600
+ provide(tabsRootContextKey, {
601
+ props,
602
+ currentName,
603
+ registerPane: (pane) => {
604
+ panes.value.push(pane);
385
605
  },
386
- sortPane: u,
387
- unregisterPane: y
388
- }), s({
389
- currentName: r
606
+ sortPane,
607
+ unregisterPane
608
+ });
609
+ expose({
610
+ currentName
390
611
  });
391
- const b = ({
392
- render: o
393
- }) => o();
612
+ const TabNavRenderer = ({
613
+ render
614
+ }) => {
615
+ return render();
616
+ };
394
617
  return () => {
395
- const o = a["left-extra"], p = a["right-extra"], N = O("div", {
396
- class: [n.e("header"), P.value && n.e("header-vertical"), n.is(e.tabPosition)]
397
- }, [o && O("div", {
398
- class: n.e("extra-content-left")
399
- }, [L(a, "left-extra")]), O(b, {
400
- render: () => {
401
- const C = d.value.some(($) => $.slots.label);
402
- return O(lt, {
403
- ref: v,
404
- currentName: r.value,
405
- type: e.type,
406
- panes: d.value,
407
- stretch: e.stretch,
408
- onTabClick: f
618
+ const leftExtra = slots["left-extra"];
619
+ const rightExtra = slots["right-extra"];
620
+ const header = createVNode("div", {
621
+ "class": [ns.e("header"), isVertical.value && ns.e("header-vertical"), ns.is(props.tabPosition)]
622
+ }, [leftExtra && createVNode("div", {
623
+ "class": ns.e("extra-content-left")
624
+ }, [renderSlot(slots, "left-extra")]), createVNode(TabNavRenderer, {
625
+ "render": () => {
626
+ const hasLabelSlot = panes.value.some((pane) => pane.slots.label);
627
+ return createVNode(TabNav, {
628
+ ref: nav$,
629
+ currentName: currentName.value,
630
+ type: props.type,
631
+ panes: panes.value,
632
+ stretch: props.stretch,
633
+ onTabClick: handleTabClick
409
634
  }, {
410
- $stable: !C
635
+ $stable: !hasLabelSlot
411
636
  });
412
637
  }
413
- }, null), p && O("div", {
414
- class: n.e("extra-content-right")
415
- }, [L(a, "right-extra")])]), x = O("div", {
416
- class: n.e("content")
417
- }, [L(a, "default")]);
418
- return O("div", {
419
- class: [n.b(), n.m(e.tabPosition), {
420
- [n.m("card")]: e.type === "card",
421
- [n.m("border-card")]: e.type === "border-card"
638
+ }, null), rightExtra && createVNode("div", {
639
+ "class": ns.e("extra-content-right")
640
+ }, [renderSlot(slots, "right-extra")])]);
641
+ const panels = createVNode("div", {
642
+ "class": ns.e("content")
643
+ }, [renderSlot(slots, "default")]);
644
+ return createVNode("div", {
645
+ "class": [ns.b(), ns.m(props.tabPosition), {
646
+ [ns.m("card")]: props.type === "card",
647
+ [ns.m("border-card")]: props.type === "border-card"
422
648
  }]
423
- }, [x, N]);
649
+ }, [panels, header]);
424
650
  };
425
651
  }
426
- }), dt = ["id", "aria-hidden", "aria-labelledby"], ce = "OTabPane", vt = /* @__PURE__ */ M({
427
- name: ce,
652
+ });
653
+ const _hoisted_1 = ["id", "aria-hidden", "aria-labelledby"];
654
+ const COMPONENT_NAME = "OTabPane";
655
+ const _sfc_main = /* @__PURE__ */ defineComponent({
656
+ ...{
657
+ name: COMPONENT_NAME
658
+ },
428
659
  __name: "tab-pane",
429
- props: He,
430
- setup(e) {
431
- const t = e, a = D(), s = Te(), n = H(Q);
432
- n || q(ce, "usage: <o-tabs><o-tab-pane /></o-tabs/>");
433
- const P = V("tab-pane"), d = h(), u = Z(() => n.currentName.value === (t.name ?? d.value)), y = h(u.value), v = F(() => t.name ?? d.value), r = Z(() => !t.lazy || y.value || u.value);
434
- B(u, (f) => {
435
- f && (y.value = !0);
660
+ props: tabPaneProps,
661
+ setup(__props) {
662
+ const props = __props;
663
+ const instance = getCurrentInstance();
664
+ const slots = useSlots();
665
+ const tabsRoot = inject(tabsRootContextKey);
666
+ if (!tabsRoot) throwError(COMPONENT_NAME, "usage: <o-tabs><o-tab-pane /></o-tabs/>");
667
+ const ns = useNamespace("tab-pane");
668
+ const index2 = ref();
669
+ const active = computedEager(() => tabsRoot.currentName.value === (props.name ?? index2.value));
670
+ const loaded = ref(active.value);
671
+ const paneName = computed(() => props.name ?? index2.value);
672
+ const shouldBeRender = computedEager(() => !props.lazy || loaded.value || active.value);
673
+ watch(active, (val) => {
674
+ if (val) loaded.value = true;
675
+ });
676
+ const pane = reactive({
677
+ uid: instance.uid,
678
+ slots,
679
+ props,
680
+ paneName,
681
+ active,
682
+ index: index2
436
683
  });
437
- const i = Se({
438
- uid: a.uid,
439
- slots: s,
440
- props: t,
441
- paneName: v,
442
- active: u,
443
- index: d
684
+ tabsRoot.registerPane(pane);
685
+ onMounted(() => {
686
+ tabsRoot.sortPane(pane);
444
687
  });
445
- return n.registerPane(i), ve(() => {
446
- n.sortPane(i);
447
- }), xe(() => {
448
- n.unregisterPane(i.uid);
449
- }), (f, b) => k(r) ? $e((ue(), fe("div", {
450
- key: 0,
451
- id: `pane-${v.value}`,
452
- class: de(k(P).b()),
453
- role: "tabpanel",
454
- "aria-hidden": !k(u),
455
- "aria-labelledby": `tab-${v.value}`
456
- }, [
457
- L(f.$slots, "default")
458
- ], 10, dt)), [
459
- [Ce, k(u)]
460
- ]) : Ie("", !0);
688
+ onUnmounted(() => {
689
+ tabsRoot.unregisterPane(pane.uid);
690
+ });
691
+ return (_ctx, _cache) => {
692
+ return unref(shouldBeRender) ? withDirectives((openBlock(), createElementBlock("div", {
693
+ key: 0,
694
+ id: `pane-${paneName.value}`,
695
+ class: normalizeClass(unref(ns).b()),
696
+ role: "tabpanel",
697
+ "aria-hidden": !unref(active),
698
+ "aria-labelledby": `tab-${paneName.value}`
699
+ }, [
700
+ renderSlot(_ctx.$slots, "default")
701
+ ], 10, _hoisted_1)), [
702
+ [vShow, unref(active)]
703
+ ]) : createCommentVNode("", true);
704
+ };
461
705
  }
462
- }), kt = Be(ft, {
463
- TabPane: vt
706
+ });
707
+ const index = withInstall(Tabs, {
708
+ TabPane: _sfc_main
464
709
  });
465
710
  export {
466
- kt as default,
467
- De as tabBarProps,
468
- it as tabNavEmits,
469
- rt as tabNavProps,
470
- He as tabPaneProps,
471
- ut as tabsEmits,
472
- ct as tabsProps,
473
- Q as tabsRootContextKey
711
+ index as default,
712
+ tabBarProps,
713
+ tabNavEmits,
714
+ tabNavProps,
715
+ tabPaneProps,
716
+ tabsEmits,
717
+ tabsProps,
718
+ tabsRootContextKey
474
719
  };
475
720
  //# sourceMappingURL=index.js.map