@nutui/nutui 3.1.10 → 3.1.12-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/nutui.d.ts +5 -1
  3. package/dist/nutui.es.js +4041 -3518
  4. package/dist/nutui.umd.js +4084 -3627
  5. package/dist/packages/_es/ActionSheet.js +13 -12
  6. package/dist/packages/_es/Address.js +63 -49
  7. package/dist/packages/_es/Avatar.js +4 -5
  8. package/dist/packages/_es/BackTop.js +72 -109
  9. package/dist/packages/_es/Badge.js +4 -5
  10. package/dist/packages/_es/Barrage.js +63 -57
  11. package/dist/packages/_es/Button.js +5 -6
  12. package/dist/packages/_es/Calendar.js +27 -18
  13. package/dist/packages/_es/Card.js +104 -0
  14. package/dist/packages/_es/Cell.js +5 -13
  15. package/dist/packages/_es/CellGroup.js +4 -5
  16. package/dist/packages/_es/Checkbox.js +3 -3
  17. package/dist/packages/_es/CheckboxGroup.js +9 -4
  18. package/dist/packages/_es/CircleProgress.js +142 -46
  19. package/dist/packages/_es/Col.js +4 -5
  20. package/dist/packages/_es/Collapse.js +35 -10
  21. package/dist/packages/_es/CollapseItem.js +80 -35
  22. package/dist/packages/_es/CountDown.js +7 -5
  23. package/dist/packages/_es/CountUp.js +34 -31
  24. package/dist/packages/_es/DatePicker.js +451 -219
  25. package/dist/packages/_es/Dialog.js +13 -87
  26. package/dist/packages/_es/Divider.js +5 -6
  27. package/dist/packages/_es/Drag.js +76 -50
  28. package/dist/packages/_es/Elevator.js +81 -52
  29. package/dist/packages/_es/FixedNav.js +8 -9
  30. package/dist/packages/_es/Form.js +137 -0
  31. package/dist/packages/_es/FormItem.js +109 -0
  32. package/dist/packages/_es/Icon.js +6 -40
  33. package/dist/packages/_es/ImagePreview.js +23 -21
  34. package/dist/packages/_es/InfiniteLoading.js +95 -109
  35. package/dist/packages/_es/Input.js +22 -21
  36. package/dist/packages/_es/InputNumber.js +24 -18
  37. package/dist/packages/_es/Layout.js +2 -2
  38. package/dist/packages/_es/Menu.js +89 -171
  39. package/dist/packages/_es/MenuItem.js +155 -18
  40. package/dist/packages/_es/Navbar.js +7 -7
  41. package/dist/packages/_es/NoticeBar.js +39 -26
  42. package/dist/packages/_es/Notify.js +30 -166
  43. package/dist/packages/_es/NumberKeyboard.js +10 -6
  44. package/dist/packages/_es/OverLay.js +22 -29
  45. package/dist/packages/_es/Pagination.js +8 -9
  46. package/dist/packages/_es/Picker.js +61 -447
  47. package/dist/packages/_es/Popover.js +146 -25
  48. package/dist/packages/_es/Popup.js +18 -39
  49. package/dist/packages/_es/Price.js +18 -7
  50. package/dist/packages/_es/Progress.js +23 -12
  51. package/dist/packages/_es/Radio.js +20 -7
  52. package/dist/packages/_es/RadioGroup.js +7 -3
  53. package/dist/packages/_es/Range.js +38 -59
  54. package/dist/packages/_es/Rate.js +16 -20
  55. package/dist/packages/_es/Row.js +4 -5
  56. package/dist/packages/_es/SearchBar.js +7 -5
  57. package/dist/packages/_es/ShortPassword.js +89 -59
  58. package/dist/packages/_es/Signature.js +70 -71
  59. package/dist/packages/_es/Sku.js +508 -0
  60. package/dist/packages/_es/Step.js +10 -8
  61. package/dist/packages/_es/Steps.js +2 -2
  62. package/dist/packages/_es/Swipe.js +42 -27
  63. package/dist/packages/_es/Swiper.js +17 -418
  64. package/dist/packages/_es/SwiperItem.js +14 -39
  65. package/dist/packages/_es/Switch.js +4 -5
  66. package/dist/packages/_es/TabPane.js +4 -5
  67. package/dist/packages/_es/Tabbar.js +4 -5
  68. package/dist/packages/_es/TabbarItem.js +8 -9
  69. package/dist/packages/_es/Tabs.js +23 -17
  70. package/dist/packages/_es/Tag.js +5 -6
  71. package/dist/packages/_es/TextArea.js +16 -12
  72. package/dist/packages/_es/TimeDetail.js +7 -5
  73. package/dist/packages/_es/TimePannel.js +7 -5
  74. package/dist/packages/_es/TimeSelect.js +12 -7
  75. package/dist/packages/_es/Toast.js +41 -163
  76. package/dist/packages/_es/Uploader.js +210 -164
  77. package/dist/packages/_es/commonProps.js +30 -0
  78. package/dist/packages/_es/component.js +1 -1
  79. package/dist/packages/_es/index.js +1 -1
  80. package/dist/packages/_es/index.taro.vue_vue&type=script&lang.js +44 -0
  81. package/dist/packages/_es/index2.js +44 -8
  82. package/dist/packages/_es/index3.js +419 -0
  83. package/dist/packages/_es/pxCheck.js +1 -1
  84. package/dist/packages/_es/raf.js +1 -1
  85. package/dist/packages/_es/use-lock-scroll.js +23 -0
  86. package/dist/packages/_es/util.js +47 -0
  87. package/dist/packages/button/index.scss +9 -0
  88. package/dist/packages/card/index.scss +97 -0
  89. package/dist/packages/checkbox/index.scss +1 -1
  90. package/dist/packages/form/index.scss +2 -0
  91. package/dist/packages/formitem/index.scss +60 -0
  92. package/dist/packages/menu/index.scss +32 -60
  93. package/dist/packages/menuitem/index.scss +36 -99
  94. package/dist/packages/numberkeyboard/index.scss +1 -1
  95. package/dist/packages/progress/index.scss +2 -0
  96. package/dist/packages/radio/index.scss +32 -4
  97. package/dist/packages/radiogroup/index.scss +20 -0
  98. package/dist/packages/sku/index.scss +147 -0
  99. package/dist/packages/switch/index.scss +1 -1
  100. package/dist/packages/uploader/index.scss +95 -8
  101. package/dist/style.css +1 -1
  102. package/dist/style.es.js +1 -2
  103. package/dist/styles/mixins/index.scss +0 -4
  104. package/dist/styles/themes/default.scss +34 -30
  105. package/dist/styles/variables.scss +45 -3
  106. package/package.json +3 -2
  107. package/dist/packages/_es/Video.js +0 -405
  108. package/dist/packages/_es/plugin-vue_export-helper.js +0 -12
  109. package/dist/packages/_es/style.css +0 -160
