@aleph-alpha/ui-library 5.5.0 → 5.6.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.
Files changed (30) hide show
  1. package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +2 -0
  2. package/dist/system/components/UiButtonGroup/UiButtonGroup.vue.d.ts +20 -0
  3. package/dist/system/components/UiButtonGroup/index.d.ts +2 -0
  4. package/dist/system/components/UiButtonGroup/types.d.ts +20 -0
  5. package/dist/system/components/core/button-group/ButtonGroup.vue.d.ts +23 -0
  6. package/dist/system/components/core/button-group/ButtonGroupSeparator.vue.d.ts +9 -0
  7. package/dist/system/components/core/button-group/ButtonGroupText.vue.d.ts +26 -0
  8. package/dist/system/components/core/button-group/index.d.ts +8 -0
  9. package/dist/system/components/index.d.ts +1 -0
  10. package/dist/system/lib.js +7850 -7728
  11. package/dist/system/story-sidebar-icons.json +3 -0
  12. package/package.json +1 -1
  13. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +619 -0
  14. package/src/components/UiAutocomplete/UiAutocomplete.vue +28 -3
  15. package/src/components/UiAutocomplete/__tests__/UiAutocomplete.test.ts +14 -69
  16. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +690 -0
  17. package/src/components/UiButtonGroup/UiButtonGroup.vue +18 -0
  18. package/src/components/UiButtonGroup/__tests__/UiButtonGroup.test.ts +68 -0
  19. package/src/components/UiButtonGroup/index.ts +2 -0
  20. package/src/components/UiButtonGroup/types.ts +21 -0
  21. package/src/components/UiSelect/UiSelect.stories.ts +769 -0
  22. package/src/components/UiSelect/__tests__/UiSelect.test.ts +4 -73
  23. package/src/components/UiSelect/__tests__/UiSelectItem.test.ts +3 -31
  24. package/src/components/UiSelect/__tests__/UiSelectTrigger.test.ts +14 -5
  25. package/src/components/core/button-group/ButtonGroup.vue +24 -0
  26. package/src/components/core/button-group/ButtonGroupSeparator.vue +29 -0
  27. package/src/components/core/button-group/ButtonGroupText.vue +33 -0
  28. package/src/components/core/button-group/index.ts +25 -0
  29. package/src/components/core/select/SelectTrigger.vue +1 -1
  30. package/src/components/index.ts +1 -0
@@ -82,79 +82,10 @@ describe('UiSelect', () => {
82
82
  expect(queryByRole('listbox')).not.toBeInTheDocument();
83
83
  });
84
84
 
85
- test('opens dropdown when trigger is clicked', async () => {
86
- const user = userEvent.setup();
87
- const { getByRole } = renderSelect();
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
- test('cannot select disabled item', async () => {
186
- const user = userEvent.setup();
187
- const { getByRole } = render({
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
- expect(trigger).toHaveClass('active:border-border-surface-focus-ring');
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
- expect(trigger).toHaveClass(
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 focus-ring border when multi-select has a value', async () => {
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>;
@@ -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 data-[placeholder]:bg-background-input-default [&:not([data-placeholder])]:border-border-surface-focus-ring [&_svg:not([class*=\'text-\'])]:text-content-on-surface-muted focus:border-border-surface-focus-ring focus-visible:border-border-surface-focus-ring active: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-accent 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',
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
  "
@@ -9,6 +9,7 @@ export * from './UiAutocomplete';
9
9
  export * from './UiAvatar';
10
10
  export * from './UiBadge';
11
11
  export * from './UiButton';
12
+ export * from './UiButtonGroup';
12
13
  export * from './UiCalendar';
13
14
  export * from './UiCard';
14
15
  export * from './UiCheckbox';