@aleph-alpha/ui-library 2.0.0 → 2.3.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 (168) hide show
  1. package/config.d.ts +0 -19
  2. package/config.js +65 -81
  3. package/dist/system/components/UiSnackbar/UiSnackbar.vue.d.ts +5 -0
  4. package/dist/system/components/UiSnackbar/index.d.ts +3 -0
  5. package/dist/system/components/UiSnackbar/types.d.ts +96 -0
  6. package/dist/system/components/UiToggle/UiToggle.vue.d.ts +5 -0
  7. package/dist/system/components/UiToggle/types.d.ts +13 -0
  8. package/dist/system/components/core/sonner/Sonner.vue.d.ts +3 -0
  9. package/dist/system/components/core/sonner/index.d.ts +1 -0
  10. package/dist/system/components/index.d.ts +1 -1
  11. package/dist/system/index.d.ts +3 -4
  12. package/dist/system/lib/heightTransition.d.ts +5 -0
  13. package/dist/system/lib/useDrag.d.ts +52 -0
  14. package/dist/system/lib.js +22130 -20210
  15. package/dist/system/patterns/UiDataTable/UiDataTable.vue.d.ts +22 -3
  16. package/dist/system/patterns/UiDataTable/UiDataTableColumnFilter.vue.d.ts +14 -0
  17. package/dist/system/patterns/UiDataTable/constants.d.ts +13 -0
  18. package/dist/system/patterns/UiDataTable/index.d.ts +2 -0
  19. package/dist/system/patterns/UiDataTable/types.d.ts +32 -1
  20. package/dist/system/patterns/UiSidebar/UiSidebarGroupLabel.vue.d.ts +6 -6
  21. package/dist/system/patterns/UiSidebar/activeIndicator.d.ts +1 -2
  22. package/dist/system/patterns/UiSidebar/index.d.ts +1 -3
  23. package/dist/system/patterns/UiSidebar/types.d.ts +1 -95
  24. package/docs/public-docs/foundations.md +48 -38
  25. package/hover-mix.d.ts +8 -11
  26. package/hover-mix.js +7 -15
  27. package/package.json +6 -4
  28. package/src/components/UiAccordion/UiAccordion.stories.ts +2 -2
  29. package/src/components/UiAlert/UiAlert.stories.ts +4 -4
  30. package/src/components/UiAvatar/UiAvatar.stories.ts +2 -2
  31. package/src/components/UiButton/UiButton.stories.ts +1 -1
  32. package/src/components/UiCalendar/UiCalendar.stories.ts +1 -24
  33. package/src/components/UiCalendar/UiCalendar.vue +16 -0
  34. package/src/components/UiCard/UiCard.stories.ts +4 -4
  35. package/src/components/UiChip/UiChip.vue +1 -1
  36. package/src/components/UiDrawer/UiDrawer.stories.ts +6 -6
  37. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +4 -4
  38. package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +70 -3
  39. package/src/components/UiEmpty/UiEmpty.stories.ts +1 -0
  40. package/src/components/UiFileItem/UiFileItem.vue +1 -1
  41. package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +4 -1
  42. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +2 -2
  43. package/src/components/UiIcon/UiIcon.stories.ts +90 -18
  44. package/src/components/UiInput/UiInput.stories.ts +2 -2
  45. package/src/components/UiKbd/UiKbd.stories.ts +10 -10
  46. package/src/components/UiLabel/UiLabel.stories.ts +2 -2
  47. package/src/components/UiListbox/UiListbox.stories.ts +14 -14
  48. package/src/components/UiListbox/UiListbox.vue +16 -0
  49. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +24 -13
  50. package/src/components/UiPopover/UiPopover.stories.ts +6 -6
  51. package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +22 -22
  52. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +11 -22
  53. package/src/components/UiRangeCalendar/UiRangeCalendar.vue +16 -0
  54. package/src/components/UiSelect/UiSelectItem.vue +1 -1
  55. package/src/components/UiSeparator/UiSeparator.stories.ts +8 -8
  56. package/src/components/UiSheet/UiSheet.stories.ts +12 -12
  57. package/src/components/UiSkeleton/UiSkeleton.stories.ts +20 -20
  58. package/src/components/UiSlider/UiSlider.stories.ts +6 -6
  59. package/src/components/UiSnackbar/UiSnackbar.stories.ts +508 -0
  60. package/src/components/UiSnackbar/UiSnackbar.vue +286 -0
  61. package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +17 -0
  62. package/src/components/UiSnackbar/index.ts +4 -0
  63. package/src/components/UiSnackbar/types.ts +97 -0
  64. package/src/components/UiSwitch/UiSwitch.stories.ts +4 -4
  65. package/src/components/UiSwitch/__tests__/UiSwitch.test.ts +9 -2
  66. package/src/components/UiTable/__tests__/UiTableRow.test.ts +23 -4
  67. package/src/components/UiTabs/UiTabs.stories.ts +2 -2
  68. package/src/components/UiTabs/__tests__/UiTabs.test.ts +25 -0
  69. package/src/components/UiTagsInput/UiTagsInput.stories.ts +2 -0
  70. package/src/components/UiToggle/UiToggle.vue +18 -1
  71. package/src/components/UiToggle/__tests__/UiToggle.test.ts +42 -3
  72. package/src/components/UiToggle/types.ts +13 -0
  73. package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +18 -0
  74. package/src/components/UiTooltip/UiTooltip.stories.ts +7 -7
  75. package/src/components/core/accordion/AccordionContent.vue +36 -1
  76. package/src/components/core/alert/index.ts +3 -2
  77. package/src/components/core/button/index.ts +5 -6
  78. package/src/components/core/calendar/CalendarGrid.vue +1 -1
  79. package/src/components/core/card/Card.vue +1 -1
  80. package/src/components/core/dropdown-menu/DropdownMenuCheckboxItem.vue +14 -13
  81. package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
  82. package/src/components/core/dropdown-menu/DropdownMenuRadioItem.vue +23 -13
  83. package/src/components/core/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
  84. package/src/components/core/listbox/ListboxItem.vue +1 -1
  85. package/src/components/core/popover/PopoverContent.vue +1 -1
  86. package/src/components/core/range-calendar/RangeCalendarGrid.vue +1 -1
  87. package/src/components/core/select/SelectItem.vue +1 -1
  88. package/src/components/core/sidebar/SidebarGroupAction.vue +1 -1
  89. package/src/components/core/sidebar/SidebarMenuAction.vue +1 -1
  90. package/src/components/core/sidebar/SidebarMenuSubButton.vue +2 -2
  91. package/src/components/core/sidebar/SidebarTrigger.vue +4 -4
  92. package/src/components/core/sidebar/index.ts +4 -3
  93. package/src/components/core/sonner/Sonner.vue +43 -0
  94. package/src/components/core/sonner/index.ts +1 -0
  95. package/src/components/core/switch/Switch.vue +2 -2
  96. package/src/components/core/table/TableRow.vue +1 -1
  97. package/src/components/core/tabs/TabsList.vue +1 -1
  98. package/src/components/core/tabs/TabsTrigger.vue +1 -1
  99. package/src/components/core/toggle/index.ts +3 -3
  100. package/src/components/core/toggle-group/index.ts +1 -1
  101. package/src/components/index.ts +1 -1
  102. package/src/directives/vHover.stories.ts +1 -1
  103. package/src/index.ts +3 -0
  104. package/src/lib/heightTransition.ts +27 -0
  105. package/src/lib/useDrag.stories.ts +295 -0
  106. package/src/lib/useDrag.ts +212 -0
  107. package/src/patterns/UiDataTable/UiDataTable.stories.ts +363 -15
  108. package/src/patterns/UiDataTable/UiDataTable.vue +558 -22
  109. package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +83 -0
  110. package/src/patterns/UiDataTable/UiDataTableColumnHeader.vue +4 -13
  111. package/src/patterns/UiDataTable/UiDataTablePagination.vue +3 -3
  112. package/src/patterns/UiDataTable/UiDataTableToolbar.vue +1 -1
  113. package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +343 -0
  114. package/src/patterns/UiDataTable/__tests__/UiDataTableColumnFilter.test.ts +194 -0
  115. package/src/patterns/UiDataTable/__tests__/UiDataTableColumnHeader.test.ts +11 -0
  116. package/src/patterns/UiDataTable/constants.ts +15 -0
  117. package/src/patterns/UiDataTable/index.ts +2 -0
  118. package/src/patterns/UiDataTable/types.ts +33 -0
  119. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +4 -4
  120. package/src/patterns/UiDatePicker/UiDatePicker.vue +2 -0
  121. package/src/patterns/UiSidebar/UiSidebar.stories.ts +27 -258
  122. package/src/patterns/UiSidebar/UiSidebarGroup.stories.ts +6 -8
  123. package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +13 -36
  124. package/src/patterns/UiSidebar/UiSidebarGroupLabel.stories.ts +15 -10
  125. package/src/patterns/UiSidebar/UiSidebarGroupLabel.vue +20 -7
  126. package/src/patterns/UiSidebar/UiSidebarHeader.vue +0 -1
  127. package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +29 -40
  128. package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +9 -6
  129. package/src/patterns/UiSidebar/UiSidebarMenuItem.stories.ts +11 -13
  130. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +8 -5
  131. package/src/patterns/UiSidebar/UiSidebarPopoverMenu.stories.ts +6 -8
  132. package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.stories.ts +6 -7
  133. package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +9 -7
  134. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.stories.ts +3 -3
  135. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +11 -12
  136. package/src/patterns/UiSidebar/UiSidebarTrigger.vue +1 -1
  137. package/src/patterns/UiSidebar/activeIndicator.ts +1 -2
  138. package/src/patterns/UiSidebar/index.ts +0 -5
  139. package/src/patterns/UiSidebar/types.ts +1 -111
  140. package/src/theme/Background.stories.ts +5 -5
  141. package/src/theme/Border.stories.ts +3 -3
  142. package/src/theme/Extended.stories.ts +6 -6
  143. package/src/theme/Flex.stories.ts +10 -10
  144. package/src/theme/Grid.stories.ts +10 -10
  145. package/src/theme/HoverLayer.stories.ts +215 -0
  146. package/src/theme/Overlay.stories.ts +2 -2
  147. package/src/theme/Shadow.stories.ts +1 -1
  148. package/src/theme/Theme.stories.ts +4 -4
  149. package/src/theme/Typography.stories.ts +21 -21
  150. package/tokens.json +4835 -1369
  151. package/dist/system/components/UiIconButton/UiIconButton.vue.d.ts +0 -25
  152. package/dist/system/components/UiIconButton/index.d.ts +0 -7
  153. package/dist/system/components/UiIconButton/types.d.ts +0 -67
  154. package/dist/system/patterns/UiSidebar/UiSidebarChatHistory.vue.d.ts +0 -20
  155. package/dist/system/patterns/UiSidebar/UiSidebarChatHistoryItem.vue.d.ts +0 -34
  156. package/src/components/UiIconButton/UiIconButton.stories.ts +0 -470
  157. package/src/components/UiIconButton/UiIconButton.vue +0 -76
  158. package/src/components/UiIconButton/__tests__/UiIconButton.test.ts +0 -105
  159. package/src/components/UiIconButton/index.ts +0 -13
  160. package/src/components/UiIconButton/types.ts +0 -87
  161. package/src/patterns/UiSidebar/UiSidebarChatHistory.stories.ts +0 -104
  162. package/src/patterns/UiSidebar/UiSidebarChatHistory.vue +0 -43
  163. package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.stories.ts +0 -204
  164. package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.vue +0 -269
  165. package/src/patterns/UiSidebar/__tests__/UiSidebarChatHistory.test.ts +0 -35
  166. package/src/patterns/UiSidebar/__tests__/UiSidebarChatHistoryItem.test.ts +0 -49
  167. package/src/theme/BackgroundHover.stories.ts +0 -182
  168. package/src/theme/ContentHover.stories.ts +0 -171
