Skip to content

Commit 03492bc

Browse files
authored
feat(working_build): Working build for vite + vue-select
2 parents 2086545 + c511e24 commit 03492bc

File tree

4 files changed

+23
-106
lines changed

4 files changed

+23
-106
lines changed

package-lock.json

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
},
2121
"dependencies": {
2222
"path": "^0.12.7",
23-
"vue": "^3.2.25"
23+
"vue": "^3.2.25",
24+
"vue-select": "^4.0.0-beta.3"
2425
},
2526
"devDependencies": {
2627
"@vitejs/plugin-vue": "^2.2.0",
Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,6 @@
11
<template>
2-
<div class="relative">
3-
<input
4-
:value="value"
5-
@input="handleInput"
6-
:placeholder="placeholder"
7-
ref="input"
8-
tabindex="0"
9-
:class="inputClass"
10-
/>
11-
<span
12-
v-if="value"
13-
@click.prevent="reset()"
14-
class="absolute inset-y-0 right-0 pr-3 flex items-center cursor-pointer"
15-
>
16-
x
17-
</span>
18-
<div
19-
v-show="value && showOptions"
20-
@click.self="handleSelf()"
21-
@focusout="showOptions = false"
22-
tabindex="0"
23-
:class="dropdownClass"
24-
>
25-
<ul class="py-1">
26-
<li
27-
v-for="searchResult in searchResults"
28-
:key="searchResult.OPEID"
29-
@click="handleClick(searchResult)"
30-
class="px-3 py-2 cursor-pointer hover:bg-gray-200"
31-
>
32-
{{ searchResult.college_name }}
33-
</li>
34-
<li v-if="!searchResults.length" class="px-3 py-2 text-center">
35-
We search when you stop typing
36-
</li>
37-
</ul>
38-
</div>
39-
</div>
2+
<v-select :options="['Canada', 'United States']"></v-select>
403
</template>
414

425
<script>
43-
export default {
44-
props: {
45-
value: {
46-
type: String,
47-
required: false,
48-
},
49-
placeholder: {
50-
type: String,
51-
required: false,
52-
default: "Enter text here.",
53-
},
54-
data: {
55-
type: Array,
56-
required: true,
57-
},
58-
inputClass: {
59-
type: String,
60-
required: false,
61-
default:
62-
"px-3 py-3 placeholder-blueGray-300 text-blueGray-600 relative bg-white bg-white rounded text-sm border-0 shadow outline-none focus:outline-none focus:ring w-full",
63-
},
64-
dropdownClass: {
65-
type: String,
66-
required: false,
67-
default:
68-
"absolute w-full z-50 bg-white border border-gray-300 mt-1 mh-48 overflow-hidden overflow-y-scroll rounded-md shadow-md",
69-
},
70-
},
71-
data() {
72-
return {
73-
showOptions: false,
74-
chosenOption: "",
75-
searchTerm: "",
76-
};
77-
},
78-
computed: {
79-
searchResults() {
80-
if (this.data) {
81-
return this.data.slice(0, 10).filter((item) => {
82-
return item
83-
});
84-
}
85-
},
86-
},
87-
methods: {
88-
reset() {
89-
this.$emit("input", "");
90-
this.chosenOption = "";
91-
},
92-
handleInput(evt) {
93-
this.$emit("input", evt.target.value);
94-
this.searchTerm = evt.target.value;
95-
this.showOptions = true;
96-
},
97-
handleClick(item) {
98-
this.$emit("input", item.college_name);
99-
this.$emit("chosen", item);
100-
this.chosenOption = item.college_name;
101-
this.showOptions = false;
102-
this.$refs.input.focus();
103-
}
104-
},
105-
};
1066
</script>

vite.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
33
const path = require('path')
4+
import vSelect from 'vue-select'
5+
46

57
// https://vitejs.dev/config/
68
export default defineConfig({
@@ -9,12 +11,11 @@ export default defineConfig({
911
entry: path.resolve(__dirname, "src/index.js"),
1012
name: "@lob/vue-address-autocomplete",
1113
fileName: (format) => `@lob/vue-address-autocomplete.${format}.js`
12-
1314
},
1415
rollupOptions: {
1516
// make sure to externalize deps that shouldn't be bundled
1617
// into your library
17-
external: ['vue'],
18+
external: ['vue', 'vue-select'],
1819
output: {
1920
// Provide global variables to use in the UMD build
2021
// for externalized deps
@@ -24,5 +25,5 @@ export default defineConfig({
2425
}
2526
}
2627
},
27-
plugins: [vue()]
28+
plugins: [vue(), vSelect ]
2829
})

0 commit comments

Comments
 (0)