Skip to content

Commit b150832

Browse files
committed
docs(swingset): update Select and SegmentedControl value types in stories
1 parent 249a846 commit b150832

5 files changed

Lines changed: 43 additions & 43 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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` | `string` | **required** | The option's value |
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` | falls back to `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/segmented-control.mdx‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ The selected pill is `.cl-segmented-control-indicator`. Style that class to rest
4242

4343
### `SegmentedControl.Root`
4444

45-
| Prop | Type | Default | Description |
46-
| --------------- | ------------------------- | ------- | --------------------------------- |
47-
| `value` | `string` | — | Controlled selected value |
48-
| `defaultValue` | `string` | `""` | Initial selected value |
49-
| `onValueChange` | `(value: string) => void` | — | Called when the selection changes |
50-
| `disabled` | `boolean` | `false` | Disables every item |
45+
| Prop | Type | Default | Description |
46+
| --------------- | ------------------------ | ------- | --------------------------------- |
47+
| `value` | `Value` | — | Controlled selected value |
48+
| `defaultValue` | `Value` | — | Initial selected value |
49+
| `onValueChange` | `(value: Value) => void` | — | Called when the selection changes |
50+
| `disabled` | `boolean` | `false` | Disables every item |
5151

5252
### `SegmentedControl.Item`
5353

54-
| Prop | Type | Default | Description |
55-
| ---------- | --------- | ------------ | ------------------------------------- |
56-
| `value` | `string` | **required** | Unique option identifier |
57-
| `disabled` | `boolean` | — | Disables the item; it stays focusable |
54+
| Prop | Type | Default | Description |
55+
| ---------- | --------- | ------------ | --------------------------------------------------- |
56+
| `value` | `unknown` | **required** | Unique option identifier, compared with `Object.is` |
57+
| `disabled` | `boolean` | — | Disables the item; it stays focusable |
5858

5959
## Disabled
6060

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ const [value, setValue] = useState('member');
200200

201201
### Multiple
202202

203-
`multiple` makes the value a `string[]`. Picking an option adds or removes it and keeps the list
203+
`multiple` makes the value an array. Picking an option adds or removes it and keeps the list
204204
open, and every selected row shows the check. The trigger lists the selected labels separated by
205205
commas; pass a function as its children to render the value yourself.
206206

207207
```tsx
208-
function renderValue(value: string[]) {
208+
function renderValue(value: unknown[]) {
209209
if (value.length === 0) {
210210
return 'Select languages';
211211
}

‎packages/swingset/src/stories/select.component.stories.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ const languages = [
211211
{ value: 'swift', label: 'Swift' },
212212
];
213213

214-
function renderLanguages(value: string[]) {
214+
function renderLanguages(value: unknown[]) {
215215
if (value.length === 0) {
216216
return 'Select languages';
217217
}

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const [value, setValue] = useState('apple');
6060

6161
### Multiple
6262

63-
`multiple` makes the value a `string[]`. Picking an option adds or removes it and keeps the
63+
`multiple` makes the value an array. Picking an option adds or removes it and keeps the
6464
popup open. `Select.Value` shows the selected labels joined with commas; pass a function as
6565
its children to render the selection yourself.
6666

@@ -104,36 +104,36 @@ 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>string \| string[]</code> | — | Controlled selected value; an array when `multiple` |
111-
| <code>defaultValue</code> | <code>string \| string[]</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: string }` — 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[]</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`.
122122

123123
### `Select.Value`
124124

125-
| Prop | Type | Default | Description |
126-
| ------------------------ | ---------------------------------------------------------- | ------- | --------------------------------------------------------------------- |
127-
| <code>placeholder</code> | <code>ReactNode</code> | — | Rendered when no value is selected |
128-
| <code>children</code> | <code>ReactNode \| ((value: string[]) => ReactNode)</code> | — | Replaces the selected labels; a function receives the selected values |
125+
| Prop | Type | Default | Description |
126+
| ------------------------ | ----------------------------------------------------------- | ------- | --------------------------------------------------------------------- |
127+
| <code>placeholder</code> | <code>ReactNode</code> | — | Rendered when no value is selected |
128+
| <code>children</code> | <code>ReactNode \| ((value: unknown[]) => ReactNode)</code> | — | Replaces the selected labels; a function receives the selected values |
129129

130130
### `Select.Option`
131131

132-
| Prop | Type | Default | Description |
133-
| --------------------- | -------------------- | --------------------- | -------------------------------------------- |
134-
| <code>value</code> | <code>string</code> | — (required) | The option's value |
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> | falls back to `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)