@twilio-paste/button
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -6,2 +6,13 @@ # Change Log | ||
## [2.1.5](https://github.com/twilio-labs/paste/compare/@twilio-paste/button@2.1.4...@twilio-paste/button@2.1.5) (2020-08-27) | ||
### Bug Fixes | ||
* **button:** remove unnecessary link error ([#697](https://github.com/twilio-labs/paste/issues/697)) ([0e92b73](https://github.com/twilio-labs/paste/commit/0e92b7358d6751d6758f30828d0aea410c053314)) | ||
## [2.1.4](https://github.com/twilio-labs/paste/compare/@twilio-paste/button@2.1.3...@twilio-paste/button@2.1.4) (2020-08-24) | ||
@@ -8,0 +19,0 @@ |
@@ -15,2 +15,2 @@ import{forwardRef as o,createElement as e,useMemo as r,Children as t,isValidElement as a,Fragment as n}from"react";import{Box as i,safelySpreadBoxProps as l}from"@twilio-paste/box";import{Stack as d}from"@twilio-paste/stack";import{Spinner as s}from"@twilio-paste/spinner";import{string as c,bool as u,oneOf as h}from"prop-types"; | ||
and limitations under the License. | ||
***************************************************************************** */var g=function(){return(g=Object.assign||function(o){for(var e,r=1,t=arguments.length;r<t;r++)for(var a in e=arguments[r])Object.prototype.hasOwnProperty.call(e,a)&&(o[a]=e[a]);return o}).apply(this,arguments)};function f(o,e){var r={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(r[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(o);a<t.length;a++)e.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(o,t[a])&&(r[t[a]]=o[t[a]])}return r}var b={as:c,fullWidth:u,href:c,size:h(["small","default","icon","reset"]).isRequired,tabIndex:h([0,-1]),type:h(["submit","button","reset"]),disabled:u,buttonState:h(["disabled","loading","default"]).isRequired},p={as:c,fullWidth:u,href:c,size:h(["small","default","icon","reset"]),tabIndex:h([0,-1]),type:h(["submit","button","reset"]),disabled:u,loading:u,variant:h(["primary","secondary","destructive","destructive_link","link","reset"]).isRequired},v=require("lodash.merge"),k={appearance:"none",background:"none",display:"inline-block",border:"none",outline:"none",transition:"background-color 100ms ease-in, box-shadow 100ms ease-in, color 100ms ease-in",fontFamily:"fontFamilyText",fontWeight:"fontWeightSemibold",textDecoration:"none",position:"relative",_hover:{textDecoration:"none"},_focus:{textDecoration:"none",boxShadow:"shadowFocus"},_active:{textDecoration:"none"}},w={default:v({},k,{cursor:"pointer",_active:{boxShadow:"none"}}),disabled:v({},k,{cursor:"not-allowed"}),loading:v({},k,{cursor:"wait"})},x={default:{paddingTop:"space30",paddingBottom:"space30",paddingLeft:"space40",paddingRight:"space40",borderRadius:"borderRadius20",fontSize:"fontSize30",lineHeight:"lineHeight20"},small:{paddingTop:"space20",paddingBottom:"space20",paddingLeft:"space30",paddingRight:"space30",borderRadius:"borderRadius10",fontSize:"fontSize30",lineHeight:"lineHeight20"},icon:{padding:"space30",borderRadius:"borderRadius20"},reset:{paddingTop:"space0",paddingRight:"space0",paddingBottom:"space0",paddingLeft:"space0",borderWidth:"borderWidth0"}},m=require("lodash.merge"),y={default:m({},w.default,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimary",boxShadow:"shadowBorderPrimary",_hover:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowBorderPrimaryDarker"},_focus:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowFocus"},_active:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDark",boxShadow:"shadowBorderPrimaryDarker"}}),loading:m({},w.loading,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowBorderPrimaryDarker"}),disabled:m({},w.disabled,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryLight",boxShadow:"shadowBorderPrimaryLight"})},D=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),y[a],x[t]))}));D.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(D.propTypes=b),D.displayName="PrimaryButton";var B=require("lodash.merge"),S={color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLighter",boxShadow:"shadowBorderPrimaryLighter"},T={color:"colorTextLinkLight",backgroundColor:"colorBackgroundBody",boxShadow:"shadowBorderPrimaryLight"},L={default:B({},w.default,{color:"colorTextLink",backgroundColor:"colorBackgroundBody",boxShadow:"shadowBorderPrimary",_hover:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLightest",boxShadow:"shadowBorderPrimaryDarker"},_focus:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLightest",boxShadow:"shadowFocus"},_active:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLighter",boxShadow:"shadowBorderPrimaryDarker"}}),loading:B({},w.loading,g(g({},S),{_hover:S,_active:S,_focus:S})),disabled:B({},w.disabled,g(g({},T),{_hover:T,_active:T,_focus:T}))},_=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),L[a],x[t]))}));_.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(_.propTypes=b),_.displayName="SecondaryButton";var P=require("lodash.merge"),I={default:P({},w.default,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructive",boxShadow:"shadowBorderDestructive",_hover:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowBorderDestructiveDarker"},_focus:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowFocus"},_active:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDark",boxShadow:"shadowBorderDestructiveDarker"}}),loading:P({},w.loading,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowBorderDestructiveDarker"}),disabled:P({},w.disabled,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveLight",boxShadow:"shadowBorderDestructiveLight"})},W=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),I[a],x[t]))}));W.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(W.propTypes=b),W.displayName="DestructiveButton";var E=require("lodash.merge"),z={default:E({},w.default,{color:"colorTextLink",_hover:{color:"colorTextLinkDark",textDecoration:"underline"},_focus:{color:"colorTextLinkDark",textDecoration:"underline"},_active:{color:"colorTextLinkDarker",textDecoration:"underline"}}),loading:E({},w.loading,{color:"colorTextLinkDarker"}),disabled:E({},w.disabled,{color:"colorTextLinkLight"})},N=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),z[a],x[t]))}));N.defaultProps={as:"a"},"development"===process.env.NODE_ENV&&(N.propTypes=b),N.displayName="LinkButton";var C=require("lodash.merge"),O={default:C({},w.default,{color:"colorTextLinkDestructive",_hover:{color:"colorTextLinkDestructiveDark",textDecoration:"underline"},_active:{color:"colorTextLinkDestructiveDarker",textDecoration:"underline"},_focus:{color:"colorTextLinkDestructiveDark",textDecoration:"underline"}}),loading:C({},w.loading,{color:"colorTextLinkDestructiveDarker",_hover:{color:"colorTextLinkDestructiveDarker"},_active:{color:"colorTextLinkDestructiveDarker"},_focus:{color:"colorTextLinkDestructiveDarker"}}),disabled:C({},w.disabled,{color:"colorTextLinkDestructiveLight",_hover:{color:"colorTextLinkDestructiveLight"},_active:{color:"colorTextLinkDestructiveLight"},_focus:{color:"colorTextLinkDestructiveLight"}})},R=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),O[a],x[t]))}));R.defaultProps={as:"a"},"development"===process.env.NODE_ENV&&(R.propTypes=b),R.displayName="DestructiveLinkButton";var q=require("lodash.merge"),V={default:q({},w.default,{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverse",boxShadow:"shadowBorderInverse",_hover:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseLighter"},_focus:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowFocusInverse"},_active:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseLightest"}}),loading:q({},w.loading,{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseDarker"}),disabled:q({},w.disabled,{color:"colorTextInverseWeaker",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverse",boxShadow:"shadowBorderInverseDarker"})},j=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),V[a],x[t]))}));j.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(j.propTypes=b),j.displayName="InverseButton";var F=require("lodash.merge"),H={default:F({},w.default,{fontSize:"inherit",fontWeight:"inherit",color:"inherit"}),loading:F({},w.loading,{fontSize:"inherit",fontWeight:"inherit"}),disabled:F({},w.disabled,{fontSize:"inherit",fontWeight:"inherit"})},U=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),H[a],x[t]))}));U.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(U.propTypes=b),U.displayName="ResetButton";var M=function(o){var r=o.buttonState,a=o.children,l=o.showLoading;return e(n,null,e(i,{as:"span",display:"flex",textDecoration:"inherit",opacity:"loading"===r?"0":"1","aria-hidden":"loading"===r?"true":"false"},t.count(a)>1?e(d,{as:"span",orientation:"horizontal",spacing:"space20"},a):a),l?e(i,{as:"span",position:"absolute",top:0,right:0,bottom:0,left:0,display:"flex",justifyContent:"center",alignItems:"center",lineHeight:"lineHeight30"},e(s,{decorative:!1,title:"Loading, please wait.",delay:0})):null)},Y=o((function(o,n){var i=o.size,l=o.variant,d=o.children,s=o.disabled,c=o.loading,u=f(o,["size","variant","children","disabled","loading"]);!function(o){var e=o.as,r=o.href,t=o.tabIndex,a=o.variant,n=o.size,i=o.fullWidth,l=o.children,d=null!=r&&""!==r,s=null!=t;if("a"!==e&&d)throw new Error("[Paste: Button] You cannot pass href into a button without the 'a' tag. Use 'as=\"a\"'.");if("a"===e&&!d)throw new Error("[Paste: Button] Missing href prop for link button.");if("a"===e&&"link"===a)throw new Error("[Paste: Button] This should be a link. Use the [Paste: Anchor] component.");if("link"!==a&&"destructive_link"!==a&&d)throw new Error("[Paste: Button] You cannot pass href into a button without the 'a' tag. Use 'variant=\"link\"' or 'variant=\"destructive_link\"'.");if("reset"===a&&"reset"!==n)throw new Error('[Paste: Button] The "RESET" variant can only be used with the "RESET" size.');if("icon"===n&&i)throw new Error("[Paste: Button] Icon buttons should not be fullWidth.");if(null==l)throw new Error("[Paste: Button] Must have non-null children.");if(s&&0!==t&&-1!==t)throw new Error("[Paste: Button] tabIndex must be 0 or -1.")}(o);var h=function(o,e){return o?"disabled":e?"loading":"default"}(s,c),b="loading"===h,p="default"!==h,v=function(o){switch(o){case"secondary":return _;case"destructive":return W;case"link":return N;case"destructive_link":return R;case"reset":return U;case"inverse":return j;case"primary":default:return D}}(l),k=r((function(){return function(o,e,r){var n="default";return null!=r?n=r:"link"===o||"destructive_link"===o?n="reset":1===t.count(e)&&t.forEach(e,(function(o){a(o)&&"string"==typeof o.type.displayName&&o.type.displayName.includes("Icon")&&(n="icon")})),n}(l,d,i)}),[i,l,d]);return e(v,g({},u,{buttonState:h,disabled:p,size:k,"aria-busy":"loading"===h?"true":"false",className:void 0,style:void 0,ref:n}),e(M,{buttonState:h,showLoading:b},d))}));Y.defaultProps={as:"button",fullWidth:!1,disabled:!1,loading:!1,type:"button",variant:"primary"},"development"===process.env.NODE_ENV&&(Y.propTypes=p),Y.displayName="Button";export{Y as Button}; | ||
***************************************************************************** */var g=function(){return(g=Object.assign||function(o){for(var e,r=1,t=arguments.length;r<t;r++)for(var a in e=arguments[r])Object.prototype.hasOwnProperty.call(e,a)&&(o[a]=e[a]);return o}).apply(this,arguments)};function f(o,e){var r={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(r[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(o);a<t.length;a++)e.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(o,t[a])&&(r[t[a]]=o[t[a]])}return r}var b={as:c,fullWidth:u,href:c,size:h(["small","default","icon","reset"]).isRequired,tabIndex:h([0,-1]),type:h(["submit","button","reset"]),disabled:u,buttonState:h(["disabled","loading","default"]).isRequired},p={as:c,fullWidth:u,href:c,size:h(["small","default","icon","reset"]),tabIndex:h([0,-1]),type:h(["submit","button","reset"]),disabled:u,loading:u,variant:h(["primary","secondary","destructive","destructive_link","link","reset"]).isRequired},v=require("lodash.merge"),k={appearance:"none",background:"none",display:"inline-block",border:"none",outline:"none",transition:"background-color 100ms ease-in, box-shadow 100ms ease-in, color 100ms ease-in",fontFamily:"fontFamilyText",fontWeight:"fontWeightSemibold",textDecoration:"none",position:"relative",_hover:{textDecoration:"none"},_focus:{textDecoration:"none",boxShadow:"shadowFocus"},_active:{textDecoration:"none"}},x={default:v({},k,{cursor:"pointer",_active:{boxShadow:"none"}}),disabled:v({},k,{cursor:"not-allowed"}),loading:v({},k,{cursor:"wait"})},m={default:{paddingTop:"space30",paddingBottom:"space30",paddingLeft:"space40",paddingRight:"space40",borderRadius:"borderRadius20",fontSize:"fontSize30",lineHeight:"lineHeight20"},small:{paddingTop:"space20",paddingBottom:"space20",paddingLeft:"space30",paddingRight:"space30",borderRadius:"borderRadius10",fontSize:"fontSize30",lineHeight:"lineHeight20"},icon:{padding:"space30",borderRadius:"borderRadius20"},reset:{paddingTop:"space0",paddingRight:"space0",paddingBottom:"space0",paddingLeft:"space0",borderWidth:"borderWidth0"}},w=require("lodash.merge"),y={default:w({},x.default,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimary",boxShadow:"shadowBorderPrimary",_hover:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowBorderPrimaryDarker"},_focus:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowFocus"},_active:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDark",boxShadow:"shadowBorderPrimaryDarker"}}),loading:w({},x.loading,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowBorderPrimaryDarker"}),disabled:w({},x.disabled,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryLight",boxShadow:"shadowBorderPrimaryLight"})},D=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),y[a],m[t]))}));D.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(D.propTypes=b),D.displayName="PrimaryButton";var B=require("lodash.merge"),S={color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLighter",boxShadow:"shadowBorderPrimaryLighter"},T={color:"colorTextLinkLight",backgroundColor:"colorBackgroundBody",boxShadow:"shadowBorderPrimaryLight"},L={default:B({},x.default,{color:"colorTextLink",backgroundColor:"colorBackgroundBody",boxShadow:"shadowBorderPrimary",_hover:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLightest",boxShadow:"shadowBorderPrimaryDarker"},_focus:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLightest",boxShadow:"shadowFocus"},_active:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLighter",boxShadow:"shadowBorderPrimaryDarker"}}),loading:B({},x.loading,g(g({},S),{_hover:S,_active:S,_focus:S})),disabled:B({},x.disabled,g(g({},T),{_hover:T,_active:T,_focus:T}))},_=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),L[a],m[t]))}));_.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(_.propTypes=b),_.displayName="SecondaryButton";var P=require("lodash.merge"),I={default:P({},x.default,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructive",boxShadow:"shadowBorderDestructive",_hover:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowBorderDestructiveDarker"},_focus:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowFocus"},_active:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDark",boxShadow:"shadowBorderDestructiveDarker"}}),loading:P({},x.loading,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowBorderDestructiveDarker"}),disabled:P({},x.disabled,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveLight",boxShadow:"shadowBorderDestructiveLight"})},W=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),I[a],m[t]))}));W.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(W.propTypes=b),W.displayName="DestructiveButton";var z=require("lodash.merge"),E={default:z({},x.default,{color:"colorTextLink",_hover:{color:"colorTextLinkDark",textDecoration:"underline"},_focus:{color:"colorTextLinkDark",textDecoration:"underline"},_active:{color:"colorTextLinkDarker",textDecoration:"underline"}}),loading:z({},x.loading,{color:"colorTextLinkDarker"}),disabled:z({},x.disabled,{color:"colorTextLinkLight"})},N=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),E[a],m[t]))}));N.defaultProps={as:"a"},"development"===process.env.NODE_ENV&&(N.propTypes=b),N.displayName="LinkButton";var C=require("lodash.merge"),O={default:C({},x.default,{color:"colorTextLinkDestructive",_hover:{color:"colorTextLinkDestructiveDark",textDecoration:"underline"},_active:{color:"colorTextLinkDestructiveDarker",textDecoration:"underline"},_focus:{color:"colorTextLinkDestructiveDark",textDecoration:"underline"}}),loading:C({},x.loading,{color:"colorTextLinkDestructiveDarker",_hover:{color:"colorTextLinkDestructiveDarker"},_active:{color:"colorTextLinkDestructiveDarker"},_focus:{color:"colorTextLinkDestructiveDarker"}}),disabled:C({},x.disabled,{color:"colorTextLinkDestructiveLight",_hover:{color:"colorTextLinkDestructiveLight"},_active:{color:"colorTextLinkDestructiveLight"},_focus:{color:"colorTextLinkDestructiveLight"}})},R=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),O[a],m[t]))}));R.defaultProps={as:"a"},"development"===process.env.NODE_ENV&&(R.propTypes=b),R.displayName="DestructiveLinkButton";var q=require("lodash.merge"),V={default:q({},x.default,{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverse",boxShadow:"shadowBorderInverse",_hover:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseLighter"},_focus:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowFocusInverse"},_active:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseLightest"}}),loading:q({},x.loading,{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseDarker"}),disabled:q({},x.disabled,{color:"colorTextInverseWeaker",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverse",boxShadow:"shadowBorderInverseDarker"})},j=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),V[a],m[t]))}));j.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(j.propTypes=b),j.displayName="InverseButton";var F=require("lodash.merge"),H={default:F({},x.default,{fontSize:"inherit",fontWeight:"inherit",color:"inherit"}),loading:F({},x.loading,{fontSize:"inherit",fontWeight:"inherit"}),disabled:F({},x.disabled,{fontSize:"inherit",fontWeight:"inherit"})},M=o((function(o,r){var t=o.size,a=o.buttonState,n=o.fullWidth,d=f(o,["size","buttonState","fullWidth"]);return e(i,g({ref:r,width:n?"100%":"auto"},l(d),H[a],m[t]))}));M.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(M.propTypes=b),M.displayName="ResetButton";var U=function(o){var r=o.buttonState,a=o.children,l=o.showLoading;return e(n,null,e(i,{as:"span",display:"flex",textDecoration:"inherit",opacity:"loading"===r?"0":"1","aria-hidden":"loading"===r?"true":"false"},t.count(a)>1?e(d,{as:"span",orientation:"horizontal",spacing:"space20"},a):a),l?e(i,{as:"span",position:"absolute",top:0,right:0,bottom:0,left:0,display:"flex",justifyContent:"center",alignItems:"center",lineHeight:"lineHeight30"},e(s,{decorative:!1,title:"Loading, please wait.",delay:0})):null)},A=o((function(o,n){var i=o.size,l=o.variant,d=o.children,s=o.disabled,c=o.loading,u=f(o,["size","variant","children","disabled","loading"]);!function(o){var e=o.as,r=o.href,t=o.tabIndex,a=o.variant,n=o.size,i=o.fullWidth,l=o.children,d=null!=r&&""!==r,s=null!=t;if("a"!==e&&d)throw new Error("[Paste: Button] You cannot pass href into a button without the 'a' tag. Use 'as=\"a\"'.");if("a"===e&&!d)throw new Error("[Paste: Button] Missing href prop for link button.");if("a"===e&&"link"===a)throw new Error("[Paste: Button] This should be a link. Use the [Paste: Anchor] component.");if("reset"===a&&"reset"!==n)throw new Error('[Paste: Button] The "RESET" variant can only be used with the "RESET" size.');if("icon"===n&&i)throw new Error("[Paste: Button] Icon buttons should not be fullWidth.");if(null==l)throw new Error("[Paste: Button] Must have non-null children.");if(s&&0!==t&&-1!==t)throw new Error("[Paste: Button] tabIndex must be 0 or -1.")}(o);var h=function(o,e){return o?"disabled":e?"loading":"default"}(s,c),b="loading"===h,p="default"!==h,v=function(o){switch(o){case"secondary":return _;case"destructive":return W;case"link":return N;case"destructive_link":return R;case"reset":return M;case"inverse":return j;case"primary":default:return D}}(l),k=r((function(){return function(o,e,r){var n="default";return null!=r?n=r:"link"===o||"destructive_link"===o?n="reset":1===t.count(e)&&t.forEach(e,(function(o){a(o)&&"string"==typeof o.type.displayName&&o.type.displayName.includes("Icon")&&(n="icon")})),n}(l,d,i)}),[i,l,d]);return e(v,g({},u,{buttonState:h,disabled:p,size:k,"aria-busy":"loading"===h?"true":"false",className:void 0,style:void 0,ref:n}),e(U,{buttonState:h,showLoading:b},d))}));A.defaultProps={as:"button",fullWidth:!1,disabled:!1,loading:!1,type:"button",variant:"primary"},"development"===process.env.NODE_ENV&&(A.propTypes=p),A.displayName="Button";export{A as Button}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),o=require("@twilio-paste/box"),r=require("@twilio-paste/stack"),t=require("@twilio-paste/spinner"),a=require("prop-types"),n=function(){return(n=Object.assign||function(e){for(var o,r=1,t=arguments.length;r<t;r++)for(var a in o=arguments[r])Object.prototype.hasOwnProperty.call(o,a)&&(e[a]=o[a]);return e}).apply(this,arguments)};function i(e,o){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)o.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(r[t[a]]=e[t[a]])}return r}var l={as:a.string,fullWidth:a.bool,href:a.string,size:a.oneOf(["small","default","icon","reset"]).isRequired,tabIndex:a.oneOf([0,-1]),type:a.oneOf(["submit","button","reset"]),disabled:a.bool,buttonState:a.oneOf(["disabled","loading","default"]).isRequired},d={as:a.string,fullWidth:a.bool,href:a.string,size:a.oneOf(["small","default","icon","reset"]),tabIndex:a.oneOf([0,-1]),type:a.oneOf(["submit","button","reset"]),disabled:a.bool,loading:a.bool,variant:a.oneOf(["primary","secondary","destructive","destructive_link","link","reset"]).isRequired},s=require("lodash.merge"),c={appearance:"none",background:"none",display:"inline-block",border:"none",outline:"none",transition:"background-color 100ms ease-in, box-shadow 100ms ease-in, color 100ms ease-in",fontFamily:"fontFamilyText",fontWeight:"fontWeightSemibold",textDecoration:"none",position:"relative",_hover:{textDecoration:"none"},_focus:{textDecoration:"none",boxShadow:"shadowFocus"},_active:{textDecoration:"none"}},u={default:s({},c,{cursor:"pointer",_active:{boxShadow:"none"}}),disabled:s({},c,{cursor:"not-allowed"}),loading:s({},c,{cursor:"wait"})},h={default:{paddingTop:"space30",paddingBottom:"space30",paddingLeft:"space40",paddingRight:"space40",borderRadius:"borderRadius20",fontSize:"fontSize30",lineHeight:"lineHeight20"},small:{paddingTop:"space20",paddingBottom:"space20",paddingLeft:"space30",paddingRight:"space30",borderRadius:"borderRadius10",fontSize:"fontSize30",lineHeight:"lineHeight20"},icon:{padding:"space30",borderRadius:"borderRadius20"},reset:{paddingTop:"space0",paddingRight:"space0",paddingBottom:"space0",paddingLeft:"space0",borderWidth:"borderWidth0"}},f=require("lodash.merge"),g={default:f({},u.default,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimary",boxShadow:"shadowBorderPrimary",_hover:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowBorderPrimaryDarker"},_focus:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowFocus"},_active:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDark",boxShadow:"shadowBorderPrimaryDarker"}}),loading:f({},u.loading,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowBorderPrimaryDarker"}),disabled:f({},u.disabled,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryLight",boxShadow:"shadowBorderPrimaryLight"})},p=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),g[l],h[a]))}));p.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(p.propTypes=l),p.displayName="PrimaryButton";var b=require("lodash.merge"),v={color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLighter",boxShadow:"shadowBorderPrimaryLighter"},k={color:"colorTextLinkLight",backgroundColor:"colorBackgroundBody",boxShadow:"shadowBorderPrimaryLight"},x={default:b({},u.default,{color:"colorTextLink",backgroundColor:"colorBackgroundBody",boxShadow:"shadowBorderPrimary",_hover:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLightest",boxShadow:"shadowBorderPrimaryDarker"},_focus:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLightest",boxShadow:"shadowFocus"},_active:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLighter",boxShadow:"shadowBorderPrimaryDarker"}}),loading:b({},u.loading,n(n({},v),{_hover:v,_active:v,_focus:v})),disabled:b({},u.disabled,n(n({},k),{_hover:k,_active:k,_focus:k}))},w=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),x[l],h[a]))}));w.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(w.propTypes=l),w.displayName="SecondaryButton";var m=require("lodash.merge"),y={default:m({},u.default,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructive",boxShadow:"shadowBorderDestructive",_hover:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowBorderDestructiveDarker"},_focus:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowFocus"},_active:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDark",boxShadow:"shadowBorderDestructiveDarker"}}),loading:m({},u.loading,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowBorderDestructiveDarker"}),disabled:m({},u.disabled,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveLight",boxShadow:"shadowBorderDestructiveLight"})},B=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),y[l],h[a]))}));B.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(B.propTypes=l),B.displayName="DestructiveButton";var D=require("lodash.merge"),S={default:D({},u.default,{color:"colorTextLink",_hover:{color:"colorTextLinkDark",textDecoration:"underline"},_focus:{color:"colorTextLinkDark",textDecoration:"underline"},_active:{color:"colorTextLinkDarker",textDecoration:"underline"}}),loading:D({},u.loading,{color:"colorTextLinkDarker"}),disabled:D({},u.disabled,{color:"colorTextLinkLight"})},T=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),S[l],h[a]))}));T.defaultProps={as:"a"},"development"===process.env.NODE_ENV&&(T.propTypes=l),T.displayName="LinkButton";var L=require("lodash.merge"),P={default:L({},u.default,{color:"colorTextLinkDestructive",_hover:{color:"colorTextLinkDestructiveDark",textDecoration:"underline"},_active:{color:"colorTextLinkDestructiveDarker",textDecoration:"underline"},_focus:{color:"colorTextLinkDestructiveDark",textDecoration:"underline"}}),loading:L({},u.loading,{color:"colorTextLinkDestructiveDarker",_hover:{color:"colorTextLinkDestructiveDarker"},_active:{color:"colorTextLinkDestructiveDarker"},_focus:{color:"colorTextLinkDestructiveDarker"}}),disabled:L({},u.disabled,{color:"colorTextLinkDestructiveLight",_hover:{color:"colorTextLinkDestructiveLight"},_active:{color:"colorTextLinkDestructiveLight"},_focus:{color:"colorTextLinkDestructiveLight"}})},_=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),P[l],h[a]))}));_.defaultProps={as:"a"},"development"===process.env.NODE_ENV&&(_.propTypes=l),_.displayName="DestructiveLinkButton";var E=require("lodash.merge"),I={default:E({},u.default,{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverse",boxShadow:"shadowBorderInverse",_hover:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseLighter"},_focus:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowFocusInverse"},_active:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseLightest"}}),loading:E({},u.loading,{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseDarker"}),disabled:E({},u.disabled,{color:"colorTextInverseWeaker",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverse",boxShadow:"shadowBorderInverseDarker"})},W=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),I[l],h[a]))}));W.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(W.propTypes=l),W.displayName="InverseButton";var z=require("lodash.merge"),O={default:z({},u.default,{fontSize:"inherit",fontWeight:"inherit",color:"inherit"}),loading:z({},u.loading,{fontSize:"inherit",fontWeight:"inherit"}),disabled:z({},u.disabled,{fontSize:"inherit",fontWeight:"inherit"})},C=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),O[l],h[a]))}));C.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(C.propTypes=l),C.displayName="ResetButton";var N=function(a){var n=a.buttonState,i=a.children,l=a.showLoading;return e.createElement(e.Fragment,null,e.createElement(o.Box,{as:"span",display:"flex",textDecoration:"inherit",opacity:"loading"===n?"0":"1","aria-hidden":"loading"===n?"true":"false"},e.Children.count(i)>1?e.createElement(r.Stack,{as:"span",orientation:"horizontal",spacing:"space20"},i):i),l?e.createElement(o.Box,{as:"span",position:"absolute",top:0,right:0,bottom:0,left:0,display:"flex",justifyContent:"center",alignItems:"center",lineHeight:"lineHeight30"},e.createElement(t.Spinner,{decorative:!1,title:"Loading, please wait.",delay:0})):null)},R=e.forwardRef((function(o,r){var t=o.size,a=o.variant,l=o.children,d=o.disabled,s=o.loading,c=i(o,["size","variant","children","disabled","loading"]);!function(e){var o=e.as,r=e.href,t=e.tabIndex,a=e.variant,n=e.size,i=e.fullWidth,l=e.children,d=null!=r&&""!==r,s=null!=t;if("a"!==o&&d)throw new Error("[Paste: Button] You cannot pass href into a button without the 'a' tag. Use 'as=\"a\"'.");if("a"===o&&!d)throw new Error("[Paste: Button] Missing href prop for link button.");if("a"===o&&"link"===a)throw new Error("[Paste: Button] This should be a link. Use the [Paste: Anchor] component.");if("link"!==a&&"destructive_link"!==a&&d)throw new Error("[Paste: Button] You cannot pass href into a button without the 'a' tag. Use 'variant=\"link\"' or 'variant=\"destructive_link\"'.");if("reset"===a&&"reset"!==n)throw new Error('[Paste: Button] The "RESET" variant can only be used with the "RESET" size.');if("icon"===n&&i)throw new Error("[Paste: Button] Icon buttons should not be fullWidth.");if(null==l)throw new Error("[Paste: Button] Must have non-null children.");if(s&&0!==t&&-1!==t)throw new Error("[Paste: Button] tabIndex must be 0 or -1.")}(o);var u=function(e,o){return e?"disabled":o?"loading":"default"}(d,s),h="loading"===u,f="default"!==u,g=function(e){switch(e){case"secondary":return w;case"destructive":return B;case"link":return T;case"destructive_link":return _;case"reset":return C;case"inverse":return W;case"primary":default:return p}}(a),b=e.useMemo((function(){return function(o,r,t){var a="default";return null!=t?a=t:"link"===o||"destructive_link"===o?a="reset":1===e.Children.count(r)&&e.Children.forEach(r,(function(o){e.isValidElement(o)&&"string"==typeof o.type.displayName&&o.type.displayName.includes("Icon")&&(a="icon")})),a}(a,l,t)}),[t,a,l]);return e.createElement(g,n({},c,{buttonState:u,disabled:f,size:b,"aria-busy":"loading"===u?"true":"false",className:void 0,style:void 0,ref:r}),e.createElement(N,{buttonState:u,showLoading:h},l))}));R.defaultProps={as:"button",fullWidth:!1,disabled:!1,loading:!1,type:"button",variant:"primary"},"development"===process.env.NODE_ENV&&(R.propTypes=d),R.displayName="Button",exports.Button=R; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),o=require("@twilio-paste/box"),r=require("@twilio-paste/stack"),t=require("@twilio-paste/spinner"),a=require("prop-types"),n=function(){return(n=Object.assign||function(e){for(var o,r=1,t=arguments.length;r<t;r++)for(var a in o=arguments[r])Object.prototype.hasOwnProperty.call(o,a)&&(e[a]=o[a]);return e}).apply(this,arguments)};function i(e,o){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)o.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(r[t[a]]=e[t[a]])}return r}var l={as:a.string,fullWidth:a.bool,href:a.string,size:a.oneOf(["small","default","icon","reset"]).isRequired,tabIndex:a.oneOf([0,-1]),type:a.oneOf(["submit","button","reset"]),disabled:a.bool,buttonState:a.oneOf(["disabled","loading","default"]).isRequired},d={as:a.string,fullWidth:a.bool,href:a.string,size:a.oneOf(["small","default","icon","reset"]),tabIndex:a.oneOf([0,-1]),type:a.oneOf(["submit","button","reset"]),disabled:a.bool,loading:a.bool,variant:a.oneOf(["primary","secondary","destructive","destructive_link","link","reset"]).isRequired},s=require("lodash.merge"),c={appearance:"none",background:"none",display:"inline-block",border:"none",outline:"none",transition:"background-color 100ms ease-in, box-shadow 100ms ease-in, color 100ms ease-in",fontFamily:"fontFamilyText",fontWeight:"fontWeightSemibold",textDecoration:"none",position:"relative",_hover:{textDecoration:"none"},_focus:{textDecoration:"none",boxShadow:"shadowFocus"},_active:{textDecoration:"none"}},u={default:s({},c,{cursor:"pointer",_active:{boxShadow:"none"}}),disabled:s({},c,{cursor:"not-allowed"}),loading:s({},c,{cursor:"wait"})},h={default:{paddingTop:"space30",paddingBottom:"space30",paddingLeft:"space40",paddingRight:"space40",borderRadius:"borderRadius20",fontSize:"fontSize30",lineHeight:"lineHeight20"},small:{paddingTop:"space20",paddingBottom:"space20",paddingLeft:"space30",paddingRight:"space30",borderRadius:"borderRadius10",fontSize:"fontSize30",lineHeight:"lineHeight20"},icon:{padding:"space30",borderRadius:"borderRadius20"},reset:{paddingTop:"space0",paddingRight:"space0",paddingBottom:"space0",paddingLeft:"space0",borderWidth:"borderWidth0"}},f=require("lodash.merge"),g={default:f({},u.default,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimary",boxShadow:"shadowBorderPrimary",_hover:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowBorderPrimaryDarker"},_focus:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowFocus"},_active:{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDark",boxShadow:"shadowBorderPrimaryDarker"}}),loading:f({},u.loading,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryDarker",boxShadow:"shadowBorderPrimaryDarker"}),disabled:f({},u.disabled,{color:"colorTextInverse",backgroundColor:"colorBackgroundPrimaryLight",boxShadow:"shadowBorderPrimaryLight"})},p=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),g[l],h[a]))}));p.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(p.propTypes=l),p.displayName="PrimaryButton";var b=require("lodash.merge"),v={color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLighter",boxShadow:"shadowBorderPrimaryLighter"},k={color:"colorTextLinkLight",backgroundColor:"colorBackgroundBody",boxShadow:"shadowBorderPrimaryLight"},x={default:b({},u.default,{color:"colorTextLink",backgroundColor:"colorBackgroundBody",boxShadow:"shadowBorderPrimary",_hover:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLightest",boxShadow:"shadowBorderPrimaryDarker"},_focus:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLightest",boxShadow:"shadowFocus"},_active:{color:"colorTextLinkDarker",backgroundColor:"colorBackgroundPrimaryLighter",boxShadow:"shadowBorderPrimaryDarker"}}),loading:b({},u.loading,n(n({},v),{_hover:v,_active:v,_focus:v})),disabled:b({},u.disabled,n(n({},k),{_hover:k,_active:k,_focus:k}))},w=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),x[l],h[a]))}));w.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(w.propTypes=l),w.displayName="SecondaryButton";var m=require("lodash.merge"),y={default:m({},u.default,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructive",boxShadow:"shadowBorderDestructive",_hover:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowBorderDestructiveDarker"},_focus:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowFocus"},_active:{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDark",boxShadow:"shadowBorderDestructiveDarker"}}),loading:m({},u.loading,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveDarker",boxShadow:"shadowBorderDestructiveDarker"}),disabled:m({},u.disabled,{color:"colorTextInverse",backgroundColor:"colorBackgroundDestructiveLight",boxShadow:"shadowBorderDestructiveLight"})},B=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),y[l],h[a]))}));B.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(B.propTypes=l),B.displayName="DestructiveButton";var D=require("lodash.merge"),S={default:D({},u.default,{color:"colorTextLink",_hover:{color:"colorTextLinkDark",textDecoration:"underline"},_focus:{color:"colorTextLinkDark",textDecoration:"underline"},_active:{color:"colorTextLinkDarker",textDecoration:"underline"}}),loading:D({},u.loading,{color:"colorTextLinkDarker"}),disabled:D({},u.disabled,{color:"colorTextLinkLight"})},T=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),S[l],h[a]))}));T.defaultProps={as:"a"},"development"===process.env.NODE_ENV&&(T.propTypes=l),T.displayName="LinkButton";var L=require("lodash.merge"),P={default:L({},u.default,{color:"colorTextLinkDestructive",_hover:{color:"colorTextLinkDestructiveDark",textDecoration:"underline"},_active:{color:"colorTextLinkDestructiveDarker",textDecoration:"underline"},_focus:{color:"colorTextLinkDestructiveDark",textDecoration:"underline"}}),loading:L({},u.loading,{color:"colorTextLinkDestructiveDarker",_hover:{color:"colorTextLinkDestructiveDarker"},_active:{color:"colorTextLinkDestructiveDarker"},_focus:{color:"colorTextLinkDestructiveDarker"}}),disabled:L({},u.disabled,{color:"colorTextLinkDestructiveLight",_hover:{color:"colorTextLinkDestructiveLight"},_active:{color:"colorTextLinkDestructiveLight"},_focus:{color:"colorTextLinkDestructiveLight"}})},_=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),P[l],h[a]))}));_.defaultProps={as:"a"},"development"===process.env.NODE_ENV&&(_.propTypes=l),_.displayName="DestructiveLinkButton";var E=require("lodash.merge"),I={default:E({},u.default,{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverse",boxShadow:"shadowBorderInverse",_hover:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseLighter"},_focus:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowFocusInverse"},_active:{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseLightest"}}),loading:E({},u.loading,{color:"colorTextInverse",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverseLight",boxShadow:"shadowBorderInverseDarker"}),disabled:E({},u.disabled,{color:"colorTextInverseWeaker",fontWeight:"fontWeightSemibold",backgroundColor:"colorBackgroundInverse",boxShadow:"shadowBorderInverseDarker"})},W=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),I[l],h[a]))}));W.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(W.propTypes=l),W.displayName="InverseButton";var z=require("lodash.merge"),O={default:z({},u.default,{fontSize:"inherit",fontWeight:"inherit",color:"inherit"}),loading:z({},u.loading,{fontSize:"inherit",fontWeight:"inherit"}),disabled:z({},u.disabled,{fontSize:"inherit",fontWeight:"inherit"})},C=e.forwardRef((function(r,t){var a=r.size,l=r.buttonState,d=r.fullWidth,s=i(r,["size","buttonState","fullWidth"]);return e.createElement(o.Box,n({ref:t,width:d?"100%":"auto"},o.safelySpreadBoxProps(s),O[l],h[a]))}));C.defaultProps={as:"button"},"development"===process.env.NODE_ENV&&(C.propTypes=l),C.displayName="ResetButton";var N=function(a){var n=a.buttonState,i=a.children,l=a.showLoading;return e.createElement(e.Fragment,null,e.createElement(o.Box,{as:"span",display:"flex",textDecoration:"inherit",opacity:"loading"===n?"0":"1","aria-hidden":"loading"===n?"true":"false"},e.Children.count(i)>1?e.createElement(r.Stack,{as:"span",orientation:"horizontal",spacing:"space20"},i):i),l?e.createElement(o.Box,{as:"span",position:"absolute",top:0,right:0,bottom:0,left:0,display:"flex",justifyContent:"center",alignItems:"center",lineHeight:"lineHeight30"},e.createElement(t.Spinner,{decorative:!1,title:"Loading, please wait.",delay:0})):null)},R=e.forwardRef((function(o,r){var t=o.size,a=o.variant,l=o.children,d=o.disabled,s=o.loading,c=i(o,["size","variant","children","disabled","loading"]);!function(e){var o=e.as,r=e.href,t=e.tabIndex,a=e.variant,n=e.size,i=e.fullWidth,l=e.children,d=null!=r&&""!==r,s=null!=t;if("a"!==o&&d)throw new Error("[Paste: Button] You cannot pass href into a button without the 'a' tag. Use 'as=\"a\"'.");if("a"===o&&!d)throw new Error("[Paste: Button] Missing href prop for link button.");if("a"===o&&"link"===a)throw new Error("[Paste: Button] This should be a link. Use the [Paste: Anchor] component.");if("reset"===a&&"reset"!==n)throw new Error('[Paste: Button] The "RESET" variant can only be used with the "RESET" size.');if("icon"===n&&i)throw new Error("[Paste: Button] Icon buttons should not be fullWidth.");if(null==l)throw new Error("[Paste: Button] Must have non-null children.");if(s&&0!==t&&-1!==t)throw new Error("[Paste: Button] tabIndex must be 0 or -1.")}(o);var u=function(e,o){return e?"disabled":o?"loading":"default"}(d,s),h="loading"===u,f="default"!==u,g=function(e){switch(e){case"secondary":return w;case"destructive":return B;case"link":return T;case"destructive_link":return _;case"reset":return C;case"inverse":return W;case"primary":default:return p}}(a),b=e.useMemo((function(){return function(o,r,t){var a="default";return null!=t?a=t:"link"===o||"destructive_link"===o?a="reset":1===e.Children.count(r)&&e.Children.forEach(r,(function(o){e.isValidElement(o)&&"string"==typeof o.type.displayName&&o.type.displayName.includes("Icon")&&(a="icon")})),a}(a,l,t)}),[t,a,l]);return e.createElement(g,n({},c,{buttonState:u,disabled:f,size:b,"aria-busy":"loading"===u?"true":"false",className:void 0,style:void 0,ref:r}),e.createElement(N,{buttonState:u,showLoading:h},l))}));R.defaultProps={as:"button",fullWidth:!1,disabled:!1,loading:!1,type:"button",variant:"primary"},"development"===process.env.NODE_ENV&&(R.propTypes=d),R.displayName="Button",exports.Button=R; |
{ | ||
"name": "@twilio-paste/button", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"category": "interaction", | ||
@@ -34,11 +34,11 @@ "status": "production", | ||
"peerDependencies": { | ||
"@twilio-paste/box": "^2.9.3", | ||
"@twilio-paste/design-tokens": "^6.1.1", | ||
"@twilio-paste/icons": "^3.0.4", | ||
"@twilio-paste/spinner": "^2.0.4", | ||
"@twilio-paste/stack": "^0.1.30", | ||
"@twilio-paste/style-props": "^1.5.2", | ||
"@twilio-paste/box": "^2.9.4", | ||
"@twilio-paste/design-tokens": "^6.2.0", | ||
"@twilio-paste/icons": "^3.1.0", | ||
"@twilio-paste/spinner": "^2.0.5", | ||
"@twilio-paste/stack": "^0.1.31", | ||
"@twilio-paste/style-props": "^1.5.3", | ||
"@twilio-paste/styling-library": "^0.1.2", | ||
"@twilio-paste/theme": "^3.2.15", | ||
"@twilio-paste/types": "^3.0.18", | ||
"@twilio-paste/theme": "^3.2.16", | ||
"@twilio-paste/types": "^3.0.19", | ||
"prop-types": "^15.7.2", | ||
@@ -61,3 +61,3 @@ "react": "^16.8.6", | ||
}, | ||
"gitHead": "c493af8cd58d63177ea6c956ee15c9f04915c4f5" | ||
"gitHead": "e88e8b64c6fa65a4927567d775b8ccba4d641e88" | ||
} |
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
103180
339