profile-pane 2.0.0-newStyle-ca717ed2 → 2.0.0-shadowDom-5e9cd6d2
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/README.md +0 -1
- package/lib/CVCardElement.d.ts +2 -0
- package/lib/CVCardElement.d.ts.map +1 -0
- package/lib/CVCardElement.js +176 -0
- package/lib/CVCardElement.js.map +1 -0
- package/lib/ChatWithMeElement.d.ts +2 -0
- package/lib/ChatWithMeElement.d.ts.map +1 -0
- package/lib/ChatWithMeElement.js +157 -0
- package/lib/ChatWithMeElement.js.map +1 -0
- package/lib/FriendListElement.d.ts +7 -0
- package/lib/FriendListElement.d.ts.map +1 -0
- package/lib/FriendListElement.js +90 -0
- package/lib/FriendListElement.js.map +1 -0
- package/lib/FriendsPresenter.d.ts +20 -0
- package/lib/FriendsPresenter.d.ts.map +1 -0
- package/lib/FriendsPresenter.js +55 -0
- package/lib/FriendsPresenter.js.map +1 -0
- package/lib/ProfileCardElement.d.ts +2 -0
- package/lib/ProfileCardElement.d.ts.map +1 -0
- package/lib/ProfileCardElement.js +127 -0
- package/lib/ProfileCardElement.js.map +1 -0
- package/lib/ProfileViewElement.d.ts +13 -0
- package/lib/ProfileViewElement.d.ts.map +1 -0
- package/lib/ProfileViewElement.js +179 -0
- package/lib/ProfileViewElement.js.map +1 -0
- package/lib/QRCodeCardElement.d.ts +2 -0
- package/lib/QRCodeCardElement.d.ts.map +1 -0
- package/lib/QRCodeCardElement.js +135 -0
- package/lib/QRCodeCardElement.js.map +1 -0
- package/lib/SocialCardElement.d.ts +2 -0
- package/lib/SocialCardElement.d.ts.map +1 -0
- package/lib/SocialCardElement.js +108 -0
- package/lib/SocialCardElement.js.map +1 -0
- package/lib/SocialPresenter.d.ts.map +1 -1
- package/lib/SocialPresenter.js +0 -1
- package/lib/SocialPresenter.js.map +1 -1
- package/lib/StuffCardElement.d.ts +2 -0
- package/lib/StuffCardElement.d.ts.map +1 -0
- package/lib/StuffCardElement.js +97 -0
- package/lib/StuffCardElement.js.map +1 -0
- package/lib/StuffPresenter.d.ts.map +1 -1
- package/lib/StuffPresenter.js +0 -1
- package/lib/StuffPresenter.js.map +1 -1
- package/lib/addMeToYourFriends.d.ts +1 -0
- package/lib/addMeToYourFriends.d.ts.map +1 -1
- package/lib/addMeToYourFriends.js +2 -2
- package/lib/addMeToYourFriends.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -35
- package/lib/index.js.map +1 -1
- package/lib/styles/CVCard.css +39 -0
- package/lib/styles/ChatWithMe.css +50 -0
- package/lib/styles/ProfileCard.css +118 -0
- package/lib/styles/QRCodeCard.css +18 -0
- package/lib/styles/SocialCard.css +58 -0
- package/lib/styles/global.css +640 -0
- package/package.json +10 -10
- package/lib/CVCard.d.ts +0 -3
- package/lib/CVCard.d.ts.map +0 -1
- package/lib/CVCard.js +0 -118
- package/lib/CVCard.js.map +0 -1
- package/lib/ChatWithMe.d.ts +0 -5
- package/lib/ChatWithMe.d.ts.map +0 -1
- package/lib/ChatWithMe.js +0 -86
- package/lib/ChatWithMe.js.map +0 -1
- package/lib/FriendList.d.ts +0 -5
- package/lib/FriendList.d.ts.map +0 -1
- package/lib/FriendList.js +0 -40
- package/lib/FriendList.js.map +0 -1
- package/lib/ProfileCard.d.ts +0 -5
- package/lib/ProfileCard.d.ts.map +0 -1
- package/lib/ProfileCard.js +0 -43
- package/lib/ProfileCard.js.map +0 -1
- package/lib/ProfileView.d.ts +0 -5
- package/lib/ProfileView.d.ts.map +0 -1
- package/lib/ProfileView.js +0 -153
- package/lib/ProfileView.js.map +0 -1
- package/lib/QRCodeCard.d.ts +0 -4
- package/lib/QRCodeCard.d.ts.map +0 -1
- package/lib/QRCodeCard.js +0 -48
- package/lib/QRCodeCard.js.map +0 -1
- package/lib/SocialCard.d.ts +0 -4
- package/lib/SocialCard.d.ts.map +0 -1
- package/lib/SocialCard.js +0 -50
- package/lib/SocialCard.js.map +0 -1
- package/lib/StuffCard.d.ts +0 -6
- package/lib/StuffCard.d.ts.map +0 -1
- package/lib/StuffCard.js +0 -43
- package/lib/StuffCard.js.map +0 -1
- package/lib/profile-pane.js +0 -5163
- package/lib/profile-pane.js.map +0 -1
- package/lib/profile-pane.min.js +0 -299
- package/lib/profile-pane.min.js.map +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CVCardElement.d.ts","sourceRoot":"","sources":["../src/CVCardElement.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import cvCardCss from './styles/CVCard.css';
|
|
2
|
+
import { html, render } from 'lit-html';
|
|
3
|
+
import globalCssText from './styles/global.css';
|
|
4
|
+
class CVCardElement extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.shadow = this.attachShadow({ mode: 'open' });
|
|
8
|
+
}
|
|
9
|
+
async connectedCallback() {
|
|
10
|
+
let globalSheet = null;
|
|
11
|
+
let cardSheet = null;
|
|
12
|
+
let canUseSheets = typeof CSSStyleSheet !== 'undefined' && typeof globalCssText === 'string' && typeof cvCardCss === 'string';
|
|
13
|
+
try {
|
|
14
|
+
if (canUseSheets) {
|
|
15
|
+
globalSheet = new CSSStyleSheet();
|
|
16
|
+
globalSheet.replaceSync(globalCssText);
|
|
17
|
+
if (!CVCardElement.sheet) {
|
|
18
|
+
CVCardElement.sheet = new CSSStyleSheet();
|
|
19
|
+
CVCardElement.sheet.replaceSync(cvCardCss);
|
|
20
|
+
}
|
|
21
|
+
cardSheet = CVCardElement.sheet;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
globalSheet = null;
|
|
26
|
+
cardSheet = null;
|
|
27
|
+
}
|
|
28
|
+
if ('adoptedStyleSheets' in Document.prototype && globalSheet && cardSheet) {
|
|
29
|
+
this.shadow.adoptedStyleSheets = [globalSheet, cardSheet];
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// Fallback for browsers or test environments without adoptedStyleSheets or CSSStyleSheet
|
|
33
|
+
if (typeof globalCssText === 'string') {
|
|
34
|
+
const styleGlobal = document.createElement('style');
|
|
35
|
+
styleGlobal.textContent = globalCssText;
|
|
36
|
+
this.shadow.appendChild(styleGlobal);
|
|
37
|
+
}
|
|
38
|
+
if (typeof cvCardCss === 'string') {
|
|
39
|
+
const styleCard = document.createElement('style');
|
|
40
|
+
styleCard.textContent = cvCardCss;
|
|
41
|
+
this.shadow.appendChild(styleCard);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
this.render();
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
// .cardFrame wrapper already present from previous patch
|
|
48
|
+
// Assume cvData is passed as a property
|
|
49
|
+
const cvData = this.cvData;
|
|
50
|
+
if (!cvData)
|
|
51
|
+
return;
|
|
52
|
+
const { rolesByType, skills, languages } = cvData;
|
|
53
|
+
const futureRolesArr = rolesByType['FutureRole'] || [];
|
|
54
|
+
const currentRolesArr = rolesByType['CurrentRole'] || [];
|
|
55
|
+
const pastRolesArr = rolesByType['PastRole'] || [];
|
|
56
|
+
const skillsArr = skills || [];
|
|
57
|
+
const languagesArr = languages || [];
|
|
58
|
+
const hasFutureRole = Array.isArray(futureRolesArr) && futureRolesArr.length > 0;
|
|
59
|
+
const hasCurrentRole = Array.isArray(currentRolesArr) && currentRolesArr.length > 0;
|
|
60
|
+
const hasPastRole = Array.isArray(pastRolesArr) && pastRolesArr.length > 0;
|
|
61
|
+
const hasSkills = Array.isArray(skillsArr) && skillsArr.length > 0;
|
|
62
|
+
const hasLanguages = Array.isArray(languagesArr) && languagesArr.length > 0;
|
|
63
|
+
if (!(hasFutureRole || hasCurrentRole || hasPastRole || hasSkills || hasLanguages)) {
|
|
64
|
+
render(html ``, this.shadow);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
render(html `
|
|
68
|
+
<div class="cardFrame">
|
|
69
|
+
<article class="cvCard" aria-label="Professional Experience" data-testid="curriculum-vitae">
|
|
70
|
+
${hasFutureRole ? html `
|
|
71
|
+
<section class="cvSection" aria-labelledby="cv-future-heading">
|
|
72
|
+
<h3 id="cv-future-heading">Future Roles</h3>
|
|
73
|
+
<ul role="list" aria-label="Upcoming professional roles">
|
|
74
|
+
${renderRoles(futureRolesArr, true)}
|
|
75
|
+
</ul>
|
|
76
|
+
</section>
|
|
77
|
+
` : ''}
|
|
78
|
+
${hasCurrentRole ? html `
|
|
79
|
+
<section class="cvSection" aria-labelledby="cv-current-heading">
|
|
80
|
+
<h3 id="cv-current-heading">Current Roles</h3>
|
|
81
|
+
<ul role="list" aria-label="Current professional positions">
|
|
82
|
+
${renderRoles(currentRolesArr, true)}
|
|
83
|
+
</ul>
|
|
84
|
+
</section>
|
|
85
|
+
` : ''}
|
|
86
|
+
${hasPastRole ? html `
|
|
87
|
+
<section class="cvSection" aria-labelledby="cv-past-heading">
|
|
88
|
+
<h3 id="cv-past-heading">Past Roles</h3>
|
|
89
|
+
<ul role="list" aria-label="Previous work experience">
|
|
90
|
+
${renderRoles(pastRolesArr, true)}
|
|
91
|
+
</ul>
|
|
92
|
+
</section>
|
|
93
|
+
` : ''}
|
|
94
|
+
${hasSkills ? html `
|
|
95
|
+
<section class="cvSection" aria-labelledby="cv-skills-heading">
|
|
96
|
+
<h3 id="cv-skills-heading">Skills</h3>
|
|
97
|
+
<ul role="list" aria-label="Professional skills and competencies">
|
|
98
|
+
${renderSkills(skillsArr, true)}
|
|
99
|
+
</ul>
|
|
100
|
+
</section>
|
|
101
|
+
` : ''}
|
|
102
|
+
${hasLanguages ? html `
|
|
103
|
+
<section class="cvSection" aria-labelledby="cv-languages-heading">
|
|
104
|
+
<h3 id="cv-languages-heading">Languages</h3>
|
|
105
|
+
<ul role="list" aria-label="Known languages">
|
|
106
|
+
${renderLanguages(languagesArr, true)}
|
|
107
|
+
</ul>
|
|
108
|
+
</section>
|
|
109
|
+
` : ''}
|
|
110
|
+
</article>
|
|
111
|
+
</div>
|
|
112
|
+
`, this.shadow);
|
|
113
|
+
}
|
|
114
|
+
get cvData() {
|
|
115
|
+
return this._cvData;
|
|
116
|
+
}
|
|
117
|
+
set cvData(val) {
|
|
118
|
+
this._cvData = val;
|
|
119
|
+
this.render();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
CVCardElement.sheet = null;
|
|
123
|
+
customElements.define('cv-card', CVCardElement);
|
|
124
|
+
function renderRoles(roles, asList = false) {
|
|
125
|
+
if (!roles || !roles.length || !roles[0])
|
|
126
|
+
return html ``;
|
|
127
|
+
return html `${renderRole(roles[0], asList)}${roles.length > 1 ? renderRoles(roles.slice(1), asList) : html ``}`;
|
|
128
|
+
}
|
|
129
|
+
function renderRole(role, asList = false) {
|
|
130
|
+
if (!role)
|
|
131
|
+
return html ``;
|
|
132
|
+
return asList
|
|
133
|
+
? html `
|
|
134
|
+
<li class="cvRole" role="listitem">
|
|
135
|
+
<strong class="cvOrg" aria-label="Organization">${role.orgName}</strong>
|
|
136
|
+
<span aria-label="Role title">${strToUpperCase(role.roleText)}</span>
|
|
137
|
+
<time aria-label="Employment period">${role.dates}</time>
|
|
138
|
+
</li>`
|
|
139
|
+
: html ``;
|
|
140
|
+
}
|
|
141
|
+
function renderSkill(skill, asList = false) {
|
|
142
|
+
if (!skill)
|
|
143
|
+
return html ``;
|
|
144
|
+
return asList
|
|
145
|
+
? html `<li class="cvSkill">${strToUpperCase(skill)}</li>`
|
|
146
|
+
: html ``;
|
|
147
|
+
}
|
|
148
|
+
function renderSkills(skills, asList = false) {
|
|
149
|
+
if (!skills || !skills.length || !skills[0])
|
|
150
|
+
return html ``;
|
|
151
|
+
return html `${renderSkill(skills[0], asList)}${skills.length > 1 ? renderSkills(skills.slice(1), asList) : html ``}`;
|
|
152
|
+
}
|
|
153
|
+
function renderLan(language, asList = false) {
|
|
154
|
+
if (!language)
|
|
155
|
+
return html ``;
|
|
156
|
+
return asList
|
|
157
|
+
? html `<li class="cvLanguage">${language}</li>`
|
|
158
|
+
: html ``;
|
|
159
|
+
}
|
|
160
|
+
function renderLanguages(languages, asList = false) {
|
|
161
|
+
if (!languages || !languages.length || !languages[0])
|
|
162
|
+
return html ``;
|
|
163
|
+
return html `${renderLan(languages[0], asList)}${languages.length > 1 ? renderLanguages(languages.slice(1), asList) : html ``}`;
|
|
164
|
+
}
|
|
165
|
+
function strToUpperCase(str) {
|
|
166
|
+
if (str && str[0] > '') {
|
|
167
|
+
const strCase = str.split(' ');
|
|
168
|
+
for (let i = 0; i < strCase.length; i++) {
|
|
169
|
+
strCase[i] = strCase[i].charAt(0).toUpperCase() +
|
|
170
|
+
strCase[i].substring(1);
|
|
171
|
+
}
|
|
172
|
+
return strCase.join(' ');
|
|
173
|
+
}
|
|
174
|
+
return '';
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=CVCardElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CVCardElement.js","sourceRoot":"","sources":["../src/CVCardElement.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAE/C,MAAM,aAAc,SAAQ,WAAW;IAIrC;QACE,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IACnD,CAAC;IACD,KAAK,CAAC,iBAAiB;QACrB,IAAI,WAAW,GAAyB,IAAI,CAAA;QAC5C,IAAI,SAAS,GAAyB,IAAI,CAAA;QAC1C,IAAI,YAAY,GAAG,OAAO,aAAa,KAAK,WAAW,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ,CAAA;QAC7H,IAAI,CAAC;YACH,IAAI,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/ChatWithMeElement.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import chatWithMeCss from './styles/ChatWithMe.css';
|
|
2
|
+
import { html, render } from 'lit-html';
|
|
3
|
+
import { widgets } from 'solid-ui';
|
|
4
|
+
import { authn } from 'solid-logic';
|
|
5
|
+
import { chatWithMeButtonText, logInToChatWithMeButtonText, loadingMessage } from './texts';
|
|
6
|
+
import { checkIfAnyUserLoggedIn, complain } from './buttonsHelper';
|
|
7
|
+
import globalCssText from './styles/global.css';
|
|
8
|
+
class ChatWithMeElement extends HTMLElement {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.shadow = this.attachShadow({ mode: 'open' });
|
|
12
|
+
}
|
|
13
|
+
async connectedCallback() {
|
|
14
|
+
let globalSheet = null;
|
|
15
|
+
let cardSheet = null;
|
|
16
|
+
let canUseSheets = typeof CSSStyleSheet !== 'undefined' && typeof globalCssText === 'string' && typeof chatWithMeCss === 'string';
|
|
17
|
+
try {
|
|
18
|
+
if (canUseSheets) {
|
|
19
|
+
globalSheet = new CSSStyleSheet();
|
|
20
|
+
globalSheet.replaceSync(globalCssText);
|
|
21
|
+
if (!ChatWithMeElement.sheet) {
|
|
22
|
+
ChatWithMeElement.sheet = new CSSStyleSheet();
|
|
23
|
+
ChatWithMeElement.sheet.replaceSync(chatWithMeCss);
|
|
24
|
+
}
|
|
25
|
+
cardSheet = ChatWithMeElement.sheet;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
globalSheet = null;
|
|
30
|
+
cardSheet = null;
|
|
31
|
+
}
|
|
32
|
+
if ('adoptedStyleSheets' in Document.prototype && globalSheet && cardSheet) {
|
|
33
|
+
this.shadow.adoptedStyleSheets = [globalSheet, cardSheet];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Fallback for browsers or test environments without adoptedStyleSheets or CSSStyleSheet
|
|
37
|
+
if (typeof globalCssText === 'string') {
|
|
38
|
+
const styleGlobal = document.createElement('style');
|
|
39
|
+
styleGlobal.textContent = globalCssText;
|
|
40
|
+
this.shadow.appendChild(styleGlobal);
|
|
41
|
+
}
|
|
42
|
+
if (typeof chatWithMeCss === 'string') {
|
|
43
|
+
const styleCard = document.createElement('style');
|
|
44
|
+
styleCard.textContent = chatWithMeCss;
|
|
45
|
+
this.shadow.appendChild(styleCard);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
this.render();
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
const self = this;
|
|
52
|
+
const subject = self.subject;
|
|
53
|
+
const context = self.context;
|
|
54
|
+
if (!subject || !context) {
|
|
55
|
+
render(html ``, self.shadow);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const logic = context.session.logic;
|
|
59
|
+
const longChatPane = context.session.paneRegistry.byName('long chat');
|
|
60
|
+
const frame = document.createElement('div');
|
|
61
|
+
frame.setAttribute('class', 'cardFrame');
|
|
62
|
+
const chatContainer = document.createElement('div');
|
|
63
|
+
chatContainer.setAttribute('class', 'chatSection');
|
|
64
|
+
chatContainer.setAttribute('aria-labelledby', 'chat-section-title');
|
|
65
|
+
chatContainer.setAttribute('role', 'region');
|
|
66
|
+
chatContainer.setAttribute('data-testid', 'chat');
|
|
67
|
+
const title = document.createElement('h3');
|
|
68
|
+
title.id = 'chat-section-title';
|
|
69
|
+
title.className = 'sr-only';
|
|
70
|
+
title.textContent = 'Communication';
|
|
71
|
+
chatContainer.appendChild(title);
|
|
72
|
+
let exists;
|
|
73
|
+
(async () => {
|
|
74
|
+
try {
|
|
75
|
+
render(html `
|
|
76
|
+
<div class="chatLoading" role="status" aria-live="polite">
|
|
77
|
+
${loadingMessage.toUpperCase()}
|
|
78
|
+
</div>
|
|
79
|
+
`, self.shadow);
|
|
80
|
+
exists = await logic.chat.getChat(subject, false);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
exists = false;
|
|
84
|
+
}
|
|
85
|
+
if (exists) {
|
|
86
|
+
const chatArea = document.createElement('div');
|
|
87
|
+
chatArea.setAttribute('role', 'log');
|
|
88
|
+
chatArea.setAttribute('aria-label', 'Chat conversation');
|
|
89
|
+
chatArea.appendChild(longChatPane.render(exists, context, {}));
|
|
90
|
+
chatContainer.appendChild(chatArea);
|
|
91
|
+
frame.appendChild(chatContainer);
|
|
92
|
+
render(frame, self.shadow);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const me = authn.currentUser();
|
|
96
|
+
let label = checkIfAnyUserLoggedIn(me) ? chatWithMeButtonText.toUpperCase() : logInToChatWithMeButtonText.toUpperCase();
|
|
97
|
+
const button = widgets.button(document, undefined, label, setButtonHandler, { needsBorder: true });
|
|
98
|
+
async function setButtonHandler(event) {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
try {
|
|
101
|
+
const chat = await logic.chat.getChat(subject, true);
|
|
102
|
+
chatContainer.innerHTML = '';
|
|
103
|
+
chatContainer.appendChild(longChatPane.render(chat, context, {}));
|
|
104
|
+
frame.appendChild(chatContainer);
|
|
105
|
+
render(frame, self.shadow);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
complain(chatContainer, context, error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
button.refresh = refreshButton();
|
|
112
|
+
function refreshButton() {
|
|
113
|
+
const me = authn.currentUser();
|
|
114
|
+
if (checkIfAnyUserLoggedIn(me)) {
|
|
115
|
+
button.innerHTML = chatWithMeButtonText.toUpperCase();
|
|
116
|
+
button.className = 'button';
|
|
117
|
+
button.setAttribute('class', 'button');
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
button.innerHTML = logInToChatWithMeButtonText.toUpperCase();
|
|
121
|
+
button.className = 'button';
|
|
122
|
+
button.setAttribute('class', 'button');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
button.setAttribute('type', 'button');
|
|
126
|
+
button.setAttribute('aria-describedby', 'chat-button-description');
|
|
127
|
+
const description = document.createElement('span');
|
|
128
|
+
description.id = 'chat-button-description';
|
|
129
|
+
description.className = 'sr-only';
|
|
130
|
+
description.textContent = 'Start a new conversation or sign in to continue existing chat';
|
|
131
|
+
chatContainer.appendChild(button);
|
|
132
|
+
chatContainer.appendChild(description);
|
|
133
|
+
frame.appendChild(chatContainer);
|
|
134
|
+
render(frame, self.shadow);
|
|
135
|
+
}
|
|
136
|
+
})();
|
|
137
|
+
}
|
|
138
|
+
get subject() {
|
|
139
|
+
return this._subject;
|
|
140
|
+
}
|
|
141
|
+
set subject(val) {
|
|
142
|
+
this._subject = val;
|
|
143
|
+
this.render();
|
|
144
|
+
}
|
|
145
|
+
get context() {
|
|
146
|
+
return this._context;
|
|
147
|
+
}
|
|
148
|
+
set context(val) {
|
|
149
|
+
this._context = val;
|
|
150
|
+
this.render();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
ChatWithMeElement.sheet = null;
|
|
154
|
+
if (!customElements.get('chat-with-me')) {
|
|
155
|
+
customElements.define('chat-with-me', ChatWithMeElement);
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=ChatWithMeElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatWithMeElement.js","sourceRoot":"","sources":["../src/ChatWithMeElement.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC3F,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAE/C,MAAM,iB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,CAAC;IACxC,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;AAC1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FriendListElement.d.ts","sourceRoot":"","sources":["../src/FriendListElement.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B;CACF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { html, render } from 'lit-html';
|
|
2
|
+
import globalCssText from './styles/global.css';
|
|
3
|
+
import { widgets } from 'solid-ui';
|
|
4
|
+
class FriendListElement extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this._friendsData = null;
|
|
8
|
+
this.shadow = this.attachShadow({ mode: 'open' });
|
|
9
|
+
}
|
|
10
|
+
async connectedCallback() {
|
|
11
|
+
let globalSheet = null;
|
|
12
|
+
let canUseSheets = typeof CSSStyleSheet !== 'undefined' && typeof globalCssText === 'string';
|
|
13
|
+
try {
|
|
14
|
+
if (canUseSheets) {
|
|
15
|
+
globalSheet = new CSSStyleSheet();
|
|
16
|
+
globalSheet.replaceSync(globalCssText);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
globalSheet = null;
|
|
21
|
+
}
|
|
22
|
+
if ('adoptedStyleSheets' in Document.prototype && globalSheet) {
|
|
23
|
+
this.shadow.adoptedStyleSheets = [globalSheet];
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// Fallback for browsers or test environments without adoptedStyleSheets or CSSStyleSheet
|
|
27
|
+
if (typeof globalCssText === 'string') {
|
|
28
|
+
const styleGlobal = document.createElement('style');
|
|
29
|
+
styleGlobal.textContent = globalCssText;
|
|
30
|
+
this.shadow.appendChild(styleGlobal);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
this.render();
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
const friendsData = this.friendsData;
|
|
37
|
+
if (!friendsData || !friendsData.friends || friendsData.friends.length === 0) {
|
|
38
|
+
render(html ``, this.shadow);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
render(html `
|
|
42
|
+
<div class="cardFrame">
|
|
43
|
+
<section
|
|
44
|
+
class="friendListSection"
|
|
45
|
+
role="region"
|
|
46
|
+
aria-labelledby="friends-section-title"
|
|
47
|
+
data-testid="friend-list"
|
|
48
|
+
>
|
|
49
|
+
<header>
|
|
50
|
+
<h3 id="friends-section-title" class="sr-only">Friend Connections</h3>
|
|
51
|
+
</header>
|
|
52
|
+
<div role="table" aria-label="List of shared files and resources">
|
|
53
|
+
<table class="profileTable" data-testid="friendsTable">
|
|
54
|
+
<caption class="sr-only">Friends List</caption>
|
|
55
|
+
<tbody>
|
|
56
|
+
${renderThings(friendsData.friends, document)}
|
|
57
|
+
</tbody>
|
|
58
|
+
</table>
|
|
59
|
+
</div>
|
|
60
|
+
</section>
|
|
61
|
+
</div>
|
|
62
|
+
`, this.shadow);
|
|
63
|
+
}
|
|
64
|
+
get friendsData() {
|
|
65
|
+
return this._friendsData;
|
|
66
|
+
}
|
|
67
|
+
set friendsData(val) {
|
|
68
|
+
this._friendsData = val;
|
|
69
|
+
this.render();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
FriendListElement.sheet = null;
|
|
73
|
+
if (!customElements.get('friend-list')) {
|
|
74
|
+
customElements.define('friend-list', FriendListElement);
|
|
75
|
+
}
|
|
76
|
+
function renderThingAsDOM(thing, dom) {
|
|
77
|
+
const options = {};
|
|
78
|
+
// widgets.personTR returns a DOM node, so we need to convert it to HTML string
|
|
79
|
+
const row = widgets.personTR(dom, null, thing.instance, options);
|
|
80
|
+
return row;
|
|
81
|
+
}
|
|
82
|
+
function renderThing(thing, dom) {
|
|
83
|
+
return renderThingAsDOM(thing, dom);
|
|
84
|
+
}
|
|
85
|
+
function renderThings(things, dom) {
|
|
86
|
+
if (!things || things.length === 0)
|
|
87
|
+
return html ``;
|
|
88
|
+
return html `${renderThing(things[0], dom)}${things.length > 1 ? renderThings(things.slice(1), dom) : html ``}`;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=FriendListElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FriendListElement.js","sourceRoot":"","sources":["../src/FriendListElement.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGlC,MAAM,iBAAkB,SAAQ,WAAW;IAIzC;QACE,KAAK,EAAE,CAAA;QAJD,iBAAY,GAA+B,IAAI,CAAA;QAKrD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IACnD,CAAC;IACD,KAAK,CAAC,iBAAiB;QACrB,IAAI,WAAW,GAAyB,IAAI,CAAA;QAC5C,IAAI,YAAY,GAAG,OAAO,aAAa,KAAK,WAAW,IAAI,OAAO,aAAa,KAAK,QAAQ,CAAA;QAC5F,IAAI,CAAC;YACH,IAAI,YAAY,EAAE,CAAC;gBACjB,WAAW,GAAG,IAAI,aAAa,EAAE,CAAA;gBACjC,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,CAAA;YACxC,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,WAAW,GAAG,IAAI,CAAA;QACpB,CAAC;QACD,IAAI,oBAAoB,IAAI,QAAQ,CAAC,SAAS,IAAI,WAAW,EAAE,CAAC;YAC9D,IAAI,CAAC,MAAM,CAAC,kBAAkB,GAAG,CAAC,WAAW,CAAC,CAAA;QAChD,CAAC;aAAM,CAAC;YACN,yFAAyF;YACzF,IAAI,OAAO,aAAa,KAAK,QAA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AK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAChE,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,WAAW,CAAE,KAAK,EAAE,GAAG;IAC9B,OAAO,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC;AAED,SAAS,YAAY,CAAC,MAAM,EAAE,GAAG;IAC/B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA,EAAE,CAAA;IACjD,OAAO,IAAI,CAAA,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA,EAAE,EAAE,CAAA;AAC/G,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
__DEBUG_FRIENDS?: boolean;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
import { NamedNode } from 'rdflib';
|
|
7
|
+
import { DataBrowserContext } from 'pane-registry';
|
|
8
|
+
export interface Friend {
|
|
9
|
+
name: string;
|
|
10
|
+
uri: string;
|
|
11
|
+
profileImg: string;
|
|
12
|
+
icon: string;
|
|
13
|
+
iconHref: string;
|
|
14
|
+
instance?: NamedNode;
|
|
15
|
+
}
|
|
16
|
+
export interface FriendsPresentation {
|
|
17
|
+
friends: Friend[];
|
|
18
|
+
}
|
|
19
|
+
export declare function presentFriends(subject: NamedNode, context: DataBrowserContext): FriendsPresentation;
|
|
20
|
+
//# sourceMappingURL=FriendsPresenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FriendsPresenter.d.ts","sourceRoot":"","sources":["../src/FriendsPresenter.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B;CACF;AAED,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,GAAG,mBAAmB,CAiDnG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { NamedNode } from 'rdflib';
|
|
2
|
+
import { ns, widgets } from 'solid-ui';
|
|
3
|
+
export function presentFriends(subject, context) {
|
|
4
|
+
const friends = [];
|
|
5
|
+
const dom = context.dom;
|
|
6
|
+
const target = dom.createElement('div');
|
|
7
|
+
widgets.attachmentList(dom, subject, target, {
|
|
8
|
+
doc: subject.doc(),
|
|
9
|
+
modify: false,
|
|
10
|
+
predicate: ns.foaf('knows'),
|
|
11
|
+
noun: 'friend',
|
|
12
|
+
});
|
|
13
|
+
// Parse target.innerHTML for friend rows
|
|
14
|
+
const html = target.innerHTML;
|
|
15
|
+
// Create a temporary DOM to parse the HTML
|
|
16
|
+
const temp = dom.createElement('div');
|
|
17
|
+
temp.innerHTML = html;
|
|
18
|
+
// Find all <tr> elements that represent friends
|
|
19
|
+
const rows = temp.querySelectorAll('tr');
|
|
20
|
+
rows.forEach(row => {
|
|
21
|
+
var _a;
|
|
22
|
+
// First cell: profile image
|
|
23
|
+
const tds = row.querySelectorAll('td');
|
|
24
|
+
if (tds.length < 3)
|
|
25
|
+
return;
|
|
26
|
+
const profileImgTag = tds[0].querySelector('img');
|
|
27
|
+
const nameTd = tds[1];
|
|
28
|
+
const linkTd = tds[2];
|
|
29
|
+
const link = linkTd ? linkTd.querySelector('a') : null;
|
|
30
|
+
// Last cell: icon and iconHref
|
|
31
|
+
let icon = '';
|
|
32
|
+
let iconHref = '';
|
|
33
|
+
if (linkTd) {
|
|
34
|
+
const iconImg = linkTd.querySelector('img');
|
|
35
|
+
if (iconImg) {
|
|
36
|
+
icon = iconImg.getAttribute('src') || '';
|
|
37
|
+
}
|
|
38
|
+
if (link) {
|
|
39
|
+
iconHref = link.getAttribute('href') || '';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (profileImgTag && nameTd && link) {
|
|
43
|
+
friends.push({
|
|
44
|
+
name: ((_a = nameTd.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
|
|
45
|
+
uri: link.getAttribute('href') || '',
|
|
46
|
+
profileImg: profileImgTag.getAttribute('src') || '',
|
|
47
|
+
icon,
|
|
48
|
+
iconHref,
|
|
49
|
+
instance: link.getAttribute('href') ? new NamedNode(link.getAttribute('href')) : undefined
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return { friends };
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=FriendsPresenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FriendsPresenter.js","sourceRoot":"","sources":["../src/FriendsPresenter.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAgBtC,MAAM,UAAU,cAAc,CAAC,OAAkB,EAAE,OAA2B;IAC5E,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;IACvB,MA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