@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,29 @@
1
+ "use client";
2
+
3
+ // registry/examples/field/native/default.tsx
4
+ import { TextField } from "@krizaka/ui/native";
5
+ import * as React from "react";
6
+ import { View } from "react-native";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ function NativeFieldDefault() {
9
+ const [email, setEmail] = React.useState("eric@example.com");
10
+ const [password, setPassword] = React.useState("hunter");
11
+ return /* @__PURE__ */ jsxs(View, { style: { gap: 16, width: 296 }, children: [
12
+ /* @__PURE__ */ jsx(TextField, { label: "E-mail", value: email, onValueChange: setEmail, keyboardType: "email-address", autoComplete: "email", autoCapitalize: "none", textContentType: "emailAddress", hint: "We send a link to confirm it." }),
13
+ /* @__PURE__ */ jsx(
14
+ TextField,
15
+ {
16
+ label: "Password",
17
+ value: password,
18
+ onValueChange: setPassword,
19
+ secureTextEntry: true,
20
+ autoComplete: "new-password",
21
+ textContentType: "newPassword",
22
+ error: password.length < 8 ? "Use at least 8 characters." : void 0
23
+ }
24
+ )
25
+ ] });
26
+ }
27
+ export {
28
+ NativeFieldDefault as default
29
+ };
@@ -0,0 +1,23 @@
1
+ import { TextField } from "@krizaka/ui/native";
2
+ import * as React from "react";
3
+ import { View } from "react-native";
4
+
5
+ // The e-mail and the password of a sign-up: the right keyboards and autofill, a hint, then an error in its place.
6
+ export default function NativeFieldDefault() {
7
+ const [email, setEmail] = React.useState("eric@example.com");
8
+ const [password, setPassword] = React.useState("hunter");
9
+ return (
10
+ <View style={{ gap: 16, width: 296 }}>
11
+ <TextField label="E-mail" value={email} onValueChange={setEmail} keyboardType="email-address" autoComplete="email" autoCapitalize="none" textContentType="emailAddress" hint="We send a link to confirm it." />
12
+ <TextField
13
+ label="Password"
14
+ value={password}
15
+ onValueChange={setPassword}
16
+ secureTextEntry
17
+ autoComplete="new-password"
18
+ textContentType="newPassword"
19
+ error={password.length < 8 ? "Use at least 8 characters." : undefined}
20
+ />
21
+ </View>
22
+ );
23
+ }
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+
3
+ // registry/examples/form/amount.tsx
4
+ import { Chip } from "@krizaka/ui/chip";
5
+ import { createKrizakaForm } from "@krizaka/ui/form";
6
+ import { z } from "zod";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ var tip = createKrizakaForm({
9
+ schema: z.object({
10
+ amount: z.number({ message: "tip.amount.invalid" }).int().min(100, "tip.amount.min").max(5e4, "tip.amount.max"),
11
+ message: z.string().max(140),
12
+ anonymous: z.boolean()
13
+ }),
14
+ defaultValues: { amount: 500, message: "", anonymous: false },
15
+ i18n: { t: (key) => ({ "tip.amount.invalid": "Enter an amount.", "tip.amount.min": "At least $1.", "tip.amount.max": "At most $500." })[key] }
16
+ });
17
+ var PRESETS = [200, 500, 1e3];
18
+ function FormAmount() {
19
+ const form = tip.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
20
+ return /* @__PURE__ */ jsxs(form.Form, { "aria-label": "Send a tip", className: "flex w-80 flex-col gap-4", children: [
21
+ /* @__PURE__ */ jsx(form.Money, { name: "amount", label: "Amount", currency: "USD", hint: "Between $1 and $500." }),
22
+ /* @__PURE__ */ jsx(form.Watch, { name: "amount", children: (amount) => /* @__PURE__ */ jsx("div", { className: "flex gap-2", role: "group", "aria-label": "Suggested amounts", children: PRESETS.map((cents) => /* @__PURE__ */ jsx(Chip, { selected: amount === cents, onSelectedChange: () => form.setValue("amount", cents), children: `$${cents / 100}` }, cents)) }) }),
23
+ /* @__PURE__ */ jsx(form.TextArea, { name: "message", label: "A word for the creator", rows: 2, maxLength: 140 }),
24
+ /* @__PURE__ */ jsx(form.Checkbox, { name: "anonymous", label: "Send it anonymously" }),
25
+ /* @__PURE__ */ jsx(form.Submit, { children: "Send the tip" })
26
+ ] });
27
+ }
28
+ export {
29
+ FormAmount as default
30
+ };
@@ -0,0 +1,36 @@
1
+ "use client";
2
+
3
+ import { Chip } from "@krizaka/ui/chip";
4
+ import { createKrizakaForm } from "@krizaka/ui/form";
5
+ import { z } from "zod";
6
+
7
+ const tip = createKrizakaForm({
8
+ schema: z.object({
9
+ amount: z.number({ message: "tip.amount.invalid" }).int().min(100, "tip.amount.min").max(50_000, "tip.amount.max"),
10
+ message: z.string().max(140),
11
+ anonymous: z.boolean(),
12
+ }),
13
+ defaultValues: { amount: 500, message: "", anonymous: false },
14
+ i18n: { t: (key) => ({ "tip.amount.invalid": "Enter an amount.", "tip.amount.min": "At least $1.", "tip.amount.max": "At most $500." })[key] },
15
+ });
16
+ const PRESETS = [200, 500, 1000];
17
+
18
+ // A tip in cents: typed the locale's way (`12.50`), never a float; presets set the field from outside.
19
+ export default function FormAmount() {
20
+ const form = tip.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
21
+ return (
22
+ <form.Form aria-label="Send a tip" className="flex w-80 flex-col gap-4">
23
+ <form.Money name="amount" label="Amount" currency="USD" hint="Between $1 and $500." />
24
+ <form.Watch name="amount">
25
+ {(amount) => (
26
+ <div className="flex gap-2" role="group" aria-label="Suggested amounts">
27
+ {PRESETS.map((cents) => <Chip key={cents} selected={amount === cents} onSelectedChange={() => form.setValue("amount", cents)}>{`$${cents / 100}`}</Chip>)}
28
+ </div>
29
+ )}
30
+ </form.Watch>
31
+ <form.TextArea name="message" label="A word for the creator" rows={2} maxLength={140} />
32
+ <form.Checkbox name="anonymous" label="Send it anonymously" />
33
+ <form.Submit>Send the tip</form.Submit>
34
+ </form.Form>
35
+ );
36
+ }
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,29 @@
1
+ "use client";
2
+
3
+ // registry/examples/form/audience.tsx
4
+ import { createKrizakaForm } from "@krizaka/ui/form";
5
+ import { z } from "zod";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ var audience = createKrizakaForm({
8
+ schema: z.object({ audience: z.enum(["everyone", "followers", "subscribers"]), price: z.number().int().nullable(), publishOn: z.iso.date().or(z.literal("")), comments: z.boolean() }).refine((v) => v.audience !== "subscribers" || (v.price ?? 0) >= 100, { path: ["price"], message: "audience.price.min" }),
9
+ defaultValues: { audience: "subscribers", price: 499, publishOn: "", comments: true },
10
+ i18n: { t: (key) => key === "audience.price.min" ? "Subscribers pay at least $1." : void 0 }
11
+ });
12
+ var AUDIENCES = [
13
+ { value: "everyone", label: "Everyone", description: "Free, in the feed" },
14
+ { value: "followers", label: "Followers", description: "Free, for them" },
15
+ { value: "subscribers", label: "Subscribers", description: "Paid, once" }
16
+ ];
17
+ function FormAudience() {
18
+ const form = audience.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
19
+ return /* @__PURE__ */ jsxs(form.Form, { "aria-label": "Audience", className: "flex w-[28rem] max-w-full flex-col gap-4", children: [
20
+ /* @__PURE__ */ jsx(form.RadioGroup, { name: "audience", label: "Who can watch", variant: "cards", options: AUDIENCES }),
21
+ /* @__PURE__ */ jsx(form.Watch, { name: "audience", children: (value) => value === "subscribers" ? /* @__PURE__ */ jsx(form.Money, { name: "price", label: "Price", currency: "USD" }) : null }),
22
+ /* @__PURE__ */ jsx(form.DateField, { name: "publishOn", label: "Publish on", hint: "Empty: at once." }),
23
+ /* @__PURE__ */ jsx(form.Switch, { name: "comments", label: "Comments", hint: "Viewers can comment under the video." }),
24
+ /* @__PURE__ */ jsx(form.Submit, { children: "Save" })
25
+ ] });
26
+ }
27
+ export {
28
+ FormAudience as default
29
+ };
@@ -0,0 +1,31 @@
1
+ "use client";
2
+
3
+ import { createKrizakaForm } from "@krizaka/ui/form";
4
+ import { z } from "zod";
5
+
6
+ const audience = createKrizakaForm({
7
+ schema: z
8
+ .object({ audience: z.enum(["everyone", "followers", "subscribers"]), price: z.number().int().nullable(), publishOn: z.iso.date().or(z.literal("")), comments: z.boolean() })
9
+ .refine((v) => v.audience !== "subscribers" || (v.price ?? 0) >= 100, { path: ["price"], message: "audience.price.min" }),
10
+ defaultValues: { audience: "subscribers" as "everyone" | "followers" | "subscribers", price: 499 as number | null, publishOn: "", comments: true },
11
+ i18n: { t: (key) => (key === "audience.price.min" ? "Subscribers pay at least $1." : undefined) },
12
+ });
13
+ const AUDIENCES = [
14
+ { value: "everyone", label: "Everyone", description: "Free, in the feed" },
15
+ { value: "followers", label: "Followers", description: "Free, for them" },
16
+ { value: "subscribers", label: "Subscribers", description: "Paid, once" },
17
+ ];
18
+
19
+ // Who sees a video: cards to choose from, the price only when it is for subscribers, a publication date.
20
+ export default function FormAudience() {
21
+ const form = audience.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
22
+ return (
23
+ <form.Form aria-label="Audience" className="flex w-[28rem] max-w-full flex-col gap-4">
24
+ <form.RadioGroup name="audience" label="Who can watch" variant="cards" options={AUDIENCES} />
25
+ <form.Watch name="audience">{(value) => (value === "subscribers" ? <form.Money name="price" label="Price" currency="USD" /> : null)}</form.Watch>
26
+ <form.DateField name="publishOn" label="Publish on" hint="Empty: at once." />
27
+ <form.Switch name="comments" label="Comments" hint="Viewers can comment under the video." />
28
+ <form.Submit>Save</form.Submit>
29
+ </form.Form>
30
+ );
31
+ }
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,26 @@
1
+ "use client";
2
+
3
+ // registry/examples/form/native/amount.tsx
4
+ import { Chip } from "@krizaka/ui/native";
5
+ import { createKrizakaForm } from "@krizaka/ui/native/form";
6
+ import { z } from "zod";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ var tip = createKrizakaForm({
9
+ schema: z.object({ amount: z.number({ message: "tip.amount.invalid" }).int().min(100, "tip.amount.min").max(5e4, "tip.amount.max"), message: z.string().max(140), anonymous: z.boolean() }),
10
+ defaultValues: { amount: 500, message: "", anonymous: false },
11
+ i18n: { t: (key) => ({ "tip.amount.invalid": "Enter an amount.", "tip.amount.min": "At least \u20AC1.", "tip.amount.max": "At most \u20AC500." })[key], locale: "fr-FR" }
12
+ });
13
+ var PRESETS = [200, 500, 1e3];
14
+ function NativeFormAmount() {
15
+ const form = tip.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
16
+ return /* @__PURE__ */ jsxs(form.Form, { "aria-label": "Send a tip", style: { width: 312 }, children: [
17
+ /* @__PURE__ */ jsx(form.Money, { name: "amount", label: "Amount", currency: "EUR", hint: "Between \u20AC1 and \u20AC500." }),
18
+ /* @__PURE__ */ jsx(form.Watch, { name: "amount", children: (amount) => /* @__PURE__ */ jsx(Chip.Group, { type: "single", "aria-label": "Suggested amounts", value: String(amount), onValueChange: (v) => form.setValue("amount", Number(v)), children: PRESETS.map((cents) => /* @__PURE__ */ jsx(Chip, { value: String(cents), children: `${cents / 100} \u20AC` }, cents)) }) }),
19
+ /* @__PURE__ */ jsx(form.TextArea, { name: "message", label: "A word for the creator", maxLength: 140 }),
20
+ /* @__PURE__ */ jsx(form.Checkbox, { name: "anonymous", label: "Send it anonymously" }),
21
+ /* @__PURE__ */ jsx(form.Submit, { label: "Send the tip" })
22
+ ] });
23
+ }
24
+ export {
25
+ NativeFormAmount as default
26
+ };
@@ -0,0 +1,30 @@
1
+ import { Chip } from "@krizaka/ui/native";
2
+ import { createKrizakaForm } from "@krizaka/ui/native/form";
3
+ import { z } from "zod";
4
+
5
+ const tip = createKrizakaForm({
6
+ schema: z.object({ amount: z.number({ message: "tip.amount.invalid" }).int().min(100, "tip.amount.min").max(50_000, "tip.amount.max"), message: z.string().max(140), anonymous: z.boolean() }),
7
+ defaultValues: { amount: 500, message: "", anonymous: false },
8
+ i18n: { t: (key) => ({ "tip.amount.invalid": "Enter an amount.", "tip.amount.min": "At least €1.", "tip.amount.max": "At most €500." })[key], locale: "fr-FR" },
9
+ });
10
+ const PRESETS = [200, 500, 1000];
11
+
12
+ // A tip in cents on the decimal keypad, typed the locale's way (`12,50` in French); presets set the field from outside.
13
+ export default function NativeFormAmount() {
14
+ const form = tip.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
15
+ return (
16
+ <form.Form aria-label="Send a tip" style={{ width: 312 }}>
17
+ <form.Money name="amount" label="Amount" currency="EUR" hint="Between €1 and €500." />
18
+ <form.Watch name="amount">
19
+ {(amount) => (
20
+ <Chip.Group type="single" aria-label="Suggested amounts" value={String(amount)} onValueChange={(v) => form.setValue("amount", Number(v))}>
21
+ {PRESETS.map((cents) => <Chip key={cents} value={String(cents)}>{`${cents / 100} €`}</Chip>)}
22
+ </Chip.Group>
23
+ )}
24
+ </form.Watch>
25
+ <form.TextArea name="message" label="A word for the creator" maxLength={140} />
26
+ <form.Checkbox name="anonymous" label="Send it anonymously" />
27
+ <form.Submit label="Send the tip" />
28
+ </form.Form>
29
+ );
30
+ }
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,24 @@
1
+ "use client";
2
+
3
+ // registry/examples/form/native/audience.tsx
4
+ import { createKrizakaForm } from "@krizaka/ui/native/form";
5
+ import { z } from "zod";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ var audience = createKrizakaForm({
8
+ schema: z.object({ audience: z.enum(["everyone", "followers", "subscribers"]), price: z.number().int().nullable(), comments: z.boolean() }).refine((v) => v.audience !== "subscribers" || (v.price ?? 0) >= 100, { path: ["price"], message: "audience.price.min" }),
9
+ defaultValues: { audience: "subscribers", price: 499, comments: true },
10
+ i18n: { t: (key) => key === "audience.price.min" ? "Subscribers pay at least $1." : void 0 }
11
+ });
12
+ var AUDIENCES = [{ value: "everyone", label: "Everyone" }, { value: "followers", label: "Followers" }, { value: "subscribers", label: "Subscribers" }];
13
+ function NativeFormAudience() {
14
+ const form = audience.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
15
+ return /* @__PURE__ */ jsxs(form.Form, { "aria-label": "Audience", style: { width: 312 }, children: [
16
+ /* @__PURE__ */ jsx(form.RadioGroup, { name: "audience", label: "Who can watch", options: AUDIENCES }),
17
+ /* @__PURE__ */ jsx(form.Watch, { name: "audience", children: (value) => value === "subscribers" ? /* @__PURE__ */ jsx(form.Money, { name: "price", label: "Price", currency: "USD" }) : null }),
18
+ /* @__PURE__ */ jsx(form.Switch, { name: "comments", label: "Comments", hint: "Viewers can comment under the video." }),
19
+ /* @__PURE__ */ jsx(form.Submit, { label: "Save" })
20
+ ] });
21
+ }
22
+ export {
23
+ NativeFormAudience as default
24
+ };
@@ -0,0 +1,24 @@
1
+ import { createKrizakaForm } from "@krizaka/ui/native/form";
2
+ import { z } from "zod";
3
+
4
+ const audience = createKrizakaForm({
5
+ schema: z
6
+ .object({ audience: z.enum(["everyone", "followers", "subscribers"]), price: z.number().int().nullable(), comments: z.boolean() })
7
+ .refine((v) => v.audience !== "subscribers" || (v.price ?? 0) >= 100, { path: ["price"], message: "audience.price.min" }),
8
+ defaultValues: { audience: "subscribers" as "everyone" | "followers" | "subscribers", price: 499 as number | null, comments: true },
9
+ i18n: { t: (key) => (key === "audience.price.min" ? "Subscribers pay at least $1." : undefined) },
10
+ });
11
+ const AUDIENCES = [{ value: "everyone", label: "Everyone" }, { value: "followers", label: "Followers" }, { value: "subscribers", label: "Subscribers" }];
12
+
13
+ // Who sees a video: the price only when it is for subscribers (`Watch`), comments on or off.
14
+ export default function NativeFormAudience() {
15
+ const form = audience.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
16
+ return (
17
+ <form.Form aria-label="Audience" style={{ width: 312 }}>
18
+ <form.RadioGroup name="audience" label="Who can watch" options={AUDIENCES} />
19
+ <form.Watch name="audience">{(value) => (value === "subscribers" ? <form.Money name="price" label="Price" currency="USD" /> : null)}</form.Watch>
20
+ <form.Switch name="comments" label="Comments" hint="Viewers can comment under the video." />
21
+ <form.Submit label="Save" />
22
+ </form.Form>
23
+ );
24
+ }
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,33 @@
1
+ "use client";
2
+
3
+ // registry/examples/form/native/profile.tsx
4
+ import { KrizakaQueryProvider, useMutation } from "@krizaka/query";
5
+ import { Button } from "@krizaka/ui/native";
6
+ import { createKrizakaForm } from "@krizaka/ui/native/form";
7
+ import { z } from "zod";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ var profile = createKrizakaForm({
10
+ schema: z.object({ displayName: z.string().min(2).max(40), bio: z.string().max(160), category: z.enum(["travel", "music", "science", "sport"]), links: z.array(z.object({ url: z.url() })).max(3) }),
11
+ defaultValues: { displayName: "Elena Varga", bio: "Night skies over the Tatras.", category: "travel", links: [{ url: "https://elena.example" }] }
12
+ });
13
+ var CATEGORIES = [{ value: "travel", label: "Travel" }, { value: "music", label: "Music" }, { value: "science", label: "Science" }, { value: "sport", label: "Sport" }];
14
+ function ProfileForm() {
15
+ const mutation = useMutation({ mutationFn: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
16
+ const form = profile.useForm({ onSubmit: (values) => mutation.mutateAsync(values) });
17
+ return /* @__PURE__ */ jsxs(form.Form, { "aria-label": "Your profile", style: { width: 312 }, children: [
18
+ /* @__PURE__ */ jsx(form.TextField, { name: "displayName", label: "Display name", autoComplete: "name" }),
19
+ /* @__PURE__ */ jsx(form.TextArea, { name: "bio", label: "Bio", maxLength: 160 }),
20
+ /* @__PURE__ */ jsx(form.RadioGroup, { name: "category", label: "Category", options: CATEGORIES }),
21
+ /* @__PURE__ */ jsx(form.FieldArray, { name: "links", children: (links) => /* @__PURE__ */ jsxs(Fragment, { children: [
22
+ links.items.map((_, i) => /* @__PURE__ */ jsx(form.TextField, { name: `links[${i}].url`, label: `Link ${i + 1}`, keyboardType: "url", autoCapitalize: "none" }, i)),
23
+ links.items.length < 3 ? /* @__PURE__ */ jsx(Button, { label: "Add a link", variant: "ghost", size: "sm", onPress: () => links.push({ url: "" }) }) : null
24
+ ] }) }),
25
+ /* @__PURE__ */ jsx(form.Submit, { label: "Save the profile" })
26
+ ] });
27
+ }
28
+ function NativeFormProfile() {
29
+ return /* @__PURE__ */ jsx(KrizakaQueryProvider, { children: /* @__PURE__ */ jsx(ProfileForm, {}) });
30
+ }
31
+ export {
32
+ NativeFormProfile as default
33
+ };
@@ -0,0 +1,36 @@
1
+ import { KrizakaQueryProvider, useMutation } from "@krizaka/query";
2
+ import { Button } from "@krizaka/ui/native";
3
+ import { createKrizakaForm } from "@krizaka/ui/native/form";
4
+ import { z } from "zod";
5
+
6
+ const profile = createKrizakaForm({
7
+ schema: z.object({ displayName: z.string().min(2).max(40), bio: z.string().max(160), category: z.enum(["travel", "music", "science", "sport"]), links: z.array(z.object({ url: z.url() })).max(3) }),
8
+ defaultValues: { displayName: "Elena Varga", bio: "Night skies over the Tatras.", category: "travel" as "travel" | "music" | "science" | "sport", links: [{ url: "https://elena.example" }] },
9
+ });
10
+ const CATEGORIES = [{ value: "travel", label: "Travel" }, { value: "music", label: "Music" }, { value: "science", label: "Science" }, { value: "sport", label: "Sport" }];
11
+
12
+ function ProfileForm() {
13
+ const mutation = useMutation({ mutationFn: (values: unknown) => new Promise((done) => setTimeout(() => done(values), 400)) });
14
+ const form = profile.useForm({ onSubmit: (values) => mutation.mutateAsync(values) });
15
+ return (
16
+ <form.Form aria-label="Your profile" style={{ width: 312 }}>
17
+ <form.TextField name="displayName" label="Display name" autoComplete="name" />
18
+ <form.TextArea name="bio" label="Bio" maxLength={160} />
19
+ <form.RadioGroup name="category" label="Category" options={CATEGORIES} />
20
+ <form.FieldArray name="links">
21
+ {(links) => (
22
+ <>
23
+ {links.items.map((_, i) => <form.TextField key={i} name={`links[${i}].url`} label={`Link ${i + 1}`} keyboardType="url" autoCapitalize="none" />)}
24
+ {links.items.length < 3 ? <Button label="Add a link" variant="ghost" size="sm" onPress={() => links.push({ url: "" })} /> : null}
25
+ </>
26
+ )}
27
+ </form.FieldArray>
28
+ <form.Submit label="Save the profile" />
29
+ </form.Form>
30
+ );
31
+ }
32
+
33
+ // A profile saved by a mutation of @krizaka/query; the list of links grows.
34
+ export default function NativeFormProfile() {
35
+ return <KrizakaQueryProvider><ProfileForm /></KrizakaQueryProvider>;
36
+ }
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+
3
+ // registry/examples/form/native/settings.tsx
4
+ import { createKrizakaForm } from "@krizaka/ui/native/form";
5
+ import { z } from "zod";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ var settings = createKrizakaForm({
8
+ schema: z.object({ language: z.enum(["en", "fr", "es"]), emailDigest: z.boolean(), pushMessages: z.boolean(), quality: z.enum(["auto", "data-saver", "best"]) }),
9
+ defaultValues: { language: "en", emailDigest: true, pushMessages: false, quality: "auto" }
10
+ });
11
+ var LANGUAGES = [{ value: "en", label: "English" }, { value: "fr", label: "Fran\xE7ais" }, { value: "es", label: "Espa\xF1ol" }];
12
+ var QUALITY = [{ value: "auto", label: "Automatic" }, { value: "data-saver", label: "Data saver" }, { value: "best", label: "Best" }];
13
+ function NativeFormSettings() {
14
+ const form = settings.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
15
+ return /* @__PURE__ */ jsxs(form.Form, { "aria-label": "Settings", style: { width: 312 }, children: [
16
+ /* @__PURE__ */ jsx(form.Select, { name: "language", label: "Language", options: LANGUAGES }),
17
+ /* @__PURE__ */ jsx(form.Switch, { name: "emailDigest", label: "Weekly e-mail", hint: "What happened on your channel." }),
18
+ /* @__PURE__ */ jsx(form.Switch, { name: "pushMessages", label: "Message notifications" }),
19
+ /* @__PURE__ */ jsx(form.RadioGroup, { name: "quality", label: "Video quality", options: QUALITY }),
20
+ /* @__PURE__ */ jsx(form.Submit, { label: "Save the settings" })
21
+ ] });
22
+ }
23
+ export {
24
+ NativeFormSettings as default
25
+ };
@@ -0,0 +1,23 @@
1
+ import { createKrizakaForm } from "@krizaka/ui/native/form";
2
+ import { z } from "zod";
3
+
4
+ const settings = createKrizakaForm({
5
+ schema: z.object({ language: z.enum(["en", "fr", "es"]), emailDigest: z.boolean(), pushMessages: z.boolean(), quality: z.enum(["auto", "data-saver", "best"]) }),
6
+ defaultValues: { language: "en" as "en" | "fr" | "es", emailDigest: true, pushMessages: false, quality: "auto" as "auto" | "data-saver" | "best" },
7
+ });
8
+ const LANGUAGES = [{ value: "en", label: "English" }, { value: "fr", label: "Français" }, { value: "es", label: "Español" }];
9
+ const QUALITY = [{ value: "auto", label: "Automatic" }, { value: "data-saver", label: "Data saver" }, { value: "best", label: "Best" }];
10
+
11
+ // The app's settings: the system's switches, chips for a choice — saved in one go.
12
+ export default function NativeFormSettings() {
13
+ const form = settings.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 400)) });
14
+ return (
15
+ <form.Form aria-label="Settings" style={{ width: 312 }}>
16
+ <form.Select name="language" label="Language" options={LANGUAGES} />
17
+ <form.Switch name="emailDigest" label="Weekly e-mail" hint="What happened on your channel." />
18
+ <form.Switch name="pushMessages" label="Message notifications" />
19
+ <form.RadioGroup name="quality" label="Video quality" options={QUALITY} />
20
+ <form.Submit label="Save the settings" />
21
+ </form.Form>
22
+ );
23
+ }
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,38 @@
1
+ "use client";
2
+
3
+ // registry/examples/form/native/sign-up.tsx
4
+ import { KrizakaApiError } from "@krizaka/query";
5
+ import { createKrizakaForm, latestBirthDate } from "@krizaka/ui/native/form";
6
+ import { z } from "zod";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ var signUp = createKrizakaForm({
9
+ schema: z.object({
10
+ email: z.email(),
11
+ username: z.string().min(3).max(30).regex(/^[a-z0-9_]+$/, "signUp.username.format"),
12
+ password: z.string().min(8),
13
+ dateOfBirth: z.iso.date().refine((d) => d <= latestBirthDate(18), "form.errors.UNDERAGE"),
14
+ acceptTerms: z.boolean().refine(Boolean, "signUp.terms.required")
15
+ }),
16
+ defaultValues: { email: "", username: "", password: "", dateOfBirth: "", acceptTerms: false }
17
+ });
18
+ var WORDS = { "signUp.username.format": "Lowercase letters, digits and _ only.", "signUp.username.taken": "This username is taken.", "signUp.terms.required": "Accept the terms to continue.", "form.errors.UNDERAGE": "You must be 18 or older.", "form.errors.BIRTH_DATE_INVALID": "Enter your real date of birth.", "form.errors.USERNAME_RESERVED": "This username is reserved.", "apiErrors.ACCOUNT_EXISTS": "This e-mail already has an account. Sign in instead." };
19
+ var taken = (u) => new Promise((done) => setTimeout(() => done(["eric", "elena"].includes(u)), 300));
20
+ var register = async (v) => {
21
+ if (v.username === "admin") throw new KrizakaApiError({ status: 400, code: "USERNAME_RESERVED" });
22
+ if (v.email.endsWith("@orochia.com")) throw new KrizakaApiError({ status: 409, code: "ACCOUNT_EXISTS" });
23
+ };
24
+ function NativeFormSignUp() {
25
+ const form = signUp.useForm({ i18n: { t: (key) => WORDS[key], locale: "en-GB" }, codeFields: { UNDERAGE: "dateOfBirth", BIRTH_DATE_INVALID: "dateOfBirth", USERNAME_RESERVED: "username" }, onSubmit: register });
26
+ return /* @__PURE__ */ jsxs(form.Form, { "aria-label": "Create your account", style: { width: 312 }, children: [
27
+ /* @__PURE__ */ jsx(form.TextField, { name: "email", label: "E-mail", keyboardType: "email-address", autoComplete: "email", autoCapitalize: "none", textContentType: "emailAddress" }),
28
+ /* @__PURE__ */ jsx(form.TextField, { name: "username", label: "Username", autoCapitalize: "none", autoComplete: "username", transform: (v) => v.toLowerCase().replace(/\s+/g, "_"), availableHint: "Free", validateAsync: async (u) => await taken(u) ? { key: "signUp.username.taken", suggestion: { label: `Use @${u}_${u.length}`, value: `${u}_${u.length}` } } : null }),
29
+ /* @__PURE__ */ jsx(form.TextField, { name: "password", label: "Password", secureTextEntry: true, autoComplete: "new-password", textContentType: "newPassword", hint: "At least 8 characters." }),
30
+ /* @__PURE__ */ jsx(form.DateField, { name: "dateOfBirth", label: "Date of birth", autoComplete: "bday", hint: "Private, never shown." }),
31
+ /* @__PURE__ */ jsx(form.Checkbox, { name: "acceptTerms", label: "I accept the terms and the privacy policy" }),
32
+ /* @__PURE__ */ jsx(form.FormError, {}),
33
+ /* @__PURE__ */ jsx(form.Submit, { label: "Create my account", brand: "orochia" })
34
+ ] });
35
+ }
36
+ export {
37
+ NativeFormSignUp as default
38
+ };
@@ -0,0 +1,34 @@
1
+ import { KrizakaApiError } from "@krizaka/query";
2
+ import { createKrizakaForm, latestBirthDate } from "@krizaka/ui/native/form";
3
+ import { z } from "zod";
4
+
5
+ // The same schema as the web form (a product keeps it in packages/core): the same rules, the same keys.
6
+ const signUp = createKrizakaForm({
7
+ schema: z.object({
8
+ email: z.email(),
9
+ username: z.string().min(3).max(30).regex(/^[a-z0-9_]+$/, "signUp.username.format"),
10
+ password: z.string().min(8),
11
+ dateOfBirth: z.iso.date().refine((d) => d <= latestBirthDate(18), "form.errors.UNDERAGE"),
12
+ acceptTerms: z.boolean().refine(Boolean, "signUp.terms.required"),
13
+ }),
14
+ defaultValues: { email: "", username: "", password: "", dateOfBirth: "", acceptTerms: false },
15
+ });
16
+ const WORDS: Record<string, string> = { "signUp.username.format": "Lowercase letters, digits and _ only.", "signUp.username.taken": "This username is taken.", "signUp.terms.required": "Accept the terms to continue.", "form.errors.UNDERAGE": "You must be 18 or older.", "form.errors.BIRTH_DATE_INVALID": "Enter your real date of birth.", "form.errors.USERNAME_RESERVED": "This username is reserved.", "apiErrors.ACCOUNT_EXISTS": "This e-mail already has an account. Sign in instead." };
17
+ const taken = (u: string) => new Promise<boolean>((done) => setTimeout(() => done(["eric", "elena"].includes(u)), 300));
18
+ const register = async (v: { email: string; username: string }) => { if (v.username === "admin") throw new KrizakaApiError({ status: 400, code: "USERNAME_RESERVED" }); if (v.email.endsWith("@orochia.com")) throw new KrizakaApiError({ status: 409, code: "ACCOUNT_EXISTS" }); };
19
+
20
+ // Sign-up in the app: the return key walks the fields, the username is checked as typed, the 18+ birth date is day · month · year.
21
+ export default function NativeFormSignUp() {
22
+ const form = signUp.useForm({ i18n: { t: (key) => WORDS[key], locale: "en-GB" }, codeFields: { UNDERAGE: "dateOfBirth", BIRTH_DATE_INVALID: "dateOfBirth", USERNAME_RESERVED: "username" }, onSubmit: register });
23
+ return (
24
+ <form.Form aria-label="Create your account" style={{ width: 312 }}>
25
+ <form.TextField name="email" label="E-mail" keyboardType="email-address" autoComplete="email" autoCapitalize="none" textContentType="emailAddress" />
26
+ <form.TextField name="username" label="Username" autoCapitalize="none" autoComplete="username" transform={(v) => v.toLowerCase().replace(/\s+/g, "_")} availableHint="Free" validateAsync={async (u) => ((await taken(u)) ? { key: "signUp.username.taken", suggestion: { label: `Use @${u}_${u.length}`, value: `${u}_${u.length}` } } : null)} />
27
+ <form.TextField name="password" label="Password" secureTextEntry autoComplete="new-password" textContentType="newPassword" hint="At least 8 characters." />
28
+ <form.DateField name="dateOfBirth" label="Date of birth" autoComplete="bday" hint="Private, never shown." />
29
+ <form.Checkbox name="acceptTerms" label="I accept the terms and the privacy policy" />
30
+ <form.FormError />
31
+ <form.Submit label="Create my account" brand="orochia" />
32
+ </form.Form>
33
+ );
34
+ }
@@ -0,0 +1,4 @@
1
+ import type { ComponentType } from "react";
2
+ /** A named example of the @krizaka/ui registry; `defaultOpen` opens what it opens (a dialog, a menu, toasts) at load. */
3
+ declare const Example: ComponentType<{ defaultOpen?: boolean }>;
4
+ export default Example;
@@ -0,0 +1,23 @@
1
+ "use client";
2
+
3
+ // registry/examples/form/native/upload.tsx
4
+ import { createKrizakaForm } from "@krizaka/ui/native/form";
5
+ import { z } from "zod";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ var upload = createKrizakaForm({
8
+ schema: z.object({ title: z.string().min(3).max(100), description: z.string().max(2e3), visibility: z.enum(["public", "followers", "private"]) }),
9
+ defaultValues: { title: "Sunrise over Rysy", description: "", visibility: "public" }
10
+ });
11
+ var VISIBILITY = [{ value: "public", label: "Everyone" }, { value: "followers", label: "Followers" }, { value: "private", label: "Only me" }];
12
+ function NativeFormUpload() {
13
+ const form = upload.useForm({ onSubmit: (values) => new Promise((done) => setTimeout(() => done(values), 600)) });
14
+ return /* @__PURE__ */ jsxs(form.Form, { "aria-label": "Publish a video", style: { width: 312 }, children: [
15
+ /* @__PURE__ */ jsx(form.TextField, { name: "title", label: "Title", maxLength: 100 }),
16
+ /* @__PURE__ */ jsx(form.TextArea, { name: "description", label: "Description", placeholder: "What happens in it?" }),
17
+ /* @__PURE__ */ jsx(form.RadioGroup, { name: "visibility", label: "Who can watch", options: VISIBILITY }),
18
+ /* @__PURE__ */ jsx(form.Submit, { label: "Publish" })
19
+ ] });
20
+ }
21
+ export {
22
+ NativeFormUpload as default
23
+ };