@leafygreen-ui/radio-box-group
Advanced tools
Comparing version 7.0.0 to 8.0.0
# @leafygreen-ui/radio-box-group | ||
## 8.0.0 | ||
### Major Changes | ||
- Updated dependencies [c48e943e] | ||
- @leafygreen-ui/leafygreen-provider@2.2.0 | ||
### Patch Changes | ||
- Updated dependencies [5f28fce1] | ||
- Updated dependencies [c48e943e] | ||
- @leafygreen-ui/tokens@1.3.0 | ||
## 7.0.0 | ||
@@ -4,0 +17,0 @@ |
@@ -1,2 +0,2 @@ | ||
import e,{useContext as n,createContext as r,useMemo as o,useCallback as t}from"react";import a from"prop-types";import{createDataProp as i}from"@leafygreen-ui/lib";import{cx as l,css as u}from"@leafygreen-ui/emotion";import{useIdAllocator as s}from"@leafygreen-ui/hooks";import{palette as d}from"@leafygreen-ui/palette";import{fontFamilies as c}from"@leafygreen-ui/tokens";import{useUsingKeyboardContext as p}from"@leafygreen-ui/leafygreen-provider";import{jsx as f}from"@emotion/react";function h(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function b(){return(b=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function g(e,n){if(null==e)return{};var r,o,t=function(e,n){if(null==e)return{};var r,o,t={},a=Object.keys(e);for(o=0;o<a.length;o++)r=a[o],n.indexOf(r)>=0||(t[r]=e[r]);return t}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)r=a[o],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(t[r]=e[r])}return t}function m(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function v(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var o,t,a=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(o=r.next()).done)&&(a.push(o.value),!n||a.length!==n);i=!0);}catch(e){l=!0,t=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw t}}return a}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return y(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,o=new Array(n);r<n;r++)o[r]=e[r];return o}var x={Default:"default",Compact:"compact",Full:"full"},w=r(null),O=w.Provider;var k,z,j,C,N,P,S,A,F,T,B=["className","onChange","value","checked","default","disabled","id","size","children","name"],D=i("radio-box-wrapper"),I=i("radio-box-input"),E=(h(C={},x.Default,u(k||(k=m(["\n width: 169px;\n "])))),h(C,x.Compact,u(z||(z=m(["\n padding-right: 12px;\n padding-left: 12px;\n "])))),h(C,x.Full,u(j||(j=m(["\n flex: 1;\n "])))),C),G=u(N||(N=m(["\n opacity: 0;\n position: absolute;\n pointer-events: none;\n"]))),R=u(T||(T=m(["\n font-family: ",";\n display: flex;\n position: relative;\n\n // Establishes the root element as a new stacking context\n // so that the z-index of the span within the button doesn't\n // appear above other elements on the page that it shouldn't.\n z-index: 0;\n\n &:not(:last-of-type) {\n margin-right: 12px;\n }\n"])),c.default);function q(e){var r,a,i=e.className,c=void 0===i?"":i,v=e.onChange,y=e.value,O=e.checked,k=e.default,z=void 0!==k&&k,j=e.disabled,C=void 0!==j&&j,N=e.id,T=e.size,q=void 0===T?x.Default:T,K=e.children,M=e.name,U=g(e,B),$=n(w),H=p().usingKeyboard,J=s({prefix:"radio-box"}),L=o((function(){return null!=N?N:J}),[N,J]),Q=null!==(r=null==$?void 0:$.size)&&void 0!==r?r:q,V=null!==(a=null==$?void 0:$.name)&&void 0!==a?a:M,W=function(e){var n=e.checkedProp,r=e.defaultProp,o=e.radioBoxGroupContext,t=e.value,a=null==o?void 0:o.value;return null==a?null!=n?n:r:a===t}({value:y,checkedProp:O,defaultProp:z,radioBoxGroupContext:$}),X=null==$?void 0:$.onChange,Y=t((function(e){null==v||v(e),null==X||X(e)}),[v,X]),Z=function(e){var n,r=e.checked,o=e.disabled,t=e.size,a=e.showFocus;return l(u(P||(P=m(["\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n padding: 16px 24px;\n\n font-size: 13px;\n font-weight: 700;\n text-align: center;\n overflow-wrap: break-word;\n background-color: ",";\n border-radius: 6px;\n color: ",";\n border: 1px solid ",";\n\n cursor: pointer;\n pointer-events: auto;\n transition: 150ms ease-in-out;\n transition-property: border-color, box-shadow;\n\n &:hover,\n &:active {\n box-shadow: 0 0 0 3px ",";\n }\n "])),d.white,d.black,d.gray.base,d.gray.light2),(h(n={},u(S||(S=m(["\n border-color: transparent;\n box-shadow: 0 0 0 3px ",";\n &:hover,\n &:active {\n box-shadow: 0 0 0 3px ",";\n }\n "])),d.green.dark1,d.green.dark1),r),h(n,u(A||(A=m(["\n color: ",";\n background: ",";\n font-weight: 400;\n border-color: ",";\n cursor: not-allowed;\n &:hover,\n &:active {\n box-shadow: unset;\n }\n "])),d.gray.light1,d.gray.light3,d.gray.light2),o),h(n,u(F||(F=m(["\n input:focus + & {\n border-color: ",";\n box-shadow: 0 0 0 2px ",",\n 0 0 0 4px ",";\n }\n "])),d.gray.base,d.white,d.blue.light1),a),n),E[t])}({checked:W,disabled:C,size:Q,showFocus:H});return f("label",b({},D.prop,{htmlFor:L,className:l(R,h({},E.full,Q===x.Full),c)}),f("input",b({},U,I.prop,{type:"radio",id:L,name:V,onChange:Y,value:y,checked:W,"aria-checked":W,disabled:C,"aria-disabled":C,className:G})),f("div",{className:Z},K))}q.displayName="RadioBox",q.propTypes={value:a.oneOfType([a.string,a.number]).isRequired,onChange:a.func,checked:a.bool,disabled:a.bool,className:a.string,id:a.string,name:a.string,children:a.node,default:a.bool};var K,M=["children","className","size","onChange","name","value"],U=u(K||(K=m(["\n display: flex;\n"])));function $(n){var r=n.children,o=n.className,t=n.size,a=void 0===t?x.Default:t,i=n.onChange,u=void 0===i?function(){}:i,d=n.name,c=n.value,p=g(n,M),h=v(e.useState(),2),m=h[0],y=h[1],w=s({prefix:"radio-box-group",id:d});return f(O,{value:{value:null!=c?c:m,name:w,size:a,onChange:function(e){u&&(e.stopPropagation(),u(e)),c||y(e.target.value)}}},f("div",b({},p,{className:l(U,o),role:"group","aria-label":d}),r))}$.displayName="RadioBoxGroup",$.propTypes={children:a.node,onChange:a.func,name:a.string,value:a.oneOfType([a.string,a.number]),size:a.oneOf(["compact","default","full"]),className:a.string};export{q as RadioBox,$ as RadioBoxGroup,x as Size}; | ||
import e,{useContext as n,createContext as r,useMemo as o,useCallback as t}from"react";import a from"prop-types";import{createDataProp as i}from"@leafygreen-ui/lib";import{css as l,cx as u}from"@leafygreen-ui/emotion";import{useIdAllocator as s}from"@leafygreen-ui/hooks";import{palette as d}from"@leafygreen-ui/palette";import{fontFamilies as c}from"@leafygreen-ui/tokens";import{useUsingKeyboardContext as p}from"@leafygreen-ui/leafygreen-provider";import{jsx as f}from"@emotion/react";function h(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function b(){return b=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},b.apply(this,arguments)}function g(e,n){if(null==e)return{};var r,o,t=function(e,n){if(null==e)return{};var r,o,t={},a=Object.keys(e);for(o=0;o<a.length;o++)r=a[o],n.indexOf(r)>=0||(t[r]=e[r]);return t}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)r=a[o],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(t[r]=e[r])}return t}function m(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function v(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var o,t,a=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(o=r.next()).done)&&(a.push(o.value),!n||a.length!==n);i=!0);}catch(e){l=!0,t=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw t}}return a}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return y(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,o=new Array(n);r<n;r++)o[r]=e[r];return o}var x={Default:"default",Compact:"compact",Full:"full"},w=r(null),O=w.Provider;var k,z,j,C,N,P,S,A,F,T,B=["className","onChange","value","checked","default","disabled","id","size","children","name"],D=i("radio-box-wrapper"),I=i("radio-box-input"),E=(h(C={},x.Default,l(k||(k=m(["\n width: 169px;\n "])))),h(C,x.Compact,l(z||(z=m(["\n padding-right: 12px;\n padding-left: 12px;\n "])))),h(C,x.Full,l(j||(j=m(["\n flex: 1;\n "])))),C),G=l(N||(N=m(["\n opacity: 0;\n position: absolute;\n pointer-events: none;\n"]))),R=l(T||(T=m(["\n font-family: ",";\n display: flex;\n position: relative;\n\n // Establishes the root element as a new stacking context\n // so that the z-index of the span within the button doesn't\n // appear above other elements on the page that it shouldn't.\n z-index: 0;\n\n &:not(:last-of-type) {\n margin-right: 12px;\n }\n"])),c.default);function q(e){var r,a,i=e.className,c=void 0===i?"":i,v=e.onChange,y=e.value,O=e.checked,k=e.default,z=void 0!==k&&k,j=e.disabled,C=void 0!==j&&j,N=e.id,T=e.size,q=void 0===T?x.Default:T,K=e.children,M=e.name,U=g(e,B),$=n(w),H=p().usingKeyboard,J=s({prefix:"radio-box"}),L=o((function(){return null!=N?N:J}),[N,J]),Q=null!==(r=null==$?void 0:$.size)&&void 0!==r?r:q,V=null!==(a=null==$?void 0:$.name)&&void 0!==a?a:M,W=function(e){var n=e.checkedProp,r=e.defaultProp,o=e.radioBoxGroupContext,t=e.value,a=null==o?void 0:o.value;return null==a?null!=n?n:r:a===t}({value:y,checkedProp:O,defaultProp:z,radioBoxGroupContext:$}),X=null==$?void 0:$.onChange,Y=t((function(e){null==v||v(e),null==X||X(e)}),[v,X]),Z=function(e){var n,r=e.checked,o=e.disabled,t=e.size,a=e.showFocus;return u(l(P||(P=m(["\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n padding: 16px 24px;\n\n font-size: 13px;\n font-weight: 700;\n text-align: center;\n overflow-wrap: break-word;\n background-color: ",";\n border-radius: 6px;\n color: ",";\n border: 1px solid ",";\n\n cursor: pointer;\n pointer-events: auto;\n transition: 150ms ease-in-out;\n transition-property: border-color, box-shadow;\n\n &:hover,\n &:active {\n box-shadow: 0 0 0 3px ",";\n }\n "])),d.white,d.black,d.gray.base,d.gray.light2),(h(n={},l(S||(S=m(["\n border-color: transparent;\n box-shadow: 0 0 0 3px ",";\n &:hover,\n &:active {\n box-shadow: 0 0 0 3px ",";\n }\n "])),d.green.dark1,d.green.dark1),r),h(n,l(A||(A=m(["\n color: ",";\n background: ",";\n font-weight: 400;\n border-color: ",";\n cursor: not-allowed;\n &:hover,\n &:active {\n box-shadow: unset;\n }\n "])),d.gray.light1,d.gray.light3,d.gray.light2),o),h(n,l(F||(F=m(["\n input:focus + & {\n border-color: ",";\n box-shadow: 0 0 0 2px ",",\n 0 0 0 4px ",";\n }\n "])),d.gray.base,d.white,d.blue.light1),a),n),E[t])}({checked:W,disabled:C,size:Q,showFocus:H});return f("label",b({},D.prop,{htmlFor:L,className:u(R,h({},E.full,Q===x.Full),c)}),f("input",b({},U,I.prop,{type:"radio",id:L,name:V,onChange:Y,value:y,checked:W,"aria-checked":W,disabled:C,"aria-disabled":C,className:G})),f("div",{className:Z},K))}q.displayName="RadioBox",q.propTypes={value:a.oneOfType([a.string,a.number]).isRequired,onChange:a.func,checked:a.bool,disabled:a.bool,className:a.string,id:a.string,name:a.string,children:a.node,default:a.bool};var K,M=["children","className","size","onChange","name","value"],U=l(K||(K=m(["\n display: flex;\n"])));function $(n){var r=n.children,o=n.className,t=n.size,a=void 0===t?x.Default:t,i=n.onChange,l=void 0===i?function(){}:i,d=n.name,c=n.value,p=g(n,M),h=v(e.useState(),2),m=h[0],y=h[1],w=s({prefix:"radio-box-group",id:d});return f(O,{value:{value:null!=c?c:m,name:w,size:a,onChange:function(e){l&&(e.stopPropagation(),l(e)),c||y(e.target.value)}}},f("div",b({},p,{className:u(U,o),role:"group","aria-label":d}),r))}$.displayName="RadioBoxGroup",$.propTypes={children:a.node,onChange:a.func,name:a.string,value:a.oneOfType([a.string,a.number]),size:a.oneOf(["compact","default","full"]),className:a.string};export{q as RadioBox,$ as RadioBoxGroup,x as Size}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("prop-types"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/palette"),require("@leafygreen-ui/tokens"),require("@leafygreen-ui/leafygreen-provider"),require("@emotion/react")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@leafygreen-ui/lib","@leafygreen-ui/emotion","@leafygreen-ui/hooks","@leafygreen-ui/palette","@leafygreen-ui/tokens","@leafygreen-ui/leafygreen-provider","@emotion/react"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@leafygreen-ui/radio-box-group"]={},e.React,e.PropTypes,e["@leafygreen-ui/lib"],e["@leafygreen-ui/emotion"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/palette"],e["@leafygreen-ui/tokens"],e["@leafygreen-ui/leafygreen-provider"],e.react)}(this,(function(e,n,t,r,a,o,l,i,u,s){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(n),f=d(t);function p(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function g(){return(g=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function y(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function h(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function b(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var r,a,o=[],l=!0,i=!1;try{for(t=t.call(e);!(l=(r=t.next()).done)&&(o.push(r.value),!n||o.length!==n);l=!0);}catch(e){i=!0,a=e}finally{try{l||null==t.return||t.return()}finally{if(i)throw a}}return o}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return v(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return v(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var x={Default:"default",Compact:"compact",Full:"full"},m=n.createContext(null),w=m.Provider;var k,j,O,C,z,P,N,q,S,A,T=["className","onChange","value","checked","default","disabled","id","size","children","name"],F=r.createDataProp("radio-box-wrapper"),B=r.createDataProp("radio-box-input"),D=(p(C={},x.Default,a.css(k||(k=h(["\n width: 169px;\n "])))),p(C,x.Compact,a.css(j||(j=h(["\n padding-right: 12px;\n padding-left: 12px;\n "])))),p(C,x.Full,a.css(O||(O=h(["\n flex: 1;\n "])))),C),I=a.css(z||(z=h(["\n opacity: 0;\n position: absolute;\n pointer-events: none;\n"]))),R=a.css(A||(A=h(["\n font-family: ",";\n display: flex;\n position: relative;\n\n // Establishes the root element as a new stacking context\n // so that the z-index of the span within the button doesn't\n // appear above other elements on the page that it shouldn't.\n z-index: 0;\n\n &:not(:last-of-type) {\n margin-right: 12px;\n }\n"])),i.fontFamilies.default);function G(e){var t,r,i=e.className,d=void 0===i?"":i,c=e.onChange,f=e.value,b=e.checked,v=e.default,w=void 0!==v&&v,k=e.disabled,j=void 0!==k&&k,O=e.id,C=e.size,z=void 0===C?x.Default:C,A=e.children,G=e.name,E=y(e,T),M=n.useContext(m),K=u.useUsingKeyboardContext().usingKeyboard,U=o.useIdAllocator({prefix:"radio-box"}),_=n.useMemo((function(){return null!=O?O:U}),[O,U]),$=null!==(t=null==M?void 0:M.size)&&void 0!==t?t:z,H=null!==(r=null==M?void 0:M.name)&&void 0!==r?r:G,J=function(e){var n=e.checkedProp,t=e.defaultProp,r=e.radioBoxGroupContext,a=e.value,o=null==r?void 0:r.value;return null==o?null!=n?n:t:o===a}({value:f,checkedProp:b,defaultProp:w,radioBoxGroupContext:M}),L=null==M?void 0:M.onChange,Q=n.useCallback((function(e){null==c||c(e),null==L||L(e)}),[c,L]),V=function(e){var n,t=e.checked,r=e.disabled,o=e.size,i=e.showFocus;return a.cx(a.css(P||(P=h(["\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n padding: 16px 24px;\n\n font-size: 13px;\n font-weight: 700;\n text-align: center;\n overflow-wrap: break-word;\n background-color: ",";\n border-radius: 6px;\n color: ",";\n border: 1px solid ",";\n\n cursor: pointer;\n pointer-events: auto;\n transition: 150ms ease-in-out;\n transition-property: border-color, box-shadow;\n\n &:hover,\n &:active {\n box-shadow: 0 0 0 3px ",";\n }\n "])),l.palette.white,l.palette.black,l.palette.gray.base,l.palette.gray.light2),(p(n={},a.css(N||(N=h(["\n border-color: transparent;\n box-shadow: 0 0 0 3px ",";\n &:hover,\n &:active {\n box-shadow: 0 0 0 3px ",";\n }\n "])),l.palette.green.dark1,l.palette.green.dark1),t),p(n,a.css(q||(q=h(["\n color: ",";\n background: ",";\n font-weight: 400;\n border-color: ",";\n cursor: not-allowed;\n &:hover,\n &:active {\n box-shadow: unset;\n }\n "])),l.palette.gray.light1,l.palette.gray.light3,l.palette.gray.light2),r),p(n,a.css(S||(S=h(["\n input:focus + & {\n border-color: ",";\n box-shadow: 0 0 0 2px ",",\n 0 0 0 4px ",";\n }\n "])),l.palette.gray.base,l.palette.white,l.palette.blue.light1),i),n),D[o])}({checked:J,disabled:j,size:$,showFocus:K});return s.jsx("label",g({},F.prop,{htmlFor:_,className:a.cx(R,p({},D.full,$===x.Full),d)}),s.jsx("input",g({},E,B.prop,{type:"radio",id:_,name:H,onChange:Q,value:f,checked:J,"aria-checked":J,disabled:j,"aria-disabled":j,className:I})),s.jsx("div",{className:V},A))}G.displayName="RadioBox",G.propTypes={value:f.default.oneOfType([f.default.string,f.default.number]).isRequired,onChange:f.default.func,checked:f.default.bool,disabled:f.default.bool,className:f.default.string,id:f.default.string,name:f.default.string,children:f.default.node,default:f.default.bool};var E,M=["children","className","size","onChange","name","value"],K=a.css(E||(E=h(["\n display: flex;\n"])));function U(e){var n=e.children,t=e.className,r=e.size,l=void 0===r?x.Default:r,i=e.onChange,u=void 0===i?function(){}:i,d=e.name,f=e.value,p=y(e,M),h=b(c.default.useState(),2),v=h[0],m=h[1],k=o.useIdAllocator({prefix:"radio-box-group",id:d});return s.jsx(w,{value:{value:null!=f?f:v,name:k,size:l,onChange:function(e){u&&(e.stopPropagation(),u(e)),f||m(e.target.value)}}},s.jsx("div",g({},p,{className:a.cx(K,t),role:"group","aria-label":d}),n))}U.displayName="RadioBoxGroup",U.propTypes={children:f.default.node,onChange:f.default.func,name:f.default.string,value:f.default.oneOfType([f.default.string,f.default.number]),size:f.default.oneOf(["compact","default","full"]),className:f.default.string},e.RadioBox=G,e.RadioBoxGroup=U,e.Size=x,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("prop-types"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/palette"),require("@leafygreen-ui/tokens"),require("@leafygreen-ui/leafygreen-provider"),require("@emotion/react")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@leafygreen-ui/lib","@leafygreen-ui/emotion","@leafygreen-ui/hooks","@leafygreen-ui/palette","@leafygreen-ui/tokens","@leafygreen-ui/leafygreen-provider","@emotion/react"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@leafygreen-ui/radio-box-group"]={},e.React,e.PropTypes,e["@leafygreen-ui/lib"],e["@leafygreen-ui/emotion"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/palette"],e["@leafygreen-ui/tokens"],e["@leafygreen-ui/leafygreen-provider"],e.react)}(this,(function(e,n,t,r,a,o,l,i,u,s){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(n),f=d(t);function p(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function g(){return g=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},g.apply(this,arguments)}function y(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function h(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function b(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var r,a,o=[],l=!0,i=!1;try{for(t=t.call(e);!(l=(r=t.next()).done)&&(o.push(r.value),!n||o.length!==n);l=!0);}catch(e){i=!0,a=e}finally{try{l||null==t.return||t.return()}finally{if(i)throw a}}return o}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return v(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return v(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var x={Default:"default",Compact:"compact",Full:"full"},m=n.createContext(null),w=m.Provider;var k,j,O,C,z,P,N,q,S,A,T=["className","onChange","value","checked","default","disabled","id","size","children","name"],F=r.createDataProp("radio-box-wrapper"),B=r.createDataProp("radio-box-input"),D=(p(C={},x.Default,a.css(k||(k=h(["\n width: 169px;\n "])))),p(C,x.Compact,a.css(j||(j=h(["\n padding-right: 12px;\n padding-left: 12px;\n "])))),p(C,x.Full,a.css(O||(O=h(["\n flex: 1;\n "])))),C),I=a.css(z||(z=h(["\n opacity: 0;\n position: absolute;\n pointer-events: none;\n"]))),R=a.css(A||(A=h(["\n font-family: ",";\n display: flex;\n position: relative;\n\n // Establishes the root element as a new stacking context\n // so that the z-index of the span within the button doesn't\n // appear above other elements on the page that it shouldn't.\n z-index: 0;\n\n &:not(:last-of-type) {\n margin-right: 12px;\n }\n"])),i.fontFamilies.default);function G(e){var t,r,i=e.className,d=void 0===i?"":i,c=e.onChange,f=e.value,b=e.checked,v=e.default,w=void 0!==v&&v,k=e.disabled,j=void 0!==k&&k,O=e.id,C=e.size,z=void 0===C?x.Default:C,A=e.children,G=e.name,E=y(e,T),M=n.useContext(m),K=u.useUsingKeyboardContext().usingKeyboard,U=o.useIdAllocator({prefix:"radio-box"}),_=n.useMemo((function(){return null!=O?O:U}),[O,U]),$=null!==(t=null==M?void 0:M.size)&&void 0!==t?t:z,H=null!==(r=null==M?void 0:M.name)&&void 0!==r?r:G,J=function(e){var n=e.checkedProp,t=e.defaultProp,r=e.radioBoxGroupContext,a=e.value,o=null==r?void 0:r.value;return null==o?null!=n?n:t:o===a}({value:f,checkedProp:b,defaultProp:w,radioBoxGroupContext:M}),L=null==M?void 0:M.onChange,Q=n.useCallback((function(e){null==c||c(e),null==L||L(e)}),[c,L]),V=function(e){var n,t=e.checked,r=e.disabled,o=e.size,i=e.showFocus;return a.cx(a.css(P||(P=h(["\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n padding: 16px 24px;\n\n font-size: 13px;\n font-weight: 700;\n text-align: center;\n overflow-wrap: break-word;\n background-color: ",";\n border-radius: 6px;\n color: ",";\n border: 1px solid ",";\n\n cursor: pointer;\n pointer-events: auto;\n transition: 150ms ease-in-out;\n transition-property: border-color, box-shadow;\n\n &:hover,\n &:active {\n box-shadow: 0 0 0 3px ",";\n }\n "])),l.palette.white,l.palette.black,l.palette.gray.base,l.palette.gray.light2),(p(n={},a.css(N||(N=h(["\n border-color: transparent;\n box-shadow: 0 0 0 3px ",";\n &:hover,\n &:active {\n box-shadow: 0 0 0 3px ",";\n }\n "])),l.palette.green.dark1,l.palette.green.dark1),t),p(n,a.css(q||(q=h(["\n color: ",";\n background: ",";\n font-weight: 400;\n border-color: ",";\n cursor: not-allowed;\n &:hover,\n &:active {\n box-shadow: unset;\n }\n "])),l.palette.gray.light1,l.palette.gray.light3,l.palette.gray.light2),r),p(n,a.css(S||(S=h(["\n input:focus + & {\n border-color: ",";\n box-shadow: 0 0 0 2px ",",\n 0 0 0 4px ",";\n }\n "])),l.palette.gray.base,l.palette.white,l.palette.blue.light1),i),n),D[o])}({checked:J,disabled:j,size:$,showFocus:K});return s.jsx("label",g({},F.prop,{htmlFor:_,className:a.cx(R,p({},D.full,$===x.Full),d)}),s.jsx("input",g({},E,B.prop,{type:"radio",id:_,name:H,onChange:Q,value:f,checked:J,"aria-checked":J,disabled:j,"aria-disabled":j,className:I})),s.jsx("div",{className:V},A))}G.displayName="RadioBox",G.propTypes={value:f.default.oneOfType([f.default.string,f.default.number]).isRequired,onChange:f.default.func,checked:f.default.bool,disabled:f.default.bool,className:f.default.string,id:f.default.string,name:f.default.string,children:f.default.node,default:f.default.bool};var E,M=["children","className","size","onChange","name","value"],K=a.css(E||(E=h(["\n display: flex;\n"])));function U(e){var n=e.children,t=e.className,r=e.size,l=void 0===r?x.Default:r,i=e.onChange,u=void 0===i?function(){}:i,d=e.name,f=e.value,p=y(e,M),h=b(c.default.useState(),2),v=h[0],m=h[1],k=o.useIdAllocator({prefix:"radio-box-group",id:d});return s.jsx(w,{value:{value:null!=f?f:v,name:k,size:l,onChange:function(e){u&&(e.stopPropagation(),u(e)),f||m(e.target.value)}}},s.jsx("div",g({},p,{className:a.cx(K,t),role:"group","aria-label":d}),n))}U.displayName="RadioBoxGroup",U.propTypes={children:f.default.node,onChange:f.default.func,name:f.default.string,value:f.default.oneOfType([f.default.string,f.default.number]),size:f.default.oneOf(["compact","default","full"]),className:f.default.string},e.RadioBox=G,e.RadioBoxGroup=U,e.Size=x,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.js.map |
@@ -58,3 +58,3 @@ import React from 'react'; | ||
var propTypes: { | ||
value: PropTypes.Validator<React.ReactText>; | ||
value: PropTypes.Validator<string | number>; | ||
onChange: PropTypes.Requireable<(...args: any[]) => any>; | ||
@@ -61,0 +61,0 @@ checked: PropTypes.Requireable<boolean>; |
@@ -57,3 +57,3 @@ import React from 'react'; | ||
name: PropTypes.Requireable<string>; | ||
value: PropTypes.Requireable<React.ReactText>; | ||
value: PropTypes.Requireable<string | number>; | ||
size: PropTypes.Requireable<string>; | ||
@@ -60,0 +60,0 @@ className: PropTypes.Requireable<string>; |
{ | ||
"name": "@leafygreen-ui/radio-box-group", | ||
"version": "7.0.0", | ||
"version": "8.0.0", | ||
"description": "leafyGreen UI Kit RadioBoxGroup", | ||
@@ -26,8 +26,8 @@ "main": "./dist/index.js", | ||
"@leafygreen-ui/palette": "^3.3.1", | ||
"@leafygreen-ui/tokens": "^1.0.0" | ||
"@leafygreen-ui/tokens": "^1.3.0" | ||
}, | ||
"peerDependencies": { | ||
"@leafygreen-ui/leafygreen-provider": "^2.1.3" | ||
"@leafygreen-ui/leafygreen-provider": "^2.2.0" | ||
}, | ||
"gitHead": "dd71a2d404218ccec2e657df9c0263dc1c15b9e0" | ||
} |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135165
972
Updated@leafygreen-ui/tokens@^1.3.0