@airalogy/aimd-recorder 1.19.2 → 1.21.0

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 (75) hide show
  1. package/README.md +6 -0
  2. package/README.zh-CN.md +6 -0
  3. package/dist/{AimdCodeField-BQUuM-EF.js → AimdCodeField-BN_0UQMx.js} +34 -32
  4. package/dist/{AimdDnaSequenceField-TBKunqU_.js → AimdDnaSequenceField-Cp0cgBYl.js} +1 -1
  5. package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-gTySIxvX.js → AimdEditor.vue_vue_type_style_index_0_lang-Dj5y1p3U.js} +2202 -2158
  6. package/dist/{AimdMarkdownField-DGV5KFUs.js → AimdMarkdownField-Vp72mf5d.js} +18 -17
  7. package/dist/{AimdMarkdownNoteField-C78KHCBA.js → AimdMarkdownNoteField-8AHO9zwW.js} +17 -16
  8. package/dist/aimd-recorder.css +1 -1
  9. package/dist/{arc-BMhAnOm7.js → arc-YTgUVhxi.js} +1 -1
  10. package/dist/{architectureDiagram-3BPJPVTR-DXuPTBR3.js → architectureDiagram-3BPJPVTR-BFddgj3h.js} +2 -2
  11. package/dist/{blockDiagram-GPEHLZMM-HKz9kQ49.js → blockDiagram-GPEHLZMM-BNFU64lo.js} +4 -4
  12. package/dist/{c4Diagram-AAUBKEIU-B2a8Aupm.js → c4Diagram-AAUBKEIU-DDg-ymRq.js} +2 -2
  13. package/dist/{channel-CQnbPm6T.js → channel-Cswcnlp1.js} +1 -1
  14. package/dist/{chunk-2J33WTMH-CPwhDANL.js → chunk-2J33WTMH-CP2V6jff.js} +1 -1
  15. package/dist/{chunk-4BX2VUAB-BJV0R8-Z.js → chunk-4BX2VUAB-CbWr2vv6.js} +1 -1
  16. package/dist/{chunk-55IACEB6-CSqUgTVA.js → chunk-55IACEB6-DQOKhaUL.js} +1 -1
  17. package/dist/{chunk-727SXJPM-C3LCZWaC.js → chunk-727SXJPM-4VuCu0m8.js} +5 -5
  18. package/dist/{chunk-AQP2D5EJ-BC5kHyik.js → chunk-AQP2D5EJ-D7Pq-oug.js} +3 -3
  19. package/dist/{chunk-FMBD7UC4-lv-SQuSa.js → chunk-FMBD7UC4-slF0wbDn.js} +1 -1
  20. package/dist/{chunk-ND2GUHAM-BnnHbOOp.js → chunk-ND2GUHAM-BrNrmeyL.js} +1 -1
  21. package/dist/{chunk-QZHKN3VN-DE1_5lrn.js → chunk-QZHKN3VN-CII3oQmH.js} +1 -1
  22. package/dist/{classDiagram-v2-Q7XG4LA2-32SrXsR3.js → classDiagram-4FO5ZUOK-skT5SNaU.js} +2 -2
  23. package/dist/{classDiagram-4FO5ZUOK-32SrXsR3.js → classDiagram-v2-Q7XG4LA2-skT5SNaU.js} +2 -2
  24. package/dist/components.js +3194 -2847
  25. package/dist/composables.js +89 -85
  26. package/dist/{cose-bilkent-S5V4N54A-BKyR6PrF.js → cose-bilkent-S5V4N54A-CiwUUHaz.js} +1 -1
  27. package/dist/{dagre-BM42HDAG-D8Nwouf2.js → dagre-BM42HDAG-BzaKejHz.js} +3 -3
  28. package/dist/{diagram-2AECGRRQ-DfoNEchZ.js → diagram-2AECGRRQ-B7jPt7Sf.js} +2 -2
  29. package/dist/{diagram-5GNKFQAL-Dlpl3XO8.js → diagram-5GNKFQAL-z6ygEwZY.js} +3 -3
  30. package/dist/{diagram-KO2AKTUF-CgwROod_.js → diagram-KO2AKTUF-BBQMMIgY.js} +2 -2
  31. package/dist/{diagram-LMA3HP47-UiiviX43.js → diagram-LMA3HP47-IFDVFs2m.js} +2 -2
  32. package/dist/{diagram-OG6HWLK6-BPuH-4Wa.js → diagram-OG6HWLK6-DjEAxof0.js} +3 -3
  33. package/dist/{erDiagram-TEJ5UH35-B19WKSiS.js → erDiagram-TEJ5UH35-DxMYC2Iw.js} +4 -4
  34. package/dist/{flowDiagram-I6XJVG4X-SsfO1IYz.js → flowDiagram-I6XJVG4X-EIHEHG32.js} +6 -6
  35. package/dist/{ganttDiagram-6RSMTGT7-8BCxW9SC.js → ganttDiagram-6RSMTGT7-TEOWSxVA.js} +2 -2
  36. package/dist/{gitGraphDiagram-PVQCEYII-D-jzaXKg.js → gitGraphDiagram-PVQCEYII-Cwzy4bEc.js} +3 -3
  37. package/dist/{graph-Dd8Vx0lj.js → graph-Cyx6ry93.js} +1 -1
  38. package/dist/index-Dtvv88SS.js +1308 -0
  39. package/dist/index.js +72 -68
  40. package/dist/{infoDiagram-5YYISTIA-B_XwkyXw.js → infoDiagram-5YYISTIA-DNv6Z1ol.js} +1 -1
  41. package/dist/{ishikawaDiagram-YF4QCWOH-nevqOMkV.js → ishikawaDiagram-YF4QCWOH-D3eaxgy9.js} +1 -1
  42. package/dist/{journeyDiagram-JHISSGLW-DKQOkZNx.js → journeyDiagram-JHISSGLW-D5g7q2RP.js} +4 -4
  43. package/dist/{kanban-definition-UN3LZRKU-BYvizbN0.js → kanban-definition-UN3LZRKU-C0hUSCKH.js} +2 -2
  44. package/dist/{layout-BiHDh2wu.js → layout-CpB8OqeJ.js} +2 -2
  45. package/dist/{linear-BcUgIsNC.js → linear-D55SCqYq.js} +1 -1
  46. package/dist/{mermaid.core-DPv1ut6K.js → mermaid.core-wqUqC7-u.js} +34 -34
  47. package/dist/{mindmap-definition-RKZ34NQL-CiT97EC2.js → mindmap-definition-RKZ34NQL-tCWbcVMf.js} +3 -3
  48. package/dist/{pieDiagram-4H26LBE5-BHcFVpCC.js → pieDiagram-4H26LBE5-JtTllP1a.js} +3 -3
  49. package/dist/{quadrantDiagram-W4KKPZXB-BFBAb3Zx.js → quadrantDiagram-W4KKPZXB-CLL79FuD.js} +2 -2
  50. package/dist/record.js +90 -1196
  51. package/dist/{requirementDiagram-4Y6WPE33-CUS2OOyE.js → requirementDiagram-4Y6WPE33-3BVAevi9.js} +3 -3
  52. package/dist/{sankeyDiagram-5OEKKPKP-IuhX4tCb.js → sankeyDiagram-5OEKKPKP-BfUuX3gj.js} +1 -1
  53. package/dist/{sequenceDiagram-3UESZ5HK-DWHcFiUF.js → sequenceDiagram-3UESZ5HK-vTd4YJPb.js} +3 -3
  54. package/dist/{stateDiagram-AJRCARHV-J49Kafj_.js → stateDiagram-AJRCARHV-BzlMdp-U.js} +4 -4
  55. package/dist/{stateDiagram-v2-BHNVJYJU-DL2VCR5X.js → stateDiagram-v2-BHNVJYJU-Ciwlhuza.js} +2 -2
  56. package/dist/{timeline-definition-PNZ67QCA-l9xSQ_pX.js → timeline-definition-PNZ67QCA-CySiSuYS.js} +2 -2
  57. package/dist/{useCodeBlockRendering-CY70U0Xm.js → useCodeBlockRendering-DtcAJyK9.js} +1239 -1123
  58. package/dist/{vennDiagram-CIIHVFJN-BQjdmOkd.js → vennDiagram-CIIHVFJN-Bbf0BSAq.js} +1 -1
  59. package/dist/{wardleyDiagram-YWT4CUSO-CmVdsV9b.js → wardleyDiagram-YWT4CUSO-J0jnd8EV.js} +2 -2
  60. package/dist/{xychartDiagram-2RQKCTM6-F-cC_Igm.js → xychartDiagram-2RQKCTM6-XCPLxT4O.js} +2 -2
  61. package/package.json +3 -3
  62. package/src/__tests__/recorder-assigner-control.test.ts +4 -1
  63. package/src/__tests__/recorder-editor.test.ts +3 -1
  64. package/src/__tests__/var-field-render.test.ts +547 -3
  65. package/src/components/AimdCodeField.vue +11 -3
  66. package/src/components/AimdRecorder.vue +469 -7
  67. package/src/components/AimdRecorderEditor.vue +3 -1
  68. package/src/components/AimdVarField.vue +589 -17
  69. package/src/components/AimdVarTableField.vue +10 -5
  70. package/src/composables/__tests__/useVarHelpers.test.ts +214 -7
  71. package/src/composables/index.ts +6 -0
  72. package/src/composables/useFieldRendering.ts +28 -0
  73. package/src/composables/useVarHelpers.ts +285 -14
  74. package/src/locales.ts +60 -0
  75. package/src/types.ts +1 -1
