fimo 2.15.0-staging.3 → 2.15.0-staging.4

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.
@@ -62,6 +62,8 @@ export function submitContactUs(
62
62
 
63
63
  The schema, parser, submitter, and form id are re-exported by `src/forms/index.ts`.
64
64
 
65
+ `parseXFormData` validates with the schema and throws a `ZodError` on invalid input. Catch it to show field errors; do not pass its result to `safeParse`.
66
+
65
67
  The `submitX` helper uses the framework adapter's shared Fimo transport and handles presigned file uploads automatically. Never hand-roll the Fimo API fetch or validation.
66
68
 
67
69
  ## Common code pattern
@@ -70,8 +72,9 @@ Always import the generated module. Keep the native form and pending/error state
70
72
 
71
73
  ```tsx
72
74
  import { useState } from 'react';
75
+ import { z } from 'zod';
73
76
 
74
- import { ContactUsSchema, parseContactUsFormData, submitContactUs } from '@/forms/contact-us';
77
+ import { parseContactUsFormData, submitContactUs } from '@/forms/contact-us';
75
78
  import type { ContactUsData } from '@/forms/contact-us';
76
79
 
77
80
  export function ContactForm() {
@@ -83,16 +86,19 @@ export function ContactForm() {
83
86
  setErrors({});
84
87
  setLoading(true);
85
88
 
86
- const parsed = ContactUsSchema.safeParse(parseContactUsFormData(new FormData(e.currentTarget)));
87
- if (!parsed.success) {
89
+ let data: ContactUsData;
90
+ try {
91
+ data = parseContactUsFormData(new FormData(e.currentTarget));
92
+ } catch (error) {
93
+ if (!(error instanceof z.ZodError)) throw error;
88
94
  const fieldErrors: Record<string, string> = {};
89
- for (const issue of parsed.error.issues) fieldErrors[issue.path[0] as string] = issue.message;
95
+ for (const issue of error.issues) fieldErrors[issue.path[0] as string] = issue.message;
90
96
  setErrors(fieldErrors);
91
97
  setLoading(false);
92
98
  return;
93
99
  }
94
100
 
95
- const result = await submitContactUs(parsed.data);
101
+ const result = await submitContactUs(data);
96
102
  setLoading(false);
97
103
  if (!result.success && result.errors) setErrors(result.errors);
98
104
  };
@@ -132,8 +132,12 @@ const [articles, labels] = await Promise.all([
132
132
  fimo.articles.list({ sort: '-publishedAt', limit: 12 }),
133
133
  getLabels({ locale }),
134
134
  ]);
135
+
136
+ return <Text value={labels.t('articles.title')} as="h1" />;
135
137
  ```
136
138
 
139
+ `getLabels()` returns `{ locale, snapshot, t }`: `t` for this Server Component, `snapshot` for `FimoProvider` (see Provider boundary). Neither entry exports `Label`; render labels with `Text`.
140
+
137
141
  Client Components import from `fimo-next/client` and generated `.client` modules:
138
142
 
139
143
  ```tsx
@@ -38,8 +38,8 @@ Missing keys render as an empty tracked value. Run `fimo validate`, then create
38
38
 
39
39
  The label contract is shared; acquisition differs by runtime:
40
40
 
41
- - Next server: `getLabels({ locale? })` from `fimo-next`.
42
- - Next client: `useLabels()` from `fimo-next/client`, under `FimoProvider`.
41
+ - Next server: `getLabels({ locale? })` from `fimo-next` returns `{ locale, snapshot, t }`. Render with `<Text value={labels.t('key')} />` and pass `labels.snapshot` to the root `FimoProvider`.
42
+ - Next client: `useLabels()` from `fimo-next/client`, under `FimoProvider`. `fimo-next` exports no `Label`; render `<Text value={t('key')} />`.
43
43
  - React Router/Vite client: `Label` and `useLabels()` from `fimo-react`, under the existing framework integration.
44
44
  - SvelteKit: pass the application's resolved locale to `getLabels({ apiUrl, event, locale })`, or omit it to let the API choose the project default. Wrap the root layout with `FimoProvider` from `fimo-sveltekit/components`; the snapshot supplies its locale. Descendants use `Label` from that entrypoint or `useLabels().t()` from `fimo-sveltekit`. Apply the same explicit-or-omitted rule to `createFimo({ content, event, locale? })` in content loads.
45
45
  - Astro server page: `getLabels({ locale? })` from `fimo/astro`; no provider.
@@ -25,6 +25,14 @@ Use Fimo components for source-tracked schema and label values so Studio can ide
25
25
  <DateTime value={article.lastReviewedAt} />
26
26
  ```
27
27
 
28
+ `Date` and `DateTime` accept `className` and an optional render function as children to format the displayed text; the `<time datetime>` attribute and the edit target stay intact:
29
+
30
+ ```tsx
31
+ <Date value={event.startsOn}>
32
+ {(date) => date.toLocaleDateString(locale, { weekday: 'long', day: 'numeric', month: 'long' })}
33
+ </Date>
34
+ ```
35
+
28
36
  Pass the tracked value directly. Do not replace `<Text>` with `<h1>{article.title}</h1>`, unwrap media into raw `<img>`, or hand-roll richtext rendering.
29
37
 
30
38
  Blocks do not change this rule. Every visible nested scalar is source-tracked too, including fields inside repeated and nested blocks:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "bundled": true,
3
3
  "bundler": "esbuild",
4
- "bundledAt": "2026-11-16T17:20:01.091Z",
4
+ "bundledAt": "2026-11-17T16:44:59.146Z",
5
5
  "cliVersion": "2.14.0",
6
6
  "external": [
7
7
  "oxc-parser",