Skip to content

Commit 876d58c

Browse files
committed
docs(mosaic): document SelectItem<Value> and the String(value) label fallback
1 parent b150832 commit 876d58c

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

‎packages/mosaic/src/primitives/select/README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ By default, the selected option visually aligns with the trigger. Disable this f
121121
| `open` | `boolean` | — | Controlled open state |
122122
| `defaultOpen` | `boolean` | `false` | Initial open state (uncontrolled) |
123123
| `onOpenChange` | `(open: boolean) => void` | — | Called when open state changes |
124-
| `items` | `SelectItem[]` | — | `{ label, value }` pairs for label resolution before options mount |
124+
| `items` | `SelectItem<Value>[]` | — | `{ label, value }` pairs for label resolution before options mount |
125125
| `alignItemWithTrigger` | `boolean` | `true` | Visually align selected option over the trigger |
126126
| `placement` | `Placement` | `"bottom-start"` | Floating UI placement |
127127
| `sideOffset` | `number` | `4` | Gap between trigger and popup (px) |
@@ -135,11 +135,11 @@ By default, the selected option visually aligns with the trigger. Disable this f
135135

136136
### `Select.Option`
137137

138-
| Prop | Type | Default | Description |
139-
| ---------- | --------- | --------------------- | --------------------------------------------- |
140-
| `value` | `unknown` | **required** | The option's value, compared with `Object.is` |
141-
| `label` | `string` | falls back to `value` | Display label, also used for typeahead |
142-
| `disabled` | `boolean` | — | Prevents selection |
138+
| Prop | Type | Default | Description |
139+
| ---------- | --------- | --------------- | --------------------------------------------- |
140+
| `value` | `unknown` | **required** | The option's value, compared with `Object.is` |
141+
| `label` | `string` | `String(value)` | Display label, also used for typeahead |
142+
| `disabled` | `boolean` | — | Prevents selection |
143143

144144
### `Select.Trigger`, `Select.Positioner`, `Select.Popup`
145145

‎packages/swingset/src/stories/select.mdx‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,21 @@ props. `Select.Portal` is optional.
104104

105105
### `Select.Root`
106106

107-
| Prop | Type | Default | Description |
108-
| --------------------------------- | ------------------------------------- | --------------------------- | -------------------------------------------------------------------- |
109-
| <code>multiple</code> | <code>boolean</code> | <code>false</code> | Allow selecting several options |
110-
| <code>value</code> | <code>Value \| null \| Value[]</code> | — | Controlled selected value; `null` for none, an array when `multiple` |
111-
| <code>defaultValue</code> | <code>Value \| null \| Value[]</code> | — | Initial selected value (uncontrolled); an array when `multiple` |
112-
| <code>onValueChange</code> | <code>(value) => void</code> | — | Called with the new value when the selection changes |
113-
| <code>open</code> | <code>boolean</code> | — | Controlled open state |
114-
| <code>defaultOpen</code> | <code>boolean</code> | <code>false</code> | Initial open state (uncontrolled) |
115-
| <code>onOpenChange</code> | <code>(open: boolean) => void</code> | — | Called when the open state changes |
116-
| <code>items</code> | <code>SelectItem[]</code> | — | `{ label, value }[]` used to resolve the selected label early |
117-
| <code>alignItemWithTrigger</code> | <code>boolean</code> | <code>true</code> | Overlay the selected item on the trigger (native-`<select>` style) |
118-
| <code>placement</code> | <code>Placement</code> | <code>'bottom-start'</code> | Placement when not aligning to the item |
119-
| <code>sideOffset</code> | <code>number</code> | <code>4</code> | Gap in px (applies only when `alignItemWithTrigger={false}`) |
120-
121-
`SelectItem` is `{ label: string; value: Value }` — disabling is done per-`Option`.
107+
| Prop | Type | Default | Description |
108+
| --------------------------------- | -------------------------------------- | --------------------------- | -------------------------------------------------------------------- |
109+
| <code>multiple</code> | <code>boolean</code> | <code>false</code> | Allow selecting several options |
110+
| <code>value</code> | <code>Value \| null \| Value[]</code> | — | Controlled selected value; `null` for none, an array when `multiple` |
111+
| <code>defaultValue</code> | <code>Value \| null \| Value[]</code> | — | Initial selected value (uncontrolled); an array when `multiple` |
112+
| <code>onValueChange</code> | <code>(value) => void</code> | — | Called with the new value when the selection changes |
113+
| <code>open</code> | <code>boolean</code> | — | Controlled open state |
114+
| <code>defaultOpen</code> | <code>boolean</code> | <code>false</code> | Initial open state (uncontrolled) |
115+
| <code>onOpenChange</code> | <code>(open: boolean) => void</code> | — | Called when the open state changes |
116+
| <code>items</code> | <code>SelectItem&lt;Value&gt;[]</code> | — | `{ label, value }[]` used to resolve the selected label early |
117+
| <code>alignItemWithTrigger</code> | <code>boolean</code> | <code>true</code> | Overlay the selected item on the trigger (native-`<select>` style) |
118+
| <code>placement</code> | <code>Placement</code> | <code>'bottom-start'</code> | Placement when not aligning to the item |
119+
| <code>sideOffset</code> | <code>number</code> | <code>4</code> | Gap in px (applies only when `alignItemWithTrigger={false}`) |
120+
121+
`SelectItem<Value>` is `{ label: string; value: Value }` — disabling is done per-`Option`.
122122

123123
### `Select.Value`
124124

@@ -129,11 +129,11 @@ props. `Select.Portal` is optional.
129129

130130
### `Select.Option`
131131

132-
| Prop | Type | Default | Description |
133-
| --------------------- | -------------------- | --------------------- | --------------------------------------------- |
134-
| <code>value</code> | <code>unknown</code> | — (required) | The option's value, compared with `Object.is` |
135-
| <code>label</code> | <code>string</code> | falls back to `value` | Display label, also used for typeahead |
136-
| <code>disabled</code> | <code>boolean</code> | — | Prevent selection (stays keyboard-focusable) |
132+
| Prop | Type | Default | Description |
133+
| --------------------- | -------------------- | --------------- | --------------------------------------------- |
134+
| <code>value</code> | <code>unknown</code> | — (required) | The option's value, compared with `Object.is` |
135+
| <code>label</code> | <code>string</code> | `String(value)` | Display label, also used for typeahead |
136+
| <code>disabled</code> | <code>boolean</code> | — | Prevent selection (stays keyboard-focusable) |
137137

138138
`Select.Trigger`, `Select.Positioner`, and `Select.Popup` take no additional props beyond
139139
standard HTML attributes for their default element. `Select.Portal` accepts `root`.

0 commit comments

Comments
 (0)