Skip to content

Commit

Permalink
Fix building error
Browse files Browse the repository at this point in the history
  • Loading branch information
nosir committed Jun 25, 2016
1 parent df05117 commit d3761a4
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 24 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

[![Travis](https://img.shields.io/travis/nosir/cleave.js.svg?maxAge=2592000)](https://travis-ci.org/nosir/cleave.js)
[![Codacy branch grade](https://img.shields.io/codacy/grade/b1c0b0da42fa418f887076a3f7352aea/master.svg?maxAge=2592000)](https://www.codacy.com/app/nosir/cleave-js)
[![npm version](https://badge.fury.io/js/cleave.js.svg)](https://badge.fury.io/js/cleave.js)

Cleave.js has a simple purpose: to help you format input text content automatically.

## Features

- Credit card number formatting
- Phone number formatting (metadata pattern js separated by countries to reduce size)
- Phone number formatting (i18n pattern js separated by countries to reduce size)
- Date formatting
- Numeral formatting
- Custom delimiter, prefix and blocks pattern
Expand Down Expand Up @@ -37,8 +38,8 @@ npm install --save cleave.js
bower install --save cleave.js
```

#### throwback
Grab the file from [dist](https://github.com/nosir/cleave.js/tree/master/dist) directory
#### old school
Grab file from [dist](https://github.com/nosir/cleave.js/tree/master/dist) directory

## Usage

Expand Down Expand Up @@ -68,7 +69,7 @@ var cleave = new Cleave('.input-phone', {

More examples: [the demo page](https://github.com)

#### CommonJS (Node.js)
#### CommonJS
```js
var Cleave = require('cleave.js');
require('cleave.js/dist/plugin/cleave-phone.{country}');
Expand Down Expand Up @@ -156,6 +157,12 @@ gulp mocha && gulp eslint
- [x] Mocha unit tests for formatter classes
- [ ] PhantomJS / Jest browser tests

## Get in touch
- [x] ReactJS component port
- [ ] AngularJS component port
- [x] Mocha unit tests for formatter classes
- [ ] PhantomJS / Jest browser tests

## References

- Payment credit card number IIN https://en.wikipedia.org/wiki/Payment_card_number#Issuer_identification_number_.28IIN.29
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"form",
"input"
],
"version": "0.2.0",
"version": "0.2.1",
"author": {
"name": "Max Huang",
"email": "[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions dist/cleave-react.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/cleave-react.min.js

Large diffs are not rendered by default.

126 changes: 126 additions & 0 deletions dist/cleave.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,132 @@ if (typeof module === 'object' && typeof module.exports === 'object') {

'use strict';

var Util = {
noop: function () {
},

strip: function (value, re) {
return value.replace(re, '');
},

headStr: function (str, length) {
return str.slice(0, length);
},

getMaxLength: function (blocks) {
return blocks.reduce(function (previous, current) {
return previous + current;
}, 0);
},

getPrefixAppliedValue: function (value, prefix) {
var prefixLength = prefix.length,
prefixLengthValue;

if (prefixLength === 0) {
return value;
}

prefixLengthValue = value.slice(0, prefixLength);

if (prefixLengthValue.length < prefixLength) {
value = prefix;
} else if (prefixLengthValue !== prefix) {
value = prefix + value.slice(prefixLength);
}

return value;
},

getFormattedValue: function (value, blocks, blocksLength, delimiter) {
var result = '';

blocks.forEach(function (length, index) {
if (value.length > 0) {
var sub = value.slice(0, length),
rest = value.slice(length);

result += sub;

if (sub.length === length && index < blocksLength - 1) {
result += delimiter;
}

// update remaining string
value = rest;
}
});

return result;
}
};

if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = exports = Util;
}

'use strict';

/**
* Props Assignment
*
* Separate this, so react module can share the usage
*/
var DefaultProperties = {
// Maybe change to object-assign
// for now just keep it as simple
assign: function (target, opts) {
target = target || {};
opts = opts || {};

// credit card
target.creditCard = !!opts.creditCard;
target.creditCardStrictMode = !!opts.creditCardStrictMode;

// phone
target.phone = !!opts.phone;
target.phoneRegionCode = opts.phoneRegionCode || 'AU';
target.phoneFormatter = {};

// date
target.date = !!opts.date;
target.datePattern = opts.datePattern || ['d', 'm', 'Y'];
target.dateFormatter = {};

// numeral
target.numeral = !!opts.numeral;
target.numeralDecimalScale = opts.numeralDecimalScale || 2;
target.numeralDecimalMark = opts.numeralDecimalMark || '.';
target.numeralThousandsGroupStyle = opts.numeralThousandsGroupStyle || 'thousand';

// others
target.initValue = opts.initValue || '';

target.numericOnly = target.creditCard || target.date || !!opts.numericOnly;

target.prefix = (target.creditCard || target.phone || target.date) ? '' : (opts.prefix || '');

target.delimiter = opts.delimiter || (target.date ? '/' : (target.numeral ? ',' : ' '));
target.delimiterRE = new RegExp(target.delimiter, 'g');

target.blocks = opts.blocks || [];
target.blocksLength = target.blocks.length;

target.maxLength = 0;

target.backspace = false;
target.result = '';

return target;
}
};

if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = exports = DefaultProperties;
}

'use strict';

var CreditCardDetector = {
blocks: {
uatp: [4, 5, 6],
Expand Down
4 changes: 2 additions & 2 deletions dist/cleave.min.js

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

Loading

0 comments on commit d3761a4

Please sign in to comment.