@@ -5,12 +5,23 @@ import { h } from 'vue'
5
5
  import { flushPromises, mount } from '@vue/test-utils'
6
6
  import { afterEach, describe, expect, it, vi } from 'vitest'
7
7
  import type { AimdVarNode, AimdVarTableNode } from '@airalogy/aimd-core/types'
8
+ import { getAimdBuiltInTypeEnumValues } from '@airalogy/aimd-core/utils'
8
9
 
9
10
  import AimdRecorder from '../components/AimdRecorder.vue'
10
11
  import AimdVarField from '../components/AimdVarField.vue'
11
12
  import AimdVarTableField from '../components/AimdVarTableField.vue'
12
13
  import { createAimdRecorderMessages } from '../locales'
13
14
 
15
+ vi.mock('../components/AimdCodeField.vue', () => ({
16
+ __esModule: true,
17
+ default: {
18
+ name: 'AimdCodeField',
19
+ props: ['modelValue', 'language', 'disabled', 'compact'],
20
+ emits: ['update:modelValue', 'blur'],
21
+ template: '<textarea class="aimd-code-field-stub" :value="modelValue" :disabled="disabled" @input="$emit(\'update:modelValue\', $event.target.value)" @blur="$emit(\'blur\')" />',
22
+ },
23
+ }))
24
+
14
25
  const __filename = fileURLToPath(import.meta.url)
15
26
  const __dirname = dirname(__filename)
16
27
  const source = readFileSync(resolve(__dirname, '../components/AimdVarField.vue'), 'utf8')
@@ -48,12 +59,16 @@ describe('AimdVarField render behavior', () => {
48
59
  expect(source).toMatch(/if \(inputKind === "code"\)/)
49
60
  expect(source).toMatch(/language: codeLanguage/)
50
61
  expect(source).toMatch(/"aimd-rec-inline--var-stacked--code"/)
62
+ expect(source).toMatch(/language: "json"/)
51
63
  })
