@aleph-alpha/ui-library 5.8.0 → 5.10.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 (111) hide show
  1. package/README.md +8 -7
  2. package/config.js +157 -4
  3. package/dist/system/__tests__/test-utils.d.ts +24 -0
  4. package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +8 -4
  5. package/dist/system/components/UiAutocomplete/types.d.ts +11 -0
  6. package/dist/system/components/UiFadeMask/UiFadeMask.vue.d.ts +21 -0
  7. package/dist/system/components/UiFadeMask/index.d.ts +2 -0
  8. package/dist/system/components/UiFadeMask/types.d.ts +33 -0
  9. package/dist/system/components/UiFileItem/UiFileItem.vue.d.ts +3 -1
  10. package/dist/system/components/UiFileType/types.d.ts +2 -1
  11. package/dist/system/components/UiListbox/UiListboxVirtualizer.vue.d.ts +21 -0
  12. package/dist/system/components/UiListbox/index.d.ts +1 -0
  13. package/dist/system/components/UiListbox/types.d.ts +36 -0
  14. package/dist/system/components/UiSelect/UiSelectVirtualizer.vue.d.ts +21 -0
  15. package/dist/system/components/UiSelect/index.d.ts +1 -0
  16. package/dist/system/components/UiSelect/types.d.ts +36 -0
  17. package/dist/system/components/UiSwitch/UiSwitch.vue.d.ts +1 -0
  18. package/dist/system/components/UiSwitch/types.d.ts +12 -0
  19. package/dist/system/components/core/native-select/NativeSelectOptGroup.vue.d.ts +2 -2
  20. package/dist/system/components/core/native-select/NativeSelectOption.vue.d.ts +2 -2
  21. package/dist/system/components/core/switch/Switch.vue.d.ts +2 -0
  22. package/dist/system/components/core/switch/index.d.ts +8 -0
  23. package/dist/system/components/index.d.ts +1 -0
  24. package/dist/system/index.d.ts +1 -0
  25. package/dist/system/lib/scrollbar.d.ts +37 -0
  26. package/dist/system/lib/useAnchorFloat.d.ts +0 -2
  27. package/dist/system/lib/useIsTruncated.d.ts +15 -0
  28. package/dist/system/lib.js +22660 -21292
  29. package/dist/system/mobile-device-frame.png +0 -0
  30. package/dist/system/patterns/UiFloatActions/types.d.ts +2 -2
  31. package/dist/system/patterns/UiProfileCard/index.d.ts +7 -0
  32. package/dist/system/patterns/UiTopBar/UiTopBar.vue.d.ts +23 -0
  33. package/dist/system/patterns/UiTopBar/index.d.ts +2 -0
  34. package/dist/system/patterns/UiTopBar/types.d.ts +28 -0
  35. package/dist/system/patterns/index.d.ts +2 -0
  36. package/dist/system/story-sidebar-icons.json +7 -1
  37. package/docs/public-docs/foundations.md +17 -15
  38. package/package.json +4 -3
  39. package/src/__tests__/test-utils.ts +74 -0
  40. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +94 -0
  41. package/src/components/UiAutocomplete/UiAutocomplete.vue +164 -44
  42. package/src/components/UiAutocomplete/__tests__/UiAutocompleteVirtualized.test.ts +107 -0
  43. package/src/components/UiAutocomplete/types.ts +11 -0
  44. package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +54 -0
  45. package/src/components/UiCodeBlock/UiCodeBlock.vue +84 -32
  46. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +65 -21
  47. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +760 -0
  48. package/src/components/UiFadeMask/UiFadeMask.stories.ts +563 -0
  49. package/src/components/UiFadeMask/UiFadeMask.vue +86 -0
  50. package/src/components/UiFadeMask/__tests__/UiFadeMask.test.ts +52 -0
  51. package/src/components/UiFadeMask/index.ts +6 -0
  52. package/src/components/UiFadeMask/types.ts +35 -0
  53. package/src/components/UiFileItem/UiFileItem.vue +17 -4
  54. package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +49 -90
  55. package/src/components/UiFileType/UiFileType.stories.ts +13 -2
  56. package/src/components/UiFileType/UiFileType.vue +8 -0
  57. package/src/components/UiFileType/__tests__/UiFileType.test.ts +10 -0
  58. package/src/components/UiFileType/types.ts +3 -1
  59. package/src/components/UiListbox/UiListbox.stories.ts +121 -0
  60. package/src/components/UiListbox/UiListboxVirtualizer.vue +42 -0
  61. package/src/components/UiListbox/__tests__/UiListboxVirtualizer.test.ts +96 -0
  62. package/src/components/UiListbox/index.ts +1 -0
  63. package/src/components/UiListbox/types.ts +42 -0
  64. package/src/components/UiSelect/UiSelect.stories.ts +109 -1
  65. package/src/components/UiSelect/UiSelectVirtualizer.vue +373 -0
  66. package/src/components/UiSelect/__tests__/UiSelectVirtualizer.test.ts +185 -0
  67. package/src/components/UiSelect/index.ts +1 -0
  68. package/src/components/UiSelect/types.ts +38 -0
  69. package/src/components/UiSnackbar/UiSnackbar.stories.ts +4 -5
  70. package/src/components/UiSwitch/UiSwitch.stories.ts +658 -7
  71. package/src/components/UiSwitch/UiSwitch.vue +1 -0
  72. package/src/components/UiSwitch/__tests__/UiSwitch.test.ts +48 -0
  73. package/src/components/UiSwitch/types.ts +13 -0
  74. package/src/components/UiToggleGroup/UiToggleGroup.vue +1 -1
  75. package/src/components/core/dropdown-menu/DropdownMenuCheckboxItem.vue +8 -2
  76. package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
  77. package/src/components/core/dropdown-menu/DropdownMenuRadioItem.vue +8 -2
  78. package/src/components/core/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
  79. package/src/components/core/field/FieldLabel.vue +1 -1
  80. package/src/components/core/label/Label.vue +1 -1
  81. package/src/components/core/listbox/ListboxItem.vue +1 -1
  82. package/src/components/core/switch/Switch.vue +23 -17
  83. package/src/components/core/switch/index.ts +36 -0
  84. package/src/components/index.ts +1 -0
  85. package/src/index.ts +3 -0
  86. package/src/lib/scrollbar.ts +295 -0
  87. package/src/lib/useAnchorFloat.ts +0 -2
  88. package/src/lib/useIsTruncated.test.ts +174 -0
  89. package/src/lib/useIsTruncated.ts +75 -0
  90. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +1162 -0
  91. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +552 -1
  92. package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +5 -21
  93. package/src/patterns/UiFloatActions/UiFloatActionItems.vue +0 -1
  94. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +4 -6
  95. package/src/patterns/UiFloatActions/UiFloatActions.vue +23 -12
  96. package/src/patterns/UiFloatActions/__tests__/UiFloatActions.test.ts +23 -0
  97. package/src/patterns/UiFloatActions/types.ts +2 -2
  98. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +1079 -0
  99. package/src/patterns/UiProfileCard/index.ts +7 -0
  100. package/src/patterns/UiTopBar/UiTopBar.stories.ts +1121 -0
  101. package/src/patterns/UiTopBar/UiTopBar.vue +166 -0
  102. package/src/patterns/UiTopBar/__tests__/UiTopBar.test.ts +245 -0
  103. package/src/patterns/UiTopBar/index.ts +2 -0
  104. package/src/patterns/UiTopBar/types.ts +29 -0
  105. package/src/patterns/index.ts +2 -0
  106. package/src/theme/Background.stories.ts +27 -1
  107. package/src/theme/BorderRadius.stories.ts +5 -0
  108. package/src/theme/Overlay.stories.ts +12 -1
  109. package/src/theme/Scrollbar.stories.ts +260 -0
  110. package/tokens.json +224 -2
  111. package/src/components/UiFileItem/UiFileItem.stories.ts +0 -442
