@aleph-alpha/ui-library 6.5.0 → 6.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 (176) hide show
  1. package/dist/system/components/core/toggle/index.d.ts +1 -1
  2. package/dist/system/lib.js +14623 -14438
  3. package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +21 -174
  4. package/dist/system/patterns/UiFloatActions/core/FloatingButton.vue.d.ts +36 -0
  5. package/dist/system/patterns/UiFloatActions/core/FloatingInput.vue.d.ts +19 -0
  6. package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +3 -1
  7. package/dist/system/patterns/UiFloatActions/types.d.ts +93 -19
  8. package/dist/system/patterns/UiLayout/layout-shell.d.ts +117 -252
  9. package/package.json +2 -2
  10. package/src/components/UiAccordion/UiAccordion.stories.ts +8 -8
  11. package/src/components/UiAlert/UiAlert.stories.ts +13 -13
  12. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +4 -4
  13. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +13 -13
  14. package/src/components/UiAutocomplete/UiAutocomplete.vue +3 -3
  15. package/src/components/UiBadge/UiBadge.stories.ts +9 -9
  16. package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +14 -14
  17. package/src/components/UiButton/UiButton.stories.ts +35 -35
  18. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +6 -6
  19. package/src/components/UiCalendar/UiCalendar.stories.ts +6 -6
  20. package/src/components/UiCard/UiCard.stories.ts +6 -6
  21. package/src/components/UiCheckbox/UiCheckbox.stories.ts +30 -30
  22. package/src/components/UiChip/UiChip.stories.ts +14 -14
  23. package/src/components/UiChip/UiChip.vue +1 -1
  24. package/src/components/UiDialog/UiDialog.stories.ts +20 -20
  25. package/src/components/UiDrawer/UiDrawer.stories.ts +29 -29
  26. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +13 -13
  27. package/src/components/UiEmpty/UiEmpty.vue +1 -1
  28. package/src/components/UiFadeMask/UiFadeMask.stories.ts +13 -13
  29. package/src/components/UiField/UiField.stories.ts +27 -27
  30. package/src/components/UiFileItem/UiFileItem.vue +4 -4
  31. package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +2 -2
  32. package/src/components/UiFileType/UiFileType.stories.ts +10 -10
  33. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +10 -10
  34. package/src/components/UiFileUploadBox/UiFileUploadBox.vue +3 -3
  35. package/src/components/UiIcon/UiIcon.stories.ts +9 -9
  36. package/src/components/UiInput/UiInput.stories.ts +13 -13
  37. package/src/components/UiInput/UiInput.vue +1 -1
  38. package/src/components/UiInputGroup/UiInputGroup.stories.ts +10 -10
  39. package/src/components/UiItem/UiItem.stories.ts +12 -12
  40. package/src/components/UiItem/__tests__/UiItem.test.ts +2 -2
  41. package/src/components/UiKbd/UiKbd.stories.ts +18 -18
  42. package/src/components/UiKbd/UiKbd.vue +1 -1
  43. package/src/components/UiLabel/UiLabel.stories.ts +12 -12
  44. package/src/components/UiLabel/__tests__/UiLabel.test.ts +1 -1
  45. package/src/components/UiListbox/UiListbox.stories.ts +20 -20
  46. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +94 -94
  47. package/src/components/UiPopover/UiPopover.stories.ts +35 -35
  48. package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +53 -53
  49. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +6 -6
  50. package/src/components/UiResizable/UiResizable.stories.ts +40 -40
  51. package/src/components/UiSelect/UiSelect.stories.ts +14 -14
  52. package/src/components/UiSeparator/UiSeparator.stories.ts +16 -16
  53. package/src/components/UiSheet/UiSheet.stories.ts +29 -29
  54. package/src/components/UiSlider/UiSlider.stories.ts +28 -28
  55. package/src/components/UiSnackbar/UiSnackbar.stories.ts +6 -6
  56. package/src/components/UiSnackbar/UiSnackbar.vue +2 -2
  57. package/src/components/UiSnackbar/UiSnackbarContent.vue +2 -2
  58. package/src/components/UiSpinner/UiSpinner.stories.ts +8 -8
  59. package/src/components/UiStepper/UiStepper.stories.ts +6 -6
  60. package/src/components/UiSwitch/UiSwitch.stories.ts +37 -37
  61. package/src/components/UiTable/UiTable.stories.ts +4 -4
  62. package/src/components/UiTabs/UiTabs.stories.ts +64 -64
  63. package/src/components/UiTagsInput/UiTagsInput.stories.ts +16 -16
  64. package/src/components/UiTextarea/UiTextarea.stories.ts +20 -20
  65. package/src/components/UiToggle/UiToggle.stories.ts +26 -26
  66. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +31 -31
  67. package/src/components/UiTooltip/UiTooltip.stories.ts +7 -7
  68. package/src/components/core/accordion/AccordionContent.vue +1 -1
  69. package/src/components/core/accordion/AccordionTrigger.vue +1 -1
  70. package/src/components/core/alert/AlertDescription.vue +1 -1
  71. package/src/components/core/alert/index.ts +1 -1
  72. package/src/components/core/alert-dialog/AlertDialogDescription.vue +1 -1
  73. package/src/components/core/badge/index.ts +2 -2
  74. package/src/components/core/button/index.ts +3 -3
  75. package/src/components/core/calendar/Calendar.vue +4 -4
  76. package/src/components/core/calendar/CalendarCell.vue +1 -1
  77. package/src/components/core/calendar/CalendarHeading.vue +1 -1
  78. package/src/components/core/card/CardDescription.vue +1 -1
  79. package/src/components/core/dialog/DialogDescription.vue +1 -1
  80. package/src/components/core/drawer/DrawerDescription.vue +1 -1
  81. package/src/components/core/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
  82. package/src/components/core/dropdown-menu/DropdownMenuLabel.vue +1 -1
  83. package/src/components/core/dropdown-menu/DropdownMenuRadioItem.vue +1 -1
  84. package/src/components/core/dropdown-menu/DropdownMenuShortcut.vue +1 -1
  85. package/src/components/core/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
  86. package/src/components/core/field/FieldDescription.vue +1 -1
  87. package/src/components/core/field/FieldError.vue +1 -1
  88. package/src/components/core/field/FieldLabel.vue +1 -1
  89. package/src/components/core/field/FieldLegend.vue +2 -2
  90. package/src/components/core/field/FieldSeparator.vue +1 -1
  91. package/src/components/core/field/FieldTitle.vue +1 -1
  92. package/src/components/core/input/Input.vue +1 -1
  93. package/src/components/core/input-group/InputGroupText.vue +1 -1
  94. package/src/components/core/input-group/index.ts +1 -1
  95. package/src/components/core/item/ItemDescription.vue +1 -1
  96. package/src/components/core/item/ItemTitle.vue +1 -1
  97. package/src/components/core/item/index.ts +2 -2
  98. package/src/components/core/label/Label.vue +1 -1
  99. package/src/components/core/listbox/ListboxFilter.vue +1 -1
  100. package/src/components/core/listbox/ListboxGroupLabel.vue +1 -1
  101. package/src/components/core/listbox/ListboxItem.vue +1 -1
  102. package/src/components/core/native-select/NativeSelect.vue +1 -1
  103. package/src/components/core/navigation-menu/NavigationMenuLink.vue +1 -1
  104. package/src/components/core/navigation-menu/index.ts +1 -1
  105. package/src/components/core/range-calendar/RangeCalendarCell.vue +1 -1
  106. package/src/components/core/range-calendar/RangeCalendarHeading.vue +1 -1
  107. package/src/components/core/select/SelectItem.vue +1 -1
  108. package/src/components/core/select/SelectLabel.vue +1 -1
  109. package/src/components/core/select/SelectTrigger.vue +1 -1
  110. package/src/components/core/sheet/SheetDescription.vue +1 -1
  111. package/src/components/core/sidebar/SidebarGroupContent.vue +1 -1
  112. package/src/components/core/sidebar/SidebarGroupLabel.vue +1 -1
  113. package/src/components/core/sidebar/SidebarMenuBadge.vue +1 -1
  114. package/src/components/core/sidebar/SidebarMenuSubButton.vue +2 -2
  115. package/src/components/core/sidebar/index.ts +4 -4
  116. package/src/components/core/stepper/StepperDescription.vue +1 -1
  117. package/src/components/core/stepper/StepperTitle.vue +1 -1
  118. package/src/components/core/table/Table.vue +1 -1
  119. package/src/components/core/table/TableCaption.vue +1 -1
  120. package/src/components/core/table/TableEmpty.vue +1 -1
  121. package/src/components/core/tabs/TabsTrigger.vue +1 -1
  122. package/src/components/core/tags-input/TagsInput.vue +1 -1
  123. package/src/components/core/tags-input/TagsInputItem.vue +1 -1
  124. package/src/components/core/textarea/Textarea.vue +1 -1
  125. package/src/components/core/toggle/index.ts +1 -1
  126. package/src/components/core/tooltip/TooltipContent.vue +1 -1
  127. package/src/directives/vHover.stories.ts +17 -17
  128. package/src/lib/useDevice.stories.ts +29 -29
  129. package/src/lib/useDrag.stories.ts +14 -14
  130. package/src/patterns/UiDataTable/UiDataTable.stories.ts +27 -27
  131. package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +2 -2
  132. package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +2 -2
  133. package/src/patterns/UiDataTable/UiDataTablePagination.vue +3 -3
  134. package/src/patterns/UiDataTable/__tests__/UiDataTableColumnFilter.test.ts +2 -2
  135. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +14 -14
  136. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +14 -14
  137. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +6 -6
  138. package/src/patterns/UiFloatActions/UiFloatActionItems.vue +226 -76
  139. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +1136 -116
  140. package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +187 -1
  141. package/src/patterns/UiFloatActions/core/FloatingButton.vue +83 -0
  142. package/src/patterns/UiFloatActions/core/FloatingInput.vue +53 -0
  143. package/src/patterns/UiFloatActions/floatActionItemContext.ts +3 -1
  144. package/src/patterns/UiFloatActions/types.ts +106 -19
  145. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +17 -17
  146. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +4 -4
  147. package/src/patterns/UiLayout/layout-shell.ts +6 -6
  148. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +8 -8
  149. package/src/patterns/UiProfileCard/profile-card.ts +2 -2
  150. package/src/patterns/UiSidebar/UiSidebar.stories.ts +6 -6
  151. package/src/patterns/UiSidebar/UiSidebarGroup.stories.ts +1 -1
  152. package/src/patterns/UiSidebar/UiSidebarGroupLabel.stories.ts +4 -4
  153. package/src/patterns/UiSidebar/UiSidebarGroupLabel.vue +1 -1
  154. package/src/patterns/UiSidebar/UiSidebarHeader.vue +1 -1
  155. package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +7 -7
  156. package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +4 -4
  157. package/src/patterns/UiSidebar/UiSidebarMenuItem.stories.ts +4 -4
  158. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.stories.ts +1 -1
  159. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +1 -1
  160. package/src/patterns/UiSidebar/UiSidebarPopoverMenu.vue +1 -1
  161. package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +3 -3
  162. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.stories.ts +1 -1
  163. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +1 -1
  164. package/src/patterns/UiSidebar/UiSidebarSub.stories.ts +1 -1
  165. package/src/patterns/UiTopBar/UiTopBar.stories.ts +24 -24
  166. package/src/theme/Background.stories.ts +62 -62
  167. package/src/theme/Border.stories.ts +19 -19
  168. package/src/theme/BorderRadius.stories.ts +14 -14
  169. package/src/theme/Extended.stories.ts +26 -26
  170. package/src/theme/Flex.stories.ts +21 -21
  171. package/src/theme/Grid.stories.ts +19 -19
  172. package/src/theme/HoverLayer.stories.ts +26 -26
  173. package/src/theme/Overlay.stories.ts +14 -14
  174. package/src/theme/Scrollbar.stories.ts +58 -58
  175. package/src/theme/Shadow.stories.ts +5 -5
  176. package/src/theme/Theme.stories.ts +38 -38
