@krizaka/ui 3.0.0 → 3.2.0

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 (310) hide show
  1. package/README.md +1 -1
  2. package/dist/achievement.js +1 -1
  3. package/dist/action-bar.js +1 -1
  4. package/dist/app-shell.js +1 -1
  5. package/dist/argument-card.js +2 -2
  6. package/dist/card-grid.js +1 -1
  7. package/dist/card.js +1 -1
  8. package/dist/choice-grid.js +1 -1
  9. package/dist/{chunk-OGJI5X4W.js → chunk-2PUDI7JS.js} +2 -2
  10. package/dist/chunk-4LOMIQVX.js +21 -0
  11. package/dist/chunk-4LOMIQVX.js.map +1 -0
  12. package/dist/{chunk-K3SWZXYT.js → chunk-DGQMDJXK.js} +2 -2
  13. package/dist/chunk-G3ETON2A.js +22 -0
  14. package/dist/chunk-G3ETON2A.js.map +1 -0
  15. package/dist/chunk-I5RVM5CW.js +27 -0
  16. package/dist/chunk-I5RVM5CW.js.map +1 -0
  17. package/dist/chunk-IZ7MV6HM.js +26 -0
  18. package/dist/chunk-IZ7MV6HM.js.map +1 -0
  19. package/dist/chunk-ZNMFG62E.js +20 -0
  20. package/dist/chunk-ZNMFG62E.js.map +1 -0
  21. package/dist/cn.d.ts +9 -1
  22. package/dist/cn.js +5 -3
  23. package/dist/code-block.js +1 -1
  24. package/dist/command.js +1 -1
  25. package/dist/confirm-button.js +1 -1
  26. package/dist/continue-prompt.js +1 -1
  27. package/dist/cta-panel.js +1 -1
  28. package/dist/data-table.js +2 -2
  29. package/dist/date-picker.d.ts +650 -61
  30. package/dist/date-picker.js +918 -122
  31. package/dist/date-picker.js.map +1 -1
  32. package/dist/decision-list.js +1 -1
  33. package/dist/dropdown-menu.js +1 -1
  34. package/dist/error-page.js +1 -1
  35. package/dist/field.js +1 -1
  36. package/dist/filter-bar.js +2 -2
  37. package/dist/form/server.d.ts +96 -0
  38. package/dist/form/server.js +82 -0
  39. package/dist/form/server.js.map +1 -0
  40. package/dist/form.d.ts +503 -0
  41. package/dist/form.js +760 -0
  42. package/dist/form.js.map +1 -0
  43. package/dist/gallery-page.js +1 -1
  44. package/dist/glow-card.js +1 -1
  45. package/dist/goal-gauge.js +1 -1
  46. package/dist/how-it-works-page.js +1 -1
  47. package/dist/landscape.js +1 -1
  48. package/dist/link-card.js +1 -1
  49. package/dist/longform-page.js +1 -1
  50. package/dist/marquee.js +1 -1
  51. package/dist/mascot-quote.js +1 -1
  52. package/dist/motion.css +18 -1
  53. package/dist/native/form.d.ts +376 -0
  54. package/dist/native/form.js +650 -0
  55. package/dist/native/form.js.map +1 -0
  56. package/dist/native.d.ts +351 -3
  57. package/dist/native.js +1205 -399
  58. package/dist/native.js.map +1 -1
  59. package/dist/nav-bar.js +1 -1
  60. package/dist/page-hero.js +2 -2
  61. package/dist/page.js +2 -2
  62. package/dist/popover.js +1 -1
  63. package/dist/pricing-page.js +1 -1
  64. package/dist/product-page.js +1 -1
  65. package/dist/profile-card.js +1 -1
  66. package/dist/promise-card.js +1 -1
  67. package/dist/scroll-stage.js +1 -1
  68. package/dist/stage-banner.js +1 -1
  69. package/dist/terminal-replay.js +1 -1
  70. package/dist/toast.js +1 -1
  71. package/dist/toc.js +1 -1
  72. package/dist/tooltip.js +1 -1
  73. package/package.json +50 -7
  74. package/registry/achievement.json +1 -1
  75. package/registry/action-bar.json +1 -1
  76. package/registry/alert.json +1 -1
  77. package/registry/app-shell.json +1 -1
  78. package/registry/argument-card.json +1 -1
  79. package/registry/audio-player.json +1 -1
  80. package/registry/auth-layout.json +1 -1
  81. package/registry/avatar.json +1 -1
  82. package/registry/badge.json +1 -1
  83. package/registry/button.json +1 -1
  84. package/registry/card-grid.json +1 -1
  85. package/registry/card.json +1 -1
  86. package/registry/catalogue-page.json +1 -1
  87. package/registry/changelog-page.json +1 -1
  88. package/registry/checkbox.json +89 -4
  89. package/registry/chip-link.json +1 -1
  90. package/registry/chip.json +1 -1
  91. package/registry/choice-grid.json +1 -1
  92. package/registry/cn.json +1 -1
  93. package/registry/code-block.json +1 -1
  94. package/registry/combobox.json +1 -1
  95. package/registry/command.json +1 -1
  96. package/registry/component-page.json +1 -1
  97. package/registry/confirm-button.json +1 -1
  98. package/registry/contact-page.json +1 -1
  99. package/registry/continue-prompt.json +1 -1
  100. package/registry/countdown.json +1 -1
  101. package/registry/cta-panel.json +1 -1
  102. package/registry/dashboard-layout.json +1 -1
  103. package/registry/data-table.json +1 -1
  104. package/registry/date-picker.json +1811 -236
  105. package/registry/decision-list.json +1 -1
  106. package/registry/detail-layout.json +1 -1
  107. package/registry/dialog.json +1 -1
  108. package/registry/docs-article-page.json +1 -1
  109. package/registry/docs-hub-page.json +1 -1
  110. package/registry/docs-layout.json +1 -1
  111. package/registry/dropdown-menu.json +1 -1
  112. package/registry/empty-state.json +1 -1
  113. package/registry/error-page.json +1 -1
  114. package/registry/examples/checkbox/native/terms.d.ts +4 -0
  115. package/registry/examples/checkbox/native/terms.dark.png +0 -0
  116. package/registry/examples/checkbox/native/terms.js +26 -0
  117. package/registry/examples/checkbox/native/terms.light.png +0 -0
  118. package/registry/examples/checkbox/native/terms.tsx +28 -0
  119. package/registry/examples/date-picker/birth-date-wheel.d.ts +4 -0
  120. package/registry/examples/date-picker/birth-date-wheel.js +13 -0
  121. package/registry/examples/date-picker/birth-date-wheel.tsx +11 -0
  122. package/registry/examples/date-picker/birth-date.d.ts +4 -0
  123. package/registry/examples/date-picker/birth-date.js +25 -0
  124. package/registry/examples/date-picker/birth-date.tsx +21 -0
  125. package/registry/examples/date-picker/calendar.js +1 -1
  126. package/registry/examples/date-picker/calendar.tsx +2 -6
  127. package/registry/examples/date-picker/day-strip.d.ts +4 -0
  128. package/registry/examples/date-picker/day-strip.js +28 -0
  129. package/registry/examples/date-picker/day-strip.tsx +27 -0
  130. package/registry/examples/date-picker/month-year.d.ts +4 -0
  131. package/registry/examples/date-picker/month-year.js +13 -0
  132. package/registry/examples/date-picker/month-year.tsx +10 -0
  133. package/registry/examples/date-picker/native/birth-date-wheel.d.ts +4 -0
  134. package/registry/examples/date-picker/native/birth-date-wheel.dark.png +0 -0
  135. package/registry/examples/date-picker/native/birth-date-wheel.js +13 -0
  136. package/registry/examples/date-picker/native/birth-date-wheel.light.png +0 -0
  137. package/registry/examples/date-picker/native/birth-date-wheel.tsx +9 -0
  138. package/registry/examples/date-picker/native/birth-date.d.ts +4 -0
  139. package/registry/examples/date-picker/native/birth-date.dark.png +0 -0
  140. package/registry/examples/date-picker/native/birth-date.js +30 -0
  141. package/registry/examples/date-picker/native/birth-date.light.png +0 -0
  142. package/registry/examples/date-picker/native/birth-date.tsx +27 -0
  143. package/registry/examples/date-picker/native/calendar.d.ts +4 -0
  144. package/registry/examples/date-picker/native/calendar.dark.png +0 -0
  145. package/registry/examples/date-picker/native/calendar.js +13 -0
  146. package/registry/examples/date-picker/native/calendar.light.png +0 -0
  147. package/registry/examples/date-picker/native/calendar.tsx +8 -0
  148. package/registry/examples/date-picker/native/day-strip.d.ts +4 -0
  149. package/registry/examples/date-picker/native/day-strip.dark.png +0 -0
  150. package/registry/examples/date-picker/native/day-strip.js +29 -0
  151. package/registry/examples/date-picker/native/day-strip.light.png +0 -0
  152. package/registry/examples/date-picker/native/day-strip.tsx +26 -0
  153. package/registry/examples/date-picker/native/month-year.d.ts +4 -0
  154. package/registry/examples/date-picker/native/month-year.dark.png +0 -0
  155. package/registry/examples/date-picker/native/month-year.js +13 -0
  156. package/registry/examples/date-picker/native/month-year.light.png +0 -0
  157. package/registry/examples/date-picker/native/month-year.tsx +8 -0
  158. package/registry/examples/date-picker/native/time-slots.d.ts +4 -0
  159. package/registry/examples/date-picker/native/time-slots.dark.png +0 -0
  160. package/registry/examples/date-picker/native/time-slots.js +15 -0
  161. package/registry/examples/date-picker/native/time-slots.light.png +0 -0
  162. package/registry/examples/date-picker/native/time-slots.tsx +15 -0
  163. package/registry/examples/date-picker/native/time-wheel.d.ts +4 -0
  164. package/registry/examples/date-picker/native/time-wheel.dark.png +0 -0
  165. package/registry/examples/date-picker/native/time-wheel.js +13 -0
  166. package/registry/examples/date-picker/native/time-wheel.light.png +0 -0
  167. package/registry/examples/date-picker/native/time-wheel.tsx +8 -0
  168. package/registry/examples/date-picker/time-slots.d.ts +4 -0
  169. package/registry/examples/date-picker/time-slots.js +26 -0
  170. package/registry/examples/date-picker/time-slots.tsx +25 -0
  171. package/registry/examples/date-picker/time-wheel.d.ts +4 -0
  172. package/registry/examples/date-picker/time-wheel.js +13 -0
  173. package/registry/examples/date-picker/time-wheel.tsx +10 -0
  174. package/registry/examples/date-picker/wheel.d.ts +4 -0
  175. package/registry/examples/date-picker/wheel.js +14 -0
  176. package/registry/examples/date-picker/wheel.tsx +16 -0
  177. package/registry/examples/field/native/default.d.ts +4 -0
  178. package/registry/examples/field/native/default.dark.png +0 -0
  179. package/registry/examples/field/native/default.js +29 -0
  180. package/registry/examples/field/native/default.light.png +0 -0
  181. package/registry/examples/field/native/default.tsx +23 -0
  182. package/registry/examples/form/amount.d.ts +4 -0
  183. package/registry/examples/form/amount.js +30 -0
  184. package/registry/examples/form/amount.tsx +36 -0
  185. package/registry/examples/form/audience.d.ts +4 -0
  186. package/registry/examples/form/audience.js +29 -0
  187. package/registry/examples/form/audience.tsx +31 -0
  188. package/registry/examples/form/native/amount.d.ts +4 -0
  189. package/registry/examples/form/native/amount.dark.png +0 -0
  190. package/registry/examples/form/native/amount.js +26 -0
  191. package/registry/examples/form/native/amount.light.png +0 -0
  192. package/registry/examples/form/native/amount.tsx +30 -0
  193. package/registry/examples/form/native/audience.d.ts +4 -0
  194. package/registry/examples/form/native/audience.dark.png +0 -0
  195. package/registry/examples/form/native/audience.js +24 -0
  196. package/registry/examples/form/native/audience.light.png +0 -0
  197. package/registry/examples/form/native/audience.tsx +24 -0
  198. package/registry/examples/form/native/profile.d.ts +4 -0
  199. package/registry/examples/form/native/profile.dark.png +0 -0
  200. package/registry/examples/form/native/profile.js +33 -0
  201. package/registry/examples/form/native/profile.light.png +0 -0
  202. package/registry/examples/form/native/profile.tsx +36 -0
  203. package/registry/examples/form/native/settings.d.ts +4 -0
  204. package/registry/examples/form/native/settings.dark.png +0 -0
  205. package/registry/examples/form/native/settings.js +25 -0
  206. package/registry/examples/form/native/settings.light.png +0 -0
  207. package/registry/examples/form/native/settings.tsx +23 -0
  208. package/registry/examples/form/native/sign-up.d.ts +4 -0
  209. package/registry/examples/form/native/sign-up.dark.png +0 -0
  210. package/registry/examples/form/native/sign-up.js +38 -0
  211. package/registry/examples/form/native/sign-up.light.png +0 -0
  212. package/registry/examples/form/native/sign-up.tsx +34 -0
  213. package/registry/examples/form/native/upload.d.ts +4 -0
  214. package/registry/examples/form/native/upload.dark.png +0 -0
  215. package/registry/examples/form/native/upload.js +23 -0
  216. package/registry/examples/form/native/upload.light.png +0 -0
  217. package/registry/examples/form/native/upload.tsx +22 -0
  218. package/registry/examples/form/profile.d.ts +4 -0
  219. package/registry/examples/form/profile.js +35 -0
  220. package/registry/examples/form/profile.tsx +40 -0
  221. package/registry/examples/form/report.d.ts +4 -0
  222. package/registry/examples/form/report.js +30 -0
  223. package/registry/examples/form/report.tsx +30 -0
  224. package/registry/examples/form/settings.d.ts +4 -0
  225. package/registry/examples/form/settings.js +30 -0
  226. package/registry/examples/form/settings.tsx +31 -0
  227. package/registry/examples/form/sign-up.d.ts +4 -0
  228. package/registry/examples/form/sign-up.js +38 -0
  229. package/registry/examples/form/sign-up.tsx +37 -0
  230. package/registry/examples/form/upload.d.ts +4 -0
  231. package/registry/examples/form/upload.js +32 -0
  232. package/registry/examples/form/upload.tsx +32 -0
  233. package/registry/field.json +104 -4
  234. package/registry/file-upload.json +1 -1
  235. package/registry/filter-bar.json +1 -1
  236. package/registry/form.json +2940 -0
  237. package/registry/gallery-page.json +1 -1
  238. package/registry/glow-card.json +1 -1
  239. package/registry/goal-gauge.json +1 -1
  240. package/registry/how-it-works-page.json +1 -1
  241. package/registry/image-cropper.json +1 -1
  242. package/registry/index.json +43 -10
  243. package/registry/iso.json +1 -1
  244. package/registry/kbd.json +1 -1
  245. package/registry/landing-page.json +1 -1
  246. package/registry/landscape.json +1 -1
  247. package/registry/legal-page.json +1 -1
  248. package/registry/link-card.json +1 -1
  249. package/registry/loader.json +1 -1
  250. package/registry/longform-page.json +1 -1
  251. package/registry/marketing-layout.json +1 -1
  252. package/registry/marquee.json +1 -1
  253. package/registry/mascot-quote.json +1 -1
  254. package/registry/mascot-state.json +2 -2
  255. package/registry/mascots.json +2 -2
  256. package/registry/media-capture.json +1 -1
  257. package/registry/meter.json +1 -1
  258. package/registry/nav-bar.json +1 -1
  259. package/registry/number-ticker.json +1 -1
  260. package/registry/page-header.json +1 -1
  261. package/registry/page-hero.json +1 -1
  262. package/registry/page.json +1 -1
  263. package/registry/pagination.json +1 -1
  264. package/registry/pointer-light.json +1 -1
  265. package/registry/popover.json +1 -1
  266. package/registry/pricing-page.json +1 -1
  267. package/registry/product-page.json +1 -1
  268. package/registry/profile-card.json +1 -1
  269. package/registry/progress.json +1 -1
  270. package/registry/promise-card.json +1 -1
  271. package/registry/radio-group.json +1 -1
  272. package/registry/scroll-stage.json +1 -1
  273. package/registry/search-field.json +1 -1
  274. package/registry/section-backdrop.json +1 -1
  275. package/registry/separator.json +1 -1
  276. package/registry/settings-layout.json +1 -1
  277. package/registry/skeleton.json +1 -1
  278. package/registry/slider.json +1 -1
  279. package/registry/slot.json +1 -1
  280. package/registry/spinner.json +1 -1
  281. package/registry/split-view.json +1 -1
  282. package/registry/stage-banner.json +1 -1
  283. package/registry/stat.json +1 -1
  284. package/registry/status-page.json +1 -1
  285. package/registry/stepper.json +1 -1
  286. package/registry/switch.json +1 -1
  287. package/registry/tabs.json +1 -1
  288. package/registry/tag-input.json +1 -1
  289. package/registry/terminal-replay.json +1 -1
  290. package/registry/theme.json +8 -1
  291. package/registry/toast.json +1 -1
  292. package/registry/toc.json +1 -1
  293. package/registry/tooltip.json +1 -1
  294. package/registry/video-player.json +1 -1
  295. package/registry/video-trimmer.json +1 -1
  296. package/registry/virtual.json +1 -1
  297. package/skills/date-picker/SKILL.md +43 -0
  298. package/skills/form/SKILL.md +44 -0
  299. package/dist/chunk-2USC2YT6.js +0 -17
  300. package/dist/chunk-2USC2YT6.js.map +0 -1
  301. package/dist/chunk-5AXLA4LK.js +0 -13
  302. package/dist/chunk-5AXLA4LK.js.map +0 -1
  303. package/dist/chunk-FJDSLNXK.js +0 -11
  304. package/dist/chunk-FJDSLNXK.js.map +0 -1
  305. package/dist/chunk-KNBYZGSQ.js +0 -11
  306. package/dist/chunk-KNBYZGSQ.js.map +0 -1
  307. package/dist/chunk-VCAAHCHL.js +0 -17
  308. package/dist/chunk-VCAAHCHL.js.map +0 -1
  309. /package/dist/{chunk-OGJI5X4W.js.map → chunk-2PUDI7JS.js.map} +0 -0
  310. /package/dist/{chunk-K3SWZXYT.js.map → chunk-DGQMDJXK.js.map} +0 -0
