@aleph-alpha/ui-library 2.4.4 → 2.5.2

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 (103) hide show
  1. package/config.d.ts +33 -2
  2. package/config.js +145 -47
  3. package/dist/system/components/UiAvatar/UiAvatar.vue.d.ts +4 -1
  4. package/dist/system/components/UiAvatar/UiAvatarGroup.vue.d.ts +18 -0
  5. package/dist/system/components/UiAvatar/index.d.ts +1 -0
  6. package/dist/system/components/UiAvatar/types.d.ts +12 -1
  7. package/dist/system/components/UiFileItem/UiFileItem.vue.d.ts +6 -1
  8. package/dist/system/components/UiFileItem/types.d.ts +30 -10
  9. package/dist/system/components/UiFileType/UiFileType.vue.d.ts +8 -0
  10. package/dist/system/components/UiFileType/index.d.ts +2 -0
  11. package/dist/system/components/UiFileType/types.d.ts +33 -0
  12. package/dist/system/components/UiItem/UiItem.vue.d.ts +8 -1
  13. package/dist/system/components/UiItem/constants.d.ts +4 -3
  14. package/dist/system/components/UiItem/index.d.ts +1 -1
  15. package/dist/system/components/UiItem/types.d.ts +53 -13
  16. package/dist/system/components/core/avatar/Avatar.vue.d.ts +2 -0
  17. package/dist/system/components/core/avatar/index.d.ts +1 -0
  18. package/dist/system/components/core/calendar/Calendar.vue.d.ts +247 -3
  19. package/dist/system/components/core/item/Item.vue.d.ts +1 -1
  20. package/dist/system/components/core/item/ItemAction.vue.d.ts +25 -0
  21. package/dist/system/components/core/item/index.d.ts +8 -4
  22. package/dist/system/components/core/popover/PopoverContent.vue.d.ts +1 -1
  23. package/dist/system/components/core/range-calendar/RangeCalendar.vue.d.ts +139 -2
  24. package/dist/system/components/index.d.ts +1 -0
  25. package/dist/system/lib/activeIndicator.d.ts +1 -0
  26. package/dist/system/lib.js +6700 -6448
  27. package/dist/system/patterns/UiSidebar/activeIndicator.d.ts +1 -15
  28. package/package.json +1 -1
  29. package/src/components/UiAvatar/UiAvatar.stories.ts +103 -12
  30. package/src/components/UiAvatar/UiAvatar.vue +6 -1
  31. package/src/components/UiAvatar/UiAvatarGroup.vue +16 -0
  32. package/src/components/UiAvatar/UiAvatarImage.vue +1 -1
  33. package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +86 -0
  34. package/src/components/UiAvatar/index.ts +1 -0
  35. package/src/components/UiAvatar/types.ts +15 -1
  36. package/src/components/UiButton/UiButton.stories.ts +60 -0
  37. package/src/components/UiCodeBlock/UiCodeBlock.vue +7 -2
  38. package/src/components/UiField/UiField.stories.ts +15 -9
  39. package/src/components/UiFileItem/UiFileItem.stories.ts +344 -185
  40. package/src/components/UiFileItem/UiFileItem.vue +110 -70
  41. package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +64 -3
  42. package/src/components/UiFileItem/types.ts +33 -10
  43. package/src/components/UiFileType/UiFileType.stories.ts +193 -0
  44. package/src/components/UiFileType/UiFileType.vue +114 -0
  45. package/src/components/UiFileType/__tests__/UiFileType.test.ts +41 -0
  46. package/src/components/UiFileType/index.ts +2 -0
  47. package/src/components/UiFileType/types.ts +38 -0
  48. package/src/components/UiFileUploadBox/UiFileUploadBox.vue +58 -56
  49. package/src/components/UiItem/UiItem.stories.ts +555 -855
  50. package/src/components/UiItem/UiItem.vue +59 -4
  51. package/src/components/UiItem/UiItemMedia.vue +1 -1
  52. package/src/components/UiItem/__tests__/UiItem.test.ts +432 -26
  53. package/src/components/UiItem/constants.ts +16 -2
  54. package/src/components/UiItem/index.ts +1 -1
  55. package/src/components/UiItem/types.ts +64 -13
  56. package/src/components/UiKbd/UiKbd.stories.ts +1 -1
  57. package/src/components/UiListbox/UiListbox.stories.ts +1 -1
  58. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +4 -4
  59. package/src/components/UiSelect/UiSelectTrigger.vue +8 -2
  60. package/src/components/UiSelect/__tests__/UiSelectGroup.test.ts +2 -2
  61. package/src/components/UiSnackbar/UiSnackbar.stories.ts +1 -0
  62. package/src/components/UiTable/UiTable.stories.ts +6 -2
  63. package/src/components/UiTable/__tests__/UiTableRow.test.ts +4 -2
  64. package/src/components/UiTabs/UiTabs.stories.ts +2 -2
  65. package/src/components/UiTagsInput/UiTagsInput.stories.ts +12 -2
  66. package/src/components/core/avatar/Avatar.vue +17 -1
  67. package/src/components/core/avatar/AvatarFallback.vue +1 -1
  68. package/src/components/core/{item/ItemActions.vue → avatar/AvatarGroup.vue} +7 -2
  69. package/src/components/core/avatar/index.ts +1 -0
  70. package/src/components/core/button/index.ts +1 -1
  71. package/src/components/core/calendar/Calendar.vue +17 -1
  72. package/src/components/core/checkbox/Checkbox.vue +1 -0
  73. package/src/components/core/drawer/DrawerContent.vue +1 -1
  74. package/src/components/core/item/Item.vue +2 -2
  75. package/src/components/core/item/ItemAction.vue +30 -0
  76. package/src/components/core/item/ItemContent.vue +1 -1
  77. package/src/components/core/item/ItemDescription.vue +1 -1
  78. package/src/components/core/item/ItemGroup.vue +0 -1
  79. package/src/components/core/item/index.ts +32 -9
  80. package/src/components/core/kbd/Kbd.vue +1 -1
  81. package/src/components/core/listbox/ListboxContent.vue +1 -0
  82. package/src/components/core/native-select/NativeSelect.vue +6 -0
  83. package/src/components/core/range-calendar/RangeCalendar.vue +19 -0
  84. package/src/components/core/skeleton/Skeleton.vue +3 -1
  85. package/src/components/core/slider/Slider.vue +2 -1
  86. package/src/components/core/table/TableFooter.vue +4 -1
  87. package/src/components/core/table/TableRow.vue +1 -1
  88. package/src/components/index.ts +1 -0
  89. package/src/directives/vHover.stories.ts +16 -12
  90. package/src/lib/activeIndicator.ts +1 -0
  91. package/src/patterns/UiDataTable/UiDataTable.stories.ts +2 -2
  92. package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +2 -2
  93. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +2 -2
  94. package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +2 -2
  95. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +2 -2
  96. package/src/patterns/UiSidebar/__tests__/UiSidebarMenuButton.test.ts +33 -0
  97. package/src/patterns/UiSidebar/activeIndicator.ts +1 -16
  98. package/src/theme/Background.stories.ts +16 -0
  99. package/src/theme/BorderRadius.stories.ts +12 -12
  100. package/src/theme/Flex.stories.ts +1 -1
  101. package/src/theme/Theme.stories.ts +3 -3
  102. package/tokens.json +4273 -1152
  103. /package/dist/system/components/core/{item/ItemActions.vue.d.ts → avatar/AvatarGroup.vue.d.ts} +0 -0
