@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.
- package/README.md +6 -0
- package/README.zh-CN.md +6 -0
- package/dist/{AimdCodeField-BQUuM-EF.js → AimdCodeField-BN_0UQMx.js} +34 -32
- package/dist/{AimdDnaSequenceField-TBKunqU_.js → AimdDnaSequenceField-Cp0cgBYl.js} +1 -1
- package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-gTySIxvX.js → AimdEditor.vue_vue_type_style_index_0_lang-Dj5y1p3U.js} +2202 -2158
- package/dist/{AimdMarkdownField-DGV5KFUs.js → AimdMarkdownField-Vp72mf5d.js} +18 -17
- package/dist/{AimdMarkdownNoteField-C78KHCBA.js → AimdMarkdownNoteField-8AHO9zwW.js} +17 -16
- package/dist/aimd-recorder.css +1 -1
- package/dist/{arc-BMhAnOm7.js → arc-YTgUVhxi.js} +1 -1
- package/dist/{architectureDiagram-3BPJPVTR-DXuPTBR3.js → architectureDiagram-3BPJPVTR-BFddgj3h.js} +2 -2
- package/dist/{blockDiagram-GPEHLZMM-HKz9kQ49.js → blockDiagram-GPEHLZMM-BNFU64lo.js} +4 -4
- package/dist/{c4Diagram-AAUBKEIU-B2a8Aupm.js → c4Diagram-AAUBKEIU-DDg-ymRq.js} +2 -2
- package/dist/{channel-CQnbPm6T.js → channel-Cswcnlp1.js} +1 -1
- package/dist/{chunk-2J33WTMH-CPwhDANL.js → chunk-2J33WTMH-CP2V6jff.js} +1 -1
- package/dist/{chunk-4BX2VUAB-BJV0R8-Z.js → chunk-4BX2VUAB-CbWr2vv6.js} +1 -1
- package/dist/{chunk-55IACEB6-CSqUgTVA.js → chunk-55IACEB6-DQOKhaUL.js} +1 -1
- package/dist/{chunk-727SXJPM-C3LCZWaC.js → chunk-727SXJPM-4VuCu0m8.js} +5 -5
- package/dist/{chunk-AQP2D5EJ-BC5kHyik.js → chunk-AQP2D5EJ-D7Pq-oug.js} +3 -3
- package/dist/{chunk-FMBD7UC4-lv-SQuSa.js → chunk-FMBD7UC4-slF0wbDn.js} +1 -1
- package/dist/{chunk-ND2GUHAM-BnnHbOOp.js → chunk-ND2GUHAM-BrNrmeyL.js} +1 -1
- package/dist/{chunk-QZHKN3VN-DE1_5lrn.js → chunk-QZHKN3VN-CII3oQmH.js} +1 -1
- package/dist/{classDiagram-v2-Q7XG4LA2-32SrXsR3.js → classDiagram-4FO5ZUOK-skT5SNaU.js} +2 -2
- package/dist/{classDiagram-4FO5ZUOK-32SrXsR3.js → classDiagram-v2-Q7XG4LA2-skT5SNaU.js} +2 -2
- package/dist/components.js +3194 -2847
- package/dist/composables.js +89 -85
- package/dist/{cose-bilkent-S5V4N54A-BKyR6PrF.js → cose-bilkent-S5V4N54A-CiwUUHaz.js} +1 -1
- package/dist/{dagre-BM42HDAG-D8Nwouf2.js → dagre-BM42HDAG-BzaKejHz.js} +3 -3
- package/dist/{diagram-2AECGRRQ-DfoNEchZ.js → diagram-2AECGRRQ-B7jPt7Sf.js} +2 -2
- package/dist/{diagram-5GNKFQAL-Dlpl3XO8.js → diagram-5GNKFQAL-z6ygEwZY.js} +3 -3
- package/dist/{diagram-KO2AKTUF-CgwROod_.js → diagram-KO2AKTUF-BBQMMIgY.js} +2 -2
- package/dist/{diagram-LMA3HP47-UiiviX43.js → diagram-LMA3HP47-IFDVFs2m.js} +2 -2
- package/dist/{diagram-OG6HWLK6-BPuH-4Wa.js → diagram-OG6HWLK6-DjEAxof0.js} +3 -3
- package/dist/{erDiagram-TEJ5UH35-B19WKSiS.js → erDiagram-TEJ5UH35-DxMYC2Iw.js} +4 -4
- package/dist/{flowDiagram-I6XJVG4X-SsfO1IYz.js → flowDiagram-I6XJVG4X-EIHEHG32.js} +6 -6
- package/dist/{ganttDiagram-6RSMTGT7-8BCxW9SC.js → ganttDiagram-6RSMTGT7-TEOWSxVA.js} +2 -2
- package/dist/{gitGraphDiagram-PVQCEYII-D-jzaXKg.js → gitGraphDiagram-PVQCEYII-Cwzy4bEc.js} +3 -3
- package/dist/{graph-Dd8Vx0lj.js → graph-Cyx6ry93.js} +1 -1
- package/dist/index-Dtvv88SS.js +1308 -0
- package/dist/index.js +72 -68
- package/dist/{infoDiagram-5YYISTIA-B_XwkyXw.js → infoDiagram-5YYISTIA-DNv6Z1ol.js} +1 -1
- package/dist/{ishikawaDiagram-YF4QCWOH-nevqOMkV.js → ishikawaDiagram-YF4QCWOH-D3eaxgy9.js} +1 -1
- package/dist/{journeyDiagram-JHISSGLW-DKQOkZNx.js → journeyDiagram-JHISSGLW-D5g7q2RP.js} +4 -4
- package/dist/{kanban-definition-UN3LZRKU-BYvizbN0.js → kanban-definition-UN3LZRKU-C0hUSCKH.js} +2 -2
- package/dist/{layout-BiHDh2wu.js → layout-CpB8OqeJ.js} +2 -2
- package/dist/{linear-BcUgIsNC.js → linear-D55SCqYq.js} +1 -1
- package/dist/{mermaid.core-DPv1ut6K.js → mermaid.core-wqUqC7-u.js} +34 -34
- package/dist/{mindmap-definition-RKZ34NQL-CiT97EC2.js → mindmap-definition-RKZ34NQL-tCWbcVMf.js} +3 -3
- package/dist/{pieDiagram-4H26LBE5-BHcFVpCC.js → pieDiagram-4H26LBE5-JtTllP1a.js} +3 -3
- package/dist/{quadrantDiagram-W4KKPZXB-BFBAb3Zx.js → quadrantDiagram-W4KKPZXB-CLL79FuD.js} +2 -2
- package/dist/record.js +90 -1196
- package/dist/{requirementDiagram-4Y6WPE33-CUS2OOyE.js → requirementDiagram-4Y6WPE33-3BVAevi9.js} +3 -3
- package/dist/{sankeyDiagram-5OEKKPKP-IuhX4tCb.js → sankeyDiagram-5OEKKPKP-BfUuX3gj.js} +1 -1
- package/dist/{sequenceDiagram-3UESZ5HK-DWHcFiUF.js → sequenceDiagram-3UESZ5HK-vTd4YJPb.js} +3 -3
- package/dist/{stateDiagram-AJRCARHV-J49Kafj_.js → stateDiagram-AJRCARHV-BzlMdp-U.js} +4 -4
- package/dist/{stateDiagram-v2-BHNVJYJU-DL2VCR5X.js → stateDiagram-v2-BHNVJYJU-Ciwlhuza.js} +2 -2
- package/dist/{timeline-definition-PNZ67QCA-l9xSQ_pX.js → timeline-definition-PNZ67QCA-CySiSuYS.js} +2 -2
- package/dist/{useCodeBlockRendering-CY70U0Xm.js → useCodeBlockRendering-DtcAJyK9.js} +1239 -1123
- package/dist/{vennDiagram-CIIHVFJN-BQjdmOkd.js → vennDiagram-CIIHVFJN-Bbf0BSAq.js} +1 -1
- package/dist/{wardleyDiagram-YWT4CUSO-CmVdsV9b.js → wardleyDiagram-YWT4CUSO-J0jnd8EV.js} +2 -2
- package/dist/{xychartDiagram-2RQKCTM6-F-cC_Igm.js → xychartDiagram-2RQKCTM6-XCPLxT4O.js} +2 -2
- package/package.json +3 -3
- package/src/__tests__/recorder-assigner-control.test.ts +4 -1
- package/src/__tests__/recorder-editor.test.ts +3 -1
- package/src/__tests__/var-field-render.test.ts +547 -3
- package/src/components/AimdCodeField.vue +11 -3
- package/src/components/AimdRecorder.vue +469 -7
- package/src/components/AimdRecorderEditor.vue +3 -1
- package/src/components/AimdVarField.vue +589 -17
- package/src/components/AimdVarTableField.vue +10 -5
- package/src/composables/__tests__/useVarHelpers.test.ts +214 -7
- package/src/composables/index.ts +6 -0
- package/src/composables/useFieldRendering.ts +28 -0
- package/src/composables/useVarHelpers.ts +285 -14
- package/src/locales.ts +60 -0
- package/src/types.ts +1 -1
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
AimdVarInputKind,
|
|
19
19
|
} from "../types"
|
|
20
20
|
import type { AimdRecorderMessages } from "../locales"
|
|
21
|
-
import { getAimdRecorderScopeLabel } from "../locales"
|
|
21
|
+
import { getAimdRecorderEmptyValueLabel, getAimdRecorderScopeLabel } from "../locales"
|
|
22
22
|
import { resolveAimdCodeEditorLanguage } from "../code-types"
|
|
23
23
|
import {
|
|
24
24
|
normalizeVarTypeName,
|
|
@@ -32,9 +32,15 @@ import {
|
|
|
32
32
|
getFileValueId,
|
|
33
33
|
getFileDisplayName,
|
|
34
34
|
getFileInputConfig,
|
|
35
|
+
getScalarListInputItems,
|
|
36
|
+
getScalarListItemType,
|
|
35
37
|
getVarEnumSelectValue,
|
|
36
38
|
getVarEnumValueFromSelectValue,
|
|
39
|
+
isNullableVarType,
|
|
40
|
+
normalizeScalarListInputItems,
|
|
37
41
|
type NumericInputAttributes,
|
|
42
|
+
type ScalarListInputItem,
|
|
43
|
+
type ScalarListItemType,
|
|
38
44
|
} from "../composables/useVarHelpers"
|
|
39
45
|
|
|
40
46
|
const AimdCodeField = defineAsyncComponent(() => import("./AimdCodeField.vue"))
|
|
@@ -72,6 +78,13 @@ interface FileDisplayInfo {
|
|
|
72
78
|
size?: number
|
|
73
79
|
}
|
|
74
80
|
|
|
81
|
+
type ScalarListEditMode = "items" | "json"
|
|
82
|
+
type ScalarListJsonParseError = "syntax" | "array" | "item"
|
|
83
|
+
|
|
84
|
+
type ScalarListJsonParseResult =
|
|
85
|
+
| { ok: true; value: ScalarListInputItem[] }
|
|
86
|
+
| { ok: false; error: ScalarListJsonParseError }
|
|
87
|
+
|
|
75
88
|
function parseCsvPreviewLine(line: string): string[] {
|
|
76
89
|
const cells: string[] = []
|
|
77
90
|
let current = ""
|
|
@@ -174,7 +187,191 @@ function formatFileSize(size: number | undefined): string {
|
|
|
174
187
|
return `${value >= 10 ? value.toFixed(0) : value.toFixed(1)} ${units[unitIndex]}`
|
|
175
188
|
}
|
|
176
189
|
|
|
177
|
-
function
|
|
190
|
+
function areArraysEqual(left: unknown[], right: unknown[]): boolean {
|
|
191
|
+
return left.length === right.length && left.every((value, index) => Object.is(value, right[index]))
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const SCALAR_LIST_INPUT_MIN_WIDTH_PX = 50
|
|
195
|
+
const SCALAR_LIST_INPUT_EXTRA_SPACE_PX = 8
|
|
196
|
+
const SCALAR_LIST_COMPACT_MAX_WIDTH_EM = 42
|
|
197
|
+
let scalarListTextMeasureContext: CanvasRenderingContext2D | null | undefined
|
|
198
|
+
|
|
199
|
+
function getApproximateTextWidthEm(text: string): number {
|
|
200
|
+
return Array.from(text).reduce((width, char) => {
|
|
201
|
+
const codePoint = char.codePointAt(0) ?? 0
|
|
202
|
+
if (codePoint >= 0x1100) {
|
|
203
|
+
return width + 1
|
|
204
|
+
}
|
|
205
|
+
if (/\s/.test(char)) {
|
|
206
|
+
return width + 0.35
|
|
207
|
+
}
|
|
208
|
+
if (/[ilI|.,'`!:;]/.test(char)) {
|
|
209
|
+
return width + 0.3
|
|
210
|
+
}
|
|
211
|
+
if (/[mwMW@#%&]/.test(char)) {
|
|
212
|
+
return width + 0.82
|
|
213
|
+
}
|
|
214
|
+
if (/[A-Z0-9]/.test(char)) {
|
|
215
|
+
return width + 0.62
|
|
216
|
+
}
|
|
217
|
+
if (/[a-z]/.test(char)) {
|
|
218
|
+
return width + 0.56
|
|
219
|
+
}
|
|
220
|
+
return width + 0.65
|
|
221
|
+
}, 0)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function getApproximateTextMaxLineWidthEm(text: string): number {
|
|
225
|
+
return text
|
|
226
|
+
.split(/\r\n|\r|\n/)
|
|
227
|
+
.reduce((maxWidth, line) => Math.max(maxWidth, getApproximateTextWidthEm(line)), 0)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function hasExplicitLineBreak(text: string): boolean {
|
|
231
|
+
return /\r|\n/.test(text)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function getScalarListInputWidthEm(value: string, placeholder: string | undefined): number {
|
|
235
|
+
const trimmedValue = value.trim()
|
|
236
|
+
if (trimmedValue.length > 0) {
|
|
237
|
+
return Math.ceil(Math.max(2.4, getApproximateTextMaxLineWidthEm(trimmedValue) + 0.75) * 10) / 10
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const placeholderText = placeholder ?? ""
|
|
241
|
+
return Math.ceil(Math.max(3.4, getApproximateTextMaxLineWidthEm(placeholderText) + 0.75) * 10) / 10
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function getScalarListInputFallbackWidthPx(value: string, placeholder: string | undefined): number {
|
|
245
|
+
return Math.ceil(getScalarListInputWidthEm(value, placeholder) * 14 + 16)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function isWideScalarListTextItem(value: string, placeholder: string | undefined): boolean {
|
|
249
|
+
return value.trim().length > 0 && getScalarListInputWidthEm(value, placeholder) > SCALAR_LIST_COMPACT_MAX_WIDTH_EM
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function getScalarListTextMeasureContext(): CanvasRenderingContext2D | null {
|
|
253
|
+
if (scalarListTextMeasureContext !== undefined) {
|
|
254
|
+
return scalarListTextMeasureContext
|
|
255
|
+
}
|
|
256
|
+
if (typeof document === "undefined") {
|
|
257
|
+
scalarListTextMeasureContext = null
|
|
258
|
+
return scalarListTextMeasureContext
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
261
|
+
const canvas = document.createElement("canvas")
|
|
262
|
+
const context = canvas.getContext("2d")
|
|
263
|
+
scalarListTextMeasureContext = context && typeof context.measureText === "function" ? context : null
|
|
264
|
+
} catch {
|
|
265
|
+
scalarListTextMeasureContext = null
|
|
266
|
+
}
|
|
267
|
+
return scalarListTextMeasureContext
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function getComputedFontShorthand(style: CSSStyleDeclaration): string {
|
|
271
|
+
return style.font && style.font !== ""
|
|
272
|
+
? style.font
|
|
273
|
+
: `${style.fontStyle} ${style.fontVariant} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function getCssPixelValue(value: string): number {
|
|
277
|
+
const parsed = Number.parseFloat(value)
|
|
278
|
+
return Number.isFinite(parsed) ? parsed : 0
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function getScalarListInputChromeWidthPx(style: CSSStyleDeclaration): number {
|
|
282
|
+
if (style.boxSizing !== "border-box") {
|
|
283
|
+
return 0
|
|
284
|
+
}
|
|
285
|
+
return getCssPixelValue(style.paddingLeft)
|
|
286
|
+
+ getCssPixelValue(style.paddingRight)
|
|
287
|
+
+ getCssPixelValue(style.borderLeftWidth)
|
|
288
|
+
+ getCssPixelValue(style.borderRightWidth)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function getScalarListMeasuredInputWidthPx(control: HTMLInputElement | HTMLTextAreaElement): number | null {
|
|
292
|
+
if (typeof window === "undefined" || typeof window.getComputedStyle !== "function") {
|
|
293
|
+
return null
|
|
294
|
+
}
|
|
295
|
+
const context = getScalarListTextMeasureContext()
|
|
296
|
+
if (!context) {
|
|
297
|
+
return null
|
|
298
|
+
}
|
|
299
|
+
const style = window.getComputedStyle(control)
|
|
300
|
+
context.font = getComputedFontShorthand(style)
|
|
301
|
+
const text = control.value.length > 0 ? control.value : control.placeholder
|
|
302
|
+
const maxTextWidth = text
|
|
303
|
+
.split(/\r\n|\r|\n/)
|
|
304
|
+
.reduce((maxWidth, line) => Math.max(maxWidth, context.measureText(line).width), 0)
|
|
305
|
+
return Math.ceil(Math.max(
|
|
306
|
+
SCALAR_LIST_INPUT_MIN_WIDTH_PX,
|
|
307
|
+
maxTextWidth + getScalarListInputChromeWidthPx(style) + SCALAR_LIST_INPUT_EXTRA_SPACE_PX,
|
|
308
|
+
))
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function syncScalarListInputWidth(control: HTMLInputElement | HTMLTextAreaElement) {
|
|
312
|
+
const measuredWidth = getScalarListMeasuredInputWidthPx(control)
|
|
313
|
+
if (measuredWidth !== null) {
|
|
314
|
+
control.style.setProperty("--aimd-rec-scalar-list-input-width", `${measuredWidth}px`)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function syncScalarListTextInputLayout(control: HTMLTextAreaElement) {
|
|
319
|
+
syncScalarListInputWidth(control)
|
|
320
|
+
syncAutoWrapTextareaHeight(control)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function formatScalarListJsonValue(value: unknown, itemType: ScalarListItemType): string {
|
|
324
|
+
return JSON.stringify(normalizeScalarListInputItems(getScalarListInputItems(value), itemType), null, 2)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function isValidScalarListJsonItem(item: unknown, itemType: ScalarListItemType): boolean {
|
|
328
|
+
if (item === null || Array.isArray(item) || typeof item === "object") {
|
|
329
|
+
return false
|
|
330
|
+
}
|
|
331
|
+
if (itemType === "string") {
|
|
332
|
+
return typeof item === "string" || typeof item === "number" || typeof item === "boolean"
|
|
333
|
+
}
|
|
334
|
+
if (typeof item === "number") {
|
|
335
|
+
return Number.isFinite(item) && (itemType !== "int" || Number.isInteger(item))
|
|
336
|
+
}
|
|
337
|
+
if (typeof item === "string" && item.trim()) {
|
|
338
|
+
const parsed = Number(item)
|
|
339
|
+
return Number.isFinite(parsed) && (itemType !== "int" || Number.isInteger(parsed))
|
|
340
|
+
}
|
|
341
|
+
return false
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function parseScalarListJsonValue(rawValue: string, itemType: ScalarListItemType): ScalarListJsonParseResult {
|
|
345
|
+
const text = rawValue.trim()
|
|
346
|
+
if (!text) {
|
|
347
|
+
return { ok: true, value: [] }
|
|
348
|
+
}
|
|
349
|
+
let parsed: unknown
|
|
350
|
+
try {
|
|
351
|
+
parsed = JSON.parse(text)
|
|
352
|
+
} catch {
|
|
353
|
+
return { ok: false, error: "syntax" }
|
|
354
|
+
}
|
|
355
|
+
if (!Array.isArray(parsed)) {
|
|
356
|
+
return { ok: false, error: "array" }
|
|
357
|
+
}
|
|
358
|
+
if (!parsed.every(item => isValidScalarListJsonItem(item, itemType))) {
|
|
359
|
+
return { ok: false, error: "item" }
|
|
360
|
+
}
|
|
361
|
+
return { ok: true, value: normalizeScalarListInputItems(parsed, itemType) }
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function getScalarListJsonPlaceholder(itemType: ScalarListItemType): string {
|
|
365
|
+
if (itemType === "int") {
|
|
366
|
+
return "[1, 2]"
|
|
367
|
+
}
|
|
368
|
+
if (itemType === "float") {
|
|
369
|
+
return "[1.2, 3.4]"
|
|
370
|
+
}
|
|
371
|
+
return "[\"alpha\", \"beta\"]"
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function renderUtilityIcon(kind: "download" | "open" | "clear" | "replace" | "preview" | "add" | "drag"): VNode {
|
|
178
375
|
const common = {
|
|
179
376
|
viewBox: "0 0 24 24",
|
|
180
377
|
width: "1em",
|
|
@@ -214,6 +411,22 @@ function renderUtilityIcon(kind: "download" | "open" | "clear" | "replace" | "pr
|
|
|
214
411
|
h("circle", { cx: "12", cy: "12", r: "3" }),
|
|
215
412
|
])
|
|
216
413
|
}
|
|
414
|
+
if (kind === "add") {
|
|
415
|
+
return h("svg", common, [
|
|
416
|
+
h("path", { d: "M12 5v14" }),
|
|
417
|
+
h("path", { d: "M5 12h14" }),
|
|
418
|
+
])
|
|
419
|
+
}
|
|
420
|
+
if (kind === "drag") {
|
|
421
|
+
return h("svg", common, [
|
|
422
|
+
h("circle", { cx: "9", cy: "6", r: "1" }),
|
|
423
|
+
h("circle", { cx: "9", cy: "12", r: "1" }),
|
|
424
|
+
h("circle", { cx: "9", cy: "18", r: "1" }),
|
|
425
|
+
h("circle", { cx: "15", cy: "6", r: "1" }),
|
|
426
|
+
h("circle", { cx: "15", cy: "12", r: "1" }),
|
|
427
|
+
h("circle", { cx: "15", cy: "18", r: "1" }),
|
|
428
|
+
])
|
|
429
|
+
}
|
|
217
430
|
return h("svg", common, [
|
|
218
431
|
h("path", { d: "M3 6h18" }),
|
|
219
432
|
h("path", { d: "M8 6V4h8v2" }),
|
|
@@ -288,8 +501,45 @@ export default defineComponent({
|
|
|
288
501
|
const csvPreview = ref<CsvPreviewState | null>(null)
|
|
289
502
|
const resolvedFileInfo = ref<FileDisplayInfo | null>(null)
|
|
290
503
|
const lastSelectedFileInfo = ref<FileDisplayInfo | null>(null)
|
|
504
|
+
const scalarListDraftRows = ref<string[] | null>(null)
|
|
505
|
+
const scalarListMode = ref<ScalarListEditMode>("items")
|
|
506
|
+
const scalarListJsonDraft = ref<string | null>(null)
|
|
507
|
+
const scalarListJsonError = ref("")
|
|
508
|
+
const scalarListDragIndex = ref<number | null>(null)
|
|
509
|
+
const scalarListDropIndex = ref<number | null>(null)
|
|
291
510
|
let csvPreviewRequestId = 0
|
|
292
511
|
|
|
512
|
+
watch(
|
|
513
|
+
() => [props.inputKind, props.value] as const,
|
|
514
|
+
([inputKind, value]) => {
|
|
515
|
+
if (inputKind !== "scalar-list") {
|
|
516
|
+
scalarListDraftRows.value = null
|
|
517
|
+
scalarListMode.value = "items"
|
|
518
|
+
scalarListJsonDraft.value = null
|
|
519
|
+
scalarListJsonError.value = ""
|
|
520
|
+
scalarListDragIndex.value = null
|
|
521
|
+
scalarListDropIndex.value = null
|
|
522
|
+
return
|
|
523
|
+
}
|
|
524
|
+
const itemType = getScalarListItemType(props.node.definition?.type || "str") ?? "string"
|
|
525
|
+
const persistedItems = normalizeScalarListInputItems(getScalarListInputItems(value), itemType)
|
|
526
|
+
if (scalarListDraftRows.value) {
|
|
527
|
+
const draftItems = normalizeScalarListInputItems(scalarListDraftRows.value, itemType)
|
|
528
|
+
if (!areArraysEqual(persistedItems, draftItems)) {
|
|
529
|
+
scalarListDraftRows.value = null
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (scalarListJsonDraft.value !== null) {
|
|
533
|
+
const parsedDraft = parseScalarListJsonValue(scalarListJsonDraft.value, itemType)
|
|
534
|
+
if (parsedDraft.ok && !areArraysEqual(persistedItems, parsedDraft.value)) {
|
|
535
|
+
scalarListJsonDraft.value = null
|
|
536
|
+
scalarListJsonError.value = ""
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
{ immediate: true },
|
|
541
|
+
)
|
|
542
|
+
|
|
293
543
|
watch(
|
|
294
544
|
() => {
|
|
295
545
|
const type = props.node.definition?.type || "str"
|
|
@@ -424,7 +674,7 @@ export default defineComponent({
|
|
|
424
674
|
}
|
|
425
675
|
}
|
|
426
676
|
|
|
427
|
-
function
|
|
677
|
+
function syncCompositeControlLayout(control: HTMLElement) {
|
|
428
678
|
applyVarStackWidth(control, inputKind)
|
|
429
679
|
}
|
|
430
680
|
|
|
@@ -469,12 +719,16 @@ export default defineComponent({
|
|
|
469
719
|
}
|
|
470
720
|
}
|
|
471
721
|
|
|
472
|
-
const renderHeaderAssignerActions = (): VNode | null => {
|
|
473
|
-
|
|
722
|
+
const renderHeaderAssignerActions = (headerAction?: VNode | null): VNode | null => {
|
|
723
|
+
const hasAssignerActions = ["file", "code", "scalar-list"].includes(inputKind) && Boolean(props.assignerControl || props.assignerStatus)
|
|
724
|
+
if (!headerAction && !hasAssignerActions) {
|
|
474
725
|
return null
|
|
475
726
|
}
|
|
476
727
|
|
|
477
728
|
return h("span", { class: "aimd-rec-inline__header-assigner-actions" }, [
|
|
729
|
+
headerAction
|
|
730
|
+
? h("span", { class: "aimd-rec-inline__header-extra-action" }, [headerAction])
|
|
731
|
+
: null,
|
|
478
732
|
props.assignerControl
|
|
479
733
|
? h("span", { class: "aimd-rec-inline__header-assigner-action" }, [props.assignerControl])
|
|
480
734
|
: null,
|
|
@@ -484,7 +738,7 @@ export default defineComponent({
|
|
|
484
738
|
])
|
|
485
739
|
}
|
|
486
740
|
|
|
487
|
-
const renderVarLabel = (): VNode => {
|
|
741
|
+
const renderVarLabel = (headerAction?: VNode | null): VNode => {
|
|
488
742
|
const metaTitle = normalizeMetaString(meta?.title)
|
|
489
743
|
const definitionTitle = getAimdFieldTitle(node.definition)
|
|
490
744
|
const displayTitle = metaTitle ?? getAimdFieldDisplayLabel(id, node.definition)
|
|
@@ -513,11 +767,11 @@ export default defineComponent({
|
|
|
513
767
|
tabindex: hasHelp ? 0 : undefined,
|
|
514
768
|
"aria-label": help.tooltip || undefined,
|
|
515
769
|
}, [
|
|
516
|
-
h("span", { class: "aimd-field__title" }, displayTitle),
|
|
517
|
-
hasCustomTitle ? h("span", { class: "aimd-field__key" }, id) : null,
|
|
770
|
+
h("span", { class: "aimd-field__title", title: displayTitle }, displayTitle),
|
|
771
|
+
hasCustomTitle ? h("span", { class: "aimd-field__key", title: id }, id) : null,
|
|
518
772
|
renderFieldMetadataPopover(help),
|
|
519
773
|
]),
|
|
520
|
-
renderHeaderAssignerActions(),
|
|
774
|
+
renderHeaderAssignerActions(headerAction),
|
|
521
775
|
])
|
|
522
776
|
}
|
|
523
777
|
|
|
@@ -547,6 +801,11 @@ export default defineComponent({
|
|
|
547
801
|
const enumOptions = meta?.enumOptions ?? []
|
|
548
802
|
if (enumOptions.length) {
|
|
549
803
|
const selectedEnumValue = getVarEnumSelectValue(enumOptions, props.value)
|
|
804
|
+
const emptyEnumValue = isNullableVarType(type) ? null : ""
|
|
805
|
+
const showEmptyEnumOption = emptyEnumValue === null || selectedEnumValue === ""
|
|
806
|
+
const emptyEnumLabel = emptyEnumValue === null
|
|
807
|
+
? getAimdRecorderEmptyValueLabel(props.messages)
|
|
808
|
+
: placeholder ?? ""
|
|
550
809
|
return h("span", {
|
|
551
810
|
class: [
|
|
552
811
|
"aimd-rec-inline aimd-rec-inline--var-stacked aimd-field-wrapper",
|
|
@@ -561,13 +820,13 @@ export default defineComponent({
|
|
|
561
820
|
disabled,
|
|
562
821
|
value: selectedEnumValue,
|
|
563
822
|
onChange: (e: Event) => {
|
|
564
|
-
const value = getVarEnumValueFromSelectValue(enumOptions, (e.target as HTMLSelectElement).value)
|
|
823
|
+
const value = getVarEnumValueFromSelectValue(enumOptions, (e.target as HTMLSelectElement).value, emptyEnumValue)
|
|
565
824
|
emit("change", { id, value, type, inputKind })
|
|
566
825
|
},
|
|
567
826
|
onBlur: onVarBlur,
|
|
568
827
|
}, [
|
|
569
|
-
|
|
570
|
-
? h("option", { value: "" },
|
|
828
|
+
showEmptyEnumOption
|
|
829
|
+
? h("option", { value: "" }, emptyEnumLabel)
|
|
571
830
|
: null,
|
|
572
831
|
...enumOptions.map((opt, index) => h("option", { key: `${index}:${String(opt.value)}`, value: String(index) }, opt.label)),
|
|
573
832
|
])),
|
|
@@ -579,7 +838,7 @@ export default defineComponent({
|
|
|
579
838
|
const renderStackedVar = (
|
|
580
839
|
control: VNode,
|
|
581
840
|
variantClass?: string | string[],
|
|
582
|
-
options: { controlRow?: boolean } = {},
|
|
841
|
+
options: { controlRow?: boolean; headerAction?: VNode | null } = {},
|
|
583
842
|
): VNode =>
|
|
584
843
|
h("span", {
|
|
585
844
|
class: [
|
|
@@ -590,7 +849,7 @@ export default defineComponent({
|
|
|
590
849
|
...extraClasses,
|
|
591
850
|
],
|
|
592
851
|
}, [
|
|
593
|
-
renderVarLabel(),
|
|
852
|
+
renderVarLabel(options.headerAction),
|
|
594
853
|
options.controlRow === false ? control : renderControlRow(control),
|
|
595
854
|
renderAssignerError(),
|
|
596
855
|
])
|
|
@@ -616,6 +875,26 @@ export default defineComponent({
|
|
|
616
875
|
)
|
|
617
876
|
}
|
|
618
877
|
|
|
878
|
+
if (inputKind === "boolean-select") {
|
|
879
|
+
return renderStackedVar(
|
|
880
|
+
h("select", {
|
|
881
|
+
"data-rec-focus-key": `var:${id}`,
|
|
882
|
+
class: "aimd-rec-inline__value-control aimd-rec-inline__input aimd-rec-inline__input--stacked aimd-rec-inline__select aimd-rec-inline__boolean-select",
|
|
883
|
+
disabled,
|
|
884
|
+
value: String(displayValue),
|
|
885
|
+
onVnodeMounted: (vnode: any) => applyVarStackWidth(vnode.el as HTMLElement, inputKind),
|
|
886
|
+
onVnodeUpdated: (vnode: any) => applyVarStackWidth(vnode.el as HTMLElement, inputKind),
|
|
887
|
+
onChange: (event: Event) => onVarChange((event.target as HTMLSelectElement).value),
|
|
888
|
+
onBlur: onVarBlur,
|
|
889
|
+
}, [
|
|
890
|
+
h("option", { value: "" }, getAimdRecorderEmptyValueLabel(props.messages)),
|
|
891
|
+
h("option", { value: "true" }, props.messages.boolean.true),
|
|
892
|
+
h("option", { value: "false" }, props.messages.boolean.false),
|
|
893
|
+
]),
|
|
894
|
+
"aimd-rec-inline--var-stacked--boolean-select",
|
|
895
|
+
)
|
|
896
|
+
}
|
|
897
|
+
|
|
619
898
|
if (inputKind === "textarea" || inputKind === "dna") {
|
|
620
899
|
return renderStackedVar(
|
|
621
900
|
h("textarea", {
|
|
@@ -687,7 +966,7 @@ export default defineComponent({
|
|
|
687
966
|
fileUploadError.value = ""
|
|
688
967
|
lastSelectedFileInfo.value = null
|
|
689
968
|
resolvedFileInfo.value = null
|
|
690
|
-
emit("change", { id, value: "", type, inputKind })
|
|
969
|
+
emit("change", { id, value: isNullableVarType(type) ? null : "", type, inputKind })
|
|
691
970
|
}
|
|
692
971
|
const actionButton = (
|
|
693
972
|
kind: "download" | "open" | "clear" | "replace" | "preview",
|
|
@@ -708,8 +987,8 @@ export default defineComponent({
|
|
|
708
987
|
h("span", {
|
|
709
988
|
class: "aimd-rec-inline__value-control aimd-rec-inline__file-control",
|
|
710
989
|
"data-file-kind": fileConfig.kind,
|
|
711
|
-
onVnodeMounted: (vnode: any) =>
|
|
712
|
-
onVnodeUpdated: (vnode: any) =>
|
|
990
|
+
onVnodeMounted: (vnode: any) => syncCompositeControlLayout(vnode.el as HTMLElement),
|
|
991
|
+
onVnodeUpdated: (vnode: any) => syncCompositeControlLayout(vnode.el as HTMLElement),
|
|
713
992
|
}, [
|
|
714
993
|
hasFileValue
|
|
715
994
|
? h("span", { class: "aimd-rec-file-card" }, [
|
|
@@ -821,6 +1100,299 @@ export default defineComponent({
|
|
|
821
1100
|
)
|
|
822
1101
|
}
|
|
823
1102
|
|
|
1103
|
+
if (inputKind === "scalar-list") {
|
|
1104
|
+
const scalarListItemType = getScalarListItemType(type) ?? "string"
|
|
1105
|
+
const isNumericScalarList = scalarListItemType === "int" || scalarListItemType === "float"
|
|
1106
|
+
const persistedRows = getScalarListInputItems(props.value)
|
|
1107
|
+
const rows = scalarListDraftRows.value ?? (persistedRows.length > 0 ? persistedRows : [""])
|
|
1108
|
+
const emitScalarListRows = (nextRows: string[]) => {
|
|
1109
|
+
const visibleRows = nextRows.length > 0 ? nextRows : [""]
|
|
1110
|
+
scalarListDraftRows.value = visibleRows
|
|
1111
|
+
emit("change", {
|
|
1112
|
+
id,
|
|
1113
|
+
value: normalizeScalarListInputItems(visibleRows, scalarListItemType),
|
|
1114
|
+
type,
|
|
1115
|
+
inputKind,
|
|
1116
|
+
})
|
|
1117
|
+
}
|
|
1118
|
+
const updateScalarListRow = (rowIndex: number, value: string) => {
|
|
1119
|
+
const nextRows = rows.slice()
|
|
1120
|
+
nextRows[rowIndex] = value
|
|
1121
|
+
emitScalarListRows(nextRows)
|
|
1122
|
+
}
|
|
1123
|
+
const removeScalarListRow = (rowIndex: number) => {
|
|
1124
|
+
emitScalarListRows(rows.filter((_, index) => index !== rowIndex))
|
|
1125
|
+
}
|
|
1126
|
+
const addScalarListRow = () => {
|
|
1127
|
+
emitScalarListRows([...rows, ""])
|
|
1128
|
+
}
|
|
1129
|
+
const resetScalarListDragState = () => {
|
|
1130
|
+
scalarListDragIndex.value = null
|
|
1131
|
+
scalarListDropIndex.value = null
|
|
1132
|
+
}
|
|
1133
|
+
const getScalarListDragSourceIndex = (event: DragEvent): number | null => {
|
|
1134
|
+
const transferred = event.dataTransfer?.getData("text/plain")
|
|
1135
|
+
const parsed = transferred ? Number.parseInt(transferred, 10) : NaN
|
|
1136
|
+
if (Number.isInteger(parsed) && parsed >= 0 && parsed < rows.length) {
|
|
1137
|
+
return parsed
|
|
1138
|
+
}
|
|
1139
|
+
return scalarListDragIndex.value
|
|
1140
|
+
}
|
|
1141
|
+
const reorderScalarListRow = (sourceIndex: number, targetIndex: number) => {
|
|
1142
|
+
if (sourceIndex === targetIndex || sourceIndex < 0 || targetIndex < 0 || sourceIndex >= rows.length || targetIndex >= rows.length) {
|
|
1143
|
+
return
|
|
1144
|
+
}
|
|
1145
|
+
const nextRows = rows.slice()
|
|
1146
|
+
const [moved] = nextRows.splice(sourceIndex, 1)
|
|
1147
|
+
nextRows.splice(targetIndex, 0, moved)
|
|
1148
|
+
emitScalarListRows(nextRows)
|
|
1149
|
+
}
|
|
1150
|
+
const onScalarListDragStart = (rowIndex: number, event: DragEvent) => {
|
|
1151
|
+
scalarListDragIndex.value = rowIndex
|
|
1152
|
+
scalarListDropIndex.value = null
|
|
1153
|
+
if (event.dataTransfer) {
|
|
1154
|
+
event.dataTransfer.effectAllowed = "move"
|
|
1155
|
+
event.dataTransfer.setData("text/plain", String(rowIndex))
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
const onScalarListDragOver = (rowIndex: number, event: DragEvent) => {
|
|
1159
|
+
const sourceIndex = getScalarListDragSourceIndex(event)
|
|
1160
|
+
if (sourceIndex === null || sourceIndex === rowIndex) {
|
|
1161
|
+
return
|
|
1162
|
+
}
|
|
1163
|
+
event.preventDefault()
|
|
1164
|
+
scalarListDropIndex.value = rowIndex
|
|
1165
|
+
if (event.dataTransfer) {
|
|
1166
|
+
event.dataTransfer.dropEffect = "move"
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
const onScalarListDrop = (rowIndex: number, event: DragEvent) => {
|
|
1170
|
+
event.preventDefault()
|
|
1171
|
+
const sourceIndex = getScalarListDragSourceIndex(event)
|
|
1172
|
+
resetScalarListDragState()
|
|
1173
|
+
if (sourceIndex === null) {
|
|
1174
|
+
return
|
|
1175
|
+
}
|
|
1176
|
+
reorderScalarListRow(sourceIndex, rowIndex)
|
|
1177
|
+
}
|
|
1178
|
+
const getScalarListJsonErrorMessage = (error: ScalarListJsonParseError): string => {
|
|
1179
|
+
if (error === "array") {
|
|
1180
|
+
return props.messages.scalarList.jsonInvalidArray
|
|
1181
|
+
}
|
|
1182
|
+
if (error === "item") {
|
|
1183
|
+
return props.messages.scalarList.jsonInvalidItem
|
|
1184
|
+
}
|
|
1185
|
+
return props.messages.scalarList.jsonInvalidSyntax
|
|
1186
|
+
}
|
|
1187
|
+
const getScalarListJsonDraft = () => (
|
|
1188
|
+
scalarListJsonDraft.value
|
|
1189
|
+
?? formatScalarListJsonValue(scalarListDraftRows.value ?? props.value, scalarListItemType)
|
|
1190
|
+
)
|
|
1191
|
+
const emitScalarListJsonDraft = (rawValue: string) => {
|
|
1192
|
+
scalarListJsonDraft.value = rawValue
|
|
1193
|
+
const parsed = parseScalarListJsonValue(rawValue, scalarListItemType)
|
|
1194
|
+
if (!parsed.ok) {
|
|
1195
|
+
scalarListJsonError.value = getScalarListJsonErrorMessage(parsed.error)
|
|
1196
|
+
return
|
|
1197
|
+
}
|
|
1198
|
+
scalarListJsonError.value = ""
|
|
1199
|
+
scalarListDraftRows.value = parsed.value.length > 0 ? getScalarListInputItems(parsed.value) : [""]
|
|
1200
|
+
emit("change", {
|
|
1201
|
+
id,
|
|
1202
|
+
value: parsed.value,
|
|
1203
|
+
type,
|
|
1204
|
+
inputKind,
|
|
1205
|
+
})
|
|
1206
|
+
}
|
|
1207
|
+
const setScalarListMode = (mode: ScalarListEditMode) => {
|
|
1208
|
+
if (scalarListMode.value === mode) {
|
|
1209
|
+
return
|
|
1210
|
+
}
|
|
1211
|
+
if (mode === "json") {
|
|
1212
|
+
scalarListJsonDraft.value = formatScalarListJsonValue(scalarListDraftRows.value ?? props.value, scalarListItemType)
|
|
1213
|
+
scalarListJsonError.value = ""
|
|
1214
|
+
} else {
|
|
1215
|
+
scalarListJsonDraft.value = null
|
|
1216
|
+
scalarListJsonError.value = ""
|
|
1217
|
+
}
|
|
1218
|
+
scalarListMode.value = mode
|
|
1219
|
+
}
|
|
1220
|
+
const modeButton = (mode: ScalarListEditMode, label: string) => h("button", {
|
|
1221
|
+
type: "button",
|
|
1222
|
+
class: [
|
|
1223
|
+
"aimd-rec-scalar-list__mode-button",
|
|
1224
|
+
scalarListMode.value === mode ? "aimd-rec-scalar-list__mode-button--active" : undefined,
|
|
1225
|
+
],
|
|
1226
|
+
disabled,
|
|
1227
|
+
"aria-pressed": scalarListMode.value === mode,
|
|
1228
|
+
onClick: () => setScalarListMode(mode),
|
|
1229
|
+
}, label)
|
|
1230
|
+
const modeToolbar = h("span", { class: "aimd-rec-scalar-list__toolbar" }, [
|
|
1231
|
+
h("span", { class: "aimd-rec-scalar-list__mode" }, [
|
|
1232
|
+
modeButton("items", props.messages.scalarList.itemsMode),
|
|
1233
|
+
modeButton("json", props.messages.scalarList.jsonMode),
|
|
1234
|
+
]),
|
|
1235
|
+
])
|
|
1236
|
+
const rowsControl = h("span", { class: "aimd-rec-scalar-list__rows" }, rows.map((item, rowIndex) => {
|
|
1237
|
+
const canRemoveRow = !disabled && (rows.length > 1 || item.trim().length > 0)
|
|
1238
|
+
const canDragRow = !disabled && rows.length > 1
|
|
1239
|
+
const isDropTarget = scalarListDropIndex.value === rowIndex
|
|
1240
|
+
const dropPlacement = isDropTarget && scalarListDragIndex.value !== null && scalarListDragIndex.value < rowIndex ? "after" : "before"
|
|
1241
|
+
const itemIndexLabel = props.messages.scalarList.itemIndex(rowIndex + 1)
|
|
1242
|
+
const itemPlaceholder = placeholder ?? props.messages.scalarList.itemPlaceholder
|
|
1243
|
+
const isExplicitMultilineItem = !isNumericScalarList && hasExplicitLineBreak(item)
|
|
1244
|
+
const isWideTextItem = !isNumericScalarList && isWideScalarListTextItem(item, itemPlaceholder)
|
|
1245
|
+
const itemControlProps = {
|
|
1246
|
+
"data-rec-focus-key": rowIndex === 0 ? `var:${id}` : `var:${id}:${rowIndex}`,
|
|
1247
|
+
class: [
|
|
1248
|
+
"aimd-rec-scalar-list__input",
|
|
1249
|
+
isNumericScalarList ? "aimd-rec-scalar-list__input--number" : "aimd-rec-scalar-list__input--text",
|
|
1250
|
+
],
|
|
1251
|
+
disabled,
|
|
1252
|
+
placeholder: itemPlaceholder,
|
|
1253
|
+
title: item.trim().length > 0 ? item : undefined,
|
|
1254
|
+
value: item,
|
|
1255
|
+
style: {
|
|
1256
|
+
"--aimd-rec-scalar-list-input-width": `${getScalarListInputFallbackWidthPx(item, itemPlaceholder)}px`,
|
|
1257
|
+
},
|
|
1258
|
+
onBlur: onVarBlur,
|
|
1259
|
+
}
|
|
1260
|
+
return h("span", {
|
|
1261
|
+
key: rowIndex,
|
|
1262
|
+
class: [
|
|
1263
|
+
"aimd-rec-scalar-list__row",
|
|
1264
|
+
canDragRow ? "aimd-rec-scalar-list__row--has-drag" : undefined,
|
|
1265
|
+
canRemoveRow ? "aimd-rec-scalar-list__row--has-remove" : undefined,
|
|
1266
|
+
isNumericScalarList ? "aimd-rec-scalar-list__row--number" : "aimd-rec-scalar-list__row--text",
|
|
1267
|
+
isExplicitMultilineItem || isWideTextItem ? "aimd-rec-scalar-list__row--multiline" : undefined,
|
|
1268
|
+
scalarListDragIndex.value === rowIndex ? "aimd-rec-scalar-list__row--dragging" : undefined,
|
|
1269
|
+
isDropTarget ? "aimd-rec-scalar-list__row--drop-target" : undefined,
|
|
1270
|
+
isDropTarget ? `aimd-rec-scalar-list__row--drop-target-${dropPlacement}` : undefined,
|
|
1271
|
+
],
|
|
1272
|
+
onDragover: (event: DragEvent) => onScalarListDragOver(rowIndex, event),
|
|
1273
|
+
onDrop: (event: DragEvent) => onScalarListDrop(rowIndex, event),
|
|
1274
|
+
}, [
|
|
1275
|
+
canDragRow
|
|
1276
|
+
? h("button", {
|
|
1277
|
+
type: "button",
|
|
1278
|
+
class: "aimd-rec-scalar-list__drag",
|
|
1279
|
+
title: props.messages.scalarList.dragItem,
|
|
1280
|
+
"aria-label": props.messages.scalarList.dragItem,
|
|
1281
|
+
draggable: true,
|
|
1282
|
+
onDragstart: (event: DragEvent) => onScalarListDragStart(rowIndex, event),
|
|
1283
|
+
onDragend: resetScalarListDragState,
|
|
1284
|
+
}, [
|
|
1285
|
+
renderUtilityIcon("drag"),
|
|
1286
|
+
h("span", { class: "aimd-rec-scalar-list__icon-label" }, props.messages.scalarList.dragItem),
|
|
1287
|
+
])
|
|
1288
|
+
: null,
|
|
1289
|
+
h("span", {
|
|
1290
|
+
class: "aimd-rec-scalar-list__index",
|
|
1291
|
+
title: itemIndexLabel,
|
|
1292
|
+
"aria-label": itemIndexLabel,
|
|
1293
|
+
}, String(rowIndex + 1)),
|
|
1294
|
+
isNumericScalarList
|
|
1295
|
+
? h("input", {
|
|
1296
|
+
...itemControlProps,
|
|
1297
|
+
type: "number",
|
|
1298
|
+
inputmode: scalarListItemType === "int" ? "numeric" : scalarListItemType === "float" ? "decimal" : undefined,
|
|
1299
|
+
step: scalarListItemType === "int" ? "1" : scalarListItemType === "float" ? "any" : undefined,
|
|
1300
|
+
onVnodeMounted: (vnode: any) => {
|
|
1301
|
+
const el = vnode.el as HTMLInputElement
|
|
1302
|
+
syncScalarListInputWidth(el)
|
|
1303
|
+
},
|
|
1304
|
+
onVnodeUpdated: (vnode: any) => {
|
|
1305
|
+
const el = vnode.el as HTMLInputElement
|
|
1306
|
+
syncScalarListInputWidth(el)
|
|
1307
|
+
},
|
|
1308
|
+
onInput: (event: Event) => {
|
|
1309
|
+
const el = event.target as HTMLInputElement
|
|
1310
|
+
syncScalarListInputWidth(el)
|
|
1311
|
+
updateScalarListRow(rowIndex, el.value)
|
|
1312
|
+
},
|
|
1313
|
+
})
|
|
1314
|
+
: h("textarea", {
|
|
1315
|
+
...itemControlProps,
|
|
1316
|
+
rows: 1,
|
|
1317
|
+
wrap: "soft",
|
|
1318
|
+
onVnodeMounted: (vnode: any) => {
|
|
1319
|
+
const el = vnode.el as HTMLTextAreaElement
|
|
1320
|
+
syncScalarListTextInputLayout(el)
|
|
1321
|
+
},
|
|
1322
|
+
onVnodeUpdated: (vnode: any) => {
|
|
1323
|
+
const el = vnode.el as HTMLTextAreaElement
|
|
1324
|
+
syncScalarListTextInputLayout(el)
|
|
1325
|
+
},
|
|
1326
|
+
onInput: (event: Event) => {
|
|
1327
|
+
const el = event.target as HTMLTextAreaElement
|
|
1328
|
+
syncScalarListTextInputLayout(el)
|
|
1329
|
+
updateScalarListRow(rowIndex, el.value)
|
|
1330
|
+
},
|
|
1331
|
+
}),
|
|
1332
|
+
canRemoveRow
|
|
1333
|
+
? h("button", {
|
|
1334
|
+
type: "button",
|
|
1335
|
+
class: "aimd-rec-scalar-list__remove",
|
|
1336
|
+
title: props.messages.scalarList.removeItem,
|
|
1337
|
+
"aria-label": props.messages.scalarList.removeItem,
|
|
1338
|
+
onClick: () => removeScalarListRow(rowIndex),
|
|
1339
|
+
}, [
|
|
1340
|
+
renderUtilityIcon("clear"),
|
|
1341
|
+
h("span", { class: "aimd-rec-scalar-list__icon-label" }, props.messages.scalarList.removeItem),
|
|
1342
|
+
])
|
|
1343
|
+
: null,
|
|
1344
|
+
])
|
|
1345
|
+
}))
|
|
1346
|
+
const addButton = !disabled
|
|
1347
|
+
? h("button", {
|
|
1348
|
+
type: "button",
|
|
1349
|
+
class: "aimd-rec-scalar-list__add",
|
|
1350
|
+
title: props.messages.scalarList.addItem,
|
|
1351
|
+
onClick: addScalarListRow,
|
|
1352
|
+
}, [
|
|
1353
|
+
renderUtilityIcon("add"),
|
|
1354
|
+
h("span", { class: "aimd-rec-scalar-list__add-label" }, props.messages.scalarList.addItem),
|
|
1355
|
+
])
|
|
1356
|
+
: null
|
|
1357
|
+
const itemsControl = h("span", { class: "aimd-rec-scalar-list__items" }, [
|
|
1358
|
+
rowsControl,
|
|
1359
|
+
addButton,
|
|
1360
|
+
].filter((child): child is VNode => Boolean(child)))
|
|
1361
|
+
const jsonControl = h("span", { class: "aimd-rec-scalar-list__json-wrap" }, [
|
|
1362
|
+
h(AimdCodeField, {
|
|
1363
|
+
"data-rec-focus-key": `var:${id}:json`,
|
|
1364
|
+
class: [
|
|
1365
|
+
"aimd-rec-scalar-list__json-editor",
|
|
1366
|
+
scalarListJsonError.value ? "aimd-rec-scalar-list__json-editor--invalid" : undefined,
|
|
1367
|
+
],
|
|
1368
|
+
modelValue: getScalarListJsonDraft(),
|
|
1369
|
+
language: "json",
|
|
1370
|
+
disabled,
|
|
1371
|
+
compact: true,
|
|
1372
|
+
"aria-label": getScalarListJsonPlaceholder(scalarListItemType),
|
|
1373
|
+
"onUpdate:modelValue": (nextValue: string) => emitScalarListJsonDraft(nextValue),
|
|
1374
|
+
onBlur: onVarBlur,
|
|
1375
|
+
}),
|
|
1376
|
+
scalarListJsonError.value
|
|
1377
|
+
? h("span", { class: "aimd-rec-scalar-list__json-error" }, scalarListJsonError.value)
|
|
1378
|
+
: null,
|
|
1379
|
+
])
|
|
1380
|
+
|
|
1381
|
+
return renderStackedVar(
|
|
1382
|
+
h("span", {
|
|
1383
|
+
class: "aimd-rec-inline__value-control aimd-rec-inline__scalar-list",
|
|
1384
|
+
onVnodeMounted: (vnode: any) => syncCompositeControlLayout(vnode.el as HTMLElement),
|
|
1385
|
+
onVnodeUpdated: (vnode: any) => syncCompositeControlLayout(vnode.el as HTMLElement),
|
|
1386
|
+
}, [
|
|
1387
|
+
...(scalarListMode.value === "json"
|
|
1388
|
+
? [jsonControl]
|
|
1389
|
+
: [itemsControl]),
|
|
1390
|
+
]),
|
|
1391
|
+
"aimd-rec-inline--var-stacked--scalar-list",
|
|
1392
|
+
{ controlRow: false, headerAction: modeToolbar },
|
|
1393
|
+
)
|
|
1394
|
+
}
|
|
1395
|
+
|
|
824
1396
|
if (inputKind === "text") {
|
|
825
1397
|
return renderStackedVar(
|
|
826
1398
|
h("textarea", {
|