@airalogy/aimd-recorder 1.20.0 → 1.22.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 (80) hide show
  1. package/README.md +5 -0
  2. package/README.zh-CN.md +5 -0
  3. package/dist/{AimdCodeField-BQUuM-EF.js → AimdCodeField-BN_0UQMx.js} +34 -32
  4. package/dist/{AimdDnaSequenceField-Cp0cgBYl.js → AimdDnaSequenceField-Bhj28fP8.js} +1 -1
  5. package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-DTdcoNs1.js → AimdEditor.vue_vue_type_style_index_0_lang-D7c01UqN.js} +1040 -976
  6. package/dist/{AimdMarkdownField-D4AEz_mB.js → AimdMarkdownField-GS15pv4z.js} +4 -4
  7. package/dist/{AimdMarkdownNoteField-CSGaShKi.js → AimdMarkdownNoteField-H9WP8tR6.js} +15 -15
  8. package/dist/aimd-recorder.css +1 -1
  9. package/dist/{arc-jL17V0L2.js → arc-B50G9-kH.js} +1 -1
  10. package/dist/{architectureDiagram-3BPJPVTR-CijadmFI.js → architectureDiagram-3BPJPVTR-D9mBEbpY.js} +2 -2
  11. package/dist/{blockDiagram-GPEHLZMM-BPqvb85_.js → blockDiagram-GPEHLZMM-Cs4swgto.js} +4 -4
  12. package/dist/{c4Diagram-AAUBKEIU-i4fqlMXu.js → c4Diagram-AAUBKEIU-C12HKS3r.js} +2 -2
  13. package/dist/{channel-DnnUQTdl.js → channel-D69VnjVz.js} +1 -1
  14. package/dist/{chunk-2J33WTMH-DKKEpdr1.js → chunk-2J33WTMH-oc-89G5c.js} +1 -1
  15. package/dist/{chunk-4BX2VUAB-WvuuiYYH.js → chunk-4BX2VUAB-BDJS9G3r.js} +1 -1
  16. package/dist/{chunk-55IACEB6-B_UkHTnd.js → chunk-55IACEB6-BPl3uHcA.js} +1 -1
  17. package/dist/{chunk-727SXJPM-CR6Pb04P.js → chunk-727SXJPM-pWe-vDGf.js} +5 -5
  18. package/dist/{chunk-AQP2D5EJ-B68Ie417.js → chunk-AQP2D5EJ-D-R5sIr1.js} +3 -3
  19. package/dist/{chunk-FMBD7UC4-CeCGT6rb.js → chunk-FMBD7UC4-bo6Qyom1.js} +1 -1
  20. package/dist/{chunk-ND2GUHAM-BYN-eC_q.js → chunk-ND2GUHAM-DQMvtYV7.js} +1 -1
  21. package/dist/{chunk-QZHKN3VN-BNSp120j.js → chunk-QZHKN3VN-DlCn3HON.js} +1 -1
  22. package/dist/{classDiagram-v2-Q7XG4LA2-Cgbn4w3f.js → classDiagram-4FO5ZUOK-DzUwWFwr.js} +2 -2
  23. package/dist/{classDiagram-4FO5ZUOK-Cgbn4w3f.js → classDiagram-v2-Q7XG4LA2-DzUwWFwr.js} +2 -2
  24. package/dist/components.js +3757 -2910
  25. package/dist/composables.js +84 -80
  26. package/dist/{cose-bilkent-S5V4N54A-TfrsQ2c3.js → cose-bilkent-S5V4N54A-BXLMzfpO.js} +1 -1
  27. package/dist/{dagre-BM42HDAG-BAyvB_JI.js → dagre-BM42HDAG-DHnofIh9.js} +3 -3
  28. package/dist/{diagram-2AECGRRQ-Bijq8bHO.js → diagram-2AECGRRQ-BqTTVPsm.js} +2 -2
  29. package/dist/{diagram-5GNKFQAL-B3ZuTuxm.js → diagram-5GNKFQAL-D5p1UVbw.js} +3 -3
  30. package/dist/{diagram-KO2AKTUF-DrqLeGCI.js → diagram-KO2AKTUF-Uuoz9cFn.js} +2 -2
  31. package/dist/{diagram-LMA3HP47-CCSQH8O0.js → diagram-LMA3HP47-W001U31X.js} +2 -2
  32. package/dist/{diagram-OG6HWLK6-DM5cUEjW.js → diagram-OG6HWLK6-DL516LDr.js} +3 -3
  33. package/dist/{erDiagram-TEJ5UH35-DQhmDdAF.js → erDiagram-TEJ5UH35-CCxgMb67.js} +4 -4
  34. package/dist/{flowDiagram-I6XJVG4X-DrqiPSHI.js → flowDiagram-I6XJVG4X-nXGdmC0O.js} +6 -6
  35. package/dist/{ganttDiagram-6RSMTGT7-DpX_Y2vA.js → ganttDiagram-6RSMTGT7-Bi9Ro7_Z.js} +2 -2
  36. package/dist/{gitGraphDiagram-PVQCEYII-3isOhIyZ.js → gitGraphDiagram-PVQCEYII-w1kNAy4E.js} +3 -3
  37. package/dist/{graph-C30SJlSk.js → graph-CpOkL_eZ.js} +1 -1
  38. package/dist/{index-Dtvv88SS.js → index-Dkrf2LJl.js} +51 -51
  39. package/dist/index.js +62 -58
  40. package/dist/{infoDiagram-5YYISTIA-Cr_MlPvz.js → infoDiagram-5YYISTIA-Bde_w9T1.js} +1 -1
  41. package/dist/{ishikawaDiagram-YF4QCWOH-DydyFn3h.js → ishikawaDiagram-YF4QCWOH-x5M1KR0l.js} +1 -1
  42. package/dist/{journeyDiagram-JHISSGLW-V_5MmeOu.js → journeyDiagram-JHISSGLW-CIDQP8Zm.js} +4 -4
  43. package/dist/{kanban-definition-UN3LZRKU-C_XXCuvp.js → kanban-definition-UN3LZRKU-CKgO7sG8.js} +2 -2
  44. package/dist/{layout-85j-z7Lr.js → layout-BZYprqYR.js} +2 -2
  45. package/dist/{linear-DMtodz-6.js → linear-ClSH2F_v.js} +1 -1
  46. package/dist/{mermaid.core-CkanUCyS.js → mermaid.core-CcRV6K2R.js} +34 -34
  47. package/dist/{mindmap-definition-RKZ34NQL-CyikmuF2.js → mindmap-definition-RKZ34NQL-s3h6uszV.js} +3 -3
  48. package/dist/{pieDiagram-4H26LBE5-CesqzEGg.js → pieDiagram-4H26LBE5-CgiazyWv.js} +3 -3
  49. package/dist/{quadrantDiagram-W4KKPZXB-BsPKPfNd.js → quadrantDiagram-W4KKPZXB-DCPVgHoW.js} +2 -2
  50. package/dist/record.js +19 -19
  51. package/dist/{requirementDiagram-4Y6WPE33-BwB1tQvi.js → requirementDiagram-4Y6WPE33-DE6F9oSB.js} +3 -3
  52. package/dist/{sankeyDiagram-5OEKKPKP-CfSNbWMY.js → sankeyDiagram-5OEKKPKP-DZZoFFr-.js} +1 -1
  53. package/dist/{sequenceDiagram-3UESZ5HK-DZZlUNys.js → sequenceDiagram-3UESZ5HK-DaYEOl60.js} +3 -3
  54. package/dist/{stateDiagram-AJRCARHV-DNJmz_op.js → stateDiagram-AJRCARHV-BmgpHJlH.js} +4 -4
  55. package/dist/{stateDiagram-v2-BHNVJYJU-DVfDNM6l.js → stateDiagram-v2-BHNVJYJU-D49CHQD6.js} +2 -2
  56. package/dist/{timeline-definition-PNZ67QCA-DEUCAg_N.js → timeline-definition-PNZ67QCA-DdVLoCkC.js} +2 -2
  57. package/dist/{useCodeBlockRendering-DF6zm7nf.js → useCodeBlockRendering-CCuoP52e.js} +1241 -1074
  58. package/dist/{vennDiagram-CIIHVFJN-DVDP__od.js → vennDiagram-CIIHVFJN-CCcMKcd7.js} +1 -1
  59. package/dist/{wardleyDiagram-YWT4CUSO-sEtxBd33.js → wardleyDiagram-YWT4CUSO-R4UGgGWY.js} +2 -2
  60. package/dist/{xychartDiagram-2RQKCTM6-DM8QeR5M.js → xychartDiagram-2RQKCTM6-DyFhCubk.js} +2 -2
  61. package/package.json +3 -3
  62. package/src/__tests__/record-search-render.test.ts +108 -0
  63. package/src/__tests__/recorder-assigner-control.test.ts +4 -1
  64. package/src/__tests__/var-field-render.test.ts +556 -43
  65. package/src/components/AimdCodeField.vue +11 -3
  66. package/src/components/AimdQuizRecorder.vue +3 -1
  67. package/src/components/AimdRecorder.vue +52 -1882
  68. package/src/components/AimdRecorderSearchToolbar.vue +258 -0
  69. package/src/components/AimdVarField.vue +589 -17
  70. package/src/components/AimdVarTableField.vue +12 -6
  71. package/src/components/index.ts +1 -0
  72. package/src/composables/__tests__/useVarHelpers.test.ts +214 -7
  73. package/src/composables/index.ts +6 -0
  74. package/src/composables/useFieldRendering.ts +28 -0
  75. package/src/composables/useRecordSearch.ts +299 -0
  76. package/src/composables/useVarHelpers.ts +285 -14
  77. package/src/locales.ts +96 -0
  78. package/src/styles/recorder-surface.css +2374 -0
  79. package/src/styles/recorder.css +1 -0
  80. 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", {