@@ -1,269 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed, ref, useAttrs, useSlots, watch } from 'vue';
3
- import { MoreVertical } from 'lucide-vue-next';
4
- import { Primitive } from 'reka-ui';
5
- import {
6
- Popover,
7
- PopoverContent,
8
- PopoverTrigger,
9
- } from '@/components/core/popover';
10
- import { UiTooltip } from '@/components/UiTooltip';
11
- import { cn } from '@/lib/utils';
12
- import { SIDEBAR_ACTIVE_INDICATOR_CLASS } from './activeIndicator';
13
- import type {
14
- UiSidebarChatHistoryItemEmits,
15
- UiSidebarChatHistoryItemProps,
16
- } from './types';
17
-
18
- /**
19
- * @deprecated Use `CkHistoryItem` from `@aleph-alpha/chat-kit` instead.
20
- * This sidebar-coupled component will be removed in a future release.
21
- */
22
- defineOptions({
23
- name: 'UiSidebarChatHistoryItem',
24
- inheritAttrs: false,
25
- });
26
-
27
- const emit = defineEmits<UiSidebarChatHistoryItemEmits>();
28
-
29
- const props = withDefaults(defineProps<UiSidebarChatHistoryItemProps>(), {
30
- as: 'button',
31
- isActive: false,
32
- showAction: true,
33
- showActionOnHover: true,
34
- actionTooltip: '',
35
- actionAriaLabel: 'History item action',
36
- actionPopover: false,
37
- actionPopoverSide: 'right',
38
- actionPopoverAlign: 'start',
39
- actionPopoverSideOffset: 8,
40
- });
41
-
42
- const attrs = useAttrs();
43
- const slots = useSlots();
44
-
45
- const resolvedActionIcon = computed(() => props.actionIcon ?? MoreVertical);
46
- const hasMeta = computed(() =>
47
- Boolean(props.metaStart || props.metaEnd || slots.meta),
48
- );
49
-
50
- /**
51
- * When true, pointer/focus is in the action column. The row-level hover
52
- * tint is suppressed so the icon's own hover-mix tint + outlined border
53
- * don't stack on top of it.
54
- */
55
- const pointerOnAction = ref(false);
56
-
57
- function onActionPointerEnter() {
58
- pointerOnAction.value = true;
59
- }
60
-
61
- function onActionPointerLeave() {
62
- pointerOnAction.value = false;
63
- }
64
-
65
- function onActionFocusIn() {
66
- pointerOnAction.value = true;
67
- }
68
-
69
- function onActionFocusOut() {
70
- pointerOnAction.value = false;
71
- }
72
-
73
- watch(
74
- () => props.showAction,
75
- (show) => {
76
- if (!show) {
77
- pointerOnAction.value = false;
78
- }
79
- },
80
- );
81
-
82
- const containerClass = computed(() =>
83
- cn(
84
- 'group/sidebar-chat-history-item relative flex w-full min-w-0 items-stretch gap-2 rounded-md border border-transparent px-2 py-1.5 transition-colors group-data-[collapsible=icon]:hidden',
85
- hasMeta.value ? 'h-12' : 'h-10',
86
- // Whole-row focus ring: first tab lands on the main row control; second tab on the action button — both are inside this container.
87
- // `:has(:focus-visible)` instead of `:focus-within` so mouse clicks on the row don't flash a keyboard focus ring.
88
- 'has-[:focus-visible]:border-border-surface-focus-ring has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-ring/50',
89
- // Row hover/active tint — flat `default` hover-mix color. Hover is suppressed while the
90
- // pointer/focus is on the action column so the icon's own tint does not stack on top.
91
- props.isActive && 'bg-background-surface-primary-hover-default',
92
- !pointerOnAction.value &&
93
- 'hover:bg-background-surface-primary-hover-default',
94
- SIDEBAR_ACTIVE_INDICATOR_CLASS,
95
- ),
96
- );
97
-
98
- const itemClass = computed(() =>
99
- cn(
100
- 'text-left outline-hidden transition-colors',
101
- 'body-14-regular text-content-on-surface-primary',
102
- '!hover:bg-transparent !active:bg-transparent',
103
- // Suppress a second ring on the primary control; the row ring is on the outer container.
104
- 'focus-visible:ring-0 focus-visible:outline-none',
105
- 'data-[active=true]:text-content-on-surface-primary',
106
- // Stretched-link: extend the primary control's hit area to cover the full row
107
- // container (including its `px-2 py-1.5` padding and the gap before the action
108
- // column) so clicks anywhere on the row activate the item. The action button
109
- // stays interactive because it comes later in the DOM and is `relative`.
110
- 'before:content-[""] before:absolute before:inset-0 before:z-0',
111
- attrs.class as string | undefined,
112
- ),
113
- );
114
-
115
- /**
116
- * Wrapper column that owns the action button and the `pointerenter` /
117
- * `pointerleave` hit area driving `pointerOnAction`. Uses `self-stretch` so
118
- * the full row height reports pointer-enter on the column (not just the
119
- * 32×32 button), and — when `showActionOnHover` is true — hides the inner
120
- * button with `opacity-0` until the row is hovered or keyboard focus lands
121
- * anywhere inside it.
122
- */
123
- const actionColumnClass = computed(() =>
124
- cn(
125
- 'ml-auto flex shrink-0 items-center self-stretch ',
126
- props.showActionOnHover &&
127
- '[&_button]:opacity-0 [&_button]:transition-opacity group-hover/sidebar-chat-history-item:[&_button]:opacity-100 group-focus-within/sidebar-chat-history-item:[&_button]:opacity-100',
128
- ),
129
- );
130
-
131
- /**
132
- * Action control: same `default` hover-mix tint as the row, plus the
133
- * `border/button/outlined` token so the icon picks up a visible outline on
134
- * hover/focus (mirrors the outline button variant). Applied only while
135
- * pointer/focus is on the action column so the row tint does not stack
136
- * underneath the icon.
137
- */
138
- const actionButtonClass = computed(() =>
139
- cn(
140
- 'relative z-10 inline-flex size-8 shrink-0 items-center justify-center rounded-sm border border-transparent text-content-on-surface-primary outline-hidden transition-colors',
141
- '[&_svg]:size-4 [&_svg]:shrink-0',
142
- 'focus-visible:ring-0 focus-visible:outline-none',
143
- pointerOnAction.value &&
144
- 'bg-background-surface-primary-hover-default border-border-button-outlined',
145
- ),
146
- );
147
-
148
- const actionPopoverPanelClass = computed(() =>
149
- // Sidebar popover surface is `background/surface/secondary`; override the
150
- // core popover's default `floating` background so the outer frame matches
151
- // the `UiSidebarPopoverMenu` it hosts.
152
- cn(
153
- 'w-auto min-w-48 max-w-sm p-0 bg-background-surface-secondary',
154
- props.actionPopoverContentClass,
155
- ),
156
- );
157
-
158
- const passthroughAttrs = computed(() => {
159
- const { class: _class, ...rest } = attrs as Record<string, unknown>;
160
- return rest;
161
- });
162
-
163
- function onActionClick(event: MouseEvent) {
164
- event.stopPropagation();
165
- const el = event.currentTarget;
166
- if (el instanceof HTMLElement && el.focus) {
167
- queueMicrotask(() => el.focus({ preventScroll: true }));
168
- }
169
- if (!props.actionPopover) {
170
- // Public kebab-case event preserved for backwards compatibility.
171
- // eslint-disable-next-line vue/custom-event-name-casing
172
- emit('action-click', event);
173
- }
174
- }
175
- </script>
176
-
177
- <template>
178
- <div :data-active="props.isActive" :class="containerClass">
179
- <Primitive
180
- v-bind="passthroughAttrs"
181
- :as="props.as"
182
- :as-child="props.asChild"
183
- :data-active="props.isActive"
184
- :class="cn(itemClass, 'flex min-w-0 flex-1 items-center')"
185
- >
186
- <div class="min-w-0 flex-1">
187
- <div class="truncate body-14-regular text-content-on-surface-primary">
188
- {{ props.title }}
189
- </div>
190
-
191
- <div
192
- v-if="props.metaStart || props.metaEnd || $slots.meta"
193
- class="mt-0.5 flex min-w-0 items-center gap-1 label-12-medium text-content-on-surface-muted"
194
- >
195
- <slot name="meta">
196
- <span v-if="props.metaStart" class="truncate">{{
197
- props.metaStart
198
- }}</span>
199
- <span v-if="props.metaStart && props.metaEnd" aria-hidden="true"
200
- >|</span
201
- >
202
- <span v-if="props.metaEnd" class="truncate">{{
203
- props.metaEnd
204
- }}</span>
205
- </slot>
206
- </div>
207
- </div>
208
- </Primitive>
209
-
210
- <div
211
- v-if="props.showAction"
212
- :class="actionColumnClass"
213
- @pointerenter="onActionPointerEnter"
214
- @pointerleave="onActionPointerLeave"
215
- >
216
- <Popover v-if="props.actionPopover">
217
- <PopoverTrigger as-child>
218
- <button
219
- type="button"
220
- :aria-label="props.actionAriaLabel"
221
- :aria-haspopup="'dialog'"
222
- :class="actionButtonClass"
223
- @focusin="onActionFocusIn"
224
- @focusout="onActionFocusOut"
225
- @click.stop="onActionClick"
226
- >
227
- <component :is="resolvedActionIcon" :size="16" />
228
- </button>
229
- </PopoverTrigger>
230
- <PopoverContent
231
- :side="props.actionPopoverSide"
232
- :align="props.actionPopoverAlign"
233
- :side-offset="props.actionPopoverSideOffset"
234
- :class="actionPopoverPanelClass"
235
- >
236
- <slot name="action-popover" />
237
- </PopoverContent>
238
- </Popover>
239
-
240
- <UiTooltip
241
- v-else-if="props.actionTooltip"
242
- :content="props.actionTooltip"
243
- side="right"
244
- >
245
- <button
246
- type="button"
247
- :aria-label="props.actionAriaLabel"
248
- :class="actionButtonClass"
249
- @focusin="onActionFocusIn"
250
- @focusout="onActionFocusOut"
251
- @click.stop="onActionClick"
252
- >
253
- <component :is="resolvedActionIcon" :size="16" />
254
- </button>
255
- </UiTooltip>
256
- <button
257
- v-else
258
- type="button"
259
- :aria-label="props.actionAriaLabel"
260
- :class="actionButtonClass"
261
- @focusin="onActionFocusIn"
262
- @focusout="onActionFocusOut"
263
- @click.stop="onActionClick"
264
- >
265
- <component :is="resolvedActionIcon" :size="16" />
266
- </button>
267
- </div>
268
- </div>
269
- </template>
@@ -1,35 +0,0 @@
1
- import { render } from '@testing-library/vue';
2
- import { describe, expect, test, beforeEach, afterEach, vi } from 'vitest';
3
- import UiSidebarChatHistory from '../UiSidebarChatHistory.vue';
4
- import {
5
- createSidebarShell,
6
- mockMatchMediaDesktop,
7
- } from './sidebar-test-helpers';
8
-
9
- beforeEach(() => mockMatchMediaDesktop());
10
- afterEach(() => vi.restoreAllMocks());
11
-
12
- describe('UiSidebarChatHistory', () => {
13
- test('sets data-slot and optional gap class', () => {
14
- const { container: withGap } = render(
15
- createSidebarShell(
16
- '<UiSidebarChatHistory><span>x</span></UiSidebarChatHistory>',
17
- {
18
- UiSidebarChatHistory,
19
- },
20
- ),
21
- );
22
- const root = withGap.querySelector('[data-slot="sidebar-chat-history"]');
23
- expect(root).toBeTruthy();
24
- expect(root?.className).toMatch(/gap-1/);
25
-
26
- const { container: noGap } = render(
27
- createSidebarShell(
28
- '<UiSidebarChatHistory :with-gap="false"><span>y</span></UiSidebarChatHistory>',
29
- { UiSidebarChatHistory },
30
- ),
31
- );
32
- const root2 = noGap.querySelector('[data-slot="sidebar-chat-history"]');
33
- expect(root2?.className).not.toMatch(/gap-1/);
34
- });
35
- });
@@ -1,49 +0,0 @@
1
- import { render } from '@testing-library/vue';
2
- import userEvent from '@testing-library/user-event';
3
- import { defineComponent } from 'vue';
4
- import { describe, expect, test, beforeEach, afterEach, vi } from 'vitest';
5
- import UiSidebar from '../UiSidebar.vue';
6
- import UiSidebarChatHistoryItem from '../UiSidebarChatHistoryItem.vue';
7
- import UiSidebarContent from '../UiSidebarContent.vue';
8
- import UiSidebarProvider from '../UiSidebarProvider.vue';
9
- import { mockMatchMediaDesktop } from './sidebar-test-helpers';
10
-
11
- beforeEach(() => mockMatchMediaDesktop());
12
- afterEach(() => vi.restoreAllMocks());
13
-
14
- describe('UiSidebarChatHistoryItem', () => {
15
- test('renders title and emits action-click', async () => {
16
- const user = userEvent.setup();
17
- const onAction = vi.fn();
18
- const Harness = defineComponent({
19
- components: {
20
- UiSidebarProvider,
21
- UiSidebar,
22
- UiSidebarContent,
23
- UiSidebarChatHistoryItem,
24
- },
25
- setup() {
26
- return { onAction };
27
- },
28
- template: `
29
- <UiSidebarProvider :default-open="true">
30
- <UiSidebar collapsible="none" class="min-h-32">
31
- <UiSidebarContent>
32
- <UiSidebarChatHistoryItem
33
- title="Thread A"
34
- meta-start="Mon"
35
- :show-action-on-hover="false"
36
- action-aria-label="More"
37
- @action-click="onAction"
38
- />
39
- </UiSidebarContent>
40
- </UiSidebar>
41
- </UiSidebarProvider>
42
- `,
43
- });
44
- const { getByText, getByRole } = render(Harness);
45
- expect(getByText('Thread A')).toBeInTheDocument();
46
- await user.click(getByRole('button', { name: 'More' }));
47
- expect(onAction).toHaveBeenCalledTimes(1);
48
- });
49
- });
@@ -1,182 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
- import { defineComponent, h } from 'vue';
3
-
4
- const ThemePlaceholder = defineComponent({
5
- name: 'ThemePlaceholder',
6
- render() {
7
- return h('div');
8
- },
9
- });
10
-
11
- const meta: Meta<typeof ThemePlaceholder> = {
12
- title: 'CSS utility/Background Hover',
13
- component: ThemePlaceholder,
14
- tags: ['autodocs'],
15
- parameters: {
16
- layout: 'fullscreen',
17
- },
18
- };
19
-
20
- export default meta;
21
- type Story = StoryObj<typeof ThemePlaceholder>;
22
-
23
- const HOVER_VARIANTS = ['subtle', 'default', 'strong'] as const;
24
- type HoverVariant = (typeof HOVER_VARIANTS)[number];
25
-
26
- /**
27
- * Given a base background utility class (e.g. `bg-background-surface-primary`)
28
- * return the utility class that renders the solid color for a given hover
29
- * variant. Classes are generated by `hover-mix.js` + `config.js` and backed by
30
- * the CSS variable `--<bg>-hover-<variant>`.
31
- * @param bgClass
32
- * @param variant
33
- */
34
- const getHoverMixClass = (bgClass: string, variant: HoverVariant): string =>
35
- `${bgClass}-hover-${variant}`;
36
-
37
- /** Background tokens to preview, mirroring the Background.stories.ts layout. */
38
- const BG_GROUPS: Array<{
39
- title: string;
40
- description: string;
41
- tokens: string[];
42
- }> = [
43
- {
44
- title: 'Surface',
45
- description:
46
- 'Base and sheet-level surfaces composited with the three hover overlay tiers.',
47
- tokens: [
48
- 'bg-background-surface-primary',
49
- 'bg-background-surface-secondary',
50
- 'bg-background-surface-muted',
51
- 'bg-background-surface-selected',
52
- 'bg-background-surface-inverse',
53
- 'bg-background-surface-modal',
54
- 'bg-background-surface-floating',
55
- ],
56
- },
57
- {
58
- title: 'Button',
59
- description:
60
- 'Button backgrounds composited with the three hover overlay tiers.',
61
- tokens: [
62
- 'bg-background-button-primary-button',
63
- 'bg-background-button-secondary-button',
64
- 'bg-background-button-danger-button',
65
- ],
66
- },
67
- {
68
- title: 'Accent',
69
- description:
70
- 'Accent backgrounds composited with the three hover overlay tiers.',
71
- tokens: ['bg-background-accent-default', 'bg-background-accent-soft'],
72
- },
73
- {
74
- title: 'Input',
75
- description:
76
- 'Input backgrounds composited with the three hover overlay tiers.',
77
- tokens: ['bg-background-input-default'],
78
- },
79
- ];
80
-
81
- const copyScript = `
82
- function copyToClipboard(text, el) {
83
- navigator.clipboard.writeText(text).then(() => {
84
- el.classList.add('copied');
85
- setTimeout(() => el.classList.remove('copied'), 1500);
86
- });
87
- }
88
- `;
89
-
90
- const renderSwatch = (className: string): string => `
91
- <div class="w-12 h-12 rounded-md border border-border-surface-default ${className}"></div>
92
- `;
93
-
94
- const renderCopyCode = (text: string): string => `
95
- <code
96
- class="copy-btn label-12-regular text-content-on-surface-muted inline-block px-1 py-0.5 rounded"
97
- onclick="copyToClipboard('${text}', this)"
98
- >${text}</code>
99
- `;
100
-
101
- const renderTokenRow = (bgClass: string): string => {
102
- const variantCells = HOVER_VARIANTS.map((variant) => {
103
- const mixedClass = getHoverMixClass(bgClass, variant);
104
- return `
105
- <td class="p-3 align-middle">
106
- <div class="flex items-center gap-3">
107
- ${renderSwatch(mixedClass)}
108
- ${renderCopyCode(mixedClass)}
109
- </div>
110
- </td>
111
- `;
112
- }).join('');
113
-
114
- return `
115
- <tr class="border-b border-border-surface-default last:border-b-0">
116
- <td class="p-3 align-middle">${renderSwatch(bgClass)}</td>
117
- <td class="p-3 align-middle">${renderCopyCode(bgClass)}</td>
118
- ${variantCells}
119
- </tr>
120
- `;
121
- };
122
-
123
- const renderGroup = (group: (typeof BG_GROUPS)[number]): string => `
124
- <div class="mb-10">
125
- <h3 class="body-14-bold text-content-on-surface-primary mb-1">${group.title}</h3>
126
- <p class="label-12-regular text-content-on-surface-muted mb-3">${group.description}</p>
127
- <div class="overflow-x-auto">
128
- <table class="w-full border-collapse text-left">
129
- <thead>
130
- <tr class="border-b border-border-surface-default">
131
- <th class="p-3 label-12-medium text-content-on-surface-muted font-medium w-20">Base</th>
132
- <th class="p-3 label-12-medium text-content-on-surface-muted font-medium">Token</th>
133
- <th class="p-3 label-12-medium text-content-on-surface-muted font-medium">Subtle</th>
134
- <th class="p-3 label-12-medium text-content-on-surface-muted font-medium">Default</th>
135
- <th class="p-3 label-12-medium text-content-on-surface-muted font-medium">Strong</th>
136
- </tr>
137
- </thead>
138
- <tbody>
139
- ${group.tokens.map(renderTokenRow).join('')}
140
- </tbody>
141
- </table>
142
- </div>
143
- </div>
144
- `;
145
-
146
- /**
147
- * Preview of every background token composited with each hover overlay tier
148
- * (`subtle`, `default`, `strong`). Each swatch is a genuine, flat color
149
- * generated at build time by the hover-mix utility in
150
- * `@aleph-alpha/ui-library/hover-mix`, and rendered via the corresponding
151
- * utility class (e.g. `bg-background-surface-primary-hover-subtle`).
152
- */
153
- export const All: Story = {
154
- render: () => ({
155
- template: `
156
- <div class="p-8 bg-white dark:bg-background min-h-screen">
157
- <style>
158
- .copy-btn { cursor: pointer; transition: all 0.15s; }
159
- .copy-btn:hover { background: rgba(0,0,0,0.05); }
160
- .copy-btn.copied { background: #22c55e22; }
161
- .copy-btn.copied::after { content: ' ✓'; color: #22c55e; }
162
- </style>
163
- <script>${copyScript}</script>
164
-
165
- <div class="mb-6">
166
- <h2 class="heading-s text-content-on-surface-primary mb-1">Background Hover</h2>
167
- <p class="body-14-regular text-content-on-surface-muted">
168
- For each background token, the three swatches show the flat color produced by the
169
- hover-mix formula (alpha compositing) combining the base with
170
- <code class="label-12-medium">overlay-hover-subtle</code>,
171
- <code class="label-12-medium">overlay-hover-default</code> and
172
- <code class="label-12-medium">overlay-hover-strong</code>.
173
- Class names take the form <code class="label-12-medium">bg-&lt;token&gt;-hover-&lt;variant&gt;</code>.
174
- Click a label to copy.
175
- </p>
176
- </div>
177
-
178
- ${BG_GROUPS.map(renderGroup).join('')}
179
- </div>
180
- `,
181
- }),
182
- };