Skip to content
This repository has been archived by the owner on May 5, 2018. It is now read-only.

Commit

Permalink
Added tel input type support.
Browse files Browse the repository at this point in the history
Changes:
1. Added `tel` to supported input types
2. Added `beforeDestroy()` cleanup
3. Fixed `package.json`: keywords, git url, deps
4. Fixed issue with mobile docs
5. Improoved examples

Closes #20, closes #18, closes #14, closes #11, closes #6
  • Loading branch information
sobolevn committed Nov 2, 2016
1 parent fe86e16 commit 0ffb1f1
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 42 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,5 @@
# Changelog

## Version 1.0.4

- Initial semver release
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,15 @@
# Contributing to vue-material-input

## Pull Requests Welcome

1. Fork `vue-material-input`
2. Create a topic branch
3. Make logically-grouped commits with clear commit messages
4. Push commits to your fork
5. Open a pull request against vue-material-input/master

## Issues

If you believe there to be a bug, please provide the maintainers with enough
detail to reproduce or a link to an app exhibiting unexpected behavior. For
help, please start with Stack Overflow.
8 changes: 8 additions & 0 deletions LICENSE.md
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 wemake.service company

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions dev/MaterialFieldTypes.vue
@@ -1,11 +1,14 @@
<template>
<form class="material-field-type-form">
<a href="#">back</a>

<p>Input types</p>
<MaterialInput name="name" type="text">Text</MaterialInput>
<MaterialInput name="name" type="password">Password</MaterialInput>
<MaterialInput name="name" type="number">Number</MaterialInput>
<MaterialInput name="name" type="url">URL</MaterialInput>
<MaterialInput name="name" type="email">Email</MaterialInput>
<MaterialInput name="name" type="tel">Telephone</MaterialInput>
</form>
</template>

Expand Down
2 changes: 2 additions & 0 deletions dev/MaterialModel.vue
@@ -1,5 +1,7 @@
<template>
<form class="material-model-form">
<a href="#">back</a>

<p>Hello, {{ username }}</p>
<MaterialInput name="name" v-model="username">Your name</MaterialInput>
</form>
Expand Down
2 changes: 2 additions & 0 deletions dev/MaterialWithValidation.vue
@@ -1,5 +1,7 @@
<template>
<form class="material-validation-form">
<a href="#">back</a>

<MaterialInput
name="validated-name"
:minlength="4"
Expand Down
21 changes: 14 additions & 7 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "vue-material-input",
"version": "1.0.3",
"version": "1.0.4",
"description": "Simple material input without dependencies",
"author": "sobolevn <mail@sobolevn.me>",
"private": false,
Expand Down Expand Up @@ -78,13 +78,13 @@
"opn": "^4.0.2",
"ora": "^0.3.0",
"phantomjs-prebuilt": "^2.1.3",
"publish-please": "^2.2.0",
"sass-loader": "^4.0.2",
"selenium-server": "2.53.1",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"url-loader": "^0.5.7",
"vue": "^2.0.3",
"vue-dev-server": "^2.0.1",
"vue-hot-reload-api": "^2.0.6",
"vue-html-loader": "^1.2.3",
"vue-loader": "^9.7.0",
Expand All @@ -95,15 +95,22 @@
"webpack": "^1.13.3",
"webpack-dev-middleware": "^1.8.3",
"webpack-hot-middleware": "^2.12.2",
"webpack-merge": "^0.14.1",
"publish-please": "^2.2.0",
"vue-dev-server": "2.0.2"
"webpack-merge": "^0.14.1"
},
"main": "index.js",
"repository": {
"url": "https://github.com/wemake-services/razgrebaem.ru.git",
"url": "https://github.com/wemake-services/vue-material-input.git",
"type": "git"
},
"keywords": [
"vue",
"component",
"material",
"input",
"wemake.services"
],
"license": "MIT",
"dependencies": {}
"dependencies": {
"vue-dev-server": "^2.0.4"
}
}
55 changes: 47 additions & 8 deletions src/components/MaterialInput.vue
Expand Up @@ -64,6 +64,20 @@
:step="step"
:required="required"
>
<input
v-if="type === 'tel'"
type="tel"
class="material-input"
:class="{'material-input--has-value': hasValue}"
:name="name"
:id="id"
v-model="valueCopy"

:readonly="readonly"
:disabled="disabled"

:required="required"
>
<input
v-if="type === 'text'"
type="text"
Expand All @@ -80,6 +94,7 @@
:maxlength="maxlength"
:required="required"
>

<span class="material-input-bar"></span>