@@ -0,0 +1,376 @@
1
+ import { AnyFieldApi, StandardSchemaV1, DeepKeys, AnyFormApi } from '@tanstack/react-form';
2
+ import * as React from 'react';
3
+ import { DateFieldLabels, BrandId, TextFieldProps as TextFieldProps$1 } from '@krizaka/ui/native';
4
+ import { StyleProp, ViewStyle } from 'react-native';
5
+
6
+ /** A value a message placeholder takes (`{minimum}`, `{suggestion}`). */
7
+ type FormMessageValue = string | number;
8
+ /** An error of a field or of the whole form: the key of its words in the app's catalogue, and what fills them in. */
9
+ interface FormFieldError {
10
+ /** The i18n key: `form.errors.required`, or the key a schema names (`z.string().min(3, "signUp.username.short")`). */
11
+ key: string;
12
+ /** The placeholders of the message (`{ minimum: 3 }`). */
13
+ values?: Readonly<Record<string, FormMessageValue>>;
14
+ /** The server's own words, in English: shown only when the catalogue has no message for the key. */
15
+ message?: string;
16
+ /** A value to offer instead (a free username): a button under the error sets it. Its label is passed translated. */
17
+ suggestion?: {
18
+ readonly label: string;
19
+ readonly value: unknown;
20
+ };
21
+ /** Shown at once, while the person types (an availability check), not only once they leave the field. */
22
+ immediate?: boolean;
23
+ /** Where it comes from: the schema (default), a field's check, or the server's answer (kept until the field changes). */
24
+ source?: "schema" | "check" | "server";
25
+ }
26
+ /** The English defaults of the generic errors, by code — the words a form shows when the app's catalogue has none. */
27
+ declare const formMessages: Readonly<Record<string, string>>;
28
+ /** How a form finds its words: the app's translate function, and the prefixes of its keys. */
29
+ interface FormI18n {
30
+ /** The app's translate function (`(key, values) => t(key, values)`): a string, or `undefined` when the key is missing. */
31
+ t?: (key: string, values?: Readonly<Record<string, FormMessageValue>>) => string | undefined;
32
+ /** The prefix of the generic field errors. Default `form.errors` (→ `form.errors.tooShort`). */
33
+ prefix?: string;
34
+ /** The prefix of the server's codes for the whole form, as `KrizakaApiError.messageKey()`. Default `apiErrors`. */
35
+ apiPrefix?: string;
36
+ /** The locale of numbers, money and dates. Default `en`. */
37
+ locale?: string;
38
+ }
39
+ /** The words of an error: the app's catalogue, else the English default of its code, else the server's words, else the key. */
40
+ declare function formMessage(error: FormFieldError | string, i18n?: FormI18n): string;
41
+ /**
42
+ * A refusal the form shows, serialisable (a Server Action returns it): the shape of `KrizakaApiError` of @krizaka/query —
43
+ * a `KrizakaApiError` *is* a `FormProblem`. `fields` go under their fields, the rest above the submit button.
44
+ */
45
+ interface FormProblem {
46
+ /** The HTTP status (0 when no response arrived). */
47
+ status?: number;
48
+ /** The stable code of the refusal (`rate-limited`, `conflict`, `ACCOUNT_EXISTS`): the key of its words. */
49
+ code?: string;
50
+ /** The server's sentence, in English: shown only when the catalogue has no message for the code. */
51
+ detail?: string;
52
+ /** The refused fields, by name: a server's `{ code, message }`, or an error the form already knows (`key`). */
53
+ fields?: Readonly<Record<string, {
54
+ code?: string;
55
+ message: string;
56
+ } | FormFieldError | string>>;
57
+ /** Epoch ms before which the same call is refused (a 429). */
58
+ retryAt?: number;
59
+ }
60
+
61
+ /** A schema the form validates with: any Standard Schema — zod 4 (`z.object`), valibot, arktype. */
62
+ type FormSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;
63
+ /** The values a form holds: the schema's input. */
64
+ type FormValues<S> = S extends {
65
+ readonly "~standard": {
66
+ readonly types?: {
67
+ readonly input: infer I;
68
+ };
69
+ };
70
+ } ? I : never;
71
+ /** The values a form sends: the schema's output (zod transforms applied). */
72
+ type FormOutput<S> = S extends {
73
+ readonly "~standard": {
74
+ readonly types?: {
75
+ readonly output: infer O;
76
+ };
77
+ };
78
+ } ? O : never;
79
+ /** A field's name: `email`, `address.city`, `links[0].url`. */
80
+ type FieldName<V> = DeepKeys<V> & string;
81
+ /** What a Server Action (or any submit) answers: done, or a refusal the form shows. */
82
+ type FormActionResult<T = unknown> = {
83
+ ok: true;
84
+ data?: T;
85
+ } | {
86
+ ok: false;
87
+ problem: FormProblem;
88
+ };
89
+ /** A value checked on the server as it is typed: an error (or its key), or nothing when the value is fine. */
90
+ type FieldCheck<T = unknown> = (value: T, signal: AbortSignal) => Promise<FormFieldError | string | null | undefined> | FormFieldError | string | null | undefined;
91
+ interface KrizakaFormDefinition<S extends FormSchema> {
92
+ /** The schema of the values (zod 4): the same one the server parses with. */
93
+ schema: S;
94
+ /** The values at first: every field of the schema. */
95
+ defaultValues: FormValues<S>;
96
+ /** The words: the app's translate function, the key prefixes, the locale. */
97
+ i18n?: FormI18n;
98
+ }
99
+ interface UseKrizakaFormOptions<S extends FormSchema, R = unknown> {
100
+ /** Sends the values (the schema's output): a mutation of @krizaka/query, a Server Action. Throw a `KrizakaApiError` or
101
+ * return `{ ok: false, problem }` to refuse: its `fields` go under their fields, the rest above the button. */
102
+ onSubmit?: (values: FormOutput<S>) => R | Promise<R>;
103
+ /** Called after a successful submit with what `onSubmit` returned (`data` of a `{ ok: true, data }`). */
104
+ onSuccess?: (result: R extends FormActionResult<infer T> ? T | undefined : R) => void;
105
+ /** Values that replace the definition's (a profile loaded from the server). */
106
+ defaultValues?: FormValues<S>;
107
+ /** Overrides the definition's words (the translate function of a hook). */
108
+ i18n?: FormI18n;
109
+ /** The server's codes that belong to a field (`{ UNDERAGE: "dateOfBirth", USERNAME_RESERVED: "username" }`): a refusal
110
+ * with that code shows under the field, as `form.errors.<CODE>`, instead of above the button. */
111
+ codeFields?: Readonly<Record<string, string>>;
112
+ }
113
+ /** The state of a form, for its fields and its button. */
114
+ interface FormContextValue {
115
+ /** TanStack's form, through the facade: never import @tanstack/* in a product. */
116
+ readonly api: AnyFormApi;
117
+ readonly i18n: FormI18n;
118
+ /** The whole form's error (a refusal without a field), or null. */
119
+ readonly error: FormFieldError | null;
120
+ /** Sends the form: validates, focuses (web) or announces (native) the first error, else calls `onSubmit`. */
121
+ readonly submit: () => Promise<boolean>;
122
+ }
123
+ /** The form around a field: inside `form.Form`. */
124
+ declare function useFormContext(): FormContextValue;
125
+ interface FieldOptions<T> {
126
+ /** Checks the value on the server as it is typed (a username's availability): debounced, aborted when it changes. */
127
+ validateAsync?: FieldCheck<T>;
128
+ /** The wait, in ms, between the last change and `validateAsync`. Default 350. */
129
+ asyncDebounceMs?: number;
130
+ }
131
+ /** A field as its component draws it: the value, its setter, its error in words, its state. */
132
+ interface KrizakaField<T = unknown> {
133
+ /** The id of the control (`htmlFor` of its label). */
134
+ readonly id: string;
135
+ readonly name: string;
136
+ readonly value: T;
137
+ /** Sets the value (clears a refusal of the server on it). */
138
+ setValue(value: T): void;
139
+ /** Call when the control loses focus: from then on, its errors show. */
140
+ readonly onBlur: () => void;
141
+ /** The error to show, in words — only once it should show. */
142
+ readonly error: string | undefined;
143
+ /** The error itself, with its suggestion. */
144
+ readonly errorDetail: FormFieldError | undefined;
145
+ /** A check (`validateAsync`) is running. */
146
+ readonly validating: boolean;
147
+ /** The check passed for the current value. */
148
+ readonly available: boolean;
149
+ /** The ids of the hint and the error (`aria-describedby`). */
150
+ readonly hintId: string;
151
+ readonly errorId: string;
152
+ /** The form's locale (numbers, money, dates). */
153
+ readonly locale: string;
154
+ /** TanStack's field, through the facade. */
155
+ readonly api: AnyFieldApi;
156
+ }
157
+ /** Binds a field of the form around it (inside `form.Form`): what the platform's field components are made of. */
158
+ declare function useKrizakaField<T = unknown>(name: string, options?: FieldOptions<T>): KrizakaField<T>;
159
+ /** The array of a field array, with its operations (`form.FieldArray`). */
160
+ interface KrizakaFieldArray<T = unknown> {
161
+ readonly name: string;
162
+ readonly items: readonly T[];
163
+ /** Adds an item at the end. */
164
+ readonly push: (item: T) => void;
165
+ /** Removes the item at `index`. */
166
+ readonly remove: (index: number) => void;
167
+ /** Moves an item. */
168
+ readonly move: (from: number, to: number) => void;
169
+ /** The name of a sub-field of an item: `name(0, "url")` → `links[0].url`. */
170
+ readonly fieldName: (index: number, key?: string) => string;
171
+ /** The error of the array itself (too few, too many), in words, once it should show. */
172
+ readonly error: string | undefined;
173
+ }
174
+ /** Binds an array of the form (a list of links, of tiers): its items and their operations. */
175
+ declare function useKrizakaFieldArray<T = unknown>(name: string): KrizakaFieldArray<T>;
176
+ /** The value of a field, kept up to date (`form.Watch`): show a part of the form only when a box is ticked. */
177
+ declare function useFormValue<T = unknown>(name: string): T;
178
+ /** The state of the submit, for a button: sending, and whether the last try succeeded. */
179
+ declare function useFormStatus(): {
180
+ submitting: boolean;
181
+ succeeded: boolean;
182
+ attempts: number;
183
+ };
184
+ /** The platform's components, typed by the form's field names: `name` completes and is checked against the schema. */
185
+ type BoundFields<C, N extends string> = {
186
+ [K in keyof C]: C[K] extends (props: infer P) => infer R ? (P extends {
187
+ name: string;
188
+ } ? (props: Omit<P, "name"> & {
189
+ name: N;
190
+ }) => R : C[K]) : C[K];
191
+ };
192
+ /** A form in a component: its fields (typed by the schema), its submit and its state. */
193
+ type KrizakaFormInstance<S extends FormSchema, C, RootProps> = BoundFields<C, FieldName<FormValues<S>>> & {
194
+ /** The form element (web) or view (native): renders its fields and provides them the form. */
195
+ Form: (props: RootProps) => React.ReactElement;
196
+ /** Sends the form (what `Submit` does): `true` when it went through. */
197
+ submit: () => Promise<boolean>;
198
+ /** Back to the default values (or the given ones), errors cleared. */
199
+ reset: (values?: FormValues<S>) => void;
200
+ /** Sets a field's value from outside (a suggestion, a preset). */
201
+ setValue: (name: FieldName<FormValues<S>>, value: unknown) => void;
202
+ /** The values now. */
203
+ getValues: () => FormValues<S>;
204
+ /** The whole form's error (a refusal without a field), or null. */
205
+ error: FormFieldError | null;
206
+ /** TanStack's form, the escape hatch — never import @tanstack/* in a product. */
207
+ api: AnyFormApi;
208
+ };
209
+ /** A form defined once (schema + defaults), used in components: `signUp.useForm({ onSubmit })`. */
210
+ interface KrizakaFormFactory<S extends FormSchema, C, RootProps> {
211
+ readonly schema: S;
212
+ readonly defaultValues: FormValues<S>;
213
+ /** The form in a component: `onSubmit` sends the values (a mutation), a thrown `KrizakaApiError` lands on the fields. */
214
+ useForm<R = unknown>(options?: UseKrizakaFormOptions<S, R>): KrizakaFormInstance<S, C, RootProps>;
215
+ /** The form sent by a Server Action: it receives the values and answers `{ ok: true, data }` or `{ ok: false, problem }`. */
216
+ useFormWithAction<T = unknown>(action: (values: FormOutput<S>) => Promise<FormActionResult<T>>, options?: Omit<UseKrizakaFormOptions<S, FormActionResult<T>>, "onSubmit">): KrizakaFormInstance<S, C, RootProps>;
217
+ }
218
+
219
+ /** True for a real calendar date written `YYYY-MM-DD` (not `2001-02-30`). */
220
+ declare function isRealDate(value: string): boolean;
221
+ /** The latest date of birth of someone `age` years old today (`YYYY-MM-DD`): an age gate's `max`, `value <= latestBirthDate(18)`. */
222
+ declare function latestBirthDate(age: number, today?: Date): string;
223
+
224
+ type Base = {
225
+ /** The field's name in the schema (typed by the form). */
226
+ name: string;
227
+ /** The visible label, passed translated (also the accessible name). */
228
+ label: string;
229
+ /** A help text under the control; the error takes its place when there is one. */
230
+ hint?: string;
231
+ /** Not available. */
232
+ disabled?: boolean;
233
+ /** Styles merged last, on the field. */
234
+ style?: StyleProp<ViewStyle>;
235
+ };
236
+ type FormProps = {
237
+ /** The fields, the error and the button. */
238
+ children?: React.ReactNode;
239
+ /** The form's accessible name ("Create your account"), passed translated. */
240
+ "aria-label"?: string;
241
+ /** The form is the screen's scrolling content: it moves above the keyboard (iOS), keeps the focused field in view, and
242
+ * a tap on a button works while the keyboard is open. Give the form `flex: 1` room (a screen). */
243
+ scroll?: boolean;
244
+ /** Styles merged last, on the form's view — or its scrolled content (a column with a 16-pt gap by default). */
245
+ style?: StyleProp<ViewStyle>;
246
+ };
247
+ type SubmitProps = {
248
+ /** The button's words, passed translated ("Create my account"). */
249
+ label: string;
250
+ /** The look. Default `primary`. */
251
+ variant?: "primary" | "gradient" | "secondary" | "outline" | "ghost" | "danger";
252
+ /** The product whose animated mark turns in the button while the form is sent (the brand's loader); the system's spinner otherwise. */
253
+ brand?: BrandId;
254
+ /** Styles merged last, on the button. */
255
+ style?: StyleProp<ViewStyle>;
256
+ };
257
+ /** Sends the form: busy while it is sent (the product's mark turning, or a spinner); a refused submit announces its first error. */
258
+ declare function Submit({ label, variant, brand, style }: SubmitProps): React.JSX.Element;
259
+ type FormErrorProps = {
260
+ /** A headline above the message, passed translated. */
261
+ title?: string;
262
+ /** Styles merged last. */
263
+ style?: StyleProp<ViewStyle>;
264
+ };
265
+ /** The whole form's error — a refusal that belongs to no field (a conflict, too many tries, no network). */
266
+ declare function FormError({ title, style }: FormErrorProps): React.JSX.Element | null;
267
+ type TextFieldProps = Base & Pick<TextFieldProps$1, "secureTextEntry" | "keyboardType" | "autoComplete" | "autoCapitalize" | "autoCorrect" | "textContentType" | "returnKeyType" | "onSubmitEditing" | "placeholder" | "maxLength" | "inputRef"> & {
268
+ /** Cleans what is typed before it is stored (`(v) => v.toLowerCase()`). */
269
+ transform?: (raw: string) => string;
270
+ /** Checks the value on the server as it is typed (availability): an error key, or nothing when it is fine. */
271
+ validateAsync?: FieldCheck<string>;
272
+ /** The wait, in ms, before `validateAsync`. Default 350. */
273
+ asyncDebounceMs?: number;
274
+ /** The words once `validateAsync` accepted the value ("@eric is free"), passed translated. */
275
+ availableHint?: string;
276
+ /** The name of the wait while it checks ("Checking"), passed translated. */
277
+ checkingLabel?: string;
278
+ };
279
+ /** A text field of the form: its label, the input, the hint or the error, an optional check on the server. */
280
+ declare function TextField({ name, label, hint, disabled, style, transform, validateAsync, asyncDebounceMs, availableHint, checkingLabel, ...input }: TextFieldProps): React.JSX.Element;
281
+ type TextAreaProps = Base & {
282
+ /** An example, passed translated. */
283
+ placeholder?: string;
284
+ /** The most characters. */
285
+ maxLength?: number;
286
+ };
287
+ /** A longer text of the form (a bio, a description, a report). */
288
+ declare function TextArea({ name, label, hint, disabled, style, ...input }: TextAreaProps): React.JSX.Element;
289
+ type CheckboxProps = Omit<Base, "label" | "hint"> & {
290
+ /** The words next to the box: text, or a `Txt` with links inside (then name it with `accessibleLabel`). */
291
+ label: React.ReactNode;
292
+ /** The accessible name when `label` is not plain text, passed translated. */
293
+ accessibleLabel?: string;
294
+ };
295
+ /** A box of the form (`boolean`): terms to accept, an option. */
296
+ declare function Checkbox({ name, label, accessibleLabel, disabled, style }: CheckboxProps): React.JSX.Element;
297
+ /** An on/off setting of the form (`boolean`): its label and hint beside the system's switch. */
298
+ declare function Switch({ name, label, hint, disabled, style }: Base): React.JSX.Element;
299
+ /** A choice of the form: the value stored and its words (passed translated). */
300
+ type FormOption = {
301
+ value: string;
302
+ label: string;
303
+ disabled?: boolean;
304
+ };
305
+ type RadioGroupProps = Base & {
306
+ /** The choices, as chips (one chosen). */
307
+ options: readonly FormOption[];
308
+ /** Scrolls the chips sideways instead of wrapping them (many choices). */
309
+ scrollable?: boolean;
310
+ };
311
+ /** One choice among a few, as chips (a radio group). On native, `Select` is the same control. */
312
+ declare function RadioGroup({ name, label, hint, disabled, style, options, scrollable }: RadioGroupProps): React.JSX.Element;
313
+ /** One choice among several (the web's `<select>`): chips on native, scrolled sideways when they are many. */
314
+ declare function Select(props: RadioGroupProps): React.JSX.Element;
315
+ type DateFieldProps = Base & {
316
+ /** The names of the boxes (`day`, `month`, `year`), passed translated. */
317
+ labels?: Partial<DateFieldLabels>;
318
+ /** `bday` for a date of birth. */
319
+ autoComplete?: "bday" | "off";
320
+ };
321
+ /** A date of the form (`YYYY-MM-DD`): day, month and year typed in the locale's order — the schema checks it. */
322
+ declare function DateField({ name, label, hint, disabled, style, labels, autoComplete }: DateFieldProps): React.JSX.Element;
323
+ type MoneyProps = Base & {
324
+ /** The currency (ISO 4217): its sign beside the amount, its decimals. */
325
+ currency: string;
326
+ /** An example of an amount, passed translated. */
327
+ placeholder?: string;
328
+ };
329
+ /** An amount of the form, stored as integer minor units (cents), typed on the decimal keypad the locale's way. */
330
+ declare function Money({ name, label, hint, disabled, style, currency, placeholder }: MoneyProps): React.JSX.Element;
331
+ type FormFieldProps<T = unknown> = {
332
+ /** The field's name in the schema (typed by the form). */
333
+ name: string;
334
+ /** Checks the value on the server as it changes. */
335
+ validateAsync?: FieldCheck<T>;
336
+ /** The wait, in ms, before `validateAsync`. */
337
+ asyncDebounceMs?: number;
338
+ /** Draws the field: its value, setter, error (`useKrizakaField`). */
339
+ children: (field: KrizakaField<T>) => React.ReactNode;
340
+ };
341
+ /** A field drawn by the app (a control the package does not have). */
342
+ declare function FormField({ name, validateAsync, asyncDebounceMs, children }: FormFieldProps): React.JSX.Element;
343
+ type FieldArrayProps<T = unknown> = {
344
+ /** The array's name in the schema (typed by the form). */
345
+ name: string;
346
+ /** Draws the items: `items`, `push`, `remove`, `move`, `fieldName(i, "url")`. */
347
+ children: (array: KrizakaFieldArray<T>) => React.ReactNode;
348
+ };
349
+ /** A list of fields that grows and shrinks: each item's fields named `links[0].url`. */
350
+ declare function FieldArray({ name, children }: FieldArrayProps): React.JSX.Element;
351
+ type WatchProps<T = unknown> = {
352
+ /** The field to follow (typed by the form). */
353
+ name: string;
354
+ /** Draws from its current value. */
355
+ children: (value: T) => React.ReactNode;
356
+ };
357
+ /** Renders from a field's current value (a part shown only when a choice is made). */
358
+ declare function Watch({ name, children }: WatchProps): React.JSX.Element;
359
+ /** A form, defined once — the same schema and defaults as the web (`packages/core` of a product) — on native fields. */
360
+ declare const createKrizakaForm: <S extends FormSchema>(definition: KrizakaFormDefinition<S>) => KrizakaFormFactory<S, {
361
+ TextField: typeof TextField;
362
+ TextArea: typeof TextArea;
363
+ Checkbox: typeof Checkbox;
364
+ Switch: typeof Switch;
365
+ RadioGroup: typeof RadioGroup;
366
+ Select: typeof Select;
367
+ DateField: typeof DateField;
368
+ Money: typeof Money;
369
+ Field: typeof FormField;
370
+ FieldArray: typeof FieldArray;
371
+ Watch: typeof Watch;
372
+ Submit: typeof Submit;
373
+ FormError: typeof FormError;
374
+ }, FormProps>;
375
+
376
+ export { Checkbox, type CheckboxProps, DateField, type DateFieldProps, FieldArray, type FieldArrayProps, type FieldCheck, type FormActionResult, FormError, type FormErrorProps, FormField, type FormFieldError, type FormFieldProps, type FormI18n, type FormOption, type FormOutput, type FormProblem, type FormProps, type FormSchema, type FormValues, type KrizakaField, type KrizakaFieldArray, type KrizakaFormFactory, type KrizakaFormInstance, Money, type MoneyProps, RadioGroup, type RadioGroupProps, Select, Submit, type SubmitProps, Switch, TextArea, type TextAreaProps, TextField, type TextFieldProps, Watch, type WatchProps, createKrizakaForm, formMessage, formMessages, isRealDate, latestBirthDate, useFormContext, useFormStatus, useFormValue, useKrizakaField, useKrizakaFieldArray };