solid-panes 4.2.6 → 4.4.1-test.0

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 (143) hide show
  1. package/README.md +45 -1
  2. package/dist/0314353e28ce6e5539af.svg +9 -0
  3. package/dist/04567ff683933c35c465.png +0 -0
  4. package/dist/10163fd9b5a0e00d63a0.png +0 -0
  5. package/dist/1234dcb2eec2e45f252b.png +0 -0
  6. package/dist/20899934157df4db56cb.png +0 -0
  7. package/dist/33760bf79f097f449da5.png +0 -0
  8. package/dist/4cceba29ab33b1ddd9bb.svg +6 -0
  9. package/dist/578d2b6ed32e7624164e.png +0 -0
  10. package/dist/5f62a5b2b7e99b9640c7.png +0 -0
  11. package/dist/6525766ecd288ec60129.png +0 -0
  12. package/dist/7800be6f6c4b5b0f4f20.png +0 -0
  13. package/dist/7b7538c6f6b317968009.svg +9 -0
  14. package/dist/92d03142abe6efc0b42d.svg +6 -0
  15. package/dist/976473cf5fe24d657d4b.png +0 -0
  16. package/dist/RDFXMLPane.css +70 -0
  17. package/dist/RDFXMLPane.d.ts +13 -0
  18. package/dist/RDFXMLPane.d.ts.map +1 -0
  19. package/dist/RDFXMLPane.js +46 -4
  20. package/dist/bda84f59e7216675a208.png +0 -0
  21. package/dist/cd68e8f3990ba8b2139e.png +0 -0
  22. package/dist/dashboard/basicPreferences.d.ts.map +1 -1
  23. package/dist/dashboard/basicPreferences.js +1 -0
  24. package/dist/dashboard/dashboardPane.d.ts.map +1 -1
  25. package/dist/dashboard/dashboardPane.js +9 -3
  26. package/dist/dashboard/homepage.d.ts +1 -1
  27. package/dist/dashboard/homepage.d.ts.map +1 -1
  28. package/dist/dashboard/homepage.js +5 -35
  29. package/dist/dataContentPane.css +271 -0
  30. package/dist/dataContentPane.d.ts +14 -0
  31. package/dist/dataContentPane.d.ts.map +1 -0
  32. package/dist/dataContentPane.js +68 -101
  33. package/dist/defaultPane.css +97 -0
  34. package/dist/defaultPane.d.ts +14 -0
  35. package/dist/defaultPane.d.ts.map +1 -0
  36. package/dist/defaultPane.js +9 -2
  37. package/dist/e7074a7e2cb69e51cfd3.png +0 -0
  38. package/dist/f3772696fb7ee53c23d8.png +0 -0
  39. package/dist/form/formPane.css +120 -0
  40. package/dist/form/pane.d.ts +4 -0
  41. package/dist/form/pane.d.ts.map +1 -0
  42. package/dist/form/pane.js +120 -54
  43. package/dist/home/homePane.d.ts.map +1 -1
  44. package/dist/home/homePane.js +2 -0
  45. package/dist/humanReadablePane.css +129 -0
  46. package/dist/humanReadablePane.d.ts +13 -0
  47. package/dist/humanReadablePane.d.ts.map +1 -0
  48. package/dist/humanReadablePane.js +53 -16
  49. package/dist/icons/clock.svg +7 -0
  50. package/dist/icons/comment.svg +6 -0
  51. package/dist/icons/dashboard.svg +9 -0
  52. package/dist/icons/downArrow.svg +6 -0
  53. package/dist/icons/folder.svg +6 -0
  54. package/dist/icons/friends.svg +9 -0
  55. package/dist/icons/help.svg +8 -0
  56. package/dist/icons/iconHelper.d.ts +2 -0
  57. package/dist/icons/iconHelper.d.ts.map +1 -0
  58. package/dist/icons/iconHelper.js +23 -0
  59. package/dist/icons/menu.svg +8 -0
  60. package/dist/icons/person.svg +6 -0
  61. package/dist/icons/personInCircle.svg +8 -0
  62. package/dist/icons/sharing.svg +10 -0
  63. package/dist/icons/signOut.svg +8 -0
  64. package/dist/icons/signUp.svg +9 -0
  65. package/dist/icons/star.svg +3 -0
  66. package/dist/imagePane.css +4 -0
  67. package/dist/imagePane.d.ts +12 -0
  68. package/dist/imagePane.d.ts.map +1 -0
  69. package/dist/imagePane.js +19 -21
  70. package/dist/index.d.ts +5 -4
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +19 -4
  73. package/dist/internal/internalPane.css +14 -0
  74. package/dist/internal/internalPane.d.ts +1 -0
  75. package/dist/internal/internalPane.d.ts.map +1 -1
  76. package/dist/internal/internalPane.js +6 -6
  77. package/dist/mainPage/footer.d.ts +14 -2
  78. package/dist/mainPage/footer.d.ts.map +1 -1
  79. package/dist/mainPage/footer.js +21 -13
  80. package/dist/mainPage/header.d.ts +16 -1
  81. package/dist/mainPage/header.d.ts.map +1 -1
  82. package/dist/mainPage/header.js +179 -61
  83. package/dist/mainPage/index.d.ts +16 -1
  84. package/dist/mainPage/index.d.ts.map +1 -1
  85. package/dist/mainPage/index.js +61 -7
  86. package/dist/mainPage/menu.css +243 -0
  87. package/dist/mainPage/menu.d.ts +7 -0
  88. package/dist/mainPage/menu.d.ts.map +1 -0
  89. package/dist/mainPage/menu.js +436 -0
  90. package/dist/n3Pane.css +49 -0
  91. package/dist/n3Pane.d.ts +13 -0
  92. package/dist/n3Pane.d.ts.map +1 -0
  93. package/dist/n3Pane.js +36 -4
  94. package/dist/outline/context.d.ts +2 -2
  95. package/dist/outline/context.d.ts.map +1 -1
  96. package/dist/outline/context.js +5 -2
  97. package/dist/outline/manager.css +12 -14
  98. package/dist/outline/manager.js +172 -82
  99. package/dist/outline/userInput.js +6 -3
  100. package/dist/pad/padPane.css +40 -0
  101. package/dist/pad/padPane.d.ts +1 -0
  102. package/dist/pad/padPane.d.ts.map +1 -1
  103. package/dist/pad/padPane.js +33 -22
  104. package/dist/playlist/playlistPane.js +2 -6
  105. package/dist/profileUtils/ownerProfile.d.ts +5 -0
  106. package/dist/profileUtils/ownerProfile.d.ts.map +1 -0
  107. package/dist/profileUtils/ownerProfile.js +84 -0
  108. package/dist/registerPanes.js +12 -12
  109. package/dist/schedule/schedulePane.css +294 -0
  110. package/dist/schedule/schedulePane.d.ts +23 -0
  111. package/dist/schedule/schedulePane.d.ts.map +1 -0
  112. package/dist/schedule/schedulePane.js +161 -61
  113. package/dist/slideshow/slideshowPane.js +1 -1
  114. package/dist/social/editProfileDetails.d.ts +19 -0
  115. package/dist/social/editProfileDetails.d.ts.map +1 -0
  116. package/dist/social/editProfileDetails.js +362 -0
  117. package/dist/social/icons.d.ts +7 -0
  118. package/dist/social/icons.d.ts.map +1 -0
  119. package/dist/social/icons.js +95 -0
  120. package/dist/social/socialPane.css +1464 -0
  121. package/dist/social/socialPane.d.ts +30 -0
  122. package/dist/social/socialPane.d.ts.map +1 -0
  123. package/dist/social/socialPane.js +651 -0
  124. package/dist/social/socialSections.d.ts +77 -0
  125. package/dist/social/socialSections.d.ts.map +1 -0
  126. package/dist/social/socialSections.js +393 -0
  127. package/dist/social/spinner.d.ts +3 -0
  128. package/dist/social/spinner.d.ts.map +1 -0
  129. package/dist/social/spinner.js +13 -0
  130. package/dist/social/triage.d.ts +17 -0
  131. package/dist/social/triage.d.ts.map +1 -0
  132. package/dist/social/triage.js +79 -0
  133. package/dist/solid-panes.js +49544 -18164
  134. package/dist/solid-panes.js.map +1 -1
  135. package/dist/solid-panes.min.js +3884 -240
  136. package/dist/solid-panes.min.js.map +1 -1
  137. package/dist/{style → styles}/tabbedtab.css +0 -281
  138. package/dist/styles/utilities.css +5 -0
  139. package/dist/tabbed/tabbedPane.d.ts.map +1 -1
  140. package/dist/tabbed/tabbedPane.js +2 -0
  141. package/dist/versionInfo.js +14 -14
  142. package/package.json +37 -31
  143. package/dist/socialPane.js +0 -430
