@airalogy/aimd-recorder 1.27.2 → 1.29.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 (78) hide show
  1. package/README.md +5 -1
  2. package/README.zh-CN.md +5 -1
  3. package/dist/{AimdDnaSequenceField-CjcZ1fpz.js → AimdDnaSequenceField-CC07idJ1.js} +1 -1
  4. package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-4yWDudoV.js → AimdEditor.vue_vue_type_style_index_0_lang-C9xOPWUf.js} +6731 -6636
  5. package/dist/{AimdEntityRefField-CiGP3IyQ.js → AimdEntityRefField-Bc55EWW7.js} +1 -1
  6. package/dist/{AimdEntityRefField.vue_vue_type_script_setup_true_lang-B-a446u5.js → AimdEntityRefField.vue_vue_type_script_setup_true_lang-B539YY-u.js} +1 -1
  7. package/dist/{AimdMarkdownField-BAJ7otCw.js → AimdMarkdownField-DaYdXrEN.js} +3 -3
  8. package/dist/{AimdMarkdownNoteField-Ca-kRvLz.js → AimdMarkdownNoteField-DE2eyIeG.js} +2 -2
  9. package/dist/{AimdResourceRefField-Yc3j0Pgu.js → AimdResourceRefField-Dv1EfosL.js} +2 -2
  10. package/dist/aimd-recorder.css +1 -1
  11. package/dist/{arc-CAjOitck.js → arc-COg5ULhj.js} +1 -1
  12. package/dist/{architectureDiagram-3BPJPVTR-Dqk9MN5z.js → architectureDiagram-3BPJPVTR-Cl6dfzfF.js} +2 -2
  13. package/dist/{blockDiagram-GPEHLZMM-DQLn0TV3.js → blockDiagram-GPEHLZMM-BACKnDKc.js} +4 -4
  14. package/dist/{c4Diagram-AAUBKEIU-DZZ_f9Fy.js → c4Diagram-AAUBKEIU-zq3HwKb_.js} +2 -2
  15. package/dist/{channel-rjOxq-6_.js → channel-BJlkYmQY.js} +1 -1
  16. package/dist/{chunk-2J33WTMH-tQlc96HU.js → chunk-2J33WTMH-B7oyQtnK.js} +1 -1
  17. package/dist/{chunk-4BX2VUAB-DJYTZE2c.js → chunk-4BX2VUAB-DVmdXl0Z.js} +1 -1
  18. package/dist/{chunk-55IACEB6-CRiTC3Ls.js → chunk-55IACEB6-C6G6r1Hs.js} +1 -1
  19. package/dist/{chunk-727SXJPM-BD2QhWqt.js → chunk-727SXJPM-DRauMxlM.js} +5 -5
  20. package/dist/{chunk-AQP2D5EJ-B0aa98ib.js → chunk-AQP2D5EJ-CFOFED2g.js} +3 -3
  21. package/dist/{chunk-FMBD7UC4-ByDG3u38.js → chunk-FMBD7UC4-D6pbxcrd.js} +1 -1
  22. package/dist/{chunk-ND2GUHAM-Cj1D7wW5.js → chunk-ND2GUHAM-CTRvR7V6.js} +1 -1
  23. package/dist/{chunk-QZHKN3VN-g2yBIr1b.js → chunk-QZHKN3VN-JYLI2Fou.js} +1 -1
  24. package/dist/{classDiagram-v2-Q7XG4LA2-BHrQHB1_.js → classDiagram-4FO5ZUOK-CvWmPFSb.js} +2 -2
  25. package/dist/{classDiagram-4FO5ZUOK-BHrQHB1_.js → classDiagram-v2-Q7XG4LA2-CvWmPFSb.js} +2 -2
  26. package/dist/components.js +3621 -3567
  27. package/dist/composables.js +2 -2
  28. package/dist/{cose-bilkent-S5V4N54A-DoR6eiyr.js → cose-bilkent-S5V4N54A-g5sJsJsO.js} +1 -1
  29. package/dist/{dagre-BM42HDAG-Dojxqnuq.js → dagre-BM42HDAG-CgURX0XQ.js} +3 -3
  30. package/dist/{diagram-2AECGRRQ-CXtd1KGZ.js → diagram-2AECGRRQ-DkDoyjIE.js} +2 -2
  31. package/dist/{diagram-5GNKFQAL-BnJ2DhKE.js → diagram-5GNKFQAL-CjmQeZ1p.js} +3 -3
  32. package/dist/{diagram-KO2AKTUF-DJZFSngn.js → diagram-KO2AKTUF-xkwe4Z-T.js} +2 -2
  33. package/dist/{diagram-LMA3HP47-Dx6TLGwi.js → diagram-LMA3HP47-B4XAB0Ul.js} +2 -2
  34. package/dist/{diagram-OG6HWLK6-BX5km_SS.js → diagram-OG6HWLK6-DIDrCkjk.js} +3 -3
  35. package/dist/{erDiagram-TEJ5UH35-PWmJC0ho.js → erDiagram-TEJ5UH35-HCGS4huB.js} +4 -4
  36. package/dist/{example-record-AHkkwdqV.js → example-record-6TUyxByY.js} +2 -2
  37. package/dist/{flowDiagram-I6XJVG4X-ODu7JRxY.js → flowDiagram-I6XJVG4X-DCR0zjVf.js} +6 -6
  38. package/dist/{ganttDiagram-6RSMTGT7-CZY08InD.js → ganttDiagram-6RSMTGT7-D0cqiqhS.js} +2 -2
  39. package/dist/{gitGraphDiagram-PVQCEYII-1FOO5ySv.js → gitGraphDiagram-PVQCEYII-CjEJrOfY.js} +3 -3
  40. package/dist/{graph-Dx1st3gR.js → graph-vXOGPp0B.js} +1 -1
  41. package/dist/index.js +5 -5
  42. package/dist/{infoDiagram-5YYISTIA-Rqn1YuSl.js → infoDiagram-5YYISTIA-Cwa9CA9R.js} +1 -1
  43. package/dist/{ishikawaDiagram-YF4QCWOH-DTqjtgII.js → ishikawaDiagram-YF4QCWOH-Dtm2EQRM.js} +1 -1
  44. package/dist/{journeyDiagram-JHISSGLW-Dfc2a9K3.js → journeyDiagram-JHISSGLW-Cwsyan_q.js} +4 -4
  45. package/dist/{kanban-definition-UN3LZRKU-DZz55ohU.js → kanban-definition-UN3LZRKU-Cocu6oQX.js} +2 -2
  46. package/dist/{layout-k1LKX9WI.js → layout-BQZ5CVhn.js} +2 -2
  47. package/dist/{linear-DSz9nhkN.js → linear-Dl1Cl9MO.js} +1 -1
  48. package/dist/{mermaid.core-iwpvEomj.js → mermaid.core-CcTsVOub.js} +34 -34
  49. package/dist/{mindmap-definition-RKZ34NQL-CEz0DgQr.js → mindmap-definition-RKZ34NQL-CJD4ZSsv.js} +3 -3
  50. package/dist/{pieDiagram-4H26LBE5-BcuSLA0L.js → pieDiagram-4H26LBE5-miM6t9w3.js} +3 -3
  51. package/dist/{quadrantDiagram-W4KKPZXB-D3IixvxS.js → quadrantDiagram-W4KKPZXB-BbjEmdfP.js} +2 -2
  52. package/dist/record.js +3 -3
  53. package/dist/{requirementDiagram-4Y6WPE33-Bk-lwb2t.js → requirementDiagram-4Y6WPE33-Btxs6bPP.js} +3 -3
  54. package/dist/{sankeyDiagram-5OEKKPKP-BmUhv9kI.js → sankeyDiagram-5OEKKPKP-BFlv9Za2.js} +1 -1
  55. package/dist/{sequenceDiagram-3UESZ5HK-BhAJ2Wz1.js → sequenceDiagram-3UESZ5HK-CzsCwM84.js} +3 -3
  56. package/dist/{stateDiagram-AJRCARHV-DvH3mI9R.js → stateDiagram-AJRCARHV-Cr-X25OO.js} +4 -4
  57. package/dist/{stateDiagram-v2-BHNVJYJU-DvkU8jpH.js → stateDiagram-v2-BHNVJYJU-BU8pS5zo.js} +2 -2
  58. package/dist/{timeline-definition-PNZ67QCA-CQFLx2MG.js → timeline-definition-PNZ67QCA-CCxtC3I1.js} +2 -2
  59. package/dist/{useFieldRendering-Bj2H9CPx.js → useFieldRendering-fRL0kBSG.js} +57 -57
  60. package/dist/{useVarHelpers-Bf3wNHxF.js → useVarHelpers-CC6Jk-Vu.js} +1308 -1292
  61. package/dist/{validation-CH6pi638.js → validation-qjnL_HTT.js} +1431 -1426
  62. package/dist/{vennDiagram-CIIHVFJN-D_qwBk9R.js → vennDiagram-CIIHVFJN-DoQdCEMx.js} +1 -1
  63. package/dist/{wardleyDiagram-YWT4CUSO-BezUR1jm.js → wardleyDiagram-YWT4CUSO-3t148oYZ.js} +2 -2
  64. package/dist/{xychartDiagram-2RQKCTM6-CTFs3FiD.js → xychartDiagram-2RQKCTM6-DCni6kCQ.js} +2 -2
  65. package/package.json +4 -4
  66. package/src/__tests__/field-panel.test.ts +45 -0
  67. package/src/__tests__/record-validation.test.ts +41 -3
  68. package/src/__tests__/var-field-render.test.ts +28 -0
  69. package/src/components/AimdRecorder.vue +64 -13
  70. package/src/components/AimdRecorderWysiwygSurface.vue +5 -0
  71. package/src/components/AimdVarField.vue +41 -17
  72. package/src/composables/__tests__/useVarHelpers.test.ts +7 -1
  73. package/src/composables/useFieldPresentation.ts +2 -2
  74. package/src/composables/useFieldRendering.ts +2 -1
  75. package/src/locales.ts +12 -0
  76. package/src/record/validation.ts +18 -9
  77. package/src/styles/recorder-compact.css +17 -0
  78. package/src/styles/recorder.css +7 -0
