diff --git a/docs/choice-inputs/searchable-select.md b/docs/choice-inputs/searchable-select.md
index 83e07787..654b1d14 100644
--- a/docs/choice-inputs/searchable-select.md
+++ b/docs/choice-inputs/searchable-select.md
@@ -108,7 +108,7 @@ While `onCreate` runs the row shows "Creating…"; if it throws, the row shows "
## Dependent fields
-A field whose options depend on another (atoll → island): pass `parentValue`. The field is disabled until the parent has a value (the placeholder says which field to fill first) and **clears itself whenever the parent changes**: `onValueChange(null)` (or `[]` for multiple) is called. `options` can then be a map keyed by the parent value or a function of it. For options from an API, [API select](./api-select) takes the same props and sends the parent value with each request.
+A field whose options depend on another (atoll → island): pass `parentValue`. The field is disabled until the parent has a value (the placeholder says which field to fill first) and **clears itself whenever the parent changes**: `onValueChange(null)` (or `[]` for multiple) is called. A value that arrives in the same render as its parent (react-hook-form's `reset(data)`, or an edit page that fetches both) is kept, and so is one set while the field waits for its parent. `options` can then be a map keyed by the parent value or a function of it. For options from an API, [API select](./api-select) takes the same props and sends the parent value with each request.
```tsx
import { ApiSelect, SearchableSelect, Select } from '@javaabu/onu';
diff --git a/docs/choice-inputs/select.md b/docs/choice-inputs/select.md
index 6b103464..ff4e6c89 100644
--- a/docs/choice-inputs/select.md
+++ b/docs/choice-inputs/select.md
@@ -27,8 +27,8 @@ Options with the same `group` are listed under that heading. Options may be plai
| Prop | Type | Default | Description |
| --------------------------------------- | ----------------------------------------- | ------------------ | ------------------------------------------------------------- |
| `options` | `(ChoiceOption \| string)[]` | | Options; or pass `SelectItem` / `SelectGroup` children |
-| `value` / `defaultValue` | `string` | `""` | Selected value; `""` shows the placeholder |
-| `onValueChange` | `(value: string) => void` | | Also called with `""` when cleared |
+| `value` / `defaultValue` | `string \| null` | `null` | Selected value; `null` shows the placeholder |
+| `onValueChange` | `(value: string \| null, option) => void` | | `(null, null)` when cleared; `option` is `null` for children |
| `placeholder` | `string` | "Select an option" | Text when empty |
| `clearable` | `boolean` | `false` | Show a clear button when a value is set; hidden when required |
| `size` | `"sm" \| "default" \| "lg"` | `"default"` | Trigger height |
@@ -42,7 +42,7 @@ Other button props (`aria-label`, `id`, …) and `ref` go to the trigger button.
:::info
-`Select` replaces shadcn's `Select` root in the main export. It stays compatible: if its children contain `SelectTrigger` and `SelectContent`, it behaves exactly like the shadcn root. The primitive is still available from `@javaabu/onu/primitives`. Differences: it always manages the value (so it can be cleared), and an empty value is `""`.
+`Select` replaces shadcn's `Select` root in the main export. It stays compatible: if its children contain `SelectTrigger` and `SelectContent`, it behaves exactly like the shadcn root. The primitive is still available from `@javaabu/onu/primitives`. Differences: it always manages the value (so it can be cleared), an empty value is `null`, and `onValueChange` also gets the option, like `SearchableSelect` and `ApiSelect`.
:::
diff --git a/docs/date-and-time/date-range-picker.md b/docs/date-and-time/date-range-picker.md
index da6aba60..f14d1dee 100644
--- a/docs/date-and-time/date-range-picker.md
+++ b/docs/date-and-time/date-range-picker.md
@@ -17,7 +17,7 @@ const [range, setRange] = React.useState({ from: null, to: null
- Either end may be `null` for an open-ended range ("from 1 March onwards", "up to 31 March").
- Without `withTime`, `to` is the **end of that day** (23:59:59.999). With `withTime`, the To field's time defaults to 23:59.
- If To is before From, the message "End date is before start date" shows under the fields and both triggers are marked invalid.
-- With `name`, hidden inputs post `name[from]` and `name[to]` (`yyyy-MM-dd`, or ISO date-time with `withTime`); override them with `names`.
+- With `name`, hidden inputs post `name[from]` and `name[to]` (`yyyy-MM-dd`, or ISO date-time with `withTime`); override them with `names`, which also works without `name`.
- The fields stack in narrow containers (container query).
## Props
diff --git a/docs/text-inputs/phone-input.md b/docs/text-inputs/phone-input.md
index c3b081d8..3080c70a 100644
--- a/docs/text-inputs/phone-input.md
+++ b/docs/text-inputs/phone-input.md
@@ -3,7 +3,7 @@ title: PhoneInput
sidebar_position: 9
---
-An international phone number input built on [`react-phone-number-input`](https://gitlab.com/catamphetamine/react-phone-number-input) (libphonenumber). It formats the number as you type, defaults to the Maldives (+960), has a searchable country picker built from Onu's `Popover` and `Command`, and returns an [E.164](https://en.wikipedia.org/wiki/E.164) value such as `+9607771234`.
+An international phone number input built on [`react-phone-number-input`](https://gitlab.com/catamphetamine/react-phone-number-input) (libphonenumber). It formats the number as you type, defaults to the Maldives (+960), has a searchable country picker built from Onu's `Popover` and `Command`, and returns an [E.164](https://en.wikipedia.org/wiki/E.164) value such as `+9607771234`. With a `name` (or inside a `FormField`), the form submits that E.164 value, not the formatted text.
```tsx
import { PhoneInput } from "@javaabu/onu"
diff --git a/figma/plugin/code.js b/figma/plugin/code.js
index 43bfac18..b1427456 100644
--- a/figma/plugin/code.js
+++ b/figma/plugin/code.js
@@ -2,7 +2,7 @@
(function() {
//#region ../packages/onu/package.json
- var version = "0.3.1";
+ var version = "0.3.2";
//#endregion
//#region ../tokens.json
diff --git a/packages/onu-mcp/CHANGELOG.md b/packages/onu-mcp/CHANGELOG.md
index fad5a59f..46e470a8 100644
--- a/packages/onu-mcp/CHANGELOG.md
+++ b/packages/onu-mcp/CHANGELOG.md
@@ -1,5 +1,9 @@
# @javaabu/onu-mcp
+## 0.3.2
+
+No changes in this release.
+
## 0.3.1
No changes in this release.
diff --git a/packages/onu-mcp/package.json b/packages/onu-mcp/package.json
index 33e2ff4a..fb6a9897 100644
--- a/packages/onu-mcp/package.json
+++ b/packages/onu-mcp/package.json
@@ -1,6 +1,6 @@
{
"name": "@javaabu/onu-mcp",
- "version": "0.3.1",
+ "version": "0.3.2",
"description": "MCP server for Onu (@javaabu/onu): gives AI assistants the component docs and the rules for writing Onu code.",
"license": "MIT",
"author": {
diff --git a/packages/onu/CHANGELOG.md b/packages/onu/CHANGELOG.md
index 64a6858c..069bee74 100644
--- a/packages/onu/CHANGELOG.md
+++ b/packages/onu/CHANGELOG.md
@@ -1,5 +1,20 @@
# @javaabu/onu
+## 0.3.2
+
+### Patch Changes
+
+- ac87774: `Button` and `LinkButton` keep `data-slot="button"` when a caller passes its own `data-slot`, so the 44px touch-target rule still applies. Use `data-part` to tag a button.
+- b3b347a: `DateRangePicker` submits under `names` (for example `{ from: "start", to: "end" }`) without `name` too. It used to submit nothing unless `name` was also set.
+- aa000a1: Dependent `SearchableSelect` and `ApiSelect` fields (`parentValue`) keep a value that arrives together with the parent, as with react-hook-form's `reset(data)` or an edit page that fetches both, and a value set while the field waits for its parent. They still clear when the parent changes after the value was settled.
+- 4be1c44: `Form` passes the button that submitted it to `onSubmit`'s values, so `
) : null}
- {name ? (
- <>
-
-
- >
- ) : null}
+
+
)
}
diff --git a/packages/onu/src/components/date/date-time-picker.tsx b/packages/onu/src/components/date/date-time-picker.tsx
index 54a704c0..bedb1eb7 100644
--- a/packages/onu/src/components/date/date-time-picker.tsx
+++ b/packages/onu/src/components/date/date-time-picker.tsx
@@ -7,7 +7,7 @@ import { Icon } from "../../icons/icon"
import { useOnu } from "../../providers/onu-provider"
import { Button } from "../../ui/button"
import { DateCalendar } from "./date-calendar"
-import { HiddenInput, PickerShell, type PickerFieldProps } from "./_picker-shell"
+import { PickerShell, type PickerFieldProps } from "./_picker-shell"
import {
DEFAULT_DATE_FORMAT,
defaultTimeFormat,
@@ -97,7 +97,7 @@ export function DateTimePicker({
placeholder={placeholder ?? t("date.selectDateTime")}
panelLabel={t("date.chooseDateTime")}
announcement={display ? t("date.selected", { value: display }) : ""}
- hidden={(name) => }
+ submit={(name) => [[name, value ? toISODateTime(value) : ""]]}
onClear={() => {
setValue(null)
setPendingTime(null)
diff --git a/packages/onu/src/components/date/hijri-date-picker.tsx b/packages/onu/src/components/date/hijri-date-picker.tsx
index 0475befd..176e9a8e 100644
--- a/packages/onu/src/components/date/hijri-date-picker.tsx
+++ b/packages/onu/src/components/date/hijri-date-picker.tsx
@@ -9,7 +9,7 @@ import { DEFAULT_WEEKEND_DAYS } from "./date-calendar"
import { CalendarHeader } from "./_calendar-header"
import { addHijriMonths, fromHijri, hijriDaysInMonth, toHijri, type HijriParts } from "./_hijri"
import { PeriodGrid } from "./_period-grid"
-import { HiddenInput, PickerShell, type PickerFieldProps } from "./_picker-shell"
+import { PickerShell, type PickerFieldProps } from "./_picker-shell"
import { DEFAULT_DATE_FORMAT, formatDate, isOutOfRange, toISODate, yearBlockStart } from "./_utils"
import { formatHijriParts, hijriMonthName, type HijriFormat } from "./hijri-date"
import { registerEnglish } from "../../i18n/english"
@@ -374,7 +374,7 @@ export function HijriDatePicker({
placeholder={placeholder ?? t("date.selectHijriDate")}
panelLabel={t("date.chooseDate")}
announcement={value ? t("date.selected", { value: formatHijriParts(toHijri(value), t, "long") }) : ""}
- hidden={(name) => }
+ submit={(name) => [[name, value ? toISODate(value) : ""]]}
onClear={() => setValue(null)}
>
{({ close }) => (
diff --git a/packages/onu/src/components/date/reporting-period-picker.tsx b/packages/onu/src/components/date/reporting-period-picker.tsx
index b3751701..41f36f56 100644
--- a/packages/onu/src/components/date/reporting-period-picker.tsx
+++ b/packages/onu/src/components/date/reporting-period-picker.tsx
@@ -9,7 +9,7 @@ import { ToggleGroup, ToggleGroupItem } from "../../ui/toggle-group"
import { DateCalendar } from "./date-calendar"
import { CalendarHeader } from "./_calendar-header"
import { PeriodGrid } from "./_period-grid"
-import { HiddenInput, PickerShell, type PickerFieldProps } from "./_picker-shell"
+import { PickerShell, type PickerFieldProps } from "./_picker-shell"
import { DEFAULT_DATE_FORMAT, formatDate, toISODate, yearBlockStart, type DateRangeValue } from "./_utils"
import { registerEnglish } from "../../i18n/english"
import { date as en_date } from "../../locales/en/date"
@@ -125,13 +125,11 @@ export function ReportingPeriodPicker({
placeholder={placeholder ?? t("date.selectPeriod")}
panelLabel={t("date.choosePeriod")}
announcement={display ? t("date.selected", { value: display }) : ""}
- hidden={(name) => (
- <>
-
-
-
- >
- )}
+ submit={(name) => [
+ [`${name}[type]`, value?.type ?? ""],
+ [`${name}[from]`, value ? toISODate(value.from) : ""],
+ [`${name}[to]`, value ? toISODate(value.to) : ""],
+ ]}
onClear={() => {
setValue(null)
setPending(null)
diff --git a/packages/onu/src/components/date/time-picker.tsx b/packages/onu/src/components/date/time-picker.tsx
index a681c6aa..944bdab2 100644
--- a/packages/onu/src/components/date/time-picker.tsx
+++ b/packages/onu/src/components/date/time-picker.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { useOnu } from "../../providers/onu-provider"
-import { HiddenInput, PickerShell, type PickerFieldProps } from "./_picker-shell"
+import { PickerShell, type PickerFieldProps } from "./_picker-shell"
import { defaultTimeFormat, formatDate, getTimeValue, toISOTime, withTime } from "./_utils"
import { TimePanel } from "./time-panel"
import { registerEnglish } from "../../i18n/english"
@@ -57,7 +57,7 @@ export function TimePicker({
placeholder={placeholder ?? t("date.selectTime")}
panelLabel={t("date.chooseTime")}
announcement={display ? t("date.selected", { value: display }) : ""}
- hidden={(name) => }
+ submit={(name) => [[name, value ? toISOTime(value) : ""]]}
onClear={() => setValue(null)}
>
],
+ ["TagsInput", ],
+ ["SearchableSelect", ],
+ ["DatePicker", ],
+ ["ColorPicker", ],
+ ["IconPicker", ],
+ ["SegmentedControl", ],
+ ["DualListbox", ],
+ ["Rating", ],
+]
+
+describe("composite controls' submitted value", () => {
+ it.each(controls)("%s submits nothing inside a disabled FormField", (_, control) => {
+ const { container } = renderWithOnu(
+ ,
+ )
+ const values = formDataToObject(new FormData(container.querySelector("form")!))
+ expect(Object.keys(values)).toEqual([])
+ })
+
+ it.each(controls)("%s submits its value inside an enabled FormField", (_, control) => {
+ const { container } = renderWithOnu(
+ ,
+ )
+ const data = new FormData(container.querySelector("form")!)
+ expect([...data.keys()].some((key) => key === "field" || key === "field[]")).toBe(true)
+ })
+
+ it("clears a NumberInput's server error when it is edited", async () => {
+ renderWithOnu(
+ ,
+ )
+ await userEvent.click(screen.getByRole("button", { name: "Save" }))
+ await waitFor(() => expect(screen.getByRole("spinbutton", { name: "Amount" })).toHaveFocus())
+ await userEvent.type(screen.getByRole("spinbutton", { name: "Amount" }), "2")
+ expect(screen.queryAllByText("Too small")).toHaveLength(0)
+ })
+
+ it("lets the summary focus a NumberInput, a DatePicker and an empty TagsInput from the field name", async () => {
+ renderWithOnu(
+ ,
+ )
+ const links = screen.getAllByRole("link", { name: "Required" })
+ await userEvent.click(links[0]!)
+ await waitFor(() => expect(screen.getByRole("spinbutton", { name: "Amount" })).toHaveFocus())
+ await userEvent.click(links[1]!)
+ await waitFor(() =>
+ expect(document.activeElement).toBe(document.getElementById(screen.getByText("Date").closest("label")!.htmlFor)),
+ )
+ await userEvent.click(links[2]!)
+ await waitFor(() => expect(screen.getByRole("combobox", { name: "Tags" })).toHaveFocus())
+ })
+})
diff --git a/packages/onu/src/components/form/_field-value.tsx b/packages/onu/src/components/form/_field-value.tsx
new file mode 100644
index 00000000..8b8f88ff
--- /dev/null
+++ b/packages/onu/src/components/form/_field-value.tsx
@@ -0,0 +1,64 @@
+"use client"
+
+import * as React from "react"
+
+import { useClearFieldError } from "./form-context"
+import { useFormField } from "./form-field"
+
+export type FieldValueValue = string | number | null | undefined | readonly string[]
+
+export interface FieldValueProps {
+ /** Field name. Nothing renders without one. Arrays submit as `name[]`. */
+ name?: string
+ /** Value to submit. `null`/`undefined` submit an empty string; an array submits one input per item. */
+ value: FieldValueValue
+ /** `id` of the visible control, so errors for `name` can find and focus it. Defaults to the FormField's `id`. */
+ control?: string
+ /** The control's own disabled state. A disabled `FormField` disables the value too. */
+ disabled?: boolean
+ /** `form` attribute, for controls outside their `