@airalogy/aimd-recorder 1.16.0 → 1.17.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/dist/{AimdDnaSequenceField-CPyMqIVh.js → AimdDnaSequenceField-D6ZgCDpp.js} +1 -1
- package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-lyHIpch9.js → AimdEditor.vue_vue_type_style_index_0_lang-B5Tq4zPV.js} +3 -3
- package/dist/{AimdMarkdownField-CX71bOdX.js → AimdMarkdownField-BJ20QtO8.js} +2 -2
- package/dist/{AimdMarkdownNoteField--ssNIQfG.js → AimdMarkdownNoteField-DwAQhoyk.js} +2 -2
- package/dist/aimd-recorder.css +1 -1
- package/dist/components.js +2150 -2064
- package/dist/composables.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{useFieldRendering-Dh6Kib_0.js → useFieldRendering-xLajJhyA.js} +350 -345
- package/package.json +4 -4
- package/src/__tests__/quiz-recorder.test.ts +47 -0
- package/src/__tests__/recorder-check-field.test.ts +103 -0
- package/src/__tests__/step-field.test.ts +40 -3
- package/src/components/AimdQuizOptionFollowups.vue +121 -0
- package/src/components/AimdQuizRecorder.vue +79 -148
- package/src/components/AimdRecorder.vue +124 -28
- package/src/components/AimdStepCheckField.vue +125 -35
- package/src/composables/__tests__/useRecordState.test.ts +28 -0
- package/src/composables/useRecordState.ts +18 -11
- package/src/locales.ts +2 -2
- package/src/styles/aimd.css +20 -5
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
getAimdRecorderQuizTypeLabel,
|
|
17
17
|
getAimdRecorderScopeLabel,
|
|
18
18
|
} from "../locales"
|
|
19
|
+
import AimdQuizOptionFollowups from "./AimdQuizOptionFollowups.vue"
|
|
19
20
|
|
|
20
21
|
interface StemTextSegment {
|
|
21
22
|
type: "text"
|
|
@@ -28,8 +29,8 @@ interface StemBlankSegment {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
type StemSegment = StemTextSegment | StemBlankSegment
|
|
31
|
-
type
|
|
32
|
-
type
|
|
32
|
+
type OptionFollowupPrimitive = string | number | boolean
|
|
33
|
+
type OptionFollowupAnswerMap = Record<string, Record<string, OptionFollowupPrimitive>>
|
|
33
34
|
|
|
34
35
|
const props = withDefaults(defineProps<{
|
|
35
36
|
quiz: AimdQuizField
|
|
@@ -95,8 +96,8 @@ const stemSegments = computed<StemSegment[]>(() => {
|
|
|
95
96
|
: [{ type: "text", value: stem }]
|
|
96
97
|
})
|
|
97
98
|
|
|
98
|
-
const
|
|
99
|
-
props.quiz.type === "choice"
|
|
99
|
+
const hasOptionFollowups = computed(() => (
|
|
100
|
+
(props.quiz.type === "choice" || props.quiz.type === "true_false")
|
|
100
101
|
&& Array.isArray(props.quiz.options)
|
|
101
102
|
&& props.quiz.options.some(option => Array.isArray(option.followups) && option.followups.length > 0)
|
|
102
103
|
))
|
|
@@ -108,8 +109,8 @@ function asObjectRecord(value: unknown): Record<string, unknown> | null {
|
|
|
108
109
|
return value as Record<string, unknown>
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
function
|
|
112
|
-
if (!
|
|
112
|
+
function getOptionSelectedValue(): unknown {
|
|
113
|
+
if (!hasOptionFollowups.value) {
|
|
113
114
|
return props.modelValue
|
|
114
115
|
}
|
|
115
116
|
const recordValue = asObjectRecord(props.modelValue)
|
|
@@ -120,6 +121,9 @@ function getChoiceSelectedValue(): unknown {
|
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
function getSelectedChoiceKeys(value: unknown): string[] {
|
|
124
|
+
if (typeof value === "boolean") {
|
|
125
|
+
return [String(value)]
|
|
126
|
+
}
|
|
123
127
|
if (typeof value === "string") {
|
|
124
128
|
return value ? [value] : []
|
|
125
129
|
}
|
|
@@ -129,19 +133,19 @@ function getSelectedChoiceKeys(value: unknown): string[] {
|
|
|
129
133
|
return []
|
|
130
134
|
}
|
|
131
135
|
|
|
132
|
-
function
|
|
136
|
+
function asOptionFollowupAnswerMap(value: unknown): OptionFollowupAnswerMap {
|
|
133
137
|
const source = asObjectRecord(value)
|
|
134
138
|
if (!source) {
|
|
135
139
|
return {}
|
|
136
140
|
}
|
|
137
141
|
|
|
138
|
-
const normalized:
|
|
142
|
+
const normalized: OptionFollowupAnswerMap = {}
|
|
139
143
|
for (const [optionKey, rawFields] of Object.entries(source)) {
|
|
140
144
|
const fieldSource = asObjectRecord(rawFields)
|
|
141
145
|
if (!fieldSource) {
|
|
142
146
|
continue
|
|
143
147
|
}
|
|
144
|
-
const fields: Record<string,
|
|
148
|
+
const fields: Record<string, OptionFollowupPrimitive> = {}
|
|
145
149
|
for (const [fieldKey, fieldValue] of Object.entries(fieldSource)) {
|
|
146
150
|
if (
|
|
147
151
|
typeof fieldValue === "string"
|
|
@@ -158,16 +162,16 @@ function asChoiceFollowupAnswerMap(value: unknown): ChoiceFollowupAnswerMap {
|
|
|
158
162
|
return normalized
|
|
159
163
|
}
|
|
160
164
|
|
|
161
|
-
function
|
|
162
|
-
if (!
|
|
165
|
+
function getOptionFollowupsMap(): OptionFollowupAnswerMap {
|
|
166
|
+
if (!hasOptionFollowups.value) {
|
|
163
167
|
return {}
|
|
164
168
|
}
|
|
165
|
-
return
|
|
169
|
+
return asOptionFollowupAnswerMap(asObjectRecord(props.modelValue)?.followups)
|
|
166
170
|
}
|
|
167
171
|
|
|
168
|
-
function
|
|
172
|
+
function getOptionFollowupDefaults(optionKey: string): Record<string, OptionFollowupPrimitive> {
|
|
169
173
|
const option = props.quiz.options?.find(item => item.key === optionKey)
|
|
170
|
-
const defaults: Record<string,
|
|
174
|
+
const defaults: Record<string, OptionFollowupPrimitive> = {}
|
|
171
175
|
for (const followup of option?.followups || []) {
|
|
172
176
|
if (followup.default !== undefined) {
|
|
173
177
|
defaults[followup.key] = followup.default
|
|
@@ -176,16 +180,16 @@ function getChoiceOptionFollowupDefaults(optionKey: string): Record<string, Choi
|
|
|
176
180
|
return defaults
|
|
177
181
|
}
|
|
178
182
|
|
|
179
|
-
function
|
|
183
|
+
function buildStructuredOptionAnswer(
|
|
180
184
|
selected: unknown,
|
|
181
|
-
followups:
|
|
185
|
+
followups: OptionFollowupAnswerMap = getOptionFollowupsMap(),
|
|
182
186
|
): Record<string, unknown> {
|
|
183
187
|
const selectedKeys = getSelectedChoiceKeys(selected)
|
|
184
|
-
const nextFollowups:
|
|
188
|
+
const nextFollowups: OptionFollowupAnswerMap = {}
|
|
185
189
|
|
|
186
190
|
for (const selectedKey of selectedKeys) {
|
|
187
191
|
const values = {
|
|
188
|
-
...
|
|
192
|
+
...getOptionFollowupDefaults(selectedKey),
|
|
189
193
|
...(followups[selectedKey] || {}),
|
|
190
194
|
}
|
|
191
195
|
if (Object.keys(values).length > 0) {
|
|
@@ -199,9 +203,9 @@ function buildStructuredChoiceAnswer(
|
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
205
|
|
|
202
|
-
function
|
|
203
|
-
if (
|
|
204
|
-
emit("update:modelValue",
|
|
206
|
+
function emitOptionSelectedValue(value: string | string[] | boolean): void {
|
|
207
|
+
if (hasOptionFollowups.value) {
|
|
208
|
+
emit("update:modelValue", buildStructuredOptionAnswer(value))
|
|
205
209
|
return
|
|
206
210
|
}
|
|
207
211
|
emit("update:modelValue", value)
|
|
@@ -209,16 +213,16 @@ function emitChoiceSelectedValue(value: string | string[]): void {
|
|
|
209
213
|
|
|
210
214
|
const singleChoiceValue = computed<string>({
|
|
211
215
|
get() {
|
|
212
|
-
const selected =
|
|
216
|
+
const selected = getOptionSelectedValue()
|
|
213
217
|
return typeof selected === "string" ? selected : ""
|
|
214
218
|
},
|
|
215
219
|
set(value) {
|
|
216
|
-
|
|
220
|
+
emitOptionSelectedValue(value)
|
|
217
221
|
},
|
|
218
222
|
})
|
|
219
223
|
|
|
220
224
|
const multipleChoiceValue = computed<string[]>(() => {
|
|
221
|
-
const selected =
|
|
225
|
+
const selected = getOptionSelectedValue()
|
|
222
226
|
if (!Array.isArray(selected)) {
|
|
223
227
|
return []
|
|
224
228
|
}
|
|
@@ -239,9 +243,14 @@ const selectedChoiceKeys = computed<string[]>(() => {
|
|
|
239
243
|
|
|
240
244
|
const trueFalseValue = computed<boolean | null>({
|
|
241
245
|
get() {
|
|
242
|
-
|
|
246
|
+
const selected = getOptionSelectedValue()
|
|
247
|
+
return typeof selected === "boolean" ? selected : null
|
|
243
248
|
},
|
|
244
249
|
set(value) {
|
|
250
|
+
if (hasOptionFollowups.value && typeof value === "boolean") {
|
|
251
|
+
emit("update:modelValue", buildStructuredOptionAnswer(value))
|
|
252
|
+
return
|
|
253
|
+
}
|
|
245
254
|
emit("update:modelValue", value)
|
|
246
255
|
},
|
|
247
256
|
})
|
|
@@ -261,7 +270,7 @@ const resolvedTrueFalseOptions = computed<NonNullable<AimdQuizField["options"]>>
|
|
|
261
270
|
|
|
262
271
|
const selectedQuizOptionKeys = computed<string[]>(() => {
|
|
263
272
|
if (props.quiz.type === "true_false") {
|
|
264
|
-
return typeof
|
|
273
|
+
return typeof trueFalseValue.value === "boolean" ? [String(trueFalseValue.value)] : []
|
|
265
274
|
}
|
|
266
275
|
return selectedChoiceKeys.value
|
|
267
276
|
})
|
|
@@ -275,35 +284,23 @@ function toggleMultipleChoice(key: string, checked: boolean): void {
|
|
|
275
284
|
const next = checked
|
|
276
285
|
? [...new Set([...current, key])]
|
|
277
286
|
: current.filter(item => item !== key)
|
|
278
|
-
|
|
287
|
+
emitOptionSelectedValue(next)
|
|
279
288
|
}
|
|
280
289
|
|
|
281
|
-
function
|
|
290
|
+
function shouldShowOptionFollowups(option: NonNullable<AimdQuizField["options"]>[number]): boolean {
|
|
282
291
|
return Array.isArray(option.followups)
|
|
283
292
|
&& option.followups.length > 0
|
|
284
|
-
&&
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function getFollowupLabel(followup: AimdQuizFollowupField): string {
|
|
288
|
-
return followup.title || followup.key
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function getFollowupTextValue(optionKey: string, followup: AimdQuizFollowupField): string {
|
|
292
|
-
const value = getChoiceFollowupsMap()[optionKey]?.[followup.key]
|
|
293
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
294
|
-
return String(value)
|
|
295
|
-
}
|
|
296
|
-
return ""
|
|
293
|
+
&& selectedQuizOptionKeys.value.includes(option.key)
|
|
297
294
|
}
|
|
298
295
|
|
|
299
|
-
function
|
|
300
|
-
return
|
|
296
|
+
function getOptionFollowupValues(optionKey: string): Record<string, OptionFollowupPrimitive> {
|
|
297
|
+
return getOptionFollowupsMap()[optionKey] || {}
|
|
301
298
|
}
|
|
302
299
|
|
|
303
300
|
function normalizeFollowupInputValue(
|
|
304
301
|
followup: AimdQuizFollowupField,
|
|
305
302
|
value: string | boolean,
|
|
306
|
-
):
|
|
303
|
+
): OptionFollowupPrimitive | undefined {
|
|
307
304
|
if (followup.type === "bool") {
|
|
308
305
|
return Boolean(value)
|
|
309
306
|
}
|
|
@@ -332,12 +329,12 @@ function normalizeFollowupInputValue(
|
|
|
332
329
|
return parsed
|
|
333
330
|
}
|
|
334
331
|
|
|
335
|
-
function
|
|
332
|
+
function setOptionFollowupValue(
|
|
336
333
|
optionKey: string,
|
|
337
334
|
followup: AimdQuizFollowupField,
|
|
338
335
|
value: string | boolean,
|
|
339
336
|
): void {
|
|
340
|
-
const nextFollowups =
|
|
337
|
+
const nextFollowups = getOptionFollowupsMap()
|
|
341
338
|
const optionFollowups = { ...(nextFollowups[optionKey] || {}) }
|
|
342
339
|
const normalizedValue = normalizeFollowupInputValue(followup, value)
|
|
343
340
|
if (normalizedValue === undefined) {
|
|
@@ -354,7 +351,7 @@ function setChoiceFollowupValue(
|
|
|
354
351
|
delete nextFollowups[optionKey]
|
|
355
352
|
}
|
|
356
353
|
|
|
357
|
-
emit("update:modelValue",
|
|
354
|
+
emit("update:modelValue", buildStructuredOptionAnswer(getOptionSelectedValue(), nextFollowups))
|
|
358
355
|
}
|
|
359
356
|
|
|
360
357
|
function asBlankValueMap(value: unknown): Record<string, string> {
|
|
@@ -607,6 +604,17 @@ function shouldShowChoiceOptionExplanation(optionKey: string, explanation?: stri
|
|
|
607
604
|
</span>
|
|
608
605
|
</span>
|
|
609
606
|
</label>
|
|
607
|
+
<AimdQuizOptionFollowups
|
|
608
|
+
v-if="shouldShowOptionFollowups(option)"
|
|
609
|
+
:quiz-id="quiz.id"
|
|
610
|
+
:option-key="option.key"
|
|
611
|
+
input-scope="true_false"
|
|
612
|
+
:followups="option.followups || []"
|
|
613
|
+
:values="getOptionFollowupValues(option.key)"
|
|
614
|
+
:readonly="readonly"
|
|
615
|
+
:focus-key-prefix="focusKeyPrefix"
|
|
616
|
+
@update="(followup, value) => setOptionFollowupValue(option.key, followup, value)"
|
|
617
|
+
/>
|
|
610
618
|
</div>
|
|
611
619
|
</div>
|
|
612
620
|
|
|
@@ -632,35 +640,17 @@ function shouldShowChoiceOptionExplanation(optionKey: string, explanation?: stri
|
|
|
632
640
|
</span>
|
|
633
641
|
</span>
|
|
634
642
|
</label>
|
|
635
|
-
<
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
:data-rec-focus-key="`${focusKeyPrefix || `quiz:${quiz.id}`}:single:${option.key}:followup:${followup.key}`"
|
|
647
|
-
:checked="getFollowupBooleanValue(option.key, followup)"
|
|
648
|
-
:disabled="readonly"
|
|
649
|
-
@change="setChoiceFollowupValue(option.key, followup, ($event.target as HTMLInputElement).checked)"
|
|
650
|
-
/>
|
|
651
|
-
<input
|
|
652
|
-
v-else
|
|
653
|
-
:type="followup.type === 'str' ? 'text' : 'number'"
|
|
654
|
-
:step="followup.type === 'int' ? '1' : undefined"
|
|
655
|
-
class="aimd-quiz-recorder__followup-input"
|
|
656
|
-
:data-rec-focus-key="`${focusKeyPrefix || `quiz:${quiz.id}`}:single:${option.key}:followup:${followup.key}`"
|
|
657
|
-
:value="getFollowupTextValue(option.key, followup)"
|
|
658
|
-
:readonly="readonly"
|
|
659
|
-
@input="setChoiceFollowupValue(option.key, followup, ($event.target as HTMLInputElement).value)"
|
|
660
|
-
/>
|
|
661
|
-
<span v-if="followup.unit" class="aimd-quiz-recorder__followup-unit">{{ followup.unit }}</span>
|
|
662
|
-
</label>
|
|
663
|
-
</div>
|
|
643
|
+
<AimdQuizOptionFollowups
|
|
644
|
+
v-if="shouldShowOptionFollowups(option)"
|
|
645
|
+
:quiz-id="quiz.id"
|
|
646
|
+
:option-key="option.key"
|
|
647
|
+
input-scope="single"
|
|
648
|
+
:followups="option.followups || []"
|
|
649
|
+
:values="getOptionFollowupValues(option.key)"
|
|
650
|
+
:readonly="readonly"
|
|
651
|
+
:focus-key-prefix="focusKeyPrefix"
|
|
652
|
+
@update="(followup, value) => setOptionFollowupValue(option.key, followup, value)"
|
|
653
|
+
/>
|
|
664
654
|
</div>
|
|
665
655
|
</div>
|
|
666
656
|
|
|
@@ -685,35 +675,17 @@ function shouldShowChoiceOptionExplanation(optionKey: string, explanation?: stri
|
|
|
685
675
|
</span>
|
|
686
676
|
</span>
|
|
687
677
|
</label>
|
|
688
|
-
<
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
:data-rec-focus-key="`${focusKeyPrefix || `quiz:${quiz.id}`}:multiple:${option.key}:followup:${followup.key}`"
|
|
700
|
-
:checked="getFollowupBooleanValue(option.key, followup)"
|
|
701
|
-
:disabled="readonly"
|
|
702
|
-
@change="setChoiceFollowupValue(option.key, followup, ($event.target as HTMLInputElement).checked)"
|
|
703
|
-
/>
|
|
704
|
-
<input
|
|
705
|
-
v-else
|
|
706
|
-
:type="followup.type === 'str' ? 'text' : 'number'"
|
|
707
|
-
:step="followup.type === 'int' ? '1' : undefined"
|
|
708
|
-
class="aimd-quiz-recorder__followup-input"
|
|
709
|
-
:data-rec-focus-key="`${focusKeyPrefix || `quiz:${quiz.id}`}:multiple:${option.key}:followup:${followup.key}`"
|
|
710
|
-
:value="getFollowupTextValue(option.key, followup)"
|
|
711
|
-
:readonly="readonly"
|
|
712
|
-
@input="setChoiceFollowupValue(option.key, followup, ($event.target as HTMLInputElement).value)"
|
|
713
|
-
/>
|
|
714
|
-
<span v-if="followup.unit" class="aimd-quiz-recorder__followup-unit">{{ followup.unit }}</span>
|
|
715
|
-
</label>
|
|
716
|
-
</div>
|
|
678
|
+
<AimdQuizOptionFollowups
|
|
679
|
+
v-if="shouldShowOptionFollowups(option)"
|
|
680
|
+
:quiz-id="quiz.id"
|
|
681
|
+
:option-key="option.key"
|
|
682
|
+
input-scope="multiple"
|
|
683
|
+
:followups="option.followups || []"
|
|
684
|
+
:values="getOptionFollowupValues(option.key)"
|
|
685
|
+
:readonly="readonly"
|
|
686
|
+
:focus-key-prefix="focusKeyPrefix"
|
|
687
|
+
@update="(followup, value) => setOptionFollowupValue(option.key, followup, value)"
|
|
688
|
+
/>
|
|
717
689
|
</div>
|
|
718
690
|
</div>
|
|
719
691
|
|
|
@@ -923,48 +895,8 @@ function shouldShowChoiceOptionExplanation(optionKey: string, explanation?: stri
|
|
|
923
895
|
accent-color: #4181fd;
|
|
924
896
|
}
|
|
925
897
|
|
|
926
|
-
.aimd-quiz-recorder__followups {
|
|
927
|
-
display: flex;
|
|
928
|
-
flex-direction: column;
|
|
929
|
-
gap: 6px;
|
|
930
|
-
margin-left: 22px;
|
|
931
|
-
padding: 8px 10px;
|
|
932
|
-
border-left: 2px solid #dbeafe;
|
|
933
|
-
background: #f8fbff;
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
.aimd-quiz-recorder__followup {
|
|
937
|
-
display: grid;
|
|
938
|
-
grid-template-columns: minmax(92px, max-content) minmax(120px, 1fr) auto;
|
|
939
|
-
gap: 6px;
|
|
940
|
-
align-items: center;
|
|
941
|
-
font-size: 13px;
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
.aimd-quiz-recorder__followup-label {
|
|
945
|
-
color: #344054;
|
|
946
|
-
font-weight: 500;
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
.aimd-quiz-recorder__followup-input {
|
|
950
|
-
min-width: 0;
|
|
951
|
-
width: 100%;
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
.aimd-quiz-recorder__followup-checkbox {
|
|
955
|
-
justify-self: start;
|
|
956
|
-
width: 16px;
|
|
957
|
-
height: 16px;
|
|
958
|
-
accent-color: #4181fd;
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
.aimd-quiz-recorder__followup-unit {
|
|
962
|
-
color: #667085;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
898
|
.aimd-quiz-recorder__open-input,
|
|
966
|
-
.aimd-quiz-recorder__blank-input
|
|
967
|
-
.aimd-quiz-recorder__followup-input {
|
|
899
|
+
.aimd-quiz-recorder__blank-input {
|
|
968
900
|
border: 1px solid #d0d7de;
|
|
969
901
|
border-radius: 6px;
|
|
970
902
|
padding: 6px 8px;
|
|
@@ -989,8 +921,7 @@ function shouldShowChoiceOptionExplanation(optionKey: string, explanation?: stri
|
|
|
989
921
|
}
|
|
990
922
|
|
|
991
923
|
.aimd-quiz-recorder__open-input:focus,
|
|
992
|
-
.aimd-quiz-recorder__blank-input:focus
|
|
993
|
-
.aimd-quiz-recorder__followup-input:focus {
|
|
924
|
+
.aimd-quiz-recorder__blank-input:focus {
|
|
994
925
|
border-color: #4181fd;
|
|
995
926
|
box-shadow: 0 0 0 2px rgba(65, 129, 253, 0.1);
|
|
996
927
|
}
|
|
@@ -584,12 +584,7 @@ function isGroupedStepBodyNode(node: unknown): node is VNode {
|
|
|
584
584
|
return false
|
|
585
585
|
}
|
|
586
586
|
|
|
587
|
-
const
|
|
588
|
-
const classNames = Array.isArray(classValue)
|
|
589
|
-
? classValue
|
|
590
|
-
: typeof classValue === "string"
|
|
591
|
-
? [classValue]
|
|
592
|
-
: []
|
|
587
|
+
const classNames = getVNodeClassNames(props.class)
|
|
593
588
|
|
|
594
589
|
return props["data-aimd-step-body"] === "true"
|
|
595
590
|
|| props["data-aimd-step-body"] === true
|
|
@@ -644,26 +639,72 @@ function isGroupedCheckBodyNode(node: unknown): node is VNode {
|
|
|
644
639
|
|| classNames.some((className) => typeof className === "string" && className.includes("aimd-check-body"))
|
|
645
640
|
}
|
|
646
641
|
|
|
642
|
+
function getVNodeClassNames(classValue: unknown): string[] {
|
|
643
|
+
if (Array.isArray(classValue)) {
|
|
644
|
+
return classValue.flatMap(item => getVNodeClassNames(item))
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (typeof classValue === "string") {
|
|
648
|
+
return classValue.split(/\s+/).filter(Boolean)
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
if (classValue && typeof classValue === "object") {
|
|
652
|
+
return Object.entries(classValue as Record<string, unknown>)
|
|
653
|
+
.filter(([, enabled]) => Boolean(enabled))
|
|
654
|
+
.map(([className]) => className)
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
return []
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function isDefaultCheckControlNode(node: unknown): boolean {
|
|
661
|
+
if (!node || typeof node !== "object" || !("type" in node) || !("props" in node)) {
|
|
662
|
+
return false
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
const vnode = node as VNode
|
|
666
|
+
const props = vnode.props as Record<string, unknown> | null | undefined
|
|
667
|
+
if (!props) {
|
|
668
|
+
return false
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
const classNames = getVNodeClassNames(props.class)
|
|
672
|
+
|
|
673
|
+
return (
|
|
674
|
+
vnode.type === "input"
|
|
675
|
+
&& props.type === "checkbox"
|
|
676
|
+
&& classNames.includes("aimd-checkbox")
|
|
677
|
+
) || (
|
|
678
|
+
vnode.type === "span"
|
|
679
|
+
&& classNames.includes("aimd-field__label")
|
|
680
|
+
)
|
|
681
|
+
}
|
|
682
|
+
|
|
647
683
|
function normalizeCheckBodyNodes(bodyNodes: VNodeChild[] = []): VNodeChild[] {
|
|
648
684
|
if (bodyNodes.length === 0) {
|
|
649
685
|
return []
|
|
650
686
|
}
|
|
651
687
|
|
|
652
688
|
const groupedBody = bodyNodes.find((child) => isGroupedCheckBodyNode(child))
|
|
653
|
-
if (
|
|
654
|
-
|
|
655
|
-
|
|
689
|
+
if (groupedBody && typeof groupedBody === "object" && groupedBody !== null) {
|
|
690
|
+
const groupedChildren = (groupedBody as VNode).children
|
|
691
|
+
if (Array.isArray(groupedChildren)) {
|
|
692
|
+
return groupedChildren as VNodeChild[]
|
|
693
|
+
}
|
|
656
694
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
695
|
+
if (groupedChildren == null) {
|
|
696
|
+
return []
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
return [groupedChildren as VNodeChild]
|
|
660
700
|
}
|
|
661
701
|
|
|
662
|
-
|
|
663
|
-
|
|
702
|
+
const withoutDefaultControl = bodyNodes.filter(child => !isDefaultCheckControlNode(child))
|
|
703
|
+
if (withoutDefaultControl.length !== bodyNodes.length) {
|
|
704
|
+
return withoutDefaultControl
|
|
664
705
|
}
|
|
665
706
|
|
|
666
|
-
return
|
|
707
|
+
return bodyNodes
|
|
667
708
|
}
|
|
668
709
|
|
|
669
710
|
function renderInlineStep(node: AimdStepNode, bodyNodes: VNodeChild[] = []): VNode {
|
|
@@ -754,6 +795,7 @@ function renderInlineCheck(node: AimdCheckNode, bodyNodes: VNodeChild[] = []): V
|
|
|
754
795
|
bodyNodes: normalizedBodyNodes,
|
|
755
796
|
disabled,
|
|
756
797
|
extraClasses,
|
|
798
|
+
locale: resolvedLocale.value,
|
|
757
799
|
messages: resolvedMessages.value,
|
|
758
800
|
onCheckChange: (payload: { id: string, value: boolean }) => {
|
|
759
801
|
state.checked = payload.value
|
|
@@ -1108,8 +1150,10 @@ defineExpose({
|
|
|
1108
1150
|
.aimd-protocol-recorder__content :deep(.aimd-field--var .aimd-field__scope) { background: #dceaff; color: #255eab; }
|
|
1109
1151
|
.aimd-protocol-recorder__content :deep(.aimd-field--step) { background: #fff9ef; border-color: #f4d9a8; color: #9a5800; }
|
|
1110
1152
|
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--step > .aimd-step-field__main .aimd-rec-inline__check-wrap > .aimd-field__scope) { background: #ffe8bf; color: #9a5800; }
|
|
1111
|
-
.aimd-protocol-recorder__content :deep(.aimd-field--check) { background: #
|
|
1112
|
-
.aimd-protocol-recorder__content :deep(.aimd-field--check .aimd-field__scope) { background: #
|
|
1153
|
+
.aimd-protocol-recorder__content :deep(.aimd-field--check) { background: #fffafa; border-color: rgba(185, 28, 28, 0.2); color: #2b3443; padding: 3px 8px; }
|
|
1154
|
+
.aimd-protocol-recorder__content :deep(.aimd-field--check .aimd-field__scope) { background: #fee2e2; color: #991b1b; }
|
|
1155
|
+
.aimd-protocol-recorder__content :deep(.aimd-field--check.aimd-rec-inline--check-passed) { background: #f6fdf9; border-color: rgba(22, 101, 52, 0.22); color: #1f3d2a; }
|
|
1156
|
+
.aimd-protocol-recorder__content :deep(.aimd-field--check.aimd-rec-inline--check-passed .aimd-field__scope) { background: #dcfce7; color: #166534; }
|
|
1113
1157
|
.aimd-protocol-recorder__content :deep(.aimd-field--var-table) {
|
|
1114
1158
|
display: block;
|
|
1115
1159
|
width: 100%;
|
|
@@ -1274,10 +1318,22 @@ defineExpose({
|
|
|
1274
1318
|
max-width: 100%;
|
|
1275
1319
|
margin: 10px 0;
|
|
1276
1320
|
padding: 10px 12px;
|
|
1277
|
-
border: 1px solid
|
|
1321
|
+
border: 1px solid rgba(185, 28, 28, 0.2);
|
|
1322
|
+
border-left-width: 3px;
|
|
1278
1323
|
border-radius: 14px;
|
|
1279
|
-
background: #
|
|
1324
|
+
background: #fffafa;
|
|
1325
|
+
box-shadow:
|
|
1326
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.9),
|
|
1327
|
+
0 8px 24px rgba(185, 28, 28, 0.025);
|
|
1280
1328
|
box-sizing: border-box;
|
|
1329
|
+
transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
|
|
1330
|
+
}
|
|
1331
|
+
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--check-passed) {
|
|
1332
|
+
border-color: rgba(22, 101, 52, 0.22);
|
|
1333
|
+
background: #f6fdf9;
|
|
1334
|
+
box-shadow:
|
|
1335
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.9),
|
|
1336
|
+
0 8px 24px rgba(22, 101, 52, 0.035);
|
|
1281
1337
|
}
|
|
1282
1338
|
.aimd-protocol-recorder__content :deep(.aimd-check-field__main) {
|
|
1283
1339
|
display: flex;
|
|
@@ -1285,19 +1341,42 @@ defineExpose({
|
|
|
1285
1341
|
gap: 8px;
|
|
1286
1342
|
min-width: 0;
|
|
1287
1343
|
}
|
|
1288
|
-
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--check > .aimd-rec-inline__input--annotation) {
|
|
1289
|
-
min-width: 0;
|
|
1290
|
-
width: 100%;
|
|
1291
|
-
}
|
|
1292
1344
|
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--check > .aimd-rec-inline__check-wrap) {
|
|
1293
1345
|
display: inline-flex;
|
|
1294
1346
|
align-items: center;
|
|
1295
1347
|
flex-wrap: wrap;
|
|
1296
1348
|
min-width: 0;
|
|
1297
1349
|
}
|
|
1350
|
+
.aimd-protocol-recorder__content :deep(.aimd-check-field__header) {
|
|
1351
|
+
display: flex;
|
|
1352
|
+
align-items: flex-start;
|
|
1353
|
+
justify-content: space-between;
|
|
1354
|
+
gap: 8px 12px;
|
|
1355
|
+
min-width: 0;
|
|
1356
|
+
}
|
|
1357
|
+
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--check-bodyless .aimd-check-field__header) {
|
|
1358
|
+
align-items: center;
|
|
1359
|
+
}
|
|
1360
|
+
.aimd-protocol-recorder__content :deep(.aimd-check-field__actions) {
|
|
1361
|
+
display: flex;
|
|
1362
|
+
flex: 0 0 auto;
|
|
1363
|
+
flex-wrap: wrap;
|
|
1364
|
+
justify-content: flex-end;
|
|
1365
|
+
gap: 8px;
|
|
1366
|
+
}
|
|
1298
1367
|
.aimd-protocol-recorder__content :deep(.aimd-check-field__toggle) {
|
|
1299
1368
|
gap: 8px;
|
|
1300
1369
|
}
|
|
1370
|
+
.aimd-protocol-recorder__content :deep(.aimd-check-field__toggle-btn) {
|
|
1371
|
+
color: #475569;
|
|
1372
|
+
border-color: rgba(100, 116, 139, 0.2);
|
|
1373
|
+
background: rgba(255, 255, 255, 0.82);
|
|
1374
|
+
}
|
|
1375
|
+
.aimd-protocol-recorder__content :deep(.aimd-check-field__toggle-btn:hover:not(:disabled)) {
|
|
1376
|
+
border-color: rgba(100, 116, 139, 0.34);
|
|
1377
|
+
background: rgba(255, 255, 255, 0.96);
|
|
1378
|
+
color: #334155;
|
|
1379
|
+
}
|
|
1301
1380
|
.aimd-protocol-recorder__content :deep(.aimd-check-field__key) {
|
|
1302
1381
|
font-size: 12px;
|
|
1303
1382
|
font-weight: 600;
|
|
@@ -1314,11 +1393,7 @@ defineExpose({
|
|
|
1314
1393
|
margin: 0;
|
|
1315
1394
|
}
|
|
1316
1395
|
.aimd-protocol-recorder__content :deep(.aimd-check-field__body--checked) {
|
|
1317
|
-
color: #
|
|
1318
|
-
opacity: 0.92;
|
|
1319
|
-
text-decoration: line-through;
|
|
1320
|
-
text-decoration-thickness: 1.5px;
|
|
1321
|
-
text-decoration-color: rgba(102, 112, 133, 0.55);
|
|
1396
|
+
color: #24563e;
|
|
1322
1397
|
}
|
|
1323
1398
|
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--check > .aimd-rec-inline__check-wrap > .aimd-field__name),
|
|
1324
1399
|
.aimd-protocol-recorder__content :deep(.aimd-check-field__body) {
|
|
@@ -1335,6 +1410,25 @@ defineExpose({
|
|
|
1335
1410
|
font-weight: 600;
|
|
1336
1411
|
line-height: 1.5;
|
|
1337
1412
|
}
|
|
1413
|
+
.aimd-protocol-recorder__content :deep(.aimd-check-field__details) {
|
|
1414
|
+
display: flex;
|
|
1415
|
+
flex-direction: column;
|
|
1416
|
+
gap: 10px;
|
|
1417
|
+
min-width: 0;
|
|
1418
|
+
padding-top: 10px;
|
|
1419
|
+
border-top: 1px solid rgba(185, 28, 28, 0.1);
|
|
1420
|
+
}
|
|
1421
|
+
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--check-passed .aimd-check-field__details) {
|
|
1422
|
+
border-top-color: rgba(22, 101, 52, 0.12);
|
|
1423
|
+
}
|
|
1424
|
+
.aimd-protocol-recorder__content :deep(.aimd-check-field__detail--annotation) {
|
|
1425
|
+
display: flex;
|
|
1426
|
+
width: 100%;
|
|
1427
|
+
min-width: 0;
|
|
1428
|
+
}
|
|
1429
|
+
.aimd-protocol-recorder__content :deep(.aimd-check-field__annotation-editor) {
|
|
1430
|
+
width: 100%;
|
|
1431
|
+
}
|
|
1338
1432
|
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--step) {
|
|
1339
1433
|
display: flex;
|
|
1340
1434
|
flex-direction: column;
|
|
@@ -1518,6 +1612,8 @@ defineExpose({
|
|
|
1518
1612
|
}
|
|
1519
1613
|
.aimd-protocol-recorder__content :deep(.aimd-rec-inline input[type="checkbox"]),
|
|
1520
1614
|
.aimd-protocol-recorder__content :deep(.aimd-checkbox) { width: 16px; height: 16px; accent-color: var(--rec-focus); }
|
|
1615
|
+
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--check-open .aimd-checkbox) { accent-color: #dc2626; }
|
|
1616
|
+
.aimd-protocol-recorder__content :deep(.aimd-rec-inline--check-passed .aimd-checkbox) { accent-color: #16a34a; }
|
|
1521
1617
|
.aimd-protocol-recorder__content :deep(.aimd-rec-inline__input) {
|
|
1522
1618
|
height: 30px;
|
|
1523
1619
|
min-width: 94px;
|