@aleph-alpha/ui-library 6.4.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 (188) hide show
  1. package/dist/system/components/UiFileItem/UiFileItem.vue.d.ts +10 -1
  2. package/dist/system/components/UiFileItem/index.d.ts +1 -1
  3. package/dist/system/components/UiFileItem/types.d.ts +81 -5
  4. package/dist/system/components/UiPopover/UiPopoverContent.vue.d.ts +1 -0
  5. package/dist/system/components/UiPopover/types.d.ts +6 -0
  6. package/dist/system/components/core/popover/PopoverContent.vue.d.ts +1 -0
  7. package/dist/system/components/core/toggle/index.d.ts +1 -1
  8. package/dist/system/lib.js +12336 -12055
  9. package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +21 -174
  10. package/dist/system/patterns/UiFloatActions/core/FloatingButton.vue.d.ts +36 -0
  11. package/dist/system/patterns/UiFloatActions/core/FloatingInput.vue.d.ts +19 -0
  12. package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +3 -1
  13. package/dist/system/patterns/UiFloatActions/types.d.ts +93 -19
  14. package/dist/system/patterns/UiLayout/layout-shell.d.ts +117 -252
  15. package/package.json +2 -2
  16. package/src/components/UiAccordion/UiAccordion.stories.ts +8 -8
  17. package/src/components/UiAlert/UiAlert.stories.ts +13 -13
  18. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +4 -4
  19. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +13 -13
  20. package/src/components/UiAutocomplete/UiAutocomplete.vue +3 -3
  21. package/src/components/UiBadge/UiBadge.stories.ts +9 -9
  22. package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +14 -14
  23. package/src/components/UiButton/UiButton.stories.ts +35 -35
  24. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +6 -6
  25. package/src/components/UiCalendar/UiCalendar.stories.ts +6 -6
  26. package/src/components/UiCard/UiCard.stories.ts +6 -6
  27. package/src/components/UiCheckbox/UiCheckbox.stories.ts +30 -30
  28. package/src/components/UiChip/UiChip.stories.ts +14 -14
  29. package/src/components/UiChip/UiChip.vue +1 -1
  30. package/src/components/UiDialog/UiDialog.stories.ts +20 -20
  31. package/src/components/UiDrawer/UiDrawer.stories.ts +29 -29
  32. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +13 -13
  33. package/src/components/UiEmpty/UiEmpty.vue +1 -1
  34. package/src/components/UiFadeMask/UiFadeMask.stories.ts +13 -13
  35. package/src/components/UiField/UiField.stories.ts +27 -27
  36. package/src/components/UiFileItem/UiFileItem.vue +114 -9
  37. package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +54 -2
  38. package/src/components/UiFileItem/index.ts +1 -0
  39. package/src/components/UiFileItem/types.ts +82 -5
  40. package/src/components/UiFileType/UiFileType.stories.ts +10 -10
  41. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +10 -10
  42. package/src/components/UiFileUploadBox/UiFileUploadBox.vue +3 -3
  43. package/src/components/UiIcon/UiIcon.stories.ts +9 -9
  44. package/src/components/UiInput/UiInput.stories.ts +13 -13
  45. package/src/components/UiInput/UiInput.vue +1 -1
  46. package/src/components/UiInputGroup/UiInputGroup.stories.ts +10 -10
  47. package/src/components/UiItem/UiItem.stories.ts +12 -12
  48. package/src/components/UiItem/__tests__/UiItem.test.ts +2 -2
  49. package/src/components/UiKbd/UiKbd.stories.ts +18 -18
  50. package/src/components/UiKbd/UiKbd.vue +1 -1
  51. package/src/components/UiLabel/UiLabel.stories.ts +12 -12
  52. package/src/components/UiLabel/__tests__/UiLabel.test.ts +1 -1
  53. package/src/components/UiListbox/UiListbox.stories.ts +20 -20
  54. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +94 -94
  55. package/src/components/UiPopover/UiPopover.stories.ts +168 -27
  56. package/src/components/UiPopover/UiPopoverContent.vue +2 -0
  57. package/src/components/UiPopover/__tests__/UiPopover.test.ts +48 -0
  58. package/src/components/UiPopover/types.ts +7 -0
  59. package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +53 -53
  60. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +6 -6
  61. package/src/components/UiResizable/UiResizable.stories.ts +40 -40
  62. package/src/components/UiSelect/UiSelect.stories.ts +14 -14
  63. package/src/components/UiSeparator/UiSeparator.stories.ts +16 -16
  64. package/src/components/UiSheet/UiSheet.stories.ts +29 -29
  65. package/src/components/UiSlider/UiSlider.stories.ts +28 -28
  66. package/src/components/UiSnackbar/UiSnackbar.stories.ts +6 -6
  67. package/src/components/UiSnackbar/UiSnackbar.vue +2 -2
  68. package/src/components/UiSnackbar/UiSnackbarContent.vue +2 -2
  69. package/src/components/UiSpinner/UiSpinner.stories.ts +8 -8
  70. package/src/components/UiStepper/UiStepper.stories.ts +6 -6
  71. package/src/components/UiSwitch/UiSwitch.stories.ts +37 -37
  72. package/src/components/UiTable/UiTable.stories.ts +4 -4
  73. package/src/components/UiTabs/UiTabs.stories.ts +64 -64
  74. package/src/components/UiTagsInput/UiTagsInput.stories.ts +16 -16
  75. package/src/components/UiTextarea/UiTextarea.stories.ts +20 -20
  76. package/src/components/UiToggle/UiToggle.stories.ts +26 -26
  77. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +31 -31
  78. package/src/components/UiTooltip/UiTooltip.stories.ts +7 -7
  79. package/src/components/core/accordion/AccordionContent.vue +1 -1
  80. package/src/components/core/accordion/AccordionTrigger.vue +1 -1
  81. package/src/components/core/alert/AlertDescription.vue +1 -1
  82. package/src/components/core/alert/index.ts +1 -1
  83. package/src/components/core/alert-dialog/AlertDialogDescription.vue +1 -1
  84. package/src/components/core/badge/index.ts +2 -2
  85. package/src/components/core/button/index.ts +3 -3
  86. package/src/components/core/calendar/Calendar.vue +4 -4
  87. package/src/components/core/calendar/CalendarCell.vue +1 -1
  88. package/src/components/core/calendar/CalendarHeading.vue +1 -1
  89. package/src/components/core/card/CardDescription.vue +1 -1
  90. package/src/components/core/dialog/DialogDescription.vue +1 -1
  91. package/src/components/core/drawer/DrawerDescription.vue +1 -1
  92. package/src/components/core/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
  93. package/src/components/core/dropdown-menu/DropdownMenuLabel.vue +1 -1
  94. package/src/components/core/dropdown-menu/DropdownMenuRadioItem.vue +1 -1
  95. package/src/components/core/dropdown-menu/DropdownMenuShortcut.vue +1 -1
  96. package/src/components/core/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
  97. package/src/components/core/field/FieldDescription.vue +1 -1
  98. package/src/components/core/field/FieldError.vue +1 -1
  99. package/src/components/core/field/FieldLabel.vue +1 -1
  100. package/src/components/core/field/FieldLegend.vue +2 -2
  101. package/src/components/core/field/FieldSeparator.vue +1 -1
  102. package/src/components/core/field/FieldTitle.vue +1 -1
  103. package/src/components/core/input/Input.vue +1 -1
  104. package/src/components/core/input-group/InputGroupText.vue +1 -1
  105. package/src/components/core/input-group/index.ts +1 -1
  106. package/src/components/core/item/ItemDescription.vue +1 -1
  107. package/src/components/core/item/ItemTitle.vue +1 -1
  108. package/src/components/core/item/index.ts +2 -2
  109. package/src/components/core/label/Label.vue +1 -1
  110. package/src/components/core/listbox/ListboxFilter.vue +1 -1
  111. package/src/components/core/listbox/ListboxGroupLabel.vue +1 -1
  112. package/src/components/core/listbox/ListboxItem.vue +1 -1
  113. package/src/components/core/native-select/NativeSelect.vue +1 -1
  114. package/src/components/core/navigation-menu/NavigationMenuLink.vue +1 -1
  115. package/src/components/core/navigation-menu/index.ts +1 -1
  116. package/src/components/core/popover/PopoverContent.vue +9 -3
  117. package/src/components/core/range-calendar/RangeCalendarCell.vue +1 -1
  118. package/src/components/core/range-calendar/RangeCalendarHeading.vue +1 -1
  119. package/src/components/core/select/SelectItem.vue +1 -1
  120. package/src/components/core/select/SelectLabel.vue +1 -1
  121. package/src/components/core/select/SelectTrigger.vue +1 -1
  122. package/src/components/core/sheet/SheetDescription.vue +1 -1
  123. package/src/components/core/sidebar/SidebarGroupContent.vue +1 -1
  124. package/src/components/core/sidebar/SidebarGroupLabel.vue +1 -1
  125. package/src/components/core/sidebar/SidebarMenuBadge.vue +1 -1
  126. package/src/components/core/sidebar/SidebarMenuSubButton.vue +2 -2
  127. package/src/components/core/sidebar/index.ts +4 -4
  128. package/src/components/core/stepper/StepperDescription.vue +1 -1
  129. package/src/components/core/stepper/StepperTitle.vue +1 -1
  130. package/src/components/core/table/Table.vue +1 -1
  131. package/src/components/core/table/TableCaption.vue +1 -1
  132. package/src/components/core/table/TableEmpty.vue +1 -1
  133. package/src/components/core/tabs/TabsTrigger.vue +1 -1
  134. package/src/components/core/tags-input/TagsInput.vue +1 -1
  135. package/src/components/core/tags-input/TagsInputItem.vue +1 -1
  136. package/src/components/core/textarea/Textarea.vue +1 -1
  137. package/src/components/core/toggle/index.ts +1 -1
  138. package/src/components/core/tooltip/TooltipContent.vue +1 -1
  139. package/src/directives/vHover.stories.ts +17 -17
  140. package/src/lib/useDevice.stories.ts +29 -29
  141. package/src/lib/useDrag.stories.ts +14 -14
  142. package/src/patterns/UiDataTable/UiDataTable.stories.ts +27 -27
  143. package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +2 -2
  144. package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +2 -2
  145. package/src/patterns/UiDataTable/UiDataTablePagination.vue +3 -3
  146. package/src/patterns/UiDataTable/__tests__/UiDataTableColumnFilter.test.ts +2 -2
  147. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +14 -14
  148. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +818 -32
  149. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +194 -12
  150. package/src/patterns/UiFloatActions/UiFloatActionItems.vue +226 -76
  151. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +1136 -116
  152. package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +187 -1
  153. package/src/patterns/UiFloatActions/core/FloatingButton.vue +83 -0
  154. package/src/patterns/UiFloatActions/core/FloatingInput.vue +53 -0
  155. package/src/patterns/UiFloatActions/floatActionItemContext.ts +3 -1
  156. package/src/patterns/UiFloatActions/types.ts +106 -19
  157. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +17 -17
  158. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +4 -4
  159. package/src/patterns/UiLayout/layout-shell.ts +6 -6
  160. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +8 -8
  161. package/src/patterns/UiProfileCard/profile-card.ts +2 -2
  162. package/src/patterns/UiSidebar/UiSidebar.stories.ts +6 -6
  163. package/src/patterns/UiSidebar/UiSidebarGroup.stories.ts +1 -1
  164. package/src/patterns/UiSidebar/UiSidebarGroupLabel.stories.ts +4 -4
  165. package/src/patterns/UiSidebar/UiSidebarGroupLabel.vue +1 -1
  166. package/src/patterns/UiSidebar/UiSidebarHeader.vue +1 -1
  167. package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +7 -7
  168. package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +4 -4
  169. package/src/patterns/UiSidebar/UiSidebarMenuItem.stories.ts +4 -4
  170. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.stories.ts +1 -1
  171. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +1 -1
  172. package/src/patterns/UiSidebar/UiSidebarPopoverMenu.vue +1 -1
  173. package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +3 -3
  174. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.stories.ts +1 -1
  175. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +1 -1
  176. package/src/patterns/UiSidebar/UiSidebarSub.stories.ts +1 -1
  177. package/src/patterns/UiTopBar/UiTopBar.stories.ts +24 -24
  178. package/src/theme/Background.stories.ts +62 -62
  179. package/src/theme/Border.stories.ts +19 -19
  180. package/src/theme/BorderRadius.stories.ts +14 -14
  181. package/src/theme/Extended.stories.ts +26 -26
  182. package/src/theme/Flex.stories.ts +21 -21
  183. package/src/theme/Grid.stories.ts +19 -19
  184. package/src/theme/HoverLayer.stories.ts +26 -26
  185. package/src/theme/Overlay.stories.ts +14 -14
  186. package/src/theme/Scrollbar.stories.ts +58 -58
  187. package/src/theme/Shadow.stories.ts +5 -5
  188. package/src/theme/Theme.stories.ts +38 -38
