Socket
Socket
Sign inDemoInstall

uncontrollable

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uncontrollable - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

README.md

22

createUncontrollable.js

@@ -19,6 +19,2 @@ 'use strict';

var _reactLibInvariant = require('react/lib/invariant');
var _reactLibInvariant2 = _interopRequireDefault(_reactLibInvariant);
var _utils = require('./utils');

@@ -33,21 +29,11 @@

function uncontrollable(Component, controlledValues) {
var displayName = 'Uncontrolled(' + (Component.displayName || Component.name || 'Component') + ')',
var displayName = Component.displayName || Component.name || 'Component',
basePropTypes = utils.getType(Component).propTypes,
propTypes = {};
propTypes;
if (process.env.NODE_ENV !== 'production' && basePropTypes) {
utils.transform(controlledValues, function (obj, handler, prop) {
var type = basePropTypes[prop];
propTypes = utils.uncontrolledPropTypes(controlledValues, basePropTypes, displayName);
_reactLibInvariant2['default'](typeof handler === 'string' && handler.trim().length, 'Uncontrollable - [%s]: the prop `%s` needs a valid handler key name in order to make it uncontrollable', Component.displayName, prop);
obj[prop] = utils.customPropType(handler, type, Component.displayName);
if (type !== undefined) obj[utils.defaultKey(prop)] = type;
}, propTypes);
}
var component = _react2['default'].createClass({
displayName: displayName,
displayName: 'Uncontrolled(' + displayName + ')',

@@ -54,0 +40,0 @@ mixins: mixins,

{
"name": "uncontrollable",
"version": "3.0.0",
"version": "3.0.1",
"description": "Wrap a controlled react component, to allow spcific prop/handler pairs to be uncontrolled",

@@ -19,3 +19,9 @@ "author": {

"form"
]
],
"dependencies": {
"invariant": "^2.1.0"
},
"peerDependencies": {
"react": ">=0.11.0"
}
}

@@ -5,2 +5,3 @@ 'use strict';

exports.customPropType = customPropType;
exports.uncontrolledPropTypes = uncontrolledPropTypes;
exports.getType = getType;

@@ -20,10 +21,16 @@ exports.getLinkName = getLinkName;

var _invariant = require('invariant');
var _invariant2 = _interopRequireDefault(_invariant);
function customPropType(handler, propType, name) {
return function (props, propName, componentName, location) {
return function (props, propName, componentName) {
if (props[propName] !== undefined) {
if (!props[handler]) return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`');
if (!props[handler]) {
return new Error('You have provided a `' + propName + '` prop to ' + '`' + name + '` without an `' + handler + '` handler. This will render a read-only field. ' + 'If the field should be mutable use `' + defaultKey(propName) + '`. Otherwise, set `' + handler + '`');
}
return propType && propType(props, propName, name, location);
return propType && propType(props, propName, name);
}

@@ -33,2 +40,20 @@ };

function uncontrolledPropTypes(controlledValues, basePropTypes, displayName) {
var propTypes = {};
if (process.env.NODE_ENV !== 'production' && basePropTypes) {
transform(controlledValues, function (obj, handler, prop) {
var type = basePropTypes[prop];
_invariant2['default'](typeof handler === 'string' && handler.trim().length, 'Uncontrollable - [%s]: the prop `%s` needs a valid handler key name in order to make it uncontrollable', displayName, prop);
obj[prop] = customPropType(handler, type, displayName);
if (type !== undefined) obj[defaultKey(prop)] = type;
}, propTypes);
}
return propTypes;
}
var version = _react2['default'].version.split('.').map(parseFloat);

@@ -35,0 +60,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc