@bagelink/vue 1.10.3 → 1.10.7
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/components/form/inputs/CodeEditor/Index.vue.d.ts.map +1 -1
- package/dist/form-flow/FormFlow.vue.d.ts +15 -5
- package/dist/form-flow/FormFlow.vue.d.ts.map +1 -1
- package/dist/index.cjs +38 -38
- package/dist/index.mjs +5706 -5704
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/components/form/inputs/CodeEditor/Index.vue +0 -1
- package/src/form-flow/FormFlow.vue +27 -22
- package/src/styles/base-colors.css +2 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.10.
|
|
4
|
+
"version": "1.10.7",
|
|
5
5
|
"description": "Bagel core sdk packages",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bagel Studio",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"signature_pad": "^5.0.9",
|
|
91
91
|
"vue-i18n": "^11.2.8",
|
|
92
92
|
"vue-toastification": "^2.0.0-rc.5",
|
|
93
|
-
"@bagelink/utils": "1.10.
|
|
93
|
+
"@bagelink/utils": "1.10.7"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"dev": "tsx watch src/index.ts",
|
|
@@ -22,19 +22,22 @@ import { useI18n, resolveI18n } from '../i18n'
|
|
|
22
22
|
|
|
23
23
|
import { parseQuery } from '../utils/queryFilter'
|
|
24
24
|
|
|
25
|
+
export type FormState = 'idle' | 'submitting' | 'success' | 'error'
|
|
26
|
+
|
|
25
27
|
export interface Props<T extends Record<string, any> = Record<string, any>> {
|
|
26
28
|
schema: SchemaDefinition
|
|
27
29
|
modelValue?: T
|
|
28
30
|
components?: Record<string, any>
|
|
29
31
|
/** External validation errors (from parent MultiStepForm) */
|
|
30
32
|
errors?: Record<string, string>
|
|
33
|
+
/** Async submit handler — use @submit="fn" to bind. FormFlow awaits it and manages formState. */
|
|
34
|
+
onSubmit?: (data: T) => Promise<void> | void
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
const props = defineProps<Props<T>>()
|
|
34
38
|
|
|
35
39
|
const emit = defineEmits<{
|
|
36
40
|
'update:modelValue': [value: T]
|
|
37
|
-
'submit': [value: T]
|
|
38
41
|
}>()
|
|
39
42
|
|
|
40
43
|
const { $t } = useI18n()
|
|
@@ -86,6 +89,9 @@ const validationErrors = ref<Record<string, string>>({})
|
|
|
86
89
|
// After first submit attempt, validate on input (like native form validation)
|
|
87
90
|
const hasSubmitted = ref(false)
|
|
88
91
|
|
|
92
|
+
// Internal form lifecycle state
|
|
93
|
+
const formState = ref<FormState>('idle')
|
|
94
|
+
|
|
89
95
|
// Form element ref for native validation
|
|
90
96
|
const formElement = ref<HTMLFormElement>()
|
|
91
97
|
|
|
@@ -205,6 +211,9 @@ const visibleFields = computed(() => {
|
|
|
205
211
|
// Update field value - validate on input only after first submit attempt
|
|
206
212
|
function updateField(key: string, value: any, field: FieldBuilder) {
|
|
207
213
|
setNestedValue(formData.value, key, value)
|
|
214
|
+
if (formState.value === 'success' || formState.value === 'error') {
|
|
215
|
+
formState.value = 'idle'
|
|
216
|
+
}
|
|
208
217
|
if (hasSubmitted.value) {
|
|
209
218
|
validateField(key, field)
|
|
210
219
|
}
|
|
@@ -386,7 +395,7 @@ function validateAll(): boolean {
|
|
|
386
395
|
}
|
|
387
396
|
|
|
388
397
|
// Submit handler for the slot (arrow function preserves closure scope during bundling)
|
|
389
|
-
function handleSubmit(event?: Event): boolean {
|
|
398
|
+
async function handleSubmit(event?: Event): Promise<boolean> {
|
|
390
399
|
// Prevent default form submission if event is provided
|
|
391
400
|
if (event) {
|
|
392
401
|
event.preventDefault()
|
|
@@ -419,9 +428,14 @@ function handleSubmit(event?: Event): boolean {
|
|
|
419
428
|
}, 300)
|
|
420
429
|
}
|
|
421
430
|
}
|
|
422
|
-
} else {
|
|
423
|
-
|
|
424
|
-
|
|
431
|
+
} else if (props.onSubmit) {
|
|
432
|
+
formState.value = 'submitting'
|
|
433
|
+
try {
|
|
434
|
+
await props.onSubmit(formData.value)
|
|
435
|
+
formState.value = 'success'
|
|
436
|
+
} catch {
|
|
437
|
+
formState.value = 'error'
|
|
438
|
+
}
|
|
425
439
|
}
|
|
426
440
|
|
|
427
441
|
return isValid
|
|
@@ -430,7 +444,8 @@ function handleSubmit(event?: Event): boolean {
|
|
|
430
444
|
// Expose methods for parent components (e.g., dialogs)
|
|
431
445
|
defineExpose({
|
|
432
446
|
validate: validateAll,
|
|
433
|
-
handleSubmit
|
|
447
|
+
submit: handleSubmit,
|
|
448
|
+
formState
|
|
434
449
|
})
|
|
435
450
|
</script>
|
|
436
451
|
|
|
@@ -491,27 +506,17 @@ defineExpose({
|
|
|
491
506
|
name="errors" :errors="mergedErrors"
|
|
492
507
|
:error-count="Object.keys(mergedErrors).filter(k => mergedErrors[k]).length"
|
|
493
508
|
:visible-fields="visibleFields"
|
|
494
|
-
|
|
495
|
-
<!-- Default errors summary (only shown if there are errors) -->
|
|
496
|
-
<div v-if="Object.keys(mergedErrors).some(k => mergedErrors[k])" class="form-errors-summary">
|
|
497
|
-
<div class="form-errors-title">
|
|
498
|
-
Please fix the following errors:
|
|
499
|
-
</div>
|
|
500
|
-
<ul class="form-errors-list">
|
|
501
|
-
<template v-for="{ key, field } in visibleFields" :key="key">
|
|
502
|
-
<li v-if="mergedErrors[key]">
|
|
503
|
-
<strong>{{ generateLabel(key, field) }}:</strong> {{ mergedErrors[key] }}
|
|
504
|
-
</li>
|
|
505
|
-
</template>
|
|
506
|
-
</ul>
|
|
507
|
-
</div>
|
|
508
|
-
</slot>
|
|
509
|
+
/>
|
|
509
510
|
|
|
510
511
|
<!-- Submit slot -->
|
|
511
512
|
<slot
|
|
512
513
|
name="submit" :submit="handleSubmit" :validate="validateAll" :form-data="formData"
|
|
513
|
-
:errors="mergedErrors"
|
|
514
|
+
:errors="mergedErrors" :form-state="formState"
|
|
514
515
|
/>
|
|
516
|
+
|
|
517
|
+
<!-- Success/error lifecycle slots (only rendered when submitFn is used) -->
|
|
518
|
+
<slot v-if="formState === 'success'" name="success" :form-data="formData" />
|
|
519
|
+
<slot v-else-if="formState === 'error'" name="error" :form-data="formData" />
|
|
515
520
|
</form>
|
|
516
521
|
</template>
|
|
517
522
|
|
|
@@ -1401,11 +1401,11 @@
|
|
|
1401
1401
|
/* Flat and Border modifiers - Universal approach */
|
|
1402
1402
|
/* For all pair classes, flat mode uses border-color as text color */
|
|
1403
1403
|
[class*="pair-"].bgl_flatPill {
|
|
1404
|
-
background-color: transparent
|
|
1404
|
+
background-color: transparent;
|
|
1405
1405
|
}
|
|
1406
1406
|
|
|
1407
1407
|
[class*="pair-"].bgl_pill-border {
|
|
1408
|
-
background-color: transparent
|
|
1408
|
+
background-color: transparent;
|
|
1409
1409
|
outline: 1px solid;
|
|
1410
1410
|
}
|
|
1411
1411
|
|