@effect-app/vue-components 4.0.0-beta.20 → 4.0.0-beta.201

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 (196) hide show
  1. package/README.md +36 -8
  2. package/dist/reset.css +52 -0
  3. package/dist/types/components/CommandButton.vue.d.ts +6 -4
  4. package/dist/types/components/OmegaForm/OmegaArray.vue.d.ts +1 -1
  5. package/dist/types/components/OmegaForm/OmegaAutoGen.vue.d.ts +1 -1
  6. package/dist/types/components/OmegaForm/OmegaErrorsInternal.vue.d.ts +1 -1
  7. package/dist/types/components/OmegaForm/OmegaFormInput.vue.d.ts +1 -1
  8. package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +1 -1
  9. package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +2 -1
  10. package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +1 -1
  11. package/dist/types/components/OmegaForm/createUseFormWithCustomInput.d.ts +2 -2
  12. package/dist/types/components/OmegaForm/errors.d.ts +33 -0
  13. package/dist/types/components/OmegaForm/getOmegaStore.d.ts +1 -1
  14. package/dist/types/components/OmegaForm/hocs.d.ts +3 -0
  15. package/dist/types/components/OmegaForm/index.d.ts +13 -3
  16. package/dist/types/components/OmegaForm/inputs.d.ts +4 -0
  17. package/dist/types/components/OmegaForm/meta/checks.d.ts +4 -0
  18. package/dist/types/components/OmegaForm/meta/createMeta.d.ts +32 -0
  19. package/dist/types/components/OmegaForm/meta/defaults.d.ts +2 -0
  20. package/dist/types/components/OmegaForm/meta/redacted.d.ts +2 -0
  21. package/dist/types/components/OmegaForm/meta/types.d.ts +56 -0
  22. package/dist/types/components/OmegaForm/meta/walker.d.ts +18 -0
  23. package/dist/types/components/OmegaForm/persistency.d.ts +58 -0
  24. package/dist/types/components/OmegaForm/submit.d.ts +60 -0
  25. package/dist/types/components/OmegaForm/types.d.ts +281 -0
  26. package/dist/types/components/OmegaForm/useOmegaForm.d.ts +7 -213
  27. package/dist/types/components/OmegaForm/validation/localized.d.ts +10 -0
  28. package/dist/types/index.d.ts +0 -1
  29. package/dist/types/utils/index.d.ts +6 -6
  30. package/dist/vue-components.es.js +29 -45
  31. package/dist/vue-components10.es.js +5 -0
  32. package/dist/vue-components11.es.js +20 -0
  33. package/dist/vue-components12.es.js +49 -0
  34. package/dist/vue-components13.es.js +128 -0
  35. package/dist/vue-components14.es.js +65 -0
  36. package/dist/vue-components15.es.js +60 -0
  37. package/dist/vue-components16.es.js +22 -0
  38. package/dist/vue-components17.es.js +5 -0
  39. package/dist/vue-components18.es.js +80 -0
  40. package/dist/vue-components19.es.js +92 -0
  41. package/dist/vue-components2.es.js +11 -0
  42. package/dist/vue-components20.es.js +73 -0
  43. package/dist/vue-components21.es.js +12 -0
  44. package/dist/vue-components22.es.js +56 -0
  45. package/dist/vue-components23.es.js +5 -0
  46. package/dist/vue-components24.es.js +44 -0
  47. package/dist/vue-components25.es.js +5 -0
  48. package/dist/vue-components26.es.js +84 -0
  49. package/dist/vue-components28.es.js +8 -0
  50. package/dist/vue-components29.es.js +9 -0
  51. package/dist/vue-components3.es.js +86 -0
  52. package/dist/vue-components30.es.js +269 -0
  53. package/dist/vue-components32.es.js +8 -0
  54. package/dist/vue-components33.es.js +73 -0
  55. package/dist/vue-components34.es.js +5 -0
  56. package/dist/vue-components35.es.js +52 -0
  57. package/dist/vue-components36.es.js +5 -0
  58. package/dist/vue-components37.es.js +24 -0
  59. package/dist/vue-components38.es.js +5 -0
  60. package/dist/vue-components39.es.js +59 -0
  61. package/dist/vue-components4.es.js +5 -0
  62. package/dist/vue-components40.es.js +5 -0
  63. package/dist/vue-components41.es.js +12 -0
  64. package/dist/vue-components42.es.js +22 -0
  65. package/dist/vue-components44.es.js +9 -0
  66. package/dist/vue-components45.es.js +4 -0
  67. package/dist/vue-components46.es.js +38 -0
  68. package/dist/vue-components47.es.js +27 -0
  69. package/dist/vue-components48.es.js +28 -0
  70. package/dist/vue-components49.es.js +7 -0
  71. package/dist/vue-components5.es.js +24 -0
  72. package/dist/vue-components50.es.js +18 -0
  73. package/dist/vue-components51.es.js +36 -0
  74. package/dist/vue-components52.es.js +18 -0
  75. package/dist/vue-components53.es.js +21 -0
  76. package/dist/vue-components54.es.js +30 -0
  77. package/dist/vue-components55.es.js +7 -0
  78. package/dist/vue-components56.es.js +9 -0
  79. package/dist/vue-components57.es.js +38 -0
  80. package/dist/vue-components58.es.js +25 -0
  81. package/dist/vue-components59.es.js +128 -0
  82. package/dist/vue-components6.es.js +13 -0
  83. package/dist/vue-components60.es.js +24 -0
  84. package/dist/vue-components61.es.js +21 -0
  85. package/dist/vue-components62.es.js +9 -0
  86. package/dist/vue-components63.es.js +19 -0
  87. package/dist/vue-components64.es.js +5 -0
  88. package/dist/vue-components65.es.js +29 -0
  89. package/dist/vue-components66.es.js +5 -0
  90. package/dist/vue-components67.es.js +29 -0
  91. package/dist/vue-components68.es.js +6 -0
  92. package/dist/vue-components69.es.js +18 -0
  93. package/dist/vue-components7.es.js +13 -0
  94. package/dist/vue-components70.es.js +40 -0
  95. package/dist/vue-components71.es.js +81 -0
  96. package/dist/vue-components72.es.js +33 -0
  97. package/dist/vue-components73.es.js +19 -0
  98. package/dist/vue-components74.es.js +48 -0
  99. package/dist/vue-components8.es.js +35 -0
  100. package/dist/vue-components9.es.js +47 -0
  101. package/package.json +35 -31
  102. package/src/components/CommandButton.vue +55 -7
  103. package/src/components/OmegaForm/OmegaArray.vue +2 -4
  104. package/src/components/OmegaForm/OmegaAutoGen.vue +2 -1
  105. package/src/components/OmegaForm/OmegaErrorsInternal.vue +1 -1
  106. package/src/components/OmegaForm/OmegaFormInput.vue +1 -1
  107. package/src/components/OmegaForm/OmegaInput.vue +7 -36
  108. package/src/components/OmegaForm/OmegaInputVuetify.vue +5 -2
  109. package/src/components/OmegaForm/OmegaInternalInput.vue +18 -10
  110. package/src/components/OmegaForm/OmegaTaggedUnion.vue +2 -1
  111. package/src/components/OmegaForm/OmegaTaggedUnionInternal.vue +1 -1
  112. package/src/components/OmegaForm/OmegaWrapper.vue +1 -1
  113. package/src/components/OmegaForm/blockDialog.ts +18 -6
  114. package/src/components/OmegaForm/createUseFormWithCustomInput.ts +2 -1
  115. package/src/components/OmegaForm/errors.ts +136 -0
  116. package/src/components/OmegaForm/getOmegaStore.ts +1 -1
  117. package/src/components/OmegaForm/hocs.ts +19 -0
  118. package/src/components/OmegaForm/index.ts +16 -4
  119. package/src/components/OmegaForm/inputs.ts +22 -0
  120. package/src/components/OmegaForm/meta/checks.ts +81 -0
  121. package/src/components/OmegaForm/meta/createMeta.ts +138 -0
  122. package/src/components/OmegaForm/meta/defaults.ts +132 -0
  123. package/src/components/OmegaForm/meta/redacted.ts +66 -0
  124. package/src/components/OmegaForm/meta/types.ts +78 -0
  125. package/src/components/OmegaForm/meta/walker.ts +248 -0
  126. package/src/components/OmegaForm/persistency.ts +247 -0
  127. package/src/components/OmegaForm/submit.ts +128 -0
  128. package/src/components/OmegaForm/types.ts +751 -0
  129. package/src/components/OmegaForm/useOmegaForm.ts +58 -893
  130. package/src/components/OmegaForm/validation/localized.ts +202 -0
  131. package/src/index.ts +0 -1
  132. package/src/reset.css +52 -0
  133. package/src/utils/index.ts +10 -7
  134. package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +0 -157
  135. package/dist/types/constants/index.d.ts +0 -1
  136. package/dist/vue-components.es10.js +0 -239
  137. package/dist/vue-components.es11.js +0 -32
  138. package/dist/vue-components.es12.js +0 -481
  139. package/dist/vue-components.es13.js +0 -49
  140. package/dist/vue-components.es14.js +0 -4
  141. package/dist/vue-components.es15.js +0 -4
  142. package/dist/vue-components.es16.js +0 -13
  143. package/dist/vue-components.es17.js +0 -6
  144. package/dist/vue-components.es18.js +0 -13
  145. package/dist/vue-components.es19.js +0 -57
  146. package/dist/vue-components.es2.js +0 -31
  147. package/dist/vue-components.es20.js +0 -56
  148. package/dist/vue-components.es21.js +0 -8
  149. package/dist/vue-components.es22.js +0 -8
  150. package/dist/vue-components.es23.js +0 -5
  151. package/dist/vue-components.es24.js +0 -5
  152. package/dist/vue-components.es25.js +0 -4
  153. package/dist/vue-components.es26.js +0 -4
  154. package/dist/vue-components.es27.js +0 -4
  155. package/dist/vue-components.es28.js +0 -4
  156. package/dist/vue-components.es29.js +0 -19
  157. package/dist/vue-components.es3.js +0 -17
  158. package/dist/vue-components.es30.js +0 -194
  159. package/dist/vue-components.es32.js +0 -31
  160. package/dist/vue-components.es33.js +0 -6
  161. package/dist/vue-components.es34.js +0 -4
  162. package/dist/vue-components.es35.js +0 -4
  163. package/dist/vue-components.es36.js +0 -113
  164. package/dist/vue-components.es38.js +0 -9
  165. package/dist/vue-components.es39.js +0 -34
  166. package/dist/vue-components.es4.js +0 -52
  167. package/dist/vue-components.es41.js +0 -6
  168. package/dist/vue-components.es42.js +0 -25
  169. package/dist/vue-components.es43.js +0 -7
  170. package/dist/vue-components.es44.js +0 -23
  171. package/dist/vue-components.es45.js +0 -32
  172. package/dist/vue-components.es46.js +0 -24
  173. package/dist/vue-components.es47.js +0 -14
  174. package/dist/vue-components.es48.js +0 -7
  175. package/dist/vue-components.es49.js +0 -21
  176. package/dist/vue-components.es5.js +0 -52
  177. package/dist/vue-components.es50.js +0 -11
  178. package/dist/vue-components.es51.js +0 -33
  179. package/dist/vue-components.es52.js +0 -50
  180. package/dist/vue-components.es53.js +0 -28
  181. package/dist/vue-components.es54.js +0 -13
  182. package/dist/vue-components.es55.js +0 -67
  183. package/dist/vue-components.es56.js +0 -58
  184. package/dist/vue-components.es57.js +0 -19
  185. package/dist/vue-components.es58.js +0 -35
  186. package/dist/vue-components.es59.js +0 -31
  187. package/dist/vue-components.es6.js +0 -69
  188. package/dist/vue-components.es60.js +0 -44
  189. package/dist/vue-components.es61.js +0 -4
  190. package/dist/vue-components.es62.js +0 -46
  191. package/dist/vue-components.es63.js +0 -4
  192. package/dist/vue-components.es7.js +0 -83
  193. package/dist/vue-components.es8.js +0 -63
  194. package/dist/vue-components.es9.js +0 -21
  195. package/src/components/OmegaForm/OmegaFormStuff.ts +0 -1184
  196. package/src/constants/index.ts +0 -1
