@aleph-alpha/ui-library 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -32
- package/config.js +9 -10
- package/dist/system/components/UiSnackbar/UiSnackbar.vue.d.ts +1 -0
- package/dist/system/components/UiSnackbar/UiSnackbarContent.vue.d.ts +29 -0
- package/dist/system/components/UiSnackbar/UiSnackbarIcon.vue.d.ts +3 -0
- package/dist/system/components/UiSnackbar/index.d.ts +3 -0
- package/dist/system/components/UiSnackbar/showSnackbar.d.ts +55 -0
- package/dist/system/components/UiSnackbar/types.d.ts +76 -17
- package/dist/system/lib.js +8218 -7978
- package/package.json +4 -4
- package/src/@types/shims-vue.d.ts +5 -0
- package/src/components/UiButton/UiButton.stories.ts +4 -20
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +4 -20
- package/src/components/UiField/UiField.stories.ts +4 -20
- package/src/components/UiIcon/UiIcon.stories.ts +2 -0
- package/src/components/UiItem/UiItem.stories.ts +4 -19
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +281 -255
- package/src/components/UiSnackbar/UiSnackbar.vue +71 -241
- package/src/components/UiSnackbar/UiSnackbarContent.vue +114 -0
- package/src/components/UiSnackbar/UiSnackbarIcon.vue +78 -0
- package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +154 -1
- package/src/components/UiSnackbar/__tests__/showSnackbar.test.ts +258 -0
- package/src/components/UiSnackbar/assets/error.svg +3 -0
- package/src/components/UiSnackbar/assets/info.svg +3 -0
- package/src/components/UiSnackbar/assets/loading.svg +14 -0
- package/src/components/UiSnackbar/assets/success.svg +5 -0
- package/src/components/UiSnackbar/assets/warning.svg +3 -0
- package/src/components/UiSnackbar/index.ts +3 -0
- package/src/components/UiSnackbar/showSnackbar.ts +174 -0
- package/src/components/UiSnackbar/types.ts +90 -17
- package/src/components/core/sonner/Sonner.vue +3 -20
- package/src/directives/vHover.stories.ts +1 -0
- package/src/lib/useDevice.stories.ts +2 -1
- package/src/lib/useDrag.stories.ts +2 -1
- package/src/theme/Background.stories.ts +2 -0
- package/src/theme/Border.stories.ts +2 -0
- package/src/theme/BorderRadius.stories.ts +2 -0
- package/src/theme/Extended.stories.ts +2 -0
- package/src/theme/Flex.stories.ts +2 -0
- package/src/theme/Grid.stories.ts +2 -0
- package/src/theme/HoverLayer.stories.ts +2 -0
- package/src/theme/Overlay.stories.ts +2 -0
- package/src/theme/Shadow.stories.ts +2 -0
- package/src/theme/Theme.stories.ts +2 -0
- package/src/theme/Typography.stories.ts +2 -0
package/README.md
CHANGED
|
@@ -22,11 +22,11 @@ The library exports a helper function `getUiLibraryContentConfig()` to simplify
|
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
24
|
// uno.config.ts
|
|
25
|
-
import { defineConfig } from 'unocss'
|
|
26
|
-
import { getUiLibraryContentConfig } from '@aleph-alpha/ui-library/config'
|
|
27
|
-
import presetWind from '@unocss/preset-wind4'
|
|
28
|
-
import presetAnimations from 'unocss-preset-animations'
|
|
29
|
-
import presetShadcn from 'unocss-preset-shadcn'
|
|
25
|
+
import { defineConfig } from 'unocss';
|
|
26
|
+
import { getUiLibraryContentConfig } from '@aleph-alpha/ui-library/config';
|
|
27
|
+
import presetWind from '@unocss/preset-wind4';
|
|
28
|
+
import presetAnimations from 'unocss-preset-animations';
|
|
29
|
+
import presetShadcn from 'unocss-preset-shadcn';
|
|
30
30
|
|
|
31
31
|
export default defineConfig({
|
|
32
32
|
...getUiLibraryContentConfig(),
|
|
@@ -35,7 +35,7 @@ export default defineConfig({
|
|
|
35
35
|
presetAnimations(),
|
|
36
36
|
presetShadcn({ color: 'neutral', darkSelector: 'html.dark' }),
|
|
37
37
|
],
|
|
38
|
-
})
|
|
38
|
+
});
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
### Custom theme (via design tokens)
|
|
@@ -49,11 +49,14 @@ If you added/maintain tokens in `packages/ui-library/tokens.json`, you can load
|
|
|
49
49
|
|
|
50
50
|
```typescript
|
|
51
51
|
// uno.config.ts
|
|
52
|
-
import { defineConfig } from 'unocss'
|
|
53
|
-
import {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
import { defineConfig } from 'unocss';
|
|
53
|
+
import {
|
|
54
|
+
getUiLibraryContentConfig,
|
|
55
|
+
presetUiLibraryThemeFromTokens,
|
|
56
|
+
} from '@aleph-alpha/ui-library/config';
|
|
57
|
+
import presetWind from '@unocss/preset-wind4';
|
|
58
|
+
import presetAnimations from 'unocss-preset-animations';
|
|
59
|
+
import presetShadcn from 'unocss-preset-shadcn';
|
|
57
60
|
|
|
58
61
|
export default defineConfig({
|
|
59
62
|
...getUiLibraryContentConfig(),
|
|
@@ -64,7 +67,7 @@ export default defineConfig({
|
|
|
64
67
|
// Put the theme preset AFTER shadcn so it overrides shadcn's default CSS vars
|
|
65
68
|
presetUiLibraryThemeFromTokens(),
|
|
66
69
|
],
|
|
67
|
-
})
|
|
70
|
+
});
|
|
68
71
|
```
|
|
69
72
|
|
|
70
73
|
#### Option B: Provide your own shadcn vars explicitly
|
|
@@ -73,11 +76,14 @@ To implement a custom theme from your token values, add `presetUiLibraryTheme()`
|
|
|
73
76
|
|
|
74
77
|
```typescript
|
|
75
78
|
// uno.config.ts
|
|
76
|
-
import { defineConfig } from 'unocss'
|
|
77
|
-
import {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
import { defineConfig } from 'unocss';
|
|
80
|
+
import {
|
|
81
|
+
getUiLibraryContentConfig,
|
|
82
|
+
presetUiLibraryTheme,
|
|
83
|
+
} from '@aleph-alpha/ui-library/config';
|
|
84
|
+
import presetWind from '@unocss/preset-wind4';
|
|
85
|
+
import presetAnimations from 'unocss-preset-animations';
|
|
86
|
+
import presetShadcn from 'unocss-preset-shadcn';
|
|
81
87
|
|
|
82
88
|
export default defineConfig({
|
|
83
89
|
...getUiLibraryContentConfig(),
|
|
@@ -107,7 +113,7 @@ export default defineConfig({
|
|
|
107
113
|
},
|
|
108
114
|
}),
|
|
109
115
|
],
|
|
110
|
-
})
|
|
116
|
+
});
|
|
111
117
|
```
|
|
112
118
|
|
|
113
119
|
Notes:
|
|
@@ -119,33 +125,33 @@ Notes:
|
|
|
119
125
|
|
|
120
126
|
```typescript
|
|
121
127
|
// vite.config.ts
|
|
122
|
-
import { defineConfig } from 'vite'
|
|
123
|
-
import vue from '@vitejs/plugin-vue'
|
|
124
|
-
import UnoCSS from 'unocss/vite'
|
|
128
|
+
import { defineConfig } from 'vite';
|
|
129
|
+
import vue from '@vitejs/plugin-vue';
|
|
130
|
+
import UnoCSS from 'unocss/vite';
|
|
125
131
|
|
|
126
132
|
export default defineConfig({
|
|
127
133
|
plugins: [vue(), UnoCSS()],
|
|
128
|
-
})
|
|
134
|
+
});
|
|
129
135
|
```
|
|
130
136
|
|
|
131
137
|
### 3. Import Styles
|
|
132
138
|
|
|
133
139
|
```typescript
|
|
134
140
|
// main.ts
|
|
135
|
-
import '@unocss/reset/tailwind.css'
|
|
136
|
-
import 'virtual:uno.css'
|
|
141
|
+
import '@unocss/reset/tailwind.css';
|
|
142
|
+
import 'virtual:uno.css';
|
|
137
143
|
|
|
138
|
-
import { createApp } from 'vue'
|
|
139
|
-
import App from './App.vue'
|
|
144
|
+
import { createApp } from 'vue';
|
|
145
|
+
import App from './App.vue';
|
|
140
146
|
|
|
141
|
-
createApp(App).mount('#app')
|
|
147
|
+
createApp(App).mount('#app');
|
|
142
148
|
```
|
|
143
149
|
|
|
144
150
|
### 4. Use Components
|
|
145
151
|
|
|
146
152
|
```vue
|
|
147
153
|
<script setup lang="ts">
|
|
148
|
-
import { UiButton, UiBadge } from '@aleph-alpha/ui-library'
|
|
154
|
+
import { UiButton, UiBadge } from '@aleph-alpha/ui-library';
|
|
149
155
|
</script>
|
|
150
156
|
|
|
151
157
|
<template>
|
|
@@ -156,6 +162,8 @@ import { UiButton, UiBadge } from '@aleph-alpha/ui-library'
|
|
|
156
162
|
|
|
157
163
|
### Using with @aleph-alpha/ds-components-vue
|
|
158
164
|
|
|
165
|
+
> **Deprecated package:** `@aleph-alpha/ds-components-vue` is deprecated. Use this coexistence setup only while migrating existing `Aa*` usage to `@aleph-alpha/ui-library`; do not add it to new applications.
|
|
166
|
+
|
|
159
167
|
If you're using both `ui-library` and `ds-components-vue`, configure UnoCSS to include both:
|
|
160
168
|
|
|
161
169
|
> **⚠️ Important:** Do NOT add `presetWind()` or `presetAnimations()` separately when using `presetsAlephAlpha()`. The DS presets already include these utilities. Adding them again from different packages causes style conflicts.
|
|
@@ -163,12 +171,12 @@ If you're using both `ui-library` and `ds-components-vue`, configure UnoCSS to i
|
|
|
163
171
|
```typescript
|
|
164
172
|
// uno.config.ts
|
|
165
173
|
import { defineConfig } from 'unocss'
|
|
166
|
-
import { presetsAlephAlpha, getDesignSystemContentPathConfig } from '@aleph-alpha/config-
|
|
174
|
+
import { presetsAlephAlpha, getDesignSystemContentPathConfig } from '@aleph-alpha/config-unocss'
|
|
167
175
|
import { getUiLibraryContentConfig } from '@aleph-alpha/ui-library/config'
|
|
168
176
|
import presetShadcn from 'unocss-preset-shadcn'
|
|
169
177
|
|
|
170
|
-
const uiLibraryConfig = getUiLibraryContentConfig()
|
|
171
|
-
const dsConfig = getDesignSystemContentPathConfig('vue')
|
|
178
|
+
const uiLibraryConfig = getUiLibraryContentConfig();
|
|
179
|
+
const dsConfig = getDesignSystemContentPathConfig('vue');
|
|
172
180
|
|
|
173
181
|
export default defineConfig({
|
|
174
182
|
presets: [
|
|
@@ -191,7 +199,7 @@ export default defineConfig({
|
|
|
191
199
|
],
|
|
192
200
|
},
|
|
193
201
|
},
|
|
194
|
-
})
|
|
202
|
+
});
|
|
195
203
|
```
|
|
196
204
|
|
|
197
205
|
## AI Assistant Integration
|
|
@@ -205,6 +213,7 @@ npx @aleph-alpha/ui-library mcp-install
|
|
|
205
213
|
For Cursor, add `--cursor` flag. Then restart your IDE.
|
|
206
214
|
|
|
207
215
|
**Available tools:**
|
|
216
|
+
|
|
208
217
|
- `list_components` - Browse all components (optionally filter by name/category/description)
|
|
209
218
|
- `get_component_docs` - Get full documentation for a component
|
|
210
219
|
|
package/config.js
CHANGED
|
@@ -3,7 +3,7 @@ import { defineConfig, definePreset } from 'unocss';
|
|
|
3
3
|
import presetWind from '@unocss/preset-wind4';
|
|
4
4
|
import presetAnimations from 'unocss-preset-animations';
|
|
5
5
|
import presetShadcn from 'unocss-preset-shadcn';
|
|
6
|
-
import { tokenPreset as sparkTokenPreset } from '@aleph-alpha/config-
|
|
6
|
+
import { tokenPreset as sparkTokenPreset } from '@aleph-alpha/config-unocss';
|
|
7
7
|
|
|
8
8
|
let tokensCache;
|
|
9
9
|
|
|
@@ -1179,15 +1179,14 @@ const getAaBaseFontFamilyName = (fontFamilyRef) => {
|
|
|
1179
1179
|
const tokenKey = refPath?.startsWith('font.font-family.')
|
|
1180
1180
|
? refPath.slice('font.font-family.'.length)
|
|
1181
1181
|
: 'font-body';
|
|
1182
|
-
const candidateKeys =
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
}[tokenKey] ?? [tokenKey];
|
|
1182
|
+
const candidateKeys = {
|
|
1183
|
+
body: ['body', 'font-body'],
|
|
1184
|
+
heading: ['heading', 'font-heading'],
|
|
1185
|
+
mono: ['mono', 'font-mono'],
|
|
1186
|
+
'font-body': ['font-body', 'body'],
|
|
1187
|
+
'font-heading': ['font-heading', 'heading'],
|
|
1188
|
+
'font-mono': ['font-mono', 'mono'],
|
|
1189
|
+
}[tokenKey] ?? [tokenKey];
|
|
1191
1190
|
|
|
1192
1191
|
for (const candidateKey of candidateKeys) {
|
|
1193
1192
|
const name = resolveTokenValue(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UiSnackbarProps } from './types';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<UiSnackbarProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<UiSnackbarProps> & Readonly<{}>, {
|
|
3
|
+
closeButton: boolean;
|
|
3
4
|
containerAriaLabel: string;
|
|
4
5
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
5
6
|
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UiSnackbarContentProps, UiSnackbarContentSlots } from './types';
|
|
2
|
+
declare function __VLS_template(): {
|
|
3
|
+
attrs: Partial<{}>;
|
|
4
|
+
slots: Readonly<UiSnackbarContentSlots> & UiSnackbarContentSlots;
|
|
5
|
+
refs: {};
|
|
6
|
+
rootEl: HTMLDivElement;
|
|
7
|
+
};
|
|
8
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
9
|
+
declare const __VLS_component: import('vue').DefineComponent<UiSnackbarContentProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
10
|
+
action: () => any;
|
|
11
|
+
}, string, import('vue').PublicProps, Readonly<UiSnackbarContentProps> & Readonly<{
|
|
12
|
+
onAction?: (() => any) | undefined;
|
|
13
|
+
}>, {
|
|
14
|
+
description: string;
|
|
15
|
+
closeButton: boolean;
|
|
16
|
+
iconMode: import('./types').UiSnackbarIconMode;
|
|
17
|
+
actionLabel: string;
|
|
18
|
+
actionMode: import('./types').UiSnackbarActionMode;
|
|
19
|
+
embedded: boolean;
|
|
20
|
+
closeButtonAriaLabel: string;
|
|
21
|
+
onCloseToast: () => void;
|
|
22
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
23
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
24
|
+
export default _default;
|
|
25
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
26
|
+
new (): {
|
|
27
|
+
$slots: S;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { UiSnackbarIconProps } from './types';
|
|
2
|
+
declare const _default: import('vue').DefineComponent<UiSnackbarIconProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<UiSnackbarIconProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLSpanElement>;
|
|
3
|
+
export default _default;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { default as UiSnackbar } from './UiSnackbar.vue';
|
|
2
|
+
export { default as UiSnackbarContent } from './UiSnackbarContent.vue';
|
|
3
|
+
export { default as UiSnackbarIcon } from './UiSnackbarIcon.vue';
|
|
4
|
+
export { showSnackbar, showSnackbarPromise } from './showSnackbar';
|
|
2
5
|
export { toast } from 'vue-sonner';
|
|
3
6
|
export type * from './types';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
import { ExternalToast } from 'vue-sonner';
|
|
3
|
+
import { UiSnackbarActionMode, UiSnackbarIconMode } from './types';
|
|
4
|
+
export type ShowSnackbarOptions = Omit<ExternalToast, 'description' | 'action' | 'icon'> & {
|
|
5
|
+
/** Primary snackbar message. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Supporting context shown below the title. */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Built-in status icon mode. */
|
|
10
|
+
iconMode?: UiSnackbarIconMode;
|
|
11
|
+
/** Built-in action label. Ignored when `action` is provided. */
|
|
12
|
+
actionLabel?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Visual mode for the built-in action button.
|
|
15
|
+
* @default 'default'
|
|
16
|
+
*/
|
|
17
|
+
actionMode?: UiSnackbarActionMode;
|
|
18
|
+
/** Called when the built-in action button is clicked. */
|
|
19
|
+
onAction?: () => void;
|
|
20
|
+
/** Optional custom trailing action rendered through the action slot. */
|
|
21
|
+
action?: VNode;
|
|
22
|
+
/**
|
|
23
|
+
* Accessible label for the close button.
|
|
24
|
+
* @default 'Close toast'
|
|
25
|
+
*/
|
|
26
|
+
closeButtonAriaLabel?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Display a snackbar with title, optional description, icon, and action content.
|
|
30
|
+
* Mount `<UiSnackbar />` once near the app root before calling this helper.
|
|
31
|
+
*
|
|
32
|
+
* Uses the default Sonner toast API for text-only messages. Switches to
|
|
33
|
+
* `toast.custom()` with embedded `UiSnackbarContent` when icon or action UI
|
|
34
|
+
* is provided.
|
|
35
|
+
* @param options Snackbar content and Sonner toast options.
|
|
36
|
+
*/
|
|
37
|
+
export declare function showSnackbar(options: ShowSnackbarOptions): string | number;
|
|
38
|
+
type SnackbarMessageContent = string | Pick<ShowSnackbarOptions, 'title' | 'description'>;
|
|
39
|
+
export type ShowSnackbarPromiseMessages<T> = {
|
|
40
|
+
/** Snackbar content shown while the promise is pending. */
|
|
41
|
+
loading: SnackbarMessageContent;
|
|
42
|
+
/** Snackbar content shown when the promise resolves. */
|
|
43
|
+
success: SnackbarMessageContent | ((data: T) => SnackbarMessageContent);
|
|
44
|
+
/** Snackbar content shown when the promise rejects. */
|
|
45
|
+
error: SnackbarMessageContent | ((error: unknown) => SnackbarMessageContent);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Track an async operation with loading, success, and error snackbars that use
|
|
49
|
+
* built-in status icon modes.
|
|
50
|
+
* @param promise Async work to monitor.
|
|
51
|
+
* @param messages Titles for each phase of the promise lifecycle.
|
|
52
|
+
* @param options Shared Sonner toast options applied to every phase.
|
|
53
|
+
*/
|
|
54
|
+
export declare function showSnackbarPromise<T>(promise: Promise<T> | (() => Promise<T>), messages: ShowSnackbarPromiseMessages<T>, options?: Omit<ShowSnackbarOptions, 'title' | 'description' | 'iconMode'>): string | number;
|
|
55
|
+
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
1
2
|
import { ToasterProps } from 'vue-sonner';
|
|
2
3
|
/**
|
|
3
|
-
* Toast notification container
|
|
4
|
-
* then call `
|
|
5
|
-
*
|
|
4
|
+
* Toast notification container. Place once near the app root,
|
|
5
|
+
* then call `showSnackbar()` or `toast()` from anywhere to display
|
|
6
|
+
* a non-blocking notification with a title and optional description.
|
|
7
|
+
*
|
|
8
|
+
* This component is currently experimental. Its API and behavior may still change
|
|
9
|
+
* before it is considered stable.
|
|
6
10
|
* @category Feedback
|
|
7
|
-
* @useCases
|
|
8
|
-
* @keywords snackbar, toast,
|
|
9
|
-
* @related UiAlert, UiAlertDialog
|
|
11
|
+
* @useCases confirmation, undo action, async progress, background updates
|
|
12
|
+
* @keywords snackbar, toast, notification, alert, message, banner, undo, experimental
|
|
13
|
+
* @related UiAlert, UiAlertDialog, UiSnackbarContent
|
|
10
14
|
*/
|
|
11
15
|
export type UiSnackbarProps = {
|
|
12
16
|
/**
|
|
@@ -21,15 +25,6 @@ export type UiSnackbarProps = {
|
|
|
21
25
|
theme?: ToasterProps['theme'];
|
|
22
26
|
/** Mirror the body color scheme so toasts contrast against it. */
|
|
23
27
|
invert?: ToasterProps['invert'];
|
|
24
|
-
/**
|
|
25
|
-
* Apply colored backgrounds for `success`, `error`, `info`, and `warning` toasts.
|
|
26
|
-
*
|
|
27
|
-
* Accessibility: color must not be the only signal of toast type
|
|
28
|
-
* (WCAG 1.4.1 Use of Color). Always pair with a descriptive message
|
|
29
|
-
* and/or icon so the meaning is conveyed to users who cannot perceive
|
|
30
|
-
* the color difference.
|
|
31
|
-
*/
|
|
32
|
-
richColors?: ToasterProps['richColors'];
|
|
33
28
|
/** Show all stacked toasts expanded by default instead of collapsed. */
|
|
34
29
|
expand?: ToasterProps['expand'];
|
|
35
30
|
/**
|
|
@@ -40,6 +35,7 @@ export type UiSnackbarProps = {
|
|
|
40
35
|
* reader users can dismiss them on their own terms. The close
|
|
41
36
|
* button has an accessible name of `'Close toast'` by default;
|
|
42
37
|
* customise via `toastOptions.closeButtonAriaLabel`.
|
|
38
|
+
* @default true
|
|
43
39
|
*/
|
|
44
40
|
closeButton?: ToasterProps['closeButton'];
|
|
45
41
|
/** Position of the close button within each toast. */
|
|
@@ -78,8 +74,6 @@ export type UiSnackbarProps = {
|
|
|
78
74
|
hotkey?: ToasterProps['hotkey'];
|
|
79
75
|
/** Directions in which a toast can be dismissed by swipe. */
|
|
80
76
|
swipeDirections?: ToasterProps['swipeDirections'];
|
|
81
|
-
/** Custom icons used for each toast type. */
|
|
82
|
-
icons?: ToasterProps['icons'];
|
|
83
77
|
/** Default options applied to every toast. */
|
|
84
78
|
toastOptions?: ToasterProps['toastOptions'];
|
|
85
79
|
/**
|
|
@@ -94,3 +88,68 @@ export type UiSnackbarProps = {
|
|
|
94
88
|
/** Identifier when rendering more than one Toaster instance. */
|
|
95
89
|
id?: ToasterProps['id'];
|
|
96
90
|
};
|
|
91
|
+
export type UiSnackbarIconMode = 'success' | 'info' | 'warning' | 'error' | 'loading';
|
|
92
|
+
export type UiSnackbarActionMode = 'default' | 'secondary';
|
|
93
|
+
/**
|
|
94
|
+
* Design-system snackbar status icon.
|
|
95
|
+
* @category Feedback
|
|
96
|
+
* @keywords snackbar, icon, success, info, warning, error, loading
|
|
97
|
+
* @related UiSnackbar, UiSnackbarContent
|
|
98
|
+
*/
|
|
99
|
+
export type UiSnackbarIconProps = {
|
|
100
|
+
/** Visual mode for the snackbar status icon. */
|
|
101
|
+
mode: UiSnackbarIconMode;
|
|
102
|
+
/** Accessible label. Defaults to a mode-specific label. */
|
|
103
|
+
ariaLabel?: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Presentational snackbar layout with a title, optional description,
|
|
107
|
+
* leading status icon, and trailing action slot.
|
|
108
|
+
* @category Feedback
|
|
109
|
+
* @useCases static preview, custom toast content, composed notifications
|
|
110
|
+
* @keywords snackbar, toast, notification, title, description, icon, action
|
|
111
|
+
* @related UiSnackbar
|
|
112
|
+
*/
|
|
113
|
+
export type UiSnackbarContentProps = {
|
|
114
|
+
/** Primary snackbar message. */
|
|
115
|
+
title: string;
|
|
116
|
+
/** Supporting context shown below the title. */
|
|
117
|
+
description?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Built-in status icon mode.
|
|
120
|
+
*/
|
|
121
|
+
iconMode?: UiSnackbarIconMode;
|
|
122
|
+
/** Built-in action label. Ignored when the action slot is provided. */
|
|
123
|
+
actionLabel?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Visual mode for the built-in action button.
|
|
126
|
+
* @default 'default'
|
|
127
|
+
*/
|
|
128
|
+
actionMode?: UiSnackbarActionMode;
|
|
129
|
+
/**
|
|
130
|
+
* When true, renders only the inner layout without surface chrome.
|
|
131
|
+
* Used when the snackbar is rendered inside the toast container.
|
|
132
|
+
* @default false
|
|
133
|
+
*/
|
|
134
|
+
embedded?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Show a close button on the trailing edge. Used for embedded toasts where
|
|
137
|
+
* Sonner does not render its own close control.
|
|
138
|
+
* @default true
|
|
139
|
+
*/
|
|
140
|
+
closeButton?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Accessible label for the close button.
|
|
143
|
+
* @default 'Close toast'
|
|
144
|
+
*/
|
|
145
|
+
closeButtonAriaLabel?: string;
|
|
146
|
+
/** Called by Sonner when the close button is clicked. */
|
|
147
|
+
onCloseToast?: () => void;
|
|
148
|
+
};
|
|
149
|
+
export type { ShowSnackbarOptions, ShowSnackbarPromiseMessages, } from './showSnackbar';
|
|
150
|
+
export type UiSnackbarContentSlots = {
|
|
151
|
+
/** Supporting text rendered below the title. Overrides `description` when provided. */
|
|
152
|
+
description?: () => VNode[];
|
|
153
|
+
/** Trailing action content such as a button or link. */
|
|
154
|
+
action?: () => VNode[];
|
|
155
|
+
};
|