@arronqzy/react-view 1.0.5 → 1.0.7

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.
Files changed (36) hide show
  1. package/dist/styles.css +519 -9
  2. package/package.json +12 -4
  3. package/src/core/template.tsx +12 -2
  4. package/src/panel/ReactViewOnlinePreview.tsx +18 -8
  5. package/src/panel/ReactViewPanel.tsx +386 -170
  6. package/src/panel/ai/AssistantChatPanel.tsx +895 -0
  7. package/src/panel/ai/AssistantMarkdown.tsx +256 -0
  8. package/src/panel/ai/applyAssistantAction.ts +652 -0
  9. package/src/panel/ai/revealConfigField.ts +137 -0
  10. package/src/panel/components/ConfigHintIcon.tsx +6 -2
  11. package/src/panel/components/ElementsLayer.tsx +37 -18
  12. package/src/panel/components/MaterialSidebar.tsx +157 -109
  13. package/src/panel/components/MoveableLayer.tsx +7 -6
  14. package/src/panel/components/PanelConfigSidebar.tsx +434 -389
  15. package/src/panel/components/ViewElementScopePanel.tsx +9 -5
  16. package/src/panel/components/WorkspaceConfigSidebar.tsx +5 -2
  17. package/src/panel/components/WorkspaceProjectNav.tsx +25 -14
  18. package/src/panel/components/WorkspaceStageSplit.tsx +3 -1
  19. package/src/panel/components/scope-config/ScopeTemplatePreviewHost.tsx +11 -7
  20. package/src/panel/components/scope-config/ScopeTemplateUsageHint.tsx +6 -18
  21. package/src/panel/components/scope-config/ScopeTemplateWarningsPanel.tsx +5 -2
  22. package/src/panel/components/table/ConditionEditor.tsx +205 -0
  23. package/src/panel/components/table/JsonCodeEditor.tsx +115 -0
  24. package/src/panel/components/table/PanelConfigTableSection.tsx +2192 -0
  25. package/src/panel/components/table/TableNodeContent.tsx +544 -0
  26. package/src/panel/constants/messages.ts +76 -34
  27. package/src/panel/hooks/usePanelElements.ts +64 -52
  28. package/src/panel/hooks/useWorkspaceProjects.ts +11 -8
  29. package/src/panel/types.ts +4 -0
  30. package/src/panel/utils/panelElementDefaults.ts +69 -39
  31. package/src/panel/utils/scope-field-labels.ts +51 -38
  32. package/src/panel/utils/scope-template-preview.ts +10 -6
  33. package/src/panel/utils/scope-template-spread.ts +44 -21
  34. package/src/panel/utils/scope-template-warnings.ts +28 -16
  35. package/src/panel/utils/scope-template.ts +82 -2
  36. package/src/tailwind.css +17 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arronqzy/react-view",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "files": [
5
5
  "src",
6
6
  "dist",
@@ -15,6 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@scena/react-ruler": "^0.19.0",
18
+ "@tanstack/react-virtual": "^3.13.2",
18
19
  "react-infinite-viewer": "^0.28.1",
19
20
  "react-moveable": "^0.56.0",
20
21
  "react-selecto": "^1.26.3",
@@ -25,10 +26,17 @@
25
26
  "infinite-viewer": "^0.29.1",
26
27
  "echarts": "^6.0.0",
27
28
  "uuid": "^13.0.0",
28
- "@arronqzy/ui": "1.0.2",
29
+ "@uiw/react-codemirror": "^4.23.8",
30
+ "@codemirror/lang-json": "^6.0.1",
31
+ "@codemirror/theme-one-dark": "^6.1.2",
32
+ "@codemirror/view": "^6.36.2",
33
+ "@arronqzy/ui": "1.0.3",
29
34
  "@arronqzy/blueprint-dsl": "1.0.3",
30
- "@arronqzy/react-blueprint": "1.0.3",
31
- "@arronqzy/rx-store": "1.0.2"
35
+ "@arronqzy/i18n": "0.1.1",
36
+ "@arronqzy/rx-store": "1.0.2",
37
+ "@arronqzy/webllm-assistant": "0.1.1",
38
+ "@arronqzy/react-blueprint": "1.0.4",
39
+ "@arronqzy/view-table": "0.1.1"
32
40
  },
