@aleph-alpha/ui-library 5.8.0 → 5.9.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 (65) hide show
  1. package/README.md +8 -7
  2. package/dist/system/__tests__/test-utils.d.ts +24 -0
  3. package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +8 -4
  4. package/dist/system/components/UiAutocomplete/types.d.ts +11 -0
  5. package/dist/system/components/UiFadeMask/UiFadeMask.vue.d.ts +21 -0
  6. package/dist/system/components/UiFadeMask/index.d.ts +2 -0
  7. package/dist/system/components/UiFadeMask/types.d.ts +33 -0
  8. package/dist/system/components/UiListbox/UiListboxVirtualizer.vue.d.ts +21 -0
  9. package/dist/system/components/UiListbox/index.d.ts +1 -0
  10. package/dist/system/components/UiListbox/types.d.ts +36 -0
  11. package/dist/system/components/UiSelect/UiSelectVirtualizer.vue.d.ts +21 -0
  12. package/dist/system/components/UiSelect/index.d.ts +1 -0
  13. package/dist/system/components/UiSelect/types.d.ts +36 -0
  14. package/dist/system/components/core/native-select/NativeSelectOptGroup.vue.d.ts +2 -2
  15. package/dist/system/components/core/native-select/NativeSelectOption.vue.d.ts +2 -2
  16. package/dist/system/components/index.d.ts +1 -0
  17. package/dist/system/lib.js +22249 -21090
  18. package/dist/system/mobile-device-frame.png +0 -0
  19. package/dist/system/patterns/UiFloatActions/types.d.ts +2 -1
  20. package/dist/system/patterns/UiProfileCard/index.d.ts +7 -0
  21. package/dist/system/patterns/UiTopBar/UiTopBar.vue.d.ts +23 -0
  22. package/dist/system/patterns/UiTopBar/index.d.ts +2 -0
  23. package/dist/system/patterns/UiTopBar/types.d.ts +28 -0
  24. package/dist/system/patterns/index.d.ts +2 -0
  25. package/dist/system/story-sidebar-icons.json +4 -1
  26. package/package.json +2 -1
  27. package/src/__tests__/test-utils.ts +74 -0
  28. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +94 -0
  29. package/src/components/UiAutocomplete/UiAutocomplete.vue +164 -44
  30. package/src/components/UiAutocomplete/__tests__/UiAutocompleteVirtualized.test.ts +107 -0
  31. package/src/components/UiAutocomplete/types.ts +11 -0
  32. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +760 -0
  33. package/src/components/UiFadeMask/UiFadeMask.stories.ts +563 -0
  34. package/src/components/UiFadeMask/UiFadeMask.vue +86 -0
  35. package/src/components/UiFadeMask/__tests__/UiFadeMask.test.ts +52 -0
  36. package/src/components/UiFadeMask/index.ts +6 -0
  37. package/src/components/UiFadeMask/types.ts +35 -0
  38. package/src/components/UiListbox/UiListbox.stories.ts +121 -0
  39. package/src/components/UiListbox/UiListboxVirtualizer.vue +42 -0
  40. package/src/components/UiListbox/__tests__/UiListboxVirtualizer.test.ts +96 -0
  41. package/src/components/UiListbox/index.ts +1 -0
  42. package/src/components/UiListbox/types.ts +42 -0
  43. package/src/components/UiSelect/UiSelect.stories.ts +109 -1
  44. package/src/components/UiSelect/UiSelectVirtualizer.vue +373 -0
  45. package/src/components/UiSelect/__tests__/UiSelectVirtualizer.test.ts +185 -0
  46. package/src/components/UiSelect/index.ts +1 -0
  47. package/src/components/UiSelect/types.ts +38 -0
  48. package/src/components/core/dropdown-menu/DropdownMenuCheckboxItem.vue +8 -2
  49. package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
  50. package/src/components/core/dropdown-menu/DropdownMenuRadioItem.vue +8 -2
  51. package/src/components/core/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
  52. package/src/components/core/listbox/ListboxItem.vue +1 -1
  53. package/src/components/index.ts +1 -0
  54. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +4 -5
  55. package/src/patterns/UiFloatActions/UiFloatActions.vue +23 -11
  56. package/src/patterns/UiFloatActions/__tests__/UiFloatActions.test.ts +23 -0
  57. package/src/patterns/UiFloatActions/types.ts +2 -1
  58. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +1064 -0
  59. package/src/patterns/UiProfileCard/index.ts +7 -0
  60. package/src/patterns/UiTopBar/UiTopBar.stories.ts +1121 -0
  61. package/src/patterns/UiTopBar/UiTopBar.vue +166 -0
  62. package/src/patterns/UiTopBar/__tests__/UiTopBar.test.ts +245 -0
  63. package/src/patterns/UiTopBar/index.ts +2 -0
  64. package/src/patterns/UiTopBar/types.ts +29 -0
  65. package/src/patterns/index.ts +2 -0