52
64
 
53
- it('starts CodeStr and PyStr editors at a compact content-driven height', () => {
65
+ it('starts code editors at a content-driven height and supports compact density', () => {
54
66
  expect(codeFieldSource).toContain('createMonacoAutoHeight')
55
67
  expect(codeFieldSource).toMatch(/const editorHeight = codeAutoHeight\.editorHeight/)
56
68
  expect(codeFieldSource).toMatch(/codeAutoHeight\.attachEditor\(monacoEditor\)/)
69
+ expect(codeFieldSource).toContain('compact?: boolean')
70
+ expect(codeFieldSource).toContain("verticalPadding: props.compact ? 12 : 24")
71
+ expect(codeFieldSource).toContain("padding: props.compact ? { top: 6, bottom: 6 } : { top: 12, bottom: 12 }")
57
72
  expect(codeFieldSource).toContain('--aimd-code-field-editor-height')
58
73
  expect(codeFieldSource).not.toContain('min-height: 240px;')
59
74
  })
@@ -136,6 +151,16 @@ describe('AimdVarField render behavior', () => {
136
151
  expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline--var-stacked \.aimd-field__key\) \{[\s\S]*?overflow: visible;[\s\S]*?white-space: nowrap;/)
137
152
  })
138
153
 
154
+ it('keeps complex markdown tables scrollable without expanding the recorder', () => {
155
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(table:not\(\.aimd-rec-inline-table__table\):not\(\.aimd-scale__table\)\) \{[\s\S]*?display: block;[\s\S]*?max-width: 100%;[\s\S]*?overflow-x: auto;/)
156
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(table:not\(\.aimd-rec-inline-table__table\):not\(\.aimd-scale__table\) th:first-child\),[\s\S]*?\.aimd-protocol-recorder__content :deep\(table:not\(\.aimd-rec-inline-table__table\):not\(\.aimd-scale__table\) td:first-child\) \{[\s\S]*?position: sticky;[\s\S]*?left: 0;/)
157
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(table:not\(\.aimd-rec-inline-table__table\):not\(\.aimd-scale__table\) td:has\(\.aimd-rec-inline--var-stacked\)\) \{[\s\S]*?min-width: min\(360px, 80vw\);[\s\S]*?max-width: min\(680px, 80vw\);/)
158
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(table:not\(\.aimd-rec-inline-table__table\):not\(\.aimd-scale__table\) \.aimd-rec-inline--var-stacked\) \{[\s\S]*?width: max-content;[\s\S]*?max-width: min\(680px, 100%\);/)
159
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(table:not\(\.aimd-rec-inline-table__table\):not\(\.aimd-scale__table\) \.aimd-rec-inline--var-stacked \.aimd-field__title\),[\s\S]*?\.aimd-protocol-recorder__content :deep\(table:not\(\.aimd-rec-inline-table__table\):not\(\.aimd-scale__table\) \.aimd-rec-inline--var-stacked \.aimd-field__key\) \{[\s\S]*?overflow-wrap: break-word;[\s\S]*?white-space: normal;[\s\S]*?word-break: normal;/)
160
+ expect(source).toContain('class: "aimd-field__title", title: displayTitle')
161
+ expect(source).toContain('class: "aimd-field__key", title: id')
162
+ })
163
+
139
164
  it('normalizes stacked var value typography across native control types', () => {
140
165
  expect(recorderSource).toContain('--rec-body-font-size: 14px;')
141
166
  expect(recorderSource).toContain('--rec-var-value-font-size: var(--rec-body-font-size);')
@@ -264,9 +289,381 @@ describe('AimdVarField render behavior', () => {
264
289
  })
265
290
 
266
291
  it('places code assigner actions in the field header instead of a side prefix', () => {
267
- expect(source).toContain('["file", "code"].includes(inputKind)')
292
+ expect(source).toContain('["file", "code", "scalar-list"].includes(inputKind)')
268
293
  expect(source).toMatch(/if \(inputKind === "code"\) \{[\s\S]*?"aimd-rec-inline--var-stacked--code",[\s\S]*?\{ controlRow: false \}/)
269
- expect(recorderSource).toContain('["number", "date", "datetime", "time", "text", "textarea", "checkbox", "file", "code"].includes(inputKind)')
294
+ expect(recorderSource).toContain('["number", "date", "datetime", "time", "text", "textarea", "scalar-list", "checkbox", "boolean-select", "file", "code"].includes(inputKind)')
295
+ })
296
+
297
+ it('renders nullable boolean vars as tri-state select fields', async () => {
298
+ const wrapper = mount(AimdRecorder, {
299
+ props: {
300
+ content: 'Rash: {{var|reaction_rash: bool | None}}',
301
+ locale: 'en-US',
302
+ modelValue: { var: {}, step: {}, check: {}, quiz: {} },
303
+ },
304
+ })
305
+
306
+ await flushPromises()
307
+ await wrapper.vm.$nextTick()
308
+ await vi.dynamicImportSettled()
309
+ await wrapper.vm.$nextTick()
310
+
311
+ const select = wrapper.find<HTMLSelectElement>('select[data-rec-focus-key="var:reaction_rash"]')
312
+ expect(select.exists()).toBe(true)
313
+ expect(select.classes()).toContain('aimd-rec-inline__boolean-select')
314
+ expect(select.findAll('option').map(option => option.text())).toEqual(['Not set', 'True', 'False'])
315
+ expect(select.element.value).toBe('')
316
+
317
+ await select.setValue('true')
318
+ await flushPromises()
319
+
320
+ let updates = wrapper.emitted('update:modelValue') ?? []
321
+ let latest = updates[updates.length - 1]?.[0] as { var?: Record<string, unknown> } | undefined
322
+ expect(latest?.var?.reaction_rash).toBe(true)
323
+
324
+ await select.setValue('')
325
+ await flushPromises()
326
+
327
+ updates = wrapper.emitted('update:modelValue') ?? []
328
+ latest = updates[updates.length - 1]?.[0] as { var?: Record<string, unknown> } | undefined
329
+ expect(latest?.var?.reaction_rash).toBeNull()
330
+ })
331
+
332
+ it('renders scalar-list fields as full-row controls with horizontal items before wrapping', () => {
333
+ expect(source).toContain('{ controlRow: false, headerAction: modeToolbar }')
334
+ expect(source).toContain('context.measureText(line).width')
335
+ expect(source).toContain('syncScalarListTextInputLayout(el)')
336
+ expect(source).toContain('"--aimd-rec-scalar-list-input-width"')
337
+ expect(source).toContain('hasExplicitLineBreak(item)')
338
+ expect(source).toContain('isWideScalarListTextItem(item, itemPlaceholder)')
339
+ expect(source).toMatch(/isNumericScalarList\s*\?\s*h\("input"/)
340
+ expect(source).toContain('h("textarea"')
341
+ expect(source).toContain('syncAutoWrapTextareaHeight(control)')
342
+ expect(source).toContain('props.messages.scalarList.itemIndex(rowIndex + 1)')
343
+ expect(recorderSource).toContain('.aimd-rec-inline__header-extra-action')
344
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline--var-stacked--scalar-list\) \{[\s\S]*?display: flex;[\s\S]*?width: 100%;[\s\S]*?margin: 12px 0;/)
345
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__items\) \{[\s\S]*?flex-flow: row wrap;[\s\S]*?gap: 5px;/)
346
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__rows\) \{[\s\S]*?display: contents;/)
347
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__row\) \{[\s\S]*?display: inline-flex;[\s\S]*?align-items: stretch;[\s\S]*?gap: 0;[\s\S]*?width: fit-content;/)
348
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__row--has-drag\.aimd-rec-scalar-list__row--has-remove\) \{[\s\S]*?--aimd-rec-scalar-list-control-offset: 68px;/)
349
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__row--multiline\) \{[\s\S]*?flex: 1 1 100%;[\s\S]*?width: 100%;/)
350
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__input\) \{[\s\S]*?width: var\(--aimd-rec-scalar-list-input-width, calc\(8em \+ 16px\)\);[\s\S]*?max-width: min\(calc\(42em \+ 16px\), calc\(100% - var\(--aimd-rec-scalar-list-control-offset, 0px\)\)\);/)
351
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__input--text\) \{[\s\S]*?resize: none;[\s\S]*?overflow: hidden;[\s\S]*?white-space: pre-wrap;[\s\S]*?overflow-wrap: anywhere;/)
352
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__row--multiline \.aimd-rec-scalar-list__input--text\) \{[\s\S]*?flex: 1 1 auto;[\s\S]*?width: auto;/)
353
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__index\) \{[\s\S]*?min-width: 22px;[\s\S]*?min-height: 26px;[\s\S]*?font-size: 10px;[\s\S]*?font-variant-numeric: tabular-nums;/)
354
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__drag\) \{[\s\S]*?width: 20px;[\s\S]*?min-height: 26px;[\s\S]*?font-size: 12px;/)
355
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__remove\) \{[\s\S]*?width: 26px;[\s\S]*?min-height: 26px;[\s\S]*?font-size: 13px;/)
356
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__row--drop-target-before\)::before,[\s\S]*?\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__row--drop-target-after\)::after \{[\s\S]*?animation: aimd-rec-scalar-list-insert-pulse/)
357
+ expect(recorderSource).toContain('@keyframes aimd-rec-scalar-list-insert-pulse')
358
+ expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-scalar-list__mode-button:first-child\) \{[\s\S]*?border-radius: 5px 0 0 5px;/)
359
+ expect(recorderSource).not.toContain('min-height: 72px;')
360
+ })
361
+
362
+ it('renders explicit multiline list string items as full-row controls', async () => {
363
+ const node: AimdVarNode = {
364
+ type: 'aimd',
365
+ fieldType: 'var',
366
+ scope: 'var',
367
+ id: 'sample_notes',
368
+ raw: '{{var|sample_notes}}',
369
+ definition: {
370
+ id: 'sample_notes',
371
+ type: 'list[str]',
372
+ },
373
+ }
374
+
375
+ const wrapper = mount(AimdVarField, {
376
+ props: {
377
+ node,
378
+ value: ['a\nb\nc'] as any,
379
+ disabled: false,
380
+ extraClasses: [],
381
+ messages: createAimdRecorderMessages('en-US'),
382
+ displayValue: '["a\\nb\\nc"]',
383
+ inputKind: 'scalar-list',
384
+ initialized: true,
385
+ },
386
+ })
387
+
388
+ const row = wrapper.find('.aimd-rec-scalar-list__row')
389
+ expect(row.classes()).toContain('aimd-rec-scalar-list__row--multiline')
390
+ expect(wrapper.find<HTMLTextAreaElement>('.aimd-rec-scalar-list__input').element.value).toBe('a\nb\nc')
391
+ })
392
+
393
+ it('renders long auto-wrapped list string items as full-row controls', async () => {
394
+ const node: AimdVarNode = {
395
+ type: 'aimd',
396
+ fieldType: 'var',
397
+ scope: 'var',
398
+ id: 'sample_notes',
399
+ raw: '{{var|sample_notes}}',
400
+ definition: {
401
+ id: 'sample_notes',
402
+ type: 'list[str]',
403
+ },
404
+ }
405
+ const longText = 'This is a long list item without explicit line breaks. It should occupy the full row once it exceeds the compact scalar-list width.'
406
+
407
+ const wrapper = mount(AimdVarField, {
408
+ props: {
409
+ node,
410
+ value: [longText] as any,
411
+ disabled: false,
412
+ extraClasses: [],
413
+ messages: createAimdRecorderMessages('en-US'),
414
+ displayValue: JSON.stringify([longText]),
415
+ inputKind: 'scalar-list',
416
+ initialized: true,
417
+ },
418
+ })
419
+
420
+ expect(wrapper.find('.aimd-rec-scalar-list__row').classes()).toContain('aimd-rec-scalar-list__row--multiline')
421
+ expect(wrapper.find<HTMLTextAreaElement>('.aimd-rec-scalar-list__input').element.value).toBe(longText)
422
+ })
423
+
424
+ it('renders list[str] vars as repeatable string inputs', async () => {
425
+ const node: AimdVarNode = {
426
+ type: 'aimd',
427
+ fieldType: 'var',
428
+ scope: 'var',
429
+ id: 'sample_tags',
430
+ raw: '{{var|sample_tags}}',
431
+ definition: {
432
+ id: 'sample_tags',
433
+ type: 'list[str]',
434
+ kwargs: {
435
+ title: 'Sample tags',
436
+ },
437
+ },
438
+ }
439
+
440
+ const wrapper = mount(AimdVarField, {
441
+ props: {
442
+ node,
443
+ value: ['alpha'] as any,
444
+ disabled: false,
445
+ extraClasses: [],
446
+ messages: createAimdRecorderMessages('en-US'),
447
+ displayValue: '["alpha"]',
448
+ inputKind: 'scalar-list',
449
+ initialized: true,
450
+ },
451
+ })
452
+
453
+ const getInputs = () => wrapper.findAll<HTMLInputElement>('.aimd-rec-scalar-list__input')
454
+ const getLatestChange = () => {
455
+ const changes = wrapper.emitted('change') ?? []
456
+ return changes[changes.length - 1]?.[0]
457
+ }
458
+ expect(getInputs()).toHaveLength(1)
459
+ expect(getInputs()[0].element.tagName).toBe('TEXTAREA')
460
+ expect(getInputs()[0].element.value).toBe('alpha')
461
+ expect(wrapper.findAll('.aimd-rec-scalar-list__index').map(index => index.text())).toEqual(['1'])
462
+ expect(wrapper.find('.aimd-rec-scalar-list__index').attributes('title')).toBe('Item 1')
463
+ expect(wrapper.find('.aimd-rec-scalar-list__add').text()).toBe('Add item')
464
+
465
+ await wrapper.find('.aimd-rec-scalar-list__add').trigger('click')
466
+ await wrapper.vm.$nextTick()
467
+ expect(getInputs()).toHaveLength(2)
468
+ expect(wrapper.findAll('.aimd-rec-scalar-list__index').map(index => index.text())).toEqual(['1', '2'])
469
+ expect(getLatestChange()).toMatchObject({
470
+ id: 'sample_tags',
471
+ value: ['alpha'],
472
+ type: 'list[str]',
473
+ inputKind: 'scalar-list',
474
+ })
475
+
476
+ await getInputs()[1].setValue('beta')
477
+ await wrapper.vm.$nextTick()
478
+ expect(getLatestChange()).toMatchObject({
479
+ value: ['alpha', 'beta'],
480
+ })
481
+
482
+ const dragButtons = wrapper.findAll('.aimd-rec-scalar-list__drag')
483
+ expect(dragButtons).toHaveLength(2)
484
+ await dragButtons[1].trigger('dragstart', {
485
+ dataTransfer: {
486
+ effectAllowed: '',
487
+ setData: vi.fn(),
488
+ },
489
+ })
490
+ await wrapper.findAll('.aimd-rec-scalar-list__row')[0].trigger('dragover')
491
+ expect(wrapper.findAll('.aimd-rec-scalar-list__row')[0].classes()).toContain('aimd-rec-scalar-list__row--drop-target-before')
492
+ await wrapper.findAll('.aimd-rec-scalar-list__row')[0].trigger('drop')
493
+ await wrapper.vm.$nextTick()
494
+ expect(getLatestChange()).toMatchObject({
495
+ value: ['beta', 'alpha'],
496
+ })
497
+
498
+ await wrapper.findAll('.aimd-rec-scalar-list__remove')[0].trigger('click')
499
+ await wrapper.vm.$nextTick()
500
+ expect(getLatestChange()).toMatchObject({
501
+ value: ['alpha'],
502
+ })
503
+ })
504
+
505
+ it('renders list[int] vars as repeatable number inputs', async () => {
506
+ const node: AimdVarNode = {
507
+ type: 'aimd',
508
+ fieldType: 'var',
509
+ scope: 'var',
510
+ id: 'counts',
511
+ raw: '{{var|counts}}',
512
+ definition: {
513
+ id: 'counts',
514
+ type: 'list[int]',
515
+ kwargs: {
516
+ title: 'Counts',
517
+ },
518
+ },
519
+ }
520
+
521
+ const wrapper = mount(AimdVarField, {
522
+ props: {
523
+ node,
524
+ value: [1] as any,
525
+ disabled: false,
526
+ extraClasses: [],
527
+ messages: createAimdRecorderMessages('en-US'),
528
+ displayValue: '[1]',
529
+ inputKind: 'scalar-list',
530
+ initialized: true,
531
+ },
532
+ })
533
+
534
+ const getInputs = () => wrapper.findAll<HTMLInputElement>('.aimd-rec-scalar-list__input')
535
+ const getLatestChange = () => {
536
+ const changes = wrapper.emitted('change') ?? []
537
+ return changes[changes.length - 1]?.[0]
538
+ }
539
+ expect(getInputs()).toHaveLength(1)
540
+ expect(getInputs()[0].attributes('type')).toBe('number')
541
+ expect(getInputs()[0].attributes('step')).toBe('1')
542
+ expect(getInputs()[0].element.value).toBe('1')
543
+
544
+ await wrapper.find('.aimd-rec-scalar-list__add').trigger('click')
545
+ await wrapper.vm.$nextTick()
546
+ await getInputs()[1].setValue('2')
547
+ await wrapper.vm.$nextTick()
548
+ expect(getLatestChange()).toMatchObject({
549
+ id: 'counts',
550
+ value: [1, 2],
551
+ type: 'list[int]',
552
+ inputKind: 'scalar-list',
553
+ })
554
+ })
555
+
556
+ it('edits scalar-list vars in JSON mode without emitting invalid JSON', async () => {
557
+ const node: AimdVarNode = {
558
+ type: 'aimd',
559
+ fieldType: 'var',
560
+ scope: 'var',
561
+ id: 'sample_tags',
562
+ raw: '{{var|sample_tags}}',
563
+ definition: {
564
+ id: 'sample_tags',
565
+ type: 'list[str]',
566
+ },
567
+ }
568
+
569
+ const wrapper = mount(AimdVarField, {
570
+ props: {
571
+ node,
572
+ value: ['alpha'] as any,
573
+ disabled: false,
574
+ extraClasses: [],
575
+ messages: createAimdRecorderMessages('en-US'),
576
+ displayValue: '["alpha"]',
577
+ inputKind: 'scalar-list',
578
+ initialized: true,
579
+ },
580
+ })
581
+
582
+ const modeButtons = wrapper.findAll('.aimd-rec-scalar-list__mode-button')
583
+ expect(modeButtons.map(button => button.text())).toEqual(['Items', 'JSON'])
584
+ expect(wrapper.find('.aimd-field__label .aimd-rec-scalar-list__toolbar').exists()).toBe(true)
585
+ expect(wrapper.find('.aimd-rec-inline__scalar-list > .aimd-rec-scalar-list__toolbar').exists()).toBe(false)
586
+
587
+ await modeButtons[1].trigger('click')
588
+ await wrapper.vm.$nextTick()
589
+ await vi.dynamicImportSettled()
590
+ await wrapper.vm.$nextTick()
591
+ const jsonEditor = wrapper.findComponent({ name: 'AimdCodeField' })
592
+ expect(jsonEditor.exists()).toBe(true)
593
+ expect(jsonEditor.props('modelValue')).toContain('"alpha"')
594
+ expect(jsonEditor.props('language')).toBe('json')
595
+ expect(jsonEditor.props('compact')).toBe(true)
596
+
597
+ await jsonEditor.vm.$emit('update:modelValue', '["aaa", "bbb"]')
598
+ await wrapper.vm.$nextTick()
599
+ const getLatestChange = () => {
600
+ const changes = wrapper.emitted('change') ?? []
601
+ return changes[changes.length - 1]?.[0]
602
+ }
603
+ expect(getLatestChange()).toMatchObject({
604
+ id: 'sample_tags',
605
+ value: ['aaa', 'bbb'],
606
+ type: 'list[str]',
607
+ inputKind: 'scalar-list',
608
+ })
609
+
610
+ const emittedCount = (wrapper.emitted('change') ?? []).length
611
+ await jsonEditor.vm.$emit('update:modelValue', '{"bad": true}')
612
+ await wrapper.vm.$nextTick()
613
+ expect(wrapper.find('.aimd-rec-scalar-list__json-error').text()).toBe('JSON value must be an array.')
614
+ expect((wrapper.emitted('change') ?? [])).toHaveLength(emittedCount)
615
+
616
+ await modeButtons[0].trigger('click')
617
+ await wrapper.vm.$nextTick()
618
+ expect(wrapper.findAll<HTMLInputElement>('.aimd-rec-scalar-list__input').map(input => input.element.value)).toEqual(['aaa', 'bbb'])
619
+ })
620
+
621
+ it('parses numeric scalar-list JSON according to the item type', async () => {
622
+ const node: AimdVarNode = {
623
+ type: 'aimd',
624
+ fieldType: 'var',
625
+ scope: 'var',
626
+ id: 'counts',
627
+ raw: '{{var|counts}}',
628
+ definition: {
629
+ id: 'counts',
630
+ type: 'list[int]',
631
+ },
632
+ }
633
+
634
+ const wrapper = mount(AimdVarField, {
635
+ props: {
636
+ node,
637
+ value: [] as any,
638
+ disabled: false,
639
+ extraClasses: [],
640
+ messages: createAimdRecorderMessages('en-US'),
641
+ displayValue: '[]',
642
+ inputKind: 'scalar-list',
643
+ initialized: true,
644
+ },
645
+ })
646
+
647
+ await wrapper.findAll('.aimd-rec-scalar-list__mode-button')[1].trigger('click')
648
+ await wrapper.vm.$nextTick()
649
+ await vi.dynamicImportSettled()
650
+ await wrapper.vm.$nextTick()
651
+ const jsonEditor = wrapper.findComponent({ name: 'AimdCodeField' })
652
+ await jsonEditor.vm.$emit('update:modelValue', '[1, 2]')
653
+ await wrapper.vm.$nextTick()
654
+ const getLatestChange = () => {
655
+ const changes = wrapper.emitted('change') ?? []
656
+ return changes[changes.length - 1]?.[0]
657
+ }
658
+ expect(getLatestChange()).toMatchObject({
659
+ value: [1, 2],
660
+ })
661
+
662
+ const emittedCount = (wrapper.emitted('change') ?? []).length
663
+ await jsonEditor.vm.$emit('update:modelValue', '[1.2]')
664
+ await wrapper.vm.$nextTick()
665
+ expect(wrapper.find('.aimd-rec-scalar-list__json-error').text()).toBe('JSON array items do not match this list type.')
666
+ expect((wrapper.emitted('change') ?? [])).toHaveLength(emittedCount)
270
667
  })
