@nutui/nutui 4.0.9 → 4.0.10

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 (168) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/nutui.es.js +1 -1
  3. package/dist/nutui.js +15382 -0
  4. package/dist/nutui.umd.js +1 -7
  5. package/dist/packages/_es/ActionSheet.js +78 -111
  6. package/dist/packages/_es/Address.js +250 -375
  7. package/dist/packages/_es/AddressList.js +269 -354
  8. package/dist/packages/_es/Animate.js +41 -58
  9. package/dist/packages/_es/Audio.js +128 -197
  10. package/dist/packages/_es/AudioOperate.js +60 -71
  11. package/dist/packages/_es/Avatar.js +66 -89
  12. package/dist/packages/_es/AvatarGroup.js +23 -31
  13. package/dist/packages/_es/Backtop.js +59 -99
  14. package/dist/packages/_es/Badge.js +36 -47
  15. package/dist/packages/_es/Barrage.js +68 -147
  16. package/dist/packages/_es/Button.js +47 -66
  17. package/dist/packages/_es/Calendar.js +135 -157
  18. package/dist/packages/_es/CalendarItem.js +6 -6
  19. package/dist/packages/_es/Card.js +42 -56
  20. package/dist/packages/_es/Cascader.js +315 -474
  21. package/dist/packages/_es/Category.js +29 -39
  22. package/dist/packages/_es/CategoryPane.js +57 -83
  23. package/dist/packages/_es/Cell.js +56 -71
  24. package/dist/packages/_es/CellGroup.js +19 -27
  25. package/dist/packages/_es/Checkbox.js +109 -156
  26. package/dist/packages/_es/CheckboxGroup.js +38 -59
  27. package/dist/packages/_es/CircleProgress.js +67 -96
  28. package/dist/packages/_es/Col.js +23 -31
  29. package/dist/packages/_es/Collapse.js +33 -58
  30. package/dist/packages/_es/CollapseItem.js +78 -108
  31. package/dist/packages/_es/Comment.js +207 -279
  32. package/dist/packages/_es/ConfigProvider.js +37 -55
  33. package/dist/packages/_es/Countdown.js +100 -212
  34. package/dist/packages/_es/Countup.js +232 -445
  35. package/dist/packages/_es/DatePicker.js +162 -265
  36. package/dist/packages/_es/Dialog.js +161 -213
  37. package/dist/packages/_es/Divider.js +42 -57
  38. package/dist/packages/_es/Drag.js +70 -153
  39. package/dist/packages/_es/Ecard.js +64 -104
  40. package/dist/packages/_es/Elevator.js +143 -219
  41. package/dist/packages/_es/Ellipsis.js +95 -178
  42. package/dist/packages/_es/Empty.js +23 -39
  43. package/dist/packages/_es/FixedNav.js +93 -116
  44. package/dist/packages/_es/Form.js +107 -178
  45. package/dist/packages/_es/FormItem.js +48 -61
  46. package/dist/packages/_es/Grid.js +5 -6
  47. package/dist/packages/_es/GridItem.js +58 -84
  48. package/dist/packages/_es/Image.js +90 -129
  49. package/dist/packages/_es/ImagePreview.js +256 -412
  50. package/dist/packages/_es/Indicator.js +30 -34
  51. package/dist/packages/_es/InfiniteLoading.js +83 -136
  52. package/dist/packages/_es/Input.js +160 -264
  53. package/dist/packages/_es/InputNumber.js +81 -117
  54. package/dist/packages/_es/Interceptor-6e26b757.js +18 -0
  55. package/dist/packages/_es/Invoice.js +104 -130
  56. package/dist/packages/_es/Layout.js +3 -4
  57. package/dist/packages/_es/List.js +117 -215
  58. package/dist/packages/_es/Menu.js +96 -152
  59. package/dist/packages/_es/MenuItem.js +117 -172
  60. package/dist/packages/_es/Navbar.js +103 -119
  61. package/dist/packages/_es/Noticebar.js +197 -312
  62. package/dist/packages/_es/Notify.js +110 -166
  63. package/dist/packages/_es/NumberKeyboard.js +127 -202
  64. package/dist/packages/_es/Overlay.js +52 -80
  65. package/dist/packages/_es/Pagination.js +70 -100
  66. package/dist/packages/_es/Picker.js +275 -441
  67. package/dist/packages/_es/Popover.js +122 -225
  68. package/dist/packages/_es/Popup.js +4 -4
  69. package/dist/packages/_es/Price.js +44 -82
  70. package/dist/packages/_es/Progress.js +63 -79
  71. package/dist/packages/_es/PullRefresh.js +95 -173
  72. package/dist/packages/_es/Radio.js +4 -4
  73. package/dist/packages/_es/RadioGroup.js +3 -3
  74. package/dist/packages/_es/Range.js +204 -347
  75. package/dist/packages/_es/Rate.js +92 -141
  76. package/dist/packages/_es/Row.js +21 -27
  77. package/dist/packages/_es/Searchbar.js +130 -179
  78. package/dist/packages/_es/ShortPassword.js +69 -93
  79. package/dist/packages/_es/SideNavbar.js +49 -80
  80. package/dist/packages/_es/SideNavbarItem.js +22 -32
  81. package/dist/packages/_es/Signature.js +83 -146
  82. package/dist/packages/_es/Skeleton.js +110 -130
  83. package/dist/packages/_es/Sku.js +250 -343
  84. package/dist/packages/_es/Step.js +59 -86
  85. package/dist/packages/_es/Steps.js +26 -31
  86. package/dist/packages/_es/Sticky.js +4 -4
  87. package/dist/packages/_es/SubSideNavbar.js +52 -74
  88. package/dist/packages/_es/Swipe.js +83 -155
  89. package/dist/packages/_es/Swiper.js +174 -311
  90. package/dist/packages/_es/SwiperItem.js +28 -44
  91. package/dist/packages/_es/Switch.js +55 -68
  92. package/dist/packages/_es/TabPane.js +30 -41
  93. package/dist/packages/_es/Tabbar.js +41 -52
  94. package/dist/packages/_es/TabbarItem.js +61 -82
  95. package/dist/packages/_es/Table.js +109 -165
  96. package/dist/packages/_es/Tabs.js +240 -388
  97. package/dist/packages/_es/Tag.js +44 -61
  98. package/dist/packages/_es/Textarea.js +80 -124
  99. package/dist/packages/_es/TimeDetail.js +49 -76
  100. package/dist/packages/_es/TimePannel.js +34 -48
  101. package/dist/packages/_es/TimeSelect.js +47 -68
  102. package/dist/packages/_es/Toast.js +144 -218
  103. package/dist/packages/_es/Tour.js +138 -192
  104. package/dist/packages/_es/TrendArrow.js +57 -77
  105. package/dist/packages/_es/Uploader.js +234 -359
  106. package/dist/packages/_es/Video.js +191 -316
  107. package/dist/packages/_es/Watermark.js +84 -117
  108. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +9 -0
  109. package/dist/packages/_es/common-d218746f.js +116 -0
  110. package/dist/packages/_es/component-234624bc.js +89 -0
  111. package/dist/packages/_es/index-14dfadc4.js +561 -0
  112. package/dist/packages/_es/index-192a3ef6.js +29 -0
  113. package/dist/packages/_es/index-360c5092.js +210 -0
  114. package/dist/packages/_es/index-496e6e05.js +24 -0
  115. package/dist/packages/_es/index-50eed3d9.js +7 -0
  116. package/dist/packages/_es/index-53ec2d4d.js +34 -0
  117. package/dist/packages/_es/index-fadb0974.js +8 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +43 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +77 -0
  120. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +110 -0
  121. package/dist/packages/_es/mountComponent-6d4ff200.js +23 -0
  122. package/dist/packages/_es/pxCheck-38173291.js +4 -0
  123. package/dist/packages/_es/raf-a74f1a06.js +16 -0
  124. package/dist/packages/_es/renderIcon-47498b32.js +5 -0
  125. package/dist/packages/col/index.scss +2 -2
  126. package/dist/packages/menuitem/index.scss +7 -10
  127. package/dist/packages/searchbar/index.scss +4 -0
  128. package/dist/smartips/web-types.json +2 -2
  129. package/dist/style.css +1 -1
  130. package/dist/styles/themes/default.scss +158 -55
  131. package/dist/styles/themes/jdb.scss +158 -55
  132. package/dist/styles/themes/jddkh.scss +158 -55
  133. package/dist/styles/themes/jdt.scss +158 -55
  134. package/dist/types/__VUE/address/index.vue.d.ts +1 -1
  135. package/dist/types/__VUE/collapseitem/index.vue.d.ts +110 -3
  136. package/dist/types/__VUE/image/index.vue.d.ts +2 -2
  137. package/dist/types/__VUE/menu/index.vue.d.ts +0 -2
  138. package/dist/types/__VUE/menuitem/index.vue.d.ts +9 -17
  139. package/dist/types/__VUE/navbar/index.vue.d.ts +1 -1
  140. package/dist/types/__VUE/picker/usePicker.d.ts +1 -1
  141. package/dist/types/__VUE/rate/index.vue.d.ts +110 -3
  142. package/dist/types/__VUE/row/index.vue.d.ts +1 -1
  143. package/dist/types/__VUE/searchbar/index.vue.d.ts +121 -5
  144. package/dist/types/__VUE/skeleton/index.vue.d.ts +2 -2
  145. package/dist/types/__VUE/swiper/index.vue.d.ts +1 -1
  146. package/dist/types/__VUE/table/common.d.ts +55 -2
  147. package/dist/types/__VUE/timeselect/index.vue.d.ts +1 -1
  148. package/dist/types/__VUE/watermark/index.vue.d.ts +1 -1
  149. package/dist/types/index.d.ts +1 -1
  150. package/package.json +2 -2
  151. package/dist/packages/_es/Interceptor-956b24fc.js +0 -29
  152. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +0 -10
  153. package/dist/packages/_es/common-b9a5e726.js +0 -145
  154. package/dist/packages/_es/component-81a4c1d0.js +0 -145
  155. package/dist/packages/_es/index-29892cda.js +0 -33
  156. package/dist/packages/_es/index-43c34ac6.js +0 -30
  157. package/dist/packages/_es/index-54d03fc1.js +0 -8
  158. package/dist/packages/_es/index-79c5dc33.js +0 -10
  159. package/dist/packages/_es/index-7a7385e4.js +0 -67
  160. package/dist/packages/_es/index-87422be8.js +0 -942
  161. package/dist/packages/_es/index-da0a7662.js +0 -259
  162. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +0 -46
  163. package/dist/packages/_es/index.vue_vue_type_script_lang-442e4704.js +0 -98
  164. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +0 -151
  165. package/dist/packages/_es/mountComponent-8b24c346.js +0 -39
  166. package/dist/packages/_es/pxCheck-c6b9f6b7.js +0 -6
  167. package/dist/packages/_es/raf-729dad54.js +0 -25
  168. package/dist/packages/_es/renderIcon-3d0fd47c.js +0 -9
