@tiny-server/avatars 0.0.0-pre202605241751
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/AvatarExtension-wsvVGy1v.js +9 -0
- package/dist/AvatarSettingsMenuItem-CAw81GMv.js +33 -0
- package/dist/ManageAccountTabExtension-CJj7tXQq.js +16 -0
- package/dist/ManageAccountTabPanelExtension-umstphbQ.js +11 -0
- package/dist/ManageAvatarCard-B6u43CrW.js +116 -0
- package/dist/UserAvatar-Bgb5L9YF.js +37 -0
- package/dist/api/avatar.d.ts +37 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/permissions.d.ts +10 -0
- package/dist/api/status.d.ts +11 -0
- package/dist/components/ManageAvatarCard.d.ts +4 -0
- package/dist/components/UserAvatar.d.ts +11 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/createLucideIcon-DJ4QdTU4.js +74 -0
- package/dist/declarations.d.ts +11 -0
- package/dist/extensions/AvatarExtension.d.ts +3 -0
- package/dist/extensions/ManageAccountTabExtension.d.ts +2 -0
- package/dist/extensions/ManageAccountTabPanelExtension.d.ts +3 -0
- package/dist/forms/UploadAvatarForm.d.ts +4 -0
- package/dist/forms/index.d.ts +1 -0
- package/dist/i18n-BBsN4SUB.js +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +81 -0
- package/dist/menu/AvatarSettingsMenuItem.d.ts +3 -0
- package/dist/module.d.ts +1 -0
- package/dist/routes/settings.avatar.d.ts +1 -0
- package/dist/settings.avatar-4bVoqwjW.js +16 -0
- package/dist/utils/i18n.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { withPermissions as r, useApp as n } from "@tiny-server/core";
|
|
3
|
+
import { c as i } from "./createLucideIcon-DJ4QdTU4.js";
|
|
4
|
+
import { d as s } from "./i18n-BBsN4SUB.js";
|
|
5
|
+
const c = [
|
|
6
|
+
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
|
|
7
|
+
["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
|
|
8
|
+
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
|
|
9
|
+
], m = i("image", c), p = s("AvatarSettingsMenuItem", {
|
|
10
|
+
en: {
|
|
11
|
+
label: "Avatar",
|
|
12
|
+
description: "Manage your avatar."
|
|
13
|
+
}
|
|
14
|
+
}), g = r(
|
|
15
|
+
{ permissions: ["write.avatar.own"] },
|
|
16
|
+
(a) => {
|
|
17
|
+
const e = p(), { MenuItem: o } = n().components;
|
|
18
|
+
return /* @__PURE__ */ t(
|
|
19
|
+
o,
|
|
20
|
+
{
|
|
21
|
+
label: e("label"),
|
|
22
|
+
description: e("description"),
|
|
23
|
+
to: "/settings/avatar",
|
|
24
|
+
leftSection: /* @__PURE__ */ t(m, { size: "1em" }),
|
|
25
|
+
...a
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
export {
|
|
31
|
+
g as AvatarSettingsMenuItem,
|
|
32
|
+
g as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { Tabs as e } from "@mantine/core";
|
|
3
|
+
import { d as o } from "./i18n-BBsN4SUB.js";
|
|
4
|
+
const n = o("ManageAccountTab", {
|
|
5
|
+
en: {
|
|
6
|
+
title: "Avatar"
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
function s() {
|
|
10
|
+
const t = n();
|
|
11
|
+
return /* @__PURE__ */ a(e.Tab, { value: "avatar", children: t("title") });
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
s as ManageAccountTabExtension,
|
|
15
|
+
s as default
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { Tabs as t } from "@mantine/core";
|
|
3
|
+
import { M as o } from "./ManageAvatarCard-B6u43CrW.js";
|
|
4
|
+
function i({ params: r }) {
|
|
5
|
+
const a = r?.account?.id;
|
|
6
|
+
return typeof a != "string" ? null : /* @__PURE__ */ n(t.Panel, { value: "avatar", children: /* @__PURE__ */ n(o, { userId: a }) });
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
i as ManageAccountTabPanelExtension,
|
|
10
|
+
i as default
|
|
11
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsxs as o, jsx as e, Fragment as k } from "react/jsx-runtime";
|
|
2
|
+
import { Form as l, ImageCropper as C, SectionCard as h } from "@tiny-server/design";
|
|
3
|
+
import { Input as P, Box as j, LoadingOverlay as T, FileButton as w, Tooltip as L, Button as v, Skeleton as x } from "@mantine/core";
|
|
4
|
+
import { useSuspenseQuery as Q, useQuery as V, useMutation as b } from "@tanstack/react-query";
|
|
5
|
+
import { readStatusQuery as z, useSession as O } from "@tiny-server/core";
|
|
6
|
+
import { useForm as _ } from "@mantine/form";
|
|
7
|
+
import { useState as B, useMemo as H } from "react";
|
|
8
|
+
import { readAvatarQuery as R, upsertAvatarMutation as D, deleteAvatarMutation as I } from "./index.js";
|
|
9
|
+
import { U as N } from "./UserAvatar-Bgb5L9YF.js";
|
|
10
|
+
import { c as y } from "./createLucideIcon-DJ4QdTU4.js";
|
|
11
|
+
import { d as S } from "./i18n-BBsN4SUB.js";
|
|
12
|
+
const $ = [
|
|
13
|
+
["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
|
|
14
|
+
["path", { d: "M3 6h18", key: "d0wm0j" }],
|
|
15
|
+
["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
|
|
16
|
+
], q = y("trash", $);
|
|
17
|
+
const G = [
|
|
18
|
+
["path", { d: "M12 3v12", key: "1x0j5s" }],
|
|
19
|
+
["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
|
|
20
|
+
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
|
|
21
|
+
], W = y("upload", G), f = "12rem", Y = S("UploadAvatarForm", {
|
|
22
|
+
en: {
|
|
23
|
+
pickFileTooltip: "Click to select an image file to upload as your avatar...",
|
|
24
|
+
avatar: {
|
|
25
|
+
label: "Current Avatar",
|
|
26
|
+
description: "Click the avatar to upload a new image."
|
|
27
|
+
},
|
|
28
|
+
error: {
|
|
29
|
+
title: "Avatar upload failed.",
|
|
30
|
+
description: "An error occurred while uploading the image. Please try again later."
|
|
31
|
+
},
|
|
32
|
+
submit: "Upload",
|
|
33
|
+
delete: "Delete current"
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
function E({ userId: i }) {
|
|
37
|
+
const t = Y(), { data: s } = Q(z()), A = s.data.avatar.allowedMimeTypes.join(","), c = V({ ...R(i), retry: !1 }), n = b(D(i)), d = b(I(i)), u = n.isPending || d.isPending, r = _({
|
|
38
|
+
initialValues: {
|
|
39
|
+
file: null
|
|
40
|
+
}
|
|
41
|
+
}), [p, m] = B(null), g = H(() => p ? URL.createObjectURL(p) : null, [p]), U = (a) => {
|
|
42
|
+
m(a), r.setFieldValue("file", a);
|
|
43
|
+
}, F = () => {
|
|
44
|
+
n.mutate(r.values.file, {
|
|
45
|
+
onSuccess: () => {
|
|
46
|
+
r.reset(), m(null);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}, M = () => {
|
|
50
|
+
d.mutate(void 0, {
|
|
51
|
+
onSuccess: () => {
|
|
52
|
+
r.reset(), m(null);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ o(l, { onSubmit: r.onSubmit(F), children: [
|
|
57
|
+
/* @__PURE__ */ o(l.Section, { children: [
|
|
58
|
+
n.error && /* @__PURE__ */ e(l.Alert, { kind: "error", title: t("error.title"), children: t("error.description") }),
|
|
59
|
+
/* @__PURE__ */ e(P.Wrapper, { label: t("avatar.label"), description: t("avatar.description"), children: /* @__PURE__ */ e(j, { pos: "relative", mt: "lg", w: f, h: f, children: g ? /* @__PURE__ */ o(k, { children: [
|
|
60
|
+
/* @__PURE__ */ e(
|
|
61
|
+
C,
|
|
62
|
+
{
|
|
63
|
+
src: g,
|
|
64
|
+
aspect: 1,
|
|
65
|
+
cropShape: "round",
|
|
66
|
+
showGrid: !1,
|
|
67
|
+
objectFit: "cover",
|
|
68
|
+
onCropped: (a) => r.setFieldValue("file", a)
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
/* @__PURE__ */ e(T, { loaderProps: { visibility: "hidden" }, visible: u })
|
|
72
|
+
] }) : /* @__PURE__ */ e(w, { accept: A, ...r.getInputProps("file"), onChange: (a) => U(a), children: (a) => /* @__PURE__ */ e(L, { label: t("pickFileTooltip"), children: /* @__PURE__ */ e(v, { variant: "transparent", h: "auto", p: 0, ...a, children: /* @__PURE__ */ e(N, { userId: i, size: f, resolution: "Lg" }) }) }) }) }) })
|
|
73
|
+
] }),
|
|
74
|
+
/* @__PURE__ */ o(l.Footer, { children: [
|
|
75
|
+
/* @__PURE__ */ e(
|
|
76
|
+
v,
|
|
77
|
+
{
|
|
78
|
+
type: "submit",
|
|
79
|
+
leftSection: /* @__PURE__ */ e(W, { size: "1em" }),
|
|
80
|
+
loading: n.isPending,
|
|
81
|
+
disabled: !r.values.file || u,
|
|
82
|
+
children: t("submit")
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
/* @__PURE__ */ e(x, { width: "fit-content", visible: c.isFetching, children: !!c.data && !c.error && /* @__PURE__ */ e(
|
|
86
|
+
v,
|
|
87
|
+
{
|
|
88
|
+
variant: "transparent",
|
|
89
|
+
color: "red",
|
|
90
|
+
leftSection: /* @__PURE__ */ e(q, { size: "1em" }),
|
|
91
|
+
onClick: M,
|
|
92
|
+
loading: d.isPending,
|
|
93
|
+
disabled: u,
|
|
94
|
+
children: t("delete")
|
|
95
|
+
}
|
|
96
|
+
) })
|
|
97
|
+
] })
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
const J = S("UploadAvatarCard", {
|
|
101
|
+
en: {
|
|
102
|
+
titleCurrentUser: "Your Avatar",
|
|
103
|
+
titleOtherUser: "User's Avatar",
|
|
104
|
+
subTitle: "Avatars are public profile images visible to other users."
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
function se({ userId: i }) {
|
|
108
|
+
const t = J(), s = i === O().userId;
|
|
109
|
+
return /* @__PURE__ */ o(h, { children: [
|
|
110
|
+
/* @__PURE__ */ e(h.Header, { title: t(s ? "titleCurrentUser" : "titleOtherUser") }),
|
|
111
|
+
/* @__PURE__ */ e(h.Section, { children: /* @__PURE__ */ e(E, { userId: i }) })
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
se as M
|
|
116
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { Skeleton as c, Avatar as u } from "@mantine/core";
|
|
3
|
+
import { useSessionState as v } from "@tiny-server/core";
|
|
4
|
+
import { useQuery as p } from "@tanstack/react-query";
|
|
5
|
+
import { useState as h } from "react";
|
|
6
|
+
import { readAvatarQuery as L } from "./index.js";
|
|
7
|
+
function $({ userId: a, resolution: l = "Md", src: r, ...m }) {
|
|
8
|
+
const e = v().session?.userId;
|
|
9
|
+
a ??= e;
|
|
10
|
+
const {
|
|
11
|
+
isLoading: o,
|
|
12
|
+
data: i,
|
|
13
|
+
error: f
|
|
14
|
+
} = p({
|
|
15
|
+
...L(a ?? ""),
|
|
16
|
+
retry: !1,
|
|
17
|
+
enabled: !!a
|
|
18
|
+
}), [d, t] = h(!1), s = !o && i && !f, g = s ? i.data.eTag : "";
|
|
19
|
+
return r ??= s ? `/api/v1/users/${a ?? e}/avatar/file?resolution=${l}&_uid=${g}` : null, /* @__PURE__ */ n(c, { width: "fit-content", height: "fit-content", visible: o || d, circle: !0, children: /* @__PURE__ */ n(
|
|
20
|
+
u,
|
|
21
|
+
{
|
|
22
|
+
variant: "light",
|
|
23
|
+
bg: "gray",
|
|
24
|
+
color: "initials",
|
|
25
|
+
...m,
|
|
26
|
+
src: r,
|
|
27
|
+
imageProps: {
|
|
28
|
+
onLoadStart: () => t(!0),
|
|
29
|
+
onLoad: () => t(!1),
|
|
30
|
+
onError: () => t(!1)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
) });
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
$ as U
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ApiResult, EntityRead } from '@tiny-server/core';
|
|
2
|
+
/**
|
|
3
|
+
* Specifies the avatar resolutions that the system supports.
|
|
4
|
+
*/
|
|
5
|
+
export type AvatarResolution = 'Xs' | 'Sm' | 'Md' | 'Lg' | 'Xl';
|
|
6
|
+
/**
|
|
7
|
+
* Represents metadata about a user's avatar.
|
|
8
|
+
*/
|
|
9
|
+
export interface AvatarRead extends EntityRead {
|
|
10
|
+
/**
|
|
11
|
+
* The avatar file's content type.
|
|
12
|
+
*/
|
|
13
|
+
contentType: string;
|
|
14
|
+
/**
|
|
15
|
+
* A hash value which uniquely identifies the avatar file in its current version.
|
|
16
|
+
*/
|
|
17
|
+
eTag: string;
|
|
18
|
+
}
|
|
19
|
+
/** `GET api/v1/users/{userId}/avatar` */
|
|
20
|
+
export declare function readAvatar(userId: string): Promise<ApiResult<AvatarRead>>;
|
|
21
|
+
/** `PUT api/v1/users/{userId}/avatar` */
|
|
22
|
+
export declare function upsertAvatar(userId: string, file: File): Promise<ApiResult<AvatarRead>>;
|
|
23
|
+
/** `DELETE api/v1/users/{userId}/avatar` */
|
|
24
|
+
export declare function deleteAvatar(userId: string): Promise<null>;
|
|
25
|
+
/** {@link readAvatar} */
|
|
26
|
+
export declare function readAvatarQuery(userId: string): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<ApiResult<AvatarRead>, Error, ApiResult<AvatarRead>, readonly ["users", string, "avatar"]>, "queryFn"> & {
|
|
27
|
+
queryFn?: import('@tanstack/query-core').QueryFunction<ApiResult<AvatarRead>, readonly ["users", string, "avatar"], never> | undefined;
|
|
28
|
+
} & {
|
|
29
|
+
queryKey: readonly ["users", string, "avatar"] & {
|
|
30
|
+
[dataTagSymbol]: ApiResult<AvatarRead>;
|
|
31
|
+
[dataTagErrorSymbol]: Error;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/** {@link upsertAvatar} */
|
|
35
|
+
export declare function upsertAvatarMutation(userId: string): Omit<import('@tanstack/react-query').UseMutationOptions<ApiResult<AvatarRead>, Error, File, unknown>, "mutationKey">;
|
|
36
|
+
/** {@link deleteAvatar} */
|
|
37
|
+
export declare function deleteAvatarMutation(userId: string): Omit<import('@tanstack/react-query').UseMutationOptions<null, Error, void, unknown>, "mutationKey">;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AvatarProps } from '@mantine/core';
|
|
2
|
+
import { AvatarResolution } from '../api';
|
|
3
|
+
export interface UserAvatarProps extends AvatarProps {
|
|
4
|
+
userId?: string;
|
|
5
|
+
resolution?: AvatarResolution;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Renders a user's avatar image.
|
|
9
|
+
* If no {@link UserAvatarProps.userId} is provided, the current session user's avatar will be displayed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function UserAvatar({ userId, resolution, src, ...rest }: UserAvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useContext as b, createContext as L, forwardRef as C, createElement as i } from "react";
|
|
2
|
+
const h = (...e) => e.filter((t, o, r) => !!t && t.trim() !== "" && r.indexOf(t) === o).join(" ").trim();
|
|
3
|
+
const W = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
4
|
+
const S = (e) => e.replace(
|
|
5
|
+
/^([A-Z])|[\s-_]+(\w)/g,
|
|
6
|
+
(t, o, r) => r ? r.toUpperCase() : o.toLowerCase()
|
|
7
|
+
);
|
|
8
|
+
const d = (e) => {
|
|
9
|
+
const t = S(e);
|
|
10
|
+
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
11
|
+
};
|
|
12
|
+
var c = {
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
width: 24,
|
|
15
|
+
height: 24,
|
|
16
|
+
viewBox: "0 0 24 24",
|
|
17
|
+
fill: "none",
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
strokeWidth: 2,
|
|
20
|
+
strokeLinecap: "round",
|
|
21
|
+
strokeLinejoin: "round"
|
|
22
|
+
};
|
|
23
|
+
const v = (e) => {
|
|
24
|
+
for (const t in e)
|
|
25
|
+
if (t.startsWith("aria-") || t === "role" || t === "title")
|
|
26
|
+
return !0;
|
|
27
|
+
return !1;
|
|
28
|
+
}, y = L({}), $ = () => b(y), j = C(
|
|
29
|
+
({ color: e, size: t, strokeWidth: o, absoluteStrokeWidth: r, className: a = "", children: s, iconNode: p, ...l }, m) => {
|
|
30
|
+
const {
|
|
31
|
+
size: n = 24,
|
|
32
|
+
strokeWidth: u = 2,
|
|
33
|
+
absoluteStrokeWidth: x = !1,
|
|
34
|
+
color: w = "currentColor",
|
|
35
|
+
className: f = ""
|
|
36
|
+
} = $() ?? {}, k = r ?? x ? Number(o ?? u) * 24 / Number(t ?? n) : o ?? u;
|
|
37
|
+
return i(
|
|
38
|
+
"svg",
|
|
39
|
+
{
|
|
40
|
+
ref: m,
|
|
41
|
+
...c,
|
|
42
|
+
width: t ?? n ?? c.width,
|
|
43
|
+
height: t ?? n ?? c.height,
|
|
44
|
+
stroke: e ?? w,
|
|
45
|
+
strokeWidth: k,
|
|
46
|
+
className: h("lucide", f, a),
|
|
47
|
+
...!s && !v(l) && { "aria-hidden": "true" },
|
|
48
|
+
...l
|
|
49
|
+
},
|
|
50
|
+
[
|
|
51
|
+
...p.map(([g, A]) => i(g, A)),
|
|
52
|
+
...Array.isArray(s) ? s : [s]
|
|
53
|
+
]
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
const I = (e, t) => {
|
|
58
|
+
const o = C(
|
|
59
|
+
({ className: r, ...a }, s) => i(j, {
|
|
60
|
+
ref: s,
|
|
61
|
+
iconNode: t,
|
|
62
|
+
className: h(
|
|
63
|
+
`lucide-${W(d(e))}`,
|
|
64
|
+
`lucide-${e}`,
|
|
65
|
+
r
|
|
66
|
+
),
|
|
67
|
+
...a
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
return o.displayName = d(e), o;
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
I as c
|
|
74
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UserAvatarProps } from './components';
|
|
2
|
+
export interface AvatarExtensionParams extends UserAvatarProps {
|
|
3
|
+
}
|
|
4
|
+
declare module '@tiny-server/core' {
|
|
5
|
+
interface MenuParamsMap {
|
|
6
|
+
settings: {};
|
|
7
|
+
}
|
|
8
|
+
interface ExtensionParamsMap {
|
|
9
|
+
avatar: AvatarExtensionParams;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ExtensionComponentProps } from '@tiny-server/core';
|
|
2
|
+
export declare function ManageAccountTabPanelExtension({ params }: ExtensionComponentProps<'manage-account-tab-panel'>): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
export default ManageAccountTabPanelExtension;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { appFetch as o, createModule as s, requireSession as m } from "@tiny-server/core";
|
|
2
|
+
import { lazy as r } from "react";
|
|
3
|
+
import { queryOptions as p, mutationOptions as i } from "@tanstack/react-query";
|
|
4
|
+
function c(a) {
|
|
5
|
+
return o({ url: `/api/v1/users/${a}/avatar` });
|
|
6
|
+
}
|
|
7
|
+
function v(a, t) {
|
|
8
|
+
const n = new FormData();
|
|
9
|
+
return n.append("file", t), o({
|
|
10
|
+
url: `/api/v1/users/${a}/avatar`,
|
|
11
|
+
method: "PUT",
|
|
12
|
+
body: n
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function l(a) {
|
|
16
|
+
return o({ url: `/api/v1/users/${a}/avatar`, method: "DELETE" });
|
|
17
|
+
}
|
|
18
|
+
function d(a) {
|
|
19
|
+
return p({
|
|
20
|
+
queryKey: ["users", a, "avatar"],
|
|
21
|
+
queryFn: () => c(a),
|
|
22
|
+
staleTime: 1 / 0
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function A(a) {
|
|
26
|
+
return i({
|
|
27
|
+
mutationFn: (t) => v(a, t),
|
|
28
|
+
onSuccess(t, n, u, e) {
|
|
29
|
+
e.client.setQueryData(["users", a, "avatar"], t), e.client.invalidateQueries({ queryKey: ["users", a, "avatar"] });
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function q(a) {
|
|
34
|
+
return i({
|
|
35
|
+
mutationFn: () => l(a),
|
|
36
|
+
onSuccess(t, n, u, e) {
|
|
37
|
+
e.client.setQueryData(["users", a, "avatar"], null), e.client.invalidateQueries({ queryKey: ["users", a, "avatar"] });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function g() {
|
|
42
|
+
return s({
|
|
43
|
+
routes: [
|
|
44
|
+
{
|
|
45
|
+
middleware: [m({ permissions: ["write.avatar.own"] })],
|
|
46
|
+
path: "/settings/avatar",
|
|
47
|
+
Component: r(() => import("./settings.avatar-4bVoqwjW.js"))
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
extensions: [
|
|
51
|
+
{
|
|
52
|
+
name: "avatar",
|
|
53
|
+
component: r(() => import("./AvatarExtension-wsvVGy1v.js"))
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "manage-account-tab",
|
|
57
|
+
component: r(() => import("./ManageAccountTabExtension-CJj7tXQq.js"))
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "manage-account-tab-panel",
|
|
61
|
+
component: r(() => import("./ManageAccountTabPanelExtension-umstphbQ.js"))
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
menuItems: [
|
|
65
|
+
{
|
|
66
|
+
id: "avatars-avatar-settings",
|
|
67
|
+
menu: "settings",
|
|
68
|
+
component: r(() => import("./AvatarSettingsMenuItem-CAw81GMv.js"))
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
g as createAvatarsModule,
|
|
75
|
+
l as deleteAvatar,
|
|
76
|
+
q as deleteAvatarMutation,
|
|
77
|
+
c as readAvatar,
|
|
78
|
+
d as readAvatarQuery,
|
|
79
|
+
v as upsertAvatar,
|
|
80
|
+
A as upsertAvatarMutation
|
|
81
|
+
};
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createAvatarsModule(): import('@tiny-server/core').Module;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Component(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useApp as s, useSession as r } from "@tiny-server/core";
|
|
3
|
+
import { M as a } from "./ManageAvatarCard-B6u43CrW.js";
|
|
4
|
+
import { d as i } from "./i18n-BBsN4SUB.js";
|
|
5
|
+
const c = i("AccountSettingsRoute", {
|
|
6
|
+
en: {
|
|
7
|
+
title: "Avatar Settings"
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
function f() {
|
|
11
|
+
const e = c(), { Page: o } = s().components, { userId: n } = r();
|
|
12
|
+
return /* @__PURE__ */ t(o, { header: e("title"), children: /* @__PURE__ */ t(a, { userId: n }) });
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
f as default
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './i18n';
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tiny-server/avatars",
|
|
3
|
+
"version": "0.0.0-pre202605241751",
|
|
4
|
+
"description": "The Tiny Server avatars frontend package.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tiny-server",
|
|
7
|
+
"module",
|
|
8
|
+
"avatars"
|
|
9
|
+
],
|
|
10
|
+
"author": "Manuel Römer",
|
|
11
|
+
"license": "AGPL-3.0-only",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/manuelroemer/tiny-server.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/manuelroemer/tiny-server/issues"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"module": "dist/index.js",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"start": "vite build --watch",
|
|
34
|
+
"build": "vite build",
|
|
35
|
+
"test": "",
|
|
36
|
+
"lint": "eslint src"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@mantine/core": "^9",
|
|
40
|
+
"@mantine/form": "^9",
|
|
41
|
+
"@mantine/hooks": "^9",
|
|
42
|
+
"@tanstack/react-query": "^5",
|
|
43
|
+
"i18next": "^26",
|
|
44
|
+
"react": "^19",
|
|
45
|
+
"react-dom": "^19",
|
|
46
|
+
"react-i18next": "^17",
|
|
47
|
+
"react-router": "^7"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@tiny-server/core": "0.0.0-pre202605241751",
|
|
51
|
+
"@tiny-server/design": "0.0.0-pre202605241751"
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "193d19cb2bc34732a7d80e709067851e249803c4"
|
|
54
|
+
}
|