@@ -143,6 +143,7 @@ export default defineComponent({
143
143
  columns: { type: Array as PropType<string[]>, required: true },
144
144
  disabled: { type: Boolean, default: false },
145
145
  readonly: { type: Boolean, default: false },
146
+ extraClasses: { type: Array as PropType<string[]>, default: () => [] },
146
147
  settlingRowKey: { type: String as PropType<string | null>, default: null },
147
148
  messages: { type: Object as PropType<AimdRecorderMessages>, required: true },
148
149
  fieldMeta: { type: Object as PropType<Record<string, AimdFieldMeta> | undefined>, default: undefined },
@@ -352,6 +353,11 @@ export default defineComponent({
352
353
 
353
354
  if (enumOptions.length > 0) {
354
355
  const selectedEnumValue = getVarEnumSelectValue(enumOptions, row[column])
356
+ const emptyEnumValue = isNullableVarType(getColumnDefinition(column)?.type) ? null : ""
357
+ const showEmptyEnumOption = emptyEnumValue === null || selectedEnumValue === ""
358
+ const emptyEnumLabel = emptyEnumValue === null
359
+ ? getAimdRecorderEmptyValueLabel(props.messages)
360
+ : placeholder
355
361
  return h("select", {
356
362
  "data-rec-focus-key": focusKey,
357
363
  class: [className, "aimd-rec-enum-select"],
@@ -362,14 +368,14 @@ export default defineComponent({
362
368
  tableName,
363
369
  column,
364
370
  rowIndex,
365
- value: getVarEnumValueFromSelectValue(enumOptions, (event.target as HTMLSelectElement).value),
371
+ value: getVarEnumValueFromSelectValue(enumOptions, (event.target as HTMLSelectElement).value, emptyEnumValue),
366
372
  row,
367
373
  })
368
374
  },
369
375
  onBlur: () => emit("cell-blur", { tableName, column }),
370
376
  }, [
371
- selectedEnumValue === ""
372
- ? h("option", { value: "" }, placeholder)
377
+ showEmptyEnumOption
378
+ ? h("option", { value: "" }, emptyEnumLabel)
373
379
  : null,
374
380
  ...enumOptions.map((option, optionIndex) => h("option", {
375
381
  key: `${optionIndex}:${String(option.value)}`,
@@ -529,7 +535,7 @@ export default defineComponent({
529
535
 
530
536
  return h("div", {
531
537
  ref: wrapperRef,
532
- class: "aimd-field aimd-field--var-table aimd-rec-inline-table",
538
+ class: ["aimd-field aimd-field--var-table aimd-rec-inline-table", ...props.extraClasses],
533
539
  "data-aimd-table-name": tableName,
534
540
  "data-aimd-table-layout": layoutReady.value && isOverflow.value ? "cards" : "table",
535
541
  }, [
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import { defineAsyncComponent } from "vue"
9
+ import "../styles/recorder.css"
9
10
  import AimdAssignerGraph from "./AimdAssignerGraph.vue"
10
11
  import AimdRecorder from "./AimdRecorder.vue"
11
12
  import AimdRecorderEditor from "./AimdRecorderEditor.vue"
@@ -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