@effect-app/vue-components 0.3.2 → 0.3.3

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.
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as d, watch as b, createElementBlock as g, openBlock as S, withModifiers as v, unref as n, createElementVNode as h, renderSlot as O } from "vue";
2
2
  import { useStore as i } from "@tanstack/vue-form";
3
- import { getOmegaStore as M } from "./vue-components.es18.js";
3
+ import { getOmegaStore as M } from "./vue-components.es17.js";
4
4
  import { provideOmegaErrors as y } from "./vue-components.es4.js";
5
5
  import { useOmegaForm as E } from "./vue-components.es5.js";
6
6
  const w = ["disabled"], A = /* @__PURE__ */ d({
@@ -1,4 +1,4 @@
1
- import { isFunction as c } from "./vue-components.es16.js";
1
+ import { isFunction as c } from "./vue-components.es18.js";
2
2
  const s = c, t = (o) => typeof o == "object" && o !== null, i = (o) => t(o) || s(o);
3
3
  export {
4
4
  s as isFunction,
@@ -1,4 +1,95 @@
1
- const o = (n) => typeof n == "function";
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 n, watch as x, onMounted as _, ref as S, watchEffect as A, renderSlot as D, normalizeProps as F, guardReactiveProps as M, createElementVNode as N, createBlock as R, createCommentVNode as T, unref as U, openBlock as z, mergeProps as j } from "vue";
3
+ import { useStore as G } from "@tanstack/vue-form";
4
+ import { useOmegaErrors as H } from "./vue-components.es4.js";
5
+ import J from "./vue-components.es20.js";
6
+
7
+ const Z = /* @__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(), C = o == null ? void 0 : o.appContext.components.VTextField, u = P(), s = e.field, a = G(s.store, (t) => t), f = n(() => {
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
+ }), l = n(() => a.value.value), d = n(
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
+ x(
29
+ () => [!!l.value],
30
+ () => {
31
+ var t, r;
32
+ d.value.length && !l.value && !((t = e.meta) != null && t.required) && s.setValue(
33
+ ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "undefined" ? void 0 : null
34
+ );
35
+ }
36
+ ), _(() => {
37
+ var t, r;
38
+ !l.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && s.setValue(null);
39
+ });
40
+ const { addError: I, removeError: O, showErrors: $, showErrorsOn: k } = H(), i = S(!1);
41
+ A(() => {
42
+ ($.value || k === "onChange") && (i.value = !0);
43
+ });
44
+ const m = () => {
45
+ i.value = !0;
46
+ };
47
+ _(() => {
48
+ l.value && m();
49
+ });
50
+ const v = n(() => !i.value && f.value !== "select" ? [] : d.value);
51
+ x(
52
+ () => a.value.meta.errors,
53
+ () => {
54
+ a.value.meta.errors.length ? I({
55
+ inputId: u,
56
+ errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
57
+ label: e.label
58
+ }) : O(u);
59
+ }
60
+ );
61
+ const p = n(() => {
62
+ var t, r, c, g, y, h, b, E, V, w;
63
+ return {
64
+ id: u,
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) => D(t.$slots, "default", F(M(p.value)), () => [
82
+ N("div", { onFocusout: m }, [
83
+ U(C) ? (z(), R(J, j({
84
+ key: 0,
85
+ "input-props": p.value
86
+ }, t.$attrs, {
87
+ "vuetify-value": p.value.field.state.value
88
+ }), null, 16, ["input-props", "vuetify-value"])) : T("", !0)
89
+ ], 32)
90
+ ]);
91
+ }
92
+ });
2
93
  export {
3
- o as isFunction
94
+ Z as default
4
95
  };
@@ -1,95 +1,13 @@
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 n, watch as x, onMounted as _, ref as S, watchEffect as A, renderSlot as D, normalizeProps as F, guardReactiveProps as M, createElementVNode as N, createBlock as R, createCommentVNode as T, unref as U, openBlock as z, mergeProps as j } from "vue";
3
- import { useStore as G } from "@tanstack/vue-form";
4
- import { useOmegaErrors as H } from "./vue-components.es4.js";
5
- import J from "./vue-components.es20.js";
6
-
7
- const Z = /* @__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(), C = o == null ? void 0 : o.appContext.components.VTextField, u = P(), s = e.field, a = G(s.store, (t) => t), f = n(() => {
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
- }), l = n(() => a.value.value), d = n(
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
- x(
29
- () => [!!l.value],
30
- () => {
31
- var t, r;
32
- d.value.length && !l.value && !((t = e.meta) != null && t.required) && s.setValue(
33
- ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "undefined" ? void 0 : null
34
- );
35
- }
36
- ), _(() => {
37
- var t, r;
38
- !l.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && s.setValue(null);
39
- });
40
- const { addError: I, removeError: O, showErrors: $, showErrorsOn: k } = H(), i = S(!1);
41
- A(() => {
42
- ($.value || k === "onChange") && (i.value = !0);
43
- });
44
- const m = () => {
45
- i.value = !0;
46
- };
47
- _(() => {
48
- l.value && m();
49
- });
50
- const v = n(() => !i.value && f.value !== "select" ? [] : d.value);
51
- x(
52
- () => a.value.meta.errors,
53
- () => {
54
- a.value.meta.errors.length ? I({
55
- inputId: u,
56
- errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
57
- label: e.label
58
- }) : O(u);
59
- }
60
- );
61
- const p = n(() => {
62
- var t, r, c, g, y, h, b, E, V, w;
63
- return {
64
- id: u,
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) => D(t.$slots, "default", F(M(p.value)), () => [
82
- N("div", { onFocusout: m }, [
83
- U(C) ? (z(), R(J, j({
84
- key: 0,
85
- "input-props": p.value
86
- }, t.$attrs, {
87
- "vuetify-value": p.value.field.state.value
88
- }), null, 16, ["input-props", "vuetify-value"])) : T("", !0)
89
- ], 32)
90
- ]);
91
- }
92
- });
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
+ }
93
11
  export {
94
- Z as default
12
+ c as getOmegaStore
95
13
  };
@@ -1,13 +1,4 @@
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
- }
1
+ const o = (n) => typeof n == "function";
11
2
  export {
12
- c as getOmegaStore
3
+ o as isFunction
13
4
  };
@@ -1,4 +1,4 @@
1
- import f from "./vue-components.es17.js";
1
+ import f from "./vue-components.es16.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -14,7 +14,7 @@ const y = i.NonEmptyArray(i.String), v = (e) => i.AST.isUnion(e) && e.types.find
14
14
  });
15
15
  if (a) {
16
16
  for (const s of a) {
17
- const u = t ? `${t}.${s.name.toString()}` : s.name.toString(), r = x(s.type), o = e.required ?? !r;
17
+ const u = t ? `${t}.${s.name.toString()}` : s.name.toString(), r = x(s.type), o = !r;
18
18
  let d = s.type;
19
19
  if (i.AST.isUnion(s.type) && (d = s.type.types.find(
20
20
  (g) => g._tag !== "UndefinedKeyword" && g !== i.Null.ast
@@ -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.es6.js";
3
- import b from "./vue-components.es17.js";
3
+ import b from "./vue-components.es16.js";
4
4
  const S = /* @__PURE__ */ i({
5
5
  inheritAttrs: !1,
6
6
  __name: "OmegaInput",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -241,7 +241,7 @@ const createMeta = <T = any>(
241
241
  for (const p of propertySignatures) {
242
242
  const key = parent ? `${parent}.${p.name.toString()}` : p.name.toString()
243
243
  const nullableOrUndefined = isNullableOrUndefined(p.type)
244
- const isRequired = meta["required"] ?? !nullableOrUndefined
244
+ const isRequired = !nullableOrUndefined
245
245
 
246
246
  let typeToProcess = p.type
247
247
  if (S.AST.isUnion(p.type)) {
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <OmegaForm
3
+ :schema="
4
+ S.Struct({
5
+ a: S.NullOr(S.String),
6
+ b: S.UndefinedOr(S.Number),
7
+ c: S.NullishOr(S.Number),
8
+ d: S.String,
9
+ e: S.Number,
10
+ f: S.Number,
11
+ struct: S.Struct({
12
+ a: S.NullOr(S.String),
13
+ b: S.UndefinedOr(S.Number),
14
+ c: S.NullishOr(S.Number),
15
+ d: S.String,
16
+ e: S.Number,
17
+ f: S.Number,
18
+ }),
19
+ })
20
+ "
21
+ >
22
+ <template #default="{ form }">
23
+ <ul>
24
+ <li v-for="key in Object.keys(form.meta)" :key="key">
25
+ {{ key }}: {{ (form.meta as any)[key] }}
26
+ </li>
27
+ </ul>
28
+ <OmegaInput label="a" :form="form" name="a" />
29
+ <OmegaInput label="b" :form="form" name="b" />
30
+ <OmegaInput label="c" :form="form" name="c" />
31
+ <OmegaInput label="d" :form="form" name="d" />
32
+ <OmegaInput label="e" :form="form" name="e" />
33
+ <OmegaInput label="f" :form="form" name="f" />
34
+ <OmegaInput label="struct.a" :form="form" name="struct.a" />
35
+ <OmegaInput label="struct.b" :form="form" name="struct.b" />
36
+ <OmegaInput label="struct.c" :form="form" name="struct.c" />
37
+ <OmegaInput label="struct.d" :form="form" name="struct.d" />
38
+ <OmegaInput label="struct.e" :form="form" name="struct.e" />
39
+ <OmegaInput label="struct.f" :form="form" name="struct.f" />
40
+ </template>
41
+ </OmegaForm>
42
+ </template>
43
+
44
+ <script setup lang="ts">
45
+ import { OmegaForm, OmegaInput } from "../../components/OmegaForm"
46
+ import { S } from "effect-app"
47
+ </script>
@@ -9,6 +9,7 @@ import ComplexForm from "./OmegaForm/ComplexForm.vue"
9
9
  import SimpleFormVuetifyDefault from "./OmegaForm/SimpleFormVuetifyDefault.vue"
10
10
  import SumExample from "./OmegaForm/SumExample.vue"
11
11
  import PersistencyForm from "./OmegaForm/PersistencyForm.vue"
12
+ import MetaForm from "./OmegaForm/Meta.vue"
12
13
 
13
14
  const mockIntl = {
14
15
  locale: ref("en"),
@@ -81,3 +82,10 @@ export const PersistencyFormStory: Story = {
81
82
  template: "<PersistencyForm />",
82
83
  }),
83
84
  }
85
+
86
+ export const MetaStory: Story = {
87
+ render: () => ({
88
+ components: { MetaForm },
89
+ template: "<MetaForm />",
90
+ }),
91
+ }