@arronqzy/react-view 1.0.18 → 1.0.19
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arronqzy/react-view",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"dist",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"@arronqzy/ui": "1.0.6",
|
|
34
34
|
"@arronqzy/blueprint-dsl": "1.0.9",
|
|
35
35
|
"@arronqzy/i18n": "0.1.7",
|
|
36
|
-
"@arronqzy/rx-store": "1.0.5",
|
|
37
36
|
"@arronqzy/view-scene3d": "0.1.2",
|
|
37
|
+
"@arronqzy/react-blueprint": "1.0.11",
|
|
38
|
+
"@arronqzy/rx-store": "1.0.5",
|
|
38
39
|
"@arronqzy/view-table": "0.1.5",
|
|
39
|
-
"@arronqzy/webllm-assistant": "0.1.9"
|
|
40
|
-
"@arronqzy/react-blueprint": "1.0.11"
|
|
40
|
+
"@arronqzy/webllm-assistant": "0.1.9"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/react": "^19.0.1",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"eslint": "^8.57.0",
|
|
47
47
|
"typescript": "^5.5.4",
|
|
48
48
|
"@arronqzy/eslint-config": "0.0.0",
|
|
49
|
-
"@arronqzy/
|
|
50
|
-
"@arronqzy/
|
|
49
|
+
"@arronqzy/tailwind": "1.0.2",
|
|
50
|
+
"@arronqzy/typescript-config": "1.0.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { I18nProvider } from "@arronqzy/i18n/react";
|
|
2
|
+
import type { Locale } from "@arronqzy/i18n";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
export type I18nRootProps = {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
locale?: Locale | null;
|
|
8
|
+
onLocaleChange?: (locale: Locale) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Ensures panel / preview subtree always has i18n context (host apps, duplicate package graphs). */
|
|
12
|
+
export function I18nRoot({ children, locale, onLocaleChange }: I18nRootProps) {
|
|
13
|
+
return (
|
|
14
|
+
<I18nProvider locale={locale} onLocaleChange={onLocaleChange}>
|
|
15
|
+
{children}
|
|
16
|
+
</I18nProvider>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { I18nProvider } from "@arronqzy/i18n/react";
|
|
21
|
+
export type { Locale } from "@arronqzy/i18n";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { useI18n } from "@arronqzy/i18n/react";
|
|
3
|
+
import type { Locale } from "@arronqzy/i18n";
|
|
3
4
|
import {
|
|
4
5
|
BlueprintGraph,
|
|
5
6
|
documentToRunnableGraph,
|
|
@@ -41,6 +42,7 @@ import {
|
|
|
41
42
|
import { applyPreviewSceneFill, readOutputScale } from "./utils/outputScale";
|
|
42
43
|
import { capturePreviewSceneElement } from "./library/capture-preview-snapshot";
|
|
43
44
|
import { registerPreviewSnapshotProvider } from "./library/preview-snapshot";
|
|
45
|
+
import { I18nRoot } from "./I18nRoot";
|
|
44
46
|
|
|
45
47
|
const PREVIEW_BOOT_PHASES: PageLifecyclePhase[] = ["mounted"];
|
|
46
48
|
|
|
@@ -50,6 +52,8 @@ export type ReactViewOnlinePreviewProps = {
|
|
|
50
52
|
previewInstanceId?: string;
|
|
51
53
|
/** 直接传入完整工作区数据,用于外部持久化后预览 */
|
|
52
54
|
workspace?: WorkspaceProjectRecord | null;
|
|
55
|
+
locale?: Locale | null;
|
|
56
|
+
onLocaleChange?: (locale: Locale) => void;
|
|
53
57
|
};
|
|
54
58
|
|
|
55
59
|
function applyTitleIcon(titleIconDataUrl?: string) {
|
|
@@ -71,6 +75,18 @@ async function loadWorkspaceRecord(projectId: string): Promise<WorkspaceProjectR
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
export function ReactViewOnlinePreview({
|
|
78
|
+
locale,
|
|
79
|
+
onLocaleChange,
|
|
80
|
+
...rest
|
|
81
|
+
}: ReactViewOnlinePreviewProps) {
|
|
82
|
+
return (
|
|
83
|
+
<I18nRoot locale={locale} onLocaleChange={onLocaleChange}>
|
|
84
|
+
<ReactViewOnlinePreviewInner {...rest} />
|
|
85
|
+
</I18nRoot>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function ReactViewOnlinePreviewInner({
|
|
74
90
|
projectId,
|
|
75
91
|
previewInstanceId,
|
|
76
92
|
workspace = null,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { useI18n } from "@arronqzy/i18n/react";
|
|
3
|
+
import type { Locale } from "@arronqzy/i18n";
|
|
3
4
|
import type { State } from "@arronqzy/rx-store";
|
|
4
5
|
import type { PanelElement } from "./types";
|
|
5
6
|
|
|
@@ -78,6 +79,7 @@ import {
|
|
|
78
79
|
useViewScopeStoreVersion,
|
|
79
80
|
} from "./scope/view-scope-store";
|
|
80
81
|
import { resolvePanelElementScope } from "./utils/scope-template";
|
|
82
|
+
import { I18nRoot } from "./I18nRoot";
|
|
81
83
|
import { getPanelMessages } from "./constants/messages";
|
|
82
84
|
import { PANEL_Z_INDEX } from "./constants/zIndex";
|
|
83
85
|
import { useRafThrottledScroll } from "./hooks/useRafThrottledScroll";
|
|
@@ -362,9 +364,12 @@ export type ReactViewPanelProps = {
|
|
|
362
364
|
className?: string;
|
|
363
365
|
/** 外部传入的完整工作区数据,挂载后自动渲染 */
|
|
364
366
|
initialWorkspace?: WorkspaceProjectRecord | null;
|
|
367
|
+
/** 界面语言;省略时按 localStorage / 浏览器语言解析 */
|
|
368
|
+
locale?: Locale | null;
|
|
369
|
+
onLocaleChange?: (locale: Locale) => void;
|
|
365
370
|
};
|
|
366
371
|
|
|
367
|
-
|
|
372
|
+
function ReactViewPanelInner({
|
|
368
373
|
initialZoom = 1,
|
|
369
374
|
className,
|
|
370
375
|
initialWorkspace = null,
|
|
@@ -3578,3 +3583,15 @@ export function ReactViewPanel({
|
|
|
3578
3583
|
</div>
|
|
3579
3584
|
);
|
|
3580
3585
|
}
|
|
3586
|
+
|
|
3587
|
+
export function ReactViewPanel({
|
|
3588
|
+
locale,
|
|
3589
|
+
onLocaleChange,
|
|
3590
|
+
...rest
|
|
3591
|
+
}: ReactViewPanelProps) {
|
|
3592
|
+
return (
|
|
3593
|
+
<I18nRoot locale={locale} onLocaleChange={onLocaleChange}>
|
|
3594
|
+
<ReactViewPanelInner {...rest} />
|
|
3595
|
+
</I18nRoot>
|
|
3596
|
+
);
|
|
3597
|
+
}
|