@airalogy/aimd-recorder 1.14.1

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 (178) hide show
  1. package/README.md +240 -0
  2. package/README.zh-CN.md +224 -0
  3. package/dist/AimdCodeField-DC3DPvgc.js +172 -0
  4. package/dist/AimdDnaSequenceField-__jdnFS9.js +59466 -0
  5. package/dist/AimdEditor.vue_vue_type_style_index_0_lang-Bq79rKNw.js +28370 -0
  6. package/dist/AimdMarkdownField-98ImHGbc.js +66 -0
  7. package/dist/AimdMarkdownNoteField-CuUJZkgT.js +185 -0
  8. package/dist/_.contribution-IP0cDNhs.js +38 -0
  9. package/dist/_commonjsHelpers-CZXJ37nu.js +40 -0
  10. package/dist/abap-Bs8kvjsq.js +1398 -0
  11. package/dist/aimd-recorder.css +1 -0
  12. package/dist/apex-Dspwrl5m.js +326 -0
  13. package/dist/assets/css.worker-Dmf38jDD.js +79 -0
  14. package/dist/assets/editor.worker-CpuX8TSY.js +12 -0
  15. package/dist/assets/html.worker-DotaEs7v.js +456 -0
  16. package/dist/assets/json.worker-B4VHhH6h.js +44 -0
  17. package/dist/assets/ts.worker-sl17zBDo.js +51316 -0
  18. package/dist/azcli-k1BiOau1.js +68 -0
  19. package/dist/bat-BIP72KWc.js +100 -0
  20. package/dist/bicep-VhQeYhS3.js +102 -0
  21. package/dist/cameligo-DnuAXtHg.js +174 -0
  22. package/dist/clojure-BAuDPsal.js +761 -0
  23. package/dist/coffee-BV06qSnj.js +232 -0
  24. package/dist/components.js +3595 -0
  25. package/dist/composables.js +72 -0
  26. package/dist/cpp-Cz8Jeyrf.js +389 -0
  27. package/dist/csharp-F6hhlXFb.js +326 -0
  28. package/dist/csp-KzlEHCyI.js +53 -0
  29. package/dist/css-e4FKntZ3.js +187 -0
  30. package/dist/cssMode-uz9U6SUU.js +1571 -0
  31. package/dist/cypher-CpvDGKRr.js +263 -0
  32. package/dist/dart-DdHeFWR0.js +281 -0
  33. package/dist/dockerfile-aoNXDcio.js +130 -0
  34. package/dist/ecl-C4Q0DYuA.js +456 -0
  35. package/dist/editor.api-CgD9w0gG.js +77091 -0
  36. package/dist/editor.main-Du02abDl.js +33783 -0
  37. package/dist/elixir-C9X42b0T.js +569 -0
  38. package/dist/flow9-Bff42pfB.js +142 -0
  39. package/dist/freemarker2-DFLX4iQ-.js +989 -0
  40. package/dist/fsharp-C6vPAsHG.js +217 -0
  41. package/dist/go-DEr8zx9f.js +218 -0
  42. package/dist/graphql-BiNBBRFh.js +151 -0
  43. package/dist/handlebars-aiZbIuWY.js +419 -0
  44. package/dist/hcl-2T9lKuFg.js +183 -0
  45. package/dist/html-phzTMObN.js +308 -0
  46. package/dist/htmlMode-BF7wMi3N.js +1581 -0
  47. package/dist/index.js +89 -0
  48. package/dist/ini-CZGtssYM.js +71 -0
  49. package/dist/ini.contribution-DyWtiacL.js +8 -0
  50. package/dist/java-B260NeH3.js +232 -0
  51. package/dist/javascript-BKKOItMi.js +70 -0
  52. package/dist/jsonMode-CDYK4B5l.js +1996 -0
  53. package/dist/julia-kuNLM9c5.js +511 -0
  54. package/dist/kotlin-Bz6kAefA.js +253 -0
  55. package/dist/less-AZUtS89I.js +162 -0
  56. package/dist/lexon-BcmgnyRb.js +157 -0
  57. package/dist/liquid-B2eRz5SA.js +240 -0
  58. package/dist/lua-Dz1RbATg.js +162 -0
  59. package/dist/m3-CIMooLFn.js +210 -0
  60. package/dist/markdown-C1BsCK9P.js +229 -0
  61. package/dist/markdown.contribution-DYYk6zUU.js +7 -0
  62. package/dist/mdx-BfV1HDRG.js +165 -0
  63. package/dist/mips-BovsnfLQ.js +198 -0
  64. package/dist/monaco.contribution-C-bQhUTI.js +114 -0
  65. package/dist/monaco.contribution-CCVvl3Jx.js +72 -0
  66. package/dist/monaco.contribution-Col-f0XR.js +164 -0
  67. package/dist/monaco.contribution-b5xkgQ-s.js +112 -0
  68. package/dist/msdax-CiRB2ZB-.js +375 -0
  69. package/dist/mysql-BwdpPE19.js +878 -0
  70. package/dist/objective-c-D4nfHfso.js +183 -0
  71. package/dist/pascal--j5-PYtz.js +251 -0
  72. package/dist/pascaligo-C7TcJxNL.js +164 -0
  73. package/dist/perl-BzEWqUb5.js +626 -0
  74. package/dist/pgsql-B_KZ0mGX.js +851 -0
  75. package/dist/php-A19QHzQV.js +500 -0
  76. package/dist/pla-COeKY1hA.js +137 -0
  77. package/dist/postiats-BfMp7zJL.js +907 -0
  78. package/dist/powerquery-B0TS_5Gb.js +890 -0
  79. package/dist/powershell-5jSbKdYB.js +239 -0
  80. package/dist/protobuf-YgnOutn3.js +420 -0
  81. package/dist/pug-DLej6kn5.js +402 -0
  82. package/dist/python-CQrZx9mR.js +301 -0
  83. package/dist/python.contribution-CcKs2Ktm.js +8 -0
  84. package/dist/qsharp-AhjqtSHB.js +301 -0
  85. package/dist/r-D-F4P80w.js +243 -0
  86. package/dist/razor-DWmpHMcx.js +550 -0
  87. package/dist/redis-hwwIlMnV.js +302 -0
  88. package/dist/redshift-Bcm_kjEG.js +809 -0
  89. package/dist/restructuredtext-CrdzfPP-.js +174 -0
  90. package/dist/ruby-QC2UNm1s.js +511 -0
  91. package/dist/rust-5aqiQ3L5.js +343 -0
  92. package/dist/sb-B1g1ZfLJ.js +115 -0
  93. package/dist/scala-C2U4R5Gb.js +370 -0
  94. package/dist/scheme-DeFRbslr.js +108 -0
  95. package/dist/scss-RSTCiCmI.js +262 -0
  96. package/dist/shell-BpF-iNu8.js +221 -0
  97. package/dist/shell.contribution-B80NZ3iO.js +7 -0
  98. package/dist/solidity-C00r2mbQ.js +1367 -0
  99. package/dist/sophia-DVW5ZKDB.js +199 -0
  100. package/dist/sparql-B0nmpxeX.js +201 -0
  101. package/dist/sql-CJwKPERn.js +853 -0
  102. package/dist/sql.contribution-DQy36aE5.js +7 -0
  103. package/dist/st-DPlKG5DT.js +416 -0
  104. package/dist/swift-YZBAbVHV.js +309 -0
  105. package/dist/systemverilog-CDQSaH63.js +576 -0
  106. package/dist/tcl-Dlu8sp6Q.js +232 -0
  107. package/dist/tsMode-Bh-v12OL.js +887 -0
  108. package/dist/twig-C5TO7-kw.js +392 -0
  109. package/dist/typescript-c7y6IZVP.js +343 -0
  110. package/dist/typespec-BsmjDEu7.js +117 -0
  111. package/dist/useFieldRendering-BIqeE3qo.js +6083 -0
  112. package/dist/vb-ChHvIDrk.js +372 -0
  113. package/dist/wgsl-XEp1ju8c.js +439 -0
  114. package/dist/xml-MAEprTnF.js +95 -0
  115. package/dist/xml.contribution-XMOaon8i.js +27 -0
  116. package/dist/yaml-C1p8rXG7.js +206 -0
  117. package/dist/yaml.contribution-DRRVhJmJ.js +8 -0
  118. package/package.json +88 -0
  119. package/src/__tests__/client-assigner.test.ts +341 -0
  120. package/src/__tests__/code-types.test.ts +30 -0
  121. package/src/__tests__/markdown-field.test.ts +34 -0
  122. package/src/__tests__/markdown-note-field.test.ts +135 -0
  123. package/src/__tests__/quiz-recorder.test.ts +195 -0
  124. package/src/__tests__/recorder-editor-content-sync.test.ts +172 -0
  125. package/src/__tests__/recorder-editor.test.ts +143 -0
  126. package/src/__tests__/recorder-render.test.ts +57 -0
  127. package/src/__tests__/recorder-wysiwyg-field-host.test.ts +33 -0
  128. package/src/__tests__/step-field.test.ts +270 -0
  129. package/src/__tests__/type-plugins.test.ts +59 -0
  130. package/src/__tests__/var-field-render.test.ts +26 -0
  131. package/src/client-assigner.ts +269 -0
  132. package/src/code-types.ts +94 -0
  133. package/src/components/AimdCodeField.vue +228 -0
  134. package/src/components/AimdDnaSequenceField.vue +983 -0
  135. package/src/components/AimdMarkdownField.vue +168 -0
  136. package/src/components/AimdMarkdownNoteField.vue +457 -0
  137. package/src/components/AimdQuizRecorder.vue +792 -0
  138. package/src/components/AimdRecorder.vue +1959 -0
  139. package/src/components/AimdRecorderEditor.vue +2281 -0
  140. package/src/components/AimdRecorderWysiwygFieldHost.vue +93 -0
  141. package/src/components/AimdRecorderWysiwygSurface.vue +487 -0
  142. package/src/components/AimdSeqVizViewer.vue +122 -0
  143. package/src/components/AimdStepCheckField.vue +453 -0
  144. package/src/components/AimdVarField.vue +213 -0
  145. package/src/components/AimdVarTableField.vue +516 -0
  146. package/src/components/DnaAnnotationEditor.vue +477 -0
  147. package/src/components/DnaSequenceEditor.vue +44 -0
  148. package/src/components/DnaSequenceToolbar.vue +98 -0
  149. package/src/components/DnaSequenceViewer.vue +162 -0
  150. package/src/components/index.ts +21 -0
  151. package/src/components/recorderMilkdownPlugin.ts +632 -0
  152. package/src/composables/__tests__/useDnaSequence.test.ts +467 -0
  153. package/src/composables/__tests__/useFieldAdapters.test.ts +115 -0
  154. package/src/composables/__tests__/useFocusManagement.test.ts +66 -0
  155. package/src/composables/__tests__/useRecordState.test.ts +586 -0
  156. package/src/composables/__tests__/useStepTimers.test.ts +64 -0
  157. package/src/composables/__tests__/useVarHelpers.test.ts +424 -0
  158. package/src/composables/__tests__/workbenchFieldEditing.test.ts +97 -0
  159. package/src/composables/index.ts +94 -0
  160. package/src/composables/useClientAssignerRunner.ts +74 -0
  161. package/src/composables/useDnaSequence.ts +400 -0
  162. package/src/composables/useDnaSequenceField.ts +316 -0
  163. package/src/composables/useFieldAdapters.ts +61 -0
  164. package/src/composables/useFieldRendering.ts +269 -0
  165. package/src/composables/useFocusManagement.ts +144 -0
  166. package/src/composables/useRecordState.ts +429 -0
  167. package/src/composables/useStepTimers.ts +243 -0
  168. package/src/composables/useVarHelpers.ts +545 -0
  169. package/src/composables/useVarTableDragDrop.ts +236 -0
  170. package/src/composables/workbenchFieldEditing.ts +705 -0
  171. package/src/css.d.ts +9 -0
  172. package/src/index.ts +65 -0
  173. package/src/locales.ts +559 -0
  174. package/src/monaco-code.ts +75 -0
  175. package/src/styles/aimd.css +994 -0
  176. package/src/type-plugins.ts +132 -0
  177. package/src/type-utils.ts +3 -0
  178. package/src/types.ts +191 -0
