Skip to content

Commit 5d5d810

Browse files
fix(registry): correct Select metadata types and add missing props for object values (#471)
1 parent 62e093c commit 5d5d810

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@cloudflare/kumo": patch
3+
---
4+
5+
fix(registry): correct Select component metadata for AI-generated code
6+
7+
The component registry metadata was incorrectly typing Select's `value`, `defaultValue`, and `onValueChange` props as `string`, causing AI agents to produce broken code when implementing Select with object values (e.g., rendering `object.value` in the trigger instead of the label).
8+
9+
Changes:
10+
- `value` type: `string``T` (generic, matches actual component interface)
11+
- `defaultValue` type: `string``T`
12+
- `onValueChange` type: `(value: string) => void``(value: T) => void`
13+
- Added missing `renderValue` prop: `(value: T) => ReactNode` — required for object values
14+
- Added missing `items` prop: supports both `Record<string, string>` and `Array<{ label, value }>` forms
15+
- Added missing `isItemEqualToValue` prop: required for object equality comparison

packages/kumo/scripts/component-registry/metadata.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,28 @@ export const ADDITIONAL_COMPONENT_PROPS: Record<
289289
},
290290
Select: {
291291
onValueChange: {
292-
type: "(value: string) => void",
292+
type: "(value: T) => void",
293293
description: "Callback when selection changes",
294294
},
295295
defaultValue: {
296-
type: "string",
296+
type: "T",
297297
description: "Initial value for uncontrolled mode",
298298
},
299+
renderValue: {
300+
type: "(value: T) => ReactNode",
301+
description:
302+
"A function that returns a ReactNode to format the selected value in the trigger. Required when using object values. Use `placeholder` for the empty state.",
303+
},
304+
items: {
305+
type: 'Record<string, string> | Array<{ label: ReactNode; value: T }>',
306+
description:
307+
"Data structure of items rendered in the popup. Accepts a plain object map (`{ key: \"Label\" }`) or an array of `{ label, value }` for object/complex values.",
308+
},
309+
isItemEqualToValue: {
310+
type: "(item: T, value: T) => boolean",
311+
description:
312+
"Custom equality function for comparing items. Required when value is an object, since object identity (`===`) won't match across renders.",
313+
},
299314
},
300315
DateRangePicker: {
301316
onStartDateChange: {
@@ -532,7 +547,7 @@ export const PROP_TYPE_OVERRIDES: Record<string, Record<string, string>> = {
532547
value: "T | T[]",
533548
},
534549
Select: {
535-
value: "string",
550+
value: "T",
536551
},
537552
};
538553

0 commit comments

Comments
 (0)