@@ -1,4 +1,4 @@
1
- import { render } from '@testing-library/vue';
1
+ import { fireEvent, render } from '@testing-library/vue';
2
2
  import { describe, expect, test, vi } from 'vitest';
3
3
  import { UiFloatActionItems } from '../index';
4
4
 
@@ -123,4 +123,190 @@ describe('UiFloatActionItems', () => {
123
123
  'Filter...',
124
124
  );
125
125
  });
126
+
127
+ test('defaults every item to the md size', () => {
128
+ const { getByRole } = render({
129
+ components: { UiFloatActionItems },
130
+ template: `
131
+ <UiFloatActionItems aria-label="Actions">
132
+ <UiFloatActionItems type="button" aria-label="Edit">Edit</UiFloatActionItems>
133
+ <UiFloatActionItems type="icon" icon="copy" aria-label="Copy" />
134
+ </UiFloatActionItems>
135
+ `,
136
+ });
137
+
138
+ expect(getByRole('toolbar')).toHaveAttribute('data-size', 'md');
139
+ expect(getByRole('button', { name: 'Edit' })).toHaveAttribute(
140
+ 'data-size',
141
+ 'md',
142
+ );
143
+ expect(getByRole('button', { name: 'Copy' })).toHaveAttribute(
144
+ 'data-size',
145
+ 'md',
146
+ );
147
+ });
148
+
149
+ test('items inherit the toolbar size and can override it', () => {
150
+ const { getByRole } = render({
151
+ components: { UiFloatActionItems },
152
+ template: `
153
+ <UiFloatActionItems aria-label="Actions" size="xs">
154
+ <UiFloatActionItems type="label">Edit</UiFloatActionItems>
155
+ <UiFloatActionItems type="icon" icon="copy" aria-label="Copy" size="md" />
156
+ </UiFloatActionItems>
157
+ `,
158
+ });
159
+
160
+ expect(getByRole('button', { name: 'Edit' })).toHaveAttribute(
161
+ 'data-size',
162
+ 'xs',
163
+ );
164
+ expect(getByRole('button', { name: 'Copy' })).toHaveAttribute(
165
+ 'data-size',
166
+ 'md',
167
+ );
168
+ });
169
+
170
+ test('label items render text with prefix and suffix icons', () => {
171
+ const { getByRole } = render({
172
+ components: { UiFloatActionItems },
173
+ template: `
174
+ <UiFloatActionItems aria-label="Actions">
175
+ <UiFloatActionItems type="label" prefix-icon="edit" suffix-icon="chevron-down">
176
+ Edit
177
+ </UiFloatActionItems>
178
+ </UiFloatActionItems>
179
+ `,
180
+ });
181
+
182
+ const label = getByRole('button', { name: 'Edit' });
183
+ expect(label).toHaveAttribute('data-slot', 'float-item-action');
184
+ expect(label.querySelectorAll('svg')).toHaveLength(2);
185
+ });
186
+
187
+ test('label and icon items join the toolbar v-model selection', async () => {
188
+ const onUpdate = vi.fn();
189
+ const { getByRole } = render({
190
+ components: { UiFloatActionItems },
191
+ setup() {
192
+ return { onUpdate };
193
+ },
194
+ template: `
195
+ <UiFloatActionItems aria-label="View" model-value="grid" @update:model-value="onUpdate">
196
+ <UiFloatActionItems type="label" value="grid">Grid</UiFloatActionItems>
197
+ <UiFloatActionItems type="icon" icon="list" value="list" aria-label="List" />
198
+ </UiFloatActionItems>
199
+ `,
200
+ });
201
+
202
+ expect(getByRole('button', { name: 'Grid' })).toHaveAttribute(
203
+ 'aria-pressed',
204
+ 'true',
205
+ );
206
+ await getByRole('button', { name: 'List' }).click();
207
+ expect(onUpdate).toHaveBeenCalledWith('list');
208
+ });
209
+
210
+ test('input items render previous / next buttons around the field', async () => {
211
+ const onPrevious = vi.fn();
212
+ const onNext = vi.fn();
213
+ const onUpdate = vi.fn();
214
+ const { getByRole } = render({
215
+ components: { UiFloatActionItems },
216
+ setup() {
217
+ return { onPrevious, onNext, onUpdate };
218
+ },
219
+ template: `
220
+ <UiFloatActionItems aria-label="Pagination">
221
+ <UiFloatActionItems
222
+ type="input"
223
+ aria-label="Page"
224
+ model-value="1/3"
225
+ previous-aria-label="Previous page"
226
+ next-aria-label="Next page"
227
+ @previous="onPrevious"
228
+ @next="onNext"
229
+ @update:model-value="onUpdate"
230
+ />
231
+ </UiFloatActionItems>
232
+ `,
233
+ });
234
+
235
+ const field = getByRole('textbox', { name: 'Page' });
236
+ expect(field).toHaveValue('1/3');
237
+
238
+ await getByRole('button', { name: 'Previous page' }).click();
239
+ await getByRole('button', { name: 'Next page' }).click();
240
+ expect(onPrevious).toHaveBeenCalledTimes(1);
241
+ expect(onNext).toHaveBeenCalledTimes(1);
242
+
243
+ await fireEvent.update(field, '2/3');
244
+ expect(onUpdate).toHaveBeenCalledWith('2/3');
245
+ });
246
+
247
+ test('input items apply class to the field and groupClass to the wrapper', () => {
248
+ const { getByRole, container } = render({
249
+ components: { UiFloatActionItems },
250
+ template: `
251
+ <UiFloatActionItems aria-label="Zoom">
252
+ <UiFloatActionItems type="input" aria-label="Zoom level" class="w-16" group-class="gap-2" />
253
+ </UiFloatActionItems>
254
+ `,
255
+ });
256
+
257
+ const group = container.querySelector('[data-slot="float-item-input"]');
258
+ expect(getByRole('textbox', { name: 'Zoom level' })).toHaveClass('w-16');
259
+ expect(group).not.toHaveClass('w-16');
260
+ expect(group).toHaveClass('gap-2');
261
+ });
262
+
263
+ test('input items stack vertically in a vertical toolbar', () => {
264
+ const { container } = render({
265
+ components: { UiFloatActionItems },
266
+ template: `
267
+ <UiFloatActionItems aria-label="Pagination" orientation="vertical">
268
+ <UiFloatActionItems type="input" aria-label="Page" />
269
+ </UiFloatActionItems>
270
+ `,
271
+ });
272
+
273
+ expect(
274
+ container.querySelector('[data-slot="float-item-input"]'),
275
+ ).toHaveClass('flex-col');
276
+ });
277
+
278
+ test('disabled input items disable the field and both buttons', () => {
279
+ const { getByRole } = render({
280
+ components: { UiFloatActionItems },
281
+ template: `
282
+ <UiFloatActionItems aria-label="Pagination">
283
+ <UiFloatActionItems type="input" aria-label="Page" disabled />
284
+ </UiFloatActionItems>
285
+ `,
286
+ });
287
+
288
+ expect(getByRole('textbox', { name: 'Page' })).toBeDisabled();
289
+ expect(getByRole('button', { name: 'Previous' })).toBeDisabled();
290
+ expect(getByRole('button', { name: 'Next' })).toBeDisabled();
291
+ });
292
+
293
+ test('disabled label and icon items do not emit click', async () => {
294
+ const onClick = vi.fn();
295
+ const { getByRole } = render({
296
+ components: { UiFloatActionItems },
297
+ setup() {
298
+ return { onClick };
299
+ },
300
+ template: `
301
+ <UiFloatActionItems aria-label="Actions">
302
+ <UiFloatActionItems type="label" disabled @click="onClick">Edit</UiFloatActionItems>
303
+ <UiFloatActionItems type="icon" icon="copy" aria-label="Copy" disabled @click="onClick" />
304
+ </UiFloatActionItems>
305
+ `,
306
+ });
307
+
308
+ await fireEvent.click(getByRole('button', { name: 'Edit' }));
309
+ await fireEvent.click(getByRole('button', { name: 'Copy' }));
310
+ expect(onClick).not.toHaveBeenCalled();
311
+ });
126
312
  });
