@effect-app/vue-components 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
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 w, nextTick as S, onMounted as x, ref as T, watchEffect as z, renderSlot as A, normalizeProps as D, guardReactiveProps as F, createElementVNode as M, normalizeClass as N, createBlock as R, createCommentVNode as U, unref as j, openBlock as G, mergeProps as H } from "vue";
2
+ import { defineComponent as q, getCurrentInstance as L, useId as P, computed as l, watch as w, nextTick as F, onMounted as x, ref as S, watchEffect as T, renderSlot as z, normalizeProps as A, guardReactiveProps as D, createElementVNode as M, normalizeClass as R, createBlock as U, createCommentVNode as Z, unref as j, openBlock as G, mergeProps as H } from "vue";
3
3
  import { useStore as J } from "@tanstack/vue-form";
4
4
  import { useOmegaErrors as K } from "./vue-components.es7.js";
5
5
  import Q from "./vue-components.es27.js";
6
6
 
7
- const te = /* @__PURE__ */ B({
7
+ const re = /* @__PURE__ */ q({
8
8
  inheritAttrs: !1,
9
9
  __name: "OmegaInternalInput",
10
10
  props: {
@@ -16,33 +16,33 @@ const te = /* @__PURE__ */ B({
16
16
  validators: {}
17
17
  },
18
18
  setup(C) {
19
- const e = C, o = L(), $ = o == null ? void 0 : o.appContext.components.VTextField, s = P(), u = e.field, a = J(u.store, (t) => t), d = 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
- }), i = n(() => a.value.value), k = n(
19
+ const t = C, o = L(), N = o == null ? void 0 : o.appContext.components.VTextField, s = P(), u = t.field, a = J(u.store, (e) => e), d = l(() => {
20
+ var e, r;
21
+ return t.type ? t.type : ((e = t.meta) == null ? void 0 : e.type) === "string" ? t.meta.format === "email" ? "email" : "string" : ((r = t.meta) == null ? void 0 : r.type) || "unknown";
22
+ }), i = l(() => a.value.value), $ = l(
23
23
  () => (
24
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)
25
+ a.value.meta.errors.map((e) => e == null ? void 0 : e.message).filter(Boolean)
26
26
  )
27
- );
27
+ ), k = (e) => e == null || e === !1 || e === "" || Number.isNaN(e);
28
28
  w(
29
29
  () => !!i.value,
30
- (t) => {
30
+ (e) => {
31
31
  var r;
32
- !t && ((r = e.meta) == null ? void 0 : r.type) !== "boolean" && S(() => {
33
- var l;
32
+ k(e) && ((r = t.meta) == null ? void 0 : r.type) !== "boolean" && F(() => {
33
+ var n;
34
34
  u.setValue(
35
- ((l = e.meta) == null ? void 0 : l.nullableOrUndefined) === "undefined" ? void 0 : null
35
+ ((n = t.meta) == null ? void 0 : n.nullableOrUndefined) === "undefined" ? void 0 : null
36
36
  );
37
37
  });
38
38
  }
39
39
  ), x(() => {
40
- var t, r;
41
- !i.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && u.setValue(null);
40
+ var e, r;
41
+ !i.value && !((e = t.meta) != null && e.required) && ((r = t.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && u.setValue(null);
42
42
  });
43
- const { addError: I, removeError: O, showErrors: _, showErrorsOn: q } = K(), m = T(!1);
44
- z(() => {
45
- (_.value || q === "onChange") && (m.value = !0);
43
+ const { addError: B, removeError: I, showErrors: O, showErrorsOn: _ } = K(), m = S(!1);
44
+ T(() => {
45
+ (O.value || _ === "onChange") && (m.value = !0);
46
46
  });
47
47
  const p = () => {
48
48
  m.value = !0;
@@ -50,52 +50,52 @@ const te = /* @__PURE__ */ B({
50
50
  x(() => {
51
51
  i.value && p();
52
52
  });
53
- const c = n(() => !m.value && d.value !== "select" ? [] : k.value);
53
+ const c = l(() => !m.value && d.value !== "select" ? [] : $.value);
54
54
  w(
55
55
  () => a.value.meta.errors,
56
56
  () => {
57
- a.value.meta.errors.length ? I({
57
+ a.value.meta.errors.length ? B({
58
58
  inputId: s,
59
- errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
60
- label: e.label
61
- }) : O(s);
59
+ errors: a.value.meta.errors.map((e) => e.message).filter(Boolean),
60
+ label: t.label
61
+ }) : I(s);
62
62
  }
63
63
  );
64
- const f = n(() => {
65
- var t, r, l, v, g, y, h, b, E, V;
64
+ const f = l(() => {
65
+ var e, r, n, v, g, y, h, b, E, V;
66
66
  return {
67
67
  id: s,
68
- required: (t = e.meta) == null ? void 0 : t.required,
69
- minLength: ((r = e.meta) == null ? void 0 : r.type) === "string" && ((l = e.meta) == null ? void 0 : l.minLength),
70
- maxLength: ((v = e.meta) == null ? void 0 : v.type) === "string" && ((g = e.meta) == null ? void 0 : g.maxLength),
71
- max: ((y = e.meta) == null ? void 0 : y.type) === "number" && ((h = e.meta) == null ? void 0 : h.maximum),
72
- min: ((b = e.meta) == null ? void 0 : b.type) === "number" && ((E = e.meta) == null ? void 0 : E.minimum),
73
- name: e.field.name,
74
- modelValue: e.field.state.value,
68
+ required: (e = t.meta) == null ? void 0 : e.required,
69
+ minLength: ((r = t.meta) == null ? void 0 : r.type) === "string" && ((n = t.meta) == null ? void 0 : n.minLength),
70
+ maxLength: ((v = t.meta) == null ? void 0 : v.type) === "string" && ((g = t.meta) == null ? void 0 : g.maxLength),
71
+ max: ((y = t.meta) == null ? void 0 : y.type) === "number" && ((h = t.meta) == null ? void 0 : h.maximum),
72
+ min: ((b = t.meta) == null ? void 0 : b.type) === "number" && ((E = t.meta) == null ? void 0 : E.minimum),
73
+ name: t.field.name,
74
+ modelValue: t.field.state.value,
75
75
  errorMessages: c.value,
76
76
  error: !!c.value.length,
77
- field: e.field,
77
+ field: t.field,
78
78
  setRealDirty: p,
79
79
  type: d.value,
80
- label: `${e.label}${(V = e.meta) != null && V.required ? " *" : ""}`,
81
- options: e.options
80
+ label: `${t.label}${(V = t.meta) != null && V.required ? " *" : ""}`,
81
+ options: t.options
82
82
  };
83
83
  });
84
- return (t, r) => A(t.$slots, "default", D(F(f.value)), () => [
84
+ return (e, r) => z(e.$slots, "default", A(D(f.value)), () => [
85
85
  M("div", {
86
- class: N(t.$attrs.class),
86
+ class: R(e.$attrs.class),
87
87
  onFocusout: p
88
88
  }, [
89
- j($) ? (G(), R(Q, H({
89
+ j(N) ? (G(), U(Q, H({
90
90
  key: 0,
91
91
  "input-props": f.value
92
- }, t.$attrs, {
92
+ }, e.$attrs, {
93
93
  "vuetify-value": f.value.field.state.value
94
- }), null, 16, ["input-props", "vuetify-value"])) : U("", !0)
94
+ }), null, 16, ["input-props", "vuetify-value"])) : Z("", !0)
95
95
  ], 34)
96
96
  ]);
97
97
  }
98
98
  });
99
99
  export {
100
- te as default
100
+ re as default
101
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -71,12 +71,16 @@ const errors = computed(() =>
71
71
  fieldState.value.meta.errors.map((e: any) => e?.message).filter(Boolean),
72
72
  )
73
73
 
74
+ const isFalsyButNotZero = (value: unknown): boolean => {
75
+ return value == null || value === false || value === "" || Number.isNaN(value)
76
+ }
77
+
74
78
  // we remove value and errors when the field is empty and not required
75
79
  //watchEffect will trigger infinite times with both free fieldValue and errors, so bet to watch a stupid boolean
76
80
  watch(
77
81
  () => !!fieldValue.value,
78
82
  value => {
79
- if (!value && props.meta?.type !== "boolean") {
83
+ if (isFalsyButNotZero(value) && props.meta?.type !== "boolean") {
80
84
  nextTick(() => {
81
85
  fieldApi.setValue(
82
86
  props.meta?.nullableOrUndefined === "undefined" ? undefined : null,