@factorialco/rjsf-f0 3.4.0 → 3.9.1

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 CHANGED
@@ -58,9 +58,12 @@ The host app must render f0's `F0Provider` above the form and import `@factorial
58
58
  | `textarea` | `F0FormField` `textarea` |
59
59
  | enum select, multi-select | `F0FormField` `select` |
60
60
  | boolean checkbox, `checkboxes` | `F0Checkbox` |
61
+ | boolean with `display: "switch"` | f0's `Switch` (see below) |
62
+ | `checkboxes` with `display: "cards"` | `CardSelectableContainer` `multiple` (see below) |
61
63
  | `radio` | `F0FormField` `cardSelect` (f0 has no radio control) |
62
64
  | `file` / `data-url` | f0-styled dropzone + file chips (see below) |
63
65
  | submit, add/move/copy/remove | `F0Button` |
66
+ | `button` action field | `F0Button` (see below) |
64
67
  | `oauth` connect control | `F0Button` (see below) |
65
68
  | `pairing` table | a table of `F0Select`, `F0TagStatus` (see below) |
66
69
  | `launch-one` button | `F0Button` with the `Ai` icon (see below) |
@@ -92,9 +95,11 @@ It does **not** bridge to f0's `F0FormField` `file`. That field is driven by an
92
95
 
93
96
  ### Localising the chrome
94
97
 
95
- 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.
98
+ 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. Nothing in this package translates on its own: RJSF's default translator is the identity function and its `TranslatableString` values _are_ the English text (`RemoveButton` is the literal `'Remove'`), so used with plain RJSF, all of them stay English until a host supplies a translator.
96
99
 
97
- One prop on the form localises the lot:
100
+ Rendered through `@factorialco/fcode-react-forms` (`FcodeForm` or `FcodeJsonSchemaForm`), the form always gets one: the SDK picks the form's language from `locale` (then `fallbackLocale`) and translates these texts with its own table, so a Spanish form shows Spanish buttons and dropzone copy with no setup. Only Spanish ships a table today; any other language stays English.
101
+
102
+ One prop on the form replaces that translator, to add a language or change a wording:
98
103
 
