@semapps/activitypub-components 1.0.3 → 1.1.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.
package/dist/index.es.js CHANGED
@@ -30,57 +30,57 @@ import $85cNH$tippyjs from "tippy.js";
30
30
 
31
31
 
32
32
  const $338f387df48a40d7$export$1ec8e53e7d982d22 = {
33
- ACCEPT: "Accept",
34
- ADD: "Add",
35
- ANNOUNCE: "Announce",
36
- ARRIVE: "Arrive",
37
- BLOCK: "Block",
38
- CREATE: "Create",
39
- DELETE: "Delete",
40
- DISLIKE: "Dislike",
41
- FLAG: "Flag",
42
- FOLLOW: "Follow",
43
- IGNORE: "Ignore",
44
- INVITE: "Invite",
45
- JOIN: "Join",
46
- LEAVE: "Leave",
47
- LIKE: "Like",
48
- LISTEN: "Listen",
49
- MOVE: "Move",
50
- OFFER: "Offer",
51
- QUESTION: "Question",
52
- REJECT: "Reject",
53
- READ: "Read",
54
- REMOVE: "Remove",
55
- TENTATIVE_REJECT: "TentativeReject",
56
- TENTATIVE_ACCEPT: "TentativeAccept",
57
- TRAVEL: "Travel",
58
- UNDO: "Undo",
59
- UPDATE: "Update",
60
- VIEW: "View"
33
+ ACCEPT: 'Accept',
34
+ ADD: 'Add',
35
+ ANNOUNCE: 'Announce',
36
+ ARRIVE: 'Arrive',
37
+ BLOCK: 'Block',
38
+ CREATE: 'Create',
39
+ DELETE: 'Delete',
40
+ DISLIKE: 'Dislike',
41
+ FLAG: 'Flag',
42
+ FOLLOW: 'Follow',
43
+ IGNORE: 'Ignore',
44
+ INVITE: 'Invite',
45
+ JOIN: 'Join',
46
+ LEAVE: 'Leave',
47
+ LIKE: 'Like',
48
+ LISTEN: 'Listen',
49
+ MOVE: 'Move',
50
+ OFFER: 'Offer',
51
+ QUESTION: 'Question',
52
+ REJECT: 'Reject',
53
+ READ: 'Read',
54
+ REMOVE: 'Remove',
55
+ TENTATIVE_REJECT: 'TentativeReject',
56
+ TENTATIVE_ACCEPT: 'TentativeAccept',
57
+ TRAVEL: 'Travel',
58
+ UNDO: 'Undo',
59
+ UPDATE: 'Update',
60
+ VIEW: 'View'
61
61
  };
62
62
  const $338f387df48a40d7$export$9649665d7ccb0dc2 = {
63
- APPLICATION: "Application",
64
- GROUP: "Group",
65
- ORGANIZATION: "Organization",
66
- PERSON: "Person",
67
- SERVICE: "Service"
63
+ APPLICATION: 'Application',
64
+ GROUP: 'Group',
65
+ ORGANIZATION: 'Organization',
66
+ PERSON: 'Person',
67
+ SERVICE: 'Service'
68
68
  };
69
69
  const $338f387df48a40d7$export$c49cfb2681596b20 = {
70
- ARTICLE: "Article",
71
- AUDIO: "Audio",
72
- DOCUMENT: "Document",
73
- EVENT: "Event",
74
- IMAGE: "Image",
75
- NOTE: "Note",
76
- PAGE: "Page",
77
- PLACE: "Place",
78
- PROFILE: "Profile",
79
- RELATIONSHIP: "Relationship",
80
- TOMBSTONE: "Tombstone",
81
- VIDEO: "Video"
70
+ ARTICLE: 'Article',
71
+ AUDIO: 'Audio',
72
+ DOCUMENT: 'Document',
73
+ EVENT: 'Event',
74
+ IMAGE: 'Image',
75
+ NOTE: 'Note',
76
+ PAGE: 'Page',
77
+ PLACE: 'Place',
78
+ PROFILE: 'Profile',
79
+ RELATIONSHIP: 'Relationship',
80
+ TOMBSTONE: 'Tombstone',
81
+ VIDEO: 'Video'
82
82
  };
83
- const $338f387df48a40d7$export$4d8d554031975581 = "https://www.w3.org/ns/activitystreams#Public";
83
+ const $338f387df48a40d7$export$4d8d554031975581 = 'https://www.w3.org/ns/activitystreams#Public';
84
84
 
85
85
 
86
86
 
@@ -122,15 +122,15 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
122
122
  ]);
123
123
  // We will force dereference, if some items are not URI string references.
124
124
  const shouldDereference = (0, $85cNH$useMemo)(()=>{
125
- return dereferenceItems || items.some((item)=>typeof item !== "string");
125
+ return dereferenceItems || items.some((item)=>typeof item !== 'string');
126
126
  }, [
127
127
  dereferenceItems,
128
128
  items
129
129
  ]);
130
130
  // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called).
