@arronqzy/vue-view 0.1.0 → 0.1.2

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 (48) hide show
  1. package/package.json +9 -6
  2. package/src/panel/VueViewOnlinePreview.vue +15 -7
  3. package/src/panel/VueViewPanel.vue +81 -55
  4. package/src/panel/components/ConfigHintIcon.vue +4 -2
  5. package/src/panel/components/ElementsLayer.vue +15 -0
  6. package/src/panel/components/MaterialPreview.vue +19 -1
  7. package/src/panel/components/MaterialSidebar.vue +35 -31
  8. package/src/panel/components/MaterialSidebarTreeNode.vue +27 -26
  9. package/src/panel/components/MoveableLayer.vue +7 -4
  10. package/src/panel/components/PanelConfigSidebar.vue +57 -39
  11. package/src/panel/components/ViewElementScopePanel.vue +6 -4
  12. package/src/panel/components/WorkspaceConfigSidebar.vue +7 -1
  13. package/src/panel/components/WorkspaceProjectNav.vue +23 -16
  14. package/src/panel/components/WorkspaceStageSplit.vue +10 -7
  15. package/src/panel/components/config/ConfigColorField.vue +3 -1
  16. package/src/panel/components/config/PanelConfigAudioSection.vue +44 -43
  17. package/src/panel/components/config/PanelConfigChartSection.vue +79 -76
  18. package/src/panel/components/config/PanelConfigGeometrySection.vue +21 -19
  19. package/src/panel/components/config/PanelConfigGridChildSpan.vue +7 -5
  20. package/src/panel/components/config/PanelConfigGridSection.vue +10 -8
  21. package/src/panel/components/config/PanelConfigImageSection.vue +22 -21
  22. package/src/panel/components/config/PanelConfigMultiSelect.vue +42 -40
  23. package/src/panel/components/config/PanelConfigNodeInfo.vue +19 -16
  24. package/src/panel/components/config/PanelConfigReferenceSection.vue +11 -9
  25. package/src/panel/components/config/PanelConfigStyleSections.vue +27 -26
  26. package/src/panel/components/config/PanelConfigTextSection.vue +20 -17
  27. package/src/panel/components/config/PanelConfigVideoSection.vue +15 -14
  28. package/src/panel/components/config/shared.ts +0 -3
  29. package/src/panel/components/elementsLayerNodes.ts +37 -18
  30. package/src/panel/components/materialSidebarData.ts +73 -54
  31. package/src/panel/components/scope-config/ScopeTemplatePreviewHost.vue +7 -2
  32. package/src/panel/components/scope-config/ScopeTemplatePreviewPanel.vue +6 -3
  33. package/src/panel/components/scope-config/ScopeTemplateUsageHint.vue +7 -16
  34. package/src/panel/components/scope-config/ScopeTemplateWarningsPanel.vue +4 -2
  35. package/src/panel/components/table/ConditionEditor.vue +181 -0
  36. package/src/panel/components/table/JsonCodeEditor.vue +148 -0
  37. package/src/panel/components/table/PanelConfigTableSection.vue +2033 -0
  38. package/src/panel/components/table/TableNodeContent.vue +557 -0
  39. package/src/panel/constants/messages.ts +76 -34
  40. package/src/panel/hooks/usePanelElements.ts +54 -41
  41. package/src/panel/hooks/useWorkspaceProjects.ts +8 -5
  42. package/src/panel/types.ts +4 -0
  43. package/src/panel/utils/panelElementDefaults.ts +73 -39
  44. package/src/panel/utils/scope-field-labels.ts +53 -39
  45. package/src/panel/utils/scope-template-spread.ts +57 -24
  46. package/src/panel/utils/scope-template-warnings.ts +23 -22
  47. package/src/panel/utils/scope-template.ts +80 -0
  48. package/src/tailwind.css +18 -10
