@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
@@ -67,6 +67,8 @@ export interface NumericInputAttributes {
67
67
 
68
68
  export type FileInputDisplayKind = AimdAssetKind
69
69
  export type FileInputConfig = AimdFileInputConfig
70
+ export type ScalarListItemType = "string" | "int" | "float"
71
+ export type ScalarListInputItem = string | number
70
72
 
71
73
  export function getFileInputConfig(
72
74
  type: string | undefined,
@@ -137,11 +139,15 @@ export function getVarEnumSelectValue(options: AimdVarEnumOption[], value: unkno
137
139
  return ""
138
140
  }
139
141
 
140
- export function getVarEnumValueFromSelectValue(options: AimdVarEnumOption[], selectValue: string): unknown {
142
+ export function getVarEnumValueFromSelectValue(
143
+ options: AimdVarEnumOption[],
144
+ selectValue: string,
145
+ emptyValue: unknown = "",
146
+ ): unknown {
141
147
  const index = Number.parseInt(selectValue, 10)
142
148
  return Number.isInteger(index) && index >= 0 && index < options.length
143
149
  ? options[index].value
144
- : ""
150
+ : emptyValue
145
151
  }
146
152
 
147
153
  function resolveOverrideInputKind(inputType: string | undefined, codeLanguage: string | undefined): VarInputKind | undefined {
@@ -179,6 +185,10 @@ function resolveOverrideInputKind(inputType: string | undefined, codeLanguage: s
179
185
  return 'textarea'
180
186
  }
181
187
 
188
+ if (normalized === 'scalarlist' || normalized === 'stringlist' || normalized === 'strlist') {
189
+ return 'scalar-list'
190
+ }
191
+
182
192
  if (normalized === 'dna') {
183
193
  return 'dna'
184
194
  }
@@ -202,14 +212,147 @@ export function normalizeVarTypeName(type: string | undefined): string {
202
212
  return normalizeAimdTypeName(type)
203
213
  }
204
214
 
215
+ function splitTopLevelTypeUnion(annotation: string): string[] {
216
+ const parts: string[] = []
217
+ let depth = 0
218
+ let quote: string | null = null
219
+ let current = ""
220
+
221
+ for (let index = 0; index < annotation.length; index += 1) {
222
+ const char = annotation[index]
223
+ const previous = annotation[index - 1]
224
+
225
+ if (quote) {
226
+ current += char
227
+ if (char === quote && previous !== "\\") {
228
+ quote = null
229
+ }
230
+ continue
231
+ }
232
+
233
+ if (char === "\"" || char === "'") {
234
+ quote = char
235
+ current += char
236
+ continue
237
+ }
238
+
239
+ if (char === "[" || char === "(" || char === "{") {
240
+ depth += 1
241
+ current += char
242
+ continue
243
+ }
244
+
245
+ if (char === "]" || char === ")" || char === "}") {
246
+ depth = Math.max(0, depth - 1)
247
+ current += char
248
+ continue
249
+ }
250
+
251
+ if (char === "|" && depth === 0) {
252
+ parts.push(current.trim())
253
+ current = ""
254
+ continue
255
+ }
256
+
257
+ current += char
258
+ }
259
+
260
+ if (current.trim()) {
261
+ parts.push(current.trim())
262
+ }
263
+
264
+ return parts.length > 0 ? parts : [annotation.trim()]
265
+ }
266
+
267
+ function canonicalizeTypeExpression(type: string | undefined): string {
268
+ return typeof type === "string" ? type.trim().replace(/\s+/g, "").toLowerCase() : ""
269
+ }
270
+
271
+ function unwrapOptionalTypeAnnotation(type: string | undefined): string {
272
+ let raw = typeof type === "string" ? type.trim() : ""
273
+
274
+ for (let index = 0; index < 4; index += 1) {
275
+ const compact = canonicalizeTypeExpression(raw)
276
+ const optionalMatch = compact.match(/^(?:typing\.)?optional\[(.*)\]$/)
277
+ if (optionalMatch) {
278
+ raw = optionalMatch[1]
279
+ continue
280
+ }
281
+
282
+ const unionParts = splitTopLevelTypeUnion(raw)
283
+ if (unionParts.length > 1) {
284
+ const valueParts = unionParts.filter(part => {
285
+ const normalized = canonicalizeTypeExpression(part)
286
+ return normalized !== "none" && normalized !== "null" && normalized !== "undefined"
287
+ })
288
+ if (valueParts.length === 1) {
289
+ raw = valueParts[0]
290
+ continue
291
+ }
292
+ }
293
+
294
+ break
295
+ }
296
+
297
+ return raw
298
+ }
299
+
300
+ export function isNullableVarType(type: string | undefined): boolean {
301
+ const raw = typeof type === "string" ? type.trim() : ""
302
+ if (!raw) {
303
+ return false
304
+ }
305
+
306
+ const compact = canonicalizeTypeExpression(raw)
307
+ if (/^(?:typing\.)?optional\[.*\]$/.test(compact)) {
308
+ return true
309
+ }
310
+
311
+ const unionParts = splitTopLevelTypeUnion(raw)
312
+ return unionParts.length > 1 && unionParts.some(part => {
313
+ const normalized = canonicalizeTypeExpression(part)
314
+ return normalized === "none" || normalized === "null" || normalized === "undefined"
315
+ })
316
+ }
317
+
205
318
  export function isNumericVarType(type: string | undefined): boolean {
206
- const normalized = normalizeVarTypeName(type)
319
+ const normalized = normalizeVarTypeName(unwrapOptionalTypeAnnotation(type))
207
320
  return normalized === "float" || normalized === "int" || normalized === "integer" || normalized === "number"
208
321
  }
209
322
 
323
+ function getScalarListItemTypeFromExpression(type: string | undefined): ScalarListItemType | undefined {
324
+ const normalized = canonicalizeTypeExpression(type).replace(/^typing\./, "")
325
+ if (normalized === "str" || normalized === "string" || normalized === "builtins.str") {
326
+ return "string"
327
+ }
328
+ if (normalized === "int" || normalized === "integer" || normalized === "builtins.int") {
329
+ return "int"
330
+ }
331
+ if (normalized === "float" || normalized === "number" || normalized === "builtins.float") {
332
+ return "float"
333
+ }
334
+ return undefined
335
+ }
336
+
337
+ export function getScalarListItemType(type: string | undefined): ScalarListItemType | undefined {
338
+ const compact = canonicalizeTypeExpression(unwrapOptionalTypeAnnotation(type)).replace(/^typing\./, "")
339
+
340
+ if (compact.endsWith("[]")) {
341
+ return getScalarListItemTypeFromExpression(compact.slice(0, -2))
342
+ }
343
+
344
+ const listMatch = compact.match(/^(?:list|array)\[(.*)\]$/)
345
+ return listMatch ? getScalarListItemTypeFromExpression(listMatch[1]) : undefined
346
+ }
347
+
348
+ export function isScalarListVarType(type: string | undefined): boolean {
349
+ return getScalarListItemType(type) !== undefined
350
+ }
351
+
210
352
  export function isStructuredVarType(type: string | undefined): boolean {
211
- const raw = typeof type === "string" ? type.trim().toLowerCase() : ""
212
- const normalized = normalizeVarTypeName(type)
353
+ const unwrappedType = unwrapOptionalTypeAnnotation(type)
354
+ const raw = canonicalizeTypeExpression(unwrappedType).replace(/^typing\./, "")
355
+ const normalized = normalizeVarTypeName(unwrappedType)
213
356
  return normalized === "json"
214
357
  || normalized === "list"
215
358
  || raw.startsWith("list[")
@@ -234,14 +377,19 @@ export function getVarInputKind(type: string | undefined, options: VarInputKindO
234
377
  return typePlugin.inputKind
235
378
  }
236
379
 
237
- const normalized = normalizeVarTypeName(type)
380
+ if (isScalarListVarType(type)) {
381
+ return "scalar-list"
382
+ }
383
+
384
+ const unwrappedType = unwrapOptionalTypeAnnotation(type)
385
+ const normalized = normalizeVarTypeName(unwrappedType)
238
386
 
239
387
  if (normalized === "float" || normalized === "int" || normalized === "integer" || normalized === "number") {
240
388
  return "number"
241
389
  }
242
390
 
243
391
  if (normalized === "bool" || normalized === "boolean" || normalized === "checkbox") {
244
- return "checkbox"
392
+ return isNullableVarType(type) ? "boolean-select" : "checkbox"
245
393
  }
246
394
 
247
395
  if (normalized === "date") {
@@ -268,11 +416,11 @@ export function getVarInputKind(type: string | undefined, options: VarInputKindO
268
416
  return "textarea"
269
417
  }
270
418
 
271
- if (isFileLikeVarType(type, options.kwargs, options.fieldMeta)) {
419
+ if (isFileLikeVarType(unwrappedType, options.kwargs, options.fieldMeta)) {
272
420
  return "file"
273
421
  }
274
422
 
275
- if (isAimdCodeEditorType(type, { codeLanguage: options.codeLanguage })) {
423
+ if (isAimdCodeEditorType(unwrappedType, { codeLanguage: options.codeLanguage })) {
276
424
  return 'code'
277
425
  }
278
426
 
@@ -293,6 +441,61 @@ function stringifyStructuredInputValue(value: unknown): string {
293
441
  }
294
442
  }
295
443
 
444
+ function normalizeScalarListNumberItem(text: string, itemType: ScalarListItemType): ScalarListInputItem {
445
+ const parsed = Number(text)
446
+ if (!Number.isFinite(parsed)) {
447
+ return text
448
+ }
449
+ if (itemType === "int" && !Number.isInteger(parsed)) {
450
+ return text
451
+ }
452
+ return parsed
453
+ }
454
+
455
+ export function normalizeScalarListInputItems(
456
+ items: unknown[],
457
+ itemType: ScalarListItemType = "string",
458
+ ): ScalarListInputItem[] {
459
+ return items
460
+ .map(item => item === null || typeof item === "undefined" ? "" : String(item).trim())
461
+ .filter(item => item.length > 0)
462
+ .map(item => itemType === "string" ? item : normalizeScalarListNumberItem(item, itemType))
463
+ }
464
+
465
+ export function getScalarListInputItems(value: unknown): string[] {
466
+ const normalized = unwrapStructuredValue(value)
467
+
468
+ if (Array.isArray(normalized)) {
469
+ return normalized.map(item => item === null || typeof item === "undefined" ? "" : String(item))
470
+ }
471
+
472
+ if (typeof normalized === "string") {
473
+ const text = normalized.trim()
474
+ if (!text) {
475
+ return []
476
+ }
477
+ if (text.startsWith("[")) {
478
+ try {
479
+ const parsed = JSON.parse(text)
480
+ if (Array.isArray(parsed)) {
481
+ return parsed.map(item => item === null || typeof item === "undefined" ? "" : String(item))
482
+ }
483
+ } catch {
484
+ // Fall through to plain text handling.
485
+ }
486
+ }
487
+ return text.includes("\n")
488
+ ? text.split(/\r?\n/)
489
+ : [normalized]
490
+ }
491
+
492
+ if (normalized === null || typeof normalized === "undefined") {
493
+ return []
494
+ }
495
+
496
+ return [String(normalized)]
497
+ }
498
+
296
499
  function toFiniteNumber(value: unknown): number | undefined {
297
500
  if (typeof value === "number") {
298
501
  return Number.isFinite(value) ? value : undefined
@@ -548,6 +751,22 @@ export function getVarInputDisplayValue(
548
751
  return typeof normalized === "number" ? normalized : (typeof normalized === "string" ? normalized : "")
549
752
  }
550
753
 
754
+ if (kind === "boolean-select") {
755
+ if (typeof normalized === "boolean") {
756
+ return normalized ? "true" : "false"
757
+ }
758
+ if (typeof normalized === "string") {
759
+ const text = normalized.trim().toLowerCase()
760
+ if (["true", "1", "yes", "on"].includes(text)) {
761
+ return "true"
762
+ }
763
+ if (["false", "0", "no", "off"].includes(text)) {
764
+ return "false"
765
+ }
766
+ }
767
+ return ""
768
+ }
769
+
551
770
  if (kind === "dna") {
552
771
  return typeof normalized === "string" ? normalized : JSON.stringify(normalized)
553
772
  }
@@ -556,6 +775,13 @@ export function getVarInputDisplayValue(
556
775
  return getFileDisplayName(normalized)
557
776
  }
558
777
 
778
+ if (kind === "scalar-list") {
779
+ return JSON.stringify(normalizeScalarListInputItems(
780
+ getScalarListInputItems(normalized),
781
+ getScalarListItemType(options.type) ?? "string",
782
+ ))
783
+ }
784
+
559
785
  if (isStructuredVarType(options.type)) {
560
786
  return stringifyStructuredInputValue(normalized)
561
787
  }
@@ -591,7 +817,12 @@ export function parseVarInputValue(
591
817
  return typePlugin.parseInputValue(context)
592
818
  }
593
819
 
594
- const normalizedType = normalizeVarTypeName(type)
820
+ const nullableType = isNullableVarType(type)
821
+ const normalizedType = normalizeVarTypeName(unwrapOptionalTypeAnnotation(type))
822
+
823
+ if ((kind === "date" || kind === "datetime" || kind === "time") && nullableType && rawValue.trim() === "") {
824
+ return null
825
+ }
595
826
 
596
827
  if (kind === "datetime") {
597
828
  return normalizeDateTimeValueWithTimezone(rawValue)
@@ -600,7 +831,7 @@ export function parseVarInputValue(
600
831
  if (kind === "number") {
601
832
  const text = rawValue.trim()
602
833
  if (!text) {
603
- return ""
834
+ return nullableType ? null : ""
604
835
  }
605
836
  const parsed = normalizedType === "int" || normalizedType === "integer"
606
837
  ? Number.parseInt(text, 10)
@@ -608,10 +839,31 @@ export function parseVarInputValue(
608
839
  return Number.isNaN(parsed) ? rawValue : parsed
609
840
  }
610
841
 
842
+ if (kind === "scalar-list") {
843
+ return normalizeScalarListInputItems(
844
+ getScalarListInputItems(rawValue),
845
+ getScalarListItemType(type) ?? "string",
846
+ )
847
+ }
848
+
849
+ if (kind === "boolean-select") {
850
+ const text = rawValue.trim().toLowerCase()
851
+ if (!text) {
852
+ return null
853
+ }
854
+ if (text === "true") {
855
+ return true
856
+ }
857
+ if (text === "false") {
858
+ return false
859
+ }
860
+ return rawValue
861
+ }
862
+
611
863
  if (isStructuredVarType(type)) {
612
864
  const text = rawValue.trim()
613
865
  if (!text) {
614
- return ""
866
+ return nullableType ? null : ""
615
867
  }
616
868
  try {
617
869
  return JSON.parse(text)
@@ -620,6 +872,10 @@ export function parseVarInputValue(
620
872
  }
621
873
  }
622
874
 
875
+ if (nullableType && rawValue.trim() === "") {
876
+ return null
877
+ }
878
+
623
879
  return rawValue
624
880
  }
625
881
 
@@ -633,7 +889,8 @@ function getVarControlMinWidth(inputKind: VarInputKind): number {
633
889
  case "dna":
634
890
  case "code":
635
891
  case "file":
636
- return 160
892
+ case "scalar-list":
893
+ return inputKind === "scalar-list" ? 220 : 160
637
894
  default:
638
895
  return 0
639
896
  }
@@ -649,6 +906,8 @@ function getVarControlExtraWidth(inputKind: VarInputKind): number {
649
906
  return 28
650
907
  case "file":
651
908
  return 24
909
+ case "scalar-list":
910
+ return 16
652
911
  default:
653
912
  return 4
654
913
  }
@@ -843,10 +1102,22 @@ export function applyVarStackWidth(target: HTMLElement, inputKind: VarInputKind)
843
1102
  return
844
1103
  }
845
1104
 
1105
+ if (inputKind === "scalar-list") {
1106
+ wrapper.style.width = "100%"
1107
+ wrapper.style.maxWidth = "100%"
1108
+ return
1109
+ }
1110
+
1111
+ if (wrapper.closest("table:not(.aimd-rec-inline-table__table):not(.aimd-scale__table)")) {
1112
+ wrapper.style.width = "max-content"
1113
+ wrapper.style.maxWidth = "min(680px, 100%)"
1114
+ return
1115
+ }
1116
+
846
1117
  const labelWidth = measureVarLabelWidth(wrapper)
847
1118
 
848
1119
  let controlWidth = 0
849
- const input = wrapper.querySelector(".aimd-rec-inline__input--stacked, .aimd-rec-inline__textarea--stacked-text, .aimd-rec-inline__file-control") as HTMLElement | null
1120
+ const input = wrapper.querySelector(".aimd-rec-inline__input--stacked, .aimd-rec-inline__textarea--stacked-text, .aimd-rec-inline__file-control, .aimd-rec-inline__scalar-list") as HTMLElement | null
850
1121
  const minWidthPx = Math.max(getVarControlMinWidth(inputKind), getFileControlMinWidth(input))
851
1122
  if (input) {
852
1123
  controlWidth = measureSingleLineControlWidth(input) + getVarControlExtraWidth(inputKind)
package/src/locales.ts CHANGED
@@ -95,6 +95,23 @@ export interface AimdRecorderMessages {
95
95
  replace: string
96
96
  uploadFailed: string
97
97
  }
98
+ scalarList: {
99
+ itemsMode: string
100
+ jsonMode: string
101
+ itemPlaceholder: string
102
+ itemIndex: (index: number) => string
103
+ addItem: string
104
+ removeItem: string
105
+ dragItem: string
106
+ jsonInvalidSyntax: string
107
+ jsonInvalidArray: string
108
+ jsonInvalidItem: string
109
+ }
110
+ boolean: {
111
+ unset: string
112
+ true: string
113
+ false: string
114
+ }
98
115
  dna: {
99
116
  editMode: string
100
117
  interactiveMode: string
@@ -167,6 +184,7 @@ export interface AimdRecorderMessages {
167
184
  segmentOutOfBounds: (end: number, length: number) => string
168
185
  }
169
186
  common: {
187
+ emptyValue?: string
170
188
  emptyContent: string
171
189
  }
172
190
  }
@@ -279,6 +297,23 @@ const EN_US_MESSAGES: AimdRecorderMessages = {
279
297
  replace: "Replace file",
280
298
  uploadFailed: "File upload failed.",
281
299
  },
300
+ scalarList: {
301
+ itemsMode: "Items",
302
+ jsonMode: "JSON",
303
+ itemPlaceholder: "List item",
304
+ itemIndex: index => `Item ${index}`,
305
+ addItem: "Add item",
306
+ removeItem: "Remove item",
307
+ dragItem: "Drag to reorder",
308
+ jsonInvalidSyntax: "Invalid JSON.",
309
+ jsonInvalidArray: "JSON value must be an array.",
310
+ jsonInvalidItem: "JSON array items do not match this list type.",
311
+ },
312
+ boolean: {
313
+ unset: "Not set",
314
+ true: "True",
315
+ false: "False",
316
+ },
282
317
  dna: {
283
318
  editMode: "Edit mode",
284
319
  interactiveMode: "Interactive",
@@ -351,6 +386,7 @@ const EN_US_MESSAGES: AimdRecorderMessages = {
351
386
  segmentOutOfBounds: (end, length) => `Segment end ${end} exceeds sequence length ${length}.`,
352
387
  },
353
388
  common: {
389
+ emptyValue: "Not set",
354
390
  emptyContent: "No renderable protocol content.",
355
391
  },
356
392
  }
@@ -436,6 +472,23 @@ const ZH_CN_MESSAGES: AimdRecorderMessages = {
436
472
  replace: "替换文件",
437
473
  uploadFailed: "文件上传失败。",
438
474
  },
475
+ scalarList: {
476
+ itemsMode: "逐项",
477
+ jsonMode: "JSON",
478
+ itemPlaceholder: "列表项",
479
+ itemIndex: index => `第 ${index} 项`,
480
+ addItem: "添加项",
481
+ removeItem: "删除项",
482
+ dragItem: "拖拽排序",
483
+ jsonInvalidSyntax: "JSON 格式无效。",
484
+ jsonInvalidArray: "JSON 值必须是数组。",
485
+ jsonInvalidItem: "JSON 数组项与当前列表类型不匹配。",
486
+ },
487
+ boolean: {
488
+ unset: "未填写",
489
+ true: "是",
490
+ false: "否",
491
+ },
439
492
  dna: {
440
493
  editMode: "编辑模式",
441
494
  interactiveMode: "交互式",
@@ -508,6 +561,7 @@ const ZH_CN_MESSAGES: AimdRecorderMessages = {
508
561
  segmentOutOfBounds: (end, length) => `片段终点 ${end} 超出了序列长度 ${length}。`,
509
562
  },
510
563
  common: {
564
+ emptyValue: "未填写",
511
565
  emptyContent: "没有可渲染的协议内容。",
512
566
  },
513
567
  }
@@ -598,6 +652,12 @@ export function getAimdRecorderScopeLabel(
598
652
  }
599
653
  }
600
654
 
655
+ export function getAimdRecorderEmptyValueLabel(
656
+ messages: Pick<AimdRecorderMessages, "common" | "boolean">,
657
+ ): string {
658
+ return messages.common.emptyValue ?? messages.boolean.unset
659
+ }
660
+
601
661
  export function getAimdRecorderQuizTypeLabel(
602
662
  quizType: string | undefined,
603
663
  messages: Pick<AimdRecorderMessages, "quiz">,
package/src/types.ts CHANGED
@@ -112,7 +112,7 @@ export type AimdFileInfoResolver = (
112
112
  context: AimdFileResolveContext,
113
113
  ) => AimdResolvedFileInfo | string | null | undefined | Promise<AimdResolvedFileInfo | string | null | undefined>
114
114
 
115
- export type AimdVarInputKind = "text" | "number" | "checkbox" | "textarea" | "date" | "datetime" | "time" | "dna" | "code" | "file"
115
+ export type AimdVarInputKind = "text" | "number" | "checkbox" | "boolean-select" | "textarea" | "scalar-list" | "date" | "datetime" | "time" | "dna" | "code" | "file"
116
116
  export type AimdStepDetailDisplay = "auto" | "always"
117
117
  export type AimdChoiceOptionExplanationMode = "hidden" | "selected" | "submitted" | "graded"
118
118
  export type AimdScaleGradeDisplayMode = "hidden" | "completed" | "submitted" | "graded"