@svp-chain-sdk/ui 0.1.6 → 0.1.10
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 +14 -8
- package/dist/components/feedback-widget/feedback-widget.d.ts +4 -1
- package/dist/components/notice-marquee/notice-marquee.d.ts +5 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +592 -483
- package/dist/lib/locale.d.ts +4 -0
- package/dist/styles.css +82 -3
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -183,32 +183,34 @@ const config = createSvpWalletConfig({
|
|
|
183
183
|
|
|
184
184
|
### FeedbackWidget
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
页面右侧垂直居中的悬浮入口。点击后在按钮左侧打开说明 Popover,再前往 Google Form。按钮、标题、说明和操作文案支持 `en`、`ja`、`ko`、`zh-CN`、`zh-TW`,可由外部 `locale` 即时切换;未传时读取浏览器语言,未知语言回退到 `en`。
|
|
187
187
|
|
|
188
188
|
```tsx
|
|
189
|
-
<FeedbackWidget />
|
|
190
|
-
<FeedbackWidget className="my-feedback" />
|
|
189
|
+
<FeedbackWidget locale="zh-CN" />
|
|
190
|
+
<FeedbackWidget locale={currentLocale} className="my-feedback" />
|
|
191
191
|
```
|
|
192
192
|
|
|
193
193
|
#### FeedbackWidgetProps
|
|
194
194
|
|
|
195
195
|
| 参数 | 类型 | 默认值 | 说明 |
|
|
196
196
|
| --- | --- | --- | --- |
|
|
197
|
+
| `locale` | `Locale` | 浏览器语言,未知时 `en` | 外部语言选择:`en`、`ja`、`ko`、`zh-CN`、`zh-TW` |
|
|
197
198
|
| `className` | `string` | 无 | 附加 class |
|
|
198
199
|
|
|
199
200
|
内置地址:`https://forms.gle/6semmo55DSLtcbnw7`。链接使用 `target="_blank"` 和 `rel="noopener noreferrer"`。
|
|
200
201
|
|
|
201
202
|
### NoticeMarquee
|
|
202
203
|
|
|
203
|
-
顶部居中的高层级通知浮层,默认距顶部 `100px`。默认读取 SDK 内置 IPFS JSON
|
|
204
|
+
顶部居中的高层级通知浮层,默认距顶部 `100px`。默认读取 SDK 内置 IPFS JSON,支持 `en`、`ja`、`ko`、`zh-CN`、`zh-TW`,可由外部 `locale` 即时切换;未传时读取浏览器语言,未知语言回退到 `en`。组件每 5 分钟静默刷新,并仅依据服务端 `endtime`(Unix epoch 毫秒)决定通知是否有效。
|
|
204
205
|
|
|
205
206
|
- **已知晓**:记录当前完整公告快照,本轮公告不再显示;远程公告内容发生变化后会再次显示。
|
|
206
207
|
- **关闭**:只关闭当前页面实例,不写入 localStorage;刷新页面后仍会再次显示。
|
|
207
208
|
|
|
208
209
|
```tsx
|
|
209
|
-
<NoticeMarquee />
|
|
210
|
+
<NoticeMarquee locale="zh-CN" />
|
|
210
211
|
|
|
211
212
|
<NoticeMarquee
|
|
213
|
+
locale={currentLocale}
|
|
212
214
|
url="https://example.com/notice.json"
|
|
213
215
|
storageKey="my-app:notice"
|
|
214
216
|
refreshIntervalMs={5 * 60 * 1000}
|
|
@@ -223,17 +225,21 @@ const config = createSvpWalletConfig({
|
|
|
223
225
|
```json
|
|
224
226
|
{
|
|
225
227
|
"en": "English notice",
|
|
226
|
-
"
|
|
227
|
-
"
|
|
228
|
+
"ja": "日本語のお知らせ",
|
|
229
|
+
"ko": "한국어 알림",
|
|
230
|
+
"zh-CN": "简体中文通知",
|
|
231
|
+
"zh-TW": "繁體中文通知",
|
|
232
|
+
"endtime": "1789646400000"
|
|
228
233
|
}
|
|
229
234
|
```
|
|
230
235
|
|
|
231
|
-
|
|
236
|
+
组件读取与 `locale` 同名的字段;该字段为空或缺失时回退到 `en`,`en` 也不可用时不显示。为兼容当前已发布的公告,`zh-CN` 与 `zh-TW` 在对应字段缺失时会先尝试旧的 `zh` 字段。`endtime` 必须是未来的 Unix epoch 毫秒,可使用数字或十进制字符串;缺失、非法或已过期时不显示。页面保持打开期间到达 `endtime` 会自动隐藏,过期判断不使用 localStorage 中的时间。内容按纯文本渲染。localStorage 仅在用户点击“已知晓”时保存包含 `endtime` 的完整公告快照,切换语言只替换当前译文,不会把同一公告误判为新公告。
|
|
232
237
|
|
|
233
238
|
#### NoticeMarqueeProps
|
|
234
239
|
|
|
235
240
|
| 参数 | 类型 | 默认值 | 说明 |
|
|
236
241
|
| --- | --- | --- | --- |
|
|
242
|
+
| `locale` | `Locale` | 浏览器语言,未知时 `en` | 外部语言选择:`en`、`ja`、`ko`、`zh-CN`、`zh-TW` |
|
|
237
243
|
| `url` | `string` | `DEFAULT_NOTICE_URL` | 远程 JSON 地址,需要允许 CORS |
|
|
238
244
|
| `storageKey` | `string` | `DEFAULT_NOTICE_STORAGE_KEY` | localStorage key |
|
|
239
245
|
| `refreshIntervalMs` | `number` | `DEFAULT_NOTICE_REFRESH_INTERVAL_MS` | 静默刷新间隔;小于等于 0 时关闭轮询 |
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type Locale } from '../../lib/locale';
|
|
1
3
|
export interface FeedbackWidgetProps {
|
|
4
|
+
locale?: Locale;
|
|
2
5
|
className?: string;
|
|
3
6
|
}
|
|
4
|
-
export declare function FeedbackWidget({ className }?: FeedbackWidgetProps):
|
|
7
|
+
export declare function FeedbackWidget({ locale, className }?: FeedbackWidgetProps): React.JSX.Element;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
import { type Locale } from '../../lib/locale';
|
|
3
|
+
export declare const DEFAULT_NOTICE_URL = "https://apricot-delicate-cat-926.mypinata.cloud/ipfs/bafkreifbmbatyxthnx4k5uukq2tuirp6gwadiaicjb5zcmt4gbvmw5z624";
|
|
3
4
|
export declare const DEFAULT_NOTICE_STORAGE_KEY = "@svp-chain-sdk/ui:notice-marquee";
|
|
4
5
|
export declare const DEFAULT_NOTICE_REFRESH_INTERVAL_MS: number;
|
|
5
6
|
export type NoticeMarqueeProps = {
|
|
7
|
+
/** External locale override. Defaults to the browser language, then English. */
|
|
8
|
+
locale?: Locale;
|
|
6
9
|
/** Optional override for the SDK default multilingual JSON URL. */
|
|
7
10
|
url?: string;
|
|
8
11
|
/** Optional override for the localStorage key used to remember acknowledged content. */
|
|
@@ -13,8 +16,4 @@ export type NoticeMarqueeProps = {
|
|
|
13
16
|
closeLabel?: string;
|
|
14
17
|
className?: string;
|
|
15
18
|
};
|
|
16
|
-
|
|
17
|
-
* Fixed remote notice. Acknowledging persists the current payload; closing only
|
|
18
|
-
* dismisses it for the current mounted page, so a browser refresh shows it again.
|
|
19
|
-
*/
|
|
20
|
-
export declare function NoticeMarquee({ url, storageKey, refreshIntervalMs, acknowledgeLabel, closeLabel, className, }?: NoticeMarqueeProps): React.JSX.Element | null;
|
|
19
|
+
export declare function NoticeMarquee({ locale, url, storageKey, refreshIntervalMs, acknowledgeLabel, closeLabel, className, }?: NoticeMarqueeProps): React.JSX.Element | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { Button, buttonVariants, DEFAULT_NOTICE_REFRESH_INTERVAL_MS, DEFAULT_NOTICE_STORAGE_KEY, DEFAULT_NOTICE_URL, FeedbackWidget, NoticeMarquee, } from './components';
|
|
2
2
|
export type { ButtonProps, FeedbackWidgetProps, NoticeMarqueeProps, } from './components';
|
|
3
|
+
export { SUPPORTED_LOCALES, resolveLocale } from './lib/locale';
|
|
4
|
+
export type { Locale } from './lib/locale';
|
|
3
5
|
export { cn } from './lib/utils';
|
|
4
6
|
export { ConnectWalletButton, createSvpWalletConfig, resolveSvpProvider, resolveSvpProviderForConnection, SVP_WALLET_DOWNLOAD_URL, svpTestnet, svpWallet, SvpWalletProvider, walletDefaults, walletTheme, } from './wallet';
|
|
5
7
|
export type { ConnectWalletButtonProps, ConnectWalletLabels, CreateSvpWalletConfigOptions, SvpWalletProviderProps, SvpWalletDefaults, } from './wallet';
|