@arcgis/portal-components 5.2.0-next.4 → 5.2.0-next.6
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.
- package/dist/cdn/DFTUMKSN.js +3 -0
- package/dist/cdn/G6QT6MYP.js +65 -0
- package/dist/cdn/{GNOZCQ34.js → L3BQK62N.js} +1 -1
- package/dist/cdn/{5DPWJ7DI.js → MX3F5ZCL.js} +1 -1
- package/dist/cdn/{N6G6Z7BF.js → T25WZ6OL.js} +47 -47
- package/dist/cdn/{2UUZHENH.js → UPEVTVNZ.js} +1 -1
- package/dist/cdn/{CI5ENGVT.js → X5NBQPTM.js} +1 -1
- package/dist/cdn/YVJRXWM3.js +3 -0
- package/dist/cdn/assets/portal-user-popup/t9n/messages.en.json +1 -0
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/user2.js +26 -25
- package/dist/components/arcgis-portal-ai-assistant/customElement.js +2 -2
- package/dist/components/arcgis-portal-ai-assistant-interrupt/customElement.js +10 -10
- package/dist/components/arcgis-portal-user-popup/customElement.d.ts +111 -0
- package/dist/components/arcgis-portal-user-popup/customElement.js +231 -0
- package/dist/components/arcgis-portal-user-popup/index.d.ts +1 -0
- package/dist/components/arcgis-portal-user-popup/index.js +5 -0
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/loader.js +4 -3
- package/dist/types/lumina.d.ts +7 -0
- package/dist/types/preact.d.ts +8 -0
- package/dist/types/react.d.ts +9 -0
- package/dist/types/stencil.d.ts +7 -0
- package/dist/types/tracking.d.ts +10 -0
- package/dist/types/user.d.ts +2 -2
- package/package.json +5 -5
- package/dist/cdn/SM4GWLRA.js +0 -66
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import { c as A } from "../../chunks/runtime.js";
|
|
3
|
+
import { LitElement as B, createEvent as y, safeClassMap as k, safeStyleMap as L } from "@arcgis/lumina";
|
|
4
|
+
import { css as R, html as u } from "lit";
|
|
5
|
+
import { createRef as U, ref as I } from "lit/directives/ref.js";
|
|
6
|
+
import { u as z } from "../../chunks/useT9n.js";
|
|
7
|
+
import { a as _, r as $, f as w } from "../../chunks/user2.js";
|
|
8
|
+
import { g as T } from "../../chunks/user.js";
|
|
9
|
+
import { Sanitizer as H } from "@esri/arcgis-html-sanitizer";
|
|
10
|
+
import { g as P } from "../../chunks/portal.js";
|
|
11
|
+
function C(e) {
|
|
12
|
+
const t = /(https?:\/\/[^\s]+)/gu;
|
|
13
|
+
return e?.replace(t, (r) => `<a href="${r}" target="_blank">${r}</a>`);
|
|
14
|
+
}
|
|
15
|
+
function M(e) {
|
|
16
|
+
return e?.replace(/(?:\r)/gu, " ").replace(/(?:\n)/gu, " ");
|
|
17
|
+
}
|
|
18
|
+
function q(e) {
|
|
19
|
+
return e?.replace(/(?: )/gu, "\r").replace(/(?: )/gu, `
|
|
20
|
+
`);
|
|
21
|
+
}
|
|
22
|
+
function S(e) {
|
|
23
|
+
return e?.replace(/ | | |\r\n|\r|\n/gu, "<br>");
|
|
24
|
+
}
|
|
25
|
+
function E(e) {
|
|
26
|
+
return S(M(C(q(e))));
|
|
27
|
+
}
|
|
28
|
+
function F(e) {
|
|
29
|
+
return e?.endsWith("/") ? e.slice(0, e.length - 1) : e;
|
|
30
|
+
}
|
|
31
|
+
const G = R`:host{display:flex}.button{display:flex;align-items:center;max-width:100%;cursor:pointer;white-space:normal;border-style:none;padding:0;font-size:.75rem;color:var(--calcite-color-text-2);outline:2px solid transparent;outline-offset:2px;transition-property:all;outline-color:transparent;background:transparent;font-family:inherit;line-height:1.5;&:focus{outline:2px solid var(--calcite-color-brand);outline-offset:2px}}.button--outline{box-sizing:border-box;width:100%;padding:.5rem .75rem;transition-property:all;border:1px solid var(--calcite-color-border-3);&:hover{box-shadow:inset 0 0 0 1px var(--calcite-color-foreground-3)}}.name{overflow:hidden;white-space:nowrap;margin-inline-start:.5rem;text-overflow:ellipsis}.popover__wrapper{background-color:var(--calcite-color-foreground-1);width:min(32rem,80vw)}.popover__header{padding:1.25rem 1rem}.popover__avatar{max-width:100%}.popover__content{padding:.5rem 1rem 1.25rem}.popover__description{margin:0;overflow:auto;padding:0;padding-bottom:1rem;font-size:.875rem;color:var(--calcite-color-text-2);max-height:21.25rem}.popover__fade{position:relative;z-index:10;margin-bottom:.25rem;display:block;height:1rem;width:100%;background:linear-gradient(to bottom,transparent,var(--calcite-color-foreground-1) 100%);margin-top:-1rem}.popover__buttons{display:grid;grid-auto-flow:column;grid-gap:.5rem}.popover__buttons--no-description{padding-top:1rem}.popover__button{min-width:0px}.popover__loader{--calcite-loader-padding: 0}`;
|
|
32
|
+
function O(e) {
|
|
33
|
+
return new H().sanitize(e);
|
|
34
|
+
}
|
|
35
|
+
function D(e) {
|
|
36
|
+
const t = O(e), r = document.createElement("div");
|
|
37
|
+
return r.innerHTML = t, r.textContent || r.innerText || "";
|
|
38
|
+
}
|
|
39
|
+
async function J(e, t, r, s, o) {
|
|
40
|
+
const n = e.portal?.portalHostname || s?.portalHostname || s?.restUrl?.replace("/sharing/rest", ""), a = o ? `https://www.arcgis.com/sharing/rest/portals/${t}` : `https://${n}/sharing/rest/portals/${t}`;
|
|
41
|
+
if (!n && !o)
|
|
42
|
+
return null;
|
|
43
|
+
const i = o ? { disableIdentityLookup: !0, addTokenManually: !1 } : {}, l = await $({ url: a, portal: s, options: i }), { urlKey: m, thumbnail: c, customBaseUrl: p } = l, f = `https://${m}.${p}/`, h = c ? `${f}sharing/rest/portals/self/resources/${c}` : null;
|
|
44
|
+
let d = "", v = "";
|
|
45
|
+
try {
|
|
46
|
+
const g = await $({
|
|
47
|
+
url: `${a}/resources/localizedOrgProperties`,
|
|
48
|
+
portal: s,
|
|
49
|
+
params: { start: 1, num: 100 },
|
|
50
|
+
options: i
|
|
51
|
+
});
|
|
52
|
+
if (g) {
|
|
53
|
+
const b = g[r] || g.default;
|
|
54
|
+
d = b.name, v = b.description;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
name: d || l.name,
|
|
60
|
+
description: D(v || l.description),
|
|
61
|
+
url: `${f}home/`,
|
|
62
|
+
thumbnail: h
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async function K(e, t, r, s) {
|
|
66
|
+
const o = e.sourceJSON?.orgId ?? e.portal?.id ?? r?.id;
|
|
67
|
+
return await _({
|
|
68
|
+
requester: async () => await J(e, o, t, r, s),
|
|
69
|
+
key: "verified",
|
|
70
|
+
id: o
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const N = (e) => (
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
75
|
+
e?.sourceJSON?.contentStatus === "public_authoritative"
|
|
76
|
+
);
|
|
77
|
+
async function V(e, t, r, s) {
|
|
78
|
+
if (N(e)) {
|
|
79
|
+
const o = e.owner || "", n = await K(e, r, t, s);
|
|
80
|
+
if (!n)
|
|
81
|
+
return await w(o, t, s);
|
|
82
|
+
const { description: a, name: i, thumbnail: l, url: m } = n;
|
|
83
|
+
return {
|
|
84
|
+
description: a ? O(a) : "",
|
|
85
|
+
fullName: i,
|
|
86
|
+
username: o,
|
|
87
|
+
thumbnail: l,
|
|
88
|
+
id: e.portal.id,
|
|
89
|
+
url: m
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return await w(e.owner || "", t, s);
|
|
93
|
+
}
|
|
94
|
+
async function W(e, t, r) {
|
|
95
|
+
const s = r ? "https://www.arcgis.com/sharing/rest/" : P(t), o = r ? { disableIdentityLookup: !0, addTokenManually: !1 } : {};
|
|
96
|
+
return await _({
|
|
97
|
+
requester: async () => await $({
|
|
98
|
+
url: `${s}community/groups`,
|
|
99
|
+
portal: t,
|
|
100
|
+
params: {
|
|
101
|
+
q: `(owner:"${e}")`,
|
|
102
|
+
num: 100
|
|
103
|
+
},
|
|
104
|
+
options: o
|
|
105
|
+
}),
|
|
106
|
+
key: "userGroups",
|
|
107
|
+
id: e
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async function j(e, t, r) {
|
|
111
|
+
const s = r ? "https://www.arcgis.com/sharing/rest/" : P(t), o = r ? { disableIdentityLookup: !0, addTokenManually: !1 } : {};
|
|
112
|
+
return await _({
|
|
113
|
+
requester: async () => (await $({
|
|
114
|
+
url: `${s}search`,
|
|
115
|
+
portal: t,
|
|
116
|
+
params: {
|
|
117
|
+
q: `(owner:"${e}") -typekeywords:"recyclebin"`,
|
|
118
|
+
num: 1
|
|
119
|
+
},
|
|
120
|
+
options: o
|
|
121
|
+
})).total,
|
|
122
|
+
key: "userItemsTotal",
|
|
123
|
+
id: e
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function x({
|
|
127
|
+
baseUrl: e,
|
|
128
|
+
user: t,
|
|
129
|
+
type: r
|
|
130
|
+
}) {
|
|
131
|
+
const s = F(e), o = encodeURIComponent(t.username || "");
|
|
132
|
+
return o ? `${s}/${r}.html?user=${o}` : `${s}/${r}.html`;
|
|
133
|
+
}
|
|
134
|
+
class Q extends B {
|
|
135
|
+
constructor() {
|
|
136
|
+
super(...arguments), this.messages = z({ blocking: !0 }), this.buttonRef = U(), this.popoverRef = U(), this.isPopoverOpen = !1, this.scale = "m", this.showAvatar = !0, this.showName = !0, this.showUsername = !1, this.appearance = "transparent", this.arcgisUserPopupInternalUIAction = y(), this.arcgisUserPopupClose = y();
|
|
137
|
+
}
|
|
138
|
+
static {
|
|
139
|
+
this.properties = { itemUserInfo: 16, groups: 16, total: 16, isPopoverOpen: 16, user: 0, username: 1, fullName: 1, item: 0, scale: 3, portal: 0, baseUrl: 1, underline: 5, showAvatar: 5, showName: 5, showUsername: 5, wrap: 5, appearance: 1, zIndex: 9, avatarAriaHidden: 5, checkOnline: 5 };
|
|
140
|
+
}
|
|
141
|
+
static {
|
|
142
|
+
this.styles = G;
|
|
143
|
+
}
|
|
144
|
+
async setFocus() {
|
|
145
|
+
this.buttonRef.value?.focus();
|
|
146
|
+
}
|
|
147
|
+
async openPopup() {
|
|
148
|
+
this.buttonRef.value?.click();
|
|
149
|
+
}
|
|
150
|
+
connectedCallback() {
|
|
151
|
+
super.connectedCallback(), this.init();
|
|
152
|
+
}
|
|
153
|
+
updated(t) {
|
|
154
|
+
t.has("isPopoverOpen") && this.isPopoverOpen && this.setPopoverOpen(!0);
|
|
155
|
+
}
|
|
156
|
+
get resolvedBaseUrl() {
|
|
157
|
+
return this.baseUrl || `${this.portal.url}/home`;
|
|
158
|
+
}
|
|
159
|
+
async init() {
|
|
160
|
+
const { item: t, username: r, portal: s, fullName: o, messages: n } = this;
|
|
161
|
+
if (!(!n._lang || !s)) {
|
|
162
|
+
if (t) {
|
|
163
|
+
this.itemUserInfo = await V(t, s, n._lang, this.checkOnline);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (r) {
|
|
167
|
+
const a = await w(r, s, this.checkOnline);
|
|
168
|
+
!a.fullName && o && (a.fullName = o), this.itemUserInfo = a;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async fetchItemsAndGroups() {
|
|
173
|
+
const { user: t, itemUserInfo: r, item: s, portal: o, username: n, checkOnline: a } = this, i = n || t?.username || s?.owner || r?.username;
|
|
174
|
+
if (!(!i || !o)) {
|
|
175
|
+
if (!this.groups) {
|
|
176
|
+
const l = await W(i, o, a);
|
|
177
|
+
this.groups = l;
|
|
178
|
+
}
|
|
179
|
+
this.total = await j(i, o, a);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
setPopoverOpen(t) {
|
|
183
|
+
requestAnimationFrame(() => {
|
|
184
|
+
this.popoverRef.value && (this.popoverRef.value.open = t);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
openLink(t, r) {
|
|
188
|
+
t.preventDefault(), window.open(r, "_blank");
|
|
189
|
+
}
|
|
190
|
+
renderOrgButtons(t) {
|
|
191
|
+
const { messages: r } = this, o = (t.url || this.resolvedBaseUrl).replace(/\/$/u, "");
|
|
192
|
+
return u`<calcite-button appearance=outline-fill kind=neutral .href=${o} target=_blank @click=${(n) => this.openLink(n, o)}>${r.homepage}</calcite-button><calcite-button appearance=outline-fill kind=neutral .href=${`${o}/gallery.html`} target=_blank @click=${(n) => this.openLink(n, `${o}/gallery.html`)}>${r.gallery}</calcite-button>`;
|
|
193
|
+
}
|
|
194
|
+
renderUserButtons(t) {
|
|
195
|
+
const { total: r, groups: s, messages: o } = this, n = t.username || "";
|
|
196
|
+
if (typeof r != "number" || !s)
|
|
197
|
+
return u`<calcite-loader .label=${o.loadingUserInformation} scale=s class="popover__loader"></calcite-loader>`;
|
|
198
|
+
const i = x({ baseUrl: this.resolvedBaseUrl, user: { username: n }, type: "groups" }), l = x({ baseUrl: this.resolvedBaseUrl, user: { username: n }, type: "content" }), m = `${this.resolvedBaseUrl.replace(/\/$/u, "")}/user.html?user=${encodeURIComponent(n)}`;
|
|
199
|
+
return u`${!!s.total && u`<calcite-button class="popover__button" appearance=outline-fill kind=neutral .href=${i} target=_blank @click=${(c) => {
|
|
200
|
+
this.openLink(c, i), this.arcgisUserPopupInternalUIAction.emit({ category: "profile popup", action: "view all groups" });
|
|
201
|
+
}}>${o.groups.replace("${number}", new Intl.NumberFormat(o._lang).format(s.total))}</calcite-button>` || ""}${!!r && u`<calcite-button class="popover__button" appearance=outline-fill kind=neutral .href=${l} target=_blank @click=${(c) => {
|
|
202
|
+
this.openLink(c, l), this.arcgisUserPopupInternalUIAction.emit({ category: "profile popup", action: "view all content" });
|
|
203
|
+
}}>${o.items.replace("${number}", new Intl.NumberFormat(o._lang).format(r))}</calcite-button>` || ""}<calcite-button class="popover__button" appearance=outline-fill kind=neutral .href=${m} target=_blank @click=${(c) => {
|
|
204
|
+
this.openLink(c, m), this.arcgisUserPopupInternalUIAction.emit({ category: "profile popup", action: "view profile" });
|
|
205
|
+
}}>${o.profile}</calcite-button>`;
|
|
206
|
+
}
|
|
207
|
+
render() {
|
|
208
|
+
const { user: t, itemUserInfo: r, portal: s, item: o, appearance: n, scale: a, isPopoverOpen: i, showName: l, showUsername: m, messages: c } = this, p = t || r;
|
|
209
|
+
if (!c._lang || !p)
|
|
210
|
+
return u`<arcgis-portal-user-avatar scale=s show-name .checkOnline=${this.checkOnline}></arcgis-portal-user-avatar>`;
|
|
211
|
+
const f = N(o), h = p.username || "", d = E(p.description || "") || "", v = T(p, c._lang), g = f ? c.itemManagedBy.replace("${username}", h) : h;
|
|
212
|
+
return u`<button class=${k({
|
|
213
|
+
button: !0,
|
|
214
|
+
"button--outline": n === "outline"
|
|
215
|
+
})} @click=${() => {
|
|
216
|
+
this.isPopoverOpen || (this.isPopoverOpen = !0), this.fetchItemsAndGroups();
|
|
217
|
+
}} ${I(this.buttonRef)}><slot><arcgis-portal-user-avatar .user=${p} .scale=${a} .portal=${s} .showName=${l} .description=${m ? h : ""} .hideAvatar=${!this.showAvatar} .underline=${this.underline} .checkOnline=${this.checkOnline} .wrap=${this.wrap}></arcgis-portal-user-avatar></slot></button>${i && this.buttonRef.value && p && u`<calcite-popover class="popover" .label=${v} pointer-disabled .referenceElement=${this.buttonRef.value} placement=auto .id=${`${h}-popover`} auto-close style=${L({ "--calcite-popover-z-index": this.zIndex?.toString() || "12" })} @calcitePopoverOpen=${() => {
|
|
218
|
+
this.arcgisUserPopupInternalUIAction.emit({ category: "profile popup", action: "open profile popup" });
|
|
219
|
+
}} @calcitePopoverClose=${() => {
|
|
220
|
+
this.isPopoverOpen = !1, this.arcgisUserPopupClose.emit();
|
|
221
|
+
}} @keydown=${(b) => {
|
|
222
|
+
b.key === "Escape" && setTimeout(() => {
|
|
223
|
+
this.buttonRef.value?.focus();
|
|
224
|
+
}, 200);
|
|
225
|
+
}} ${I(this.popoverRef)}><div class="popover__wrapper"><div class="popover__header"><arcgis-portal-user-avatar class="popover__avatar" .user=${p} scale=l .portal=${s} show-name .description=${g} .checkOnline=${this.checkOnline}></arcgis-portal-user-avatar></div><div class="popover__content">${!!d && u`<p class="popover__description">${d}</p>` || ""}${!!d && u`<div class="popover__fade"></div>` || ""}<div class=${k({ popover__buttons: !0, "popover__buttons--no-description": !d })}>${f ? this.renderOrgButtons(p) : this.renderUserButtons(p)}</div></div></div></calcite-popover>` || ""}`;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
A("arcgis-portal-user-popup", Q);
|
|
229
|
+
export {
|
|
230
|
+
Q as ArcgisPortalUserPopup
|
|
231
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./customElement.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "@esri/calcite-components/components/calcite-button";
|
|
2
|
+
import "@esri/calcite-components/components/calcite-loader";
|
|
3
|
+
import "../arcgis-portal-user-avatar/index.js";
|
|
4
|
+
import "@esri/calcite-components/components/calcite-popover";
|
|
5
|
+
export * from "./customElement.js";
|