@semapps/activitypub-components 1.0.4 → 1.1.0-patch.1

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.cjs.js CHANGED
@@ -52,57 +52,57 @@ $parcel$export(module.exports, "PUBLIC_URI", () => $ebea823cebb2f44b$export$4d8d
52
52
 
53
53
 
54
54
  const $ebea823cebb2f44b$export$1ec8e53e7d982d22 = {
55
- ACCEPT: "Accept",
56
- ADD: "Add",
57
- ANNOUNCE: "Announce",
58
- ARRIVE: "Arrive",
59
- BLOCK: "Block",
60
- CREATE: "Create",
61
- DELETE: "Delete",
62
- DISLIKE: "Dislike",
63
- FLAG: "Flag",
64
- FOLLOW: "Follow",
65
- IGNORE: "Ignore",
66
- INVITE: "Invite",
67
- JOIN: "Join",
68
- LEAVE: "Leave",
69
- LIKE: "Like",
70
- LISTEN: "Listen",
71
- MOVE: "Move",
72
- OFFER: "Offer",
73
- QUESTION: "Question",
74
- REJECT: "Reject",
75
- READ: "Read",
76
- REMOVE: "Remove",
77
- TENTATIVE_REJECT: "TentativeReject",
78
- TENTATIVE_ACCEPT: "TentativeAccept",
79
- TRAVEL: "Travel",
80
- UNDO: "Undo",
81
- UPDATE: "Update",
82
- VIEW: "View"
55
+ ACCEPT: 'Accept',
56
+ ADD: 'Add',
57
+ ANNOUNCE: 'Announce',
58
+ ARRIVE: 'Arrive',
59
+ BLOCK: 'Block',
60
+ CREATE: 'Create',
61
+ DELETE: 'Delete',
62
+ DISLIKE: 'Dislike',
63
+ FLAG: 'Flag',
64
+ FOLLOW: 'Follow',
65
+ IGNORE: 'Ignore',
66
+ INVITE: 'Invite',
67
+ JOIN: 'Join',
68
+ LEAVE: 'Leave',
69
+ LIKE: 'Like',
70
+ LISTEN: 'Listen',
71
+ MOVE: 'Move',
72
+ OFFER: 'Offer',
73
+ QUESTION: 'Question',
74
+ REJECT: 'Reject',
75
+ READ: 'Read',
76
+ REMOVE: 'Remove',
77
+ TENTATIVE_REJECT: 'TentativeReject',
78
+ TENTATIVE_ACCEPT: 'TentativeAccept',
79
+ TRAVEL: 'Travel',
80
+ UNDO: 'Undo',
81
+ UPDATE: 'Update',
82
+ VIEW: 'View'
83
83
  };
84
84
  const $ebea823cebb2f44b$export$9649665d7ccb0dc2 = {
85
- APPLICATION: "Application",
86
- GROUP: "Group",
87
- ORGANIZATION: "Organization",
88
- PERSON: "Person",
89
- SERVICE: "Service"
85
+ APPLICATION: 'Application',
86
+ GROUP: 'Group',
87
+ ORGANIZATION: 'Organization',
88
+ PERSON: 'Person',
89
+ SERVICE: 'Service'
90
90
  };
91
91
  const $ebea823cebb2f44b$export$c49cfb2681596b20 = {
92
- ARTICLE: "Article",
93
- AUDIO: "Audio",
94
- DOCUMENT: "Document",
95
- EVENT: "Event",
96
- IMAGE: "Image",
97
- NOTE: "Note",
98
- PAGE: "Page",
99
- PLACE: "Place",
100
- PROFILE: "Profile",
101
- RELATIONSHIP: "Relationship",
102
- TOMBSTONE: "Tombstone",
103
- VIDEO: "Video"
92
+ ARTICLE: 'Article',
93
+ AUDIO: 'Audio',
94
+ DOCUMENT: 'Document',
95
+ EVENT: 'Event',
96
+ IMAGE: 'Image',
97
+ NOTE: 'Note',
98
+ PAGE: 'Page',
99
+ PLACE: 'Place',
100
+ PROFILE: 'Profile',
101
+ RELATIONSHIP: 'Relationship',
102
+ TOMBSTONE: 'Tombstone',
103
+ VIDEO: 'Video'
104
104
  };
105
- const $ebea823cebb2f44b$export$4d8d554031975581 = "https://www.w3.org/ns/activitystreams#Public";
105
+ const $ebea823cebb2f44b$export$4d8d554031975581 = 'https://www.w3.org/ns/activitystreams#Public';
106
106
 
107
107
 
108
108
 
@@ -144,15 +144,15 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
144
144
  ]);
145
145
  // We will force dereference, if some items are not URI string references.
146
146
  const shouldDereference = (0, $583VT$react.useMemo)(()=>{
147
- return dereferenceItems || items.some((item)=>typeof item !== "string");
147
+ return dereferenceItems || items.some((item)=>typeof item !== 'string');
148
148
  }, [
149
149
  dereferenceItems,
150
150
  items
151
151
  ]);
152
152
  // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called).
