@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.
- package/dist/system/components/UiFileItem/UiFileItem.vue.d.ts +10 -1
- package/dist/system/components/UiFileItem/index.d.ts +1 -1
- package/dist/system/components/UiFileItem/types.d.ts +81 -5
- package/dist/system/components/UiPopover/UiPopoverContent.vue.d.ts +1 -0
- package/dist/system/components/UiPopover/types.d.ts +6 -0
- package/dist/system/components/core/popover/PopoverContent.vue.d.ts +1 -0
- package/dist/system/components/core/toggle/index.d.ts +1 -1
- package/dist/system/lib.js +12336 -12055
- package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +21 -174
- package/dist/system/patterns/UiFloatActions/core/FloatingButton.vue.d.ts +36 -0
- package/dist/system/patterns/UiFloatActions/core/FloatingInput.vue.d.ts +19 -0
- package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +3 -1
- package/dist/system/patterns/UiFloatActions/types.d.ts +93 -19
- package/dist/system/patterns/UiLayout/layout-shell.d.ts +117 -252
- package/package.json +2 -2
- package/src/components/UiAccordion/UiAccordion.stories.ts +8 -8
- package/src/components/UiAlert/UiAlert.stories.ts +13 -13
- package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +4 -4
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +13 -13
- package/src/components/UiAutocomplete/UiAutocomplete.vue +3 -3
- package/src/components/UiBadge/UiBadge.stories.ts +9 -9
- package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +14 -14
- package/src/components/UiButton/UiButton.stories.ts +35 -35
- package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +6 -6
- package/src/components/UiCalendar/UiCalendar.stories.ts +6 -6
- package/src/components/UiCard/UiCard.stories.ts +6 -6
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +30 -30
- package/src/components/UiChip/UiChip.stories.ts +14 -14
- package/src/components/UiChip/UiChip.vue +1 -1
- package/src/components/UiDialog/UiDialog.stories.ts +20 -20
- package/src/components/UiDrawer/UiDrawer.stories.ts +29 -29
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +13 -13
- package/src/components/UiEmpty/UiEmpty.vue +1 -1
- package/src/components/UiFadeMask/UiFadeMask.stories.ts +13 -13
- package/src/components/UiField/UiField.stories.ts +27 -27
- package/src/components/UiFileItem/UiFileItem.vue +114 -9
- package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +54 -2
- package/src/components/UiFileItem/index.ts +1 -0
- package/src/components/UiFileItem/types.ts +82 -5
- package/src/components/UiFileType/UiFileType.stories.ts +10 -10
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +10 -10
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +3 -3
- package/src/components/UiIcon/UiIcon.stories.ts +9 -9
- package/src/components/UiInput/UiInput.stories.ts +13 -13
- package/src/components/UiInput/UiInput.vue +1 -1
- package/src/components/UiInputGroup/UiInputGroup.stories.ts +10 -10
- package/src/components/UiItem/UiItem.stories.ts +12 -12
- package/src/components/UiItem/__tests__/UiItem.test.ts +2 -2
- package/src/components/UiKbd/UiKbd.stories.ts +18 -18
- package/src/components/UiKbd/UiKbd.vue +1 -1
- package/src/components/UiLabel/UiLabel.stories.ts +12 -12
- package/src/components/UiLabel/__tests__/UiLabel.test.ts +1 -1
- package/src/components/UiListbox/UiListbox.stories.ts +20 -20
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +94 -94
- package/src/components/UiPopover/UiPopover.stories.ts +168 -27
- package/src/components/UiPopover/UiPopoverContent.vue +2 -0
- package/src/components/UiPopover/__tests__/UiPopover.test.ts +48 -0
- package/src/components/UiPopover/types.ts +7 -0
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +53 -53
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +6 -6
- package/src/components/UiResizable/UiResizable.stories.ts +40 -40
- package/src/components/UiSelect/UiSelect.stories.ts +14 -14
- package/src/components/UiSeparator/UiSeparator.stories.ts +16 -16
- package/src/components/UiSheet/UiSheet.stories.ts +29 -29
- package/src/components/UiSlider/UiSlider.stories.ts +28 -28
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +6 -6
- package/src/components/UiSnackbar/UiSnackbar.vue +2 -2
- package/src/components/UiSnackbar/UiSnackbarContent.vue +2 -2
- package/src/components/UiSpinner/UiSpinner.stories.ts +8 -8
- package/src/components/UiStepper/UiStepper.stories.ts +6 -6
- package/src/components/UiSwitch/UiSwitch.stories.ts +37 -37
- package/src/components/UiTable/UiTable.stories.ts +4 -4
- package/src/components/UiTabs/UiTabs.stories.ts +64 -64
- package/src/components/UiTagsInput/UiTagsInput.stories.ts +16 -16
- package/src/components/UiTextarea/UiTextarea.stories.ts +20 -20
- package/src/components/UiToggle/UiToggle.stories.ts +26 -26
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +31 -31
- package/src/components/UiTooltip/UiTooltip.stories.ts +7 -7
- package/src/components/core/accordion/AccordionContent.vue +1 -1
- package/src/components/core/accordion/AccordionTrigger.vue +1 -1
- package/src/components/core/alert/AlertDescription.vue +1 -1
- package/src/components/core/alert/index.ts +1 -1
- package/src/components/core/alert-dialog/AlertDialogDescription.vue +1 -1
- package/src/components/core/badge/index.ts +2 -2
- package/src/components/core/button/index.ts +3 -3
- package/src/components/core/calendar/Calendar.vue +4 -4
- package/src/components/core/calendar/CalendarCell.vue +1 -1
- package/src/components/core/calendar/CalendarHeading.vue +1 -1
- package/src/components/core/card/CardDescription.vue +1 -1
- package/src/components/core/dialog/DialogDescription.vue +1 -1
- package/src/components/core/drawer/DrawerDescription.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuLabel.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuRadioItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuShortcut.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
- package/src/components/core/field/FieldDescription.vue +1 -1
- package/src/components/core/field/FieldError.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +1 -1
- package/src/components/core/field/FieldLegend.vue +2 -2
- package/src/components/core/field/FieldSeparator.vue +1 -1
- package/src/components/core/field/FieldTitle.vue +1 -1
- package/src/components/core/input/Input.vue +1 -1
- package/src/components/core/input-group/InputGroupText.vue +1 -1
- package/src/components/core/input-group/index.ts +1 -1
- package/src/components/core/item/ItemDescription.vue +1 -1
- package/src/components/core/item/ItemTitle.vue +1 -1
- package/src/components/core/item/index.ts +2 -2
- package/src/components/core/label/Label.vue +1 -1
- package/src/components/core/listbox/ListboxFilter.vue +1 -1
- package/src/components/core/listbox/ListboxGroupLabel.vue +1 -1
- package/src/components/core/listbox/ListboxItem.vue +1 -1
- package/src/components/core/native-select/NativeSelect.vue +1 -1
- package/src/components/core/navigation-menu/NavigationMenuLink.vue +1 -1
- package/src/components/core/navigation-menu/index.ts +1 -1
- package/src/components/core/popover/PopoverContent.vue +9 -3
- package/src/components/core/range-calendar/RangeCalendarCell.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendarHeading.vue +1 -1
- package/src/components/core/select/SelectItem.vue +1 -1
- package/src/components/core/select/SelectLabel.vue +1 -1
- package/src/components/core/select/SelectTrigger.vue +1 -1
- package/src/components/core/sheet/SheetDescription.vue +1 -1
- package/src/components/core/sidebar/SidebarGroupContent.vue +1 -1
- package/src/components/core/sidebar/SidebarGroupLabel.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuBadge.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuSubButton.vue +2 -2
- package/src/components/core/sidebar/index.ts +4 -4
- package/src/components/core/stepper/StepperDescription.vue +1 -1
- package/src/components/core/stepper/StepperTitle.vue +1 -1
- package/src/components/core/table/Table.vue +1 -1
- package/src/components/core/table/TableCaption.vue +1 -1
- package/src/components/core/table/TableEmpty.vue +1 -1
- package/src/components/core/tabs/TabsTrigger.vue +1 -1
- package/src/components/core/tags-input/TagsInput.vue +1 -1
- package/src/components/core/tags-input/TagsInputItem.vue +1 -1
- package/src/components/core/textarea/Textarea.vue +1 -1
- package/src/components/core/toggle/index.ts +1 -1
- package/src/components/core/tooltip/TooltipContent.vue +1 -1
- package/src/directives/vHover.stories.ts +17 -17
- package/src/lib/useDevice.stories.ts +29 -29
- package/src/lib/useDrag.stories.ts +14 -14
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +27 -27
- package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +2 -2
- package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +2 -2
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +3 -3
- package/src/patterns/UiDataTable/__tests__/UiDataTableColumnFilter.test.ts +2 -2
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +14 -14
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +818 -32
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +194 -12
- package/src/patterns/UiFloatActions/UiFloatActionItems.vue +226 -76
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +1136 -116
- package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +187 -1
- package/src/patterns/UiFloatActions/core/FloatingButton.vue +83 -0
- package/src/patterns/UiFloatActions/core/FloatingInput.vue +53 -0
- package/src/patterns/UiFloatActions/floatActionItemContext.ts +3 -1
- package/src/patterns/UiFloatActions/types.ts +106 -19
- package/src/patterns/UiLayout/UiLayoutContent.stories.ts +17 -17
- package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +4 -4
- package/src/patterns/UiLayout/layout-shell.ts +6 -6
- package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +8 -8
- package/src/patterns/UiProfileCard/profile-card.ts +2 -2
- package/src/patterns/UiSidebar/UiSidebar.stories.ts +6 -6
- package/src/patterns/UiSidebar/UiSidebarGroup.stories.ts +1 -1
- package/src/patterns/UiSidebar/UiSidebarGroupLabel.stories.ts +4 -4
- package/src/patterns/UiSidebar/UiSidebarGroupLabel.vue +1 -1
- package/src/patterns/UiSidebar/UiSidebarHeader.vue +1 -1
- package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +7 -7
- package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +4 -4
- package/src/patterns/UiSidebar/UiSidebarMenuItem.stories.ts +4 -4
- package/src/patterns/UiSidebar/UiSidebarMenuSubItem.stories.ts +1 -1
- package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +1 -1
- package/src/patterns/UiSidebar/UiSidebarPopoverMenu.vue +1 -1
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +3 -3
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.stories.ts +1 -1
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +1 -1
- package/src/patterns/UiSidebar/UiSidebarSub.stories.ts +1 -1
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +24 -24
- package/src/theme/Background.stories.ts +62 -62
- package/src/theme/Border.stories.ts +19 -19
- package/src/theme/BorderRadius.stories.ts +14 -14
- package/src/theme/Extended.stories.ts +26 -26
- package/src/theme/Flex.stories.ts +21 -21
- package/src/theme/Grid.stories.ts +19 -19
- package/src/theme/HoverLayer.stories.ts +26 -26
- package/src/theme/Overlay.stories.ts +14 -14
- package/src/theme/Scrollbar.stories.ts +58 -58
- package/src/theme/Shadow.stories.ts +5 -5
- 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
|
-
*
|
|
7
|
-
*
|
|
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' | '
|
|
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} [
|
|
18
|
-
*
|
|
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
|
-
*
|
|
21
|
-
* @example
|
|
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="
|
|
24
|
-
* <UiFloatActionItems type="
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
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
|
|
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"
|
|
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"
|
|
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 {
|
|
62
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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(
|
|
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(
|
|
227
|
-
}
|
|
228
|
-
{ immediate: true },
|
|
229
|
-
);
|
|
273
|
+
parentContext.unregisterItem(id);
|
|
274
|
+
});
|
|
230
275
|
|
|
231
|
-
|
|
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
|
-
|
|
324
|
-
|
|
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-
|
|
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
|
|
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
|
|
359
|
-
cn(
|
|
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
|
|
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(
|
|
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
|
-
<
|
|
404
|
-
v-else-if="
|
|
405
|
-
ref="
|
|
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="
|
|
414
|
-
@focus="
|
|
508
|
+
:tabindex="mainControl.tabIndex.value"
|
|
509
|
+
:class="attrs.class ?? ''"
|
|
510
|
+
@focus="mainControl.onFocus"
|
|
415
511
|
@click="onButtonClick"
|
|
416
512
|
>
|
|
417
513
|
<slot />
|
|
418
|
-
</
|
|
514
|
+
</FloatingButton>
|
|
419
515
|
|
|
420
|
-
<
|
|
516
|
+
<div
|
|
421
517
|
v-else-if="isInput"
|
|
422
|
-
|
|
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
|
-
|
|
566
|
+
:data-size="resolvedSize"
|
|
425
567
|
:aria-label="props.ariaLabel"
|
|
426
|
-
:
|
|
568
|
+
:aria-pressed="isSelectable ? isActive : undefined"
|
|
427
569
|
:disabled="props.disabled"
|
|
428
|
-
:tabindex="tabIndex"
|
|
429
|
-
:class="
|
|
430
|
-
|
|
431
|
-
@
|
|
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
|
|
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>
|