@@ -17,29 +17,28 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __publicField = (obj, key, value) => {
21
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
- return value;
20
+ var __require = typeof require !== "undefined" ? require : (x) => {
21
+ throw new Error('Dynamic require of "' + x + '" is not supported');
23
22
  };
24
23
  /*!
25
- * @nutui/nutui v3.1.10 Fri Nov 05 2021 19:52:49 GMT+0800 (中国标准时间)
24
+ * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
26
25
  * (c) 2021 @jdf2e.
27
26
  * Released under the MIT License.
28
27
  */
29
- import { ref, onMounted, watch, computed, resolveComponent, openBlock, createBlock, withCtx, createElementVNode, normalizeClass, createElementBlock, renderSlot, Fragment, createTextVNode, toDisplayString, createCommentVNode, normalizeStyle, createVNode, render, h } from "vue";
28
+ import { ref, onMounted, watch, computed, resolveComponent, openBlock, createBlock, withCtx, createElementVNode, normalizeClass, createElementBlock, renderSlot, Fragment, createTextVNode, toDisplayString, createCommentVNode, normalizeStyle } from "vue";
30
29
  import { c as createComponent } from "./component.js";
31
- import Popup, { popupProps } from "./Popup.js";
32
- import Button from "./Button.js";
33
- import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
30
+ import _sfc_main$1, { popupProps } from "./Popup.js";
31
+ import _sfc_main$2 from "./Button.js";
32
+ import "./use-lock-scroll.js";
34
33
  import "./OverLay.js";
35
- import "./Icon.js";
34
+ import "./index.taro.vue_vue&type=script&lang.js";
36
35
  import "./pxCheck.js";
37
36
  const { componentName, create } = createComponent("dialog");
38
- const _sfc_main = create({
37
+ var _sfc_main = create({
39
38
  inheritAttrs: false,
40
39
  components: {
41
- [Popup.name]: Popup,
42
- [Button.name]: Button
40
+ [_sfc_main$1.name]: _sfc_main$1,
41
+ [_sfc_main$2.name]: _sfc_main$2
43
42
  },
44
43
  props: __spreadProps(__spreadValues({}, popupProps), {
45
44
  closeOnClickOverlay: {
@@ -236,78 +235,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
236
235
  _: 3
237
236
  }, 8, ["teleport", "visible", "close-on-click-overlay", "lock-scroll", "onClickOverlay", "onClickCloseIcon"]);
238
237
  }
239
- var Dialog = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
240
- class DialogOptions {
241
- constructor() {
242
- __publicField(this, "title", "");
243
- __publicField(this, "content", "");
244
- __publicField(this, "cancelText", "\u53D6\u6D88");
245
- __publicField(this, "okText", "\u786E\u5B9A");
246
- __publicField(this, "textAlign", "center");
247
- __publicField(this, "teleport", "body");
248
- __publicField(this, "onUpdate", (value) => {
249
- });
250
- __publicField(this, "onOk", () => {
251
- });
252
- __publicField(this, "onCancel", () => {
253
- });
254
- __publicField(this, "onClose", () => {
255
- });
256
- __publicField(this, "onClosed", () => {
257
- });
258
- __publicField(this, "visible", true);
259
- __publicField(this, "noFooter", false);
260
- __publicField(this, "noOkBtn", false);
261
- __publicField(this, "noCancelBtn", false);
262
- __publicField(this, "okBtnDisabled", false);
263
- __publicField(this, "closeOnPopstate", false);
264
- __publicField(this, "lockScroll", false);
265
- }
266
- }
267
- class DialogFunction {
268
- constructor(_options) {
269
- __publicField(this, "options", new DialogOptions());
270
- __publicField(this, "close", () => {
271
- });
272
- __publicField(this, "setDefaultOptions", (options) => {
273
- });
274
- __publicField(this, "resetDefaultOptions", () => {
275
- });
276
- let options = Object.assign(this.options, _options);
277
- let elWarp = document.body;
278
- let teleport = options.teleport;
279
- if (teleport != "body") {
280
- if (typeof teleport == "string") {
281
- elWarp = document.querySelector(teleport);
282
- } else {
283
- elWarp = options.teleport;
284
- }
285
- }
286
- const root = document.createElement("view");
287
- root.id = "dialog-" + new Date().getTime();
288
- const Wrapper = {
289
- setup() {
290
- options.onUpdate = (val) => {
291
- if (val == false) {
292
- elWarp.removeChild(root);
293
- }
294
- };
295
- options.teleport = `#${root.id}`;
296
- return () => {
297
- return h(Dialog, options);
298
- };
299
- }
300
- };
301
- const instance = createVNode(Wrapper);
302
- elWarp.appendChild(root);
303
- render(instance, root);
304
- }
305
- }
306
- const _Dialog = function(options) {
307
- return new DialogFunction(options);
308
- };
309
- _Dialog.install = (app) => {
310
- app.use(Dialog);
311
- app.config.globalProperties.$dialog = _Dialog;
312
- };
313
- export { Dialog, DialogOptions, _Dialog as default };
238
+ _sfc_main.render = _sfc_render;
239
+ export { _sfc_main as default };
@@ -1,13 +1,12 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.10 Fri Nov 05 2021 19:52:49 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
6
  import { computed, openBlock, createElementBlock, normalizeClass, renderSlot } from "vue";
7
7
  import { c as createComponent } from "./component.js";
8
- import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
9
8
  const { componentName, create } = createComponent("divider");
10
- const _sfc_main = create({
9
+ var _sfc_main = create({
11
10
  props: {
12
11
  contentPosition: {
13
12
  type: String,
@@ -39,11 +38,11 @@ const _sfc_main = create({
39
38
  }
40
39
  });
41
40
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
42
- return openBlock(), createElementBlock("div", {
41
+ return openBlock(), createElementBlock("view", {
43
42
  class: normalizeClass(_ctx.classes)
44
43
  }, [
45
44
  renderSlot(_ctx.$slots, "default")
46
45
  ], 2);
47
46
  }
48
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
49
- export { index as default };
47
+ _sfc_main.render = _sfc_render;
48
+ export { _sfc_main as default };
@@ -1,14 +1,14 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.10 Fri Nov 05 2021 19:52:49 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { ref, reactive, computed, onMounted, onActivated, onDeactivated, openBlock, createElementBlock, normalizeClass, renderSlot } from "vue";
6
+ import { ref, reactive, computed, onMounted, onActivated, onDeactivated, openBlock, createElementBlock, normalizeClass, withModifiers, normalizeStyle, renderSlot } from "vue";
7
7
  import { c as createComponent } from "./component.js";
8
8
  import { r as requestAniFrame } from "./raf.js";
9
- import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
9
+ import Taro, { eventCenter, getCurrentInstance } from "@tarojs/taro";
10
10
  const { componentName, create } = createComponent("drag");
11
- const _sfc_main = create({
11
+ var _sfc_main = create({
12
12
  props: {
13
13
  attract: {
14
14
  type: Boolean,
@@ -40,10 +40,13 @@ const _sfc_main = create({
40
40
  screenHeight: 0,
41
41
  startTop: 0,
42
42
  startLeft: 0,
43
+ initTop: 0,
43
44
  nx: 0,
44
45
  ny: 0,
45
46
  xPum: 0,
46
47
  yPum: 0,
48
+ top: 0,
49
+ left: 0,
47
50
  position: { x: 0, y: 0 },
48
51
  boundary: {
49
52
  top: 0,
@@ -53,54 +56,58 @@ const _sfc_main = create({
53
56
  }
54
57
  });
55
58
  const classes = computed(() => {
56
- const prefixCls = componentName;
59
+ const prefixCls = "nut-taro-drag";
57
60
  return {
58
61
  [prefixCls]: true
59
62
  };
60
63
  });
64
+ const domElem = Taro.getSystemInfoSync();
61
65
  function getInfo() {
62
- const domElem = document.documentElement;
63
- state.elWidth = myDrag.value.offsetWidth;
64
- state.elHeight = myDrag.value.offsetHeight;
65
- state.screenWidth = domElem.clientWidth;
66
- state.screenHeight = domElem.clientHeight;
66
+ const query = Taro.createSelectorQuery();
67
+ query.select(".myDrag").boundingClientRect((rec) => {
68
+ state.elWidth = rec.width;
69
+ state.elHeight = rec.height;
70
+ state.initTop = rec.top;
71
+ }).exec();
72
+ console.log(domElem.windowWidth);
73
+ state.screenWidth = domElem.screenWidth;
74
+ state.screenHeight = domElem.screenHeight;
67
75
  }
68
- function goLeft(target) {
76
+ function goLeft() {
69
77
  if (state.boundary.left) {
70
- if (+target.style.left.split("px")[0] > state.boundary.left) {
71
- target.style.left = +target.style.left.split("px")[0] - 10 + "px";
78
+ if (+state.left.split("px")[0] > state.boundary.left) {
79
+ state.left = +state.left.split("px")[0] - 10 + "px";
72
80
  requestAniFrame(() => {
73
- goLeft(target);
81
+ goLeft();
74
82
  });
75
83
  } else {
76
- target.style.left = `${state.boundary.left}px`;
84
+ state.left = `${state.boundary.left}px`;
77
85
  }
78
86
  } else {
79
- if (+target.style.left.split("px")[0] > 10) {
80
- target.style.left = +target.style.left.split("px")[0] - 10 + "px";
87
+ if (+state.left.split("px")[0] > 10) {
88
+ state.left = +state.left.split("px")[0] - 10 + "px";
81
89
  requestAniFrame(() => {
82
- goLeft(target);
90
+ goLeft();
83
91
  });
84
92
  } else {
85
- target.style.left = "0px";
93
+ state.left = "0px";
86
94
  }
87
95
  }
88
96
  }
89
- function goRight(target, rightLocation) {
90
- if (rightLocation - parseInt(target.style.left.split("px")[0]) > 10) {
91
- target.style.left = parseInt(target.style.left.split("px")[0]) + 10 + "px";
97
+ function goRight(rightLocation) {
98
+ if (rightLocation - parseInt(state.left.split("px")[0]) > 10) {
99
+ state.left = parseInt(state.left.split("px")[0]) + 10 + "px";
92
100
  requestAniFrame(() => {
93
- goRight(target, rightLocation);
101
+ goRight(rightLocation);
94
102
  });
95
103
  } else {
96
- target.style.left = rightLocation + "px";
104
+ state.left = rightLocation + "px";
97
105
  }
98
106
  }
99
107
  function touchMove(e) {
100
108
  e.preventDefault();
101
- const target = e.currentTarget;
102
- if (e.targetTouches.length === 1) {
103
- const touch = e.targetTouches[0];
109
+ if (e.touches.length === 1) {
110
+ const touch = e.touches[0];
104
111
  state.nx = touch.clientX - state.position.x;
105
112
  state.ny = touch.clientY - state.position.y;
106
113
  state.xPum = state.startLeft + state.nx;
@@ -117,15 +124,14 @@ const _sfc_main = create({
117
124
  state.yPum = state.screenHeight - state.elHeight - state.boundary.bottom;
118
125
  }
119
126
  if (props.direction != "y") {
120
- target.style.left = state.xPum + "px";
127
+ state.left = state.xPum;
121
128
  }
122
129
  if (props.direction != "x") {
123
- target.style.top = state.yPum + "px";
130
+ state.top = state.yPum;
124
131
  }
125
132
  }
126
133
  }
127
134
  function touchEnd(e) {
128
- const target = e.currentTarget;
129
135
  const touch = e.changedTouches[0];
130
136
  let currX = touch.clientX;
131
137
  const rightLocation = state.screenWidth - state.elWidth - state.boundary.right;
@@ -139,33 +145,47 @@ const _sfc_main = create({
139
145
  if (props.direction != "y" && props.attract) {
140
146
  if (currX < state.screenWidth / 2) {
141
147
  requestAniFrame(() => {
142
- goLeft(target);
148
+ goLeft();
143
149
  });
144
150
  } else {
145
151
  requestAniFrame(() => {
146
- goRight(target, rightLocation);
152
+ goRight(rightLocation);
147
153
  });
148
154
  }
149
155
  }
150
- if (props.direction != "x") {
151
- target.style.top = state.yPum + "px";
156
+ if (props.direction !== "x") {
157
+ state.top = state.yPum;
152
158
  }
153
159
  }
154
160
  function touchStart(e) {
155
- const target = e.currentTarget;
161
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
162
+ const query = Taro.createSelectorQuery();
163
+ let id = (_a = e == null ? void 0 : e.mpEvent) == null ? void 0 : _a.currentTarget.id;
164
+ let offsetTop = (_b = e == null ? void 0 : e.currentTarget) == null ? void 0 : _b.offsetTop;
165
+ let offsetLeft = (_c = e == null ? void 0 : e.currentTarget) == null ? void 0 : _c.offsetLeft;
156
166
  const touches = e.touches[0];
157
- const touch = e.targetTouches[0];
158
- state.startTop = target.offsetTop;
159
- state.startLeft = target.offsetLeft;
167
+ const mobileTop = (_f = (_e = (_d = e.touches[0]) == null ? void 0 : _d.target) == null ? void 0 : _e.parentNode) == null ? void 0 : _f.style.top;
168
+ const mobileLeft = (_i = (_h = (_g = e.touches[0]) == null ? void 0 : _g.target) == null ? void 0 : _h.parentNode) == null ? void 0 : _i.style.left;
169
+ query.selectAll(".myDrag").boundingClientRect((rec) => {
170
+ rec.forEach((element) => {
171
+ if (id && id == element.id) {
172
+ state.startTop = element.top - offsetTop;
173
+ state.startLeft = element.left - offsetLeft;
174
+ } else if (mobileTop) {
175
+ state.startTop = Number(mobileTop.slice(0, -2));
176
+ state.startLeft = Number(mobileLeft.slice(0, -2));
177
+ }
178
+ });
179
+ }).exec();
160
180
  state.position.x = touches.clientX;
161
181
  state.position.y = touches.clientY;
162
- state.nx = touch.clientX - state.position.x;
163
- state.ny = touch.clientY - state.position.y;
164
- state.xPum = state.startLeft + state.nx;
165
- state.yPum = state.startTop + state.ny;
166
182
  }
167
183
  onMounted(() => {
168
- getInfo();
184
+ setTimeout(() => {
185
+ getInfo();
186
+ }, 200);
187
+ eventCenter.once(getCurrentInstance().router.onReady, () => {
188
+ });
169
189
  state.boundary = props.boundary;
170
190
  });
171
191
  onActivated(() => {
@@ -184,20 +204,26 @@ const _sfc_main = create({
184
204
  myDrag,
185
205
  touchStart,
186
206
  touchMove,
187
- touchEnd
207
+ touchEnd,
208
+ state
188
209
  };
189
210
  }
190
211
  });
191
212
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
192
213
  return openBlock(), createElementBlock("view", {
193
- class: normalizeClass(_ctx.classes),
214
+ class: normalizeClass([_ctx.classes, "myDrag"]),
194
215
  ref: "myDrag",
195
216
  onTouchstart: _cache[0] || (_cache[0] = ($event) => _ctx.touchStart($event)),
196
- onTouchmove: _cache[1] || (_cache[1] = ($event) => _ctx.touchMove($event)),
197
- onTouchend: _cache[2] || (_cache[2] = ($event) => _ctx.touchEnd($event))
217
+ onTouchmove: _cache[1] || (_cache[1] = withModifiers(($event) => _ctx.touchMove($event), ["prevent"])),
218
+ catchtouchmove: "true",
219
+ style: normalizeStyle({
220
+ transform: ` translate(${_ctx.state.left + "px"}, ${_ctx.state.top + "px"})`,
221
+ top: _ctx.state.top + "px",
222
+ left: _ctx.state.left + "px"
223
+ })
198
224
  }, [
199
225
  renderSlot(_ctx.$slots, "default")
200
- ], 34);
226
+ ], 38);
201
227
  }
202
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
203
- export { index as default };
228
+ _sfc_main.render = _sfc_render;
229
+ export { _sfc_main as default };
@@ -17,16 +17,19 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __require = typeof require !== "undefined" ? require : (x) => {
21
+ throw new Error('Dynamic require of "' + x + '" is not supported');
22
+ };
20
23
  /*!
21
- * @nutui/nutui v3.1.10 Fri Nov 05 2021 19:52:49 GMT+0800 (中国标准时间)
24
+ * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
22
25
  * (c) 2021 @jdf2e.
23
26
  * Released under the MIT License.
24
27
  */
25
- import { ref, reactive, computed, toRefs, nextTick, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, Fragment, renderList, toDisplayString, withDirectives, vShow, createCommentVNode, withModifiers } from "vue";
28
+ import { ref, reactive, computed, onMounted, toRefs, nextTick, resolveComponent, openBlock, createElementBlock, normalizeClass, createVNode, normalizeStyle, withCtx, Fragment, renderList, createElementVNode, toDisplayString, withDirectives, vShow, createCommentVNode, withModifiers } from "vue";
26
29
  import { c as createComponent } from "./component.js";
27
- import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
30
+ import Taro, { eventCenter, getCurrentInstance } from "@tarojs/taro";
28
31
  const { componentName, create } = createComponent("elevator");
29
- const _sfc_main = create({
32
+ var _sfc_main = create({
30
33
  props: {
31
34
  height: {
32
35
  type: [Number, String],
@@ -46,7 +49,7 @@ const _sfc_main = create({
46
49
  emits: ["click-item", "click-index"],
47
50
  setup(props, context) {
48
51
  const spaceHeight = 23;
49
- const listview = ref(null);
52
+ const listview = ref();
50
53
  const state = reactive({
51
54
  anchorIndex: 0,
52
55
  listHeight: [],
@@ -56,7 +59,10 @@ const _sfc_main = create({
56
59
  y2: 0
57
60
  },
58
61
  scrollStart: false,
59
- currentIndex: 0
62
+ currentIndex: 0,
63
+ query: Taro.createSelectorQuery(),
64
+ scrollTop: 0,
65
+ storageListHeight: []
60
66
  });
61
67
  const classes = computed(() => {
62
68
  const prefixCls = componentName;
@@ -75,9 +81,11 @@ const _sfc_main = create({
75
81
  y2: 0
76
82
  };
77
83
  };
78
- const getData = (el, name) => {
79
- const prefix = "data-";
80
- return el.getAttribute(prefix + name);
84
+ const getData = (el) => {
85
+ if (!el.dataset.index) {
86
+ return "0";
87
+ }
88
+ return el.dataset.index;
81
89
  };
82
90
  const setListGroup = (el) => {
83
91
  nextTick(() => {
@@ -89,35 +97,38 @@ const _sfc_main = create({
89
97
  const calculateHeight = () => {
90
98
  let height = 0;
91
99
  state.listHeight.push(height);
100
+ state.storageListHeight.push(height);
92
101
  for (let i = 0; i < state.listGroup.length; i++) {
93
- let item = state.listGroup[i];
94
- height += item.clientHeight;
95
- state.listHeight.push(height);
102
+ state.query.selectAll(`.elevator__item__${i}`).boundingClientRect();
103
+ state.query.exec((res) => {
104
+ height += res[i][0].height;
105
+ state.listHeight.push(height);
106
+ state.storageListHeight.push(height);
107
+ });
96
108
  }
97
109
  };
98
- const scrollTo = (index2) => {
99
- if (!index2 && index2 !== 0) {
110
+ const scrollTo = (index) => {
111
+ if (!index && index !== 0) {
100
112
  return;
101
113
  }
102
114
  if (!state.listHeight.length) {
103
- calculateHeight();
115
+ state.listHeight = state.storageListHeight.slice();
104
116
  }
105
- if (index2 < 0)
106
- index2 = 0;
107
- if (index2 > state.listHeight.length - 2)
108
- index2 = state.listHeight.length - 2;
109
- state.currentIndex = index2;
110
- listview.value.scrollTo(0, state.listHeight[index2]);
117
+ if (index < 0)
118
+ index = 0;
119
+ if (index > state.listHeight.length - 2)
120
+ index = state.listHeight.length - 2;
121
+ state.currentIndex = index;
122
+ state.scrollTop = state.listHeight[index];
111
123
  };
112
124
  const touchStart = (e) => {
113
125
  state.scrollStart = true;
114
- let index2 = getData(e.target, "index");
126
+ let index = getData(e.target);
115
127
  let firstTouch = e.touches[0];
116
128
  state.touchState.y1 = firstTouch.pageY;
117
- state.anchorIndex = +index2;
118
- state.currentIndex = +index2;
119
- console.log(state.currentIndex);
120
- scrollTo(+index2);
129
+ state.anchorIndex = +index;
130
+ state.currentIndex = +index;
131
+ scrollTo(+index);
121
132
  };
122
133
  const touchMove = (e) => {
123
134
  let firstTouch = e.touches[0];
@@ -135,6 +146,18 @@ const _sfc_main = create({
135
146
  const handleClickIndex = (key) => {
136
147
  context.emit("click-index", key);
137
148
  };
149
+ onMounted(() => {
150
+ Taro.nextTick(() => {
151
+ calculateHeight();
152
+ });
153
+ if (Taro.getEnv() === "WEB") {
154
+ calculateHeight();
155
+ } else {
156
+ eventCenter.once(getCurrentInstance().router.onReady, () => {
157
+ calculateHeight();
158
+ });
159
+ }
160
+ });
138
161
  return __spreadProps(__spreadValues({
139
162
  classes
140
163
  }, toRefs(state)), {
@@ -153,33 +176,39 @@ const _hoisted_2 = ["onClick", "innerHTML"];
153
176
  const _hoisted_3 = { class: "nut-elevator__bars__inner" };
154
177
  const _hoisted_4 = ["data-index", "onClick"];
155
178
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
179
+ const _component_scroll_view = resolveComponent("scroll-view");
156
180
  return openBlock(), createElementBlock("view", {
157
181
  class: normalizeClass(_ctx.classes)
158
182
  }, [
159
- createElementVNode("view", {
160
- class: "nut-elevator__list",
183
+ createVNode(_component_scroll_view, {
184
+ class: "nut-elevator__list scrollview",
185
+ "scroll-top": _ctx.scrollTop,
186
+ "scroll-y": true,
161
187
  ref: "listview",
162
188
  style: normalizeStyle({ height: isNaN(+_ctx.height) ? _ctx.height : `${_ctx.height}px` })
163
- }, [
164
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.indexList, (item) => {
165
- return openBlock(), createElementBlock("view", {
166
- class: "nut-elevator__list__item",
167
- key: item[_ctx.acceptKey],
168
- ref: _ctx.setListGroup
169
- }, [
170
- createElementVNode("view", _hoisted_1, toDisplayString(item[_ctx.acceptKey]), 1),
171
- (openBlock(true), createElementBlock(Fragment, null, renderList(item.list, (subitem) => {
172
- return openBlock(), createElementBlock("view", {
173
- class: "nut-elevator__list__item__name",
174
- key: subitem["id"],
175
- onClick: ($event) => _ctx.handleClickItem(item[_ctx.acceptKey], subitem),
176
- innerHTML: subitem.name
177
- }, null, 8, _hoisted_2);
178
- }), 128))
179
- ], 512);
180
- }), 128))
181
- ], 4),
182
- _ctx.indexList.length ? withDirectives((openBlock(), createElementBlock("view", {
189
+ }, {
190
+ default: withCtx(() => [
191
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.indexList, (item, index) => {
192
+ return openBlock(), createElementBlock("view", {
193
+ class: normalizeClass(["nut-elevator__list__item", `elevator__item__${index}`]),
194
+ key: item[_ctx.acceptKey],
195
+ ref: _ctx.setListGroup
196
+ }, [
197
+ createElementVNode("view", _hoisted_1, toDisplayString(item[_ctx.acceptKey]), 1),
198
+ (openBlock(true), createElementBlock(Fragment, null, renderList(item.list, (subitem) => {
199
+ return openBlock(), createElementBlock("view", {
200
+ class: "nut-elevator__list__item__name",
201
+ key: subitem["id"],
202
+ onClick: ($event) => _ctx.handleClickItem(item[_ctx.acceptKey], subitem),
203
+ innerHTML: subitem.name
204
+ }, null, 8, _hoisted_2);
205
+ }), 128))
206
+ ], 2);
207
+ }), 128))
208
+ ]),
209
+ _: 1
210
+ }, 8, ["scroll-top", "style"]),
211
+ _ctx.indexList.length > 0 ? withDirectives((openBlock(), createElementBlock("view", {
183
212
  key: 0,
184
213
  class: "nut-elevator__code--current"
185
214
  }, toDisplayString(_ctx.indexList[_ctx.currentIndex][_ctx.acceptKey]), 513)), [
@@ -192,10 +221,10 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
192
221
  onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.touchEnd && _ctx.touchEnd(...args))
193
222
  }, [
194
223
  createElementVNode("view", _hoisted_3, [
195
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.indexList, (item, index2) => {
224
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.indexList, (item, index) => {
196
225
  return openBlock(), createElementBlock("view", {
197
226
  class: "nut-elevator__bars__inner__item",
198
- "data-index": index2,
227
+ "data-index": index,
199
228
  key: item[_ctx.acceptKey],
200
229
  onClick: ($event) => _ctx.handleClickIndex(item[_ctx.acceptKey])
201
230
  }, toDisplayString(item[_ctx.acceptKey]), 9, _hoisted_4);
@@ -204,5 +233,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
204
233
  ], 32)
205
234
  ], 2);
206
235
  }
207
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
208
- export { index as default };
236
+ _sfc_main.render = _sfc_render;
237
+ export { _sfc_main as default };
@@ -1,16 +1,15 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.10 Fri Nov 05 2021 19:52:49 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
6
  import { computed, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createBlock, createCommentVNode, renderSlot, createElementVNode, Fragment, renderList, toDisplayString, createVNode } from "vue";
7
7
  import { c as createComponent } from "./component.js";
8
- import overlay from "./OverLay.js";
9
- import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
8
+ import _sfc_main$1 from "./OverLay.js";
10
9
  const { componentName, create } = createComponent("fixednav");
11
- const _sfc_main = create({
10
+ var _sfc_main = create({
12
11
  components: {
13
- [overlay.name]: overlay
12
+ [_sfc_main$1.name]: _sfc_main$1
14
13
  },
15
14
  props: {
16
15
  visible: {
@@ -94,11 +93,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
94
93
  }, null, 8, ["visible"])) : createCommentVNode("", true),
95
94
  renderSlot(_ctx.$slots, "list", {}, () => [
96
95
  createElementVNode("view", _hoisted_1, [
97
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.navList, (item, index2) => {
96
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.navList, (item, index) => {
98
97
  return openBlock(), createElementBlock("view", {
99
98
  class: "nut-fixednav__list-item",
100
99
  onClick: ($event) => _ctx.selected(item, $event),
101
- key: item.id || index2
100
+ key: item.id || index
102
101
  }, [
103
102
  createElementVNode("img", {
104
103
  src: item.icon
@@ -123,5 +122,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
123
122
  ])
124
123
  ], 6);
125
124
  }
126
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
127
- export { index as default };
125
+ _sfc_main.render = _sfc_render;
126
+ export { _sfc_main as default };