@openpeepshq/react 0.6.0 → 0.6.2
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/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/post/CompactReplyParent.js +8 -0
- package/dist/components/post/FeedPostContent.js +3 -0
- package/dist/components/post/NewResourceButton.d.ts +8 -0
- package/dist/components/post/NewResourceButton.js +36 -0
- package/dist/components/post/PostDetail.js +3 -0
- package/dist/components/post/index.d.ts +5 -0
- package/dist/components/post/index.js +3 -0
- package/dist/components/post/pieces/PostMenu.js +4 -0
- package/dist/components/post/post-form/PostTypeSwitcher.js +12 -2
- package/dist/components/post/post-form/ResourceForm.d.ts +7 -0
- package/dist/components/post/post-form/ResourceForm.js +68 -0
- package/dist/components/post/types/event/FullEvent.js +3 -1
- package/dist/components/post/types/resource/FullResource.d.ts +5 -0
- package/dist/components/post/types/resource/FullResource.js +99 -0
- package/dist/components/resources/CategoryPathPicker.d.ts +7 -0
- package/dist/components/resources/CategoryPathPicker.js +26 -0
- package/dist/components/resources/ResourceCard.d.ts +8 -0
- package/dist/components/resources/ResourceCard.js +121 -0
- package/dist/components/resources/ResourceLibrary.d.ts +4 -0
- package/dist/components/resources/ResourceLibrary.js +106 -0
- package/dist/components/resources/index.d.ts +6 -0
- package/dist/components/resources/index.js +3 -0
- package/dist/contexts/openpeeps/hooks/admin.d.ts +1064 -38
- package/dist/contexts/openpeeps/hooks/jams.d.ts +1064 -38
- package/dist/contexts/openpeeps/hooks/posts.d.ts +4508 -39936
- package/dist/hooks/events/useEventComposer.d.ts +1184 -44
- package/dist/hooks/events/useEventsCalendar.d.ts +2113 -61
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/jams/useCreateNewJamForm.d.ts +39 -1
- package/dist/hooks/jams/useJamDetails.d.ts +1064 -38
- package/dist/hooks/jams/useJamRoom.d.ts +2113 -61
- package/dist/hooks/posts/useArticleComposer.d.ts +1184 -44
- package/dist/hooks/posts/useFeedPostPresentation.d.ts +2113 -61
- package/dist/hooks/posts/usePostDetailTitle.d.ts +1064 -38
- package/dist/hooks/posts/useResourceComposer.d.ts +12019 -0
- package/dist/hooks/posts/useResourceComposer.js +139 -0
- package/dist/hooks/resources/useResourceLibrary.d.ts +21880 -0
- package/dist/hooks/resources/useResourceLibrary.js +130 -0
- package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
- package/dist/navigation/menuItems.js +5 -0
- package/dist/navigation/targets.d.ts +4 -0
- package/dist/pages/admin/analytics/Content.js +2 -1
- package/dist/pages/admin/analytics/Overview.js +15 -3
- package/dist/pages/groups/Show.js +7 -3
- package/dist/pages/index.d.ts +3 -0
- package/dist/pages/index.js +3 -0
- package/dist/pages/resources/Edit.d.ts +1 -0
- package/dist/pages/resources/Edit.js +26 -0
- package/dist/pages/resources/Index.d.ts +1 -0
- package/dist/pages/resources/Index.js +29 -0
- package/dist/pages/resources/New.d.ts +1 -0
- package/dist/pages/resources/New.js +15 -0
- package/dist/react-native.d.ts +1 -1
- package/dist/react-native.js +1 -1
- package/dist/stores/index.d.ts +1 -1
- package/dist/stores/index.js +1 -1
- package/dist/stores/newPosts.d.ts +79 -2
- package/dist/stores/newPosts.js +26 -2
- package/dist/stores/types.d.ts +2 -0
- package/package.json +6 -6
- package/src/components/index.ts +1 -0
- package/src/components/post/CompactReplyParent.tsx +8 -0
- package/src/components/post/FeedPostContent.tsx +3 -0
- package/src/components/post/NewResourceButton.tsx +75 -0
- package/src/components/post/PostDetail.tsx +3 -0
- package/src/components/post/index.ts +5 -0
- package/src/components/post/pieces/PostMenu.tsx +4 -0
- package/src/components/post/post-form/PostTypeSwitcher.tsx +19 -1
- package/src/components/post/post-form/ResourceForm.tsx +237 -0
- package/src/components/post/types/event/FullEvent.tsx +11 -3
- package/src/components/post/types/resource/FullResource.tsx +173 -0
- package/src/components/resources/CategoryPathPicker.tsx +95 -0
- package/src/components/resources/ResourceCard.tsx +335 -0
- package/src/components/resources/ResourceLibrary.tsx +374 -0
- package/src/components/resources/index.ts +6 -0
- package/src/contexts/openpeeps/hooks/posts.ts +11 -2
- package/src/hooks/index.ts +2 -0
- package/src/hooks/posts/useResourceComposer.ts +165 -0
- package/src/hooks/resources/useResourceLibrary.ts +156 -0
- package/src/navigation/menuItems.ts +6 -0
- package/src/navigation/targets.ts +1 -0
- package/src/pages/admin/analytics/Content.tsx +2 -1
- package/src/pages/admin/analytics/Overview.tsx +15 -3
- package/src/pages/groups/Show.tsx +30 -1
- package/src/pages/index.ts +3 -0
- package/src/pages/resources/Edit.tsx +73 -0
- package/src/pages/resources/Index.tsx +45 -0
- package/src/pages/resources/New.tsx +53 -0
- package/src/react-native.ts +1 -0
- package/src/stores/index.ts +1 -0
- package/src/stores/newPosts.ts +33 -2
- package/src/stores/types.ts +2 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { categoryTreeFromPaths, normalizeResourceTags, pathStartsWith, } from '@openpeepshq/common/lib';
|
|
3
|
+
import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
|
|
4
|
+
import { useFeedListParams } from '../useResolvedFeedFormat.js';
|
|
5
|
+
export const useResourceLibrary = (groupId) => {
|
|
6
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
7
|
+
const params = useFeedListParams({ format: 'linear' });
|
|
8
|
+
const query = openpeepsApi.usePostsByType('resource', {
|
|
9
|
+
...params,
|
|
10
|
+
...(groupId ? { groupId } : { ungrouped: 'true' }),
|
|
11
|
+
});
|
|
12
|
+
const bookmarkedIds = openpeepsApi.useCurrentProfileBookmarkedIds();
|
|
13
|
+
const [search, setSearch] = useState('');
|
|
14
|
+
const [kind, setKind] = useState('all');
|
|
15
|
+
const [selectedTags, setSelectedTags] = useState([]);
|
|
16
|
+
const [pathPrefix, setPathPrefix] = useState([]);
|
|
17
|
+
const [hierarchy, setHierarchy] = useState(false);
|
|
18
|
+
const [view, setView] = useState('cards');
|
|
19
|
+
const [saved, setSaved] = useState(false);
|
|
20
|
+
const posts = useMemo(() => {
|
|
21
|
+
const flat = (query.data?.pages ?? []).flat();
|
|
22
|
+
const seen = new Set();
|
|
23
|
+
const out = [];
|
|
24
|
+
for (const post of flat) {
|
|
25
|
+
if (seen.has(post.id) || post.type !== 'resource')
|
|
26
|
+
continue;
|
|
27
|
+
seen.add(post.id);
|
|
28
|
+
out.push(post);
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}, [query.data]);
|
|
32
|
+
const tags = useMemo(() => {
|
|
33
|
+
const counts = new Map();
|
|
34
|
+
for (const post of posts) {
|
|
35
|
+
if (post.data?.type !== 'resource')
|
|
36
|
+
continue;
|
|
37
|
+
for (const value of normalizeResourceTags(post.data.tags)) {
|
|
38
|
+
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return [...counts.entries()]
|
|
42
|
+
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
|
|
43
|
+
.map(([name, count]) => ({ name, count }));
|
|
44
|
+
}, [posts]);
|
|
45
|
+
const tree = useMemo(() => categoryTreeFromPaths(posts.flatMap((post) => post.data?.type === 'resource' && post.data.categoryPath?.length
|
|
46
|
+
? [post.data.categoryPath]
|
|
47
|
+
: [])), [posts]);
|
|
48
|
+
const toggleTag = (tag) => setSelectedTags((prev) => prev.includes(tag) ? prev.filter((t) => t !== tag) : [...prev, tag]);
|
|
49
|
+
const filtered = useMemo(() => {
|
|
50
|
+
const q = search.trim().toLowerCase();
|
|
51
|
+
const bookmarked = new Set(bookmarkedIds.data ?? []);
|
|
52
|
+
return posts.filter((post) => {
|
|
53
|
+
if (post.data?.type !== 'resource')
|
|
54
|
+
return false;
|
|
55
|
+
const resource = post.data;
|
|
56
|
+
if (kind !== 'all' && resource.resourceKind !== kind)
|
|
57
|
+
return false;
|
|
58
|
+
if (selectedTags.length > 0) {
|
|
59
|
+
const resourceTagSet = new Set(normalizeResourceTags(resource.tags));
|
|
60
|
+
if (!selectedTags.every((t) => resourceTagSet.has(t)))
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (pathPrefix.length &&
|
|
64
|
+
!pathStartsWith(resource.categoryPath ?? [], pathPrefix)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (saved && !bookmarked.has(post.id))
|
|
68
|
+
return false;
|
|
69
|
+
if (!q)
|
|
70
|
+
return true;
|
|
71
|
+
const hay = [
|
|
72
|
+
resource.title,
|
|
73
|
+
resource.content,
|
|
74
|
+
...(resource.tags ?? []),
|
|
75
|
+
...(resource.categoryPath ?? []),
|
|
76
|
+
resource.url,
|
|
77
|
+
]
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.join(' ')
|
|
80
|
+
.toLowerCase();
|
|
81
|
+
return hay.includes(q);
|
|
82
|
+
});
|
|
83
|
+
}, [
|
|
84
|
+
kind,
|
|
85
|
+
pathPrefix,
|
|
86
|
+
posts,
|
|
87
|
+
search,
|
|
88
|
+
selectedTags,
|
|
89
|
+
saved,
|
|
90
|
+
bookmarkedIds.data,
|
|
91
|
+
]);
|
|
92
|
+
const activeFilterCount = useMemo(() => (kind !== 'all' ? 1 : 0) +
|
|
93
|
+
(selectedTags.length ? 1 : 0) +
|
|
94
|
+
(pathPrefix.length ? 1 : 0) +
|
|
95
|
+
(search.trim() ? 1 : 0) +
|
|
96
|
+
(saved ? 1 : 0), [kind, pathPrefix, search, selectedTags, saved]);
|
|
97
|
+
const clearAllFilters = () => {
|
|
98
|
+
setKind('all');
|
|
99
|
+
setSelectedTags([]);
|
|
100
|
+
setPathPrefix([]);
|
|
101
|
+
setSearch('');
|
|
102
|
+
setSaved(false);
|
|
103
|
+
};
|
|
104
|
+
const [tagsOpen, setTagsOpen] = useState(false);
|
|
105
|
+
return {
|
|
106
|
+
query,
|
|
107
|
+
posts: filtered,
|
|
108
|
+
tags,
|
|
109
|
+
tree,
|
|
110
|
+
search,
|
|
111
|
+
setSearch,
|
|
112
|
+
kind,
|
|
113
|
+
setKind,
|
|
114
|
+
selectedTags,
|
|
115
|
+
setSelectedTags,
|
|
116
|
+
toggleTag,
|
|
117
|
+
pathPrefix,
|
|
118
|
+
setPathPrefix,
|
|
119
|
+
hierarchy,
|
|
120
|
+
setHierarchy,
|
|
121
|
+
view,
|
|
122
|
+
setView,
|
|
123
|
+
saved,
|
|
124
|
+
setSaved,
|
|
125
|
+
activeFilterCount,
|
|
126
|
+
clearAllFilters,
|
|
127
|
+
tagsOpen,
|
|
128
|
+
setTagsOpen,
|
|
129
|
+
};
|
|
130
|
+
};
|
|
@@ -7,7 +7,7 @@ export declare const useNotificationPreferences: ({ ensurePush, }?: UseNotificat
|
|
|
7
7
|
me: import("@openpeepshq/common").ProfileWithMeta | undefined;
|
|
8
8
|
types: {
|
|
9
9
|
type: string;
|
|
10
|
-
requiredCapabilities?: ("core-posts-delete" | "core-groups-read" | "core-groups-delete" | "core-groups-addMember" | "core-groups-removeMember" | "core-groups-changeMemberRole" | "core-profiles-read" | "core-profiles-update" | "core-profiles-delete" | "core-reports-create" | "core-serviceTokens-create" | "core-serviceTokens-read" | "core-serviceTokens-delete" | "core-local" | "core-accounts-read" | "core-accounts-create" | "core-accounts-update" | "core-accounts-delete" | "core-reports-update" | "core-groups-create" | "core-posts-create-note-local" | "core-posts-create-note-public" | "core-posts-create-note-direct" | "core-posts-create-note-private" | "core-posts-create-event-local" | "core-posts-create-event-public" | "core-posts-create-event-direct" | "core-posts-create-event-private" | "core-posts-create-poll-local" | "core-posts-create-poll-public" | "core-posts-create-poll-direct" | "core-posts-create-poll-private" | "core-posts-create-article-local" | "core-posts-create-article-public" | "core-posts-create-article-direct" | "core-posts-create-article-private" | "core-posts-read-local" | "core-posts-announce" | "core-profiles-roles-update" | "core-profiles-suspend" | "core-profiles-impersonate" | "core-analytics-read" | "core-config-update" | "core-config-read" | "core-customization-read" | "core-customization-update" | "core-capabilities-read" | "core-capabilities-update" | "core-backups-create" | "core-backups-read" | "core-backups-download" | "core-backups-restore" | "core-db-access" | "core-i18n-update" | "core-logs-read" | "core-roles-read" | "core-roles-update" | "core-maintenance-restart" | "core-inviteLinks-create" | "core-inviteLinks-read" | "core-inviteLinks-update" | "core-inviteLinks-delete" | "core-serviceTokens-update" | "core-plugins-manage")[] | undefined;
|
|
10
|
+
requiredCapabilities?: ("core-posts-delete" | "core-groups-read" | "core-groups-delete" | "core-groups-addMember" | "core-groups-removeMember" | "core-groups-changeMemberRole" | "core-profiles-read" | "core-profiles-update" | "core-profiles-delete" | "core-reports-create" | "core-serviceTokens-create" | "core-serviceTokens-read" | "core-serviceTokens-delete" | "core-local" | "core-accounts-read" | "core-accounts-create" | "core-accounts-update" | "core-accounts-delete" | "core-reports-update" | "core-groups-create" | "core-posts-create-note-local" | "core-posts-create-note-public" | "core-posts-create-note-direct" | "core-posts-create-note-private" | "core-posts-create-event-local" | "core-posts-create-event-public" | "core-posts-create-event-direct" | "core-posts-create-event-private" | "core-posts-create-poll-local" | "core-posts-create-poll-public" | "core-posts-create-poll-direct" | "core-posts-create-poll-private" | "core-posts-create-article-local" | "core-posts-create-article-public" | "core-posts-create-article-direct" | "core-posts-create-article-private" | "core-posts-create-resource-local" | "core-posts-create-resource-public" | "core-posts-create-resource-direct" | "core-posts-create-resource-private" | "core-posts-read-local" | "core-posts-announce" | "core-profiles-roles-update" | "core-profiles-suspend" | "core-profiles-impersonate" | "core-analytics-read" | "core-config-update" | "core-config-read" | "core-customization-read" | "core-customization-update" | "core-capabilities-read" | "core-capabilities-update" | "core-backups-create" | "core-backups-read" | "core-backups-download" | "core-backups-restore" | "core-db-access" | "core-i18n-update" | "core-logs-read" | "core-roles-read" | "core-roles-update" | "core-maintenance-restart" | "core-inviteLinks-create" | "core-inviteLinks-read" | "core-inviteLinks-update" | "core-inviteLinks-delete" | "core-serviceTokens-update" | "core-plugins-manage")[] | undefined;
|
|
11
11
|
defaultSettings?: {
|
|
12
12
|
create: boolean;
|
|
13
13
|
push: boolean;
|
|
@@ -49,6 +49,11 @@ export const buildMainNavItems = (caps) => {
|
|
|
49
49
|
target: { type: 'articles' },
|
|
50
50
|
labelKey: 'navigation.articles',
|
|
51
51
|
icon: 'ScrollText',
|
|
52
|
+
}, {
|
|
53
|
+
id: 'resources',
|
|
54
|
+
target: { type: 'resources' },
|
|
55
|
+
labelKey: 'navigation.resources',
|
|
56
|
+
icon: 'Library',
|
|
52
57
|
}, {
|
|
53
58
|
id: 'messages',
|
|
54
59
|
target: { type: 'conversation' },
|
|
@@ -10,6 +10,7 @@ const POST_TYPE_META = [
|
|
|
10
10
|
{ key: 'article', label: 'Articles', color: analyticsChartColor(1) },
|
|
11
11
|
{ key: 'note', label: 'Notes', color: analyticsChartColor(2) },
|
|
12
12
|
{ key: 'poll', label: 'Polls', color: analyticsChartColor(3) },
|
|
13
|
+
{ key: 'resource', label: 'Resources', color: analyticsChartColor(5) },
|
|
13
14
|
];
|
|
14
15
|
const utcDayCount = (from, to) => {
|
|
15
16
|
const start = Date.parse(`${from}T00:00:00.000Z`);
|
|
@@ -58,7 +59,7 @@ export const AnalyticsContentPage = () => {
|
|
|
58
59
|
const avgPostsPerDay = Math.round((postsThisPeriod / days) * 10) / 10;
|
|
59
60
|
const postsByPeriod = data.postsOverTime.map((p) => ({
|
|
60
61
|
label: p.label,
|
|
61
|
-
value: p.jam + p.article + p.note + p.poll + p.event,
|
|
62
|
+
value: p.jam + p.article + p.note + p.poll + p.event + p.resource,
|
|
62
63
|
}));
|
|
63
64
|
const info = (key, defaultValue) => t(`admin.analytics.info.${key}`, { defaultValue });
|
|
64
65
|
return (_jsxs("div", { className: "space-y-5", children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-3", children: [_jsx(MetricCard, { label: t('admin.analytics.metrics.totalPosts', {
|
|
@@ -10,6 +10,7 @@ const POST_TYPE_SERIES = [
|
|
|
10
10
|
{ key: 'note', label: 'Notes', color: analyticsChartColor(2) },
|
|
11
11
|
{ key: 'poll', label: 'Polls', color: analyticsChartColor(3) },
|
|
12
12
|
{ key: 'event', label: 'Events', color: analyticsChartColor(4) },
|
|
13
|
+
{ key: 'resource', label: 'Resources', color: analyticsChartColor(5) },
|
|
13
14
|
];
|
|
14
15
|
const PostTypesList = ({ items, }) => {
|
|
15
16
|
const max = Math.max(1, ...items.map((i) => i.count));
|
|
@@ -32,12 +33,13 @@ export const AnalyticsOverviewPage = () => {
|
|
|
32
33
|
return null;
|
|
33
34
|
const stackedData = data.postsOverTime.map((p) => ({
|
|
34
35
|
label: p.label,
|
|
35
|
-
value: p.jam + p.article + p.note + p.poll + p.event,
|
|
36
|
+
value: p.jam + p.article + p.note + p.poll + p.event + p.resource,
|
|
36
37
|
jam: p.jam,
|
|
37
38
|
article: p.article,
|
|
38
39
|
note: p.note,
|
|
39
40
|
poll: p.poll,
|
|
40
41
|
event: p.event,
|
|
42
|
+
resource: p.resource,
|
|
41
43
|
}));
|
|
42
44
|
const activeUsersChart = data.activeUsersSeries.map((p) => ({
|
|
43
45
|
label: p.label,
|
|
@@ -62,8 +64,17 @@ export const AnalyticsOverviewPage = () => {
|
|
|
62
64
|
defaultValue: 'All-time',
|
|
63
65
|
}), info: info('totalGroups', 'Count of non-deleted groups existing on or before the end of the selected range.') })] }), _jsxs("div", { className: "grid min-w-0 gap-4 lg:grid-cols-3", children: [_jsxs(AnalyticsSection, { className: "lg:col-span-2", title: t('admin.analytics.postsOverTime', {
|
|
64
66
|
defaultValue: 'Posts made over time',
|
|
65
|
-
}), info: info('postsOverTime', 'Posts created in each time bucket of the range, stacked by type (jams, articles, notes, polls, events).'), csvFilename: "posts-over-time.csv", csvRows: [
|
|
66
|
-
[
|
|
67
|
+
}), info: info('postsOverTime', 'Posts created in each time bucket of the range, stacked by type (jams, articles, notes, polls, events, resources).'), csvFilename: "posts-over-time.csv", csvRows: [
|
|
68
|
+
[
|
|
69
|
+
'bucket',
|
|
70
|
+
'label',
|
|
71
|
+
'jam',
|
|
72
|
+
'article',
|
|
73
|
+
'note',
|
|
74
|
+
'poll',
|
|
75
|
+
'event',
|
|
76
|
+
'resource',
|
|
77
|
+
],
|
|
67
78
|
...data.postsOverTime.map((p) => [
|
|
68
79
|
p.day,
|
|
69
80
|
p.label,
|
|
@@ -72,6 +83,7 @@ export const AnalyticsOverviewPage = () => {
|
|
|
72
83
|
p.note,
|
|
73
84
|
p.poll,
|
|
74
85
|
p.event,
|
|
86
|
+
p.resource,
|
|
75
87
|
]),
|
|
76
88
|
], children: [_jsx(AnalyticsStackedBarChart, { data: stackedData, series: POST_TYPE_SERIES }), _jsx("div", { className: "mt-3 flex flex-wrap gap-3 text-xs", children: POST_TYPE_SERIES.map((s) => (_jsxs("span", { className: "text-muted-foreground inline-flex items-center gap-1.5", children: [_jsx("span", { className: "inline-block size-2.5 rounded-full", style: { backgroundColor: s.color } }), s.label] }, s.key))) })] }), _jsx(AnalyticsSection, { title: t('admin.analytics.postTypes', {
|
|
77
89
|
defaultValue: 'Post types',
|
|
@@ -2,9 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useNavigate, useParams } from 'react-router-dom';
|
|
4
4
|
import { useT, useOpenpeeps } from '../../index.js';
|
|
5
|
-
import { EventsView, Feed, GroupFeed, GroupHeader, NewEventButton, PostMarkdown, useCurrentProfile, } from '../../components/index.js';
|
|
5
|
+
import { EventsView, Feed, GroupFeed, GroupHeader, NewEventButton, NewResourceButton, PostMarkdown, useCurrentProfile, } from '../../components/index.js';
|
|
6
6
|
import { routeHandleParam } from '../../lib/routeHandles.js';
|
|
7
7
|
import { LoadingSpinner } from '@openpeepshq/react-ui';
|
|
8
|
+
import { ResourceLibrary } from '../../components/resources/ResourceLibrary.js';
|
|
8
9
|
export function GroupShow() {
|
|
9
10
|
const t = useT();
|
|
10
11
|
const navigate = useNavigate();
|
|
@@ -52,12 +53,15 @@ export function GroupShow() {
|
|
|
52
53
|
}, children: t('groups.sections.posts', { defaultValue: 'Posts' }) }), _jsx(TabButton, { active: tab === 'events', onClick: () => {
|
|
53
54
|
setTab('events');
|
|
54
55
|
window.history.replaceState(null, '', `${window.location.pathname}#events`);
|
|
55
|
-
}, testId: "groups-tab-events", children: t('groups.sections.events', { defaultValue: 'Events' }) }), _jsx(TabButton, { active: tab === '
|
|
56
|
+
}, testId: "groups-tab-events", children: t('groups.sections.events', { defaultValue: 'Events' }) }), _jsx(TabButton, { active: tab === 'resources', onClick: () => {
|
|
57
|
+
setTab('resources');
|
|
58
|
+
window.history.replaceState(null, '', `${window.location.pathname}#resources`);
|
|
59
|
+
}, testId: "groups-tab-resources", children: t('groups.sections.resources', { defaultValue: 'Resources' }) }), _jsx(TabButton, { active: tab === 'description', onClick: () => {
|
|
56
60
|
setTab('description');
|
|
57
61
|
window.history.replaceState(null, '', `${window.location.pathname}#description`);
|
|
58
62
|
}, testId: "groups-tab-description", children: t('groups.sections.description', { defaultValue: 'Description' }) })] }), tab === 'posts' && _jsx(GroupFeed, { group: group }), tab === 'events' && (_jsxs("div", { children: [_jsx(NewEventButton, { visibility: "group", currentProfile: currentProfile, group: group, onNavigate: () => navigate('/events/new') }), _jsxs("nav", { "aria-label": t('groups.eventsTabs.label', {
|
|
59
63
|
defaultValue: 'Event timeframe',
|
|
60
|
-
}), className: "border-border flex border-b", children: [_jsx(TabButton, { active: eventsTab === 'upcoming', onClick: () => setEventsTab('upcoming'), children: t('events.feed.upcoming', { defaultValue: 'Upcoming' }) }), _jsx(TabButton, { active: eventsTab === 'past', onClick: () => setEventsTab('past'), children: t('events.feed.past', { defaultValue: 'Past' }) })] }), _jsx(EventsView, { query: eventsTab === 'upcoming' ? upcomingEvents : pastEvents, agenda: eventsTab, list: _jsx(Feed, { query: eventsTab === 'upcoming' ? upcomingEvents : pastEvents, formatSwitch: false }) })] })), tab === 'description' && (_jsxs("div", { className: "space-y-2 p-4", children: [_jsxs("section", { className: "border-b py-2", children: [_jsx("h3", { className: "text-lg font-semibold", children: "Description" }), _jsx(PostMarkdown, { source: group.description || 'No description yet' })] }), _jsxs("section", { className: "space-y-2 border-b py-2", children: [_jsx("h3", { className: "text-lg font-semibold", children: "Details" }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: "Created" }), _jsx("p", { children: new Date(group.createdAt).toLocaleDateString() })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.visibility.title') }), _jsx("p", { children: t(`groups.visibility.${visibilityValue}.description`) })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.whoCanJoin.title') }), _jsx("p", { children: t(`groups.whoCanJoin.${whoCanJoinValue}.description`) })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.whoCanPost.title') }), _jsxs("p", { children: [t(`groups.whoCanPost.${whoCanPostValue}.description`), ".", ' ', t(`groups.whoCanPostEvents.${whoCanPostEventsValue}.description`)] })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.postsVisibility.title') }), _jsx("p", { children: t(`groups.postsVisibility.${postsVisibilityValue}.description`) })] })] }), _jsxs("section", { className: "border-b py-2", children: [_jsx("h3", { className: "text-lg font-semibold", children: "Rules" }), _jsx(PostMarkdown, { source: group.rules || 'No rules yet' })] })] }))] }));
|
|
64
|
+
}), className: "border-border flex border-b", children: [_jsx(TabButton, { active: eventsTab === 'upcoming', onClick: () => setEventsTab('upcoming'), children: t('events.feed.upcoming', { defaultValue: 'Upcoming' }) }), _jsx(TabButton, { active: eventsTab === 'past', onClick: () => setEventsTab('past'), children: t('events.feed.past', { defaultValue: 'Past' }) })] }), _jsx(EventsView, { query: eventsTab === 'upcoming' ? upcomingEvents : pastEvents, agenda: eventsTab, list: _jsx(Feed, { query: eventsTab === 'upcoming' ? upcomingEvents : pastEvents, formatSwitch: false }) })] })), tab === 'resources' && (_jsxs("div", { children: [_jsx(NewResourceButton, { visibility: "group", currentProfile: currentProfile, group: group }), _jsx(ResourceLibrary, { groupId: group.id })] })), tab === 'description' && (_jsxs("div", { className: "space-y-2 p-4", children: [_jsxs("section", { className: "border-b py-2", children: [_jsx("h3", { className: "text-lg font-semibold", children: "Description" }), _jsx(PostMarkdown, { source: group.description || 'No description yet' })] }), _jsxs("section", { className: "space-y-2 border-b py-2", children: [_jsx("h3", { className: "text-lg font-semibold", children: "Details" }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: "Created" }), _jsx("p", { children: new Date(group.createdAt).toLocaleDateString() })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.visibility.title') }), _jsx("p", { children: t(`groups.visibility.${visibilityValue}.description`) })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.whoCanJoin.title') }), _jsx("p", { children: t(`groups.whoCanJoin.${whoCanJoinValue}.description`) })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.whoCanPost.title') }), _jsxs("p", { children: [t(`groups.whoCanPost.${whoCanPostValue}.description`), ".", ' ', t(`groups.whoCanPostEvents.${whoCanPostEventsValue}.description`)] })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.postsVisibility.title') }), _jsx("p", { children: t(`groups.postsVisibility.${postsVisibilityValue}.description`) })] })] }), _jsxs("section", { className: "border-b py-2", children: [_jsx("h3", { className: "text-lg font-semibold", children: "Rules" }), _jsx(PostMarkdown, { source: group.rules || 'No rules yet' })] })] }))] }));
|
|
61
65
|
}
|
|
62
66
|
function TabButton({ active, onClick, children, testId, }) {
|
|
63
67
|
return (_jsx("button", { type: "button", onClick: onClick, "data-testid": testId, className: `px-4 py-2 text-sm ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`, children: children }));
|
package/dist/pages/index.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ export { GroupMembers } from './groups/Members';
|
|
|
33
33
|
export { JamsIndex } from './jams/Index';
|
|
34
34
|
export { JamEvent } from './jams/Event';
|
|
35
35
|
export { ArticlesIndex } from './articles/Index';
|
|
36
|
+
export { ResourcesIndex } from './resources/Index';
|
|
37
|
+
export { NewResource } from './resources/New';
|
|
38
|
+
export { EditResource } from './resources/Edit';
|
|
36
39
|
export { Followers as ProfileFollowers } from './profile/Followers';
|
|
37
40
|
export { PublicProfileSettings } from './settings/PublicProfile';
|
|
38
41
|
export { ThemeSettings } from './settings/Theme';
|
package/dist/pages/index.js
CHANGED
|
@@ -33,6 +33,9 @@ export { GroupMembers } from './groups/Members.js';
|
|
|
33
33
|
export { JamsIndex } from './jams/Index.js';
|
|
34
34
|
export { JamEvent } from './jams/Event.js';
|
|
35
35
|
export { ArticlesIndex } from './articles/Index.js';
|
|
36
|
+
export { ResourcesIndex } from './resources/Index.js';
|
|
37
|
+
export { NewResource } from './resources/New.js';
|
|
38
|
+
export { EditResource } from './resources/Edit.js';
|
|
36
39
|
export { Followers as ProfileFollowers } from './profile/Followers.js';
|
|
37
40
|
export { PublicProfileSettings } from './settings/PublicProfile.js';
|
|
38
41
|
export { ThemeSettings } from './settings/Theme.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EditResource: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useParams } from 'react-router-dom';
|
|
4
|
+
import { truncateText } from '@openpeepshq/common/lib';
|
|
5
|
+
import { useT, useSetPageHeader } from '../../index.js';
|
|
6
|
+
import { ResourceForm } from '../../components/post/post-form/ResourceForm.js';
|
|
7
|
+
import { useEditResource } from '../../hooks/index.js';
|
|
8
|
+
import { Button, LoadingSpinner, Toast } from '@openpeepshq/react-ui';
|
|
9
|
+
export const EditResource = () => {
|
|
10
|
+
const t = useT();
|
|
11
|
+
const { resourceId = '' } = useParams();
|
|
12
|
+
const { postQuery, postData, setPostData, resourceTitle, submitting, error, clearError, submit, } = useEditResource(resourceId);
|
|
13
|
+
const headerActions = useMemo(() => (_jsx(Button, { title: t('resources.update.title', { defaultValue: 'Update resource' }), variant: "default", action: submit, disabled: submitting, children: submitting
|
|
14
|
+
? t('common.saving', { defaultValue: 'Saving…' })
|
|
15
|
+
: t('resources.update.title', { defaultValue: 'Update resource' }) })), [submit, submitting, t]);
|
|
16
|
+
useSetPageHeader(resourceTitle
|
|
17
|
+
? `${t('resources.edit', { defaultValue: 'Edit resource' })} ${truncateText(resourceTitle)}`
|
|
18
|
+
: t('resources.edit', { defaultValue: 'Edit resource' }), headerActions);
|
|
19
|
+
if (postQuery.isLoading) {
|
|
20
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: _jsx(LoadingSpinner, {}) }));
|
|
21
|
+
}
|
|
22
|
+
if (!postQuery.data || !postData) {
|
|
23
|
+
return (_jsx("div", { className: "p-8 text-center text-2xl", children: t('resources.notFound', { defaultValue: 'Resource not found' }) }));
|
|
24
|
+
}
|
|
25
|
+
return (_jsxs("div", { className: "pb-12", children: [_jsx(ResourceForm, { postData: postData, onChange: setPostData, isEdit: true }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ResourcesIndex: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { FilePlus } from 'lucide-react';
|
|
4
|
+
import { canCreatePostType } from '@openpeepshq/common/lib';
|
|
5
|
+
import { useT, useSetPageHeader, useSetPlusButtonActions, useAuthData, } from '../../index.js';
|
|
6
|
+
import { useNavigate } from '../../contexts/router/index.js';
|
|
7
|
+
import { ResourceLibrary } from '../../components/resources/ResourceLibrary.js';
|
|
8
|
+
import { getNewPostStores } from '../../stores/index.js';
|
|
9
|
+
export const ResourcesIndex = () => {
|
|
10
|
+
const t = useT();
|
|
11
|
+
const navigate = useNavigate();
|
|
12
|
+
const authData = useAuthData();
|
|
13
|
+
const canCreate = canCreatePostType(authData, 'resource');
|
|
14
|
+
const openNew = useCallback(() => {
|
|
15
|
+
const stores = getNewPostStores();
|
|
16
|
+
stores.resource = { ...stores.resource, groupId: undefined };
|
|
17
|
+
navigate({ type: 'resources', view: 'new' });
|
|
18
|
+
}, [navigate]);
|
|
19
|
+
const plusButton = useMemo(() => canCreate
|
|
20
|
+
? {
|
|
21
|
+
title: t('resources.new', { defaultValue: 'New resource' }),
|
|
22
|
+
icon: FilePlus,
|
|
23
|
+
action: openNew,
|
|
24
|
+
}
|
|
25
|
+
: undefined, [canCreate, openNew, t]);
|
|
26
|
+
useSetPlusButtonActions(plusButton);
|
|
27
|
+
useSetPageHeader(t('navigation.resources', { defaultValue: 'Resources' }), undefined, 'resources-page-heading');
|
|
28
|
+
return _jsx(ResourceLibrary, {});
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NewResource: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useT, useSetPageHeader } from '../../index.js';
|
|
4
|
+
import { ResourceForm } from '../../components/post/post-form/ResourceForm.js';
|
|
5
|
+
import { useNewResource } from '../../hooks/index.js';
|
|
6
|
+
import { Button, Toast } from '@openpeepshq/react-ui';
|
|
7
|
+
export const NewResource = () => {
|
|
8
|
+
const t = useT();
|
|
9
|
+
const { postData, setPostData, canSubmit, submitting, error, clearError, submit, } = useNewResource();
|
|
10
|
+
const headerActions = useMemo(() => (_jsx(Button, { title: t('resources.create.title', { defaultValue: 'Create resource' }), variant: "default", action: submit, disabled: submitting || !canSubmit, "data-testid": "resources-submit", children: submitting
|
|
11
|
+
? t('common.submitting', { defaultValue: 'Publishing…' })
|
|
12
|
+
: t('resources.create.title', { defaultValue: 'Create resource' }) })), [canSubmit, submit, submitting, t]);
|
|
13
|
+
useSetPageHeader(t('resources.new', { defaultValue: 'New resource' }), headerActions);
|
|
14
|
+
return (_jsxs("div", { className: "pb-12", children: [_jsx(ResourceForm, { postData: postData, onChange: setPostData }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
|
|
15
|
+
};
|
package/dist/react-native.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export * from './lib/audienceChoices';
|
|
|
42
42
|
export * from './components/post/attachmentPreview';
|
|
43
43
|
export * from './components/profile/profileFieldDisplay';
|
|
44
44
|
export { firstNWords, postReactionStats, stringToSegments, } from './components/post/helpers';
|
|
45
|
-
export { initializeNewPostStores, getNewPostStores, useNewPostStores, resetStore, defaultNewArticle, defaultNewEvent, defaultNewNote, defaultNewQuestion, eventSanitizer, getReplyStore, resetReplyData, useReplyStore, } from './stores/newPosts';
|
|
45
|
+
export { initializeNewPostStores, getNewPostStores, useNewPostStores, resetStore, defaultNewArticle, defaultNewResource, defaultNewEvent, defaultNewNote, defaultNewQuestion, eventSanitizer, getReplyStore, resetReplyData, useReplyStore, } from './stores/newPosts';
|
|
46
46
|
export type { NewPostsState, PlusButtonAction, PlusButtonActions, } from './stores/types';
|
|
47
47
|
export { extractUrlsFromText, isValidUrl, } from './components/preview-link/helpers';
|
|
48
48
|
export { JamProvider, useJamContext, useJamObserver, } from './components/jams/JamContext';
|
package/dist/react-native.js
CHANGED
|
@@ -33,7 +33,7 @@ export * from './lib/audienceChoices.js';
|
|
|
33
33
|
export * from './components/post/attachmentPreview.js';
|
|
34
34
|
export * from './components/profile/profileFieldDisplay.js';
|
|
35
35
|
export { firstNWords, postReactionStats, stringToSegments, } from './components/post/helpers.js';
|
|
36
|
-
export { initializeNewPostStores, getNewPostStores, useNewPostStores, resetStore, defaultNewArticle, defaultNewEvent, defaultNewNote, defaultNewQuestion, eventSanitizer, getReplyStore, resetReplyData, useReplyStore, } from './stores/newPosts.js';
|
|
36
|
+
export { initializeNewPostStores, getNewPostStores, useNewPostStores, resetStore, defaultNewArticle, defaultNewResource, defaultNewEvent, defaultNewNote, defaultNewQuestion, eventSanitizer, getReplyStore, resetReplyData, useReplyStore, } from './stores/newPosts.js';
|
|
37
37
|
export { extractUrlsFromText, isValidUrl, } from './components/preview-link/helpers.js';
|
|
38
38
|
// Jam logic that only depends on livekit-client (no @livekit/components-react).
|
|
39
39
|
export { JamProvider, useJamContext, useJamObserver, } from './components/jams/JamContext.js';
|
package/dist/stores/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export { feedFormatSessionStore, useFeedFormatSession } from './feedFormat';
|
|
|
5
5
|
export { eventViewStore, useEventView } from './eventView';
|
|
6
6
|
export type { EventView } from './eventView';
|
|
7
7
|
export { plusButtonStore, usePlusButton, useSetPlusButtonActions, } from './plusButton';
|
|
8
|
-
export { initializeNewPostStores, getNewPostStores, useNewPostStores, resetStore, defaultNewArticle, defaultNewEvent, defaultNewNote, defaultNewQuestion, eventSanitizer, getReplyStore, resetReplyData, useReplyStore, } from './newPosts';
|
|
8
|
+
export { initializeNewPostStores, getNewPostStores, useNewPostStores, resetStore, defaultNewArticle, defaultNewResource, defaultNewEvent, defaultNewNote, defaultNewQuestion, eventSanitizer, getReplyStore, resetReplyData, useReplyStore, } from './newPosts';
|
|
9
9
|
export type { Crumb, PageHeader, PlusButtonAction, PlusButtonActions, NewPostsState, } from './types';
|
|
10
10
|
export declare const initializePageStores: () => void;
|
package/dist/stores/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { pageHeaderStore, usePageHeader, useSetPageHeader } from './pageHeader.j
|
|
|
4
4
|
export { feedFormatSessionStore, useFeedFormatSession } from './feedFormat.js';
|
|
5
5
|
export { eventViewStore, useEventView } from './eventView.js';
|
|
6
6
|
export { plusButtonStore, usePlusButton, useSetPlusButtonActions, } from './plusButton.js';
|
|
7
|
-
export { initializeNewPostStores, getNewPostStores, useNewPostStores, resetStore, defaultNewArticle, defaultNewEvent, defaultNewNote, defaultNewQuestion, eventSanitizer, getReplyStore, resetReplyData, useReplyStore, } from './newPosts.js';
|
|
7
|
+
export { initializeNewPostStores, getNewPostStores, useNewPostStores, resetStore, defaultNewArticle, defaultNewResource, defaultNewEvent, defaultNewNote, defaultNewQuestion, eventSanitizer, getReplyStore, resetReplyData, useReplyStore, } from './newPosts.js';
|
|
8
8
|
export const initializePageStores = () => {
|
|
9
9
|
// page-scoped stores live module-level — calling this is a no-op kept for
|
|
10
10
|
// API compatibility with @openpeepshq/svelte.
|
|
@@ -4,6 +4,7 @@ export declare const defaultNewEvent: (publicContent?: boolean) => PostCreationD
|
|
|
4
4
|
export declare const defaultNewNote: (publicContent?: boolean) => PostCreationData;
|
|
5
5
|
export declare const defaultNewQuestion: (publicContent?: boolean) => PostCreationData;
|
|
6
6
|
export declare const defaultNewArticle: (publicContent?: boolean) => PostCreationData;
|
|
7
|
+
export declare const defaultNewResource: (publicContent?: boolean) => PostCreationData;
|
|
7
8
|
export declare const eventSanitizer: (publicContent?: boolean) => (event: PostCreationData) => PostCreationData;
|
|
8
9
|
export declare const initializeNewPostStores: (publicContent?: boolean) => void;
|
|
9
10
|
export declare const getNewPostStores: () => NewPostsState;
|
|
@@ -11,7 +12,7 @@ export declare const useNewPostStores: () => NewPostsState;
|
|
|
11
12
|
/** Persisted draft store for a reply to a specific post. */
|
|
12
13
|
export declare const getReplyStore: (inReplyToId: string) => import("./createStore").ReactStore<{
|
|
13
14
|
visibility: "group" | "local" | "report" | "public" | "unlisted" | "private" | "direct";
|
|
14
|
-
type: "event" | "note" | "question" | "article";
|
|
15
|
+
type: "event" | "resource" | "note" | "question" | "article";
|
|
15
16
|
data: {
|
|
16
17
|
type: "note";
|
|
17
18
|
content?: string | undefined;
|
|
@@ -204,6 +205,44 @@ export declare const getReplyStore: (inReplyToId: string) => import("./createSto
|
|
|
204
205
|
language?: string | undefined;
|
|
205
206
|
image?: string | undefined;
|
|
206
207
|
title?: string | undefined;
|
|
208
|
+
} | {
|
|
209
|
+
type: "resource";
|
|
210
|
+
title: string;
|
|
211
|
+
resourceKind: "link" | "file" | "video" | "gallery" | "audio";
|
|
212
|
+
content?: string | undefined;
|
|
213
|
+
sensitive?: boolean | undefined;
|
|
214
|
+
spoilerText?: string | undefined;
|
|
215
|
+
attachments?: {
|
|
216
|
+
type: string;
|
|
217
|
+
url: string;
|
|
218
|
+
previewUrl: string | null;
|
|
219
|
+
textUrl: null;
|
|
220
|
+
filename: string;
|
|
221
|
+
meta: {
|
|
222
|
+
usage?: string | undefined;
|
|
223
|
+
focus?: {
|
|
224
|
+
x: number;
|
|
225
|
+
y: number;
|
|
226
|
+
} | undefined;
|
|
227
|
+
mimetype?: string | undefined;
|
|
228
|
+
size?: number | undefined;
|
|
229
|
+
};
|
|
230
|
+
description?: string | undefined;
|
|
231
|
+
blurhash?: string | undefined;
|
|
232
|
+
status?: "processing" | "ready" | "failed" | undefined;
|
|
233
|
+
error?: string | undefined;
|
|
234
|
+
}[] | undefined;
|
|
235
|
+
customEmojis?: {
|
|
236
|
+
shortcode: string;
|
|
237
|
+
url: string;
|
|
238
|
+
staticUrl: string;
|
|
239
|
+
visibleInPicker: boolean;
|
|
240
|
+
category: string;
|
|
241
|
+
}[] | undefined;
|
|
242
|
+
language?: string | undefined;
|
|
243
|
+
tags?: string[] | undefined;
|
|
244
|
+
categoryPath?: string[] | undefined;
|
|
245
|
+
url?: string | undefined;
|
|
207
246
|
};
|
|
208
247
|
inReplyToId?: string | null | undefined;
|
|
209
248
|
mentions?: {
|
|
@@ -334,7 +373,7 @@ export declare const getReplyStore: (inReplyToId: string) => import("./createSto
|
|
|
334
373
|
export declare const resetReplyData: (inReplyToId: string) => void;
|
|
335
374
|
export declare const useReplyStore: (inReplyToId: string) => import("./createStore").ReactStore<{
|
|
336
375
|
visibility: "group" | "local" | "report" | "public" | "unlisted" | "private" | "direct";
|
|
337
|
-
type: "event" | "note" | "question" | "article";
|
|
376
|
+
type: "event" | "resource" | "note" | "question" | "article";
|
|
338
377
|
data: {
|
|
339
378
|
type: "note";
|
|
340
379
|
content?: string | undefined;
|
|
@@ -527,6 +566,44 @@ export declare const useReplyStore: (inReplyToId: string) => import("./createSto
|
|
|
527
566
|
language?: string | undefined;
|
|
528
567
|
image?: string | undefined;
|
|
529
568
|
title?: string | undefined;
|
|
569
|
+
} | {
|
|
570
|
+
type: "resource";
|
|
571
|
+
title: string;
|
|
572
|
+
resourceKind: "link" | "file" | "video" | "gallery" | "audio";
|
|
573
|
+
content?: string | undefined;
|
|
574
|
+
sensitive?: boolean | undefined;
|
|
575
|
+
spoilerText?: string | undefined;
|
|
576
|
+
attachments?: {
|
|
577
|
+
type: string;
|
|
578
|
+
url: string;
|
|
579
|
+
previewUrl: string | null;
|
|
580
|
+
textUrl: null;
|
|
581
|
+
filename: string;
|
|
582
|
+
meta: {
|
|
583
|
+
usage?: string | undefined;
|
|
584
|
+
focus?: {
|
|
585
|
+
x: number;
|
|
586
|
+
y: number;
|
|
587
|
+
} | undefined;
|
|
588
|
+
mimetype?: string | undefined;
|
|
589
|
+
size?: number | undefined;
|
|
590
|
+
};
|
|
591
|
+
description?: string | undefined;
|
|
592
|
+
blurhash?: string | undefined;
|
|
593
|
+
status?: "processing" | "ready" | "failed" | undefined;
|
|
594
|
+
error?: string | undefined;
|
|
595
|
+
}[] | undefined;
|
|
596
|
+
customEmojis?: {
|
|
597
|
+
shortcode: string;
|
|
598
|
+
url: string;
|
|
599
|
+
staticUrl: string;
|
|
600
|
+
visibleInPicker: boolean;
|
|
601
|
+
category: string;
|
|
602
|
+
}[] | undefined;
|
|
603
|
+
language?: string | undefined;
|
|
604
|
+
tags?: string[] | undefined;
|
|
605
|
+
categoryPath?: string[] | undefined;
|
|
606
|
+
url?: string | undefined;
|
|
530
607
|
};
|
|
531
608
|
inReplyToId?: string | null | undefined;
|
|
532
609
|
mentions?: {
|
package/dist/stores/newPosts.js
CHANGED
|
@@ -45,6 +45,18 @@ export const defaultNewArticle = (publicContent = false) => ({
|
|
|
45
45
|
visibility: defaultVisibility(publicContent),
|
|
46
46
|
data: { type: 'article', content: '' },
|
|
47
47
|
});
|
|
48
|
+
export const defaultNewResource = (publicContent = false) => ({
|
|
49
|
+
type: 'resource',
|
|
50
|
+
visibility: defaultVisibility(publicContent),
|
|
51
|
+
data: {
|
|
52
|
+
type: 'resource',
|
|
53
|
+
title: '',
|
|
54
|
+
content: '',
|
|
55
|
+
resourceKind: 'link',
|
|
56
|
+
tags: [],
|
|
57
|
+
categoryPath: [],
|
|
58
|
+
},
|
|
59
|
+
});
|
|
48
60
|
export const eventSanitizer = (publicContent = false) => {
|
|
49
61
|
const def = defaultNewEvent(publicContent);
|
|
50
62
|
return (event) => {
|
|
@@ -84,6 +96,7 @@ const ensureInitialized = (publicContent = false) => {
|
|
|
84
96
|
const jam = persistedStore('new-jam-state', defaultNewEvent(publicContent));
|
|
85
97
|
const event = persistedStore('new-event-state', defaultNewEvent(publicContent));
|
|
86
98
|
const article = persistedStore('new-article-state', defaultNewArticle(publicContent));
|
|
99
|
+
const resource = persistedStore('new-resource-state', defaultNewResource(publicContent));
|
|
87
100
|
const note = persistedStore('new-note-state', defaultNewNote(publicContent));
|
|
88
101
|
const question = persistedStore('new-question-state', defaultNewQuestion(publicContent));
|
|
89
102
|
initialized = {
|
|
@@ -108,6 +121,13 @@ const ensureInitialized = (publicContent = false) => {
|
|
|
108
121
|
article.set(v);
|
|
109
122
|
},
|
|
110
123
|
resetNewArticleState: () => article.reset(),
|
|
124
|
+
get resource() {
|
|
125
|
+
return resource.get();
|
|
126
|
+
},
|
|
127
|
+
set resource(v) {
|
|
128
|
+
resource.set(v);
|
|
129
|
+
},
|
|
130
|
+
resetNewResourceState: () => resource.reset(),
|
|
111
131
|
get note() {
|
|
112
132
|
return note.get();
|
|
113
133
|
},
|
|
@@ -124,7 +144,7 @@ const ensureInitialized = (publicContent = false) => {
|
|
|
124
144
|
resetNewQuestionState: () => question.reset(),
|
|
125
145
|
};
|
|
126
146
|
// wire subscribe so React `useNewPostStores` can re-render on writes
|
|
127
|
-
internalStores = { jam, event, article, note, question };
|
|
147
|
+
internalStores = { jam, event, article, resource, note, question };
|
|
128
148
|
return initialized;
|
|
129
149
|
};
|
|
130
150
|
let internalStores;
|
|
@@ -134,12 +154,13 @@ export const initializeNewPostStores = (publicContent = false) => {
|
|
|
134
154
|
export const getNewPostStores = () => ensureInitialized();
|
|
135
155
|
export const useNewPostStores = () => {
|
|
136
156
|
ensureInitialized();
|
|
137
|
-
// Subscribe to all
|
|
157
|
+
// Subscribe to all composer sub-stores so any write triggers a re-render.
|
|
138
158
|
useSyncExternalStore((l) => {
|
|
139
159
|
const subs = [
|
|
140
160
|
internalStores.jam.subscribe(l),
|
|
141
161
|
internalStores.event.subscribe(l),
|
|
142
162
|
internalStores.article.subscribe(l),
|
|
163
|
+
internalStores.resource.subscribe(l),
|
|
143
164
|
internalStores.note.subscribe(l),
|
|
144
165
|
internalStores.question.subscribe(l),
|
|
145
166
|
];
|
|
@@ -185,6 +206,9 @@ export const resetStore = (type) => {
|
|
|
185
206
|
case 'article':
|
|
186
207
|
stores.resetNewArticleState();
|
|
187
208
|
return;
|
|
209
|
+
case 'resource':
|
|
210
|
+
stores.resetNewResourceState();
|
|
211
|
+
return;
|
|
188
212
|
default:
|
|
189
213
|
return;
|
|
190
214
|
}
|
package/dist/stores/types.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export interface NewPostsState {
|
|
|
28
28
|
resetNewEventState: () => void;
|
|
29
29
|
article: PostCreationData;
|
|
30
30
|
resetNewArticleState: () => void;
|
|
31
|
+
resource: PostCreationData;
|
|
32
|
+
resetNewResourceState: () => void;
|
|
31
33
|
note: PostCreationData;
|
|
32
34
|
resetNewNoteState: () => void;
|
|
33
35
|
question: PostCreationData;
|