Skip to content

Commit d5c08e9

Browse files
committed
slots, button text
remove test all demo demo
1 parent 4bbbf2a commit d5c08e9

24 files changed

+6223
-15084
lines changed

.browserslistrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
> 1%
2+
last 2 versions

.editorconfig

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*.{js,jsx,ts,tsx,vue}]
2+
indent_style = space
3+
indent_size = 4
4+
end_of_line = lf
5+
trim_trailing_whitespace = true
6+
insert_final_newline = true
7+
max_line_length = 200

.eslintrc.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
root: true,
3+
4+
env: {
5+
node: true
6+
},
7+
8+
extends: ["plugin:vue/essential", "eslint:recommended"],
9+
10+
rules: {
11+
'no-console': 'off',
12+
'no-debugger': 'off',
13+
'vue/script-indent': ['error', 4, {
14+
baseIndent: 1,
15+
switchCase: 0,
16+
ignores: []
17+
}]
18+
},
19+
20+
parserOptions: {
21+
parser: 'babel-eslint'
22+
},
23+
};

.github/main.workflow

-15
This file was deleted.

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
node_modules
33
/dist
44

5+
/tests/e2e/reports/
6+
selenium-debug.log
7+
58
# local env files
69
.env.local
710
.env.*.local
@@ -18,4 +21,4 @@ yarn-error.log*
1821
*.ntvs*
1922
*.njsproj
2023
*.sln
21-
*.sw*
24+
*.sw?

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,10 @@ All notable changes to `vue-csv-import` will be documented in this file
1717

1818
## 2.1.0
1919
- Remove csv-parse dependency and replace with papaparse - smaller and more dependable.
20-
- Can now use with v-model. will return a parsed csv.
20+
- Can now use with v-model. will return a parsed csv.
21+
22+
## 2.3.0
23+
- Added slots for file header checkbox and table thead.
24+
- default button text changed to "next"
25+
- added callback for usage without url.
26+
- Added 'headers' prop. Define whether csv has headers by default. Removes checkbox.

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,37 @@ or with v-model:
5555
```html
5656
<vue-csv-import v-model="parseCsv" :map-fields="[field1: 'Label 1', field2: 'Label 2']"></vue-csv-import>
5757

58+
```
59+
With all available slots:
60+
```html
61+
<vue-csv-import
62+
v-model="csv"
63+
url="/hello"
64+
:map-fields="['name', 'age']">
65+
66+
<template slot="hasHeaders" slot-scope="{headers, toggle}">
67+
<label>
68+
<input type="checkbox" id="hasHeaders" :value="headers" @change="toggle">
69+
Headers?
70+
</label>
71+
</template>
72+
73+
<template slot="thead">
74+
<tr>
75+
<th>My Fields</th>
76+
<th>Column</th>
77+
</tr>
78+
</template>
79+
80+
<template slot="next" slot-scope="{load}">
81+
<button @click.prevent="load">load!</button>
82+
</template>
83+
84+
<template slot="submit" slot-scope="{submit}">
85+
<button @click.prevent="submit">send!</button>
86+
</template>
87+
</vue-csv-import>
88+
5889
```
5990
Options:
6091

@@ -71,6 +102,16 @@ Options:
71102
| inputClass | "form-control-file" | The class to be added to the file input |
72103
| submitBtnText | "Submit" | The value of the final submit button |
73104
| loadBtnText | "Submit" | The value of the initial load file button |
105+
| headers | null | Define whether csv has headers by default. Removes checkbox. |
106+
107+
Slots:
108+
109+
| Slot | Description |
110+
| ------ | ----------- |
111+
| thead | The content of "thead" in the field mapping table |
112+
| next | The next button. Use slot-scope "next" to load csv. |
113+
| submit | The submit button. Use slot-scope "submit" to submit form. |
114+
| hasHeaders | The "has headers" checkbox. Use slot-scope "toggle" and "headers". |
74115

75116
### Testing
76117

babel.config.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
module.exports = {
2-
presets: [
3-
['@vue/app', {
4-
useBuiltIns: false
5-
}]
6-
]
2+
presets: ["@vue/app"]
73
};

deploy.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
3+
# abort on errors
4+
set -e
5+
6+
# build
7+
npm run build
8+
9+
# navigate into the build output directory
10+
cd dist
11+
git init
12+
git add -A
13+
git commit -m 'deploy'
14+
git push -f [email protected]:jgile/vue-csv-import.git master:gh-pages
15+
16+
cd -

jest.config.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
moduleFileExtensions: ["js", "jsx", "json", "vue"],
3+
transform: {
4+
"^.+\\.vue$": "vue-jest",
5+
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$":
6+
"jest-transform-stub",
7+
"^.+\\.jsx?$": "babel-jest"
8+
},
9+
transformIgnorePatterns: ["/node_modules/"],
10+
moduleNameMapper: {
11+
"^@/(.*)$": "<rootDir>/src/$1"
12+
},
13+
snapshotSerializers: ["jest-serializer-vue"],
14+
testMatch: [
15+
"**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"
16+
],
17+
testURL: "http://localhost/",
18+
watchPlugins: [
19+
"jest-watch-typeahead/filename",
20+
"jest-watch-typeahead/testname"
21+
]
22+
};

0 commit comments

Comments
 (0)