Skip to content

Commit 875f402

Browse files
committed
feat: Created the Vue Vue CSC Selector package.
1 parent c3d09d2 commit 875f402

24 files changed

+574
-209
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"devDependencies": {
2020
"@eslint/js": "^9.13.0",
2121
"@paystack/inline-js": "^2.22.1",
22+
"@types/node": "^22.10.5",
2223
"@vitejs/plugin-vue": "^5.1.4",
2324
"eslint": "~9.18.0",
2425
"eslint-plugin-vue": "^9.29.1",

packages/vue-csc-selector/README.md

-77
This file was deleted.

packages/vue-csc-selector/index.ts

-10
This file was deleted.

packages/vue-csc-selector/src/components/csc-selector.vue

-15
This file was deleted.

packages/vue-csc-selector/src/styles/main.scss

-1
This file was deleted.

packages/vue-csc-selector/src/types.ts

-7
This file was deleted.

packages/vue-place-selector/README.md

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Vue CSC Selector
2+
3+
[![npm](https://img.shields.io/npm/v/@toneflix/vue-place-selector.svg?style=flat-square)](https://www.npmjs.com/package/@toneflix/vue-place-selector)
4+
[![npm](https://img.shields.io/npm/dt/@toneflix/vue-place-selector.svg?style=flat-square)](https://www.npmjs.com/package/@toneflix/vue-place-selector)
5+
6+
Country State City Selector component for Vue3. - See a live demo [here](https://toneflix.github.io/vue-component-pack/vue-place-selector/demo.html).
7+
8+
<p align="center">
9+
<img width="200" src="https://toneflix.github.io/vue-component-pack/vue-place-selector/images/banner.png" alt="CSC Selector">
10+
<!--<img width="200" src="https://vuejs.org/images/logo.png" alt="Vue.js">-->
11+
</p>
12+
13+
## Documentation
14+
15+
Read the full documentation [here](https://toneflix.github.io/vue-component-pack/vue-place-selector/)
16+
17+
## Installation
18+
19+
```bash
20+
npm install @toneflix/vue-place-selector
21+
#or
22+
yarn add @toneflix/vue-place-selector
23+
#or
24+
pnpm add @toneflix/vue-place-selector
25+
```
26+
27+
## Usage
28+
29+
## Get API Key
30+
31+
This package depends on the `Toneflix Places API` for it's data set, the `Toneflix Places API` requires an API key for use on production, the get you api keys, head to `https://naija-places.toneflix.com.ng`:
32+
33+
1. Click on `Portal`.
34+
2. Login if required.
35+
3. Click on `API Keys`
36+
4. Click on `Create new API Key`
37+
5. Provide a name to identify your API key and click on `Create`
38+
39+
### Global Registration
40+
41+
You can make `Vue CSC Selector` available throughout your Vue project.
42+
43+
**main.js or main.ts**
44+
45+
```js
46+
import { createApp } from 'vue'
47+
import App from './app.vue'
48+
import VuePlaceSelector from '@toneflix/vue-place-selector'
49+
50+
const app = createApp(App)
51+
app.use(VuePlaceSelector)
52+
app.mount('#app')
53+
```
54+
55+
### Local Registration
56+
57+
You can also import the component in your Vue component.
58+
59+
**SomeComponent.vue**
60+
61+
```vue
62+
<script setup>
63+
import { VuePlaceSelector } from '@toneflix/vue-place-selector'
64+
</script>
65+
```
66+
67+
### Use the Registered Component in Your Vue Template
68+
69+
**SomeComponent.vue**
70+
71+
```vue
72+
<script setup lang="ts">
73+
import { VuePlaceSelector } from '@toneflix/vue-place-selector'
74+
import { ref } from 'vue'
75+
76+
const form = ref({
77+
country: '',
78+
state: '',
79+
city: ''
80+
})
81+
</script>
82+
83+
<template>
84+
<div style="display: flex; flex-direction: row;">
85+
<div>
86+
<VuePlaceSelector type="country" v-model="form.country" @error="console.log" />
87+
</div>
88+
<div>
89+
<VuePlaceSelector
90+
type="state"
91+
v-model="form.state"
92+
:params="{ countries: form.country }"
93+
@error="console.log"
94+
/>
95+
</div>
96+
<div>
97+
<VuePlaceSelector
98+
type="city"
99+
v-model="form.city"
100+
:params="{ countries: form.country, states: form.state }"
101+
@error="console.log"
102+
/>
103+
</div>
104+
</div>
105+
</template>
106+
```
107+
108+
### Setup API Key (For Production)
109+
110+
If you have an `env` file, that would be the best place to provide your API key, add `VITE_VUE_PLACESELECTOR_API_KEY` to your env file with your API Key as the value
111+
112+
```env
113+
VITE_VUE_PLACESELECTOR_API_KEY=ExampleApiKeyHere
114+
```
115+
116+
If you do not have an `env` file, you can pass the `api-key` prop to each component instance.
117+
118+
```vue
119+
<template>
120+
<VuePlaceSelector
121+
api-key="ExampleApiKeyHere"
122+
v-model="form.city"
123+
:params="{ countries: form.country, states: form.state }"
124+
@error="console.log"
125+
/>
126+
</template>
127+
```

packages/vue-place-selector/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { App } from 'vue'
2+
import { VuePlaceSelector } from './src/index'
3+
4+
export { VuePlaceSelector } from './src/index'
5+
6+
export default {
7+
install: (app: App): void => {
8+
app.use(VuePlaceSelector)
9+
}
10+
}

packages/vue-csc-selector/package.json packages/vue-place-selector/package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "@toneflix/vue-csc-selector",
2+
"name": "@toneflix/vue-place-selector",
33
"version": "1.0.0",
4-
"description": "Country State City Selector component for Vue3.",
4+
"description": "Place (Country, State, City, e.t.c) Selector component for Vue3.",
55
"style": "dist/lib/style.css",
66
"main": "dist/lib/index.cjs",
77
"module": "dist/es/index.mjs",
88
"type": "module",
9-
"homepage": "https://toneflix.github.io/vue-component-pack/vue-csc-selector",
9+
"homepage": "https://toneflix.github.io/vue-component-pack/vue-place-selector",
1010
"repository": {
1111
"url": "https://github.com/toneflix/vue-component-pack"
1212
},
@@ -16,7 +16,7 @@
1616
"scripts": {
1717
"test": "echo \"Error: no test specified\" && exit 1",
1818
"build": "vite build",
19-
"deploy": "../deploy.sh vue-csc-selector"
19+
"deploy": "../deploy.sh vue-place-selector"
2020
},
2121
"keywords": [],
2222
"author": "",
@@ -31,5 +31,9 @@
3131
"vitepress": "^1.4.0",
3232
"vue": "^3.5.11"
3333
},
34-
"nx": {}
34+
"nx": {},
35+
"dependencies": {
36+
"@vueuse/core": "^12.4.0",
37+
"axios": "^1.7.7"
38+
}
3539
}

0 commit comments

Comments
 (0)