<label class="material-label">
Expand All @@ -102,25 +117,49 @@
}
},
mounted () {
const vm = this
const input = this.$el.querySelector('input')
if (this.value) { // value might not be provided
// Here we are following the Vue2 convention on custom v-model:
// https://github.com/vuejs/vue/issues/2873#issuecomment-223759341
this.valueCopy = this.value
input.addEventListener(
'input', (e) => vm.$emit('input', e.target.value), false
'input', this.handleModelInput, false
)
}
if (this.pattern) {
input.addEventListener('input', (e) => {
const message = vm.pattern.regex.test(input.value)
? '' : vm.pattern.message
// We might want to provide custom message for the pattern prop.
input.setCustomValidity(message)
})
input.addEventListener(
'input', this.handleValidationInput, false
)
}
},
beforeDestroy () {
// Unbinding events:
const input = this.$el.querySelector('input')
if (this.value) {
input.removeEventListener(
'input', this.handleModelInput
)
}
if (this.pattern) {
input.removeEventListener(
'input', this.handleValidationInput
)
}
},
methods: {
handleModelInput (event) {
this.$emit('input', event.target.value)
},
handleValidationInput (event) {
const input = this.$el.querySelector('input')
const message = this.pattern.regex.test(input.value)
? '' : this.pattern.message
// We might want to provide custom message for the pattern prop.
input.setCustomValidity(message)
}
},
props: {
Expand Down
34 changes: 7 additions & 27 deletions yarn.lock
Expand Up @@ -2961,8 +2961,8 @@ invert-kv@^1.0.0:
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6"

ip@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.3.tgz#12b16294a38925486d618a1103506e4eb4f8b296"
version "1.1.4"
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.4.tgz#de8247ffef940451832550fba284945e6e039bfb"

is-absolute-url@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -5781,7 +5781,7 @@ uglify-js@^2.6, uglify-js@~2.7.3, uglify-js@2.7.x:
uglify-to-browserify "~1.0.0"
yargs "~3.10.0"

uglify-js@~2.6.0, uglify-js@2.6.x:
uglify-js@2.6.x:
version "2.6.4"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.6.4.tgz#65ea2fb3059c9394692f15fed87c2b36c16b9adf"
dependencies:
Expand Down Expand Up @@ -5951,9 +5951,9 @@ vue:
version "2.0.3"
resolved "https://registry.yarnpkg.com/vue/-/vue-2.0.3.tgz#3f7698f83d6ad1f0e35955447901672876c63fde"

vue-dev-server@2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/vue-dev-server/-/vue-dev-server-2.0.2.tgz#2ec2dced455f70aaccd9aa4383854d2c1ce15c56"
vue-dev-server:
version "2.0.4"
resolved "https://registry.yarnpkg.com/vue-dev-server/-/vue-dev-server-2.0.4.tgz#7e2ab27eb58f6bdc2bf167571a62bba211c0ac31"
dependencies:
chokidar "^1.6.0"
coffee-script "^1.11.1"
Expand Down Expand Up @@ -6061,7 +6061,7 @@ weak-map@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/weak-map/-/weak-map-1.0.0.tgz#b66e56a9df0bd25a76bbf1b514db129080614a37"

webpack:
webpack, webpack@^1.13.2:
version "1.13.3"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-1.13.3.tgz#e79c46fe5a37c5ca70084ba0894c595cdcb42815"
dependencies:
Expand Down Expand Up @@ -6122,26 +6122,6 @@ webpack-sources@^0.1.0:
source-list-map "~0.1.0"
source-map "~0.5.3"

webpack@^1.13.2:
version "1.13.2"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-1.13.2.tgz#f11a96f458eb752970a86abe746c0704fabafaf3"
dependencies:
acorn "^3.0.0"
async "^1.3.0"
clone "^1.0.2"
enhanced-resolve "~0.9.0"
interpret "^0.6.4"
loader-utils "^0.2.11"
memory-fs "~0.3.0"
mkdirp "~0.5.0"
node-libs-browser "^0.6.0"
optimist "~0.6.0"
supports-color "^3.1.0"
tapable "~0.1.8"
uglify-js "~2.6.0"
watchpack "^0.2.1"
webpack-core "~0.6.0"

whet.extend@~0.9.9:
version "0.9.9"
resolved "https://registry.yarnpkg.com/whet.extend/-/whet.extend-0.9.9.tgz#f877d5bf648c97e5aa542fadc16d6a259b9c11a1"
Expand Down

0 comments on commit 0ffb1f1

Please sign in to comment.