@@ -5,11 +5,11 @@
5
5
  * Use for contextual toolbars, quick actions, and inline controls that appear
6
6
  * on hover, focus, or click. Pair with {@link UiFloatActionItems} for pill-shaped
7
7
  * action bars. For rich panels or forms, prefer {@link UiPopover}.
8
- *
9
8
  * @component UiFloatActions
10
9
  * @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.
10
+ * How the panel opens. `hover` opens on pointer hover and keyboard focus
11
+ * (focusable non-button so slotted text stays selectable); `focus` opens on
12
+ * keyboard focus; `click` toggles on pointer or Enter/Space.
13
13
  * @property {Placement} [placement='top'] -
14
14
  * Preferred placement relative to the anchor. Auto-flips when space is limited.
15
15
  * @property {number | AnchorFloatOffset} [offset=8] -
@@ -115,22 +115,29 @@ const supportsPopover =
115
115
  typeof HTMLElement.prototype.showPopover === 'function';
116
116
 
117
117
  const isClickTrigger = computed(() => props.trigger === 'click');
118
+ const isHoverTrigger = computed(() => props.trigger === 'hover');
118
119
 
119
- /** Hover, click, and focus anchors render as a native `button` for focus ring parity. */
120
+ /**
121
+ * Click and focus anchors are native `button`s (activation targets).
122
+ * Hover anchors stay a focusable non-button so slotted text (e.g. a user
123
+ * message) remains selectable/copyable and nested controls stay valid HTML.
124
+ */
120
125
  const usesButtonAnchor = computed(() =>
121
- ['hover', 'click', 'focus'].includes(props.trigger),
126
+ ['click', 'focus'].includes(props.trigger),
122
127
  );
