@effect-app/vue-components 1.1.0 → 1.1.1

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,9 +1,9 @@
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
- import { defineComponent as E, getCurrentInstance as V, useId as w, computed as a, watch as f, nextTick as N, onMounted as d, ref as $, watchEffect as k, renderSlot as B, normalizeProps as I, guardReactiveProps as _, createElementVNode as q, normalizeClass as L, createBlock as O, createCommentVNode as P, unref as F, openBlock as S, mergeProps as T } from "vue";
2
+ import { defineComponent as E, getCurrentInstance as V, useId as w, computed as a, watch as d, nextTick as N, onMounted as c, ref as $, watchEffect as k, onUnmounted as B, renderSlot as I, normalizeProps as _, guardReactiveProps as q, createElementVNode as L, normalizeClass as O, createBlock as P, createCommentVNode as F, unref as S, openBlock as T, mergeProps as U } from "vue";
3
3
  import { useStore as z } from "@tanstack/vue-form";
4
4
  import A from "./vue-components.es19.js";
5
5
 
6
- const G = /* @__PURE__ */ E({
6
+ const H = /* @__PURE__ */ E({
7
7
  inheritAttrs: !1,
8
8
  __name: "OmegaInternalInput",
9
9
  props: {
@@ -14,48 +14,48 @@ const G = /* @__PURE__ */ E({
14
14
  type: {},
15
15
  validators: {}
16
16
  },
17
- setup(c) {
18
- const e = c, v = V()?.appContext.components.VTextField, l = w(), o = e.field, r = z(o.store, (t) => t), m = a(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown"), n = a(() => r.value.value), g = a(
17
+ setup(v) {
18
+ const e = v, g = V()?.appContext.components.VTextField, n = w(), o = e.field, r = z(o.store, (t) => t), m = a(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown"), l = a(() => r.value.value), y = a(
19
19
  () => (
20
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
21
  r.value.meta.errors.map((t) => t?.message).filter(Boolean)
22
22
  )
23
- ), y = (t) => t == null || t === !1 || t === "" || Number.isNaN(t);
24
- f(
25
- () => !!n.value,
23
+ ), h = (t) => t == null || t === !1 || t === "" || Number.isNaN(t);
24
+ d(
25
+ () => !!l.value,
26
26
  () => {
27
- y(n.value) && e.meta?.type !== "boolean" && N(() => {
27
+ h(l.value) && e.meta?.type !== "boolean" && N(() => {
28
28
  o.setValue(
29
29
  e.meta?.nullableOrUndefined === "undefined" ? void 0 : null
30
30
  );
31
31
  });
32
32
  }
33
- ), d(() => {
34
- !n.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null" && o.setValue(null);
33
+ ), c(() => {
34
+ !l.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null" && o.setValue(null);
35
35
  });
36
- const { addError: h, removeError: b, showErrors: x, showErrorsOn: C } = e.field.form.errorContext, s = $(!1);
36
+ const { addError: b, removeError: p, showErrors: x, showErrorsOn: C } = e.field.form.errorContext, s = $(!1);
37
37
  k(() => {
38
38
  (x.value || C === "onChange") && (s.value = !0);
39
39
  });
40
- const i = () => {
40
+ const u = () => {
41
41
  s.value = !0;
42
42
  };
43
- d(() => {
44
- n.value && i();
43
+ c(() => {
44
+ l.value && u();
45
45
  });
46
- const p = a(() => !s.value && m.value !== "select" ? [] : g.value);
47
- f(
46
+ const f = a(() => !s.value && m.value !== "select" ? [] : y.value);
47
+ d(
48
48
  () => r.value.meta.errors,
49
49
  () => {
50
- r.value.meta.errors.length ? h({
51
- inputId: l,
50
+ r.value.meta.errors.length ? b({
51
+ inputId: n,
52
52
  errors: r.value.meta.errors.map((t) => t.message).filter(Boolean),
53
53
  label: e.label
54
- }) : b(l);
54
+ }) : p(n);
55
55
  }
56
- );
57
- const u = a(() => ({
58
- id: l,
56
+ ), B(() => p(n));
57
+ const i = a(() => ({
58
+ id: n,
59
59
  required: e.meta?.required,
60
60
  minLength: e.meta?.type === "string" && e.meta?.minLength,
61
61
  maxLength: e.meta?.type === "string" && e.meta?.maxLength,
@@ -63,29 +63,29 @@ const G = /* @__PURE__ */ E({
63
63
  min: e.meta?.type === "number" && e.meta?.minimum,
64
64
  name: e.field.name,
65
65
  modelValue: e.field.state.value,
66
- errorMessages: p.value,
67
- error: !!p.value.length,
66
+ errorMessages: f.value,
67
+ error: !!f.value.length,
68
68
  field: e.field,
69
- setRealDirty: i,
69
+ setRealDirty: u,
70
70
  type: m.value,
71
71
  label: `${e.label}${e.meta?.required ? " *" : ""}`,
72
72
  options: e.options
73
73
  }));
74
- return (t, M) => B(t.$slots, "default", I(_(u.value)), () => [
75
- q("div", {
76
- class: L(t.$attrs.class),
77
- onFocusout: i
74
+ return (t, M) => I(t.$slots, "default", _(q(i.value)), () => [
75
+ L("div", {
76
+ class: O(t.$attrs.class),
77
+ onFocusout: u
78
78
  }, [
79
- F(v) ? (S(), O(A, T({
79
+ S(g) ? (T(), P(A, U({
80
80
  key: 0,
81
- "input-props": u.value
81
+ "input-props": i.value
82
82
  }, t.$attrs, {
83
- "vuetify-value": u.value.field.state.value
84
- }), null, 16, ["input-props", "vuetify-value"])) : P("", !0)
83
+ "vuetify-value": i.value.field.state.value
84
+ }), null, 16, ["input-props", "vuetify-value"])) : F("", !0)
85
85
  ], 34)
86
86
  ]);
87
87
  }
88
88
  });
89
89
  export {
90
- G as default
90
+ H as default
91
91
  };
@@ -1,6 +1,6 @@
1
1
  import { useForm as J, useStore as q } from "@tanstack/vue-form";
2
- import { Data as K, S as A, Effect as c, Fiber as y, Option as B } from "effect-app";
3
- import { runtimeFiberAsPromise as k } from "./vue-components.es10.js";
2
+ import { Data as K, S as A, Effect as c, Fiber as y, Option as k } from "effect-app";
3
+ import { runtimeFiberAsPromise as B } from "./vue-components.es10.js";
4
4
  import { isObject as G } from "./vue-components.es11.js";
5
5
  import { computed as I, onUnmounted as T, onMounted as W, onBeforeUnmount as z, watch as Q, h as P } from "vue";
6
6
  import X from "./vue-components.es12.js";
@@ -105,7 +105,7 @@ const p = (l) => function(o) {
105
105
  meta: r,
106
106
  value: s
107
107
  });
108
- return y.isFiber(n) && y.isRuntimeFiber(n) ? await k(n) : c.isEffect(n) ? await c.runPromise(
108
+ return y.isFiber(n) && y.isRuntimeFiber(n) ? await B(n) : c.isEffect(n) ? await c.runPromise(
109
109
  n.pipe(
110
110
  // meta?.currentSpan
111
111
  // ? Effect.withParentSpan(meta.currentSpan)
@@ -122,7 +122,7 @@ const p = (l) => function(o) {
122
122
  }, F = (e) => e.reduce((r, t) => {
123
123
  const s = t.split(".");
124
124
  return s.reduce((n, f, H) => (H === s.length - 1 ? n[f] = u.getFieldValue(t) : n[f] = n[f] ?? {}, n[f]), r), r;
125
- }, {}), V = (e) => {
125
+ }, {}), O = (e) => {
126
126
  if (e) {
127
127
  if (Array.isArray(e.keys))
128
128
  return F(e.keys);
@@ -137,31 +137,31 @@ const p = (l) => function(o) {
137
137
  if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
138
138
  const r = e.policies.includes("local") ? localStorage : sessionStorage;
139
139
  if (!r) return;
140
- const t = V(e);
140
+ const t = O(e);
141
141
  return r.setItem(m.value, JSON.stringify(t));
142
142
  }
143
- }, O = () => {
143
+ }, V = () => {
144
144
  const e = o?.persistency;
145
145
  if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
146
- const r = V(e), t = new URLSearchParams(window.location.search);
146
+ const r = O(e), t = new URLSearchParams(window.location.search);
147
147
  t.set(m.value, JSON.stringify(r));
148
148
  const s = new URL(window.location.href);
149
149
  s.search = t.toString(), window.history.replaceState({}, "", s.toString());
150
150
  }
151
151
  };
152
152
  T(b), W(() => {
153
- window.addEventListener("beforeunload", b), window.addEventListener("blur", O);
153
+ window.addEventListener("beforeunload", b), window.addEventListener("blur", V);
154
154
  }), z(() => {
155
- window.removeEventListener("beforeunload", b), window.removeEventListener("blur", O);
155
+ window.removeEventListener("beforeunload", b), window.removeEventListener("blur", V);
156
156
  });
157
157
  const j = (e) => c.currentSpan.pipe(
158
158
  c.option,
159
159
  c.flatMap(
160
- (r) => c.promise(() => u.handleSubmit(B.isSome(r) ? { currentSpan: r.value, ...e } : e))
160
+ (r) => c.promise(() => u.handleSubmit(k.isSome(r) ? { currentSpan: r.value, ...e } : e))
161
161
  )
162
162
  ), R = (e) => e?.checkErrors ? j(e?.meta).pipe(c.flatMap(c.fnUntraced(function* () {
163
163
  const r = u.getAllErrors();
164
- if (r.form.errors.length)
164
+ if (Object.keys(r.fields).length || r.form.errors.length)
165
165
  return yield* new se({ form: r.form, fields: r.fields });
166
166
  }))) : j(e?.meta), x = u.handleSubmit, i = Object.assign(u, {
167
167
  i18nNamespace: o?.i18nNamespace,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.17.13",
@@ -49,8 +49,8 @@
49
49
  "@tanstack/vue-form": "^1.23.4",
50
50
  "highlight.js": "^11.11.1",
51
51
  "vue3-highlightjs": "^1.0.5",
52
- "effect-app": "3.8.1",
53
- "@effect-app/vue": "2.81.0"
52
+ "@effect-app/vue": "2.81.0",
53
+ "effect-app": "3.8.1"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "pnpm build:run",
@@ -20,7 +20,7 @@
20
20
  generic="From extends Record<PropertyKey, any>, Name extends DeepKeys<From>"
21
21
  >
22
22
  import { type DeepKeys, useStore } from "@tanstack/vue-form"
23
- import { computed, type ComputedRef, getCurrentInstance, nextTick, onMounted, ref, useId, watch, watchEffect } from "vue"
23
+ import { computed, type ComputedRef, getCurrentInstance, nextTick, onMounted, onUnmounted, ref, useId, watch, watchEffect } from "vue"
24
24
  import type { InputProps, OmegaFieldInternalApi } from "./InputProps"
25
25
  import type { FieldValidators, MetaRecord, NestedKeyOf, TypeOverride } from "./OmegaFormStuff"
26
26
  import OmegaInputVuetify from "./OmegaInputVuetify.vue"
@@ -139,6 +139,8 @@ watch(
139
139
  }
140
140
  )
141
141
 
142
+ onUnmounted(() => removeError(id))
143
+
142
144
  const inputProps: ComputedRef<InputProps<From, Name>> = computed(() => ({
143
145
  id,
144
146
  required: props.meta?.required,
@@ -842,7 +842,7 @@ export const useOmegaForm = <
842
842
  options?.checkErrors
843
843
  ? handleSubmitEffect_(options?.meta).pipe(Effect.flatMap(Effect.fnUntraced(function*() {
844
844
  const errors = form.getAllErrors()
845
- if (errors.form.errors.length) {
845
+ if (Object.keys(errors.fields).length || errors.form.errors.length) {
846
846
  return yield* new FormErrors({ form: errors.form, fields: errors.fields })
847
847
  }
848
848
  })))