Skip to content

Commit 43fa51f

Browse files
committed
chore: Merge branch 'beta'
2 parents a55dade + 9095837 commit 43fa51f

22 files changed

+4391
-4032
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/pull_request_template.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Description
2+
A few sentences describing the overall goals of the pull request's commits.
3+
4+
## Checklist
5+
- [ ] Tests
6+
- [ ] Documentation
7+
- [ ] Used commitizen and followed [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary)
8+
- [ ] Commit footer references issue num. If applicable.

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,35 @@ See the [token source file](https://github.com/RonaldJerez/vue-input-facade/blob
8484
<input type="text" v-facade="'##/##/##'" />
8585
```
8686

87-
See [demo page](https://ronaldjerez.github.io/vue-input-facade) for more usage examples
87+
### Migrating existing projects
8888

89-
## Thanks
89+
If you are migrating an existing project to vue-input-facade from another plugin and dont want to touch the whole codebase. You may pass options during plugin installation to override the default tokens or directive name.
9090

91-
Thanks to [Marcos Neves](https://vuejs-tips.github.io/) for the vue-the-mask component of which this vue-input-facade was originally forked from.
91+
```javascript
92+
import InputFacade from 'vue-input-facade'
93+
94+
// migrating from v-mask
95+
const options = {
96+
// rename the directive from: v-facade to: v-mask
97+
name: 'mask',
98+
99+
// use these tokens instead of the default
100+
tokens: {
101+
'#': { pattern: /\d/ },
102+
'A': { pattern: /[a-z]/i },
103+
'N': { pattern: /[0-9a-z]/i },
104+
'X': { pattern: /./ }
105+
}
106+
}
107+
108+
Vue.use(InputFacade, options)
109+
```
110+
111+
See [demo page](https://ronaldjerez.github.io/vue-input-facade) for more usage examples
92112

93113
## Contribution
94114

95-
You're free to contribute to this project by submitting Issues and/or pull requests. This project is test-driven, so keep in mind that every change and new feature should be covered by tests.
115+
You're free to contribute to this project by submitting issues and/or pull requests. This project is test-driven, so keep in mind that every change and new feature should be covered by tests. The project uses [semantic-release](https://github.com/semantic-release/semantic-release) to release new versions, therefore all commit messages should follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary), we are using [commitizen](https://github.com/commitizen/cz-cli) to facilitate writting the commit messages.
96116

97117
## License
98118

docs/advanced.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ If you are migrating an existing project to vue-input-facade from another plugin
66
import InputFacade from 'vue-input-facade'
77

88
// migrating from v-mask
9-
// the directive will now be v-mask instead of v-facade
10-
// and all the tokens will be replaced globally by the following
119
const options = {
10+
// rename the directive from: v-facade to: v-mask
1211
name: 'mask',
12+
13+
// use these tokens instead of the default
1314
tokens: {
1415
'#': { pattern: /\d/ },
1516
'A': { pattern: /[a-z]/i },

docs/component.md

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,27 @@ let masked = false
1717
Accepts an array of masking pattern and dynamically chooses the appropriate one based on the number of characters in the field.
1818

1919
```js
20-
let value = ''
21-
let masked = true
20+
let USPostal = ''
21+
let UKPostal = ''
2222

23+
let masked = true
2324
<example label="US Zip Code">
24-
<input-facade v-model="value" :mask="['#####', '#####-####']" :masked="masked" />
25+
<input-facade v-model="USPostal" :mask="['#####', '#####-####']" :masked="masked" />
26+
</example>
27+
28+
<example label="UK Postal Code">
29+
<input-facade v-model="UKPostal" :mask="['A# #AA', 'AXX #AA', 'AA#X #AA']" :masked="masked" />
2530
</example>
2631

2732
<checkbox v-model="masked" />
28-
<display :value="value" />
33+
<display label="Zip Code" :value="USPostal" />
34+
<display label="Postal Code" :value="UKPostal" />
2935
```
3036

3137
### Custom Tokens
3238

3339
You can override the tokens on a per field basis. Just pass in your own token definition to the field.
40+
This can also be used to add internatilization support.
3441

3542
```js
3643
let value = ''
@@ -50,3 +57,52 @@ let hexTokens = {
5057
<checkbox v-model="masked" />
5158
<display :value="value" />
5259
```
60+
61+
### Post masking input formatter
62+
63+
Returning a string in the format function will re-run that value through the masker routine, Ensuring that the end result still confirms to the mask.
64+
65+
```js
66+
const date = (value, event) => {
67+
// do not format on deletion, this could leave the input in bad state
68+
// but allows user to delete the leading 0 if needed for some reason
69+
if (event.inputType !== 'deleteContentBackward') {
70+
const [ month ] = value.masked.split('/')
71+
72+
if (month > 12) {
73+
return '0' + value.unmasked
74+
}
75+
}
76+
}
77+
78+
let value = ''
79+
80+
<example label="Date as MM/YY">
81+
<input-facade v-model="value" mask="##/##" :formatter="date" />
82+
</example>
83+
84+
<display :value="value" />
85+
```
86+
87+
Returning a boolean `true` will leave the masked or unmasked value as is, the value is passed by reference so if you modify them here, that will be their final value. However if a `false` is returned, the user's input will be ignored and the value will remain as it was prior.
88+
89+
```js
90+
const evenMoney = (value, event) => {
91+
if (event.data && event.data % 2 !== 0) {
92+
// odd number, ignore it
93+
return false
94+
} else if (value.unmasked) {
95+
const formatted = value.unmasked.match(/\d{1,3}/g).join(',')
96+
value.masked = `\$${formatted}`
97+
return true
98+
}
99+
}
100+
101+
let value = ''
102+
103+
<example label="Enter an even num">
104+
<input-facade v-model="value" mask="#########" :formatter="evenMoney" masked />
105+
</example>
106+
107+
<display :value="value" />
108+
```

docs/directive.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
For times when you cannot use the component, you may use the directive instead. The directive has all the same features as the component, however the interface may not be as straight forward as using a component.
1+
For times when you cannot use the component, you may use the directive instead. The directive has all the same features as the component, however the interface may not be as straight forward as using a component. The `prefill` and `short` features may passed in to the directive as modifiers.
22

33
### Basic usage
44

55
```js
6-
let value = ''
6+
let value = '12A789MM'
77

88
<example label="Order number">
99
<input type="text" v-model="value" v-facade="'XXX-###-AA'">
@@ -16,11 +16,13 @@ let value = ''
1616

1717
You have access to the unmasked value via the input event. The `unmaskedValue` property can be found as part of the `target` property of the input event.
1818

19+
> Note: Some 3rd party components may not pass the `event` parameter when emitting input, such is the case with vuetify's v-text-input. In this case you can listen to the native event so you can still access the unmasked value. ex: `v-on:input.native="handler"`.
20+
1921
```js
2022
let event = ''
2123

2224
<example label="Enter your phone number">
23-
<input type="tel" v-facade="'(###) ### - ####'" @input="event = $event">
25+
<input type="tel" v-facade="'(###) ### - ####'" v-on:input="event = $event">
2426
</example>
2527

2628
<display :value="event" />

0 commit comments

Comments
 (0)