@effect-app/vue-components 4.0.0-beta.32 → 4.0.0-beta.321

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.
Files changed (211) hide show
  1. package/README.md +13 -9
  2. package/dist/reset.css +39 -38
  3. package/dist/types/components/CommandButton.vue.d.ts +24 -5
  4. package/dist/types/components/Dialog.vue.d.ts +4 -2
  5. package/dist/types/components/FixedNuxtErrorBoundary.vue.d.ts +39 -0
  6. package/dist/types/components/OmegaForm/InputProps.d.ts +2 -1
  7. package/dist/types/components/OmegaForm/OmegaArray.vue.d.ts +1 -1
  8. package/dist/types/components/OmegaForm/OmegaAutoGen.vue.d.ts +2 -2
  9. package/dist/types/components/OmegaForm/OmegaErrorsInternal.vue.d.ts +2 -3
  10. package/dist/types/components/OmegaForm/OmegaFormInput.vue.d.ts +1 -1
  11. package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +1 -1
  12. package/dist/types/components/OmegaForm/OmegaInputVuetify.vue.d.ts +12 -0
  13. package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +7 -9
  14. package/dist/types/components/OmegaForm/OmegaTaggedUnion.vue.d.ts +2 -2
  15. package/dist/types/components/OmegaForm/OmegaTaggedUnionInternal.vue.d.ts +3 -3
  16. package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +1 -1
  17. package/dist/types/components/OmegaForm/createUseFormWithCustomInput.d.ts +4 -2
  18. package/dist/types/components/OmegaForm/decimalSeparatorInput.d.ts +13 -0
  19. package/dist/types/components/OmegaForm/errors.d.ts +33 -0
  20. package/dist/types/components/OmegaForm/getOmegaStore.d.ts +1 -1
  21. package/dist/types/components/OmegaForm/hocs.d.ts +3 -0
  22. package/dist/types/components/OmegaForm/index.d.ts +14 -3
  23. package/dist/types/components/OmegaForm/inputs.d.ts +4 -0
  24. package/dist/types/components/OmegaForm/meta/checks.d.ts +4 -0
  25. package/dist/types/components/OmegaForm/meta/createMeta.d.ts +33 -0
  26. package/dist/types/components/OmegaForm/meta/defaults.d.ts +21 -0
  27. package/dist/types/components/OmegaForm/meta/redacted.d.ts +2 -0
  28. package/dist/types/components/OmegaForm/meta/types.d.ts +56 -0
  29. package/dist/types/components/OmegaForm/meta/walker.d.ts +18 -0
  30. package/dist/types/components/OmegaForm/persistency.d.ts +58 -0
  31. package/dist/types/components/OmegaForm/submit.d.ts +60 -0
  32. package/dist/types/components/OmegaForm/types.d.ts +312 -0
  33. package/dist/types/components/OmegaForm/useOmegaForm.d.ts +9 -213
  34. package/dist/types/components/OmegaForm/validation/localized.d.ts +10 -0
  35. package/dist/types/components/index.d.ts +1 -0
  36. package/dist/types/index.d.ts +0 -1
  37. package/dist/types/utils/index.d.ts +8 -8
  38. package/dist/vue-components.es.js +30 -44
  39. package/dist/vue-components10.es.js +5 -0
  40. package/dist/vue-components11.es.js +56 -0
  41. package/dist/vue-components12.es.js +5 -0
  42. package/dist/vue-components13.es.js +20 -0
  43. package/dist/vue-components14.es.js +50 -0
  44. package/dist/vue-components15.es.js +128 -0
  45. package/dist/vue-components16.es.js +65 -0
  46. package/dist/vue-components17.es.js +114 -0
  47. package/dist/vue-components18.es.js +26 -0
  48. package/dist/vue-components19.es.js +5 -0
  49. package/dist/vue-components2.es.js +11 -0
  50. package/dist/vue-components20.es.js +80 -0
  51. package/dist/vue-components21.es.js +115 -0
  52. package/dist/vue-components22.es.js +74 -0
  53. package/dist/vue-components23.es.js +12 -0
  54. package/dist/vue-components24.es.js +54 -0
  55. package/dist/vue-components25.es.js +5 -0
  56. package/dist/vue-components26.es.js +44 -0
  57. package/dist/vue-components27.es.js +5 -0
  58. package/dist/vue-components28.es.js +84 -0
  59. package/dist/vue-components3.es.js +98 -0
  60. package/dist/vue-components30.es.js +8 -0
  61. package/dist/vue-components31.es.js +9 -0
  62. package/dist/vue-components32.es.js +15 -0
  63. package/dist/vue-components33.es.js +24 -0
  64. package/dist/vue-components34.es.js +344 -0
  65. package/dist/vue-components36.es.js +8 -0
  66. package/dist/vue-components37.es.js +74 -0
  67. package/dist/vue-components38.es.js +5 -0
  68. package/dist/vue-components39.es.js +64 -0
  69. package/dist/vue-components4.es.js +5 -0
  70. package/dist/vue-components40.es.js +5 -0
  71. package/dist/vue-components41.es.js +24 -0
  72. package/dist/vue-components42.es.js +5 -0
  73. package/dist/vue-components43.es.js +59 -0
  74. package/dist/vue-components44.es.js +5 -0
  75. package/dist/vue-components45.es.js +12 -0
  76. package/dist/vue-components46.es.js +22 -0
  77. package/dist/vue-components48.es.js +9 -0
  78. package/dist/vue-components49.es.js +4 -0
  79. package/dist/vue-components5.es.js +24 -0
  80. package/dist/vue-components50.es.js +38 -0
  81. package/dist/vue-components51.es.js +27 -0
  82. package/dist/vue-components52.es.js +28 -0
  83. package/dist/vue-components53.es.js +7 -0
  84. package/dist/vue-components54.es.js +18 -0
  85. package/dist/vue-components55.es.js +36 -0
  86. package/dist/vue-components56.es.js +18 -0
  87. package/dist/vue-components57.es.js +21 -0
  88. package/dist/vue-components58.es.js +30 -0
  89. package/dist/vue-components59.es.js +7 -0
  90. package/dist/vue-components6.es.js +13 -0
  91. package/dist/vue-components60.es.js +9 -0
  92. package/dist/vue-components61.es.js +38 -0
  93. package/dist/vue-components62.es.js +25 -0
  94. package/dist/vue-components63.es.js +128 -0
  95. package/dist/vue-components64.es.js +24 -0
  96. package/dist/vue-components65.es.js +21 -0
  97. package/dist/vue-components66.es.js +9 -0
  98. package/dist/vue-components67.es.js +19 -0
  99. package/dist/vue-components68.es.js +5 -0
  100. package/dist/vue-components69.es.js +29 -0
  101. package/dist/vue-components7.es.js +13 -0
  102. package/dist/vue-components70.es.js +5 -0
  103. package/dist/vue-components71.es.js +43 -0
  104. package/dist/vue-components72.es.js +101 -0
  105. package/dist/vue-components73.es.js +36 -0
  106. package/dist/vue-components74.es.js +19 -0
  107. package/dist/vue-components75.es.js +50 -0
  108. package/dist/vue-components8.es.js +35 -0
  109. package/dist/vue-components9.es.js +47 -0
  110. package/package.json +39 -33
  111. package/src/components/CommandButton.vue +96 -16
  112. package/src/components/Dialog.vue +0 -1
  113. package/src/components/FixedNuxtErrorBoundary.vue +112 -0
  114. package/src/components/OmegaForm/InputProps.ts +2 -1
  115. package/src/components/OmegaForm/OmegaArray.vue +9 -23
  116. package/src/components/OmegaForm/OmegaAutoGen.vue +3 -2
  117. package/src/components/OmegaForm/OmegaErrorsInternal.vue +20 -17
  118. package/src/components/OmegaForm/OmegaFormInput.vue +1 -1
  119. package/src/components/OmegaForm/OmegaInput.vue +29 -43
  120. package/src/components/OmegaForm/OmegaInputVuetify.vue +122 -16
  121. package/src/components/OmegaForm/OmegaInternalInput.vue +33 -13
  122. package/src/components/OmegaForm/OmegaTaggedUnion.vue +10 -3
  123. package/src/components/OmegaForm/OmegaTaggedUnionInternal.vue +6 -6
  124. package/src/components/OmegaForm/OmegaWrapper.vue +1 -1
  125. package/src/components/OmegaForm/blockDialog.ts +18 -6
  126. package/src/components/OmegaForm/createUseFormWithCustomInput.ts +16 -14
  127. package/src/components/OmegaForm/decimalSeparatorInput.ts +38 -0
  128. package/src/components/OmegaForm/errors.ts +139 -0
  129. package/src/components/OmegaForm/getOmegaStore.ts +1 -1
  130. package/src/components/OmegaForm/hocs.ts +19 -0
  131. package/src/components/OmegaForm/index.ts +17 -4
  132. package/src/components/OmegaForm/inputs.ts +22 -0
  133. package/src/components/OmegaForm/meta/checks.ts +107 -0
  134. package/src/components/OmegaForm/meta/createMeta.ts +140 -0
  135. package/src/components/OmegaForm/meta/defaults.ts +263 -0
  136. package/src/components/OmegaForm/meta/redacted.ts +71 -0
  137. package/src/components/OmegaForm/meta/types.ts +78 -0
  138. package/src/components/OmegaForm/meta/walker.ts +248 -0
  139. package/src/components/OmegaForm/persistency.ts +247 -0
  140. package/src/components/OmegaForm/submit.ts +131 -0
  141. package/src/components/OmegaForm/types.ts +801 -0
  142. package/src/components/OmegaForm/useOmegaForm.ts +103 -896
  143. package/src/components/OmegaForm/useRegisterField.ts +1 -1
  144. package/src/components/OmegaForm/validation/localized.ts +242 -0
  145. package/src/components/index.ts +1 -0
  146. package/src/index.ts +0 -1
  147. package/src/reset.css +39 -38
  148. package/src/utils/index.ts +11 -8
  149. package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +0 -159
  150. package/dist/types/constants/index.d.ts +0 -1
  151. package/dist/vue-components.es10.js +0 -239
  152. package/dist/vue-components.es11.js +0 -32
  153. package/dist/vue-components.es12.js +0 -503
  154. package/dist/vue-components.es13.js +0 -49
  155. package/dist/vue-components.es14.js +0 -4
  156. package/dist/vue-components.es15.js +0 -4
  157. package/dist/vue-components.es16.js +0 -6
  158. package/dist/vue-components.es17.js +0 -13
  159. package/dist/vue-components.es18.js +0 -57
  160. package/dist/vue-components.es19.js +0 -56
  161. package/dist/vue-components.es2.js +0 -30
  162. package/dist/vue-components.es20.js +0 -8
  163. package/dist/vue-components.es21.js +0 -8
  164. package/dist/vue-components.es22.js +0 -5
  165. package/dist/vue-components.es23.js +0 -5
  166. package/dist/vue-components.es24.js +0 -4
  167. package/dist/vue-components.es25.js +0 -4
  168. package/dist/vue-components.es26.js +0 -4
  169. package/dist/vue-components.es27.js +0 -4
  170. package/dist/vue-components.es28.js +0 -19
  171. package/dist/vue-components.es29.js +0 -13
  172. package/dist/vue-components.es3.js +0 -17
  173. package/dist/vue-components.es30.js +0 -31
  174. package/dist/vue-components.es31.js +0 -6
  175. package/dist/vue-components.es32.js +0 -4
  176. package/dist/vue-components.es33.js +0 -4
  177. package/dist/vue-components.es34.js +0 -113
  178. package/dist/vue-components.es36.js +0 -9
  179. package/dist/vue-components.es37.js +0 -34
  180. package/dist/vue-components.es39.js +0 -194
  181. package/dist/vue-components.es4.js +0 -52
  182. package/dist/vue-components.es41.js +0 -6
  183. package/dist/vue-components.es42.js +0 -25
  184. package/dist/vue-components.es43.js +0 -7
  185. package/dist/vue-components.es44.js +0 -23
  186. package/dist/vue-components.es45.js +0 -32
  187. package/dist/vue-components.es46.js +0 -24
  188. package/dist/vue-components.es47.js +0 -14
  189. package/dist/vue-components.es48.js +0 -7
  190. package/dist/vue-components.es49.js +0 -21
  191. package/dist/vue-components.es5.js +0 -52
  192. package/dist/vue-components.es50.js +0 -11
  193. package/dist/vue-components.es51.js +0 -33
  194. package/dist/vue-components.es52.js +0 -50
  195. package/dist/vue-components.es53.js +0 -28
  196. package/dist/vue-components.es54.js +0 -13
  197. package/dist/vue-components.es55.js +0 -67
  198. package/dist/vue-components.es56.js +0 -58
  199. package/dist/vue-components.es57.js +0 -19
  200. package/dist/vue-components.es58.js +0 -35
  201. package/dist/vue-components.es59.js +0 -31
  202. package/dist/vue-components.es6.js +0 -69
  203. package/dist/vue-components.es60.js +0 -44
  204. package/dist/vue-components.es61.js +0 -4
  205. package/dist/vue-components.es62.js +0 -46
  206. package/dist/vue-components.es63.js +0 -4
  207. package/dist/vue-components.es7.js +0 -83
  208. package/dist/vue-components.es8.js +0 -63
  209. package/dist/vue-components.es9.js +0 -21
  210. package/src/components/OmegaForm/OmegaFormStuff.ts +0 -1276
  211. package/src/constants/index.ts +0 -1
