@the-seeker/changes-react 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -2
- package/dist/core/cache.d.ts +14 -0
- package/dist/core/cache.js +34 -0
- package/dist/core/client.d.ts +161 -0
- package/dist/core/client.js +97 -0
- package/dist/core/decide.d.ts +16 -0
- package/dist/core/decide.js +57 -0
- package/dist/core/rating.d.ts +7 -0
- package/dist/core/rating.js +18 -0
- package/dist/core/storage.d.ts +20 -0
- package/dist/core/storage.js +73 -0
- package/dist/core/types.d.ts +332 -0
- package/dist/core/types.js +126 -0
- package/dist/core/versions.d.ts +2 -0
- package/dist/core/versions.js +20 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +47 -0
- package/dist/web/Blocks.d.ts +5 -0
- package/dist/web/Blocks.js +42 -0
- package/dist/web/ChangelogButton.d.ts +5 -0
- package/dist/web/ChangelogButton.js +17 -0
- package/dist/web/ChangelogDialog.d.ts +2 -0
- package/dist/web/ChangelogDialog.js +19 -0
- package/dist/web/ChangelogList.d.ts +2 -0
- package/dist/web/ChangelogList.js +32 -0
- package/dist/web/CommentComposer.d.ts +9 -0
- package/dist/web/CommentComposer.js +47 -0
- package/dist/web/CommentItem.d.ts +11 -0
- package/dist/web/CommentItem.js +23 -0
- package/dist/web/CommentsThread.d.ts +4 -0
- package/dist/web/CommentsThread.js +15 -0
- package/dist/web/DialogShell.d.ts +11 -0
- package/dist/web/DialogShell.js +36 -0
- package/dist/web/Provider.d.ts +24 -0
- package/dist/web/Provider.js +109 -0
- package/dist/web/ReleaseCard.d.ts +5 -0
- package/dist/web/ReleaseCard.js +23 -0
- package/dist/web/ReleaseEngagement.d.ts +5 -0
- package/dist/web/ReleaseEngagement.js +24 -0
- package/dist/web/ReleaseSummary.d.ts +8 -0
- package/dist/web/ReleaseSummary.js +15 -0
- package/dist/web/ReportMenu.d.ts +4 -0
- package/dist/web/ReportMenu.js +79 -0
- package/dist/web/VoteCapsule.d.ts +9 -0
- package/dist/web/VoteCapsule.js +12 -0
- package/dist/web/WhatsNewModal.d.ts +2 -0
- package/dist/web/WhatsNewModal.js +26 -0
- package/dist/web/context.d.ts +82 -0
- package/dist/web/context.js +5 -0
- package/dist/web/controls-css.d.ts +1 -0
- package/dist/web/controls-css.js +48 -0
- package/dist/web/focus-trap.d.ts +7 -0
- package/dist/web/focus-trap.js +69 -0
- package/dist/web/icons.d.ts +17 -0
- package/dist/web/icons.js +29 -0
- package/dist/web/links.d.ts +11 -0
- package/dist/web/links.js +45 -0
- package/dist/web/load.d.ts +35 -0
- package/dist/web/load.js +61 -0
- package/dist/web/local-store.d.ts +7 -0
- package/dist/web/local-store.js +27 -0
- package/dist/web/model.d.ts +36 -0
- package/dist/web/model.js +37 -0
- package/dist/web/storage.d.ts +7 -0
- package/dist/web/storage.js +53 -0
- package/dist/web/styles.d.ts +273 -0
- package/dist/web/styles.js +201 -0
- package/dist/web/texts-defaults.d.ts +115 -0
- package/dist/web/texts-defaults.js +117 -0
- package/dist/web/texts.d.ts +9 -0
- package/dist/web/texts.js +49 -0
- package/dist/web/theme.d.ts +6 -0
- package/dist/web/theme.js +82 -0
- package/dist/web/use-actions.d.ts +10 -0
- package/dist/web/use-actions.js +114 -0
- package/dist/web/use-comments-api.d.ts +5 -0
- package/dist/web/use-comments-api.js +75 -0
- package/dist/web/use-thread.d.ts +23 -0
- package/dist/web/use-thread.js +82 -0
- package/dist/web/useChanges.d.ts +5 -0
- package/dist/web/useChanges.js +19 -0
- package/package.json +33 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChangelogList = ChangelogList;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ReleaseCard_1 = require("./ReleaseCard");
|
|
6
|
+
const styles_1 = require("./styles");
|
|
7
|
+
const useChanges_1 = require("./useChanges");
|
|
8
|
+
const placeholder = { height: 14, borderRadius: 4, background: "var(--tsc-control)" };
|
|
9
|
+
function LoadingCards() {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: [0, 1].map((index) => ((0, jsx_runtime_1.jsxs)("div", { "aria-hidden": "true", style: styles_1.surface.card, children: [(0, jsx_runtime_1.jsx)("div", { style: { ...placeholder, width: "55%", height: 20 } }), (0, jsx_runtime_1.jsx)("div", { style: { ...placeholder, width: "35%" } }), (0, jsx_runtime_1.jsx)("div", { style: { ...placeholder, width: "90%" } }), (0, jsx_runtime_1.jsx)("div", { style: { ...placeholder, width: "70%" } })] }, index))) }));
|
|
11
|
+
}
|
|
12
|
+
/** Every visible release as a card. Renders inline anywhere inside the provider; also used by the changelog dialog. */
|
|
13
|
+
function ChangelogList() {
|
|
14
|
+
const { status, releases, texts, stale, rootProps, reload } = (0, useChanges_1.useChanges)();
|
|
15
|
+
if (status === "disabled")
|
|
16
|
+
return null;
|
|
17
|
+
const body = () => {
|
|
18
|
+
switch (status) {
|
|
19
|
+
case "loading":
|
|
20
|
+
return (0, jsx_runtime_1.jsx)(LoadingCards, {});
|
|
21
|
+
case "error":
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)("div", { role: "alert", style: { ...styles_1.surface.card, justifyItems: "start" }, children: [(0, jsx_runtime_1.jsx)("p", { style: styles_1.text.body, children: texts.loadError }), (0, jsx_runtime_1.jsx)("button", { type: "button", "data-tsc-btn": "secondary", onClick: reload, children: texts.retry })] }));
|
|
23
|
+
case "ready":
|
|
24
|
+
return releases.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { style: { ...styles_1.surface.note, textAlign: "center" }, children: texts.empty })) : ((0, jsx_runtime_1.jsx)("ol", { style: { ...styles_1.layout.list, ...styles_1.layout.stack12 }, children: releases.map((release) => ((0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)(ReleaseCard_1.ReleaseCard, { release: release }) }, release.id))) }));
|
|
25
|
+
default: {
|
|
26
|
+
const exhaustive = status;
|
|
27
|
+
return exhaustive;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ...rootProps, "aria-busy": status === "loading", style: { ...rootProps.style, ...styles_1.layout.stack12 }, children: [stale ? ((0, jsx_runtime_1.jsx)("p", { role: "status", style: styles_1.surface.note, children: texts.offline })) : null, body()] }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommentReply } from "../core/types";
|
|
2
|
+
export type CommentComposerProps = Readonly<{
|
|
3
|
+
releaseId: string;
|
|
4
|
+
parentId?: string;
|
|
5
|
+
onPosted: (comment: CommentReply) => void;
|
|
6
|
+
onCancel?: () => void;
|
|
7
|
+
}>;
|
|
8
|
+
/** Comment or reply form. The first post asks for the community guidelines when the project requires it. */
|
|
9
|
+
export declare function CommentComposer({ releaseId, parentId, onPosted, onCancel }: CommentComposerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommentComposer = CommentComposer;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const styles_1 = require("./styles");
|
|
7
|
+
const useChanges_1 = require("./useChanges");
|
|
8
|
+
const MAX_LENGTH = 2000;
|
|
9
|
+
const ERROR_TEXT = {
|
|
10
|
+
BANNED: "errorBanned",
|
|
11
|
+
COMMENTS_DISABLED: "errorCommentsDisabled",
|
|
12
|
+
RATE_LIMITED: "errorRateLimited",
|
|
13
|
+
GUIDELINES_REQUIRED: "errorGuidelines",
|
|
14
|
+
};
|
|
15
|
+
/** Comment or reply form. The first post asks for the community guidelines when the project requires it. */
|
|
16
|
+
function CommentComposer({ releaseId, parentId, onPosted, onCancel }) {
|
|
17
|
+
const { texts, config, guidelinesAccepted, comments } = (0, useChanges_1.useChanges)();
|
|
18
|
+
const [body, setBody] = (0, react_1.useState)("");
|
|
19
|
+
const [checked, setChecked] = (0, react_1.useState)(false);
|
|
20
|
+
const [sending, setSending] = (0, react_1.useState)(false);
|
|
21
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
22
|
+
const fieldId = (0, react_1.useId)();
|
|
23
|
+
const errorId = (0, react_1.useId)();
|
|
24
|
+
const needsAck = config?.community.requireGuidelinesAck === true && !guidelinesAccepted;
|
|
25
|
+
const ready = body.trim().length > 0 && (!needsAck || checked) && !sending;
|
|
26
|
+
const submit = async (event) => {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
if (!ready)
|
|
29
|
+
return;
|
|
30
|
+
setSending(true);
|
|
31
|
+
setError(null);
|
|
32
|
+
const result = await comments.post({
|
|
33
|
+
releaseId,
|
|
34
|
+
body,
|
|
35
|
+
...(parentId ? { parentId } : {}),
|
|
36
|
+
...(needsAck ? { guidelinesAccepted: checked } : {}),
|
|
37
|
+
});
|
|
38
|
+
setSending(false);
|
|
39
|
+
if (!result.ok) {
|
|
40
|
+
setError(ERROR_TEXT[result.code] ?? "errorGeneric");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
setBody("");
|
|
44
|
+
onPosted(result.body);
|
|
45
|
+
};
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)("form", { onSubmit: (event) => void submit(event), style: styles_1.layout.stack8, noValidate: true, children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: fieldId, style: styles_1.text.label, children: parentId ? texts.reply : texts.writeComment }), (0, jsx_runtime_1.jsx)("textarea", { id: fieldId, "data-tsc-field": "", value: body, maxLength: MAX_LENGTH, placeholder: texts.commentPlaceholder, "aria-describedby": error ? errorId : undefined, "aria-invalid": error ? true : undefined, rows: 3, onChange: (event) => setBody(event.target.value) }), needsAck ? ((0, jsx_runtime_1.jsxs)("div", { style: styles_1.thread.guidelines, children: [(0, jsx_runtime_1.jsx)("p", { style: { ...styles_1.text.label, color: "var(--tsc-fg)", fontWeight: 600, margin: 0 }, children: texts.guidelinesTitle }), (0, jsx_runtime_1.jsx)("p", { style: { ...styles_1.text.meta, lineHeight: 1.5 }, children: texts.guidelinesBody }), (0, jsx_runtime_1.jsxs)("label", { style: styles_1.thread.check, children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: checked, onChange: (event) => setChecked(event.target.checked) }), (0, jsx_runtime_1.jsx)("span", { children: texts.guidelinesAccept })] })] })) : null, error ? ((0, jsx_runtime_1.jsx)("p", { id: errorId, role: "alert", style: styles_1.surface.notice, children: texts[error] })) : null, (0, jsx_runtime_1.jsxs)("div", { style: { ...styles_1.layout.row8, justifyContent: "flex-end" }, children: [onCancel ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-tsc-btn": "ghost", onClick: onCancel, children: texts.cancel })) : null, (0, jsx_runtime_1.jsx)("button", { type: "submit", "data-tsc-btn": "secondary", disabled: !ready, children: texts.commentSubmit })] })] }));
|
|
47
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommentReply } from "../core/types";
|
|
2
|
+
import type { VoteValue } from "./context";
|
|
3
|
+
export type CommentItemProps = Readonly<{
|
|
4
|
+
comment: CommentReply;
|
|
5
|
+
replies?: readonly CommentReply[];
|
|
6
|
+
releaseId: string;
|
|
7
|
+
onVote: (comment: CommentReply, value: VoteValue) => void;
|
|
8
|
+
onReplyPosted?: (reply: CommentReply) => void;
|
|
9
|
+
}>;
|
|
10
|
+
/** Author, developer badge, body, ↑/↓, reply and report. Top-level comments nest one level of replies. */
|
|
11
|
+
export declare function CommentItem({ comment, replies, releaseId, onVote, onReplyPosted }: CommentItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommentItem = CommentItem;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const CommentComposer_1 = require("./CommentComposer");
|
|
7
|
+
const icons_1 = require("./icons");
|
|
8
|
+
const ReportMenu_1 = require("./ReportMenu");
|
|
9
|
+
const styles_1 = require("./styles");
|
|
10
|
+
const texts_1 = require("./texts");
|
|
11
|
+
const useChanges_1 = require("./useChanges");
|
|
12
|
+
const VoteCapsule_1 = require("./VoteCapsule");
|
|
13
|
+
/** Author, developer badge, body, ↑/↓, reply and report. Top-level comments nest one level of replies. */
|
|
14
|
+
function CommentItem({ comment, replies, releaseId, onVote, onReplyPosted }) {
|
|
15
|
+
const { texts, locale, config, banned } = (0, useChanges_1.useChanges)();
|
|
16
|
+
const [replying, setReplying] = (0, react_1.useState)(false);
|
|
17
|
+
const votesEnabled = config?.community.votesEnabled === true;
|
|
18
|
+
const canReply = onReplyPosted !== undefined && !banned;
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)("li", { "data-comment-id": comment.id, style: styles_1.layout.stack8, children: [(0, jsx_runtime_1.jsxs)("div", { style: styles_1.layout.rowBetween, children: [(0, jsx_runtime_1.jsxs)("div", { style: { ...styles_1.layout.row8, ...styles_1.layout.grow }, children: [(0, jsx_runtime_1.jsx)("span", { style: styles_1.thread.author, children: comment.authorName }), comment.isDeveloper ? (0, jsx_runtime_1.jsx)("span", { style: styles_1.surface.developer, children: texts.developerBadge }) : null, (0, jsx_runtime_1.jsx)("time", { dateTime: comment.createdAt, style: styles_1.thread.date, children: (0, texts_1.formatShortDate)(comment.createdAt, locale) })] }), (0, jsx_runtime_1.jsx)(ReportMenu_1.ReportMenu, { commentId: comment.id })] }), (0, jsx_runtime_1.jsx)("p", { style: styles_1.thread.body, children: comment.body }), votesEnabled || canReply ? ((0, jsx_runtime_1.jsxs)("div", { style: styles_1.layout.row8, children: [votesEnabled ? ((0, jsx_runtime_1.jsx)(VoteCapsule_1.VoteCapsule, { upvotes: comment.upvotes, myVote: comment.myVote, disabled: banned, onVote: (value) => onVote(comment, value) })) : null, canReply ? ((0, jsx_runtime_1.jsxs)("button", { type: "button", "data-tsc-btn": "ghost", "data-tsc-reply": "", "aria-expanded": replying, onClick: () => setReplying((value) => !value), children: [(0, jsx_runtime_1.jsx)(icons_1.Reply, { size: 18 }), texts.reply] })) : null] })) : null, replying && onReplyPosted ? ((0, jsx_runtime_1.jsx)(CommentComposer_1.CommentComposer, { releaseId: releaseId, parentId: comment.id, onCancel: () => setReplying(false), onPosted: (reply) => {
|
|
20
|
+
setReplying(false);
|
|
21
|
+
onReplyPosted(reply);
|
|
22
|
+
} })) : null, replies && replies.length > 0 ? ((0, jsx_runtime_1.jsx)("ul", { style: styles_1.thread.replies, children: replies.map((reply) => ((0, jsx_runtime_1.jsx)(CommentItem, { comment: reply, releaseId: releaseId, onVote: onVote }, reply.id))) })) : null] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommentsThread = CommentsThread;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const CommentComposer_1 = require("./CommentComposer");
|
|
6
|
+
const CommentItem_1 = require("./CommentItem");
|
|
7
|
+
const styles_1 = require("./styles");
|
|
8
|
+
const useChanges_1 = require("./useChanges");
|
|
9
|
+
const use_thread_1 = require("./use-thread");
|
|
10
|
+
/** Composer on top, newest comments first, replies nested one level, paginated by 20. */
|
|
11
|
+
function CommentsThread({ releaseId }) {
|
|
12
|
+
const { texts, banned } = (0, useChanges_1.useChanges)();
|
|
13
|
+
const { thread, loadMore, added, voteOn, retry } = (0, use_thread_1.useThread)(releaseId);
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: styles_1.thread.root, "aria-busy": thread.status === "loading", children: [banned ? ((0, jsx_runtime_1.jsx)("p", { role: "alert", style: styles_1.surface.notice, children: texts.errorBanned })) : ((0, jsx_runtime_1.jsx)(CommentComposer_1.CommentComposer, { releaseId: releaseId, onPosted: (comment) => added(comment) })), thread.status === "error" ? ((0, jsx_runtime_1.jsxs)("div", { style: { ...styles_1.layout.stack8, justifyItems: "start" }, children: [(0, jsx_runtime_1.jsx)("p", { role: "alert", style: styles_1.surface.notice, children: texts.loadError }), (0, jsx_runtime_1.jsx)("button", { type: "button", "data-tsc-btn": "secondary", onClick: () => void retry(), children: texts.retry })] })) : null, thread.status === "ready" && thread.items.length === 0 ? (0, jsx_runtime_1.jsx)("p", { style: styles_1.text.meta, children: texts.noComments }) : null, thread.items.length > 0 ? ((0, jsx_runtime_1.jsx)("ul", { style: { ...styles_1.layout.list, display: "grid", gap: 20 }, children: thread.items.map((comment) => ((0, jsx_runtime_1.jsx)(CommentItem_1.CommentItem, { comment: comment, replies: comment.replies, releaseId: releaseId, onVote: (target, value) => void voteOn(target, value), onReplyPosted: (reply) => added(reply, comment.id) }, comment.id))) })) : null, thread.nextCursor !== null ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-tsc-btn": "secondary", disabled: thread.loadingMore, onClick: () => void loadMore(), style: { justifySelf: "start" }, children: texts.loadMore })) : null] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type DialogShellProps = Readonly<{
|
|
3
|
+
labelledBy: string;
|
|
4
|
+
header: ReactNode;
|
|
5
|
+
footer?: ReactNode;
|
|
6
|
+
size?: "default" | "wide";
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
/** Portal + backdrop + `role="dialog"` panel. Centered card on wide screens, bottom sheet at ≤520px. */
|
|
11
|
+
export declare function DialogShell({ labelledBy, header, footer, size, onClose, children }: DialogShellProps): import("react").ReactPortal | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DialogShell = DialogShell;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_dom_1 = require("react-dom");
|
|
7
|
+
const focus_trap_1 = require("./focus-trap");
|
|
8
|
+
const icons_1 = require("./icons");
|
|
9
|
+
const styles_1 = require("./styles");
|
|
10
|
+
const useChanges_1 = require("./useChanges");
|
|
11
|
+
/** Portal + backdrop + `role="dialog"` panel. Centered card on wide screens, bottom sheet at ≤520px. */
|
|
12
|
+
function DialogShell({ labelledBy, header, footer, size = "default", onClose, children }) {
|
|
13
|
+
const { rootProps, texts } = (0, useChanges_1.useChanges)();
|
|
14
|
+
const overlay = (0, react_1.useRef)(null);
|
|
15
|
+
const panel = (0, react_1.useRef)(null);
|
|
16
|
+
(0, focus_trap_1.useFocusTrap)(panel, onClose);
|
|
17
|
+
const close = (0, react_1.useRef)(onClose);
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
close.current = onClose;
|
|
20
|
+
});
|
|
21
|
+
(0, react_1.useEffect)(() => {
|
|
22
|
+
const element = overlay.current;
|
|
23
|
+
if (element === null)
|
|
24
|
+
return;
|
|
25
|
+
// Pointer convenience only: Escape and the close button are the keyboard paths.
|
|
26
|
+
const dismiss = (event) => {
|
|
27
|
+
if (event.target === element)
|
|
28
|
+
close.current();
|
|
29
|
+
};
|
|
30
|
+
element.addEventListener("mousedown", dismiss);
|
|
31
|
+
return () => element.removeEventListener("mousedown", dismiss);
|
|
32
|
+
}, []);
|
|
33
|
+
if (typeof document === "undefined")
|
|
34
|
+
return null;
|
|
35
|
+
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", { ...rootProps, ref: overlay, "data-tsc-overlay": "", children: (0, jsx_runtime_1.jsxs)("div", { ref: panel, "data-tsc-dialog": size, role: "dialog", "aria-modal": "true", "aria-labelledby": labelledBy, tabIndex: -1, children: [(0, jsx_runtime_1.jsxs)("div", { style: styles_1.dialogParts.header, children: [(0, jsx_runtime_1.jsx)("div", { style: { minWidth: 0 }, children: header }), (0, jsx_runtime_1.jsx)("button", { type: "button", "data-tsc-btn": "icon", "aria-label": texts.close, onClick: onClose, children: (0, jsx_runtime_1.jsx)(icons_1.Close, { size: 20 }) })] }), (0, jsx_runtime_1.jsx)("div", { style: styles_1.dialogParts.body, children: children }), footer ? (0, jsx_runtime_1.jsx)("div", { style: styles_1.dialogParts.footer, children: footer }) : null] }) }), document.body);
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { FetchImpl } from "../core/client";
|
|
3
|
+
import type { ChangesStorage } from "../core/storage";
|
|
4
|
+
import type { ErrorCode, User } from "../core/types";
|
|
5
|
+
import type { LocalePreference } from "./texts";
|
|
6
|
+
import type { ColorScheme } from "./theme";
|
|
7
|
+
export type ChangesProviderProps = Readonly<{
|
|
8
|
+
changesKey: string;
|
|
9
|
+
appVersion?: string;
|
|
10
|
+
user?: User;
|
|
11
|
+
locale?: LocalePreference;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
storage?: ChangesStorage;
|
|
14
|
+
/** Transport override for tests and non-browser runtimes; defaults to the global `fetch`. */
|
|
15
|
+
fetchImpl?: FetchImpl;
|
|
16
|
+
showOnFirstLaunch?: boolean;
|
|
17
|
+
forceShow?: boolean;
|
|
18
|
+
/** Render the What's New sheet automatically (default). Set `false` to place `<WhatsNewModal />` yourself. */
|
|
19
|
+
autoPresent?: boolean;
|
|
20
|
+
colorScheme?: ColorScheme;
|
|
21
|
+
onError?: (code: ErrorCode) => void;
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function ChangesProvider(props: ChangesProviderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChangesProvider = ChangesProvider;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const client_1 = require("../core/client");
|
|
7
|
+
const decide_1 = require("../core/decide");
|
|
8
|
+
const storage_1 = require("../core/storage");
|
|
9
|
+
const ChangelogDialog_1 = require("./ChangelogDialog");
|
|
10
|
+
const context_1 = require("./context");
|
|
11
|
+
const controls_css_1 = require("./controls-css");
|
|
12
|
+
const load_1 = require("./load");
|
|
13
|
+
const model_1 = require("./model");
|
|
14
|
+
const storage_2 = require("./storage");
|
|
15
|
+
const texts_1 = require("./texts");
|
|
16
|
+
const theme_1 = require("./theme");
|
|
17
|
+
const use_actions_1 = require("./use-actions");
|
|
18
|
+
const WhatsNewModal_1 = require("./WhatsNewModal");
|
|
19
|
+
const STYLESHEET = `${theme_1.THEME_CSS}\n${controls_css_1.CONTROLS_CSS}`;
|
|
20
|
+
const browserFetch = (url, init) => fetch(url, { method: init.method, headers: init.headers, ...(init.body === undefined ? {} : { body: init.body }) });
|
|
21
|
+
function randomBytes(length) {
|
|
22
|
+
const bytes = new Uint8Array(length);
|
|
23
|
+
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function")
|
|
24
|
+
return crypto.getRandomValues(bytes);
|
|
25
|
+
return bytes.map(() => Math.floor(Math.random() * 256));
|
|
26
|
+
}
|
|
27
|
+
function browserLanguages() {
|
|
28
|
+
if (typeof navigator === "undefined")
|
|
29
|
+
return [];
|
|
30
|
+
return navigator.languages.length > 0 ? navigator.languages : [navigator.language];
|
|
31
|
+
}
|
|
32
|
+
function ChangesProvider(props) {
|
|
33
|
+
const { changesKey, appVersion, baseUrl, locale = "auto", showOnFirstLaunch = false, forceShow = false } = props;
|
|
34
|
+
const { autoPresent = true, colorScheme = "auto", children } = props;
|
|
35
|
+
const userId = props.user?.userId;
|
|
36
|
+
const userName = props.user?.name;
|
|
37
|
+
const [model, setModel] = (0, react_1.useState)(() => (0, model_1.initialModel)(locale === "auto" ? "ko" : locale));
|
|
38
|
+
const injected = (0, react_1.useRef)({ storage: props.storage, fetchImpl: props.fetchImpl, onError: props.onError });
|
|
39
|
+
(0, react_1.useEffect)(() => {
|
|
40
|
+
injected.current = { storage: props.storage, fetchImpl: props.fetchImpl, onError: props.onError };
|
|
41
|
+
});
|
|
42
|
+
const start = (0, react_1.useCallback)(async (guard) => {
|
|
43
|
+
const { storage: given, fetchImpl, onError } = injected.current;
|
|
44
|
+
const storage = given ?? (0, storage_2.localStorageAdapter)();
|
|
45
|
+
const user = { ...(userId ? { userId } : {}), ...(userName ? { name: userName } : {}) };
|
|
46
|
+
const client = (0, client_1.createChangesClient)({
|
|
47
|
+
key: changesKey,
|
|
48
|
+
platform: "web",
|
|
49
|
+
fetchImpl: fetchImpl ?? browserFetch,
|
|
50
|
+
user,
|
|
51
|
+
...(baseUrl ? { baseUrl } : {}),
|
|
52
|
+
...(appVersion ? { appVersion } : {}),
|
|
53
|
+
});
|
|
54
|
+
const installId = await (0, storage_1.getOrCreateInstallId)(storage, changesKey, randomBytes);
|
|
55
|
+
const loaded = await (0, load_1.loadChanges)({
|
|
56
|
+
client,
|
|
57
|
+
storage,
|
|
58
|
+
key: changesKey,
|
|
59
|
+
appVersion: appVersion ?? null,
|
|
60
|
+
showOnFirstLaunch,
|
|
61
|
+
forceShow,
|
|
62
|
+
now: new Date(),
|
|
63
|
+
locale,
|
|
64
|
+
languages: browserLanguages(),
|
|
65
|
+
});
|
|
66
|
+
if (!guard.active)
|
|
67
|
+
return;
|
|
68
|
+
const runtime = { client, storage, key: changesKey, installId, appVersion: appVersion ?? null };
|
|
69
|
+
setModel((current) => ({ ...current, ...loaded, overrides: {}, runtime }));
|
|
70
|
+
if (loaded.error !== null)
|
|
71
|
+
onError?.(loaded.error);
|
|
72
|
+
}, [changesKey, baseUrl, appVersion, userId, userName, locale, showOnFirstLaunch, forceShow]);
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
74
|
+
const guard = { active: true };
|
|
75
|
+
void start(guard);
|
|
76
|
+
return () => {
|
|
77
|
+
guard.active = false;
|
|
78
|
+
};
|
|
79
|
+
}, [start]);
|
|
80
|
+
const reload = (0, react_1.useCallback)(() => {
|
|
81
|
+
setModel((current) => ({ ...current, status: "loading" }));
|
|
82
|
+
void start({ active: true });
|
|
83
|
+
}, [start]);
|
|
84
|
+
const actions = (0, use_actions_1.useActions)(model, setModel);
|
|
85
|
+
const accentColor = model.config?.app.accentColor;
|
|
86
|
+
const value = (0, react_1.useMemo)(() => {
|
|
87
|
+
const releases = model.releases.map((release) => (0, model_1.releaseView)(model, release));
|
|
88
|
+
const pending = model.pending === null ? null : (releases.find(({ id }) => id === model.pending?.id) ?? null);
|
|
89
|
+
return {
|
|
90
|
+
...actions,
|
|
91
|
+
status: model.status,
|
|
92
|
+
error: model.error,
|
|
93
|
+
stale: model.stale,
|
|
94
|
+
config: model.config,
|
|
95
|
+
locale: model.locale,
|
|
96
|
+
texts: (0, texts_1.resolveTexts)(model.config, model.locale),
|
|
97
|
+
releases,
|
|
98
|
+
latest: releases[0] ?? null,
|
|
99
|
+
unseenCount: model.state === null ? 0 : (0, decide_1.unseenCount)(releases, model.state),
|
|
100
|
+
pendingWhatsNew: pending,
|
|
101
|
+
changelogOpen: model.changelogOpen,
|
|
102
|
+
guidelinesAccepted: model.guidelinesAccepted,
|
|
103
|
+
banned: model.banned,
|
|
104
|
+
rootProps: { "data-tsc": "", "data-tsc-scheme": colorScheme, style: (0, theme_1.accentVars)(accentColor) },
|
|
105
|
+
reload,
|
|
106
|
+
};
|
|
107
|
+
}, [model, actions, colorScheme, accentColor, reload]);
|
|
108
|
+
return ((0, jsx_runtime_1.jsxs)(context_1.ChangesContext.Provider, { value: value, children: [(0, jsx_runtime_1.jsx)("style", { "data-tsc-style": "", children: STYLESHEET }), children, autoPresent ? (0, jsx_runtime_1.jsx)(WhatsNewModal_1.WhatsNewModal, {}) : null, (0, jsx_runtime_1.jsx)(ChangelogDialog_1.ChangelogDialog, {})] }));
|
|
109
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReleaseCard = ReleaseCard;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_1 = require("./icons");
|
|
6
|
+
const links_1 = require("./links");
|
|
7
|
+
const ReleaseEngagement_1 = require("./ReleaseEngagement");
|
|
8
|
+
const ReleaseSummary_1 = require("./ReleaseSummary");
|
|
9
|
+
const styles_1 = require("./styles");
|
|
10
|
+
const useChanges_1 = require("./useChanges");
|
|
11
|
+
/** One release in the changelog: summary, community actions and the hosted permalink. */
|
|
12
|
+
function ReleaseCard({ release }) {
|
|
13
|
+
const { config, texts } = (0, useChanges_1.useChanges)();
|
|
14
|
+
const href = (0, links_1.permalink)(config, release);
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)("article", { "data-release-id": release.id, style: styles_1.surface.card, children: [(0, jsx_runtime_1.jsx)(ReleaseSummary_1.ReleaseSummary, { release: release, level: 3 }), (0, jsx_runtime_1.jsx)(ReleaseEngagement_1.ReleaseEngagement, { release: release }), href ? ((0, jsx_runtime_1.jsxs)("a", { href: href, target: "_blank", rel: "noopener noreferrer", "data-tsc-link": "", style: {
|
|
16
|
+
display: "inline-flex",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
gap: 6,
|
|
19
|
+
minHeight: 44,
|
|
20
|
+
justifySelf: "start",
|
|
21
|
+
fontSize: 15,
|
|
22
|
+
}, children: [texts.readUpdate, (0, jsx_runtime_1.jsx)(icons_1.ArrowRight, { size: 16 })] })) : null] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReleaseEngagement = ReleaseEngagement;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const CommentsThread_1 = require("./CommentsThread");
|
|
7
|
+
const icons_1 = require("./icons");
|
|
8
|
+
const links_1 = require("./links");
|
|
9
|
+
const styles_1 = require("./styles");
|
|
10
|
+
const texts_1 = require("./texts");
|
|
11
|
+
const useChanges_1 = require("./useChanges");
|
|
12
|
+
const VoteCapsule_1 = require("./VoteCapsule");
|
|
13
|
+
/** Vote capsule, the rating CTA under it, and the comment count with its inline thread. */
|
|
14
|
+
function ReleaseEngagement({ release }) {
|
|
15
|
+
const { config, texts, vote, openRating, banned } = (0, useChanges_1.useChanges)();
|
|
16
|
+
const [threadOpen, setThreadOpen] = (0, react_1.useState)(false);
|
|
17
|
+
const threadId = (0, react_1.useId)();
|
|
18
|
+
const votesEnabled = config?.community.votesEnabled === true;
|
|
19
|
+
const commentsEnabled = config?.community.commentsEnabled === true;
|
|
20
|
+
const rating = (0, links_1.offersRating)(config, release) ? (0, links_1.ratingTarget)(config) : null;
|
|
21
|
+
if (!votesEnabled && rating === null && !commentsEnabled)
|
|
22
|
+
return null;
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: styles_1.layout.stack16, children: [votesEnabled || rating !== null ? ((0, jsx_runtime_1.jsxs)("div", { style: { display: "grid", gap: 12, justifyItems: "start" }, children: [votesEnabled ? ((0, jsx_runtime_1.jsx)(VoteCapsule_1.VoteCapsule, { upvotes: release.upvotes, myVote: release.myVote, disabled: banned, onVote: (value) => void vote(release.id, value) })) : null, rating !== null ? ((0, jsx_runtime_1.jsxs)("button", { type: "button", "data-tsc-btn": "secondary", onClick: () => openRating(release), children: [(0, jsx_runtime_1.jsx)(icons_1.Star, { size: 18 }), (0, jsx_runtime_1.jsx)("span", { children: texts[rating.label] }), (0, jsx_runtime_1.jsx)(icons_1.ArrowUpRight, { size: 16 })] })) : null] })) : null, commentsEnabled ? ((0, jsx_runtime_1.jsxs)("div", { style: styles_1.layout.stack8, children: [(0, jsx_runtime_1.jsxs)("div", { style: styles_1.layout.rowBetween, children: [(0, jsx_runtime_1.jsxs)("span", { style: { ...styles_1.text.meta, display: "inline-flex", alignItems: "center", gap: 6 }, children: [(0, jsx_runtime_1.jsx)(icons_1.MessageCircle, { size: 16 }), (0, texts_1.fillCount)(texts.commentCount, release.commentCount)] }), (0, jsx_runtime_1.jsxs)("button", { type: "button", "data-tsc-btn": "ghost", "aria-expanded": threadOpen, "aria-controls": threadOpen ? threadId : undefined, onClick: () => setThreadOpen((open) => !open), style: { marginInlineEnd: -12 }, children: [texts.viewComments, (0, jsx_runtime_1.jsx)(icons_1.ChevronDown, { size: 16 })] })] }), threadOpen ? ((0, jsx_runtime_1.jsx)("div", { id: threadId, children: (0, jsx_runtime_1.jsx)(CommentsThread_1.CommentsThread, { releaseId: release.id }) })) : null] })) : null] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Release } from "../core/types";
|
|
2
|
+
export type ReleaseSummaryProps = Readonly<{
|
|
3
|
+
release: Release;
|
|
4
|
+
level: 2 | 3;
|
|
5
|
+
titleId?: string;
|
|
6
|
+
}>;
|
|
7
|
+
/** Title, `version · date`, tags and notes. The sheet renders it as an h2; list cards as h3. */
|
|
8
|
+
export declare function ReleaseSummary({ release, level, titleId }: ReleaseSummaryProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReleaseSummary = ReleaseSummary;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Blocks_1 = require("./Blocks");
|
|
6
|
+
const styles_1 = require("./styles");
|
|
7
|
+
const texts_1 = require("./texts");
|
|
8
|
+
const useChanges_1 = require("./useChanges");
|
|
9
|
+
/** Title, `version · date`, tags and notes. The sheet renders it as an h2; list cards as h3. */
|
|
10
|
+
function ReleaseSummary({ release, level, titleId }) {
|
|
11
|
+
const { texts, locale } = (0, useChanges_1.useChanges)();
|
|
12
|
+
const Heading = level === 2 ? "h2" : "h3";
|
|
13
|
+
const meta = [release.version, (0, texts_1.formatDate)(release.publishedAt, locale)].filter(Boolean).join(" · ");
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: styles_1.layout.stack12, children: [(0, jsx_runtime_1.jsxs)("div", { style: styles_1.layout.stack4, children: [(0, jsx_runtime_1.jsx)(Heading, { id: titleId, style: level === 2 ? styles_1.text.sheetTitle : styles_1.text.cardTitle, children: release.title }), (0, jsx_runtime_1.jsx)("p", { style: styles_1.text.meta, children: (0, jsx_runtime_1.jsx)("time", { dateTime: release.publishedAt, children: meta }) })] }), release.tags.length > 0 ? ((0, jsx_runtime_1.jsx)("ul", { style: { ...styles_1.layout.list, ...styles_1.layout.row8, gap: 6 }, children: release.tags.map((tag) => ((0, jsx_runtime_1.jsx)("li", { style: styles_1.surface.tag, children: texts[`tag_${tag}`] }, tag))) })) : null, (0, jsx_runtime_1.jsx)(Blocks_1.Blocks, { blocks: release.blocks })] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportMenu = ReportMenu;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const icons_1 = require("./icons");
|
|
7
|
+
const styles_1 = require("./styles");
|
|
8
|
+
const useChanges_1 = require("./useChanges");
|
|
9
|
+
const REASONS = ["spam", "abuse", "off_topic", "other"];
|
|
10
|
+
function items(menu) {
|
|
11
|
+
return menu === null ? [] : Array.from(menu.querySelectorAll('[role="menuitem"]'));
|
|
12
|
+
}
|
|
13
|
+
/** `⋯` menu on a comment. Choosing a reason files the report once; arrow keys move, Escape closes. */
|
|
14
|
+
function ReportMenu({ commentId }) {
|
|
15
|
+
const { texts, comments } = (0, useChanges_1.useChanges)();
|
|
16
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
17
|
+
const [reported, setReported] = (0, react_1.useState)(false);
|
|
18
|
+
const menuId = (0, react_1.useId)();
|
|
19
|
+
const trigger = (0, react_1.useRef)(null);
|
|
20
|
+
const menu = (0, react_1.useRef)(null);
|
|
21
|
+
(0, react_1.useEffect)(() => {
|
|
22
|
+
const element = menu.current;
|
|
23
|
+
if (!open || element === null)
|
|
24
|
+
return;
|
|
25
|
+
items(element)[0]?.focus();
|
|
26
|
+
const outside = (event) => {
|
|
27
|
+
const target = event.target;
|
|
28
|
+
if (!(target instanceof Node))
|
|
29
|
+
return;
|
|
30
|
+
if (!element.contains(target) && !trigger.current?.contains(target))
|
|
31
|
+
setOpen(false);
|
|
32
|
+
};
|
|
33
|
+
// Native so it runs before the dialog's own Escape listener and only closes the menu.
|
|
34
|
+
const escape = (event) => {
|
|
35
|
+
if (event.key !== "Escape")
|
|
36
|
+
return;
|
|
37
|
+
event.stopPropagation();
|
|
38
|
+
setOpen(false);
|
|
39
|
+
trigger.current?.focus();
|
|
40
|
+
};
|
|
41
|
+
document.addEventListener("mousedown", outside);
|
|
42
|
+
element.addEventListener("keydown", escape);
|
|
43
|
+
return () => {
|
|
44
|
+
document.removeEventListener("mousedown", outside);
|
|
45
|
+
element.removeEventListener("keydown", escape);
|
|
46
|
+
};
|
|
47
|
+
}, [open]);
|
|
48
|
+
const onKeyDown = (event) => {
|
|
49
|
+
const list = items(menu.current);
|
|
50
|
+
const index = list.findIndex((item) => item === document.activeElement);
|
|
51
|
+
switch (event.key) {
|
|
52
|
+
case "ArrowDown":
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
list[(index + 1) % list.length]?.focus();
|
|
55
|
+
return;
|
|
56
|
+
case "ArrowUp":
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
list[(index - 1 + list.length) % list.length]?.focus();
|
|
59
|
+
return;
|
|
60
|
+
case "Tab":
|
|
61
|
+
setOpen(false);
|
|
62
|
+
return;
|
|
63
|
+
default:
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const submit = async (reason) => {
|
|
68
|
+
setOpen(false);
|
|
69
|
+
const result = await comments.report(commentId, reason);
|
|
70
|
+
if (result.ok)
|
|
71
|
+
setReported(true);
|
|
72
|
+
else
|
|
73
|
+
trigger.current?.focus();
|
|
74
|
+
};
|
|
75
|
+
if (reported) {
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)("span", { role: "status", style: { ...styles_1.text.meta, minHeight: 44, display: "inline-flex", alignItems: "center" }, children: texts.reported }));
|
|
77
|
+
}
|
|
78
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { position: "relative", flex: "none" }, children: [(0, jsx_runtime_1.jsx)("button", { ref: trigger, type: "button", "data-tsc-btn": "icon", "aria-label": texts.commentMenu, "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": open ? menuId : undefined, onClick: () => setOpen((value) => !value), children: (0, jsx_runtime_1.jsx)(icons_1.Ellipsis, { size: 18 }) }), open ? ((0, jsx_runtime_1.jsxs)("div", { ref: menu, id: menuId, role: "menu", tabIndex: -1, "aria-label": texts.report, style: styles_1.surface.menu, onKeyDown: onKeyDown, children: [(0, jsx_runtime_1.jsx)("p", { "aria-hidden": "true", style: { ...styles_1.text.label, margin: 0, padding: "4px 12px" }, children: texts.report }), REASONS.map((reason) => ((0, jsx_runtime_1.jsx)("button", { type: "button", role: "menuitem", tabIndex: -1, "data-tsc-menuitem": "", onClick: () => void submit(reason), children: texts[`reportReasons_${reason}`] }, reason)))] })) : null] }));
|
|
79
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VoteValue } from "./context";
|
|
2
|
+
export type VoteCapsuleProps = Readonly<{
|
|
3
|
+
upvotes: number;
|
|
4
|
+
myVote: VoteValue;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
onVote: (value: VoteValue) => void;
|
|
7
|
+
}>;
|
|
8
|
+
/** `↑ n | ↓` pill. Pressing the active side again clears the vote; the filled arrow marks the current vote. */
|
|
9
|
+
export declare function VoteCapsule({ upvotes, myVote, disabled, onVote }: VoteCapsuleProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoteCapsule = VoteCapsule;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_1 = require("./icons");
|
|
6
|
+
const styles_1 = require("./styles");
|
|
7
|
+
const useChanges_1 = require("./useChanges");
|
|
8
|
+
/** `↑ n | ↓` pill. Pressing the active side again clears the vote; the filled arrow marks the current vote. */
|
|
9
|
+
function VoteCapsule({ upvotes, myVote, disabled = false, onVote }) {
|
|
10
|
+
const { texts } = (0, useChanges_1.useChanges)();
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)("div", { "data-tsc-capsule": "", role: "group", "aria-label": `${texts.upvote} / ${texts.downvote}`, children: [(0, jsx_runtime_1.jsxs)("button", { type: "button", "data-tsc-vote": "up", "aria-pressed": myVote === 1, "aria-label": `${texts.upvote} ${upvotes}`, disabled: disabled, onClick: () => onVote(myVote === 1 ? 0 : 1), children: [(0, jsx_runtime_1.jsx)(icons_1.ArrowBigUp, { size: 18 }), (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", children: upvotes })] }), (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", style: styles_1.surface.divider }), (0, jsx_runtime_1.jsx)("button", { type: "button", "data-tsc-vote": "down", "aria-pressed": myVote === -1, "aria-label": texts.downvote, disabled: disabled, onClick: () => onVote(myVote === -1 ? 0 : -1), children: (0, jsx_runtime_1.jsx)(icons_1.ArrowBigDown, { size: 18 }) })] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsNewModal = WhatsNewModal;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const DialogShell_1 = require("./DialogShell");
|
|
7
|
+
const ReleaseEngagement_1 = require("./ReleaseEngagement");
|
|
8
|
+
const ReleaseSummary_1 = require("./ReleaseSummary");
|
|
9
|
+
const styles_1 = require("./styles");
|
|
10
|
+
const useChanges_1 = require("./useChanges");
|
|
11
|
+
function WhatsNewSheet({ release }) {
|
|
12
|
+
const { markPresented, dismissWhatsNew, texts } = (0, useChanges_1.useChanges)();
|
|
13
|
+
const titleId = (0, react_1.useId)();
|
|
14
|
+
// The show-once state advances only here, after the sheet is really on screen.
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
markPresented(release);
|
|
17
|
+
}, [markPresented, release]);
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(DialogShell_1.DialogShell, { labelledBy: titleId, onClose: dismissWhatsNew, header: (0, jsx_runtime_1.jsx)("p", { style: styles_1.text.eyebrow, children: texts.whatsNew }), footer: (0, jsx_runtime_1.jsx)("button", { type: "button", "data-tsc-btn": "primary", onClick: dismissWhatsNew, children: texts.continue }), children: (0, jsx_runtime_1.jsxs)("div", { style: { ...styles_1.layout.stack16, gap: 24 }, children: [(0, jsx_runtime_1.jsx)(ReleaseSummary_1.ReleaseSummary, { release: release, level: 2, titleId: titleId }), (0, jsx_runtime_1.jsx)(ReleaseEngagement_1.ReleaseEngagement, { release: release })] }) }));
|
|
19
|
+
}
|
|
20
|
+
/** What's New sheet for the release chosen by the show-once rules. Rendered by the provider unless `autoPresent={false}`. */
|
|
21
|
+
function WhatsNewModal() {
|
|
22
|
+
const { pendingWhatsNew } = (0, useChanges_1.useChanges)();
|
|
23
|
+
if (pendingWhatsNew === null)
|
|
24
|
+
return null;
|
|
25
|
+
return (0, jsx_runtime_1.jsx)(WhatsNewSheet, { release: pendingWhatsNew }, pendingWhatsNew.id);
|
|
26
|
+
}
|