@@ -2,40 +2,61 @@
2
2
  /**
3
3
  * UiFloatActionItems renders a pill-shaped floating toolbar and its action items.
4
4
  *
5
- * Use the root (default `type="toolbar"`) as the container and nest child items
6
- * for buttons, inputs, text labels, groups, and separators. Follows the WAI-ARIA
7
- * APG toolbar pattern with roving arrow-key navigation.
5
+ * Use the root (default `type="toolbar"`) as the container and nest child items.
6
+ * Follows the WAI-ARIA APG toolbar pattern with roving arrow-key navigation.
7
+ *
8
+ * There are two ways to fill the toolbar, and they can be mixed:
9
+ * - **Predefined types** — `label`, `icon`, and `input` follow the design-system
10
+ * spec, including the mobile styles below the `sm` breakpoint. Pass icons and
11
+ * text through props; no extra markup needed.
12
+ * - **Composition types** — `button`, `text`, `group`, and `separator` keep the
13
+ * original API: you supply the slot content (e.g. a `UiIcon`) and layout.
8
14
  * @component UiFloatActionItems
9
- * @property {'toolbar' | 'button' | 'input' | 'text' | 'group' | 'separator'} [type='toolbar'] -
15
+ * @property {'toolbar' | 'label' | 'icon' | 'input' | 'button' | 'text' | 'group' | 'separator'} [type='toolbar'] -
10
16
  * Item role. Omit or use `toolbar` for the root pill container.
17
+ * @property {'xs' | 'md'} [size='md'] -
18
+ * Item size. Set on the toolbar to size every nested item; items can override it.
11
19
  * @property {string} [ariaLabel] -
12
- * Accessible label. **Required** for `toolbar`, `button`, and `input` types.
20
+ * Accessible label. **Required** for `toolbar`, `button`, `icon`, and `input` types.
13
21
  * @property {'horizontal' | 'vertical'} [orientation='horizontal'] -
14
- * Arrow-key navigation direction for toolbar items.
22
+ * Arrow-key navigation direction and layout for toolbar items.
15
23
  * @property {boolean} [disabled=false] -
16
- * Disables interaction for `button` and `input` items.
17
- * @property {string} [placeholder] -
18
- * Placeholder text for `input` items.
24
+ * Disables interaction for `button`, `label`, `icon`, and `input` items.
25
+ * @property {string | Component} [icon] - Icon of an `icon` item.
26
+ * @property {string | Component} [prefixIcon] - Icon before the text of a `label` item.
27
+ * @property {string | Component} [suffixIcon] - Icon after the text of a `label` item.
28
+ * @property {string} [placeholder] - Placeholder text for `input` items.
29
+ * @property {string} [groupClass] -
30
+ * Classes for the previous / field / next wrapper of an `input` item; `class` styles the field.
19
31
  * @slot default
20
- * Icon or label content for `button`, `text`, and `toolbar` items.
21
- * @example Flat action bar
32
+ * Text for `label` items, or content for `button`, `text`, `group`, and `toolbar` items.
33
+ * @example Predefined types
22
34
  * ```vue
23
- * <UiFloatActionItems aria-label="Text actions">
24
- * <UiFloatActionItems type="button" aria-label="Edit">
25
- * <UiIcon name="edit" size="s" />
26
- * </UiFloatActionItems>
27
- * <UiFloatActionItems type="button" aria-label="Copy">
28
- * <UiIcon name="copy" size="s" />
29
- * </UiFloatActionItems>
35
+ * <UiFloatActionItems aria-label="Document actions" size="xs">
36
+ * <UiFloatActionItems type="label" prefix-icon="edit">Edit</UiFloatActionItems>
37
+ * <UiFloatActionItems type="icon" icon="copy" aria-label="Copy" />
38
+ * <UiFloatActionItems
39
+ * v-model="page"
40
+ * type="input"
41
+ * aria-label="Page"
42
+ * previous-aria-label="Previous page"
43
+ * next-aria-label="Next page"
44
+ * @previous="page--"
45
+ * @next="page++"
46
+ * />
30
47
  * </UiFloatActionItems>
31
48
  * ```
32
- * @example Pagination group
49
+ * @example Composition types
33
50
  * ```vue
34
51
  * <UiFloatActionItems aria-label="Pagination">
35
52
  * <UiFloatActionItems type="group">
36
- * <UiFloatActionItems type="button" aria-label="Previous">&lt;</UiFloatActionItems>
53
+ * <UiFloatActionItems type="button" aria-label="Previous">
54
+ * <UiIcon name="chevron-left" size="s" />
55
+ * </UiFloatActionItems>
37
56
  * <UiFloatActionItems type="text">2/2</UiFloatActionItems>
38
- * <UiFloatActionItems type="button" aria-label="Next">&gt;</UiFloatActionItems>
57
+ * <UiFloatActionItems type="button" aria-label="Next">
58
+ * <UiIcon name="chevron-right" size="s" />
59
+ * </UiFloatActionItems>
39
60
  * </UiFloatActionItems>
40
61
  * </UiFloatActionItems>
41
62
  * ```
@@ -50,7 +71,9 @@ import {
50
71
  provide,
51
72
  ref,
52
73
  useAttrs,
74
+ useId,
53
75
  watch,
76
+ type ComponentPublicInstance,
54
77
  } from 'vue';
55
78
  import {
56
79
  FLOAT_ACTION_ITEM_SELECTOR,
@@ -58,8 +81,13 @@ import {
58
81
  type FloatActionItemContext,
59
82
  type FloatActionItemRegistration,
60
83
  } from './floatActionItemContext';
61
- import type { UiFloatActionItemsEmits, UiFloatActionItemsProps } from './types';
62
- import UiInput from '@/components/UiInput/UiInput.vue';
84
+ import type {
85
+ UiFloatActionItemsEmits,
86
+ UiFloatActionItemsProps,
87
+ UiFloatActionItemsValue,
88
+ } from './types';
89
+ import FloatingButton from './core/FloatingButton.vue';
90
+ import FloatingInput from './core/FloatingInput.vue';
63
91
 
64
92
  defineOptions({
65
93
  name: 'UiFloatActionItems',
@@ -68,18 +96,26 @@ defineOptions({
68
96
 
69
97
  const props = withDefaults(defineProps<UiFloatActionItemsProps>(), {
70
98
  type: 'toolbar',
99
+ size: undefined,
71
100
  disabled: false,
72
101
  orientation: 'horizontal',
73
102
  ariaLabel: undefined,
74
103
  placeholder: undefined,
75
104
  modelValue: undefined,
76
105
  value: undefined,
106
+ icon: undefined,
107
+ prefixIcon: undefined,
108
+ suffixIcon: undefined,
109
+ previousIcon: undefined,
110
+ nextIcon: undefined,
111
+ previousAriaLabel: 'Previous',
112
+ nextAriaLabel: 'Next',
113
+ groupClass: undefined,
77
114
  });
78
115
 
79
116
  const emit = defineEmits<UiFloatActionItemsEmits>();
80
117
  const attrs = useAttrs();
81
118
 
82
- const itemId = Symbol('UiFloatActionItems');
83
119
  const itemRef = ref<HTMLElement | null>(null);
84
120
  const parentContext = inject<FloatActionItemContext | null>(
85
121
  FLOAT_ACTION_ITEM_CONTEXT,
@@ -90,11 +126,17 @@ const isToolbar = computed(
90
126
  () => props.type === 'toolbar' || props.type === undefined,
91
127
  );
92
128
  const isButton = computed(() => props.type === 'button');
129
+ const isLabel = computed(() => props.type === 'label');
130
+ const isIcon = computed(() => props.type === 'icon');
93
131
  const isInput = computed(() => props.type === 'input');
94
132
  const isText = computed(() => props.type === 'text');
95
133
  const isGroup = computed(() => props.type === 'group');
96
134
  const isSeparator = computed(() => props.type === 'separator');
97
135
 
136
+ const resolvedSize = computed(
137
+ () => props.size ?? parentContext?.size.value ?? 'md',
138
+ );
139
+
98
140
  const activeIndex = ref(0);
99
141
  type RegisteredItem = FloatActionItemRegistration & {
100
142
  /** Unique id used for roving-tabindex bookkeeping. */
