Skip to content

fix(filter): remove unsupported Vue.filter #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ yarn add vue-input-facade@beta

### Globally

Installs the component, directive and filter for your entire application.
Installs the component and directive for your entire application.

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

```javascript
import { InputFacade, facade, filter } from 'vue-input-facade'
import { InputFacade, facade, masker } from 'vue-input-facade'

export default {
components: { InputFacade },
directives: { facade },
filters: { facade: filter },
setup() {
return { masker }
}
// ... rest of component config
}
```
Expand Down
8 changes: 0 additions & 8 deletions docs/filter.md

This file was deleted.

8 changes: 8 additions & 0 deletions docs/masker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
You may use the library to mask values in static text as well, taking advantage of the same mask tokens.

```js
let phoneNumber = 18001234567
let orderNumber = 'ABC1234510'

<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>
```
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"build:docs": "vue-cli-service styleguidist:build --config styleguide/config.js",
"test": "jest --coverage",
"test:filter": "func() { yarn test \"$1\" --coverage-reporters=\"lcov\" --coverageThreshold={} ${@:2}; }; func",
"test:watch": "jest --coverage --watchAll"
"test:watch": "jest --coverage --watchAll",
"preyalcpublish": "yarn build:plugin"
},
"main": "dist/vue-input-facade.umd.min.js",
"files": [
Expand Down
14 changes: 1 addition & 13 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,10 @@ function install(Vue, options = {}) {

Vue.component(InputFacade.name, InputFacade)
Vue.directive(options.name || 'facade', facade)
Vue.filter(options.name || 'facade', filter)
}

/**
* Utility function to be used as a vue filter
*
* @param {String} value the value to apply the filter to
* @param {*} config the masking config
* @returns {string} the masked value as returned by the masker function
*/
function filter(value, config) {
return masker(value, config).masked
}

export default install
export { InputFacade, facade, tokens, masker, filter }
export { InputFacade, facade, tokens, masker }

// Install by default if included from script tag
if (typeof window !== 'undefined' && window.Vue) {
Expand Down
6 changes: 3 additions & 3 deletions styleguide/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path')
const pkg = require('../package.json')
const { execSync } = require('child_process');
const { execSync } = require('child_process')

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

Expand Down Expand Up @@ -35,8 +35,8 @@ module.exports = {
content: `${root}/docs/directive.md`
},
{
name: 'Filter',
content: `${root}/docs/filter.md`
name: 'Masker',
content: `${root}/docs/masker.md`
},
{
name: 'Advanced',
Expand Down