131
- const itemQueries = (0, $85cNH$useQueries)(!shouldDereference ? $8281f3ce3b9d6123$var$emptyArray : items.filter((item)=>typeof item === "string").map((itemUri)=>({
131
+ const itemQueries = (0, $85cNH$useQueries)(!shouldDereference ? $8281f3ce3b9d6123$var$emptyArray : items.filter((item)=>typeof item === 'string').map((itemUri)=>({
132
132
  queryKey: [
133
- "resource",
133
+ 'resource',
134
134
  itemUri
135
135
  ],
136
136
  queryFn: async ()=>(await dataProvider.fetch(itemUri)).json,
@@ -142,7 +142,7 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
142
142
  isFetching: false
143
143
  };
144
144
  // Put all loaded items together (might be dereferenced already, so concatenate).
145
- const loadedItems = items.filter((item)=>typeof item !== "string").concat(itemQueries.flatMap((itemQuery)=>{
145
+ const loadedItems = items.filter((item)=>typeof item !== 'string').concat(itemQueries.flatMap((itemQuery)=>{
146
146
  return itemQuery.isSuccess && itemQuery.data || [];
147
147
  }));
148
148
  const errors = itemQueries.filter((q)=>q.error);
@@ -161,16 +161,18 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
161
161
  const { dereferenceItems: dereferenceItems = false, liveUpdates: liveUpdates = false } = options;
162
162
  const { data: identity } = (0, $85cNH$useGetIdentity)();
163
163
  const [totalItems, setTotalItems] = (0, $85cNH$useState)(0);
164
+ const [isPaginated, setIsPaginated] = (0, $85cNH$useState)(false); // true if the collection is paginated
165
+ const [yieldsTotalItems, setYieldsTotalItems] = (0, $85cNH$useState)(false); // true if the collection server yields totalItems
164
166
  const queryClient = (0, $85cNH$useQueryClient)();
165
167
  const [hasLiveUpdates, setHasLiveUpdates] = (0, $85cNH$useState)({
166
- status: "connecting"
168
+ status: 'connecting'
167
169
  });
168
170
  const dataProvider = (0, $85cNH$useDataProvider)();
169
171
  const webSocketRef = (0, $85cNH$useRef)(null);
170
172
  // Get collectionUrl from webId predicate or URL.
171
173
  const collectionUrl = (0, $85cNH$useMemo)(()=>{
172
174
  if (predicateOrUrl) {
173
- if (predicateOrUrl.startsWith("http")) return predicateOrUrl;
175
+ if (predicateOrUrl.startsWith('http')) return predicateOrUrl;
174
176
  if (identity?.webIdData) return identity?.webIdData?.[predicateOrUrl];
175
177
  }
176
178
  return undefined;
@@ -182,11 +184,26 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
182
184
  // Fetch page of collection item references (if pageParam provided)
183
185
  // or default to `collectionUrl` (which should give you the first page).
184
186
  const fetchCollection = (0, $85cNH$useCallback)(async ({ pageParam: nextPageUrl })=>{
187
+ // If there is a nextPageUrl, we are fetching a page, otherwise we are fetching the first page or the collection
188
+ const fetchingPage = !!nextPageUrl;
185
189
  // Fetch page or first page (collectionUrl)
186
190
  let { json: json } = await dataProvider.fetch(nextPageUrl || collectionUrl);
187
- if (json.totalItems) setTotalItems(json.totalItems);
191
+ // If we are fetching the first page or the collection, we can workout some information
192
+ if (!fetchingPage) {
193
+ const localIsPaginated = !!json.first || !!json.next;
194
+ setIsPaginated(localIsPaginated);
195
+ // If the server yields totalItems, we can use it
196
+ if (json.totalItems) {
197
+ setTotalItems(json.totalItems);
198
+ setYieldsTotalItems(true);
199
+ } else if (!localIsPaginated) {
200
+ // If the collection is not paginated, we can count items
201
+ const items = (0, $577f4953dfa5de4f$export$e57ff0f701c44363)(json.orderedItems || json.items);
202
+ if (items) setTotalItems(items.length);
203
+ }
204
+ }
188
205
  // If first page, handle this here.
189
- if ((json.type === "OrderedCollection" || json.type === "Collection") && json.first) {
206
+ if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {
190
207
  if (json.first?.items) {
191
208
  if (json.first?.items.length === 0 && json.first?.next) // Special case where the first property is an object without items
192
209
  ({ json: json } = await dataProvider.fetch(json.first?.next));
@@ -199,11 +216,13 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
199
216
  dataProvider,
200
217
  collectionUrl,
201
218
  identity,
202
- setTotalItems
219
+ setTotalItems,
220
+ setIsPaginated,
221
+ setYieldsTotalItems
203
222
  ]);
204
223
  // Use infiniteQuery to handle pagination, fetching, etc.
205
224
  const { data: pageData, error: collectionError, fetchNextPage: fetchNextPage, refetch: refetch, hasNextPage: hasNextPage, isLoading: isLoadingPage, isFetching: isFetchingPage, isFetchingNextPage: isFetchingNextPage } = (0, $85cNH$useInfiniteQuery)([
206
- "collection",
225
+ 'collection',
207
226
  {
208
227
  collectionUrl: collectionUrl
209
228
  }
@@ -217,13 +236,14 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
217
236
  const allErrors = (0, $577f4953dfa5de4f$export$e57ff0f701c44363)(collectionError).concat((0, $577f4953dfa5de4f$export$e57ff0f701c44363)(itemErrors));
218
237
  const addItem = (0, $85cNH$useCallback)((item, shouldRefetch = true)=>{
219
238
  queryClient.setQueryData([
220
- "collection",
239
+ 'collection',
221
240
  {
222
241
  collectionUrl: collectionUrl
223
242
  }
224
243
  ], (oldData)=>{
225
244
  if (!oldData) return oldData;
226
- setTotalItems((totalItems)=>totalItems + 1);
245
+ // Only update totalItems if collection is not paginated or if the server yields totalItems
246
+ if (yieldsTotalItems || !isPaginated) setTotalItems((totalItems)=>totalItems + 1);
227
247
  // Destructure, so react knows, it needs to re-render the pages.
228
248
  const pages = [
229
249
  ...oldData.pages
@@ -240,28 +260,31 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
240
260
  return oldData;
241
261
  });
242
262
  if (shouldRefetch) setTimeout(()=>queryClient.refetchQueries([
243
- "collection",
263
+ 'collection',
244
264
  {
245
265
  collectionUrl: collectionUrl
246
266
  }
247
267
  ], {
248
268
  active: true,
249
269
  exact: true
250
- }), typeof shouldRefetch === "number" ? shouldRefetch : 2000);
270
+ }), typeof shouldRefetch === 'number' ? shouldRefetch : 2000);
251
271
  }, [
252
272
  queryClient,
253
273
  collectionUrl,
254
- setTotalItems
274
+ setTotalItems,
275
+ isPaginated,
276
+ yieldsTotalItems
255
277
  ]);
256
278
  const removeItem = (0, $85cNH$useCallback)((item, shouldRefetch = true)=>{
257
279
  queryClient.setQueryData([
258
- "collection",
280
+ 'collection',
259
281
  {
260
282
  collectionUrl: collectionUrl
261
283
  }
262
284
  ], (oldData)=>{
263
285
  if (!oldData) return oldData;
264
- setTotalItems((totalItems)=>totalItems - 1);
286
+ // Only update totalItems if collection is not paginated or if the server yields totalItems
287
+ if (yieldsTotalItems || !isPaginated) setTotalItems((totalItems)=>totalItems - 1);
265
288
  // Destructure, so react knows, it needs to re-render the pages array.
266
289
  const pages = [
267
290
  ...oldData.pages
@@ -275,44 +298,46 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
275
298
  return oldData;
276
299
  });
277
300
  if (shouldRefetch) setTimeout(()=>queryClient.refetchQueries([
278
- "collection",
301
+ 'collection',
279
302
  {
280
303
  collectionUrl: collectionUrl
281
304
  }
282
305
  ], {
283
306
  active: true,
284
307
  exact: true
285
- }), typeof shouldRefetch === "number" ? shouldRefetch : 2000);
308
+ }), typeof shouldRefetch === 'number' ? shouldRefetch : 2000);
286
309
  }, [
287
310
  queryClient,
288
311
  collectionUrl,
289
- setTotalItems
312
+ setTotalItems,
313
+ isPaginated,
314
+ yieldsTotalItems
290
315
  ]);
291
316
  // Live Updates
292
317
  (0, $85cNH$useEffect)(()=>{
293
318
  if (liveUpdates && collectionUrl) // Create ws that listens to collectionUri changes
294
319
  (0, $85cNH$getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((ws)=>{
295
320
  webSocketRef.current = ws; // Keep a ref to the webSocket so that it can be used elsewhere
296
- webSocketRef.current.addEventListener("message", (e)=>{
321
+ webSocketRef.current.addEventListener('message', (e)=>{
297
322
  const data = JSON.parse(e.data);
298
- if (data.type === "Add") addItem(data.object, true);
299
- else if (data.type === "Remove") removeItem(data.object, true);
323
+ if (data.type === 'Add') addItem(data.object, true);
324
+ else if (data.type === 'Remove') removeItem(data.object, true);
300
325
  });
301
- webSocketRef.current.addEventListener("error", (e)=>{
326
+ webSocketRef.current.addEventListener('error', (e)=>{
302
327
  setHasLiveUpdates({
303
- status: "error",
328
+ status: 'error',
304
329
  error: e
305
330
  });
306
331
  // TODO: Retry after a while
307
332
  });
308
- webSocketRef.current.addEventListener("close", (e)=>{
333
+ webSocketRef.current.addEventListener('close', (e)=>{
309
334
  if (!hasLiveUpdates.error) setHasLiveUpdates({
310
335
  ...hasLiveUpdates,
311
- status: "closed"
336
+ status: 'closed'
312
337
  });
313
338
  });
314
339
  setHasLiveUpdates({
315
- status: "connected"
340
+ status: 'connected'
316
341
  });
317
342
  }).catch(()=>{}); // If it fails, we won't receive live updates. But that's okay.
318
343
  }, [
@@ -338,7 +363,7 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
338
363
  clearInterval(intervalId);
339
364
  clearTimeout(timeoutId);
340
365
  resolve(webSocketRef);
341
- } else console.log("WebSocket is not initialized yet, waiting...");
366
+ } else console.log('WebSocket is not initialized yet, waiting...');
342
367
  }, 100);
343
368
  }
344
369
  });
@@ -346,9 +371,9 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
346
371
  webSocketRef,
347
372
  liveUpdates
348
373
  ]);
349
- return {
374
+ // Construct return object conditionally
375
+ const returnObject = {
350
376
  items: items,
351
- totalItems: totalItems,
352
377
  error: allErrors.length > 0 && allErrors,
353
378
  refetch: refetch,
354
379
  fetchNextPage: fetchNextPage,
@@ -363,6 +388,12 @@ const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{
363
388
  awaitWebSocketConnection: awaitWebSocketConnection,
364
389
  webSocketRef: webSocketRef
365
390
  };
391
+ // Only include totalItems if the server yields totalItems or for non-paginated collections
392
+ if (yieldsTotalItems || !isPaginated) return {
393
+ ...returnObject,
394
+ totalItems: totalItems
395
+ };
396
+ return returnObject;
366
397
  };
367
398
  var $8281f3ce3b9d6123$export$2e2bcd8739ae039 = $8281f3ce3b9d6123$var$useCollection;
368
399
 
@@ -382,7 +413,7 @@ var $8281f3ce3b9d6123$export$2e2bcd8739ae039 = $8281f3ce3b9d6123$var$useCollecti
382
413
  awaitWebSocketConnection().then((webSocketRef)=>{
383
414
  const onMessage = (event)=>{
384
415
  const data = JSON.parse(event.data);
385
- if (data.type === "Add") dataProvider.fetch(data.object).then(({ json: json })=>{
416
+ if (data.type === 'Add') dataProvider.fetch(data.object).then(({ json: json })=>{
386
417
  if (matchActivity(json)) {
387
418
  removeListeners();
388
419
  return resolve(json);
@@ -399,16 +430,16 @@ var $8281f3ce3b9d6123$export$2e2bcd8739ae039 = $8281f3ce3b9d6123$var$useCollecti
399
430
  reject(new Error(`${e.reason} (Code: ${e.code})`));
400
431
  };
401
432
  const removeListeners = ()=>{
402
- webSocketRef.current?.removeEventListener("message", onMessage);
403
- webSocketRef.current?.removeEventListener("error", onError);
404
- webSocketRef.current?.removeEventListener("close", onClose);
433
+ webSocketRef.current?.removeEventListener('message', onMessage);
434
+ webSocketRef.current?.removeEventListener('error', onError);
435
+ webSocketRef.current?.removeEventListener('close', onClose);
405
436
  };
406
- webSocketRef.current?.addEventListener("message", onMessage);
407
- webSocketRef.current?.addEventListener("error", onError);
408
- webSocketRef.current?.addEventListener("close", onClose);
437
+ webSocketRef.current?.addEventListener('message', onMessage);
438
+ webSocketRef.current?.addEventListener('error', onError);
439
+ webSocketRef.current?.addEventListener('close', onClose);
409
440
  // If a list of activities is already loaded, verify if there is a match
410
441
  if (existingActivities && checkExistingActivities) for (const a of existingActivities){
411
- if (typeof a !== "string") {
442
+ if (typeof a !== 'string') {
412
443
  if (matchActivity(a)) {
413
444
  removeListeners();
414
445
  return resolve(a);
@@ -417,7 +448,7 @@ var $8281f3ce3b9d6123$export$2e2bcd8739ae039 = $8281f3ce3b9d6123$var$useCollecti
417
448
  }
418
449
  setTimeout(()=>{
419
450
  removeListeners();
420
- reject(new Error("Timeout"));
451
+ reject(new Error('Timeout'));
421
452
  }, timeout);
422
453
  }).catch((e)=>{
423
454
  reject(e);
@@ -443,19 +474,19 @@ var $600ca419166a1ded$export$2e2bcd8739ae039 = $600ca419166a1ded$var$useAwaitAct
443
474
  */ const $4d1d40fdbcd30589$var$useOutbox = (options = {})=>{
444
475
  const dataProvider = (0, $85cNH$useDataProvider)();
445
476
  const { data: identity } = (0, $85cNH$useGetIdentity)();
446
- const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $8281f3ce3b9d6123$export$2e2bcd8739ae039)("outbox", options);
477
+ const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $8281f3ce3b9d6123$export$2e2bcd8739ae039)('outbox', options);
447
478
  const awaitActivity = (0, $600ca419166a1ded$export$2e2bcd8739ae039)(awaitWebSocketConnection, items);
448
479
  // Post an activity to the logged user's outbox and return its URI
449
480
  const post = (0, $85cNH$useCallback)(async (activity)=>{
450
- if (!url) throw new Error("Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox");
481
+ if (!url) throw new Error('Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox');
451
482
  const { headers: headers } = await dataProvider.fetch(url, {
452
- method: "POST",
483
+ method: 'POST',
453
484
  body: JSON.stringify({
454
- "@context": "https://www.w3.org/ns/activitystreams",
485
+ '@context': 'https://www.w3.org/ns/activitystreams',
455
486
  ...activity
456
487
  })
457
488
  });
458
- return headers.get("Location");
489
+ return headers.get('Location');
459
490
  }, [
460
491
  url,
461
492
  dataProvider
@@ -481,7 +512,7 @@ var $4d1d40fdbcd30589$export$2e2bcd8739ae039 = $4d1d40fdbcd30589$var$useOutbox;
481
512
  const $6080c8a288f71367$var$CustomMention = (0, $85cNH$tiptapextensionmention).extend({
482
513
  renderHTML ({ node: node, HTMLAttributes: HTMLAttributes }) {
483
514
  return [
484
- "span",
515
+ 'span',
485
516
  (0, $85cNH$mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
486
517
  `@${node.attrs.id.label}`
487
518
  ];
@@ -492,13 +523,13 @@ const $6080c8a288f71367$var$CustomMention = (0, $85cNH$tiptapextensionmention).e
492
523
  default: null,
493
524
  parseHTML: (element)=>{
494
525
  return {
495
- label: element.getAttribute("data-mention-label")
526
+ label: element.getAttribute('data-mention-label')
496
527
  };
497
528
  },
498
529
  renderHTML: (attributes)=>{
499
530
  if (!attributes.id.label) return {};
500
531
  return {
501
- "data-mention-label": attributes.id.label
532
+ 'data-mention-label': attributes.id.label
502
533
  };
503
534
  }
504
535
  },
@@ -506,13 +537,13 @@ const $6080c8a288f71367$var$CustomMention = (0, $85cNH$tiptapextensionmention).e
506
537
  default: null,
507
538
  parseHTML: (element)=>{
508
539
  return {
509
- id: element.getAttribute("data-mention-id")
540
+ id: element.getAttribute('data-mention-id')
510
541
  };
511
542
  },
512
543
  renderHTML: (attributes)=>{
513
544
  if (!attributes.id.id) return {};
514
545
  return {
515
- "data-mention-id": attributes.id.id
546
+ 'data-mention-id': attributes.id.id
516
547
  };
517
548
  }
518
549
  }
@@ -528,10 +559,10 @@ const $3c17312a40ebf1ed$var$useStyles = (0, $85cNH$muistylesmakeStyles)((theme)=
528
559
  },
529
560
  container: {
530
561
  paddingLeft: 80,
531
- position: "relative"
562
+ position: 'relative'
532
563
  },
533
564
  avatar: {
534
- position: "absolute",
565
+ position: 'absolute',
535
566
  top: 16,
536
567
  left: 0,
537
568
  bottom: 0,
@@ -539,28 +570,28 @@ const $3c17312a40ebf1ed$var$useStyles = (0, $85cNH$muistylesmakeStyles)((theme)=
539
570
  height: 64
540
571
  },
541
572
  editorContent: {
542
- "& > div": {
543
- backgroundColor: "rgba(0, 0, 0, 0.09)",
544
- padding: "2px 12px",
545
- borderWidth: "0px !important",
573
+ '& > div': {
574
+ backgroundColor: 'rgba(0, 0, 0, 0.09)',
575
+ padding: '2px 12px',
576
+ borderWidth: '0px !important',
546
577
  borderRadius: 0,
547
- borderBottom: "1px solid #FFF",
578
+ borderBottom: '1px solid #FFF',
548
579
  minHeight: 60,
549
- outline: "unset !important"
580
+ outline: 'unset !important'
550
581
  },
551
- "& > div > p": {
582
+ '& > div > p': {
552
583
  marginTop: 12,
553
584
  marginBottom: 12,
554
585
  fontFamily: theme.typography.body1.fontFamily,
555
- marginBlockStart: "0.5em",
556
- marginBlockEnd: "0.5em"
586
+ marginBlockStart: '0.5em',
587
+ marginBlockEnd: '0.5em'
557
588
  },
558
- "& > div > p.is-editor-empty:first-child::before": {
559
- color: "grey",
560
- content: "attr(data-placeholder)",
561
- float: "left",
589
+ '& > div > p.is-editor-empty:first-child::before': {
590
+ color: 'grey',
591
+ content: 'attr(data-placeholder)',
592
+ float: 'left',
562
593
  height: 0,
563
- pointerEvents: "none"
594
+ pointerEvents: 'none'
564
595
  }
565
596
  },
566
597
  button: {
@@ -579,20 +610,20 @@ const $3c17312a40ebf1ed$var$PostCommentForm = ({ context: context, placeholder:
579
610
  const [expanded, setExpanded] = (0, $85cNH$useState)(false);
580
611
  const [openAuth, setOpenAuth] = (0, $85cNH$useState)(false);
581
612
  const onSubmit = (0, $85cNH$useCallback)(async (values)=>{
582
- const document = new DOMParser().parseFromString(values.comment, "text/html");
583
- const mentions = Array.from(document.body.getElementsByClassName("mention"));
613
+ const document = new DOMParser().parseFromString(values.comment, 'text/html');
614
+ const mentions = Array.from(document.body.getElementsByClassName('mention'));
584
615
  const mentionedUsersUris = [];
585
616
  mentions.forEach((node)=>{
586
- const userUri = node.attributes["data-mention-id"].value;
587
- const userLabel = node.attributes["data-mention-label"].value;
588
- const link = document.createElement("a");
589
- link.setAttribute("href", `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`);
617
+ const userUri = node.attributes['data-mention-id'].value;
618
+ const userLabel = node.attributes['data-mention-label'].value;
619
+ const link = document.createElement('a');
620
+ link.setAttribute('href', `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`);
590
621
  link.textContent = `@${userLabel}`;
591
622
  node.parentNode.replaceChild(link, node);
592
623
  mentionedUsersUris.push(userUri);
593
624
  });
594
- if (document.body.innerHTML === "undefined") notify("Votre commentaire est vide", {
595
- type: "error"
625
+ if (document.body.innerHTML === 'undefined') notify('Votre commentaire est vide', {
626
+ type: 'error'
596
627
  });
597
628
  else {
598
629
  const tempId = Date.now();
@@ -618,13 +649,13 @@ const $3c17312a40ebf1ed$var$PostCommentForm = ({ context: context, placeholder:
618
649
  ]
619
650
  });
620
651
  notify("Commentaire post\xe9 avec succ\xe8s", {
621
- type: "success"
652
+ type: 'success'
622
653
  });
623
654
  } catch (e) {
624
655
  console.error(e);
625
656
  removeItem(tempId);
626
657
  notify(e.message, {
627
- type: "error"
658
+ type: 'error'
628
659
  });
629
660
  }
630
661
  }
@@ -676,7 +707,7 @@ const $3c17312a40ebf1ed$var$PostCommentForm = ({ context: context, placeholder:
676
707
  }) : null,
677
708
  mentions ? (0, $6080c8a288f71367$export$2e2bcd8739ae039).configure({
678
709
  HTMLAttributes: {
679
- class: "mention"
710
+ class: 'mention'
680
711
  },
681
712
  suggestion: mentions
682
713
  }) : null
@@ -721,10 +752,10 @@ const $be88b298220210d1$var$useStyles = (0, $85cNH$muistylesmakeStyles)(()=>({
721
752
  paddingLeft: 80,
722
753
  marginTop: 8,
723
754
  minHeight: 80,
724
- position: "relative"
755
+ position: 'relative'
725
756
  },
726
757
  avatar: {
727
- position: "absolute",
758
+ position: 'absolute',
728
759
  top: 0,
729
760
  left: 0,
730
761
  bottom: 0,
@@ -736,26 +767,26 @@ const $be88b298220210d1$var$useStyles = (0, $85cNH$muistylesmakeStyles)(()=>({
736
767
  paddingBottom: 8
737
768
  },
738
769
  label: {
739
- fontWeight: "bold"
770
+ fontWeight: 'bold'
740
771
  },
741
772
  content: {
742
- "& p": {
743
- marginBlockStart: "0.5em",
744
- marginBlockEnd: "0.5em"
773
+ '& p': {
774
+ marginBlockStart: '0.5em',
775
+ marginBlockEnd: '0.5em'
745
776
  }
746
777
  },
747
778
  loading: {
748
779
  zIndex: 1000,
749
- backgroundColor: "white",
780
+ backgroundColor: 'white',
750
781
  opacity: 0.5,
751
- position: "absolute",
782
+ position: 'absolute',
752
783
  top: 0,
753
784
  left: 0,
754
785
  right: 0,
755
786
  bottom: 0,
756
- display: "flex",
757
- alignItems: "center",
758
- justifyContent: "center",
787
+ display: 'flex',
788
+ alignItems: 'center',
789
+ justifyContent: 'center',
759
790
  minHeight: 200,
760
791
  marginTop: 5
761
792
  }
@@ -838,7 +869,7 @@ var $be88b298220210d1$export$2e2bcd8739ae039 = $be88b298220210d1$var$CommentsLis
838
869
  const $7ce737d4a1c88e63$var$CommentsField = ({ source: source, context: context, helperText: helperText, placeholder: placeholder, userResource: userResource, mentions: mentions })=>{
839
870
  const record = (0, $85cNH$useRecordContext)();
840
871
  const { items: comments, loading: loading, addItem: addItem, removeItem: removeItem } = (0, $8281f3ce3b9d6123$export$2e2bcd8739ae039)(record.replies);
841
- if (!userResource) throw new Error("No userResource defined for CommentsField");
872
+ if (!userResource) throw new Error('No userResource defined for CommentsField');
842
873
  return /*#__PURE__*/ (0, $85cNH$jsxs)((0, $85cNH$Fragment), {
843
874
  children: [
844
875
  /*#__PURE__*/ (0, $85cNH$jsx)((0, $3c17312a40ebf1ed$export$2e2bcd8739ae039), {
@@ -859,10 +890,10 @@ const $7ce737d4a1c88e63$var$CommentsField = ({ source: source, context: context,
859
890
  });
860
891
  };
861
892
  $7ce737d4a1c88e63$var$CommentsField.defaultProps = {
862
- label: "Commentaires",
893
+ label: 'Commentaires',
863
894
  placeholder: "Commencez \xe0 taper votre commentaire...",
864
- source: "id",
865
- context: "id"
895
+ source: 'id',
896
+ context: 'id'
866
897
  };
867
898
  var $7ce737d4a1c88e63$export$2e2bcd8739ae039 = $7ce737d4a1c88e63$var$CommentsField;
868
899
 
@@ -872,7 +903,7 @@ var $7ce737d4a1c88e63$export$2e2bcd8739ae039 = $7ce737d4a1c88e63$var$CommentsFie
872
903
 
873
904
 
874
905
  const $d3be168cd1e7aaae$var$CollectionList = ({ collectionUrl: collectionUrl, resource: resource, children: children })=>{
875
- if ((0, $85cNH$react).Children.count(children) !== 1) throw new Error("<CollectionList> only accepts a single child");
906
+ if ((0, $85cNH$react).Children.count(children) !== 1) throw new Error('<CollectionList> only accepts a single child');
876
907
  const { items: actorsUris } = (0, $8281f3ce3b9d6123$export$2e2bcd8739ae039)(collectionUrl);
877
908
  const { data: data, isLoading: isLoading, isFetching: isFetching } = (0, $85cNH$useGetMany)(resource, {
878
909
  ids: Array.isArray(actorsUris) ? actorsUris : [
@@ -900,7 +931,7 @@ var $d3be168cd1e7aaae$export$2e2bcd8739ae039 = $d3be168cd1e7aaae$var$CollectionL
900
931
 
901
932
  const $ea214512ab1a2e8f$var$ReferenceCollectionField = ({ source: source, reference: reference, children: children, ...rest })=>{
902
933
  const record = (0, $85cNH$useRecordContext)();
903
- if ((0, $85cNH$react).Children.count(children) !== 1) throw new Error("<ReferenceCollectionField> only accepts a single child");
934
+ if ((0, $85cNH$react).Children.count(children) !== 1) throw new Error('<ReferenceCollectionField> only accepts a single child');
904
935
  if (!record || !record[source]) return null;
905
936
  return /*#__PURE__*/ (0, $85cNH$jsx)((0, $d3be168cd1e7aaae$export$2e2bcd8739ae039), {
906
937
  resource: reference,
@@ -925,7 +956,7 @@ var $ea214512ab1a2e8f$export$2e2bcd8739ae039 = $ea214512ab1a2e8f$var$ReferenceCo
925
956
  * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: false }`
926
957
  */ const $cc1d1cd0e97c63a2$var$useInbox = (options = {})=>{
927
958
  const { data: identity } = (0, $85cNH$useGetIdentity)();
928
- const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $8281f3ce3b9d6123$export$2e2bcd8739ae039)("inbox", options);
959
+ const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $8281f3ce3b9d6123$export$2e2bcd8739ae039)('inbox', options);
929
960
  const awaitActivity = (0, $600ca419166a1ded$export$2e2bcd8739ae039)(awaitWebSocketConnection, items);
930
961
  return {
931
962
  url: url,
@@ -941,12 +972,12 @@ var $cc1d1cd0e97c63a2$export$2e2bcd8739ae039 = $cc1d1cd0e97c63a2$var$useInbox;
941
972
 
942
973
 
943
974
 
944
- const $6a227ddc2fd92a7a$var$useNodeinfo = (host, rel = "http://nodeinfo.diaspora.software/ns/schema/2.1")=>{
975
+ const $6a227ddc2fd92a7a$var$useNodeinfo = (host, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1')=>{
945
976
  const [schema, setSchema] = (0, $85cNH$useState)();
946
977
  (0, $85cNH$useEffect)(()=>{
947
978
  (async ()=>{
948
979
  if (host && rel) {
949
- const protocol = host.includes(":") ? "http" : "https"; // If the host has a port, we are likely on HTTP
980
+ const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP
950
981
  const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;
951
982
  try {
952
983
  const { json: links } = await (0, $85cNH$fetchUtils).fetchJson(nodeinfoUrl);
@@ -978,13 +1009,13 @@ const $2514c63dc8f4867c$var$useWebfinger = ()=>{
978
1009
  // Post an activity to the logged user's outbox and return its URI
979
1010
  const fetch = (0, $85cNH$useCallback)(async (id)=>{
980
1011
  // eslint-disable-next-line
981
- const [_, username, host] = id.split("@");
1012
+ const [_, username, host] = id.split('@');
982
1013
  if (host) {
983
- const protocol = host.includes(":") ? "http" : "https"; // If the host has a port, we are most likely on localhost
1014
+ const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost
984
1015
  const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;
985
1016
  try {
986
1017
  const { json: json } = await (0, $85cNH$fetchUtils).fetchJson(webfingerUrl);
987
- const link = json.links.find((l)=>l.type === "application/activity+json");
1018
+ const link = json.links.find((l)=>l.type === 'application/activity+json');
988
1019
  return link ? link.href : null;
989
1020
  } catch (e) {
990
1021
  return null;
@@ -1008,26 +1039,26 @@ var $2514c63dc8f4867c$export$2e2bcd8739ae039 = $2514c63dc8f4867c$var$useWebfinge
1008
1039
 
1009
1040
  const $cebd295d444aa91c$var$useStyles = (0, $85cNH$muistylesmakeStyles)((theme)=>({
1010
1041
  items: {
1011
- background: "#fff",
1012
- borderRadius: "0.5rem",
1013
- boxShadow: "0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)",
1014
- color: "rgba(0, 0, 0, 0.8)",
1015
- fontSize: "0.9rem",
1016
- overflow: "hidden",
1017
- padding: "0.2rem",
1018
- position: "relative"
1042
+ background: '#fff',
1043
+ borderRadius: '0.5rem',
1044
+ boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',
1045
+ color: 'rgba(0, 0, 0, 0.8)',
1046
+ fontSize: '0.9rem',
1047
+ overflow: 'hidden',
1048
+ padding: '0.2rem',
1049
+ position: 'relative'
1019
1050
  },
1020
1051
  item: {
1021
- background: "transparent",
1022
- border: "1px solid transparent",
1023
- borderRadius: "0.4rem",
1024
- display: "block",
1052
+ background: 'transparent',
1053
+ border: '1px solid transparent',
1054
+ borderRadius: '0.4rem',
1055
+ display: 'block',
1025
1056
  margin: 0,
1026
- padding: "0.2rem 0.4rem",
1027
- textAlign: "left",
1028
- width: "100%",
1029
- "&.selected": {
1030
- borderColor: "#000"
1057
+ padding: '0.2rem 0.4rem',
1058
+ textAlign: 'left',
1059
+ width: '100%',
1060
+ '&.selected': {
1061
+ borderColor: '#000'
1031
1062
  }
1032
1063
  }
1033
1064
  }));
@@ -1054,15 +1085,15 @@ var $cebd295d444aa91c$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $85cNH$forwardR
1054
1085
  ]);
1055
1086
  (0, $85cNH$useImperativeHandle)(ref, ()=>({
1056
1087
  onKeyDown: ({ event: event })=>{
1057
- if (event.key === "ArrowUp") {
1088
+ if (event.key === 'ArrowUp') {
1058
1089
  upHandler();
1059
1090
  return true;
1060
1091
  }
1061
- if (event.key === "ArrowDown") {
1092
+ if (event.key === 'ArrowDown') {
1062
1093
  downHandler();
1063
1094
  return true;
1064
1095
  }
1065
- if (event.key === "Enter") {
1096
+ if (event.key === 'Enter') {
1066
1097
  enterHandler();
1067
1098
  return true;
1068
1099
  }
@@ -1072,7 +1103,7 @@ var $cebd295d444aa91c$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $85cNH$forwardR
1072
1103
  return /*#__PURE__*/ (0, $85cNH$jsx)("div", {
1073
1104
  className: classes.items,
1074
1105
  children: props.items.length ? props.items.map((item, index)=>/*#__PURE__*/ (0, $85cNH$jsx)("button", {
1075
- className: classes.item + (index === selectedIndex ? " selected" : ""),
1106
+ className: classes.item + (index === selectedIndex ? ' selected' : ''),
1076
1107
  onClick: ()=>selectItem(index),
1077
1108
  children: item.label
1078
1109
  }, index)) : /*#__PURE__*/ (0, $85cNH$jsx)("div", {
@@ -1092,14 +1123,14 @@ const $a2389704c0801b9a$var$renderMentions = ()=>{
1092
1123
  props: props,
1093
1124
  editor: props.editor
1094
1125
  });
1095
- popup = (0, $85cNH$tippyjs)("body", {
1126
+ popup = (0, $85cNH$tippyjs)('body', {
1096
1127
  getReferenceClientRect: props.clientRect,
1097
1128
  appendTo: ()=>document.body,
1098
1129
  content: component.element,
1099
1130
  showOnCreate: true,
1100
1131
  interactive: true,
1101
- trigger: "manual",
1102
- placement: "bottom-start"
1132
+ trigger: 'manual',
1133
+ placement: 'bottom-start'
1103
1134
  });
1104
1135
  },
1105
1136
  onUpdate (props) {
@@ -1109,7 +1140,7 @@ const $a2389704c0801b9a$var$renderMentions = ()=>{
1109
1140
  });
1110
1141
  },
1111
1142
  onKeyDown (props) {
1112
- if (props.event.key === "Escape") {
1143
+ if (props.event.key === 'Escape') {
1113
1144
  popup[0].hide();
1114
1145
  return true;
1115
1146
  }