@@ -131,6 +173,7 @@ const toolbarContext: FloatActionItemContext = {
131
173
  return index === activeIndex.value ? 0 : -1;
132
174
  },
133
175
  orientation: toolbarOrientation,
176
+ size: computed(() => props.size),
134
177
  hasModel,
135
178
  modelValue: modelValueRef,
136
179
  select(value) {
@@ -138,10 +181,6 @@ const toolbarContext: FloatActionItemContext = {
138
181
  },
139
182
  };
140
183
 
141
- const inputName = computed(
142
- () => (attrs.name as string) ?? `float-action-input-${itemId.toString()}`,
143
- );
144
-
145
184
  if (isToolbar.value) {
146
185
  provide(FLOAT_ACTION_ITEM_CONTEXT, toolbarContext);
147
186
  }
@@ -212,26 +251,54 @@ if (isToolbar.value) {
212
251
  });
213
252
  }
214
253
 
215
- watch(
216
- itemRef,
217
- (element) => {
218
- if (!parentContext || (!isButton.value && !isInput.value)) return;
254
+ /**
255
+ * Registers one focusable control with the parent toolbar for roving tabindex.
256
+ * Toolbar focus order follows registration order, so an item that renders
257
+ * several controls must create its registrations in DOM order.
258
+ * @param value Getter for the control's selectable value.
259
+ * @returns Template ref setter, roving tabindex, and focus handler.
260
+ */
261
+ function useToolbarRegistration(
262
+ value: () => UiFloatActionItemsValue | undefined,
263
+ ) {
264
+ const id = Symbol('UiFloatActionItems');
265
+ const el = ref<HTMLElement | null>(null);
266
+
267
+ watch(el, (element) => {
268
+ if (!parentContext) return;
219
269
  if (element) {
220
- parentContext.registerItem(itemId, {
221
- el: () => itemRef.value,
222
- value: () => props.value,
223
- });
270
+ parentContext.registerItem(id, { el: () => el.value, value });
224
271
  return;
225
272
  }
226
- parentContext.unregisterItem(itemId);
227
- },
228
- { immediate: true },
229
- );
273
+ parentContext.unregisterItem(id);
274
+ });
230
275
 
231
- // Selectable buttons opt in by declaring a `value` inside a `v-model` toolbar.
276
+ onBeforeUnmount(() => {
277
+ parentContext?.unregisterItem(id);
278
+ });
279
+
280
+ return {
281
+ setRef(target: Element | ComponentPublicInstance | null) {
282
+ const element = target && '$el' in target ? target.$el : target;
283
+ el.value = element instanceof HTMLElement ? element : null;
284
+ },
285
+ tabIndex: computed(() =>
286
+ parentContext ? parentContext.getTabIndex(id) : undefined,
287
+ ),
288
+ onFocus() {
289
+ parentContext?.onItemFocus(id);
290
+ },
291
+ };
292
+ }
293
+
294
+ const previousControl = useToolbarRegistration(() => undefined);
295
+ const mainControl = useToolbarRegistration(() => props.value);
296
+ const nextControl = useToolbarRegistration(() => undefined);
297
+
298
+ // Selectable items opt in by declaring a `value` inside a `v-model` toolbar.
232
299
  const isSelectable = computed(
233
300
  () =>
234
- isButton.value &&
301
+ (isButton.value || isLabel.value || isIcon.value) &&
235
302
  parentContext?.hasModel.value === true &&
236
303
  props.value !== undefined,
237
304
  );
