1
1
<script lang="ts" setup>
2
2
import {
3
- reset ,
4
- submitForm ,
5
3
type FormKitNode ,
6
4
type FormKitSchemaCondition ,
7
5
type FormKitSchemaNode ,
6
+ reset ,
7
+ submitForm ,
8
8
} from " @formkit/core" ;
9
+
10
+ import { IconArrowRight } from " @halo-dev/components" ;
11
+
9
12
import { computed , nextTick , onMounted , ref , watch } from " vue" ;
10
13
import { apiClient } from " @/utils/api-client" ;
11
14
import type { AnnotationSetting } from " @halo-dev/api-client" ;
@@ -196,6 +199,12 @@ defineExpose({
196
199
annotations ,
197
200
customAnnotations ,
198
201
});
202
+
203
+ const showCustomForm = ref (false );
204
+
205
+ function onCustomFormToggle(e : Event ) {
206
+ showCustomForm .value = (e .target as HTMLDetailsElement ).open ;
207
+ }
199
208
</script >
200
209
201
210
<template >
@@ -219,34 +228,73 @@ defineExpose({
219
228
/>
220
229
</template >
221
230
</FormKit >
222
- <FormKit
223
- v-if =" annotations"
224
- :id =" customFormId"
225
- type =" form"
226
- :preserve =" true"
227
- :form-class =" `${avaliableAnnotationSettings.length ? 'py-4' : ''}`"
228
- @submit-invalid =" onCustomFormSubmitCheck"
229
- @submit =" customFormInvalid = false"
231
+
232
+ <details
233
+ :open =" showCustomForm"
234
+ class =" flex cursor-pointer space-y-4 py-4 transition-all first:pt-0"
235
+ @toggle =" onCustomFormToggle"
230
236
>
237
+ <summary class =" group flex items-center justify-between" >
238
+ <div class =" block text-sm font-medium text-gray-700" >
239
+ {{
240
+ $t(
241
+ showCustomForm
242
+ ? "core.components.annotations_form.buttons.collapse"
243
+ : "core.components.annotations_form.buttons.expand"
244
+ )
245
+ }}
246
+ </div >
247
+ <div
248
+ class =" -mr-1 inline-flex items-center justify-center rounded-full p-1 group-hover:bg-gray-100"
249
+ :class =" { 'bg-gray-100': showCustomForm }"
250
+ >
251
+ <IconArrowRight
252
+ :class =" { 'rotate-90 !text-gray-900': showCustomForm }"
253
+ class =" text-gray-600 transition-all"
254
+ />
255
+ </div >
256
+ </summary >
257
+
231
258
<FormKit
232
- v-model =" customAnnotationsState"
233
- type =" repeater"
234
- :label =" $t('core.components.annotations_form.custom_fields.label')"
259
+ v-if =" annotations"
260
+ :id =" customFormId"
261
+ type =" form"
262
+ :preserve =" true"
263
+ :form-class =" `${avaliableAnnotationSettings.length ? 'py-4' : ''}`"
264
+ @submit-invalid =" onCustomFormSubmitCheck"
265
+ @submit =" customFormInvalid = false"
235
266
>
236
267
<FormKit
237
- type =" text"
238
- label =" Key"
239
- name =" key"
240
- validation =" required:trim|keyValidationRule"
241
- :validation-rules =" { keyValidationRule }"
242
- :validation-messages =" {
243
- keyValidationRule: $t(
244
- 'core.components.annotations_form.custom_fields.validation'
245
- ),
246
- }"
247
- ></FormKit >
248
- <FormKit type =" text" label =" Value" name =" value" value =" " ></FormKit >
268
+ v-model =" customAnnotationsState"
269
+ type =" repeater"
270
+ :label =" $t('core.components.annotations_form.custom_fields.label')"
271
+ >
272
+ <FormKit
273
+ type =" text"
274
+ label =" Key"
275
+ name =" key"
276
+ validation =" required:trim|keyValidationRule"
277
+ :validation-rules =" { keyValidationRule }"
278
+ :validation-messages =" {
279
+ keyValidationRule: $t(
280
+ 'core.components.annotations_form.custom_fields.validation'
281
+ ),
282
+ }"
283
+ ></FormKit >
284
+ <FormKit type =" text" label =" Value" name =" value" value =" " ></FormKit >
285
+ </FormKit >
249
286
</FormKit >
250
- </FormKit >
287
+ </details >
251
288
</div >
252
289
</template >
290
+
291
+ <style scoped>
292
+ details > summary {
293
+ list-style : none ;
294
+ }
295
+
296
+ /* * Hide the default marker **/
297
+ details > summary ::-webkit-details-marker {
298
+ display : none ;
299
+ }
300
+ </style >
0 commit comments