Build 545032stable
Module 109802
1,982 characters · in a7c47bb781900424.jsDependencies
Source Raw
function(t,e,s){s.d(e,{e:()=>k,q:()=>C});var n=s(627968),i=s(64700),l=s(503698),r=s.n(l),a=s(765178),o=s(862482),c=s(504345),p=s(187322),d=s(235986),u=s(821589),h=s(375708),R=s(797525);let C={DEFAULT:"default",SUCCESS:"success",ERROR:"error"};class k extends i.PureComponent{inputRef=i.createRef();containerRef=i.createRef();static contextType=c.cK;static defaultProps={supportsCopy:!0,buttonColor:o.XD.PRIMARY,buttonLook:o.pR.FILLED,mode:C.DEFAULT};static Modes=C;static ButtonColors=o.XD;static ButtonLooks=o.pR;componentDidUpdate(t){t.mode!==this.props.mode&&this.props.mode===C.SUCCESS&&a.O.announce(h.intl.string(h.t.t5VZ88))}select(){this.inputRef.current?.select()}renderInput(t){let{value:e,mode:s,autoFocus:i,spellCheck:l,inputClassName:a,placeholder:o}=this.props,c=this.context?.titleId;return(0,n.jsx)("input",{className:r()((0,u.t)(R,"input",s),a,{[R.inputHidden]:t}),ref:this.inputRef,type:"text",value:e,onClick:this.handleInputClick,readOnly:!0,"aria-labelledby":c,autoFocus:i,spellCheck:l,placeholder:o})}render(){let t,{text:e=h.intl.string(h.t.OpuAlK),mode:s,hideMessage:i,className:l,buttonLook:a,supportsCopy:c,disabled:k}=this.props,f=null!=i;switch(s){case C.SUCCESS:t=o.XD.GREEN;break;case C.ERROR:t=o.XD.RED;break;default:t=this.props.buttonColor}return(0,n.jsx)(p.vN,{focusTarget:this.inputRef,ringTarget:this.containerRef,children:(0,n.jsx)("div",{className:r()((0,u.t)(R,"copyInput",s),l),ref:this.containerRef,"data-disabled":k,children:(0,n.jsxs)(d.A,{className:R.layout,children:[(0,n.jsxs)(d.A,{className:R.inputWrapper,children:[this.renderInput(f),f?(0,n.jsx)("div",{className:R.hiddenMessage,children:i}):null]}),c?(0,n.jsx)(d.A,{shrink:1,grow:0,style:{margin:0},children:(0,n.jsx)(o.$n,{"data-migration-pending":!0,className:R.button,onClick:this.handleButtonClick,size:o.lO.MIN,color:t,look:a,disabled:k,children:e})}):null]})})})}handleButtonClick=()=>{this.select();let{onCopy:t,value:e}=this.props;t(e)};handleInputClick=()=>{this.select()}}}