@@ -0,0 +1,41 @@
1
+ import { render } from '@testing-library/vue';
2
+ import { describe, expect, test } from 'vitest';
3
+ import UiFileType from '../UiFileType.vue';
4
+
5
+ describe('UiFileType', () => {
6
+ describe('file-extension auto-detection', () => {
7
+ // Assert via the stable `data-tone` attribute on the badge rather than
8
+ // the underlying utility class, so refactors to the styling don't
9
+ // silently change which tone the component picks for a given file type.
10
+ test.each([
11
+ { filename: 'report.pdf', tone: 'accent-pink', icon: 'lucide-file' },
12
+ { filename: 'README.md', tone: 'accent-soft', icon: 'lucide-code-xml' },
13
+ { filename: 'data.csv', tone: 'accent-yellow', icon: 'lucide-table-2' },
14
+ { filename: 'archive.zip', tone: 'default', icon: 'lucide-file' },
15
+ { filename: undefined, tone: 'default', icon: 'lucide-file' },
16
+ ])('$filename → $tone + $icon', ({ filename, tone, icon }) => {
17
+ const { container } = render(UiFileType, { props: { filename } });
18
+ const badge = container.querySelector('[data-slot="file-type"]');
19
+ expect(badge?.getAttribute('data-tone')).toBe(tone);
20
+ expect(badge?.querySelector(`svg.${icon}`)).not.toBeNull();
21
+ });
22
+ });
23
+
24
+ test('error forces the neutral badge + circle-alert icon regardless of file type', () => {
25
+ const { container } = render(UiFileType, {
26
+ props: { filename: 'data.csv', error: true },
27
+ });
28
+ const badge = container.querySelector('[data-slot="file-type"]');
29
+ expect(badge?.getAttribute('data-tone')).toBe('default');
30
+ expect(badge?.querySelector('svg.lucide-circle-alert')).not.toBeNull();
31
+ });
32
+
33
+ test('explicit tone and icon props override the auto-derived values', () => {
34
+ const { container } = render(UiFileType, {
35
+ props: { filename: 'archive.zip', tone: 'accent-pink', icon: 'star' },
36
+ });
37
+ const badge = container.querySelector('[data-slot="file-type"]');
38
+ expect(badge?.getAttribute('data-tone')).toBe('accent-pink');
39
+ expect(badge?.querySelector('svg.lucide-star')).not.toBeNull();
40
+ });
41
+ });
@@ -0,0 +1,2 @@
1
+ export { default as UiFileType } from './UiFileType.vue';
2
+ export type { UiFileTypeProps, UiFileTypeTone } from './types';
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Round 32×32 badge that visualises a file type with a tone + icon. Mirrors
3
+ * the Figma `Filetype` component (`AA26 / File Upload / Filetype`,
4
+ * node id `26438:42144`):
5
+ *
6
+ * - `Type=Text` (`pdf` / `doc` / `docx` / `txt` / `rtf`) → `accent-pink` + `file`
7
+ * - `Type=Markdown` (`html` / `htm` / `md` / `mdx`) → `accent-soft` + `code-xml`
8
+ * - `Type=Tabular` (`csv` / `tsv` / `xls` / `xlsx`) → `accent-yellow` + `table-2`
9
+ * - everything else → `default` + `file`
10
+ * @see {@link https://www.figma.com/design/SrZQ19QVN1sQkuAMnMC746/AA26--WIP-?node-id=26438-42144}
11
+ * @category Data Display
12
+ * @useCases file-type indicator, attachment badge
13
+ * @keywords file, badge, attachment, filetype, icon
14
+ * @related UiFileItem, UiFileUploadBox
15
+ */
16
+ export type UiFileTypeTone =
17
+ | 'default'
18
+ | 'accent-pink'
19
+ | 'accent-soft'
20
+ | 'accent-yellow';
21
+
22
+ export interface UiFileTypeProps {
23
+ /**
24
+ * File name used to auto-derive the tone + icon from its extension. Pass
25
+ * the original `file.name` (with extension); the badge itself doesn't
26
+ * render any text.
27
+ */
28
+ filename?: string;
29
+ /** Explicit tone override. Wins over the filename-derived tone. */
30
+ tone?: UiFileTypeTone;
31
+ /** Explicit Lucide icon name. Wins over the filename-derived icon. */
32
+ icon?: string;
33
+ /**
34
+ * Forces the neutral badge + `circle-alert` icon, regardless of any
35
+ * other prop. Use to indicate an upload/validation failure.
36
+ */
37
+ error?: boolean;
38
+ }
@@ -135,11 +135,19 @@ function processFileList(fileList: FileList) {
135
135
 
136
136
  <template>
137
137
  <div class="flex flex-col gap-3">
138
- <!-- Drop zone: tabindex -1 when disabled removes it from tab order (aria-disabled). -->
139
- <!-- eslint-disable-next-line vuejs-accessibility/interactive-supports-focus -- intentional: disabled state is not keyboard-focusable -->
138
+ <input
139
+ ref="inputRef"
140
+ type="file"
141
+ class="sr-only"
142
+ :accept="accept"
143
+ :multiple="multiple"
144
+ :disabled="disabled"
145
+ :aria-hidden="true"
146
+ tabindex="-1"
147
+ @change="onInputChange"
148
+ />
149
+
140
150
  <div
141
- role="button"
142
- :tabindex="disabled ? -1 : 0"
143
151
  :class="
144
152
  cn(
145
153
  'border-border-surface-default bg-background-surface-modal focus-visible:ring-ring relative flex cursor-pointer flex-col items-center justify-center gap-4 rounded-lg border border-dashed p-8 text-center transition-colors outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
@@ -147,69 +155,63 @@ function processFileList(fileList: FileList) {
147
155
  disabled && 'cursor-not-allowed opacity-50',
148
156
  )
149
157
  "
150
- :aria-disabled="disabled ? true : undefined"
151
- :aria-label="ariaLabel"
152
- @click="onZoneClick"
153
- @keydown="onZoneKeydown"
154
- @focus="emit('focus', $event)"
155
- @blur="emit('blur', $event)"
156
- @dragenter="onDragEnter"
157
- @dragleave="onDragLeave"
158
- @dragover="onDragOver"
159
- @drop="onDrop"
160
158
  >
161
- <input
162
- ref="inputRef"
163
- type="file"
164
- class="sr-only"
165
- :accept="accept"
166
- :multiple="multiple"
167
- :disabled="disabled"
168
- :aria-hidden="true"
169
- tabindex="-1"
170
- @change="onInputChange"
171
- />
172
-
159
+ <!-- Drop zone: tabindex -1 when disabled removes it from tab order (aria-disabled). -->
160
+ <!-- eslint-disable-next-line vuejs-accessibility/interactive-supports-focus -- intentional: disabled state is not keyboard-focusable -->
173
161
  <div
162
+ role="button"
163
+ :tabindex="disabled ? -1 : 0"
174
164
  :class="
175
165
  cn(
176
- 'text-content-on-surface-primary',
166
+ 'text-content-on-surface-primary flex flex-col items-center justify-center gap-4 outline-none',
177
167
  isDragging ? 'body-16-bold' : 'body-16-medium',
178
168
  )
179
169
  "
170
+ :aria-disabled="disabled ? true : undefined"
171
+ :aria-label="ariaLabel"
172
+ @click="onZoneClick"
173
+ @keydown="onZoneKeydown"
174
+ @focus="emit('focus', $event)"
175
+ @blur="emit('blur', $event)"
176
+ @dragenter="onDragEnter"
177
+ @dragleave="onDragLeave"
178
+ @dragover="onDragOver"
179
+ @drop="onDrop"
180
180
  >
181
- <slot name="title">{{ dropLabel }}</slot>
182
- </div>
181
+ <div>
182
+ <slot name="title">{{ dropLabel }}</slot>
183
+ </div>
183
184
 
184
- <!-- Fixed 80×80 slot so inner circle can go 72 → 80 on drag without shifting the drop zone. -->
185
- <div
186
- class="flex size-20 shrink-0 items-center justify-center"
187
- aria-hidden="true"
188
- >
185
+ <!-- Fixed 80×80 slot so inner circle can go 72 → 80 on drag without shifting the drop zone. -->
189
186
  <div
190
- :class="
191
- cn(
192
- 'flex items-center justify-center rounded-full transition-all duration-50 ease-out',
193
- isDragging
194
- ? 'size-20 bg-background-accent-soft'
195
- : 'size-18 bg-background-surface-muted',
196
- )
197
- "
187
+ class="flex size-20 shrink-0 items-center justify-center"
188
+ aria-hidden="true"
198
189
  >
199
- <slot name="icon">
200
- <UiIcon
201
- name="cloud-upload"
202
- :size="32"
203
- :class="
204
- cn(
205
- isDragging
206
- ? 'text-content-on-surface-link'
207
- : 'text-content-on-surface-muted',
208
- )
209
- "
210
- aria-hidden="true"
211
- />
212
- </slot>
190
+ <div
191
+ :class="
192
+ cn(
193
+ 'flex items-center justify-center rounded-full transition-all duration-50 ease-out',
194
+ isDragging
195
+ ? 'size-20 bg-background-accent-soft'
196
+ : 'size-18 bg-background-surface-muted',
197
+ )
198
+ "
199
+ >
200
+ <slot name="icon">
201
+ <UiIcon
202
+ name="cloud-upload"
203
+ :size="32"
204
+ :class="
205
+ cn(
206
+ isDragging
207
+ ? 'text-content-on-surface-link'
208
+ : 'text-content-on-surface-muted',
209
+ )
210
+ "
211
+ aria-hidden="true"
212
+ />
213
+ </slot>
214
+ </div>
213
215
  </div>
214
216
  </div>
215
217