@@ -0,0 +1,83 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * FloatingButton is the private base button of floating actions. It has no
4
+ * background of its own; the surrounding toolbar provides the surface.
5
+ *
6
+ * Renders text with optional prefix / suffix icons, or a single icon when
7
+ * `icon` is set. Styles follow the Figma "Floating / Button" spec, switching to
8
+ * the mobile variant below the `sm` breakpoint.
9
+ */
10
+ import UiIcon from '@/components/UiIcon/UiIcon.vue';
11
+ import { cn, omitClass } from '@/lib/utils';
12
+ import { computed, useAttrs } from 'vue';
13
+ import type { UiFloatActionItemsIcon, UiFloatActionItemsSize } from '../types';
14
+
15
+ defineOptions({
16
+ name: 'FloatingButton',
17
+ inheritAttrs: false,
18
+ });
19
+
20
+ const props = withDefaults(
21
+ defineProps<{
22
+ /** Control size. */
23
+ size?: UiFloatActionItemsSize;
24
+ /** Visible text. The default slot takes precedence. */
25
+ text?: string;
26
+ /** Icon rendered before the text. */
27
+ prefixIcon?: UiFloatActionItemsIcon;
28
+ /** Icon rendered after the text. */
29
+ suffixIcon?: UiFloatActionItemsIcon;
30
+ /** Renders an icon-only button with this icon. */
31
+ icon?: UiFloatActionItemsIcon;
32
+ }>(),
33
+ {
34
+ size: 'md',
35
+ text: undefined,
36
+ prefixIcon: undefined,
37
+ suffixIcon: undefined,
38
+ icon: undefined,
39
+ },
40
+ );
41
+
42
+ const attrs = useAttrs();
43
+
44
+ const isIconOnly = computed(() => props.icon !== undefined);
45
+
46
+ const SIZE_CLASSES = {
47
+ label: {
48
+ md: 'gap-2 px-3 py-2 max-sm:gap-1.5 max-sm:px-2 max-sm:py-1',
49
+ xs: 'gap-2 px-2 py-0.5 max-sm:gap-1.5',
50
+ },
51
+ icon: {
52
+ md: 'p-2 max-sm:p-1',
53
+ xs: 'p-1',
54
+ },
55
+ } as const;
56
+
57
+ const buttonClass = computed(() =>
58
+ cn(
59
+ 'ui-focus-ring-outline relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-full bg-transparent body-s-medium text-content-on-surface-muted transition-colors hover:text-content-on-surface-primary focus-visible:text-content-on-surface-primary aria-pressed:text-content-on-surface-primary disabled:cursor-not-allowed disabled:opacity-50 max-sm:text-content-on-surface-primary',
60
+ SIZE_CLASSES[isIconOnly.value ? 'icon' : 'label'][props.size],
61
+ attrs.class ?? '',
62
+ ),
63
+ );
64
+
65
+ const iconOnlySize = computed(() => (props.size === 'xs' ? 's' : 'm'));
66
+ </script>
67
+
68
+ <template>
69
+ <button
70
+ type="button"
71
+ data-floating="button"
72
+ :data-size="props.size"
73
+ v-bind="omitClass(attrs)"
74
+ :class="buttonClass"
75
+ >
76
+ <UiIcon v-if="isIconOnly" :name="props.icon!" :size="iconOnlySize" />
77
+ <template v-else>
78
+ <UiIcon v-if="props.prefixIcon" :name="props.prefixIcon" size="s" />
79
+ <slot>{{ props.text }}</slot>
80
+ <UiIcon v-if="props.suffixIcon" :name="props.suffixIcon" size="s" />
81
+ </template>
82
+ </button>
83
+ </template>
@@ -0,0 +1,53 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * FloatingInput is the private base text field of floating actions: a native
4
+ * `input` with centered text, sized to sit inside a floating toolbar.
5
+ */
6
+ import { cn, omitClass } from '@/lib/utils';
7
+ import { computed, useAttrs } from 'vue';
8
+ import type { UiFloatActionItemsSize, UiFloatActionItemsValue } from '../types';
9
+
10
+ defineOptions({
11
+ name: 'FloatingInput',
12
+ inheritAttrs: false,
13
+ });
14
+
15
+ const props = withDefaults(
16
+ defineProps<{
17
+ /** Field size. */
18
+ size?: UiFloatActionItemsSize;
19
+ /** Accessible name of the field. */
20
+ ariaLabel?: string;
21
+ }>(),
22
+ { size: 'md', ariaLabel: undefined },
23
+ );
24
+
25
+ const model = defineModel<UiFloatActionItemsValue>();
26
+
27
+ const attrs = useAttrs();
28
+
29
+ const SIZE_CLASSES = {
30
+ md: 'h-10 w-12 px-3 py-2.5',
31
+ xs: 'h-6 w-12 px-3 py-0.5',
32
+ } as const;
33
+
34
+ const inputClass = computed(() =>
35
+ cn(
36
+ 'ui-focus-ring min-w-0 shrink-0 rounded-md border border-border-input-default bg-background-input-default text-center body-s-regular text-content-on-surface-primary outline-none transition-[color] placeholder:text-content-on-surface-muted disabled:cursor-not-allowed disabled:opacity-50',
37
+ SIZE_CLASSES[props.size],
38
+ attrs.class ?? '',
39
+ ),
40
+ );
41
+ </script>
42
+
43
+ <template>
44
+ <input
45
+ v-model="model"
46
+ type="text"
47
+ data-floating="input"
48
+ :data-size="props.size"
49
+ :aria-label="props.ariaLabel"
50
+ v-bind="omitClass(attrs)"
51
+ :class="inputClass"
52
+ />
53
+ </template>
@@ -1,5 +1,5 @@
1
1
  import type { InjectionKey, Ref } from 'vue';
