Skip to content

Commit ce3c553

Browse files
committed
Bump version to 0.12.78
1 parent 999b2dc commit ce3c553

11 files changed

Lines changed: 146 additions & 8 deletions

File tree

packages/asterui/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ description: All notable changes to AsterUI
77

88
All notable changes to AsterUI are documented here.
99

10+
## v0.12.78 (2025-12-28)
11+
12+
### Components
13+
14+
- **Select**: Added `options` prop for array-based options with better performance
15+
- **Select**: Added `SelectOption` interface with `label`, `value`, and `disabled` properties
16+
17+
### Documentation
18+
19+
- Added "Options Array" example to Select documentation
20+
- Updated Select API documentation to include `options` prop and `SelectOption` interface
21+
- Updated AI-readable Select documentation
22+
1023
## v0.12.77 (2025-12-28)
1124

1225
### Components

packages/asterui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "asterui",
3-
"version": "0.12.77",
3+
"version": "0.12.78",
44
"description": "React UI component library with DaisyUI",
55
"homepage": "https://asterui.com",
66
"repository": {

packages/asterui/src/components/Select.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ const dSelectWarning = 'select-warning'
2020
const dSelectError = 'select-error'
2121
const dFloatingLabel = 'floating-label'
2222

23+
export interface SelectOption {
24+
label: React.ReactNode
25+
value: string | number
26+
disabled?: boolean
27+
}
28+
2329
export interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
2430
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
2531
color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error'
@@ -33,6 +39,8 @@ export interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectE
3339
addonBefore?: React.ReactNode
3440
/** Text/element after select (outside, using DaisyUI label) */
3541
addonAfter?: React.ReactNode
42+
/** Select options array (recommended for better performance) */
43+
options?: SelectOption[]
3644
className?: string
3745
children?: React.ReactNode
3846
'data-testid'?: string
@@ -49,6 +57,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
4957
floatingLabel,
5058
addonBefore,
5159
addonAfter,
60+
options,
5261
className = '',
5362
children,
5463
'data-testid': testId,
@@ -59,6 +68,18 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
5968
const { componentSize } = useConfig()
6069
const effectiveSize = size ?? componentSize ?? 'md'
6170

71+
// Render options from array or use children
72+
const renderOptions = () => {
73+
if (options) {
74+
return options.map((option) => (
75+
<option key={option.value} value={option.value} disabled={option.disabled}>
76+
{option.label}
77+
</option>
78+
))
79+
}
80+
return children
81+
}
82+
6283
const innerRef = useRef<HTMLSelectElement>(null)
6384
const selectRef = (ref as React.RefObject<HTMLSelectElement>) || innerRef
6485

@@ -110,7 +131,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
110131
// Build the core select element
111132
const selectElement = (
112133
<select ref={selectRef} className={selectClasses} data-testid={selectTestId} {...props}>
113-
{children}
134+
{renderOptions()}
114135
</select>
115136
)
116137

@@ -129,7 +150,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
129150
data-testid={selectTestId}
130151
{...props}
131152
>
132-
{children}
153+
{renderOptions()}
133154
</select>
134155
<span>{floatingLabel}</span>
135156
</label>

packages/asterui/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export { Result } from './components/Result'
247247
export type { ResultProps, ResultStatus } from './components/Result'
248248

249249
export { Select } from './components/Select'
250-
export type { SelectProps } from './components/Select'
250+
export type { SelectProps, SelectOption } from './components/Select'
251251

252252
export { Segmented } from './components/Segmented'
253253
export type { SegmentedProps, SegmentedItemProps, SegmentedValue } from './components/Segmented'

packages/docs/public/docs/select.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@ const App: React.FC = () => (
4343
export default App
4444
```
4545

46+
### Options Array
47+
48+
Use the `options` prop for better performance compared to JSX children.
49+
50+
```tsx
51+
import React from 'react'
52+
import { Select, SelectOption } from 'asterui'
53+
54+
const App: React.FC = () => {
55+
const options: SelectOption[] = [
56+
{ label: 'Apple', value: 'apple' },
57+
{ label: 'Orange', value: 'orange' },
58+
{ label: 'Banana', value: 'banana' },
59+
{ label: 'Grape', value: 'grape' },
60+
{ label: 'Mango (disabled)', value: 'mango', disabled: true },
61+
]
62+
63+
return <Select options={options} defaultValue="orange" />
64+
}
65+
66+
export default App
67+
```
68+
4669
### Sizes
4770

4871
```tsx
@@ -275,8 +298,11 @@ export default App
275298

276299
## API
277300

301+
### Select
302+
278303
| Property | Description | Type | Default |
279304
|----------|-------------|------|---------|
305+
| `options` | Select options array (recommended for better performance) | `SelectOption[]` | `-` |
280306
| `size` | Select size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `-` |
281307
| `color` | Select color variant | `'neutral' \| 'primary' \| 'secondary' \| 'accent' \| 'info' \| 'success' \| 'warning' \| 'error'` | `-` |
282308
| `status` | Validation status (takes precedence over color) | `'error' \| 'warning'` | `-` |
@@ -291,3 +317,11 @@ export default App
291317
| `onChange` | Change event handler | `(e: React.ChangeEvent<HTMLSelectElement>) => void` | `-` |
292318
| `className` | Additional CSS classes | `string` | `-` |
293319
| `data-testid` | Test ID for testing | `string` | - |
320+
321+
### SelectOption
322+
323+
| Property | Description | Type | Default |
324+
|----------|-------------|------|---------|
325+
| `label` | Display label for the option | `React.ReactNode` | `-` |
326+
| `value` | Value of the option | `string \| number` | `-` |
327+
| `disabled` | Whether option is disabled | `boolean` | `false` |

packages/docs/src/components/SelectDemo.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { Select, Space, Form, Button } from '@aster-ui/prefixed';
3+
import type { SelectOption } from '@aster-ui/prefixed';
34
import { Demo } from './Demo';
45

56
// @example-imports: { Select } from 'asterui'
@@ -37,6 +38,27 @@ export function DefaultValueDemo() {
3738
);
3839
}
3940

41+
// @example-imports: { Select, SelectOption } from 'asterui'
42+
export function OptionsDemo() {
43+
// @example-include
44+
const options: SelectOption[] = [
45+
{ label: 'Apple', value: 'apple' },
46+
{ label: 'Orange', value: 'orange' },
47+
{ label: 'Banana', value: 'banana' },
48+
{ label: 'Grape', value: 'grape' },
49+
{ label: 'Mango (disabled)', value: 'mango', disabled: true },
50+
];
51+
// @example-include-end
52+
53+
return (
54+
<Demo>
55+
{/* @example-return */}
56+
<Select options={options} defaultValue="orange" />
57+
{/* @example-return-end */}
58+
</Demo>
59+
);
60+
}
61+
4062
// @example-imports: { Select, Space } from 'asterui'
4163
export function SizesDemo() {
4264
return (

packages/docs/src/content/docs/changelog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ description: All notable changes to AsterUI
77

88
All notable changes to AsterUI are documented here.
99

10+
## v0.12.78 (2025-12-28)
11+
12+
### Components
13+
14+
- **Select**: Added `options` prop for array-based options with better performance
15+
- **Select**: Added `SelectOption` interface with `label`, `value`, and `disabled` properties
16+
17+
### Documentation
18+
19+
- Added "Options Array" example to Select documentation
20+
- Updated Select API documentation to include `options` prop and `SelectOption` interface
21+
- Updated AI-readable Select documentation
22+
1023
## v0.12.77 (2025-12-28)
1124

1225
### Components

packages/docs/src/content/docs/components/select.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ tableOfContents: false
77
import {
88
BasicDemo,
99
DefaultValueDemo,
10+
OptionsDemo,
1011
SizesDemo,
1112
ColorsDemo,
1213
GhostDemo,
@@ -36,6 +37,10 @@ import { Select } from 'asterui'
3637
<DefaultValueDemo client:load slot="demo" />
3738
</Example>
3839

40+
<Example title="Options Array" description="Use options prop for better performance." source={SelectDemoSource} fn="OptionsDemo">
41+
<OptionsDemo client:load slot="demo" />
42+
</Example>
43+
3944
<Example title="Sizes" description="Five sizes: xs, sm, md, lg, and xl." source={SelectDemoSource} fn="SizesDemo">
4045
<SizesDemo client:load slot="demo" />
4146
</Example>
@@ -64,6 +69,7 @@ import { Select } from 'asterui'
6469

6570
| Property | Description | Type | Default |
6671
|----------|-------------|------|---------|
72+
| `options` | Select options array (recommended for better performance) | `SelectOption[]` | - |
6773
| `size` | Select size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | - |
6874
| `color` | Select color theme | `'neutral' \| 'primary' \| 'secondary' \| 'accent' \| 'info' \| 'success' \| 'warning' \| 'error'` | - |
6975
| `ghost` | Ghost style variant | `boolean` | `false` |
@@ -73,6 +79,14 @@ import { Select } from 'asterui'
7379
| `children` | Option elements | `React.ReactNode` | - |
7480
| `data-testid` | Test ID for testing | `string` | - |
7581

82+
### `SelectOption`
83+
84+
| Property | Description | Type | Default |
85+
|----------|-------------|------|---------|
86+
| `label` | Display label for the option | `React.ReactNode` | - |
87+
| `value` | Value of the option | `string \| number` | - |
88+
| `disabled` | Whether option is disabled | `boolean` | `false` |
89+
7690
## Accessibility
7791

7892
- Uses native `<select>` for full accessibility

packages/prefixed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aster-ui/prefixed",
3-
"version": "0.12.77",
3+
"version": "0.12.78",
44
"description": "React UI component library with DaisyUI (prefixed classes)",
55
"homepage": "https://asterui.com",
66
"repository": {

packages/prefixed/src/components/Select.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ const dSelectWarning = 'd-select-warning'
2020
const dSelectError = 'd-select-error'
2121
const dFloatingLabel = 'd-floating-label'
2222

23+
export interface SelectOption {
24+
label: React.ReactNode
25+
value: string | number
26+
disabled?: boolean
27+
}
28+
2329
export interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
2430
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
2531
color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error'
@@ -33,6 +39,8 @@ export interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectE
3339
addonBefore?: React.ReactNode
3440
/** Text/element after select (outside, using DaisyUI label) */
3541
addonAfter?: React.ReactNode
42+
/** Select options array (recommended for better performance) */
43+
options?: SelectOption[]
3644
className?: string
3745
children?: React.ReactNode
3846
'data-testid'?: string
@@ -49,6 +57,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
4957
floatingLabel,
5058
addonBefore,
5159
addonAfter,
60+
options,
5261
className = '',
5362
children,
5463
'data-testid': testId,
@@ -59,6 +68,18 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
5968
const { componentSize } = useConfig()
6069
const effectiveSize = size ?? componentSize ?? 'md'
6170

71+
// Render options from array or use children
72+
const renderOptions = () => {
73+
if (options) {
74+
return options.map((option) => (
75+
<option key={option.value} value={option.value} disabled={option.disabled}>
76+
{option.label}
77+
</option>
78+
))
79+
}
80+
return children
81+
}
82+
6283
const innerRef = useRef<HTMLSelectElement>(null)
6384
const selectRef = (ref as React.RefObject<HTMLSelectElement>) || innerRef
6485

@@ -110,7 +131,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
110131
// Build the core select element
111132
const selectElement = (
112133
<select ref={selectRef} className={selectClasses} data-testid={selectTestId} {...props}>
113-
{children}
134+
{renderOptions()}
114135
</select>
115136
)
116137

@@ -129,7 +150,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
129150
data-testid={selectTestId}
130151
{...props}
131152
>
132-
{children}
153+
{renderOptions()}
133154
</select>
134155
<span>{floatingLabel}</span>
135156
</label>

0 commit comments

Comments
 (0)