|
1 | | -## [Unreleased] |
| 1 | +## [0.7.0] - 2026-03-01 |
2 | 2 |
|
3 | 3 | ### Added |
4 | 4 |
|
5 | 5 | - **Radio and checkbox groups** via `Field(:plan).radios(...)` and `Field(:roles).checkboxes(...)`. |
6 | | - Now return renderable Phlex components (like `input`, `select`) so they work as one-liners |
| 6 | + Return renderable Phlex components (like `input`, `select`) so they work as one-liners |
7 | 7 | via Kit. Without a block, renders default `<label><input> Text</label>` markup per choice. |
8 | | - With a block, yields each `Choice` for custom markup — choice methods (`.input`, |
9 | | - `.label`) render directly into the component's output. Accepts the same option formats as |
| 8 | + With a block, yields each `Choice` for custom markup — `choice.input` and |
| 9 | + `choice.label` render directly into the component's output. Accepts the same option formats as |
10 | 10 | `select`. Auto-detects Rails enums when called with no arguments. |
11 | 11 | `choice.label` without a block defaults to rendering `choice.text`. |
| 12 | + Subclass `Components::Radios` or `Components::Checkboxes` to customize defaults. |
12 | 13 | - **Hash options** for `select`, `radios`, and `checkboxes` — e.g. `radios(1 => "Basic", 2 => "Pro")`. |
13 | 14 | - **Radio component** with `field(:gender).radio("male")` API. Automatically handles name, value, and checked state. Each radio gets a unique DOM id based on its value (e.g. `user_gender_male`). |
14 | 15 | - **Checkbox collection support** — three modes: |
15 | 16 | - **Boolean** (on/off toggle): `Field(:featured).checkbox` renders with hidden "0" input |
16 | 17 | - **All-options** (pick from known set): `Field(:role_ids).checkbox(value: role.id)` with `[]` name and unique ids per value |
17 | 18 | - **Field collection** (from existing array): `field(:role_ids).collection { |r| r.checkbox }` for values already on the model |
| 19 | +- **Choices module** (`Superform::Rails::Choices`) — `Choices::Choice` holds per-option state, |
| 20 | + `Choices::Mapper` (renamed from `OptionMapper`) maps option args to `(value, text)` pairs. |
18 | 21 | - **Unique DOM ids** for radio and checkbox groups via `DOM#id(*suffixes)`. Prevents duplicate ids in valid HTML and allows labels to target individual inputs. |
19 | 22 | - **Select improvements**: blank options (`nil`) at any position, `multiple: true` support with hidden input for empty submissions, ActiveRecord relations as options. |
20 | 23 | - **Preview server** — run `bin/preview` to view example forms at localhost:3000 with hot-reloading. |
21 | 24 |
|
22 | 25 | ### Changed |
23 | 26 |
|
| 27 | +- `OptionMapper` renamed to `Choices::Mapper`. If you referenced `Superform::Rails::OptionMapper` directly, update to `Superform::Rails::Choices::Mapper`. |
24 | 28 | - **Deprecation**: Components now accept HTML attributes as keyword arguments directly instead of wrapping them in `attributes:`. The old `attributes:` keyword still works but emits a deprecation warning and will be removed in a future version. |
25 | 29 |
|
26 | 30 | ```ruby |
|
0 commit comments