33
41
  "devDependencies": {
34
42
  "@types/react": "^19.0.1",
@@ -1,6 +1,16 @@
1
- import { JSX, useRef } from "react";
1
+ import { JSX } from "react";
2
2
  import { instructions } from "./instructions";
3
3
 
4
+ function isDevMode(): boolean {
5
+ try {
6
+ return Boolean(
7
+ (import.meta as { env?: { DEV?: boolean } }).env?.DEV
8
+ );
9
+ } catch {
10
+ return false;
11
+ }
12
+ }
13
+
4
14
  /**
5
15
  * 事件需要补齐
6
16
  * @param props
@@ -15,7 +25,7 @@ export const Template = (
15
25
  if (props?.id) {
16
26
  instructions.execute(props.id + "click", { e });
17
27
  } else {
18
- if (import.meta.env.DEV) {
28
+ if (isDevMode()) {
19
29
  console.warn("Template 缺少 id,无法触发事件");
20
30
  }
21
31
  }
@@ -1,4 +1,5 @@
1
1
  import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
2
+ import { useI18n } from "@arronqzy/i18n/react";
2
3
  import {
3
4
  BlueprintGraph,
4
5
  documentToRunnableGraph,
@@ -10,6 +11,7 @@ import {
10
11
  import type { LibraryBlueprintResolver, PageLifecyclePhase } from "@arronqzy/blueprint-dsl";
11
12
  import type { State } from "@arronqzy/rx-store";
12
13
  import { ElementsLayer } from "./components/ElementsLayer";
14
+ import type { TableCellActionHandler } from "./components/table/TableNodeContent";
13
15
  import type { PanelElement } from "./types";
14
16
  import {
15
17
  clearViewElementScopes,
@@ -63,6 +65,8 @@ export function ReactViewOnlinePreview({
63
65
  projectId,
64
66
  previewInstanceId,
65
67
  }: ReactViewOnlinePreviewProps) {
68
+ const { t } = useI18n();
69
+
66
70
  const [loadError, setLoadError] = useState<string | null>(null);
67
71
  const [panelState, setPanelState] = useState<State | null>(null);
68
72
  const [projectRevision, setProjectRevision] = useState(0);
@@ -91,14 +95,14 @@ export function ReactViewOnlinePreview({
91
95
  const loadProject = useCallback(async () => {
92
96
  const record = await loadWorkspaceRecord(projectId);
93
97
  if (!record) {
94
- setLoadError("工作区不存在或已被删除");
98
+ setLoadError(t("panel.messages.workspaceNotFound"));
95
99
  setPanelState(null);
96
100
  return;
97
101
  }
98
102
 
99
103
  const normalized = normalizeImportedPanelState(record.panelState);
100
104
  if (!normalized) {
101
- setLoadError("工作区数据格式无效");
105
+ setLoadError(t("panel.messages.workspaceDataInvalid"));
102
106
  setPanelState(null);
103
107
  return;
104
108
  }
@@ -107,7 +111,7 @@ export function ReactViewOnlinePreview({
107
111
  clearViewElementScopes();
108
112
  setPanelState(normalized);
109
113
  setBlueprintGraph(BlueprintGraph.fromDocument(record.blueprintDocument));
110
- document.title = record.productName.trim() || record.name || "预览";
114
+ document.title = record.productName.trim() || record.name || t("panel.workspace.previewDocTitle");
111
115
  applyTitleIcon(record.titleIconDataUrl);
112
116
  setProjectRevision((v) => v + 1);
113
117
  }, [projectId]);
@@ -228,7 +232,7 @@ export function ReactViewOnlinePreview({
228
232
  const lifecycleReady =
229
233
  !!panelState && layerElements.length > 0 && layoutReady;
230
234
 
231
- useBlueprintPageLifecycle({
235
+ const { triggerBlueprintNode } = useBlueprintPageLifecycle({
232
236
  graph: blueprintGraph,
233
237
  active: true,
234
238
  enabled: lifecycleReady,
@@ -249,7 +253,12 @@ export function ReactViewOnlinePreview({
249
253
 
250
254
  const noopUpdate = useCallback((_id: string, _patch: Partial<PanelElement>) => {}, []);
251
255
  const noopSelect = useCallback((_ids: string[]) => {}, []);
252
-
256
+ const onTableCellAction = useCallback<TableCellActionHandler>(
257
+ (payload) => {
258
+ void triggerBlueprintNode(payload.blueprintNodeId, payload);
259
+ },
260
+ [triggerBlueprintNode]
261
+ );
253
262
  if (loadError) {
254
263
  return (
255
264
  <div className="flex min-h-[100vh] w-full items-center justify-center bg-white px-6 text-center text-sm text-gray-600">
@@ -261,7 +270,7 @@ export function ReactViewOnlinePreview({
261
270
  if (!panelState) {
262
271
  return (
263
272
  <div className="flex min-h-[100vh] w-full items-center justify-center bg-white text-sm text-gray-600">
264
- 加载预览中…
273
+ {t("panel.workspace.previewLoading")}
265
274
  </div>
266
275
  );
267
276
  }
@@ -269,9 +278,9 @@ export function ReactViewOnlinePreview({
269
278
  if (layerElements.length === 0) {
270
279
  return (
271
280
  <div className="flex min-h-[100vh] w-full flex-col items-center justify-center gap-2 bg-white px-6 text-center text-sm text-gray-600">
272
- <div>当前工作区没有可预览的视图节点</div>
281
+ <div>{t("panel.workspace.previewNoNodes")}</div>
273
282
  <div className="text-xs text-gray-400">
274
- 请先在编辑器中点击「同步」或「创建工作区」后再预览
283
+ {t("panel.workspace.previewHint")}
275
284
  </div>
276
285
  </div>
277
286
  );
@@ -309,6 +318,7 @@ export function ReactViewOnlinePreview({
309
318
  layerLocked
310
319
  previewMode
311
320
  previewLayoutKey={layoutRevision}
321
+ onTableCellAction={onTableCellAction}
312
322
  />
313
323
  </div>
314
324
  </div>