123
128
 
129
+ /** Popup ARIA belongs on button anchors only — not on a generic `<span>`. */
124
130
  const hasPopupA11y = computed(() => usesButtonAnchor.value);
125
131
 
126
132
  /**
127
- * Ghost button reset so the anchor inherits slot layout while matching core
128
- * button keyboard focus: accent fill and blue focus ring.
133
+ * Ghost reset so the anchor inherits slot layout while matching core
134
+ * keyboard focus: accent fill and blue focus ring.
129
135
  */
130
136
  const anchorClass = computed(() =>
131
137
  cn(
132
- usesButtonAnchor.value &&
138
+ (usesButtonAnchor.value || isHoverTrigger.value) &&
133
139
  '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',
140
+ isHoverTrigger.value && 'select-text',
134
141
  isClickTrigger.value && 'cursor-pointer',
135
142
  attrs.class ?? '',
136
143
  ),
@@ -157,10 +164,14 @@ const floatingAnimationClass = computed(() =>
157
164
 
158
165
  <template>
159
166
  <span class="inline-flex">
160
- <button
161
- v-if="usesButtonAnchor"
167
+ <!-- Button for click/focus; focusable span for hover (text stays selectable). -->
168
+ <!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -->
169
+ <component
170
+ :is="usesButtonAnchor ? 'button' : 'span'"
171
+ v-if="usesButtonAnchor || isHoverTrigger"
162
172
  ref="referenceRef"
163
- type="button"
173
+ :type="usesButtonAnchor ? 'button' : undefined"
174
+ :tabindex="isHoverTrigger ? 0 : undefined"
164
175
  data-slot="float-anchor"
165
176
  :aria-label="props.ariaLabel"
166
177
  :aria-expanded="hasPopupA11y ? open : undefined"
@@ -176,7 +187,7 @@ const floatingAnimationClass = computed(() =>
176
187
  @keydown="onReferenceKeydown"
177
188
  >
178
189
  <slot name="container" />
179
- </button>
190
+ </component>
180
191
 
181
192
  <!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -->
182
193
  <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`
@@ -111,7 +112,6 @@ export type UiFloatActionItemsValue = string | number;
111
112
  * Use the root item (`type="toolbar"`) as the container and nest child items
112
113
  * for buttons, inputs, text labels, groups, and separators. Implements the
113
114
  * WAI-ARIA APG toolbar pattern with roving tabindex.
114
- *
115
115
  * @category Overlays
116
116
  * @useCases contextual toolbar, inline actions, pagination controls, filter bar
117
117
  * @keywords float, toolbar, pill, actions, keyboard, roving focus