@semapps/activitypub-components 0.6.0-alpha.2 → 0.6.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.cjs.js +138 -107
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +141 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +136 -108
- package/dist/index.es.js.map +1 -1
- package/package.json +9 -11
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Development
|
|
4
4
|
|
|
5
|
-
### `
|
|
5
|
+
### `yarn run build`
|
|
6
6
|
|
|
7
7
|
Build the library in CommonJS and ES mode.
|
|
8
8
|
This command should always be run before publishing.
|
|
9
9
|
|
|
10
|
-
### `
|
|
10
|
+
### `yarn run watch`
|
|
11
11
|
|
|
12
12
|
Develop mode. Any change you make to a file in the `/src` directory will be immediately compiled.
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
5
|
-
var $
|
|
6
|
-
var $
|
|
7
|
-
var $
|
|
8
|
-
var $
|
|
9
|
-
var $
|
|
10
|
-
var $
|
|
11
|
-
var $
|
|
12
|
-
var $
|
|
13
|
-
var $
|
|
14
|
-
var $
|
|
15
|
-
var $
|
|
1
|
+
var $583VT$reactjsxruntime = require("react/jsx-runtime");
|
|
2
|
+
var $583VT$react = require("react");
|
|
3
|
+
var $583VT$reactadmin = require("react-admin");
|
|
4
|
+
var $583VT$rainputrichtext = require("ra-input-rich-text");
|
|
5
|
+
var $583VT$tiptapextensionplaceholder = require("@tiptap/extension-placeholder");
|
|
6
|
+
var $583VT$muimaterial = require("@mui/material");
|
|
7
|
+
var $583VT$muistylesmakeStyles = require("@mui/styles/makeStyles");
|
|
8
|
+
var $583VT$muiiconsmaterialSend = require("@mui/icons-material/Send");
|
|
9
|
+
var $583VT$semappssemanticdataprovider = require("@semapps/semantic-data-provider");
|
|
10
|
+
var $583VT$semappsauthprovider = require("@semapps/auth-provider");
|
|
11
|
+
var $583VT$tiptapcore = require("@tiptap/core");
|
|
12
|
+
var $583VT$tiptapextensionmention = require("@tiptap/extension-mention");
|
|
13
|
+
var $583VT$semappsfieldcomponents = require("@semapps/field-components");
|
|
14
|
+
var $583VT$tiptapreact = require("@tiptap/react");
|
|
15
|
+
var $583VT$tippyjs = require("tippy.js");
|
|
16
|
+
|
|
16
17
|
|
|
17
18
|
function $parcel$export(e, n, v, s) {
|
|
18
19
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
19
20
|
}
|
|
21
|
+
|
|
20
22
|
function $parcel$interopDefault(a) {
|
|
21
23
|
return a && a.__esModule ? a.default : a;
|
|
22
24
|
}
|
|
@@ -26,6 +28,7 @@ $parcel$export(module.exports, "CollectionList", () => $505d598a33288aad$export$
|
|
|
26
28
|
$parcel$export(module.exports, "ReferenceCollectionField", () => $b0c94a9bdea99da5$export$2e2bcd8739ae039);
|
|
27
29
|
$parcel$export(module.exports, "useCollection", () => $2b75a2f49c9ef165$export$2e2bcd8739ae039);
|
|
28
30
|
$parcel$export(module.exports, "useInbox", () => $97664763db3c0a46$export$2e2bcd8739ae039);
|
|
31
|
+
$parcel$export(module.exports, "useNodeinfo", () => $30fd77858150739b$export$2e2bcd8739ae039);
|
|
29
32
|
$parcel$export(module.exports, "useOutbox", () => $decfdd34cc00b80e$export$2e2bcd8739ae039);
|
|
30
33
|
$parcel$export(module.exports, "useWebfinger", () => $5b61553556e35016$export$2e2bcd8739ae039);
|
|
31
34
|
$parcel$export(module.exports, "useMentions", () => $968ea07fb81eda0b$export$2e2bcd8739ae039);
|
|
@@ -105,22 +108,22 @@ const $ebea823cebb2f44b$export$4d8d554031975581 = "https://www.w3.org/ns/activit
|
|
|
105
108
|
|
|
106
109
|
|
|
107
110
|
const $decfdd34cc00b80e$var$useOutbox = ()=>{
|
|
108
|
-
const { identity: identity } = (0, $
|
|
109
|
-
const outboxUrl = (0, $
|
|
111
|
+
const { identity: identity } = (0, $583VT$reactadmin.useGetIdentity)();
|
|
112
|
+
const outboxUrl = (0, $583VT$react.useMemo)(()=>{
|
|
110
113
|
if (identity?.webIdData) return identity?.webIdData?.outbox;
|
|
111
114
|
}, [
|
|
112
115
|
identity
|
|
113
116
|
]);
|
|
114
|
-
const sparqlEndpoint = (0, $
|
|
117
|
+
const sparqlEndpoint = (0, $583VT$react.useMemo)(()=>{
|
|
115
118
|
if (identity?.webIdData) return identity?.webIdData?.endpoints?.["void:sparqlEndpoint"] || `${identity?.id}/sparql`;
|
|
116
119
|
}, [
|
|
117
120
|
identity
|
|
118
121
|
]);
|
|
119
122
|
// Post an activity to the logged user's outbox and return its URI
|
|
120
|
-
const post = (0, $
|
|
123
|
+
const post = (0, $583VT$react.useCallback)(async (activity)=>{
|
|
121
124
|
if (!outboxUrl) throw new Error("Cannot post to outbox before user identity is loaded. Please use the loaded argument of useOutbox");
|
|
122
125
|
const token = localStorage.getItem("token");
|
|
123
|
-
const { headers: headers } = await (0, $
|
|
126
|
+
const { headers: headers } = await (0, $583VT$reactadmin.fetchUtils).fetchJson(outboxUrl, {
|
|
124
127
|
method: "POST",
|
|
125
128
|
body: JSON.stringify({
|
|
126
129
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
@@ -135,10 +138,10 @@ const $decfdd34cc00b80e$var$useOutbox = ()=>{
|
|
|
135
138
|
}, [
|
|
136
139
|
outboxUrl
|
|
137
140
|
]);
|
|
138
|
-
const fetch = (0, $
|
|
141
|
+
const fetch = (0, $583VT$react.useCallback)(async ()=>{
|
|
139
142
|
if (!sparqlEndpoint || !outboxUrl) return;
|
|
140
143
|
const token = localStorage.getItem("token");
|
|
141
|
-
const blankNodesQuery = (0, $
|
|
144
|
+
const blankNodesQuery = (0, $583VT$semappssemanticdataprovider.buildBlankNodesQuery)([
|
|
142
145
|
"as:object"
|
|
143
146
|
]);
|
|
144
147
|
const query = `
|
|
@@ -153,7 +156,7 @@ const $decfdd34cc00b80e$var$useOutbox = ()=>{
|
|
|
153
156
|
${blankNodesQuery.where}
|
|
154
157
|
}
|
|
155
158
|
`;
|
|
156
|
-
const { json: json } = await (0, $
|
|
159
|
+
const { json: json } = await (0, $583VT$reactadmin.fetchUtils).fetchJson(sparqlEndpoint, {
|
|
157
160
|
method: "POST",
|
|
158
161
|
body: query,
|
|
159
162
|
headers: new Headers({
|
|
@@ -183,11 +186,11 @@ var $decfdd34cc00b80e$export$2e2bcd8739ae039 = $decfdd34cc00b80e$var$useOutbox;
|
|
|
183
186
|
// Fix a bug in the current version of the mention extension
|
|
184
187
|
// (The { id, label } object is located inside the id property)
|
|
185
188
|
// See https://github.com/ueberdosis/tiptap/pull/1322
|
|
186
|
-
const $9b1343b281972d72$var$CustomMention = (0, ($parcel$interopDefault($
|
|
189
|
+
const $9b1343b281972d72$var$CustomMention = (0, ($parcel$interopDefault($583VT$tiptapextensionmention))).extend({
|
|
187
190
|
renderHTML ({ node: node, HTMLAttributes: HTMLAttributes }) {
|
|
188
191
|
return [
|
|
189
192
|
"span",
|
|
190
|
-
(0, $
|
|
193
|
+
(0, $583VT$tiptapcore.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
|
|
191
194
|
`@${node.attrs.id.label}`
|
|
192
195
|
];
|
|
193
196
|
},
|
|
@@ -227,7 +230,7 @@ const $9b1343b281972d72$var$CustomMention = (0, ($parcel$interopDefault($jwOeV$t
|
|
|
227
230
|
var $9b1343b281972d72$export$2e2bcd8739ae039 = $9b1343b281972d72$var$CustomMention;
|
|
228
231
|
|
|
229
232
|
|
|
230
|
-
const $703eba3e46be7ee5$var$useStyles = (0, ($parcel$interopDefault($
|
|
233
|
+
const $703eba3e46be7ee5$var$useStyles = (0, ($parcel$interopDefault($583VT$muistylesmakeStyles)))((theme)=>({
|
|
231
234
|
form: {
|
|
232
235
|
marginTop: -12 // Negative margin to keep the form close to the label
|
|
233
236
|
},
|
|
@@ -275,15 +278,15 @@ const $703eba3e46be7ee5$var$useStyles = (0, ($parcel$interopDefault($jwOeV$muist
|
|
|
275
278
|
}));
|
|
276
279
|
const $703eba3e46be7ee5$var$EmptyToolbar = ()=>null;
|
|
277
280
|
const $703eba3e46be7ee5$var$PostCommentForm = ({ context: context, placeholder: placeholder, helperText: helperText, mentions: mentions, userResource: userResource, addItem: addItem, removeItem: removeItem })=>{
|
|
278
|
-
const record = (0, $
|
|
279
|
-
const { identity: identity, isLoading: isLoading } = (0, $
|
|
280
|
-
const userDataModel = (0, $
|
|
281
|
+
const record = (0, $583VT$reactadmin.useRecordContext)();
|
|
282
|
+
const { identity: identity, isLoading: isLoading } = (0, $583VT$reactadmin.useGetIdentity)();
|
|
283
|
+
const userDataModel = (0, $583VT$semappssemanticdataprovider.useDataModel)(userResource);
|
|
281
284
|
const classes = $703eba3e46be7ee5$var$useStyles();
|
|
282
|
-
const notify = (0, $
|
|
285
|
+
const notify = (0, $583VT$reactadmin.useNotify)();
|
|
283
286
|
const outbox = (0, $decfdd34cc00b80e$export$2e2bcd8739ae039)();
|
|
284
|
-
const [expanded, setExpanded] = (0, $
|
|
285
|
-
const [openAuth, setOpenAuth] = (0, $
|
|
286
|
-
const onSubmit = (0, $
|
|
287
|
+
const [expanded, setExpanded] = (0, $583VT$react.useState)(false);
|
|
288
|
+
const [openAuth, setOpenAuth] = (0, $583VT$react.useState)(false);
|
|
289
|
+
const onSubmit = (0, $583VT$react.useCallback)(async (values)=>{
|
|
287
290
|
const document = new DOMParser().parseFromString(values.comment, "text/html");
|
|
288
291
|
const mentions = Array.from(document.body.getElementsByClassName("mention"));
|
|
289
292
|
const mentionedUsersUris = [];
|
|
@@ -340,7 +343,7 @@ const $703eba3e46be7ee5$var$PostCommentForm = ({ context: context, placeholder:
|
|
|
340
343
|
addItem,
|
|
341
344
|
removeItem
|
|
342
345
|
]);
|
|
343
|
-
const openAuthIfDisconnected = (0, $
|
|
346
|
+
const openAuthIfDisconnected = (0, $583VT$react.useCallback)(()=>{
|
|
344
347
|
if (!identity?.id) setOpenAuth(true);
|
|
345
348
|
}, [
|
|
346
349
|
identity,
|
|
@@ -348,35 +351,35 @@ const $703eba3e46be7ee5$var$PostCommentForm = ({ context: context, placeholder:
|
|
|
348
351
|
]);
|
|
349
352
|
// Don't init the editor options until mentions and identity are loaded, as they can only be initialized once
|
|
350
353
|
if (mentions && !mentions.items || isLoading) return null;
|
|
351
|
-
return /*#__PURE__*/ (0, $
|
|
354
|
+
return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsxs)((0, $583VT$reactjsxruntime.Fragment), {
|
|
352
355
|
children: [
|
|
353
|
-
/*#__PURE__*/ (0, $
|
|
356
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$reactadmin.Form), {
|
|
354
357
|
onSubmit: onSubmit,
|
|
355
358
|
className: classes.form,
|
|
356
|
-
children: /*#__PURE__*/ (0, $
|
|
359
|
+
children: /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsxs)((0, $583VT$muimaterial.Box), {
|
|
357
360
|
className: classes.container,
|
|
358
361
|
onClick: openAuthIfDisconnected,
|
|
359
362
|
children: [
|
|
360
|
-
/*#__PURE__*/ (0, $
|
|
363
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$muimaterial.Avatar), {
|
|
361
364
|
src: identity?.webIdData?.[userDataModel?.fieldsMapping?.image] || identity?.profileData?.[userDataModel?.fieldsMapping?.image],
|
|
362
365
|
className: classes.avatar
|
|
363
366
|
}),
|
|
364
|
-
/*#__PURE__*/ (0, $
|
|
367
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$rainputrichtext.RichTextInput), {
|
|
365
368
|
source: "comment",
|
|
366
369
|
label: " ",
|
|
367
|
-
toolbar: /*#__PURE__*/ (0, $
|
|
370
|
+
toolbar: /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)($703eba3e46be7ee5$var$EmptyToolbar, {}),
|
|
368
371
|
fullWidth: true,
|
|
369
372
|
classes: {
|
|
370
373
|
editorContent: classes.editorContent
|
|
371
374
|
},
|
|
372
375
|
editorOptions: {
|
|
373
|
-
...(0, $
|
|
376
|
+
...(0, $583VT$rainputrichtext.DefaultEditorOptions),
|
|
374
377
|
onFocus () {
|
|
375
378
|
setExpanded(true);
|
|
376
379
|
},
|
|
377
380
|
extensions: [
|
|
378
|
-
...(0, $
|
|
379
|
-
placeholder ? (0, ($parcel$interopDefault($
|
|
381
|
+
...(0, $583VT$rainputrichtext.DefaultEditorOptions).extensions,
|
|
382
|
+
placeholder ? (0, ($parcel$interopDefault($583VT$tiptapextensionplaceholder))).configure({
|
|
380
383
|
placeholder: placeholder
|
|
381
384
|
}) : null,
|
|
382
385
|
mentions ? (0, $9b1343b281972d72$export$2e2bcd8739ae039).configure({
|
|
@@ -391,19 +394,19 @@ const $703eba3e46be7ee5$var$PostCommentForm = ({ context: context, placeholder:
|
|
|
391
394
|
},
|
|
392
395
|
helperText: helperText
|
|
393
396
|
}),
|
|
394
|
-
expanded && /*#__PURE__*/ (0, $
|
|
397
|
+
expanded && /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$muimaterial.Button), {
|
|
395
398
|
type: "submit",
|
|
396
399
|
size: "small",
|
|
397
400
|
variant: "contained",
|
|
398
401
|
color: "primary",
|
|
399
|
-
endIcon: /*#__PURE__*/ (0, $
|
|
402
|
+
endIcon: /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, ($parcel$interopDefault($583VT$muiiconsmaterialSend))), {}),
|
|
400
403
|
className: classes.button,
|
|
401
404
|
children: "Envoyer"
|
|
402
405
|
})
|
|
403
406
|
]
|
|
404
407
|
})
|
|
405
408
|
}),
|
|
406
|
-
/*#__PURE__*/ (0, $
|
|
409
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$semappsauthprovider.AuthDialog), {
|
|
407
410
|
open: openAuth,
|
|
408
411
|
onClose: ()=>setOpenAuth(false),
|
|
409
412
|
message: "Pour poster un commentaire, vous devez \xeatre connect\xe9."
|
|
@@ -421,7 +424,7 @@ var $703eba3e46be7ee5$export$2e2bcd8739ae039 = $703eba3e46be7ee5$var$PostComment
|
|
|
421
424
|
|
|
422
425
|
|
|
423
426
|
|
|
424
|
-
const $d68cd57b2d06b6d5$var$useStyles = (0, ($parcel$interopDefault($
|
|
427
|
+
const $d68cd57b2d06b6d5$var$useStyles = (0, ($parcel$interopDefault($583VT$muistylesmakeStyles)))(()=>({
|
|
425
428
|
container: {
|
|
426
429
|
paddingLeft: 80,
|
|
427
430
|
marginTop: 8,
|
|
@@ -467,44 +470,44 @@ const $d68cd57b2d06b6d5$var$useStyles = (0, ($parcel$interopDefault($jwOeV$muist
|
|
|
467
470
|
}));
|
|
468
471
|
const $d68cd57b2d06b6d5$var$CommentsList = ({ comments: comments, userResource: userResource, loading: loading })=>{
|
|
469
472
|
const classes = $d68cd57b2d06b6d5$var$useStyles();
|
|
470
|
-
const userDataModel = (0, $
|
|
471
|
-
return /*#__PURE__*/ (0, $
|
|
473
|
+
const userDataModel = (0, $583VT$semappssemanticdataprovider.useDataModel)(userResource);
|
|
474
|
+
return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsxs)((0, $583VT$muimaterial.Box), {
|
|
472
475
|
position: "relative",
|
|
473
476
|
children: [
|
|
474
|
-
comments && comments.sort((a, b)=>new Date(b.published) - new Date(a.published)).map((comment)=>/*#__PURE__*/ (0, $
|
|
477
|
+
comments && comments.sort((a, b)=>new Date(b.published) - new Date(a.published)).map((comment)=>/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsxs)((0, $583VT$muimaterial.Box), {
|
|
475
478
|
className: classes.container,
|
|
476
479
|
children: [
|
|
477
|
-
/*#__PURE__*/ (0, $
|
|
480
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$muimaterial.Box), {
|
|
478
481
|
className: classes.avatar,
|
|
479
|
-
children: /*#__PURE__*/ (0, $
|
|
482
|
+
children: /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$semappsfieldcomponents.ReferenceField), {
|
|
480
483
|
record: comment,
|
|
481
484
|
reference: userResource,
|
|
482
485
|
source: "attributedTo",
|
|
483
486
|
linkType: "show",
|
|
484
|
-
children: /*#__PURE__*/ (0, $
|
|
487
|
+
children: /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$semappsfieldcomponents.AvatarWithLabelField), {
|
|
485
488
|
image: userDataModel?.fieldsMapping?.image
|
|
486
489
|
})
|
|
487
490
|
})
|
|
488
491
|
}),
|
|
489
|
-
/*#__PURE__*/ (0, $
|
|
492
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsxs)((0, $583VT$muimaterial.Box), {
|
|
490
493
|
className: classes.text,
|
|
491
494
|
children: [
|
|
492
|
-
/*#__PURE__*/ (0, $
|
|
495
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsxs)((0, $583VT$muimaterial.Typography), {
|
|
493
496
|
variant: "body2",
|
|
494
497
|
children: [
|
|
495
|
-
/*#__PURE__*/ (0, $
|
|
498
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$semappsfieldcomponents.ReferenceField), {
|
|
496
499
|
record: comment,
|
|
497
500
|
reference: userResource,
|
|
498
501
|
source: "attributedTo",
|
|
499
502
|
linkType: "show",
|
|
500
|
-
children: /*#__PURE__*/ (0, $
|
|
503
|
+
children: /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$reactadmin.TextField), {
|
|
501
504
|
variant: "body2",
|
|
502
505
|
source: userDataModel?.fieldsMapping?.title,
|
|
503
506
|
className: classes.label
|
|
504
507
|
})
|
|
505
508
|
}),
|
|
506
|
-
"\xa0
|
|
507
|
-
/*#__PURE__*/ (0, $
|
|
509
|
+
"\xa0\u2022\xa0",
|
|
510
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$reactadmin.DateField), {
|
|
508
511
|
record: comment,
|
|
509
512
|
variant: "body2",
|
|
510
513
|
source: "published",
|
|
@@ -512,7 +515,7 @@ const $d68cd57b2d06b6d5$var$CommentsList = ({ comments: comments, userResource:
|
|
|
512
515
|
})
|
|
513
516
|
]
|
|
514
517
|
}),
|
|
515
|
-
/*#__PURE__*/ (0, $
|
|
518
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$reactadmin.RichTextField), {
|
|
516
519
|
record: comment,
|
|
517
520
|
variant: "body1",
|
|
518
521
|
source: "content",
|
|
@@ -522,12 +525,12 @@ const $d68cd57b2d06b6d5$var$CommentsList = ({ comments: comments, userResource:
|
|
|
522
525
|
})
|
|
523
526
|
]
|
|
524
527
|
}, comment.id)),
|
|
525
|
-
loading && /*#__PURE__*/ (0, $
|
|
528
|
+
loading && /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$muimaterial.Box), {
|
|
526
529
|
minHeight: 200,
|
|
527
|
-
children: /*#__PURE__*/ (0, $
|
|
530
|
+
children: /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$muimaterial.Box), {
|
|
528
531
|
alignItems: "center",
|
|
529
532
|
className: classes.loading,
|
|
530
|
-
children: /*#__PURE__*/ (0, $
|
|
533
|
+
children: /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$muimaterial.CircularProgress), {
|
|
531
534
|
size: 60,
|
|
532
535
|
thickness: 6
|
|
533
536
|
})
|
|
@@ -542,12 +545,12 @@ var $d68cd57b2d06b6d5$export$2e2bcd8739ae039 = $d68cd57b2d06b6d5$var$CommentsLis
|
|
|
542
545
|
|
|
543
546
|
|
|
544
547
|
const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl)=>{
|
|
545
|
-
const { identity: identity, isLoading: identityLoading } = (0, $
|
|
546
|
-
const [items, setItems] = (0, $
|
|
547
|
-
const [loading, setLoading] = (0, $
|
|
548
|
-
const [loaded, setLoaded] = (0, $
|
|
549
|
-
const [error, setError] = (0, $
|
|
550
|
-
const collectionUrl = (0, $
|
|
548
|
+
const { identity: identity, isLoading: identityLoading } = (0, $583VT$reactadmin.useGetIdentity)();
|
|
549
|
+
const [items, setItems] = (0, $583VT$react.useState)([]);
|
|
550
|
+
const [loading, setLoading] = (0, $583VT$react.useState)(false);
|
|
551
|
+
const [loaded, setLoaded] = (0, $583VT$react.useState)(false);
|
|
552
|
+
const [error, setError] = (0, $583VT$react.useState)(false);
|
|
553
|
+
const collectionUrl = (0, $583VT$react.useMemo)(()=>{
|
|
551
554
|
if (predicateOrUrl) {
|
|
552
555
|
if (predicateOrUrl.startsWith("http")) return predicateOrUrl;
|
|
553
556
|
if (identity?.webIdData) return identity?.webIdData?.[predicateOrUrl];
|
|
@@ -556,7 +559,7 @@ const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl)=>{
|
|
|
556
559
|
identity,
|
|
557
560
|
predicateOrUrl
|
|
558
561
|
]);
|
|
559
|
-
const fetch = (0, $
|
|
562
|
+
const fetch = (0, $583VT$react.useCallback)(async ()=>{
|
|
560
563
|
if (!collectionUrl) return;
|
|
561
564
|
setLoading(true);
|
|
562
565
|
const headers = new Headers({
|
|
@@ -567,7 +570,7 @@ const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl)=>{
|
|
|
567
570
|
const collectionOrigin = new URL(collectionUrl).origin;
|
|
568
571
|
const token = localStorage.getItem("token");
|
|
569
572
|
if (identityOrigin === collectionOrigin && token) headers.set("Authorization", `Bearer ${token}`);
|
|
570
|
-
(0, $
|
|
573
|
+
(0, $583VT$reactadmin.fetchUtils).fetchJson(collectionUrl, {
|
|
571
574
|
headers: headers
|
|
572
575
|
}).then(({ json: json })=>{
|
|
573
576
|
if (json && json.items) setItems(json.items);
|
|
@@ -589,7 +592,7 @@ const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl)=>{
|
|
|
589
592
|
collectionUrl,
|
|
590
593
|
identity
|
|
591
594
|
]);
|
|
592
|
-
(0, $
|
|
595
|
+
(0, $583VT$react.useEffect)(()=>{
|
|
593
596
|
if (!identityLoading && !loading && !loaded && !error) fetch();
|
|
594
597
|
}, [
|
|
595
598
|
fetch,
|
|
@@ -598,7 +601,7 @@ const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl)=>{
|
|
|
598
601
|
loaded,
|
|
599
602
|
error
|
|
600
603
|
]);
|
|
601
|
-
const addItem = (0, $
|
|
604
|
+
const addItem = (0, $583VT$react.useCallback)((item)=>{
|
|
602
605
|
setItems((oldItems)=>[
|
|
603
606
|
...oldItems,
|
|
604
607
|
item
|
|
@@ -606,7 +609,7 @@ const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl)=>{
|
|
|
606
609
|
}, [
|
|
607
610
|
setItems
|
|
608
611
|
]);
|
|
609
|
-
const removeItem = (0, $
|
|
612
|
+
const removeItem = (0, $583VT$react.useCallback)((itemId)=>{
|
|
610
613
|
setItems((oldItems)=>oldItems.filter((item)=>typeof item === "string" ? item !== itemId : item.id !== itemId));
|
|
611
614
|
}, [
|
|
612
615
|
setItems
|
|
@@ -626,12 +629,12 @@ var $2b75a2f49c9ef165$export$2e2bcd8739ae039 = $2b75a2f49c9ef165$var$useCollecti
|
|
|
626
629
|
|
|
627
630
|
|
|
628
631
|
const $2e5504cc4159ca8d$var$CommentsField = ({ source: source, context: context, helperText: helperText, placeholder: placeholder, userResource: userResource, mentions: mentions })=>{
|
|
629
|
-
const record = (0, $
|
|
632
|
+
const record = (0, $583VT$reactadmin.useRecordContext)();
|
|
630
633
|
const { items: comments, loading: loading, addItem: addItem, removeItem: removeItem } = (0, $2b75a2f49c9ef165$export$2e2bcd8739ae039)(record.replies);
|
|
631
634
|
if (!userResource) throw new Error("No userResource defined for CommentsField");
|
|
632
|
-
return /*#__PURE__*/ (0, $
|
|
635
|
+
return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsxs)((0, $583VT$reactjsxruntime.Fragment), {
|
|
633
636
|
children: [
|
|
634
|
-
/*#__PURE__*/ (0, $
|
|
637
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $703eba3e46be7ee5$export$2e2bcd8739ae039), {
|
|
635
638
|
context: context,
|
|
636
639
|
helperText: helperText,
|
|
637
640
|
userResource: userResource,
|
|
@@ -640,7 +643,7 @@ const $2e5504cc4159ca8d$var$CommentsField = ({ source: source, context: context,
|
|
|
640
643
|
addItem: addItem,
|
|
641
644
|
removeItem: removeItem
|
|
642
645
|
}),
|
|
643
|
-
/*#__PURE__*/ (0, $
|
|
646
|
+
/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $d68cd57b2d06b6d5$export$2e2bcd8739ae039), {
|
|
644
647
|
comments: comments,
|
|
645
648
|
loading: loading,
|
|
646
649
|
userResource: userResource
|
|
@@ -662,19 +665,19 @@ var $2e5504cc4159ca8d$export$2e2bcd8739ae039 = $2e5504cc4159ca8d$var$CommentsFie
|
|
|
662
665
|
|
|
663
666
|
|
|
664
667
|
const $505d598a33288aad$var$CollectionList = ({ collectionUrl: collectionUrl, resource: resource, children: children, ...rest })=>{
|
|
665
|
-
if ((0, ($parcel$interopDefault($
|
|
668
|
+
if ((0, ($parcel$interopDefault($583VT$react))).Children.count(children) !== 1) throw new Error("<CollectionList> only accepts a single child");
|
|
666
669
|
// TODO use a simple fetch call, as the resource is not good and it is useless
|
|
667
|
-
const { data: collection, isLoading: isLoading } = (0, $
|
|
670
|
+
const { data: collection, isLoading: isLoading } = (0, $583VT$reactadmin.useGetOne)(resource, collectionUrl, {
|
|
668
671
|
enabled: !!collectionUrl
|
|
669
672
|
});
|
|
670
|
-
if (isLoading) return /*#__PURE__*/ (0, $
|
|
673
|
+
if (isLoading) return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)("div", {
|
|
671
674
|
style: {
|
|
672
675
|
marginTop: 8
|
|
673
676
|
},
|
|
674
|
-
children: /*#__PURE__*/ (0, $
|
|
677
|
+
children: /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$reactadmin.LinearProgress), {})
|
|
675
678
|
});
|
|
676
679
|
if (!collection) return null;
|
|
677
|
-
return /*#__PURE__*/ (0, $
|
|
680
|
+
return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $583VT$semappsfieldcomponents.ReferenceArrayField), {
|
|
678
681
|
reference: resource,
|
|
679
682
|
record: collection,
|
|
680
683
|
source: "items",
|
|
@@ -689,9 +692,9 @@ var $505d598a33288aad$export$2e2bcd8739ae039 = $505d598a33288aad$var$CollectionL
|
|
|
689
692
|
|
|
690
693
|
|
|
691
694
|
const $b0c94a9bdea99da5$var$ReferenceCollectionField = ({ source: source, record: record, reference: reference, children: children, ...rest })=>{
|
|
692
|
-
if ((0, ($parcel$interopDefault($
|
|
695
|
+
if ((0, ($parcel$interopDefault($583VT$react))).Children.count(children) !== 1) throw new Error("<ReferenceCollectionField> only accepts a single child");
|
|
693
696
|
if (!record || !record[source]) return null;
|
|
694
|
-
return /*#__PURE__*/ (0, $
|
|
697
|
+
return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)((0, $505d598a33288aad$export$2e2bcd8739ae039), {
|
|
695
698
|
resource: reference,
|
|
696
699
|
collectionUrl: record[source],
|
|
697
700
|
...rest,
|
|
@@ -706,21 +709,21 @@ var $b0c94a9bdea99da5$export$2e2bcd8739ae039 = $b0c94a9bdea99da5$var$ReferenceCo
|
|
|
706
709
|
|
|
707
710
|
|
|
708
711
|
const $97664763db3c0a46$var$useInbox = ()=>{
|
|
709
|
-
const { identity: identity } = (0, $
|
|
710
|
-
const inboxUrl = (0, $
|
|
712
|
+
const { identity: identity } = (0, $583VT$reactadmin.useGetIdentity)();
|
|
713
|
+
const inboxUrl = (0, $583VT$react.useMemo)(()=>{
|
|
711
714
|
if (identity?.webIdData) return identity?.webIdData?.inbox;
|
|
712
715
|
}, [
|
|
713
716
|
identity
|
|
714
717
|
]);
|
|
715
|
-
const sparqlEndpoint = (0, $
|
|
718
|
+
const sparqlEndpoint = (0, $583VT$react.useMemo)(()=>{
|
|
716
719
|
if (identity?.webIdData) return identity?.webIdData?.endpoints?.["void:sparqlEndpoint"] || `${identity?.id}/sparql`;
|
|
717
720
|
}, [
|
|
718
721
|
identity
|
|
719
722
|
]);
|
|
720
|
-
const fetch = (0, $
|
|
723
|
+
const fetch = (0, $583VT$react.useCallback)(async ({ filters: filters })=>{
|
|
721
724
|
if (!sparqlEndpoint || !inboxUrl) return;
|
|
722
725
|
const token = localStorage.getItem("token");
|
|
723
|
-
const blankNodesQuery = (0, $
|
|
726
|
+
const blankNodesQuery = (0, $583VT$semappssemanticdataprovider.buildBlankNodesQuery)([
|
|
724
727
|
"as:object"
|
|
725
728
|
]);
|
|
726
729
|
let filtersWhereQuery = "";
|
|
@@ -744,7 +747,7 @@ const $97664763db3c0a46$var$useInbox = ()=>{
|
|
|
744
747
|
${blankNodesQuery.where}
|
|
745
748
|
}
|
|
746
749
|
`;
|
|
747
|
-
const { json: json } = await (0, $
|
|
750
|
+
const { json: json } = await (0, $583VT$reactadmin.fetchUtils).fetchJson(sparqlEndpoint, {
|
|
748
751
|
method: "POST",
|
|
749
752
|
body: query,
|
|
750
753
|
headers: new Headers({
|
|
@@ -769,17 +772,45 @@ var $97664763db3c0a46$export$2e2bcd8739ae039 = $97664763db3c0a46$var$useInbox;
|
|
|
769
772
|
|
|
770
773
|
|
|
771
774
|
|
|
775
|
+
const $30fd77858150739b$var$useNodeinfo = (host, rel = "http://nodeinfo.diaspora.software/ns/schema/2.1")=>{
|
|
776
|
+
const [schema, setSchema] = (0, $583VT$react.useState)();
|
|
777
|
+
(0, $583VT$react.useEffect)(()=>{
|
|
778
|
+
(async ()=>{
|
|
779
|
+
const protocol = host.includes(":") ? "http" : "https"; // If the host has a port, we are likely on HTTP
|
|
780
|
+
const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;
|
|
781
|
+
try {
|
|
782
|
+
const { json: links } = await (0, $583VT$reactadmin.fetchUtils).fetchJson(nodeinfoUrl);
|
|
783
|
+
// Accept any version of the nodeinfo protocol
|
|
784
|
+
const link = links?.links?.find((l)=>l.rel === rel);
|
|
785
|
+
const { json: json } = await (0, $583VT$reactadmin.fetchUtils).fetchJson(link.href);
|
|
786
|
+
setSchema(json);
|
|
787
|
+
} catch (e) {
|
|
788
|
+
// Do nothing if nodeinfo can't be fetched
|
|
789
|
+
}
|
|
790
|
+
})();
|
|
791
|
+
}, [
|
|
792
|
+
host,
|
|
793
|
+
setSchema,
|
|
794
|
+
rel
|
|
795
|
+
]);
|
|
796
|
+
return schema;
|
|
797
|
+
};
|
|
798
|
+
var $30fd77858150739b$export$2e2bcd8739ae039 = $30fd77858150739b$var$useNodeinfo;
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
772
803
|
|
|
773
804
|
const $5b61553556e35016$var$useWebfinger = ()=>{
|
|
774
805
|
// Post an activity to the logged user's outbox and return its URI
|
|
775
|
-
const fetch = (0, $
|
|
806
|
+
const fetch = (0, $583VT$react.useCallback)(async (id)=>{
|
|
776
807
|
// eslint-disable-next-line
|
|
777
808
|
const [_, username, host] = id.split("@");
|
|
778
809
|
if (host) {
|
|
779
810
|
const protocol = host.includes(":") ? "http" : "https"; // If the host has a port, we are most likely on localhost
|
|
780
811
|
const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;
|
|
781
812
|
try {
|
|
782
|
-
const { json: json } = await (0, $
|
|
813
|
+
const { json: json } = await (0, $583VT$reactadmin.fetchUtils).fetchJson(webfingerUrl);
|
|
783
814
|
const link = json.links.find((l)=>l.type === "application/activity+json");
|
|
784
815
|
return link ? link.href : null;
|
|
785
816
|
} catch (e) {
|
|
@@ -802,7 +833,7 @@ var $5b61553556e35016$export$2e2bcd8739ae039 = $5b61553556e35016$var$useWebfinge
|
|
|
802
833
|
|
|
803
834
|
|
|
804
835
|
|
|
805
|
-
const $27d3788851661769$var$useStyles = (0, ($parcel$interopDefault($
|
|
836
|
+
const $27d3788851661769$var$useStyles = (0, ($parcel$interopDefault($583VT$muistylesmakeStyles)))((theme)=>({
|
|
806
837
|
items: {
|
|
807
838
|
background: "#fff",
|
|
808
839
|
borderRadius: "0.5rem",
|
|
@@ -827,8 +858,8 @@ const $27d3788851661769$var$useStyles = (0, ($parcel$interopDefault($jwOeV$muist
|
|
|
827
858
|
}
|
|
828
859
|
}
|
|
829
860
|
}));
|
|
830
|
-
var $27d3788851661769$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $
|
|
831
|
-
const [selectedIndex, setSelectedIndex] = (0, $
|
|
861
|
+
var $27d3788851661769$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $583VT$react.forwardRef)((props, ref)=>{
|
|
862
|
+
const [selectedIndex, setSelectedIndex] = (0, $583VT$react.useState)(0);
|
|
832
863
|
const classes = $27d3788851661769$var$useStyles();
|
|
833
864
|
const selectItem = (index)=>{
|
|
834
865
|
const item = props.items[index];
|
|
@@ -845,10 +876,10 @@ var $27d3788851661769$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $jwOeV$react.fo
|
|
|
845
876
|
const enterHandler = ()=>{
|
|
846
877
|
selectItem(selectedIndex);
|
|
847
878
|
};
|
|
848
|
-
(0, $
|
|
879
|
+
(0, $583VT$react.useEffect)(()=>setSelectedIndex(0), [
|
|
849
880
|
props.items
|
|
850
881
|
]);
|
|
851
|
-
(0, $
|
|
882
|
+
(0, $583VT$react.useImperativeHandle)(ref, ()=>({
|
|
852
883
|
onKeyDown: ({ event: event })=>{
|
|
853
884
|
if (event.key === "ArrowUp") {
|
|
854
885
|
upHandler();
|
|
@@ -865,13 +896,13 @@ var $27d3788851661769$export$2e2bcd8739ae039 = /*#__PURE__*/ (0, $jwOeV$react.fo
|
|
|
865
896
|
return false;
|
|
866
897
|
}
|
|
867
898
|
}));
|
|
868
|
-
return /*#__PURE__*/ (0, $
|
|
899
|
+
return /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)("div", {
|
|
869
900
|
className: classes.items,
|
|
870
|
-
children: props.items.length ? props.items.map((item, index)=>/*#__PURE__*/ (0, $
|
|
901
|
+
children: props.items.length ? props.items.map((item, index)=>/*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)("button", {
|
|
871
902
|
className: classes.item + (index === selectedIndex ? " selected" : ""),
|
|
872
903
|
onClick: ()=>selectItem(index),
|
|
873
904
|
children: item.label
|
|
874
|
-
}, index)) : /*#__PURE__*/ (0, $
|
|
905
|
+
}, index)) : /*#__PURE__*/ (0, $583VT$reactjsxruntime.jsx)("div", {
|
|
875
906
|
className: classes.item,
|
|
876
907
|
children: "Aucun r\xe9sultat"
|
|
877
908
|
})
|
|
@@ -884,11 +915,11 @@ const $7b7f4b18327176f8$var$renderMentions = ()=>{
|
|
|
884
915
|
let popup;
|
|
885
916
|
return {
|
|
886
917
|
onStart: (props)=>{
|
|
887
|
-
component = new (0, $
|
|
918
|
+
component = new (0, $583VT$tiptapreact.ReactRenderer)((0, $27d3788851661769$export$2e2bcd8739ae039), {
|
|
888
919
|
props: props,
|
|
889
920
|
editor: props.editor
|
|
890
921
|
});
|
|
891
|
-
popup = (0, ($parcel$interopDefault($
|
|
922
|
+
popup = (0, ($parcel$interopDefault($583VT$tippyjs)))("body", {
|
|
892
923
|
getReferenceClientRect: props.clientRect,
|
|
893
924
|
appendTo: ()=>document.body,
|
|
894
925
|
content: component.element,
|
|
@@ -921,8 +952,8 @@ var $7b7f4b18327176f8$export$2e2bcd8739ae039 = $7b7f4b18327176f8$var$renderMenti
|
|
|
921
952
|
|
|
922
953
|
|
|
923
954
|
const $968ea07fb81eda0b$var$useMentions = (userResource)=>{
|
|
924
|
-
const userDataModel = (0, $
|
|
925
|
-
const { data: data } = (0, $
|
|
955
|
+
const userDataModel = (0, $583VT$semappssemanticdataprovider.useDataModel)(userResource);
|
|
956
|
+
const { data: data } = (0, $583VT$reactadmin.useGetList)(userResource, {
|
|
926
957
|
filter: {
|
|
927
958
|
_predicates: [
|
|
928
959
|
userDataModel?.fieldsMapping?.title
|
|
@@ -932,7 +963,7 @@ const $968ea07fb81eda0b$var$useMentions = (userResource)=>{
|
|
|
932
963
|
}, {
|
|
933
964
|
enabled: !!userDataModel?.fieldsMapping?.title
|
|
934
965
|
});
|
|
935
|
-
const availableMentions = (0, $
|
|
966
|
+
const availableMentions = (0, $583VT$react.useMemo)(()=>{
|
|
936
967
|
if (data) return data.map((item)=>({
|
|
937
968
|
id: item.id,
|
|
938
969
|
label: item[userDataModel?.fieldsMapping?.title]
|
|
@@ -940,7 +971,7 @@ const $968ea07fb81eda0b$var$useMentions = (userResource)=>{
|
|
|
940
971
|
}, [
|
|
941
972
|
data
|
|
942
973
|
]);
|
|
943
|
-
const items = (0, $
|
|
974
|
+
const items = (0, $583VT$react.useMemo)(()=>{
|
|
944
975
|
if (availableMentions) return ({ query: query })=>{
|
|
945
976
|
return availableMentions.filter(({ label: label })=>label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);
|
|
946
977
|
};
|