Initial commit
This commit is contained in:
4
node_modules/react-password-mask/.babelrc
generated
vendored
Normal file
4
node_modules/react-password-mask/.babelrc
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"presets": ["react", "es2015", "stage-0"],
|
||||
"plugins": ["add-module-exports"]
|
||||
}
|
||||
6
node_modules/react-password-mask/lib/passwordMask.min.js
generated
vendored
Normal file
6
node_modules/react-password-mask/lib/passwordMask.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
58
node_modules/react-password-mask/package.json
generated
vendored
Normal file
58
node_modules/react-password-mask/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "react-password-mask",
|
||||
"version": "3.3.1",
|
||||
"description": "Show/hide the contents of a password field.",
|
||||
"main": "lib/passwordMask.min.js",
|
||||
"jest": {
|
||||
"testRegex": "(/test/.*|(\\.|/))\\.js?$",
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json"
|
||||
],
|
||||
"collectCoverage": true,
|
||||
"coverageDirectory": "coverage",
|
||||
"coverageReporters": [
|
||||
"lcov"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/zakangelle/react-password-mask.git"
|
||||
},
|
||||
"author": "Zak Angelle",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/zakangelle/react-password-mask#readme",
|
||||
"peerDependencies": {
|
||||
"react": "^0.14.6 || 15.x.x",
|
||||
"prop-types": "^15.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.16.0",
|
||||
"babel-eslint": "^6.1.2",
|
||||
"babel-loader": "^6.2.5",
|
||||
"babel-plugin-add-module-exports": "^0.2.1",
|
||||
"babel-preset-es2015": "^6.22.0",
|
||||
"babel-preset-react": "^6.22.0",
|
||||
"babel-preset-stage-0": "^6.5.0",
|
||||
"coveralls": "^2.11.14",
|
||||
"cross-env": "^3.1.3",
|
||||
"css-loader": "^0.25.0",
|
||||
"enzyme": "^2.4.1",
|
||||
"eslint": "^1.10.3",
|
||||
"eslint-config-airbnb": "^5.0.1",
|
||||
"eslint-loader": "^1.5.0",
|
||||
"eslint-plugin-react": "^3.16.1",
|
||||
"extract-text-webpack-plugin": "^2.0.0",
|
||||
"html-webpack-plugin": "^2.28.0",
|
||||
"jest": "^19.0.2",
|
||||
"react": "^15.3.2",
|
||||
"prop-types": "^15.3.2",
|
||||
"react-addons-test-utils": "^15.4.2",
|
||||
"react-dom": "^15.3.2",
|
||||
"react-test-renderer": "^15.4.2",
|
||||
"sinon": "^1.17.6",
|
||||
"style-loader": "^0.13.1",
|
||||
"webpack": "^2.2.1",
|
||||
"webpack-dev-server": "^2.2.0"
|
||||
}
|
||||
}
|
||||
181
node_modules/react-password-mask/src/index.js
generated
vendored
Normal file
181
node_modules/react-password-mask/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { containerStyles, inputStyles, buttonStyles } from './styles.js';
|
||||
|
||||
export default class PasswordMask extends Component {
|
||||
static propTypes = {
|
||||
value: PropTypes.any.isRequired,
|
||||
id: PropTypes.string,
|
||||
name: PropTypes.string,
|
||||
className: PropTypes.string,
|
||||
inputClassName: PropTypes.string,
|
||||
buttonClassName: PropTypes.string,
|
||||
placeholder: PropTypes.string,
|
||||
autoFocus: PropTypes.bool,
|
||||
minLength: PropTypes.number,
|
||||
maxLength: PropTypes.number,
|
||||
onChange: PropTypes.func,
|
||||
onBlur: PropTypes.func,
|
||||
onKeyDown: PropTypes.func,
|
||||
onShow: PropTypes.func,
|
||||
onHide: PropTypes.func,
|
||||
onToggle: PropTypes.func,
|
||||
useVendorStyles: PropTypes.bool,
|
||||
readOnly: PropTypes.bool,
|
||||
required: PropTypes.bool,
|
||||
disabled: PropTypes.bool,
|
||||
inputStyles: PropTypes.any,
|
||||
buttonStyles: PropTypes.any,
|
||||
showButtonContent: PropTypes.oneOfType([
|
||||
PropTypes.element,
|
||||
PropTypes.string
|
||||
]),
|
||||
hideButtonContent: PropTypes.oneOfType([
|
||||
PropTypes.element,
|
||||
PropTypes.string
|
||||
])
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
inputClassName: '',
|
||||
buttonClassName: '',
|
||||
placeholder: '',
|
||||
useVendorStyles: true,
|
||||
onChange() {},
|
||||
onBlur() {},
|
||||
onKeyDown() {}
|
||||
}
|
||||
|
||||
state = {
|
||||
passwordShown: false,
|
||||
hasBeenFocused: false
|
||||
}
|
||||
|
||||
invokeCallbacks(value, passwordShown) {
|
||||
const { onShow, onHide, onToggle } = this.props;
|
||||
|
||||
if (onToggle) {
|
||||
onToggle(value);
|
||||
}
|
||||
|
||||
if (onShow && passwordShown) {
|
||||
onShow(value);
|
||||
}
|
||||
|
||||
if (onHide && !passwordShown) {
|
||||
onHide(value);
|
||||
}
|
||||
}
|
||||
|
||||
focusVisibleInput() {
|
||||
const { passwordShown } = this.state;
|
||||
const visibleInput = passwordShown ? this.textInput : this.passwordInput;
|
||||
|
||||
visibleInput.focus();
|
||||
}
|
||||
|
||||
componentWillUpdate(nextProps, nextState) {
|
||||
const { passwordShown } = this.state;
|
||||
|
||||
if (nextState.passwordShown !== passwordShown) {
|
||||
this.invokeCallbacks(nextProps.value, nextState.passwordShown);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const { passwordShown, hasBeenFocused } = this.state;
|
||||
|
||||
if (hasBeenFocused && prevState.passwordShown !== passwordShown) {
|
||||
this.focusVisibleInput();
|
||||
}
|
||||
}
|
||||
|
||||
togglePasswordMask() {
|
||||
this.setState({ passwordShown: !this.state.passwordShown });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { value, id, name, className, inputClassName, buttonClassName, placeholder, autoFocus, minLength, maxLength, onChange, onBlur, onKeyDown, showButtonContent, hideButtonContent, useVendorStyles, readOnly, disabled, required } = this.props;
|
||||
const { passwordShown } = this.state;
|
||||
|
||||
const vendorContainerCss = useVendorStyles ? containerStyles : {};
|
||||
const vendorInputCss = useVendorStyles ? inputStyles : {};
|
||||
const vendorButtonCss = useVendorStyles ? buttonStyles : {};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={className}
|
||||
style={vendorContainerCss}
|
||||
>
|
||||
<input
|
||||
type="password"
|
||||
ref={input => this.passwordInput = input}
|
||||
value={value}
|
||||
id={!passwordShown ? id : `_${id}`}
|
||||
name={!passwordShown ? name : ''}
|
||||
className={inputClassName}
|
||||
placeholder={placeholder}
|
||||
autoFocus={autoFocus}
|
||||
minLength={minLength}
|
||||
maxLength={maxLength}
|
||||
readOnly={readOnly}
|
||||
disabled={disabled}
|
||||
required={required}
|
||||
style={{
|
||||
...vendorInputCss,
|
||||
...this.props.inputStyles,
|
||||
display: !passwordShown ? 'block' : 'none'
|
||||
}}
|
||||
onChange={onChange}
|
||||
onBlur={onBlur}
|
||||
onKeyDown={onKeyDown}
|
||||
onFocus={() => this.setState({ hasBeenFocused: true })}
|
||||
/>
|
||||
|
||||
<input
|
||||
type="text"
|
||||
ref={input => this.textInput = input}
|
||||
value={value}
|
||||
id={passwordShown ? id : `_${id}`}
|
||||
name={passwordShown ? name : ''}
|
||||
className={inputClassName}
|
||||
placeholder={placeholder}
|
||||
minLength={minLength}
|
||||
maxLength={maxLength}
|
||||
readOnly={readOnly}
|
||||
disabled={disabled}
|
||||
required={required}
|
||||
style={{
|
||||
...vendorInputCss,
|
||||
...this.props.inputStyles,
|
||||
display: passwordShown ? 'block' : 'none'
|
||||
}}
|
||||
onChange={onChange}
|
||||
onBlur={onBlur}
|
||||
onKeyDown={onKeyDown}
|
||||
onFocus={() => this.setState({ hasBeenFocused: true })}
|
||||
/>
|
||||
|
||||
<a
|
||||
href=""
|
||||
className={buttonClassName}
|
||||
style={{
|
||||
...vendorButtonCss,
|
||||
...this.props.buttonStyles
|
||||
}}
|
||||
onMouseDown={e => e.preventDefault()}
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
this.togglePasswordMask();
|
||||
}}
|
||||
tabIndex={-1}
|
||||
>
|
||||
{passwordShown ?
|
||||
hideButtonContent || 'Hide' :
|
||||
showButtonContent || 'Show'
|
||||
}
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
23
node_modules/react-password-mask/src/styles.js
generated
vendored
Normal file
23
node_modules/react-password-mask/src/styles.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
export const containerStyles = {
|
||||
position: 'relative'
|
||||
};
|
||||
|
||||
export const inputStyles = {
|
||||
width: '100%'
|
||||
};
|
||||
|
||||
export const buttonStyles = {
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
right: '6px',
|
||||
marginTop: '-13px',
|
||||
padding: '4px 10px',
|
||||
background: '#e2e2e2',
|
||||
borderRadius: '2px',
|
||||
color: '#000',
|
||||
textAlign: 'center',
|
||||
textDecoration: 'none',
|
||||
WebkitUserSelect: 'none',
|
||||
MozUserSelect: 'none',
|
||||
userSelect: 'none'
|
||||
};
|
||||
33
node_modules/react-password-mask/webpack.config.js
generated
vendored
Normal file
33
node_modules/react-password-mask/webpack.config.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
|
||||
const libraryName = 'passwordMask';
|
||||
|
||||
module.exports = {
|
||||
entry: path.join(__dirname, 'src/index.js'),
|
||||
output: {
|
||||
path: path.join(__dirname, 'lib'),
|
||||
filename: libraryName + '.min.js',
|
||||
library: libraryName,
|
||||
libraryTarget: 'umd',
|
||||
umdNamedDefine: true
|
||||
},
|
||||
externals: {
|
||||
react: 'react'
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: 'babel-loader',
|
||||
exclude: /node_modules/
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: 'eslint-loader',
|
||||
exclude: /node_modules/
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [new webpack.optimize.UglifyJsPlugin({ minimize: true })]
|
||||
};
|
||||
Reference in New Issue
Block a user