@effect-app/vue-components 0.4.3 → 0.4.5
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/OmegaFormInput.vue.d.ts +26 -0
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +6 -4
- package/dist/vue-components.es11.js +1 -1
- package/dist/vue-components.es17.js +1 -1
- package/dist/vue-components.es18.js +32 -2
- package/dist/vue-components.es19.js +2 -11
- package/dist/vue-components.es20.js +2 -96
- package/dist/vue-components.es21.js +11 -2
- package/dist/vue-components.es22.js +89 -108
- package/dist/vue-components.es23.js +4 -0
- package/dist/vue-components.es24.js +115 -4
- package/dist/vue-components.es26.js +6 -0
- package/dist/vue-components.es4.js +1 -1
- package/dist/vue-components.es6.js +63 -80
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaFormInput.vue +45 -0
- package/src/components/OmegaForm/useOmegaForm.ts +12 -35
- package/src/stories/OmegaForm/form.Input.vue +14 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FieldValidators, NestedKeyOf, TypeOverride } from "./OmegaFormStuff";
|
|
2
|
+
import type { InputProps } from "./InputProps";
|
|
3
|
+
declare const _default: <From, To extends Record<PropertyKey, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & {
|
|
5
|
+
name: NestedKeyOf<To>;
|
|
6
|
+
label: string;
|
|
7
|
+
validators?: FieldValidators<From>;
|
|
8
|
+
options?: {
|
|
9
|
+
title: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}[];
|
|
12
|
+
type?: TypeOverride;
|
|
13
|
+
} & Partial<{}>> & import("vue").PublicProps;
|
|
14
|
+
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
15
|
+
attrs: any;
|
|
16
|
+
slots: {
|
|
17
|
+
default: (props: InputProps<To>) => any;
|
|
18
|
+
};
|
|
19
|
+
emit: {};
|
|
20
|
+
}>) => import("vue").VNode & {
|
|
21
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
24
|
+
type __VLS_PrettifyLocal<T> = {
|
|
25
|
+
[K in keyof T]: T[K];
|
|
26
|
+
} & {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Record, S } from "effect-app";
|
|
2
|
-
import { type NestedKeyOf, type FilterItems, type FormProps, type MetaRecord, type OmegaFormApi
|
|
3
|
-
import { type
|
|
2
|
+
import { type NestedKeyOf, type FilterItems, type FormProps, type MetaRecord, type OmegaFormApi } from "./OmegaFormStuff";
|
|
3
|
+
import { type InjectionKey } from "vue";
|
|
4
|
+
import OmegaFormInput from "./OmegaFormInput.vue";
|
|
4
5
|
type keysRule<T> = {
|
|
5
6
|
keys?: NestedKeyOf<T>[];
|
|
6
7
|
banKeys?: "You should only use one of banKeys or keys, not both, moron";
|
|
@@ -24,8 +25,9 @@ interface OF<To, From> extends OmegaFormApi<To, From> {
|
|
|
24
25
|
filterItems?: FilterItems;
|
|
25
26
|
clear: () => void;
|
|
26
27
|
}
|
|
27
|
-
export
|
|
28
|
-
|
|
28
|
+
export declare const OmegaFormKey: InjectionKey<OF<any, any>>;
|
|
29
|
+
export interface OmegaFormReturn<To extends Record<PropertyKey, any>, From> extends OF<To, From> {
|
|
30
|
+
Input: typeof OmegaFormInput<From, To>;
|
|
29
31
|
}
|
|
30
32
|
export declare const useOmegaForm: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>>(schema: S.Schema<From, To, never>, tanstackFormOptions?: NoInfer<FormProps<To, From>>, omegaConfig?: OmegaConfig<From>) => OmegaFormReturn<To, From>;
|
|
31
33
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as h, computed as u, watch as F, createElementBlock as c, openBlock as d, withModifiers as y, createElementVNode as O, unref as i, renderSlot as l, createCommentVNode as E, Fragment as M } from "vue";
|
|
2
2
|
import { useStore as v } from "@tanstack/vue-form";
|
|
3
|
-
import { getOmegaStore as V } from "./vue-components.
|
|
3
|
+
import { getOmegaStore as V } from "./vue-components.es21.js";
|
|
4
4
|
import { provideOmegaErrors as w } from "./vue-components.es5.js";
|
|
5
5
|
import { useOmegaForm as I } from "./vue-components.es6.js";
|
|
6
6
|
const k = ["disabled"], j = /* @__PURE__ */ h({
|
|
@@ -1,4 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineComponent as a, inject as t, createBlock as n, openBlock as m, mergeProps as p, unref as s, withCtx as i, renderSlot as l, normalizeProps as f, guardReactiveProps as u } from "vue";
|
|
2
|
+
import d from "./vue-components.es4.js";
|
|
3
|
+
import { OmegaFormKey as c } from "./vue-components.es6.js";
|
|
4
|
+
const w = /* @__PURE__ */ a({
|
|
5
|
+
__name: "OmegaFormInput",
|
|
6
|
+
props: {
|
|
7
|
+
name: {},
|
|
8
|
+
label: {},
|
|
9
|
+
validators: {},
|
|
10
|
+
options: {},
|
|
11
|
+
type: {}
|
|
12
|
+
},
|
|
13
|
+
setup(g) {
|
|
14
|
+
const o = t(c);
|
|
15
|
+
if (!o)
|
|
16
|
+
throw new Error("OmegaFormInput must be used within an OmegaForm context");
|
|
17
|
+
return (e, b) => (m(), n(d, p(e.$props, {
|
|
18
|
+
form: s(o),
|
|
19
|
+
name: e.name,
|
|
20
|
+
label: e.label,
|
|
21
|
+
validators: e.validators,
|
|
22
|
+
options: e.options,
|
|
23
|
+
type: e.type
|
|
24
|
+
}), {
|
|
25
|
+
default: i((r) => [
|
|
26
|
+
l(e.$slots, "default", f(u(r)))
|
|
27
|
+
]),
|
|
28
|
+
_: 3
|
|
29
|
+
}, 16, ["form", "name", "label", "validators", "options", "type"]));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
2
32
|
export {
|
|
3
|
-
|
|
33
|
+
w as default
|
|
4
34
|
};
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { computed as f } from "vue";
|
|
3
|
-
function c(o, t) {
|
|
4
|
-
return f(() => t ? u(o.store, (n) => {
|
|
5
|
-
const r = {};
|
|
6
|
-
for (const e of t)
|
|
7
|
-
r[e] = n[e];
|
|
8
|
-
return r;
|
|
9
|
-
}).value : {});
|
|
10
|
-
}
|
|
1
|
+
const o = (n) => typeof n == "function";
|
|
11
2
|
export {
|
|
12
|
-
|
|
3
|
+
o as isFunction
|
|
13
4
|
};
|
|
@@ -1,98 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineComponent as B, getCurrentInstance as L, useId as P, computed as l, watch as C, onMounted as $, ref as S, watchEffect as z, renderSlot as A, normalizeProps as D, guardReactiveProps as F, createElementVNode as M, normalizeClass as N, createBlock as R, createCommentVNode as T, unref as U, openBlock as j, mergeProps as G } from "vue";
|
|
3
|
-
import { useStore as H } from "@tanstack/vue-form";
|
|
4
|
-
import { useOmegaErrors as J } from "./vue-components.es5.js";
|
|
5
|
-
import K from "./vue-components.es22.js";
|
|
6
|
-
|
|
7
|
-
const ee = /* @__PURE__ */ B({
|
|
8
|
-
inheritAttrs: !1,
|
|
9
|
-
__name: "OmegaInternalInput",
|
|
10
|
-
props: {
|
|
11
|
-
field: {},
|
|
12
|
-
meta: {},
|
|
13
|
-
label: {},
|
|
14
|
-
options: {},
|
|
15
|
-
type: {},
|
|
16
|
-
validators: {}
|
|
17
|
-
},
|
|
18
|
-
setup(q) {
|
|
19
|
-
const e = q, o = L(), x = o == null ? void 0 : o.appContext.components.VTextField, s = P(), u = e.field, a = H(u.store, (t) => t), f = l(() => {
|
|
20
|
-
var t, r;
|
|
21
|
-
return e.type ? e.type : ((t = e.meta) == null ? void 0 : t.type) === "string" ? e.meta.format === "email" ? "email" : "string" : ((r = e.meta) == null ? void 0 : r.type) || "unknown";
|
|
22
|
-
}), n = l(() => a.value.value), d = l(
|
|
23
|
-
() => (
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
-
a.value.meta.errors.map((t) => t == null ? void 0 : t.message).filter(Boolean)
|
|
26
|
-
)
|
|
27
|
-
);
|
|
28
|
-
C(
|
|
29
|
-
() => [!!n.value],
|
|
30
|
-
() => {
|
|
31
|
-
var t, r;
|
|
32
|
-
d.value.length && !n.value && !((t = e.meta) != null && t.required) && u.setValue(
|
|
33
|
-
((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "undefined" ? void 0 : null
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
), $(() => {
|
|
37
|
-
var t, r;
|
|
38
|
-
!n.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && u.setValue(null);
|
|
39
|
-
});
|
|
40
|
-
const { addError: I, removeError: O, showErrors: _, showErrorsOn: k } = J(), i = S(!1);
|
|
41
|
-
z(() => {
|
|
42
|
-
(_.value || k === "onChange") && (i.value = !0);
|
|
43
|
-
});
|
|
44
|
-
const m = () => {
|
|
45
|
-
i.value = !0;
|
|
46
|
-
};
|
|
47
|
-
$(() => {
|
|
48
|
-
n.value && m();
|
|
49
|
-
});
|
|
50
|
-
const v = l(() => !i.value && f.value !== "select" ? [] : d.value);
|
|
51
|
-
C(
|
|
52
|
-
() => a.value.meta.errors,
|
|
53
|
-
() => {
|
|
54
|
-
a.value.meta.errors.length ? I({
|
|
55
|
-
inputId: s,
|
|
56
|
-
errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
|
|
57
|
-
label: e.label
|
|
58
|
-
}) : O(s);
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
const p = l(() => {
|
|
62
|
-
var t, r, c, g, y, h, b, E, V, w;
|
|
63
|
-
return {
|
|
64
|
-
id: s,
|
|
65
|
-
required: (t = e.meta) == null ? void 0 : t.required,
|
|
66
|
-
minLength: ((r = e.meta) == null ? void 0 : r.type) === "string" && ((c = e.meta) == null ? void 0 : c.minLength),
|
|
67
|
-
maxLength: ((g = e.meta) == null ? void 0 : g.type) === "string" && ((y = e.meta) == null ? void 0 : y.maxLength),
|
|
68
|
-
max: ((h = e.meta) == null ? void 0 : h.type) === "number" && ((b = e.meta) == null ? void 0 : b.maximum),
|
|
69
|
-
min: ((E = e.meta) == null ? void 0 : E.type) === "number" && ((V = e.meta) == null ? void 0 : V.minimum),
|
|
70
|
-
name: e.field.name,
|
|
71
|
-
modelValue: e.field.state.value,
|
|
72
|
-
errorMessages: v.value,
|
|
73
|
-
error: !!v.value.length,
|
|
74
|
-
field: e.field,
|
|
75
|
-
setRealDirty: m,
|
|
76
|
-
type: f.value,
|
|
77
|
-
label: `${e.label}${(w = e.meta) != null && w.required ? " *" : ""}`,
|
|
78
|
-
options: e.options
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
return (t, r) => A(t.$slots, "default", D(F(p.value)), () => [
|
|
82
|
-
M("div", {
|
|
83
|
-
class: N(t.$attrs.class),
|
|
84
|
-
onFocusout: m
|
|
85
|
-
}, [
|
|
86
|
-
U(x) ? (j(), R(K, G({
|
|
87
|
-
key: 0,
|
|
88
|
-
"input-props": p.value
|
|
89
|
-
}, t.$attrs, {
|
|
90
|
-
"vuetify-value": p.value.field.state.value
|
|
91
|
-
}), null, 16, ["input-props", "vuetify-value"])) : T("", !0)
|
|
92
|
-
], 34)
|
|
93
|
-
]);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
1
|
+
import f from "./vue-components.es18.js";
|
|
96
2
|
export {
|
|
97
|
-
|
|
3
|
+
f as default
|
|
98
4
|
};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useStore as u } from "@tanstack/vue-form";
|
|
2
|
+
import { computed as f } from "vue";
|
|
3
|
+
function c(o, t) {
|
|
4
|
+
return f(() => t ? u(o.store, (n) => {
|
|
5
|
+
const r = {};
|
|
6
|
+
for (const e of t)
|
|
7
|
+
r[e] = n[e];
|
|
8
|
+
return r;
|
|
9
|
+
}).value : {});
|
|
10
|
+
}
|
|
2
11
|
export {
|
|
3
|
-
|
|
12
|
+
c as getOmegaStore
|
|
4
13
|
};
|
|
@@ -1,117 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.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;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(o,t){const a=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(a&&a.call(this),this.shadowRoot){const i=document.createElement("style");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;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(i)}},e.call(window.customElements,o,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import { defineComponent as B, getCurrentInstance as L, useId as P, computed as l, watch as C, onMounted as $, ref as S, watchEffect as z, renderSlot as A, normalizeProps as D, guardReactiveProps as F, createElementVNode as M, normalizeClass as N, createBlock as R, createCommentVNode as T, unref as U, openBlock as j, mergeProps as G } from "vue";
|
|
3
|
+
import { useStore as H } from "@tanstack/vue-form";
|
|
4
|
+
import { useOmegaErrors as J } from "./vue-components.es5.js";
|
|
5
|
+
import K from "./vue-components.es24.js";
|
|
6
|
+
|
|
7
|
+
const ee = /* @__PURE__ */ B({
|
|
3
8
|
inheritAttrs: !1,
|
|
4
|
-
__name: "
|
|
9
|
+
__name: "OmegaInternalInput",
|
|
5
10
|
props: {
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
field: {},
|
|
12
|
+
meta: {},
|
|
13
|
+
label: {},
|
|
14
|
+
options: {},
|
|
15
|
+
type: {},
|
|
16
|
+
validators: {}
|
|
8
17
|
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
setup(q) {
|
|
19
|
+
const e = q, o = L(), x = o == null ? void 0 : o.appContext.components.VTextField, s = P(), u = e.field, a = H(u.store, (t) => t), f = l(() => {
|
|
20
|
+
var t, r;
|
|
21
|
+
return e.type ? e.type : ((t = e.meta) == null ? void 0 : t.type) === "string" ? e.meta.format === "email" ? "email" : "string" : ((r = e.meta) == null ? void 0 : r.type) || "unknown";
|
|
22
|
+
}), n = l(() => a.value.value), d = l(
|
|
23
|
+
() => (
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
a.value.meta.errors.map((t) => t == null ? void 0 : t.message).filter(Boolean)
|
|
26
|
+
)
|
|
27
|
+
);
|
|
28
|
+
C(
|
|
29
|
+
() => [!!n.value],
|
|
30
|
+
() => {
|
|
31
|
+
var t, r;
|
|
32
|
+
d.value.length && !n.value && !((t = e.meta) != null && t.required) && u.setValue(
|
|
33
|
+
((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "undefined" ? void 0 : null
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
), $(() => {
|
|
37
|
+
var t, r;
|
|
38
|
+
!n.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && u.setValue(null);
|
|
39
|
+
});
|
|
40
|
+
const { addError: I, removeError: O, showErrors: _, showErrorsOn: k } = J(), i = S(!1);
|
|
41
|
+
z(() => {
|
|
42
|
+
(_.value || k === "onChange") && (i.value = !0);
|
|
43
|
+
});
|
|
44
|
+
const m = () => {
|
|
45
|
+
i.value = !0;
|
|
46
|
+
};
|
|
47
|
+
$(() => {
|
|
48
|
+
n.value && m();
|
|
49
|
+
});
|
|
50
|
+
const v = l(() => !i.value && f.value !== "select" ? [] : d.value);
|
|
51
|
+
C(
|
|
52
|
+
() => a.value.meta.errors,
|
|
53
|
+
() => {
|
|
54
|
+
a.value.meta.errors.length ? I({
|
|
55
|
+
inputId: s,
|
|
56
|
+
errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
|
|
57
|
+
label: e.label
|
|
58
|
+
}) : O(s);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
const p = l(() => {
|
|
62
|
+
var t, r, c, g, y, h, b, E, V, w;
|
|
63
|
+
return {
|
|
64
|
+
id: s,
|
|
65
|
+
required: (t = e.meta) == null ? void 0 : t.required,
|
|
66
|
+
minLength: ((r = e.meta) == null ? void 0 : r.type) === "string" && ((c = e.meta) == null ? void 0 : c.minLength),
|
|
67
|
+
maxLength: ((g = e.meta) == null ? void 0 : g.type) === "string" && ((y = e.meta) == null ? void 0 : y.maxLength),
|
|
68
|
+
max: ((h = e.meta) == null ? void 0 : h.type) === "number" && ((b = e.meta) == null ? void 0 : b.maximum),
|
|
69
|
+
min: ((E = e.meta) == null ? void 0 : E.type) === "number" && ((V = e.meta) == null ? void 0 : V.minimum),
|
|
70
|
+
name: e.field.name,
|
|
71
|
+
modelValue: e.field.state.value,
|
|
72
|
+
errorMessages: v.value,
|
|
73
|
+
error: !!v.value.length,
|
|
74
|
+
field: e.field,
|
|
75
|
+
setRealDirty: m,
|
|
76
|
+
type: f.value,
|
|
77
|
+
label: `${e.label}${(w = e.meta) != null && w.required ? " *" : ""}`,
|
|
78
|
+
options: e.options
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
return (t, r) => A(t.$slots, "default", D(F(p.value)), () => [
|
|
82
|
+
M("div", {
|
|
83
|
+
class: N(t.$attrs.class),
|
|
84
|
+
onFocusout: m
|
|
17
85
|
}, [
|
|
18
|
-
|
|
86
|
+
U(x) ? (j(), R(K, G({
|
|
19
87
|
key: 0,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, e.$attrs, {
|
|
27
|
-
"model-value": e.vuetifyValue,
|
|
28
|
-
onChange: r[0] || (r[0] = (p) => e.inputProps.field.handleChange(p.target.checked))
|
|
29
|
-
}), null, 16, ["id", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
|
|
30
|
-
e.inputProps.type === "email" || e.inputProps.type === "string" ? (o(), n(u, s({
|
|
31
|
-
key: 1,
|
|
32
|
-
id: e.inputProps.id,
|
|
33
|
-
required: e.inputProps.required,
|
|
34
|
-
"min-length": e.inputProps.minLength,
|
|
35
|
-
"max-length": e.inputProps.maxLength,
|
|
36
|
-
type: e.inputProps.type,
|
|
37
|
-
name: e.inputProps.name,
|
|
38
|
-
label: e.inputProps.label,
|
|
39
|
-
"error-messages": e.inputProps.errorMessages,
|
|
40
|
-
error: e.inputProps.error
|
|
41
|
-
}, e.$attrs, {
|
|
42
|
-
"model-value": e.vuetifyValue,
|
|
43
|
-
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
44
|
-
}), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
|
|
45
|
-
e.inputProps.type === "text" ? (o(), n(t, s({
|
|
46
|
-
key: 2,
|
|
47
|
-
id: e.inputProps.id,
|
|
48
|
-
required: e.inputProps.required,
|
|
49
|
-
"min-length": e.inputProps.minLength,
|
|
50
|
-
"max-length": e.inputProps.maxLength,
|
|
51
|
-
type: e.inputProps.type,
|
|
52
|
-
name: e.inputProps.name,
|
|
53
|
-
label: e.inputProps.label,
|
|
54
|
-
"error-messages": e.inputProps.errorMessages,
|
|
55
|
-
error: e.inputProps.error
|
|
56
|
-
}, e.$attrs, {
|
|
57
|
-
"model-value": e.vuetifyValue,
|
|
58
|
-
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
59
|
-
}), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
|
|
60
|
-
e.inputProps.type === "number" ? (o(), n(u, s({
|
|
61
|
-
key: 3,
|
|
62
|
-
id: e.inputProps.id,
|
|
63
|
-
required: e.inputProps.required,
|
|
64
|
-
min: e.inputProps.min,
|
|
65
|
-
max: e.inputProps.max,
|
|
66
|
-
type: e.inputProps.type,
|
|
67
|
-
name: e.inputProps.name,
|
|
68
|
-
label: e.inputProps.label,
|
|
69
|
-
"error-messages": e.inputProps.errorMessages,
|
|
70
|
-
error: e.inputProps.error
|
|
71
|
-
}, e.$attrs, {
|
|
72
|
-
"model-value": e.vuetifyValue,
|
|
73
|
-
"onUpdate:modelValue": r[1] || (r[1] = (p) => {
|
|
74
|
-
e.inputProps.field.handleChange(Number(p));
|
|
75
|
-
})
|
|
76
|
-
}), null, 16, ["id", "required", "min", "max", "type", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
|
|
77
|
-
e.inputProps.type === "select" || e.inputProps.type === "multiple" ? (o(), n(m, s({
|
|
78
|
-
key: 4,
|
|
79
|
-
id: e.inputProps.id,
|
|
80
|
-
clearable: e.inputProps.type === "select",
|
|
81
|
-
required: e.inputProps.required,
|
|
82
|
-
multiple: e.inputProps.type === "multiple",
|
|
83
|
-
chips: e.inputProps.type === "multiple",
|
|
84
|
-
name: e.inputProps.name,
|
|
85
|
-
label: e.inputProps.label,
|
|
86
|
-
items: e.inputProps.options,
|
|
87
|
-
"error-messages": e.inputProps.errorMessages,
|
|
88
|
-
error: e.inputProps.error
|
|
89
|
-
}, e.$attrs, {
|
|
90
|
-
"model-value": e.vuetifyValue,
|
|
91
|
-
onClear: r[2] || (r[2] = (p) => e.inputProps.field.handleChange(void 0)),
|
|
92
|
-
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
93
|
-
}), null, 16, ["id", "clearable", "required", "multiple", "chips", "name", "label", "items", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
|
|
94
|
-
e.inputProps.type === "autocomplete" || e.inputProps.type === "autocompletemultiple" ? (o(), n(d, s({
|
|
95
|
-
key: 5,
|
|
96
|
-
id: e.inputProps.id,
|
|
97
|
-
clearable: e.inputProps.type === "autocomplete",
|
|
98
|
-
multiple: e.inputProps.type === "autocompletemultiple",
|
|
99
|
-
required: e.inputProps.required,
|
|
100
|
-
name: e.inputProps.name,
|
|
101
|
-
label: e.inputProps.label,
|
|
102
|
-
items: e.inputProps.options,
|
|
103
|
-
"error-messages": e.inputProps.errorMessages,
|
|
104
|
-
error: e.inputProps.error,
|
|
105
|
-
chips: e.inputProps.type === "autocompletemultiple"
|
|
106
|
-
}, e.$attrs, {
|
|
107
|
-
"model-value": e.vuetifyValue,
|
|
108
|
-
onClear: r[3] || (r[3] = (p) => e.inputProps.field.handleChange(void 0)),
|
|
109
|
-
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
110
|
-
}), null, 16, ["id", "clearable", "multiple", "required", "name", "label", "items", "error-messages", "error", "chips", "model-value", "onUpdate:modelValue"])) : l("", !0)
|
|
111
|
-
], 32);
|
|
112
|
-
};
|
|
88
|
+
"input-props": p.value
|
|
89
|
+
}, t.$attrs, {
|
|
90
|
+
"vuetify-value": p.value.field.state.value
|
|
91
|
+
}), null, 16, ["input-props", "vuetify-value"])) : T("", !0)
|
|
92
|
+
], 34)
|
|
93
|
+
]);
|
|
113
94
|
}
|
|
114
95
|
});
|
|
115
96
|
export {
|
|
116
|
-
|
|
97
|
+
ee as default
|
|
117
98
|
};
|
|
@@ -1,6 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { defineComponent as P, resolveComponent as i, createElementBlock as g, openBlock as o, createBlock as n, createCommentVNode as l, mergeProps as s } from "vue";
|
|
2
|
+
const b = /* @__PURE__ */ P({
|
|
3
|
+
inheritAttrs: !1,
|
|
4
|
+
__name: "OmegaInputVuetify",
|
|
5
|
+
props: {
|
|
6
|
+
inputProps: {},
|
|
7
|
+
vuetifyValue: {}
|
|
8
|
+
},
|
|
9
|
+
emits: ["focus", "blur"],
|
|
10
|
+
setup(y) {
|
|
11
|
+
return (e, r) => {
|
|
12
|
+
const a = i("v-checkbox"), u = i("v-text-field"), t = i("v-textarea"), m = i("v-select"), d = i("v-autocomplete");
|
|
13
|
+
return o(), g("div", {
|
|
14
|
+
class: "omega-input",
|
|
15
|
+
onFocusout: r[4] || (r[4] = (p) => e.$emit("blur", p)),
|
|
16
|
+
onFocusin: r[5] || (r[5] = (p) => e.$emit("focus", p))
|
|
17
|
+
}, [
|
|
18
|
+
e.inputProps.type === "boolean" ? (o(), n(a, s({
|
|
19
|
+
key: 0,
|
|
20
|
+
id: e.inputProps.id,
|
|
21
|
+
name: e.inputProps.name,
|
|
22
|
+
label: e.inputProps.label,
|
|
23
|
+
"error-messages": e.inputProps.errorMessages,
|
|
24
|
+
error: e.inputProps.error,
|
|
25
|
+
ripple: ""
|
|
26
|
+
}, e.$attrs, {
|
|
27
|
+
"model-value": e.vuetifyValue,
|
|
28
|
+
onChange: r[0] || (r[0] = (p) => e.inputProps.field.handleChange(p.target.checked))
|
|
29
|
+
}), null, 16, ["id", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
|
|
30
|
+
e.inputProps.type === "email" || e.inputProps.type === "string" ? (o(), n(u, s({
|
|
31
|
+
key: 1,
|
|
32
|
+
id: e.inputProps.id,
|
|
33
|
+
required: e.inputProps.required,
|
|
34
|
+
"min-length": e.inputProps.minLength,
|
|
35
|
+
"max-length": e.inputProps.maxLength,
|
|
36
|
+
type: e.inputProps.type,
|
|
37
|
+
name: e.inputProps.name,
|
|
38
|
+
label: e.inputProps.label,
|
|
39
|
+
"error-messages": e.inputProps.errorMessages,
|
|
40
|
+
error: e.inputProps.error
|
|
41
|
+
}, e.$attrs, {
|
|
42
|
+
"model-value": e.vuetifyValue,
|
|
43
|
+
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
44
|
+
}), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
|
|
45
|
+
e.inputProps.type === "text" ? (o(), n(t, s({
|
|
46
|
+
key: 2,
|
|
47
|
+
id: e.inputProps.id,
|
|
48
|
+
required: e.inputProps.required,
|
|
49
|
+
"min-length": e.inputProps.minLength,
|
|
50
|
+
"max-length": e.inputProps.maxLength,
|
|
51
|
+
type: e.inputProps.type,
|
|
52
|
+
name: e.inputProps.name,
|
|
53
|
+
label: e.inputProps.label,
|
|
54
|
+
"error-messages": e.inputProps.errorMessages,
|
|
55
|
+
error: e.inputProps.error
|
|
56
|
+
}, e.$attrs, {
|
|
57
|
+
"model-value": e.vuetifyValue,
|
|
58
|
+
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
59
|
+
}), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
|
|
60
|
+
e.inputProps.type === "number" ? (o(), n(u, s({
|
|
61
|
+
key: 3,
|
|
62
|
+
id: e.inputProps.id,
|
|
63
|
+
required: e.inputProps.required,
|
|
64
|
+
min: e.inputProps.min,
|
|
65
|
+
max: e.inputProps.max,
|
|
66
|
+
type: e.inputProps.type,
|
|
67
|
+
name: e.inputProps.name,
|
|
68
|
+
label: e.inputProps.label,
|
|
69
|
+
"error-messages": e.inputProps.errorMessages,
|
|
70
|
+
error: e.inputProps.error
|
|
71
|
+
}, e.$attrs, {
|
|
72
|
+
"model-value": e.vuetifyValue,
|
|
73
|
+
"onUpdate:modelValue": r[1] || (r[1] = (p) => {
|
|
74
|
+
e.inputProps.field.handleChange(Number(p));
|
|
75
|
+
})
|
|
76
|
+
}), null, 16, ["id", "required", "min", "max", "type", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
|
|
77
|
+
e.inputProps.type === "select" || e.inputProps.type === "multiple" ? (o(), n(m, s({
|
|
78
|
+
key: 4,
|
|
79
|
+
id: e.inputProps.id,
|
|
80
|
+
clearable: e.inputProps.type === "select",
|
|
81
|
+
required: e.inputProps.required,
|
|
82
|
+
multiple: e.inputProps.type === "multiple",
|
|
83
|
+
chips: e.inputProps.type === "multiple",
|
|
84
|
+
name: e.inputProps.name,
|
|
85
|
+
label: e.inputProps.label,
|
|
86
|
+
items: e.inputProps.options,
|
|
87
|
+
"error-messages": e.inputProps.errorMessages,
|
|
88
|
+
error: e.inputProps.error
|
|
89
|
+
}, e.$attrs, {
|
|
90
|
+
"model-value": e.vuetifyValue,
|
|
91
|
+
onClear: r[2] || (r[2] = (p) => e.inputProps.field.handleChange(void 0)),
|
|
92
|
+
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
93
|
+
}), null, 16, ["id", "clearable", "required", "multiple", "chips", "name", "label", "items", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
|
|
94
|
+
e.inputProps.type === "autocomplete" || e.inputProps.type === "autocompletemultiple" ? (o(), n(d, s({
|
|
95
|
+
key: 5,
|
|
96
|
+
id: e.inputProps.id,
|
|
97
|
+
clearable: e.inputProps.type === "autocomplete",
|
|
98
|
+
multiple: e.inputProps.type === "autocompletemultiple",
|
|
99
|
+
required: e.inputProps.required,
|
|
100
|
+
name: e.inputProps.name,
|
|
101
|
+
label: e.inputProps.label,
|
|
102
|
+
items: e.inputProps.options,
|
|
103
|
+
"error-messages": e.inputProps.errorMessages,
|
|
104
|
+
error: e.inputProps.error,
|
|
105
|
+
chips: e.inputProps.type === "autocompletemultiple"
|
|
106
|
+
}, e.$attrs, {
|
|
107
|
+
"model-value": e.vuetifyValue,
|
|
108
|
+
onClear: r[3] || (r[3] = (p) => e.inputProps.field.handleChange(void 0)),
|
|
109
|
+
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
110
|
+
}), null, 16, ["id", "clearable", "multiple", "required", "name", "label", "items", "error-messages", "error", "chips", "model-value", "onUpdate:modelValue"])) : l("", !0)
|
|
111
|
+
], 32);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
4
115
|
export {
|
|
5
|
-
|
|
116
|
+
b as default
|
|
6
117
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.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;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(o,t){const a=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(a&&a.call(this),this.shadowRoot){const i=document.createElement("style");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;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(i)}},e.call(window.customElements,o,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import o from "./vue-components.es24.js";
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
o as default
|
|
6
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as i, computed as t, createBlock as p, openBlock as d, resolveDynamicComponent as u, withCtx as r, createVNode as f, mergeProps as c, renderSlot as v, normalizeProps as h, guardReactiveProps as g } from "vue";
|
|
2
2
|
import { generateInputStandardSchemaFromFieldMeta as y } from "./vue-components.es7.js";
|
|
3
|
-
import b from "./vue-components.
|
|
3
|
+
import b from "./vue-components.es22.js";
|
|
4
4
|
const S = /* @__PURE__ */ i({
|
|
5
5
|
inheritAttrs: !1,
|
|
6
6
|
__name: "OmegaInput",
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { useForm as
|
|
2
|
-
import { S as
|
|
3
|
-
import { generateMetaFromSchema as
|
|
4
|
-
import { computed as b, onUnmounted as
|
|
5
|
-
import { isObject as
|
|
6
|
-
import M from "./vue-components.
|
|
7
|
-
const
|
|
1
|
+
import { useForm as I } from "@tanstack/vue-form";
|
|
2
|
+
import { S as N } from "effect-app";
|
|
3
|
+
import { generateMetaFromSchema as R } from "./vue-components.es7.js";
|
|
4
|
+
import { computed as b, onUnmounted as A, onMounted as D, onBeforeUnmount as J, provide as K } from "vue";
|
|
5
|
+
import { isObject as q } from "./vue-components.es17.js";
|
|
6
|
+
import M from "./vue-components.es18.js";
|
|
7
|
+
const x = Symbol("OmegaForm"), H = (w, s, i) => {
|
|
8
8
|
if (!w) throw new Error("Schema is required");
|
|
9
|
-
const V =
|
|
9
|
+
const V = N.standardSchemaV1(w), { filterItems: L, meta: t } = R(w), d = b(() => {
|
|
10
10
|
var l;
|
|
11
11
|
if ((l = i == null ? void 0 : i.persistency) != null && l.id)
|
|
12
12
|
return i.persistency.id;
|
|
13
|
-
const e = window.location.pathname, r = Object.keys(
|
|
13
|
+
const e = window.location.pathname, r = Object.keys(t);
|
|
14
14
|
return `${e}-${r.join("-")}`;
|
|
15
15
|
}), U = () => {
|
|
16
16
|
const e = new URLSearchParams(window.location.search);
|
|
17
|
-
e.delete(
|
|
17
|
+
e.delete(d.value);
|
|
18
18
|
const r = new URL(window.location.href);
|
|
19
19
|
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
20
20
|
};
|
|
21
|
-
function
|
|
21
|
+
function v(e, r) {
|
|
22
22
|
for (const l in r)
|
|
23
|
-
r[l] &&
|
|
23
|
+
r[l] && q(r[l]) ? (e[l] || (e[l] = {}), v(e[l], r[l])) : e[l] = r[l];
|
|
24
24
|
return e;
|
|
25
25
|
}
|
|
26
26
|
const j = b(() => {
|
|
27
27
|
var l;
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
28
|
+
if (s != null && s.defaultValues && !((l = i == null ? void 0 : i.persistency) != null && l.overrideDefaultValues))
|
|
29
|
+
return s == null ? void 0 : s.defaultValues;
|
|
30
30
|
let e;
|
|
31
31
|
const r = i == null ? void 0 : i.persistency;
|
|
32
32
|
if (!(r != null && r.policies) || r.policies.length === 0) return {};
|
|
33
33
|
if (r.policies.includes("querystring"))
|
|
34
34
|
try {
|
|
35
|
-
const
|
|
36
|
-
U(),
|
|
37
|
-
} catch (
|
|
38
|
-
console.error(
|
|
35
|
+
const c = new URLSearchParams(window.location.search).get(d.value);
|
|
36
|
+
U(), c && (e = JSON.parse(c));
|
|
37
|
+
} catch (u) {
|
|
38
|
+
console.error(u);
|
|
39
39
|
}
|
|
40
40
|
if (
|
|
41
41
|
// query string has higher priority than local/session storage
|
|
42
42
|
!e && (r.policies.includes("local") || r.policies.includes("session"))
|
|
43
43
|
) {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
44
|
+
const u = r.policies.includes("local") ? localStorage : sessionStorage;
|
|
45
|
+
if (u)
|
|
46
46
|
try {
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const c = JSON.parse(
|
|
48
|
+
u.getItem(d.value) || "{}"
|
|
49
49
|
);
|
|
50
|
-
|
|
51
|
-
} catch (
|
|
52
|
-
console.error(
|
|
50
|
+
u.removeItem(d.value), e = c;
|
|
51
|
+
} catch (c) {
|
|
52
|
+
console.error(c);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
if (e ?? (e = {}), (
|
|
55
|
+
if (e ?? (e = {}), (s == null ? void 0 : s.defaultValues) == null)
|
|
56
56
|
return e;
|
|
57
57
|
{
|
|
58
|
-
const
|
|
59
|
-
return
|
|
58
|
+
const u = s == null ? void 0 : s.defaultValues;
|
|
59
|
+
return v(u, e);
|
|
60
60
|
}
|
|
61
|
-
}),
|
|
62
|
-
...
|
|
61
|
+
}), n = I({
|
|
62
|
+
...s,
|
|
63
63
|
validators: {
|
|
64
64
|
onSubmit: V,
|
|
65
|
-
...(
|
|
65
|
+
...(s == null ? void 0 : s.validators) || {}
|
|
66
66
|
},
|
|
67
|
-
onSubmit:
|
|
68
|
-
var
|
|
69
|
-
return (
|
|
67
|
+
onSubmit: s != null && s.onSubmit ? ({ formApi: e, meta: r, value: l }) => {
|
|
68
|
+
var u;
|
|
69
|
+
return (u = s.onSubmit) == null ? void 0 : u.call(s, {
|
|
70
70
|
formApi: e,
|
|
71
71
|
meta: r,
|
|
72
72
|
value: l
|
|
@@ -74,79 +74,62 @@ const G = (w, u, i) => {
|
|
|
74
74
|
} : void 0,
|
|
75
75
|
defaultValues: j.value
|
|
76
76
|
}), E = () => {
|
|
77
|
-
Object.keys(
|
|
78
|
-
|
|
77
|
+
Object.keys(t).forEach((e) => {
|
|
78
|
+
n.setFieldValue(e, void 0);
|
|
79
79
|
});
|
|
80
|
-
},
|
|
80
|
+
}, S = (e) => e.reduce(
|
|
81
81
|
(r, l) => {
|
|
82
|
-
const
|
|
83
|
-
return
|
|
82
|
+
const u = l.split(".");
|
|
83
|
+
return u.reduce((c, o, P) => (P === u.length - 1 ? c[o] = n.getFieldValue(l) : c[o] = c[o] ?? {}, c[o]), r), r;
|
|
84
84
|
},
|
|
85
85
|
{}
|
|
86
|
-
),
|
|
86
|
+
), f = (e) => {
|
|
87
87
|
if (e) {
|
|
88
88
|
if (Array.isArray(e.keys))
|
|
89
|
-
return
|
|
89
|
+
return S(e.keys);
|
|
90
90
|
if (Array.isArray(e.banKeys)) {
|
|
91
|
-
const r = Object.keys(
|
|
91
|
+
const r = Object.keys(t).filter(
|
|
92
92
|
(l) => {
|
|
93
|
-
var
|
|
94
|
-
return (
|
|
93
|
+
var u;
|
|
94
|
+
return (u = e.banKeys) == null ? void 0 : u.includes(l);
|
|
95
95
|
}
|
|
96
96
|
);
|
|
97
|
-
return
|
|
97
|
+
return S(r);
|
|
98
98
|
}
|
|
99
|
-
return
|
|
99
|
+
return n.store.state.values;
|
|
100
100
|
}
|
|
101
101
|
}, h = () => {
|
|
102
102
|
const e = i == null ? void 0 : i.persistency;
|
|
103
103
|
if (!(!(e != null && e.policies) || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
104
104
|
const r = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
105
105
|
if (!r) return;
|
|
106
|
-
const l =
|
|
107
|
-
return r.setItem(
|
|
106
|
+
const l = f(e);
|
|
107
|
+
return r.setItem(d.value, JSON.stringify(l));
|
|
108
108
|
}
|
|
109
|
-
},
|
|
109
|
+
}, a = () => {
|
|
110
110
|
const e = i == null ? void 0 : i.persistency;
|
|
111
111
|
if (!(!(e != null && e.policies) || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
112
|
-
const r =
|
|
113
|
-
l.set(
|
|
114
|
-
const
|
|
115
|
-
|
|
112
|
+
const r = f(e), l = new URLSearchParams(window.location.search);
|
|
113
|
+
l.set(d.value, JSON.stringify(r));
|
|
114
|
+
const u = new URL(window.location.href);
|
|
115
|
+
u.search = l.toString(), window.history.replaceState({}, "", u.toString());
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
|
|
119
|
-
window.addEventListener("beforeunload", h), window.addEventListener("blur",
|
|
120
|
-
}),
|
|
121
|
-
window.removeEventListener("beforeunload", h), window.removeEventListener("blur",
|
|
118
|
+
A(h), D(() => {
|
|
119
|
+
window.addEventListener("beforeunload", h), window.addEventListener("blur", a);
|
|
120
|
+
}), J(() => {
|
|
121
|
+
window.removeEventListener("beforeunload", h), window.removeEventListener("blur", a);
|
|
122
122
|
});
|
|
123
|
-
const y = Object.assign(
|
|
124
|
-
meta:
|
|
123
|
+
const y = Object.assign(n, {
|
|
124
|
+
meta: t,
|
|
125
125
|
filterItems: L,
|
|
126
126
|
clear: E
|
|
127
127
|
});
|
|
128
|
-
return Object.assign(y, {
|
|
129
|
-
Input:
|
|
130
|
-
name: "FormInput",
|
|
131
|
-
inheritAttrs: !0,
|
|
132
|
-
setup(e, { attrs: r, slots: l }) {
|
|
133
|
-
const s = r.name, t = r.label;
|
|
134
|
-
if (!s || !t)
|
|
135
|
-
throw new Error("OmegaForm.Input requires name and label props");
|
|
136
|
-
return () => J(
|
|
137
|
-
M,
|
|
138
|
-
{
|
|
139
|
-
...r,
|
|
140
|
-
name: s,
|
|
141
|
-
label: t,
|
|
142
|
-
form: y
|
|
143
|
-
},
|
|
144
|
-
l
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
})
|
|
128
|
+
return K(x, y), Object.assign(y, {
|
|
129
|
+
Input: M
|
|
148
130
|
});
|
|
149
131
|
};
|
|
150
132
|
export {
|
|
151
|
-
|
|
133
|
+
x as OmegaFormKey,
|
|
134
|
+
H as useOmegaForm
|
|
152
135
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"@tanstack/vue-form": "^1.2.4",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"highlight.js": "^11.11.1",
|
|
54
54
|
"vue3-highlightjs": "^1.0.5",
|
|
55
|
-
"@effect-app/vue": "2.41.
|
|
56
|
-
"effect-app": "2.40.
|
|
55
|
+
"@effect-app/vue": "2.41.1",
|
|
56
|
+
"effect-app": "2.40.1"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "rimraf dist && vue-tsc && vite build",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<OmegaInput
|
|
3
|
+
v-bind="$props"
|
|
4
|
+
:form="form"
|
|
5
|
+
:name="name"
|
|
6
|
+
:label="label"
|
|
7
|
+
:validators="validators"
|
|
8
|
+
:options="options"
|
|
9
|
+
:type="type"
|
|
10
|
+
>
|
|
11
|
+
<template #default="slotProps">
|
|
12
|
+
<slot v-bind="slotProps"></slot>
|
|
13
|
+
</template>
|
|
14
|
+
</OmegaInput>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts" generic="From, To extends Record<PropertyKey, any>">
|
|
18
|
+
import { inject } from "vue"
|
|
19
|
+
import type {
|
|
20
|
+
FieldValidators,
|
|
21
|
+
NestedKeyOf,
|
|
22
|
+
TypeOverride,
|
|
23
|
+
} from "./OmegaFormStuff"
|
|
24
|
+
import type { InputProps } from "./InputProps"
|
|
25
|
+
import OmegaInput from "./OmegaInput.vue"
|
|
26
|
+
import { OmegaFormKey } from "./useOmegaForm" // Import the injection key
|
|
27
|
+
|
|
28
|
+
const form = inject(OmegaFormKey)
|
|
29
|
+
if (!form) {
|
|
30
|
+
throw new Error("OmegaFormInput must be used within an OmegaForm context")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
defineProps<{
|
|
34
|
+
name: NestedKeyOf<To>
|
|
35
|
+
label: string
|
|
36
|
+
validators?: FieldValidators<From>
|
|
37
|
+
options?: { title: string; value: string }[]
|
|
38
|
+
type?: TypeOverride
|
|
39
|
+
}>()
|
|
40
|
+
|
|
41
|
+
defineSlots<{
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
default: (props: InputProps<To>) => any
|
|
44
|
+
}>()
|
|
45
|
+
</script>
|
|
@@ -13,20 +13,17 @@ import {
|
|
|
13
13
|
type FormProps,
|
|
14
14
|
type MetaRecord,
|
|
15
15
|
type OmegaFormApi,
|
|
16
|
-
type OmegaInputProps,
|
|
17
16
|
} from "./OmegaFormStuff"
|
|
18
17
|
import {
|
|
19
18
|
computed,
|
|
20
19
|
onBeforeUnmount,
|
|
21
20
|
onMounted,
|
|
22
21
|
onUnmounted,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type DefineComponent,
|
|
26
|
-
type Component,
|
|
22
|
+
provide,
|
|
23
|
+
type InjectionKey,
|
|
27
24
|
} from "vue"
|
|
28
25
|
import { isObject } from "effect/Predicate"
|
|
29
|
-
import
|
|
26
|
+
import OmegaFormInput from "./OmegaFormInput.vue"
|
|
30
27
|
|
|
31
28
|
type keysRule<T> =
|
|
32
29
|
| {
|
|
@@ -55,8 +52,12 @@ interface OF<To, From> extends OmegaFormApi<To, From> {
|
|
|
55
52
|
filterItems?: FilterItems
|
|
56
53
|
clear: () => void
|
|
57
54
|
}
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
|
|
56
|
+
export const OmegaFormKey = Symbol("OmegaForm") as InjectionKey<OF<any, any>>
|
|
57
|
+
|
|
58
|
+
export interface OmegaFormReturn<To extends Record<PropertyKey, any>, From>
|
|
59
|
+
extends OF<To, From> {
|
|
60
|
+
Input: typeof OmegaFormInput<From, To>
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
export const useOmegaForm = <
|
|
@@ -285,33 +286,9 @@ export const useOmegaForm = <
|
|
|
285
286
|
clear,
|
|
286
287
|
})
|
|
287
288
|
|
|
288
|
-
|
|
289
|
-
Input: defineComponent({
|
|
290
|
-
name: "FormInput",
|
|
291
|
-
inheritAttrs: true,
|
|
292
|
-
setup(_, { attrs, slots }) {
|
|
293
|
-
const name = attrs.name as NestedKeyOf<To>
|
|
294
|
-
const label = attrs.label as string
|
|
295
|
-
if (!name || !label) {
|
|
296
|
-
throw new Error("OmegaForm.Input requires name and label props")
|
|
297
|
-
}
|
|
289
|
+
provide(OmegaFormKey, formWithExtras)
|
|
298
290
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
OmegaInput as Component,
|
|
302
|
-
{
|
|
303
|
-
...attrs,
|
|
304
|
-
name,
|
|
305
|
-
label,
|
|
306
|
-
form: formWithExtras,
|
|
307
|
-
},
|
|
308
|
-
slots,
|
|
309
|
-
)
|
|
310
|
-
},
|
|
311
|
-
}) as any as DefineComponent<
|
|
312
|
-
Omit<OmegaInputProps<From, To>, "form">,
|
|
313
|
-
{},
|
|
314
|
-
{}
|
|
315
|
-
>,
|
|
291
|
+
return Object.assign(formWithExtras, {
|
|
292
|
+
Input: OmegaFormInput,
|
|
316
293
|
})
|
|
317
294
|
}
|
|
@@ -4,11 +4,23 @@
|
|
|
4
4
|
:on-submit="console.log"
|
|
5
5
|
>
|
|
6
6
|
<template #internalForm="{ form }">
|
|
7
|
-
<component :is="form.Input" label="myString" name="myString"
|
|
7
|
+
<component :is="form.Input" label="myString" name="myString">
|
|
8
|
+
<template #default="{ field }">
|
|
9
|
+
<div>
|
|
10
|
+
<input v-model="field.state.value" />
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
</component>
|
|
8
14
|
</template>
|
|
9
15
|
</OmegaForm>
|
|
10
16
|
<OmegaForm :form="exampleForm">
|
|
11
|
-
<exampleForm.Input label="aString" name="aString"
|
|
17
|
+
<exampleForm.Input label="aString" name="aString">
|
|
18
|
+
<template #default="{ field }">
|
|
19
|
+
<div>
|
|
20
|
+
<input v-model="field.state.value" />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
</exampleForm.Input>
|
|
12
24
|
<exampleForm.Input label="aStringMin2" name="aStringMin2" />
|
|
13
25
|
<exampleForm.Input label="aStringMin2Max4" name="aStringMin2Max4" />
|
|
14
26
|
<exampleForm.Input
|