Skip to content

Commit 95614cd

Browse files
Copilothuangyiirene
andcommitted
Add JSDoc comments for select/multiselect field helpers
Document backward-compatible API with examples for both old and new signatures Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 4326c5a commit 95614cd

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

packages/spec/src/data/field.zod.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ export const Field = {
122122
html: (config: FieldInput = {}) => ({ type: 'html', ...config } as const),
123123
password: (config: FieldInput = {}) => ({ type: 'password', ...config } as const),
124124

125+
/**
126+
* Select field helper with backward-compatible API
127+
*
128+
* @example Old API (array first)
129+
* Field.select(['High', 'Low'], { label: 'Priority' })
130+
*
131+
* @example New API (config object)
132+
* Field.select({ options: [{label: 'High', value: 'high'}], label: 'Priority' })
133+
*/
125134
select: (optionsOrConfig: SelectOption[] | string[] | FieldInput & { options: SelectOption[] | string[] }, config?: FieldInput) => {
126135
// Support both old and new signatures:
127136
// Old: Field.select(['a', 'b'], { label: 'X' })
@@ -142,6 +151,15 @@ export const Field = {
142151
return { type: 'select', ...finalConfig, options } as const;
143152
},
144153

154+
/**
155+
* Multiselect field helper with backward-compatible API
156+
*
157+
* @example Old API (array first)
158+
* Field.multiselect(['Tag1', 'Tag2'], { label: 'Tags' })
159+
*
160+
* @example New API (config object)
161+
* Field.multiselect({ options: [{label: 'Tag 1', value: 'tag1'}], label: 'Tags' })
162+
*/
145163
multiselect: (optionsOrConfig: SelectOption[] | string[] | FieldInput & { options: SelectOption[] | string[] }, config?: FieldInput) => {
146164
// Support both old and new signatures
147165
let options: SelectOption[];

0 commit comments

Comments
 (0)