@opentinyvue/vue-crop 2.21.0
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/LICENSE +22 -0
- package/index.d.ts +13 -0
- package/lib/index.js +271 -0
- package/package.json +22 -0
- package/src/pc.vue.d.ts +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 - present TinyVue Authors.
|
|
4
|
+
Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 - present TinyVue Authors.
|
|
3
|
+
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license.
|
|
6
|
+
*
|
|
7
|
+
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
|
|
8
|
+
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
|
|
9
|
+
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
import Crop from './src/pc.vue';
|
|
13
|
+
export default Crop;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { defineComponent, $prefix, setup } from '@opentinyvue/vue-common';
|
|
2
|
+
import { renderless, api } from '@opentinyvue/vue-renderless/crop/vue';
|
|
3
|
+
import { iconConmentRefresh, iconNew, iconZoomIn, iconZoomOut, iconRepeat, iconRefres, iconClose, iconYes, iconCrop } from '@opentinyvue/vue-icon';
|
|
4
|
+
import Cropper from 'cropperjs';
|
|
5
|
+
import 'cropperjs/dist/cropper.css';
|
|
6
|
+
import '@opentinyvue/vue-theme/crop/index.css';
|
|
7
|
+
|
|
8
|
+
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
9
|
+
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
10
|
+
if (render) {
|
|
11
|
+
options.render = render;
|
|
12
|
+
options.staticRenderFns = staticRenderFns;
|
|
13
|
+
options._compiled = true;
|
|
14
|
+
}
|
|
15
|
+
var hook;
|
|
16
|
+
if (injectStyles) {
|
|
17
|
+
hook = injectStyles;
|
|
18
|
+
}
|
|
19
|
+
if (hook) {
|
|
20
|
+
if (options.functional) {
|
|
21
|
+
options._injectStyles = hook;
|
|
22
|
+
var originalRender = options.render;
|
|
23
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
24
|
+
hook.call(context);
|
|
25
|
+
return originalRender(h, context);
|
|
26
|
+
};
|
|
27
|
+
} else {
|
|
28
|
+
var existing = options.beforeCreate;
|
|
29
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
exports: scriptExports,
|
|
34
|
+
options
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var __vue2_script = defineComponent({
|
|
39
|
+
name: $prefix + "Crop",
|
|
40
|
+
components: {
|
|
41
|
+
IconConmentRefresh: iconConmentRefresh(),
|
|
42
|
+
IconNew: iconNew(),
|
|
43
|
+
IconZoomIn: iconZoomIn(),
|
|
44
|
+
IconZoomOut: iconZoomOut(),
|
|
45
|
+
IconRepeat: iconRepeat(),
|
|
46
|
+
IconRefres: iconRefres(),
|
|
47
|
+
IconClose: iconClose(),
|
|
48
|
+
IconYes: iconYes(),
|
|
49
|
+
IconCrop: iconCrop()
|
|
50
|
+
},
|
|
51
|
+
props: {
|
|
52
|
+
/** 设置图片上的alt属性 */
|
|
53
|
+
alt: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: "image"
|
|
56
|
+
},
|
|
57
|
+
/** 裁剪框的宽高比,默认 16/9 */
|
|
58
|
+
aspectRatio: {
|
|
59
|
+
type: Number,
|
|
60
|
+
default: 16 / 9
|
|
61
|
+
},
|
|
62
|
+
/** 初始化时,是否自动显示裁剪框,默认 true */
|
|
63
|
+
autoCrop: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: true
|
|
66
|
+
},
|
|
67
|
+
/** 定义自动裁剪面积大小(百分比) 默认0.8 */
|
|
68
|
+
autoCropArea: {
|
|
69
|
+
type: Number,
|
|
70
|
+
default: 0.8
|
|
71
|
+
},
|
|
72
|
+
/** 是否显示容器的网格背景 默认true */
|
|
73
|
+
background: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: true
|
|
76
|
+
},
|
|
77
|
+
/** 裁剪框是否在图片正中心,并显示一个 + 号 默认false */
|
|
78
|
+
center: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false
|
|
81
|
+
},
|
|
82
|
+
/** 设置图片裁剪后返回的类型,可配置为 blob 和 base64 默认 base64 */
|
|
83
|
+
cropType: {
|
|
84
|
+
type: String,
|
|
85
|
+
default: "base64"
|
|
86
|
+
},
|
|
87
|
+
/** 设置裁剪弹框是否可见 默认false */
|
|
88
|
+
cropvisible: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: false
|
|
91
|
+
},
|
|
92
|
+
/** 定义 cropper 的拖拽模式,默认 crop ;'crop': 可以产生一个新的裁剪框 3 。'move':只可以移动图片 3 。'none': 什么也不处理 */
|
|
93
|
+
dragMode: {
|
|
94
|
+
type: String,
|
|
95
|
+
default: "crop"
|
|
96
|
+
},
|
|
97
|
+
/** 是否在裁剪框上方显示虚线 默认true */
|
|
98
|
+
guides: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: true
|
|
101
|
+
},
|
|
102
|
+
/** 设置待裁剪图片的最大大小,默认为 1M */
|
|
103
|
+
maxSize: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: "1M"
|
|
106
|
+
},
|
|
107
|
+
/** 容器的最小高度 默认 300 */
|
|
108
|
+
minContainerHeight: {
|
|
109
|
+
type: Number,
|
|
110
|
+
default: 300
|
|
111
|
+
},
|
|
112
|
+
/** 容器的最小宽度 默认 652 */
|
|
113
|
+
minContainerWidth: {
|
|
114
|
+
type: Number,
|
|
115
|
+
default: 652
|
|
116
|
+
},
|
|
117
|
+
/** 裁剪层的最小高度 默认0 */
|
|
118
|
+
minCropBoxHeight: {
|
|
119
|
+
type: Number,
|
|
120
|
+
default: 0
|
|
121
|
+
},
|
|
122
|
+
/** 裁剪层的最小宽度 默认0 */
|
|
123
|
+
minCropBoxWidth: {
|
|
124
|
+
type: Number,
|
|
125
|
+
default: 0
|
|
126
|
+
},
|
|
127
|
+
/** 是否显示图片上方裁剪框下方的黑色模态 默认true */
|
|
128
|
+
modal: {
|
|
129
|
+
type: Boolean,
|
|
130
|
+
default: true
|
|
131
|
+
},
|
|
132
|
+
/** 是否允许可以移动后面的图片 默认true */
|
|
133
|
+
movable: {
|
|
134
|
+
type: Boolean,
|
|
135
|
+
default: true
|
|
136
|
+
},
|
|
137
|
+
plugin: {
|
|
138
|
+
type: [Object, Function],
|
|
139
|
+
default: function _default() {
|
|
140
|
+
return Cropper;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
/** 设置图片裁剪后的压缩比例,值在 0-1 之间 默认0.92 */
|
|
144
|
+
quality: {
|
|
145
|
+
type: Number,
|
|
146
|
+
default: 0.92,
|
|
147
|
+
validator: function validator(value) {
|
|
148
|
+
return value <= 1 && value > 0;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
/** 是否允许旋转图像;默认为 true */
|
|
152
|
+
rotatable: {
|
|
153
|
+
type: Boolean,
|
|
154
|
+
default: true
|
|
155
|
+
},
|
|
156
|
+
/** 默认裁剪的源图片 */
|
|
157
|
+
src: {
|
|
158
|
+
type: String,
|
|
159
|
+
default: ""
|
|
160
|
+
},
|
|
161
|
+
/** 定义 cropper 的视图模式,默认 0 ;0:没有限制,3 可以移动到 2 外。1:3 只能在 2 内移动。2:2 图片不全部铺满 1 (即缩小时可以有一边出现空隙)。3:2 图片填充整个 1 */
|
|
162
|
+
viewMode: {
|
|
163
|
+
type: Number,
|
|
164
|
+
default: 0
|
|
165
|
+
},
|
|
166
|
+
/** 用鼠标移动图像时,定义缩放比例 默认 0.1 */
|
|
167
|
+
wheelZoomRatio: {
|
|
168
|
+
type: Number,
|
|
169
|
+
default: 0.1
|
|
170
|
+
},
|
|
171
|
+
/** 是否可以通过滚动鼠标滚轮来缩放图像 默认true */
|
|
172
|
+
zoomOnWheel: {
|
|
173
|
+
type: Boolean,
|
|
174
|
+
default: true
|
|
175
|
+
},
|
|
176
|
+
/** 是否允许放大图像 默认true */
|
|
177
|
+
zoomable: {
|
|
178
|
+
type: Boolean,
|
|
179
|
+
default: true
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
emits: ["update:cropvisible", "update:visible", "ready", "cropstart", "cropmove", "cropend", "crop", "cropdata"],
|
|
183
|
+
setup: function setup$1(props, context) {
|
|
184
|
+
return setup({
|
|
185
|
+
props,
|
|
186
|
+
context,
|
|
187
|
+
renderless,
|
|
188
|
+
api,
|
|
189
|
+
mono: true
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
var render = function render2() {
|
|
194
|
+
var _vm = this;
|
|
195
|
+
var _h = _vm.$createElement;
|
|
196
|
+
var _c = _vm._self._c || _h;
|
|
197
|
+
return _c("div", {
|
|
198
|
+
staticClass: "tiny-crop__wrapper"
|
|
199
|
+
}, [_c("div", {
|
|
200
|
+
directives: [{
|
|
201
|
+
name: "show",
|
|
202
|
+
rawName: "v-show",
|
|
203
|
+
value: _vm.state.cropvisible,
|
|
204
|
+
expression: "state.cropvisible"
|
|
205
|
+
}],
|
|
206
|
+
staticClass: "tiny-crop"
|
|
207
|
+
}, [_c("div", {
|
|
208
|
+
staticClass: "tiny-crop__dialog"
|
|
209
|
+
}, [_c("input", {
|
|
210
|
+
ref: "cropInput",
|
|
211
|
+
attrs: {
|
|
212
|
+
"type": "file",
|
|
213
|
+
"name": "image",
|
|
214
|
+
"accept": "image/*"
|
|
215
|
+
},
|
|
216
|
+
on: {
|
|
217
|
+
"change": _vm.setImage
|
|
218
|
+
}
|
|
219
|
+
}), _c("div", {
|
|
220
|
+
staticClass: "tiny-crop__dialog-cropper"
|
|
221
|
+
}, [_c("img", {
|
|
222
|
+
ref: "cropImage",
|
|
223
|
+
attrs: {
|
|
224
|
+
"src": _vm.state.src,
|
|
225
|
+
"id": "crops",
|
|
226
|
+
"alt": _vm.alt
|
|
227
|
+
}
|
|
228
|
+
})]), _c("div", {
|
|
229
|
+
staticClass: "tiny-crop__dialog-content__handle"
|
|
230
|
+
}, [_c("div", {
|
|
231
|
+
staticClass: "tiny-crop__dialog-content__handle__button"
|
|
232
|
+
}, _vm._l(_vm.state.renderIcon, function(item, index) {
|
|
233
|
+
return _c("div", {
|
|
234
|
+
key: index,
|
|
235
|
+
staticClass: "iconButton"
|
|
236
|
+
}, [!item.split ? _c("div", {
|
|
237
|
+
attrs: {
|
|
238
|
+
"title": item.title
|
|
239
|
+
}
|
|
240
|
+
}, [_c(item.icon, {
|
|
241
|
+
tag: "component",
|
|
242
|
+
staticClass: "iconButtonset",
|
|
243
|
+
on: {
|
|
244
|
+
"click": function click($event) {
|
|
245
|
+
$event.preventDefault();
|
|
246
|
+
return item.method.apply(null, arguments);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
})], 1) : _c("div", {
|
|
250
|
+
staticClass: "iconButton__split"
|
|
251
|
+
})]);
|
|
252
|
+
}), 0)])])])]);
|
|
253
|
+
};
|
|
254
|
+
var staticRenderFns = [];
|
|
255
|
+
var __cssModules = {};
|
|
256
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
|
|
257
|
+
function __vue2_injectStyles(context) {
|
|
258
|
+
for (var o in __cssModules) {
|
|
259
|
+
this[o] = __cssModules[o];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
var Crop = /* @__PURE__ */ function() {
|
|
263
|
+
return __component__.exports;
|
|
264
|
+
}();
|
|
265
|
+
var version = "2.21.0";
|
|
266
|
+
Crop.install = function(Vue) {
|
|
267
|
+
Vue.component(Crop.name, Crop);
|
|
268
|
+
};
|
|
269
|
+
Crop.version = version;
|
|
270
|
+
|
|
271
|
+
export { Crop as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentinyvue/vue-crop",
|
|
3
|
+
"version": "2.21.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"module": "./lib/index.js",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"type": "module",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@opentinyvue/vue-common": "~2.21.0",
|
|
11
|
+
"@opentinyvue/vue-renderless": "~3.21.0",
|
|
12
|
+
"@opentinyvue/vue-icon": "~2.21.0",
|
|
13
|
+
"cropperjs": "1.5.7",
|
|
14
|
+
"@opentinyvue/vue-theme": "~3.21.0"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"types": "index.d.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "pnpm -w build:ui $npm_package_name",
|
|
20
|
+
"//postversion": "pnpm build"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/pc.vue.d.ts
ADDED