@leafygreen-ui/radio-group
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("prop-types"),require("@leafygreen-ui/theme"),require("@leafygreen-ui/lib"));else if("function"==typeof define&&define.amd)define(["react","prop-types","@leafygreen-ui/theme","@leafygreen-ui/lib"],t);else{var r="object"==typeof exports?t(require("react"),require("prop-types"),require("@leafygreen-ui/theme"),require("@leafygreen-ui/lib")):t(e.react,e["prop-types"],e["@leafygreen-ui/theme"],e["@leafygreen-ui/lib"]);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,function(e,t,r,n){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"Radio",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"RadioGroup",{enumerable:!0,get:function(){return o.default}});var n=a(r(5)),o=a(r(6));function a(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,r):{};n.get||n.set?Object.defineProperty(t,r,n):t[r]=e[r]}return t.default=e,t}(r(0)),a=(n=r(1))&&n.__esModule?n:{default:n},u=r(2),i=r(3);function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function f(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,t){return!t||"object"!==l(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var m=i.emotion.css,h=m("cursor:pointer;margin-bottom:5px;display:block;"),v=m("margin-right:0.5em;cursor:pointer;&:disabled{cursor:not-allowed;}"),g={default:m(".",v,":disabled + &{color:",u.colors.gray[5],";}"),light:m(".",v,":disabled + &{color:",u.colors.gray[4],";}")},O=m("line-height:0.9em;"),j=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),p(this,d(t).apply(this,arguments))}var r,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&y(e,t)}(t,o.PureComponent),r=t,(n=[{key:"render",value:function(){var e=this.props,t=e.children,r=e.className,n=e.onChange,a=e.value,u=e.checked,l=e.disabled,s=e.id,p=e.name,d=e.variant,y=f(e,["children","className","onChange","value","checked","disabled","id","name","variant"]),b=g[d];return o.default.createElement("label",{htmlFor:s,className:(0,i.ccClassName)(h,r)},o.default.createElement("input",c({},y,{id:s,name:p,type:"radio",className:(0,i.ccClassName)(v,r),onChange:n,value:a,checked:u,"aria-checked":u,disabled:l,"aria-disabled":l})),o.default.createElement("span",{className:(0,i.ccClassName)(O,b)},t))}}])&&s(r.prototype,n),a&&s(r,a),t}();t.default=j,b(j,"displayName","Radio"),b(j,"propTypes",{checked:a.default.bool,disabled:a.default.bool,className:a.default.string,children:a.default.node,onChange:a.default.func,value:a.default.oneOfType([a.default.string,a.default.number]).isRequired,id:a.default.string,name:a.default.string,variant:a.default.oneOf(["default","light"])}),b(j,"defaultProps",{checked:!1,disabled:!1,className:"",onChange:function(){},variant:"default"})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,r):{};n.get||n.set?Object.defineProperty(t,r,n):t[r]=e[r]}return t.default=e,t}(r(0)),a=(n=r(1))&&n.__esModule?n:{default:n},u=r(2),i=r(3);function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var y=i.emotion.css,b={default:y("color:",u.colors.gray[2],";"),light:y("color:",u.colors.gray[6],";")},m=y("padding:5px;"),h=function(e){function t(){var e,r,n,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var a=arguments.length,u=new Array(a),i=0;i<a;i++)u[i]=arguments[i];return n=this,o=(e=f(t)).call.apply(e,[this].concat(u)),r=!o||"object"!==l(o)&&"function"!=typeof o?p(n):o,d(p(p(r)),"state",{value:""}),d(p(p(r)),"defaultName","radio-group-".concat(Math.floor(1e6*Math.random()))),d(p(p(r)),"handleChange",function(e){var t=r.props,n=t.onChange,o=t.value;n&&n(e),o||r.setState({value:e.target.value})}),r}var r,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,o.PureComponent),r=t,(n=[{key:"render",value:function(){var e=this,t=this.props,r=t.children,n=t.name,a=void 0===n?this.defaultName:n,u=t.className,l=t.variant,c=t.value,f=void 0===c?this.state.value:c,s=o.default.Children.map(r,function(t,r){return"Radio"!==t.type.displayName?t:o.default.cloneElement(t,{onChange:e.handleChange,checked:f===t.props.value,id:t.props.id||"".concat(e.defaultName,"-button-").concat(r),variant:l,name:a})}),p=b[l];return o.default.createElement("div",{className:(0,i.ccClassName)(y(p," ",m),u)},s)}}])&&c(r.prototype,n),a&&c(r,a),t}();t.default=h,d(h,"displayName","RadioGroup"),d(h,"propTypes",{variant:a.default.oneOf(["default","light"]),className:a.default.string,value:a.default.oneOfType([a.default.string,a.default.number]),onChange:a.default.func,children:a.default.node,name:a.default.string}),d(h,"defaultProps",{variant:"default",className:"",onChange:function(){}})}])}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("prop-types"),require("@leafygreen-ui/theme"),require("@leafygreen-ui/lib"));else if("function"==typeof define&&define.amd)define(["react","prop-types","@leafygreen-ui/theme","@leafygreen-ui/lib"],t);else{var r="object"==typeof exports?t(require("react"),require("prop-types"),require("@leafygreen-ui/theme"),require("@leafygreen-ui/lib")):t(e.react,e["prop-types"],e["@leafygreen-ui/theme"],e["@leafygreen-ui/lib"]);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,function(e,t,r,n){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"Radio",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"RadioGroup",{enumerable:!0,get:function(){return o.default}});var n=a(r(5)),o=a(r(6));function a(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,r):{};n.get||n.set?Object.defineProperty(t,r,n):t[r]=e[r]}return t.default=e,t}(r(0)),a=(n=r(1))&&n.__esModule?n:{default:n},u=r(2),i=r(3);function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(){return(f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t){return!t||"object"!==l(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var m=i.emotion.css,h=i.emotion.cx,v=m("cursor:pointer;margin-bottom:5px;display:block;"),g=m("margin-right:0.5em;cursor:pointer;&:disabled{cursor:not-allowed;}"),O={default:m("color:",u.colors.gray[5],";"),light:m("color:",u.colors.gray[4],";")},j=m("line-height:0.9em;"),P=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),s(this,d(t).apply(this,arguments))}var r,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&y(e,t)}(t,o.PureComponent),r=t,(n=[{key:"render",value:function(){var e=this.props,t=e.children,r=e.className,n=e.onChange,a=e.value,u=e.checked,i=e.disabled,l=e.id,p=e.name,s=e.variant,d=c(e,["children","className","onChange","value","checked","disabled","id","name","variant"]);return o.default.createElement("label",{htmlFor:l,className:h(v,r)},o.default.createElement("input",f({},d,{id:l,name:p,type:"radio",className:h(g,r),onChange:n,value:a,checked:u,"aria-checked":u,disabled:i,"aria-disabled":i})),o.default.createElement("span",{className:h(j,b({},O[s],i))},t))}}])&&p(r.prototype,n),a&&p(r,a),t}();t.default=P,b(P,"displayName","Radio"),b(P,"propTypes",{checked:a.default.bool,disabled:a.default.bool,className:a.default.string,children:a.default.node,onChange:a.default.func,value:a.default.oneOfType([a.default.string,a.default.number]).isRequired,id:a.default.string,name:a.default.string,variant:a.default.oneOf(["default","light"])}),b(P,"defaultProps",{checked:!1,disabled:!1,className:"",onChange:function(){},variant:"default"})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,r):{};n.get||n.set?Object.defineProperty(t,r,n):t[r]=e[r]}return t.default=e,t}(r(0)),a=(n=r(1))&&n.__esModule?n:{default:n},u=r(2),i=r(3);function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var y=i.emotion.css,b={default:y("color:",u.colors.gray[2],";"),light:y("color:",u.colors.gray[6],";")},m=y("padding:5px;"),h=function(e){function t(){var e,r,n,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var a=arguments.length,u=new Array(a),i=0;i<a;i++)u[i]=arguments[i];return n=this,o=(e=c(t)).call.apply(e,[this].concat(u)),r=!o||"object"!==l(o)&&"function"!=typeof o?s(n):o,d(s(s(r)),"state",{value:""}),d(s(s(r)),"defaultName","radio-group-".concat(Math.floor(1e6*Math.random()))),d(s(s(r)),"handleChange",function(e){var t=r.props,n=t.onChange,o=t.value;n&&n(e),o||r.setState({value:e.target.value})}),r}var r,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(t,o.PureComponent),r=t,(n=[{key:"render",value:function(){var e=this,t=this.props,r=t.children,n=t.name,a=void 0===n?this.defaultName:n,u=t.className,l=t.variant,f=t.value,c=void 0===f?this.state.value:f,p=o.default.Children.map(r,function(t,r){return"Radio"!==t.type.displayName?t:o.default.cloneElement(t,{onChange:e.handleChange,checked:c===t.props.value,id:t.props.id||"".concat(e.defaultName,"-button-").concat(r),variant:l,name:a})}),s=b[l];return o.default.createElement("div",{className:(0,i.ccClassName)(y(s," ",m),u)},p)}}])&&f(r.prototype,n),a&&f(r,a),t}();t.default=h,d(h,"displayName","RadioGroup"),d(h,"propTypes",{variant:a.default.oneOf(["default","light"]),className:a.default.string,value:a.default.oneOfType([a.default.string,a.default.number]),onChange:a.default.func,children:a.default.node,name:a.default.string}),d(h,"defaultProps",{variant:"default",className:"",onChange:function(){}})}])}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@leafygreen-ui/radio-group", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "leafyGreen UI Kit RadioGroup", | ||
@@ -14,6 +14,6 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@leafygreen-ui/lib": "^2.1.3", | ||
"@leafygreen-ui/theme": "^1.1.3" | ||
"@leafygreen-ui/lib": "^2.1.4", | ||
"@leafygreen-ui/theme": "^1.1.4" | ||
}, | ||
"gitHead": "bf431409f0e214d729ced5d82d379b6fb442e0b5" | ||
"gitHead": "02c7f4e02c3ef22492b6bfac36bd40b08be5582f" | ||
} |
import React, { PureComponent } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { colors } from '@leafygreen-ui/theme'; | ||
import { ccClassName, emotion } from '@leafygreen-ui/lib'; | ||
import { emotion } from '@leafygreen-ui/lib'; | ||
const { css } = emotion; | ||
const { css, cx } = emotion; | ||
@@ -23,13 +23,9 @@ const labelStyle = css` | ||
const buttonVariants = { | ||
const disabledButtonVariant = { | ||
default: css` | ||
.${inputStyle}:disabled + & { | ||
color: ${colors.gray[5]}; | ||
} | ||
color: ${colors.gray[5]}; | ||
`, | ||
light: css` | ||
.${inputStyle}:disabled + & { | ||
color: ${colors.gray[4]}; | ||
} | ||
color: ${colors.gray[4]}; | ||
`, | ||
@@ -79,6 +75,4 @@ }; | ||
const variantStyle = buttonVariants[variant]; | ||
return ( | ||
<label htmlFor={id} className={ccClassName(labelStyle, className)}> | ||
<label htmlFor={id} className={cx(labelStyle, className)}> | ||
<input | ||
@@ -89,3 +83,3 @@ {...rest} | ||
type="radio" | ||
className={ccClassName(inputStyle, className)} | ||
className={cx(inputStyle, className)} | ||
onChange={onChange} | ||
@@ -98,3 +92,9 @@ value={value} | ||
/> | ||
<span className={ccClassName(textStyle, variantStyle)}>{children}</span> | ||
<span | ||
className={cx(textStyle, { | ||
[disabledButtonVariant[variant]]: disabled, | ||
})} | ||
> | ||
{children} | ||
</span> | ||
</label> | ||
@@ -101,0 +101,0 @@ ); |
Sorry, the diff of this file is not supported yet
89274
13
323
Updated@leafygreen-ui/lib@^2.1.4
Updated@leafygreen-ui/theme@^1.1.4