Skip to content

Commit f820a25

Browse files
Robo-RinJosh Espinosa
authored and
Josh Espinosa
committed
fix(filter): remove unsupported Vue.filter (RonaldJerez#81)
Vue 3 doesn't support Vue.filter anymore but we can use the masker directly instead. closes RonaldJerez#44
1 parent ae303ba commit f820a25

File tree

6 files changed

+19
-28
lines changed

6 files changed

+19
-28
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ yarn add vue-input-facade@beta
3333

3434
### Globally
3535

36-
Installs the component, directive and filter for your entire application.
36+
Installs the component and directive for your entire application.
3737

3838
```javascript
3939
import InputFacade from 'vue-input-facade'
@@ -45,12 +45,14 @@ app.use(InputFacade)
4545
Install per component as needed
4646

4747
```javascript
48-
import { InputFacade, facade, filter } from 'vue-input-facade'
48+
import { InputFacade, facade, masker } from 'vue-input-facade'
4949

5050
export default {
5151
components: { InputFacade },
5252
directives: { facade },
53-
filters: { facade: filter },
53+
setup() {
54+
return { masker }
55+
}
5456
// ... rest of component config
5557
}
5658
```

docs/filter.md

-8
This file was deleted.

docs/masker.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
You may use the library to mask values in static text as well, taking advantage of the same mask tokens.
2+
3+
```js
4+
let phoneNumber = 18001234567
5+
let orderNumber = 'ABC1234510'
6+
7+
<p>Thanks for ordering with us. Your order number is <b>{{ masker(orderNumber, 'SSS-#####-##').masked }}</b>. If you need assistance please call us at <b>{{ facade(phoneNumber, '#-###-###-####').masked }}</b></p>
8+
```

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"build:docs": "vue-cli-service styleguidist:build --config styleguide/config.js",
2121
"test": "jest --coverage",
2222
"test:filter": "func() { yarn test \"$1\" --coverage-reporters=\"lcov\" --coverageThreshold={} ${@:2}; }; func",
23-
"test:watch": "jest --coverage --watchAll"
23+
"test:watch": "jest --coverage --watchAll",
24+
"preyalcpublish": "yarn build:plugin"
2425
},
2526
"main": "dist/vue-input-facade.umd.min.js",
2627
"files": [

src/plugin.js

+1-13
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,10 @@ function install(Vue, options = {}) {
1818

1919
Vue.component(InputFacade.name, InputFacade)
2020
Vue.directive(options.name || 'facade', facade)
21-
Vue.filter(options.name || 'facade', filter)
22-
}
23-
24-
/**
25-
* Utility function to be used as a vue filter
26-
*
27-
* @param {String} value the value to apply the filter to
28-
* @param {*} config the masking config
29-
* @returns {string} the masked value as returned by the masker function
30-
*/
31-
function filter(value, config) {
32-
return masker(value, config).masked
3321
}
3422

3523
export default install
36-
export { InputFacade, facade, tokens, masker, filter }
24+
export { InputFacade, facade, tokens, masker }
3725

3826
// Install by default if included from script tag
3927
if (typeof window !== 'undefined' && window.Vue) {

styleguide/config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path')
22
const pkg = require('../package.json')
3-
const { execSync } = require('child_process');
3+
const { execSync } = require('child_process')
44

55
const root = path.resolve(__dirname, '../')
66

@@ -35,8 +35,8 @@ module.exports = {
3535
content: `${root}/docs/directive.md`
3636
},
3737
{
38-
name: 'Filter',
39-
content: `${root}/docs/filter.md`
38+
name: 'Masker',
39+
content: `${root}/docs/masker.md`
4040
},
4141
{
4242
name: 'Advanced',

0 commit comments

Comments
 (0)