@@ -0,0 +1,148 @@
1
+ <script setup lang="ts">
2
+ import { computed, nextTick, ref, watch } from "vue";
3
+ import { useI18n } from "@arronqzy/i18n/vue";
4
+ import { Button } from "ant-design-vue";
5
+
6
+ const props = defineProps<{
7
+ modelValue: string;
8
+ class?: string;
9
+ }>();
10
+
11
+ const emit = defineEmits<{
12
+ "update:modelValue": [value: string];
13
+ }>();
14
+
15
+ const { t } = useI18n();
16
+ const textareaRef = ref<HTMLTextAreaElement | null>(null);
17
+ const preRef = ref<HTMLPreElement | null>(null);
18
+ const gutterRef = ref<HTMLDivElement | null>(null);
19
+
20
+ const lines = computed(() => Math.max(1, (props.modelValue || "").split("\n").length));
21
+ const rootClass = computed(() =>
22
+ ["flex h-full min-h-0 flex-col overflow-hidden", props.class].filter(Boolean).join(" ")
23
+ );
24
+
25
+ function escapeHtml(text: string): string {
26
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
27
+ }
28
+
29
+ function highlightJson(source: string): string {
30
+ const escaped = escapeHtml(source || " ");
31
+ return escaped.replace(
32
+ /("(?:\\.|[^"\\])*")\s*(:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,
33
+ (match, str, colon, boolNull) => {
34
+ if (str != null) {
35
+ if (colon != null) return `<span class="jt-key">${str}</span>${colon}`;
36
+ return `<span class="jt-str">${str}</span>`;
37
+ }
38
+ if (boolNull != null) return `<span class="jt-bool">${boolNull}</span>`;
39
+ return `<span class="jt-num">${match}</span>`;
40
+ }
41
+ );
42
+ }
43
+
44
+ const highlighted = computed(() => highlightJson(props.modelValue));
45
+
46
+ function syncScroll() {
47
+ const ta = textareaRef.value;
48
+ const pre = preRef.value;
49
+ const gutter = gutterRef.value;
50
+ if (!ta) return;
51
+ if (pre) {
52
+ pre.scrollTop = ta.scrollTop;
53
+ pre.scrollLeft = ta.scrollLeft;
54
+ }
55
+ if (gutter) gutter.scrollTop = ta.scrollTop;
56
+ }
57
+
58
+ function onInput(e: Event) {
59
+ emit("update:modelValue", (e.target as HTMLTextAreaElement).value);
60
+ }
61
+
62
+ function onKeydown(e: KeyboardEvent) {
63
+ if (e.key !== "Tab") return;
64
+ e.preventDefault();
65
+ const el = e.target as HTMLTextAreaElement;
66
+ const start = el.selectionStart;
67
+ const end = el.selectionEnd;
68
+ const value = props.modelValue ?? "";
69
+ const next = `${value.slice(0, start)} ${value.slice(end)}`;
70
+ emit("update:modelValue", next);
71
+ void nextTick(() => {
72
+ el.selectionStart = el.selectionEnd = start + 2;
73
+ });
74
+ }
75
+
76
+ function formatJson() {
77
+ const trimmed = (props.modelValue ?? "").trim();
78
+ if (!trimmed) return;
79
+ try {
80
+ emit("update:modelValue", JSON.stringify(JSON.parse(trimmed), null, 2));
81
+ } catch {
82
+ // ignore
83
+ }
84
+ }
85
+
86
+ watch(
87
+ () => props.modelValue,
88
+ () => {
89
+ void nextTick(syncScroll);
90
+ }
91
+ );
92
+ </script>
93
+
94
+ <template>
95
+ <div :class="rootClass">
96
+ <div class="mb-1.5 flex shrink-0 items-center justify-between gap-2">
97
+ <div class="text-[11px] text-gray-500">{{ t("panel.config.tableRowsEditEditorHint") }}</div>
98
+ <Button size="small" @click="formatJson">{{ t("panel.config.tableRowsEditFormat") }}</Button>
99
+ </div>
100
+ <div class="min-h-0 flex-1 overflow-hidden rounded-lg border border-zinc-700/80 bg-[#0f1419] shadow-inner">
101
+ <div class="relative h-full min-h-0">
102
+ <div class="absolute inset-0 flex min-h-0">
103
+ <div
104
+ ref="gutterRef"
105
+ aria-hidden="true"
106
+ class="h-full min-h-0 shrink-0 select-none overflow-hidden border-r border-zinc-800 bg-[#0b1015] px-2 py-3 text-right font-mono text-[12px] leading-5 text-zinc-600"
107
+ style="min-width: 36px"
108
+ >
109
+ <div v-for="n in lines" :key="n">{{ n }}</div>
110
+ </div>
111
+ <div class="relative h-full min-h-0 min-w-0 flex-1 overflow-hidden">
112
+ <pre
113
+ ref="preRef"
114
+ class="pointer-events-none absolute inset-0 m-0 overflow-hidden whitespace-pre p-3 font-mono text-[12.5px] leading-5 text-zinc-200"
115
+ v-html="highlighted + '\n'"
116
+ />
117
+ <textarea
118
+ ref="textareaRef"
119
+ :value="modelValue"
120
+ spellcheck="false"
121
+ class="absolute inset-0 h-full w-full resize-none overflow-auto bg-transparent p-3 font-mono text-[12.5px] leading-5 text-transparent caret-sky-300 outline-none"
122
+ style="-webkit-text-fill-color: transparent"
123
+ :aria-label="t('panel.config.tableRowsEditTitle')"
124
+ @scroll="syncScroll"
125
+ @input="onInput"
126
+ @keydown="onKeydown"
127
+ />
128
+ </div>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </template>
134
+
135
+ <style scoped>
136
+ :deep(.jt-key) {
137
+ color: #7dd3fc;
138
+ }
139
+ :deep(.jt-str) {
140
+ color: #86efac;
141
+ }
142
+ :deep(.jt-num) {
143
+ color: #fcd34d;
144
+ }
145
+ :deep(.jt-bool) {
146
+ color: #f9a8d4;
147
+ }
148
+ </style>