@nutui/nutui 4.0.11 → 4.0.12

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 (158) hide show
  1. package/dist/nutui.es.js +1 -1
  2. package/dist/nutui.js +2 -2
  3. package/dist/nutui.umd.js +1 -1
  4. package/dist/packages/_es/ActionSheet.js +111 -78
  5. package/dist/packages/_es/Address.js +375 -250
  6. package/dist/packages/_es/AddressList.js +354 -269
  7. package/dist/packages/_es/Animate.js +58 -41
  8. package/dist/packages/_es/Audio.js +197 -128
  9. package/dist/packages/_es/AudioOperate.js +71 -60
  10. package/dist/packages/_es/Avatar.js +89 -66
  11. package/dist/packages/_es/AvatarGroup.js +31 -23
  12. package/dist/packages/_es/Backtop.js +99 -59
  13. package/dist/packages/_es/Badge.js +47 -36
  14. package/dist/packages/_es/Barrage.js +147 -68
  15. package/dist/packages/_es/Button.js +66 -47
  16. package/dist/packages/_es/Calendar.js +157 -135
  17. package/dist/packages/_es/CalendarItem.js +6 -6
  18. package/dist/packages/_es/Card.js +56 -42
  19. package/dist/packages/_es/Cascader.js +474 -315
  20. package/dist/packages/_es/Category.js +39 -29
  21. package/dist/packages/_es/CategoryPane.js +83 -57
  22. package/dist/packages/_es/Cell.js +71 -56
  23. package/dist/packages/_es/CellGroup.js +27 -19
  24. package/dist/packages/_es/Checkbox.js +156 -109
  25. package/dist/packages/_es/CheckboxGroup.js +59 -38
  26. package/dist/packages/_es/CircleProgress.js +96 -67
  27. package/dist/packages/_es/Col.js +31 -23
  28. package/dist/packages/_es/Collapse.js +58 -33
  29. package/dist/packages/_es/CollapseItem.js +108 -78
  30. package/dist/packages/_es/Comment.js +279 -207
  31. package/dist/packages/_es/ConfigProvider.js +55 -37
  32. package/dist/packages/_es/Countdown.js +212 -100
  33. package/dist/packages/_es/Countup.js +445 -232
  34. package/dist/packages/_es/DatePicker.js +265 -162
  35. package/dist/packages/_es/Dialog.js +213 -161
  36. package/dist/packages/_es/Divider.js +57 -42
  37. package/dist/packages/_es/Drag.js +153 -70
  38. package/dist/packages/_es/Ecard.js +104 -64
  39. package/dist/packages/_es/Elevator.js +219 -143
  40. package/dist/packages/_es/Ellipsis.js +178 -95
  41. package/dist/packages/_es/Empty.js +39 -23
  42. package/dist/packages/_es/FixedNav.js +116 -93
  43. package/dist/packages/_es/Form.js +178 -107
  44. package/dist/packages/_es/FormItem.js +61 -48
  45. package/dist/packages/_es/Grid.js +6 -5
  46. package/dist/packages/_es/GridItem.js +84 -58
  47. package/dist/packages/_es/Image.js +130 -90
  48. package/dist/packages/_es/ImagePreview.js +412 -256
  49. package/dist/packages/_es/Indicator.js +34 -30
  50. package/dist/packages/_es/InfiniteLoading.js +136 -83
  51. package/dist/packages/_es/Input.js +264 -160
  52. package/dist/packages/_es/InputNumber.js +117 -81
  53. package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
  54. package/dist/packages/_es/Invoice.js +130 -104
  55. package/dist/packages/_es/Layout.js +4 -3
  56. package/dist/packages/_es/List.js +215 -117
  57. package/dist/packages/_es/Menu.js +150 -95
  58. package/dist/packages/_es/MenuItem.js +154 -109
  59. package/dist/packages/_es/Navbar.js +119 -103
  60. package/dist/packages/_es/Noticebar.js +312 -197
  61. package/dist/packages/_es/Notify.js +166 -110
  62. package/dist/packages/_es/NumberKeyboard.js +202 -127
  63. package/dist/packages/_es/Overlay.js +80 -52
  64. package/dist/packages/_es/Pagination.js +100 -70
  65. package/dist/packages/_es/Picker.js +437 -275
  66. package/dist/packages/_es/Popover.js +225 -122
  67. package/dist/packages/_es/Popup.js +4 -4
  68. package/dist/packages/_es/Price.js +82 -44
  69. package/dist/packages/_es/Progress.js +79 -63
  70. package/dist/packages/_es/PullRefresh.js +173 -95
  71. package/dist/packages/_es/Radio.js +4 -4
  72. package/dist/packages/_es/RadioGroup.js +3 -3
  73. package/dist/packages/_es/Range.js +347 -204
  74. package/dist/packages/_es/Rate.js +141 -92
  75. package/dist/packages/_es/Row.js +27 -21
  76. package/dist/packages/_es/Searchbar.js +174 -123
  77. package/dist/packages/_es/ShortPassword.js +93 -69
  78. package/dist/packages/_es/SideNavbar.js +80 -49
  79. package/dist/packages/_es/SideNavbarItem.js +32 -22
  80. package/dist/packages/_es/Signature.js +146 -83
  81. package/dist/packages/_es/Skeleton.js +130 -110
  82. package/dist/packages/_es/Sku.js +343 -250
  83. package/dist/packages/_es/Step.js +86 -59
  84. package/dist/packages/_es/Steps.js +31 -26
  85. package/dist/packages/_es/Sticky.js +4 -4
  86. package/dist/packages/_es/SubSideNavbar.js +74 -52
  87. package/dist/packages/_es/Swipe.js +155 -83
  88. package/dist/packages/_es/Swiper.js +311 -174
  89. package/dist/packages/_es/SwiperItem.js +44 -28
  90. package/dist/packages/_es/Switch.js +68 -55
  91. package/dist/packages/_es/TabPane.js +41 -30
  92. package/dist/packages/_es/Tabbar.js +52 -41
  93. package/dist/packages/_es/TabbarItem.js +82 -61
  94. package/dist/packages/_es/Table.js +165 -109
  95. package/dist/packages/_es/Tabs.js +388 -240
  96. package/dist/packages/_es/Tag.js +61 -44
  97. package/dist/packages/_es/Textarea.js +124 -80
  98. package/dist/packages/_es/TimeDetail.js +76 -49
  99. package/dist/packages/_es/TimePannel.js +48 -34
  100. package/dist/packages/_es/TimeSelect.js +68 -47
  101. package/dist/packages/_es/Toast.js +218 -144
  102. package/dist/packages/_es/Tour.js +192 -138
  103. package/dist/packages/_es/TrendArrow.js +77 -57
  104. package/dist/packages/_es/Uploader.js +359 -234
  105. package/dist/packages/_es/Video.js +316 -191
  106. package/dist/packages/_es/Watermark.js +117 -84
  107. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
  108. package/dist/packages/_es/common-b9a5e726.js +145 -0
  109. package/dist/packages/_es/component-81a4c1d0.js +145 -0
  110. package/dist/packages/_es/index-29892cda.js +33 -0
  111. package/dist/packages/_es/index-43c34ac6.js +30 -0
  112. package/dist/packages/_es/index-54d03fc1.js +8 -0
  113. package/dist/packages/_es/index-79c5dc33.js +10 -0
  114. package/dist/packages/_es/index-7a7385e4.js +67 -0
  115. package/dist/packages/_es/index-87422be8.js +942 -0
  116. package/dist/packages/_es/index-da0a7662.js +259 -0
  117. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
  120. package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
  121. package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
  122. package/dist/packages/_es/raf-729dad54.js +25 -0
  123. package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
  124. package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
  125. package/dist/packages/locale/lang/en-US.js +39 -36
  126. package/dist/packages/locale/lang/id-ID.js +39 -36
  127. package/dist/packages/locale/lang/index.js +44 -22
  128. package/dist/packages/locale/lang/zh-CN.js +38 -35
  129. package/dist/packages/locale/lang/zh-TW.js +38 -35
  130. package/dist/resolver/index.js +26 -1
  131. package/dist/resolver/index.mjs +17 -14
  132. package/dist/smartips/web-types.json +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/styles/themes/default.scss +48 -48
  135. package/dist/styles/themes/jdb.scss +48 -48
  136. package/dist/styles/themes/jddkh.scss +48 -48
  137. package/dist/styles/themes/jdt.scss +48 -48
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +3 -4
  140. package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
  141. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
  142. package/dist/packages/_es/common-d218746f.js +0 -116
  143. package/dist/packages/_es/component-234624bc.js +0 -89
  144. package/dist/packages/_es/index-14dfadc4.js +0 -561
  145. package/dist/packages/_es/index-192a3ef6.js +0 -29
  146. package/dist/packages/_es/index-360c5092.js +0 -210
  147. package/dist/packages/_es/index-496e6e05.js +0 -24
  148. package/dist/packages/_es/index-50eed3d9.js +0 -7
  149. package/dist/packages/_es/index-53ec2d4d.js +0 -34
  150. package/dist/packages/_es/index-fadb0974.js +0 -8
  151. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
  152. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
  153. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
  154. package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
  155. package/dist/packages/_es/pxCheck-38173291.js +0 -4
  156. package/dist/packages/_es/raf-a74f1a06.js +0 -16
  157. package/dist/packages/_es/renderIcon-47498b32.js +0 -5
  158. package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
