@nutui/nutui 3.1.19-beta.0 → 3.1.19-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 (110) hide show
  1. package/dist/nutui.d.ts +38 -37
  2. package/dist/nutui.es.js +13439 -12616
  3. package/dist/nutui.umd.js +13431 -12695
  4. package/dist/packages/_es/ActionSheet.js +12 -18
  5. package/dist/packages/_es/Address.js +78 -69
  6. package/dist/packages/_es/Audio.js +12 -12
  7. package/dist/packages/_es/AudioOperate.js +1 -1
  8. package/dist/packages/_es/Avatar.js +3 -3
  9. package/dist/packages/_es/BackTop.js +68 -110
  10. package/dist/packages/_es/Badge.js +3 -3
  11. package/dist/packages/_es/Barrage.js +62 -55
  12. package/dist/packages/_es/Button.js +2 -2
  13. package/dist/packages/_es/Calendar.js +28 -23
  14. package/dist/packages/_es/CalendarItem.js +3 -3
  15. package/dist/packages/_es/Card.js +6 -5
  16. package/dist/packages/_es/Cascader.js +7 -7
  17. package/dist/packages/_es/Cell.js +4 -11
  18. package/dist/packages/_es/CellGroup.js +1 -1
  19. package/dist/packages/_es/Checkbox.js +1 -1
  20. package/dist/packages/_es/CheckboxGroup.js +1 -1
  21. package/dist/packages/_es/CircleProgress.js +149 -40
  22. package/dist/packages/_es/Col.js +1 -1
  23. package/dist/packages/_es/Collapse.js +34 -8
  24. package/dist/packages/_es/CollapseItem.js +90 -59
  25. package/dist/packages/_es/CountDown.js +5 -5
  26. package/dist/packages/_es/CountUp.js +43 -51
  27. package/dist/packages/_es/DatePicker.js +21 -20
  28. package/dist/packages/_es/Dialog.js +8 -86
  29. package/dist/packages/_es/Divider.js +4 -4
  30. package/dist/packages/_es/Drag.js +92 -54
  31. package/dist/packages/_es/Elevator.js +74 -49
  32. package/dist/packages/_es/Empty.js +3 -3
  33. package/dist/packages/_es/FixedNav.js +5 -5
  34. package/dist/packages/_es/Form.js +4 -4
  35. package/dist/packages/_es/FormItem.js +1 -1
  36. package/dist/packages/_es/Grid.js +1 -1
  37. package/dist/packages/_es/GridItem.js +8 -26
  38. package/dist/packages/_es/Icon.js +1 -1
  39. package/dist/packages/_es/ImagePreview.js +15 -84
  40. package/dist/packages/_es/Indicator.js +3 -3
  41. package/dist/packages/_es/InfiniteLoading.js +93 -107
  42. package/dist/packages/_es/Input.js +8 -8
  43. package/dist/packages/_es/InputNumber.js +23 -16
  44. package/dist/packages/_es/Layout.js +1 -1
  45. package/dist/packages/_es/List.js +41 -34
  46. package/dist/packages/_es/Menu.js +15 -12
  47. package/dist/packages/_es/MenuItem.js +9 -9
  48. package/dist/packages/_es/Navbar.js +3 -4
  49. package/dist/packages/_es/NoticeBar.js +47 -40
  50. package/dist/packages/_es/Notify.js +29 -168
  51. package/dist/packages/_es/NumberKeyboard.js +5 -10
  52. package/dist/packages/_es/OldPicker.js +122 -120
  53. package/dist/packages/_es/OverLay.js +5 -25
  54. package/dist/packages/_es/Pagination.js +7 -7
  55. package/dist/packages/_es/Picker.js +39 -16
  56. package/dist/packages/_es/Popover.js +155 -30
  57. package/dist/packages/_es/Popup.js +8 -71
  58. package/dist/packages/_es/Price.js +17 -5
  59. package/dist/packages/_es/Progress.js +18 -8
  60. package/dist/packages/_es/PullRefresh.js +1 -1
  61. package/dist/packages/_es/Radio.js +2 -2
  62. package/dist/packages/_es/RadioGroup.js +1 -1
  63. package/dist/packages/_es/Range.js +46 -33
  64. package/dist/packages/_es/Rate.js +16 -19
  65. package/dist/packages/_es/Row.js +1 -1
  66. package/dist/packages/_es/SearchBar.js +8 -6
  67. package/dist/packages/_es/ShortPassword.js +89 -67
  68. package/dist/packages/_es/SideNavBar.js +5 -16
  69. package/dist/packages/_es/SideNavBarItem.js +1 -1
  70. package/dist/packages/_es/Signature.js +69 -88
  71. package/dist/packages/_es/Skeleton.js +8 -11
  72. package/dist/packages/_es/Sku.js +47 -56
  73. package/dist/packages/_es/Step.js +1 -1
  74. package/dist/packages/_es/Steps.js +1 -1
  75. package/dist/packages/_es/Sticky.js +28 -23
  76. package/dist/packages/_es/SubSideNavBar.js +1 -1
  77. package/dist/packages/_es/Swipe.js +39 -26
  78. package/dist/packages/_es/Swiper.js +31 -13
  79. package/dist/packages/_es/SwiperItem.js +1 -1
  80. package/dist/packages/_es/Switch.js +3 -3
  81. package/dist/packages/_es/TabPane.js +1 -1
  82. package/dist/packages/_es/Tabbar.js +3 -3
  83. package/dist/packages/_es/TabbarItem.js +17 -23
  84. package/dist/packages/_es/Table.js +13 -13
  85. package/dist/packages/_es/Tabs.js +21 -20
  86. package/dist/packages/_es/Tag.js +4 -4
  87. package/dist/packages/_es/TextArea.js +44 -42
  88. package/dist/packages/_es/TimeDetail.js +4 -3
  89. package/dist/packages/_es/TimePannel.js +3 -3
  90. package/dist/packages/_es/TimeSelect.js +8 -7
  91. package/dist/packages/_es/Toast.js +41 -170
  92. package/dist/packages/_es/Uploader.js +109 -138
  93. package/dist/packages/_es/Video.js +3 -3
  94. package/dist/packages/_es/common.js +1 -1
  95. package/dist/packages/_es/component.js +1 -1
  96. package/dist/packages/_es/index.js +44 -6
  97. package/dist/packages/_es/{index5.js → index.taro.js} +127 -95
  98. package/dist/packages/_es/index2.js +1 -1
  99. package/dist/packages/_es/index3.js +56 -28
  100. package/dist/packages/_es/index4.js +413 -56
  101. package/dist/packages/_es/plugin-vue_export-helper.js +1 -1
  102. package/dist/packages/_es/pxCheck.js +1 -1
  103. package/dist/packages/_es/use-lock-scroll.js +23 -0
  104. package/dist/packages/_es/util.js +1 -1
  105. package/dist/packages/uploader/index.scss +2 -2
  106. package/dist/style.css +1 -1
  107. package/dist/styles/themes/default.scss +61 -61
  108. package/dist/styles/themes/jdt.scss +61 -61
  109. package/package.json +1 -1
  110. package/dist/packages/_es/raf.js +0 -19