@@ -1,4 +1,4 @@
1
- import { injectCertain } from "@effect-app/vue"
1
+ import { injectCertain } from "@effect-app/vue/makeContext"
2
2
  import { type ComputedRef, type InjectionKey, onUnmounted, provide, watch } from "vue"
3
3
 
4
4
  const Key = Symbol("injected") as InjectionKey<Map<string, { label: string; id: string }>>
@@ -0,0 +1,242 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import type { StandardSchemaV1 } from "@tanstack/vue-form"
3
+ import * as S from "effect-app/Schema"
4
+ import type { useIntl } from "../../../utils"
5
+
6
+ export type TransFn = ReturnType<typeof useIntl>["trans"]
7
+
8
+ type FilterMeta =
9
+ | { readonly _tag: "isMinLength"; readonly minLength: number }
10
+ | { readonly _tag: "isMaxLength"; readonly maxLength: number }
11
+ | { readonly _tag: "isInt" }
12
+ | { readonly _tag: "isGreaterThanOrEqualTo"; readonly minimum: number }
13
+ | { readonly _tag: "isGreaterThan"; readonly exclusiveMinimum: number }
14
+ | { readonly _tag: "isLessThanOrEqualTo"; readonly maximum: number }
15
+ | { readonly _tag: "isLessThan"; readonly exclusiveMaximum: number }
16
+ | { readonly _tag: "isBetween"; readonly minimum: number; readonly maximum: number }
17
+ | { readonly _tag?: undefined }
18
+
19
+ /** Map filter annotations (representation since beta.107, legacy meta before) to FilterMeta. */
20
+ const filterMetaOf = (filter: {
21
+ readonly annotations?: {
22
+ readonly meta?: unknown
23
+ readonly representation?: { readonly id?: string; readonly payload?: unknown }
24
+ }
25
+ }): FilterMeta => {
26
+ const rep = filter.annotations?.representation
27
+ if (rep && typeof rep.id === "string") {
28
+ const tag = rep.id.replace(/^effect\/schema\//, "")
29
+ const payload = rep.payload !== null && typeof rep.payload === "object"
30
+ ? rep.payload as Record<string, unknown>
31
+ : {}
32
+ return { _tag: tag, ...payload } as FilterMeta
33
+ }
34
+ return (filter.annotations?.meta ?? {})
35
+ }
36
+
37
+ const reportedInput = (issue: S.SchemaIssue.Issue): unknown => S.SchemaIssue.hasInput(issue) ? issue.input : undefined
38
+
39
+ export const makeStandardSchemaV1Hooks = (
40
+ trans: TransFn
41
+ ): {
42
+ leafHook: S.SchemaIssue.LeafHook
43
+ checkHook: S.SchemaIssue.CheckHook
44
+ } => {
45
+ const leafHook: S.SchemaIssue.LeafHook = (issue) => {
46
+ const override = (issue as { annotations?: { message?: unknown } }).annotations?.message
47
+ if (override !== undefined) return String(override)
48
+ switch (issue._tag) {
49
+ case "MissingKey":
50
+ return trans("validation.empty")
51
+ case "InvalidType": {
52
+ const ast = issue.ast
53
+ // Detect undefined/missing actual values across required leaves and return a uniform empty message.
54
+ const input = reportedInput(issue)
55
+ const actualUndefined = input === undefined
56
+ if (actualUndefined) return trans("validation.empty")
57
+ if (S.AST.isString(ast)) return trans("validation.empty")
58
+ if (S.AST.isBoolean(ast)) return trans("validation.not_a_valid", { type: "boolean" })
59
+ if (S.AST.isNumber(ast)) {
60
+ return trans("validation.number.expected", { actualValue: String(input) })
61
+ }
62
+ return trans("validation.not_a_valid")
63
+ }
64
+ default:
65
+ return trans("validation.not_a_valid")
66
+ }
67
+ }
68
+
69
+ const checkHook: S.SchemaIssue.CheckHook = (issue) => {
70
+ // S.Email's `refine(isValidEmail, ...)` has no representation meta but carries
71
+ // `identifier: "Email"`. Localize it explicitly — otherwise the
72
+ // formatter falls back to the generic "Expected <filter>, got <actual>".
73
+ if (issue.filter.annotations?.identifier === "Email") {
74
+ return trans("validation.email.invalid")
75
+ }
76
+ const meta = filterMetaOf(issue.filter)
77
+ switch (meta._tag) {
78
+ case "isMinLength":
79
+ return meta.minLength === 1
80
+ ? trans("validation.empty")
81
+ : trans("validation.string.minLength", { minLength: meta.minLength })
82
+ case "isMaxLength":
83
+ return trans("validation.string.maxLength", { maxLength: meta.maxLength })
84
+ case "isInt": {
85
+ const input = reportedInput(issue)
86
+ const actual = input !== undefined ? String(input) : "NaN"
87
+ return trans("validation.integer.expected", { actualValue: actual })
88
+ }
89
+ // isExclusive semantics in the message catalog: true = strict bound
90
+ // ("greater/less than"), false = inclusive bound ("at least/at most").
91
+ case "isGreaterThanOrEqualTo":
92
+ return trans(
93
+ meta.minimum === 0 ? "validation.number.positive" : "validation.number.min",
94
+ { minimum: meta.minimum, isExclusive: false }
95
+ )
96
+ case "isGreaterThan":
97
+ return trans(
98
+ meta.exclusiveMinimum === 0 ? "validation.number.positive" : "validation.number.min",
99
+ { minimum: meta.exclusiveMinimum, isExclusive: true }
100
+ )
101
+ case "isLessThanOrEqualTo":
102
+ return trans("validation.number.max", { maximum: meta.maximum, isExclusive: false })
103
+ case "isLessThan":
104
+ return trans("validation.number.max", { maximum: meta.exclusiveMaximum, isExclusive: true })
105
+ case "isBetween": {
106
+ // Inclusive on both ends; report the side the value actually violated.
107
+ const input = reportedInput(issue)
108
+ const below = typeof input === "number" && input < meta.minimum
109
+ return below
110
+ ? trans("validation.number.min", { minimum: meta.minimum, isExclusive: false })
111
+ : trans("validation.number.max", { maximum: meta.maximum, isExclusive: false })
112
+ }
113
+ default:
114
+ // Fall back to the default check hook so custom S.makeFilter messages
115
+ // (which surface as InvalidValue.annotations.message on issue.issue)
116
+ // are returned verbatim instead of getting the generic
117
+ // "Expected <filter>, got <actual>" formatter output.
118
+ return S.SchemaIssue.defaultCheckHook(issue)
119
+ }
120
+ }
121
+
122
+ return { leafHook, checkHook }
123
+ }
124
+
125
+ export const toLocalizedStandardSchemaV1 = <To, From>(
126
+ schema: S.Codec<To, From>,
127
+ trans: TransFn
128
+ ): StandardSchemaV1<From, To> => {
129
+ const { checkHook, leafHook } = makeStandardSchemaV1Hooks(trans)
130
+ // reportInput so leaf/check hooks can include the rejected value in messages
131
+ return S.toStandardSchemaV1(schema, {
132
+ leafHook,
133
+ checkHook,
134
+ parseOptions: { reportInput: true, errors: "all" }
135
+ })
136
+ }
137
+
138
+ /*
139
+ * Effect's Standard Schema formatter handles `AnyOf` issues (produced by
140
+ * `S.Literals(...)` failures and by `S.Array` of literal unions when the
141
+ * top-level value isn't an array) by generating the message directly via
142
+ * `getExpectedMessage(...)` — *without* invoking `leafHook` / `checkHook`.
143
+ * The only override path is `findMessage(issue)`, which reads the AST's
144
+ * `message` annotation. So we walk the schema AST once at form setup and
145
+ * stamp a localized `message` annotation on:
146
+ * - Union AST whose every member is a Literal → "select"
147
+ * - Arrays AST whose `rest` is a Union of Literals → "multiple"
148
+ * Existing `message` annotations are preserved.
149
+ */
150
+ const isLiteralUnion = (ast: S.AST.AST): ast is S.AST.Union<S.AST.Literal> =>
151
+ S.AST.isUnion(ast) && ast.types.every(S.AST.isLiteral)
152
+
153
+ const walkAst = (ast: S.AST.AST, trans: TransFn): S.AST.AST => {
154
+ if (isLiteralUnion(ast)) {
155
+ if (ast.annotations?.message !== undefined) return ast
156
+ const members = ast.types.map((t) => t.literal)
157
+ return new S.AST.Union(
158
+ ast.types,
159
+ ast.options,
160
+ {
161
+ ...ast.annotations,
162
+ message: trans("validation.not_a_valid", { type: "select", message: members.join(", ") })
163
+ },
164
+ ast.checks,
165
+ ast.encoding,
166
+ ast.context,
167
+ ast.encodingChecks
168
+ )
169
+ }
170
+ // Mixed unions (e.g. `S.NullOr(S.Literals(...))` → Union<Null, Union<Literals>>)
171
+ // need recursion so the inner literal-union still gets annotated. We don't
172
+ // touch the outer mixed Union's own annotations.
173
+ if (S.AST.isUnion(ast)) {
174
+ const newTypes = ast.types.map((t) => walkAst(t, trans))
175
+ const changed = newTypes.some((t, i) => t !== ast.types[i])
176
+ if (!changed) return ast
177
+ return new S.AST.Union(
178
+ newTypes,
179
+ ast.options,
180
+ ast.annotations,
181
+ ast.checks,
182
+ ast.encoding,
183
+ ast.context,
184
+ ast.encodingChecks
185
+ )
186
+ }
187
+ if (S.AST.isArrays(ast)) {
188
+ const newRest = ast.rest.map((e) => walkAst(e, trans))
189
+ const newElements = ast.elements.map((e) => walkAst(e, trans))
190
+ let annotations = ast.annotations
191
+ if (
192
+ ast.annotations?.message === undefined
193
+ && ast.rest.length === 1
194
+ && isLiteralUnion(ast.rest[0])
195
+ ) {
196
+ const members = ast.rest[0].types.map((t) => t.literal)
197
+ annotations = {
198
+ ...ast.annotations,
199
+ message: trans("validation.not_a_valid", { type: "multiple", message: members.join(", ") })
200
+ }
201
+ }
202
+ const restChanged = newRest.some((r, i) => r !== ast.rest[i])
203
+ const elemsChanged = newElements.some((e, i) => e !== ast.elements[i])
204
+ if (!restChanged && !elemsChanged && annotations === ast.annotations) return ast
205
+ return new S.AST.Arrays(
206
+ ast.isMutable,
207
+ newElements,
208
+ newRest,
209
+ annotations,
210
+ ast.checks,
211
+ ast.encoding,
212
+ ast.context,
213
+ ast.encodingChecks
214
+ )
215
+ }
216
+ if (S.AST.isObjects(ast)) {
217
+ const newProps = ast.propertySignatures.map((p) => {
218
+ const newType = walkAst(p.type, trans)
219
+ return newType === p.type ? p : new S.AST.PropertySignature(p.name, newType)
220
+ })
221
+ const changed = newProps.some((p, i) => p !== ast.propertySignatures[i])
222
+ if (!changed) return ast
223
+ return new S.AST.Objects(
224
+ newProps,
225
+ ast.indexSignatures,
226
+ ast.annotations,
227
+ ast.checks,
228
+ ast.encoding,
229
+ ast.context,
230
+ ast.encodingChecks
231
+ )
232
+ }
233
+ return ast
234
+ }
235
+
236
+ export const annotateLiteralUnionMessages = <To, From>(
237
+ schema: S.Codec<To, From>,
238
+ trans: TransFn
239
+ ): S.Codec<To, From> => {
240
+ const newAst = walkAst(schema.ast, trans)
241
+ return newAst === schema.ast ? schema : S.make(newAst)
242
+ }
@@ -1,3 +1,4 @@
1
1
  export { default as CommandButton } from "./CommandButton.vue"
2
2
  export { default as Dialog } from "./Dialog.vue"
3
+ export { default as FixedNuxtErrorBoundary } from "./FixedNuxtErrorBoundary.vue"
3
4
  export * from "./OmegaForm"
package/src/index.ts CHANGED
@@ -17,5 +17,4 @@ function install(app: App) {
17
17
  export default { install }
18
18
 
19
19
  export * from "./components"
20
- export * from "./constants"
21
20
  export * from "./utils"
package/src/reset.css CHANGED
@@ -4,48 +4,49 @@
4
4
  * Import this file to restore equivalent behavior:
5
5
  * import '@effect-app/vue-components/reset.css'
6
6
  */
7
+ @layer vuetify-reset {
8
+ body {
9
+ margin: 0;
10
+ }
7
11
 
8
- body {
9
- margin: 0;
10
- }
12
+ ul,
13
+ ol {
14
+ margin: 0;
15
+ padding: 0;
16
+ list-style: none;
17
+ }
11
18
 
12
- ul,
13
- ol {
14
- margin: 0;
15
- padding: 0;
16
- list-style: none;
17
- }
19
+ h1,
20
+ h2,
21
+ h3,
22
+ h4,
23
+ h5,
24
+ h6 {
25
+ margin: 0;
26
+ font-size: inherit;
27
+ font-weight: inherit;
28
+ }
18
29
 
19
- h1,
20
- h2,
21
- h3,
22
- h4,
23
- h5,
24
- h6 {
25
- margin: 0;
26
- font-size: inherit;
27
- font-weight: inherit;
28
- }
30
+ p {
31
+ margin: 0;
32
+ }
29
33
 
30
- p {
31
- margin: 0;
32
- }
34
+ input,
35
+ textarea,
36
+ select {
37
+ border: 0;
38
+ background: transparent;
39
+ }
33
40
 
34
- input,
35
- textarea,
36
- select {
37
- border: 0;
38
- background: transparent;
39
- }
40
-
41
- a {
42
- text-decoration: none;
43
- color: inherit;
44
- }
41
+ a {
42
+ text-decoration: none;
43
+ color: inherit;
44
+ }
45
45
 
46
- figure,
47
- details,
48
- summary {
49
- margin: 0;
50
- padding: 0;
46
+ figure,
47
+ details,
48
+ summary {
49
+ margin: 0;
50
+ padding: 0;
51
+ }
51
52
  }
@@ -1,5 +1,5 @@
1
- import { type makeIntl } from "@effect-app/vue"
2
- import { S } from "effect-app"
1
+ import { type makeIntl } from "@effect-app/vue/makeIntl"
2
+ import type * as S from "effect-app/Schema"
3
3
  import { inject, type InjectionKey, provide } from "vue"
4
4
 
5
5
  export const useIntlKey = Symbol() as InjectionKey<
@@ -17,12 +17,15 @@ export const provideIntl = (
17
17
  ) => provide(useIntlKey, intl)
18
18
 
19
19
  /**
20
- * Recursively extracts the source AST from a transformation chain.
21
- * If the provided AST is a transformation, it follows the chain to find the original source AST.
22
- *
23
- * @param ast - The AST node to extract the transformation source from
24
- * @returns The source AST at the end of the transformation chain
20
+ * Walks the encoding chain of the given AST node to its source (encoded)
21
+ * side. Shallow does not recurse into children, so inner prop-level
22
+ * transformations (e.g. `FiniteFromString`) keep their decoded shape
23
+ * while struct-level `decodeTo` transformations are unwrapped to their
24
+ * input side (e.g. `NonNegativeInt` rather than the decoded `PositiveInt`).
25
25
  */
26
26
  export function getTransformationFrom(ast: S.AST.AST) {
27
- return S.AST.toType(ast)
27
+ while (ast.encoding) {
28
+ ast = ast.encoding[0].to
29
+ }
30
+ return ast
28
31
  }
@@ -1,159 +0,0 @@
1
- import { Effect, S } from "effect-app";
2
- 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";
3
- import type { Fiber as EffectFiber } from "effect/Fiber";
4
- import { useIntl } from "../../utils";
5
- import { type OmegaFieldInternalApi } from "./InputProps";
6
- import { type OF, type OmegaFormReturn } from "./useOmegaForm";
7
- export type FieldPath<T> = unknown extends T ? string : T extends string | boolean | number | null | undefined | symbol | bigint ? "" : T extends ReadonlyArray<infer U> ? FieldPath_<U, `[${number}]`> : {
8
- [K in keyof T]: FieldPath_<T[K], `${K & string}`>;
9
- }[keyof T];
10
- export type FieldPath_<T, Path extends string> = unknown extends T ? string : T extends string | boolean | number | null | undefined | symbol | bigint ? Path : T extends ReadonlyArray<infer U> ? FieldPath_<U, `${Path}[${number}]`> | Path : {
11
- [K in keyof T]: FieldPath_<T[K], `${Path}.${K & string}`>;
12
- }[keyof T];
13
- export type BaseProps<From, TName extends FieldPath<From>> = {
14
- /**
15
- * Will fallback to i18n when not specified.
16
- * Can also be provided via #label slot for custom HTML labels.
17
- * When using the slot, it receives bindings: { required, id, label }
18
- */
19
- label?: string;
20
- validators?: FieldValidators<From>;
21
- name: TName;
22
- /**
23
- * Optional class to apply to the input element.
24
- * - If a string is provided, it will be used instead of the general class
25
- * - If null is provided, no class will be applied (neither inputClass nor general class)
26
- * - If undefined (not provided), the general class will be used
27
- */
28
- inputClass?: string | null;
29
- };
30
- export type TypesWithOptions = "radio" | "select" | "multiple" | "autocomplete" | "autocompletemultiple";
31
- export type DefaultTypeProps = {
32
- type?: TypeOverride;
33
- options?: undefined;
34
- } | {
35
- type?: TypesWithOptions;
36
- options?: {
37
- title: string;
38
- value: unknown;
39
- }[];
40
- };
41
- export type OmegaInputPropsBase<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>> = {
42
- form: OF<From, To> & {
43
- meta: MetaRecord<From>;
44
- i18nNamespace?: string;
45
- };
46
- } & BaseProps<From, Name>;
47
- export type OmegaInputProps<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>, TypeProps = DefaultTypeProps> = {
48
- form: OmegaFormReturn<From, To, TypeProps> & {
49
- meta: MetaRecord<From>;
50
- i18nNamespace?: string;
51
- };
52
- } & BaseProps<From, Name>;
53
- export type OmegaArrayProps<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>> = Omit<OmegaInputProps<From, To, Name>, "validators" | "options" | "label" | "type" | "items" | "name"> & {
54
- name: DeepKeys<From>;
55
- defaultItems?: DeepValue<From, DeepKeys<From>>;
56
- items?: "please use `defaultItems` instead";
57
- };
58
- export type TypeOverride = "string" | "text" | "number" | "select" | "multiple" | "boolean" | "radio" | "autocomplete" | "autocompletemultiple" | "switch" | "range" | "password" | "email" | "date";
59
- export interface OmegaError {
60
- label: string;
61
- inputId: string;
62
- errors: readonly string[];
63
- }
64
- export type FormProps<From, To> = Omit<FormOptions<From, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, StandardSchemaV1<From, To>, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, Record<string, any> | undefined>, "onSubmit" | "defaultValues"> & {
65
- defaultValues?: Partial<From>;
66
- onSubmit?: (props: {
67
- formApi: OmegaFormParams<From, To>;
68
- meta: any;
69
- value: To;
70
- }) => Promise<any> | EffectFiber<any, any> | Effect.Effect<unknown, any, never>;
71
- };
72
- export type OmegaFormParams<From, To> = FormApi<From, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, StandardSchemaV1<From, To>, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, Record<string, any> | undefined>;
73
- export type OmegaFormState<From, To> = FormState<From, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, StandardSchemaV1<From, To>, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined>;
74
- export type OmegaFormApi<From, To, TSubmitMeta = Record<string, any> | undefined> = OmegaFormParams<From, To> & VueFormApi<From, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, StandardSchemaV1<From, To>, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, TSubmitMeta>;
75
- export type FormComponent<T, S> = VueFormApi<T, FormValidateOrFn<T> | undefined, FormValidateOrFn<T> | undefined, StandardSchemaV1<T, S>, FormValidateOrFn<T> | undefined, FormAsyncValidateOrFn<T> | undefined, FormValidateOrFn<T> | undefined, FormAsyncValidateOrFn<T> | undefined, FormValidateOrFn<T> | undefined, FormAsyncValidateOrFn<T> | undefined, FormAsyncValidateOrFn<T> | undefined, Record<string, any> | undefined>;
76
- export type FormType<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>> = OmegaFormApi<From, To> & {
77
- Field: OmegaFieldInternalApi<From, Name>;
78
- };
79
- export type PrefixFromDepth<K extends string | number, _TDepth extends any[]> = K;
80
- export type NestedKeyOf<T> = DeepKeys<T>;
81
- export type FieldValidators<T> = {
82
- onChangeAsync?: FieldAsyncValidateOrFn<T, any, any>;
83
- onChange?: FieldValidateOrFn<T, any, any>;
84
- onBlur?: FieldValidateOrFn<T, any, any>;
85
- onBlurAsync?: FieldAsyncValidateOrFn<T, any, any>;
86
- };
87
- export type BaseFieldMeta = {
88
- required: boolean;
89
- nullableOrUndefined?: false | "undefined" | "null";
90
- };
91
- export type StringFieldMeta = BaseFieldMeta & {
92
- type: "string";
93
- maxLength?: number;
94
- minLength?: number;
95
- format?: string;
96
- };
97
- export type NumberFieldMeta = BaseFieldMeta & {
98
- type: "number";
99
- minimum?: number;
100
- maximum?: number;
101
- exclusiveMinimum?: number;
102
- exclusiveMaximum?: number;
103
- refinement?: "int";
104
- };
105
- export type SelectFieldMeta = BaseFieldMeta & {
106
- type: "select";
107
- members: any[];
108
- };
109
- export type MultipleFieldMeta = BaseFieldMeta & {
110
- type: "multiple";
111
- members: any[];
112
- rest: readonly S.AST.AST[];
113
- };
114
- export type BooleanFieldMeta = BaseFieldMeta & {
115
- type: "boolean";
116
- };
117
- export type DateFieldMeta = BaseFieldMeta & {
118
- type: "date";
119
- };
120
- export type UnknownFieldMeta = BaseFieldMeta & {
121
- type: "unknown";
122
- };
123
- export type FieldMeta = StringFieldMeta | NumberFieldMeta | SelectFieldMeta | MultipleFieldMeta | BooleanFieldMeta | DateFieldMeta | UnknownFieldMeta;
124
- export type MetaRecord<T = string> = {
125
- [K in NestedKeyOf<T>]?: FieldMeta;
126
- };
127
- export type FilterItems = {
128
- items: readonly [string, ...string[]];
129
- message: string | Effect.Effect<string, never, never> | {
130
- readonly message: string | Effect.Effect<string>;
131
- };
132
- };
133
- export type CreateMeta = {
134
- parent?: string;
135
- meta?: Record<string, any>;
136
- nullableOrUndefined?: false | "undefined" | "null";
137
- } & ({
138
- propertySignatures: readonly S.AST.PropertySignature[];
139
- property?: never;
140
- } | {
141
- propertySignatures?: never;
142
- property: S.AST.AST;
143
- });
144
- export declare const isNullableOrUndefined: (property: false | S.AST.AST | undefined) => false | "undefined" | "null";
145
- export declare const createMeta: <T = any>({ meta, parent, property, propertySignatures }: CreateMeta, acc?: Partial<MetaRecord<T>>) => MetaRecord<T> | FieldMeta;
146
- export declare const duplicateSchema: <From, To>(schema: S.Codec<To, From, never>) => S.Codec<To, From, never, never>;
147
- export declare const generateMetaFromSchema: <From, To>(schema: S.Codec<To, From, never>) => {
148
- schema: S.Codec<To, From, never>;
149
- meta: MetaRecord<To>;
150
- unionMeta: Record<string, MetaRecord<To>>;
151
- };
152
- export declare const generateInputStandardSchemaFromFieldMeta: (meta: FieldMeta, trans?: ReturnType<typeof useIntl>["trans"]) => StandardSchemaV1<any, any>;
153
- export type OmegaAutoGenMeta<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>> = Omit<OmegaInputProps<From, To, Name>, "form">;
154
- declare const supportedInputs: readonly ["button", "checkbox", "color", "date", "email", "number", "password", "radio", "range", "search", "submit", "tel", "text", "time", "url"];
155
- export type SupportedInputs = typeof supportedInputs[number];
156
- export declare const getInputType: (input: string) => SupportedInputs;
157
- export declare function deepMerge(target: any, source: any): any;
158
- export declare const defaultsValueFromSchema: (schema: S.Schema<any>, record?: Record<string, any>) => any;
159
- export {};
@@ -1 +0,0 @@
1
- export {};