@@ -1,28 +1,20 @@
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";
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";
23
16
  import "../locale/lang";
24
- const { componentName, create } = createComponent("side-navbar");
25
- const _sfc_main = create({
17
+ const { componentName: M, create: z } = E("side-navbar"), D = z({
26
18
  props: {
27
19
  offset: {
28
20
  type: [String, Number],
@@ -30,76 +22,53 @@ const _sfc_main = create({
30
22
  }
31
23
  },
32
24
  emits: [],
33
- setup: (props) => {
34
- const list = ref(null);
35
- const state = reactive({
25
+ setup: (s) => {
26
+ const t = x(null), e = y({
36
27
  count: 1,
37
28
  observer: null
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
- }
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));
55
36
  }
56
- state.count--;
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));
57
41
  };
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();
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
72
50
  });
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
51
+ }), m(p({}, C(e)), {
52
+ list: t,
53
+ classes: i
83
54
  });
84
55
  }
85
- });
86
- const _hoisted_1 = { class: "nut-side-navbar__content" };
87
- const _hoisted_2 = {
56
+ }), O = { class: "nut-side-navbar__content" }, P = {
88
57
  class: "nut-side-navbar__content__list",
89
58
  ref: "list"
90
59
  };
91
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
92
- return openBlock(), createElementBlock("view", {
93
- class: normalizeClass(_ctx.classes)
60
+ function R(s, t, e, i, a, c) {
61
+ return S(), k("view", {
62
+ class: A(s.classes)
94
63
  }, [
95
- createElementVNode("view", _hoisted_1, [
96
- createElementVNode("view", _hoisted_2, [
97
- renderSlot(_ctx.$slots, "default")
64
+ _("view", O, [
65
+ _("view", P, [
66
+ B(s.$slots, "default")
98
67
  ], 512)
99
68
  ])
100
69
  ], 2);
101
70
  }
102
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
71
+ const G = /* @__PURE__ */ L(D, [["render", R]]);
103
72
  export {
104
- index as default
73
+ G as default
105
74
  };
@@ -1,9 +1,8 @@
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";
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";
4
4
  import "../locale/lang";
5
- const { componentName, create } = createComponent("side-navbar-item");
6
- const _sfc_main = create({
5
+ const { componentName: u, create: C } = f("side-navbar-item"), _ = C({
7
6
  props: {
8
7
  title: {
9
8
  type: String,
@@ -15,34 +14,25 @@ const _sfc_main = create({
15
14
  }
16
15
  },
17
16
  emits: ["click"],
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
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
41
31
  }, [
42
- createElementVNode("span", _hoisted_2, toDisplayString(_ctx.title), 1)
43
- ], 10, _hoisted_1);
32
+ m("span", h, d(e.title), 1)
33
+ ], 10, y);
44
34
  }
45
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
35
+ const B = /* @__PURE__ */ k(_, [["render", $]]);
46
36
  export {
47
- index as default
37
+ B as default
48
38
  };
@@ -1,30 +1,22 @@
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";
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";
24
17
  import "../locale/lang";
25
18
  import "@nutui/icons-vue";
26
- const { componentName, create, translate } = createComponent("signature");
27
- const _sfc_main = create({
19
+ const { componentName: J, create: K, translate: Q } = G("signature"), Z = K({
28
20
  props: {
29
21
  customClass: {
30
22
  type: String,
@@ -36,15 +28,7 @@ const _sfc_main = create({
36
28
  },
37
29
  strokeStyle: {
38
30
  type: String,
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
- }
31
+ default: () => document.getElementsByTagName("body")[0].className.indexOf("nut-theme-dark") == -1 ? "#000" : "#fff"
48
32
  },
49
33
  type: {
50
34
  type: String,
@@ -56,154 +40,107 @@ const _sfc_main = create({
56
40
  }
57
41
  },
58
42
  components: {
59
- [Button.name]: Button
43
+ [x.name]: x
60
44
  },
61
45
  emits: ["start", "end", "signing", "confirm", "clear"],
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({
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({
73
51
  canvasHeight: 0,
74
52
  canvasWidth: 0,
75
53
  ctx: null,
76
54
  isSupportTouch: "ontouchstart" in window,
77
55
  events: "ontouchstart" in window ? ["touchstart", "touchmove", "touchend", "touchleave"] : ["mousedown", "mousemove", "mouseup", "mouseleave"]
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) {
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) {
138
85
  case "png":
139
- dataurl = canvas2.toDataURL("image/png");
86
+ o = t.toDataURL("image/png");
140
87
  break;
141
88
  case "jpg":
142
- dataurl = canvas2.toDataURL("image/jpeg", 0.8);
89
+ o = t.toDataURL("image/jpeg", 0.8);
143
90
  break;
144
91
  }
145
- const _canvas = isCanvasBlank(canvas2) ? "请绘制签名" : canvas2;
146
- const _filePath = isCanvasBlank(canvas2) ? "" : dataurl;
147
- emit("confirm", _canvas, _filePath);
92
+ const u = f(t) ? "请绘制签名" : t, v = f(t) ? "" : o;
93
+ s("confirm", u, v);
148
94
  };
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 });
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 });
158
98
  }
159
- });
160
- const _hoisted_1 = {
99
+ }), ee = {
161
100
  class: "nut-signature-inner",
162
101
  ref: "wrap"
163
- };
164
- const _hoisted_2 = ["height", "width"];
165
- const _hoisted_3 = {
102
+ }, te = ["height", "width"], ne = {
166
103
  key: 0,
167
104
  class: "nut-signature-unsopport"
168
105
  };
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)
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)
173
110
  }, [
174
- createElementVNode("div", _hoisted_1, [
175
- withDirectives(createElementVNode("canvas", {
111
+ k("div", ee, [
112
+ q(k("canvas", {
176
113
  ref: "canvas",
177
- height: _ctx.canvasHeight,
178
- width: _ctx.canvasWidth
179
- }, null, 8, _hoisted_2), [
180
- [vShow, _ctx.isCanvasSupported()]
114
+ height: e.canvasHeight,
115
+ width: e.canvasWidth
116
+ }, null, 8, te), [
117
+ [A, e.isCanvasSupported()]
181
118
  ]),
182
- !_ctx.isCanvasSupported() ? (openBlock(), createElementBlock("p", _hoisted_3, toDisplayString(_ctx.unSupportTpl || _ctx.translate("unSupportTpl")), 1)) : createCommentVNode("", true)
119
+ e.isCanvasSupported() ? F("", !0) : (S(), w("p", ne, p(e.unSupportTpl || e.translate("unSupportTpl")), 1))
183
120
  ], 512),
184
- createVNode(_component_nut_button, {
121
+ L(r, {
185
122
  class: "nut-signature-btn",
186
123
  type: "default",
187
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clear())
124
+ onClick: s[0] || (s[0] = (c) => e.clear())
188
125
  }, {
189
- default: withCtx(() => [
190
- createTextVNode(toDisplayString(_ctx.translate("reSign")), 1)
126
+ default: b(() => [
127
+ D(p(e.translate("reSign")), 1)
191
128
  ]),
192
129
  _: 1
193
130
  }),
194
- createVNode(_component_nut_button, {
131
+ L(r, {
195
132
  class: "nut-signature-btn",
196
133
  type: "primary",
197
- onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirm())
134
+ onClick: s[1] || (s[1] = (c) => e.confirm())
198
135
  }, {
199
- default: withCtx(() => [
200
- createTextVNode(toDisplayString(_ctx.translate("confirm")), 1)
136
+ default: b(() => [
137
+ D(p(e.translate("confirm")), 1)
201
138
  ]),
202
139
  _: 1
203
140
  })
204
141
  ], 2);
205
142
  }
206
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
143
+ const de = /* @__PURE__ */ I(Z, [["render", se]]);
207
144
  export {
208
- index as default
145
+ de as default
209
146
  };