react-two-cents
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,2 +0,2 @@ | ||
var r,t=require("react"),e=(r=t)&&"object"==typeof r&&"default"in r?r.default:r,o=Object.assign||function(r){for(var t=arguments,e=1;e<arguments.length;e++){var o=t[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r},n=t.createContext({touched:!1,focused:!1,error:!1,controlId:null,register:function(){return function(){}}});function i(r){return function(t){return e.createElement(n.Consumer,null,function(n){return e.createElement(r,o({register:n.register},t))})}}var u=function(r){function t(t){r.call(this,t),this.register=this.register.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.state={touched:!1,focused:!1,error:null,controlId:null,register:this.register,focus:this.focus,blur:this.blur,setError:this.setError}}return r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t,t.prototype.register=function(r){var t,e=this;return function(o){e.setState("error"===r?function(r){return{error:!r.error}}:((t={})[r+"Id"]=o,t))}},t.prototype.focus=function(){this.setState({focused:!0,touched:!0})},t.prototype.blur=function(){this.setState({focused:!1})},t.prototype.render=function(){var r=this;return e.createElement(n.Provider,{value:this.state},e.createElement(n.Consumer,null,function(t){return r.props.children(t)}))},t}(e.Component);u.displayName="Field";var c=Object.assign||function(r){for(var t=arguments,e=1;e<arguments.length;e++){var o=t[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r};var s=function(r){function t(){r.apply(this,arguments)}return r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t,t.prototype.componentDidMount=function(){var r=this.props,t=r.id;(0,r.register)("control")(t)},t.prototype.render=function(){var r=this.props,t=r.children,o=r.onBlur,i=r.onFocus,u=function(r,t){var e={};for(var o in r)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}(r,["children","id","onBlur","onFocus","register"]);return e.createElement(n.Consumer,null,function(r){var n=r.focus,s=r.blur,p={id:r.controlId,onFocus:function(){n(),i&&i()},onBlur:function(){s(),o&&o()},"aria-invalid":!!r.error};return t?t(p):e.createElement("input",c({},p,u))})},t}(e.Component);s.displayName="RegisteredControl";var p=i(s);p.displayName="Control";var a=Object.assign||function(r){for(var t=arguments,e=1;e<arguments.length;e++){var o=t[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r},l=function(r){return e.createElement(n.Consumer,null,function(t){return e.createElement("label",a({htmlFor:t.controlId},r))})};l.displayName="label";var f=function(r){function t(){r.apply(this,arguments)}return r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t,t.prototype.componentDidMount=function(){var r=this.props;(0,r.register)("error")(!0)},t.prototype.componentWillUnmount=function(){(0,this.props.register)("error")(!1)},t.prototype.render=function(){return this.props.children},t}(e.Component);f.displayName="RegisteredError";var d=i(f);d.displayName="Error",exports.Label=l,exports.Control=p,exports.Field=u,exports.Error=d; | ||
var t,r=require("react"),e=(t=r)&&"object"==typeof t&&"default"in t?t.default:t,o=Object.assign||function(t){for(var r=arguments,e=1;e<arguments.length;e++){var o=r[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},n=r.createContext({touched:!1,focused:!1,error:!1,controlId:null,register:function(){return function(){}}});function i(t){return function(r){return e.createElement(n.Consumer,null,function(n){return e.createElement(t,o({register:n.register},r))})}}var u=function(t){function r(r){t.call(this,r),this.register=this.register.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.state={touched:!1,focused:!1,error:null,controlId:null,register:this.register,focus:this.focus,blur:this.blur,setError:this.setError}}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.register=function(t){var r,e=this;return function(o){e.setState("error"===t?function(t){return{error:!t.error}}:((r={})[t+"Id"]=o,r))}},r.prototype.focus=function(){this.setState({focused:!0,touched:!0})},r.prototype.blur=function(){this.setState({focused:!1})},r.prototype.render=function(){var t=this;return e.createElement(n.Provider,{value:this.state},e.createElement(n.Consumer,null,function(r){return t.props.children(r)}))},r}(e.Component),c=Object.assign||function(t){for(var r=arguments,e=1;e<arguments.length;e++){var o=r[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t};var s=i(function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.componentDidMount=function(){var t=this.props,r=t.id;(0,t.register)("control")(r)},r.prototype.render=function(){var t=this.props,r=t.children,o=t.onBlur,i=t.onFocus,u=function(t,r){var e={};for(var o in t)r.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}(t,["children","id","onBlur","onFocus"]);return e.createElement(n.Consumer,null,function(t){var n=t.focus,s=t.blur,p={id:t.controlId,onFocus:function(){n(),i&&i()},onBlur:function(){s(),o&&o()},"aria-invalid":!!t.error};return r?r(p):e.createElement("input",c({},p,u))})},r}(e.Component)),p=Object.assign||function(t){for(var r=arguments,e=1;e<arguments.length;e++){var o=r[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},l=i(function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.componentDidMount=function(){var t=this.props;(0,t.register)("error")(!0)},r.prototype.componentWillUnmount=function(){(0,this.props.register)("error")(!1)},r.prototype.render=function(){return this.props.children},r}(e.Component));exports.Label=function(t){return e.createElement(n.Consumer,null,function(r){return e.createElement("label",p({htmlFor:r.controlId},t))})},exports.Control=s,exports.Field=u,exports.Error=l; | ||
//# sourceMappingURL=react-two-cents.js.map |
@@ -1,2 +0,2 @@ | ||
import r,{createContext as t}from"react";var e=Object.assign||function(r){for(var t=arguments,e=1;e<arguments.length;e++){var o=t[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r},o=t({touched:!1,focused:!1,error:!1,controlId:null,register:function(){return function(){}}});function n(t){return function(n){return r.createElement(o.Consumer,null,function(o){return r.createElement(t,e({register:o.register},n))})}}var i=function(t){function e(r){t.call(this,r),this.register=this.register.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.state={touched:!1,focused:!1,error:null,controlId:null,register:this.register,focus:this.focus,blur:this.blur,setError:this.setError}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.register=function(r){var t,e=this;return function(o){e.setState("error"===r?function(r){return{error:!r.error}}:((t={})[r+"Id"]=o,t))}},e.prototype.focus=function(){this.setState({focused:!0,touched:!0})},e.prototype.blur=function(){this.setState({focused:!1})},e.prototype.render=function(){var t=this;return r.createElement(o.Provider,{value:this.state},r.createElement(o.Consumer,null,function(r){return t.props.children(r)}))},e}(r.Component);i.displayName="Field";var u=Object.assign||function(r){for(var t=arguments,e=1;e<arguments.length;e++){var o=t[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r};var c=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.componentDidMount=function(){var r=this.props,t=r.id;(0,r.register)("control")(t)},e.prototype.render=function(){var t=this.props,e=t.children,n=t.onBlur,i=t.onFocus,c=function(r,t){var e={};for(var o in r)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}(t,["children","id","onBlur","onFocus","register"]);return r.createElement(o.Consumer,null,function(t){var o=t.focus,s=t.blur,p={id:t.controlId,onFocus:function(){o(),i&&i()},onBlur:function(){s(),n&&n()},"aria-invalid":!!t.error};return e?e(p):r.createElement("input",u({},p,c))})},e}(r.Component);c.displayName="RegisteredControl";var s=n(c);s.displayName="Control";var p=Object.assign||function(r){for(var t=arguments,e=1;e<arguments.length;e++){var o=t[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r},a=function(t){return r.createElement(o.Consumer,null,function(e){return r.createElement("label",p({htmlFor:e.controlId},t))})};a.displayName="label";var l=function(r){function t(){r.apply(this,arguments)}return r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t,t.prototype.componentDidMount=function(){var r=this.props;(0,r.register)("error")(!0)},t.prototype.componentWillUnmount=function(){(0,this.props.register)("error")(!1)},t.prototype.render=function(){return this.props.children},t}(r.Component);l.displayName="RegisteredError";var f=n(l);f.displayName="Error";export{a as Label,s as Control,i as Field,f as Error}; | ||
import t,{createContext as r}from"react";var e=Object.assign||function(t){for(var r=arguments,e=1;e<arguments.length;e++){var o=r[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},o=r({touched:!1,focused:!1,error:!1,controlId:null,register:function(){return function(){}}});function n(r){return function(n){return t.createElement(o.Consumer,null,function(o){return t.createElement(r,e({register:o.register},n))})}}var i=function(r){function e(t){r.call(this,t),this.register=this.register.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.state={touched:!1,focused:!1,error:null,controlId:null,register:this.register,focus:this.focus,blur:this.blur,setError:this.setError}}return r&&(e.__proto__=r),(e.prototype=Object.create(r&&r.prototype)).constructor=e,e.prototype.register=function(t){var r,e=this;return function(o){e.setState("error"===t?function(t){return{error:!t.error}}:((r={})[t+"Id"]=o,r))}},e.prototype.focus=function(){this.setState({focused:!0,touched:!0})},e.prototype.blur=function(){this.setState({focused:!1})},e.prototype.render=function(){var r=this;return t.createElement(o.Provider,{value:this.state},t.createElement(o.Consumer,null,function(t){return r.props.children(t)}))},e}(t.Component),u=Object.assign||function(t){for(var r=arguments,e=1;e<arguments.length;e++){var o=r[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t};var c=n(function(r){function e(){r.apply(this,arguments)}return r&&(e.__proto__=r),(e.prototype=Object.create(r&&r.prototype)).constructor=e,e.prototype.componentDidMount=function(){var t=this.props,r=t.id;(0,t.register)("control")(r)},e.prototype.render=function(){var r=this.props,e=r.children,n=r.onBlur,i=r.onFocus,c=function(t,r){var e={};for(var o in t)r.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}(r,["children","id","onBlur","onFocus"]);return t.createElement(o.Consumer,null,function(r){var o=r.focus,s=r.blur,p={id:r.controlId,onFocus:function(){o(),i&&i()},onBlur:function(){s(),n&&n()},"aria-invalid":!!r.error};return e?e(p):t.createElement("input",u({},p,c))})},e}(t.Component)),s=Object.assign||function(t){for(var r=arguments,e=1;e<arguments.length;e++){var o=r[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},p=function(r){return t.createElement(o.Consumer,null,function(e){return t.createElement("label",s({htmlFor:e.controlId},r))})},l=n(function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.componentDidMount=function(){var t=this.props;(0,t.register)("error")(!0)},r.prototype.componentWillUnmount=function(){(0,this.props.register)("error")(!1)},r.prototype.render=function(){return this.props.children},r}(t.Component));export{p as Label,c as Control,i as Field,l as Error}; | ||
//# sourceMappingURL=react-two-cents.m.js.map |
@@ -1,2 +0,2 @@ | ||
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t(r.reactTwoCents={},r.react)}(this,function(r,t){var e="default"in t?t.default:t,o=Object.assign||function(r){for(var t=arguments,e=1;e<arguments.length;e++){var o=t[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r},n=t.createContext({touched:!1,focused:!1,error:!1,controlId:null,register:function(){return function(){}}});function i(r){return function(t){return e.createElement(n.Consumer,null,function(n){return e.createElement(r,o({register:n.register},t))})}}var u=function(r){function t(t){r.call(this,t),this.register=this.register.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.state={touched:!1,focused:!1,error:null,controlId:null,register:this.register,focus:this.focus,blur:this.blur,setError:this.setError}}return r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t,t.prototype.register=function(r){var t,e=this;return function(o){e.setState("error"===r?function(r){return{error:!r.error}}:((t={})[r+"Id"]=o,t))}},t.prototype.focus=function(){this.setState({focused:!0,touched:!0})},t.prototype.blur=function(){this.setState({focused:!1})},t.prototype.render=function(){var r=this;return e.createElement(n.Provider,{value:this.state},e.createElement(n.Consumer,null,function(t){return r.props.children(t)}))},t}(e.Component);u.displayName="Field";var c=Object.assign||function(r){for(var t=arguments,e=1;e<arguments.length;e++){var o=t[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r};var s=function(r){function t(){r.apply(this,arguments)}return r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t,t.prototype.componentDidMount=function(){var r=this.props,t=r.id;(0,r.register)("control")(t)},t.prototype.render=function(){var r=this.props,t=r.children,o=r.onBlur,i=r.onFocus,u=function(r,t){var e={};for(var o in r)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}(r,["children","id","onBlur","onFocus","register"]);return e.createElement(n.Consumer,null,function(r){var n=r.focus,s=r.blur,a={id:r.controlId,onFocus:function(){n(),i&&i()},onBlur:function(){s(),o&&o()},"aria-invalid":!!r.error};return t?t(a):e.createElement("input",c({},a,u))})},t}(e.Component);s.displayName="RegisteredControl";var a=i(s);a.displayName="Control";var p=Object.assign||function(r){for(var t=arguments,e=1;e<arguments.length;e++){var o=t[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r[n]=o[n])}return r},l=function(r){return e.createElement(n.Consumer,null,function(t){return e.createElement("label",p({htmlFor:t.controlId},r))})};l.displayName="label";var f=function(r){function t(){r.apply(this,arguments)}return r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t,t.prototype.componentDidMount=function(){var r=this.props;(0,r.register)("error")(!0)},t.prototype.componentWillUnmount=function(){(0,this.props.register)("error")(!1)},t.prototype.render=function(){return this.props.children},t}(e.Component);f.displayName="RegisteredError";var d=i(f);d.displayName="Error",r.Label=l,r.Control=a,r.Field=u,r.Error=d}); | ||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],r):r(t.reactTwoCents={},t.react)}(this,function(t,r){var e="default"in r?r.default:r,o=Object.assign||function(t){for(var r=arguments,e=1;e<arguments.length;e++){var o=r[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},n=r.createContext({touched:!1,focused:!1,error:!1,controlId:null,register:function(){return function(){}}});function i(t){return function(r){return e.createElement(n.Consumer,null,function(n){return e.createElement(t,o({register:n.register},r))})}}var u=function(t){function r(r){t.call(this,r),this.register=this.register.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.state={touched:!1,focused:!1,error:null,controlId:null,register:this.register,focus:this.focus,blur:this.blur,setError:this.setError}}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.register=function(t){var r,e=this;return function(o){e.setState("error"===t?function(t){return{error:!t.error}}:((r={})[t+"Id"]=o,r))}},r.prototype.focus=function(){this.setState({focused:!0,touched:!0})},r.prototype.blur=function(){this.setState({focused:!1})},r.prototype.render=function(){var t=this;return e.createElement(n.Provider,{value:this.state},e.createElement(n.Consumer,null,function(r){return t.props.children(r)}))},r}(e.Component),c=Object.assign||function(t){for(var r=arguments,e=1;e<arguments.length;e++){var o=r[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t};var s=i(function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.componentDidMount=function(){var t=this.props,r=t.id;(0,t.register)("control")(r)},r.prototype.render=function(){var t=this.props,r=t.children,o=t.onBlur,i=t.onFocus,u=function(t,r){var e={};for(var o in t)r.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}(t,["children","id","onBlur","onFocus"]);return e.createElement(n.Consumer,null,function(t){var n=t.focus,s=t.blur,p={id:t.controlId,onFocus:function(){n(),i&&i()},onBlur:function(){s(),o&&o()},"aria-invalid":!!t.error};return r?r(p):e.createElement("input",c({},p,u))})},r}(e.Component)),p=Object.assign||function(t){for(var r=arguments,e=1;e<arguments.length;e++){var o=r[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},l=i(function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.componentDidMount=function(){var t=this.props;(0,t.register)("error")(!0)},r.prototype.componentWillUnmount=function(){(0,this.props.register)("error")(!1)},r.prototype.render=function(){return this.props.children},r}(e.Component));t.Label=function(t){return e.createElement(n.Consumer,null,function(r){return e.createElement("label",p({htmlFor:r.controlId},t))})},t.Control=s,t.Field=u,t.Error=l}); | ||
//# sourceMappingURL=react-two-cents.umd.js.map |
{ | ||
"name": "react-two-cents", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "My input on input fields in React", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-two-cents.js", |
@@ -18,12 +18,12 @@ import React from 'react'; | ||
id: controlId, | ||
onFocus: () => { | ||
onFocus: (e) => { | ||
focus(); | ||
if (onFocus) { | ||
onFocus(); | ||
onFocus(e); | ||
} | ||
}, | ||
onBlur: () => { | ||
onBlur: (e) => { | ||
blur(); | ||
if (onBlur) { | ||
onBlur(); | ||
onBlur(e); | ||
} | ||
@@ -30,0 +30,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
120925
177