Skip to content

Commit 0c71b24

Browse files
committed
Bump version to 0.12.74
1 parent 9f8a094 commit 0c71b24

21 files changed

Lines changed: 259 additions & 17 deletions

File tree

packages/asterui/CHANGELOG.md

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

88
All notable changes to AsterUI are documented here.
99

10+
## v0.12.74 (2025-12-26)
11+
12+
### Components
13+
14+
- Added closable functionality to Alert component with onClose, closeIcon, and afterClose callbacks
15+
- Added 'xs' size support to Typography.Text component
16+
1017
## v0.12.73 (2025-12-25)
1118

1219
### Documentation

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.73",
3+
"version": "0.12.74",
44
"description": "React UI component library with DaisyUI",
55
"homepage": "https://asterui.com",
66
"repository": {

packages/asterui/src/components/Alert.tsx

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import React, { useState } from 'react'
22

33
// DaisyUI classes
44
const dAlert = 'alert'
@@ -11,13 +11,20 @@ const dAlertDash = 'alert-dash'
1111
const dAlertSoft = 'alert-soft'
1212
const dAlertVertical = 'alert-vertical'
1313

14+
export interface ClosableType {
15+
onClose?: () => void
16+
closeIcon?: React.ReactNode
17+
afterClose?: () => void
18+
}
19+
1420
export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
1521
children: React.ReactNode
1622
type?: 'info' | 'success' | 'warning' | 'error'
1723
outline?: boolean
1824
dash?: boolean
1925
soft?: boolean
2026
vertical?: boolean
27+
closable?: boolean | ClosableType
2128
/** Test ID for testing */
2229
'data-testid'?: string
2330
}
@@ -30,8 +37,11 @@ export const Alert: React.FC<AlertProps> = ({
3037
dash = false,
3138
soft = false,
3239
vertical = false,
40+
closable = false,
3341
...rest
3442
}) => {
43+
const [visible, setVisible] = useState(true)
44+
3545
const typeClasses = {
3646
info: dAlertInfo,
3747
success: dAlertSuccess,
@@ -51,9 +61,40 @@ export const Alert: React.FC<AlertProps> = ({
5161
.filter(Boolean)
5262
.join(' ')
5363

64+
// Determine close config from props
65+
const isClosable = closable !== false
66+
const closableConfig = typeof closable === 'object' ? closable : {}
67+
const handleClose = closableConfig.onClose
68+
const afterClose = closableConfig.afterClose
69+
const closeIcon = closableConfig.closeIcon
70+
71+
const handleCloseClick = () => {
72+
if (handleClose) {
73+
handleClose()
74+
}
75+
setVisible(false)
76+
if (afterClose) {
77+
afterClose()
78+
}
79+
}
80+
81+
if (!visible) {
82+
return null
83+
}
84+
5485
return (
5586
<div role="alert" className={classes} {...rest}>
5687
{children}
88+
{isClosable && (
89+
<button
90+
type="button"
91+
className="btn btn-sm btn-circle ml-auto opacity-70 hover:opacity-100"
92+
onClick={handleCloseClick}
93+
aria-label="Close"
94+
>
95+
{closeIcon || '✕'}
96+
</button>
97+
)}
5798
</div>
5899
)
59100
}

packages/asterui/src/components/Typography.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const dBtnXs = 'btn-xs'
77
const dLink = 'link'
88
const dLinkPrimary = 'link-primary'
99

10-
export type TypographySize = 'sm' | 'base' | 'lg' | 'xl' | '2xl'
10+
export type TypographySize = 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl'
1111
export type TitleLevel = 1 | 2 | 3 | 4 | 5
1212

1313
export interface TypographyProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -42,6 +42,7 @@ export interface TextProps extends React.HTMLAttributes<HTMLSpanElement> {
4242
underline?: boolean
4343
delete?: boolean
4444
type?: 'default' | 'secondary' | 'success' | 'warning' | 'error'
45+
size?: TypographySize
4546
copyable?: boolean
4647
'data-testid'?: string
4748
}
@@ -94,6 +95,7 @@ function CopyButton({ text, 'data-testid': testId }: { text: string; 'data-testi
9495

9596
function TypographyRoot({ children, size = 'base', className = '', 'data-testid': testId, ...rest }: TypographyProps) {
9697
const sizeClasses = {
98+
xs: 'prose-xs text-xs',
9799
sm: 'prose-sm text-sm',
98100
base: 'prose-base text-base',
99101
lg: 'prose-lg text-lg',
@@ -223,6 +225,7 @@ function Text({
223225
underline,
224226
delete: del,
225227
type = 'default',
228+
size,
226229
copyable,
227230
className = '',
228231
'data-testid': testId,
@@ -267,7 +270,18 @@ function Text({
267270
content = <del className="line-through opacity-70">{content}</del>
268271
}
269272

270-
const classes = `group inline ${typeClasses[type]} ${className}`.trim()
273+
const classes = [
274+
'group',
275+
'inline',
276+
typeClasses[type],
277+
size === 'xs' && 'text-xs',
278+
size === 'sm' && 'text-sm',
279+
size === 'base' && 'text-base',
280+
size === 'lg' && 'text-lg',
281+
size === 'xl' && 'text-xl',
282+
size === '2xl' && 'text-2xl',
283+
className,
284+
].filter(Boolean).join(' ')
271285

272286
return (
273287
<span className={classes} data-testid={testId} {...rest}>

packages/docs/public/docs/alert.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,62 @@ const App: React.FC = () => (
112112
export default App
113113
```
114114

115+
### Closable Alert
116+
117+
Alert with close button and callbacks.
118+
119+
```tsx
120+
import React from 'react'
121+
import { Alert, Space, message } from 'asterui'
122+
import {
123+
InformationCircleIcon,
124+
CheckCircleIcon,
125+
ExclamationTriangleIcon,
126+
} from '@aster-ui/icons'
127+
128+
const App: React.FC = () => (
129+
<Space direction="vertical" size="sm">
130+
<Alert type="info" closable>
131+
<InformationCircleIcon size="lg" className="shrink-0" />
132+
<span>Closable alert with default close button</span>
133+
</Alert>
134+
135+
<Alert
136+
type="success"
137+
closable={{
138+
onClose: () => message.success('Success alert closed'),
139+
afterClose: () => message.info('After close callback executed'),
140+
}}
141+
>
142+
<CheckCircleIcon size="lg" className="shrink-0" />
143+
<span>Closable with onClose and afterClose callbacks</span>
144+
</Alert>
145+
146+
<Alert
147+
type="warning"
148+
closable={{
149+
closeIcon: <span className="text-lg font-bold">×</span>,
150+
onClose: () => message.warning('Custom close icon clicked'),
151+
}}
152+
>
153+
<ExclamationTriangleIcon size="lg" className="shrink-0" />
154+
<span>Closable with custom close icon</span>
155+
</Alert>
156+
</Space>
157+
)
158+
159+
export default App
160+
```
161+
115162
## API
116163

117164
### Alert
118165

119166
| Property | Description | Type | Default |
120167
|----------|-------------|------|---------|
121168
| `children` | Alert content | `React.ReactNode` | `-` |
122-
| `type` | Alert color variant | `info' \| 'success' \| 'warning' \| 'error` | `-` |
169+
| `type` | Alert color variant | `'info' \| 'success' \| 'warning' \| 'error'` | `-` |
170+
| `closable` | Show close button | `boolean \| { onClose?: () => void; closeIcon?: ReactNode; afterClose?: () => void }` | `false` |
123171
| `outline` | Outline style | `boolean` | `false` |
124172
| `dash` | Dash outline style | `boolean` | `false` |
125173
| `soft` | Soft style | `boolean` | `false` |

packages/docs/public/docs/typography.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export default App
150150
| `code` | Code style | `boolean` | `false` |
151151
| `mark` | Highlighted text | `boolean` | `false` |
152152
| `keyboard` | Keyboard style | `boolean` | `false` |
153+
| `size` | Text size | `'xs' \| 'sm' \| 'base' \| 'lg' \| 'xl' \| '2xl'` | `-` |
153154
| `className` | Additional CSS classes | `string` | `-` |
154155
| `data-testid` | Test ID for testing | `string` | - |
155156

@@ -159,7 +160,7 @@ export default App
159160
|----------|-------------|------|---------|
160161
| `copyable` | Enable copy to clipboard | `boolean \| { text?: string }` | `-` |
161162
| `ellipsis` | Truncate with ellipsis | `boolean \| { rows?: number }` | `-` |
162-
| `size` | Text size | `'sm' \| 'base' \| 'lg' \| 'xl' \| '2xl'` | `-` |
163+
| `size` | Text size | `'xs' \| 'sm' \| 'base' \| 'lg' \| 'xl' \| '2xl'` | `-` |
163164
| `align` | Text alignment | `'left' \| 'center' \| 'right'` | `-` |
164165
| `className` | Additional CSS classes | `string` | `-` |
165166
| `data-testid` | Test ID for testing | `string` | - |
@@ -169,7 +170,7 @@ export default App
169170
| Property | Description | Type | Default |
170171
|----------|-------------|------|---------|
171172
| `href` | Link URL | `string` | `'#'` |
172-
| `size` | Text size | `'sm' \| 'base' \| 'lg' \| 'xl' \| '2xl'` | `-` |
173+
| `size` | Text size | `'xs' \| 'sm' \| 'base' \| 'lg' \| 'xl' \| '2xl'` | `-` |
173174
| `external` | Open in new tab with external icon | `boolean` | `false` |
174175
| `className` | Additional CSS classes | `string` | `-` |
175176
| `data-testid` | Test ID for testing | `string` | - |

packages/docs/src/components/AlertDemo.tsx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Alert, Space, Button } from '@aster-ui/prefixed'
1+
import { Alert, Space, Button, message } from '@aster-ui/prefixed'
22
import { InformationCircleIcon, CheckCircleIcon, ExclamationTriangleIcon, XCircleIcon } from '@aster-ui/icons-prefixed'
33
import { Demo } from './Demo'
44

@@ -132,3 +132,42 @@ export function SoftDemo() {
132132
</Demo>
133133
)
134134
}
135+
136+
// @example-imports: { Alert, Space, message } from 'asterui'
137+
// @example-imports: { InformationCircleIcon, CheckCircleIcon, ExclamationTriangleIcon } from '@aster-ui/icons'
138+
export function ClosableDemo() {
139+
return (
140+
<Demo>
141+
{/* @example-return */}
142+
<Space direction="vertical" size="sm">
143+
<Alert type="info" closable>
144+
<InformationCircleIcon size="lg" className="shrink-0" />
145+
<span>Closable alert with default close button</span>
146+
</Alert>
147+
148+
<Alert
149+
type="success"
150+
closable={{
151+
onClose: () => message.success('Success alert closed'),
152+
afterClose: () => message.info('After close callback executed')
153+
}}
154+
>
155+
<CheckCircleIcon size="lg" className="shrink-0" />
156+
<span>Closable with onClose and afterClose callbacks</span>
157+
</Alert>
158+
159+
<Alert
160+
type="warning"
161+
closable={{
162+
closeIcon: <span className="text-lg font-bold">×</span>,
163+
onClose: () => message.warning('Custom close icon clicked')
164+
}}
165+
>
166+
<ExclamationTriangleIcon size="lg" className="shrink-0" />
167+
<span>Closable with custom close icon</span>
168+
</Alert>
169+
</Space>
170+
{/* @example-return-end */}
171+
</Demo>
172+
)
173+
}

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

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

88
All notable changes to AsterUI are documented here.
99

10+
## v0.12.74 (2025-12-26)
11+
12+
### Components
13+
14+
- Added closable functionality to Alert component with onClose, closeIcon, and afterClose callbacks
15+
- Added 'xs' size support to Typography.Text component
16+
1017
## v0.12.73 (2025-12-25)
1118

1219
### Documentation

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
OutlineDemo,
1212
DashDemo,
1313
SoftDemo,
14+
ClosableDemo,
1415
} from '../../../components/AlertDemo'
1516
import AlertDemoSource from '../../../components/AlertDemo.tsx?raw'
1617
import Example from '../../../components/Example.astro'
@@ -51,6 +52,10 @@ import { Alert } from 'asterui'
5152
<SoftDemo client:load slot="demo" />
5253
</Example>
5354

55+
<Example title="Closable Alert" description="Alert with close button and callbacks." source={AlertDemoSource} fn="ClosableDemo">
56+
<ClosableDemo client:load slot="demo" />
57+
</Example>
58+
5459
</div>
5560

5661
## API
@@ -61,6 +66,7 @@ import { Alert } from 'asterui'
6166
|----------|-------------|------|---------|
6267
| `children` | Alert content | `ReactNode` | - |
6368
| `type` | Alert color variant | `'info' \| 'success' \| 'warning' \| 'error'` | - |
69+
| `closable` | Show close button | `boolean \| { onClose?: () => void; closeIcon?: ReactNode; afterClose?: () => void }` | `false` |
6470
| `outline` | Outline style | `boolean` | `false` |
6571
| `dash` | Dash outline style | `boolean` | `false` |
6672
| `soft` | Soft style | `boolean` | `false` |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const { Title, Paragraph, Text, Link } = Typography
8484
| `code` | Code style - Text only | `boolean` | `false` |
8585
| `mark` | Highlighted text - Text only | `boolean` | `false` |
8686
| `keyboard` | Keyboard style - Text only | `boolean` | `false` |
87-
| `size` | Text size - Paragraph and Link | `'sm' \| 'base' \| 'lg' \| 'xl' \| '2xl'` | - |
87+
| `size` | Text size - Text, Paragraph, and Link | `'xs' \| 'sm' \| 'base' \| 'lg' \| 'xl' \| '2xl'` | - |
8888
| `align` | Text alignment - Paragraph only | `'left' \| 'center' \| 'right'` | - |
8989
| `href` | Link URL - Link only | `string` | `'#'` |
9090
| `external` | Open in new tab with external icon - Link only | `boolean` | `false` |

0 commit comments

Comments
 (0)