153
- const itemQueries = (0, $583VT$reactquery.useQueries)(!shouldDereference ? $5ca5f7e9fc1c3544$var$emptyArray : items.filter((item)=>typeof item === "string").map((itemUri)=>({
153
+ const itemQueries = (0, $583VT$reactquery.useQueries)(!shouldDereference ? $5ca5f7e9fc1c3544$var$emptyArray : items.filter((item)=>typeof item === 'string').map((itemUri)=>({
154
154
  queryKey: [
155
- "resource",
155
+ 'resource',
156
156
  itemUri
157
157
  ],
158
158
  queryFn: async ()=>(await dataProvider.fetch(itemUri)).json,
@@ -164,7 +164,7 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
164
164
  isFetching: false
165
165
  };
166
166
  // Put all loaded items together (might be dereferenced already, so concatenate).
167
- const loadedItems = items.filter((item)=>typeof item !== "string").concat(itemQueries.flatMap((itemQuery)=>{
167
+ const loadedItems = items.filter((item)=>typeof item !== 'string').concat(itemQueries.flatMap((itemQuery)=>{
168
168
  return itemQuery.isSuccess && itemQuery.data || [];
169
169
  }));
170
170
  const errors = itemQueries.filter((q)=>q.error);
@@ -183,16 +183,18 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
183
183
  const { dereferenceItems: dereferenceItems = false, liveUpdates: liveUpdates = false } = options;
184
184
  const { data: identity } = (0, $583VT$reactadmin.useGetIdentity)();
185
185
  const [totalItems, setTotalItems] = (0, $583VT$react.useState)(0);
186
+ const [isPaginated, setIsPaginated] = (0, $583VT$react.useState)(false); // true if the collection is paginated
187
+ const [yieldsTotalItems, setYieldsTotalItems] = (0, $583VT$react.useState)(false); // true if the collection server yields totalItems
186
188
  const queryClient = (0, $583VT$reactquery.useQueryClient)();
187
189
  const [hasLiveUpdates, setHasLiveUpdates] = (0, $583VT$react.useState)({
188
- status: "connecting"
190
+ status: 'connecting'
189
191
  });
190
192
  const dataProvider = (0, $583VT$reactadmin.useDataProvider)();
191
193
  const webSocketRef = (0, $583VT$react.useRef)(null);
192
194
  // Get collectionUrl from webId predicate or URL.
193
195
  const collectionUrl = (0, $583VT$react.useMemo)(()=>{
194
196
  if (predicateOrUrl) {
195
- if (predicateOrUrl.startsWith("http")) return predicateOrUrl;
197
+ if (predicateOrUrl.startsWith('http')) return predicateOrUrl;
196
198
  if (identity?.webIdData) return identity?.webIdData?.[predicateOrUrl];
197
199
  }
198
200
  return undefined;
@@ -204,11 +206,26 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
204
206
  // Fetch page of collection item references (if pageParam provided)
205
207
  // or default to `collectionUrl` (which should give you the first page).
206
208
  const fetchCollection = (0, $583VT$react.useCallback)(async ({ pageParam: nextPageUrl })=>{
209
+ // If there is a nextPageUrl, we are fetching a page, otherwise we are fetching the first page or the collection
210
+ const fetchingPage = !!nextPageUrl;
207
211
  // Fetch page or first page (collectionUrl)
208
212
  let { json: json } = await dataProvider.fetch(nextPageUrl || collectionUrl);
209
- if (json.totalItems) setTotalItems(json.totalItems);
213
+ // If we are fetching the first page or the collection, we can workout some information
214
+ if (!fetchingPage) {
215
+ const localIsPaginated = !!json.first || !!json.next;
216
+ setIsPaginated(localIsPaginated);
217
+ // If the server yields totalItems, we can use it
218
+ if (json.totalItems) {
219
+ setTotalItems(json.totalItems);
220
+ setYieldsTotalItems(true);
221
+ } else if (!localIsPaginated) {
222
+ // If the collection is not paginated, we can count items
223
+ const items = (0, $03510abb28fd3d8a$export$e57ff0f701c44363)(json.orderedItems || json.items);
224
+ if (items) setTotalItems(items.length);
225
+ }
226
+ }
210
227
  // If first page, handle this here.
211
- if ((json.type === "OrderedCollection" || json.type === "Collection") && json.first) {
228
+ if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {
212
229
  if (json.first?.items) {
213
230
  if (json.first?.items.length === 0 && json.first?.next) // Special case where the first property is an object without items
214
231
  ({ json: json } = await dataProvider.fetch(json.first?.next));
@@ -221,11 +238,13 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
221
238
  dataProvider,
222
239
  collectionUrl,
223
240
  identity,
224
- setTotalItems
241
+ setTotalItems,
242
+ setIsPaginated,
243
+ setYieldsTotalItems
225
244
  ]);
226
245
  // Use infiniteQuery to handle pagination, fetching, etc.
227
246
  const { data: pageData, error: collectionError, fetchNextPage: fetchNextPage, refetch: refetch, hasNextPage: hasNextPage, isLoading: isLoadingPage, isFetching: isFetchingPage, isFetchingNextPage: isFetchingNextPage } = (0, $583VT$reactquery.useInfiniteQuery)([
228
- "collection",
247
+ 'collection',
229
248
  {
230
249
  collectionUrl: collectionUrl
231
250
  }
@@ -239,13 +258,14 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
239
258
  const allErrors = (0, $03510abb28fd3d8a$export$e57ff0f701c44363)(collectionError).concat((0, $03510abb28fd3d8a$export$e57ff0f701c44363)(itemErrors));
240
259
  const addItem = (0, $583VT$react.useCallback)((item, shouldRefetch = true)=>{
241
260
  queryClient.setQueryData([
242
- "collection",
261
+ 'collection',
243
262
  {
244
263
  collectionUrl: collectionUrl
245
264
  }
246
265
  ], (oldData)=>{
247
266
  if (!oldData) return oldData;
248
- setTotalItems((totalItems)=>totalItems + 1);
267
+ // Only update totalItems if collection is not paginated or if the server yields totalItems
268
+ if (yieldsTotalItems || !isPaginated) setTotalItems((totalItems)=>totalItems + 1);
249
269
  // Destructure, so react knows, it needs to re-render the pages.
250
270
  const pages = [
251
271
  ...oldData.pages
@@ -262,28 +282,31 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
262
282
  return oldData;
263
283
  });
264
284
  if (shouldRefetch) setTimeout(()=>queryClient.refetchQueries([
265
- "collection",
285
+ 'collection',
266
286
  {
267
287
  collectionUrl: collectionUrl
268
288
  }
269
289
  ], {
270
290
  active: true,
271
291
  exact: true
272
- }), typeof shouldRefetch === "number" ? shouldRefetch : 2000);
292
+ }), typeof shouldRefetch === 'number' ? shouldRefetch : 2000);
273
293
  }, [
274
294
  queryClient,
275
295
  collectionUrl,
276
- setTotalItems
296
+ setTotalItems,
297
+ isPaginated,
298
+ yieldsTotalItems
277
299
  ]);
278
300
  const removeItem = (0, $583VT$react.useCallback)((item, shouldRefetch = true)=>{
279
301
  queryClient.setQueryData([
280
- "collection",
302
+ 'collection',
281
303
  {
282
304
  collectionUrl: collectionUrl
283
305
  }
284
306
  ], (oldData)=>{
285
307
  if (!oldData) return oldData;
286
- setTotalItems((totalItems)=>totalItems - 1);
308
+ // Only update totalItems if collection is not paginated or if the server yields totalItems
309
+ if (yieldsTotalItems || !isPaginated) setTotalItems((totalItems)=>totalItems - 1);
287
310
  // Destructure, so react knows, it needs to re-render the pages array.
288
311
  const pages = [
289
312
  ...oldData.pages
@@ -297,44 +320,46 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
297
320
  return oldData;
298
321
  });
299
322
  if (shouldRefetch) setTimeout(()=>queryClient.refetchQueries([
300
- "collection",
323
+ 'collection',
301
324
  {
302
325
  collectionUrl: collectionUrl
303
326
  }
304
327
  ], {
305
328
  active: true,
306
329
  exact: true
307
- }), typeof shouldRefetch === "number" ? shouldRefetch : 2000);
330
+ }), typeof shouldRefetch === 'number' ? shouldRefetch : 2000);
308
331
  }, [
309
332
  queryClient,
310
333
  collectionUrl,
311
- setTotalItems
334
+ setTotalItems,
335
+ isPaginated,
336
+ yieldsTotalItems
312
337
  ]);
313
338
  // Live Updates
314
339
  (0, $583VT$react.useEffect)(()=>{
315
340
  if (liveUpdates && collectionUrl) // Create ws that listens to collectionUri changes
316
341
  (0, $583VT$semappssemanticdataprovider.getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((ws)=>{
317
342
  webSocketRef.current = ws; // Keep a ref to the webSocket so that it can be used elsewhere
318
- webSocketRef.current.addEventListener("message", (e)=>{
343
+ webSocketRef.current.addEventListener('message', (e)=>{
319
344
  const data = JSON.parse(e.data);
320
- if (data.type === "Add") addItem(data.object, true);
321
- else if (data.type === "Remove") removeItem(data.object, true);
345
+ if (data.type === 'Add') addItem(data.object, true);
346
+ else if (data.type === 'Remove') removeItem(data.object, true);
322
347
  });
323
- webSocketRef.current.addEventListener("error", (e)=>{
348
+ webSocketRef.current.addEventListener('error', (e)=>{
324
349
  setHasLiveUpdates({
325
- status: "error",
350
+ status: 'error',
326
351
  error: e
327
352
  });
328
353
  // TODO: Retry after a while
329
354
  });
330
- webSocketRef.current.addEventListener("close", (e)=>{
355
+ webSocketRef.current.addEventListener('close', (e)=>{
331
356
  if (!hasLiveUpdates.error) setHasLiveUpdates({
332
357
  ...hasLiveUpdates,
333
- status: "closed"
358
+ status: 'closed'
334
359
  });
335
360
  });
336
361
  setHasLiveUpdates({
337
- status: "connected"
362
+ status: 'connected'
338
363
  });
339
364
  }).catch(()=>{}); // If it fails, we won't receive live updates. But that's okay.
340
365
  }, [
@@ -360,7 +385,7 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
360
385
  clearInterval(intervalId);
361
386
  clearTimeout(timeoutId);
362
387
  resolve(webSocketRef);
363
- } else console.log("WebSocket is not initialized yet, waiting...");
388
+ } else console.log('WebSocket is not initialized yet, waiting...');
364
389
  }, 100);
365
390
  }
366
391
  });
@@ -368,9 +393,9 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
368
393
  webSocketRef,
369
394
  liveUpdates
370
395
  ]);
371
- return {
396
+ // Construct return object conditionally
397
+ const returnObject = {
372
398
  items: items,
373
- totalItems: totalItems,
374
399
  error: allErrors.length > 0 && allErrors,
375
400
  refetch: refetch,
376
401
  fetchNextPage: fetchNextPage,
@@ -385,6 +410,12 @@ const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{
385
410
  awaitWebSocketConnection: awaitWebSocketConnection,
386
411
  webSocketRef: webSocketRef
387
412
  };
413
+ // Only include totalItems if the server yields totalItems or for non-paginated collections
414
+ if (yieldsTotalItems || !isPaginated) return {
415
+ ...returnObject,
416
+ totalItems: totalItems
417
+ };
418
+ return returnObject;
388
419
  };
389
420
  var $5ca5f7e9fc1c3544$export$2e2bcd8739ae039 = $5ca5f7e9fc1c3544$var$useCollection;
390
421
 
@@ -404,7 +435,7 @@ var $5ca5f7e9fc1c3544$export$2e2bcd8739ae039 = $5ca5f7e9fc1c3544$var$useCollecti
404
435
  awaitWebSocketConnection().then((webSocketRef)=>{
405
436
  const onMessage = (event)=>{
406
437
  const data = JSON.parse(event.data);
407
- if (data.type === "Add") dataProvider.fetch(data.object).then(({ json: json })=>{
438
+ if (data.type === 'Add') dataProvider.fetch(data.object).then(({ json: json })=>{
408
439
  if (matchActivity(json)) {
409
440
  removeListeners();
410
441
  return resolve(json);
@@ -421,16 +452,16 @@ var $5ca5f7e9fc1c3544$export$2e2bcd8739ae039 = $5ca5f7e9fc1c3544$var$useCollecti
421
452
  reject(new Error(`${e.reason} (Code: ${e.code})`));
422
453
  };
423
454
  const removeListeners = ()=>{
424
- webSocketRef.current?.removeEventListener("message", onMessage);
425
- webSocketRef.current?.removeEventListener("error", onError);
426
- webSocketRef.current?.removeEventListener("close", onClose);
455
+ webSocketRef.current?.removeEventListener('message', onMessage);
456
+ webSocketRef.current?.removeEventListener('error', onError);
457
+ webSocketRef.current?.removeEventListener('close', onClose);
427
458
  };
428
- webSocketRef.current?.addEventListener("message", onMessage);
429
- webSocketRef.current?.addEventListener("error", onError);
430
- webSocketRef.current?.addEventListener("close", onClose);
459
+ webSocketRef.current?.addEventListener('message', onMessage);
460
+ webSocketRef.current?.addEventListener('error', onError);
461
+ webSocketRef.current?.addEventListener('close', onClose);
431
462
  // If a list of activities is already loaded, verify if there is a match
432
463
  if (existingActivities && checkExistingActivities) for (const a of existingActivities){
433
- if (typeof a !== "string") {
464
+ if (typeof a !== 'string') {
434
465
  if (matchActivity(a)) {
435
466
  removeListeners();
436
467
  return resolve(a);
@@ -439,7 +470,7 @@ var $5ca5f7e9fc1c3544$export$2e2bcd8739ae039 = $5ca5f7e9fc1c3544$var$useCollecti
439
470
  }
440
471
  setTimeout(()=>{
441
472
  removeListeners();
442
- reject(new Error("Timeout"));
473
+ reject(new Error('Timeout'));
443
474
  }, timeout);
444
475
  }).catch((e)=>{
445
476
  reject(e);
@@ -465,19 +496,19 @@ var $5e70f9d0635e25dd$export$2e2bcd8739ae039 = $5e70f9d0635e25dd$var$useAwaitAct
465
496
  */ const $456aea3814dded7d$var$useOutbox = (options = {})=>{
466
497
  const dataProvider = (0, $583VT$reactadmin.useDataProvider)();
467
498
  const { data: identity } = (0, $583VT$reactadmin.useGetIdentity)();
468
- const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $5ca5f7e9fc1c3544$export$2e2bcd8739ae039)("outbox", options);
499
+ const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $5ca5f7e9fc1c3544$export$2e2bcd8739ae039)('outbox', options);
469
500
  const awaitActivity = (0, $5e70f9d0635e25dd$export$2e2bcd8739ae039)(awaitWebSocketConnection, items);
470
501
  // Post an activity to the logged user's outbox and return its URI
471
502
  const post = (0, $583VT$react.useCallback)(async (activity)=>{
472
- if (!url) throw new Error("Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox");
503
+ if (!url) throw new Error('Cannot post to outbox before user identity is loaded. Please use the isLoading argument of useOutbox');
473
504
  const { headers: headers } = await dataProvider.fetch(url, {
474
- method: "POST",
505
+ method: 'POST',
475
506
  body: JSON.stringify({
476
- "@context": "https://www.w3.org/ns/activitystreams",
507
+ '@context': 'https://www.w3.org/ns/activitystreams',
477
508
  ...activity
478
509
  })
479
510
  });
480
- return headers.get("Location");
511
+ return headers.get('Location');
481
512
  }, [
482
513
  url,
483
514
  dataProvider
@@ -503,7 +534,7 @@ var $456aea3814dded7d$export$2e2bcd8739ae039 = $456aea3814dded7d$var$useOutbox;
503
534
  const $9b1343b281972d72$var$CustomMention = (0, ($parcel$interopDefault($583VT$tiptapextensionmention))).extend({
504
535
  renderHTML ({ node: node, HTMLAttributes: HTMLAttributes }) {
505
536
  return [
506
- "span",
537
+ 'span',
507
538
  (0, $583VT$tiptapcore.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
508
539
  `@${node.attrs.id.label}`
509
540
  ];
@@ -514,13 +545,13 @@ const $9b1343b281972d72$var$CustomMention = (0, ($parcel$interopDefault($583VT$t
514
545
  default: null,
515
546
  parseHTML: (element)=>{
516
547
  return {
517
- label: element.getAttribute("data-mention-label")
548
+ label: element.getAttribute('data-mention-label')
518
549
  };
519
550
  },
520
551
  renderHTML: (attributes)=>{
521
552
  if (!attributes.id.label) return {};
522
553
  return {
523
- "data-mention-label": attributes.id.label
554
+ 'data-mention-label': attributes.id.label
524
555
  };
525
556
  }
526
557
  },
@@ -528,13 +559,13 @@ const $9b1343b281972d72$var$CustomMention = (0, ($parcel$interopDefault($583VT$t
528
559
  default: null,
529
560
  parseHTML: (element)=>{
530
561
  return {
531
- id: element.getAttribute("data-mention-id")
562
+ id: element.getAttribute('data-mention-id')
532
563
  };
533
564
  },
534
565
  renderHTML: (attributes)=>{
535
566
  if (!attributes.id.id) return {};
536
567
  return {
537
- "data-mention-id": attributes.id.id
568
+ 'data-mention-id': attributes.id.id
538
569
  };
539
570
  }
540
571
  }
@@ -550,10 +581,10 @@ const $703eba3e46be7ee5$var$useStyles = (0, ($parcel$interopDefault($583VT$muist
550
581
  },
551
582
  container: {
552
583
  paddingLeft: 80,
553
- position: "relative"
584
+ position: 'relative'
554
585
  },
555
586
  avatar: {
556
- position: "absolute",
587
+ position: 'absolute',
557
588
  top: 16,
558
589
  left: 0,
559
590
  bottom: 0,
@@ -561,28 +592,28 @@ const $703eba3e46be7ee5$var$useStyles = (0, ($parcel$interopDefault($583VT$muist
561
592
  height: 64
562
593
  },
563
594
  editorContent: {
564
- "& > div": {
565
- backgroundColor: "rgba(0, 0, 0, 0.09)",
566
- padding: "2px 12px",
567
- borderWidth: "0px !important",
595
+ '& > div': {
596
+ backgroundColor: 'rgba(0, 0, 0, 0.09)',
597
+ padding: '2px 12px',
598
+ borderWidth: '0px !important',
568
599
  borderRadius: 0,
569
- borderBottom: "1px solid #FFF",
600
+ borderBottom: '1px solid #FFF',
570
601
  minHeight: 60,
571
- outline: "unset !important"
602
+ outline: 'unset !important'
572
603
  },
573
- "& > div > p": {
604
+ '& > div > p': {
574
605
  marginTop: 12,
575
606
  marginBottom: 12,
576
607
  fontFamily: theme.typography.body1.fontFamily,
577
- marginBlockStart: "0.5em",
578
- marginBlockEnd: "0.5em"
608
+ marginBlockStart: '0.5em',
609
+ marginBlockEnd: '0.5em'
579
610
  },
580
- "& > div > p.is-editor-empty:first-child::before": {
581
- color: "grey",
582
- content: "attr(data-placeholder)",
583
- float: "left",
611
+ '& > div > p.is-editor-empty:first-child::before': {
612
+ color: 'grey',
613
+ content: 'attr(data-placeholder)',
614
+ float: 'left',
584
615
  height: 0,
585
- pointerEvents: "none"
616
+ pointerEvents: 'none'
586
617
  }
587
618
  },
588
619
  button: {
@@ -601,20 +632,20 @@ const $703eba3e46be7ee5$var$PostCommentForm = ({ context: context, placeholder:
601
632
  const [expanded, setExpanded] = (0, $583VT$react.useState)(false);
602
633
  const [openAuth, setOpenAuth] = (0, $583VT$react.useState)(false);
603
634
  const onSubmit = (0, $583VT$react.useCallback)(async (values)=>{
604
- const document = new DOMParser().parseFromString(values.comment, "text/html");
605
- const mentions = Array.from(document.body.getElementsByClassName("mention"));
635
+ const document = new DOMParser().parseFromString(values.comment, 'text/html');
636
+ const mentions = Array.from(document.body.getElementsByClassName('mention'));
606
637
  const mentionedUsersUris = [];
607
638
  mentions.forEach((node)=>{
608
- const userUri = node.attributes["data-mention-id"].value;
609
- const userLabel = node.attributes["data-mention-label"].value;
610
- const link = document.createElement("a");
611
- link.setAttribute("href", `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`);
639
+ const userUri = node.attributes['data-mention-id'].value;
640
+ const userLabel = node.attributes['data-mention-label'].value;
641
+ const link = document.createElement('a');
642
+ link.setAttribute('href', `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`);
612
643
  link.textContent = `@${userLabel}`;
613
644
  node.parentNode.replaceChild(link, node);
614
645
  mentionedUsersUris.push(userUri);
615
646
  });
616
- if (document.body.innerHTML === "undefined") notify("Votre commentaire est vide", {
617
- type: "error"
647
+ if (document.body.innerHTML === 'undefined') notify('Votre commentaire est vide', {
648
+ type: 'error'
618
649
  });
619
650
  else {
620
651
  const tempId = Date.now();
@@ -640,13 +671,13 @@ const $703eba3e46be7ee5$var$PostCommentForm = ({ context: context, placeholder:
640
671
  ]
641
672
  });
642
673
  notify("Commentaire post\xe9 avec succ\xe8s", {
643
- type: "success"
674
+ type: 'success'
644
675
  });
645
676
  } catch (e) {
646
677
  console.error(e);
647
678
  removeItem(tempId);
648
679
  notify(e.message, {
649
- type: "error"
680
+ type: 'error'
650
681
  });
651
682
  }
652
683
  }
@@ -698,7 +729,7 @@ const $703eba3e46be7ee5$var$PostCommentForm = ({ context: context, placeholder:
698
729
  }) : null,
699
730
  mentions ? (0, $9b1343b281972d72$export$2e2bcd8739ae039).configure({
700
731
  HTMLAttributes: {
701
- class: "mention"
732
+ class: 'mention'
702
733
  },
703
734
  suggestion: mentions
704
735
  }) : null
@@ -743,10 +774,10 @@ const $d68cd57b2d06b6d5$var$useStyles = (0, ($parcel$interopDefault($583VT$muist
743
774
  paddingLeft: 80,
744
775
  marginTop: 8,
745
776
  minHeight: 80,
746
- position: "relative"
777
+ position: 'relative'
747
778
  },
748
779
  avatar: {
749
- position: "absolute",
780
+ position: 'absolute',
750
781
  top: 0,
751
782
  left: 0,
752
783
  bottom: 0,
@@ -758,26 +789,26 @@ const $d68cd57b2d06b6d5$var$useStyles = (0, ($parcel$interopDefault($583VT$muist
758
789
  paddingBottom: 8
759
790
  },
760
791
  label: {
761
- fontWeight: "bold"
792
+ fontWeight: 'bold'
762
793
  },
763
794
  content: {
764
- "& p": {
765
- marginBlockStart: "0.5em",
766
- marginBlockEnd: "0.5em"
795
+ '& p': {
796
+ marginBlockStart: '0.5em',
797
+ marginBlockEnd: '0.5em'
767
798
  }
768
799
  },
769
800
  loading: {
770
801
  zIndex: 1000,
771
- backgroundColor: "white",
802
+ backgroundColor: 'white',
772
803
  opacity: 0.5,
773
- position: "absolute",
804
+ position: 'absolute',
774
805
  top: 0,
775
806
  left: 0,
776
807
  right: 0,
777
808
  bottom: 0,
778
- display: "flex",
779
- alignItems: "center",
780
- justifyContent: "center",
809
+ display: 'flex',
810
+ alignItems: 'center',
811
+ justifyContent: 'center',
781
812
  minHeight: 200,
782
813
  marginTop: 5
783
814
  }
@@ -860,7 +891,7 @@ var $d68cd57b2d06b6d5$export$2e2bcd8739ae039 = $d68cd57b2d06b6d5$var$CommentsLis
860
891
  const $2e5504cc4159ca8d$var$CommentsField = ({ source: source, context: context, helperText: helperText, placeholder: placeholder, userResource: userResource, mentions: mentions })=>{
861
892
  const record = (0, $583VT$reactadmin.useRecordContext)();
862
893
  const { items: comments, loading: loading, addItem: addItem, removeItem: removeItem } = (0, $5ca5f7e9fc1c3544$export$2e2bcd8739ae039)(record.replies);
863
- if (!userResource) throw new Error("No userResource defined for CommentsField");
894
+ if (!userResource) throw new Error('No userResource defined for CommentsField');
864
895
  return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsxs)((0, $583VT$reactjsxruntime.Fragment), {
865
896
  children: [
866
897
  /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $703eba3e46be7ee5$export$2e2bcd8739ae039), {
@@ -881,10 +912,10 @@ const $2e5504cc4159ca8d$var$CommentsField = ({ source: source, context: context,
881
912
  });
882
913
  };
883
914
  $2e5504cc4159ca8d$var$CommentsField.defaultProps = {
884
- label: "Commentaires",
915
+ label: 'Commentaires',
885
916
  placeholder: "Commencez \xe0 taper votre commentaire...",
886
- source: "id",
887
- context: "id"
917
+ source: 'id',
918
+ context: 'id'
888
919
  };
889
920
  var $2e5504cc4159ca8d$export$2e2bcd8739ae039 = $2e5504cc4159ca8d$var$CommentsField;
890
921
 
@@ -894,7 +925,7 @@ var $2e5504cc4159ca8d$export$2e2bcd8739ae039 = $2e5504cc4159ca8d$var$CommentsFie
894
925
 
895
926
 
896
927
  const $505d598a33288aad$var$CollectionList = ({ collectionUrl: collectionUrl, resource: resource, children: children })=>{
897
- if ((0, ($parcel$interopDefault($583VT$react))).Children.count(children) !== 1) throw new Error("<CollectionList> only accepts a single child");
928
+ if ((0, ($parcel$interopDefault($583VT$react))).Children.count(children) !== 1) throw new Error('<CollectionList> only accepts a single child');
898
929
  const { items: actorsUris } = (0, $5ca5f7e9fc1c3544$export$2e2bcd8739ae039)(collectionUrl);
899
930
  const { data: data, isLoading: isLoading, isFetching: isFetching } = (0, $583VT$reactadmin.useGetMany)(resource, {
900
931
  ids: Array.isArray(actorsUris) ? actorsUris : [
@@ -922,7 +953,7 @@ var $505d598a33288aad$export$2e2bcd8739ae039 = $505d598a33288aad$var$CollectionL
922
953
 
923
954
  const $b0c94a9bdea99da5$var$ReferenceCollectionField = ({ source: source, reference: reference, children: children, ...rest })=>{
924
955
  const record = (0, $583VT$reactadmin.useRecordContext)();
925
- if ((0, ($parcel$interopDefault($583VT$react))).Children.count(children) !== 1) throw new Error("<ReferenceCollectionField> only accepts a single child");
956
+ if ((0, ($parcel$interopDefault($583VT$react))).Children.count(children) !== 1) throw new Error('<ReferenceCollectionField> only accepts a single child');
926
957
  if (!record || !record[source]) return null;
927
958
  return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $505d598a33288aad$export$2e2bcd8739ae039), {
928
959
  resource: reference,
@@ -947,7 +978,7 @@ var $b0c94a9bdea99da5$export$2e2bcd8739ae039 = $b0c94a9bdea99da5$var$ReferenceCo
947
978
  * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: false }`
948
979
  */ const $486f741c94cd8f74$var$useInbox = (options = {})=>{
949
980
  const { data: identity } = (0, $583VT$reactadmin.useGetIdentity)();
950
- const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $5ca5f7e9fc1c3544$export$2e2bcd8739ae039)("inbox", options);
981
+ const { url: url, items: items, awaitWebSocketConnection: awaitWebSocketConnection, ...rest } = (0, $5ca5f7e9fc1c3544$export$2e2bcd8739ae039)('inbox', options);
951
982
  const awaitActivity = (0, $5e70f9d0635e25dd$export$2e2bcd8739ae039)(awaitWebSocketConnection, items);
952
983
  return {
953
984
  url: url,
@@ -963,12 +994,12 @@ var $486f741c94cd8f74$export$2e2bcd8739ae039 = $486f741c94cd8f74$var$useInbox;
963
994
 
964
995
 
965
996
 
966
- const $59fc2d2cba62bd8e$var$useNodeinfo = (host, rel = "http://nodeinfo.diaspora.software/ns/schema/2.1")=>{
997
+ const $59fc2d2cba62bd8e$var$useNodeinfo = (host, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1')=>{
967
998
  const [schema, setSchema] = (0, $583VT$react.useState)();
968
999
  (0, $583VT$react.useEffect)(()=>{
969
1000
  (async ()=>{
970
1001
  if (host && rel) {
971
- const protocol = host.includes(":") ? "http" : "https"; // If the host has a port, we are likely on HTTP
1002
+ const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP
972
1003
  const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;
973
1004
  try {
974
1005
  const { json: links } = await (0, $583VT$reactadmin.fetchUtils).fetchJson(nodeinfoUrl);
@@ -1000,13 +1031,13 @@ const $5b61553556e35016$var$useWebfinger = ()=>{
1000
1031
  // Post an activity to the logged user's outbox and return its URI
1001
1032
  const fetch = (0, $583VT$react.useCallback)(async (id)=>{
1002
1033
  // eslint-disable-next-line
1003
- const [_, username, host] = id.split("@");
1034
+ const [_, username, host] = id.split('@');
1004
1035
  if (host) {
1005
- const protocol = host.includes(":") ? "http" : "https"; // If the host has a port, we are most likely on localhost
1036
+ const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost
1006
1037
  const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;
1007
1038
  try {
1008
1039
  const { json: json } = await (0, $583VT$reactadmin.fetchUtils).fetchJson(webfingerUrl);
1009
- const link = json.links.find((l)=>l.type === "application/activity+json");
1040
+ const link = json.links.find((l)=>l.type === 'application/activity+json');
1010
1041
  return link ? link.href : null;
1011
1042
  } catch (e) {
1012
1043
  return null;
@@ -1030,26 +1061,26 @@ var $5b61553556e35016$export$2e2bcd8739ae039 = $5b61553556e35016$var$useWebfinge
1030
1061
 
1031
1062
  const $27d3788851661769$var$useStyles = (0, ($parcel$interopDefault($583VT$muistylesmakeStyles)))((theme)=>({
1032
1063
  items: {
1033
- background: "#fff",
1034
- borderRadius: "0.5rem",
1035
- boxShadow: "0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)",
1036
- color: "rgba(0, 0, 0, 0.8)",
1037
- fontSize: "0.9rem",
1038
- overflow: "hidden",
1039
- padding: "0.2rem",
1040
- position: "relative"
1064
+ background: '#fff',
1065
+ borderRadius: '0.5rem',
1066
+ boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',
1067
+ color: 'rgba(0, 0, 0, 0.8)',
1068
+ fontSize: '0.9rem',
1069
+ overflow: 'hidden',
1070
+ padding: '0.2rem',
1071
+ position: 'relative'
1041
1072
  },
1042
1073
  item: {
1043
- background: "transparent",
1044
- border: "1px solid transparent",
1045
- borderRadius: "0.4rem",
1046
- display: "block",
1074
+ background: 'transparent',
1075
+ border: '1px solid transparent',
1076
+ borderRadius: '0.4rem',
1077
+ display: 'block',
1047
1078
  margin: 0,
1048
- padding: "0.2rem 0.4rem",
1049
- textAlign: "left",
1050
- width: "100%",
1051
- "&.selected": {
1052
- borderColor: "#000"
1079
+ padding: '0.2rem 0.4rem',
1080
+ textAlign: 'left',
1081
+ width: '100%',
1082
+ '&.selected': {
1083
+ borderColor: '#000'
1053
1084
  }
1054
1085
  }
1055
1086
  }));
@@ -1076,15 +1107,15 @@ var $27d3788851661769$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $583VT$react.fo
1076
1107
  ]);
1077
1108
  (0, $583VT$react.useImperativeHandle)(ref, ()=>({
1078
1109
  onKeyDown: ({ event: event })=>{
1079
- if (event.key === "ArrowUp") {
1110
+ if (event.key === 'ArrowUp') {
1080
1111
  upHandler();
1081
1112
  return true;
1082
1113
  }
1083
- if (event.key === "ArrowDown") {
1114
+ if (event.key === 'ArrowDown') {
1084
1115
  downHandler();
1085
1116
  return true;
1086
1117
  }
1087
- if (event.key === "Enter") {
1118
+ if (event.key === 'Enter') {
1088
1119
  enterHandler();
1089
1120
  return true;
1090
1121
  }
@@ -1094,7 +1125,7 @@ var $27d3788851661769$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $583VT$react.fo
1094
1125
  return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)("div", {
1095
1126
  className: classes.items,
1096
1127
  children: props.items.length ? props.items.map((item, index)=>/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)("button", {
1097
- className: classes.item + (index === selectedIndex ? " selected" : ""),
1128
+ className: classes.item + (index === selectedIndex ? ' selected' : ''),
1098
1129
  onClick: ()=>selectItem(index),
1099
1130
  children: item.label
1100
1131
  }, index)) : /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)("div", {
@@ -1114,14 +1145,14 @@ const $7b7f4b18327176f8$var$renderMentions = ()=>{
1114
1145
  props: props,
1115
1146
  editor: props.editor
1116
1147
  });
1117
- popup = (0, ($parcel$interopDefault($583VT$tippyjs)))("body", {
1148
+ popup = (0, ($parcel$interopDefault($583VT$tippyjs)))('body', {
1118
1149
  getReferenceClientRect: props.clientRect,
1119
1150
  appendTo: ()=>document.body,
1120
1151
  content: component.element,
1121
1152
  showOnCreate: true,
1122
1153
  interactive: true,
1123
- trigger: "manual",
1124
- placement: "bottom-start"
1154
+ trigger: 'manual',
1155
+ placement: 'bottom-start'
1125
1156
  });
1126
1157
  },
1127
1158
  onUpdate (props) {
@@ -1131,7 +1162,7 @@ const $7b7f4b18327176f8$var$renderMentions = ()=>{
1131
1162
  });
1132
1163
  },
1133
1164
  onKeyDown (props) {
1134
- if (props.event.key === "Escape") {
1165
+ if (props.event.key === 'Escape') {
1135
1166
  popup[0].hide();
1136
1167
  return true;
1137
1168
  }