@aleph-alpha/ui-library 7.2.1 → 7.3.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/config.js +6 -0
- package/dist/system/components/UiFileUploadBox/UiFileUploadBox.vue.d.ts +2 -2
- package/dist/system/components/UiSpinner/UiSpinner.vue.d.ts +1 -3
- package/dist/system/components/UiSpinner/index.d.ts +1 -1
- package/dist/system/components/UiSpinner/types.d.ts +19 -6
- package/dist/system/components/core/native-select/NativeSelectOptGroup.vue.d.ts +2 -2
- package/dist/system/components/core/native-select/NativeSelectOption.vue.d.ts +2 -2
- package/dist/system/icons/story-sidebar-icons.json +2 -0
- package/dist/system/lib.js +7081 -6851
- package/dist/system/patterns/UiFileUpload/UiFileUpload.vue.d.ts +2 -2
- package/dist/system/patterns/UiHeadline/UiHeadline.vue.d.ts +204 -0
- package/dist/system/patterns/UiHeadline/index.d.ts +2 -0
- package/dist/system/patterns/UiHeadline/types.d.ts +64 -0
- package/dist/system/patterns/index.d.ts +1 -0
- package/dist/system/story-sidebar-icons.json +2 -0
- package/package.json +1 -1
- package/src/components/UiField/UiField.stories.ts +302 -0
- package/src/components/UiSpinner/UiSpinner.stories.ts +579 -6
- package/src/components/UiSpinner/UiSpinner.vue +76 -4
- package/src/components/UiSpinner/__tests__/UiSpinner.test.ts +79 -0
- package/src/components/UiSpinner/index.ts +1 -1
- package/src/components/UiSpinner/types.ts +21 -6
- package/src/components/core/input/Input.vue +1 -1
- package/src/components/core/input-group/InputGroupInput.vue +1 -1
- package/src/components/core/native-select/NativeSelect.vue +1 -1
- package/src/patterns/UiHeadline/UiHeadline.guidance.md +53 -0
- package/src/patterns/UiHeadline/UiHeadline.stories.ts +915 -0
- package/src/patterns/UiHeadline/UiHeadline.vue +203 -0
- package/src/patterns/UiHeadline/__tests__/UiHeadline.test.ts +204 -0
- package/src/patterns/UiHeadline/index.ts +2 -0
- package/src/patterns/UiHeadline/types.ts +73 -0
- package/src/patterns/index.ts +1 -0
|
@@ -11,11 +11,11 @@ declare function __VLS_template(): {
|
|
|
11
11
|
};
|
|
12
12
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
13
13
|
declare const __VLS_component: import('vue').DefineComponent<import('../../components/UiFileUploadBox').UiFileUploadBoxProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
14
|
+
error: (payload: import('../../components/UiFileUploadBox').UiFileUploadBoxErrorPayload) => any;
|
|
14
15
|
click: (event: MouseEvent) => any;
|
|
15
16
|
focus: (event: FocusEvent) => any;
|
|
16
17
|
blur: (event: FocusEvent) => any;
|
|
17
18
|
keydown: (event: KeyboardEvent) => any;
|
|
18
|
-
error: (payload: import('../../components/UiFileUploadBox').UiFileUploadBoxErrorPayload) => any;
|
|
19
19
|
change: (event: Event) => any;
|
|
20
20
|
dragenter: (event: DragEvent) => any;
|
|
21
21
|
dragleave: (event: DragEvent) => any;
|
|
@@ -24,11 +24,11 @@ declare const __VLS_component: import('vue').DefineComponent<import('../../compo
|
|
|
24
24
|
"update:files": (files: File[]) => any;
|
|
25
25
|
pickerOpen: () => any;
|
|
26
26
|
}, string, import('vue').PublicProps, Readonly<import('../../components/UiFileUploadBox').UiFileUploadBoxProps> & Readonly<{
|
|
27
|
+
onError?: ((payload: import('../../components/UiFileUploadBox').UiFileUploadBoxErrorPayload) => any) | undefined;
|
|
27
28
|
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
28
29
|
onFocus?: ((event: FocusEvent) => any) | undefined;
|
|
29
30
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
30
31
|
onKeydown?: ((event: KeyboardEvent) => any) | undefined;
|
|
31
|
-
onError?: ((payload: import('../../components/UiFileUploadBox').UiFileUploadBoxErrorPayload) => any) | undefined;
|
|
32
32
|
onChange?: ((event: Event) => any) | undefined;
|
|
33
33
|
onDragenter?: ((event: DragEvent) => any) | undefined;
|
|
34
34
|
onDragleave?: ((event: DragEvent) => any) | undefined;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { nextTick } from 'vue';
|
|
2
|
+
import { UiHeadlineProps } from './types';
|
|
3
|
+
type __VLS_Props = UiHeadlineProps;
|
|
4
|
+
/** Switches to edit mode with the current title selected. */
|
|
5
|
+
declare function edit(): Promise<void>;
|
|
6
|
+
type __VLS_PublicProps = {
|
|
7
|
+
modelValue?: string;
|
|
8
|
+
} & __VLS_Props;
|
|
9
|
+
declare function __VLS_template(): {
|
|
10
|
+
attrs: Partial<{}>;
|
|
11
|
+
slots: Readonly<{
|
|
12
|
+
/** Extra menu items, rendered after "Edit name". */
|
|
13
|
+
menu?: () => unknown;
|
|
14
|
+
/** Replaces the description text. */
|
|
15
|
+
description?: () => unknown;
|
|
16
|
+
}> & {
|
|
17
|
+
/** Extra menu items, rendered after "Edit name". */
|
|
18
|
+
menu?: () => unknown;
|
|
19
|
+
/** Replaces the description text. */
|
|
20
|
+
description?: () => unknown;
|
|
21
|
+
};
|
|
22
|
+
refs: {
|
|
23
|
+
inputRef: HTMLInputElement;
|
|
24
|
+
menuButtonRef: ({
|
|
25
|
+
$: import('vue').ComponentInternalInstance;
|
|
26
|
+
$data: {};
|
|
27
|
+
$props: {
|
|
28
|
+
readonly variant?: import('../../components/UiButton').UiButtonVariant | undefined;
|
|
29
|
+
readonly size?: import('../../components/UiButton').UiButtonSize | undefined;
|
|
30
|
+
readonly asChild?: boolean | undefined;
|
|
31
|
+
readonly type?: "button" | "submit" | "reset" | undefined;
|
|
32
|
+
readonly disabled?: boolean | undefined;
|
|
33
|
+
readonly loading?: boolean | undefined;
|
|
34
|
+
readonly ariaLabel?: string | undefined;
|
|
35
|
+
readonly startIcon?: import('vue').Component | undefined;
|
|
36
|
+
readonly endIcon?: import('vue').Component | undefined;
|
|
37
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps;
|
|
38
|
+
$attrs: {
|
|
39
|
+
[x: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
$refs: {
|
|
42
|
+
[x: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
$slots: Readonly<{
|
|
45
|
+
[name: string]: import('vue').Slot<any> | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
$root: import('vue').ComponentPublicInstance | null;
|
|
48
|
+
$parent: import('vue').ComponentPublicInstance | null;
|
|
49
|
+
$host: Element | null;
|
|
50
|
+
$emit: (event: string, ...args: any[]) => void;
|
|
51
|
+
$el: any;
|
|
52
|
+
$options: import('vue').ComponentOptionsBase<Readonly<import('../../components/UiButton').UiButtonProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
|
|
53
|
+
disabled: boolean;
|
|
54
|
+
asChild: boolean;
|
|
55
|
+
type: "button" | "submit" | "reset";
|
|
56
|
+
size: import('../../components/UiButton').UiButtonSize;
|
|
57
|
+
ariaLabel: string;
|
|
58
|
+
variant: import('../../components/UiButton').UiButtonVariant;
|
|
59
|
+
loading: boolean;
|
|
60
|
+
startIcon: import('vue').Component;
|
|
61
|
+
endIcon: import('vue').Component;
|
|
62
|
+
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & {
|
|
63
|
+
beforeCreate?: (() => void) | (() => void)[];
|
|
64
|
+
created?: (() => void) | (() => void)[];
|
|
65
|
+
beforeMount?: (() => void) | (() => void)[];
|
|
66
|
+
mounted?: (() => void) | (() => void)[];
|
|
67
|
+
beforeUpdate?: (() => void) | (() => void)[];
|
|
68
|
+
updated?: (() => void) | (() => void)[];
|
|
69
|
+
activated?: (() => void) | (() => void)[];
|
|
70
|
+
deactivated?: (() => void) | (() => void)[];
|
|
71
|
+
beforeDestroy?: (() => void) | (() => void)[];
|
|
72
|
+
beforeUnmount?: (() => void) | (() => void)[];
|
|
73
|
+
destroyed?: (() => void) | (() => void)[];
|
|
74
|
+
unmounted?: (() => void) | (() => void)[];
|
|
75
|
+
renderTracked?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
|
|
76
|
+
renderTriggered?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
|
|
77
|
+
errorCaptured?: ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void)[];
|
|
78
|
+
};
|
|
79
|
+
$forceUpdate: () => void;
|
|
80
|
+
$nextTick: typeof nextTick;
|
|
81
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
|
|
82
|
+
} & Readonly<{
|
|
83
|
+
disabled: boolean;
|
|
84
|
+
asChild: boolean;
|
|
85
|
+
type: "button" | "submit" | "reset";
|
|
86
|
+
size: import('../../components/UiButton').UiButtonSize;
|
|
87
|
+
ariaLabel: string;
|
|
88
|
+
variant: import('../../components/UiButton').UiButtonVariant;
|
|
89
|
+
loading: boolean;
|
|
90
|
+
startIcon: import('vue').Component;
|
|
91
|
+
endIcon: import('vue').Component;
|
|
92
|
+
}> & Omit<Readonly<import('../../components/UiButton').UiButtonProps> & Readonly<{}>, "disabled" | "asChild" | "type" | "size" | "ariaLabel" | "variant" | "loading" | "startIcon" | "endIcon"> & import('vue').ShallowUnwrapRef<{}> & {} & import('vue').ComponentCustomProperties & {} & {
|
|
93
|
+
$slots: {
|
|
94
|
+
default?(_: {}): any;
|
|
95
|
+
default?(_: {}): any;
|
|
96
|
+
};
|
|
97
|
+
}) | null;
|
|
98
|
+
};
|
|
99
|
+
rootEl: any;
|
|
100
|
+
};
|
|
101
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
102
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
103
|
+
edit: typeof edit;
|
|
104
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
105
|
+
"update:modelValue": (value: string) => any;
|
|
106
|
+
cancel: () => any;
|
|
107
|
+
save: (value: string) => any;
|
|
108
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
109
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
110
|
+
onCancel?: (() => any) | undefined;
|
|
111
|
+
onSave?: ((value: string) => any) | undefined;
|
|
112
|
+
}>, {
|
|
113
|
+
as: import('./types').UiHeadlineLevel;
|
|
114
|
+
description: string;
|
|
115
|
+
editable: boolean;
|
|
116
|
+
editLabel: string;
|
|
117
|
+
menuLabel: string;
|
|
118
|
+
inputLabel: string;
|
|
119
|
+
saveLabel: string;
|
|
120
|
+
cancelLabel: string;
|
|
121
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
122
|
+
inputRef: HTMLInputElement;
|
|
123
|
+
menuButtonRef: ({
|
|
124
|
+
$: import('vue').ComponentInternalInstance;
|
|
125
|
+
$data: {};
|
|
126
|
+
$props: {
|
|
127
|
+
readonly variant?: import('../../components/UiButton').UiButtonVariant | undefined;
|
|
128
|
+
readonly size?: import('../../components/UiButton').UiButtonSize | undefined;
|
|
129
|
+
readonly asChild?: boolean | undefined;
|
|
130
|
+
readonly type?: "button" | "submit" | "reset" | undefined;
|
|
131
|
+
readonly disabled?: boolean | undefined;
|
|
132
|
+
readonly loading?: boolean | undefined;
|
|
133
|
+
readonly ariaLabel?: string | undefined;
|
|
134
|
+
readonly startIcon?: import('vue').Component | undefined;
|
|
135
|
+
readonly endIcon?: import('vue').Component | undefined;
|
|
136
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps;
|
|
137
|
+
$attrs: {
|
|
138
|
+
[x: string]: unknown;
|
|
139
|
+
};
|
|
140
|
+
$refs: {
|
|
141
|
+
[x: string]: unknown;
|
|
142
|
+
};
|
|
143
|
+
$slots: Readonly<{
|
|
144
|
+
[name: string]: import('vue').Slot<any> | undefined;
|
|
145
|
+
}>;
|
|
146
|
+
$root: import('vue').ComponentPublicInstance | null;
|
|
147
|
+
$parent: import('vue').ComponentPublicInstance | null;
|
|
148
|
+
$host: Element | null;
|
|
149
|
+
$emit: (event: string, ...args: any[]) => void;
|
|
150
|
+
$el: any;
|
|
151
|
+
$options: import('vue').ComponentOptionsBase<Readonly<import('../../components/UiButton').UiButtonProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
|
|
152
|
+
disabled: boolean;
|
|
153
|
+
asChild: boolean;
|
|
154
|
+
type: "button" | "submit" | "reset";
|
|
155
|
+
size: import('../../components/UiButton').UiButtonSize;
|
|
156
|
+
ariaLabel: string;
|
|
157
|
+
variant: import('../../components/UiButton').UiButtonVariant;
|
|
158
|
+
loading: boolean;
|
|
159
|
+
startIcon: import('vue').Component;
|
|
160
|
+
endIcon: import('vue').Component;
|
|
161
|
+
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & {
|
|
162
|
+
beforeCreate?: (() => void) | (() => void)[];
|
|
163
|
+
created?: (() => void) | (() => void)[];
|
|
164
|
+
beforeMount?: (() => void) | (() => void)[];
|
|
165
|
+
mounted?: (() => void) | (() => void)[];
|
|
166
|
+
beforeUpdate?: (() => void) | (() => void)[];
|
|
167
|
+
updated?: (() => void) | (() => void)[];
|
|
168
|
+
activated?: (() => void) | (() => void)[];
|
|
169
|
+
deactivated?: (() => void) | (() => void)[];
|
|
170
|
+
beforeDestroy?: (() => void) | (() => void)[];
|
|
171
|
+
beforeUnmount?: (() => void) | (() => void)[];
|
|
172
|
+
destroyed?: (() => void) | (() => void)[];
|
|
173
|
+
unmounted?: (() => void) | (() => void)[];
|
|
174
|
+
renderTracked?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
|
|
175
|
+
renderTriggered?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
|
|
176
|
+
errorCaptured?: ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void)[];
|
|
177
|
+
};
|
|
178
|
+
$forceUpdate: () => void;
|
|
179
|
+
$nextTick: typeof nextTick;
|
|
180
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
|
|
181
|
+
} & Readonly<{
|
|
182
|
+
disabled: boolean;
|
|
183
|
+
asChild: boolean;
|
|
184
|
+
type: "button" | "submit" | "reset";
|
|
185
|
+
size: import('../../components/UiButton').UiButtonSize;
|
|
186
|
+
ariaLabel: string;
|
|
187
|
+
variant: import('../../components/UiButton').UiButtonVariant;
|
|
188
|
+
loading: boolean;
|
|
189
|
+
startIcon: import('vue').Component;
|
|
190
|
+
endIcon: import('vue').Component;
|
|
191
|
+
}> & Omit<Readonly<import('../../components/UiButton').UiButtonProps> & Readonly<{}>, "disabled" | "asChild" | "type" | "size" | "ariaLabel" | "variant" | "loading" | "startIcon" | "endIcon"> & import('vue').ShallowUnwrapRef<{}> & {} & import('vue').ComponentCustomProperties & {} & {
|
|
192
|
+
$slots: {
|
|
193
|
+
default?(_: {}): any;
|
|
194
|
+
default?(_: {}): any;
|
|
195
|
+
};
|
|
196
|
+
}) | null;
|
|
197
|
+
}, any>;
|
|
198
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
199
|
+
export default _default;
|
|
200
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
201
|
+
new (): {
|
|
202
|
+
$slots: S;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heading levels the headline can render as.
|
|
3
|
+
*/
|
|
4
|
+
export type UiHeadlineLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
5
|
+
/**
|
|
6
|
+
* A page or section headline with an optional description that the user can
|
|
7
|
+
* rename in place: "Edit name" in its menu turns the title into a field with
|
|
8
|
+
* save and cancel actions.
|
|
9
|
+
* @category Layout
|
|
10
|
+
* @useCases page title, section title, rename in place, editable name, workspace name
|
|
11
|
+
* @keywords headline, heading, title, rename, inline edit, editable, description
|
|
12
|
+
* @related UiDropdownMenu, UiInput, UiButton
|
|
13
|
+
*/
|
|
14
|
+
export interface UiHeadlineProps {
|
|
15
|
+
/**
|
|
16
|
+
* Supporting text shown below the title.
|
|
17
|
+
*/
|
|
18
|
+
description?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Heading element the title renders as. Pick the level that fits the page
|
|
21
|
+
* outline; the visual size stays the same.
|
|
22
|
+
* @default 'h2'
|
|
23
|
+
*/
|
|
24
|
+
as?: UiHeadlineLevel;
|
|
25
|
+
/**
|
|
26
|
+
* Shows the menu with "Edit name". Set to `false` for a read-only headline.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
editable?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Label of the menu item that starts editing.
|
|
32
|
+
* @default 'Edit name'
|
|
33
|
+
*/
|
|
34
|
+
editLabel?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Accessible name of the menu button.
|
|
37
|
+
* @default 'More actions'
|
|
38
|
+
*/
|
|
39
|
+
menuLabel?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Accessible name of the title field while editing.
|
|
42
|
+
* @default 'Name'
|
|
43
|
+
*/
|
|
44
|
+
inputLabel?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Accessible name of the save button.
|
|
47
|
+
* @default 'Save'
|
|
48
|
+
*/
|
|
49
|
+
saveLabel?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Accessible name of the cancel button.
|
|
52
|
+
* @default 'Cancel'
|
|
53
|
+
*/
|
|
54
|
+
cancelLabel?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Emits for the UiHeadline component.
|
|
58
|
+
*/
|
|
59
|
+
export interface UiHeadlineEmits {
|
|
60
|
+
/** Emitted with the trimmed title when a changed name is saved. */
|
|
61
|
+
save: [value: string];
|
|
62
|
+
/** Emitted when editing ends without saving. */
|
|
63
|
+
cancel: [];
|
|
64
|
+
}
|
|
@@ -7,6 +7,7 @@ export * from './UiDataTable';
|
|
|
7
7
|
export * from './UiDatePicker';
|
|
8
8
|
export * from './UiFileUpload';
|
|
9
9
|
export * from './UiFloatActions';
|
|
10
|
+
export * from './UiHeadline';
|
|
10
11
|
export * from './UiLayout';
|
|
11
12
|
export * from './UiPlaceholder';
|
|
12
13
|
export * from './UiProfileCard';
|
|
@@ -102,6 +102,8 @@
|
|
|
102
102
|
"patterns-uifileupload-uifileupload--design-notes": "palette",
|
|
103
103
|
"patterns-uifileupload-uifileupload--accessibility": "accessibility",
|
|
104
104
|
"patterns-uifloatactions--accessibility": "accessibility",
|
|
105
|
+
"patterns-uiheadline--design-notes": "palette",
|
|
106
|
+
"patterns-uiheadline--accessibility": "accessibility",
|
|
105
107
|
"patterns-uilayout-content--accessibility": "accessibility",
|
|
106
108
|
"patterns-uilayout-mobile--design-notes": "palette",
|
|
107
109
|
"patterns-uiprofilecard--accessibility": "accessibility",
|
package/package.json
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
UiSelectTrigger,
|
|
32
32
|
UiSelectValue,
|
|
33
33
|
} from '../UiSelect';
|
|
34
|
+
import { UiSpinner } from '../UiSpinner';
|
|
34
35
|
import { UiSwitch } from '../UiSwitch';
|
|
35
36
|
import { UiTextarea } from '../UiTextarea';
|
|
36
37
|
import { UiButton } from '../UiButton';
|
|
@@ -1633,6 +1634,307 @@ export const ValidationAndErrors: Story = {
|
|
|
1633
1634
|
},
|
|
1634
1635
|
};
|
|
1635
1636
|
|
|
1637
|
+
type SaveOutcome = 'success' | 'warning' | 'error';
|
|
1638
|
+
|
|
1639
|
+
const saveStatuses = {
|
|
1640
|
+
success: ref<'loading' | SaveOutcome>('loading'),
|
|
1641
|
+
warning: ref<'loading' | SaveOutcome>('loading'),
|
|
1642
|
+
error: ref<'loading' | SaveOutcome>('loading'),
|
|
1643
|
+
};
|
|
1644
|
+
let saveTimer: ReturnType<typeof setTimeout> | undefined;
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* Starts all three fields on the spinner, then resolves each to its outcome.
|
|
1648
|
+
* The play function restarts it so assertions always see the loading state.
|
|
1649
|
+
*/
|
|
1650
|
+
function runInlineSave() {
|
|
1651
|
+
clearTimeout(saveTimer);
|
|
1652
|
+
for (const status of Object.values(saveStatuses)) status.value = 'loading';
|
|
1653
|
+
saveTimer = setTimeout(() => {
|
|
1654
|
+
for (const outcome of Object.keys(saveStatuses) as SaveOutcome[]) {
|
|
1655
|
+
saveStatuses[outcome].value = outcome;
|
|
1656
|
+
}
|
|
1657
|
+
}, 600);
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
const inlineSaveStatusTemplateSource = `<script setup lang="ts">
|
|
1661
|
+
import { onMounted, ref } from 'vue'
|
|
1662
|
+
import {
|
|
1663
|
+
UiField,
|
|
1664
|
+
UiFieldDescription,
|
|
1665
|
+
UiFieldError,
|
|
1666
|
+
UiFieldGroup,
|
|
1667
|
+
UiFieldLabel,
|
|
1668
|
+
UiInput,
|
|
1669
|
+
UiSpinner,
|
|
1670
|
+
} from '@aleph-alpha/ui-library'
|
|
1671
|
+
|
|
1672
|
+
const name = ref('Ada Lovelace')
|
|
1673
|
+
const handle = ref('ada')
|
|
1674
|
+
const email = ref('ada@example')
|
|
1675
|
+
|
|
1676
|
+
const nameStatus = ref<'loading' | 'success'>('loading')
|
|
1677
|
+
const handleStatus = ref<'loading' | 'warning'>('loading')
|
|
1678
|
+
const emailStatus = ref<'loading' | 'error'>('loading')
|
|
1679
|
+
|
|
1680
|
+
onMounted(() => {
|
|
1681
|
+
window.setTimeout(() => {
|
|
1682
|
+
nameStatus.value = 'success'
|
|
1683
|
+
handleStatus.value = 'warning'
|
|
1684
|
+
emailStatus.value = 'error'
|
|
1685
|
+
}, 600)
|
|
1686
|
+
})
|
|
1687
|
+
</script>
|
|
1688
|
+
|
|
1689
|
+
<template>
|
|
1690
|
+
<UiFieldGroup class="max-w-sm">
|
|
1691
|
+
<!-- Success: no message needed. -->
|
|
1692
|
+
<UiField>
|
|
1693
|
+
<UiFieldLabel for="save-name">Display name</UiFieldLabel>
|
|
1694
|
+
<UiInput id="save-name" v-model="name" name="display-name" :aria-busy="nameStatus === 'loading'">
|
|
1695
|
+
<template #end>
|
|
1696
|
+
<UiSpinner :status="nameStatus" :aria-label="nameStatus === 'loading' ? 'Saving' : 'Saved'" />
|
|
1697
|
+
</template>
|
|
1698
|
+
</UiInput>
|
|
1699
|
+
</UiField>
|
|
1700
|
+
|
|
1701
|
+
<!-- Warning: saved, with a message below the input. -->
|
|
1702
|
+
<UiField>
|
|
1703
|
+
<UiFieldLabel for="save-handle">Handle</UiFieldLabel>
|
|
1704
|
+
<UiInput
|
|
1705
|
+
id="save-handle"
|
|
1706
|
+
v-model="handle"
|
|
1707
|
+
name="handle"
|
|
1708
|
+
:aria-busy="handleStatus === 'loading'"
|
|
1709
|
+
:aria-describedby="handleStatus === 'warning' ? 'save-handle-message' : undefined"
|
|
1710
|
+
>
|
|
1711
|
+
<template #end>
|
|
1712
|
+
<UiSpinner :status="handleStatus" :aria-label="handleStatus === 'loading' ? 'Saving' : 'Saved with a warning'" />
|
|
1713
|
+
</template>
|
|
1714
|
+
</UiInput>
|
|
1715
|
+
<UiFieldDescription
|
|
1716
|
+
v-if="handleStatus === 'warning'"
|
|
1717
|
+
id="save-handle-message"
|
|
1718
|
+
class="text-background-status-warning"
|
|
1719
|
+
>
|
|
1720
|
+
Short handles are harder for teammates to find.
|
|
1721
|
+
</UiFieldDescription>
|
|
1722
|
+
</UiField>
|
|
1723
|
+
|
|
1724
|
+
<!-- Error: not saved, the field is invalid and the reason is announced. -->
|
|
1725
|
+
<UiField :data-invalid="emailStatus === 'error' ? 'true' : undefined">
|
|
1726
|
+
<UiFieldLabel for="save-email">Email</UiFieldLabel>
|
|
1727
|
+
<UiInput
|
|
1728
|
+
id="save-email"
|
|
1729
|
+
v-model="email"
|
|
1730
|
+
name="email"
|
|
1731
|
+
:aria-busy="emailStatus === 'loading'"
|
|
1732
|
+
:aria-invalid="emailStatus === 'error'"
|
|
1733
|
+
:aria-describedby="emailStatus === 'error' ? 'save-email-message' : undefined"
|
|
1734
|
+
>
|
|
1735
|
+
<template #end>
|
|
1736
|
+
<UiSpinner :status="emailStatus" :aria-label="emailStatus === 'loading' ? 'Saving' : 'Failed to save'" />
|
|
1737
|
+
</template>
|
|
1738
|
+
</UiInput>
|
|
1739
|
+
<UiFieldError v-if="emailStatus === 'error'" id="save-email-message">
|
|
1740
|
+
<span class="block">Failed to save</span>
|
|
1741
|
+
Enter an email address with a domain, like name@company.com.
|
|
1742
|
+
</UiFieldError>
|
|
1743
|
+
</UiField>
|
|
1744
|
+
</UiFieldGroup>
|
|
1745
|
+
</template>`;
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Inline save status inside fields: each input shows the spinner while it
|
|
1749
|
+
* saves, then a success, warning, or error icon. Success needs no message.
|
|
1750
|
+
* Warning adds a description below the input. Error marks the field invalid
|
|
1751
|
+
* and announces the reason.
|
|
1752
|
+
*/
|
|
1753
|
+
export const InlineSaveStatus: Story = {
|
|
1754
|
+
render: () => ({
|
|
1755
|
+
components: {
|
|
1756
|
+
UiField,
|
|
1757
|
+
UiFieldDescription,
|
|
1758
|
+
UiFieldError,
|
|
1759
|
+
UiFieldGroup,
|
|
1760
|
+
UiFieldLabel,
|
|
1761
|
+
UiInput,
|
|
1762
|
+
UiSpinner,
|
|
1763
|
+
},
|
|
1764
|
+
setup() {
|
|
1765
|
+
const name = ref('Ada Lovelace');
|
|
1766
|
+
const handle = ref('ada');
|
|
1767
|
+
const email = ref('ada@example');
|
|
1768
|
+
runInlineSave();
|
|
1769
|
+
return {
|
|
1770
|
+
name,
|
|
1771
|
+
handle,
|
|
1772
|
+
email,
|
|
1773
|
+
nameStatus: saveStatuses.success,
|
|
1774
|
+
handleStatus: saveStatuses.warning,
|
|
1775
|
+
emailStatus: saveStatuses.error,
|
|
1776
|
+
};
|
|
1777
|
+
},
|
|
1778
|
+
template: `
|
|
1779
|
+
<UiFieldGroup class="max-w-sm">
|
|
1780
|
+
<UiField>
|
|
1781
|
+
<UiFieldLabel for="save-name">Display name</UiFieldLabel>
|
|
1782
|
+
<UiInput id="save-name" v-model="name" name="display-name" :aria-busy="nameStatus === 'loading'">
|
|
1783
|
+
<template #end>
|
|
1784
|
+
<UiSpinner :status="nameStatus" :aria-label="nameStatus === 'loading' ? 'Saving' : 'Saved'" />
|
|
1785
|
+
</template>
|
|
1786
|
+
</UiInput>
|
|
1787
|
+
</UiField>
|
|
1788
|
+
|
|
1789
|
+
<UiField>
|
|
1790
|
+
<UiFieldLabel for="save-handle">Handle</UiFieldLabel>
|
|
1791
|
+
<UiInput
|
|
1792
|
+
id="save-handle"
|
|
1793
|
+
v-model="handle"
|
|
1794
|
+
name="handle"
|
|
1795
|
+
:aria-busy="handleStatus === 'loading'"
|
|
1796
|
+
:aria-describedby="handleStatus === 'warning' ? 'save-handle-message' : undefined"
|
|
1797
|
+
>
|
|
1798
|
+
<template #end>
|
|
1799
|
+
<UiSpinner :status="handleStatus" :aria-label="handleStatus === 'loading' ? 'Saving' : 'Saved with a warning'" />
|
|
1800
|
+
</template>
|
|
1801
|
+
</UiInput>
|
|
1802
|
+
<UiFieldDescription
|
|
1803
|
+
v-if="handleStatus === 'warning'"
|
|
1804
|
+
id="save-handle-message"
|
|
1805
|
+
class="text-background-status-warning"
|
|
1806
|
+
>
|
|
1807
|
+
Short handles are harder for teammates to find.
|
|
1808
|
+
</UiFieldDescription>
|
|
1809
|
+
</UiField>
|
|
1810
|
+
|
|
1811
|
+
<UiField :data-invalid="emailStatus === 'error' ? 'true' : undefined">
|
|
1812
|
+
<UiFieldLabel for="save-email">Email</UiFieldLabel>
|
|
1813
|
+
<UiInput
|
|
1814
|
+
id="save-email"
|
|
1815
|
+
v-model="email"
|
|
1816
|
+
name="email"
|
|
1817
|
+
:aria-busy="emailStatus === 'loading'"
|
|
1818
|
+
:aria-invalid="emailStatus === 'error'"
|
|
1819
|
+
:aria-describedby="emailStatus === 'error' ? 'save-email-message' : undefined"
|
|
1820
|
+
>
|
|
1821
|
+
<template #end>
|
|
1822
|
+
<UiSpinner :status="emailStatus" :aria-label="emailStatus === 'loading' ? 'Saving' : 'Failed to save'" />
|
|
1823
|
+
</template>
|
|
1824
|
+
</UiInput>
|
|
1825
|
+
<UiFieldError v-if="emailStatus === 'error'" id="save-email-message">
|
|
1826
|
+
<span class="block">Failed to save</span>
|
|
1827
|
+
Enter an email address with a domain, like name@company.com.
|
|
1828
|
+
</UiFieldError>
|
|
1829
|
+
</UiField>
|
|
1830
|
+
</UiFieldGroup>
|
|
1831
|
+
`,
|
|
1832
|
+
}),
|
|
1833
|
+
parameters: {
|
|
1834
|
+
controls: { disable: true },
|
|
1835
|
+
// Tab moves focus during the play function.
|
|
1836
|
+
chromatic: { disableSnapshot: true },
|
|
1837
|
+
docs: { source: { code: inlineSaveStatusTemplateSource } },
|
|
1838
|
+
},
|
|
1839
|
+
play: async ({ canvasElement, step }) => {
|
|
1840
|
+
// Scenario (UiField + UiSpinner): three fields save at once. Each shows
|
|
1841
|
+
// the spinner, then resolves to success, warning, or error, with the
|
|
1842
|
+
// message wired to its input.
|
|
1843
|
+
runInlineSave();
|
|
1844
|
+
const canvas = within(canvasElement);
|
|
1845
|
+
const name = canvas.getByRole('textbox', { name: 'Display name' });
|
|
1846
|
+
const handle = canvas.getByRole('textbox', { name: 'Handle' });
|
|
1847
|
+
const email = canvas.getByRole('textbox', { name: 'Email' });
|
|
1848
|
+
|
|
1849
|
+
await step(
|
|
1850
|
+
'interaction: every field starts on the loading spinner',
|
|
1851
|
+
async () => {
|
|
1852
|
+
const saving = canvas.getAllByRole('status', { name: 'Saving' });
|
|
1853
|
+
await expect(saving).toHaveLength(3);
|
|
1854
|
+
for (const status of saving) {
|
|
1855
|
+
await expect(status).toHaveAttribute('data-status', 'loading');
|
|
1856
|
+
}
|
|
1857
|
+
for (const input of [name, handle, email]) {
|
|
1858
|
+
await expect(input).toHaveAttribute('aria-busy', 'true');
|
|
1859
|
+
}
|
|
1860
|
+
await expect(canvas.queryByRole('alert')).not.toBeInTheDocument();
|
|
1861
|
+
},
|
|
1862
|
+
);
|
|
1863
|
+
|
|
1864
|
+
await step(
|
|
1865
|
+
'interaction: each field resolves to success, warning, and error',
|
|
1866
|
+
async () => {
|
|
1867
|
+
await waitFor(
|
|
1868
|
+
() => {
|
|
1869
|
+
for (const status of canvas.getAllByRole('status')) {
|
|
1870
|
+
expect(status.querySelector('.animate-spin')).toBeNull();
|
|
1871
|
+
}
|
|
1872
|
+
},
|
|
1873
|
+
{ timeout: 2000 },
|
|
1874
|
+
);
|
|
1875
|
+
await expect(
|
|
1876
|
+
canvas.getByRole('status', { name: 'Saved' }),
|
|
1877
|
+
).toHaveAttribute('data-status', 'success');
|
|
1878
|
+
await expect(
|
|
1879
|
+
canvas.getByRole('status', { name: 'Saved with a warning' }),
|
|
1880
|
+
).toHaveAttribute('data-status', 'warning');
|
|
1881
|
+
await expect(
|
|
1882
|
+
canvas.getByRole('status', { name: 'Failed to save' }),
|
|
1883
|
+
).toHaveAttribute('data-status', 'error');
|
|
1884
|
+
for (const input of [name, handle, email]) {
|
|
1885
|
+
await expect(input).toHaveAttribute('aria-busy', 'false');
|
|
1886
|
+
}
|
|
1887
|
+
},
|
|
1888
|
+
);
|
|
1889
|
+
|
|
1890
|
+
await step(
|
|
1891
|
+
'screen-reader: success adds no message and leaves the field valid',
|
|
1892
|
+
async () => {
|
|
1893
|
+
await expect(name).not.toHaveAttribute('aria-describedby');
|
|
1894
|
+
await expect(name).not.toHaveAttribute('aria-invalid', 'true');
|
|
1895
|
+
},
|
|
1896
|
+
);
|
|
1897
|
+
|
|
1898
|
+
await step(
|
|
1899
|
+
'screen-reader: the warning message describes its field without marking it invalid (WCAG 1.3.1)',
|
|
1900
|
+
async () => {
|
|
1901
|
+
await expect(handle).toHaveAccessibleDescription(
|
|
1902
|
+
'Short handles are harder for teammates to find.',
|
|
1903
|
+
);
|
|
1904
|
+
await expect(handle).not.toHaveAttribute('aria-invalid', 'true');
|
|
1905
|
+
},
|
|
1906
|
+
);
|
|
1907
|
+
|
|
1908
|
+
await step(
|
|
1909
|
+
'screen-reader: the error is announced and tied to the invalid field (WCAG 3.3.1)',
|
|
1910
|
+
async () => {
|
|
1911
|
+
const alert = canvas.getByRole('alert');
|
|
1912
|
+
await expect(alert).toHaveTextContent('Failed to save');
|
|
1913
|
+
await expect(email).toHaveAttribute('aria-invalid', 'true');
|
|
1914
|
+
await expect(email).toHaveAccessibleDescription(
|
|
1915
|
+
/Enter an email address with a domain/,
|
|
1916
|
+
);
|
|
1917
|
+
},
|
|
1918
|
+
);
|
|
1919
|
+
|
|
1920
|
+
await step(
|
|
1921
|
+
'keyboard: Tab moves between the inputs and skips the status icons',
|
|
1922
|
+
async () => {
|
|
1923
|
+
name.blur();
|
|
1924
|
+
await userEvent.tab();
|
|
1925
|
+
await expect(name).toHaveFocus();
|
|
1926
|
+
await userEvent.tab();
|
|
1927
|
+
await expect(handle).toHaveFocus();
|
|
1928
|
+
await userEvent.tab();
|
|
1929
|
+
await expect(email).toHaveFocus();
|
|
1930
|
+
for (const status of canvas.getAllByRole('status')) {
|
|
1931
|
+
await expect(status).not.toHaveAttribute('tabindex');
|
|
1932
|
+
}
|
|
1933
|
+
},
|
|
1934
|
+
);
|
|
1935
|
+
},
|
|
1936
|
+
};
|
|
1937
|
+
|
|
1636
1938
|
const checkboxGroupTemplateSource = `<script setup lang="ts">
|
|
1637
1939
|
import { ref } from 'vue'
|
|
1638
1940
|
import {
|