@effect-app/vue-components 4.0.0-beta.15 → 4.0.0-beta.151
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 +24 -0
- package/dist/reset.css +52 -0
- package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +24 -8
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +1 -1
- package/dist/types/utils/index.d.ts +6 -6
- package/dist/vue-components.es.js +21 -45
- package/dist/vue-components10.es.js +5 -0
- package/dist/vue-components11.es.js +13 -0
- package/dist/vue-components12.es.js +471 -0
- package/dist/vue-components13.es.js +4 -0
- package/dist/vue-components14.es.js +38 -0
- package/dist/vue-components15.es.js +27 -0
- package/dist/vue-components16.es.js +28 -0
- package/dist/vue-components17.es.js +7 -0
- package/dist/vue-components18.es.js +18 -0
- package/dist/vue-components19.es.js +36 -0
- package/dist/vue-components2.es.js +11 -0
- package/dist/vue-components20.es.js +18 -0
- package/dist/vue-components21.es.js +21 -0
- package/dist/vue-components22.es.js +30 -0
- package/dist/vue-components23.es.js +7 -0
- package/dist/vue-components24.es.js +9 -0
- package/dist/vue-components25.es.js +38 -0
- package/dist/vue-components26.es.js +25 -0
- package/dist/vue-components27.es.js +128 -0
- package/dist/vue-components28.es.js +24 -0
- package/dist/vue-components29.es.js +21 -0
- package/dist/vue-components3.es.js +54 -0
- package/dist/vue-components30.es.js +9 -0
- package/dist/vue-components31.es.js +19 -0
- package/dist/vue-components32.es.js +5 -0
- package/dist/vue-components33.es.js +29 -0
- package/dist/vue-components34.es.js +5 -0
- package/dist/vue-components35.es.js +29 -0
- package/dist/vue-components36.es.js +6 -0
- package/dist/vue-components37.es.js +18 -0
- package/dist/vue-components38.es.js +56 -0
- package/dist/vue-components39.es.js +5 -0
- package/dist/vue-components4.es.js +5 -0
- package/dist/vue-components40.es.js +44 -0
- package/dist/vue-components41.es.js +5 -0
- package/dist/vue-components42.es.js +84 -0
- package/dist/vue-components44.es.js +8 -0
- package/dist/vue-components45.es.js +9 -0
- package/dist/vue-components46.es.js +269 -0
- package/dist/vue-components48.es.js +8 -0
- package/dist/vue-components49.es.js +80 -0
- package/dist/vue-components5.es.js +24 -0
- package/dist/vue-components50.es.js +5 -0
- package/dist/vue-components51.es.js +73 -0
- package/dist/vue-components52.es.js +5 -0
- package/dist/vue-components53.es.js +24 -0
- package/dist/vue-components54.es.js +5 -0
- package/dist/vue-components55.es.js +59 -0
- package/dist/vue-components56.es.js +5 -0
- package/dist/vue-components57.es.js +12 -0
- package/dist/vue-components58.es.js +22 -0
- package/dist/vue-components6.es.js +13 -0
- package/dist/vue-components60.es.js +9 -0
- package/dist/vue-components61.es.js +235 -0
- package/dist/vue-components62.es.js +33 -0
- package/dist/vue-components63.es.js +8 -0
- package/dist/vue-components64.es.js +36 -0
- package/dist/vue-components7.es.js +28 -0
- package/dist/vue-components8.es.js +47 -0
- package/dist/vue-components9.es.js +5 -0
- package/package.json +33 -28
- package/src/components/CommandButton.vue +1 -1
- package/src/components/OmegaForm/OmegaFormStuff.ts +367 -129
- package/src/components/OmegaForm/OmegaInput.vue +36 -2
- package/src/components/OmegaForm/OmegaInputVuetify.vue +4 -1
- package/src/components/OmegaForm/OmegaInternalInput.vue +19 -5
- package/src/components/OmegaForm/useOmegaForm.ts +31 -8
- package/src/reset.css +52 -0
- package/src/utils/index.ts +10 -7
- package/dist/vue-components.es10.js +0 -239
- package/dist/vue-components.es11.js +0 -32
- package/dist/vue-components.es12.js +0 -481
- package/dist/vue-components.es13.js +0 -49
- package/dist/vue-components.es14.js +0 -4
- package/dist/vue-components.es15.js +0 -4
- package/dist/vue-components.es16.js +0 -13
- package/dist/vue-components.es17.js +0 -6
- package/dist/vue-components.es18.js +0 -13
- package/dist/vue-components.es19.js +0 -57
- package/dist/vue-components.es2.js +0 -31
- package/dist/vue-components.es20.js +0 -56
- package/dist/vue-components.es21.js +0 -8
- package/dist/vue-components.es22.js +0 -8
- package/dist/vue-components.es23.js +0 -5
- package/dist/vue-components.es24.js +0 -5
- package/dist/vue-components.es25.js +0 -4
- package/dist/vue-components.es26.js +0 -4
- package/dist/vue-components.es27.js +0 -4
- package/dist/vue-components.es28.js +0 -4
- package/dist/vue-components.es29.js +0 -19
- package/dist/vue-components.es3.js +0 -17
- package/dist/vue-components.es30.js +0 -31
- package/dist/vue-components.es31.js +0 -6
- package/dist/vue-components.es32.js +0 -4
- package/dist/vue-components.es33.js +0 -4
- package/dist/vue-components.es34.js +0 -113
- package/dist/vue-components.es36.js +0 -9
- package/dist/vue-components.es37.js +0 -34
- package/dist/vue-components.es39.js +0 -194
- package/dist/vue-components.es4.js +0 -52
- package/dist/vue-components.es41.js +0 -6
- package/dist/vue-components.es42.js +0 -25
- package/dist/vue-components.es43.js +0 -7
- package/dist/vue-components.es44.js +0 -23
- package/dist/vue-components.es45.js +0 -32
- package/dist/vue-components.es46.js +0 -24
- package/dist/vue-components.es47.js +0 -14
- package/dist/vue-components.es48.js +0 -7
- package/dist/vue-components.es49.js +0 -21
- package/dist/vue-components.es5.js +0 -52
- package/dist/vue-components.es50.js +0 -11
- package/dist/vue-components.es51.js +0 -33
- package/dist/vue-components.es52.js +0 -50
- package/dist/vue-components.es53.js +0 -28
- package/dist/vue-components.es54.js +0 -13
- package/dist/vue-components.es55.js +0 -67
- package/dist/vue-components.es56.js +0 -58
- package/dist/vue-components.es57.js +0 -19
- package/dist/vue-components.es58.js +0 -35
- package/dist/vue-components.es59.js +0 -31
- package/dist/vue-components.es6.js +0 -69
- package/dist/vue-components.es60.js +0 -44
- package/dist/vue-components.es61.js +0 -4
- package/dist/vue-components.es62.js +0 -46
- package/dist/vue-components.es63.js +0 -4
- package/dist/vue-components.es7.js +0 -83
- package/dist/vue-components.es8.js +0 -63
- package/dist/vue-components.es9.js +0 -21
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
:key="fieldKey"
|
|
5
5
|
:name="name"
|
|
6
6
|
:validators="{
|
|
7
|
-
onChange: schema,
|
|
7
|
+
// onChange: schema,
|
|
8
|
+
onBlur: schema,
|
|
8
9
|
...validators
|
|
9
10
|
}"
|
|
10
11
|
>
|
|
@@ -97,12 +98,45 @@ const fieldKey = computed(() => {
|
|
|
97
98
|
// Call useIntl during setup to avoid issues when computed re-evaluates
|
|
98
99
|
const { trans } = useIntl()
|
|
99
100
|
|
|
101
|
+
const hasIssues = (result: any): boolean => Array.isArray(result?.issues) && result.issues.length > 0
|
|
102
|
+
|
|
103
|
+
const composeStandardSchemas = (
|
|
104
|
+
omegaSchema: any,
|
|
105
|
+
originalSchema: any
|
|
106
|
+
) => ({
|
|
107
|
+
"~standard": {
|
|
108
|
+
...omegaSchema["~standard"],
|
|
109
|
+
validate: (value: unknown) => {
|
|
110
|
+
const omegaResult = omegaSchema["~standard"].validate(value)
|
|
111
|
+
if (omegaResult && typeof omegaResult.then === "function") {
|
|
112
|
+
return omegaResult.then((resolved: any) => {
|
|
113
|
+
if (hasIssues(resolved)) {
|
|
114
|
+
return resolved
|
|
115
|
+
}
|
|
116
|
+
return originalSchema["~standard"].validate(value)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (hasIssues(omegaResult)) {
|
|
121
|
+
return omegaResult
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return originalSchema["~standard"].validate(value)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
|
|
100
129
|
const schema = computed(() => {
|
|
101
130
|
if (!meta.value) {
|
|
102
131
|
console.log(props.name, Object.keys(props.form.meta), props.form.meta)
|
|
103
132
|
throw new Error("Meta is undefined")
|
|
104
133
|
}
|
|
105
|
-
|
|
134
|
+
const omegaSchema = generateInputStandardSchemaFromFieldMeta(meta.value, trans)
|
|
135
|
+
const fieldSchema = meta.value.originalSchema
|
|
136
|
+
if (fieldSchema) {
|
|
137
|
+
return composeStandardSchemas(omegaSchema, fieldSchema)
|
|
138
|
+
}
|
|
139
|
+
return omegaSchema
|
|
106
140
|
})
|
|
107
141
|
|
|
108
142
|
const errori18n = useErrorLabel(props.form)
|
|
@@ -119,6 +119,7 @@ const isFalsyButNotZero = (value: unknown): boolean => {
|
|
|
119
119
|
// we remove value and errors when the field is empty and not required
|
|
120
120
|
// convert nullish value to null or undefined based on schema
|
|
121
121
|
const handleChange: OmegaFieldInternalApi<From, Name>["handleChange"] = (value) => {
|
|
122
|
+
let fieldDeleted = false
|
|
122
123
|
if (isFalsyButNotZero(value) && props.meta?.type !== "boolean") {
|
|
123
124
|
// Only convert to null/undefined if the field is actually nullable or optional
|
|
124
125
|
if (props.meta?.nullableOrUndefined) {
|
|
@@ -128,6 +129,14 @@ const handleChange: OmegaFieldInternalApi<From, Name>["handleChange"] = (value)
|
|
|
128
129
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
130
|
: null as any
|
|
130
131
|
)
|
|
132
|
+
} else if (props.meta?.isOptionalKey) {
|
|
133
|
+
// `S.optionalKey` expects the key to be ABSENT from the submitted
|
|
134
|
+
// object, not present-with-undefined. Remove it from form state
|
|
135
|
+
// rather than setting it to `undefined`. Note: this is distinct
|
|
136
|
+
// from `required: false`, which may also just mean "empty string
|
|
137
|
+
// is valid" for unconstrained `S.String` fields.
|
|
138
|
+
props.field.form.deleteField(props.field.name)
|
|
139
|
+
fieldDeleted = true
|
|
131
140
|
} else {
|
|
132
141
|
// Keep the actual value (e.g., empty string for S.String fields)
|
|
133
142
|
props.field.handleChange(value)
|
|
@@ -138,7 +147,10 @@ const handleChange: OmegaFieldInternalApi<From, Name>["handleChange"] = (value)
|
|
|
138
147
|
|
|
139
148
|
// whenever we change the field, regardless if we set it to null, we should reset onSubmit.
|
|
140
149
|
// not sure why this is not the case in tanstack form.
|
|
141
|
-
|
|
150
|
+
// Skip when the field was deleted — its meta no longer exists in the form store.
|
|
151
|
+
if (!fieldDeleted) {
|
|
152
|
+
props.field.setMeta((m) => ({ ...m, errorMap: { ...m.errorMap, onSubmit: undefined } }))
|
|
153
|
+
}
|
|
142
154
|
}
|
|
143
155
|
|
|
144
156
|
// Note: Default value normalization (converting empty strings to null/undefined for nullable fields)
|
|
@@ -165,11 +177,13 @@ const inputProps: ComputedRef<InputProps<From, Name>> = computed(() => ({
|
|
|
165
177
|
minLength: props.meta?.type === "string" && props.meta?.minLength,
|
|
166
178
|
maxLength: props.meta?.type === "string" && props.meta?.maxLength,
|
|
167
179
|
max: (props.meta?.type === "number")
|
|
168
|
-
|
|
169
|
-
?? (typeof props.meta?.exclusiveMaximum === "number"
|
|
180
|
+
? (props.meta?.maximum
|
|
181
|
+
?? (typeof props.meta?.exclusiveMaximum === "number" ? props.meta.exclusiveMaximum - 1 : undefined))
|
|
182
|
+
: undefined,
|
|
170
183
|
min: (props.meta?.type === "number")
|
|
171
|
-
|
|
172
|
-
?? (typeof props.meta?.exclusiveMinimum === "number"
|
|
184
|
+
? (props.meta?.minimum
|
|
185
|
+
?? (typeof props.meta?.exclusiveMinimum === "number" ? props.meta.exclusiveMinimum + 1 : undefined))
|
|
186
|
+
: undefined,
|
|
173
187
|
errorMessages: errors.value,
|
|
174
188
|
error: !!errors.value.length,
|
|
175
189
|
type: fieldType.value,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import * as api from "@opentelemetry/api"
|
|
5
5
|
import { type DeepKeys, DeepValue, type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, StandardSchemaV1Issue, useForm, ValidationError, ValidationErrorMap } from "@tanstack/vue-form"
|
|
6
|
-
import { Array, Data, Effect, Fiber, Option, Order, S } from "effect-app"
|
|
6
|
+
import { Array, Context, Data, Effect, Fiber, Option, Order, S } from "effect-app"
|
|
7
7
|
import { runtimeFiberAsPromise, UnionToTuples } from "effect-app/utils"
|
|
8
8
|
import { Component, computed, ComputedRef, ConcreteComponent, h, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, Ref, ref, watch } from "vue"
|
|
9
9
|
import { useIntl } from "../../utils"
|
|
@@ -11,11 +11,13 @@ import { MergedInputProps } from "./InputProps"
|
|
|
11
11
|
import OmegaArray from "./OmegaArray.vue"
|
|
12
12
|
import OmegaAutoGen from "./OmegaAutoGen.vue"
|
|
13
13
|
import OmegaErrorsInternal from "./OmegaErrorsInternal.vue"
|
|
14
|
-
import { BaseProps, deepMerge, defaultsValueFromSchema, DefaultTypeProps, FieldPath, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState } from "./OmegaFormStuff"
|
|
14
|
+
import { BaseProps, deepMerge, defaultsValueFromSchema, DefaultTypeProps, FieldPath, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, toFormSchema } from "./OmegaFormStuff"
|
|
15
15
|
import OmegaInput from "./OmegaInput.vue"
|
|
16
16
|
import OmegaTaggedUnion from "./OmegaTaggedUnion.vue"
|
|
17
17
|
import OmegaForm from "./OmegaWrapper.vue"
|
|
18
18
|
|
|
19
|
+
import { makeRunPromise } from "@effect-app/vue/runtime"
|
|
20
|
+
|
|
19
21
|
type keysRule<T> =
|
|
20
22
|
| {
|
|
21
23
|
keys?: NestedKeyOf<T>[]
|
|
@@ -395,7 +397,7 @@ export interface OmegaFormReturn<
|
|
|
395
397
|
> extends OF<From, To> {
|
|
396
398
|
// Pre-computed type aliases - computed ONCE for performance
|
|
397
399
|
_paths: FieldPath<From>
|
|
398
|
-
_keys:
|
|
400
|
+
_keys: NestedKeyOf<From>
|
|
399
401
|
_schema: S.Codec<To, From, never>
|
|
400
402
|
|
|
401
403
|
// this crazy thing here is copied from the OmegaFormInput.vue.d.ts, with `From` removed as Generic, instead closed over from the From generic above..
|
|
@@ -668,6 +670,8 @@ export interface OmegaFormReturn<
|
|
|
668
670
|
}
|
|
669
671
|
}
|
|
670
672
|
|
|
673
|
+
const runPromise = makeRunPromise(Context.empty())
|
|
674
|
+
|
|
671
675
|
export const useOmegaForm = <
|
|
672
676
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
673
677
|
From extends Record<PropertyKey, any>,
|
|
@@ -680,10 +684,11 @@ export const useOmegaForm = <
|
|
|
680
684
|
omegaConfig?: OmegaConfig<To>
|
|
681
685
|
): OmegaFormReturn<From, To, TypeProps> => {
|
|
682
686
|
if (!schema) throw new Error("Schema is required")
|
|
683
|
-
const
|
|
684
|
-
const
|
|
687
|
+
const formCompatibleSchema = toFormSchema(schema)
|
|
688
|
+
const standardSchema = S.toStandardSchemaV1(formCompatibleSchema)
|
|
689
|
+
const decode = S.decodeUnknownEffect(formCompatibleSchema)
|
|
685
690
|
|
|
686
|
-
const { meta, unionMeta } = generateMetaFromSchema(
|
|
691
|
+
const { meta, unionMeta } = generateMetaFromSchema(formCompatibleSchema)
|
|
687
692
|
|
|
688
693
|
const persistencyKey = computed(() => {
|
|
689
694
|
if (omegaConfig?.persistency?.id) {
|
|
@@ -790,7 +795,7 @@ export const useOmegaForm = <
|
|
|
790
795
|
? ({ formApi, meta, value }) =>
|
|
791
796
|
wrapWithSpan(meta?.currentSpan, async () => {
|
|
792
797
|
// validators only validate, they don't actually transform, so we have to do that manually here.
|
|
793
|
-
const parsedValue = await
|
|
798
|
+
const parsedValue = await runPromise(decode(value))
|
|
794
799
|
const r = tanstackFormOptions.onSubmit!({
|
|
795
800
|
formApi: formApi as OmegaFormApi<From, To>,
|
|
796
801
|
meta,
|
|
@@ -800,7 +805,7 @@ export const useOmegaForm = <
|
|
|
800
805
|
return await runtimeFiberAsPromise(r)
|
|
801
806
|
}
|
|
802
807
|
if (Effect.isEffect(r)) {
|
|
803
|
-
const effectResult = await
|
|
808
|
+
const effectResult = await runPromise(r)
|
|
804
809
|
return Fiber.isFiber(effectResult)
|
|
805
810
|
? await runtimeFiberAsPromise(effectResult)
|
|
806
811
|
: effectResult
|
|
@@ -974,6 +979,24 @@ export const useOmegaForm = <
|
|
|
974
979
|
}
|
|
975
980
|
})
|
|
976
981
|
|
|
982
|
+
// Clear all field onSubmit errors when any value changes after a failed submission.
|
|
983
|
+
// Form-level onSubmit validation (e.g. union schemas) distributes errors to individual fields.
|
|
984
|
+
// TanStack only clears the changed field's onSubmit error, leaving sibling fields with stale
|
|
985
|
+
// errors that keep isFieldsValid=false and block re-submission.
|
|
986
|
+
const lastSubmitAttempts = ref(0)
|
|
987
|
+
const submissionAttempts = form.useStore((s) => s.submissionAttempts)
|
|
988
|
+
const formValues = form.useStore((s) => s.values)
|
|
989
|
+
watch(formValues, () => {
|
|
990
|
+
if (lastSubmitAttempts.value === submissionAttempts.value) return
|
|
991
|
+
lastSubmitAttempts.value = submissionAttempts.value
|
|
992
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
993
|
+
for (const info of Object.values(form.fieldInfo) as any[]) {
|
|
994
|
+
if (info?.instance?.state.meta.errorMap?.onSubmit) {
|
|
995
|
+
info.instance.setMeta((prev: any) => ({ ...prev, errorMap: { ...prev.errorMap, onSubmit: undefined } }))
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}, { deep: true })
|
|
999
|
+
|
|
977
1000
|
const errorContext = { form: formWithExtras, fieldMap }
|
|
978
1001
|
|
|
979
1002
|
return Object.assign(formWithExtras, {
|
package/src/reset.css
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Supplemental CSS reset for Vuetify 4.
|
|
3
|
+
* Vuetify 4 removed the aggressive global reset that v3 included.
|
|
4
|
+
* Import this file to restore equivalent behavior:
|
|
5
|
+
* import '@effect-app/vue-components/reset.css'
|
|
6
|
+
*/
|
|
7
|
+
@layer vuetify-reset {
|
|
8
|
+
body {
|
|
9
|
+
margin: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
ul,
|
|
13
|
+
ol {
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0;
|
|
16
|
+
list-style: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
h1,
|
|
20
|
+
h2,
|
|
21
|
+
h3,
|
|
22
|
+
h4,
|
|
23
|
+
h5,
|
|
24
|
+
h6 {
|
|
25
|
+
margin: 0;
|
|
26
|
+
font-size: inherit;
|
|
27
|
+
font-weight: inherit;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
p {
|
|
31
|
+
margin: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
input,
|
|
35
|
+
textarea,
|
|
36
|
+
select {
|
|
37
|
+
border: 0;
|
|
38
|
+
background: transparent;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
a {
|
|
42
|
+
text-decoration: none;
|
|
43
|
+
color: inherit;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
figure,
|
|
47
|
+
details,
|
|
48
|
+
summary {
|
|
49
|
+
margin: 0;
|
|
50
|
+
padding: 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type makeIntl } from "@effect-app/vue"
|
|
2
|
-
import { S } from "effect-app"
|
|
2
|
+
import type { S } from "effect-app"
|
|
3
3
|
import { inject, type InjectionKey, provide } from "vue"
|
|
4
4
|
|
|
5
5
|
export const useIntlKey = Symbol() as InjectionKey<
|
|
@@ -17,12 +17,15 @@ export const provideIntl = (
|
|
|
17
17
|
) => provide(useIntlKey, intl)
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* Walks the encoding chain of the given AST node to its source (encoded)
|
|
21
|
+
* side. Shallow — does not recurse into children, so inner prop-level
|
|
22
|
+
* transformations (e.g. `FiniteFromString`) keep their decoded shape
|
|
23
|
+
* while struct-level `decodeTo` transformations are unwrapped to their
|
|
24
|
+
* input side (e.g. `NonNegativeInt` rather than the decoded `PositiveInt`).
|
|
25
25
|
*/
|
|
26
26
|
export function getTransformationFrom(ast: S.AST.AST) {
|
|
27
|
-
|
|
27
|
+
while (ast.encoding) {
|
|
28
|
+
ast = ast.encoding[0].to
|
|
29
|
+
}
|
|
30
|
+
return ast
|
|
28
31
|
}
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { useForm as K } from "@tanstack/vue-form";
|
|
2
|
-
import { Data as T, S as I, Effect as m, Fiber as V, Option as z, Array as P } from "effect-app";
|
|
3
|
-
import { runtimeFiberAsPromise as W } from "./vue-components.es18.js";
|
|
4
|
-
import { computed as $, onUnmounted as D, onMounted as G, onBeforeUnmount as Z, watch as R, ref as Q, h as J } from "vue";
|
|
5
|
-
import { useIntl as X } from "./vue-components.es3.js";
|
|
6
|
-
import Y from "./vue-components.es19.js";
|
|
7
|
-
import C from "./vue-components.es20.js";
|
|
8
|
-
import ee from "./vue-components.es21.js";
|
|
9
|
-
import { generateMetaFromSchema as re, deepMerge as N, defaultsValueFromSchema as te } from "./vue-components.es12.js";
|
|
10
|
-
import se from "./vue-components.es6.js";
|
|
11
|
-
import ne from "./vue-components.es8.js";
|
|
12
|
-
import oe from "./vue-components.es22.js";
|
|
13
|
-
import { trace as H } from "./vue-components.es23.js";
|
|
14
|
-
import { context as _ } from "./vue-components.es24.js";
|
|
15
|
-
class ie extends T.TaggedError("FormErrors") {
|
|
16
|
-
}
|
|
17
|
-
const M = (a) => function(s) {
|
|
18
|
-
return {
|
|
19
|
-
render() {
|
|
20
|
-
return J(s, {
|
|
21
|
-
form: a,
|
|
22
|
-
...this.$attrs
|
|
23
|
-
}, this.$slots);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}, ae = (a) => {
|
|
27
|
-
const { formatMessage: l } = X(), s = (c) => c.replace(/([A-Z])/g, " $1").replace(/^./, (F) => F.toUpperCase()).trim(), p = (c) => l ? l({ id: `general.fields.${c}`, defaultMessage: s(c) }) : s(c);
|
|
28
|
-
return (c) => a.i18nNamespace ? l({ id: `${a.i18nNamespace}.fields.${c}`, defaultMessage: p(c) }) : p(c);
|
|
29
|
-
}, ce = (a) => function(s) {
|
|
30
|
-
return {
|
|
31
|
-
setup() {
|
|
32
|
-
const { fieldMap: p, form: v } = a, c = v.useStore((S) => S.errors), F = v.useStore((S) => S.fieldMeta), h = v.useStore((S) => S.errorMap), A = ae(v), L = $(() => {
|
|
33
|
-
const S = Object.entries(F.value).reduce((y, [w, g]) => {
|
|
34
|
-
const u = g?.errors ?? [];
|
|
35
|
-
if (!u.length)
|
|
36
|
-
return y;
|
|
37
|
-
const d = p.value.get(w);
|
|
38
|
-
return d && y.push({
|
|
39
|
-
label: d.label,
|
|
40
|
-
inputId: d.id,
|
|
41
|
-
errors: [u[0]?.message].filter(Boolean)
|
|
42
|
-
}), y;
|
|
43
|
-
}, []), o = [];
|
|
44
|
-
if (h.value.onSubmit) {
|
|
45
|
-
for (const [y, w] of Object.entries(h.value.onSubmit))
|
|
46
|
-
if (P.isArray(w) && w.length)
|
|
47
|
-
for (const g of w) {
|
|
48
|
-
const u = g;
|
|
49
|
-
if (u?.path && P.isArray(u.path) && u.path.length) {
|
|
50
|
-
const d = u.path.join(".");
|
|
51
|
-
if (!p.value.has(d)) {
|
|
52
|
-
o.push({
|
|
53
|
-
label: A(d),
|
|
54
|
-
inputId: d,
|
|
55
|
-
errors: [u.message].filter(Boolean)
|
|
56
|
-
});
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return [...S, ...o];
|
|
63
|
-
});
|
|
64
|
-
return {
|
|
65
|
-
generalErrors: c,
|
|
66
|
-
errors: L
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
render({ errors: p, generalErrors: v }) {
|
|
70
|
-
return J(s, {
|
|
71
|
-
errors: p,
|
|
72
|
-
generalErrors: v,
|
|
73
|
-
...this.$attrs
|
|
74
|
-
}, this.$slots);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}, b = (a, l) => a.includes(l), Fe = (a, l, s) => {
|
|
78
|
-
if (!a) throw new Error("Schema is required");
|
|
79
|
-
const p = I.toStandardSchemaV1(a), v = I.decodeUnknownEffect(a), { meta: c, unionMeta: F } = re(a), h = $(() => {
|
|
80
|
-
if (s?.persistency?.id)
|
|
81
|
-
return s.persistency.id;
|
|
82
|
-
const e = window.location.pathname, r = Object.keys(c);
|
|
83
|
-
return `${e}-${r.join("-")}`;
|
|
84
|
-
}), A = () => {
|
|
85
|
-
const e = new URLSearchParams(window.location.search);
|
|
86
|
-
e.delete(h.value);
|
|
87
|
-
const r = new URL(window.location.href);
|
|
88
|
-
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
89
|
-
}, L = $(() => {
|
|
90
|
-
let e;
|
|
91
|
-
const r = s?.persistency;
|
|
92
|
-
if (
|
|
93
|
-
// query string has higher priority than local/session storage
|
|
94
|
-
r?.policies && !e && (b(r.policies, "local") || b(r.policies, "session"))
|
|
95
|
-
) {
|
|
96
|
-
const n = b(r.policies, "local") ? localStorage : sessionStorage;
|
|
97
|
-
if (n)
|
|
98
|
-
try {
|
|
99
|
-
const t = JSON.parse(
|
|
100
|
-
n.getItem(h.value) || "{}"
|
|
101
|
-
);
|
|
102
|
-
n.removeItem(h.value), e = t;
|
|
103
|
-
} catch (t) {
|
|
104
|
-
console.error(t);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (r?.policies && b(r.policies, "querystring"))
|
|
108
|
-
try {
|
|
109
|
-
const t = new URLSearchParams(window.location.search).get(h.value);
|
|
110
|
-
A(), t && (e = N(e || {}, JSON.parse(t)));
|
|
111
|
-
} catch (n) {
|
|
112
|
-
console.error(n);
|
|
113
|
-
}
|
|
114
|
-
e ??= {};
|
|
115
|
-
const i = {
|
|
116
|
-
tanstack: l?.defaultValues || {},
|
|
117
|
-
persistency: e,
|
|
118
|
-
schema: te(a)
|
|
119
|
-
};
|
|
120
|
-
return (s?.defaultValuesPriority || ["tanstack", "persistency", "schema"]).reverse().reduce(
|
|
121
|
-
(n, t) => Object.keys(n).length ? N(n, i[t]) : i[t],
|
|
122
|
-
{}
|
|
123
|
-
);
|
|
124
|
-
}), S = (e, r) => e ? _.with(H.setSpan(_.active(), e), r) : r(), o = K({
|
|
125
|
-
...l,
|
|
126
|
-
validators: {
|
|
127
|
-
onSubmit: p,
|
|
128
|
-
...l?.validators || {}
|
|
129
|
-
},
|
|
130
|
-
onSubmit: l?.onSubmit ? ({ formApi: e, meta: r, value: i }) => S(r?.currentSpan, async () => {
|
|
131
|
-
const n = await m.runPromise(v(i)), t = l.onSubmit({
|
|
132
|
-
formApi: e,
|
|
133
|
-
meta: r,
|
|
134
|
-
value: n
|
|
135
|
-
});
|
|
136
|
-
if (V.isFiber(t))
|
|
137
|
-
return await W(t);
|
|
138
|
-
if (m.isEffect(t)) {
|
|
139
|
-
const f = await m.runPromise(t);
|
|
140
|
-
return V.isFiber(f) ? await W(f) : f;
|
|
141
|
-
}
|
|
142
|
-
return t;
|
|
143
|
-
}) : void 0,
|
|
144
|
-
defaultValues: L.value
|
|
145
|
-
}), y = () => {
|
|
146
|
-
Object.keys(c).forEach((e) => {
|
|
147
|
-
o.setFieldValue(e, void 0);
|
|
148
|
-
});
|
|
149
|
-
}, w = (e) => e.reduce((r, i) => {
|
|
150
|
-
const n = i.split(".");
|
|
151
|
-
return n.reduce((t, f, U) => (U === n.length - 1 ? t[f] = o.getFieldValue(i) : t[f] = t[f] ?? {}, t[f]), r), r;
|
|
152
|
-
}, {}), g = (e) => {
|
|
153
|
-
if (!e) return;
|
|
154
|
-
const { banKeys: r, keys: i } = e;
|
|
155
|
-
if (P.isArray(i))
|
|
156
|
-
return w(i);
|
|
157
|
-
if (P.isArray(r)) {
|
|
158
|
-
const n = Object.keys(c).filter((t) => r.includes(t));
|
|
159
|
-
return w(n);
|
|
160
|
-
}
|
|
161
|
-
return o.store.state.values;
|
|
162
|
-
}, u = () => {
|
|
163
|
-
const e = s?.persistency;
|
|
164
|
-
if (!(!e?.policies || e.policies.length === 0) && (b(e.policies, "local") || b(e.policies, "session"))) {
|
|
165
|
-
const r = b(e.policies, "local") ? localStorage : sessionStorage;
|
|
166
|
-
if (!r) return;
|
|
167
|
-
const i = g(e);
|
|
168
|
-
return r.setItem(h.value, JSON.stringify(i));
|
|
169
|
-
}
|
|
170
|
-
}, d = () => {
|
|
171
|
-
const e = s?.persistency;
|
|
172
|
-
if (!(!e?.policies || e.policies.length === 0) && b(e.policies, "querystring")) {
|
|
173
|
-
const r = g(e), i = new URLSearchParams(window.location.search);
|
|
174
|
-
i.set(h.value, JSON.stringify(r));
|
|
175
|
-
const n = new URL(window.location.href);
|
|
176
|
-
n.search = i.toString(), window.history.replaceState({}, "", n.toString());
|
|
177
|
-
}
|
|
178
|
-
}, j = (e) => {
|
|
179
|
-
o.store.state.isDirty && e.preventDefault();
|
|
180
|
-
};
|
|
181
|
-
if (D(u), G(() => {
|
|
182
|
-
window.addEventListener("beforeunload", u), window.addEventListener("blur", d), s?.preventWindowExit && s.preventWindowExit !== "nope" && window.addEventListener("beforeunload", j);
|
|
183
|
-
}), Z(() => {
|
|
184
|
-
window.removeEventListener("beforeunload", u), window.removeEventListener("blur", d), s?.preventWindowExit && s.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", j);
|
|
185
|
-
}), s?.preventWindowExit === "prevent-and-reset") {
|
|
186
|
-
const e = o.useStore((t) => t.isSubmitting), r = o.useStore((t) => t.submissionAttempts), i = o.useStore((t) => t.canSubmit), n = o.useStore((t) => t.values);
|
|
187
|
-
R([e, r], ([t, f], [U]) => {
|
|
188
|
-
U && !t && f > 0 && i.value && o.reset(n.value);
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
const x = (e) => m.currentSpan.pipe(
|
|
192
|
-
m.option,
|
|
193
|
-
m.flatMap(
|
|
194
|
-
(r) => m.promise(() => o.handleSubmit(z.isSome(r) ? { currentSpan: r.value, ...e } : e))
|
|
195
|
-
)
|
|
196
|
-
), q = (e) => e?.checkErrors ? x(e?.meta).pipe(m.flatMap(m.fnUntraced(function* () {
|
|
197
|
-
const r = o.getAllErrors();
|
|
198
|
-
if (Object.keys(r.fields).length || r.form.errors.length)
|
|
199
|
-
return yield* m.fail(new ie({ form: r.form, fields: r.fields }));
|
|
200
|
-
}))) : x(e?.meta), B = o.handleSubmit, O = Q(/* @__PURE__ */ new Map()), E = Object.assign(o, {
|
|
201
|
-
i18nNamespace: s?.i18nNamespace,
|
|
202
|
-
ignorePreventCloseEvents: s?.ignorePreventCloseEvents,
|
|
203
|
-
meta: c,
|
|
204
|
-
unionMeta: F,
|
|
205
|
-
clear: y,
|
|
206
|
-
handleSubmit: (e) => {
|
|
207
|
-
const r = H.getSpan(_.active());
|
|
208
|
-
return B({ currentSpan: r, ...e });
|
|
209
|
-
},
|
|
210
|
-
// /** @experimental */
|
|
211
|
-
handleSubmitEffect: q,
|
|
212
|
-
registerField: (e) => {
|
|
213
|
-
R(e, (r) => {
|
|
214
|
-
O.value.set(r.name, { label: r.label, id: r.id });
|
|
215
|
-
}, { immediate: !0 }), D(() => {
|
|
216
|
-
O.value.get(e.value.name)?.id === e.value.id && O.value.delete(e.value.name);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}), k = { form: E, fieldMap: O };
|
|
220
|
-
return Object.assign(E, {
|
|
221
|
-
// Type-level properties for performance optimization (not used at runtime)
|
|
222
|
-
_paths: void 0,
|
|
223
|
-
_keys: void 0,
|
|
224
|
-
_schema: a,
|
|
225
|
-
errorContext: k,
|
|
226
|
-
Form: M(E)(oe),
|
|
227
|
-
Input: M(E)(s?.input ?? se),
|
|
228
|
-
TaggedUnion: M(E)(ne),
|
|
229
|
-
Field: o.Field,
|
|
230
|
-
Errors: ce(k)(ee),
|
|
231
|
-
Array: M(E)(Y),
|
|
232
|
-
AutoGen: M(E)(C)
|
|
233
|
-
});
|
|
234
|
-
};
|
|
235
|
-
export {
|
|
236
|
-
ie as FormErrors,
|
|
237
|
-
ae as useErrorLabel,
|
|
238
|
-
Fe as useOmegaForm
|
|
239
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import l from "./vue-components.es29.js";
|
|
2
|
-
import { inject as c, provide as u } from "vue";
|
|
3
|
-
import { onMountedWithCleanup as f } from "./vue-components.es16.js";
|
|
4
|
-
const p = () => l(), i = /* @__PURE__ */ Symbol("DialogBus"), r = () => c(i, null), g = () => {
|
|
5
|
-
const n = p();
|
|
6
|
-
return u(i, n), n;
|
|
7
|
-
}, d = (n) => {
|
|
8
|
-
const o = r();
|
|
9
|
-
if (!o)
|
|
10
|
-
return;
|
|
11
|
-
const s = n();
|
|
12
|
-
f(() => {
|
|
13
|
-
const e = (t) => {
|
|
14
|
-
s.value && (confirm("Es sind ungespeicherte Änderungen vorhanden. Wirklich schließen?") || (t.prevent = !0));
|
|
15
|
-
};
|
|
16
|
-
return o.on("dialog-closing", e), () => o.off("dialog-closing", e);
|
|
17
|
-
});
|
|
18
|
-
}, h = (n) => {
|
|
19
|
-
let o = r();
|
|
20
|
-
return o || (o = g()), () => {
|
|
21
|
-
const e = {};
|
|
22
|
-
o.emit("dialog-closing", e), e.prevent ? typeof e.prevent == "object" && "then" in e.prevent && e.prevent.then((t) => {
|
|
23
|
-
t !== !1 && n();
|
|
24
|
-
}) : n();
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
r as injectBus,
|
|
29
|
-
g as provideBus,
|
|
30
|
-
h as useOnClose,
|
|
31
|
-
d as usePreventClose
|
|
32
|
-
};
|