@@ -25,7 +25,7 @@ const isDisabled = computed(() => props.disabled || isListboxDisabled.value);
25
25
  :aria-disabled="isDisabled ? 'true' : undefined"
26
26
  :class="
27
27
  cn(
28
- 'hover-layer hover-layer-default data-[highlighted]:text-foreground [&_svg:not([class*=\'text-\'])]:text-content-on-surface-muted ui-focus-ring-inset relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 label-14-regular select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
28
+ 'hover-layer hover-layer-default data-[highlighted]:text-foreground [&_svg:not([class*=\'text-\'])]:text-content-on-surface-muted ui-focus-ring-inset relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 body-14-regular select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
29
29
  props.class,
30
30
  )
31
31
  "
@@ -20,6 +20,7 @@ export * from './UiDialog';
20
20
  export * from './UiDrawer';
21
21
  export * from './UiDropdownMenu';
22
22
  export * from './UiEmpty';
23
+ export * from './UiFadeMask';
23
24
  export * from './UiField';
24
25
  export * from './UiFileItem';
25
26
  export * from './UiFileType';
@@ -1368,17 +1368,16 @@ export const HoverTriggerKeyboard: Story = {
1368
1368
  // Tabbing to the anchor opens the teleported panel (queried on the body).
1369
1369
  const canvas = within(canvasElement);
1370
1370
  const body = within(document.body);
1371
- const anchor = canvas.getByRole('button', { name: 'Text actions' });
1371
+ const anchor = canvasElement.querySelector(
1372
+ '[data-slot="float-anchor"]',
1373
+ ) as HTMLElement;
1372
1374
 
1373
1375
  await step(
1374
1376
  'keyboard: focusing a hover trigger opens the panel for keyboard users (WCAG 2.1.1)',
1375
1377
  async () => {
1376
- await expect(anchor).toHaveAttribute('aria-haspopup', 'true');
1378
+ expect(anchor).toHaveAttribute('tabindex', '0');
1377
1379
  await userEvent.tab();
1378
1380
  await expect(anchor).toHaveFocus();
1379
- await waitFor(() =>
1380
- expect(anchor).toHaveAttribute('aria-expanded', 'true'),
1381
- );
1382
1381
  await expect(
1383
1382
  await body.findByRole('button', { name: 'Copy' }),
1384
1383
  ).toBeInTheDocument();
@@ -8,8 +8,9 @@
8
8
  *
9
9
  * @component UiFloatActions
10
10
  * @property {'hover' | 'focus' | 'click' | 'manual'} [trigger='hover'] -
11
- * How the panel opens. `hover` opens on pointer hover and keyboard focus;
12
- * `focus` opens on keyboard focus; `click` toggles on pointer or Enter/Space.
11
+ * How the panel opens. `hover` opens on pointer hover and keyboard focus
12
+ * (focusable non-button so slotted text stays selectable); `focus` opens on
13
+ * keyboard focus; `click` toggles on pointer or Enter/Space.
13
14
  * @property {Placement} [placement='top'] -
14
15
  * Preferred placement relative to the anchor. Auto-flips when space is limited.
15
16
  * @property {number | AnchorFloatOffset} [offset=8] -
@@ -115,22 +116,29 @@ const supportsPopover =
115
116
  typeof HTMLElement.prototype.showPopover === 'function';
116
117
 
117
118
  const isClickTrigger = computed(() => props.trigger === 'click');
119
+ const isHoverTrigger = computed(() => props.trigger === 'hover');
118
120
 
119
- /** Hover, click, and focus anchors render as a native `button` for focus ring parity. */
121
+ /**
122
+ * Click and focus anchors are native `button`s (activation targets).
123
+ * Hover anchors stay a focusable non-button so slotted text (e.g. a user
124
+ * message) remains selectable/copyable and nested controls stay valid HTML.
125
+ */
120
126
  const usesButtonAnchor = computed(() =>
121
- ['hover', 'click', 'focus'].includes(props.trigger),
127
+ ['click', 'focus'].includes(props.trigger),
122
128
  );
123
129
 
130
+ /** Popup ARIA belongs on button anchors only — not on a generic `<span>`. */
124
131
  const hasPopupA11y = computed(() => usesButtonAnchor.value);
125
132
 
126
133
  /**
127
- * Ghost button reset so the anchor inherits slot layout while matching core
128
- * button keyboard focus: accent fill and blue focus ring.
134
+ * Ghost reset so the anchor inherits slot layout while matching core
135
+ * keyboard focus: accent fill and blue focus ring.
129
136
  */
130
137
  const anchorClass = computed(() =>
131
138
  cn(
132
- usesButtonAnchor.value &&
139
+ (usesButtonAnchor.value || isHoverTrigger.value) &&
133
140
  'ui-focus-ring inline-flex max-w-full cursor-default rounded-md border border-transparent bg-transparent p-0 text-left font-inherit text-inherit',
141
+ isHoverTrigger.value && 'select-text',
134
142
  isClickTrigger.value && 'cursor-pointer',
135
143
  attrs.class ?? '',
136
144
  ),
@@ -157,10 +165,14 @@ const floatingAnimationClass = computed(() =>
157
165
 
158
166
  <template>
159
167
  <span class="inline-flex">
160
- <button
161
- v-if="usesButtonAnchor"
168
+ <!-- Button for click/focus; focusable span for hover (text stays selectable). -->
169
+ <!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -->
170
+ <component
171
+ v-if="usesButtonAnchor || isHoverTrigger"
172
+ :is="usesButtonAnchor ? 'button' : 'span'"
162
173
  ref="referenceRef"
163
- type="button"
174
+ :type="usesButtonAnchor ? 'button' : undefined"
175
+ :tabindex="isHoverTrigger ? 0 : undefined"
164
176
  data-slot="float-anchor"
165
177
  :aria-label="props.ariaLabel"
166
178
  :aria-expanded="hasPopupA11y ? open : undefined"
@@ -176,7 +188,7 @@ const floatingAnimationClass = computed(() =>
176
188
  @keydown="onReferenceKeydown"
177
189
  >
178
190
  <slot name="container" />
179
- </button>
191
+ </component>
180
192
 
181
193
  <!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -->
182
194
  <span
@@ -4,6 +4,29 @@ import { nextTick } from 'vue';
4
4
  import { UiFloatActions, UiFloatActionItems } from '../index';
5
5
 
6
6
  describe('UiFloatActions', () => {
7
+ test('uses a focusable non-button anchor for hover so text stays selectable', () => {
8
+ const { container, getByText } = render({
9
+ components: { UiFloatActions, UiFloatActionItems },
10
+ template: `
11
+ <UiFloatActions trigger="hover" aria-label="Open actions">
12
+ <template #container>
13
+ <span>Select text</span>
14
+ </template>
15
+ <template #action>
16
+ <UiFloatActionItems aria-label="Actions">
17
+ <UiFloatActionItems type="button" aria-label="Edit">Edit</UiFloatActionItems>
18
+ </UiFloatActionItems>
19
+ </template>
20
+ </UiFloatActions>
21
+ `,
22
+ });
23
+
24
+ const anchor = container.querySelector('[data-slot="float-anchor"]');
25
+ expect(anchor?.tagName).toBe('SPAN');
26
+ expect(anchor).toHaveAttribute('tabindex', '0');
27
+ expect(getByText('Select text')).toBeInTheDocument();
28
+ });
29
+
7
30
  test('shows action content on click trigger', async () => {
8
31
  const { getByRole, queryByRole } = render({
9
32
  components: { UiFloatActions, UiFloatActionItems },
@@ -24,7 +24,8 @@ export type UiFloatActionsOffset = number | AnchorFloatOffset;
24
24
  export interface UiFloatActionsProps {
25
25
  /**
26
26
  * How the floating panel opens.
27
- * - `hover` — pointer hover and keyboard focus on a focusable `button` anchor
27
+ * - `hover` — pointer hover and keyboard focus on a focusable non-button
28
+ * anchor (text inside remains selectable/copyable)
28
29
  * - `focus` — keyboard focus on the `button` anchor
29
30
  * - `click` — click or Enter/Space on the `button` anchor
30
31
  * - `manual` — controlled via `v-model:open`