Product form
The product fields shared by the create and edit dialogs: name, description, unit price, a currency picker over the currencies the API accepts, and type (Product or Service), with client-side checks and the API's field errors beside their fields.
Component: A piece you place inside your own screens: a table, a form, a card or a dialog. You decide the layout around it. Pages vs components
Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.
Installation
Needs the Dolfin registry token. The CLI copies the source into your app.
bunx --bun shadcn@4.23.0 add @dolfin/ar-product-formAlso installs: button, command, input, label, popover, select, textarea, base-theme, ui-ar-product-form.
Usage
import { ArProductFormFields } from "@/components/dolfin/ar/product-form";
// Place it anywhere inside your <DolfinProvider>.
<ArProductFormFields values={values} onChange={handleChange} />Renders inside DolfinProvider (set it up once). By default it loads its own data through the SDK. Supplied-data examples show how to override that behavior.
API reference
| Prop | Type | Description |
|---|---|---|
values required | ProductFormValue | |
onChange required | (next: ProductFormValue) => void | |
errors | Readonly<Record<string, string | undefined>> | Messages by field: `name`, `description`, `unitPrice`, `currency`, `type`. |
idPrefix | string | Prefix for input ids (`product` gives `product-name`, `product-price`); keep it unique per page. |
autoFocus | boolean | |
disabled | boolean | |
lockCurrency | boolean | Fix the currency (e.g. a product created from an invoice must match the invoice's). |
currencies | readonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[] | The currencies to offer, instead of loading them. |
children | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Extra fields after the type (e.g. an income account when accounting sync is on). |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
ar.productscore.errors
Or edit the installed file directly: it is your code. See theming for colours and fonts.
Hooks
The SDK hooks this component uses. Use them directly from @dolfinai/react to build your own version.
useMessagesuseProductCurrenciesFiles
Written to your app by the install command:
components/dolfin/ar/product-form.tsx169 linescomponents/dolfin/ar/product-currency-combobox.tsx61 lines