@nutui/nutui 4.0.12-beta.1 → 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 +1 -1
  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 +50 -50
  135. package/dist/styles/themes/jdb.scss +50 -50
  136. package/dist/styles/themes/jddkh.scss +50 -50
  137. package/dist/styles/themes/jdt.scss +50 -50
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +2 -2
  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,20 +1,28 @@
1
- var v = Object.defineProperty, h = Object.defineProperties;
2
- var b = Object.getOwnPropertyDescriptors;
3
- var u = Object.getOwnPropertySymbols;
4
- var N = Object.prototype.hasOwnProperty, g = Object.prototype.propertyIsEnumerable;
5
- var f = (s, t, e) => t in s ? v(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, p = (s, t) => {
6
- for (var e in t || (t = {}))
7
- N.call(t, e) && f(s, e, t[e]);
8
- if (u)
9
- for (var e of u(t))
10
- g.call(t, e) && f(s, e, t[e]);
11
- return s;
12
- }, m = (s, t) => h(s, b(t));
13
- import { ref as x, reactive as y, computed as $, onMounted as w, toRefs as C, openBlock as S, createElementBlock as k, normalizeClass as A, createElementVNode as _, renderSlot as B } from "vue";
14
- import { c as E } from "./component-234624bc.js";
15
- import { _ as L } from "./_plugin-vue_export-helper-dad06003.js";
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
+ import { ref, reactive, computed, onMounted, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot } from "vue";
21
+ import { c as createComponent } from "./component-81a4c1d0.js";
22
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
16
23
  import "../locale/lang";
17
- const { componentName: M, create: z } = E("side-navbar"), D = z({
24
+ const { componentName, create } = createComponent("side-navbar");
25
+ const _sfc_main = create({
18
26
  props: {
19
27
  offset: {
20
28
  type: [String, Number],
@@ -22,53 +30,76 @@ const { componentName: M, create: z } = E("side-navbar"), D = z({
22
30
  }
23
31
  },
24
32
  emits: [],
25
- setup: (s) => {
26
- const t = x(null), e = y({
33
+ setup: (props) => {
34
+ const list = ref(null);
35
+ const state = reactive({
27
36
  count: 1,
28
37
  observer: null
29
- }), i = $(() => ({
30
- [M]: !0
31
- })), a = (r, o = 1) => {
32
- var d;
33
- for (let l = 0; l < r.length; l++) {
34
- let n = r[l];
35
- (d = n == null ? void 0 : n.children) != null && d[0] && (n.children[0].style.paddingLeft = +s.offset * o + "px", n.className.includes("nut-side-navbar-item") || a(Array.from(n.children[1].children), ++e.count));
38
+ });
39
+ const classes = computed(() => {
40
+ const prefixCls = componentName;
41
+ return {
42
+ [prefixCls]: true
43
+ };
44
+ });
45
+ const setPaddingLeft = (nodeList, level = 1) => {
46
+ var _a;
47
+ for (let i = 0; i < nodeList.length; i++) {
48
+ let item = nodeList[i];
49
+ if ((_a = item == null ? void 0 : item.children) == null ? void 0 : _a[0]) {
50
+ item.children[0].style.paddingLeft = +props.offset * level + "px";
51
+ if (!item.className.includes("nut-side-navbar-item")) {
52
+ setPaddingLeft(Array.from(item.children[1].children), ++state.count);
53
+ }
54
+ }
36
55
  }
37
- e.count--;
38
- }, c = () => {
39
- let r = t.value.childNodes;
40
- r.length && (r = Array.from(r).filter((o) => o.nodeType !== 3).map((o) => o), a(r));
56
+ state.count--;
41
57
  };
42
- return w(() => {
43
- c(), e.observer = new MutationObserver(function() {
44
- e.count = 1, c();
45
- }), e.observer.observe(t.value, {
46
- attributes: !1,
47
- childList: !0,
48
- characterData: !1,
49
- subtree: !0
58
+ const handleSlots = () => {
59
+ let childNodes = list.value.childNodes;
60
+ if (childNodes.length) {
61
+ childNodes = Array.from(childNodes).filter((item) => item.nodeType !== 3).map((item) => {
62
+ return item;
63
+ });
64
+ setPaddingLeft(childNodes);
65
+ }
66
+ };
67
+ onMounted(() => {
68
+ handleSlots();
69
+ state.observer = new MutationObserver(function() {
70
+ state.count = 1;
71
+ handleSlots();
50
72
  });
51
- }), m(p({}, C(e)), {
52
- list: t,
53
- classes: i
73
+ state.observer.observe(list.value, {
74
+ attributes: false,
75
+ childList: true,
76
+ characterData: false,
77
+ subtree: true
78
+ });
79
+ });
80
+ return __spreadProps(__spreadValues({}, toRefs(state)), {
81
+ list,
82
+ classes
54
83
  });
55
84
  }
56
- }), O = { class: "nut-side-navbar__content" }, P = {
85
+ });
86
+ const _hoisted_1 = { class: "nut-side-navbar__content" };
87
+ const _hoisted_2 = {
57
88
  class: "nut-side-navbar__content__list",
58
89
  ref: "list"
59
90
  };
60
- function R(s, t, e, i, a, c) {
61
- return S(), k("view", {
62
- class: A(s.classes)
91
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
92
+ return openBlock(), createElementBlock("view", {
93
+ class: normalizeClass(_ctx.classes)
63
94
  }, [
64
- _("view", O, [
65
- _("view", P, [
66
- B(s.$slots, "default")
95
+ createElementVNode("view", _hoisted_1, [
96
+ createElementVNode("view", _hoisted_2, [
97
+ renderSlot(_ctx.$slots, "default")
67
98
  ], 512)
68
99
  ])
69
100
  ], 2);
70
101
  }
71
- const G = /* @__PURE__ */ L(D, [["render", R]]);
102
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
72
103
  export {
73
- G as default
104
+ index as default
74
105
  };
@@ -1,8 +1,9 @@
1
- import { computed as r, openBlock as l, createElementBlock as a, normalizeClass as c, withModifiers as p, createElementVNode as m, toDisplayString as d } from "vue";
2
- import { c as f } from "./component-234624bc.js";
3
- import { _ as k } from "./_plugin-vue_export-helper-dad06003.js";
1
+ import { computed, openBlock, createElementBlock, normalizeClass, withModifiers, createElementVNode, toDisplayString } from "vue";
2
+ import { c as createComponent } from "./component-81a4c1d0.js";
3
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
4
4
  import "../locale/lang";
5
- const { componentName: u, create: C } = f("side-navbar-item"), _ = C({
5
+ const { componentName, create } = createComponent("side-navbar-item");
6
+ const _sfc_main = create({
6
7
  props: {
7
8
  title: {
8
9
  type: String,
@@ -14,25 +15,34 @@ const { componentName: u, create: C } = f("side-navbar-item"), _ = C({
14
15
  }
15
16
  },
16
17
  emits: ["click"],
17
- setup: (e, t) => ({
18
- classes: r(() => ({
19
- [u]: !0
20
- })),
21
- handleClick: () => {
22
- t.emit("click");
23
- }
24
- })
25
- }), y = ["ikey"], h = { class: "nut-side-navbar-item__title" };
26
- function $(e, t, s, i, o, g) {
27
- return l(), a("view", {
28
- class: c(e.classes),
29
- onClick: t[0] || (t[0] = p((...n) => e.handleClick && e.handleClick(...n), ["stop"])),
30
- ikey: e.ikey
18
+ setup: (props, context) => {
19
+ const classes = computed(() => {
20
+ const prefixCls = componentName;
21
+ return {
22
+ [prefixCls]: true
23
+ };
24
+ });
25
+ const handleClick = () => {
26
+ context.emit("click");
27
+ };
28
+ return {
29
+ classes,
30
+ handleClick
31
+ };
32
+ }
33
+ });
34
+ const _hoisted_1 = ["ikey"];
35
+ const _hoisted_2 = { class: "nut-side-navbar-item__title" };
36
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
37
+ return openBlock(), createElementBlock("view", {
38
+ class: normalizeClass(_ctx.classes),
39
+ onClick: _cache[0] || (_cache[0] = withModifiers((...args) => _ctx.handleClick && _ctx.handleClick(...args), ["stop"])),
40
+ ikey: _ctx.ikey
31
41
  }, [
32
- m("span", h, d(e.title), 1)
33
- ], 10, y);
42
+ createElementVNode("span", _hoisted_2, toDisplayString(_ctx.title), 1)
43
+ ], 10, _hoisted_1);
34
44
  }
35
- const B = /* @__PURE__ */ k(_, [["render", $]]);
45
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
36
46
  export {
37
- B as default
47
+ index as default
38
48
  };
@@ -1,22 +1,30 @@
1
- var $ = Object.defineProperty, B = Object.defineProperties;
2
- var P = Object.getOwnPropertyDescriptors;
3
- var h = Object.getOwnPropertySymbols;
4
- var U = Object.prototype.hasOwnProperty, V = Object.prototype.propertyIsEnumerable;
5
- var g = (e, s, n) => s in e ? $(e, s, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[s] = n, C = (e, s) => {
6
- for (var n in s || (s = {}))
7
- U.call(s, n) && g(e, n, s[n]);
8
- if (h)
9
- for (var n of h(s))
10
- V.call(s, n) && g(e, n, s[n]);
11
- return e;
12
- }, y = (e, s) => B(e, P(s));
13
- import { ref as E, computed as j, reactive as X, onMounted as Y, toRefs as z, resolveComponent as M, openBlock as S, createElementBlock as w, normalizeClass as O, createElementVNode as k, withDirectives as q, vShow as A, toDisplayString as p, createCommentVNode as F, createVNode as L, withCtx as b, createTextVNode as D } from "vue";
14
- import { c as G } from "./component-234624bc.js";
15
- import x from "./Button.js";
16
- import { _ as I } from "./_plugin-vue_export-helper-dad06003.js";
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
+ import { ref, computed, reactive, onMounted, toRefs, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, withDirectives, vShow, toDisplayString, createCommentVNode, createVNode, withCtx, createTextVNode } from "vue";
21
+ import { c as createComponent } from "./component-81a4c1d0.js";
22
+ import Button from "./Button.js";
23
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
17
24
  import "../locale/lang";
18
25
  import "@nutui/icons-vue";
19
- const { componentName: J, create: K, translate: Q } = G("signature"), Z = K({
26
+ const { componentName, create, translate } = createComponent("signature");
27
+ const _sfc_main = create({
20
28
  props: {
21
29
  customClass: {
22
30
  type: String,
@@ -28,7 +36,15 @@ const { componentName: J, create: K, translate: Q } = G("signature"), Z = K({
28
36
  },
29
37
  strokeStyle: {
30
38
  type: String,
31
- default: () => document.getElementsByTagName("body")[0].className.indexOf("nut-theme-dark") == -1 ? "#000" : "#fff"
39
+ default: () => {
40
+ let bodyDom = document.getElementsByTagName("body");
41
+ let clsName = bodyDom[0]["className"];
42
+ if (clsName.indexOf("nut-theme-dark") == -1) {
43
+ return "#000";
44
+ } else {
45
+ return "#fff";
46
+ }
47
+ }
32
48
  },
33
49
  type: {
34
50
  type: String,
@@ -40,107 +56,154 @@ const { componentName: J, create: K, translate: Q } = G("signature"), Z = K({
40
56
  }
41
57
  },
42
58
  components: {
43
- [x.name]: x
59
+ [Button.name]: Button
44
60
  },
45
61
  emits: ["start", "end", "signing", "confirm", "clear"],
46
- setup(e, { emit: s }) {
47
- const n = E(null), l = E(null), m = j(() => ({
48
- [J]: !0,
49
- [`${e.customClass}`]: e.customClass
50
- })), a = X({
62
+ setup(props, { emit }) {
63
+ const canvas = ref(null);
64
+ const wrap = ref(null);
65
+ const classes = computed(() => {
66
+ const prefixCls = componentName;
67
+ return {
68
+ [prefixCls]: true,
69
+ [`${props.customClass}`]: props.customClass
70
+ };
71
+ });
72
+ const state = reactive({
51
73
  canvasHeight: 0,
52
74
  canvasWidth: 0,
53
75
  ctx: null,
54
76
  isSupportTouch: "ontouchstart" in window,
55
77
  events: "ontouchstart" in window ? ["touchstart", "touchmove", "touchend", "touchleave"] : ["mousedown", "mousemove", "mouseup", "mouseleave"]
56
- }), r = () => {
57
- let t = document.createElement("canvas");
58
- return !!(t.getContext && t.getContext("2d"));
59
- }, c = () => {
60
- n.value.addEventListener(a.events[0], N, !1);
61
- }, N = (t) => {
62
- t.preventDefault(), a.ctx.beginPath(), a.ctx.lineWidth = e.lineWidth, a.ctx.strokeStyle = e.strokeStyle, s("start"), n.value.addEventListener(a.events[1], d, !1), n.value.addEventListener(a.events[2], i, !1), n.value.addEventListener(a.events[3], H, !1);
63
- }, d = (t) => {
64
- t.preventDefault();
65
- let o = a.isSupportTouch ? t.touches[0] : t;
66
- s("signing", o);
67
- let u = n.value.getBoundingClientRect(), v = o.clientX - u.left, _ = o.clientY - u.top;
68
- a.ctx.lineTo(v, _), a.ctx.stroke();
69
- }, i = (t) => {
70
- t.preventDefault(), s("end"), n.value.removeEventListener(a.events[1], d, !1), n.value.removeEventListener(a.events[2], i, !1);
71
- }, H = (t) => {
72
- t.preventDefault(), n.value.removeEventListener(a.events[1], d, !1), n.value.removeEventListener(a.events[2], i, !1);
73
- }, T = () => {
74
- n.value.addEventListener(a.events[2], i, !1), a.ctx.clearRect(0, 0, a.canvasWidth, a.canvasHeight), a.ctx.closePath(), s("clear");
75
- }, W = () => {
76
- R(n.value);
77
- }, f = (t) => {
78
- if (!t)
79
- return !0;
80
- var o = document.createElement("canvas");
81
- return o.width = t.width, o.height = t.height, (t == null ? void 0 : t.toDataURL()) == o.toDataURL();
82
- }, R = (t) => {
83
- let o;
84
- switch (e.type) {
78
+ });
79
+ const isCanvasSupported = () => {
80
+ let elem = document.createElement("canvas");
81
+ return !!(elem.getContext && elem.getContext("2d"));
82
+ };
83
+ const addEvent = () => {
84
+ canvas.value.addEventListener(state.events[0], startEventHandler, false);
85
+ };
86
+ const startEventHandler = (event) => {
87
+ event.preventDefault();
88
+ state.ctx.beginPath();
89
+ state.ctx.lineWidth = props.lineWidth;
90
+ state.ctx.strokeStyle = props.strokeStyle;
91
+ emit("start");
92
+ canvas.value.addEventListener(state.events[1], moveEventHandler, false);
93
+ canvas.value.addEventListener(state.events[2], endEventHandler, false);
94
+ canvas.value.addEventListener(state.events[3], leaveEventHandler, false);
95
+ };
96
+ const moveEventHandler = (event) => {
97
+ event.preventDefault();
98
+ let evt = state.isSupportTouch ? event.touches[0] : event;
99
+ emit("signing", evt);
100
+ let coverPos = canvas.value.getBoundingClientRect();
101
+ let mouseX = evt.clientX - coverPos.left;
102
+ let mouseY = evt.clientY - coverPos.top;
103
+ state.ctx.lineTo(mouseX, mouseY);
104
+ state.ctx.stroke();
105
+ };
106
+ const endEventHandler = (event) => {
107
+ event.preventDefault();
108
+ emit("end");
109
+ canvas.value.removeEventListener(state.events[1], moveEventHandler, false);
110
+ canvas.value.removeEventListener(state.events[2], endEventHandler, false);
111
+ };
112
+ const leaveEventHandler = (event) => {
113
+ event.preventDefault();
114
+ canvas.value.removeEventListener(state.events[1], moveEventHandler, false);
115
+ canvas.value.removeEventListener(state.events[2], endEventHandler, false);
116
+ };
117
+ const clear = () => {
118
+ canvas.value.addEventListener(state.events[2], endEventHandler, false);
119
+ state.ctx.clearRect(0, 0, state.canvasWidth, state.canvasHeight);
120
+ state.ctx.closePath();
121
+ emit("clear");
122
+ };
123
+ const confirm = () => {
124
+ onSave(canvas.value);
125
+ };
126
+ const isCanvasBlank = (canvas2) => {
127
+ if (!canvas2) {
128
+ return true;
129
+ }
130
+ var blank = document.createElement("canvas");
131
+ blank.width = canvas2.width;
132
+ blank.height = canvas2.height;
133
+ return (canvas2 == null ? void 0 : canvas2.toDataURL()) == blank.toDataURL();
134
+ };
135
+ const onSave = (canvas2) => {
136
+ let dataurl;
137
+ switch (props.type) {
85
138
  case "png":
86
- o = t.toDataURL("image/png");
139
+ dataurl = canvas2.toDataURL("image/png");
87
140
  break;
88
141
  case "jpg":
89
- o = t.toDataURL("image/jpeg", 0.8);
142
+ dataurl = canvas2.toDataURL("image/jpeg", 0.8);
90
143
  break;
91
144
  }
92
- const u = f(t) ? "请绘制签名" : t, v = f(t) ? "" : o;
93
- s("confirm", u, v);
145
+ const _canvas = isCanvasBlank(canvas2) ? "请绘制签名" : canvas2;
146
+ const _filePath = isCanvasBlank(canvas2) ? "" : dataurl;
147
+ emit("confirm", _canvas, _filePath);
94
148
  };
95
- return Y(() => {
96
- r() && (a.ctx = n.value.getContext("2d"), a.canvasWidth = l.value.offsetWidth, a.canvasHeight = l.value.offsetHeight, c());
97
- }), y(C({}, z(a)), { canvas: n, wrap: l, isCanvasSupported: r, confirm: W, clear: T, classes: m, translate: Q });
149
+ onMounted(() => {
150
+ if (isCanvasSupported()) {
151
+ state.ctx = canvas.value.getContext("2d");
152
+ state.canvasWidth = wrap.value.offsetWidth;
153
+ state.canvasHeight = wrap.value.offsetHeight;
154
+ addEvent();
155
+ }
156
+ });
157
+ return __spreadProps(__spreadValues({}, toRefs(state)), { canvas, wrap, isCanvasSupported, confirm, clear, classes, translate });
98
158
  }
99
- }), ee = {
159
+ });
160
+ const _hoisted_1 = {
100
161
  class: "nut-signature-inner",
101
162
  ref: "wrap"
102
- }, te = ["height", "width"], ne = {
163
+ };
164
+ const _hoisted_2 = ["height", "width"];
165
+ const _hoisted_3 = {
103
166
  key: 0,
104
167
  class: "nut-signature-unsopport"
105
168
  };
106
- function se(e, s, n, l, m, a) {
107
- const r = M("nut-button");
108
- return S(), w("div", {
109
- class: O(e.classes)
169
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
170
+ const _component_nut_button = resolveComponent("nut-button");
171
+ return openBlock(), createElementBlock("div", {
172
+ class: normalizeClass(_ctx.classes)
110
173
  }, [
111
- k("div", ee, [
112
- q(k("canvas", {
174
+ createElementVNode("div", _hoisted_1, [
175
+ withDirectives(createElementVNode("canvas", {
113
176
  ref: "canvas",
114
- height: e.canvasHeight,
115
- width: e.canvasWidth
116
- }, null, 8, te), [
117
- [A, e.isCanvasSupported()]
177
+ height: _ctx.canvasHeight,
178
+ width: _ctx.canvasWidth
179
+ }, null, 8, _hoisted_2), [
180
+ [vShow, _ctx.isCanvasSupported()]
118
181
  ]),
119
- e.isCanvasSupported() ? F("", !0) : (S(), w("p", ne, p(e.unSupportTpl || e.translate("unSupportTpl")), 1))
182
+ !_ctx.isCanvasSupported() ? (openBlock(), createElementBlock("p", _hoisted_3, toDisplayString(_ctx.unSupportTpl || _ctx.translate("unSupportTpl")), 1)) : createCommentVNode("", true)
120
183
  ], 512),
121
- L(r, {
184
+ createVNode(_component_nut_button, {
122
185
  class: "nut-signature-btn",
123
186
  type: "default",
124
- onClick: s[0] || (s[0] = (c) => e.clear())
187
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clear())
125
188
  }, {
126
- default: b(() => [
127
- D(p(e.translate("reSign")), 1)
189
+ default: withCtx(() => [
190
+ createTextVNode(toDisplayString(_ctx.translate("reSign")), 1)
128
191
  ]),
129
192
  _: 1
130
193
  }),
131
- L(r, {
194
+ createVNode(_component_nut_button, {
132
195
  class: "nut-signature-btn",
133
196
  type: "primary",
134
- onClick: s[1] || (s[1] = (c) => e.confirm())
197
+ onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirm())
135
198
  }, {
136
- default: b(() => [
137
- D(p(e.translate("confirm")), 1)
199
+ default: withCtx(() => [
200
+ createTextVNode(toDisplayString(_ctx.translate("confirm")), 1)
138
201
  ]),
139
202
  _: 1
140
203
  })
141
204
  ], 2);
142
205
  }
143
- const de = /* @__PURE__ */ I(Z, [["render", se]]);
206
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
144
207
  export {
145
- de as default
208
+ index as default
146
209
  };