@@ -1,107 +1,165 @@
1
- var de = Object.defineProperty;
2
- var q = Object.getOwnPropertySymbols;
3
- var me = Object.prototype.hasOwnProperty, ye = Object.prototype.propertyIsEnumerable;
4
- var H = (e, i, n) => i in e ? de(e, i, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[i] = n, P = (e, i) => {
5
- for (var n in i || (i = {}))
6
- me.call(i, n) && H(e, n, i[n]);
7
- if (q)
8
- for (var n of q(i))
9
- ye.call(i, n) && H(e, n, i[n]);
10
- return e;
11
- };
12
- var K = (e, i, n) => (H(e, typeof i != "symbol" ? i + "" : i, n), n);
13
- var j = (e, i, n) => new Promise((T, m) => {
14
- var r = (l) => {
15
- try {
16
- a(n.next(l));
17
- } catch (c) {
18
- m(c);
19
- }
20
- }, h = (l) => {
21
- try {
22
- a(n.throw(l));
23
- } catch (c) {
24
- m(c);
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
25
14
  }
26
- }, a = (l) => l.done ? T(l.value) : Promise.resolve(l.value).then(r, h);
27
- a((n = n.apply(e, i)).next());
28
- });
29
- import { c as pe, T as Q } from "./component-234624bc.js";
30
- import { ref as V, onMounted as le, reactive as he, provide as be, computed as S, watch as U, onActivated as ve, nextTick as ge, resolveComponent as X, openBlock as y, createElementBlock as p, normalizeClass as w, createBlock as Se, withCtx as Te, createElementVNode as N, normalizeStyle as b, renderSlot as D, Fragment as Z, renderList as _, createCommentVNode as M, createVNode as x, toDisplayString as ee } from "vue";
31
- import { p as ke } from "./pxCheck-38173291.js";
32
- import { u as we } from "./index-192a3ef6.js";
33
- import { r as Ve } from "./raf-a74f1a06.js";
34
- import { _ as te } from "./index.vue_vue_type_script_lang-f44c159d.js";
35
- import { JoySmile as Ce } from "@nutui/icons-vue";
36
- import { u as Ee } from "./index-53ec2d4d.js";
37
- import { _ as $e } from "./_plugin-vue_export-helper-dad06003.js";
15
+ return a;
16
+ };
17
+ var __publicField = (obj, key, value) => {
18
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
+ return value;
20
+ };
21
+ var __async = (__this, __arguments, generator) => {
22
+ return new Promise((resolve, reject) => {
23
+ var fulfilled = (value) => {
24
+ try {
25
+ step(generator.next(value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ };
30
+ var rejected = (value) => {
31
+ try {
32
+ step(generator.throw(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ };
37
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
+ step((generator = generator.apply(__this, __arguments)).next());
39
+ });
40
+ };
41
+ import { c as createComponent, T as TypeOfFun } from "./component-81a4c1d0.js";
42
+ import { ref, onMounted, reactive, provide, computed, watch, onActivated, nextTick, resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, createElementVNode, normalizeStyle, renderSlot, Fragment, renderList, createCommentVNode, createVNode, toDisplayString } from "vue";
43
+ import { p as pxCheck } from "./pxCheck-c6b9f6b7.js";
44
+ import { u as useRect } from "./index-29892cda.js";
45
+ import { r as requestAniFrame } from "./raf-729dad54.js";
46
+ import { _ as _sfc_main$1 } from "./index.vue_vue_type_script_lang-cc5c4086.js";
47
+ import { JoySmile } from "@nutui/icons-vue";
48
+ import { u as useTouch } from "./index-7a7385e4.js";
49
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
38
50
  import "../locale/lang";
39
- const ze = (e, i, n, T) => {
40
- const m = V(), r = V({ width: 0, height: 0 }), h = () => j(void 0, null, function* () {
41
- var u, k;
42
- if (n && n.getEnv() !== n.ENV_TYPE.WEB) {
43
- let s = yield T(m, n);
44
- r.value.width = s.width || 0, r.value.height = s.height || 0;
45
- } else
46
- r.value.width = ((u = m.value) == null ? void 0 : u.clientWidth) || 0, r.value.height = ((k = m.value) == null ? void 0 : k.clientHeight) || 0;
51
+ const useTabContentTouch = (props, tabMethods, taro, useTaroRect) => {
52
+ const tabsContentRef = ref();
53
+ const tabsContentRefRect = ref({ width: 0, height: 0 });
54
+ const initTaroWidth = () => __async(void 0, null, function* () {
55
+ var _a, _b;
56
+ if (taro && taro.getEnv() !== taro.ENV_TYPE.WEB) {
57
+ let rect = yield useTaroRect(tabsContentRef, taro);
58
+ tabsContentRefRect.value.width = rect.width || 0;
59
+ tabsContentRefRect.value.height = rect.height || 0;
60
+ } else {
61
+ tabsContentRefRect.value.width = ((_a = tabsContentRef.value) == null ? void 0 : _a.clientWidth) || 0;
62
+ tabsContentRefRect.value.height = ((_b = tabsContentRef.value) == null ? void 0 : _b.clientHeight) || 0;
63
+ }
47
64
  });
48
- le(() => {
65
+ onMounted(() => {
49
66
  setTimeout(() => {
50
- h();
67
+ initTaroWidth();
51
68
  }, 100);
52
69
  });
53
- const a = he({
70
+ const touchState = reactive({
54
71
  offset: 0,
55
- moving: !1
56
- }), l = Ee();
57
- let c = "";
58
- const v = (u, k) => {
59
- var R;
60
- let s = u;
61
- switch (e.direction == "horizontal" ? (c = u > 0 ? "right" : "left", s = Math.abs(s) / r.value.width * 100) : (c = k > 0 ? "bottom" : "top", s = k, s = Math.abs(s) / ((R = r.value) == null ? void 0 : R.height) * 100), s > 85 && (s = 85), c) {
72
+ moving: false
73
+ });
74
+ const touch = useTouch();
75
+ let position = "";
76
+ const setoffset = (deltaX, deltaY) => {
77
+ var _a;
78
+ let offset = deltaX;
79
+ if (props.direction == "horizontal") {
80
+ position = deltaX > 0 ? "right" : "left";
81
+ offset = Math.abs(offset) / tabsContentRefRect.value.width * 100;
82
+ } else {
83
+ position = deltaY > 0 ? "bottom" : "top";
84
+ offset = deltaY;
85
+ offset = Math.abs(offset) / ((_a = tabsContentRefRect.value) == null ? void 0 : _a.height) * 100;
86
+ }
87
+ if (offset > 85) {
88
+ offset = 85;
89
+ }
90
+ switch (position) {
62
91
  case "left":
63
92
  case "top":
64
- i.isEnd() && (s = 0, a.moving = !1);
93
+ if (tabMethods.isEnd()) {
94
+ offset = 0;
95
+ touchState.moving = false;
96
+ }
65
97
  break;
66
98
  case "right":
67
99
  case "bottom":
68
- s = -s, i.isBegin() && (s = 0, a.moving = !1);
100
+ offset = -offset;
101
+ if (tabMethods.isBegin()) {
102
+ offset = 0;
103
+ touchState.moving = false;
104
+ }
69
105
  break;
70
106
  }
71
- a.offset = s;
107
+ touchState.offset = offset;
72
108
  };
73
- return { touchMethods: {
74
- onTouchStart(u) {
75
- e.swipeable && l.start(u);
109
+ const touchMethods = {
110
+ onTouchStart(event) {
111
+ if (!props.swipeable)
112
+ return;
113
+ touch.start(event);
76
114
  },
77
- onTouchMove(u) {
78
- e.swipeable && (l.move(u), a.moving = !0, v(l.deltaX.value, l.deltaY.value), e.direction == "horizontal" && l.isHorizontal() && (u.preventDefault(), u.stopPropagation()), e.direction == "vertical" && l.isVertical() && (u.preventDefault(), u.stopPropagation()));
115
+ onTouchMove(event) {
116
+ if (!props.swipeable)
117
+ return;
118
+ touch.move(event);
119
+ touchState.moving = true;
120
+ setoffset(touch.deltaX.value, touch.deltaY.value);
121
+ if (props.direction == "horizontal" && touch.isHorizontal()) {
122
+ event.preventDefault();
123
+ event.stopPropagation();
124
+ }
125
+ if (props.direction == "vertical" && touch.isVertical()) {
126
+ event.preventDefault();
127
+ event.stopPropagation();
128
+ }
79
129
  },
80
130
  onTouchEnd() {
81
- if (a.moving)
82
- switch (a.moving = !1, c) {
131
+ if (touchState.moving) {
132
+ touchState.moving = false;
133
+ switch (position) {
83
134
  case "left":
84
135
  case "top":
85
- a.offset > 35 && i.next();
136
+ if (touchState.offset > 35) {
137
+ tabMethods.next();
138
+ }
86
139
  break;
87
140
  case "right":
88
141
  case "bottom":
89
- a.offset < -35 && i.prev();
142
+ if (touchState.offset < -35) {
143
+ tabMethods.prev();
144
+ }
90
145
  break;
91
146
  }
147
+ }
92
148
  }
93
- }, touchState: a, tabsContentRef: m };
149
+ };
150
+ return { touchMethods, touchState, tabsContentRef };
94
151
  };
95
- class Ke {
152
+ class Title {
96
153
  constructor() {
97
- K(this, "title", "");
98
- K(this, "titleSlot");
99
- K(this, "paneKey", "");
100
- K(this, "disabled", !1);
154
+ __publicField(this, "title", "");
155
+ __publicField(this, "titleSlot");
156
+ __publicField(this, "paneKey", "");
157
+ __publicField(this, "disabled", false);
101
158
  }
102
159
  }
103
- const { create: Re } = pe("tabs"), Be = Re({
104
- components: { [te.name]: te, JoySmile: Ce },
160
+ const { create } = createComponent("tabs");
161
+ const _sfc_main = create({
162
+ components: { [_sfc_main$1.name]: _sfc_main$1, JoySmile },
105
163
  props: {
106
164
  modelValue: {
107
165
  type: [String, Number],
@@ -127,19 +185,19 @@ const { create: Re } = pe("tabs"), Be = Re({
127
185
  },
128
186
  titleScroll: {
129
187
  type: Boolean,
130
- default: !1
188
+ default: false
131
189
  },
132
190
  ellipsis: {
133
191
  type: Boolean,
134
- default: !0
192
+ default: true
135
193
  },
136
194
  swipeable: {
137
195
  type: Boolean,
138
- default: !1
196
+ default: false
139
197
  },
140
198
  autoHeight: {
141
199
  type: Boolean,
142
- default: !1
200
+ default: false
143
201
  },
144
202
  background: {
145
203
  type: String,
@@ -155,7 +213,7 @@ const { create: Re } = pe("tabs"), Be = Re({
155
213
  },
156
214
  sticky: {
157
215
  type: Boolean,
158
- default: !1
216
+ default: false
159
217
  },
160
218
  top: {
161
219
  type: Number,
@@ -163,217 +221,307 @@ const { create: Re } = pe("tabs"), Be = Re({
163
221
  }
164
222
  },
165
223
  emits: ["update:modelValue", "click", "change"],
166
- setup(e, { emit: i, slots: n }) {
167
- const T = V(null);
168
- let m;
169
- be("tabsOpiton", {
170
- activeKey: S(() => e.modelValue || "0"),
171
- autoHeight: S(() => e.autoHeight),
172
- animatedTime: S(() => e.animatedTime)
224
+ setup(props, { emit, slots }) {
225
+ const container = ref(null);
226
+ let stickyFixed;
227
+ provide("tabsOpiton", {
228
+ activeKey: computed(() => props.modelValue || "0"),
229
+ autoHeight: computed(() => props.autoHeight),
230
+ animatedTime: computed(() => props.animatedTime)
173
231
  });
174
- const r = V([]), h = (t) => {
175
- t.forEach((o, f) => {
176
- var g, C, E, z, L, W, F, Y, G;
177
- let d = o.type;
178
- if (d = d.name || d, d == "nut-tab-pane") {
179
- let B = new Ke();
180
- if ((g = o.props) != null && g.title || (C = o.props) != null && C["pane-key"] || (E = o.props) != null && E.paneKey) {
181
- let J = Q((z = o.props) == null ? void 0 : z["pane-key"]), ce = J == "number" || J == "string" ? String((L = o.props) == null ? void 0 : L["pane-key"]) : null, O = Q((W = o.props) == null ? void 0 : W.paneKey), fe = O == "number" || O == "string" ? String((F = o.props) == null ? void 0 : F.paneKey) : null;
182
- B.title = (Y = o.props) == null ? void 0 : Y.title, B.paneKey = ce || fe || String(f), B.disabled = (G = o.props) == null ? void 0 : G.disabled;
232
+ const titles = ref([]);
233
+ const renderTitles = (vnodes) => {
234
+ vnodes.forEach((vnode, index) => {
235
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
236
+ let type = vnode.type;
237
+ type = type.name || type;
238
+ if (type == "nut-tab-pane") {
239
+ let title = new Title();
240
+ if (((_a = vnode.props) == null ? void 0 : _a.title) || ((_b = vnode.props) == null ? void 0 : _b["pane-key"]) || ((_c = vnode.props) == null ? void 0 : _c["paneKey"])) {
241
+ let paneKeyType = TypeOfFun((_d = vnode.props) == null ? void 0 : _d["pane-key"]);
242
+ let paneIndex = paneKeyType == "number" || paneKeyType == "string" ? String((_e = vnode.props) == null ? void 0 : _e["pane-key"]) : null;
243
+ let camelPaneKeyType = TypeOfFun((_f = vnode.props) == null ? void 0 : _f["paneKey"]);
244
+ let camelPaneIndex = camelPaneKeyType == "number" || camelPaneKeyType == "string" ? String((_g = vnode.props) == null ? void 0 : _g["paneKey"]) : null;
245
+ title.title = (_h = vnode.props) == null ? void 0 : _h.title;
246
+ title.paneKey = paneIndex || camelPaneIndex || String(index);
247
+ title.disabled = (_i = vnode.props) == null ? void 0 : _i.disabled;
183
248
  }
184
- r.value.push(B);
249
+ titles.value.push(title);
185
250
  } else {
186
- if (o.children == " ")
251
+ if (vnode.children == " ") {
187
252
  return;
188
- h(o.children);
253
+ }
254
+ renderTitles(vnode.children);
189
255
  }
190
256
  });
191
- }, a = V(e.modelValue || 0), l = (t) => {
192
- let o = r.value.findIndex((f) => f.paneKey == t);
193
- r.value.length == 0 || o == -1 || (a.value = o);
194
- }, c = S(() => e.titleScroll && e.direction === "vertical"), v = V(), I = V([]), u = (t) => {
195
- const o = v.value, f = I.value;
196
- if (!o || !f || !f[a.value])
257
+ };
258
+ const currentIndex = ref(props.modelValue || 0);
259
+ const findTabsIndex = (value) => {
260
+ let index = titles.value.findIndex((item) => item.paneKey == value);
261
+ if (titles.value.length == 0)
262
+ ;
263
+ else if (index == -1)
264
+ ;
265
+ else {
266
+ currentIndex.value = index;
267
+ }
268
+ };
269
+ const getScrollY = computed(() => {
270
+ return props.titleScroll && props.direction === "vertical";
271
+ });
272
+ const navRef = ref();
273
+ const titleRef = ref([]);
274
+ const scrollIntoView = (immediate) => {
275
+ const nav = navRef.value;
276
+ const _titles = titleRef.value;
277
+ if (!nav || !_titles || !_titles[currentIndex.value]) {
197
278
  return;
198
- const d = f[a.value];
199
- let g = 0;
200
- e.direction === "vertical" ? g = d.offsetTop - o.offsetTop + 10 - (o.offsetHeight - d.offsetHeight) / 2 : g = d.offsetLeft - (o.offsetWidth - d.offsetWidth) / 2, k(o, g, t ? 0 : 0.3, e.direction);
201
- }, k = (t, o, f, d) => {
202
- let g = 0;
203
- const C = d === "horizontal" ? t.scrollLeft : t.scrollTop, E = f === 0 ? 1 : Math.round(f * 1e3 / 16);
204
- function z() {
205
- d === "horizontal" ? t.scrollLeft += (o - C) / E : t.scrollTop += (o - C) / E, ++g < E && Ve(z);
206
279
  }
207
- z();
208
- }, s = (t = ((o) => (o = n.default) == null ? void 0 : o.call(n))()) => {
209
- r.value = [], t = t == null ? void 0 : t.filter((f) => typeof f.children != "string"), t && t.length && h(t), l(e.modelValue), ge(() => {
210
- u();
280
+ const title = _titles[currentIndex.value];
281
+ let to = 0;
282
+ if (props.direction === "vertical") {
283
+ const runTop = title.offsetTop - nav.offsetTop + 10;
284
+ to = runTop - (nav.offsetHeight - title.offsetHeight) / 2;
285
+ } else {
286
+ to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
287
+ }
288
+ scrollDirection(nav, to, immediate ? 0 : 0.3, props.direction);
289
+ };
290
+ const scrollDirection = (nav, to, duration, direction) => {
291
+ let count = 0;
292
+ const from = direction === "horizontal" ? nav.scrollLeft : nav.scrollTop;
293
+ const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
294
+ function animate() {
295
+ if (direction === "horizontal") {
296
+ nav.scrollLeft += (to - from) / frames;
297
+ } else {
298
+ nav.scrollTop += (to - from) / frames;
299
+ }
300
+ if (++count < frames) {
301
+ requestAniFrame(animate);
302
+ }
303
+ }
304
+ animate();
305
+ };
306
+ const init = (vnodes = ((_a) => (_a = slots.default) == null ? void 0 : _a.call(slots))()) => {
307
+ titles.value = [];
308
+ vnodes = vnodes == null ? void 0 : vnodes.filter((item) => typeof item.children !== "string");
309
+ if (vnodes && vnodes.length) {
310
+ renderTitles(vnodes);
311
+ }
312
+ findTabsIndex(props.modelValue);
313
+ nextTick(() => {
314
+ scrollIntoView();
211
315
  });
212
- }, R = (t) => {
213
- m = t.fixed;
214
316
  };
215
- U(
317
+ const onStickyScroll = (params) => {
318
+ stickyFixed = params.fixed;
319
+ };
320
+ watch(
216
321
  () => {
217
- var t;
218
- return (t = n.default) == null ? void 0 : t.call(n);
322
+ var _a;
323
+ return (_a = slots.default) == null ? void 0 : _a.call(slots);
219
324
  },
220
- (t) => {
221
- s(t);
325
+ (vnodes) => {
326
+ init(vnodes);
222
327
  }
223
328
  );
224
- const oe = () => window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
225
- U(
226
- () => e.modelValue,
227
- (t) => {
228
- if (l(t), u(), m) {
229
- let o = we(T.value).top + oe(), f = Math.ceil(o - e.top);
329
+ const getScrollTopRoot = () => {
330
+ return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
331
+ };
332
+ watch(
333
+ () => props.modelValue,
334
+ (value) => {
335
+ findTabsIndex(value);
336
+ scrollIntoView();
337
+ if (stickyFixed) {
338
+ let top = useRect(container.value).top + getScrollTopRoot();
339
+ let value2 = Math.ceil(top - props.top);
230
340
  window.scrollTo({
231
- top: f,
341
+ top: value2,
232
342
  behavior: "smooth"
233
343
  });
234
344
  }
235
345
  }
236
- ), le(s), ve(s);
237
- const $ = {
238
- isBegin: () => a.value == 0,
239
- isEnd: () => a.value == r.value.length - 1,
346
+ );
347
+ onMounted(init);
348
+ onActivated(init);
349
+ const tabMethods = {
350
+ isBegin: () => {
351
+ return currentIndex.value == 0;
352
+ },
353
+ isEnd: () => {
354
+ return currentIndex.value == titles.value.length - 1;
355
+ },
240
356
  next: () => {
241
- a.value += 1, $.updateValue(r.value[a.value]);
357
+ currentIndex.value += 1;
358
+ tabMethods.updateValue(titles.value[currentIndex.value]);
242
359
  },
243
360
  prev: () => {
244
- a.value -= 1, $.updateValue(r.value[a.value]);
361
+ currentIndex.value -= 1;
362
+ tabMethods.updateValue(titles.value[currentIndex.value]);
245
363
  },
246
- updateValue: (t) => {
247
- i("update:modelValue", t.paneKey), i("change", t);
364
+ updateValue: (item) => {
365
+ emit("update:modelValue", item.paneKey);
366
+ emit("change", item);
248
367
  },
249
- tabChange: (t, o) => {
250
- i("click", t), !(t.disabled || a.value == o) && (a.value = o, $.updateValue(t));
368
+ tabChange: (item, index) => {
369
+ emit("click", item);
370
+ if (item.disabled || currentIndex.value == index) {
371
+ return;
372
+ }
373
+ currentIndex.value = index;
374
+ tabMethods.updateValue(item);
251
375
  },
252
- setTabItemRef: (t, o) => {
253
- I.value[o] = t;
376
+ setTabItemRef: (el, index) => {
377
+ titleRef.value[index] = el;
378
+ }
379
+ };
380
+ const { tabsContentRef, touchState, touchMethods } = useTabContentTouch(props, tabMethods);
381
+ const contentStyle = computed(() => {
382
+ let offsetPercent = currentIndex.value * 100;
383
+ if (touchState.moving) {
384
+ offsetPercent += touchState.offset;
254
385
  }
255
- }, { tabsContentRef: ie, touchState: A, touchMethods: ne } = ze(e, $), ae = S(() => {
256
- let t = a.value * 100;
257
- A.moving && (t += A.offset);
258
- let o = {
259
- transform: e.direction == "horizontal" ? `translate3d(-${t}%, 0, 0)` : `translate3d( 0,-${t}%, 0)`,
260
- transitionDuration: A.moving ? void 0 : `${e.animatedTime}ms`
386
+ let style = {
387
+ transform: props.direction == "horizontal" ? `translate3d(-${offsetPercent}%, 0, 0)` : `translate3d( 0,-${offsetPercent}%, 0)`,
388
+ transitionDuration: touchState.moving ? void 0 : `${props.animatedTime}ms`
261
389
  };
262
- return e.animatedTime == 0 && (o = {}), o;
263
- }), se = S(() => ({
264
- background: e.background
265
- })), re = S(() => ({
266
- color: e.type == "smile" ? e.color : "",
267
- background: e.type == "line" ? e.color : ""
268
- })), ue = S(() => {
269
- if (!e.titleGutter)
390
+ if (props.animatedTime == 0) {
391
+ style = {};
392
+ }
393
+ return style;
394
+ });
395
+ const tabsNavStyle = computed(() => {
396
+ return {
397
+ background: props.background
398
+ };
399
+ });
400
+ const tabsActiveStyle = computed(() => {
401
+ return {
402
+ color: props.type == "smile" ? props.color : "",
403
+ background: props.type == "line" ? props.color : ""
404
+ };
405
+ });
406
+ const titleStyle = computed(() => {
407
+ if (!props.titleGutter)
270
408
  return {};
271
- const t = ke(e.titleGutter);
272
- return e.direction === "vertical" ? { marginTop: t, marginBottom: t } : { marginLeft: t, marginRight: t };
409
+ const px = pxCheck(props.titleGutter);
410
+ if (props.direction === "vertical") {
411
+ return { marginTop: px, marginBottom: px };
412
+ }
413
+ return { marginLeft: px, marginRight: px };
273
414
  });
274
- return P(P({
275
- navRef: v,
276
- tabsContentRef: ie,
277
- titles: r,
278
- contentStyle: ae,
279
- tabsNavStyle: se,
280
- titleStyle: ue,
281
- tabsActiveStyle: re,
282
- container: T,
283
- getScrollY: c,
284
- onStickyScroll: R
285
- }, $), ne);
415
+ return __spreadValues(__spreadValues({
416
+ navRef,
417
+ tabsContentRef,
418
+ titles,
419
+ contentStyle,
420
+ tabsNavStyle,
421
+ titleStyle,
422
+ tabsActiveStyle,
423
+ container,
424
+ getScrollY,
425
+ onStickyScroll
426
+ }, tabMethods), touchMethods);
286
427
  }
287
- }), Ne = ["onClick"], Me = ["onClick"];
288
- function Ie(e, i, n, T, m, r) {
289
- const h = X("JoySmile"), a = X("nut-sticky");
290
- return y(), p("view", {
291
- class: w(["nut-tabs", [e.direction]]),
428
+ });
429
+ const _hoisted_1 = ["onClick"];
430
+ const _hoisted_2 = ["onClick"];
431
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
432
+ const _component_JoySmile = resolveComponent("JoySmile");
433
+ const _component_nut_sticky = resolveComponent("nut-sticky");
434
+ return openBlock(), createElementBlock("view", {
435
+ class: normalizeClass(["nut-tabs", [_ctx.direction]]),
292
436
  ref: "container"
293
437
  }, [
294
- e.sticky ? (y(), Se(a, {
438
+ _ctx.sticky ? (openBlock(), createBlock(_component_nut_sticky, {
295
439
  key: 0,
296
- top: e.top,
297
- container: e.container,
298
- onScroll: e.onStickyScroll
440
+ top: _ctx.top,
441
+ container: _ctx.container,
442
+ onScroll: _ctx.onStickyScroll
299
443
  }, {
300
- default: Te(() => [
301
- N("view", {
302
- class: w(["nut-tabs__titles", { [e.type]: e.type, scrollable: e.titleScroll, [e.size]: e.size }]),
303
- style: b(e.tabsNavStyle),
444
+ default: withCtx(() => [
445
+ createElementVNode("view", {
446
+ class: normalizeClass(["nut-tabs__titles", { [_ctx.type]: _ctx.type, scrollable: _ctx.titleScroll, [_ctx.size]: _ctx.size }]),
447
+ style: normalizeStyle(_ctx.tabsNavStyle),
304
448
  ref: "navRef"
305
449
  }, [
306
- e.$slots.titles ? D(e.$slots, "titles", { key: 0 }) : (y(!0), p(Z, { key: 1 }, _(e.titles, (l, c) => (y(), p("view", {
307
- class: w(["nut-tabs__titles-item", { active: l.paneKey == e.modelValue, disabled: l.disabled }]),
308
- style: b(e.titleStyle),
309
- onClick: (v) => e.tabChange(l, c),
310
- key: l.paneKey
311
- }, [
312
- e.type == "line" ? (y(), p("view", {
313
- key: 0,
314
- class: "nut-tabs__titles-item__line",
315
- style: b(e.tabsActiveStyle)
316
- }, null, 4)) : M("", !0),
317
- e.type == "smile" ? (y(), p("view", {
318
- key: 1,
319
- class: "nut-tabs__titles-item__smile",
320
- style: b(e.tabsActiveStyle)
450
+ _ctx.$slots.titles ? renderSlot(_ctx.$slots, "titles", { key: 0 }) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.titles, (item, index) => {
451
+ return openBlock(), createElementBlock("view", {
452
+ class: normalizeClass(["nut-tabs__titles-item", { active: item.paneKey == _ctx.modelValue, disabled: item.disabled }]),
453
+ style: normalizeStyle(_ctx.titleStyle),
454
+ onClick: ($event) => _ctx.tabChange(item, index),
455
+ key: item.paneKey
321
456
  }, [
322
- x(h, { color: e.color }, null, 8, ["color"])
323
- ], 4)) : M("", !0),
324
- N("view", {
325
- class: w(["nut-tabs__titles-item__text", { ellipsis: e.ellipsis }])
326
- }, ee(l.title), 3)
327
- ], 14, Ne))), 128))
457
+ _ctx.type == "line" ? (openBlock(), createElementBlock("view", {
458
+ key: 0,
459
+ class: "nut-tabs__titles-item__line",
460
+ style: normalizeStyle(_ctx.tabsActiveStyle)
461
+ }, null, 4)) : createCommentVNode("", true),
462
+ _ctx.type == "smile" ? (openBlock(), createElementBlock("view", {
463
+ key: 1,
464
+ class: "nut-tabs__titles-item__smile",
465
+ style: normalizeStyle(_ctx.tabsActiveStyle)
466
+ }, [
467
+ createVNode(_component_JoySmile, { color: _ctx.color }, null, 8, ["color"])
468
+ ], 4)) : createCommentVNode("", true),
469
+ createElementVNode("view", {
470
+ class: normalizeClass(["nut-tabs__titles-item__text", { ellipsis: _ctx.ellipsis }])
471
+ }, toDisplayString(item.title), 3)
472
+ ], 14, _hoisted_1);
473
+ }), 128))
328
474
  ], 6)
329
475
  ]),
330
476
  _: 3
331
- }, 8, ["top", "container", "onScroll"])) : (y(), p("view", {
477
+ }, 8, ["top", "container", "onScroll"])) : (openBlock(), createElementBlock("view", {
332
478
  key: 1,
333
- class: w(["nut-tabs__titles", { [e.type]: e.type, scrollable: e.titleScroll, "scroll-vertical": e.getScrollY, [e.size]: e.size }]),
334
- style: b(e.tabsNavStyle),
479
+ class: normalizeClass(["nut-tabs__titles", { [_ctx.type]: _ctx.type, scrollable: _ctx.titleScroll, "scroll-vertical": _ctx.getScrollY, [_ctx.size]: _ctx.size }]),
480
+ style: normalizeStyle(_ctx.tabsNavStyle),
335
481
  ref: "navRef"
336
482
  }, [
337
- e.$slots.titles ? D(e.$slots, "titles", { key: 0 }) : (y(!0), p(Z, { key: 1 }, _(e.titles, (l, c) => (y(), p("view", {
338
- class: w(["nut-tabs__titles-item", { active: l.paneKey == e.modelValue, disabled: l.disabled }]),
339
- style: b(e.titleStyle),
340
- onClick: (v) => e.tabChange(l, c),
341
- key: l.paneKey,
342
- ref_for: !0,
343
- ref: (v) => e.setTabItemRef(v, c)
344
- }, [
345
- e.type == "line" ? (y(), p("view", {
346
- key: 0,
347
- class: "nut-tabs__titles-item__line",
348
- style: b(e.tabsActiveStyle)
349
- }, null, 4)) : M("", !0),
350
- e.type == "smile" ? (y(), p("view", {
351
- key: 1,
352
- class: "nut-tabs__titles-item__smile",
353
- style: b(e.tabsActiveStyle)
483
+ _ctx.$slots.titles ? renderSlot(_ctx.$slots, "titles", { key: 0 }) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.titles, (item, index) => {
484
+ return openBlock(), createElementBlock("view", {
485
+ class: normalizeClass(["nut-tabs__titles-item", { active: item.paneKey == _ctx.modelValue, disabled: item.disabled }]),
486
+ style: normalizeStyle(_ctx.titleStyle),
487
+ onClick: ($event) => _ctx.tabChange(item, index),
488
+ key: item.paneKey,
489
+ ref_for: true,
490
+ ref: (e) => _ctx.setTabItemRef(e, index)
354
491
  }, [
355
- x(h, { color: e.color }, null, 8, ["color"])
356
- ], 4)) : M("", !0),
357
- N("view", {
358
- class: w(["nut-tabs__titles-item__text", { ellipsis: e.ellipsis }])
359
- }, ee(l.title), 3)
360
- ], 14, Me))), 128))
492
+ _ctx.type == "line" ? (openBlock(), createElementBlock("view", {
493
+ key: 0,
494
+ class: "nut-tabs__titles-item__line",
495
+ style: normalizeStyle(_ctx.tabsActiveStyle)
496
+ }, null, 4)) : createCommentVNode("", true),
497
+ _ctx.type == "smile" ? (openBlock(), createElementBlock("view", {
498
+ key: 1,
499
+ class: "nut-tabs__titles-item__smile",
500
+ style: normalizeStyle(_ctx.tabsActiveStyle)
501
+ }, [
502
+ createVNode(_component_JoySmile, { color: _ctx.color }, null, 8, ["color"])
503
+ ], 4)) : createCommentVNode("", true),
504
+ createElementVNode("view", {
505
+ class: normalizeClass(["nut-tabs__titles-item__text", { ellipsis: _ctx.ellipsis }])
506
+ }, toDisplayString(item.title), 3)
507
+ ], 14, _hoisted_2);
508
+ }), 128))
361
509
  ], 6)),
362
- N("view", {
510
+ createElementVNode("view", {
363
511
  class: "nut-tabs__content",
364
512
  ref: "tabsContentRef",
365
- style: b(e.contentStyle),
366
- onTouchstart: i[0] || (i[0] = (...l) => e.onTouchStart && e.onTouchStart(...l)),
367
- onTouchmove: i[1] || (i[1] = (...l) => e.onTouchMove && e.onTouchMove(...l)),
368
- onTouchend: i[2] || (i[2] = (...l) => e.onTouchEnd && e.onTouchEnd(...l)),
369
- onTouchcancel: i[3] || (i[3] = (...l) => e.onTouchEnd && e.onTouchEnd(...l))
513
+ style: normalizeStyle(_ctx.contentStyle),
514
+ onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
515
+ onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
516
+ onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args)),
517
+ onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
370
518
  }, [
371
- D(e.$slots, "default")
519
+ renderSlot(_ctx.$slots, "default")
372
520
  ], 36)
373
521
  ], 2);
374
522
  }
375
- const qe = /* @__PURE__ */ $e(Be, [["render", Ie]]);
523
+ const Tabs = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
376
524
  export {
377
- Ke as Title,
378
- qe as default
525
+ Title,
526
+ Tabs as default
379
527
  };