hive-react-kit 0.9.3 → 0.9.5
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 +40 -0
- package/dist/components/HiveDetailPost.d.ts +13 -1
- package/dist/components/TranslatedBody.d.ts +20 -0
- package/dist/components/TranslatedText.d.ts +26 -0
- package/dist/components/VoteSlider.d.ts +3 -1
- package/dist/components/actionButtons/PostActionButton.d.ts +6 -1
- package/dist/components/comments/AddCommentInput.d.ts +6 -3
- package/dist/components/comments/CommentsModal.d.ts +5 -1
- package/dist/components/inlineComments/InlineCommentItem.d.ts +6 -1
- package/dist/components/inlineComments/InlineCommentSection.d.ts +5 -1
- package/dist/components/user/PollListItem.d.ts +4 -0
- package/dist/components/user/UserDetailProfile.d.ts +7 -0
- package/dist/i18n/HiveLanguageContext.d.ts +67 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/messages.d.ts +25 -0
- package/dist/i18n/translateService.d.ts +20 -0
- package/dist/i18n/useTranslatedHtml.d.ts +14 -0
- package/dist/i18n/useTranslatedText.d.ts +13 -0
- package/dist/index.cjs.js +96 -96
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +9212 -8777
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ A comprehensive React component library for building Hive blockchain application
|
|
|
10
10
|
- 🎯 **TypeScript Support** - Full TypeScript support with type definitions
|
|
11
11
|
- 🚀 **Tree Shaking** - Optimized bundle size with tree shaking support
|
|
12
12
|
- 🎭 **Customizable** - Easy to customize and extend
|
|
13
|
+
- 🌐 **Content i18n** - Wrap once, every Hive post body / comment / feed preview translates to the user's language. See [docs/i18n.md](docs/i18n.md)
|
|
13
14
|
|
|
14
15
|
## Installation
|
|
15
16
|
|
|
@@ -415,6 +416,45 @@ See [docs/HiveContributionsLanding.md](docs/HiveContributionsLanding.md) for ful
|
|
|
415
416
|
| 3Speak | https://3speak.tv/ |
|
|
416
417
|
| HiveFestFacts | https://hivefestfacts.sagarkothari88.one/ |
|
|
417
418
|
|
|
419
|
+
### Content Translation (i18n)
|
|
420
|
+
|
|
421
|
+
Wrap your app once with `<HiveLanguageProvider>` and every Hive content body / title / comment / feed preview rendered by the kit translates to the chosen language. Free MyMemory-backed translator by default, fully overridable for DeepL / Google / your own backend.
|
|
422
|
+
|
|
423
|
+
```tsx
|
|
424
|
+
import { HiveLanguageProvider } from 'hive-react-kit';
|
|
425
|
+
|
|
426
|
+
<HiveLanguageProvider language="es">
|
|
427
|
+
<App />
|
|
428
|
+
</HiveLanguageProvider>
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
**Auto-translates:** post bodies (`HiveDetailPost`, `InlineCommentItem`, `CommentTile`, `UserChannel`), feed-card titles + previews (`UserDetailProfile`), poll questions / previews / choice labels (`PollListItem`).
|
|
432
|
+
|
|
433
|
+
**Available exports:**
|
|
434
|
+
|
|
435
|
+
| Export | Purpose |
|
|
436
|
+
|--------|---------|
|
|
437
|
+
| `HiveLanguageProvider` | Wrap app once with `language="es"` (or any code MyMemory accepts). `language="en"` is no-op |
|
|
438
|
+
| `useHiveLanguage()` | Read current `{ language, translateHtml }` from context |
|
|
439
|
+
| `useTranslatedHtml(html)` | Hook returning `{ html, loading }` for translated rendered HTML |
|
|
440
|
+
| `useTranslatedText(text)` | Hook returning `{ text, loading }` for translated plain strings |
|
|
441
|
+
| `<TranslatedBody>` | `forwardRef`-aware drop-in for `<div … dangerouslySetInnerHTML>` |
|
|
442
|
+
| `<TranslatedText>` | Inline wrapper for plain strings inside `.map()` loops |
|
|
443
|
+
| `translateHtml`, `translateText` | Low-level helpers (rarely needed) |
|
|
444
|
+
|
|
445
|
+
**Custom translator** — pass `translateHtml` to override the bundled MyMemory implementation:
|
|
446
|
+
|
|
447
|
+
```tsx
|
|
448
|
+
<HiveLanguageProvider
|
|
449
|
+
language={language}
|
|
450
|
+
translateHtml={async (html, target) => callDeepL(html, target)}
|
|
451
|
+
>
|
|
452
|
+
<App />
|
|
453
|
+
</HiveLanguageProvider>
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
See [docs/i18n.md](docs/i18n.md) for the full provider API, hook signatures, custom-translator integration, caching layers, failure modes, and behaviour with code blocks / embeds.
|
|
457
|
+
|
|
418
458
|
### Feed Components
|
|
419
459
|
|
|
420
460
|
- **PostFeedList** - Display a list of posts with sorting, filtering, and interaction capabilities
|
|
@@ -28,6 +28,18 @@ export interface HiveDetailPostProps {
|
|
|
28
28
|
* Typically wired to a user setting.
|
|
29
29
|
*/
|
|
30
30
|
defaultReward?: import('../utils/commentOptions').RewardOption;
|
|
31
|
+
/**
|
|
32
|
+
* Initial percent (1–100) for the post's upvote slider AND every comment
|
|
33
|
+
* composer's "upvote-on-publish" / comment-upvote slider on this page.
|
|
34
|
+
* Default 100. Typically wired to a user setting.
|
|
35
|
+
*/
|
|
36
|
+
defaultVotePercent?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Slider precision (0.25, 0.5, or 1) used by every vote slider on this
|
|
39
|
+
* page — the post upvote action, comment upvote actions, and the
|
|
40
|
+
* upvote-on-publish slider in the comment composer. Default 0.25.
|
|
41
|
+
*/
|
|
42
|
+
voteWeightStep?: number;
|
|
31
43
|
/**
|
|
32
44
|
* Override the Hive content renderer's link-generating functions so the
|
|
33
45
|
* rendered `<a>` URLs route into your app instead of an external Hive
|
|
@@ -88,5 +100,5 @@ export interface HiveDetailPostProps {
|
|
|
88
100
|
/** Called when user clicks "View parent post" — navigate to the parent post. */
|
|
89
101
|
onNavigateToPost?: (author: string, permlink: string) => void;
|
|
90
102
|
}
|
|
91
|
-
export declare function HiveDetailPost({ author, permlink, currentUser, onUpvote, onSubmitComment, onClickCommentUpvote, onReblog, onShare, onTip, onReport, onShareComment, onTipComment, onReportComment, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, reportedAuthors, reportedPosts, hiveIconUrl, backgroundColor, onBack, onUserClick, onNavigateToPost, onVotePoll, showVoteButton, processBody, defaultReward, renderOptions, }: HiveDetailPostProps): import("react/jsx-runtime").JSX.Element;
|
|
103
|
+
export declare function HiveDetailPost({ author, permlink, currentUser, onUpvote, onSubmitComment, onClickCommentUpvote, onReblog, onShare, onTip, onReport, onShareComment, onTipComment, onReportComment, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, reportedAuthors, reportedPosts, hiveIconUrl, backgroundColor, onBack, onUserClick, onNavigateToPost, onVotePoll, showVoteButton, processBody, defaultReward, defaultVotePercent, voteWeightStep, renderOptions, }: HiveDetailPostProps): import("react/jsx-runtime").JSX.Element;
|
|
92
104
|
export default HiveDetailPost;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface TranslatedBodyProps {
|
|
3
|
+
/** Rendered post / comment body HTML (output of `createHiveRenderer`). */
|
|
4
|
+
html: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Drop-in replacement for
|
|
10
|
+
* `<div className="…" onClick={…} dangerouslySetInnerHTML={{ __html: html }} />`
|
|
11
|
+
* that translates the body into the language supplied by the nearest
|
|
12
|
+
* `<HiveLanguageProvider>`. Forwards refs to the inner div so existing
|
|
13
|
+
* click-delegation / image-fallback logic continues to attach correctly.
|
|
14
|
+
*
|
|
15
|
+
* While translation is in flight the original HTML is shown and the
|
|
16
|
+
* `data-translating="true"` attribute is set on the div so consumers
|
|
17
|
+
* can apply a CSS-only loading style if they want.
|
|
18
|
+
*/
|
|
19
|
+
export declare const TranslatedBody: React.ForwardRefExoticComponent<TranslatedBodyProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export default TranslatedBody;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface TranslatedTextProps {
|
|
3
|
+
/** Plain-text source string (post title, snippet, caption, etc.). */
|
|
4
|
+
text: string | null | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Optional fallback rendered when both translated and source text are
|
|
7
|
+
* empty — typically the calling component already conditionally renders
|
|
8
|
+
* this wrapper, so it's rarely needed.
|
|
9
|
+
*/
|
|
10
|
+
fallback?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Drop-in inline wrapper for translating a plain string into the language
|
|
14
|
+
* supplied by the nearest `<HiveLanguageProvider>`. Useful inside loops /
|
|
15
|
+
* `.map()` render functions where calling `useTranslatedText` directly
|
|
16
|
+
* would break the rules of hooks.
|
|
17
|
+
*
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <h2><TranslatedText text={item.title} /></h2>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Returns the original synchronously while the translation is in flight,
|
|
23
|
+
* so titles never flash empty. No-op for English.
|
|
24
|
+
*/
|
|
25
|
+
export declare const TranslatedText: React.FC<TranslatedTextProps>;
|
|
26
|
+
export default TranslatedText;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export declare function VoteSlider({ author, permlink, defaultValue, onUpvote, onCancel, }: {
|
|
1
|
+
export declare function VoteSlider({ author, permlink, defaultValue, step, onUpvote, onCancel, }: {
|
|
2
2
|
author: string;
|
|
3
3
|
permlink: string;
|
|
4
4
|
defaultValue?: number;
|
|
5
|
+
/** Slider precision. Use 0.25, 0.5, or 1 (default 1). */
|
|
6
|
+
step?: number;
|
|
5
7
|
onUpvote: (percent: number) => Promise<void> | void;
|
|
6
8
|
onCancel: () => void;
|
|
7
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -28,6 +28,11 @@ export interface PostActionButtonProps {
|
|
|
28
28
|
parentTags?: string[];
|
|
29
29
|
/** Default reward routing seeded into the comment composer. */
|
|
30
30
|
defaultReward?: import('../../utils/commentOptions').RewardOption;
|
|
31
|
+
/** Initial percent for the upvote slider when opened (1–100). Default 100. */
|
|
32
|
+
defaultVotePercent?: number;
|
|
33
|
+
/** Slider precision used by both the post upvote slider AND the comment composer's
|
|
34
|
+
* "upvote-on-publish" slider. Use 0.25, 0.5, or 1. Default 0.25 (back-compat). */
|
|
35
|
+
voteWeightStep?: number;
|
|
31
36
|
/** Called when comment button is clicked (e.g. open comments). */
|
|
32
37
|
onComments?: () => void;
|
|
33
38
|
/** Called when reblog is clicked (when logged in). */
|
|
@@ -53,5 +58,5 @@ export interface PostActionButtonProps {
|
|
|
53
58
|
/** When true, clicking the comment icon calls onComments instead of opening the CommentsModal popup */
|
|
54
59
|
disableCommentsModal?: boolean;
|
|
55
60
|
}
|
|
56
|
-
export declare function PostActionButton({ author, permlink, currentUser: currentUserProp, hiveValue, hiveIconUrl, payoutTooltip, initialVotes, initialCommentsCount, onUpvote, onSubmitComment, onComments, onReblog, onShare, onTip, onReport, onClickCommentUpvote, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, disableCommentsModal, showVoteButton, parentTags, defaultReward, }: PostActionButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
61
|
+
export declare function PostActionButton({ author, permlink, currentUser: currentUserProp, hiveValue, hiveIconUrl, payoutTooltip, initialVotes, initialCommentsCount, onUpvote, onSubmitComment, onComments, onReblog, onShare, onTip, onReport, onClickCommentUpvote, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, disableCommentsModal, showVoteButton, parentTags, defaultReward, defaultVotePercent, voteWeightStep, }: PostActionButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
57
62
|
export default PostActionButton;
|
|
@@ -68,8 +68,11 @@ export interface PostComposerProps {
|
|
|
68
68
|
showVoteButton?: boolean;
|
|
69
69
|
/** Initial toggle state for upvote-on-publish (default false). */
|
|
70
70
|
defaultVoteEnabled?: boolean;
|
|
71
|
-
/** Initial slider percent (1–100,
|
|
71
|
+
/** Initial slider percent (1–100, default 100). Snapped to `voteWeightStep`. */
|
|
72
72
|
defaultVotePercent?: number;
|
|
73
|
+
/** Slider precision for the upvote-on-publish slider. Use 0.25, 0.5, or 1.
|
|
74
|
+
* Default 0.25 (back-compat). */
|
|
75
|
+
voteWeightStep?: number;
|
|
73
76
|
/**
|
|
74
77
|
* Called whenever the upvote-on-publish toggle or percent changes.
|
|
75
78
|
* `enabled=false` => consumer should post a plain comment.
|
|
@@ -115,8 +118,8 @@ export interface PostComposerProps {
|
|
|
115
118
|
}
|
|
116
119
|
/** @deprecated Use PostComposerProps instead */
|
|
117
120
|
export type AddCommentInputProps = PostComposerProps;
|
|
118
|
-
declare const PostComposer: ({ onSubmit, onCancel, currentUser, placeholder, parentAuthor, parentPermlink, ecencyToken, onSignMessage, signingUsername, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, hideBold, hideItalic, hideLink, hideImage, hideAudio, hideVideo, hideEmoji, hideGif, hideCode, hideMention, hideTemplate, hidePreview, hidePoll, onPollChange, defaultTags, maxTags, onTagsChange, hideTags, reward, defaultReward, onRewardChange, hideReward, showVoteButton, defaultVoteEnabled, defaultVotePercent, onVoteChange, voteLabel, showCancel, submitLabel, title, defaultPreviewOn, value, onChange, disabled, hideSubmitArea, submitRef, hideUserHeader, bgColor, borderColor, disableAutoFocus, walletApprovalLabel, awaitingWalletApproval, }: PostComposerProps) => import("react/jsx-runtime").JSX.Element;
|
|
121
|
+
declare const PostComposer: ({ onSubmit, onCancel, currentUser, placeholder, parentAuthor, parentPermlink, ecencyToken, onSignMessage, signingUsername, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, hideBold, hideItalic, hideLink, hideImage, hideAudio, hideVideo, hideEmoji, hideGif, hideCode, hideMention, hideTemplate, hidePreview, hidePoll, onPollChange, defaultTags, maxTags, onTagsChange, hideTags, reward, defaultReward, onRewardChange, hideReward, showVoteButton, defaultVoteEnabled, defaultVotePercent, voteWeightStep, onVoteChange, voteLabel, showCancel, submitLabel, title, defaultPreviewOn, value, onChange, disabled, hideSubmitArea, submitRef, hideUserHeader, bgColor, borderColor, disableAutoFocus, walletApprovalLabel, awaitingWalletApproval, }: PostComposerProps) => import("react/jsx-runtime").JSX.Element;
|
|
119
122
|
/** @deprecated Use PostComposer instead */
|
|
120
|
-
declare const AddCommentInput: ({ onSubmit, onCancel, currentUser, placeholder, parentAuthor, parentPermlink, ecencyToken, onSignMessage, signingUsername, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, hideBold, hideItalic, hideLink, hideImage, hideAudio, hideVideo, hideEmoji, hideGif, hideCode, hideMention, hideTemplate, hidePreview, hidePoll, onPollChange, defaultTags, maxTags, onTagsChange, hideTags, reward, defaultReward, onRewardChange, hideReward, showVoteButton, defaultVoteEnabled, defaultVotePercent, onVoteChange, voteLabel, showCancel, submitLabel, title, defaultPreviewOn, value, onChange, disabled, hideSubmitArea, submitRef, hideUserHeader, bgColor, borderColor, disableAutoFocus, walletApprovalLabel, awaitingWalletApproval, }: PostComposerProps) => import("react/jsx-runtime").JSX.Element;
|
|
123
|
+
declare const AddCommentInput: ({ onSubmit, onCancel, currentUser, placeholder, parentAuthor, parentPermlink, ecencyToken, onSignMessage, signingUsername, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, hideBold, hideItalic, hideLink, hideImage, hideAudio, hideVideo, hideEmoji, hideGif, hideCode, hideMention, hideTemplate, hidePreview, hidePoll, onPollChange, defaultTags, maxTags, onTagsChange, hideTags, reward, defaultReward, onRewardChange, hideReward, showVoteButton, defaultVoteEnabled, defaultVotePercent, voteWeightStep, onVoteChange, voteLabel, showCancel, submitLabel, title, defaultPreviewOn, value, onChange, disabled, hideSubmitArea, submitRef, hideUserHeader, bgColor, borderColor, disableAutoFocus, walletApprovalLabel, awaitingWalletApproval, }: PostComposerProps) => import("react/jsx-runtime").JSX.Element;
|
|
121
124
|
export { PostComposer };
|
|
122
125
|
export default AddCommentInput;
|
|
@@ -30,6 +30,10 @@ interface CommentsModalProps {
|
|
|
30
30
|
templateToken?: string;
|
|
31
31
|
/** Custom template API endpoint */
|
|
32
32
|
templateApiBaseUrl?: string;
|
|
33
|
+
/** Initial percent for the composer's "upvote on publish" slider. Default 100. */
|
|
34
|
+
defaultVotePercent?: number;
|
|
35
|
+
/** Slider precision for the composer's "upvote on publish" slider (0.25, 0.5, or 1). Default 0.25. */
|
|
36
|
+
voteWeightStep?: number;
|
|
33
37
|
}
|
|
34
|
-
declare const CommentsModal: ({ author, permlink, onClose, currentUser, token, onClickCommentUpvote, onClickCommentReply, onClickUpvoteButton, onSubmitComment, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, showVoteButton, parentTags, defaultReward }: CommentsModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
declare const CommentsModal: ({ author, permlink, onClose, currentUser, token, onClickCommentUpvote, onClickCommentReply, onClickUpvoteButton, onSubmitComment, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, showVoteButton, parentTags, defaultReward, defaultVotePercent, voteWeightStep }: CommentsModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
39
|
export default CommentsModal;
|
|
@@ -29,6 +29,11 @@ interface InlineCommentItemProps {
|
|
|
29
29
|
onUserClick?: (username: string) => void;
|
|
30
30
|
/** Default reward routing seeded into every reply composer. */
|
|
31
31
|
defaultReward?: RewardOption;
|
|
32
|
+
/** Initial percent for the comment-upvote slider AND reply composer's
|
|
33
|
+
* upvote-on-publish slider. Default 100. */
|
|
34
|
+
defaultVotePercent?: number;
|
|
35
|
+
/** Slider precision (0.25, 0.5, or 1) used by both sliders. Default 0.25. */
|
|
36
|
+
voteWeightStep?: number;
|
|
32
37
|
/** Renderer URL overrides applied to the comment body. */
|
|
33
38
|
renderOptions?: {
|
|
34
39
|
userLinkUrlFn?: (username: string) => string;
|
|
@@ -37,5 +42,5 @@ interface InlineCommentItemProps {
|
|
|
37
42
|
ipfsGateway?: string;
|
|
38
43
|
};
|
|
39
44
|
}
|
|
40
|
-
export default function InlineCommentItem({ comment, allComments, onReply, onCancelReply, onCommentSubmit, activeReplyKey, currentUser, token, depth, onVotedRefresh, onClickCommentUpvote, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, hiveIconUrl, onShareComment, onTipComment, onReportComment, onNavigateToPost, onUserClick, defaultReward, renderOptions, }: InlineCommentItemProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export default function InlineCommentItem({ comment, allComments, onReply, onCancelReply, onCommentSubmit, activeReplyKey, currentUser, token, depth, onVotedRefresh, onClickCommentUpvote, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, hiveIconUrl, onShareComment, onTipComment, onReportComment, onNavigateToPost, onUserClick, defaultReward, defaultVotePercent, voteWeightStep, renderOptions, }: InlineCommentItemProps): import("react/jsx-runtime").JSX.Element;
|
|
41
46
|
export {};
|
|
@@ -15,6 +15,10 @@ interface InlineCommentSectionProps {
|
|
|
15
15
|
parentTags?: string[];
|
|
16
16
|
/** Default reward routing seeded into every reply composer in this section. */
|
|
17
17
|
defaultReward?: RewardOption;
|
|
18
|
+
/** Initial percent for the "upvote on publish" slider in every reply composer. Default 100. */
|
|
19
|
+
defaultVotePercent?: number;
|
|
20
|
+
/** Slider precision (0.25, 0.5, or 1) used by every reply composer. Default 0.25. */
|
|
21
|
+
voteWeightStep?: number;
|
|
18
22
|
/** Renderer URL overrides applied to every comment body in this section. */
|
|
19
23
|
renderOptions?: {
|
|
20
24
|
userLinkUrlFn?: (username: string) => string;
|
|
@@ -43,5 +47,5 @@ interface InlineCommentSectionProps {
|
|
|
43
47
|
/** Intercept intra-body Hive profile links in comment bodies. */
|
|
44
48
|
onUserClick?: (username: string) => void;
|
|
45
49
|
}
|
|
46
|
-
export default function InlineCommentSection({ author, permlink, currentUser, token, onSubmitComment, onClickCommentUpvote, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, reportedAuthors, reportedPosts, hiveIconUrl, onShareComment, onTipComment, onReportComment, onNavigateToPost, onUserClick, showVoteButton, alreadyVoted, parentTags, defaultReward, renderOptions, }: InlineCommentSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export default function InlineCommentSection({ author, permlink, currentUser, token, onSubmitComment, onClickCommentUpvote, ecencyToken, threeSpeakApiKey, giphyApiKey, templateToken, templateApiBaseUrl, reportedAuthors, reportedPosts, hiveIconUrl, onShareComment, onTipComment, onReportComment, onNavigateToPost, onUserClick, showVoteButton, alreadyVoted, parentTags, defaultReward, defaultVotePercent, voteWeightStep, renderOptions, }: InlineCommentSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
47
51
|
export {};
|
|
@@ -32,6 +32,10 @@ export interface PollListItemProps {
|
|
|
32
32
|
giphyApiKey?: string;
|
|
33
33
|
templateToken?: string;
|
|
34
34
|
templateApiBaseUrl?: string;
|
|
35
|
+
/** Initial percent (1–100) for the poll's upvote slider. Default 100. */
|
|
36
|
+
defaultVotePercent?: number;
|
|
37
|
+
/** Slider precision (0.25 / 0.5 / 1) used by the poll's upvote slider. Default 0.25. */
|
|
38
|
+
voteWeightStep?: number;
|
|
35
39
|
}
|
|
36
40
|
declare const PollListItem: React.FC<PollListItemProps>;
|
|
37
41
|
export default PollListItem;
|
|
@@ -66,6 +66,13 @@ export interface UserDetailProfileProps {
|
|
|
66
66
|
onAddToFavourite?: (username: string) => void | Promise<void>;
|
|
67
67
|
isFavourited?: boolean;
|
|
68
68
|
favouriteCount?: number;
|
|
69
|
+
/** Initial percent (1–100) for every upvote slider on the profile page —
|
|
70
|
+
* post upvotes, comment upvotes, and the upvote-on-publish slider in
|
|
71
|
+
* inline comment composers. Default 100. Typically wired to a user setting. */
|
|
72
|
+
defaultVotePercent?: number;
|
|
73
|
+
/** Slider precision (0.25, 0.5, or 1) for every upvote slider on this page.
|
|
74
|
+
* Default 0.25. */
|
|
75
|
+
voteWeightStep?: number;
|
|
69
76
|
}
|
|
70
77
|
type TabType = "blogs" | "posts" | "snaps" | "polls" | "comments" | "replies" | "activities" | "authorRewards" | "curationRewards" | "followers" | "following" | "wallet" | "votingPower" | "badges" | "witnessVotes" | "growth";
|
|
71
78
|
declare const UserDetailProfile: React.FC<UserDetailProfileProps>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type KitMessageKey } from "./messages";
|
|
3
|
+
export type TranslateHtmlFn = (html: string, target: string) => Promise<string>;
|
|
4
|
+
/** Look up a UI label in the supplied dict, with English fallback. */
|
|
5
|
+
export type KitTFn = (key: KitMessageKey, vars?: Record<string, string | number>) => string;
|
|
6
|
+
export interface HiveLanguageContextValue {
|
|
7
|
+
/**
|
|
8
|
+
* Two-letter language code for translating user-generated content
|
|
9
|
+
* (post bodies, comments, activity bodies). `"en"` is the no-op default —
|
|
10
|
+
* content passes through unchanged.
|
|
11
|
+
*/
|
|
12
|
+
language: string;
|
|
13
|
+
/**
|
|
14
|
+
* Custom translator. Defaults to a free MyMemory-backed implementation
|
|
15
|
+
* that ships with the kit. Override to plug in DeepL, Google Translate,
|
|
16
|
+
* or any other service — receives the rendered HTML and target language,
|
|
17
|
+
* returns translated HTML.
|
|
18
|
+
*/
|
|
19
|
+
translateHtml: TranslateHtmlFn;
|
|
20
|
+
/**
|
|
21
|
+
* UI label translator. Resolves a key against the merged messages dict
|
|
22
|
+
* (consumer overrides → kit built-ins → English source-of-truth).
|
|
23
|
+
*/
|
|
24
|
+
t: KitTFn;
|
|
25
|
+
}
|
|
26
|
+
export interface HiveLanguageProviderProps {
|
|
27
|
+
/** Two-letter language code, e.g. `"en"`, `"es"`. Defaults to `"en"`. */
|
|
28
|
+
language?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Optional override translator for user-generated HTML. If omitted, the
|
|
31
|
+
* kit's default MyMemory-backed implementation is used.
|
|
32
|
+
*/
|
|
33
|
+
translateHtml?: TranslateHtmlFn;
|
|
34
|
+
/**
|
|
35
|
+
* Optional UI label overrides keyed by language code. Merges on top of
|
|
36
|
+
* the kit's built-in `en` + `es` dicts:
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* messages={{
|
|
40
|
+
* es: { "action.follow": "Seguir cuenta" }, // override one label
|
|
41
|
+
* fr: { "action.follow": "Suivre" }, // add a new language
|
|
42
|
+
* }}
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Missing keys for a non-English language fall back to English.
|
|
46
|
+
*/
|
|
47
|
+
messages?: Record<string, Record<string, string>>;
|
|
48
|
+
children: React.ReactNode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Wrap your app once with this provider so every Hive content body
|
|
52
|
+
* rendered by the kit (`<HiveDetailPost>`, comments, snaps, profile feeds,
|
|
53
|
+
* activity bodies) translates to the chosen language.
|
|
54
|
+
*
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <HiveLanguageProvider language={i18n.language}>
|
|
57
|
+
* <App />
|
|
58
|
+
* </HiveLanguageProvider>
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* When `language === "en"` (the default), the provider is a no-op.
|
|
62
|
+
*/
|
|
63
|
+
export declare const HiveLanguageProvider: React.FC<HiveLanguageProviderProps>;
|
|
64
|
+
/** Read the current Hive language + translator + label resolver from context. */
|
|
65
|
+
export declare function useHiveLanguage(): HiveLanguageContextValue;
|
|
66
|
+
/** Convenience hook returning just the UI label resolver. */
|
|
67
|
+
export declare function useKitT(): KitTFn;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { HiveLanguageProvider, useHiveLanguage, useKitT, type HiveLanguageProviderProps, type HiveLanguageContextValue, type TranslateHtmlFn, type KitTFn, } from "./HiveLanguageContext";
|
|
2
|
+
export { useTranslatedHtml } from "./useTranslatedHtml";
|
|
3
|
+
export { useTranslatedText } from "./useTranslatedText";
|
|
4
|
+
export { translateHtml, translateText } from "./translateService";
|
|
5
|
+
export { BUILTIN_MESSAGES, formatMessage, type KitMessageKey, type KitMessages, } from "./messages";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in UI label translations for hive-react-kit components.
|
|
3
|
+
*
|
|
4
|
+
* Keys follow the dotted convention `area.label`. Each language is a
|
|
5
|
+
* flat Record<string, string>. Consumers can extend or override specific
|
|
6
|
+
* keys via the `messages` prop on `<HiveLanguageProvider>`:
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <HiveLanguageProvider
|
|
10
|
+
* language="es"
|
|
11
|
+
* messages={{ es: { "action.follow": "Suivre" } }}
|
|
12
|
+
* />
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Missing keys for a non-English language fall back to the English entry,
|
|
16
|
+
* which is the source of truth for every label.
|
|
17
|
+
*/
|
|
18
|
+
export type KitMessageKey = "tab.blogs" | "tab.posts" | "tab.snaps" | "tab.polls" | "tab.comments" | "tab.replies" | "tab.activities" | "tab.authorRewards" | "tab.curationRewards" | "tab.growth" | "tab.followers" | "tab.following" | "tab.wallet" | "tab.votingPower" | "tab.badges" | "tab.witnessVotes" | "meta.followers" | "meta.following" | "meta.posts" | "action.follow" | "action.unfollow" | "action.ignoreAuthor" | "action.reportUser" | "action.shareProfile" | "action.cancel" | "action.confirmIgnore" | "action.processing" | "modal.ignoreAuthorTitle" | "modal.ignoreAuthorBody" | "empty.noBlogs" | "empty.noPosts" | "empty.noSnaps" | "empty.noPolls" | "empty.noComments" | "empty.noReplies" | "empty.noFollowers" | "empty.notFollowing" | "empty.noBadges" | "empty.noWitnessVotes" | "empty.noPendingAuthor" | "empty.noPendingCuration" | "empty.curationHint" | "empty.votingPowerUnavailable" | "empty.userNotFound" | "status.active" | "status.ended" | "poll.selectAnOption" | "poll.selectUpTo" | "poll.changeYourVote" | "poll.selected" | "poll.submitVote" | "poll.submitVotes" | "poll.changeVote" | "poll.submitting" | "poll.voted" | "poll.voteChangesAllowed" | "poll.voter" | "poll.voters" | "poll.option" | "poll.options" | "poll.endsIn" | "common.translating" | "common.processing" | "common.fullyCharged" | "reward.pendingAuthor" | "reward.pendingCuration" | "reward.posts" | "reward.comments" | "reward.totalHbd" | "reward.totalHp" | "reward.avgEfficiency" | "reward.post" | "reward.comment" | "vp.upvotePower" | "vp.downvotePower" | "vp.resourceCredits";
|
|
19
|
+
export type KitMessages = Partial<Record<KitMessageKey, string>>;
|
|
20
|
+
export declare const BUILTIN_MESSAGES: Record<string, Record<string, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* Format helper — replaces `{key}` placeholders with the corresponding
|
|
23
|
+
* value from `vars`. Missing vars leave the placeholder intact.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatMessage(template: string, vars?: Record<string, string | number>): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MyMemory-backed translation service for translating Hive post / comment
|
|
3
|
+
* bodies (rendered HTML) into the user's selected app language.
|
|
4
|
+
*
|
|
5
|
+
* Free, no API key, soft daily quota. The kit ships this as the default
|
|
6
|
+
* translator — consumers can override by passing their own `translate`
|
|
7
|
+
* function to `<HiveLanguageProvider>` (e.g. DeepL, Google Translate, an
|
|
8
|
+
* authenticated MyMemory account).
|
|
9
|
+
*
|
|
10
|
+
* Heavy caching: in-memory map (session) + localStorage (cross-reload) +
|
|
11
|
+
* in-flight dedup so two views of the same body share one network call.
|
|
12
|
+
*/
|
|
13
|
+
/** Translate a single text string to `target` language. */
|
|
14
|
+
export declare function translateText(text: string, target: string, source?: string): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Translate every visible text node in an HTML string to `target`. Skips
|
|
17
|
+
* text inside `<code>`, `<pre>`, `<script>`, `<style>`, `<noscript>`, and
|
|
18
|
+
* `<iframe>` so embeds and code samples render unchanged.
|
|
19
|
+
*/
|
|
20
|
+
export declare function translateHtml(html: string, target: string): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translate a rendered Hive post / comment body (HTML) into the language
|
|
3
|
+
* supplied by the nearest `<HiveLanguageProvider>`. Returns the original
|
|
4
|
+
* HTML for English (the source language) and synchronously falls back to
|
|
5
|
+
* the original on translation errors so the UI never looks broken.
|
|
6
|
+
*
|
|
7
|
+
* The translation is async — `loading` is true while the API request is
|
|
8
|
+
* in flight on the very first render. Subsequent renders read from cache
|
|
9
|
+
* and resolve instantly.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useTranslatedHtml(html: string): {
|
|
12
|
+
html: string;
|
|
13
|
+
loading: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain-text counterpart to `useTranslatedHtml`. Use for titles, captions,
|
|
3
|
+
* preview snippets, and any other short user-generated string that should
|
|
4
|
+
* follow the language set on `<HiveLanguageProvider>`.
|
|
5
|
+
*
|
|
6
|
+
* Returns the original synchronously while the translation API call is
|
|
7
|
+
* in flight, so titles never flash blank. Falls back to the original on
|
|
8
|
+
* error and bypasses the translator entirely for English.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useTranslatedText(text: string | undefined | null): {
|
|
11
|
+
text: string;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
};
|