99
104
  ```tsx
100
105
  <FcodeForm
@@ -107,8 +112,9 @@ The dropzone's two defaults are keyed on their English text, since RJSF has no e
107
112
 
108
113
  - `Drag a file here, or click to choose one`
109
114
  - `Drag files here, or click to choose them` (when `multiple`)
115
+ - `The file could not be read. Choose it again.` (the alert when the browser fails to read a chosen file)
110
116
 
111
- A form rendered inside a localised product without this prop shows English buttons next to translated field labels. `ui:options.dropzoneText` fixes only the dropzone; the translator fixes everything.
117
+ A form in a language the SDK has no table for, rendered without this prop, shows English buttons next to translated field labels. `ui:options.dropzoneText` fixes only the dropzone; the translator fixes everything.
112
118
 
113
119
  ### Markdown alerts
114
120
 
@@ -195,10 +201,26 @@ The toolbar is RJSF's, so it is the schema that decides what a row can do:
195
201
 
196
202
  `orderable` (default `true`) draws move up/down — turn it off when order carries no meaning, which is most scalar lists. `copyable` defaults to `false` already, `removable` and `addable` to `true`.
197
203
 
204
+ ### Switches
205
+
206
+ `"ui:options": { "display": "switch" }` on a boolean draws f0's `Switch` (from `@factorialco/f0-react/dist/experimental`) instead of the `F0Checkbox`, with the label beside it the same way, a markdown label included. The value stays `true` / `false`; validation, errors and disabled/read-only work as for the checkbox. It is not `F0FormField`'s `switch` field: that one always hides the switch's own label and puts the field label above the control, where this theme keeps a boolean's label beside it.
207
+
208
+ It is an option rather than a `ui:widget` so an older theme or SDK keeps the checkbox instead of failing the form with `No widget "switch"`. Any other `display` value logs a warning and keeps the checkbox; `display` on anything other than a boolean drawn as a checkbox or a `checkboxes` list (see [cards](#cards-for-multiple-choice)) — a string, a boolean with `"ui:widget": "radio"` or `"ui:field"` — logs a warning and is ignored. The theme reads the option itself (`widgets/display-option.ts`), since it also renders standalone. Table cells are unaffected: a boolean cell stays a two-choice select.
209
+
210
+ ### Cards for multiple choice
211
+
212
+ `"ui:options": { "display": "cards" }` on an array drawn with `"ui:widget": "checkboxes"` draws its options as f0's multi-select cards (`CardSelectableContainer` with `multiple` and `grouped`, one bordered block like the `radio` cards) instead of one `F0Checkbox` each. Each card shows the option's title and, when the items are a `oneOf` of `{ const, title, description }`, its description. The value is the array the checkboxes write, in the options' order whatever the order of the clicks; `uniqueItems`, `minItems` / `maxItems`, `required`, `default`, errors, disabled/read-only and `ui:enumDisabled` work as for the checkboxes.
213
+
214
+ f0's cards take plain strings, so a markdown title is shown as its plain text (`Sync **daily**` reads "Sync daily") and a description as written; the checkboxes render a markdown label as markup. The same rule as the switch applies (`widgets/display-option.ts`): any other `display` on a `checkboxes` list logs a warning and keeps the checkboxes, and `"cards"` on anything else (a multi-select dropdown, a `radio`, a boolean) logs a warning and is ignored. The Forms SDK's own theme (the hosted `forms.js`) does not draw cards: it keeps the checkboxes.
215
+
198
216
  ### OAuth connect fields
199
217
 
200
218
  The Forms SDK's `"ui:widget": "oauth"` field opens the provider in a popup and reacts when the flow finishes; the widget logic ships in `@factorialco/fcode-react-forms`. This theme only contributes the control it draws, as `Theme.oauth.ConnectControl`: an `F0Button` (`default` while idle or waiting, `outline` with a check icon once connected) plus the flow's error message underneath. `FcodeJsonSchemaForm` finds it through `rjsfTheme.oauth`, the same way it finds `rjsfTheme.multistep`.
201
219
 
220
+ ### Steps
221
+
222
+ The Forms SDK's `ui:steps` splits a form into steps; the step engine ships in `@factorialco/fcode-react-forms`, and this theme draws its navigation as `Theme.multistep.StepsNavigation` (plus the Back button and the leave confirmation), which `FcodeJsonSchemaForm` finds through `rjsfTheme.multistep`. A wizard (`navigation: "linear"`, the default) is a step list like `F0WizardForm`'s, numbered badges that turn into a check once a step is done, beside the form (`sidebar`) or in a row above it (`tabs`). A settings form with `navigation: "free"` is not a wizard: in the `tabs` layout its steps are f0's own `Tabs`, as f0 settings pages draw theirs, and a step with errors gets a critical dot after its label (f0's tabs take text only); in the `sidebar` layout it keeps the step list, every step reachable and none ever checked. f0's `Tabs` keeps its own copy of the active tab and restores it when the active tab changes from outside, as when the SDK opens the first step with errors, so the theme remounts it on every change.
223
+
202
224
  ### Pairing tables
203
225
 
204
226
  The Forms SDK's `"ui:field": "pairing"` turns an object whose properties pair Factorial records with another system's (accounts, tax codes, wage types…) into one reviewable table. The rows, their suggestions, the in-use filter and the submitted values are all handled in `@factorialco/fcode-react-forms`. This theme contributes only the drawing, as `Theme.pairing.Table`, which `FcodeJsonSchemaForm` finds through `rjsfTheme.pairing`. The table has:
@@ -228,6 +250,14 @@ The select-all checkbox is handed to the editable table as that column's `label`
228
250
 
229
251
  Like the pairing table, it re-renders every row on each edit, so it suits tens of rows, not thousands.
230
252
 
253
+ ### Action buttons
254
+
255
+ The Forms SDK's `"ui:field": "button"` puts an extra way to submit the form beside the submit button — "Check connection" next to "Save". A click sets the boolean property to `true` and submits the form; that, and the validation, are handled in `@factorialco/fcode-react-forms`. This theme contributes only the drawing, as `Theme.button.Control`, which `FcodeJsonSchemaForm` finds through `rjsfTheme.button`: an `F0Button` in the variant the schema asked for with `ui:options.variant` (`outline` when absent, the look f0 forms give a secondary action), at f0's default `md` size, with the description under it. It is a `type="button"` and also prevents the default, so it never submits the form on its own.
256
+
257
+ The submit button reads `ui:submitButtonOptions.variant` itself, since this theme also renders standalone: `default` (primary) when absent, or `outline`, `neutral`, `critical`, `ghost`. An unknown value logs a warning and keeps `default`. The key is typed on RJSF's `UISchemaSubmitButtonOptions` by this package, and RJSF's own submit button ignores it.
258
+
259
+ A button can also stay disabled until a confirmation checkbox is ticked: `ui:submitButtonOptions.enabledWhen` (or `ui:options.enabledWhen` on an action button) names a root boolean property, and `disabledReason` explains why. The rule is resolved by `@factorialco/fcode-react-forms` against the live form data — this theme has no access to it — and reaches the theme already resolved: the submit gets `props.disabled: true` (RJSF's own way to disable it) plus `ui:submitButtonOptions.disabledReason`, the action button gets `disabled` plus `disabledReason`. Either way the reason becomes `F0Button`'s own `tooltip`, only while the button is disabled; f0 opens it on pointer hover even on a disabled button, after its usual one-second delay. The button stays natively `disabled`, so browsers do not submit through it on Enter. Rendered standalone, the theme draws a `disabledReason` whenever `props.disabled` is set and ignores `enabledWhen`. Both keys are typed on `UISchemaSubmitButtonOptions` by this package and never reach the DOM.
260
+
231
261
  ### Not yet f0
232
262
 
233
263
  - **`range`** renders as a number input rather than `F0Slider`.