@@ -1,4 +1,4 @@
1
- import { aU as Gt, s as Wt, g as Kt, t as Ht, q as Yt, a as Xt, b as Zt, _ as w, F as wt, L as Jt, d as ot, al as Qt, ac as $t, ad as te, ae as ee, e as ne, A as se, H as ie, I as oe } from "./mermaid.core-iwpvEomj.js";
1
+ import { aU as Gt, s as Wt, g as Kt, t as Ht, q as Yt, a as Xt, b as Zt, _ as w, F as wt, L as Jt, d as ot, al as Qt, ac as $t, ad as te, ae as ee, e as ne, A as se, H as ie, I as oe } from "./mermaid.core-CcTsVOub.js";
2
2
  const kt = (t, n) => Gt(t, "a", -n), _t = 1e-10;
3
3
  function st(t, n) {
4
4
  const s = ae(t), e = s.filter((c) => re(c, t));
@@ -1,5 +1,5 @@
1
- import { s as Mt, g as Nt, t as Lt, q as zt, a as Tt, b as At, _ as u, a1 as Xt, F as Et, H as J, l as Q, L as Yt, e as It, A as Ft, c as V } from "./mermaid.core-iwpvEomj.js";
2
- import { p as Bt } from "./chunk-4BX2VUAB-DJYTZE2c.js";
1
+ import { s as Mt, g as Nt, t as Lt, q as zt, a as Tt, b as At, _ as u, a1 as Xt, F as Et, H as J, l as Q, L as Yt, e as It, A as Ft, c as V } from "./mermaid.core-CcTsVOub.js";
2
+ import { p as Bt } from "./chunk-4BX2VUAB-DVmdXl0Z.js";
3
3
  import { p as Rt } from "./wardley-L42UT6IY-D7b2ujEZ.js";
4
4
  var G = /* @__PURE__ */ u((o, r) => {
5
5
  const e = o <= 1 ? o * 100 : o;
@@ -1,7 +1,7 @@
1
- import { s as gi, g as xi, t as Xt, q as di, a as fi, b as pi, _ as a, l as Yt, L as mi, e as yi, A as bi, F as _t, i as Ai, H as Nt, I as wi, a1 as Ci, am as Si, a9 as Wt } from "./mermaid.core-iwpvEomj.js";
1
+ import { s as gi, g as xi, t as Xt, q as di, a as fi, b as pi, _ as a, l as Yt, L as mi, e as yi, A as bi, F as _t, i as Ai, H as Nt, I as wi, a1 as Ci, am as Si, a9 as Wt } from "./mermaid.core-CcTsVOub.js";
2
2
  import { i as _i } from "./init-DjUOC4st.js";
3
3
  import { o as ki } from "./ordinal-B6-f3MAq.js";
4
- import { l as zt } from "./linear-DSz9nhkN.js";
4
+ import { l as zt } from "./linear-Dl1Cl9MO.js";
5
5
  function Ri(e, t, i) {
6
6
  e = +e, t = +t, i = (n = arguments.length) < 2 ? (t = e, e = 0, 1) : n < 3 ? 1 : +i;
7
7
  for (var s = -1, n = Math.max(0, Math.ceil((t - e) / i)) | 0, o = new Array(n); ++s < n; )
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airalogy/aimd-recorder",
3
3
  "type": "module",
4
- "version": "1.27.2",
4
+ "version": "1.29.0",
5
5
  "description": "AIMD (Airalogy Markdown) recorder Vue components and UI",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -67,9 +67,9 @@
67
67
  "react": "^19.2.4",
68
68
  "react-dom": "^19.2.4",
69
69
  "seqviz": "^3.10.18",
70
- "@airalogy/aimd-core": "^2.18.0",
71
- "@airalogy/aimd-editor": "^1.13.1",
72
- "@airalogy/aimd-renderer": "^2.14.0"
70
+ "@airalogy/aimd-editor": "^1.14.0",
71
+ "@airalogy/aimd-renderer": "^2.14.0",
72
+ "@airalogy/aimd-core": "^2.18.1"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/node": "^24.3.0",
@@ -0,0 +1,45 @@
1
+ import { flushPromises, mount } from '@vue/test-utils'
2
+ import { describe, expect, it, vi } from 'vitest'
3
+ import AimdRecorder from '../components/AimdRecorder.vue'
4
+
5
+ describe('standalone field panel', () => {
6
+ const content = [
7
+ 'Example: `{{var|ignored}}`',
8
+ '{{step|start, title="Prepare"}} {{var|sample: str, title="Label", placeholder="S-01"}}',
9
+ '{{var|photo: FileIdJPG | None = None, title="Label photo"}}',
10
+ '{{check|inspect, title="Inspect label"}} {{check|legacy}}',
11
+ ].join('\n\n')
12
+ it('uses unique titled fields, keeps authored hints, and navigates by stable keys', async () => {
13
+ const panel = mount(AimdRecorder, { props: { content, layout: 'field-panel', locale: 'en-US' } })
14
+ await flushPromises()
15
+ expect(panel.findAll('[data-panel-field]').map(f => f.attributes('data-panel-field'))).toEqual(['var:sample', 'var:photo'])
16
+ expect(panel.get('[data-rec-focus-key="var:sample"]').attributes('placeholder')).toBe('S-01')
17
+ expect(panel.get('[data-panel-field="var:photo"]').text()).toContain('Optional')
18
+ expect(panel.findAll('.aimd-panel-outline button').map(b => b.text())).toEqual(['Prepare', 'Inspect label', 'legacy'])
19
+ await panel.get('.aimd-panel-outline button').trigger('click')
20
+ expect(panel.emitted('navigate-field')).toEqual([['step:start']])
21
+ await panel.setProps({ panelVariables: ['extra', 'photo', 'photo'], fieldMeta: { 'var:extra': {title:'Additional field'} } })
22
+ await flushPromises()
23
+ expect(panel.findAll('[data-panel-field]').map(f => f.attributes('aria-label'))).toEqual(['Additional field', 'Label photo'])
24
+ })
25
+
26
+ it('shows upload progress, preserves a failed value and emits the confirmed reference on retry', async () => {
27
+ let reject!: (error: Error) => void
28
+ const uploadFile = vi.fn().mockImplementationOnce(() => new Promise((_, fail) => { reject = fail })).mockResolvedValue('airalogy.id.file.test.jpg')
29
+ const panel = mount(AimdRecorder, { props: { content, layout: 'field-panel', uploadFile, locale: 'zh-CN' } })
30
+ await flushPromises()
31
+ expect(panel.get('.aimd-panel-upload button').text()).toContain('JPG')
32
+ const input = panel.get('input[type=file]')
33
+ const file = new File(['photo'], 'label.jpg', {type:'image/jpeg'})
34
+ Object.defineProperty(input.element, 'files', { value: [file] })
35
+ await input.trigger('change')
36
+ expect(panel.get('[role=status]').text()).toBe('上传中…')
37
+ expect(panel.emitted('field-change')).toBeUndefined()
38
+ reject(new Error('offline'))
39
+ await flushPromises()
40
+ expect(panel.find('.aimd-rec-file-field__error').exists()).toBe(true)
41
+ await input.trigger('change')
42
+ await flushPromises()
43
+ expect(panel.emitted('field-change')?.[0]?.[0]).toMatchObject({ fieldKey:'photo', value:'airalogy.id.file.test.jpg' })
44
+ })
45
+ })
@@ -28,14 +28,14 @@ describe("AimdRecorder validation", () => {
28
28
  var_definitions: [
29
29
  { id: "schema_name", type: "str", default: "" },
30
30
  { id: "aimd_name", type: "str" },
31
- { id: "optional_name", type: "str", default: "" },
31
+ { id: "optional_name", type: "str | None", default: null },
32
32
  ],
33
33
  var_table: [{
34
34
  id: "samples",
35
35
  scope: "var_table",
36
36
  subvars: [
37
37
  { id: "sample_id", type: "str" },
38
- { id: "note", type: "str", default: "" },
38
+ { id: "note", type: "str | None", default: null },
39
39
  ],
40
40
  }],
41
41
  }
@@ -54,7 +54,7 @@ describe("AimdRecorder validation", () => {
54
54
  required: ["sample_id"],
55
55
  properties: {
56
56
  sample_id: { type: "string" },
57
- note: { type: "string" },
57
+ note: { type: ["string", "null"] },
58
58
  },
59
59
  },
60
60
  },
@@ -179,6 +179,44 @@ describe("AimdRecorder validation", () => {
179
179
  ])
180
180
  })
181
181
 
182
+ it("distinguishes an omitted prefill, an explicitly cleared input and a valid false answer", async () => {
183
+ const wrapper = mount(AimdRecorder, { props: {
184
+ content: '{{var|unit: str = "mg"}} {{var|note: str | None = None}} {{var|flag: Literal[True, False]}}',
185
+ showSearch: false,
186
+ } })
187
+ await flushPromises()
188
+ const validate = () => (wrapper.vm as unknown as {
189
+ validate: (options: { focus: boolean }) => Promise<{ valid: boolean; issues: { fieldKey: string }[] }>
190
+ }).validate({ focus: false })
191
+ const unit = wrapper.get<HTMLInputElement>('[data-rec-focus-key="var:unit"]')
192
+ const flag = wrapper.get<HTMLSelectElement>('select[data-rec-focus-key="var:flag"]')
193
+ expect(unit.element.value).toBe('mg')
194
+ expect(flag.element.value).toBe('')
195
+ expect((await validate()).issues.map(issue => issue.fieldKey)).toEqual(['var:flag'])
196
+ expect(wrapper.get('.aimd-field__optional-marker').text()).toBe('Optional')
197
+ await flag.setValue('1')
198
+ expect((await validate()).valid).toBe(true)
199
+ await unit.setValue('')
200
+ expect((await validate()).issues.map(issue => issue.fieldKey)).toEqual(['var:unit'])
201
+ wrapper.unmount()
202
+ })
203
+
204
+ it("does not confuse a nullable list with a default-empty list", () => {
205
+ const fields = { ...EMPTY_FIELDS, var: ['nullable', 'omittable', 'empty'], var_definitions: [
206
+ { id: 'nullable', type: 'list[str] | None' },
207
+ { id: 'omittable', type: 'list[str] | None', default: null },
208
+ { id: 'empty', type: 'list[str]', default: [] },
209
+ ] }
210
+ const record = createEmptyProtocolRecordData()
211
+ const issues = () => validateAimdRecord(fields, record, { messages }).issues.map(issue => issue.fieldKey)
212
+ expect(issues()).toEqual(['var:nullable'])
213
+ record.var.nullable = null
214
+ record.var.empty = []
215
+ expect(issues()).toEqual([])
216
+ record.var.empty = null
217
+ expect(issues()).toEqual(['var:empty'])
218
+ })
219
+
182
220
  it("accepts null for schema-required nullable fields and table columns", () => {
183
221
  const fields: ExtractedAimdFields = {
184
222
  ...EMPTY_FIELDS,
@@ -706,6 +706,34 @@ describe('AimdVarField render behavior', () => {
706
706
  expect(wrapper.findAll<HTMLInputElement>('.aimd-rec-scalar-list__input').map(input => input.element.value)).toEqual(['aaa', 'bbb'])
707
707
  })
708
708
 
709
+ it('preserves the difference between an unanswered list and an explicit empty array in JSON mode', async () => {
710
+ const node: AimdVarNode = {
711
+ type: 'aimd', fieldType: 'var', scope: 'var', id: 'tags',
712
+ raw: '{{var|tags: list[str] | None = None}}',
713
+ definition: { id: 'tags', type: 'list[str] | None', default: null },
714
+ }
715
+ const wrapper = mount(AimdVarField, {
716
+ props: { node, value: null as any, inputKind: 'scalar-list', initialized: true, messages: createAimdRecorderMessages('en-US') },
717
+ })
718
+ const [items, json] = wrapper.findAll('.aimd-rec-scalar-list__mode-button')
719
+ await json.trigger('click')
720
+ await vi.dynamicImportSettled()
721
+ const editor = wrapper.findComponent({ name: 'AimdCodeField' })
722
+ expect(editor.props('modelValue')).toBe('null')
723
+ expect(wrapper.emitted('change')).toBeUndefined()
724
+
725
+ editor.vm.$emit('update:modelValue', '[]')
726
+ expect(wrapper.emitted('change')?.[0]?.[0]).toMatchObject({ value: [] })
727
+ await wrapper.setProps({ value: [] as any })
728
+ editor.vm.$emit('update:modelValue', 'null')
729
+ expect(wrapper.emitted('change')?.[1]?.[0]).toMatchObject({ value: null })
730
+ await wrapper.setProps({ value: null as any })
731
+ await items.trigger('click')
732
+ await json.trigger('click')
733
+ expect(wrapper.findComponent({ name: 'AimdCodeField' }).props('modelValue')).toBe('null')
734
+ expect(wrapper.emitted('change')).toHaveLength(2)
735
+ })
736
+
709
737
  it('parses numeric scalar-list JSON according to the item type', async () => {
710
738
  const node: AimdVarNode = {
711
739
  type: 'aimd',
@@ -145,6 +145,10 @@ const props = withDefaults(defineProps<{
145
145
  searchDefaultExpanded?: boolean
146
146
  /** Compact hides field metadata while preserving controls, validation and accessible names. */
147
147
  fieldDisplay?: 'compact' | 'detailed'
148
+ /** A standalone form projection of this protocol, using the same record and adapters. */
149
+ layout?: 'protocol' | 'field-panel'
150
+ /** Optional explicit field order, including variables declared only in the host schema. */
151
+ panelVariables?: string[]
148
152
 
149
153
  // ── Extension props ──────────────────────────────────────────────────────
150
154
 
@@ -256,6 +260,7 @@ const props = withDefaults(defineProps<{
256
260
  showSearch: true,
257
261
  searchDefaultExpanded: false,
258
262
  fieldDisplay: 'detailed',
263
+ layout: 'protocol',
259
264
  fieldMeta: undefined,
260
265
  serverAssigners: undefined,
261
266
  assigners: undefined,
@@ -286,6 +291,7 @@ const emit = defineEmits<{
286
291
  (e: "fields-change", fields: ExtractedAimdFields): void
287
292
  /** Parse / render error */
288
293
  (e: "error", message: string): void
294
+ (e: "navigate-field", fieldKey: string): void
289
295
  /** Local record validation completed. */
290
296
  (e: "validation", result: AimdRecorderValidationResult): void
291
297
 
@@ -332,7 +338,8 @@ const autoServerAssignerSignatures = new Map<string, string>()
332
338
  let autoServerAssignerScheduled = false
333
339
 
334
340
  const resolvedLocale = computed(() => resolveAimdRecorderLocale(props.locale))
335
- provide(fieldDisplayKey, computed(() => props.fieldDisplay))
341
+ const inPanel = computed(() => props.layout === "field-panel")
342
+ provide(fieldDisplayKey, computed(() => inPanel.value ? "panel" : props.fieldDisplay))
336
343
  const resolvedMessages = computed(() => createAimdRecorderMessages(resolvedLocale.value, props.messages))
337
344
  const resolvedTypePlugins = computed(() => createAimdTypePlugins(props.typePlugins))
338
345
  const resolvedServerAssigners = computed(() => props.serverAssigners ?? props.assigners)
@@ -607,7 +614,7 @@ const serverAssignerByAssignedField = computed(() => (
607
614
 
608
615
  function createEnumOptions(values: unknown[]): NonNullable<AimdFieldMeta["enumOptions"]> {
609
616
  return values.map(value => ({
610
- label: String(value),
617
+ label: typeof value === "boolean" ? resolvedMessages.value.boolean[value ? 'true' : 'false'] : String(value),
611
618
  value,
612
619
  }))
613
620
  }
@@ -678,6 +685,11 @@ const requiredFieldKeys = computed(() => getAimdRequiredFieldKeys(extractedField
678
685
  fieldMeta: effectiveFieldMeta.value,
679
686
  schema: props.validationSchema,
680
687
  }))
688
+ const markOptionalInputs = computed(() => {
689
+ const vars = extractedFields.value.var_definitions ?? []
690
+ const optional = vars.filter(field => !requiredFieldKeys.value.has(`var:${field.id}`)).length
691
+ return optional > 0 && optional < vars.length - optional
692
+ })
681
693
  const effectiveFieldState = computed<Record<string, AimdFieldState>>(() => {
682
694
  const keys = new Set([
683
695
  ...Object.keys(internalAssignerFieldState.value),
@@ -1370,6 +1382,7 @@ function renderInlineVar(node: AimdVarNode): VNode {
1370
1382
  messages: resolvedMessages.value,
1371
1383
  fieldMeta: meta,
1372
1384
  required,
1385
+ markOptional: markOptionalInputs.value,
1373
1386
  displayValue,
1374
1387
  inputKind,
1375
1388
  typePlugin,
@@ -1835,12 +1848,42 @@ function renderInlineQuiz(node: AimdQuizNode): VNode {
1835
1848
  // Rebuild pipeline
1836
1849
  // ---------------------------------------------------------------------------
1837
1850
 
1851
+ function buildPanelFields(nodes: Map<string, AimdVarNode>): VNode[] {
1852
+ const vars = props.panelVariables ?? [...nodes.keys()]
1853
+ return [...new Set(vars)].map(id => {
1854
+ const node: AimdVarNode = nodes.get(id) ?? { type: "aimd", fieldType: "var", scope: "var", id, raw: "" }
1855
+ const key = `var:${id}`
1856
+ const title = effectiveFieldMeta.value[key]?.title || String(node.definition?.kwargs?.title || id)
1857
+ const required = requiredFieldKeys.value.has(key)
1858
+ return h("div", { key, class: "aimd-panel-field", role: "group", "aria-label": title, "data-panel-field": key }, [
1859
+ h("div", { class: "aimd-panel-label" }, [
1860
+ title, h("small", required ? resolvedMessages.value.common.required : resolvedMessages.value.common.optional),
1861
+ ]),
1862
+ renderInlineVar(node),
1863
+ ])
1864
+ })
1865
+ }
1866
+
1867
+ const panelOutline = computed(() => {
1868
+ const fields = extractedFields.value
1869
+ const steps = new Map(fields.step_hierarchy?.map(field => [field.id, field.title]))
1870
+ const checks = new Map(fields.check_definitions?.map(field => [field.id, field.title]))
1871
+ return [
1872
+ ...fields.var_table.map(field => ({ key: `var_table:${field.id}`, title: field.title || field.id })),
1873
+ ...fields.step.map(id => ({ key: `step:${id}`, title: steps.get(id) || id })),
1874
+ ...fields.check.map(id => ({ key: `check:${id}`, title: checks.get(id) || id })),
1875
+ ...fields.quiz.map(field => ({ key: `quiz:${field.id}`, title: field.title || field.id })),
1876
+ ]
1877
+ })
1878
+
1838
1879
  async function rebuildInlineNodes(
1839
1880
  expectedRequestId?: number,
1840
1881
  focusSnapshot?: FocusSnapshot | null,
1841
1882
  expectedInlineRequestId?: number,
1842
1883
  ) {
1843
1884
  recordInitializedDuringRender = false
1885
+ const panelNodes = new Map<string, AimdVarNode>()
1886
+ const panel = inPanel.value
1844
1887
  const rendered = await renderToVue(props.content || "", {
1845
1888
  locale: resolvedLocale.value,
1846
1889
  groupStepBodies: true,
@@ -1857,11 +1900,15 @@ async function rebuildInlineNodes(
1857
1900
  pre: codeBlockPreRenderer,
1858
1901
  },
1859
1902
  aimdRenderers: {
1860
- var: node => renderInlineVar(node as AimdVarNode),
1861
- var_table: node => renderInlineVarTable(node as AimdVarTableNode),
1862
- step: (node, _ctx, children) => renderInlineStep(node as AimdStepNode, children),
1863
- check: (node, _ctx, children) => renderInlineCheck(node as AimdCheckNode, children),
1864
- quiz: node => renderInlineQuiz(node as AimdQuizNode),
1903
+ var: node => {
1904
+ if (!panel) return renderInlineVar(node as AimdVarNode)
1905
+ if (!panelNodes.has(node.id)) panelNodes.set(node.id, node as AimdVarNode)
1906
+ return h("span")
1907
+ },
1908
+ var_table: node => panel ? h("span") : renderInlineVarTable(node as AimdVarTableNode),
1909
+ step: (node, _ctx, children) => panel ? h("span") : renderInlineStep(node as AimdStepNode, children),
1910
+ check: (node, _ctx, children) => panel ? h("span") : renderInlineCheck(node as AimdCheckNode, children),
1911
+ quiz: node => panel ? h("span") : renderInlineQuiz(node as AimdQuizNode),
1865
1912
  },
1866
1913
  })
1867
1914
 
@@ -1872,7 +1919,7 @@ async function rebuildInlineNodes(
1872
1919
  return
1873
1920
  }
1874
1921
 
1875
- inlineNodes.value = rendered.nodes
1922
+ inlineNodes.value = panel ? buildPanelFields(panelNodes) : rendered.nodes
1876
1923
  await nextTick()
1877
1924
  restoreFocusSnapshot(contentRoot.value, focusSnapshot ?? null)
1878
1925
 
@@ -2036,7 +2083,7 @@ watch(
2036
2083
  )
2037
2084
 
2038
2085
  watch(
2039
- () => props.fieldDisplay,
2086
+ () => [props.fieldDisplay, props.layout, props.panelVariables],
2040
2087
  () => {
2041
2088
  // Input events keep native controls current without rebuilding every keystroke.
2042
2089
  // Refresh their VNode props before switching the presentation of those controls.
@@ -2067,6 +2114,7 @@ defineExpose({
2067
2114
  validateField,
2068
2115
  clearValidation,
2069
2116
  focusFirstInvalidField,
2117
+ focusField: focusInvalidField,
2070
2118
  runClientAssigner: clientAssignerRunner.triggerClientAssigner,
2071
2119
  runManualClientAssigners: clientAssignerRunner.triggerManualClientAssigners,
2072
2120
  startCollector: collectorRuntime.start,
@@ -2075,12 +2123,12 @@ defineExpose({
2075
2123
  </script>
2076
2124
 
2077
2125
  <template>
2078
- <div class="aimd-protocol-recorder" :class="{ 'aimd-protocol-recorder--compact': fieldDisplay === 'compact' }">
2126
+ <div class="aimd-protocol-recorder" :class="{ 'aimd-protocol-recorder--compact': inPanel || fieldDisplay === 'compact', 'aimd-recorder-panel': inPanel }">
2079
2127
  <div v-if="renderError" class="aimd-protocol-recorder__error">{{ renderError }}</div>
2080
2128
 
2081
2129
  <template v-else>
2082
2130
  <AimdRecorderSearchToolbar
2083
- v-if="showRecordSearchToolbar"
2131
+ v-if="!inPanel && showRecordSearchToolbar"
2084
2132
  v-model:field-key="recordSearch.fieldKey.value"
2085
2133
  v-model:query="recordSearch.query.value"
2086
2134
  :field-refs="recordSearch.fieldRefs.value"
@@ -2095,7 +2143,7 @@ defineExpose({
2095
2143
  @previous="recordSearch.focusPreviousMatch"
2096
2144
  />
2097
2145
 
2098
- <div v-if="showProtocolTimingSummary" class="aimd-protocol-recorder__timing">
2146
+ <div v-if="!inPanel && showProtocolTimingSummary" class="aimd-protocol-recorder__timing">
2099
2147
  <span
2100
2148
  v-if="protocolEstimatedDurationMs > 0"
2101
2149
  class="aimd-protocol-recorder__timing-pill aimd-protocol-recorder__timing-pill--estimate"
@@ -2114,7 +2162,10 @@ defineExpose({
2114
2162
  <InlineNodesOutlet :nodes="inlineNodes" />
2115
2163
  </div>
2116
2164
 
2117
- <div v-else class="aimd-protocol-recorder__empty">{{ resolvedMessages.common.emptyContent }}</div>
2165
+ <div v-else-if="!inPanel || !panelOutline.length" class="aimd-protocol-recorder__empty">{{ resolvedMessages.common.emptyContent }}</div>
2166
+ <div v-if="inPanel && panelOutline.length" class="aimd-panel-outline">
2167
+ <button v-for="entry in panelOutline" :key="entry.key" type="button" @click="emit('navigate-field', entry.key)">{{ entry.title }}</button>
2168
+ </div>
2118
2169
  </template>
2119
2170
  </div>
2120
2171
  </template>
@@ -782,6 +782,11 @@ defineExpose({
782
782
  padding: 3px 5px;
783
783
  }
784
784
 
785
+ /* The first inline field has no preceding line for its floating edit controls. */
786
+ .aimd-recorder-wysiwyg-surface :deep(.ProseMirror > :first-child:has(.aimd-recorder-wysiwyg-node--inline)) {
787
+ padding-block-start: 2rem;
788
+ }
789
+
785
790
  .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__chrome--block) {
786
791
  top: 10px;
787
792
  right: 10px;
@@ -497,6 +497,7 @@ export default defineComponent({
497
497
  messages: { type: Object as PropType<AimdRecorderMessages>, required: true },
498
498
  fieldMeta: { type: Object as PropType<AimdFieldMeta | undefined>, default: undefined },
499
499
  required: { type: Boolean, default: false },
500
+ markOptional: { type: Boolean, default: false },
500
501
  displayValue: { type: [String, Number] as PropType<string | number>, default: "" },
501
502
  inputKind: { type: String as PropType<AimdVarInputKind>, required: true },
502
503
  typePlugin: { type: Object as PropType<AimdTypePlugin | undefined>, default: undefined },
@@ -520,6 +521,7 @@ export default defineComponent({
520
521
  const checkboxValue = ref(toBooleanValue(props.value))
521
522
  watch(() => props.value, value => { checkboxValue.value = toBooleanValue(value) })
522
523
  const fileUploadError = ref("")
524
+ const uploading = ref(false)
523
525
  const csvPreview = ref<CsvPreviewState | null>(null)
524
526
  const resolvedFileInfo = ref<FileDisplayInfo | null>(null)
525
527
  const lastSelectedFileInfo = ref<FileDisplayInfo | null>(null)
@@ -553,7 +555,10 @@ export default defineComponent({
553
555
  }
554
556
  if (scalarListJsonDraft.value !== null) {
555
557
  const parsedDraft = parseScalarListJsonValue(scalarListJsonDraft.value, itemType)
556
- if (parsedDraft.ok && !areArraysEqual(persistedItems, parsedDraft.value)) {
558
+ const nullMismatch = isNullableVarType(props.node.definition?.type) &&
559
+ (parsedDraft.ok || scalarListJsonDraft.value.trim() === 'null') &&
560
+ (scalarListJsonDraft.value.trim() === 'null') !== (value === null)
561
+ if (nullMismatch || (parsedDraft.ok && !areArraysEqual(persistedItems, parsedDraft.value))) {
557
562
  scalarListJsonDraft.value = null
558
563
  scalarListJsonError.value = ""
559
564
  }
@@ -709,11 +714,12 @@ export default defineComponent({
709
714
  const input = event.target as HTMLInputElement
710
715
  const file = input.files?.[0]
711
716
  input.value = ""
712
- if (!file) {
717
+ if (!file || uploading.value) {
713
718
  return
714
719
  }
715
720
 
716
721
  fileUploadError.value = ""
722
+ uploading.value = true
717
723
  const fileConfig = getFileInputConfig(type, node.definition?.kwargs, meta)
718
724
  try {
719
725
  const uploadedValue = props.uploadFile
@@ -743,6 +749,8 @@ export default defineComponent({
743
749
  })
744
750
  } catch {
745
751
  fileUploadError.value = props.messages.file.uploadFailed
752
+ } finally {
753
+ uploading.value = false
746
754
  }
747
755
  }
748
756
 
@@ -766,9 +774,12 @@ export default defineComponent({
766
774
  }
767
775
 
768
776
  const renderVarLabel = (headerAction?: VNode | null): VNode | null => {
769
- if (fieldDisplay.value === 'compact') {
777
+ const optional = props.markOptional && !props.required
778
+ ? h('span', { class: 'aimd-field__optional-marker' }, props.messages.common.optional)
779
+ : null
780
+ if (fieldDisplay.value !== 'detailed') {
770
781
  const actions = renderHeaderAssignerActions(headerAction)
771
- return actions ? h('span', { class: 'aimd-rec-inline__compact-actions' }, [actions]) : null
782
+ return actions || optional ? h('span', { class: 'aimd-rec-inline__compact-actions' }, [optional, actions]) : null
772
783
  }
773
784
  const metaTitle = normalizeMetaString(meta?.title)
774
785
  const definitionTitle = getAimdFieldTitle(node.definition)
@@ -800,7 +811,7 @@ export default defineComponent({
800
811
  }, [
801
812
  h("span", { class: "aimd-field__title-row" }, [
802
813
  h("span", { class: "aimd-field__title", title: displayTitle }, displayTitle),
803
- props.required ? h(AimdRequiredMarker, { label: props.messages.common.required }) : null,
814
+ props.required && !props.markOptional ? h(AimdRequiredMarker, { label: props.messages.common.required }) : optional,
804
815
  ]),
805
816
  hasCustomTitle ? h("span", { class: "aimd-field__key", title: id }, id) : null,
806
817
  renderFieldMetadataPopover(help),
@@ -839,7 +850,7 @@ export default defineComponent({
839
850
  const showEmptyEnumOption = emptyEnumValue === null || selectedEnumValue === ""
840
851
  const emptyEnumLabel = emptyEnumValue === null
841
852
  ? getAimdRecorderEmptyValueLabel(props.messages)
842
- : placeholder ?? ""
853
+ : placeholder || props.messages.common.chooseValue
843
854
  return h("span", {
844
855
  class: [
845
856
  "aimd-rec-inline aimd-rec-inline--var-stacked aimd-field-wrapper",
@@ -923,7 +934,7 @@ export default defineComponent({
923
934
  },
924
935
  onBlur: onVarBlur,
925
936
  }),
926
- fieldDisplay.value === 'compact'
937
+ fieldDisplay.value !== 'detailed'
927
938
  ? h('span', { class: 'aimd-rec-inline__boolean-state' }, checkboxValue.value ? props.messages.boolean.true : props.messages.boolean.false)
928
939
  : null,
929
940
  ]),
@@ -1048,6 +1059,11 @@ export default defineComponent({
1048
1059
  const displayInfo = resolvedFileInfo.value
1049
1060
  const fileName = displayInfo?.name || getFileDisplayName(props.value)
1050
1061
  const hasFileValue = Boolean(fileId || fileName)
1062
+ const panel = fieldDisplay.value === "panel"
1063
+ const chooseLabel = fileConfig.kind === "image" ? props.messages.file.uploadPhoto : props.messages.file.choose
1064
+ const extensions = fileConfig.accept?.split(",").map(part => part.trim()).filter(part => part.startsWith("."))
1065
+ const formats = extensions?.map(ext => ext.slice(1).toUpperCase()).join(" / ")
1066
+ const panelLabel = formats ? `${chooseLabel} (${formats})` : chooseLabel
1051
1067
  const displayName = fileName || (hasFileValue ? props.messages.file.selected : placeholder || props.messages.file.choose)
1052
1068
  const resolvedUrl = displayInfo?.url || (fileId && props.resolveFile
1053
1069
  ? props.resolveFile(fileId)
@@ -1061,7 +1077,7 @@ export default defineComponent({
1061
1077
  "aria-label": accessibleLabel,
1062
1078
  type: "file",
1063
1079
  accept: fileConfig.accept,
1064
- disabled,
1080
+ disabled: disabled || uploading.value,
1065
1081
  onChange: onFileChange,
1066
1082
  onBlur: onVarBlur,
1067
1083
  })
@@ -1197,7 +1213,13 @@ export default defineComponent({
1197
1213
  ])
1198
1214
  : null,
1199
1215
  ])
1200
- : h("label", {
1216
+ : panel ? h("span", { class: "aimd-panel-upload" }, [
1217
+ fileInput,
1218
+ h("button", {
1219
+ type: "button", disabled: disabled || uploading.value,
1220
+ onClick: (event: MouseEvent) => (event.currentTarget as HTMLElement).parentElement?.querySelector("input")?.click(),
1221
+ }, panelLabel),
1222
+ ]) : h("label", {
1201
1223
  class: [
1202
1224
  "aimd-rec-file-field__trigger",
1203
1225
  disabled ? "aimd-rec-file-field__trigger--disabled" : undefined,
@@ -1208,6 +1230,7 @@ export default defineComponent({
1208
1230
  fileBadge,
1209
1231
  fileTitle,
1210
1232
  ]),
1233
+ uploading.value ? h("span", { role: "status" }, props.messages.file.uploading) : null,
1211
1234
  fileUploadError.value
1212
1235
  ? h("span", { class: "aimd-rec-file-field__error" }, fileUploadError.value)
1213
1236
  : null,
@@ -1303,10 +1326,16 @@ export default defineComponent({
1303
1326
  }
1304
1327
  const getScalarListJsonDraft = () => (
1305
1328
  scalarListJsonDraft.value
1306
- ?? formatScalarListJsonValue(scalarListDraftRows.value ?? props.value, scalarListItemType)
1329
+ ?? (props.value === null && isNullableVarType(type) ? 'null' : formatScalarListJsonValue(scalarListDraftRows.value ?? props.value, scalarListItemType))
1307
1330
  )
1308
1331
  const emitScalarListJsonDraft = (rawValue: string) => {
1309
1332
  scalarListJsonDraft.value = rawValue
1333
+ if (rawValue.trim() === 'null' && isNullableVarType(type)) {
1334
+ scalarListJsonError.value = ''
1335
+ scalarListDraftRows.value = null
1336
+ emit('change', { id, value: null, type, inputKind })
1337
+ return
1338
+ }
1310
1339
  const parsed = parseScalarListJsonValue(rawValue, scalarListItemType)
1311
1340
  if (!parsed.ok) {
1312
1341
  scalarListJsonError.value = getScalarListJsonErrorMessage(parsed.error)
@@ -1325,13 +1354,8 @@ export default defineComponent({
1325
1354
  if (scalarListMode.value === mode) {
1326
1355
  return
1327
1356
  }
1328
- if (mode === "json") {
1329
- scalarListJsonDraft.value = formatScalarListJsonValue(scalarListDraftRows.value ?? props.value, scalarListItemType)
1330
- scalarListJsonError.value = ""
1331
- } else {
1332
- scalarListJsonDraft.value = null
1333
- scalarListJsonError.value = ""
1334
- }
1357
+ scalarListJsonDraft.value = null
1358
+ scalarListJsonError.value = ""
1335
1359
  scalarListMode.value = mode
1336
1360
  }
1337
1361
  const modeButton = (mode: ScalarListEditMode, label: string) => h("button", {
@@ -695,7 +695,13 @@ describe('field rendering nullable defaults', () => {
695
695
  expect(rendering.getVarInitialValue(node('int | None') as never, 'int | None', 'var:value')).toBeNull()
696
696
  expect(rendering.getVarInitialValue(node('date | None') as never, 'date | None', 'var:value')).toBeNull()
697
697
  expect(rendering.getVarInitialValue(node('str | None') as never, 'str | None', 'var:value')).toBeNull()
698
- expect(rendering.getVarInitialValue(node('list[str] | None') as never, 'list[str] | None', 'var:value')).toEqual([])
698
+ const type = 'list[str] | None'
699
+ expect(rendering.getVarInitialValue(node(type) as never, type, 'var:value')).toBeNull()
700
+ for (const value of [null, [], ['tag']]) {
701
+ const withDefault = { ...node(type), definition: { id: 'value', type, default: value } }
702
+ expect(rendering.getVarInitialValue(withDefault as never, type, 'var:value')).toEqual(value)
703
+ expect(rendering.normalizeVarValue(node(type) as never, type, 'var:value', value, 'scalar-list')).toEqual(value)
704
+ }
699
705
  })
700
706
  })
701
707
 
@@ -1,7 +1,7 @@
1
1
  import { inject, ref, type InjectionKey, type Ref } from 'vue'
2
2
 
3
- export const fieldDisplayKey: InjectionKey<Readonly<Ref<'compact' | 'detailed'>>> = Symbol('aimd-field-display')
3
+ export const fieldDisplayKey: InjectionKey<Readonly<Ref<'compact' | 'detailed' | 'panel'>>> = Symbol('aimd-field-display')
4
4
 
5
5
  export function useFieldPresentation() {
6
- return inject(fieldDisplayKey, ref<'compact' | 'detailed'>('detailed'))
6
+ return inject(fieldDisplayKey, ref<'compact' | 'detailed' | 'panel'>('detailed'))
7
7
  }
@@ -222,7 +222,7 @@ export function useFieldRendering(options: FieldRenderingOptions) {
222
222
  typePlugin,
223
223
  })
224
224
  if (inputKind === "boolean-select") return null
225
- if (isNullableVarType(type) && inputKind !== "scalar-list" && inputKind !== "checkbox") return null
225
+ if (isNullableVarType(type) && inputKind !== "checkbox") return null
226
226
  if (inputKind === "multi-select") return []
227
227
  if (inputKind === "checkbox") return false
228
228
  if (inputKind === "scalar-list") return []
@@ -252,6 +252,7 @@ export function useFieldRendering(options: FieldRenderingOptions) {
252
252
  }
253
253
 
254
254
  if (inputKind === "scalar-list") {
255
+ if (value == null && isNullableVarType(type)) return null
255
256
  return normalizeScalarListInputItems(
256
257
  getScalarListInputItems(value),
257
258
  getScalarListItemType(type) ?? "string",