@arcgis/portal-components 5.2.0-next.85 → 5.2.0-next.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/cdn/{GADH24KO.js → 25KISBCS.js} +1 -1
  2. package/dist/cdn/2TQ4B2LU.js +2 -0
  3. package/dist/cdn/4GRTJ7XT.js +2 -0
  4. package/dist/cdn/{ZAB6B2B6.js → 5EMPEJ65.js} +1 -1
  5. package/dist/cdn/C7XKSVMU.js +2 -0
  6. package/dist/cdn/{DHWAQSKG.js → F3LFFR3K.js} +1 -1
  7. package/dist/cdn/F3M3R7X2.js +2 -0
  8. package/dist/cdn/{CD2GV5YW.js → F76RXJ66.js} +1 -1
  9. package/dist/cdn/FQTFZLHT.js +2 -0
  10. package/dist/cdn/KYNL256E.js +2 -0
  11. package/dist/cdn/{NASFEWDT.js → LDYOCDG6.js} +1 -1
  12. package/dist/cdn/{LRADZ46B.js → NQQLTGIK.js} +1 -1
  13. package/dist/cdn/{R5MGNFM2.js → PMQCCLS5.js} +1 -1
  14. package/dist/cdn/QTKBB22S.js +2 -0
  15. package/dist/cdn/SYDYG3CL.js +2 -0
  16. package/dist/cdn/{TUBYAQ6R.js → X5B4PAML.js} +1 -1
  17. package/dist/cdn/{ECA5GSSU.js → X6XTK2TE.js} +1 -1
  18. package/dist/cdn/{6BALICUQ.js → Y56BS6IQ.js} +52 -52
  19. package/dist/cdn/YBWCEZJP.js +2 -0
  20. package/dist/cdn/assets/portal-account-switcher/t9n/messages.en.json +1 -1
  21. package/dist/cdn/index.js +1 -1
  22. package/dist/chunks/fieldAddDelete.js +1 -1
  23. package/dist/chunks/groups2.js +1 -1
  24. package/dist/chunks/item2.js +1 -1
  25. package/dist/chunks/portal-account-switcher.js +3 -3
  26. package/dist/chunks/portal.js +2 -2
  27. package/dist/chunks/portal2.js +1 -1
  28. package/dist/chunks/request.js +1 -1
  29. package/dist/chunks/services.js +17 -0
  30. package/dist/chunks/user.js +1 -1
  31. package/dist/chunks/utils.js +4 -4
  32. package/dist/components/arcgis-portal-account-switcher/customElement.d.ts +22 -2
  33. package/dist/components/arcgis-portal-account-switcher/customElement.js +211 -207
  34. package/dist/components/arcgis-portal-account-switcher/index.js +1 -3
  35. package/dist/components/arcgis-portal-account-switcher/types.d.ts +6 -0
  36. package/dist/components/arcgis-portal-account-switcher-accounts/customElement.d.ts +20 -2
  37. package/dist/components/arcgis-portal-account-switcher-accounts/customElement.js +5 -5
  38. package/dist/components/arcgis-portal-account-switcher-list/customElement.d.ts +22 -4
  39. package/dist/components/arcgis-portal-account-switcher-list/customElement.js +58 -37
  40. package/dist/components/arcgis-portal-account-switcher-list/index.js +2 -3
  41. package/dist/components/arcgis-portal-ai-assistant/agents/portalRouteKeys.d.ts +25 -16
  42. package/dist/components/arcgis-portal-ai-assistant/agents/types.d.ts +4 -4
  43. package/dist/components/arcgis-portal-ai-assistant/customElement.js +611 -603
  44. package/dist/components/arcgis-portal-field-delete/customElement.js +1 -1
  45. package/dist/components/arcgis-portal-group-browser/customElement.js +1 -1
  46. package/dist/components/arcgis-portal-group-thumbnail/customElement.js +1 -1
  47. package/dist/components/arcgis-portal-navigation/customElement.js +1 -2
  48. package/dist/components/arcgis-portal-user-avatar/customElement.js +25 -36
  49. package/dist/components/arcgis-portal-user-popup/customElement.js +27 -27
  50. package/dist/docs/api.json +1 -1
  51. package/dist/docs/docs.json +1 -1
  52. package/dist/docs/vscode.html-custom-data.json +1 -1
  53. package/dist/docs/web-types.json +1 -1
  54. package/dist/loader.js +4 -4
  55. package/dist/types/lumina.d.ts +2 -2
  56. package/dist/types/preact.d.ts +2 -2
  57. package/dist/types/react.d.ts +2 -2
  58. package/dist/types/stencil.d.ts +2 -2
  59. package/dist/types/user.d.ts +1 -1
  60. package/package.json +7 -7
  61. package/dist/cdn/5MVBQWW3.js +0 -2
  62. package/dist/cdn/76A6NXMY.js +0 -2
  63. package/dist/cdn/E4D3U6ZA.js +0 -2
  64. package/dist/cdn/J57ZXL3U.js +0 -2
  65. package/dist/cdn/OAKVCMNN.js +0 -2
  66. package/dist/cdn/QREMLELA.js +0 -2
  67. package/dist/cdn/SOJ5KMMZ.js +0 -2
  68. package/dist/cdn/V6N5BWDA.js +0 -2
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as E}from"./YVKSTDL6.js";import b from"./TGTT2CVD.js";import{a as L}from"./GAZBGDIO.js";import a from"./F3ODJVJC.js";import{a as W}from"./KYNL256E.js";import"./VMQIDO4Z.js";import"./QS3GXAIH.js";import{b as x}from"./2GBRZSEC.js";import{a as C}from"./F3M3R7X2.js";import{a as N}from"./O3RR6UMN.js";import"./BTLJZVSE.js";import"./UEL7BVMB.js";import{M as v,P as _,S as I,j as d,k as S,w}from"./BXCQOWAD.js";import"./UZLQALHY.js";export default $arcgis.t(([g,{substitute:m},,{i:O,j:T,k:M,l:K}])=>{var A=1260*1e3;function H(i,t="_blank",s=582,e=670){let n=window.screenLeft??0,o=window.screenTop??0,r=window.innerWidth||document.documentElement.clientWidth||window.screen.width,a=window.innerHeight||document.documentElement.clientHeight||window.screen.height,c=r/2-s/2+n,l=a/2-e/2+o,u=window.open(i,t,`scrollbars=no, width=${s}, height=${e}, top=${l}, left=${c}`);return u?.focus(),u}function R(i,t){let s=g.findOAuthInfo(i.url),{appId:e,locale:n="en",expiration:o=A}=s??{},r=new URLSearchParams({locale:n,client_id:t??e??"arcgisonline",response_type:"token",expiration:`${o}`,linkUserRequest:"true",showSocialLogins:"true",hideEnterpriseLogins:"false",force_login:"true",parent:window.location.origin,redirect_uri:`https://${i.portalHostname}/home/link_account_callback.html`,state:JSON.stringify({useMessage:!0})}),a=`https://${i.portalHostname}/sharing/oauth2/authorize?${r.toString()}`;H(a)}function B(i){let{config:t,credential:s,clientId:e="arcgisonline",redirectToClientUri:n=!1,displaySignoutComplete:o=!1}=i,r=new URLSearchParams({display:"iframe",client_id:e,...s.token&&{token:s.token},parent:window.location.origin,redirect_uri:`${t.baseUrl}signout_callback.html`,state:JSON.stringify({signout:!0,origin:window.location.origin,redirectToClientUri:n,displaySignoutComplete:o})}),a=`${t.restBaseUrl}oauth2/signout?${r.toString()}`,c=document.createElement("iframe");c.src=a,c.style.display="none",document.body.appendChild(c)}function D(i,t,s){let e=h(i.orgUrlKey,t),n=g.findOAuthInfo(e),{appId:o,locale:r="en",expiration:a=A}=n??{},c=y(i.provider),l=new URLSearchParams({locale:r,client_id:s??o??"arcgisonline",response_type:"token",expiration:`${a}`,parent:window.location.origin,...c==="social"&&{socialLoginProviderName:i.provider},...c==="default"&&{prepopulatedusername:i.username},force_login:"true",redirect_uri:`${e}/home/sign_in_callback.html`,state:JSON.stringify({user:i.username,server:e,portalUrl:e,origin:window.location.origin})}),u=`${U(i,t)}?${l.toString()}`;H(u)}function q({accounts:i,clientId:t="arcgisonline",usersToFilter:s=[],accountsToFilter:e=""}){let n={};return i.reduce((o,r)=>{let a={disabled:r.disabled??!1,allowed:r.clientAppAccessAllowed??!0};return o[r.username]=a,(s.includes(r.username)||s.includes(r.username.toLowerCase())||e==="org"&&r.orgUrlKey||t==="esriapps"&&r.userType!=="both")&&(a.allowed=!1),o},n),n}function z({account:i,credential:t,client_id:s,portal:e}){let n=y(i.provider),o=U(i,e),r=J(i,e),a=new URLSearchParams({client_id:s,redirect_uri:r,parent:window.location.origin,response_type:"token",force_login:"false",...t.userId&&{prepopulatedusername:t.userId},...n==="social"&&{socialLoginProviderName:i.provider},expiration:`${(t?.expires??Date.now()+A)-Date.now()}`});return`${o}?${a.toString()}`}function y(i){return F(i)?"social":i==="enterprise"?"enterprise":i.includes("oidc")?"oidc":"default"}function F(i){return["apple","facebook","github","google"].includes(i)}function U(i,t){let s=h(i.orgUrlKey,t).toLowerCase(),e=y(i.provider),n="";switch(e){case"social":n="social/";break;case"enterprise":n="saml/";break;case"oidc":n=`oidc/${i.provider.split("_")[1]}/`;break}return`${s}/sharing/rest/oauth2/${n}authorize`}function h(i,t){return i?.startsWith("https://")?i:i&&t.customBaseUrl?`https://${i}.${t.customBaseUrl}`:`https://${t.portalHostname}`}function J(i,t){return`${h(i.orgUrlKey,t)}/home/accountswitcher-callback.html`}function j({origin:i,redirectToClientUri:t,displaySignoutComplete:s}){console.log("Signout complete",i,t,s)}function G(i,t){return g.findCredential(h(i.orgUrlKey,t),i.username)}function Q(i,t){let s=G(i,t);if(s)return s;let e=h(i.orgUrlKey,t),n=`${e}/home/check_sign_in_status.html#state=${JSON.stringify({origin:window.location.origin,server:e,orgKey:e})}`;X(n,`iframe__for-${e}`)}function X(i,t){let s=document.createElement("iframe");s.src=i,s.id=t,s.style.display="none",document.body.appendChild(s)}var f=100,$=class extends v{constructor(){super(),this.messages=N({blocking:!0}),this.targetUser="",this.targetToken="",this.accountAccess={},this.linkedAccounts=[],this.loading=!1,this.signedInStatus={},this.showAssociatedAccountsWarning=!1,this.clientId="arcgisonline",this.arcgisAccountSwitch=w(),this.arcgisClose=w(),this.listenOn(window,"message",this.handleMessageEvent)}static{this.properties={linkedAccounts:16,userAccounts:16,user:16,credential:16,alertOptions:16,loading:16,signedInStatus:16,showAssociatedAccountsWarning:16,portal:0,clientId:1}}static{this.styles=C}willUpdate(t){t.has("portal")&&(this.user=this.portal?.user),(t.has("portal")||t.has("user"))&&this.portal&&this.user&&this.findLinkedUsers()}handleMessageEvent(t){if(new URL(t.origin).hostname!=="localhost"&&(t.origin.endsWith(".arcgis.com")||t.origin===window.location.origin)){if(typeof t.data=="string"){JSON.parse(t.data).type==="token_exchange"&&this.handleExchangeTokenMessage(t);return}if("type"in t.data)switch(t.data.type){case"signin":this.handleSigninMessage(t);return;case"signout":this.handleSignoutMessage(t);return;case"linkUser":this.handleLinkUserMessage(t);return;case"token_exchange":this.handleExchangeTokenMessage(t);return}if("credential"in t.data){this.handleSigninMessage(t);return}this.handleCheckSignInStatusMessage(t)}}handleSignoutMessage(t){let{error:s,signout:e,accountOrigin:n,redirectToClientUri:o,displaySignoutComplete:r}=t.data;if(s&&s!=="unknown"){console.error(s),this.showAlert("danger",this.messages.errors.signout);return}e&&(this.user=void 0,this.credential=void 0,j({origin:n,redirectToClientUri:o,displaySignoutComplete:r}))}handleSigninMessage(t){let{messages:s,clientId:e}=this,{error:n,status:o,state:r,access_token:a,ssl:c}=t.data;if(n){console.error(n),this.showAlert("danger",s.errors.signin);return}if(o==="success"){let{portal:l,user:u}=this,p=this.linkedAccounts.find(P=>P.username===r.user);p?.orgUrlKey===this.portal.urlKey&&g.findCredential(`https://${l.portalHostname}`,u?.username)?.destroy();let k={server:r.portalUrl,userId:r.user,token:a,expires:Number(t.data.expires_in)+Date.now(),ssl:c===void 0||c!=="false"};g.registerToken(k);let b=z({account:p,credential:k,client_id:e,portal:l});window.self!==window.top?window.top?.postMessage({type:"navigate",url:b}):window.location.href=b}}handleCheckSignInStatusMessage(t){let{success:s,orgKey:e,server:n,userId:o,token:r,expires:a,ssl:c}=t.data;e&&n&&s&&o&&r&&a&&c!==void 0&&(this.signedInStatus[o]={token:r,expires:a,ssl:c})}async handleLinkUserMessage(t){let{error:s,username:e,access_token:n}=t.data,{portal:o,user:r,linkedAccounts:a,messages:c}=this;if(s){if(s.toString().toLowerCase().includes("user denied your request"))return;this.showAlert("danger",c.errors.accessAccount);return}if(e===r?.username){this.showAlert("danger",c.errors.selfLink);return}if(a.find(u=>u.username===e)){this.showAlert("danger",m(c.errors.alreadyLinked,{username:e}));return}let l=await T(o,e,n);if(l?.length){this.userAccounts=l,this.targetUser=e??"",this.targetToken=n??"",this.showAssociatedAccountsWarning=!0;return}this.linkAccount(e,n)}handleExchangeTokenMessage(t){let s=typeof t.data=="string"?JSON.parse(t.data):t.data;if(!(s.type&&s.type!=="token_exchange")){if(s.error)console.error(s);else if(s.status==="success"&&this.targetUser){let{portal:e,linkedAccounts:n,targetUser:o,clientId:r}=this,a=n.find(k=>k.username===o);if(!a)return;let c=J(a,e),l=h(a.orgUrlKey,e),u=new URLSearchParams({response_type:"token",client_id:r,redirect_uri:c,state:JSON.stringify({user:a.username,portalUrl:l})}),p=`${U(a,e)}?${u.toString()}`;window.opener?(window.opener.location.href=p,window.close()):window.location.href=p}}}async findLinkedUsers(){if(this.loading=!0,!this.portal||!this.user){this.linkedAccounts=[],this.loading=!1;return}this.linkedAccounts=await O(this.portal,this.user),this.linkedAccounts.length&&(this.signedInStatus=this.linkedAccounts.filter(t=>t.orgUrlKey!==this.portal.urlKey).reduce((t,s)=>(t[s.username]=Q(s,this.portal)??null,t),{}),this.accountAccess=q({accounts:this.linkedAccounts,clientId:this.clientId})),this.loading=!1}async linkAccount(t,s){let{portal:e,user:n}=this;if(!e||!n)return;let o=await M({portal:e,user:n,targetUser:t,targetToken:s}),{messages:r}=this;if(o.error){this.showAlert("danger",m(r.errors.linkAccount,{username:t})),this.targetUser="",this.userAccounts=[];return}let a=this.userAccounts?.length?r.success.linkAccountMultiple:r.success.linkAccount;this.showAlert("success",m(a,{username:t})),this.targetUser="",this.userAccounts=[],await x(350),this.findLinkedUsers()}async unlinkAccount(t){if(!this.portal||!this.user)return;let{messages:s,portal:e,user:n}=this,{success:o}=await K({portal:e,user:n,linkedUsername:t.username});o?this.showAlert("success",m(s.success.unlinkAccount,{username:t.username})):this.showAlert("danger",m(s.errors.unlinkAccount,{username:t.username})),await this.findLinkedUsers()}startAccountLink(){R(this.portal,this.clientId)}switchAccount(t){let{portal:s,user:e,clientId:n}=this;if(!s||!e||!t)return;let o=h(e.sourceJSON.orgUrlKey??"",s),r=g.findCredential(o,e.id||e.username);r&&B({config:{baseUrl:o,restBaseUrl:`${o}/sharing/rest`},credential:r,clientId:n}),D(t,s,n)}showAlert(t,s,e){this.alertOptions={kind:t,title:e,message:s}}showUnlinkConfirmation(t){let{messages:s}=this;this.alertOptions={kind:"danger",icon:"exclamation-mark-triangle-f",title:s.unlinkTitle,message:s.unlinkWarning,actions:[{text:s.unlink,kind:"danger",clickHandler:()=>{this.alertOptions=void 0,this.unlinkAccount(t)}}]}}render(){let{linkedAccounts:t,accountAccess:s,user:e,portal:n,messages:o}=this;return!n||!e?null:d`<calcite-dialog .heading=${o.switchAccounts} scale=m width=s open modal .loading=${this.loading} outside-close-disabled @calciteDialogClose=${()=>{this.arcgisClose.emit()}}><calcite-block .heading=${o.currentAccount} .description=${o.signedInAs} expanded class="current-account-block" tabindex=-1>${L(e.id??e.username,d`<calcite-block class="current-account" .label=${n.urlKey?`${e.username}, ${n.name}`:e.username} heading-level=4 .heading=${e.username} .description=${n.urlKey?`${e.fullName??e.username}, ${n.name}`:e.fullName??e.username}><calcite-avatar slot=content-start inert .fullName=${e.fullName??void 0} .username=${e.username} .userId=${e.id} .thumbnail=${W(e,n)??void 0}></calcite-avatar></calcite-block>`)}</calcite-block>${t.length>0?d`<calcite-block .heading=${o.linkedAccounts} .description=${o.linkedAccountActions} expanded class="linked-accounts-block"><calcite-button slot=content-end icon-start=plus class="link-account-button" @click=${()=>this.startAccountLink()} .disabled=${t.length>=f}>${o.addAccount}</calcite-button><arcgis-portal-account-switcher-list .portal=${n} .linkedAccounts=${t} .accountAccess=${s} .signedInUsers=${Object.keys(this.signedInStatus).filter(r=>this.signedInStatus[r]!==null)} interactive @arcgisAccountSwitch=${r=>{this.switchAccount(r.detail.account)}} @arcgisAccountUnlink=${r=>{this.showUnlinkConfirmation(r.detail.account)}}></arcgis-portal-account-switcher-list></calcite-block>`:d`<calcite-block .heading=${o.linkedAccounts} expanded class="empty-accounts-block"><div class="empty-accounts-info"><svg class="empty-accounts-icon" width=48 height=48 viewBox="0 0 48 48" fill=none xmlns=http://www.w3.org/2000/svg>${S`<path d=${E.couple??_} fill=currentColor />`}</svg><h4>${o.emptyListTitle}</h4><p>${o.emptyList}</p><calcite-button icon-start=plus class="link-account-button" @click=${()=>this.startAccountLink()} .disabled=${t.length>=f}>${o.linkAccount}</calcite-button></div></calcite-block>`}<calcite-notice kind=info .open=${t.length>=f}><div slot=message>${o.maxAccounts}</div></calcite-notice><calcite-alert .label=${o.alertLabel} slot=alerts .autoClose=${this.alertOptions?.kind!=="danger"} auto-close-duration=fast placement=bottom .kind=${this.alertOptions?.kind} .icon=${this.alertOptions?.icon} .open=${!!this.alertOptions} @calciteAlertClose=${()=>{this.alertOptions=void 0}}>${this.alertOptions?.title&&d`<h4 slot=title class="alert-title">${this.alertOptions.title}</h4>`||""}${this.alertOptions?.message&&d`<p slot=message class="alert-message">${this.alertOptions.message}</p>`||""}${this.alertOptions?.actions?.map(r=>d`<calcite-button slot=actions-end .kind=${r.kind} .appearance=${r.appearance} @click=${r.clickHandler}>${r.text}</calcite-button>`)}</calcite-alert></calcite-dialog>${this.showAssociatedAccountsWarning&&d`<arcgis-portal-account-switcher-accounts .portal=${n} .targetUser=${this.targetUser} .accounts=${this.userAccounts??[]} @arcgisLinkAll=${()=>{this.linkAccount(this.targetUser,this.targetToken)}} @arcgisCloseDialog=${()=>{this.showAssociatedAccountsWarning=!1}}></arcgis-portal-account-switcher-accounts>`||""}`}};I("arcgis-portal-account-switcher",$);return $},"identity/IdentityManager","intl",a,b)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{a as O}from"./XEK22IDA.js";import{a as D}from"./GAZBGDIO.js";import e from"./OHEUIODH.js";import c from"./AMBLICID.js";import b from"./TGTT2CVD.js";import a from"./F3ODJVJC.js";import"./VMQIDO4Z.js";import"./QS3GXAIH.js";import"./2GBRZSEC.js";import{b as P}from"./BTLJZVSE.js";import"./UEL7BVMB.js";import{K as M,L as g,M as S,N as v,S as k,h as A,j as d,w as u}from"./BXCQOWAD.js";import"./UZLQALHY.js";export default $arcgis.t(([,{a:x,e:E},{a:R},{a:L}])=>{var y=["@","#","$"],F=400;function q(n,t){let a=null;for(let l of t){let r=l.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),s=new RegExp(`${r}"([^"\\n]*)"?$`,"u"),e=n.match(s);if(e){let c=e[0],o=n.length-c.length,h=e[1]??"";(!a||o>a.startIndex)&&(a={starter:l,mentionText:c,query:h,startIndex:o})}let i=new RegExp(`${r}[\\p{L}\\p{N}_-]+$`,"u"),m=n.match(i);if(m){let c=m[0],o=n.length-c.length,h=c.slice(l.length);(!a||o>a.startIndex)&&(a={starter:l,mentionText:c,query:h,startIndex:o})}}return a}var U=n=>y.includes(n)?n:"@",N=P(n=>{let t=[],a=async s=>await x({requester:async()=>await R(n.portal,s,{num:3}),key:"items",id:s}),l=async s=>await x({requester:async()=>await L(n.portal,{query:`title:${s}`,num:3}),key:"groups",id:s}),r=O(async(s,e)=>{n.isFetchingEntities=!0;let i=s.toLowerCase();switch(U(e)){case"@":let m=10;n.filteredItemsInfo={type:"user",items:t.filter(h=>h.username?.toLowerCase().includes(i)||h.fullName?.toLowerCase().includes(i)).slice(0,m)};break;case"#":let{result:c}=await a(i);n.filteredItemsInfo={type:"item",items:c?.results??[]};break;case"$":let{results:o}=await l(i);n.filteredItemsInfo={type:"group",items:o};break}(n.filteredItemsInfo?.items?.length??0)===0&&await n.closePopover(),n.isFetchingEntities=!1},F);return{fetchUsers:async()=>{try{let{users:s}=await E(n.portal);t=s??[]}catch(s){t=[],console.error("error fetching org users:",s)}},filterItems:r,getItemText:(s,e)=>{let i="";switch(U(e)){case"@":i=s.username;break;case"#":i=s.title??"";break;case"$":i=s.title??"";break}return i.trim()}}}),$=({id:n,label:t,selected:a,description:l,contentStart:r,onSelect:s})=>D(n,d`<calcite-list-item class=${v({selected:a})} .label=${t} .description=${l} .selected=${a} @pointerdown=${async e=>{e.preventDefault(),e.stopPropagation(),await s()}} ${g(e=>{a&&e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})})}>${r}</calcite-list-item>`),K=A`.selected{--calcite-list-background-color: var(--calcite-color-foreground-2)}.mentionable-list{max-height:13rem;overflow-y:auto;padding:.25rem;width:min(100vw,24rem)}.mentionable-list--loading{min-height:10rem}`,w=class extends S{constructor(){super(...arguments),this.calciteTextAreaRef=M(),this.mentionableEntityController=N(this),this.handleInput=t=>{let{bubbleNewValueChange:a,checkForMention:l}=this,r=t.target.value;this._value=r,a(this._value);let s=this.nativeTextAreaRef?.selectionStart??0;l(r,s)},this.handleKeyDown=t=>{if(!this.popoverOpen){this.arcgisUserMentionableTextAreaKeyDown.emit(t),this.arcgisMentionableTextAreaKeyDown.emit(t);return}switch(t.key){case"ArrowDown":t.preventDefault(),this.selectedItemIndex=Math.min(this.selectedItemIndex+1,this.filteredItems.length-1);break;case"ArrowUp":t.preventDefault(),this.selectedItemIndex=Math.max(this.selectedItemIndex-1,0);break;case"Enter":t.preventDefault(),this.selectItem(this.filteredItems[this.selectedItemIndex]);break;case"Escape":t.preventDefault(),this.closePopover.bind(this)();break}},this.handleClosePopover=()=>{this.popoverOpen=!1,this.currentMentionQuery="",this.selectedItemIndex=0,this.currentStarter=null},this.bubbleNewValueChange=t=>{this.arcgisUserMentionableTextAreaChange.emit(t),this.arcgisMentionableTextAreaChange.emit(t)},this.checkForMention=(t,a)=>{let l=t.substring(0,a),r=q(l,this.starters??y);if(r){let{starter:s}=r;this.currentStarter=s,this.filterMentionItems(r),this.popoverOpen=!0;return}this.handleClosePopover()},this.filterMentionItems=t=>{let{mentionText:a,query:l,starter:r,startIndex:s}=t;this.currentMentionQuery=a,this.mentionStartPosition=s;let e=l.toLowerCase();this.mentionableEntityController.filterItems(e,r),this.selectedItemIndex=0},this.popoverOpen=!1,this.currentMentionQuery="",this.mentionStartPosition=0,this.selectedItemIndex=0,this.currentStarter=null,this._value="",this.filteredItemsInfo=null,this.isFetchingEntities=!1,this.popoverPlacement="bottom-start",this.disabled=!1,this.scale="m",this.rows=3,this.starters=y,this.readOnly=!1,this.arcgisMentionableSelectedIndexChange=u(),this.arcgisMentionableTextAreaChange=u(),this.arcgisMentionableTextAreaKeyDown=u(),this.arcgisUserMentionableTextAreaChange=u(),this.arcgisUserMentionableTextAreaKeyDown=u(),this.renderItemInfo=()=>{let{filteredItemsInfo:t,selectedItemIndex:a,portal:l}=this;if(!t)return null;let{items:r,type:s}=t;switch(s){case"user":return r.map((e,i)=>$({id:e.id,label:`@${e.username}`,description:e.fullName,selected:i===a,contentStart:d`<arcgis-portal-user-avatar slot=content-start .user=${e} .portal=${l} scale=m></arcgis-portal-user-avatar>`,onSelect:async()=>await this.selectItem(e)}));case"item":return r.map((e,i)=>$({id:e.id??`item-${i}`,label:`#${e.title}`,description:e.id??void 0,selected:i===a,onSelect:async()=>await this.selectItem(e),contentStart:d`<calcite-avatar slot=content-start .fullName=${e.title??void 0} .thumbnail=${e.thumbnailUrl??void 0} scale=m></calcite-avatar>`}));case"group":return r.map((e,i)=>$({id:e.id??`group-${i}`,label:`${e.title}`,description:e.id??void 0,selected:i===a,onSelect:async()=>await this.selectItem(e),contentStart:d`<calcite-avatar slot=content-start .fullName=${e.title??void 0} .thumbnail=${e.thumbnailUrl??void 0} scale=m></calcite-avatar>`}))}}}static{this.properties={popoverOpen:16,currentMentionQuery:16,mentionStartPosition:16,selectedItemIndex:16,currentStarter:16,_value:16,filteredItemsInfo:16,isFetchingEntities:16,popoverListLabel:1,popoverPlacement:1,disabled:5,portal:0,user:0,scale:1,value:1,maxLength:9,rows:9,starters:0,placeholder:1,readOnly:5}}static{this.styles=K}get filteredItems(){return this.filteredItemsInfo?.items??[]}async closePopover(){this.handleClosePopover()}async focusTextArea(){await this.calciteTextAreaRef.value?.setFocus()}async selectItem(t){let{currentStarter:a,_value:l,mentionStartPosition:r,currentMentionQuery:s,handleClosePopover:e,calciteTextAreaRef:i,nativeTextAreaRef:m,bubbleNewValueChange:c}=this;if(!t||!a)return;let o=this.mentionableEntityController.getItemText(t,a).replaceAll('"',"").trim(),h=/\s/u.test(o)?`${a}"${o}"`:`${a}${o}`,f=(l??"").substring(0,r),p=(l??"").substring(r+s.length),I=`${f}${h} ${p}`;this._value=I,c(this._value);let b=r+h.length+1;e(),await this.updateComplete,i.value?.setFocus(),m&&(m.selectionEnd=b)}willUpdate(t){t.has("value")&&(this._value=this.value??""),t.has("selectedItemIndex")&&this.arcgisMentionableSelectedIndexChange.emit(this.selectedItemIndex)}loaded(){this.updateComplete.then(()=>{let t=this.calciteTextAreaRef.value?.shadowRoot?.querySelector("textarea");t&&(this.nativeTextAreaRef=t)}),this.mentionableEntityController.fetchUsers()}render(){let{popoverPlacement:t,scale:a,_value:l,maxLength:r,rows:s,placeholder:e,readOnly:i,popoverOpen:m,closePopover:c,handleInput:o,handleKeyDown:h,disabled:f,isFetchingEntities:p,filteredItemsInfo:I,renderItemInfo:b,popoverListLabel:C}=this,T=this.calciteTextAreaRef.value,_=I?.items??[];return d`<calcite-text-area .placeholder=${e} .value=${l} .maxLength=${r} .rows=${s} .scale=${a} .readOnly=${i} .disabled=${f} @blur=${c} @calciteTextAreaInput=${o} @keydown=${h} ${g(this.calciteTextAreaRef)}></calcite-text-area>${T&&d`<calcite-popover .open=${m} .placement=${t} class="mention-popover" .label=${C} .referenceElement=${T} trigger-disabled pointer-disabled focus-trap-disabled><div class=${v({"mentionable-list":!0,"mentionable-list--loading":p})}>${p&&d`<calcite-scrim .loading=${p}></calcite-scrim>`||""}${_.length>0&&d`<calcite-list .label=${C}>${b()}</calcite-list>`||""}</div></calcite-popover>`||""}`}};k("arcgis-portal-mentionable-text-area",w);return w},a,b,c,e)
2
+ import{a as O}from"./XEK22IDA.js";import e from"./OHEUIODH.js";import c from"./AMBLICID.js";import b from"./TGTT2CVD.js";import{a as E}from"./GAZBGDIO.js";import a from"./F3ODJVJC.js";import"./VMQIDO4Z.js";import"./QS3GXAIH.js";import"./2GBRZSEC.js";import{b as L}from"./BTLJZVSE.js";import"./UEL7BVMB.js";import{K as M,L as g,M as S,N as v,S as k,h as A,j as d,w as u}from"./BXCQOWAD.js";import"./UZLQALHY.js";export default $arcgis.t(([,{a:x,e:P},{a:D},{a:R}])=>{var y=["@","#","$"],F=400;function q(n,t){let a=null;for(let l of t){let r=l.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),s=new RegExp(`${r}"([^"\\n]*)"?$`,"u"),e=n.match(s);if(e){let c=e[0],o=n.length-c.length,h=e[1]??"";(!a||o>a.startIndex)&&(a={starter:l,mentionText:c,query:h,startIndex:o})}let i=new RegExp(`${r}[\\p{L}\\p{N}_-]+$`,"u"),m=n.match(i);if(m){let c=m[0],o=n.length-c.length,h=c.slice(l.length);(!a||o>a.startIndex)&&(a={starter:l,mentionText:c,query:h,startIndex:o})}}return a}var U=n=>y.includes(n)?n:"@",N=L(n=>{let t=[],a=async s=>await x({requester:async()=>await D(n.portal,s,{num:3}),key:"items",id:s}),l=async s=>await x({requester:async()=>await R(n.portal,{query:`title:${s}`,num:3}),key:"groups",id:s}),r=O(async(s,e)=>{n.isFetchingEntities=!0;let i=s.toLowerCase();switch(U(e)){case"@":let m=10;n.filteredItemsInfo={type:"user",items:t.filter(h=>h.username?.toLowerCase().includes(i)||h.fullName?.toLowerCase().includes(i)).slice(0,m)};break;case"#":let{result:c}=await a(i);n.filteredItemsInfo={type:"item",items:c?.results??[]};break;case"$":let{results:o}=await l(i);n.filteredItemsInfo={type:"group",items:o};break}(n.filteredItemsInfo?.items?.length??0)===0&&await n.closePopover(),n.isFetchingEntities=!1},F);return{fetchUsers:async()=>{try{let{users:s}=await P(n.portal);t=s??[]}catch(s){t=[],console.error("error fetching org users:",s)}},filterItems:r,getItemText:(s,e)=>{let i="";switch(U(e)){case"@":i=s.username;break;case"#":i=s.title??"";break;case"$":i=s.title??"";break}return i.trim()}}}),$=({id:n,label:t,selected:a,description:l,contentStart:r,onSelect:s})=>E(n,d`<calcite-list-item class=${v({selected:a})} .label=${t} .description=${l} .selected=${a} @pointerdown=${async e=>{e.preventDefault(),e.stopPropagation(),await s()}} ${g(e=>{a&&e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})})}>${r}</calcite-list-item>`),K=A`.selected{--calcite-list-background-color: var(--calcite-color-foreground-2)}.mentionable-list{max-height:13rem;overflow-y:auto;padding:.25rem;width:min(100vw,24rem)}.mentionable-list--loading{min-height:10rem}`,w=class extends S{constructor(){super(...arguments),this.calciteTextAreaRef=M(),this.mentionableEntityController=N(this),this.handleInput=t=>{let{bubbleNewValueChange:a,checkForMention:l}=this,r=t.target.value;this._value=r,a(this._value);let s=this.nativeTextAreaRef?.selectionStart??0;l(r,s)},this.handleKeyDown=t=>{if(!this.popoverOpen){this.arcgisUserMentionableTextAreaKeyDown.emit(t),this.arcgisMentionableTextAreaKeyDown.emit(t);return}switch(t.key){case"ArrowDown":t.preventDefault(),this.selectedItemIndex=Math.min(this.selectedItemIndex+1,this.filteredItems.length-1);break;case"ArrowUp":t.preventDefault(),this.selectedItemIndex=Math.max(this.selectedItemIndex-1,0);break;case"Enter":t.preventDefault(),this.selectItem(this.filteredItems[this.selectedItemIndex]);break;case"Escape":t.preventDefault(),this.closePopover.bind(this)();break}},this.handleClosePopover=()=>{this.popoverOpen=!1,this.currentMentionQuery="",this.selectedItemIndex=0,this.currentStarter=null},this.bubbleNewValueChange=t=>{this.arcgisUserMentionableTextAreaChange.emit(t),this.arcgisMentionableTextAreaChange.emit(t)},this.checkForMention=(t,a)=>{let l=t.substring(0,a),r=q(l,this.starters??y);if(r){let{starter:s}=r;this.currentStarter=s,this.filterMentionItems(r),this.popoverOpen=!0;return}this.handleClosePopover()},this.filterMentionItems=t=>{let{mentionText:a,query:l,starter:r,startIndex:s}=t;this.currentMentionQuery=a,this.mentionStartPosition=s;let e=l.toLowerCase();this.mentionableEntityController.filterItems(e,r),this.selectedItemIndex=0},this.popoverOpen=!1,this.currentMentionQuery="",this.mentionStartPosition=0,this.selectedItemIndex=0,this.currentStarter=null,this._value="",this.filteredItemsInfo=null,this.isFetchingEntities=!1,this.popoverPlacement="bottom-start",this.disabled=!1,this.scale="m",this.rows=3,this.starters=y,this.readOnly=!1,this.arcgisMentionableSelectedIndexChange=u(),this.arcgisMentionableTextAreaChange=u(),this.arcgisMentionableTextAreaKeyDown=u(),this.arcgisUserMentionableTextAreaChange=u(),this.arcgisUserMentionableTextAreaKeyDown=u(),this.renderItemInfo=()=>{let{filteredItemsInfo:t,selectedItemIndex:a,portal:l}=this;if(!t)return null;let{items:r,type:s}=t;switch(s){case"user":return r.map((e,i)=>$({id:e.id,label:`@${e.username}`,description:e.fullName,selected:i===a,contentStart:d`<arcgis-portal-user-avatar slot=content-start .user=${e} .portal=${l} scale=m></arcgis-portal-user-avatar>`,onSelect:async()=>await this.selectItem(e)}));case"item":return r.map((e,i)=>$({id:e.id??`item-${i}`,label:`#${e.title}`,description:e.id??void 0,selected:i===a,onSelect:async()=>await this.selectItem(e),contentStart:d`<calcite-avatar slot=content-start .fullName=${e.title??void 0} .thumbnail=${e.thumbnailUrl??void 0} scale=m></calcite-avatar>`}));case"group":return r.map((e,i)=>$({id:e.id??`group-${i}`,label:`${e.title}`,description:e.id??void 0,selected:i===a,onSelect:async()=>await this.selectItem(e),contentStart:d`<calcite-avatar slot=content-start .fullName=${e.title??void 0} .thumbnail=${e.thumbnailUrl??void 0} scale=m></calcite-avatar>`}))}}}static{this.properties={popoverOpen:16,currentMentionQuery:16,mentionStartPosition:16,selectedItemIndex:16,currentStarter:16,_value:16,filteredItemsInfo:16,isFetchingEntities:16,popoverListLabel:1,popoverPlacement:1,disabled:5,portal:0,user:0,scale:1,value:1,maxLength:9,rows:9,starters:0,placeholder:1,readOnly:5}}static{this.styles=K}get filteredItems(){return this.filteredItemsInfo?.items??[]}async closePopover(){this.handleClosePopover()}async focusTextArea(){await this.calciteTextAreaRef.value?.setFocus()}async selectItem(t){let{currentStarter:a,_value:l,mentionStartPosition:r,currentMentionQuery:s,handleClosePopover:e,calciteTextAreaRef:i,nativeTextAreaRef:m,bubbleNewValueChange:c}=this;if(!t||!a)return;let o=this.mentionableEntityController.getItemText(t,a).replaceAll('"',"").trim(),h=/\s/u.test(o)?`${a}"${o}"`:`${a}${o}`,f=(l??"").substring(0,r),p=(l??"").substring(r+s.length),I=`${f}${h} ${p}`;this._value=I,c(this._value);let b=r+h.length+1;e(),await this.updateComplete,i.value?.setFocus(),m&&(m.selectionEnd=b)}willUpdate(t){t.has("value")&&(this._value=this.value??""),t.has("selectedItemIndex")&&this.arcgisMentionableSelectedIndexChange.emit(this.selectedItemIndex)}loaded(){this.updateComplete.then(()=>{let t=this.calciteTextAreaRef.value?.shadowRoot?.querySelector("textarea");t&&(this.nativeTextAreaRef=t)}),this.mentionableEntityController.fetchUsers()}render(){let{popoverPlacement:t,scale:a,_value:l,maxLength:r,rows:s,placeholder:e,readOnly:i,popoverOpen:m,closePopover:c,handleInput:o,handleKeyDown:h,disabled:f,isFetchingEntities:p,filteredItemsInfo:I,renderItemInfo:b,popoverListLabel:C}=this,T=this.calciteTextAreaRef.value,_=I?.items??[];return d`<calcite-text-area .placeholder=${e} .value=${l} .maxLength=${r} .rows=${s} .scale=${a} .readOnly=${i} .disabled=${f} @blur=${c} @calciteTextAreaInput=${o} @keydown=${h} ${g(this.calciteTextAreaRef)}></calcite-text-area>${T&&d`<calcite-popover .open=${m} .placement=${t} class="mention-popover" .label=${C} .referenceElement=${T} trigger-disabled pointer-disabled focus-trap-disabled><div class=${v({"mentionable-list":!0,"mentionable-list--loading":p})}>${p&&d`<calcite-scrim .loading=${p}></calcite-scrim>`||""}${_.length>0&&d`<calcite-list .label=${C}>${b()}</calcite-list>`||""}</div></calcite-popover>`||""}`}};k("arcgis-portal-mentionable-text-area",w);return w},a,b,c,e)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import a from"./LRADZ46B.js";import"./XEK22IDA.js";import"./VMQIDO4Z.js";import"./QS3GXAIH.js";import"./2GBRZSEC.js";import{a as u}from"./O3RR6UMN.js";import"./BTLJZVSE.js";import"./UEL7BVMB.js";import{K as l,L as c,M as d,S as v,j as s,w as n}from"./BXCQOWAD.js";import"./UZLQALHY.js";export default $arcgis.t(([{a:p,b:m,c:f}])=>{var a=class extends d{constructor(){super(),this.messages=u({blocking:!0}),this.buttonRef=l(),this.favoriteRequestId=0,this.handleFavoriteUpdate=t=>{let i=f(t,this.item?.id??void 0);i&&(this.isFavorite=i.favorite)},this.handleToggleFavorite=async t=>{t.preventDefault(),t.stopPropagation();let{item:i,portal:o,user:r}=this;if(!i.id||!o||!r)return;let F={id:i.id,access:i.access},h=this.isFavorite,e=!h;this.isFavorite=e;let{updated:g}=await m({currentFavorite:h,item:F,portal:o,user:r});if(!g){this.isFavorite=!e;return}this.arcgisItemFavoriteUpdate.emit({id:i.id,favorite:e})},this.isFavorite=!1,this.isFavoriteLoaded=!1,this.width="full",this.iconOnly=!1,this.scale="m",this.showTooltip=!1,this.arcgisItemFavoriteUpdate=n(),this.listenOn(window,"arcgisItemFavoriteUpdate",this.handleFavoriteUpdate)}static{this.properties={isFavorite:16,isFavoriteLoaded:16,item:0,portal:0,user:0,width:1,iconOnly:5,scale:1,showTooltip:5}}async setFocus(){await this.buttonRef.value?.setFocus()}willUpdate(t){(t.has("item")||t.has("portal")||t.has("user"))&&(this.isFavoriteLoaded=!1,this.refreshFavorite())}async refreshFavorite(){if(!this.item.id||!this.portal||!this.user){this.isFavorite=!1;return}let t=++this.favoriteRequestId,i=await p(this.item.id,this.portal,this.user);t===this.favoriteRequestId&&(this.isFavorite=i,this.isFavoriteLoaded=!0)}render(){if(!this.isFavoriteLoaded)return null;let t=this.isFavorite?this.messages.remove:this.messages.add;return s`<calcite-button .width=${this.iconOnly?"auto":this.width} .scale=${this.scale} .appearance=${this.iconOnly?"transparent":"outline-fill"} kind=neutral .iconStart=${this.isFavorite?"star-f":"star"} .ariaLabel=${this.iconOnly?t:void 0} @click=${this.handleToggleFavorite} ${c(this.buttonRef)}>${this.iconOnly?null:t}</calcite-button>${this.showTooltip?s`<calcite-tooltip .referenceElement=${this.buttonRef.value}>${t}</calcite-tooltip>`:null}`}};v("arcgis-portal-item-favorite",a);return a},a)
2
+ import a from"./NQQLTGIK.js";import"./XEK22IDA.js";import"./VMQIDO4Z.js";import"./QS3GXAIH.js";import"./2GBRZSEC.js";import{a as u}from"./O3RR6UMN.js";import"./BTLJZVSE.js";import"./UEL7BVMB.js";import{K as l,L as c,M as d,S as v,j as s,w as n}from"./BXCQOWAD.js";import"./UZLQALHY.js";export default $arcgis.t(([{a:p,b:m,c:f}])=>{var a=class extends d{constructor(){super(),this.messages=u({blocking:!0}),this.buttonRef=l(),this.favoriteRequestId=0,this.handleFavoriteUpdate=t=>{let i=f(t,this.item?.id??void 0);i&&(this.isFavorite=i.favorite)},this.handleToggleFavorite=async t=>{t.preventDefault(),t.stopPropagation();let{item:i,portal:o,user:r}=this;if(!i.id||!o||!r)return;let F={id:i.id,access:i.access},h=this.isFavorite,e=!h;this.isFavorite=e;let{updated:g}=await m({currentFavorite:h,item:F,portal:o,user:r});if(!g){this.isFavorite=!e;return}this.arcgisItemFavoriteUpdate.emit({id:i.id,favorite:e})},this.isFavorite=!1,this.isFavoriteLoaded=!1,this.width="full",this.iconOnly=!1,this.scale="m",this.showTooltip=!1,this.arcgisItemFavoriteUpdate=n(),this.listenOn(window,"arcgisItemFavoriteUpdate",this.handleFavoriteUpdate)}static{this.properties={isFavorite:16,isFavoriteLoaded:16,item:0,portal:0,user:0,width:1,iconOnly:5,scale:1,showTooltip:5}}async setFocus(){await this.buttonRef.value?.setFocus()}willUpdate(t){(t.has("item")||t.has("portal")||t.has("user"))&&(this.isFavoriteLoaded=!1,this.refreshFavorite())}async refreshFavorite(){if(!this.item.id||!this.portal||!this.user){this.isFavorite=!1;return}let t=++this.favoriteRequestId,i=await p(this.item.id,this.portal,this.user);t===this.favoriteRequestId&&(this.isFavorite=i,this.isFavoriteLoaded=!0)}render(){if(!this.isFavoriteLoaded)return null;let t=this.isFavorite?this.messages.remove:this.messages.add;return s`<calcite-button .width=${this.iconOnly?"auto":this.width} .scale=${this.scale} .appearance=${this.iconOnly?"transparent":"outline-fill"} kind=neutral .iconStart=${this.isFavorite?"star-f":"star"} .ariaLabel=${this.iconOnly?t:void 0} @click=${this.handleToggleFavorite} ${c(this.buttonRef)}>${this.iconOnly?null:t}</calcite-button>${this.showTooltip?s`<calcite-tooltip .referenceElement=${this.buttonRef.value}>${t}</calcite-tooltip>`:null}`}};v("arcgis-portal-item-favorite",a);return a},a)