-
Notifications
You must be signed in to change notification settings - Fork 31
/
14500.2e52da10.iframe.bundle.js
1 lines (1 loc) · 21.9 KB
/
14500.2e52da10.iframe.bundle.js
1
"use strict";(globalThis.webpackChunkmetamask_crx=globalThis.webpackChunkmetamask_crx||[]).push([[14500],{"./ui/components/app/connected-accounts-list/connected-accounts-list-options/index.js":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{A:()=>connected_accounts_list_options_component});var prop_types=__webpack_require__("./node_modules/prop-types/index.js"),prop_types_default=__webpack_require__.n(prop_types),react=__webpack_require__("./node_modules/react/index.js"),menu=__webpack_require__("./ui/components/ui/menu/index.js"),component_library=__webpack_require__("./ui/components/component-library/index.ts"),useI18nContext=__webpack_require__("./ui/hooks/useI18nContext.js"),ConnectedAccountsListOptions=function(param){var children=param.children,onShowOptions=param.onShowOptions,onHideOptions=param.onHideOptions,show=param.show,ref=(0,react.useRef)(!1),t=(0,useI18nContext.P)();return react.createElement("div",{ref:ref},react.createElement(component_library.a2,{iconName:component_library.$M.MoreVertical,className:"connected-accounts-options__button",onClick:onShowOptions,ariaLabel:t("options")}),show?react.createElement(menu.W,{anchorElement:ref.current,onHide:onHideOptions,popperOptions:{modifiers:[{name:"preventOverflow",options:{altBoundary:!0}}]}},children):null)};ConnectedAccountsListOptions.propTypes={children:prop_types_default().node.isRequired,onHideOptions:prop_types_default().func.isRequired,onShowOptions:prop_types_default().func.isRequired,show:prop_types_default().bool.isRequired};let connected_accounts_list_options_component=ConnectedAccountsListOptions;ConnectedAccountsListOptions.__docgenInfo={description:"",methods:[],displayName:"ConnectedAccountsListOptions",props:{children:{description:"",type:{name:"node"},required:!0},onHideOptions:{description:"",type:{name:"func"},required:!0},onShowOptions:{description:"",type:{name:"func"},required:!0},show:{description:"",type:{name:"bool"},required:!0}}}},"./ui/components/app/connected-accounts-list/index.js":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{A:()=>ConnectedAccountsList});var prop_types=__webpack_require__("./node_modules/prop-types/index.js"),prop_types_default=__webpack_require__.n(prop_types),react=__webpack_require__("./node_modules/react/index.js"),design_system=__webpack_require__("./ui/helpers/constants/design-system.ts"),component_library=__webpack_require__("./ui/components/component-library/index.ts"),menu=__webpack_require__("./ui/components/ui/menu/index.js"),classnames=__webpack_require__("./node_modules/classnames/index.js"),classnames_default=__webpack_require__.n(classnames),es=__webpack_require__("./node_modules/react-redux/es/index.js"),util=__webpack_require__("./ui/helpers/utils/util.js"),selectors=__webpack_require__("./ui/selectors/index.js");function ConnectedAccountsListItem(param){var address=param.address,_param_className=param.className,name=param.name,status=param.status,_param_action=param.action,_param_options=param.options,backgroundColor=param.backgroundColor,useBlockie=(0,es.d4)(selectors.bNi),containerbackgroundColor=null!=backgroundColor?backgroundColor:design_system.i0.backgroundDefault;return react.createElement(component_library.az,{className:classnames_default()("connected-accounts-list__row",void 0===_param_className?null:_param_className),padding:4,backgroundColor:containerbackgroundColor,display:design_system.nl.Flex,flexDirection:design_system.bo.Row,justifyContent:design_system.A9.spaceBetween,alignItems:design_system.k2.center},react.createElement(component_library.az,{className:"connected-accounts-list__row-content",gap:4},react.createElement(component_library.vs,{variant:useBlockie?component_library.Uj.Blockies:component_library.Uj.Jazzicon,address:address,size:component_library.oG.Md}),react.createElement(component_library.az,{display:design_system.nl.Flex,flexDirection:design_system.bo.Column},react.createElement(component_library.az,null,react.createElement(component_library.EY,{variant:design_system.J3.bodyLgMedium,className:"connected-accounts-list__account-name"},name),react.createElement(component_library.EY,{variant:design_system.J3.bodyMd},(0,util.Wr)(address)),status?react.createElement(component_library.EY,{variant:design_system.J3.bodyMd,className:"connected-accounts-list__account-status",color:design_system.r7.successDefault},status):null),react.createElement(component_library.az,{display:design_system.nl.Flex,flexDirection:design_system.bo.Column},void 0===_param_action?null:_param_action))),void 0===_param_options?null:_param_options)}ConnectedAccountsListItem.propTypes={address:prop_types_default().string.isRequired,className:prop_types_default().string,name:prop_types_default().node.isRequired,status:prop_types_default().string,action:prop_types_default().node,options:prop_types_default().node,backgroundColor:prop_types_default().string},ConnectedAccountsListItem.__docgenInfo={description:"",methods:[],displayName:"ConnectedAccountsListItem",props:{className:{defaultValue:{value:"null",computed:!1},description:"An additional className to apply",type:{name:"string"},required:!1},action:{defaultValue:{value:"null",computed:!1},description:"Action for account",type:{name:"node"},required:!1},options:{defaultValue:{value:"null",computed:!1},description:"Render Options button with actions",type:{name:"node"},required:!1},address:{description:"Address for Avatar",type:{name:"string"},required:!0},name:{description:"Name of the account",type:{name:"node"},required:!0},status:{description:"Status showing connected, not connected and active state",type:{name:"string"},required:!1},backgroundColor:{description:"ContainerbackgroundColor showing highlighted state when not connected",type:{name:"string"},required:!1}}};var connected_accounts_list_options=__webpack_require__("./ui/components/app/connected-accounts-list/connected-accounts-list-options/index.js");function _assert_this_initialized(self){if(void 0===self)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return self}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor))throw TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Constructor}function _define_property(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _get_prototype_of(o){return(_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)})(o)}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw TypeError("Super expression must either be null or a function");subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:!0,configurable:!0}}),superClass&&_set_prototype_of(subClass,superClass)}function _possible_constructor_return(self,call){return call&&("object"===_type_of(call)||"function"==typeof call)?call:_assert_this_initialized(self)}function _set_prototype_of(o,p){return(_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){return o.__proto__=p,o})(o,p)}function _type_of(obj){return obj&&"undefined"!=typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _create_super(Derived){var hasNativeReflectConstruct=_is_native_reflect_construct();return function _createSuperInternal(){var result,Super=_get_prototype_of(Derived);return result=hasNativeReflectConstruct?Reflect.construct(Super,arguments,_get_prototype_of(this).constructor):Super.apply(this,arguments),_possible_constructor_return(this,result)}}var ConnectedAccountsList=function(PureComponent){_inherits(ConnectedAccountsList,PureComponent);var _super=_create_super(ConnectedAccountsList);function ConnectedAccountsList(){var _this;return _class_call_check(this,ConnectedAccountsList),_this=_super.apply(this,arguments),_define_property(_assert_this_initialized(_this),"state",{accountWithOptionsShown:null}),_define_property(_assert_this_initialized(_this),"disconnectAccount",function(){_this.hideAccountOptions(),_this.props.removePermittedAccount(_this.state.accountWithOptionsShown)}),_define_property(_assert_this_initialized(_this),"switchAccount",function(address){_this.hideAccountOptions(),_this.props.setSelectedAddress(address)}),_define_property(_assert_this_initialized(_this),"hideAccountOptions",function(){_this.setState({accountWithOptionsShown:null})}),_define_property(_assert_this_initialized(_this),"showAccountOptions",function(address){_this.setState({accountWithOptionsShown:address})}),_this}return _create_class(ConnectedAccountsList,[{key:"renderUnconnectedAccount",value:function renderUnconnectedAccount(){var _this_props=this.props,accountToConnect=_this_props.accountToConnect,connectAccount=_this_props.connectAccount,t=this.context.t;if(!accountToConnect)return null;var address=accountToConnect.address,name=accountToConnect.metadata.name;return react.createElement(ConnectedAccountsListItem,{className:"connected-accounts-list__row--highlight",backgroundColor:design_system.i0.warningMuted,address:address,name:name,status:t("statusNotConnected"),action:react.createElement(component_library.EY,{variant:design_system.J3.bodyMd},react.createElement(component_library.vx,{className:"connected-accounts-list__account-status-link",onClick:function(){return connectAccount(address)},size:component_library.wL.Inherit},t("connect")))})}},{key:"renderListItemOptions",value:function renderListItemOptions(address){var accountWithOptionsShown=this.state.accountWithOptionsShown,t=this.context.t;return react.createElement(connected_accounts_list_options.A,{onHideOptions:this.hideAccountOptions,onShowOptions:this.showAccountOptions.bind(null,address),show:accountWithOptionsShown===address},react.createElement(menu.D,{iconName:component_library.$M.Logout,onClick:this.disconnectAccount},t("disconnectThisAccount")))}},{key:"renderListItemAction",value:function renderListItemAction(address){var _this=this,t=this.context.t;return react.createElement(component_library.EY,{variant:design_system.J3.bodyMd},react.createElement(component_library.vx,{className:"connected-accounts-list__account-status-link",onClick:function(){return _this.switchAccount(address)},size:component_library.wL.Inherit},t("switchToThisAccount")))}},{key:"render",value:function render(){var _this=this,_this_props=this.props,connectedAccounts=_this_props.connectedAccounts,selectedAddress=_this_props.selectedAddress,shouldRenderListOptions=_this_props.shouldRenderListOptions,t=this.context.t;return react.createElement(react.Fragment,null,react.createElement("main",{className:"connected-accounts-list"},this.renderUnconnectedAccount(),connectedAccounts.map(function(param,index){var address=param.address,name=param.name;return react.createElement(ConnectedAccountsListItem,{key:address,address:address,name:name,status:0===index?t("active"):null,options:shouldRenderListOptions?_this.renderListItemOptions(address):null,action:address===selectedAddress?null:_this.renderListItemAction(address)})})))}}]),ConnectedAccountsList}(react.PureComponent);_define_property(ConnectedAccountsList,"contextTypes",{t:prop_types_default().func.isRequired}),_define_property(ConnectedAccountsList,"defaultProps",{accountToConnect:null}),_define_property(ConnectedAccountsList,"propTypes",{accountToConnect:prop_types_default().shape({id:prop_types_default().string.isRequired,address:prop_types_default().string.isRequired,metadata:prop_types_default().shape({name:prop_types_default().string.isRequired,keyring:prop_types_default().shape({type:prop_types_default().string.isRequired}).isRequired}).isRequired,options:prop_types_default().object.isRequired,methods:prop_types_default().arrayOf(prop_types_default().string).isRequired,type:prop_types_default().string.isRequired}),connectedAccounts:prop_types_default().arrayOf(prop_types_default().shape({address:prop_types_default().string.isRequired,name:prop_types_default().string.isRequired,lastActive:prop_types_default().number})).isRequired,connectAccount:prop_types_default().func.isRequired,selectedAddress:prop_types_default().string.isRequired,removePermittedAccount:prop_types_default().func,setSelectedAddress:prop_types_default().func.isRequired,shouldRenderListOptions:function(props,propName,componentName){return"boolean"!=typeof props[propName]?Error("Warning: Failed prop type: '".concat(propName,"' of component '").concat(componentName,"' must be a boolean. Received: ").concat(_type_of(props[propName]))):props[propName]&&!props.removePermittedAccount?Error("Warning: Failed prop type: '".concat(propName,"' of component '").concat(componentName,"' requires prop 'removePermittedAccount'.")):void 0}}),ConnectedAccountsList.__docgenInfo={description:"",methods:[{name:"disconnectAccount",docblock:null,modifiers:[],params:[],returns:null},{name:"switchAccount",docblock:null,modifiers:[],params:[{name:"address",optional:!1,type:null}],returns:null},{name:"hideAccountOptions",docblock:null,modifiers:[],params:[],returns:null},{name:"showAccountOptions",docblock:null,modifiers:[],params:[{name:"address",optional:!1,type:null}],returns:null},{name:"renderUnconnectedAccount",docblock:null,modifiers:[],params:[],returns:null},{name:"renderListItemOptions",docblock:null,modifiers:[],params:[{name:"address",optional:!1,type:null}],returns:null},{name:"renderListItemAction",docblock:null,modifiers:[],params:[{name:"address",optional:!1,type:null}],returns:null}],displayName:"ConnectedAccountsList",props:{accountToConnect:{defaultValue:{value:"null",computed:!1},description:"",type:{name:"shape",value:{id:{name:"string",required:!0},address:{name:"string",required:!0},metadata:{name:"shape",value:{name:{name:"string",required:!0},keyring:{name:"shape",value:{type:{name:"string",required:!0}},required:!0}},required:!0},options:{name:"object",required:!0},methods:{name:"arrayOf",value:{name:"string"},required:!0},type:{name:"string",required:!0}}},required:!1},connectedAccounts:{description:"",type:{name:"arrayOf",value:{name:"shape",value:{address:{name:"string",required:!0},name:{name:"string",required:!0},lastActive:{name:"number",required:!1}}}},required:!0},connectAccount:{description:"",type:{name:"func"},required:!0},selectedAddress:{description:"",type:{name:"string"},required:!0},removePermittedAccount:{description:"",type:{name:"func"},required:!1},setSelectedAddress:{description:"",type:{name:"func"},required:!0},shouldRenderListOptions:{description:"",type:{name:"custom",raw:"(props, propName, componentName) => {\n if (typeof props[propName] !== 'boolean') {\n return new Error(\n `Warning: Failed prop type: '${propName}' of component '${componentName}' must be a boolean. Received: ${typeof props[\n propName\n ]}`,\n );\n } else if (props[propName] && !props.removePermittedAccount) {\n return new Error(\n `Warning: Failed prop type: '${propName}' of component '${componentName}' requires prop 'removePermittedAccount'.`,\n );\n }\n return undefined;\n}"},required:!1}},context:{t:{type:{name:"func"},required:!0}}}},"./ui/components/ui/menu/index.js":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{W:()=>menu,D:()=>menu_item});var prop_types=__webpack_require__("./node_modules/prop-types/index.js"),prop_types_default=__webpack_require__.n(prop_types),react=__webpack_require__("./node_modules/react/index.js"),react_dom=__webpack_require__("./node_modules/react-dom/index.js"),usePopper=__webpack_require__("./node_modules/react-popper/lib/esm/usePopper.js"),classnames=__webpack_require__("./node_modules/classnames/index.js"),classnames_default=__webpack_require__.n(classnames);function _array_like_to_array(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _define_property(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _iterable_to_array_limit(arr,i){var _s,_e,_i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}}function _non_iterable_rest(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{},ownKeys=Object.keys(source);"function"==typeof Object.getOwnPropertySymbols&&(ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))),ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(o){if("string"==typeof o)return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if("Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}}var Menu=function(param){var anchorElement=param.anchorElement,children=param.children,className=param.className,dataTestId=param["data-testid"],onHide=param.onHide,popperOptions=param.popperOptions,_useState=_sliced_to_array((0,react.useState)(null),2),popperElement=_useState[0],setPopperElement=_useState[1],popoverContainerElement=(0,react.useRef)(document.getElementById("popover-content")),_usePopper=(0,usePopper.E)(anchorElement,popperElement,popperOptions),attributes=_usePopper.attributes,styles=_usePopper.styles;return(0,react_dom.createPortal)(react.createElement(react.Fragment,null,react.createElement("div",{className:"menu__background","data-testid":dataTestId,onClick:onHide}),react.createElement("div",_object_spread({className:classnames_default()("menu__container",className),"data-testid":className,ref:setPopperElement,style:styles.popper},attributes.popper),children)),popoverContainerElement.current)};Menu.propTypes={anchorElement:prop_types_default().instanceOf(window.Element),children:prop_types_default().node.isRequired,className:prop_types_default().string,onHide:prop_types_default().func.isRequired,popperOptions:prop_types_default().object,dataTestId:prop_types_default().string},Menu.defaultProps={anchorElement:void 0,className:void 0,popperOptions:void 0};let menu=Menu;var component_library=__webpack_require__("./ui/components/component-library/index.ts"),design_system=__webpack_require__("./ui/helpers/constants/design-system.ts"),MenuItem=react.forwardRef(function(param,ref){var children=param.children,className=param.className,dataTestId=param["data-testid"],iconName=param.iconName,iconColor=param.iconColor,onClick=param.onClick,subtitle=param.subtitle,_param_disabled=param.disabled,showInfoDot=param.showInfoDot;return react.createElement("button",{className:classnames_default()("menu-item",className),"data-testid":dataTestId,onClick:onClick,ref:ref,disabled:void 0!==_param_disabled&&_param_disabled},iconName&&showInfoDot&&react.createElement(component_library.ph,{anchorElementShape:component_library.Hs.circular,display:design_system.nl.Block,position:component_library.uc.topRight,positionObj:{top:-6,right:4},badge:react.createElement(component_library.In,{name:component_library.$M.FullCircle,size:component_library.lK.Xs,color:design_system.Li.primaryDefault,style:{"--size":"10px"}})},react.createElement(component_library.In,{name:iconName,size:component_library.lK.Sm,marginRight:2})),iconName&&!showInfoDot&&react.createElement(component_library.In,{name:iconName,size:component_library.lK.Sm,marginRight:2,color:iconColor}),react.createElement("div",null,react.createElement("div",null,children),subtitle?react.createElement(component_library.EY,{variant:design_system.J3.bodyXs},subtitle):null))});MenuItem.propTypes={children:prop_types_default().node.isRequired,className:prop_types_default().string,"data-testid":prop_types_default().string,iconName:prop_types_default().string,onClick:prop_types_default().func,subtitle:prop_types_default().node,disabled:prop_types_default().bool,showInfoDot:prop_types_default().bool,iconColor:prop_types_default().string},MenuItem.displayName="MenuItem";let menu_item=MenuItem;MenuItem.__docgenInfo={description:"",methods:[],displayName:"MenuItem",props:{disabled:{defaultValue:{value:"false",computed:!1},description:"",type:{name:"bool"},required:!1},children:{description:"",type:{name:"node"},required:!0},className:{description:"",type:{name:"string"},required:!1},"data-testid":{description:"",type:{name:"string"},required:!1},iconName:{description:"",type:{name:"string"},required:!1},onClick:{description:"",type:{name:"func"},required:!1},subtitle:{description:"",type:{name:"node"},required:!1},showInfoDot:{description:"",type:{name:"bool"},required:!1},iconColor:{description:"",type:{name:"string"},required:!1}}}}}]);