@@ -0,0 +1,453 @@
1
+ <script lang="ts">
2
+ import { computed, defineAsyncComponent, defineComponent, h, onBeforeUnmount, ref, watch, type PropType, type VNodeChild } from "vue"
3
+ import type { AimdStepNode, AimdCheckNode, AimdStepTimerMode } from "@airalogy/aimd-core/types"
4
+ import type { AimdRecorderMessages } from "../locales"
5
+ import { getAimdRecorderScopeLabel } from "../locales"
6
+ import type { AimdCheckRecordItem, AimdStepDetailDisplay, AimdStepRecordItem } from "../types"
7
+ import {
8
+ formatStepDuration,
9
+ getStepElapsedMs,
10
+ getStepRemainingMs,
11
+ hasRecordedStepDuration,
12
+ isStepTimerWarning,
13
+ isStepTimerRunning,
14
+ resolveStepTimerMode,
15
+ } from "../composables/useStepTimers"
16
+
17
+ const AimdMarkdownNoteField = defineAsyncComponent(() => import("./AimdMarkdownNoteField.vue"))
18
+
19
+ export const AimdStepField = defineComponent({
20
+ name: "AimdStepField",
21
+ props: {
22
+ node: { type: Object as PropType<AimdStepNode>, required: true },
23
+ state: { type: Object as PropType<AimdStepRecordItem>, required: true },
24
+ bodyNodes: { type: Array as PropType<VNodeChild[]>, default: () => [] },
25
+ disabled: { type: Boolean, default: false },
26
+ extraClasses: { type: Array as PropType<string[]>, default: () => [] },
27
+ detailDisplay: { type: String as PropType<AimdStepDetailDisplay>, default: "auto" },
28
+ locale: { type: String, required: true },
29
+ messages: { type: Object as PropType<AimdRecorderMessages>, required: true },
30
+ },
31
+ emits: ["check-change", "annotation-change", "timer-start", "timer-pause", "timer-reset", "blur"],
32
+ setup(props, { emit }) {
33
+ const nowMs = ref(Date.now())
34
+ const rootEl = ref<HTMLElement | null>(null)
35
+ const annotationExpanded = ref(false)
36
+ const timerExpanded = ref(false)
37
+ let liveTimer: ReturnType<typeof setInterval> | null = null
38
+ let focusOutCheckTimer: ReturnType<typeof setTimeout> | null = null
39
+
40
+ function syncLiveTimer() {
41
+ if (liveTimer) {
42
+ clearInterval(liveTimer)
43
+ liveTimer = null
44
+ }
45
+
46
+ if (!isStepTimerRunning(props.state)) {
47
+ return
48
+ }
49
+
50
+ liveTimer = setInterval(() => {
51
+ nowMs.value = Date.now()
52
+ }, 1000)
53
+ }
54
+
55
+ watch(() => props.state.timer_started_at_ms, () => {
56
+ nowMs.value = Date.now()
57
+ syncLiveTimer()
58
+ }, { immediate: true })
59
+
60
+ onBeforeUnmount(() => {
61
+ if (liveTimer) {
62
+ clearInterval(liveTimer)
63
+ }
64
+ if (focusOutCheckTimer) {
65
+ clearTimeout(focusOutCheckTimer)
66
+ }
67
+ })
68
+
69
+ const alwaysShowDetails = computed(() => props.detailDisplay === "always")
70
+ const actualElapsedMs = computed(() => getStepElapsedMs(props.state, nowMs.value))
71
+ const actualDurationLabel = computed(() => formatStepDuration(actualElapsedMs.value, props.locale))
72
+ const estimatedDurationLabel = computed(() => (
73
+ typeof props.node.estimated_duration_ms === "number"
74
+ ? formatStepDuration(props.node.estimated_duration_ms, props.locale)
75
+ : ""
76
+ ))
77
+ const timerMode = computed<AimdStepTimerMode>(() => resolveStepTimerMode(props.node))
78
+ const timerRunning = computed(() => isStepTimerRunning(props.state))
79
+ const hasRecordedDuration = computed(() => hasRecordedStepDuration(props.state))
80
+ const hasAnnotation = computed(() => Boolean(props.state.annotation?.trim()))
81
+ const remainingMs = computed(() => getStepRemainingMs(props.state, props.node.estimated_duration_ms, nowMs.value))
82
+ const countdownEnabled = computed(() => timerMode.value === "countdown" || timerMode.value === "both")
83
+ const showElapsedDetail = computed(() => timerMode.value === "elapsed" || timerMode.value === "both")
84
+ const countdownWarning = computed(() => (
85
+ (timerRunning.value || hasRecordedDuration.value)
86
+ && isStepTimerWarning(remainingMs.value, props.node.estimated_duration_ms)
87
+ ))
88
+ const countdownOvertime = computed(() => typeof remainingMs.value === "number" && remainingMs.value < 0)
89
+ const countdownLabel = computed(() => {
90
+ if (remainingMs.value == null) {
91
+ return ""
92
+ }
93
+
94
+ if (countdownOvertime.value) {
95
+ return props.messages.step.overtimeBadge(formatStepDuration(Math.abs(remainingMs.value), props.locale))
96
+ }
97
+
98
+ return props.messages.step.remainingBadge(formatStepDuration(Math.max(0, remainingMs.value), props.locale))
99
+ })
100
+ const countdownTitle = computed(() => {
101
+ if (remainingMs.value == null) {
102
+ return ""
103
+ }
104
+
105
+ if (countdownOvertime.value) {
106
+ return props.messages.step.overtimeDuration(formatStepDuration(Math.abs(remainingMs.value), props.locale))
107
+ }
108
+
109
+ return props.messages.step.remainingDuration(formatStepDuration(Math.max(0, remainingMs.value), props.locale))
110
+ })
111
+ const autoShowTimerDetails = computed(() => countdownEnabled.value)
112
+ const showAnnotationEditor = computed(() => (
113
+ alwaysShowDetails.value
114
+ || hasAnnotation.value
115
+ || annotationExpanded.value
116
+ ))
117
+ const showTimerDetails = computed(() => (
118
+ alwaysShowDetails.value
119
+ || autoShowTimerDetails.value
120
+ || timerRunning.value
121
+ || hasRecordedDuration.value
122
+ || timerExpanded.value
123
+ ))
124
+ const showTimerSummary = computed(() => !showTimerDetails.value && (timerRunning.value || hasRecordedDuration.value))
125
+ const showDetailRow = computed(() => showAnnotationEditor.value || showTimerDetails.value)
126
+
127
+ function clearPendingFocusOutCheck() {
128
+ if (focusOutCheckTimer) {
129
+ clearTimeout(focusOutCheckTimer)
130
+ focusOutCheckTimer = null
131
+ }
132
+ }
133
+
134
+ function collapseTransientDetails() {
135
+ if (!hasAnnotation.value) {
136
+ annotationExpanded.value = false
137
+ }
138
+ if (!autoShowTimerDetails.value && !timerRunning.value && !hasRecordedDuration.value) {
139
+ timerExpanded.value = false
140
+ }
141
+ }
142
+
143
+ function handleFocusIn() {
144
+ clearPendingFocusOutCheck()
145
+ }
146
+
147
+ function handleFocusOut(event: FocusEvent) {
148
+ const nextTarget = event.relatedTarget
149
+ if (nextTarget instanceof Node && rootEl.value?.contains(nextTarget)) {
150
+ return
151
+ }
152
+
153
+ clearPendingFocusOutCheck()
154
+ focusOutCheckTimer = setTimeout(() => {
155
+ focusOutCheckTimer = null
156
+ const activeElement = typeof document !== "undefined" ? document.activeElement : null
157
+ if (activeElement instanceof Node && rootEl.value?.contains(activeElement)) {
158
+ return
159
+ }
160
+
161
+ collapseTransientDetails()
162
+ }, 0)
163
+ }
164
+
165
+ function openAnnotationDetail() {
166
+ annotationExpanded.value = true
167
+ }
168
+
169
+ function openTimerDetail() {
170
+ timerExpanded.value = true
171
+ emit("timer-start", { id: props.node.id })
172
+ }
173
+
174
+ function preventToggleFocus(event: MouseEvent) {
175
+ event.preventDefault()
176
+ }
177
+
178
+ return () => {
179
+ const node = props.node
180
+ const id = node.id
181
+ const state = props.state
182
+ const stepNumber = node.step || "?"
183
+ const hasCheck = Boolean(node.check)
184
+ const disabled = props.disabled
185
+ const extraClasses = props.extraClasses
186
+ const canResetTimer = hasRecordedDuration.value || timerRunning.value
187
+ const startButtonLabel = timerRunning.value
188
+ ? props.messages.step.pauseTimer
189
+ : (hasRecordedDuration.value ? props.messages.step.resumeTimer : props.messages.step.startTimer)
190
+ const detailChildren = []
191
+ const headerMetaChildren = []
192
+ const headerActionChildren = []
193
+
194
+ if (showTimerDetails.value) {
195
+ const timerDetailChildren = []
196
+
197
+ if (countdownEnabled.value && countdownLabel.value) {
198
+ timerDetailChildren.push(
199
+ h("span", {
200
+ class: [
201
+ "aimd-step-timer__hero",
202
+ countdownOvertime.value
203
+ ? "aimd-step-timer__hero--overtime"
204
+ : countdownWarning.value
205
+ ? "aimd-step-timer__hero--warning"
206
+ : "aimd-step-timer__hero--countdown",
207
+ ],
208
+ title: countdownTitle.value,
209
+ }, countdownLabel.value),
210
+ )
211
+ }
212
+
213
+ if (showElapsedDetail.value) {
214
+ timerDetailChildren.push(
215
+ h("span", {
216
+ class: [
217
+ "aimd-step-timer__pill",
218
+ "aimd-step-timer__pill--actual",
219
+ timerRunning.value ? "aimd-step-timer__pill--running" : "",
220
+ ],
221
+ title: props.messages.step.recordedDuration(actualDurationLabel.value),
222
+ }, props.messages.step.recordedBadge(actualDurationLabel.value)),
223
+ )
224
+ }
225
+
226
+ detailChildren.push(
227
+ h("span", {
228
+ class: "aimd-step-field__detail aimd-step-field__detail--timer",
229
+ }, [
230
+ ...timerDetailChildren,
231
+ !disabled
232
+ ? h("span", { class: "aimd-step-timer__controls" }, [
233
+ h("button", {
234
+ type: "button",
235
+ class: "aimd-step-timer__btn",
236
+ onClick: () => emit(timerRunning.value ? "timer-pause" : "timer-start", { id }),
237
+ }, startButtonLabel),
238
+ h("button", {
239
+ type: "button",
240
+ class: "aimd-step-timer__btn aimd-step-timer__btn--ghost",
241
+ disabled: !canResetTimer,
242
+ onClick: () => emit("timer-reset", { id }),
243
+ }, props.messages.step.resetTimer),
244
+ ])
245
+ : null,
246
+ ]),
247
+ )
248
+ }
249
+
250
+ if (showAnnotationEditor.value) {
251
+ detailChildren.push(
252
+ h("span", {
253
+ class: "aimd-step-field__detail aimd-step-field__detail--annotation",
254
+ }, [
255
+ h(AimdMarkdownNoteField, {
256
+ class: "aimd-step-field__annotation-editor",
257
+ disabled,
258
+ locale: props.locale,
259
+ minHeight: 220,
260
+ modelValue: state.annotation || "",
261
+ "onUpdate:modelValue": (value: string) => {
262
+ emit("annotation-change", {
263
+ id,
264
+ value,
265
+ })
266
+ },
267
+ onClose: () => {
268
+ annotationExpanded.value = false
269
+ emit("blur", { id })
270
+ },
271
+ onBlur: () => emit("blur", { id }),
272
+ }),
273
+ ]),
274
+ )
275
+ }
276
+
277
+ headerMetaChildren.push(
278
+ h(hasCheck ? "label" : "span", { class: "aimd-rec-inline__check-wrap" }, [
279
+ hasCheck
280
+ ? h("input", {
281
+ "data-rec-focus-key": `step:${id}:checked`,
282
+ type: "checkbox",
283
+ disabled,
284
+ checked: Boolean(state.checked),
285
+ onChange: (event: Event) => {
286
+ emit("check-change", {
287
+ id,
288
+ value: (event.target as HTMLInputElement).checked,
289
+ })
290
+ },
291
+ onBlur: () => emit("blur", { id }),
292
+ })
293
+ : null,
294
+ h("span", { class: "aimd-field__scope" }, getAimdRecorderScopeLabel("step", props.messages)),
295
+ h("span", { class: "aimd-rec-inline__step-num" }, stepNumber),
296
+ h("span", { class: "aimd-field__name" }, id),
297
+ ]),
298
+ )
299
+
300
+ if (estimatedDurationLabel.value) {
301
+ headerMetaChildren.push(
302
+ h("span", {
303
+ class: "aimd-step-timer__pill aimd-step-timer__pill--estimate",
304
+ title: props.messages.step.estimatedDuration(estimatedDurationLabel.value),
305
+ }, props.messages.step.estimatedBadge(estimatedDurationLabel.value)),
306
+ )
307
+ }
308
+
309
+ if (showTimerSummary.value) {
310
+ headerMetaChildren.push(
311
+ h("span", {
312
+ class: [
313
+ "aimd-step-timer__pill",
314
+ "aimd-step-timer__pill--actual",
315
+ timerRunning.value ? "aimd-step-timer__pill--running" : "",
316
+ ],
317
+ title: props.messages.step.recordedDuration(actualDurationLabel.value),
318
+ }, props.messages.step.recordedBadge(actualDurationLabel.value)),
319
+ )
320
+ }
321
+
322
+ if (!disabled && !showAnnotationEditor.value) {
323
+ headerActionChildren.push(
324
+ h("button", {
325
+ type: "button",
326
+ class: "aimd-step-timer__btn aimd-step-timer__btn--ghost aimd-step-field__toggle aimd-step-field__toggle--annotation",
327
+ onMousedown: preventToggleFocus,
328
+ onClick: openAnnotationDetail,
329
+ }, props.messages.step.annotationToggle),
330
+ )
331
+ }
332
+
333
+ if (!disabled && !showTimerDetails.value) {
334
+ headerActionChildren.push(
335
+ h("button", {
336
+ type: "button",
337
+ class: "aimd-step-timer__btn aimd-step-timer__btn--ghost aimd-step-field__toggle aimd-step-field__toggle--timer",
338
+ onMousedown: preventToggleFocus,
339
+ onClick: openTimerDetail,
340
+ }, props.messages.step.timerToggle),
341
+ )
342
+ }
343
+
344
+ const bodyChildren = props.bodyNodes.length > 0
345
+ ? h("div", { class: "aimd-step-field__body" }, props.bodyNodes)
346
+ : null
347
+
348
+ return h("div", {
349
+ ref: rootEl,
350
+ class: ["aimd-rec-inline aimd-rec-inline--step aimd-field aimd-field--step", ...extraClasses],
351
+ onFocusin: handleFocusIn,
352
+ onFocusout: handleFocusOut,
353
+ }, [
354
+ h("div", {
355
+ class: "aimd-step-field__main",
356
+ }, [
357
+ h("div", {
358
+ class: "aimd-step-field__main-meta",
359
+ }, headerMetaChildren),
360
+ headerActionChildren.length > 0
361
+ ? h("div", {
362
+ class: "aimd-step-field__main-actions",
363
+ }, headerActionChildren)
364
+ : null,
365
+ ]),
366
+ bodyChildren,
367
+ showDetailRow.value
368
+ ? h("div", { class: "aimd-step-field__details" }, detailChildren)
369
+ : null,
370
+ ])
371
+ }
372
+ },
373
+ })
374
+
375
+ export const AimdCheckField = defineComponent({
376
+ name: "AimdCheckField",
377
+ props: {
378
+ node: { type: Object as PropType<AimdCheckNode>, required: true },
379
+ state: { type: Object as PropType<AimdCheckRecordItem>, required: true },
380
+ bodyNodes: { type: Array as PropType<VNodeChild[]>, default: () => [] },
381
+ disabled: { type: Boolean, default: false },
382
+ extraClasses: { type: Array as PropType<string[]>, default: () => [] },
383
+ messages: { type: Object as PropType<AimdRecorderMessages>, required: true },
384
+ },
385
+ emits: ["check-change", "annotation-change", "blur"],
386
+ setup(props, { emit }) {
387
+ return () => {
388
+ const node = props.node
389
+ const id = node.id
390
+ const state = props.state
391
+ const disabled = props.disabled
392
+ const extraClasses = props.extraClasses
393
+ const hasBody = props.bodyNodes.length > 0
394
+ const showCheckedMessage = Boolean(state.checked && node.checked_message)
395
+ const fallbackLabel = node.label || id
396
+
397
+ return h("div", {
398
+ class: ["aimd-rec-inline aimd-rec-inline--check aimd-field aimd-field--check", ...extraClasses],
399
+ }, [
400
+ h("div", { class: "aimd-check-field__main" }, [
401
+ h("label", { class: "aimd-rec-inline__check-wrap aimd-check-field__toggle" }, [
402
+ h("input", {
403
+ "data-rec-focus-key": `check:${id}:checked`,
404
+ type: "checkbox",
405
+ class: "aimd-checkbox",
406
+ disabled,
407
+ checked: Boolean(state.checked),
408
+ onChange: (event: Event) => {
409
+ emit("check-change", {
410
+ id,
411
+ value: (event.target as HTMLInputElement).checked,
412
+ })
413
+ },
414
+ onBlur: () => emit("blur", { id }),
415
+ }),
416
+ h("span", { class: "aimd-field__scope" }, getAimdRecorderScopeLabel("check", props.messages)),
417
+ !hasBody
418
+ ? h("span", { class: "aimd-field__name aimd-check-field__key" }, fallbackLabel)
419
+ : null,
420
+ ]),
421
+ hasBody
422
+ ? h("div", {
423
+ class: [
424
+ "aimd-check-field__body",
425
+ state.checked ? "aimd-check-field__body--checked" : "",
426
+ ],
427
+ }, props.bodyNodes)
428
+ : null,
429
+ ]),
430
+ showCheckedMessage
431
+ ? h("div", { class: "aimd-check-field__banner" }, node.checked_message)
432
+ : null,
433
+ h("input", {
434
+ "data-rec-focus-key": `check:${id}:annotation`,
435
+ class: "aimd-rec-inline__input aimd-rec-inline__input--annotation",
436
+ disabled,
437
+ placeholder: props.messages.check.annotationPlaceholder,
438
+ value: state.annotation || "",
439
+ onInput: (event: Event) => {
440
+ emit("annotation-change", {
441
+ id,
442
+ value: (event.target as HTMLInputElement).value,
443
+ })
444
+ },
445
+ onBlur: () => emit("blur", { id }),
446
+ }),
447
+ ])
448
+ }
449
+ },
450
+ })
451
+
452
+ export default AimdStepField
453
+ </script>
@@ -0,0 +1,213 @@
1
+ <script lang="ts">
2
+ import { defineAsyncComponent, defineComponent, h, type PropType, type VNode } from "vue"
3
+ import type { AimdVarNode } from "@airalogy/aimd-core/types"
4
+ import type { AimdFieldMeta, AimdTypePlugin, AimdVarInputKind } from "../types"
5
+ import type { AimdRecorderMessages } from "../locales"
6
+ import { getAimdRecorderScopeLabel } from "../locales"
7
+ import { resolveAimdCodeEditorLanguage } from "../code-types"
8
+ import {
9
+ normalizeVarTypeName,
10
+ parseVarInputValue,
11
+ applyVarStackWidth,
12
+ syncAutoWrapTextareaHeight,
13
+ toBooleanValue,
14
+ } from "../composables/useVarHelpers"
15
+
16
+ const AimdCodeField = defineAsyncComponent(() => import("./AimdCodeField.vue"))
17
+
18
+ export default defineComponent({
19
+ name: "AimdVarField",
20
+ props: {
21
+ node: { type: Object as PropType<AimdVarNode>, required: true },
22
+ value: { type: undefined as unknown as PropType<unknown>, default: undefined },
23
+ disabled: { type: Boolean, default: false },
24
+ extraClasses: { type: Array as PropType<string[]>, default: () => [] },
25
+ messages: { type: Object as PropType<AimdRecorderMessages>, required: true },
26
+ fieldMeta: { type: Object as PropType<AimdFieldMeta | undefined>, default: undefined },
27
+ displayValue: { type: [String, Number] as PropType<string | number>, default: "" },
28
+ inputKind: { type: String as PropType<AimdVarInputKind>, required: true },
29
+ typePlugin: { type: Object as PropType<AimdTypePlugin | undefined>, default: undefined },
30
+ initialized: { type: Boolean, default: false },
31
+ },
32
+ emits: ["change", "blur"],
33
+ setup(props, { emit }) {
34
+ return () => {
35
+ const node = props.node
36
+ const id = node.id
37
+ const type = node.definition?.type || "str"
38
+ const normalizedType = normalizeVarTypeName(type)
39
+ const inputKind = props.inputKind
40
+ const isIntegerInput = normalizedType === "int" || normalizedType === "integer"
41
+ const usesDecimalTextInput = inputKind === "number" && !isIntegerInput
42
+ const meta = props.fieldMeta
43
+ const disabled = props.disabled
44
+ const extraClasses = props.extraClasses
45
+ const placeholder = meta?.placeholder ?? getVarPlaceholder(node)
46
+ const displayValue = props.displayValue
47
+ const codeLanguage = resolveAimdCodeEditorLanguage(type, meta) ?? "plaintext"
48
+
49
+ function onVarChange(rawValue: string) {
50
+ const parsed = parseVarInputValue(rawValue, type, inputKind, {
51
+ typePlugin: props.typePlugin,
52
+ })
53
+ emit("change", { id, value: parsed, type, inputKind })
54
+ }
55
+
56
+ function onVarBlur() {
57
+ emit("blur", { id })
58
+ }
59
+
60
+ function syncCompactControlLayout(control: HTMLInputElement | HTMLTextAreaElement) {
61
+ applyVarStackWidth(control, inputKind)
62
+ if (typeof HTMLTextAreaElement !== "undefined" && control instanceof HTMLTextAreaElement) {
63
+ syncAutoWrapTextareaHeight(control)
64
+ }
65
+ }
66
+
67
+ // Enum select (from fieldMeta override)
68
+ const enumOptions = meta?.enumOptions ?? []
69
+ if (enumOptions.length) {
70
+ return h("span", {
71
+ class: ["aimd-rec-inline aimd-rec-inline--var-stacked aimd-field-wrapper", ...extraClasses],
72
+ }, [
73
+ h("span", { class: "aimd-field aimd-field--no-style aimd-field__label" }, [
74
+ h("span", { class: "aimd-field__scope aimd-field__scope--var" }, "var"),
75
+ h("span", { class: "aimd-field__id" }, id),
76
+ ]),
77
+ h("select", {
78
+ "data-rec-focus-key": `var:${id}`,
79
+ class: "aimd-rec-inline__input aimd-rec-inline__input--stacked aimd-rec-inline__select",
80
+ disabled,
81
+ value: props.value,
82
+ onChange: (e: Event) => onVarChange((e.target as HTMLSelectElement).value),
83
+ onBlur: onVarBlur,
84
+ }, enumOptions.map(opt => h("option", { key: String(opt.value), value: opt.value }, opt.label))),
85
+ ])
86
+ }
87
+
88
+ // Default stacked widget
89
+ const renderStackedVar = (control: VNode, variantClass?: string): VNode =>
90
+ h("span", {
91
+ class: ["aimd-rec-inline aimd-rec-inline--var-stacked aimd-field-wrapper aimd-field-wrapper--inline", variantClass, ...extraClasses],
92
+ }, [
93
+ h("span", { class: "aimd-field aimd-field--no-style aimd-field__label" }, [
94
+ h("span", { class: "aimd-field__scope aimd-field__scope--var" }, getAimdRecorderScopeLabel("var", props.messages)),
95
+ h("span", { class: "aimd-field__id" }, id),
96
+ ]),
97
+ control,
98
+ ])
99
+
100
+ if (inputKind === "checkbox") {
101
+ return renderStackedVar(
102
+ h("span", { class: "aimd-rec-inline__checkbox-row" }, [
103
+ h("input", {
104
+ "data-rec-focus-key": `var:${id}`,
105
+ type: "checkbox",
106
+ disabled,
107
+ checked: toBooleanValue(props.value),
108
+ onVnodeMounted: (vnode: any) => applyVarStackWidth(vnode.el as HTMLElement, inputKind),
109
+ onVnodeUpdated: (vnode: any) => applyVarStackWidth(vnode.el as HTMLElement, inputKind),
110
+ onChange: (event: Event) => {
111
+ const val = (event.target as HTMLInputElement).checked
112
+ emit("change", { id, value: val, type, inputKind })
113
+ },
114
+ onBlur: onVarBlur,
115
+ }),
116
+ ]),
117
+ "aimd-rec-inline--var-stacked--checkbox",
118
+ )
119
+ }
120
+
121
+ if (inputKind === "textarea" || inputKind === "dna") {
122
+ return renderStackedVar(
123
+ h("textarea", {
124
+ "data-rec-focus-key": `var:${id}`,
125
+ class: "aimd-rec-inline__textarea aimd-rec-inline__textarea--stacked",
126
+ disabled,
127
+ placeholder,
128
+ value: displayValue,
129
+ onVnodeMounted: (vnode: any) => applyVarStackWidth(vnode.el as HTMLElement, inputKind),
130
+ onVnodeUpdated: (vnode: any) => applyVarStackWidth(vnode.el as HTMLElement, inputKind),
131
+ onInput: (event: Event) => onVarChange((event.target as HTMLTextAreaElement).value),
132
+ onBlur: onVarBlur,
133
+ }),
134
+ inputKind === "dna" ? "aimd-rec-inline--var-stacked--dna" : "aimd-rec-inline--var-stacked--textarea",
135
+ )
136
+ }
137
+
138
+ if (inputKind === "code") {
139
+ return renderStackedVar(
140
+ h(AimdCodeField, {
141
+ modelValue: typeof displayValue === "number" ? String(displayValue) : displayValue,
142
+ language: codeLanguage,
143
+ disabled,
144
+ "onUpdate:modelValue": (nextValue: string) => onVarChange(nextValue),
145
+ onBlur: onVarBlur,
146
+ }),
147
+ "aimd-rec-inline--var-stacked--code",
148
+ )
149
+ }
150
+
151
+ if (inputKind === "text") {
152
+ return renderStackedVar(
153
+ h("textarea", {
154
+ "data-rec-focus-key": `var:${id}`,
155
+ class: "aimd-rec-inline__textarea aimd-rec-inline__textarea--stacked aimd-rec-inline__textarea--stacked-text",
156
+ rows: 1,
157
+ disabled,
158
+ placeholder,
159
+ value: displayValue,
160
+ onVnodeMounted: (vnode: any) => {
161
+ const el = vnode.el as HTMLTextAreaElement
162
+ syncCompactControlLayout(el)
163
+ },
164
+ onVnodeUpdated: (vnode: any) => {
165
+ const el = vnode.el as HTMLTextAreaElement
166
+ syncCompactControlLayout(el)
167
+ },
168
+ onInput: (event: Event) => {
169
+ const el = event.target as HTMLTextAreaElement
170
+ syncCompactControlLayout(el)
171
+ onVarChange(el.value)
172
+ },
173
+ onBlur: onVarBlur,
174
+ }),
175
+ )
176
+ }
177
+
178
+ // number / date / datetime / time
179
+ const htmlInputType = inputKind === "datetime"
180
+ ? "datetime-local"
181
+ : (usesDecimalTextInput ? "text" : inputKind)
182
+
183
+ return renderStackedVar(
184
+ h("input", {
185
+ "data-rec-focus-key": `var:${id}`,
186
+ class: "aimd-rec-inline__input aimd-rec-inline__input--stacked",
187
+ type: htmlInputType,
188
+ inputmode: inputKind === "number" ? (isIntegerInput ? "numeric" : "decimal") : undefined,
189
+ disabled,
190
+ placeholder,
191
+ step: inputKind === "number"
192
+ ? (isIntegerInput ? "1" : undefined)
193
+ : (inputKind === "time" ? "1" : undefined),
194
+ value: displayValue,
195
+ onVnodeMounted: (vnode: any) => syncCompactControlLayout(vnode.el as HTMLInputElement),
196
+ onVnodeUpdated: (vnode: any) => syncCompactControlLayout(vnode.el as HTMLInputElement),
197
+ onInput: (event: Event) => {
198
+ const el = event.target as HTMLInputElement
199
+ syncCompactControlLayout(el)
200
+ onVarChange(el.value)
201
+ },
202
+ onBlur: onVarBlur,
203
+ }),
204
+ )
205
+ }
206
+ },
207
+ })
208
+
209
+ function getVarPlaceholder(node: AimdVarNode): string | undefined {
210
+ const title = node.definition?.kwargs?.title
211
+ return typeof title === "string" && title.trim() ? title.trim() : undefined
212
+ }
213
+ </script>