@factorialco/rjsf-f0 2.5.0 → 2.6.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.
- package/README.md +43 -41
- package/dist/rjsf-f0.cjs.js +10 -10
- package/dist/rjsf-f0.cjs.js.map +1 -1
- package/dist/rjsf-f0.es.js +1209 -1160
- package/dist/rjsf-f0.es.js.map +1 -1
- package/dist/src/widgets/file-widget.d.ts +22 -3
- package/dist/styles.css +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,20 +50,20 @@ The host app must render f0's `F0Provider` above the form and import `@factorial
|
|
|
50
50
|
|
|
51
51
|
## How the mapping works
|
|
52
52
|
|
|
53
|
-
| RJSF
|
|
54
|
-
|
|
|
55
|
-
| text / email / url / password
|
|
56
|
-
| number / integer / `updown` / `range` | `F0FormField` `number`
|
|
57
|
-
| `date` / `datetime-local` / `time`
|
|
58
|
-
| `textarea`
|
|
59
|
-
| enum select, multi-select
|
|
60
|
-
| boolean checkbox, `checkboxes`
|
|
61
|
-
| `radio`
|
|
62
|
-
| `file` / `data-url`
|
|
63
|
-
| submit, add/move/copy/remove
|
|
64
|
-
| `oauth` connect control
|
|
65
|
-
| error summary
|
|
66
|
-
| section title
|
|
53
|
+
| RJSF | f0 |
|
|
54
|
+
| ------------------------------------- | ---------------------------------------------------- |
|
|
55
|
+
| text / email / url / password | `F0FormField` `text` |
|
|
56
|
+
| number / integer / `updown` / `range` | `F0FormField` `number` |
|
|
57
|
+
| `date` / `datetime-local` / `time` | `F0FormField` `date` / `datetime` / `time` |
|
|
58
|
+
| `textarea` | `F0FormField` `textarea` |
|
|
59
|
+
| enum select, multi-select | `F0FormField` `select` |
|
|
60
|
+
| boolean checkbox, `checkboxes` | `F0Checkbox` |
|
|
61
|
+
| `radio` | `F0FormField` `cardSelect` (f0 has no radio control) |
|
|
62
|
+
| `file` / `data-url` | f0-styled dropzone + file chips (see below) |
|
|
63
|
+
| submit, add/move/copy/remove | `F0Button` |
|
|
64
|
+
| `oauth` connect control | `F0Button` (see below) |
|
|
65
|
+
| error summary | `F0Alert` |
|
|
66
|
+
| section title | `F0Heading` |
|
|
67
67
|
|
|
68
68
|
Two deliberate consequences of that mapping:
|
|
69
69
|
|
|
@@ -72,22 +72,24 @@ Two deliberate consequences of that mapping:
|
|
|
72
72
|
|
|
73
73
|
### File fields
|
|
74
74
|
|
|
75
|
-
`FileWidget` replaces core's, which renders a bare `<input type="file">`. That input gives away a non-native dialog in two ways CSS cannot reach: its "No file chosen" text, and a browse button the
|
|
75
|
+
`FileWidget` replaces core's, which renders a bare `<input type="file">`. That input gives away a non-native dialog in two ways CSS cannot reach: its "No file chosen" text, and a browse button the _browser_ labels in the _browser's_ locale — English chrome inside a Spanish form, which no locale propagation on our side can fix.
|
|
76
76
|
|
|
77
77
|
The theme draws its own dropzone and one chip per picked file (name, human-readable size, remove button). The value is unchanged: core's own `useFileWidgetProps` still owns the `File` -> `data:` URL exchange, so what RJSF stores is byte-identical.
|
|
78
78
|
|
|
79
|
+
One exception, opt-in: when the form provides `formContext.fcode.keptFiles` (`FcodeForm` from `@factorialco/fcode-react-forms` does), a single file larger than 50 MiB (`LARGE_FILE_BYTES`) in a root field is not read at all. Base64 of a file near 1 GB is longer than the longest string a browser can hold, so encoding it fails before the form is submitted; a file that size can only travel through an upload grant anyway, which sends the `File` as it is. The widget hands the `File` to `keptFiles.keep(file)` and stores the string it returns: a `data:` URL with no content and a `fcode-kept` parameter, so validation, conditional schemas and JSON copies of the form data treat it like any other file value. `keptFiles.get(value)` returns the `File` behind it, and the host swaps it back in at submit. Multiple-file and nested fields always encode. A host rendering this theme on its own provides no `keptFiles` and keeps getting `data:` URLs with their content. If the browser cannot read a picked file, the widget shows an error and keeps the previous value.
|
|
80
|
+
|
|
79
81
|
It does **not** bridge to f0's `F0FormField` `file`. That field is driven by an upload hook returning an opaque id, and — the blocker — its `accept` is a closed `MimeType` allowlist with no file extensions. `ui:options.accept` is a raw HTML accept string, so a schema asking for `.msj` (or any extension without a registered MIME type) would silently lose its filter. The dropzone keeps the string verbatim.
|
|
80
82
|
|
|
81
83
|
`ui:options`:
|
|
82
84
|
|
|
83
|
-
| Option
|
|
84
|
-
|
|
|
85
|
-
| `accept`
|
|
85
|
+
| Option | Effect |
|
|
86
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
87
|
+
| `accept` | Passed to the input verbatim. Also shown as a hint under the dropzone text. |
|
|
86
88
|
| `dropzoneText` | Replaces the dropzone copy, before any translation. For a marketplace app this is the path that works: schema strings go through the platform's i18n token substitution and need no cooperation from the embedder. |
|
|
87
89
|
|
|
88
90
|
### Localising the chrome
|
|
89
91
|
|
|
90
|
-
Every string this theme renders that the schema did not author goes through RJSF's `translateString` — `Add Item`, `Remove`, `Move up`, `Move down`, `Copy`, `Errors`, and the dropzone copy. **All of them are English until a host supplies a translator**, because RJSF's default translator is the identity function and its `TranslatableString` values
|
|
92
|
+
Every string this theme renders that the schema did not author goes through RJSF's `translateString` — `Add Item`, `Remove`, `Move up`, `Move down`, `Copy`, `Errors`, and the dropzone copy. **All of them are English until a host supplies a translator**, because RJSF's default translator is the identity function and its `TranslatableString` values _are_ the English text (`RemoveButton` is the literal `'Remove'`). Nothing in this package translates on its own.
|
|
91
93
|
|
|
92
94
|
One prop on the form localises the lot:
|
|
93
95
|
|
|
@@ -114,19 +116,19 @@ A form rendered inside a localised product without this prop shows English butto
|
|
|
114
116
|
> **Nothing is written yet.** You will see a preview first.
|
|
115
117
|
```
|
|
116
118
|
|
|
117
|
-
| Marker
|
|
118
|
-
|
|
|
119
|
-
| `[!NOTE]`
|
|
120
|
-
| `[!TIP]`
|
|
121
|
-
| `[!IMPORTANT]` | `info`
|
|
122
|
-
| `[!WARNING]`
|
|
123
|
-
| `[!CAUTION]`
|
|
119
|
+
| Marker | f0 variant |
|
|
120
|
+
| -------------- | ---------- |
|
|
121
|
+
| `[!NOTE]` | `info` |
|
|
122
|
+
| `[!TIP]` | `positive` |
|
|
123
|
+
| `[!IMPORTANT]` | `info` |
|
|
124
|
+
| `[!WARNING]` | `warning` |
|
|
125
|
+
| `[!CAUTION]` | `critical` |
|
|
124
126
|
|
|
125
127
|
Any other blockquote still renders as f0's blockquote, and an unrecognised marker is left as the text it is.
|
|
126
128
|
|
|
127
129
|
Two things worth knowing:
|
|
128
130
|
|
|
129
|
-
- **These are not GFM.** The GFM spec covers tables, task lists, strikethrough, autolinks and footnotes; alerts are a GitHub.com convention and `remark-gfm` does not parse them. The marker survives parsing as ordinary text at the start of the quote, which is what this renderer keys off — so no remark plugin and no new dependency is involved, and the shared `markdown-content.tsx` (and with it the hosted bundle) is untouched. It also means that
|
|
131
|
+
- **These are not GFM.** The GFM spec covers tables, task lists, strikethrough, autolinks and footnotes; alerts are a GitHub.com convention and `remark-gfm` does not parse them. The marker survives parsing as ordinary text at the start of the quote, which is what this renderer keys off — so no remark plugin and no new dependency is involved, and the shared `markdown-content.tsx` (and with it the hosted bundle) is untouched. It also means that _without_ this renderer a literal `[!NOTE]` is printed to the user.
|
|
130
132
|
- **The callout is not `F0Alert`.** That component's `title` and `description` are plain `string`s, so routing a blockquote through it would flatten the body and drop the bold, links, lists and code an author may legitimately put in a markdown block. The callout keeps the real markdown children and borrows f0's semantic colour scale, so it still flips in dark mode.
|
|
131
133
|
|
|
132
134
|
### Markdown heading levels
|
|
@@ -135,17 +137,17 @@ A schema author choosing `#` or `###` inside `markdown.before` / `markdown.after
|
|
|
135
137
|
|
|
136
138
|
f0's type scale is **not** Tailwind's default — `f0/packages/core/src/tokens/typography.ts` puts `base` at 14px, `lg` at 16px and `2xl` at 22px. So:
|
|
137
139
|
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
| **The form's own title** (schema `title`) | `F0Heading variant="heading"` | **16px / 600**
|
|
141
|
-
| `#`
|
|
142
|
-
| `##`
|
|
143
|
-
| `###`
|
|
144
|
-
| `####`
|
|
145
|
-
| `#####`
|
|
146
|
-
| `######`
|
|
147
|
-
| body text
|
|
148
|
-
| `**bold**`
|
|
140
|
+
| | Source | Renders at |
|
|
141
|
+
| ----------------------------------------- | ----------------------------- | --------------------- |
|
|
142
|
+
| **The form's own title** (schema `title`) | `F0Heading variant="heading"` | **16px / 600** |
|
|
143
|
+
| `#` | f0 `text-2xl font-medium` | **22px / 500** |
|
|
144
|
+
| `##` | f0 `text-lg font-medium` | 16px / 500 |
|
|
145
|
+
| `###` | f0 `text-base font-semibold` | 14px / 600 |
|
|
146
|
+
| `####` | this package's stylesheet | 14px / 600 |
|
|
147
|
+
| `#####` | this package's stylesheet | 14px / 500 |
|
|
148
|
+
| `######` | this package's stylesheet | 14px / 500, secondary |
|
|
149
|
+
| body text | f0 `text-base font-normal` | 14px / 400 |
|
|
150
|
+
| `**bold**` | f0 `font-semibold` | 14px / 600 |
|
|
149
151
|
|
|
150
152
|
**There is no rule relating these to the form's title.** Read the table before picking a level, because three of the rows collide:
|
|
151
153
|
|
|
@@ -157,9 +159,9 @@ The compression is f0's, not this package's: between the title (16/600) and body
|
|
|
157
159
|
|
|
158
160
|
**Which level reads as a section depends on what sits directly below it**, which is the part the table cannot tell you. A `markdown.before` heading is almost always followed by one of two things, and they are not the same weight:
|
|
159
161
|
|
|
160
|
-
| Directly below
|
|
161
|
-
|
|
|
162
|
-
| A plain field's label
|
|
162
|
+
| Directly below | Renders at | So the heading above it |
|
|
163
|
+
| ----------------------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
164
|
+
| A plain field's label | 16px / 500, dimmed | `###` (14/600, full strength) reads clearly as a heading — smaller, but bolder and darker |
|
|
163
165
|
| An object's or array's title (`TitleFieldTemplate` → `F0Heading`) | 16px / 600, full strength | `###` reads as subordinate to the field it introduces; nothing available outranks it, since `##` is 16/500 and `#` would outrank the form itself |
|
|
164
166
|
|
|
165
167
|
So `###` is the right default above an ordinary field and the wrong one above an array — and `##` is not a fix for the second case, because it only matches the title's size while staying a weight lighter. `dev/main.tsx` renders both levels above a field so the difference can be seen rather than reasoned about.
|