@effect-app/vue-components 4.0.0-beta.34 → 4.0.0-beta.36
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/types/components/OmegaForm/OmegaFormStuff.d.ts +8 -3
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +1 -1
- package/dist/vue-components.es.js +8 -7
- package/dist/vue-components.es10.js +120 -120
- package/dist/vue-components.es12.js +160 -138
- package/dist/vue-components.es17.js +2 -2
- package/dist/vue-components.es2.js +15 -14
- package/dist/vue-components.es20.js +2 -2
- package/dist/vue-components.es21.js +2 -2
- package/dist/vue-components.es30.js +191 -28
- package/dist/vue-components.es32.js +29 -2
- package/dist/vue-components.es33.js +4 -2
- package/dist/vue-components.es34.js +2 -111
- package/dist/vue-components.es35.js +4 -0
- package/dist/vue-components.es36.js +111 -7
- package/dist/vue-components.es38.js +9 -0
- package/dist/vue-components.es39.js +27 -187
- package/dist/vue-components.es41.js +1 -1
- package/dist/vue-components.es45.js +1 -1
- package/dist/vue-components.es52.js +2 -2
- package/dist/vue-components.es53.js +3 -3
- package/dist/vue-components.es55.js +29 -65
- package/dist/vue-components.es56.js +54 -45
- package/dist/vue-components.es57.js +54 -15
- package/dist/vue-components.es58.js +15 -31
- package/dist/vue-components.es59.js +30 -26
- package/dist/vue-components.es7.js +1 -1
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaFormStuff.ts +75 -4
- package/src/components/OmegaForm/useOmegaForm.ts +5 -4
- package/dist/vue-components.es31.js +0 -6
- package/dist/vue-components.es37.js +0 -34
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
var
|
|
5
|
-
function r
|
|
6
|
-
|
|
1
|
+
import { VERSION as t } from "./vue-components.es61.js";
|
|
2
|
+
import { isCompatible as f } from "./vue-components.es62.js";
|
|
3
|
+
import { _globalThis as m } from "./vue-components.es63.js";
|
|
4
|
+
var u = t.split(".")[0], n = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + u), l = m;
|
|
5
|
+
function d(r, o, e, i) {
|
|
6
|
+
var v;
|
|
7
|
+
i === void 0 && (i = !1);
|
|
8
|
+
var s = l[n] = (v = l[n]) !== null && v !== void 0 ? v : {
|
|
9
|
+
version: t
|
|
10
|
+
};
|
|
11
|
+
if (!i && s[r]) {
|
|
12
|
+
var a = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + r);
|
|
13
|
+
return e.error(a.stack || a.message), !1;
|
|
14
|
+
}
|
|
15
|
+
if (s.version !== t) {
|
|
16
|
+
var a = new Error("@opentelemetry/api: Registration of version v" + s.version + " for " + r + " does not match previously registered API v" + t);
|
|
17
|
+
return e.error(a.stack || a.message), !1;
|
|
18
|
+
}
|
|
19
|
+
return s[r] = o, e.debug("@opentelemetry/api: Registered a global for " + r + " v" + t + "."), !0;
|
|
7
20
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
21
|
+
function E(r) {
|
|
22
|
+
var o, e, i = (o = l[n]) === null || o === void 0 ? void 0 : o.version;
|
|
23
|
+
if (!(!i || !f(i)))
|
|
24
|
+
return (e = l[n]) === null || e === void 0 ? void 0 : e[r];
|
|
10
25
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return e.deleteValue(n);
|
|
16
|
-
}
|
|
17
|
-
function d(e, t) {
|
|
18
|
-
return i(e, new a(t));
|
|
19
|
-
}
|
|
20
|
-
function m(e) {
|
|
21
|
-
var t;
|
|
22
|
-
return (t = r(e)) === null || t === void 0 ? void 0 : t.spanContext();
|
|
26
|
+
function _(r, o) {
|
|
27
|
+
o.debug("@opentelemetry/api: Unregistering a global for " + r + " v" + t + ".");
|
|
28
|
+
var e = l[n];
|
|
29
|
+
e && delete e[r];
|
|
23
30
|
}
|
|
24
31
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
m as getSpanContext,
|
|
29
|
-
i as setSpan,
|
|
30
|
-
d as setSpanContext
|
|
32
|
+
E as getGlobal,
|
|
33
|
+
d as registerGlobal,
|
|
34
|
+
_ as unregisterGlobal
|
|
31
35
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");if(i.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(i),window.customElements){const e=window.customElements.define;window.customElements.define=function(s,t){const n=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(n&&n.call(this),this.shadowRoot){const a=document.createElement("style");a.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(a)}},e.call(window.customElements,s,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
2
|
import { defineComponent as k, computed as a, getCurrentInstance as q, useAttrs as B, useSlots as S, useId as w, renderSlot as p, normalizeProps as s, guardReactiveProps as f, createElementVNode as F, normalizeClass as I, createBlock as L, createCommentVNode as A, unref as O, openBlock as R, mergeProps as V, createSlots as z, withCtx as T } from "vue";
|
|
3
3
|
import { useStore as c } from "@tanstack/vue-form";
|
|
4
|
-
import U from "./vue-components.
|
|
4
|
+
import U from "./vue-components.es30.js";
|
|
5
5
|
|
|
6
6
|
const J = /* @__PURE__ */ k({
|
|
7
7
|
inheritAttrs: !1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.36",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"effect": "^4.0.0-beta.40",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"highlight.js": "^11.11.1",
|
|
58
58
|
"mitt": "^3.0.1",
|
|
59
59
|
"vue3-highlightjs": "^1.0.5",
|
|
60
|
-
"@effect-app/vue": "4.0.0-beta.
|
|
61
|
-
"effect-app": "4.0.0-beta.
|
|
60
|
+
"@effect-app/vue": "4.0.0-beta.36",
|
|
61
|
+
"effect-app": "4.0.0-beta.36"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"check": "vue-tsc",
|
|
@@ -3,6 +3,7 @@ import { Effect, Option, type Record, S } from "effect-app"
|
|
|
3
3
|
import { type DeepKeys, type DeepValue, type FieldAsyncValidateOrFn, type FieldValidateOrFn, type FormApi, type FormAsyncValidateOrFn, type FormOptions, type FormState, type FormValidateOrFn, type StandardSchemaV1, type VueFormApi } from "@tanstack/vue-form"
|
|
4
4
|
import { isObject } from "@vueuse/core"
|
|
5
5
|
import type { Fiber as EffectFiber } from "effect/Fiber"
|
|
6
|
+
import type { Redacted } from "effect/Redacted"
|
|
6
7
|
import { getTransformationFrom, useIntl } from "../../utils"
|
|
7
8
|
import { type OmegaFieldInternalApi } from "./InputProps"
|
|
8
9
|
import { type OF, type OmegaFormReturn } from "./useOmegaForm"
|
|
@@ -23,7 +24,7 @@ const isDevelopmentEnvironment = () => {
|
|
|
23
24
|
|
|
24
25
|
export type FieldPath<T> = unknown extends T ? string
|
|
25
26
|
// technically we cannot have primitive at the root
|
|
26
|
-
: T extends string | boolean | number | null | undefined | symbol | bigint ? ""
|
|
27
|
+
: T extends string | boolean | number | null | undefined | symbol | bigint | Redacted<any> ? ""
|
|
27
28
|
// technically we cannot have array at the root
|
|
28
29
|
: T extends ReadonlyArray<infer U> ? FieldPath_<U, `[${number}]`>
|
|
29
30
|
: {
|
|
@@ -31,7 +32,7 @@ export type FieldPath<T> = unknown extends T ? string
|
|
|
31
32
|
}[keyof T]
|
|
32
33
|
|
|
33
34
|
export type FieldPath_<T, Path extends string> = unknown extends T ? string
|
|
34
|
-
: T extends string | boolean | number | null | undefined | symbol | bigint ? Path
|
|
35
|
+
: T extends string | boolean | number | null | undefined | symbol | bigint | Redacted<any> ? Path
|
|
35
36
|
: T extends ReadonlyArray<infer U> ? FieldPath_<U, `${Path}[${number}]`> | Path
|
|
36
37
|
: {
|
|
37
38
|
[K in keyof T]: FieldPath_<T[K], `${Path}.${K & string}`>
|
|
@@ -236,7 +237,13 @@ export type PrefixFromDepth<
|
|
|
236
237
|
_TDepth extends any[]
|
|
237
238
|
> = K
|
|
238
239
|
|
|
239
|
-
|
|
240
|
+
// Recursively replace Redacted<A> with its inner type so DeepKeys treats it as a leaf
|
|
241
|
+
type StripRedacted<T> = T extends Redacted<any> ? string
|
|
242
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<StripRedacted<U>>
|
|
243
|
+
: T extends Record<string, any> ? { [K in keyof T]: StripRedacted<T[K]> }
|
|
244
|
+
: T
|
|
245
|
+
|
|
246
|
+
export type NestedKeyOf<T> = DeepKeys<StripRedacted<T>>
|
|
240
247
|
|
|
241
248
|
export type FieldValidators<T> = {
|
|
242
249
|
onChangeAsync?: FieldAsyncValidateOrFn<T, any, any>
|
|
@@ -730,7 +737,7 @@ export const createMeta = <T = any>(
|
|
|
730
737
|
// an empty string is valid for a S.String field, so we should not mark it as required
|
|
731
738
|
// TODO: handle this better via the createMeta minLength parsing
|
|
732
739
|
required: isRequired
|
|
733
|
-
&& (!S.AST.isString(typeToProcess) || !!getFieldMetadataFromAst(
|
|
740
|
+
&& (!S.AST.isString(typeToProcess) || !!getFieldMetadataFromAst(typeToProcess).minLength),
|
|
734
741
|
nullableOrUndefined
|
|
735
742
|
}
|
|
736
743
|
})
|
|
@@ -937,6 +944,70 @@ const metadataFromAst = <From, To>(
|
|
|
937
944
|
return { meta: newMeta, defaultValues, unionMeta }
|
|
938
945
|
}
|
|
939
946
|
|
|
947
|
+
/*
|
|
948
|
+
* Checks if an AST node is a S.Redacted Declaration without encoding.
|
|
949
|
+
* These need to be swapped to S.RedactedFromValue for form usage
|
|
950
|
+
* because S.Redacted expects Redacted objects, not plain strings.
|
|
951
|
+
*/
|
|
952
|
+
const isRedactedWithoutEncoding = (ast: S.AST.AST): boolean =>
|
|
953
|
+
S.AST.isDeclaration(ast)
|
|
954
|
+
&& (ast.annotations as any)?.typeConstructor?._tag === "effect/Redacted"
|
|
955
|
+
&& !ast.encoding
|
|
956
|
+
|
|
957
|
+
/*
|
|
958
|
+
* Creates a form-compatible schema by replacing S.Redacted(X) with
|
|
959
|
+
* S.RedactedFromValue(X). S.Redacted is a Declaration that expects
|
|
960
|
+
* Redacted<A> on both encoded and type sides, so form inputs (which
|
|
961
|
+
* produce plain strings) fail validation. S.RedactedFromValue accepts
|
|
962
|
+
* plain values on the encoded side and wraps them in Redacted on decode.
|
|
963
|
+
*/
|
|
964
|
+
export const toFormSchema = <From, To>(
|
|
965
|
+
schema: S.Codec<To, From, never>
|
|
966
|
+
): S.Codec<To, From, never> => {
|
|
967
|
+
const ast = schema.ast
|
|
968
|
+
const objAst = S.AST.isObjects(ast)
|
|
969
|
+
? ast
|
|
970
|
+
: S.AST.isDeclaration(ast)
|
|
971
|
+
? S.AST.toEncoded(ast)
|
|
972
|
+
: null
|
|
973
|
+
|
|
974
|
+
if (!objAst || !("propertySignatures" in objAst)) return schema
|
|
975
|
+
|
|
976
|
+
let hasRedacted = false
|
|
977
|
+
const props: Record<string, S.Struct.Fields[string]> = {}
|
|
978
|
+
|
|
979
|
+
for (const p of objAst.propertySignatures) {
|
|
980
|
+
if (isRedactedWithoutEncoding(p.type)) {
|
|
981
|
+
hasRedacted = true
|
|
982
|
+
const innerSchema = S.make((p.type as S.AST.Declaration).typeParameters[0]!)
|
|
983
|
+
props[p.name as string] = S.RedactedFromValue(innerSchema)
|
|
984
|
+
} else if (S.AST.isUnion(p.type)) {
|
|
985
|
+
const types = p.type.types
|
|
986
|
+
const redactedType = types.find(isRedactedWithoutEncoding)
|
|
987
|
+
if (redactedType) {
|
|
988
|
+
hasRedacted = true
|
|
989
|
+
const innerSchema = S.make((redactedType as S.AST.Declaration).typeParameters[0]!)
|
|
990
|
+
const hasNull = types.some(S.AST.isNull)
|
|
991
|
+
const hasUndefined = types.some(S.AST.isUndefined)
|
|
992
|
+
const base = S.RedactedFromValue(innerSchema)
|
|
993
|
+
props[p.name as string] = hasNull && hasUndefined
|
|
994
|
+
? S.NullishOr(base)
|
|
995
|
+
: hasNull
|
|
996
|
+
? S.NullOr(base)
|
|
997
|
+
: hasUndefined
|
|
998
|
+
? S.UndefinedOr(base)
|
|
999
|
+
: base
|
|
1000
|
+
} else {
|
|
1001
|
+
props[p.name as string] = S.make(p.type)
|
|
1002
|
+
}
|
|
1003
|
+
} else {
|
|
1004
|
+
props[p.name as string] = S.make(p.type)
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
return hasRedacted ? S.Struct(props) as unknown as S.Codec<To, From, never> : schema
|
|
1009
|
+
}
|
|
1010
|
+
|
|
940
1011
|
export const duplicateSchema = <From, To>(
|
|
941
1012
|
schema: S.Codec<To, From, never>
|
|
942
1013
|
) => {
|
|
@@ -11,7 +11,7 @@ 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"
|
|
@@ -395,7 +395,7 @@ export interface OmegaFormReturn<
|
|
|
395
395
|
> extends OF<From, To> {
|
|
396
396
|
// Pre-computed type aliases - computed ONCE for performance
|
|
397
397
|
_paths: FieldPath<From>
|
|
398
|
-
_keys:
|
|
398
|
+
_keys: NestedKeyOf<From>
|
|
399
399
|
_schema: S.Codec<To, From, never>
|
|
400
400
|
|
|
401
401
|
// 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..
|
|
@@ -680,8 +680,9 @@ export const useOmegaForm = <
|
|
|
680
680
|
omegaConfig?: OmegaConfig<To>
|
|
681
681
|
): OmegaFormReturn<From, To, TypeProps> => {
|
|
682
682
|
if (!schema) throw new Error("Schema is required")
|
|
683
|
-
const
|
|
684
|
-
const
|
|
683
|
+
const formCompatibleSchema = toFormSchema(schema)
|
|
684
|
+
const standardSchema = S.toStandardSchemaV1(formCompatibleSchema)
|
|
685
|
+
const decode = S.decodeUnknownEffect(formCompatibleSchema)
|
|
685
686
|
|
|
686
687
|
const { meta, unionMeta } = generateMetaFromSchema(schema)
|
|
687
688
|
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { defineComponent as m, createElementBlock as d, openBlock as u, withModifiers as f, createElementVNode as l, unref as s, renderSlot as a } from "vue";
|
|
2
|
-
import { useStore as b } from "@tanstack/vue-form";
|
|
3
|
-
import { usePreventClose as p } from "./vue-components.es11.js";
|
|
4
|
-
import { getOmegaStore as c } from "./vue-components.es54.js";
|
|
5
|
-
const S = ["disabled"], V = /* @__PURE__ */ m({
|
|
6
|
-
__name: "OmegaWrapper",
|
|
7
|
-
props: {
|
|
8
|
-
form: {},
|
|
9
|
-
disabled: { type: Boolean },
|
|
10
|
-
subscribe: {}
|
|
11
|
-
},
|
|
12
|
-
setup(o) {
|
|
13
|
-
const e = o, i = b(
|
|
14
|
-
e.form.store,
|
|
15
|
-
(t) => t.isSubmitting
|
|
16
|
-
), n = c(
|
|
17
|
-
e.form,
|
|
18
|
-
e.subscribe
|
|
19
|
-
);
|
|
20
|
-
return e.form.ignorePreventCloseEvents || p(() => e.form.useStore((t) => t.isDirty)), (t, r) => (u(), d("form", {
|
|
21
|
-
novalidate: "",
|
|
22
|
-
onSubmit: r[0] || (r[0] = f((v) => o.form.handleSubmit(), ["prevent", "stop"]))
|
|
23
|
-
}, [
|
|
24
|
-
l("fieldset", {
|
|
25
|
-
disabled: s(i) || o.disabled
|
|
26
|
-
}, [
|
|
27
|
-
a(t.$slots, "default", { subscribedValues: s(n) }, void 0, !0)
|
|
28
|
-
], 8, S)
|
|
29
|
-
], 32));
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
export {
|
|
33
|
-
V as default
|
|
34
|
-
};
|