@nutui/nutui 4.0.11 → 4.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nutui.es.js +1 -1
- package/dist/nutui.js +2 -2
- package/dist/nutui.umd.js +1 -1
- package/dist/packages/_es/ActionSheet.js +111 -78
- package/dist/packages/_es/Address.js +375 -250
- package/dist/packages/_es/AddressList.js +354 -269
- package/dist/packages/_es/Animate.js +58 -41
- package/dist/packages/_es/Audio.js +197 -128
- package/dist/packages/_es/AudioOperate.js +71 -60
- package/dist/packages/_es/Avatar.js +89 -66
- package/dist/packages/_es/AvatarGroup.js +31 -23
- package/dist/packages/_es/Backtop.js +99 -59
- package/dist/packages/_es/Badge.js +47 -36
- package/dist/packages/_es/Barrage.js +147 -68
- package/dist/packages/_es/Button.js +66 -47
- package/dist/packages/_es/Calendar.js +157 -135
- package/dist/packages/_es/CalendarItem.js +6 -6
- package/dist/packages/_es/Card.js +56 -42
- package/dist/packages/_es/Cascader.js +474 -315
- package/dist/packages/_es/Category.js +39 -29
- package/dist/packages/_es/CategoryPane.js +83 -57
- package/dist/packages/_es/Cell.js +71 -56
- package/dist/packages/_es/CellGroup.js +27 -19
- package/dist/packages/_es/Checkbox.js +156 -109
- package/dist/packages/_es/CheckboxGroup.js +59 -38
- package/dist/packages/_es/CircleProgress.js +96 -67
- package/dist/packages/_es/Col.js +31 -23
- package/dist/packages/_es/Collapse.js +58 -33
- package/dist/packages/_es/CollapseItem.js +108 -78
- package/dist/packages/_es/Comment.js +279 -207
- package/dist/packages/_es/ConfigProvider.js +55 -37
- package/dist/packages/_es/Countdown.js +212 -100
- package/dist/packages/_es/Countup.js +445 -232
- package/dist/packages/_es/DatePicker.js +265 -162
- package/dist/packages/_es/Dialog.js +213 -161
- package/dist/packages/_es/Divider.js +57 -42
- package/dist/packages/_es/Drag.js +153 -70
- package/dist/packages/_es/Ecard.js +104 -64
- package/dist/packages/_es/Elevator.js +219 -143
- package/dist/packages/_es/Ellipsis.js +178 -95
- package/dist/packages/_es/Empty.js +39 -23
- package/dist/packages/_es/FixedNav.js +116 -93
- package/dist/packages/_es/Form.js +178 -107
- package/dist/packages/_es/FormItem.js +61 -48
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +84 -58
- package/dist/packages/_es/Image.js +130 -90
- package/dist/packages/_es/ImagePreview.js +412 -256
- package/dist/packages/_es/Indicator.js +34 -30
- package/dist/packages/_es/InfiniteLoading.js +136 -83
- package/dist/packages/_es/Input.js +264 -160
- package/dist/packages/_es/InputNumber.js +117 -81
- package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
- package/dist/packages/_es/Invoice.js +130 -104
- package/dist/packages/_es/Layout.js +4 -3
- package/dist/packages/_es/List.js +215 -117
- package/dist/packages/_es/Menu.js +150 -95
- package/dist/packages/_es/MenuItem.js +154 -109
- package/dist/packages/_es/Navbar.js +119 -103
- package/dist/packages/_es/Noticebar.js +312 -197
- package/dist/packages/_es/Notify.js +166 -110
- package/dist/packages/_es/NumberKeyboard.js +202 -127
- package/dist/packages/_es/Overlay.js +80 -52
- package/dist/packages/_es/Pagination.js +100 -70
- package/dist/packages/_es/Picker.js +437 -275
- package/dist/packages/_es/Popover.js +225 -122
- package/dist/packages/_es/Popup.js +4 -4
- package/dist/packages/_es/Price.js +82 -44
- package/dist/packages/_es/Progress.js +79 -63
- package/dist/packages/_es/PullRefresh.js +173 -95
- package/dist/packages/_es/Radio.js +4 -4
- package/dist/packages/_es/RadioGroup.js +3 -3
- package/dist/packages/_es/Range.js +347 -204
- package/dist/packages/_es/Rate.js +141 -92
- package/dist/packages/_es/Row.js +27 -21
- package/dist/packages/_es/Searchbar.js +174 -123
- package/dist/packages/_es/ShortPassword.js +93 -69
- package/dist/packages/_es/SideNavbar.js +80 -49
- package/dist/packages/_es/SideNavbarItem.js +32 -22
- package/dist/packages/_es/Signature.js +146 -83
- package/dist/packages/_es/Skeleton.js +130 -110
- package/dist/packages/_es/Sku.js +343 -250
- package/dist/packages/_es/Step.js +86 -59
- package/dist/packages/_es/Steps.js +31 -26
- package/dist/packages/_es/Sticky.js +4 -4
- package/dist/packages/_es/SubSideNavbar.js +74 -52
- package/dist/packages/_es/Swipe.js +155 -83
- package/dist/packages/_es/Swiper.js +311 -174
- package/dist/packages/_es/SwiperItem.js +44 -28
- package/dist/packages/_es/Switch.js +68 -55
- package/dist/packages/_es/TabPane.js +41 -30
- package/dist/packages/_es/Tabbar.js +52 -41
- package/dist/packages/_es/TabbarItem.js +82 -61
- package/dist/packages/_es/Table.js +165 -109
- package/dist/packages/_es/Tabs.js +388 -240
- package/dist/packages/_es/Tag.js +61 -44
- package/dist/packages/_es/Textarea.js +124 -80
- package/dist/packages/_es/TimeDetail.js +76 -49
- package/dist/packages/_es/TimePannel.js +48 -34
- package/dist/packages/_es/TimeSelect.js +68 -47
- package/dist/packages/_es/Toast.js +218 -144
- package/dist/packages/_es/Tour.js +192 -138
- package/dist/packages/_es/TrendArrow.js +77 -57
- package/dist/packages/_es/Uploader.js +359 -234
- package/dist/packages/_es/Video.js +316 -191
- package/dist/packages/_es/Watermark.js +117 -84
- package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
- package/dist/packages/_es/common-b9a5e726.js +145 -0
- package/dist/packages/_es/component-81a4c1d0.js +145 -0
- package/dist/packages/_es/index-29892cda.js +33 -0
- package/dist/packages/_es/index-43c34ac6.js +30 -0
- package/dist/packages/_es/index-54d03fc1.js +8 -0
- package/dist/packages/_es/index-79c5dc33.js +10 -0
- package/dist/packages/_es/index-7a7385e4.js +67 -0
- package/dist/packages/_es/index-87422be8.js +942 -0
- package/dist/packages/_es/index-da0a7662.js +259 -0
- package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
- package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
- package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
- package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
- package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
- package/dist/packages/_es/raf-729dad54.js +25 -0
- package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
- package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
- package/dist/packages/locale/lang/en-US.js +39 -36
- package/dist/packages/locale/lang/id-ID.js +39 -36
- package/dist/packages/locale/lang/index.js +44 -22
- package/dist/packages/locale/lang/zh-CN.js +38 -35
- package/dist/packages/locale/lang/zh-TW.js +38 -35
- package/dist/resolver/index.js +26 -1
- package/dist/resolver/index.mjs +17 -14
- package/dist/smartips/web-types.json +1 -1
- package/dist/style.css +1 -1
- package/dist/styles/themes/default.scss +48 -48
- package/dist/styles/themes/jdb.scss +48 -48
- package/dist/styles/themes/jddkh.scss +48 -48
- package/dist/styles/themes/jdt.scss +48 -48
- package/dist/types/index.d.ts +1 -1
- package/package.json +3 -4
- package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
- package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
- package/dist/packages/_es/common-d218746f.js +0 -116
- package/dist/packages/_es/component-234624bc.js +0 -89
- package/dist/packages/_es/index-14dfadc4.js +0 -561
- package/dist/packages/_es/index-192a3ef6.js +0 -29
- package/dist/packages/_es/index-360c5092.js +0 -210
- package/dist/packages/_es/index-496e6e05.js +0 -24
- package/dist/packages/_es/index-50eed3d9.js +0 -7
- package/dist/packages/_es/index-53ec2d4d.js +0 -34
- package/dist/packages/_es/index-fadb0974.js +0 -8
- package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
- package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
- package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
- package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
- package/dist/packages/_es/pxCheck-38173291.js +0 -4
- package/dist/packages/_es/raf-a74f1a06.js +0 -16
- package/dist/packages/_es/renderIcon-47498b32.js +0 -5
- package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
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: (
|
|
26
|
-
const
|
|
33
|
+
setup: (props) => {
|
|
34
|
+
const list = ref(null);
|
|
35
|
+
const state = reactive({
|
|
27
36
|
count: 1,
|
|
28
37
|
observer: null
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
})
|
|
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
|
|
61
|
-
return
|
|
62
|
-
class:
|
|
91
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
92
|
+
return openBlock(), createElementBlock("view", {
|
|
93
|
+
class: normalizeClass(_ctx.classes)
|
|
63
94
|
}, [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
102
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
72
103
|
export {
|
|
73
|
-
|
|
104
|
+
index as default
|
|
74
105
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { computed
|
|
2
|
-
import { c as
|
|
3
|
-
import { _ as
|
|
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
|
|
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: (
|
|
18
|
-
classes
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
], 10,
|
|
42
|
+
createElementVNode("span", _hoisted_2, toDisplayString(_ctx.title), 1)
|
|
43
|
+
], 10, _hoisted_1);
|
|
34
44
|
}
|
|
35
|
-
const
|
|
45
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
36
46
|
export {
|
|
37
|
-
|
|
47
|
+
index as default
|
|
38
48
|
};
|
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
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: () =>
|
|
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
|
-
[
|
|
59
|
+
[Button.name]: Button
|
|
44
60
|
},
|
|
45
61
|
emits: ["start", "end", "signing", "confirm", "clear"],
|
|
46
|
-
setup(
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
})
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
139
|
+
dataurl = canvas2.toDataURL("image/png");
|
|
87
140
|
break;
|
|
88
141
|
case "jpg":
|
|
89
|
-
|
|
142
|
+
dataurl = canvas2.toDataURL("image/jpeg", 0.8);
|
|
90
143
|
break;
|
|
91
144
|
}
|
|
92
|
-
const
|
|
93
|
-
|
|
145
|
+
const _canvas = isCanvasBlank(canvas2) ? "请绘制签名" : canvas2;
|
|
146
|
+
const _filePath = isCanvasBlank(canvas2) ? "" : dataurl;
|
|
147
|
+
emit("confirm", _canvas, _filePath);
|
|
94
148
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
})
|
|
159
|
+
});
|
|
160
|
+
const _hoisted_1 = {
|
|
100
161
|
class: "nut-signature-inner",
|
|
101
162
|
ref: "wrap"
|
|
102
|
-
}
|
|
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
|
|
107
|
-
const
|
|
108
|
-
return
|
|
109
|
-
class:
|
|
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
|
-
|
|
112
|
-
|
|
174
|
+
createElementVNode("div", _hoisted_1, [
|
|
175
|
+
withDirectives(createElementVNode("canvas", {
|
|
113
176
|
ref: "canvas",
|
|
114
|
-
height:
|
|
115
|
-
width:
|
|
116
|
-
}, null, 8,
|
|
117
|
-
[
|
|
177
|
+
height: _ctx.canvasHeight,
|
|
178
|
+
width: _ctx.canvasWidth
|
|
179
|
+
}, null, 8, _hoisted_2), [
|
|
180
|
+
[vShow, _ctx.isCanvasSupported()]
|
|
118
181
|
]),
|
|
119
|
-
|
|
182
|
+
!_ctx.isCanvasSupported() ? (openBlock(), createElementBlock("p", _hoisted_3, toDisplayString(_ctx.unSupportTpl || _ctx.translate("unSupportTpl")), 1)) : createCommentVNode("", true)
|
|
120
183
|
], 512),
|
|
121
|
-
|
|
184
|
+
createVNode(_component_nut_button, {
|
|
122
185
|
class: "nut-signature-btn",
|
|
123
186
|
type: "default",
|
|
124
|
-
onClick:
|
|
187
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clear())
|
|
125
188
|
}, {
|
|
126
|
-
default:
|
|
127
|
-
|
|
189
|
+
default: withCtx(() => [
|
|
190
|
+
createTextVNode(toDisplayString(_ctx.translate("reSign")), 1)
|
|
128
191
|
]),
|
|
129
192
|
_: 1
|
|
130
193
|
}),
|
|
131
|
-
|
|
194
|
+
createVNode(_component_nut_button, {
|
|
132
195
|
class: "nut-signature-btn",
|
|
133
196
|
type: "primary",
|
|
134
|
-
onClick:
|
|
197
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirm())
|
|
135
198
|
}, {
|
|
136
|
-
default:
|
|
137
|
-
|
|
199
|
+
default: withCtx(() => [
|
|
200
|
+
createTextVNode(toDisplayString(_ctx.translate("confirm")), 1)
|
|
138
201
|
]),
|
|
139
202
|
_: 1
|
|
140
203
|
})
|
|
141
204
|
], 2);
|
|
142
205
|
}
|
|
143
|
-
const
|
|
206
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
144
207
|
export {
|
|
145
|
-
|
|
208
|
+
index as default
|
|
146
209
|
};
|