@@ -239,10 +306,6 @@ const isActive = computed(
239
306
  () => isSelectable.value && parentContext?.modelValue.value === props.value,
240
307
  );
241
308
 
242
- onBeforeUnmount(() => {
243
- parentContext?.unregisterItem(itemId);
244
- });
245
-
246
309
  function focusableItems(): HTMLElement[] {
247
310
  const root = itemRef.value;
248
311
  if (!root) return [];
@@ -305,10 +368,6 @@ function onToolbarKeydown(event: KeyboardEvent) {
305
368
  }
306
369
  }
307
370
 
308
- function onItemFocus() {
309
- parentContext?.onItemFocus(itemId);
310
- }
311
-
312
371
  function onButtonClick(event: MouseEvent) {
313
372
  if (props.disabled) {
314
373
  event.preventDefault();
@@ -320,18 +379,41 @@ function onButtonClick(event: MouseEvent) {
320
379
  emit('click', event);
321
380
  }
322
381
 
323
- const tabIndex = computed(() =>
324
- parentContext ? parentContext.getTabIndex(itemId) : undefined,
382
+ // An `input` item follows the toolbar direction: chevrons point left / right in
383
+ // a horizontal toolbar and up / down in a vertical one.
384
+ const isVerticalInput = computed(
385
+ () => (parentContext?.orientation.value ?? props.orientation) === 'vertical',
386
+ );
387
+ const previousIcon = computed(
388
+ () =>
389
+ props.previousIcon ??
390
+ (isVerticalInput.value ? 'chevron-up' : 'chevron-left'),
391
+ );
392
+ const nextIcon = computed(
393
+ () =>
394
+ props.nextIcon ??
395
+ (isVerticalInput.value ? 'chevron-down' : 'chevron-right'),
396
+ );
397
+
398
+ const inputId = useId();
399
+ const inputName = computed(
400
+ () => (attrs.name as string) ?? `float-action-input-${inputId}`,
325
401
  );
326
402
 
403
+ function onInputUpdate(value: UiFloatActionItemsValue | undefined) {
404
+ if (value !== undefined) emit('update:modelValue', value);
405
+ }
406
+
327
407
  // Forward inherited attributes (minus `class`, which is merged via `cn` into the
328
408
  // element class) so a `button` item can compose with wrappers like UiTooltip that
329
409
  // rely on `as-child` to pass event handlers and ARIA attributes to the trigger.
330
410
  const forwardedAttrs = computed(() => omitClass(attrs));
331
411
 
412
+ // Desktop uses the solid floating surface; below `sm` the toolbar switches to
413
+ // the translucent floating-alpha surface from the mobile spec.
332
414
  const toolbarClass = computed(() =>
333
415
  cn(
334
- 'relative inline-flex items-center gap-0.5 rounded-xl-2xl border border-border-surface-default bg-background-surface-floating p-1 shadow-xs',
416
+ 'relative inline-flex items-center gap-0.5 rounded-xl-2xl border border-border-surface-floating bg-background-surface-floating p-1 shadow-xs max-sm:border-border-surface-floating-alpha max-sm:bg-background-surface-floating-alpha',
335
417
  props.orientation === 'vertical' && 'flex-col',
336
418
  attrs.class ?? '',
337
419
  ),
@@ -350,18 +432,24 @@ const indicatorClass = computed(() =>
350
432
 
351
433
  const buttonClass = computed(() =>
352
434
  cn(
353
- 'ui-focus-ring relative inline-flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full border border-transparent bg-transparent text-content-on-surface-muted focus-visible:text-content-on-surface-primary hover:text-content-on-surface-primary transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-pressed:text-content-on-surface-primary',
435
+ 'ui-focus-ring relative inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full border border-transparent bg-transparent text-content-on-surface-muted focus-visible:text-content-on-surface-primary hover:text-content-on-surface-primary transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-pressed:text-content-on-surface-primary',
436
+ resolvedSize.value === 'xs' ? 'h-6 w-6' : 'h-8 w-8',
354
437
  attrs.class ?? '',
355
438
  ),
356
439
  );
357
440
 
358
- const inputClass = computed(() =>
359
- cn('h-8 min-w-16 label-14-regular', attrs.class ?? ''),
441
+ const inputGroupClass = computed(() =>
442
+ cn(
443
+ 'inline-flex items-center gap-1',
444
+ isVerticalInput.value && 'flex-col',
445
+ props.groupClass,
446
+ ),
360
447
  );
361
448
 
362
449
  const textClass = computed(() =>
363
450
  cn(
364
- 'inline-flex h-8 min-w-8 items-center justify-center px-1 label-14-regular text-content-on-surface-muted focus:text-content-on-surface-primary hover:text-content-on-surface-primary',
451
+ 'inline-flex min-w-8 items-center justify-center px-1 label-s-regular text-content-on-surface-muted focus:text-content-on-surface-primary hover:text-content-on-surface-primary',
452
+ resolvedSize.value === 'xs' ? 'h-6' : 'h-8',
365
453
  attrs.class ?? '',
366
454
  ),
367
455
  );
@@ -371,7 +459,11 @@ const groupClass = computed(() =>
371
459
  );
372
460
 
373
461
  const separatorClass = computed(() =>
374
- cn('mx-0.5 h-5 w-px shrink-0 bg-border-surface-default', attrs.class ?? ''),
462
+ cn(
463
+ 'mx-0.5 w-px shrink-0 bg-border-surface-default',
464
+ resolvedSize.value === 'xs' ? 'h-4' : 'h-5',
465
+ attrs.class ?? '',
466
+ ),
375
467
  );
376
468
  </script>
377
469
 
@@ -385,6 +477,7 @@ const separatorClass = computed(() =>
385
477
  ref="itemRef"
386
478
  role="toolbar"
387
479
  data-slot="float-item-toolbar"
480
+ :data-size="resolvedSize"
388
481
  :aria-label="props.ariaLabel"
389
482
  :aria-orientation="toolbarOrientation"
390
483
  :class="toolbarClass"
@@ -400,38 +493,94 @@ const separatorClass = computed(() =>
400
493
  <slot />
401
494
  </div>
402
495
 
403
- <button
404
- v-else-if="isButton"
405
- ref="itemRef"
496
+ <FloatingButton
497
+ v-else-if="isLabel || isIcon"
498
+ :ref="mainControl.setRef"
406
499
  v-bind="forwardedAttrs"
407
- type="button"
408
500
  data-slot="float-item-action"
501
+ :size="resolvedSize"
502
+ :icon="isIcon ? props.icon : undefined"
503
+ :prefix-icon="isLabel ? props.prefixIcon : undefined"
504
+ :suffix-icon="isLabel ? props.suffixIcon : undefined"
409
505
  :aria-label="props.ariaLabel"
410
506
  :aria-pressed="isSelectable ? isActive : undefined"
411
507
  :disabled="props.disabled"
412
- :tabindex="tabIndex"
413
- :class="buttonClass"
414
- @focus="onItemFocus"
508
+ :tabindex="mainControl.tabIndex.value"
509
+ :class="attrs.class ?? ''"
510
+ @focus="mainControl.onFocus"
415
511
  @click="onButtonClick"
416
512
  >
417
513
  <slot />
418
- </button>
514
+ </FloatingButton>
419
515
 
420
- <UiInput
516
+ <div
421
517
  v-else-if="isInput"
422
- ref="itemRef"
518
+ data-slot="float-item-input"
519
+ :data-size="resolvedSize"
520
+ :class="inputGroupClass"
521
+ >
522
+ <FloatingButton
523
+ :ref="previousControl.setRef"
524
+ data-slot="float-item-action"
525
+ :size="resolvedSize"
526
+ :icon="previousIcon"
527
+ :aria-label="props.previousAriaLabel"
528
+ :disabled="props.disabled"
529
+ :tabindex="previousControl.tabIndex.value"
530
+ @focus="previousControl.onFocus"
531
+ @click="emit('previous', $event)"
532
+ />
533
+ <FloatingInput
534
+ :ref="mainControl.setRef"
535
+ data-slot="float-item-action"
536
+ :size="resolvedSize"
537
+ :model-value="props.modelValue"
538
+ :name="inputName"
539
+ :aria-label="props.ariaLabel"
540
+ :placeholder="props.placeholder"
541
+ :disabled="props.disabled"
542
+ :tabindex="mainControl.tabIndex.value"
543
+ :class="attrs.class ?? ''"
544
+ @focus="mainControl.onFocus"
545
+ @update:model-value="onInputUpdate"
546
+ />
547
+ <FloatingButton
548
+ :ref="nextControl.setRef"
549
+ data-slot="float-item-action"
550
+ :size="resolvedSize"
551
+ :icon="nextIcon"
552
+ :aria-label="props.nextAriaLabel"
553
+ :disabled="props.disabled"
554
+ :tabindex="nextControl.tabIndex.value"
555
+ @focus="nextControl.onFocus"
556
+ @click="emit('next', $event)"
557
+ />
558
+ </div>
559
+
560
+ <button
561
+ v-else-if="isButton"
562
+ :ref="mainControl.setRef"
563
+ v-bind="forwardedAttrs"
564
+ type="button"
423
565
  data-slot="float-item-action"
424
- type="text"
566
+ :data-size="resolvedSize"
425
567
  :aria-label="props.ariaLabel"
426
- :placeholder="props.placeholder"
568
+ :aria-pressed="isSelectable ? isActive : undefined"
427
569
  :disabled="props.disabled"
428
- :tabindex="tabIndex"
429
- :class="inputClass"
430
- :name="inputName"
431
- @focus="onItemFocus"
432
- />
570
+ :tabindex="mainControl.tabIndex.value"
571
+ :class="buttonClass"
572
+ @focus="mainControl.onFocus"
573
+ @click="onButtonClick"
574
+ >
575
+ <slot />
576
+ </button>
433
577
 
434
- <span v-else-if="isText" data-slot="float-item-text" :class="textClass">
578
+ <span
579
+ v-else-if="isText"
580
+ data-slot="float-item-text"
581
+ :data-size="resolvedSize"
582
+ :class="textClass"
583
+ >
435
584
  <slot />
436
585
  </span>
437
586
 
@@ -449,6 +598,7 @@ const separatorClass = computed(() =>
449
598
  role="separator"
450
599
  aria-orientation="vertical"
451
600
  data-slot="float-item-separator"
601
+ :data-size="resolvedSize"
452
602
  :class="separatorClass"
453
603
  />
454
604
  </template>