@@ -0,0 +1,30 @@
1
+ import './socialPane.css';
2
+ import { LiveStore, NamedNode } from 'rdflib';
3
+ import { DataBrowserContext } from 'pane-registry';
4
+ export declare const socialPane: {
5
+ icon: string;
6
+ name: string;
7
+ label: (subject: any, context: any) => "Friends" | null;
8
+ global: boolean;
9
+ render: (s: any, context: any) => any;
10
+ };
11
+ export interface ProfileDetails {
12
+ url: string;
13
+ imageUrl?: string;
14
+ name?: string;
15
+ nickname?: string;
16
+ jobTitle?: string;
17
+ organization?: string;
18
+ location?: string | null;
19
+ pronouns?: string;
20
+ birthdate?: string;
21
+ }
22
+ export interface FriendDetails extends ProfileDetails {
23
+ subjectNode: NamedNode;
24
+ }
25
+ export declare function pronounsAsText(store: LiveStore, subject: NamedNode): string;
26
+ export declare function streamFriends(context: DataBrowserContext, subject: NamedNode, batchSize?: number): AsyncGenerator<FriendDetails[], void, void>;
27
+ export declare function extractFriends(context: DataBrowserContext, subject: NamedNode): Promise<FriendDetails[] | null>;
28
+ export declare function selectProfileData(context: DataBrowserContext, subject: NamedNode): ProfileDetails | null;
29
+ export type { ViewerMode } from './socialSections';
30
+ //# sourceMappingURL=socialPane.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socialPane.d.ts","sourceRoot":"","sources":["../../src/social/socialPane.ts"],"names":[],"mappings":"AAUA,OAAO,kBAAkB,CAAA;AAGzB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAa,MAAM,QAAQ,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AA4BlD,eAAO,MAAM,UAAU;;;;;;CAkmBtB,CAAA;AAQD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD,WAAW,EAAE,SAAS,CAAA;CACvB;AAGD,wBAAgB,cAAc,CAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,MAAM,CAS5E;AAiDD,wBAAwB,aAAa,CACnC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,SAAS,EAClB,SAAS,SAAoB,GAC5B,cAAc,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CA4C7C;AAED,wBAAsB,cAAc,CAAE,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC,CAQtH;AAED,wBAAgB,iBAAiB,CAAE,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,GAAG,cAAc,GAAG,IAAI,CAuCzG;AAED,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,651 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.extractFriends = extractFriends;
7
+ exports.pronounsAsText = pronounsAsText;
8
+ exports.selectProfileData = selectProfileData;
9
+ exports.socialPane = void 0;
10
+ exports.streamFriends = streamFriends;
11
+ require("./socialPane.css");
12
+ var _solidUi = require("solid-ui");
13
+ var _solidLogic = require("solid-logic");
14
+ var _icons = require("./icons");
15
+ var _socialSections = require("./socialSections");
16
+ var _triage = require("./triage");
17
+ /* Social Pane
18
+ **
19
+ ** This outline pane provides social network functions
20
+ ** Using for example the FOAF ontology.
21
+ ** Goal: A *distributed* version of facebook, advogato, etc etc
22
+ ** - Similarly easy user interface, but data storage distributed
23
+ ** - Read and write both user-private (address book) and public data clearly
24
+ ** -- todo: use common code to get username and load profile and set 'me'
25
+ */
26
+
27
+ function applyEnvironmentAttributes(element, context) {
28
+ const layout = context.environment?.layout ?? 'desktop';
29
+ const theme = context.environment?.theme ?? 'light';
30
+ const inputMode = context.environment?.inputMode ?? 'pointer';
31
+ element.classList.add('social-pane-host');
32
+ element.dataset.layout = layout;
33
+ element.dataset.theme = theme;
34
+ element.dataset.inputMode = inputMode;
35
+ }
36
+ const socialPane = exports.socialPane = {
37
+ icon: _solidUi.icons.originalIconBase + 'foaf/foafTiny.gif',
38
+ name: 'social',
39
+ label: function (subject, context) {
40
+ const kb = context.session.store;
41
+ const types = kb.findTypeURIs(subject);
42
+ if (types[_solidUi.ns.foaf('Person').uri] || types[_solidUi.ns.vcard('Individual').uri]) {
43
+ return 'Friends';
44
+ }
45
+ return null;
46
+ },
47
+ global: false,
48
+ render: function (s, context) {
49
+ const dom = context.dom;
50
+ const common = function (x, y) {
51
+ // Find common members of two lists
52
+ const both = [];
53
+ for (let i = 0; i < x.length; i++) {
54
+ for (let j = 0; j < y.length; j++) {
55
+ if (y[j].sameTerm(x[i])) {
56
+ both.push(y[j]);
57
+ break;
58
+ }
59
+ }
60
+ }
61
+ return both;
62
+ };
63
+ const uniqueNodes = function (nodes) {
64
+ const seen = new Set();
65
+ const unique = [];
66
+ for (const node of nodes) {
67
+ if (!node?.value || seen.has(node.value)) continue;
68
+ seen.add(node.value);
69
+ unique.push(node);
70
+ }
71
+ return unique;
72
+ };
73
+ const link = function (contents, uri) {
74
+ if (!uri) return contents;
75
+ const a = dom.createElement('a');
76
+ a.setAttribute('href', uri);
77
+ a.appendChild(contents);
78
+ return a;
79
+ };
80
+ const text = function (str) {
81
+ return dom.createTextNode(str);
82
+ };
83
+ let refreshRelationshipUi = function () {};
84
+ const buildCheckboxForm = function (lab, statement, state, options = {}) {
85
+ const f = dom.createElement('form');
86
+ const label = dom.createElement('label');
87
+ const input = dom.createElement('input');
88
+ const tx = dom.createElement('span');
89
+ tx.className = 'question';
90
+ if (typeof lab === 'string') {
91
+ tx.textContent = lab;
92
+ } else {
93
+ tx.appendChild(lab);
94
+ }
95
+ input.setAttribute('type', 'checkbox');
96
+ if (options.disabled) {
97
+ input.disabled = true;
98
+ if (options.disabledTitle) {
99
+ input.title = options.disabledTitle;
100
+ input.setAttribute('aria-label', options.disabledTitle);
101
+ }
102
+ }
103
+ label.appendChild(tx);
104
+ label.appendChild(input);
105
+ f.appendChild(label);
106
+ const boxHandler = function (_e) {
107
+ if (this.checked) {
108
+ try {
109
+ outliner.UserInput.sparqler.insert_statement(statement, function (uri, success, errorBody) {
110
+ tx.className = 'question';
111
+ if (!success) {
112
+ _solidUi.log.alert('Error occurs while inserting ' + statement + '\n\n' + errorBody);
113
+ input.checked = false; // rollback UI
114
+ return;
115
+ }
116
+ kb.add(statement.subject, statement.predicate, statement.object, statement.why);
117
+ refreshRelationshipUi();
118
+ });
119
+ } catch (e) {
120
+ _solidUi.log.error('Data write fails:' + e);
121
+ _solidUi.log.alert('Data write fails:' + e);
122
+ input.checked = false; // rollback UI
123
+ tx.className = 'question';
124
+ }
125
+ } else {
126
+ try {
127
+ outliner.UserInput.sparqler.delete_statement(statement, function (uri, success, errorBody) {
128
+ tx.className = 'question';
129
+ if (!success) {
130
+ _solidUi.log.alert('Error occurs while deleting ' + statement + '\n\n' + errorBody);
131
+ input.checked = true; // Rollback UI
132
+ } else {
133
+ kb.removeMany(statement.subject, statement.predicate, statement.object, statement.why);
134
+ refreshRelationshipUi();
135
+ }
136
+ });
137
+ } catch (e) {
138
+ _solidUi.log.alert('Delete fails:' + e);
139
+ input.checked = true; // Rollback UI
140
+ // return
141
+ }
142
+ }
143
+ };
144
+ input.checked = state;
145
+ input.addEventListener('click', boxHandler, false);
146
+ return f;
147
+ };
148
+
149
+ // ////////// Body of render():
150
+
151
+ const outliner = context.getOutliner(dom);
152
+ const kb = context.session.store;
153
+ const socialPane = dom.createElement('div');
154
+ socialPane.classList.add('social-pane', 'flex-column', 'gap-xxs');
155
+ applyEnvironmentAttributes(socialPane, context);
156
+ const foaf = _solidUi.ns.foaf;
157
+ const vcard = _solidUi.ns.vcard;
158
+ const me = _solidLogic.authn.currentUser();
159
+ const meUri = me ? me.uri : null;
160
+ const thisIsYou = me && kb.sameThings(me, s);
161
+ const knows = foaf('knows');
162
+ // var givenName = kb.sym('http://www.w3.org/2000/10/swap/pim/contact#givenName')
163
+ const familiar = kb.anyValue(s, foaf('givenname')) || kb.anyValue(s, foaf('firstName')) || kb.anyValue(s, foaf('nick')) || kb.anyValue(s, foaf('name')) || kb.anyValue(s, vcard('fn'));
164
+ const friends = kb.each(s, knows);
165
+ const uniqueFriends = uniqueNodes(friends);
166
+ const myFriends = me ? uniqueNodes(kb.each(me, foaf('knows'))) : [];
167
+ const mutualConnections = me && !thisIsYou ? uniqueNodes(common(uniqueFriends, myFriends)).filter(friend => !kb.sameThings(friend, me)) : [];
168
+ const mutualFriendCount = me && !thisIsYou ? mutualConnections.length : null;
169
+ const viewerMode = getViewerMode(s, me);
170
+
171
+ // Do I have a public profile document?
172
+ let profile = null; // This could be SPARQL { ?me foaf:primaryTopic [ a foaf:PersonalProfileDocument ] }
173
+ let editable = false;
174
+ let incoming = false;
175
+ let outgoing = false;
176
+ const structure = socialPane.appendChild(dom.createElement('div'));
177
+ structure.className = 'social-layout';
178
+ const primary = structure.appendChild(dom.createElement('div'));
179
+ primary.className = 'social-primary';
180
+ const tabs = primary.appendChild(dom.createElement('div'));
181
+ tabs.classList.add('social-primary__tabs', 'flex-center');
182
+ tabs.setAttribute('role', 'tablist');
183
+ tabs.setAttribute('aria-label', 'Social sections');
184
+ const allFriendsTab = tabs.appendChild(dom.createElement('button'));
185
+ allFriendsTab.className = 'social-primary__tab';
186
+ allFriendsTab.type = 'button';
187
+ allFriendsTab.id = 'social-tab-all-friends';
188
+ allFriendsTab.textContent = 'All Friends';
189
+ allFriendsTab.setAttribute('role', 'tab');
190
+ allFriendsTab.setAttribute('aria-controls', 'social-panel-all-friends');
191
+ allFriendsTab.setAttribute('aria-selected', 'true');
192
+ allFriendsTab.tabIndex = 0;
193
+ const mutualTab = tabs.appendChild(dom.createElement('button'));
194
+ mutualTab.className = 'social-primary__tab';
195
+ mutualTab.type = 'button';
196
+ mutualTab.id = 'social-tab-mutual';
197
+ mutualTab.textContent = 'Mutual';
198
+ mutualTab.setAttribute('role', 'tab');
199
+ mutualTab.setAttribute('aria-controls', 'social-panel-mutual');
200
+ mutualTab.setAttribute('aria-selected', 'false');
201
+ mutualTab.tabIndex = -1;
202
+ if (me) {
203
+ // The definition of FOAF personal profile document is ..
204
+ const works = kb.each(undefined, foaf('primaryTopic'), me); // having me as primary topic
205
+ let message = '';
206
+ for (let i = 0; i < works.length; i++) {
207
+ if (kb.whether(works[i], _solidUi.ns.rdf('type'), foaf('PersonalProfileDocument'))) {
208
+ const doc = works[i];
209
+ editable = outliner.UserInput.sparqler.editable(doc.uri, kb);
210
+ if (!editable) {
211
+ message += 'Your profile <' + _solidUi.utils.escapeForXML(doc.uri) + '> is not remotely editable.';
212
+ } else {
213
+ profile = doc;
214
+ break;
215
+ }
216
+ }
217
+ }
218
+
219
+ /*
220
+ if (!profile) {
221
+ say(
222
+ message + '\nI couldn\'t find your editable personal profile document.'
223
+ )
224
+ } else {
225
+ say('Editing your profile ' + profile + '.')
226
+ editable = outliner.UserInput.sparqler.editable(profile.uri, kb)
227
+ }
228
+ */
229
+
230
+ if (thisIsYou) {
231
+ // This is about me
232
+ // pass... @@
233
+ } else {
234
+ // This is about someone else
235
+ // My relationship with this person
236
+
237
+ const cme = kb.canon(me);
238
+ incoming = kb.whether(s, knows, cme);
239
+ outgoing = false;
240
+ const outgoingSt = kb.statementsMatching(cme, knows, s);
241
+ if (outgoingSt.length) {
242
+ outgoing = true;
243
+ if (!profile) profile = outgoingSt[0].why;
244
+ }
245
+ } // About someone else
246
+ } // me is defined
247
+ // End of you and s
248
+
249
+ const shouldShowHeaderAddFriendAction = mode => {
250
+ return mode === 'authenticated' && !thisIsYou && !outgoing;
251
+ };
252
+ const canEditOwnedProfile = viewerMode === 'owner' && editable;
253
+ const canManageRelationship = viewerMode === 'authenticated' && !thisIsYou && editable && Boolean(profile);
254
+ const canModifyFriendsTab = canEditOwnedProfile;
255
+ let headerControls = {
256
+ canEdit: canEditOwnedProfile,
257
+ viewerMode,
258
+ showAddFriendAction: shouldShowHeaderAddFriendAction(viewerMode)
259
+ };
260
+ const header = (0, _socialSections.createHeaderSection)(context, s, headerControls, {
261
+ friendCount: uniqueFriends.length,
262
+ mutualFriendCount,
263
+ onSelectFriends: function () {
264
+ setActivePanel('all-friends');
265
+ },
266
+ onSelectMutual: typeof mutualFriendCount === 'number' ? function () {
267
+ setActivePanel('mutual');
268
+ } : undefined
269
+ }, function () {
270
+ return selectProfileData(context, s);
271
+ });
272
+ header.classList.add('social-pane__header-section', 'flex-column');
273
+ socialPane.prepend(header);
274
+
275
+ // div.appendChild(dom.createTextNode(plural(friends.length, 'acquaintance') +'. '))
276
+
277
+ // ///////////////////////////////////////////// Main block
278
+ //
279
+ // Should: Find the intersection and difference sets
280
+
281
+ const friendDetailsByUri = new Map();
282
+ const hydrateFriendDetailsCache = function (friendNodes) {
283
+ const nextCache = new Map();
284
+ friendNodes.forEach(friendNode => {
285
+ if (!friendNode?.value || friendNode.value === s.value) return;
286
+ nextCache.set(friendNode.value, toFriendDetails(kb, friendNode));
287
+ });
288
+ friendDetailsByUri.clear();
289
+ nextCache.forEach((value, key) => {
290
+ friendDetailsByUri.set(key, value);
291
+ });
292
+ };
293
+ hydrateFriendDetailsCache(uniqueFriends);
294
+ const renderSupportingInfo = function (target, renderDom) {
295
+ const friend = friendDetailsByUri.get(target.value) || toFriendDetails(kb, target);
296
+ friendDetailsByUri.set(target.value, friend);
297
+ const container = renderDom.createElement('div');
298
+ const jobAndOrganization = [friend.jobTitle, friend.organization].filter(Boolean).join(' | ');
299
+ if (jobAndOrganization) {
300
+ const jobLine = container.appendChild(renderDom.createElement('div'));
301
+ jobLine.className = 'social-friend-job-org';
302
+ jobLine.textContent = jobAndOrganization;
303
+ }
304
+ if (friend.location) {
305
+ const locationLine = container.appendChild(renderDom.createElement('div'));
306
+ locationLine.className = 'social-friend-location';
307
+ locationLine.innerHTML = `${_icons.locationIcon} ${friend.location}`;
308
+ }
309
+ if (!container.childNodes.length) return null;
310
+ return container;
311
+ };
312
+ const renderNameSuffix = function (target, renderDom) {
313
+ const friend = friendDetailsByUri.get(target.value) || toFriendDetails(kb, target);
314
+ friendDetailsByUri.set(target.value, friend);
315
+ const pronouns = friend.pronouns;
316
+ if (!pronouns) return null;
317
+ const suffix = renderDom.createElement('span');
318
+ suffix.className = 'social-friend-pronouns';
319
+ suffix.textContent = `(${pronouns})`;
320
+ return suffix;
321
+ };
322
+ let mutualSection = me && !thisIsYou ? (0, _socialSections.createMutualSection)({
323
+ dom,
324
+ subject: s,
325
+ familiar,
326
+ me,
327
+ meUri,
328
+ incoming,
329
+ outgoing,
330
+ editable: canManageRelationship,
331
+ profile,
332
+ knows,
333
+ mutualConnections,
334
+ link,
335
+ text,
336
+ buildCheckboxForm,
337
+ renderSupportingInfo,
338
+ renderNameSuffix
339
+ }) : {
340
+ section: dom.createElement('section'),
341
+ content: dom.createElement('div'),
342
+ refreshMutualFriends: function () {}
343
+ };
344
+ let mutualFriends = mutualSection.section;
345
+ let mutualContent = mutualSection.content;
346
+ if (!mutualFriends.className) {
347
+ mutualFriends.className = 'social-pane__mutual-friends social-primary__panel';
348
+ mutualFriends.id = 'social-panel-mutual';
349
+ mutualFriends.setAttribute('role', 'tabpanel');
350
+ mutualFriends.setAttribute('aria-labelledby', 'social-tab-mutual');
351
+ mutualContent.className = 'social-main social-main--mutual';
352
+ mutualFriends.appendChild(mutualContent);
353
+ }
354
+ primary.appendChild(mutualFriends);
355
+ const allFriendsSection = (0, _socialSections.createAllFriendsSection)({
356
+ dom,
357
+ subject: s,
358
+ profile: canModifyFriendsTab ? profile : null,
359
+ editable: canModifyFriendsTab,
360
+ renderSupportingInfo,
361
+ renderNameSuffix
362
+ });
363
+ const allFriends = allFriendsSection.section;
364
+ const friendsList = allFriendsSection.friendsList;
365
+ primary.appendChild(allFriends);
366
+ let requestsTriage = (0, _triage.triageFriends)(kb, s);
367
+ const requestsSection = (0, _socialSections.createRequestsSection)({
368
+ dom,
369
+ triage: requestsTriage,
370
+ renderSupportingInfo,
371
+ renderNameSuffix
372
+ });
373
+ const requestsPanel = requestsSection.section;
374
+ primary.appendChild(requestsPanel);
375
+ const requestsTab = tabs.appendChild(dom.createElement('button'));
376
+ requestsTab.className = 'social-primary__tab';
377
+ requestsTab.type = 'button';
378
+ requestsTab.id = 'social-tab-requests';
379
+ requestsTab.textContent = 'Requests';
380
+ requestsTab.setAttribute('role', 'tab');
381
+ requestsTab.setAttribute('aria-controls', 'social-panel-requests');
382
+ requestsTab.setAttribute('aria-selected', 'false');
383
+ requestsTab.tabIndex = -1;
384
+ let activePanel = 'all-friends';
385
+ let showRequestsTab = viewerMode === 'owner';
386
+ const setActivePanel = function (panel) {
387
+ activePanel = panel;
388
+ const showMutual = panel === 'mutual';
389
+ const showAllFriends = panel === 'all-friends';
390
+ const showRequests = showRequestsTab && panel === 'requests';
391
+ mutualTab.classList.toggle('social-primary__tab--active', showMutual);
392
+ mutualTab.setAttribute('aria-selected', String(showMutual));
393
+ mutualTab.tabIndex = showMutual ? 0 : -1;
394
+ allFriendsTab.classList.toggle('social-primary__tab--active', showAllFriends);
395
+ allFriendsTab.setAttribute('aria-selected', String(showAllFriends));
396
+ allFriendsTab.tabIndex = showAllFriends ? 0 : -1;
397
+ requestsTab.classList.toggle('social-primary__tab--active', showRequests);
398
+ requestsTab.setAttribute('aria-selected', String(showRequests));
399
+ requestsTab.tabIndex = showRequests ? 0 : -1;
400
+ mutualFriends.classList.toggle('social-primary__panel--active', showMutual);
401
+ mutualFriends.setAttribute('aria-hidden', String(!showMutual));
402
+ allFriends.classList.toggle('social-primary__panel--active', showAllFriends);
403
+ allFriends.setAttribute('aria-hidden', String(!showAllFriends));
404
+ requestsPanel.classList.toggle('social-primary__panel--active', showRequests);
405
+ requestsPanel.setAttribute('aria-hidden', String(!showRequests));
406
+ requestsPanel.hidden = !showRequestsTab || !showRequests;
407
+ };
408
+ const rebuildMutualSection = function () {
409
+ if (!me || thisIsYou) return;
410
+ const cme = kb.canon(me);
411
+ incoming = kb.whether(s, knows, cme);
412
+ const outgoingStatements = kb.statementsMatching(cme, knows, s);
413
+ outgoing = outgoingStatements.length > 0;
414
+ const nextMutualSection = (0, _socialSections.createMutualSection)({
415
+ dom,
416
+ subject: s,
417
+ familiar,
418
+ me,
419
+ meUri,
420
+ incoming,
421
+ outgoing,
422
+ editable: canManageRelationship,
423
+ profile,
424
+ knows,
425
+ mutualConnections,
426
+ link,
427
+ text,
428
+ buildCheckboxForm,
429
+ renderSupportingInfo,
430
+ renderNameSuffix
431
+ });
432
+ mutualFriends.replaceWith(nextMutualSection.section);
433
+ mutualSection = nextMutualSection;
434
+ mutualFriends = nextMutualSection.section;
435
+ mutualContent = nextMutualSection.content;
436
+ };
437
+ refreshRelationshipUi = function () {
438
+ rebuildMutualSection();
439
+ headerControls = {
440
+ ...headerControls,
441
+ showAddFriendAction: shouldShowHeaderAddFriendAction(headerControls.viewerMode)
442
+ };
443
+ header.refreshSocialHeader?.(headerControls);
444
+ requestsTriage = (0, _triage.triageFriends)(kb, s);
445
+ requestsSection.refreshRequests(requestsTriage);
446
+ setActivePanel(activePanel);
447
+ };
448
+ setActivePanel('all-friends');
449
+ const applyViewerMode = function (mode) {
450
+ const showMutualTab = mode === 'authenticated' && !thisIsYou;
451
+ showRequestsTab = mode === 'owner';
452
+ mutualTab.hidden = !showMutualTab;
453
+ requestsTab.hidden = !showRequestsTab;
454
+ if (!showRequestsTab && activePanel === 'requests') {
455
+ setActivePanel('all-friends');
456
+ return;
457
+ }
458
+ setActivePanel('all-friends');
459
+ };
460
+ mutualTab.addEventListener('click', function () {
461
+ setActivePanel('mutual');
462
+ });
463
+ allFriendsTab.addEventListener('click', function () {
464
+ setActivePanel('all-friends');
465
+ });
466
+ requestsTab.addEventListener('click', function () {
467
+ setActivePanel('requests');
468
+ });
469
+ const refreshFriendsList = function () {
470
+ const refresh = friendsList.refresh;
471
+ if (typeof refresh !== 'function') return;
472
+ refresh.call(friendsList);
473
+ };
474
+ const refreshMutualFriends = function () {
475
+ mutualSection.refreshMutualFriends();
476
+ };
477
+ (async () => {
478
+ try {
479
+ for await (const streamedFriends of streamFriends(context, s)) {
480
+ friendDetailsByUri.clear();
481
+ streamedFriends.forEach(friend => {
482
+ friendDetailsByUri.set(friend.url, friend);
483
+ });
484
+ refreshFriendsList();
485
+ refreshMutualFriends();
486
+ }
487
+ } catch {
488
+ // Keep the initial snapshot if async friend loading fails.
489
+ }
490
+ })();
491
+ (async () => {
492
+ try {
493
+ requestsTriage = await (0, _triage.loadFriendshipTriage)(context, s);
494
+ requestsSection.refreshRequests(requestsTriage);
495
+ refreshFriendsList();
496
+ refreshMutualFriends();
497
+ } catch {
498
+ // Keep the initial requests snapshot if additional loading fails.
499
+ }
500
+ })();
501
+
502
+ // Older triage logic is preserved below as a reusable data helper.
503
+
504
+ applyViewerMode('anonymous');
505
+ _solidLogic.authn.checkUser().then(webId => {
506
+ const confirmedViewerMode = getViewerMode(s, webId);
507
+ applyViewerMode(confirmedViewerMode);
508
+ const confirmedCanEditOwnedProfile = confirmedViewerMode === 'owner' && editable;
509
+ headerControls = {
510
+ ...headerControls,
511
+ canEdit: confirmedCanEditOwnedProfile,
512
+ viewerMode: confirmedViewerMode,
513
+ showAddFriendAction: shouldShowHeaderAddFriendAction(confirmedViewerMode)
514
+ };
515
+ header.refreshSocialHeader?.(headerControls);
516
+ }).catch(() => {
517
+ applyViewerMode('anonymous');
518
+ headerControls = {
519
+ ...headerControls,
520
+ canEdit: false,
521
+ viewerMode: 'anonymous',
522
+ showAddFriendAction: false
523
+ };
524
+ header.refreshSocialHeader?.(headerControls);
525
+ });
526
+ return socialPane;
527
+ } // render()
528
+ }; //
529
+ // ends
530
+ // ***************** Social Pane Selectors **********/
531
+ /* Should move to another file, but will leave for now */
532
+ /* Will create a social pane folder or maybe repo later */
533
+
534
+ const FRIEND_BATCH_SIZE = 3;
535
+ /* pronounsAsText and formatLocation were copied from HeadingSection selectors */
536
+ function pronounsAsText(store, subject) {
537
+ let pronouns = store.anyJS(subject, _solidUi.ns.solid('preferredSubjectPronoun')) || '';
538
+ if (pronouns) {
539
+ const them = store.anyJS(subject, _solidUi.ns.solid('preferredObjectPronoun'));
540
+ if (them) {
541
+ pronouns += '/' + them;
542
+ }
543
+ }
544
+ return pronouns || '';
545
+ }
546
+ function formatLocation(countryName, locality) {
547
+ return countryName && locality ? `${locality}, ${countryName}` : countryName || locality || null;
548
+ }
549
+ function toFriendDetails(store, friendNode) {
550
+ const name = store.anyValue(friendNode, _solidUi.ns.vcard('fn')) || store.anyValue(friendNode, _solidUi.ns.foaf('name')) || null;
551
+ const nickname = store.anyValue(friendNode, _solidUi.ns.vcard('nickname')) || store.anyValue(friendNode, _solidUi.ns.foaf('nick')) || null;
552
+ const dateOfBirth = store.anyValue(friendNode, _solidUi.ns.vcard('bday')) || null;
553
+ const imageSrc = _solidUi.widgets.findImage(friendNode);
554
+ const jobTitle = store.anyValue(friendNode, _solidUi.ns.vcard('role')) || null;
555
+ const orgName = store.anyValue(friendNode, _solidUi.ns.vcard('organization-name')) || null;
556
+ const primaryAddressEntryNode = store.any(friendNode, _solidUi.ns.vcard('hasAddress'));
557
+ const address = primaryAddressEntryNode || null;
558
+ const countryName = address != null ? store.anyValue(address, _solidUi.ns.vcard('country-name')) : null;
559
+ const locality = address != null ? store.anyValue(address, _solidUi.ns.vcard('locality')) : null;
560
+ const location = formatLocation(countryName, locality);
561
+ const pronouns = pronounsAsText(store, friendNode);
562
+ return {
563
+ url: friendNode.value,
564
+ imageUrl: imageSrc,
565
+ name,
566
+ nickname,
567
+ jobTitle,
568
+ organization: orgName,
569
+ birthdate: dateOfBirth,
570
+ location,
571
+ pronouns,
572
+ subjectNode: friendNode
573
+ };
574
+ }
575
+ async function* streamFriends(context, subject, batchSize = FRIEND_BATCH_SIZE) {
576
+ const store = context.session.store;
577
+ const fetcher = store?.fetcher;
578
+ if (fetcher && typeof fetcher.load === 'function') {
579
+ try {
580
+ await fetcher.load(subject.doc());
581
+ } catch {
582
+ // Continue with whatever is already in the store.
583
+ }
584
+ }
585
+ const seen = new Set();
586
+ const friendNodes = store.each(subject, _solidUi.ns.foaf('knows'), null, subject.doc());
587
+ const uniqueFriendNodes = [];
588
+ for (const friendNode of friendNodes) {
589
+ const key = friendNode?.value;
590
+ if (!key || seen.has(key) || subject.value === key) continue;
591
+ seen.add(key);
592
+ uniqueFriendNodes.push(friendNode);
593
+ }
594
+ const friends = [];
595
+ for (const friendNode of uniqueFriendNodes) {
596
+ if (fetcher && typeof fetcher.load === 'function') {
597
+ try {
598
+ await fetcher.load(friendNode.doc());
599
+ } catch {
600
+ // Keep partial friend data when one linked document fails to load.
601
+ }
602
+ }
603
+ friends.push(toFriendDetails(store, friendNode));
604
+ if (friends.length % batchSize === 0) {
605
+ yield [...friends];
606
+ }
607
+ }
608
+ if (friends.length > 0 && friends.length % batchSize !== 0) {
609
+ yield [...friends];
610
+ }
611
+ }
612
+ async function extractFriends(context, subject) {
613
+ let latestFriends = null;
614
+ for await (const friends of streamFriends(context, subject)) {
615
+ latestFriends = friends;
616
+ }
617
+ return latestFriends;
618
+ }
619
+ function selectProfileData(context, subject) {
620
+ const store = context.session.store;
621
+ const name = store.anyValue(subject, _solidUi.ns.vcard('fn')) || store.anyValue(subject, _solidUi.ns.foaf('name')) || undefined;
622
+ const nickname = store.anyValue(subject, _solidUi.ns.vcard('nickname')) || store.anyValue(subject, _solidUi.ns.foaf('nick')) || undefined;
623
+ const dateOfBirth = store.anyValue(subject, _solidUi.ns.vcard('bday')) || undefined;
624
+ const imageSrc = _solidUi.widgets.findImage(subject);
625
+ const jobTitle = store.anyValue(subject, _solidUi.ns.vcard('role')) || undefined;
626
+ const orgName = store.anyValue(subject, _solidUi.ns.vcard('organization-name')) || undefined;
627
+ const primaryAddressEntryNode = store.any(subject, _solidUi.ns.vcard('hasAddress'));
628
+ const address = primaryAddressEntryNode || null;
629
+ const countryName = address != null ? store.anyValue(address, _solidUi.ns.vcard('country-name')) : undefined;
630
+ const locality = address != null ? store.anyValue(address, _solidUi.ns.vcard('locality')) : undefined;
631
+ const location = formatLocation(countryName, locality);
632
+ const pronouns = pronounsAsText(store, subject);
633
+ return {
634
+ url: subject.value,
635
+ imageUrl: imageSrc,
636
+ name,
637
+ nickname,
638
+ jobTitle,
639
+ organization: orgName,
640
+ birthdate: dateOfBirth,
641
+ location,
642
+ pronouns
643
+ };
644
+ }
645
+ function getViewerMode(subject, currentUser = _solidLogic.authn.currentUser()) {
646
+ const currentUserUri = typeof currentUser === 'string' ? currentUser : typeof currentUser === 'object' && currentUser !== null ? currentUser.value || currentUser.uri || null : null;
647
+ let mode = 'anonymous';
648
+ if (currentUserUri === subject.value) mode = 'owner';
649
+ if (currentUserUri && currentUserUri !== subject.value) mode = 'authenticated';
650
+ return mode;
651
+ }