@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
@@ -11,9 +11,9 @@ import {
11
11
  } from "@airalogy/aimd-core/utils"
12
12
  import type { AimdFieldMeta, AimdFieldState } from "../types"
13
13
  import type { AimdRecorderMessages } from "../locales"
14
- import { getAimdRecorderScopeLabel } from "../locales"
14
+ import { getAimdRecorderEmptyValueLabel, getAimdRecorderScopeLabel } from "../locales"
15
15
  import { getVarTableColumns, getVarTableRowKey } from "../composables/useVarTableDragDrop"
16
- import { getVarEnumSelectValue, getVarEnumValueFromSelectValue } from "../composables/useVarHelpers"
16
+ import { getVarEnumSelectValue, getVarEnumValueFromSelectValue, isNullableVarType } from "../composables/useVarHelpers"
17
17
 
18
18
  function renderTrashIcon(): VNode {
19
19
  return h("svg", {
@@ -352,6 +352,11 @@ export default defineComponent({
352
352
 
353
353
  if (enumOptions.length > 0) {
354
354
  const selectedEnumValue = getVarEnumSelectValue(enumOptions, row[column])
355
+ const emptyEnumValue = isNullableVarType(getColumnDefinition(column)?.type) ? null : ""
356
+ const showEmptyEnumOption = emptyEnumValue === null || selectedEnumValue === ""
357
+ const emptyEnumLabel = emptyEnumValue === null
358
+ ? getAimdRecorderEmptyValueLabel(props.messages)
359
+ : placeholder
355
360
  return h("select", {
356
361
  "data-rec-focus-key": focusKey,
357
362
  class: [className, "aimd-rec-enum-select"],
@@ -362,14 +367,14 @@ export default defineComponent({
362
367
  tableName,
363
368
  column,
364
369
  rowIndex,
365
- value: getVarEnumValueFromSelectValue(enumOptions, (event.target as HTMLSelectElement).value),
370
+ value: getVarEnumValueFromSelectValue(enumOptions, (event.target as HTMLSelectElement).value, emptyEnumValue),
366
371
  row,
367
372
  })
368
373
  },
369
374
  onBlur: () => emit("cell-blur", { tableName, column }),
370
375
  }, [
371
- selectedEnumValue === ""
372
- ? h("option", { value: "" }, placeholder)
376
+ showEmptyEnumOption
377
+ ? h("option", { value: "" }, emptyEnumLabel)
373
378
  : null,
374
379
  ...enumOptions.map((option, optionIndex) => h("option", {
375
380
  key: `${optionIndex}:${String(option.value)}`,
@@ -1,9 +1,15 @@
1
1
  import { afterEach, describe, expect, it, vi } from 'vitest'
2
+ import { useFieldRendering } from '../useFieldRendering'
2
3
 
3
4
  import {
4
5
  normalizeVarTypeName,
5
6
  getVarInputKind,
7
+ getScalarListInputItems,
8
+ getScalarListItemType,
9
+ isNullableVarType,
10
+ isScalarListVarType,
6
11
  isStructuredVarType,
12
+ normalizeScalarListInputItems,
7
13
  unwrapStructuredValue,
8
14
  toBooleanValue,
9
15
  toDateValue,
@@ -12,12 +18,14 @@ import {
12
18
  formatDateForInput,
13
19
  getFileDisplayName,
14
20
  getFileInputConfig,
21
+ getVarEnumValueFromSelectValue,
15
22
  getVarInputDisplayValue,
16
23
  parseVarInputValue,
17
24
  getNumericConstraintViolation,
18
25
  getNumericFieldConstraints,
19
26
  getNumericInputAttributes,
20
27
  calculateVarStackWidth,
28
+ applyVarStackWidth,
21
29
  syncAutoWrapTextareaHeight,
22
30
  measureVarLabelWidth,
23
31
  createSelectedFileValue,
@@ -77,6 +85,18 @@ describe('getVarInputKind', () => {
77
85
  expect(getVarInputKind('checkbox')).toBe('checkbox')
78
86
  })
79
87
 
88
+ it('returns "boolean-select" for nullable boolean types', () => {
89
+ expect(getVarInputKind('bool | None')).toBe('boolean-select')
90
+ expect(getVarInputKind('None | bool')).toBe('boolean-select')
91
+ expect(getVarInputKind('Optional[bool]')).toBe('boolean-select')
92
+ expect(getVarInputKind('typing.Optional[boolean]')).toBe('boolean-select')
93
+ })
94
+
95
+ it('unwraps nullable annotations for built-in input kinds', () => {
96
+ expect(getVarInputKind('int | None')).toBe('number')
97
+ expect(getVarInputKind('Optional[datetime]')).toBe('datetime')
98
+ })
99
+
80
100
  it('returns "date" for date', () => {
81
101
  expect(getVarInputKind('date')).toBe('date')
82
102
  })
@@ -101,9 +121,23 @@ describe('getVarInputKind', () => {
101
121
  expect(getVarInputKind('airalogymarkdown')).toBe('textarea')
102
122
  })
103
123
 
104
- it('returns "textarea" for structured list and object types', () => {
124
+ it('returns "scalar-list" for scalar list types', () => {
125
+ expect(getVarInputKind('list[str]')).toBe('scalar-list')
126
+ expect(getVarInputKind('list[str] | None')).toBe('scalar-list')
127
+ expect(getVarInputKind('Optional[list[str]]')).toBe('scalar-list')
128
+ expect(getVarInputKind('typing.List[str]')).toBe('scalar-list')
129
+ expect(getVarInputKind('array[string]')).toBe('scalar-list')
130
+ expect(getVarInputKind('str[]')).toBe('scalar-list')
131
+ expect(getVarInputKind('list[int]')).toBe('scalar-list')
132
+ expect(getVarInputKind('list[float]')).toBe('scalar-list')
133
+ expect(getVarInputKind('array[number]')).toBe('scalar-list')
134
+ expect(getVarInputKind('int[]')).toBe('scalar-list')
135
+ })
136
+
137
+ it('returns "textarea" for structured non-scalar list and object types', () => {
105
138
  expect(getVarInputKind('list')).toBe('textarea')
106
- expect(getVarInputKind('list[str]')).toBe('textarea')
139
+ expect(getVarInputKind('list[bool]')).toBe('textarea')
140
+ expect(getVarInputKind('list[dict[str, int]]')).toBe('textarea')
107
141
  expect(getVarInputKind('dict[str, int]')).toBe('textarea')
108
142
  expect(getVarInputKind('json')).toBe('textarea')
109
143
  expect(getVarInputKind('Listener')).toBe('text')
@@ -451,9 +485,20 @@ describe('getVarInputDisplayValue', () => {
451
485
  })
452
486
 
453
487
  it('pretty-prints structured list and object values', () => {
454
- expect(getVarInputDisplayValue(['a', 'b'], 'textarea', { type: 'list[str]' })).toBe(JSON.stringify(['a', 'b'], null, 2))
488
+ expect(getVarInputDisplayValue([1, 2], 'textarea', { type: 'list[int]' })).toBe(JSON.stringify([1, 2], null, 2))
455
489
  expect(getVarInputDisplayValue({ a: 1 }, 'textarea', { type: 'dict[str, int]' })).toBe(JSON.stringify({ a: 1 }, null, 2))
456
490
  })
491
+
492
+ it('formats scalar list values as compact JSON for helper consumers', () => {
493
+ expect(getVarInputDisplayValue([' a ', 'b', ''], 'scalar-list', { type: 'list[str]' })).toBe(JSON.stringify(['a', 'b']))
494
+ expect(getVarInputDisplayValue(['1', '2', ''], 'scalar-list', { type: 'list[int]' })).toBe(JSON.stringify([1, 2]))
495
+ })
496
+
497
+ it('formats nullable boolean values for a tri-state select', () => {
498
+ expect(getVarInputDisplayValue(true, 'boolean-select', { type: 'bool | None' })).toBe('true')
499
+ expect(getVarInputDisplayValue(false, 'boolean-select', { type: 'bool | None' })).toBe('false')
500
+ expect(getVarInputDisplayValue(null, 'boolean-select', { type: 'bool | None' })).toBe('')
501
+ })
457
502
  })
458
503
 
459
504
  // ---------------------------------------------------------------------------
@@ -481,28 +526,138 @@ describe('parseVarInputValue', () => {
481
526
  expect(parseVarInputValue('', 'int', 'number')).toBe('')
482
527
  })
483
528
 
529
+ it('returns null for empty nullable number input', () => {
530
+ expect(parseVarInputValue('', 'int | None', 'number')).toBeNull()
531
+ })
532
+
533
+ it('returns null for empty nullable date, time, and text inputs', () => {
534
+ expect(parseVarInputValue('', 'date | None', 'date')).toBeNull()
535
+ expect(parseVarInputValue('', 'datetime | None', 'datetime')).toBeNull()
536
+ expect(parseVarInputValue('', 'time | None', 'time')).toBeNull()
537
+ expect(parseVarInputValue('', 'str | None', 'text')).toBeNull()
538
+ })
539
+
540
+ it('parses nullable boolean select values', () => {
541
+ expect(parseVarInputValue('', 'bool | None', 'boolean-select')).toBeNull()
542
+ expect(parseVarInputValue('true', 'bool | None', 'boolean-select')).toBe(true)
543
+ expect(parseVarInputValue('false', 'bool | None', 'boolean-select')).toBe(false)
544
+ })
545
+
484
546
  it('normalizes datetime input', () => {
485
547
  const result = parseVarInputValue('2024-06-15T10:30', undefined, 'datetime')
486
548
  expect(typeof result).toBe('string')
487
549
  })
488
550
 
489
551
  it('parses JSON input for structured list types', () => {
490
- expect(parseVarInputValue('["a", "b"]', 'list[str]', 'textarea')).toEqual(['a', 'b'])
491
- expect(parseVarInputValue('not json', 'list[str]', 'textarea')).toBe('not json')
552
+ expect(parseVarInputValue('[1, 2]', 'list[int]', 'textarea')).toEqual([1, 2])
553
+ expect(parseVarInputValue('not json', 'list[int]', 'textarea')).toBe('not json')
554
+ })
555
+
556
+ it('parses scalar-list input into a clean scalar array', () => {
557
+ expect(parseVarInputValue('["a", " b ", ""]', 'list[str]', 'scalar-list')).toEqual(['a', 'b'])
558
+ expect(parseVarInputValue('a\nb\n', 'list[str]', 'scalar-list')).toEqual(['a', 'b'])
559
+ expect(parseVarInputValue('["1", "2", ""]', 'list[int]', 'scalar-list')).toEqual([1, 2])
560
+ expect(parseVarInputValue('1\n2.5\n', 'list[float]', 'scalar-list')).toEqual([1, 2.5])
561
+ expect(parseVarInputValue('1.2', 'list[int]', 'scalar-list')).toEqual(['1.2'])
562
+ })
563
+ })
564
+
565
+ // ---------------------------------------------------------------------------
566
+ // enum helpers
567
+ // ---------------------------------------------------------------------------
568
+
569
+ describe('enum helpers', () => {
570
+ it('uses caller-provided empty values for nullable enum selects', () => {
571
+ const options = [{ label: 'A', value: 'a' }]
572
+ expect(getVarEnumValueFromSelectValue(options, '0', null)).toBe('a')
573
+ expect(getVarEnumValueFromSelectValue(options, '', null)).toBeNull()
574
+ expect(getVarEnumValueFromSelectValue(options, '')).toBe('')
575
+ })
576
+ })
577
+
578
+ // ---------------------------------------------------------------------------
579
+ // field rendering value defaults
580
+ // ---------------------------------------------------------------------------
581
+
582
+ describe('field rendering nullable defaults', () => {
583
+ const rendering = useFieldRendering({
584
+ readonly: () => false,
585
+ currentUserName: () => undefined,
586
+ now: () => new Date('2024-01-01T00:00:00Z'),
587
+ fieldMeta: () => ({}),
588
+ fieldState: () => ({}),
589
+ typePlugins: () => [],
590
+ wrapField: () => undefined,
591
+ })
592
+
593
+ it('initializes nullable scalar fields as null instead of empty strings', () => {
594
+ const node = (type: string) => ({
595
+ id: 'value',
596
+ type: 'aimd',
597
+ fieldType: 'var',
598
+ scope: 'var',
599
+ raw: '',
600
+ definition: { id: 'value', type },
601
+ })
602
+
603
+ expect(rendering.getVarInitialValue(node('int | None') as never, 'int | None', 'var:value')).toBeNull()
604
+ expect(rendering.getVarInitialValue(node('date | None') as never, 'date | None', 'var:value')).toBeNull()
605
+ expect(rendering.getVarInitialValue(node('str | None') as never, 'str | None', 'var:value')).toBeNull()
606
+ expect(rendering.getVarInitialValue(node('list[str] | None') as never, 'list[str] | None', 'var:value')).toEqual([])
492
607
  })
493
608
  })
494
609
 
495
610
  // ---------------------------------------------------------------------------
496
- // isStructuredVarType
611
+ // list type helpers
497
612
  // ---------------------------------------------------------------------------
498
613
 
499
- describe('isStructuredVarType', () => {
614
+ describe('list type helpers', () => {
615
+ it('detects nullable type annotations', () => {
616
+ expect(isNullableVarType('bool | None')).toBe(true)
617
+ expect(isNullableVarType('Optional[bool]')).toBe(true)
618
+ expect(isNullableVarType('bool')).toBe(false)
619
+ })
620
+
500
621
  it('detects explicit structured types without matching unrelated names', () => {
501
622
  expect(isStructuredVarType('list[str]')).toBe(true)
623
+ expect(isStructuredVarType('list[str] | None')).toBe(true)
502
624
  expect(isStructuredVarType('dict[str, int]')).toBe(true)
503
625
  expect(isStructuredVarType('object')).toBe(true)
504
626
  expect(isStructuredVarType('Listener')).toBe(false)
505
627
  })
628
+
629
+ it('detects only scalar-item list types as scalar-list controls', () => {
630
+ expect(isScalarListVarType('list[str]')).toBe(true)
631
+ expect(isScalarListVarType('list[str] | None')).toBe(true)
632
+ expect(isScalarListVarType('Optional[list[str]]')).toBe(true)
633
+ expect(isScalarListVarType('typing.List[str]')).toBe(true)
634
+ expect(isScalarListVarType('array[string]')).toBe(true)
635
+ expect(isScalarListVarType('list[int]')).toBe(true)
636
+ expect(isScalarListVarType('list[float]')).toBe(true)
637
+ expect(isScalarListVarType('array[number]')).toBe(true)
638
+ expect(isScalarListVarType('list[bool]')).toBe(false)
639
+ expect(isScalarListVarType('list[dict[str, int]]')).toBe(false)
640
+ expect(isScalarListVarType('list')).toBe(false)
641
+ })
642
+
643
+ it('resolves scalar list item types for supported scalar arrays', () => {
644
+ expect(getScalarListItemType('list[str]')).toBe('string')
645
+ expect(getScalarListItemType('str[]')).toBe('string')
646
+ expect(getScalarListItemType('list[int] | None')).toBe('int')
647
+ expect(getScalarListItemType('Optional[list[float]]')).toBe('float')
648
+ expect(getScalarListItemType('array[number]')).toBe('float')
649
+ expect(getScalarListItemType('list[bool]')).toBeUndefined()
650
+ expect(getScalarListItemType('list[dict[str, int]]')).toBeUndefined()
651
+ })
652
+
653
+ it('normalizes scalar-list values while preserving editable draft rows', () => {
654
+ expect(getScalarListInputItems(['a', 2, null])).toEqual(['a', '2', ''])
655
+ expect(getScalarListInputItems('["a", "b"]')).toEqual(['a', 'b'])
656
+ expect(getScalarListInputItems('a\nb')).toEqual(['a', 'b'])
657
+ expect(normalizeScalarListInputItems([' a ', '', 'b'])).toEqual(['a', 'b'])
658
+ expect(normalizeScalarListInputItems(['1', '', '2'], 'int')).toEqual([1, 2])
659
+ expect(normalizeScalarListInputItems(['1.5', 'x'], 'float')).toEqual([1.5, 'x'])
660
+ })
506
661
  })
507
662
 
508
663
  // ---------------------------------------------------------------------------
@@ -526,6 +681,58 @@ describe('calculateVarStackWidth', () => {
526
681
  const px = parseInt(result)
527
682
  expect(px).toBeGreaterThanOrEqual(160)
528
683
  })
684
+
685
+ it('keeps a scalar-list fallback stack width for non-DOM callers', () => {
686
+ const result = calculateVarStackWidth('x', 'scalar-list')
687
+ const px = parseInt(result)
688
+ expect(px).toBeGreaterThanOrEqual(220)
689
+ expect(px).toBeLessThan(420)
690
+ })
691
+ })
692
+
693
+ // ---------------------------------------------------------------------------
694
+ // applyVarStackWidth
695
+ // ---------------------------------------------------------------------------
696
+
697
+ describe('applyVarStackWidth', () => {
698
+ afterEach(() => {
699
+ document.body.innerHTML = ''
700
+ })
701
+
702
+ it('keeps scalar-list vars full width instead of measuring content width', () => {
703
+ const wrapper = document.createElement('span')
704
+ wrapper.className = 'aimd-rec-inline--var-stacked aimd-rec-inline--var-stacked--scalar-list'
705
+ const control = document.createElement('span')
706
+ control.className = 'aimd-rec-inline__scalar-list'
707
+ wrapper.appendChild(control)
708
+ document.body.appendChild(wrapper)
709
+
710
+ applyVarStackWidth(control, 'scalar-list')
711
+
712
+ expect(wrapper.style.width).toBe('100%')
713
+ expect(wrapper.style.maxWidth).toBe('100%')
714
+ })
715
+
716
+ it('lets stacked vars inside markdown tables size from content before wrapping', () => {
717
+ const table = document.createElement('table')
718
+ const row = document.createElement('tr')
719
+ const cell = document.createElement('td')
720
+ const wrapper = document.createElement('span')
721
+ wrapper.className = 'aimd-rec-inline--var-stacked'
722
+ const control = document.createElement('input')
723
+ control.className = 'aimd-rec-inline__input--stacked'
724
+
725
+ wrapper.appendChild(control)
726
+ cell.appendChild(wrapper)
727
+ row.appendChild(cell)
728
+ table.appendChild(row)
729
+ document.body.appendChild(table)
730
+
731
+ applyVarStackWidth(control, 'text')
732
+
733
+ expect(wrapper.style.width).toBe('max-content')
734
+ expect(wrapper.style.maxWidth).toBe('min(680px, 100%)')
735
+ })
529
736
  })
530
737
 
531
738
  // ---------------------------------------------------------------------------
@@ -44,6 +44,8 @@ export {
44
44
  export {
45
45
  normalizeVarTypeName,
46
46
  getVarInputKind,
47
+ getScalarListItemType,
48
+ isScalarListVarType,
47
49
  isStructuredVarType,
48
50
  unwrapStructuredValue,
49
51
  toBooleanValue,
@@ -58,12 +60,16 @@ export {
58
60
  getVarEnumSelectValue,
59
61
  getVarEnumValueFromSelectValue,
60
62
  getVarInputDisplayValue,
63
+ getScalarListInputItems,
64
+ normalizeScalarListInputItems,
61
65
  parseVarInputValue,
62
66
  calculateVarStackWidth,
63
67
  measureVarLabelWidth,
64
68
  measureSingleLineControlWidth,
65
69
  syncAutoWrapTextareaHeight,
66
70
  applyVarStackWidth,
71
+ type ScalarListInputItem,
72
+ type ScalarListItemType,
67
73
  } from './useVarHelpers'
68
74
  export type { AimdVarEnumOption, FileInputConfig, FileInputDisplayKind, VarInputKind } from './useVarHelpers'
69
75
 
@@ -6,6 +6,11 @@ import {
6
6
  normalizeVarTypeName,
7
7
  getVarInputKind,
8
8
  getVarInputDisplayValue,
9
+ getScalarListInputItems,
10
+ getScalarListItemType,
11
+ isNullableVarType,
12
+ normalizeScalarListInputItems,
13
+ toBooleanValue,
9
14
  unwrapStructuredValue,
10
15
  formatDateTimeWithTimezone,
11
16
  type VarInputKind,
@@ -216,7 +221,10 @@ export function useFieldRendering(options: FieldRenderingOptions) {
216
221
  fieldMeta: options.fieldMeta()?.[fieldKey],
217
222
  typePlugin,
218
223
  })
224
+ if (inputKind === "boolean-select") return null
225
+ if (isNullableVarType(type) && inputKind !== "scalar-list" && inputKind !== "checkbox") return null
219
226
  if (inputKind === "checkbox") return false
227
+ if (inputKind === "scalar-list") return []
220
228
  if (inputKind === "dna") return normalizeDnaSequenceValue(undefined)
221
229
  if (normalizedType === "currenttime") return formatDateTimeWithTimezone(resolveNowDate())
222
230
  if (normalizedType === "username" && typeof options.currentUserName() === "string") return options.currentUserName()
@@ -242,6 +250,26 @@ export function useFieldRendering(options: FieldRenderingOptions) {
242
250
  return normalizeDnaSequenceValue(value)
243
251
  }
244
252
 
253
+ if (inputKind === "scalar-list") {
254
+ return normalizeScalarListInputItems(
255
+ getScalarListInputItems(value),
256
+ getScalarListItemType(type) ?? "string",
257
+ )
258
+ }
259
+
260
+ if (inputKind === "boolean-select") {
261
+ if (value === null || typeof value === "undefined" || value === "") {
262
+ return null
263
+ }
264
+ return toBooleanValue(value)
265
+ }
266
+
267
+ if (isNullableVarType(type) && inputKind !== "checkbox") {
268
+ if (value === null || typeof value === "undefined" || value === "") {
269
+ return null
270
+ }
271
+ }
272
+
245
273
  return value
246
274
  }
247
275