@aleph-alpha/ui-library 5.5.0 → 5.7.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 +5 -0
- package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +2 -0
- package/dist/system/components/UiButtonGroup/UiButtonGroup.vue.d.ts +20 -0
- package/dist/system/components/UiButtonGroup/index.d.ts +2 -0
- package/dist/system/components/UiButtonGroup/types.d.ts +20 -0
- package/dist/system/components/UiField/types.d.ts +2 -1
- package/dist/system/components/core/button-group/ButtonGroup.vue.d.ts +23 -0
- package/dist/system/components/core/button-group/ButtonGroupSeparator.vue.d.ts +9 -0
- package/dist/system/components/core/button-group/ButtonGroupText.vue.d.ts +26 -0
- package/dist/system/components/core/button-group/index.d.ts +8 -0
- package/dist/system/components/index.d.ts +1 -0
- package/dist/system/lib.js +7855 -7732
- package/dist/system/story-sidebar-icons.json +3 -0
- package/package.json +5 -5
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +619 -0
- package/src/components/UiAutocomplete/UiAutocomplete.vue +28 -3
- package/src/components/UiAutocomplete/__tests__/UiAutocomplete.test.ts +14 -69
- package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +690 -0
- package/src/components/UiButtonGroup/UiButtonGroup.vue +18 -0
- package/src/components/UiButtonGroup/__tests__/UiButtonGroup.test.ts +68 -0
- package/src/components/UiButtonGroup/index.ts +2 -0
- package/src/components/UiButtonGroup/types.ts +21 -0
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +625 -74
- package/src/components/UiField/UiField.stories.ts +1 -1
- package/src/components/UiField/types.ts +2 -1
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +995 -0
- package/src/components/UiSelect/UiSelect.stories.ts +769 -0
- package/src/components/UiSelect/__tests__/UiSelect.test.ts +4 -73
- package/src/components/UiSelect/__tests__/UiSelectItem.test.ts +3 -31
- package/src/components/UiSelect/__tests__/UiSelectTrigger.test.ts +14 -5
- package/src/components/core/button-group/ButtonGroup.vue +24 -0
- package/src/components/core/button-group/ButtonGroupSeparator.vue +29 -0
- package/src/components/core/button-group/ButtonGroupText.vue +33 -0
- package/src/components/core/button-group/index.ts +25 -0
- package/src/components/core/field/FieldDescription.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +3 -2
- package/src/components/core/field/FieldTitle.vue +1 -1
- package/src/components/core/select/SelectTrigger.vue +1 -1
- package/src/components/index.ts +1 -0
- package/src/components/UiCheckbox/__tests__/UiCheckbox.test.ts +0 -14
- package/src/components/UiRadioGroup/__tests__/UiRadioGroup.test.ts +0 -412
|
@@ -82,79 +82,10 @@ describe('UiSelect', () => {
|
|
|
82
82
|
expect(queryByRole('listbox')).not.toBeInTheDocument();
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await user.click(getByRole('combobox'));
|
|
90
|
-
|
|
91
|
-
await waitFor(() => {
|
|
92
|
-
expect(getByRole('listbox')).toBeInTheDocument();
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('renders all options when open', async () => {
|
|
97
|
-
const user = userEvent.setup();
|
|
98
|
-
const { getByRole, getAllByRole } = renderSelect({
|
|
99
|
-
items: [
|
|
100
|
-
{ value: 'a', label: 'Alpha' },
|
|
101
|
-
{ value: 'b', label: 'Beta' },
|
|
102
|
-
{ value: 'c', label: 'Gamma' },
|
|
103
|
-
],
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
await user.click(getByRole('combobox'));
|
|
107
|
-
|
|
108
|
-
await waitFor(() => {
|
|
109
|
-
const options = getAllByRole('option');
|
|
110
|
-
expect(options).toHaveLength(3);
|
|
111
|
-
expect(options[0]).toHaveTextContent('Alpha');
|
|
112
|
-
expect(options[1]).toHaveTextContent('Beta');
|
|
113
|
-
expect(options[2]).toHaveTextContent('Gamma');
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('selects an option when clicked', async () => {
|
|
118
|
-
const user = userEvent.setup();
|
|
119
|
-
const { getByRole } = renderSelect();
|
|
120
|
-
|
|
121
|
-
await user.click(getByRole('combobox'));
|
|
122
|
-
await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
|
|
123
|
-
|
|
124
|
-
await user.click(getByRole('option', { name: 'Option 2' }));
|
|
125
|
-
|
|
126
|
-
await waitFor(() => {
|
|
127
|
-
expect(getByRole('combobox')).toHaveTextContent('Option 2');
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test('closes dropdown after selection', async () => {
|
|
132
|
-
const user = userEvent.setup();
|
|
133
|
-
const { getByRole, queryByRole } = renderSelect();
|
|
134
|
-
|
|
135
|
-
await user.click(getByRole('combobox'));
|
|
136
|
-
await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
|
|
137
|
-
|
|
138
|
-
await user.click(getByRole('option', { name: 'Option 1' }));
|
|
139
|
-
|
|
140
|
-
await waitFor(() => {
|
|
141
|
-
expect(queryByRole('listbox')).not.toBeInTheDocument();
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test('closes dropdown when Escape is pressed', async () => {
|
|
146
|
-
const user = userEvent.setup();
|
|
147
|
-
const { getByRole, queryByRole } = renderSelect();
|
|
148
|
-
|
|
149
|
-
await user.click(getByRole('combobox'));
|
|
150
|
-
await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
|
|
151
|
-
|
|
152
|
-
await user.keyboard('{Escape}');
|
|
153
|
-
|
|
154
|
-
await waitFor(() => {
|
|
155
|
-
expect(queryByRole('listbox')).not.toBeInTheDocument();
|
|
156
|
-
});
|
|
157
|
-
});
|
|
85
|
+
// Single-select interactions (opening the dropdown, rendering options,
|
|
86
|
+
// choosing a value, closing after selection or Escape, and focus returning
|
|
87
|
+
// to the trigger) are covered by the `test - Open Select Close` and
|
|
88
|
+
// `test - Keyboard Navigation` play functions in UiSelect.stories.ts.
|
|
158
89
|
|
|
159
90
|
test('renders with default value', async () => {
|
|
160
91
|
const { getByRole } = render({
|
|
@@ -182,35 +182,7 @@ describe('UiSelectItem', () => {
|
|
|
182
182
|
expect(end).toHaveClass('right-2');
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
components: {
|
|
189
|
-
UiSelect,
|
|
190
|
-
UiSelectTrigger,
|
|
191
|
-
UiSelectContent,
|
|
192
|
-
UiSelectItem,
|
|
193
|
-
UiSelectValue,
|
|
194
|
-
},
|
|
195
|
-
template: `
|
|
196
|
-
<UiSelect>
|
|
197
|
-
<UiSelectTrigger>
|
|
198
|
-
<UiSelectValue placeholder="Select" />
|
|
199
|
-
</UiSelectTrigger>
|
|
200
|
-
<UiSelectContent>
|
|
201
|
-
<UiSelectItem value="enabled">Enabled Option</UiSelectItem>
|
|
202
|
-
<UiSelectItem value="disabled" :disabled="true">Disabled Option</UiSelectItem>
|
|
203
|
-
</UiSelectContent>
|
|
204
|
-
</UiSelect>
|
|
205
|
-
`,
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
await user.click(getByRole('combobox'));
|
|
209
|
-
await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
|
|
210
|
-
|
|
211
|
-
await user.click(getByRole('option', { name: 'Disabled Option' }));
|
|
212
|
-
|
|
213
|
-
// Listbox should still be open after clicking disabled item
|
|
214
|
-
expect(getByRole('listbox')).toBeInTheDocument();
|
|
215
|
-
});
|
|
185
|
+
// The disabled-option guard (a disabled item announces its state and cannot
|
|
186
|
+
// be chosen) is covered by the `test - Open Select Close` play function in
|
|
187
|
+
// UiSelect.stories.ts.
|
|
216
188
|
});
|
|
@@ -97,7 +97,9 @@ describe('UiSelectTrigger', () => {
|
|
|
97
97
|
expect(trigger).toHaveClass(
|
|
98
98
|
'focus-visible:border-border-surface-focus-ring',
|
|
99
99
|
);
|
|
100
|
-
|
|
100
|
+
// The pressed/active state no longer gets the focus-ring border; a
|
|
101
|
+
// selected value is represented by the filled surface instead.
|
|
102
|
+
expect(trigger).not.toHaveClass('active:border-border-surface-focus-ring');
|
|
101
103
|
expect(trigger).toHaveClass(
|
|
102
104
|
'data-[state=open]:border-border-surface-focus-ring',
|
|
103
105
|
);
|
|
@@ -124,7 +126,7 @@ describe('UiSelectTrigger', () => {
|
|
|
124
126
|
expect(trigger).toHaveClass(
|
|
125
127
|
'focus-visible:border-border-surface-focus-ring',
|
|
126
128
|
);
|
|
127
|
-
expect(trigger).toHaveClass('active:border-border-surface-focus-ring');
|
|
129
|
+
expect(trigger).not.toHaveClass('active:border-border-surface-focus-ring');
|
|
128
130
|
expect(trigger).toHaveClass(
|
|
129
131
|
'data-[state=open]:border-border-surface-focus-ring',
|
|
130
132
|
);
|
|
@@ -157,13 +159,18 @@ describe('UiSelectTrigger', () => {
|
|
|
157
159
|
const trigger = getByRole('combobox');
|
|
158
160
|
expect(trigger).not.toHaveAttribute('data-placeholder');
|
|
159
161
|
expect(trigger).toHaveTextContent('Option 1');
|
|
160
|
-
|
|
162
|
+
// Filled state: same input surface as the empty state — only the muted
|
|
163
|
+
// placeholder text switches to regular value text. The focus-ring
|
|
164
|
+
// border stays reserved for focus/open states.
|
|
165
|
+
expect(trigger).toHaveClass('bg-background-input-default');
|
|
166
|
+
expect(trigger).not.toHaveClass('bg-accent');
|
|
167
|
+
expect(trigger).not.toHaveClass(
|
|
161
168
|
'[&:not([data-placeholder])]:border-border-surface-focus-ring',
|
|
162
169
|
);
|
|
163
170
|
});
|
|
164
171
|
});
|
|
165
172
|
|
|
166
|
-
test('uses
|
|
173
|
+
test('uses the filled surface when multi-select has a value', async () => {
|
|
167
174
|
const { getByRole } = render({
|
|
168
175
|
components: {
|
|
169
176
|
UiSelect,
|
|
@@ -188,7 +195,9 @@ describe('UiSelectTrigger', () => {
|
|
|
188
195
|
const trigger = getByRole('combobox');
|
|
189
196
|
expect(trigger).not.toHaveAttribute('data-placeholder');
|
|
190
197
|
expect(trigger).toHaveTextContent('Option 1');
|
|
191
|
-
expect(trigger).toHaveClass(
|
|
198
|
+
expect(trigger).toHaveClass('bg-background-input-default');
|
|
199
|
+
expect(trigger).not.toHaveClass('bg-accent');
|
|
200
|
+
expect(trigger).not.toHaveClass(
|
|
192
201
|
'[&:not([data-placeholder])]:border-border-surface-focus-ring',
|
|
193
202
|
);
|
|
194
203
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import type { ButtonGroupVariants } from '.';
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
import { buttonGroupVariants } from '.';
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
class?: HTMLAttributes['class'];
|
|
9
|
+
orientation?: ButtonGroupVariants['orientation'];
|
|
10
|
+
}>();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<div
|
|
15
|
+
role="group"
|
|
16
|
+
data-slot="button-group"
|
|
17
|
+
:data-orientation="props.orientation"
|
|
18
|
+
:class="
|
|
19
|
+
cn(buttonGroupVariants({ orientation: props.orientation }), props.class)
|
|
20
|
+
"
|
|
21
|
+
>
|
|
22
|
+
<slot />
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { SeparatorProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
5
|
+
import { cn } from '@/lib/utils';
|
|
6
|
+
import { Separator } from '@/components/core/separator';
|
|
7
|
+
|
|
8
|
+
const props = withDefaults(
|
|
9
|
+
defineProps<SeparatorProps & { class?: HTMLAttributes['class'] }>(),
|
|
10
|
+
{
|
|
11
|
+
orientation: 'vertical',
|
|
12
|
+
},
|
|
13
|
+
);
|
|
14
|
+
const delegatedProps = reactiveOmit(props, 'class');
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<Separator
|
|
19
|
+
data-slot="button-group-separator"
|
|
20
|
+
v-bind="delegatedProps"
|
|
21
|
+
:orientation="props.orientation"
|
|
22
|
+
:class="
|
|
23
|
+
cn(
|
|
24
|
+
'bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto',
|
|
25
|
+
props.class,
|
|
26
|
+
)
|
|
27
|
+
"
|
|
28
|
+
/>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PrimitiveProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import type { ButtonGroupVariants } from '.';
|
|
5
|
+
import { Primitive } from 'reka-ui';
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
interface Props extends PrimitiveProps {
|
|
9
|
+
class?: HTMLAttributes['class'];
|
|
10
|
+
orientation?: ButtonGroupVariants['orientation'];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
14
|
+
as: 'div',
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<Primitive
|
|
20
|
+
role="group"
|
|
21
|
+
:data-orientation="props.orientation"
|
|
22
|
+
:as="as"
|
|
23
|
+
:as-child="asChild"
|
|
24
|
+
:class="
|
|
25
|
+
cn(
|
|
26
|
+
'bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*=\'size-\'])]:size-4',
|
|
27
|
+
props.class,
|
|
28
|
+
)
|
|
29
|
+
"
|
|
30
|
+
>
|
|
31
|
+
<slot />
|
|
32
|
+
</Primitive>
|
|
33
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
export { default as ButtonGroup } from './ButtonGroup.vue';
|
|
5
|
+
export { default as ButtonGroupSeparator } from './ButtonGroupSeparator.vue';
|
|
6
|
+
export { default as ButtonGroupText } from './ButtonGroupText.vue';
|
|
7
|
+
|
|
8
|
+
export const buttonGroupVariants = cva(
|
|
9
|
+
"flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
orientation: {
|
|
13
|
+
horizontal:
|
|
14
|
+
'[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none',
|
|
15
|
+
vertical:
|
|
16
|
+
'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
orientation: 'horizontal',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export type ButtonGroupVariants = VariantProps<typeof buttonGroupVariants>;
|
|
@@ -12,7 +12,7 @@ const props = defineProps<{
|
|
|
12
12
|
data-slot="field-description"
|
|
13
13
|
:class="
|
|
14
14
|
cn(
|
|
15
|
-
'text-content-on-surface-muted
|
|
15
|
+
'text-content-on-surface-muted label-14-regular group-has-[[data-orientation=horizontal]]/field:text-balance',
|
|
16
16
|
'last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5',
|
|
17
17
|
'[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',
|
|
18
18
|
props.class,
|
|
@@ -17,8 +17,9 @@ const props = defineProps<{
|
|
|
17
17
|
:class="
|
|
18
18
|
cn(
|
|
19
19
|
'group/field-label peer/field-label flex w-fit items-center gap-2 leading-snug text-content-on-surface-muted body-14-medium group-data-[disabled=true]/field:opacity-50',
|
|
20
|
-
'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-
|
|
21
|
-
'has-data-[state=checked]:bg-
|
|
20
|
+
'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:border-border-input-default',
|
|
21
|
+
'has-data-[state=checked]:bg-background-surface-selected has-data-[state=checked]:border-transparent',
|
|
22
|
+
'[&>[data-slot=field]]:p-4',
|
|
22
23
|
props.class,
|
|
23
24
|
)
|
|
24
25
|
"
|
|
@@ -12,7 +12,7 @@ const props = defineProps<{
|
|
|
12
12
|
data-slot="field-label"
|
|
13
13
|
:class="
|
|
14
14
|
cn(
|
|
15
|
-
'
|
|
15
|
+
'label-14-regular text-content-on-surface-primary flex w-fit items-center gap-2 leading-snug group-data-[disabled=true]/field:opacity-50',
|
|
16
16
|
props.class,
|
|
17
17
|
)
|
|
18
18
|
"
|
|
@@ -27,7 +27,7 @@ const forwardedProps = useForwardProps(delegatedProps);
|
|
|
27
27
|
v-bind="forwardedProps"
|
|
28
28
|
:class="
|
|
29
29
|
cn(
|
|
30
|
-
'border-input data-[placeholder]:text-content-on-surface-muted
|
|
30
|
+
'border-input data-[placeholder]:text-content-on-surface-muted [&_svg:not([class*=\'text-\'])]:text-content-on-surface-muted focus:border-border-surface-focus-ring focus-visible:border-border-surface-focus-ring data-[state=open]:border-border-surface-focus-ring focus:ring-ring/50 focus-visible:ring-ring/50 focus:shadow-xs focus-visible:shadow-xs aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-fit items-center justify-between gap-2 rounded-md border bg-background-input-default px-3 py-2 label-14-regular whitespace-nowrap transition-[color,box-shadow] outline-none focus:ring-[3px] focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([data-slot=icon]):not([class*=\'size-\'])]:size-4',
|
|
31
31
|
props.class,
|
|
32
32
|
)
|
|
33
33
|
"
|
package/src/components/index.ts
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/vue';
|
|
2
|
-
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import { describe, expect, test } from 'vitest';
|
|
4
|
-
import UiCheckbox from '../UiCheckbox.vue';
|
|
5
|
-
|
|
6
|
-
describe('UiCheckbox', () => {
|
|
7
|
-
// v-model wiring (the wrapper's own integration work) is unit-tested here.
|
|
8
|
-
test('emits update:modelValue on click', async () => {
|
|
9
|
-
const { getByRole, emitted } = render(UiCheckbox);
|
|
10
|
-
|
|
11
|
-
await userEvent.click(getByRole('checkbox'));
|
|
12
|
-
expect(emitted('update:modelValue')?.[0][0]).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
});
|