2
- import type { UiFloatActionItemsValue } from './types';
2
+ import type { UiFloatActionItemsSize, UiFloatActionItemsValue } from './types';
3
3
 
4
4
  /** Metadata a child item shares with the toolbar when it registers. */
5
5
  export interface FloatActionItemRegistration {
@@ -21,6 +21,8 @@ export interface FloatActionItemContext {
21
21
  getTabIndex: (id: symbol) => number;
22
22
  /** Keyboard navigation direction for the toolbar. */
23
23
  orientation: Ref<'horizontal' | 'vertical'>;
24
+ /** Toolbar size, inherited by items that don't set their own. */
25
+ size: Ref<UiFloatActionItemsSize | undefined>;
24
26
  /** Whether the toolbar is a `v-model`-driven single-select control. */
25
27
  hasModel: Ref<boolean>;
26
28
  /** Currently selected value when the toolbar is `v-model`-driven. */
@@ -1,5 +1,5 @@
1
1
  import type { Placement } from '@floating-ui/vue';
2
- import type { HTMLAttributes } from 'vue';
2
+ import type { Component, HTMLAttributes } from 'vue';
3
3
  import type {
4
4
  AnchorFloatOffset,
5
5
  AnchorFloatTrigger,
@@ -91,11 +91,24 @@ export interface UiFloatActionsProps {
91
91
  ariaLabel?: string;
92
92
  }
93
93
 
94
- /** Item role within a {@link UiFloatActionItems} toolbar. */
94
+ /**
95
+ * Item role within a {@link UiFloatActionItems} toolbar.
96
+ *
97
+ * Predefined types follow the Figma "Floating Action" spec and ship their own
98
+ * desktop and mobile styles:
99
+ * - `label` — text with optional prefix / suffix icons
100
+ * - `icon` — icon-only action
101
+ * - `input` — previous button, centered field, next button
102
+ *
103
+ * Composition types let you build any layout yourself:
104
+ * `button`, `text`, `group`, and `separator`.
105
+ */
95
106
  export type UiFloatActionItemsType =
96
107
  | 'toolbar'
97
- | 'button'
108
+ | 'label'
109
+ | 'icon'
98
110
  | 'input'
111
+ | 'button'
99
112
  | 'text'
100
113
  | 'group'
101
114
  | 'separator';
@@ -103,18 +116,31 @@ export type UiFloatActionItemsType =
103
116
  /** Arrow-key navigation direction for toolbar roving focus. */
104
117
  export type UiFloatActionItemsOrientation = 'horizontal' | 'vertical';
105
118
 
106
- /** Value identifying a selectable `button` item within a toolbar. */
119
+ /**
120
+ * Size of floating action items.
121
+ * - `md` — 36px controls (28px on mobile)
122
+ * - `xs` — 24px controls
123
+ */
124
+ export type UiFloatActionItemsSize = 'xs' | 'md';
125
+
126
+ /** Icon accepted by predefined items: a Lucide icon name or a brand icon component. */
127
+ export type UiFloatActionItemsIcon = string | Component;
128
+
129
+ /** Value identifying a selectable item, or the text of an `input` item. */
107
130
  export type UiFloatActionItemsValue = string | number;
108
131
 
109
132
  /**
110
133
  * Pill-shaped floating toolbar and its action items.
111
134
  *
112
- * Use the root item (`type="toolbar"`) as the container and nest child items
113
- * for buttons, inputs, text labels, groups, and separators. Implements the
114
- * WAI-ARIA APG toolbar pattern with roving tabindex.
135
+ * Use the root item (`type="toolbar"`) as the container and nest child items.
136
+ * Pick a predefined type (`label`, `icon`, `input`) to get the design-system
137
+ * look with desktop and mobile styles out of the box, or compose your own
138
+ * layout with `button`, `text`, `group`, and `separator`. Both approaches can
139
+ * be mixed in one toolbar. Implements the WAI-ARIA APG toolbar pattern with
140
+ * roving tabindex.
115
141
  * @category Overlays
116
142
  * @useCases contextual toolbar, inline actions, pagination controls, filter bar
117
- * @keywords float, toolbar, pill, actions, keyboard, roving focus
143
+ * @keywords float, toolbar, pill, actions, keyboard, roving focus, label, icon, input
118
144
  * @related UiFloatActions, useAnchorFloat
119
145
  */
120
146
  export interface UiFloatActionItemsProps {
@@ -126,13 +152,66 @@ export interface UiFloatActionItemsProps {
126
152
  type?: UiFloatActionItemsType;
127
153
 
128
154
  /**
129
- * Disables interaction for `button` and `input` items.
155
+ * Item size. Set it on the `toolbar` to size every nested item at once;
156
+ * a size on an individual item overrides the toolbar.
157
+ * @default 'md'
158
+ */
159
+ size?: UiFloatActionItemsSize;
160
+
161
+ /**
162
+ * Icon for `icon` items. Rendered at 20px (`md`) or 16px (`xs`).
163
+ */
164
+ icon?: UiFloatActionItemsIcon;
165
+
166
+ /**
167
+ * Icon rendered before the text of a `label` item (16px).
168
+ */
169
+ prefixIcon?: UiFloatActionItemsIcon;
170
+
171
+ /**
172
+ * Icon rendered after the text of a `label` item (16px).
173
+ */
174
+ suffixIcon?: UiFloatActionItemsIcon;
175
+
176
+ /**
177
+ * Icon of the previous button in an `input` item.
178
+ * Defaults to `chevron-left`, or `chevron-up` in a vertical toolbar.
179
+ */
180
+ previousIcon?: UiFloatActionItemsIcon;
181
+
182
+ /**
183
+ * Icon of the next button in an `input` item.
184
+ * Defaults to `chevron-right`, or `chevron-down` in a vertical toolbar.
185
+ */
186
+ nextIcon?: UiFloatActionItemsIcon;
187
+
188
+ /**
189
+ * Accessible label of the previous button in an `input` item.
190
+ * @default 'Previous'
191
+ */
192
+ previousAriaLabel?: string;
193
+
194
+ /**
195
+ * Accessible label of the next button in an `input` item.
196
+ * @default 'Next'
197
+ */
198
+ nextAriaLabel?: string;
199
+
200
+ /**
201
+ * Classes for the previous / field / next wrapper of an `input` item.
202
+ * `class` on an `input` item styles the text field itself.
203
+ */
204
+ groupClass?: HTMLAttributes['class'];
205
+
206
+ /**
207
+ * Disables interaction for `button`, `label`, `icon`, and `input` items.
130
208
  * @default false
131
209
  */
132
210
  disabled?: boolean;
133
211
 
134
212
  /**
135
- * Accessible label for `toolbar`, `button`, and `input` items.
213
+ * Accessible label for `toolbar`, `button`, `icon`, and `input` items
214
+ * (for `input` it names the text field).
136
215
  * **Required** for those types — icon-only buttons have no visible text.
137
216
  */
138
217
  ariaLabel?: string;
@@ -149,22 +228,23 @@ export interface UiFloatActionItemsProps {
149
228
  placeholder?: string;
150
229
 
151
230
  /**
152
- * Selected item value for the `toolbar` container.
153
- * Use `v-model` to turn the toolbar into a single-select control: the active
154
- * `button` item (the one whose `value` matches) gets a sliding background
155
- * indicator. Omit for a plain, stateless action bar.
231
+ * - On a `toolbar`: the selected item value. Use `v-model` to turn the
232
+ * toolbar into a single-select control: the active `button`, `label`, or
233
+ * `icon` item (the one whose `value` matches) gets a sliding background
234
+ * indicator. Omit for a plain, stateless action bar.
235
+ * - On an `input` item: the text of the field (`v-model`).
156
236
  * @example
157
237
  * ```vue
158
238
  * <UiFloatActionItems v-model="view" aria-label="View">
159
- * <UiFloatActionItems type="button" value="grid" aria-label="Grid" />
160
- * <UiFloatActionItems type="button" value="list" aria-label="List" />
239
+ * <UiFloatActionItems type="icon" icon="grid" value="grid" aria-label="Grid" />
240
+ * <UiFloatActionItems type="icon" icon="list" value="list" aria-label="List" />
161
241
  * </UiFloatActionItems>
162
242
  * ```
163
243
  */
164
244
  modelValue?: UiFloatActionItemsValue;
165
245
 
166
246
  /**
167
- * Value of a selectable `button` item.
247
+ * Value of a selectable `button`, `label`, or `icon` item.
168
248
  * When the parent toolbar uses `v-model`, clicking this item selects its
169
249
  * `value` and moves the active indicator onto it.
170
250
  */
@@ -173,9 +253,16 @@ export interface UiFloatActionItemsProps {
173
253
 
174
254
  /** Events emitted by {@link UiFloatActionItems}. */
175
255
  export interface UiFloatActionItemsEmits {
176
- /** Emitted when a `button` item is activated. */
256
+ /** Emitted when a `button`, `label`, or `icon` item is activated. */
177
257
  click: [event: MouseEvent];
178
- /** Emitted by a `toolbar` with `v-model` when the selected value changes. */
258
+ /** Emitted when the previous button of an `input` item is activated. */
259
+ previous: [event: MouseEvent];
260
+ /** Emitted when the next button of an `input` item is activated. */
261
+ next: [event: MouseEvent];
262
+ /**
263
+ * Emitted by a `toolbar` with `v-model` when the selected value changes, or
264
+ * by an `input` item when its text changes.
265
+ */
179
266
  'update:modelValue': [value: UiFloatActionItemsValue];
180
267
  }
181
268
 
@@ -316,24 +316,24 @@ export const Accessibility: Story = {
316
316
 
317
317
  <div class="flex flex-col gap-6">
318
318
  <div class="flex flex-col gap-2">
319
- <h3 class="body-16-medium text-content-on-surface-primary">
319
+ <h3 class="body-m-medium text-content-on-surface-primary">
320
320
  Requirements
321
321
  </h3>
322
- <ul class="body-16-regular list-disc pl-5 text-content-on-surface-primary">
323
- <li>The component renders a <code class="label-14-regular">main</code> element by default, so the content column is the page's <code class="label-14-regular">main</code> landmark (WCAG 1.3.1 Info and Relationships) and screen-reader users can jump straight to it (WCAG 2.4.1 Bypass Blocks). Keep the default when the column holds the page's primary content.</li>
324
- <li>A page may expose only one visible <code class="label-14-regular">main</code> landmark. If the shell already provides one, pass a different tag via <code class="label-14-regular">as</code> instead of nesting a second <code class="label-14-regular">main</code>.</li>
325
- <li>Choose the <code class="label-14-regular">as</code> tag for its semantics, not its styling — every tag renders identically here. A generic tag like <code class="label-14-regular">div</code> carries no landmark; if the column should stay a landmark, use a sectioning tag and name it (e.g. <code class="label-14-regular">as="section"</code> with <code class="label-14-regular">aria-label</code>), since an unnamed <code class="label-14-regular">section</code> is not exposed as a region.</li>
322
+ <ul class="body-m-regular list-disc pl-5 text-content-on-surface-primary">
323
+ <li>The component renders a <code class="label-s-regular">main</code> element by default, so the content column is the page's <code class="label-s-regular">main</code> landmark (WCAG 1.3.1 Info and Relationships) and screen-reader users can jump straight to it (WCAG 2.4.1 Bypass Blocks). Keep the default when the column holds the page's primary content.</li>
324
+ <li>A page may expose only one visible <code class="label-s-regular">main</code> landmark. If the shell already provides one, pass a different tag via <code class="label-s-regular">as</code> instead of nesting a second <code class="label-s-regular">main</code>.</li>
325
+ <li>Choose the <code class="label-s-regular">as</code> tag for its semantics, not its styling — every tag renders identically here. A generic tag like <code class="label-s-regular">div</code> carries no landmark; if the column should stay a landmark, use a sectioning tag and name it (e.g. <code class="label-s-regular">as="section"</code> with <code class="label-s-regular">aria-label</code>), since an unnamed <code class="label-s-regular">section</code> is not exposed as a region.</li>
326
326
  <li>The component brings no accessible name, heading, or focusable target of its own — the page's heading structure and controls come from your content.</li>
327
327
  <li>The margins and the 12-column grid are visual only. Keep DOM order matching reading order inside the column, so the sequence stays meaningful without the grid (WCAG 1.3.2 Meaningful Sequence).</li>
328
- <li>Span columns with <code class="label-14-regular">col-span-*</code> rather than fixed widths, so content reflows at 200% resize text and 400% reflow instead of clipping (WCAG 1.4.4, 1.4.10).</li>
328
+ <li>Span columns with <code class="label-s-regular">col-span-*</code> rather than fixed widths, so content reflows at 200% resize text and 400% reflow instead of clipping (WCAG 1.4.4, 1.4.10).</li>
329
329
  </ul>
330
330
  </div>
331
331
 
332
332
  <div class="flex flex-col gap-2">
333
- <h3 class="body-16-medium text-content-on-surface-primary">
333
+ <h3 class="body-m-medium text-content-on-surface-primary">
334
334
  Enable accessibility theme
335
335
  </h3>
336
- <p class="body-16-regular text-content-on-surface-primary">
336
+ <p class="body-m-regular text-content-on-surface-primary">
337
337
  When accessibility is required, enable our accessibility theme. This
338
338
  increases contrast and ensures there are no color contrast issues.
339
339
  </p>
@@ -342,7 +342,7 @@ export const Accessibility: Story = {
342
342
 
343
343
  <div class="flex flex-col gap-4">
344
344
  <div class="flex flex-col gap-3">
345
- <h3 class="label-16-medium text-content-on-surface-primary">
345
+ <h3 class="label-m-medium text-content-on-surface-primary">
346
346
  Default
347
347
  </h3>
348
348
  <UiLayoutContent class="rounded-md bg-background-surface-secondary shadow-lg">
@@ -351,7 +351,7 @@ export const Accessibility: Story = {
351
351
  </div>
352
352
 
353
353
  <div class="accessible-theme flex flex-col gap-3">
354
- <h3 class="label-16-medium text-content-on-surface-primary">
354
+ <h3 class="label-m-medium text-content-on-surface-primary">
355
355
  Accessible
356
356
  </h3>
357
357
  <!-- as="section" + aria-label: the page already has a main landmark
@@ -713,15 +713,15 @@ const MODE_SWITCH_CARD = `
713
713
  <UiRadioGroup v-model="layout" name="content-mode" aria-label="Content mode">
714
714
  <div class="flex items-center gap-x-2">
715
715
  <UiRadioGroupItem id="mode-focus" value="focus" />
716
- <label for="mode-focus" class="label-14-medium">Focus — twelve columns</label>
716
+ <label for="mode-focus" class="label-s-medium">Focus — twelve columns</label>
717
717
  </div>
718
718
  <div class="flex items-center gap-x-2">
719
719
  <UiRadioGroupItem id="mode-split" value="split" />
720
- <label for="mode-split" class="label-14-medium">Split — two six-column parts</label>
720
+ <label for="mode-split" class="label-s-medium">Split — two six-column parts</label>
721
721
  </div>
722
722
  <div class="flex items-center gap-x-2">
723
723
  <UiRadioGroupItem id="mode-sidebar" value="sidebar" />
724
- <label for="mode-sidebar" class="label-14-medium">Sidebar — secondary content</label>
724
+ <label for="mode-sidebar" class="label-s-medium">Sidebar — secondary content</label>
725
725
  </div>
726
726
  </UiRadioGroup>
727
727
 
@@ -736,21 +736,21 @@ const MODE_SWITCH_CARD = `
736
736
  >
737
737
  <div class="flex items-center gap-x-2">
738
738
  <UiRadioGroupItem id="sidebar-default" value="default" />
739
- <label for="sidebar-default" class="label-14-medium">Default — 8 to 4</label>
739
+ <label for="sidebar-default" class="label-s-medium">Default — 8 to 4</label>
740
740
  </div>
741
741
  <div class="flex items-center gap-x-2">
742
742
  <UiRadioGroupItem id="sidebar-wide" value="wide" />
743
- <label for="sidebar-wide" class="label-14-medium">Wide — 7 to 5</label>
743
+ <label for="sidebar-wide" class="label-s-medium">Wide — 7 to 5</label>
744
744
  </div>
745
745
  <div class="flex items-center gap-x-2">
746
746
  <UiRadioGroupItem id="sidebar-max" value="max" />
747
- <label for="sidebar-max" class="label-14-medium">Max — 6 to 6</label>
747
+ <label for="sidebar-max" class="label-s-medium">Max — 6 to 6</label>
748
748
  </div>
749
749
  </UiRadioGroup>
750
750
 
751
751
  <!-- The region is replaced without focus moving, so the new arrangement
752
752
  is announced rather than changing silently (WCAG 4.1.3). -->
753
- <p role="status" class="body-12-regular text-content-on-surface-muted">
753
+ <p role="status" class="label-xs-regular text-content-on-surface-muted">
754
754
  {{ layoutStatus }}
755
755
  </p>
756
756
  </UiCardContent>