271
668
 
272
669
  it('shows file ids as user-facing file cards instead of raw ids', async () => {
@@ -479,7 +876,9 @@ describe('AimdVarField render behavior', () => {
479
876
  })
480
877
 
481
878
  expect(wrapper.find('.aimd-field__title').text()).toBe('Record date')
879
+ expect(wrapper.find('.aimd-field__title').attributes('title')).toBe('Record date')
482
880
  expect(wrapper.find('.aimd-field__key').text()).toBe('record_date')
881
+ expect(wrapper.find('.aimd-field__key').attributes('title')).toBe('record_date')
483
882
  expect(wrapper.find('.aimd-field__description').exists()).toBe(false)
484
883
  expect(wrapper.find('.aimd-field__metadata-popover').text()).toContain('ISO date')
485
884
  expect(wrapper.find('.aimd-field__metadata-examples-label').text()).toBe('e.g.')
@@ -595,6 +994,94 @@ describe('AimdVarField render behavior', () => {
595
994
  expect(latest?.var?.review_type).toBe('quick')
596
995
  })
597
996
 
997
+ it('renders official Airalogy built-in enum types as select fields in AimdRecorder', async () => {
998
+ const enumValues = getAimdBuiltInTypeEnumValues('BloodType | None')
999
+ expect(enumValues.length).toBeGreaterThan(0)
1000
+
1001
+ const wrapper = mount(AimdRecorder, {
1002
+ props: {
1003
+ content: 'Blood type: {{var|blood_type: BloodType | None, title = "Blood type"}}',
1004
+ locale: 'en-US',
1005
+ modelValue: { var: {}, step: {}, check: {}, quiz: {} },
1006
+ },
1007
+ })
1008
+
1009
+ await flushPromises()
1010
+ await wrapper.vm.$nextTick()
1011
+ await vi.dynamicImportSettled()
1012
+ await wrapper.vm.$nextTick()
1013
+
1014
+ const select = wrapper.find('select[data-rec-focus-key="var:blood_type"]')
1015
+ expect(select.exists()).toBe(true)
1016
+ expect(select.findAll('option').map(option => option.text())).toEqual([
1017
+ 'Not set',
1018
+ ...enumValues.map(value => String(value)),
1019
+ ])
1020
+
1021
+ await select.setValue('0')
1022
+ await flushPromises()
1023
+
1024
+ const updates = wrapper.emitted('update:modelValue') ?? []
1025
+ let latest = updates[updates.length - 1]?.[0] as { var?: Record<string, unknown> } | undefined
1026
+ expect(latest?.var?.blood_type).toBe(enumValues[0])
1027
+
1028
+ const selectedSelect = wrapper.find('select[data-rec-focus-key="var:blood_type"]')
1029
+ expect(selectedSelect.findAll('option').map(option => option.text())).toEqual([
1030
+ 'Not set',
1031
+ ...enumValues.map(value => String(value)),
1032
+ ])
1033
+
1034
+ await selectedSelect.setValue('')
1035
+ await flushPromises()
1036
+
1037
+ const clearUpdates = wrapper.emitted('update:modelValue') ?? []
1038
+ latest = clearUpdates[clearUpdates.length - 1]?.[0] as { var?: Record<string, unknown> } | undefined
1039
+ expect(latest?.var?.blood_type).toBeNull()
1040
+ })
1041
+
1042
+ it('renders scalar list vars as repeatable inputs in AimdRecorder', async () => {
1043
+ const wrapper = mount(AimdRecorder, {
1044
+ props: {
1045
+ content: 'Tags: {{var|sample_tags: list[str], title = "Sample tags"}} Counts: {{var|counts: list[int], title = "Counts"}}',
1046
+ locale: 'en-US',
1047
+ modelValue: { var: {}, step: {}, check: {}, quiz: {} },
1048
+ },
1049
+ })
1050
+
1051
+ await flushPromises()
1052
+ await wrapper.vm.$nextTick()
1053
+ await vi.dynamicImportSettled()
1054
+ await wrapper.vm.$nextTick()
1055
+
1056
+ const getInputs = () => wrapper.findAll<HTMLInputElement>('.aimd-rec-scalar-list__input')
1057
+ expect(getInputs()).toHaveLength(2)
1058
+ expect(getInputs()[0].attributes('data-rec-focus-key')).toBe('var:sample_tags')
1059
+ expect(getInputs()[1].attributes('data-rec-focus-key')).toBe('var:counts')
1060
+ expect(getInputs()[1].attributes('type')).toBe('number')
1061
+
1062
+ expect(getInputs()[0].element.tagName).toBe('TEXTAREA')
1063
+
1064
+ await wrapper.find<HTMLTextAreaElement>('textarea[data-rec-focus-key="var:sample_tags"]').setValue('qc')
1065
+ await flushPromises()
1066
+
1067
+ await wrapper.findAll('.aimd-rec-scalar-list__add')[0].trigger('click')
1068
+ await wrapper.vm.$nextTick()
1069
+ await wrapper.find<HTMLTextAreaElement>('textarea[data-rec-focus-key="var:sample_tags:1"]').setValue('rna')
1070
+ await flushPromises()
1071
+
1072
+ await wrapper.find<HTMLInputElement>('input[data-rec-focus-key="var:counts"]').setValue('1')
1073
+ await flushPromises()
1074
+ await wrapper.findAll('.aimd-rec-scalar-list__add')[1].trigger('click')
1075
+ await wrapper.vm.$nextTick()
1076
+ await wrapper.find<HTMLInputElement>('input[data-rec-focus-key="var:counts:1"]').setValue('2')
1077
+ await flushPromises()
1078
+
1079
+ const updates = wrapper.emitted('update:modelValue') ?? []
1080
+ const latest = updates[updates.length - 1]?.[0] as { var?: Record<string, unknown> } | undefined
1081
+ expect(latest?.var?.sample_tags).toEqual(['qc', 'rna'])
1082
+ expect(latest?.var?.counts).toEqual([1, 2])
1083
+ })
1084
+
598
1085
  it('renders AIMD var_table and column metadata', () => {
599
1086
  vi.stubGlobal('ResizeObserver', class {
600
1087
  observe() {}
@@ -891,4 +1378,61 @@ describe('AimdVarField render behavior', () => {
891
1378
  value: 'include',
892
1379
  })
893
1380
  })
1381
+
1382
+ it('keeps nullable var_table enum cells clearable to null', async () => {
1383
+ vi.stubGlobal('ResizeObserver', class {
1384
+ observe() {}
1385
+ unobserve() {}
1386
+ disconnect() {}
1387
+ })
1388
+ vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {
1389
+ callback(0)
1390
+ return 1
1391
+ })
1392
+ vi.stubGlobal('cancelAnimationFrame', () => {})
1393
+
1394
+ const node: AimdVarTableNode = {
1395
+ type: 'aimd',
1396
+ fieldType: 'var_table',
1397
+ scope: 'var_table',
1398
+ id: 'screening',
1399
+ raw: '{{var_table|screening}}',
1400
+ columns: ['decision'],
1401
+ definition: {
1402
+ id: 'screening',
1403
+ subvars: {
1404
+ decision: {
1405
+ id: 'decision',
1406
+ type: 'Literal["include", "exclude"] | None',
1407
+ enum: ['include', 'exclude'],
1408
+ },
1409
+ },
1410
+ },
1411
+ }
1412
+
1413
+ const wrapper = mount(AimdVarTableField, {
1414
+ props: {
1415
+ node,
1416
+ rows: [{ decision: 'include' }],
1417
+ columns: ['decision'],
1418
+ disabled: false,
1419
+ readonly: false,
1420
+ settlingRowKey: null,
1421
+ messages: createAimdRecorderMessages('en-US'),
1422
+ },
1423
+ })
1424
+
1425
+ const select = wrapper.find('select[data-rec-focus-key="var_table:screening:0:decision"]')
1426
+ expect(select.findAll('option').map(option => option.text())).toEqual(['Not set', 'include', 'exclude'])
1427
+
1428
+ await select.setValue('')
1429
+
1430
+ const cellUpdates = wrapper.emitted('cell-input') ?? []
1431
+ expect(cellUpdates[cellUpdates.length - 1]?.[0]).toMatchObject({
1432
+ tableName: 'screening',
1433
+ column: 'decision',
1434
+ rowIndex: 0,
1435
+ value: null,
1436
+ })
1437
+ })
894
1438
  })
@@ -7,9 +7,11 @@ const props = withDefaults(defineProps<{
7
7
  modelValue?: string | number
8
8
  language: string
9
9
  disabled?: boolean
10
+ compact?: boolean
10
11
  }>(), {
11
12
  modelValue: '',
12
13
  disabled: false,
14
+ compact: false,
13
15
  })
14
16
 
15
17
  const emit = defineEmits<{
@@ -24,7 +26,8 @@ const draftValue = ref(normalizeCodeFieldValue(props.modelValue))
24
26
  const codeAutoHeight = createMonacoAutoHeight({
25
27
  getInitialValue: () => draftValue.value,
26
28
  getLayoutElement: () => editorContainer.value,
27
- maxHeight: 520,
29
+ verticalPadding: props.compact ? 12 : 24,
30
+ maxHeight: props.compact ? 220 : 520,
28
31
  })
29
32
  const editorHeight = codeAutoHeight.editorHeight
30
33
  const editorStyle = computed(() => ({
@@ -91,7 +94,7 @@ async function createEditor() {
91
94
  wordWrap: 'on',
92
95
  lineHeight: codeAutoHeight.lineHeight,
93
96
  tabSize: 2,
94
- padding: { top: 12, bottom: 12 },
97
+ padding: props.compact ? { top: 6, bottom: 6 } : { top: 12, bottom: 12 },
95
98
  scrollbar: { vertical: 'auto', horizontal: 'auto' },
96
99
  readOnly: props.disabled,
97
100
  })
@@ -164,7 +167,7 @@ watch(() => props.language, async (language) => {
164
167
  </script>
165
168
 
166
169
  <template>
167
- <div class="aimd-code-field" :class="{ 'aimd-code-field--disabled': disabled }" :style="editorStyle">
170
+ <div class="aimd-code-field" :class="{ 'aimd-code-field--disabled': disabled, 'aimd-code-field--compact': compact }" :style="editorStyle">
168
171
  <div v-if="loadError" class="aimd-code-field__fallback-shell">
169
172
  <textarea
170
173
  class="aimd-code-field__fallback"
@@ -237,6 +240,11 @@ watch(() => props.language, async (language) => {
237
240
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
238
241
  }
239
242
 
243
+ .aimd-code-field--compact .aimd-code-field__fallback {
244
+ padding: 6px 10px;
245
+ line-height: 1.45;
246
+ }
247
+
240
248
  .aimd-code-field--disabled {
241
249
  opacity: 0.98;
242
250
  }