@airalogy/aimd-recorder 1.17.0 → 1.19.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 +42 -10
- package/README.zh-CN.md +42 -10
- package/dist/AimdCodeField-BQUuM-EF.js +182 -0
- package/dist/{AimdDnaSequenceField-D6ZgCDpp.js → AimdDnaSequenceField-TBKunqU_.js} +2 -2
- package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-B5Tq4zPV.js → AimdEditor.vue_vue_type_style_index_0_lang-tdh0dJNa.js} +3922 -3829
- package/dist/AimdMarkdownField-DmNX2g4j.js +254 -0
- package/dist/AimdMarkdownNoteField-B5ruzmwS.js +259 -0
- package/dist/{_commonjsHelpers-CZXJ37nu.js → _commonjsHelpers-B5RozER-.js} +2 -2
- package/dist/aimd-recorder.css +1 -1
- package/dist/arc-B-vsgEXF.js +83 -0
- package/dist/architectureDiagram-3BPJPVTR-BwPNOtNH.js +4692 -0
- package/dist/blockDiagram-GPEHLZMM-CMUI4kKc.js +2425 -0
- package/dist/c4Diagram-AAUBKEIU-Cpmfsy_s.js +1577 -0
- package/dist/channel-DlMAXHQK.js +5 -0
- package/dist/chunk-2J33WTMH-DP9BS2ux.js +19 -0
- package/dist/chunk-4BX2VUAB-ncsOeLMb.js +8 -0
- package/dist/chunk-55IACEB6-C7wHk4B7.js +8 -0
- package/dist/chunk-727SXJPM-Caa5aVUO.js +1528 -0
- package/dist/chunk-AQP2D5EJ-CL8egKqD.js +1387 -0
- package/dist/chunk-FMBD7UC4-heVR6BSA.js +19 -0
- package/dist/chunk-ND2GUHAM-BYH-wC2J.js +68 -0
- package/dist/chunk-QZHKN3VN-Bx2K7vkq.js +15 -0
- package/dist/classDiagram-4FO5ZUOK-BLLfLYy0.js +16 -0
- package/dist/classDiagram-v2-Q7XG4LA2-BLLfLYy0.js +16 -0
- package/dist/components.js +3776 -2247
- package/dist/composables.js +96 -70
- package/dist/cose-bilkent-S5V4N54A-E1YmM_xr.js +2609 -0
- package/dist/cytoscape.esm-r59gEWFs.js +18710 -0
- package/dist/dagre-BM42HDAG-BsXpQirH.js +445 -0
- package/dist/defaultLocale-BgPVtth8.js +171 -0
- package/dist/diagram-2AECGRRQ-CamqbWlY.js +217 -0
- package/dist/diagram-5GNKFQAL-DZyRFcOC.js +123 -0
- package/dist/diagram-KO2AKTUF-CmkGcy7R.js +461 -0
- package/dist/diagram-LMA3HP47-IdDwQPZ-.js +142 -0
- package/dist/diagram-OG6HWLK6-t0LBcUIU.js +528 -0
- package/dist/erDiagram-TEJ5UH35-DJBY2iZG.js +899 -0
- package/dist/flowDiagram-I6XJVG4X-DE4MzPPk.js +1628 -0
- package/dist/ganttDiagram-6RSMTGT7-CmAc35Yw.js +2707 -0
- package/dist/gitGraphDiagram-PVQCEYII-DDQZ5flw.js +815 -0
- package/dist/graph-BsJ8-1Pq.js +1510 -0
- package/dist/index.js +110 -83
- package/dist/infoDiagram-5YYISTIA-DSZjFR5g.js +24 -0
- package/dist/init-DjUOC4st.js +16 -0
- package/dist/ishikawaDiagram-YF4QCWOH-DCO9dx2L.js +621 -0
- package/dist/journeyDiagram-JHISSGLW-b-PpuBqg.js +834 -0
- package/dist/kanban-definition-UN3LZRKU-BjclDuJZ.js +724 -0
- package/dist/katex-DNob3HGn.js +11690 -0
- package/dist/layout-D4wqKu72.js +1703 -0
- package/dist/linear-Voc3BJib.js +259 -0
- package/dist/mermaid.core-Dt_VbeGP.js +15940 -0
- package/dist/mindmap-definition-RKZ34NQL-B3vrXRVY.js +827 -0
- package/dist/ordinal-B6-f3MAq.js +61 -0
- package/dist/pieDiagram-4H26LBE5-DFpWxSxk.js +163 -0
- package/dist/quadrantDiagram-W4KKPZXB-BYHcrGoB.js +1024 -0
- package/dist/record.js +1199 -0
- package/dist/requirementDiagram-4Y6WPE33-C-FgWrRz.js +882 -0
- package/dist/sankeyDiagram-5OEKKPKP-IwN0Evji.js +847 -0
- package/dist/sequenceDiagram-3UESZ5HK-_OnqhBO2.js +2891 -0
- package/dist/stateDiagram-AJRCARHV-BRLv0Zcw.js +263 -0
- package/dist/stateDiagram-v2-BHNVJYJU-BofX0AdS.js +16 -0
- package/dist/timeline-definition-PNZ67QCA-C-DpPLpw.js +1055 -0
- package/dist/{useFieldRendering-xLajJhyA.js → useCodeBlockRendering-DoTZaJTW.js} +1528 -1725
- package/dist/useMonacoAutoHeight-D4T-El3J.js +66 -0
- package/dist/vennDiagram-CIIHVFJN-zTHQR9Oq.js +1557 -0
- package/dist/wardley-L42UT6IY-D7b2ujEZ.js +22512 -0
- package/dist/wardleyDiagram-YWT4CUSO-au5koizO.js +675 -0
- package/dist/xychartDiagram-2RQKCTM6-BNf12P8z.js +1342 -0
- package/package.json +13 -8
- package/src/__tests__/assigner-graph.test.ts +82 -0
- package/src/__tests__/assigner-runner-dependent-data.test.ts +32 -0
- package/src/__tests__/markdown-field.test.ts +150 -1
- package/src/__tests__/markdown-note-field.test.ts +86 -3
- package/src/__tests__/recorder-assigner-control.test.ts +993 -0
- package/src/__tests__/recorder-editor.test.ts +17 -0
- package/src/__tests__/recorder-markdown-assigner-integration.test.ts +49 -0
- package/src/__tests__/step-field.test.ts +47 -1
- package/src/__tests__/type-plugins.test.ts +1 -0
- package/src/__tests__/var-field-render.test.ts +806 -1
- package/src/components/AimdAssignerGraph.vue +816 -0
- package/src/components/AimdCodeField.vue +24 -5
- package/src/components/AimdMarkdownField.vue +556 -11
- package/src/components/AimdMarkdownNoteField.vue +241 -30
- package/src/components/AimdRecorder.vue +1619 -99
- package/src/components/AimdRecorderEditor.vue +276 -8
- package/src/components/AimdRecorderWysiwygFieldHost.vue +6 -0
- package/src/components/AimdRecorderWysiwygSurface.vue +32 -0
- package/src/components/AimdStepCheckField.vue +82 -18
- package/src/components/AimdVarField.vue +694 -25
- package/src/components/AimdVarTableField.vue +325 -138
- package/src/components/icons/AimdAssignerCalculatorIcon.vue +18 -0
- package/src/components/icons/AimdAssignerCloudStatusIcon.vue +22 -0
- package/src/components/index.ts +9 -1
- package/src/components/recorderMilkdownPlugin.ts +14 -0
- package/src/composables/__tests__/useRecordState.test.ts +86 -0
- package/src/composables/__tests__/useVarHelpers.test.ts +175 -0
- package/src/composables/index.ts +28 -1
- package/src/composables/useAssignerRunner.ts +376 -0
- package/src/composables/useCodeBlockRendering.ts +51 -0
- package/src/composables/useFieldRendering.ts +32 -4
- package/src/composables/useMonacoAutoHeight.ts +127 -0
- package/src/composables/useRecordState.ts +22 -3
- package/src/composables/useVarHelpers.ts +237 -32
- package/src/index.ts +20 -1
- package/src/locales.ts +45 -0
- package/src/record/index.ts +120 -0
- package/src/styles/aimd.css +216 -1
- package/src/type-plugins.ts +7 -0
- package/src/type-utils.ts +1 -3
- package/src/types.ts +130 -2
- package/dist/AimdCodeField-DC3DPvgc.js +0 -172
- package/dist/AimdMarkdownField-BJ20QtO8.js +0 -67
- package/dist/AimdMarkdownNoteField-DwAQhoyk.js +0 -186
package/src/components/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { defineAsyncComponent } from "vue"
|
|
9
|
+
import AimdAssignerGraph from "./AimdAssignerGraph.vue"
|
|
9
10
|
import AimdRecorder from "./AimdRecorder.vue"
|
|
10
11
|
import AimdRecorderEditor from "./AimdRecorderEditor.vue"
|
|
11
12
|
import AimdQuizRecorder from "./AimdQuizRecorder.vue"
|
|
@@ -13,7 +14,14 @@ import AimdQuizRecorder from "./AimdQuizRecorder.vue"
|
|
|
13
14
|
const AimdDnaSequenceField = defineAsyncComponent(() => import("./AimdDnaSequenceField.vue"))
|
|
14
15
|
const AimdMarkdownField = defineAsyncComponent(() => import("./AimdMarkdownField.vue"))
|
|
15
16
|
|
|
16
|
-
export {
|
|
17
|
+
export {
|
|
18
|
+
AimdAssignerGraph,
|
|
19
|
+
AimdRecorder,
|
|
20
|
+
AimdRecorderEditor,
|
|
21
|
+
AimdQuizRecorder,
|
|
22
|
+
AimdDnaSequenceField,
|
|
23
|
+
AimdMarkdownField,
|
|
24
|
+
}
|
|
17
25
|
|
|
18
26
|
/**
|
|
19
27
|
* @deprecated Use `AimdRecorder` instead.
|
|
@@ -16,6 +16,12 @@ import {
|
|
|
16
16
|
import type { AimdComponentRenderer } from '@airalogy/aimd-renderer'
|
|
17
17
|
import type { AimdRecorderMessagesInput } from '../locales'
|
|
18
18
|
import type {
|
|
19
|
+
AimdAssignerMap,
|
|
20
|
+
AimdAssignerRunner,
|
|
21
|
+
AimdServerAssignerMap,
|
|
22
|
+
AimdServerAssignerRunner,
|
|
23
|
+
AimdFileInfoResolver,
|
|
24
|
+
AimdFileUploadHandler,
|
|
19
25
|
AimdFieldMeta,
|
|
20
26
|
AimdFieldState,
|
|
21
27
|
AimdProtocolRecordData,
|
|
@@ -44,11 +50,19 @@ export interface RecorderMilkdownSurfaceState {
|
|
|
44
50
|
messages?: AimdRecorderMessagesInput
|
|
45
51
|
stepDetailDisplay: AimdStepDetailDisplay
|
|
46
52
|
fieldMeta?: Record<string, AimdFieldMeta>
|
|
53
|
+
serverAssigners?: AimdServerAssignerMap
|
|
54
|
+
/** @deprecated Use `serverAssigners` instead. */
|
|
55
|
+
assigners?: AimdAssignerMap
|
|
47
56
|
fieldState?: Record<string, AimdFieldState>
|
|
48
57
|
wrapField?: (fieldKey: string, fieldType: string, defaultVNode: any) => any
|
|
49
58
|
customRenderers?: Partial<Record<string, AimdComponentRenderer>>
|
|
50
59
|
fieldAdapters?: AimdRecorderFieldAdapters
|
|
51
60
|
resolveFile?: (src: string) => string | null
|
|
61
|
+
resolveFileInfo?: AimdFileInfoResolver
|
|
62
|
+
uploadFile?: AimdFileUploadHandler
|
|
63
|
+
runServerAssigner?: AimdServerAssignerRunner
|
|
64
|
+
/** @deprecated Use `runServerAssigner` instead. */
|
|
65
|
+
assignerRunner?: AimdAssignerRunner
|
|
52
66
|
typePlugins?: AimdTypePlugin[]
|
|
53
67
|
onUpdateRecord: (value: AimdProtocolRecordData) => void
|
|
54
68
|
onFieldsChange?: (fields: ExtractedAimdFields) => void
|
|
@@ -647,6 +647,92 @@ describe('ensureDefaultsFromFields', () => {
|
|
|
647
647
|
expect(record.quiz.q1).toBe('')
|
|
648
648
|
})
|
|
649
649
|
|
|
650
|
+
it('adds missing var table defaults from extracted AIMD fields', () => {
|
|
651
|
+
const record = createEmptyProtocolRecordData()
|
|
652
|
+
const fields = {
|
|
653
|
+
step: [],
|
|
654
|
+
check: [],
|
|
655
|
+
quiz: [],
|
|
656
|
+
var: [],
|
|
657
|
+
subvar: [],
|
|
658
|
+
assigner: [],
|
|
659
|
+
ref: [],
|
|
660
|
+
fig: [],
|
|
661
|
+
cite: [],
|
|
662
|
+
var_table: [{
|
|
663
|
+
id: 'monitoring_sites',
|
|
664
|
+
scope: 'var_table',
|
|
665
|
+
subvars: [{ id: 'site_id' }, { id: 'elevation_m' }],
|
|
666
|
+
default: [
|
|
667
|
+
{ site_id: 'S01', elevation_m: 128 },
|
|
668
|
+
{ site_id: 'S02', elevation_m: 82 },
|
|
669
|
+
],
|
|
670
|
+
}],
|
|
671
|
+
}
|
|
672
|
+
const changed = ensureDefaultsFromFields(record, fields as any)
|
|
673
|
+
expect(changed).toBe(true)
|
|
674
|
+
expect(record.var.monitoring_sites).toEqual([
|
|
675
|
+
{ site_id: 'S01', elevation_m: '128' },
|
|
676
|
+
{ site_id: 'S02', elevation_m: '82' },
|
|
677
|
+
])
|
|
678
|
+
})
|
|
679
|
+
|
|
680
|
+
it('replaces a generated empty var table placeholder with extracted defaults', () => {
|
|
681
|
+
const record = createEmptyProtocolRecordData()
|
|
682
|
+
record.var.monitoring_sites = [{ site_id: '', elevation_m: '' }]
|
|
683
|
+
const fields = {
|
|
684
|
+
step: [],
|
|
685
|
+
check: [],
|
|
686
|
+
quiz: [],
|
|
687
|
+
var: [],
|
|
688
|
+
subvar: [],
|
|
689
|
+
assigner: [],
|
|
690
|
+
ref: [],
|
|
691
|
+
fig: [],
|
|
692
|
+
cite: [],
|
|
693
|
+
var_table: [{
|
|
694
|
+
id: 'monitoring_sites',
|
|
695
|
+
scope: 'var_table',
|
|
696
|
+
subvars: [{ id: 'site_id' }, { id: 'elevation_m' }],
|
|
697
|
+
default: [
|
|
698
|
+
{ site_id: 'S01', elevation_m: 128 },
|
|
699
|
+
{ site_id: 'S02', elevation_m: 82 },
|
|
700
|
+
],
|
|
701
|
+
}],
|
|
702
|
+
}
|
|
703
|
+
const changed = ensureDefaultsFromFields(record, fields as any)
|
|
704
|
+
expect(changed).toBe(true)
|
|
705
|
+
expect(record.var.monitoring_sites).toEqual([
|
|
706
|
+
{ site_id: 'S01', elevation_m: '128' },
|
|
707
|
+
{ site_id: 'S02', elevation_m: '82' },
|
|
708
|
+
])
|
|
709
|
+
})
|
|
710
|
+
|
|
711
|
+
it('does not overwrite existing var table rows with extracted defaults', () => {
|
|
712
|
+
const record = createEmptyProtocolRecordData()
|
|
713
|
+
record.var.monitoring_sites = [{ site_id: 'USER', elevation_m: '10' }]
|
|
714
|
+
const fields = {
|
|
715
|
+
step: [],
|
|
716
|
+
check: [],
|
|
717
|
+
quiz: [],
|
|
718
|
+
var: [],
|
|
719
|
+
subvar: [],
|
|
720
|
+
assigner: [],
|
|
721
|
+
ref: [],
|
|
722
|
+
fig: [],
|
|
723
|
+
cite: [],
|
|
724
|
+
var_table: [{
|
|
725
|
+
id: 'monitoring_sites',
|
|
726
|
+
scope: 'var_table',
|
|
727
|
+
subvars: [{ id: 'site_id' }, { id: 'elevation_m' }],
|
|
728
|
+
default: [{ site_id: 'S01', elevation_m: 128 }],
|
|
729
|
+
}],
|
|
730
|
+
}
|
|
731
|
+
const changed = ensureDefaultsFromFields(record, fields as any)
|
|
732
|
+
expect(changed).toBe(false)
|
|
733
|
+
expect(record.var.monitoring_sites).toEqual([{ site_id: 'USER', elevation_m: '10' }])
|
|
734
|
+
})
|
|
735
|
+
|
|
650
736
|
it('returns false when nothing changes', () => {
|
|
651
737
|
const record = createEmptyProtocolRecordData()
|
|
652
738
|
const fields = { step: [], check: [], quiz: [], var: [], var_table: [], subvar: [], assigner: [], ref: [], fig: [], cite: [] }
|
|
@@ -3,12 +3,15 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
3
3
|
import {
|
|
4
4
|
normalizeVarTypeName,
|
|
5
5
|
getVarInputKind,
|
|
6
|
+
isStructuredVarType,
|
|
6
7
|
unwrapStructuredValue,
|
|
7
8
|
toBooleanValue,
|
|
8
9
|
toDateValue,
|
|
9
10
|
formatDateTimeWithTimezone,
|
|
10
11
|
normalizeDateTimeValueWithTimezone,
|
|
11
12
|
formatDateForInput,
|
|
13
|
+
getFileDisplayName,
|
|
14
|
+
getFileInputConfig,
|
|
12
15
|
getVarInputDisplayValue,
|
|
13
16
|
parseVarInputValue,
|
|
14
17
|
getNumericConstraintViolation,
|
|
@@ -16,6 +19,8 @@ import {
|
|
|
16
19
|
getNumericInputAttributes,
|
|
17
20
|
calculateVarStackWidth,
|
|
18
21
|
syncAutoWrapTextareaHeight,
|
|
22
|
+
measureVarLabelWidth,
|
|
23
|
+
createSelectedFileValue,
|
|
19
24
|
} from '../useVarHelpers'
|
|
20
25
|
|
|
21
26
|
// ---------------------------------------------------------------------------
|
|
@@ -96,6 +101,14 @@ describe('getVarInputKind', () => {
|
|
|
96
101
|
expect(getVarInputKind('airalogymarkdown')).toBe('textarea')
|
|
97
102
|
})
|
|
98
103
|
|
|
104
|
+
it('returns "textarea" for structured list and object types', () => {
|
|
105
|
+
expect(getVarInputKind('list')).toBe('textarea')
|
|
106
|
+
expect(getVarInputKind('list[str]')).toBe('textarea')
|
|
107
|
+
expect(getVarInputKind('dict[str, int]')).toBe('textarea')
|
|
108
|
+
expect(getVarInputKind('json')).toBe('textarea')
|
|
109
|
+
expect(getVarInputKind('Listener')).toBe('text')
|
|
110
|
+
})
|
|
111
|
+
|
|
99
112
|
it('returns "code" for built-in CodeStr aliases', () => {
|
|
100
113
|
expect(getVarInputKind('PyStr')).toBe('code')
|
|
101
114
|
expect(getVarInputKind('JsStr')).toBe('code')
|
|
@@ -111,6 +124,84 @@ describe('getVarInputKind', () => {
|
|
|
111
124
|
expect(getVarInputKind('str', { inputType: 'yaml' })).toBe('code')
|
|
112
125
|
expect(getVarInputKind('str', { codeLanguage: 'sql' })).toBe('code')
|
|
113
126
|
})
|
|
127
|
+
|
|
128
|
+
it('returns "file" for file-like AIMD types and metadata overrides', () => {
|
|
129
|
+
expect(getVarInputKind('FileIdCSV')).toBe('file')
|
|
130
|
+
expect(getVarInputKind('csv')).toBe('file')
|
|
131
|
+
expect(getVarInputKind('FileIdPNG')).toBe('file')
|
|
132
|
+
expect(getVarInputKind('image')).toBe('file')
|
|
133
|
+
expect(getVarInputKind('str', { inputType: 'audio' })).toBe('file')
|
|
134
|
+
expect(getVarInputKind('str', { kwargs: { file_extension: 'xlsx' } })).toBe('file')
|
|
135
|
+
expect(getVarInputKind('str', { fieldMeta: { accept: '.pdf' } })).toBe('file')
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
// File-like vars
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
|
|
143
|
+
describe('file-like var helpers', () => {
|
|
144
|
+
it('resolves accept strings and display badges for built-in file aliases', () => {
|
|
145
|
+
expect(getFileInputConfig('FileIdCSV')).toMatchObject({
|
|
146
|
+
kind: 'csv',
|
|
147
|
+
accept: '.csv,text/csv',
|
|
148
|
+
badge: 'CSV',
|
|
149
|
+
})
|
|
150
|
+
expect(getFileInputConfig('FileIdPNG')).toMatchObject({
|
|
151
|
+
kind: 'image',
|
|
152
|
+
accept: '.png,image/png',
|
|
153
|
+
badge: 'IMG',
|
|
154
|
+
})
|
|
155
|
+
expect(getFileInputConfig('FileIdMOV')).toMatchObject({
|
|
156
|
+
kind: 'video',
|
|
157
|
+
accept: '.mov,video/quicktime',
|
|
158
|
+
badge: 'VID',
|
|
159
|
+
})
|
|
160
|
+
expect(getFileInputConfig('FileIdWAV')).toMatchObject({
|
|
161
|
+
kind: 'audio',
|
|
162
|
+
accept: '.wav,audio/wav',
|
|
163
|
+
badge: 'AUD',
|
|
164
|
+
})
|
|
165
|
+
expect(getFileInputConfig('str', undefined, { inputType: 'image' })).toMatchObject({
|
|
166
|
+
kind: 'image',
|
|
167
|
+
accept: 'image/*',
|
|
168
|
+
badge: 'IMG',
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
it('honors explicit accept and file extension metadata', () => {
|
|
173
|
+
expect(getFileInputConfig('str', { file_extension: 'xlsx' })).toMatchObject({
|
|
174
|
+
kind: 'document',
|
|
175
|
+
accept: '.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
176
|
+
badge: 'DOC',
|
|
177
|
+
})
|
|
178
|
+
expect(getFileInputConfig('FileIdCSV', undefined, { accept: '.tsv,text/tab-separated-values' })).toMatchObject({
|
|
179
|
+
kind: 'csv',
|
|
180
|
+
accept: '.tsv,text/tab-separated-values',
|
|
181
|
+
badge: 'CSV',
|
|
182
|
+
})
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('extracts display names from file ids and structured file values', () => {
|
|
186
|
+
expect(getFileDisplayName('file-123')).toBe('file-123')
|
|
187
|
+
expect(getFileDisplayName({ name: 'dose.csv' })).toBe('dose.csv')
|
|
188
|
+
expect(getFileDisplayName({ value: { file_name: 'chart.svg' } })).toBe('chart.svg')
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
it('creates serializable selected-file metadata when no host upload handler is provided', () => {
|
|
192
|
+
const file = new File(['a,b\n1,2'], 'dose.csv', {
|
|
193
|
+
type: 'text/csv',
|
|
194
|
+
lastModified: 123,
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
expect(createSelectedFileValue(file)).toEqual({
|
|
198
|
+
format: 'airalogy_selected_file_v1',
|
|
199
|
+
name: 'dose.csv',
|
|
200
|
+
type: 'text/csv',
|
|
201
|
+
size: 7,
|
|
202
|
+
lastModified: 123,
|
|
203
|
+
})
|
|
204
|
+
})
|
|
114
205
|
})
|
|
115
206
|
|
|
116
207
|
// ---------------------------------------------------------------------------
|
|
@@ -358,6 +449,11 @@ describe('getVarInputDisplayValue', () => {
|
|
|
358
449
|
it('stringifies non-string for dna kind', () => {
|
|
359
450
|
expect(getVarInputDisplayValue({ seq: 'ATCG' }, 'dna')).toBe(JSON.stringify({ seq: 'ATCG' }))
|
|
360
451
|
})
|
|
452
|
+
|
|
453
|
+
it('pretty-prints structured list and object values', () => {
|
|
454
|
+
expect(getVarInputDisplayValue(['a', 'b'], 'textarea', { type: 'list[str]' })).toBe(JSON.stringify(['a', 'b'], null, 2))
|
|
455
|
+
expect(getVarInputDisplayValue({ a: 1 }, 'textarea', { type: 'dict[str, int]' })).toBe(JSON.stringify({ a: 1 }, null, 2))
|
|
456
|
+
})
|
|
361
457
|
})
|
|
362
458
|
|
|
363
459
|
// ---------------------------------------------------------------------------
|
|
@@ -389,6 +485,24 @@ describe('parseVarInputValue', () => {
|
|
|
389
485
|
const result = parseVarInputValue('2024-06-15T10:30', undefined, 'datetime')
|
|
390
486
|
expect(typeof result).toBe('string')
|
|
391
487
|
})
|
|
488
|
+
|
|
489
|
+
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')
|
|
492
|
+
})
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
// ---------------------------------------------------------------------------
|
|
496
|
+
// isStructuredVarType
|
|
497
|
+
// ---------------------------------------------------------------------------
|
|
498
|
+
|
|
499
|
+
describe('isStructuredVarType', () => {
|
|
500
|
+
it('detects explicit structured types without matching unrelated names', () => {
|
|
501
|
+
expect(isStructuredVarType('list[str]')).toBe(true)
|
|
502
|
+
expect(isStructuredVarType('dict[str, int]')).toBe(true)
|
|
503
|
+
expect(isStructuredVarType('object')).toBe(true)
|
|
504
|
+
expect(isStructuredVarType('Listener')).toBe(false)
|
|
505
|
+
})
|
|
392
506
|
})
|
|
393
507
|
|
|
394
508
|
// ---------------------------------------------------------------------------
|
|
@@ -414,6 +528,67 @@ describe('calculateVarStackWidth', () => {
|
|
|
414
528
|
})
|
|
415
529
|
})
|
|
416
530
|
|
|
531
|
+
// ---------------------------------------------------------------------------
|
|
532
|
+
// measureVarLabelWidth
|
|
533
|
+
// ---------------------------------------------------------------------------
|
|
534
|
+
|
|
535
|
+
describe('measureVarLabelWidth', () => {
|
|
536
|
+
afterEach(() => {
|
|
537
|
+
vi.restoreAllMocks()
|
|
538
|
+
document.body.innerHTML = ''
|
|
539
|
+
})
|
|
540
|
+
|
|
541
|
+
it('measures visible label tokens without letting metadata popovers expand the field', () => {
|
|
542
|
+
vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockImplementation(() => ({
|
|
543
|
+
measureText: (text: string) => ({ width: text.length * 8 }),
|
|
544
|
+
} as unknown as CanvasRenderingContext2D))
|
|
545
|
+
vi.spyOn(window, 'getComputedStyle').mockImplementation((element: Element) => {
|
|
546
|
+
const classList = (element as HTMLElement).classList
|
|
547
|
+
const horizontalPadding = classList.contains('aimd-field__name')
|
|
548
|
+
? '16px'
|
|
549
|
+
: classList.contains('aimd-field__scope--var')
|
|
550
|
+
? '14px'
|
|
551
|
+
: '0px'
|
|
552
|
+
return {
|
|
553
|
+
fontSize: '14px',
|
|
554
|
+
fontFamily: 'sans-serif',
|
|
555
|
+
fontWeight: '500',
|
|
556
|
+
fontStyle: 'normal',
|
|
557
|
+
paddingLeft: horizontalPadding,
|
|
558
|
+
paddingRight: '0px',
|
|
559
|
+
borderLeftWidth: '0px',
|
|
560
|
+
borderRightWidth: '0px',
|
|
561
|
+
marginLeft: '0px',
|
|
562
|
+
marginRight: '0px',
|
|
563
|
+
} as CSSStyleDeclaration
|
|
564
|
+
})
|
|
565
|
+
|
|
566
|
+
const wrapper = document.createElement('span')
|
|
567
|
+
wrapper.className = 'aimd-rec-inline--var-stacked'
|
|
568
|
+
wrapper.innerHTML = `
|
|
569
|
+
<span class="aimd-field__label">
|
|
570
|
+
<span class="aimd-field__scope aimd-field__scope--var">var</span>
|
|
571
|
+
<span class="aimd-field__name aimd-field__metadata-host">
|
|
572
|
+
<span class="aimd-field__title">Sample Name</span>
|
|
573
|
+
<span class="aimd-field__key">sample_name</span>
|
|
574
|
+
<span class="aimd-field__metadata-popover">Human-readable label used throughout this protocol</span>
|
|
575
|
+
</span>
|
|
576
|
+
</span>
|
|
577
|
+
`
|
|
578
|
+
Object.defineProperty(wrapper.querySelector('.aimd-field__label'), 'scrollWidth', {
|
|
579
|
+
configurable: true,
|
|
580
|
+
get: () => 720,
|
|
581
|
+
})
|
|
582
|
+
Object.defineProperty(wrapper.querySelector('.aimd-field__metadata-popover'), 'scrollWidth', {
|
|
583
|
+
configurable: true,
|
|
584
|
+
get: () => 680,
|
|
585
|
+
})
|
|
586
|
+
document.body.appendChild(wrapper)
|
|
587
|
+
|
|
588
|
+
expect(measureVarLabelWidth(wrapper)).toBeLessThan(240)
|
|
589
|
+
})
|
|
590
|
+
})
|
|
591
|
+
|
|
417
592
|
// ---------------------------------------------------------------------------
|
|
418
593
|
// syncAutoWrapTextareaHeight
|
|
419
594
|
// ---------------------------------------------------------------------------
|
package/src/composables/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { captureFocusSnapshot, restoreFocusSnapshot } from './useFocusManagement'
|
|
2
2
|
export type { FocusSnapshot } from './useFocusManagement'
|
|
3
|
+
export { createChainedElementRenderer, useCodeBlockRendering } from './useCodeBlockRendering'
|
|
4
|
+
export { createMonacoAutoHeight, estimateMonacoVisualLineCount } from './useMonacoAutoHeight'
|
|
5
|
+
export type { MonacoAutoHeightController, MonacoAutoHeightEditor, MonacoAutoHeightOptions } from './useMonacoAutoHeight'
|
|
3
6
|
|
|
4
7
|
export {
|
|
5
8
|
cloneRecordData,
|
|
@@ -41,12 +44,19 @@ export {
|
|
|
41
44
|
export {
|
|
42
45
|
normalizeVarTypeName,
|
|
43
46
|
getVarInputKind,
|
|
47
|
+
isStructuredVarType,
|
|
44
48
|
unwrapStructuredValue,
|
|
45
49
|
toBooleanValue,
|
|
46
50
|
toDateValue,
|
|
47
51
|
formatDateTimeWithTimezone,
|
|
48
52
|
normalizeDateTimeValueWithTimezone,
|
|
49
53
|
formatDateForInput,
|
|
54
|
+
getFileDisplayName,
|
|
55
|
+
getFileInputConfig,
|
|
56
|
+
isFileLikeVarType,
|
|
57
|
+
createSelectedFileValue,
|
|
58
|
+
getVarEnumSelectValue,
|
|
59
|
+
getVarEnumValueFromSelectValue,
|
|
50
60
|
getVarInputDisplayValue,
|
|
51
61
|
parseVarInputValue,
|
|
52
62
|
calculateVarStackWidth,
|
|
@@ -55,7 +65,7 @@ export {
|
|
|
55
65
|
syncAutoWrapTextareaHeight,
|
|
56
66
|
applyVarStackWidth,
|
|
57
67
|
} from './useVarHelpers'
|
|
58
|
-
export type { VarInputKind } from './useVarHelpers'
|
|
68
|
+
export type { AimdVarEnumOption, FileInputConfig, FileInputDisplayKind, VarInputKind } from './useVarHelpers'
|
|
59
69
|
|
|
60
70
|
export {
|
|
61
71
|
AIMD_DNA_SEQUENCE_FORMAT,
|
|
@@ -77,6 +87,23 @@ export {
|
|
|
77
87
|
export { useClientAssignerRunner } from './useClientAssignerRunner'
|
|
78
88
|
export type { ClientAssignerRunnerOptions } from './useClientAssignerRunner'
|
|
79
89
|
|
|
90
|
+
export {
|
|
91
|
+
applyAimdAssignedFieldsToRecord,
|
|
92
|
+
buildAimdAssignerDependentData,
|
|
93
|
+
extractAimdAssignedFields,
|
|
94
|
+
getAimdAssignerDependentFields,
|
|
95
|
+
getAimdAssignerFieldKey,
|
|
96
|
+
getAimdAssignerFieldNameSets,
|
|
97
|
+
getAimdAssignerMode,
|
|
98
|
+
getAimdAssignerPayloadFieldKey,
|
|
99
|
+
isReadonlyAimdAssignerMode,
|
|
100
|
+
normalizeAimdAssignerDependentData,
|
|
101
|
+
normalizeAimdAssignerDependentValue,
|
|
102
|
+
normalizeAimdAssignerMode,
|
|
103
|
+
resolveAimdAssigners,
|
|
104
|
+
} from './useAssignerRunner'
|
|
105
|
+
export type { AimdResolvedAssigner } from './useAssignerRunner'
|
|
106
|
+
|
|
80
107
|
export {
|
|
81
108
|
useVarTableDragDrop,
|
|
82
109
|
getVarTableRowKey,
|