Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetaltun committed Aug 21, 2022
0 parents commit add50cb
Show file tree
Hide file tree
Showing 26 changed files with 76,636 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
122 changes: 122 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@

# Vue State Dropdown

State dropdown for Vue@2.

## [Demo](https://vue-state-dropdown.pages.dev/)
## Installation

- **yarn**:
```bash
yarn add vue-state-dropdown
```
- **npm**:
```bash
npm i --save vue-state-dropdown
```

## Usage

- Install as a global component:

```js
import Vue from "vue";
import VueStateDropdown from "vue-state-dropdown";

Vue.use(VueStateDropdown);
```
- Or use in a specific component

```js
import VueStateDropdown from 'vue-state-dropdown'

export default {
components: {
VueStateDropdown
}
}
```

- In your component:

```html
<template>
...
<vue-state-dropdown
@onSelect="onSelect"
:countryCode="'tr'"
:selectFirstItem="true"
:preferredStates="['06', '34']"
:immediateCallSelectEvent="true"
:disabled="false"
:clearable="false"
:multiple="false"
:searchable="true"
:closeOnSelect="true"
/>
...
<template>
<script>
export default {
methods: {
onSelect(state) {
console.log(state);
// Check the state object example below.
},
},
}
</script>
```
## State Object Example
```json
{
"id": 2217,
"name": "Ankara",
"country_id": 225,
"country_code": "TR",
"country_name": "Turkey",
"state_code": "06",
"type": "province",
"latitude": "39.78052450",
"longitude": "32.71813750"
}
```
## Props

| Property value | Type | Default value | Description |
| -------------------------- | --------- | ---------------| --------------------------------------------------------------------------------------- |
| `disabled` | `Boolean` | `false` | Disables the dropdown |
| `countryCode` | `string` | `''` | Get states by country code. ie `'tr'` |
| `countryName` | `string` | `''` | Get states by country name. ie `'turkey'` |
| `countryId` | `Number` | `null` | Get states by country id. ie `225` |
| `selectFirstItem` | `Boolean` | `false` | Set first state in the list as selected |
| `clearable` | `Boolean` | `false` | User can clear or not the selected country |
| `multiple` | `Boolean` | `false` | Select multiple country |
| `searchable` | `Boolean` | `true` | Set states searchable |
| `closeOnSelect` | `Boolean` | `true` | Close country list on select |
| `placeholder` | `String` | `''` | Set a placeholder for the input |
| `preferredState` | `Array` | `[]` | Preferred states list, will be on top of the dropdown. ie `['06', 'WTO']` |
| `onlyStates` | `Array` | `[]` | List of states will be shown on the dropdown. ie `['06', 'WTO']` |
| `ignoredStates` | `Array` | `[]` | List of states will NOT be shown on the dropdown. ie `['06', 'WTO']` |
| `immediateCallSelectEvent` | `Boolean` | `false` | Call the `onSelect` event when the component is mounted. |
| `showNotSelectedOption` | `Boolean` | `false` | The `Not Selected` option is added to the top of the list. (All values are empty.) |
| `notSelectedOptionText` | `String` | `Not Selected` | Replace `Not Selected` text with another string. |


## Events

| Property value | Arguments | Description |
| ------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `onSelect` | `Object` | Fires when the input changes with the argument is the object includes `state object`. (Check the state object example above) |
| `open` | `none` | Triggered when the dropdown is open. |
| `close` | `none` | Triggered when the dropdown is closed. |
| `option_selecting` | `Object` | Triggered after an option has been selected, before updating internal state. (Return same object with onSelect). |
| `option_selected` | `Object` | Triggered when an option has been selected, after updating internal state. (Return same object with onSelect). |
| `option_deselecting`| `Object` | Triggered when an option has been deselected, before updating internal state. (Return same object with onSelect). |
| `option_deselected` | `Object` | Triggered when an option has been deselected, after updating internal state. (Return same object with onSelect). |

## Highlights & Credits

- Data source: [dr5hn/countries-states-cities-database](https://github.com/dr5hn/countries-states-cities-database)
- Vue select: [sagalbot/vue-select](https://github.com/sagalbot/vue-select)
- Vue app created by [vue-cli](https://github.com/vuejs/vue-cli).
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
1 change: 1 addition & 0 deletions dist/vue-state-dropdown.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/css/app.54eaa47e.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added docs/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>vue-state-dropdown</title><script defer="defer" src="/js/chunk-vendors.1e87f920.js"></script><script defer="defer" src="/js/app.a6089d16.js"></script><link href="/css/app.54eaa47e.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but vue-state-dropdown doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
2 changes: 2 additions & 0 deletions docs/js/app.a6089d16.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/js/app.a6089d16.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions docs/js/chunk-vendors.1e87f920.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/js/chunk-vendors.1e87f920.js.map

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}
Loading

0 comments on commit add50cb

Please sign in to comment.