Skip to content

Commit 8489edb

Browse files
committed
fix: build module
1 parent 05963f6 commit 8489edb

File tree

7 files changed

+3710
-16
lines changed

7 files changed

+3710
-16
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["env"]
3+
}

.browserslistrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Browsers that we support
2+
3+
last 1 version
4+
> 1%
5+
maintained node versions
6+
not dead

.gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@ package-lock.json*
2121

2222
# IDE
2323
/.idea
24-
25-
lib/
26-
es/
2724
dist/
2825
build/
2926
.vscode
3027

3128
# publish
32-
*.tgz
29+
*.tgz

lib/index.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _copyToClipboard = require('copy-to-clipboard');
8+
9+
var _copyToClipboard2 = _interopRequireDefault(_copyToClipboard);
10+
11+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12+
13+
var CopyToClipboardProps = {
14+
text: {
15+
type: String,
16+
required: true
17+
},
18+
options: {
19+
type: Object,
20+
'default': function _default() {
21+
return null;
22+
}
23+
}
24+
};
25+
26+
var CopyToClipboard = {
27+
name: 'VueCopyToClipboard',
28+
functional: true,
29+
props: CopyToClipboardProps,
30+
render: function render(h, ctx) {
31+
var props = ctx.props,
32+
onCopy = ctx.listeners.copy,
33+
children = ctx.children;
34+
35+
var _ref = props || {},
36+
text = _ref.text,
37+
options = _ref.options;
38+
39+
function handleClick(e) {
40+
// Bypass onClick if it was present
41+
e.preventDefault();
42+
e.stopPropagation();
43+
44+
var result = (0, _copyToClipboard2.default)(text, options);
45+
46+
if (onCopy) {
47+
onCopy(text, result);
48+
}
49+
}
50+
51+
return h('span', { on: { 'click': handleClick } }, children);
52+
}
53+
};
54+
55+
/* istanbul ignore next */
56+
CopyToClipboard.install = function (Vue) {
57+
Vue.component(CopyToClipboard.name, CopyToClipboard);
58+
};
59+
60+
exports.default = CopyToClipboard;

package.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vue-copy-to-clipboard",
33
"version": "1.0.1",
44
"description": "Copy to clipboard Vue component",
5-
"main": "index.js",
5+
"main": "lib/index.js",
66
"repository": "https://github.com/vueComponent/vue-copy-to-clipboard",
77
"author": "Sendya <[email protected]>",
88
"contributors": [
@@ -12,12 +12,22 @@
1212
"files": [
1313
"es",
1414
"lib",
15-
"index.js"
15+
"src/index.js"
1616
],
17+
"scripts": {
18+
"build": "babel src/index.js -d lib"
19+
},
1720
"peerDependencies": {
1821
"vue": ">=2.6.0"
1922
},
2023
"dependencies": {
2124
"copy-to-clipboard": "^3.3.1"
25+
},
26+
"devDependencies": {
27+
"@babel/core": "^7.10.4",
28+
"babel-cli": "^6.26.0",
29+
"babel-preset-env": "^1.7.0",
30+
"babel-preset-es2015": "^6.24.1",
31+
"webpack": "^4.43.0"
2232
}
2333
}

index.js renamed to src/index.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import copy from 'copy-to-clipboard';
22

3-
export var CopyToClipboardProps = {
3+
const CopyToClipboardProps = {
44
text: {
55
type: String,
66
required: true
@@ -13,17 +13,13 @@ export var CopyToClipboardProps = {
1313
}
1414
};
1515

16-
var CopyToClipboard = {
16+
const CopyToClipboard = {
1717
name: 'VueCopyToClipboard',
1818
functional: true,
1919
props: CopyToClipboardProps,
20-
render: function (h, ctx) {
21-
var props = ctx.props,
22-
listeners = ctx.listeners,
23-
children = ctx.children;
24-
var text = props.text,
25-
options = props.options || {};
26-
var onCopy = listeners.copy
20+
render (h, ctx) {
21+
const { props, listeners: { copy: onCopy }, children } = ctx
22+
const { text, options } = props || {}
2723

2824
function handleClick(e) {
2925
// Bypass onClick if it was present

0 commit comments

Comments
 (0)