@@ -1,10 +1,11 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.19-beta.0 Mon Mar 28 2022 17:50:21 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { ref, computed, watch, resolveComponent, openBlock, createElementBlock, createVNode, withCtx, createElementVNode, toDisplayString, withDirectives, normalizeStyle, vModelText, Fragment, renderList, createCommentVNode } from "vue";
6
+ import { ref, computed, watch, onMounted, resolveComponent, openBlock, createElementBlock, createVNode, withCtx, createElementVNode, toDisplayString, withDirectives, vModelText, createCommentVNode, Fragment, renderList } from "vue";
7
7
  import { c as createComponent } from "./component.js";
8
+ import Taro, { eventCenter, getCurrentInstance } from "@tarojs/taro";
8
9
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
9
10
  const { create } = createComponent("shortpassword");
10
11
  const _sfc_main = create({
@@ -44,10 +45,6 @@ const _sfc_main = create({
44
45
  length: {
45
46
  type: [String, Number],
46
47
  default: 6
47
- },
48
- isWrapTeleport: {
49
- type: Boolean,
50
- default: true
51
48
  }
52
49
  },
53
50
  emits: ["update:modelValue", "update:visible", "complete", "change", "ok", "tips", "close", "cancel"],
@@ -56,21 +53,42 @@ const _sfc_main = create({
56
53
  const realpwd = ref();
57
54
  const comLen = computed(() => range(Number(props.length)));
58
55
  const show = ref(props.visible);
56
+ const refRandomId = Math.random().toString(36).slice(-8);
57
+ const randRef = ref(refRandomId);
58
+ const isWx = ref(false);
59
59
  function sureClick() {
60
60
  emit("ok", realInput.value);
61
61
  }
62
62
  function focus() {
63
- realpwd.value.focus();
63
+ let dom = "";
64
+ if (isWx.value) {
65
+ setTimeout(() => {
66
+ if (!document.getElementById("nut-input-real-taro-" + randRef.value))
67
+ return;
68
+ dom = document.getElementById("nut-input-real-taro-" + randRef.value);
69
+ if (!dom)
70
+ return;
71
+ dom.focus();
72
+ }, 150);
73
+ } else {
74
+ dom = document.getElementsByClassName("nut-input-real")[0];
75
+ let h = dom.children[0];
76
+ h.focus();
77
+ }
64
78
  }
65
79
  watch(() => props.visible, (value) => {
66
80
  show.value = value;
81
+ if (value) {
82
+ randRef.value = Math.random().toString(36).slice(-8);
83
+ if (Taro.getEnv() === "WEB") {
84
+ isWx.value = false;
85
+ } else {
86
+ isWx.value = true;
87
+ }
88
+ }
67
89
  });
68
90
  watch(() => props.modelValue, (value) => {
69
91
  realInput.value = value;
70
- emit("update:modelValue", value);
71
- }, {
72
- deep: true,
73
- immediate: true
74
92
  });
75
93
  function changeValue(e) {
76
94
  const input = e.target;
@@ -99,54 +117,46 @@ const _sfc_main = create({
99
117
  function onTips() {
100
118
  emit("tips");
101
119
  }
102
- function systemStyle() {
103
- let u = navigator.userAgent;
104
- let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1;
105
- let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
106
- if (isIOS) {
107
- return {
108
- paddingRight: "1200px"
109
- };
120
+ onMounted(() => {
121
+ eventCenter.once(getCurrentInstance().router.onReady, () => {
122
+ });
123
+ if (Taro.getEnv() === "WEB") {
124
+ isWx.value = false;
125
+ } else {
126
+ isWx.value = true;
110
127
  }
111
- if (isAndroid) {
112
- return {
113
- opacity: 0,
114
- zindex: 10
115
- };
116
- }
117
- }
128
+ });
118
129
  return {
119
130
  comLen,
120
131
  sureClick,
121
132
  realInput,
122
133
  realpwd,
123
- focus,
124
134
  range,
125
135
  changeValue,
126
136
  close,
127
137
  onTips,
138
+ focus,
128
139
  show,
129
- systemStyle,
130
- closeIcon
140
+ closeIcon,
141
+ isWx,
142
+ refRandomId,
143
+ randRef
131
144
  };
132
145
  }
133
146
  });
134
147
  const _hoisted_1 = { class: "nut-shortpsd-title" };
135
- const _hoisted_2 = { class: "nut-shortpsd-subtitle" };
136
- const _hoisted_3 = { class: "nut-input-normalw" };
137
- const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "nut-input-site" }, null, -1);
138
- const _hoisted_5 = {
148
+ const _hoisted_2 = { class: "nut-shortpsdWx-subtitle" };
149
+ const _hoisted_3 = ["id", "maxlength"];
150
+ const _hoisted_4 = { class: "nut-input-w" };
151
+ const _hoisted_5 = /* @__PURE__ */ createElementVNode("view", { class: "nut-input-site" }, null, -1);
152
+ const _hoisted_6 = {
139
153
  key: 0,
140
154
  class: "nut-shortpsd-icon"
141
155
  };
142
- const _hoisted_6 = { class: "nut-shortpsd-message" };
143
- const _hoisted_7 = { class: "nut-shortpsd-error" };
144
- const _hoisted_8 = {
145
- key: 0,
146
- class: "nut-shortpsd-forget"
147
- };
156
+ const _hoisted_7 = { class: "nut-shortpsd-message" };
157
+ const _hoisted_8 = { class: "nut-shortpsd-error" };
148
158
  const _hoisted_9 = {
149
- key: 0,
159
+ key: 1,
150
160
  class: "nut-shortpsd-footer"
151
161
  };
152
162
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
@@ -160,70 +170,82 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
160
170
  textAlign: "center"
161
171
  },
162
172
  visible: _ctx.show,
163
- "onUpdate:visible": _cache[6] || (_cache[6] = ($event) => _ctx.show = $event),
173
+ "onUpdate:visible": _cache[8] || (_cache[8] = ($event) => _ctx.show = $event),
164
174
  closeable: true,
165
175
  onClickCloseIcon: _ctx.closeIcon,
166
176
  "close-on-click-overlay": _ctx.closeOnClickOverlay,
167
- onClickOverlay: _ctx.close,
168
- isWrapTeleport: _ctx.isWrapTeleport
177
+ onClickOverlay: _ctx.close
169
178
  }, {
170
179
  default: withCtx(() => [
171
180
  createElementVNode("view", _hoisted_1, toDisplayString(_ctx.title), 1),
172
181
  createElementVNode("view", _hoisted_2, toDisplayString(_ctx.desc), 1),
173
- createElementVNode("div", _hoisted_3, [
174
- withDirectives(createElementVNode("input", {
182
+ _ctx.isWx && _ctx.visible ? withDirectives((openBlock(), createElementBlock("input", {
183
+ key: 0,
184
+ class: "nut-input-real-taro",
185
+ id: "nut-input-real-taro-" + _ctx.randRef,
186
+ type: "number",
187
+ maxlength: _ctx.length,
188
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.realInput = $event),
189
+ onInput: _cache[1] || (_cache[1] = (...args) => _ctx.changeValue && _ctx.changeValue(...args))
190
+ }, null, 40, _hoisted_3)), [
191
+ [vModelText, _ctx.realInput]
192
+ ]) : createCommentVNode("", true),
193
+ createElementVNode("view", _hoisted_4, [
194
+ !_ctx.isWx ? withDirectives((openBlock(), createElementBlock("input", {
195
+ key: 0,
175
196
  ref: "realpwd",
176
197
  class: "nut-input-real",
177
198
  type: "number",
178
199
  maxlength: "6",
179
- style: normalizeStyle(_ctx.systemStyle()),
180
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.realInput = $event),
181
- onInput: _cache[1] || (_cache[1] = (...args) => _ctx.changeValue && _ctx.changeValue(...args))
182
- }, null, 36), [
200
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.realInput = $event),
201
+ onInput: _cache[3] || (_cache[3] = (...args) => _ctx.changeValue && _ctx.changeValue(...args))
202
+ }, null, 544)), [
183
203
  [vModelText, _ctx.realInput]
184
- ]),
185
- _hoisted_4,
204
+ ]) : createCommentVNode("", true),
205
+ _hoisted_5,
186
206
  createElementVNode("view", {
187
- class: "nut-shortpsd-fake",
188
- onClick: _cache[2] || (_cache[2] = (...args) => _ctx.focus && _ctx.focus(...args))
207
+ class: "nut-shortpsd-fake-taro",
208
+ onClick: _cache[4] || (_cache[4] = (...args) => _ctx.focus && _ctx.focus(...args))
189
209
  }, [
190
- (openBlock(true), createElementBlock(Fragment, null, renderList(new Array(_ctx.comLen), (sublen, index2) => {
210
+ (openBlock(true), createElementBlock(Fragment, null, renderList(new Array(_ctx.comLen), (sublen, index) => {
191
211
  return openBlock(), createElementBlock("view", {
192
212
  class: "nut-shortpsd-li",
193
- key: index2
213
+ key: index
194
214
  }, [
195
- String(_ctx.realInput).length > index2 ? (openBlock(), createElementBlock("view", _hoisted_5)) : createCommentVNode("", true)
215
+ String(_ctx.realInput).length > index ? (openBlock(), createElementBlock("view", _hoisted_6)) : createCommentVNode("", true)
196
216
  ]);
197
217
  }), 128))
198
218
  ])
199
219
  ]),
200
- createElementVNode("view", _hoisted_6, [
201
- createElementVNode("view", _hoisted_7, toDisplayString(_ctx.errorMsg), 1),
202
- _ctx.tips ? (openBlock(), createElementBlock("view", _hoisted_8, [
220
+ createElementVNode("view", _hoisted_7, [
221
+ createElementVNode("view", _hoisted_8, toDisplayString(_ctx.errorMsg), 1),
222
+ _ctx.tips ? (openBlock(), createElementBlock("view", {
223
+ key: 0,
224
+ class: "nut-shortpsd-forget",
225
+ onClick: _cache[5] || (_cache[5] = (...args) => _ctx.onTips && _ctx.onTips(...args))
226
+ }, [
203
227
  createVNode(_component_nut_icon, {
204
228
  class: "icon",
205
229
  size: "11px",
206
230
  name: "tips"
207
231
  }),
208
- createElementVNode("view", {
209
- onClick: _cache[3] || (_cache[3] = (...args) => _ctx.onTips && _ctx.onTips(...args))
210
- }, toDisplayString(_ctx.tips), 1)
232
+ createElementVNode("view", null, toDisplayString(_ctx.tips), 1)
211
233
  ])) : createCommentVNode("", true)
212
234
  ]),
213
235
  !_ctx.noButton ? (openBlock(), createElementBlock("view", _hoisted_9, [
214
236
  createElementVNode("view", {
215
237
  class: "nut-shortpsd-cancle",
216
- onClick: _cache[4] || (_cache[4] = (...args) => _ctx.close && _ctx.close(...args))
238
+ onClick: _cache[6] || (_cache[6] = (...args) => _ctx.close && _ctx.close(...args))
217
239
  }, "\u53D6\u6D88"),
218
240
  createElementVNode("view", {
219
241
  class: "nut-shortpsd-sure",
220
- onClick: _cache[5] || (_cache[5] = (...args) => _ctx.sureClick && _ctx.sureClick(...args))
242
+ onClick: _cache[7] || (_cache[7] = (...args) => _ctx.sureClick && _ctx.sureClick(...args))
221
243
  }, "\u786E\u8BA4")
222
244
  ])) : createCommentVNode("", true)
223
245
  ]),
224
246
  _: 1
225
- }, 8, ["visible", "onClickCloseIcon", "close-on-click-overlay", "onClickOverlay", "isWrapTeleport"])
247
+ }, 8, ["visible", "onClickCloseIcon", "close-on-click-overlay", "onClickOverlay"])
226
248
  ]);
227
249
  }
228
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
229
- export { index as default };
250
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
251
+ export { index_taro as default };
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  /*!
21
- * @nutui/nutui v3.1.19-beta.0 Mon Mar 28 2022 17:50:21 GMT+0800 (中国标准时间)
21
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
22
22
  * (c) 2022 @jdf2e.
23
23
  * Released under the MIT License.
24
24
  */
@@ -37,8 +37,7 @@ const _sfc_main = create({
37
37
  setup: (props, context) => {
38
38
  const list = ref(null);
39
39
  const state = reactive({
40
- count: 1,
41
- observer: null
40
+ count: 1
42
41
  });
43
42
  const classes = computed(() => {
44
43
  const prefixCls = componentName;
@@ -58,7 +57,7 @@ const _sfc_main = create({
58
57
  };
59
58
  const handleSlots = () => {
60
59
  let childNodes = list.value.childNodes;
61
- if (childNodes.length) {
60
+ if (childNodes && childNodes.length) {
62
61
  childNodes = Array.from(childNodes).filter((item) => item.nodeType !== 3).map((item) => {
63
62
  return item;
64
63
  });
@@ -67,16 +66,6 @@ const _sfc_main = create({
67
66
  };
68
67
  onMounted(() => {
69
68
  handleSlots();
70
- state.observer = new MutationObserver(function() {
71
- state.count = 1;
72
- handleSlots();
73
- });
74
- state.observer.observe(list.value, {
75
- attributes: false,
76
- childList: true,
77
- characterData: false,
78
- subtree: false
79
- });
80
69
  });
81
70
  return __spreadProps(__spreadValues({}, toRefs(state)), {
82
71
  list,
@@ -100,5 +89,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
100
89
  ])
101
90
  ], 2);
102
91
  }
103
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
104
- export { index as default };
92
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
93
+ export { index_taro as default };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.19-beta.0 Mon Mar 28 2022 17:50:21 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,28 +1,10 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
1
  /*!
21
- * @nutui/nutui v3.1.19-beta.0 Mon Mar 28 2022 17:50:21 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
22
3
  * (c) 2022 @jdf2e.
23
4
  * Released under the MIT License.
24
5
  */
25
- import { ref, computed, reactive, onMounted, toRefs, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, withCtx, createTextVNode } from "vue";
6
+ import Taro from "@tarojs/taro";
7
+ import { computed, reactive, onMounted, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, withCtx, createTextVNode } from "vue";
26
8
  import { c as createComponent } from "./component.js";
27
9
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
28
10
  const { componentName, create } = createComponent("signature");
@@ -52,8 +34,6 @@ const _sfc_main = create({
52
34
  components: {},
53
35
  emits: ["confirm", "clear"],
54
36
  setup(props, { emit }) {
55
- const canvas = ref(null);
56
- const wrap = ref(null);
57
37
  const classes = computed(() => {
58
38
  const prefixCls = componentName;
59
39
  return {
@@ -62,125 +42,126 @@ const _sfc_main = create({
62
42
  };
63
43
  });
64
44
  const state = reactive({
45
+ canvas: null,
65
46
  canvasHeight: 0,
66
47
  canvasWidth: 0,
67
- ctx: null,
68
- isSupportTouch: "ontouchstart" in window,
69
- events: "ontouchstart" in window ? ["touchstart", "touchmove", "touchend", "touchleave"] : ["mousedown", "mousemove", "mouseup", "mouseleave"]
48
+ ctx: null
70
49
  });
71
- const isCanvasSupported = () => {
72
- let elem = document.createElement("canvas");
73
- return !!(elem.getContext && elem.getContext("2d"));
74
- };
75
- const addEvent = () => {
76
- canvas.value.addEventListener(state.events[0], startEventHandler, false);
77
- };
78
50
  const startEventHandler = (event) => {
79
51
  event.preventDefault();
80
52
  state.ctx.beginPath();
81
53
  state.ctx.lineWidth = props.lineWidth;
82
54
  state.ctx.strokeStyle = props.strokeStyle;
83
- canvas.value.addEventListener(state.events[1], moveEventHandler, false);
84
- canvas.value.addEventListener(state.events[2], endEventHandler, false);
85
- canvas.value.addEventListener(state.events[3], leaveEventHandler, false);
86
55
  };
87
56
  const moveEventHandler = (event) => {
88
57
  event.preventDefault();
89
- let evt = state.isSupportTouch ? event.touches[0] : event;
90
- let coverPos = canvas.value.getBoundingClientRect();
91
- let mouseX = evt.clientX - coverPos.left;
92
- let mouseY = evt.clientY - coverPos.top;
58
+ let evt = event.changedTouches[0];
59
+ let mouseX = evt.x;
60
+ let mouseY = evt.y;
93
61
  state.ctx.lineTo(mouseX, mouseY);
94
62
  state.ctx.stroke();
95
63
  };
96
64
  const endEventHandler = (event) => {
97
65
  event.preventDefault();
98
- canvas.value.removeEventListener(state.events[1], moveEventHandler, false);
99
- canvas.value.removeEventListener(state.events[2], endEventHandler, false);
100
66
  };
101
67
  const leaveEventHandler = (event) => {
102
68
  event.preventDefault();
103
- canvas.value.removeEventListener(state.events[1], moveEventHandler, false);
104
- canvas.value.removeEventListener(state.events[2], endEventHandler, false);
105
69
  };
106
70
  const clear = () => {
107
- canvas.value.addEventListener(state.events[2], endEventHandler, false);
108
71
  state.ctx.clearRect(0, 0, state.canvasWidth, state.canvasHeight);
109
72
  state.ctx.closePath();
110
73
  emit("clear");
111
74
  };
112
75
  const confirm = () => {
113
- onSave(canvas.value);
76
+ onSave();
114
77
  };
115
- const onSave = (canvas2) => {
116
- let dataurl;
117
- switch (props.type) {
118
- case "png":
119
- dataurl = canvas2.toDataURL("image/png");
120
- break;
121
- case "jpg":
122
- dataurl = canvas2.toDataURL("image/jpeg", 0.8);
123
- break;
78
+ const onSave = () => {
79
+ if (!state.canvas) {
80
+ return;
124
81
  }
125
- clear();
126
- emit("confirm", canvas2, dataurl);
82
+ Taro.createSelectorQuery().select("#spcanvas").fields({
83
+ node: true,
84
+ size: true
85
+ }).exec(async (res) => {
86
+ Taro.canvasToTempFilePath({
87
+ canvas: res[0].node,
88
+ fileType: props.type
89
+ }).then((res2) => {
90
+ emit("confirm", res2.tempFilePath);
91
+ }).catch((e) => {
92
+ emit("confirm", e);
93
+ });
94
+ });
127
95
  };
128
96
  onMounted(() => {
129
- if (isCanvasSupported()) {
130
- state.ctx = canvas.value.getContext("2d");
131
- state.canvasWidth = wrap.value.offsetWidth;
132
- state.canvasHeight = wrap.value.offsetHeight;
133
- addEvent();
134
- }
97
+ setTimeout(() => {
98
+ Taro.createSelectorQuery().select("#spcanvas").fields({
99
+ node: true,
100
+ size: true
101
+ }, function(res) {
102
+ const canvas = res.node;
103
+ const ctx = canvas.getContext("2d");
104
+ state.canvas = canvas;
105
+ state.ctx = ctx;
106
+ state.canvasWidth = res.width;
107
+ state.canvasHeight = res.height;
108
+ }).exec();
109
+ }, 500);
135
110
  });
136
- return __spreadProps(__spreadValues({}, toRefs(state)), { canvas, wrap, isCanvasSupported, confirm, clear, classes });
111
+ return {
112
+ confirm,
113
+ clear,
114
+ classes,
115
+ startEventHandler,
116
+ moveEventHandler,
117
+ endEventHandler,
118
+ leaveEventHandler
119
+ };
137
120
  }
138
121
  });
139
- const _hoisted_1 = {
140
- class: "nut-signature-inner",
141
- ref: "wrap"
142
- };
143
- const _hoisted_2 = ["height", "width"];
144
- const _hoisted_3 = {
145
- key: 1,
146
- class: "nut-signature-unsopport"
147
- };
148
- const _hoisted_4 = /* @__PURE__ */ createTextVNode("\u91CD\u7B7E");
149
- const _hoisted_5 = /* @__PURE__ */ createTextVNode("\u786E\u8BA4");
122
+ const _hoisted_1 = { class: "nut-signature-inner" };
123
+ const _hoisted_2 = /* @__PURE__ */ createTextVNode("\u91CD\u7B7E");
124
+ const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u786E\u8BA4");
150
125
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
151
126
  const _component_nut_button = resolveComponent("nut-button");
152
127
  return openBlock(), createElementBlock("div", {
153
128
  class: normalizeClass(_ctx.classes)
154
129
  }, [
155
130
  createElementVNode("div", _hoisted_1, [
156
- (() => _ctx.isCanvasSupported()) ? (openBlock(), createElementBlock("canvas", {
157
- key: 0,
158
- ref: "canvas",
159
- height: _ctx.canvasHeight,
160
- width: _ctx.canvasWidth
161
- }, null, 8, _hoisted_2)) : (openBlock(), createElementBlock("p", _hoisted_3, _toDisplayString(_ctx.unSupportTpl), 1))
162
- ], 512),
131
+ createElementVNode("canvas", {
132
+ class: "spcanvas",
133
+ id: "spcanvas",
134
+ canvasId: "spcanvas",
135
+ "canvas-id": "spcanvas",
136
+ type: "2d",
137
+ "disable-scroll": "true",
138
+ onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.startEventHandler && _ctx.startEventHandler(...args)),
139
+ onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.moveEventHandler && _ctx.moveEventHandler(...args)),
140
+ onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.endEventHandler && _ctx.endEventHandler(...args)),
141
+ onTouchleave: _cache[3] || (_cache[3] = (...args) => _ctx.leaveEventHandler && _ctx.leaveEventHandler(...args))
142
+ }, null, 32)
143
+ ]),
163
144
  createVNode(_component_nut_button, {
164
145
  class: "nut-signature-btn",
165
146
  type: "default",
166
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clear())
147
+ onClick: _cache[4] || (_cache[4] = ($event) => _ctx.clear())
167
148
  }, {
168
149
  default: withCtx(() => [
169
- _hoisted_4
150
+ _hoisted_2
170
151
  ]),
171
152
  _: 1
172
153
  }),
173
154
  createVNode(_component_nut_button, {
174
155
  class: "nut-signature-btn",
175
156
  type: "primary",
176
- onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirm())
157
+ onClick: _cache[5] || (_cache[5] = ($event) => _ctx.confirm())
177
158
  }, {
178
159
  default: withCtx(() => [
179
- _hoisted_5
160
+ _hoisted_3
180
161
  ]),
181
162
  _: 1
182
163
  })
183
164
  ], 2);
184
165
  }
185
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
186
- export { index as default };
166
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
167
+ export { index_taro as default };
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.19-beta.0 Mon Mar 28 2022 17:50:21 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
6
  import { c as createComponent } from "./component.js";
7
- import { toRefs, computed, onMounted, resolveComponent, openBlock, createElementBlock, renderSlot, createCommentVNode, createElementVNode, createBlock, normalizeClass, normalizeStyle, Fragment, renderList } from "vue";
7
+ import { toRefs, computed, onMounted, resolveComponent, openBlock, createElementBlock, renderSlot, createElementVNode, createBlock, normalizeClass, normalizeStyle, createCommentVNode, Fragment, renderList } from "vue";
8
8
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
9
9
  const component = {
10
10
  props: {
@@ -94,10 +94,7 @@ const _hoisted_2 = {
94
94
  key: 1,
95
95
  class: "skeleton"
96
96
  };
97
- const _hoisted_3 = {
98
- key: 0,
99
- class: "skeleton-animation"
100
- };
97
+ const _hoisted_3 = /* @__PURE__ */ createElementVNode("view", { class: "skeleton-animation" }, null, -1);
101
98
  const _hoisted_4 = { class: "content" };
102
99
  const _hoisted_5 = { class: "content-line" };
103
100
  const _hoisted_6 = {
@@ -109,7 +106,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
109
106
  return !_ctx.loading ? (openBlock(), createElementBlock("view", _hoisted_1, [
110
107
  renderSlot(_ctx.$slots, "default")
111
108
  ])) : (openBlock(), createElementBlock("view", _hoisted_2, [
112
- _ctx.animated ? (openBlock(), createElementBlock("view", _hoisted_3)) : createCommentVNode("", true),
109
+ _hoisted_3,
113
110
  createElementVNode("view", _hoisted_4, [
114
111
  _ctx.avatar ? (openBlock(), createBlock(_component_nut_avatar, {
115
112
  key: 0,
@@ -125,9 +122,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
125
122
  }, null, 6)) : createCommentVNode("", true),
126
123
  createElementVNode("view", _hoisted_5, [
127
124
  _ctx.title ? (openBlock(), createElementBlock("view", _hoisted_6)) : createCommentVNode("", true),
128
- (openBlock(true), createElementBlock(Fragment, null, renderList(Number(_ctx.row), (item, index2) => {
125
+ (openBlock(true), createElementBlock(Fragment, null, renderList(Number(_ctx.row), (item, index) => {
129
126
  return openBlock(), createElementBlock("view", {
130
- key: index2,
127
+ key: index,
131
128
  class: normalizeClass(_ctx.blockClass),
132
129
  style: normalizeStyle({ width: _ctx.width, height: _ctx.height })
133
130
  }, null, 6);
@@ -136,5 +133,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
136
133
  ])
137
134
  ]));
138
135
  }
139
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
140
- export { index as default };
136
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
137
+ export { index_taro as default };