@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
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import type { VNode } from 'vue';
|
|
1
2
|
import type { ToasterProps } from 'vue-sonner';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
* Toast notification container
|
|
5
|
-
* then call `
|
|
6
|
-
*
|
|
5
|
+
* Toast notification container. Place once near the app root,
|
|
6
|
+
* then call `showSnackbar()` or `toast()` from anywhere to display
|
|
7
|
+
* a non-blocking notification with a title and optional description.
|
|
8
|
+
*
|
|
9
|
+
* This component is currently experimental. Its API and behavior may still change
|
|
10
|
+
* before it is considered stable.
|
|
7
11
|
* @category Feedback
|
|
8
|
-
* @useCases
|
|
9
|
-
* @keywords snackbar, toast,
|
|
10
|
-
* @related UiAlert, UiAlertDialog
|
|
12
|
+
* @useCases confirmation, undo action, async progress, background updates
|
|
13
|
+
* @keywords snackbar, toast, notification, alert, message, banner, undo, experimental
|
|
14
|
+
* @related UiAlert, UiAlertDialog, UiSnackbarContent
|
|
11
15
|
*/
|
|
12
16
|
export type UiSnackbarProps = {
|
|
13
17
|
/**
|
|
@@ -22,15 +26,6 @@ export type UiSnackbarProps = {
|
|
|
22
26
|
theme?: ToasterProps['theme'];
|
|
23
27
|
/** Mirror the body color scheme so toasts contrast against it. */
|
|
24
28
|
invert?: ToasterProps['invert'];
|
|
25
|
-
/**
|
|
26
|
-
* Apply colored backgrounds for `success`, `error`, `info`, and `warning` toasts.
|
|
27
|
-
*
|
|
28
|
-
* Accessibility: color must not be the only signal of toast type
|
|
29
|
-
* (WCAG 1.4.1 Use of Color). Always pair with a descriptive message
|
|
30
|
-
* and/or icon so the meaning is conveyed to users who cannot perceive
|
|
31
|
-
* the color difference.
|
|
32
|
-
*/
|
|
33
|
-
richColors?: ToasterProps['richColors'];
|
|
34
29
|
/** Show all stacked toasts expanded by default instead of collapsed. */
|
|
35
30
|
expand?: ToasterProps['expand'];
|
|
36
31
|
/**
|
|
@@ -41,6 +36,7 @@ export type UiSnackbarProps = {
|
|
|
41
36
|
* reader users can dismiss them on their own terms. The close
|
|
42
37
|
* button has an accessible name of `'Close toast'` by default;
|
|
43
38
|
* customise via `toastOptions.closeButtonAriaLabel`.
|
|
39
|
+
* @default true
|
|
44
40
|
*/
|
|
45
41
|
closeButton?: ToasterProps['closeButton'];
|
|
46
42
|
/** Position of the close button within each toast. */
|
|
@@ -79,8 +75,6 @@ export type UiSnackbarProps = {
|
|
|
79
75
|
hotkey?: ToasterProps['hotkey'];
|
|
80
76
|
/** Directions in which a toast can be dismissed by swipe. */
|
|
81
77
|
swipeDirections?: ToasterProps['swipeDirections'];
|
|
82
|
-
/** Custom icons used for each toast type. */
|
|
83
|
-
icons?: ToasterProps['icons'];
|
|
84
78
|
/** Default options applied to every toast. */
|
|
85
79
|
toastOptions?: ToasterProps['toastOptions'];
|
|
86
80
|
/**
|
|
@@ -95,3 +89,82 @@ export type UiSnackbarProps = {
|
|
|
95
89
|
/** Identifier when rendering more than one Toaster instance. */
|
|
96
90
|
id?: ToasterProps['id'];
|
|
97
91
|
};
|
|
92
|
+
|
|
93
|
+
export type UiSnackbarIconMode =
|
|
94
|
+
| 'success'
|
|
95
|
+
| 'info'
|
|
96
|
+
| 'warning'
|
|
97
|
+
| 'error'
|
|
98
|
+
| 'loading';
|
|
99
|
+
|
|
100
|
+
export type UiSnackbarActionMode = 'default' | 'secondary';
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Design-system snackbar status icon.
|
|
104
|
+
* @category Feedback
|
|
105
|
+
* @keywords snackbar, icon, success, info, warning, error, loading
|
|
106
|
+
* @related UiSnackbar, UiSnackbarContent
|
|
107
|
+
*/
|
|
108
|
+
export type UiSnackbarIconProps = {
|
|
109
|
+
/** Visual mode for the snackbar status icon. */
|
|
110
|
+
mode: UiSnackbarIconMode;
|
|
111
|
+
/** Accessible label. Defaults to a mode-specific label. */
|
|
112
|
+
ariaLabel?: string;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Presentational snackbar layout with a title, optional description,
|
|
117
|
+
* leading status icon, and trailing action slot.
|
|
118
|
+
* @category Feedback
|
|
119
|
+
* @useCases static preview, custom toast content, composed notifications
|
|
120
|
+
* @keywords snackbar, toast, notification, title, description, icon, action
|
|
121
|
+
* @related UiSnackbar
|
|
122
|
+
*/
|
|
123
|
+
export type UiSnackbarContentProps = {
|
|
124
|
+
/** Primary snackbar message. */
|
|
125
|
+
title: string;
|
|
126
|
+
/** Supporting context shown below the title. */
|
|
127
|
+
description?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Built-in status icon mode.
|
|
130
|
+
*/
|
|
131
|
+
iconMode?: UiSnackbarIconMode;
|
|
132
|
+
/** Built-in action label. Ignored when the action slot is provided. */
|
|
133
|
+
actionLabel?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Visual mode for the built-in action button.
|
|
136
|
+
* @default 'default'
|
|
137
|
+
*/
|
|
138
|
+
actionMode?: UiSnackbarActionMode;
|
|
139
|
+
/**
|
|
140
|
+
* When true, renders only the inner layout without surface chrome.
|
|
141
|
+
* Used when the snackbar is rendered inside the toast container.
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
144
|
+
embedded?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Show a close button on the trailing edge. Used for embedded toasts where
|
|
147
|
+
* Sonner does not render its own close control.
|
|
148
|
+
* @default true
|
|
149
|
+
*/
|
|
150
|
+
closeButton?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Accessible label for the close button.
|
|
153
|
+
* @default 'Close toast'
|
|
154
|
+
*/
|
|
155
|
+
closeButtonAriaLabel?: string;
|
|
156
|
+
/** Called by Sonner when the close button is clicked. */
|
|
157
|
+
onCloseToast?: () => void;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type {
|
|
161
|
+
ShowSnackbarOptions,
|
|
162
|
+
ShowSnackbarPromiseMessages,
|
|
163
|
+
} from './showSnackbar';
|
|
164
|
+
|
|
165
|
+
export type UiSnackbarContentSlots = {
|
|
166
|
+
/** Supporting text rendered below the title. Overrides `description` when provided. */
|
|
167
|
+
description?: () => VNode[];
|
|
168
|
+
/** Trailing action content such as a button or link. */
|
|
169
|
+
action?: () => VNode[];
|
|
170
|
+
};
|
|
@@ -12,30 +12,13 @@ const props = defineProps<ToasterProps>();
|
|
|
12
12
|
v-bind="props"
|
|
13
13
|
:class="cn('toaster group', props.class)"
|
|
14
14
|
:style="{
|
|
15
|
-
'--normal-bg': 'oklch(var(--background-surface-
|
|
16
|
-
'--normal-text': 'oklch(var(--content-on-surface-
|
|
17
|
-
'--normal-border': '
|
|
15
|
+
'--normal-bg': 'oklch(var(--background-surface-floating))',
|
|
16
|
+
'--normal-text': 'oklch(var(--content-on-surface-primary))',
|
|
17
|
+
'--normal-border': 'oklch(var(--border-surface-default))',
|
|
18
18
|
'--border-radius': 'var(--radius)',
|
|
19
19
|
...((typeof props.style === 'object' && props.style) || {}),
|
|
20
20
|
}"
|
|
21
21
|
>
|
|
22
|
-
<template #success-icon>
|
|
23
|
-
<UiIcon name="circle-check" size="s" />
|
|
24
|
-
</template>
|
|
25
|
-
<template #info-icon>
|
|
26
|
-
<UiIcon name="info" size="s" />
|
|
27
|
-
</template>
|
|
28
|
-
<template #warning-icon>
|
|
29
|
-
<UiIcon name="triangle-alert" size="s" />
|
|
30
|
-
</template>
|
|
31
|
-
<template #error-icon>
|
|
32
|
-
<UiIcon name="octagon-x" size="s" />
|
|
33
|
-
</template>
|
|
34
|
-
<template #loading-icon>
|
|
35
|
-
<div>
|
|
36
|
-
<UiIcon name="loader-2" size="s" class="animate-spin" />
|
|
37
|
-
</div>
|
|
38
|
-
</template>
|
|
39
22
|
<template #close-icon>
|
|
40
23
|
<UiIcon name="x" size="s" />
|
|
41
24
|
</template>
|
|
@@ -44,9 +44,10 @@ const userAgentExamples: UserAgentExample[] = [
|
|
|
44
44
|
];
|
|
45
45
|
|
|
46
46
|
const meta = {
|
|
47
|
-
title: '
|
|
47
|
+
title: 'Composables/useDevice',
|
|
48
48
|
tags: ['autodocs'],
|
|
49
49
|
parameters: {
|
|
50
|
+
a11y: { test: 'off' },
|
|
50
51
|
chromatic: {
|
|
51
52
|
disableSnapshot: true,
|
|
52
53
|
},
|