@@ -0,0 +1,202 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import type { StandardSchemaV1 } from "@tanstack/vue-form"
3
+ import { Option, S } from "effect-app"
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?: undefined }
17
+
18
+ export const makeStandardSchemaV1Hooks = (
19
+ trans: TransFn
20
+ ): {
21
+ leafHook: S.SchemaIssue.LeafHook
22
+ checkHook: S.SchemaIssue.CheckHook
23
+ } => {
24
+ const leafHook: S.SchemaIssue.LeafHook = (issue) => {
25
+ const override = (issue as { annotations?: { message?: unknown } }).annotations?.message
26
+ if (override !== undefined) return String(override)
27
+ switch (issue._tag) {
28
+ case "MissingKey":
29
+ return trans("validation.empty")
30
+ case "InvalidType": {
31
+ const ast = issue.ast
32
+ // Detect undefined/missing actual values across required leaves and return a uniform empty message.
33
+ const actualUndefined = Option.isNone(issue.actual)
34
+ || (Option.isSome(issue.actual) && issue.actual.value === undefined)
35
+ if (actualUndefined) return trans("validation.empty")
36
+ if (S.AST.isString(ast)) return trans("validation.empty")
37
+ if (S.AST.isBoolean(ast)) return trans("validation.not_a_valid", { type: "boolean" })
38
+ if (S.AST.isNumber(ast)) {
39
+ const actual = Option.isSome(issue.actual) ? String(issue.actual.value) : "NaN"
40
+ return trans("validation.number.expected", { actualValue: actual })
41
+ }
42
+ return trans("validation.not_a_valid")
43
+ }
44
+ default:
45
+ return trans("validation.not_a_valid")
46
+ }
47
+ }
48
+
49
+ const checkHook: S.SchemaIssue.CheckHook = (issue) => {
50
+ // S.Email's `refine(isValidEmail, ...)` has no `meta._tag` but carries
51
+ // `identifier: "Email"`. Localize it explicitly — otherwise the
52
+ // formatter falls back to the generic "Expected <filter>, got <actual>".
53
+ if (issue.filter.annotations?.identifier === "Email") {
54
+ return trans("validation.email.invalid")
55
+ }
56
+ const meta = (issue.filter.annotations?.meta ?? {}) as FilterMeta
57
+ switch (meta._tag) {
58
+ case "isMinLength":
59
+ return meta.minLength === 1
60
+ ? trans("validation.empty")
61
+ : trans("validation.string.minLength", { minLength: meta.minLength })
62
+ case "isMaxLength":
63
+ return trans("validation.string.maxLength", { maxLength: meta.maxLength })
64
+ case "isInt": {
65
+ const actual = issue.actual !== undefined ? String(issue.actual) : "NaN"
66
+ return trans("validation.integer.expected", { actualValue: actual })
67
+ }
68
+ case "isGreaterThanOrEqualTo":
69
+ return trans(
70
+ meta.minimum === 0 ? "validation.number.positive" : "validation.number.min",
71
+ { minimum: meta.minimum, isExclusive: true }
72
+ )
73
+ case "isGreaterThan":
74
+ return trans(
75
+ meta.exclusiveMinimum === 0 ? "validation.number.positive" : "validation.number.min",
76
+ { minimum: meta.exclusiveMinimum, isExclusive: false }
77
+ )
78
+ case "isLessThanOrEqualTo":
79
+ return trans("validation.number.max", { maximum: meta.maximum, isExclusive: true })
80
+ case "isLessThan":
81
+ return trans("validation.number.max", { maximum: meta.exclusiveMaximum, isExclusive: false })
82
+ default:
83
+ // Fall back to the default check hook so custom S.makeFilter messages
84
+ // (which surface as InvalidValue.annotations.message on issue.issue)
85
+ // are returned verbatim instead of getting the generic
86
+ // "Expected <filter>, got <actual>" formatter output.
87
+ return S.SchemaIssue.defaultCheckHook(issue)
88
+ }
89
+ }
90
+
91
+ return { leafHook, checkHook }
92
+ }
93
+
94
+ export const toLocalizedStandardSchemaV1 = <To, From>(
95
+ schema: S.Codec<To, From>,
96
+ trans: TransFn
97
+ ): StandardSchemaV1<From, To> => {
98
+ const { checkHook, leafHook } = makeStandardSchemaV1Hooks(trans)
99
+ return S.toStandardSchemaV1(schema, { leafHook, checkHook })
100
+ }
101
+
102
+ /*
103
+ * Effect's Standard Schema formatter handles `AnyOf` issues (produced by
104
+ * `S.Literals(...)` failures and by `S.Array` of literal unions when the
105
+ * top-level value isn't an array) by generating the message directly via
106
+ * `getExpectedMessage(...)` — *without* invoking `leafHook` / `checkHook`.
107
+ * The only override path is `findMessage(issue)`, which reads the AST's
108
+ * `message` annotation. So we walk the schema AST once at form setup and
109
+ * stamp a localized `message` annotation on:
110
+ * - Union AST whose every member is a Literal → "select"
111
+ * - Arrays AST whose `rest` is a Union of Literals → "multiple"
112
+ * Existing `message` annotations are preserved.
113
+ */
114
+ const isLiteralUnion = (ast: S.AST.AST): ast is S.AST.Union<S.AST.Literal> =>
115
+ S.AST.isUnion(ast) && ast.types.every(S.AST.isLiteral)
116
+
117
+ const walkAst = (ast: S.AST.AST, trans: TransFn): S.AST.AST => {
118
+ if (isLiteralUnion(ast)) {
119
+ if (ast.annotations?.message !== undefined) return ast
120
+ const members = ast.types.map((t) => t.literal)
121
+ return new S.AST.Union(
122
+ ast.types,
123
+ ast.mode,
124
+ {
125
+ ...ast.annotations,
126
+ message: trans("validation.not_a_valid", { type: "select", message: members.join(", ") })
127
+ },
128
+ ast.checks,
129
+ ast.encoding,
130
+ ast.context
131
+ )
132
+ }
133
+ // Mixed unions (e.g. `S.NullOr(S.Literals(...))` → Union<Null, Union<Literals>>)
134
+ // need recursion so the inner literal-union still gets annotated. We don't
135
+ // touch the outer mixed Union's own annotations.
136
+ if (S.AST.isUnion(ast)) {
137
+ const newTypes = ast.types.map((t) => walkAst(t, trans))
138
+ const changed = newTypes.some((t, i) => t !== ast.types[i])
139
+ if (!changed) return ast
140
+ return new S.AST.Union(
141
+ newTypes,
142
+ ast.mode,
143
+ ast.annotations,
144
+ ast.checks,
145
+ ast.encoding,
146
+ ast.context
147
+ )
148
+ }
149
+ if (S.AST.isArrays(ast)) {
150
+ const newRest = ast.rest.map((e) => walkAst(e, trans))
151
+ const newElements = ast.elements.map((e) => walkAst(e, trans))
152
+ let annotations = ast.annotations
153
+ if (
154
+ ast.annotations?.message === undefined
155
+ && ast.rest.length === 1
156
+ && isLiteralUnion(ast.rest[0])
157
+ ) {
158
+ const members = ast.rest[0].types.map((t) => t.literal)
159
+ annotations = {
160
+ ...ast.annotations,
161
+ message: trans("validation.not_a_valid", { type: "multiple", message: members.join(", ") })
162
+ }
163
+ }
164
+ const restChanged = newRest.some((r, i) => r !== ast.rest[i])
165
+ const elemsChanged = newElements.some((e, i) => e !== ast.elements[i])
166
+ if (!restChanged && !elemsChanged && annotations === ast.annotations) return ast
167
+ return new S.AST.Arrays(
168
+ ast.isMutable,
169
+ newElements,
170
+ newRest,
171
+ annotations,
172
+ ast.checks,
173
+ ast.encoding,
174
+ ast.context
175
+ )
176
+ }
177
+ if (S.AST.isObjects(ast)) {
178
+ const newProps = ast.propertySignatures.map((p) => {
179
+ const newType = walkAst(p.type, trans)
180
+ return newType === p.type ? p : new S.AST.PropertySignature(p.name, newType)
181
+ })
182
+ const changed = newProps.some((p, i) => p !== ast.propertySignatures[i])
183
+ if (!changed) return ast
184
+ return new S.AST.Objects(
185
+ newProps,
186
+ ast.indexSignatures,
187
+ ast.annotations,
188
+ ast.checks,
189
+ ast.encoding,
190
+ ast.context
191
+ )
192
+ }
193
+ return ast
194
+ }
195
+
196
+ export const annotateLiteralUnionMessages = <To, From>(
197
+ schema: S.Codec<To, From>,
198
+ trans: TransFn
199
+ ): S.Codec<To, From> => {
200
+ const newAst = walkAst(schema.ast, trans)
201
+ return newAst === schema.ast ? schema : S.make(newAst)
202
+ }
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 ADDED
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Supplemental CSS reset for Vuetify 4.
3
+ * Vuetify 4 removed the aggressive global reset that v3 included.
4
+ * Import this file to restore equivalent behavior:
5
+ * import '@effect-app/vue-components/reset.css'
6
+ */
7
+ @layer vuetify-reset {
8
+ body {
9
+ margin: 0;
10
+ }
11
+
12
+ ul,
13
+ ol {
14
+ margin: 0;
15
+ padding: 0;
16
+ list-style: none;
17
+ }
18
+
19
+ h1,
20
+ h2,
21
+ h3,
22
+ h4,
23
+ h5,
24
+ h6 {
25
+ margin: 0;
26
+ font-size: inherit;
27
+ font-weight: inherit;
28
+ }
29
+
30
+ p {
31
+ margin: 0;
32
+ }
33
+
34
+ input,
35
+ textarea,
36
+ select {
37
+ border: 0;
38
+ background: transparent;
39
+ }
40
+
41
+ a {
42
+ text-decoration: none;
43
+ color: inherit;
44
+ }
45
+
46
+ figure,
47
+ details,
48
+ summary {
49
+ margin: 0;
50
+ padding: 0;
51
+ }
52
+ }
@@ -1,5 +1,5 @@
1
1
  import { type makeIntl } from "@effect-app/vue"
2
- import { S } from "effect-app"
2
+ import type { S } from "effect-app"
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,157 +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 * as Fiber 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> | Fiber.Fiber<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 UnknownFieldMeta = BaseFieldMeta & {
118
- type: "unknown";
119
- };
120
- export type FieldMeta = StringFieldMeta | NumberFieldMeta | SelectFieldMeta | MultipleFieldMeta | BooleanFieldMeta | UnknownFieldMeta;
121
- export type MetaRecord<T = string> = {
122
- [K in NestedKeyOf<T>]?: FieldMeta;
123
- };
124
- export type FilterItems = {
125
- items: readonly [string, ...string[]];
126
- message: string | Effect.Effect<string, never, never> | {
127
- readonly message: string | Effect.Effect<string>;
128
- };
129
- };
130
- export type CreateMeta = {
131
- parent?: string;
132
- meta?: Record<string, any>;
133
- nullableOrUndefined?: false | "undefined" | "null";
134
- } & ({
135
- propertySignatures: readonly S.AST.PropertySignature[];
136
- property?: never;
137
- } | {
138
- propertySignatures?: never;
139
- property: S.AST.AST;
140
- });
141
- export declare const isNullableOrUndefined: (property: false | S.AST.AST | undefined) => false | "undefined" | "null";
142
- export declare const createMeta: <T = any>({ meta, parent, property, propertySignatures }: CreateMeta, acc?: Partial<MetaRecord<T>>) => MetaRecord<T> | FieldMeta;
143
- export declare const duplicateSchema: <From, To>(schema: S.Codec<To, From, never>) => S.Codec<To, From, never, never>;
144
- export declare const generateMetaFromSchema: <From, To>(schema: S.Codec<To, From, never>) => {
145
- schema: S.Codec<To, From, never>;
146
- meta: MetaRecord<To>;
147
- unionMeta: Record<string, MetaRecord<To>>;
148
- };
149
- export declare const generateInputStandardSchemaFromFieldMeta: (meta: FieldMeta, trans?: ReturnType<typeof useIntl>["trans"]) => StandardSchemaV1<any, any>;
150
- export declare const nullableInput: <A, I, R>(schema: S.Codec<A, I, R>, _defaultValue: () => A) => any;
151
- export type OmegaAutoGenMeta<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>> = Omit<OmegaInputProps<From, To, Name>, "form">;
152
- declare const supportedInputs: readonly ["button", "checkbox", "color", "date", "email", "number", "password", "radio", "range", "search", "submit", "tel", "text", "time", "url"];
153
- export type SupportedInputs = typeof supportedInputs[number];
154
- export declare const getInputType: (input: string) => SupportedInputs;
155
- export declare function deepMerge(target: any, source: any): any;
156
- export declare const defaultsValueFromSchema: (schema: S.Schema<any>, record?: Record<string, any>) => any;
157
- export {};
@@ -1 +0,0 @@
1
- export {};