@servicetitan/anvil2 1.45.2 → 1.46.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/CHANGELOG.md +12 -0
- package/dist/{Calendar-BK861SAW.js → Calendar-BQ5F2ENO.js} +2 -2
- package/dist/{Calendar-BK861SAW.js.map → Calendar-BQ5F2ENO.js.map} +1 -1
- package/dist/Calendar.js +1 -1
- package/dist/{Checkbox-ZphVb1l0.js → Checkbox-DDrmVC-u.js} +2 -2
- package/dist/{Checkbox-ZphVb1l0.js.map → Checkbox-DDrmVC-u.js.map} +1 -1
- package/dist/{Checkbox-CYNjFdtO.js → Checkbox-Dl4KTwEJ.js} +2 -2
- package/dist/{Checkbox-CYNjFdtO.js.map → Checkbox-Dl4KTwEJ.js.map} +1 -1
- package/dist/Checkbox.js +2 -2
- package/dist/{useInfiniteCombobox-BaYWUxjg.js → Combobox-B9nesJuc.js} +18 -185
- package/dist/Combobox-B9nesJuc.js.map +1 -0
- package/dist/Combobox.js +2 -1
- package/dist/Combobox.js.map +1 -1
- package/dist/{DateField-DnasO2rB.js → DateField-DXxPsRtf.js} +2 -2
- package/dist/{DateField-DnasO2rB.js.map → DateField-DXxPsRtf.js.map} +1 -1
- package/dist/DateField.js +1 -1
- package/dist/{DateFieldRange-Ba-8T-Nz.js → DateFieldRange-Xauviu1w.js} +6 -6
- package/dist/DateFieldRange-Xauviu1w.js.map +1 -0
- package/dist/DateFieldRange.js +1 -1
- package/dist/{DateFieldSingle-BBu5Hi9c.js → DateFieldSingle-yLnwpVzd.js} +4 -4
- package/dist/{DateFieldSingle-BBu5Hi9c.js.map → DateFieldSingle-yLnwpVzd.js.map} +1 -1
- package/dist/DateFieldSingle.js +1 -1
- package/dist/Dnd.js +1 -1
- package/dist/DndSort.js +1 -1
- package/dist/{ListView-DEAMQopB.js → ListView-pb3rIcze.js} +2 -2
- package/dist/{ListView-DEAMQopB.js.map → ListView-pb3rIcze.js.map} +1 -1
- package/dist/ListView.js +1 -1
- package/dist/{SearchField-BKXkoWPs.js → SearchField-Bb0uObwG.js} +2 -2
- package/dist/{SearchField-BKXkoWPs.js.map → SearchField-Bb0uObwG.js.map} +1 -1
- package/dist/SearchField.js +1 -1
- package/dist/{SelectCard-BWh8Yp7T.js → SelectCard-BTYZg9TG.js} +2 -2
- package/dist/{SelectCard-BWh8Yp7T.js.map → SelectCard-BTYZg9TG.js.map} +1 -1
- package/dist/SelectCard.js +1 -1
- package/dist/Toolbar-D4zuUFhb.js +2077 -0
- package/dist/Toolbar-D4zuUFhb.js.map +1 -0
- package/dist/Toolbar.css +139 -28
- package/dist/Toolbar.d.ts +3 -3
- package/dist/Toolbar.js +1 -1
- package/dist/beta/components/Toolbar/Filters/FilterButton.d.ts +30 -0
- package/dist/beta/components/Toolbar/Filters/FilterDateRange.d.ts +37 -0
- package/dist/beta/components/Toolbar/Filters/FilterDateSingle.d.ts +30 -0
- package/dist/beta/components/Toolbar/Filters/FilterDrawer.d.ts +15 -0
- package/dist/beta/components/Toolbar/Filters/FilterGroup.d.ts +25 -0
- package/dist/beta/components/Toolbar/Filters/FilterItemWrapper.d.ts +24 -0
- package/dist/beta/components/Toolbar/Filters/FilterSelect.d.ts +29 -0
- package/dist/beta/components/Toolbar/Filters/FilterToggleButton.d.ts +24 -0
- package/dist/beta/components/Toolbar/Filters/internal/FilterGroupContext.d.ts +40 -0
- package/dist/beta/components/Toolbar/Filters/internal/types.d.ts +130 -0
- package/dist/beta/components/Toolbar/Filters/internal/utils/filter-state.d.ts +40 -0
- package/dist/beta/components/Toolbar/Filters/internal/utils/test.d.ts +57 -0
- package/dist/beta/components/Toolbar/Toolbar.d.ts +302 -0
- package/dist/beta/components/Toolbar/ToolbarButton.d.ts +41 -0
- package/dist/beta/components/Toolbar/ToolbarButtonLink.d.ts +43 -0
- package/dist/beta/components/Toolbar/ToolbarButtonToggle.d.ts +42 -0
- package/dist/beta/components/Toolbar/ToolbarControlGroup.d.ts +20 -0
- package/dist/beta/components/Toolbar/ToolbarSearchField.d.ts +20 -0
- package/dist/beta/components/Toolbar/ToolbarSelect.d.ts +108 -0
- package/dist/beta/components/Toolbar/index.d.ts +9 -0
- package/dist/beta/components/Toolbar/internal/ToolbarItemOverflowContext.d.ts +19 -0
- package/dist/beta/components/Toolbar/internal/ToolbarItemWrapper.d.ts +40 -0
- package/dist/beta/components/Toolbar/internal/ToolbarOverflowContext.d.ts +35 -0
- package/dist/beta/components/Toolbar/internal/ToolbarOverflowMenu.d.ts +29 -0
- package/dist/beta/components/Toolbar/internal/utils/accessibility.d.ts +26 -0
- package/dist/beta/components/Toolbar/internal/utils/test.d.ts +29 -0
- package/dist/beta/components/Toolbar/types.d.ts +50 -0
- package/dist/beta/components/index.d.ts +1 -0
- package/dist/beta/index.d.ts +1 -0
- package/dist/beta.d.ts +2 -0
- package/dist/beta.js +2 -0
- package/dist/beta.js.map +1 -0
- package/dist/components/Combobox/ComboboxTypes.d.ts +8 -0
- package/dist/components/DateFieldRange/internal/DateFieldRangeCalendar.d.ts +1 -1
- package/dist/components/Dialog/index.d.ts +1 -1
- package/dist/{indeterminate_check_box-Bg24oeHy.js → indeterminate_check_box-RY9zr3xS.js} +17 -17
- package/dist/{indeterminate_check_box-Bg24oeHy.js.map → indeterminate_check_box-RY9zr3xS.js.map} +1 -1
- package/dist/indeterminate_check_box.css +72 -66
- package/dist/{index-CqdP5W00.js → index-V5Ez2gq_.js} +2 -2
- package/dist/{index-CqdP5W00.js.map → index-V5Ez2gq_.js.map} +1 -1
- package/dist/index.css +125 -26
- package/dist/index.js +756 -24
- package/dist/index.js.map +1 -1
- package/dist/index2.css +88 -105
- package/dist/internal/hooks/index.d.ts +1 -0
- package/dist/internal/hooks/useContainerQuery/index.d.ts +1 -0
- package/dist/internal/hooks/useContainerQuery/useContainerQuery.d.ts +46 -0
- package/dist/{useDateFieldOrchestration-DPLftOxu.js → useDateFieldOrchestration-BNJCsRkS.js} +2 -2
- package/dist/{useDateFieldOrchestration-DPLftOxu.js.map → useDateFieldOrchestration-BNJCsRkS.js.map} +1 -1
- package/dist/useInfiniteCombobox-WcRgC9p6.js +179 -0
- package/dist/useInfiniteCombobox-WcRgC9p6.js.map +1 -0
- package/dist/useIntersectionObserver-BEmMDO3P.js +70 -0
- package/dist/useIntersectionObserver-BEmMDO3P.js.map +1 -0
- package/package.json +2 -1
- package/dist/DateFieldRange-Ba-8T-Nz.js.map +0 -1
- package/dist/Toolbar-DK7tXy_W.js +0 -807
- package/dist/Toolbar-DK7tXy_W.js.map +0 -1
- package/dist/useInfiniteCombobox-BaYWUxjg.js.map +0 -1
- /package/dist/{useInfiniteCombobox.css → Combobox.css} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,54 +1,57 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './index2.css';export { DndSort, DndSortCard, DndSortZone } from './DndSort.js';
|
|
2
2
|
export { A as Alert } from './Alert-BNGvfMAV.js';
|
|
3
3
|
export { A as Announcement } from './Announcement-CoheCP1i.js';
|
|
4
4
|
export { A as Avatar } from './Avatar-CyGjhToG.js';
|
|
5
5
|
export { A as AvatarGroup } from './Avatar-D07f9NH_.js';
|
|
6
6
|
export { B as Badge } from './Badge-DCA9mfc2.js';
|
|
7
7
|
export { B as Breadcrumbs, a as BreadcrumbsElement, b as BreadcrumbsLink } from './Breadcrumbs-C4_PEolS.js';
|
|
8
|
-
|
|
8
|
+
import { B as Button } from './Button-BxFXQ0-n.js';
|
|
9
9
|
export { B as ButtonCompound } from './ButtonCompound-BF2Q6gGX.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export { C as Calendar, f as CalendarMonth, e as CalendarMonthButton, d as CalendarNext, a as CalendarNow, c as CalendarPrev, b as CalendarYearButton } from './Calendar-
|
|
10
|
+
import { B as ButtonLink } from './ButtonLink-CXv65WVV.js';
|
|
11
|
+
import { B as ButtonToggle } from './ButtonToggle-pSwg7NvT.js';
|
|
12
|
+
export { C as Calendar, f as CalendarMonth, e as CalendarMonthButton, d as CalendarNext, a as CalendarNow, c as CalendarPrev, b as CalendarYearButton } from './Calendar-BQ5F2ENO.js';
|
|
13
13
|
export { C as Card } from './Card-vTYeSkxt.js';
|
|
14
|
-
export { C as Checkbox } from './Checkbox-
|
|
15
|
-
export { C as CheckboxGroup } from './Checkbox-
|
|
14
|
+
export { C as Checkbox } from './Checkbox-DDrmVC-u.js';
|
|
15
|
+
export { C as CheckboxGroup } from './Checkbox-Dl4KTwEJ.js';
|
|
16
16
|
export { C as Chip } from './Chip-Bz-vlQ4D.js';
|
|
17
|
-
export { C as Combobox, c as ComboboxContent, a as ComboboxElement, i as ComboboxEmpty, e as ComboboxItem, f as ComboboxItemAddNew, d as ComboboxList, g as ComboboxSearchField, b as ComboboxSelect, h as ComboboxSelectTrigger
|
|
18
|
-
export {
|
|
19
|
-
export { D as
|
|
20
|
-
export { D as
|
|
17
|
+
export { C as Combobox, c as ComboboxContent, a as ComboboxElement, i as ComboboxEmpty, e as ComboboxItem, f as ComboboxItemAddNew, d as ComboboxList, g as ComboboxSearchField, b as ComboboxSelect, h as ComboboxSelectTrigger } from './Combobox-B9nesJuc.js';
|
|
18
|
+
export { u as useInfiniteCombobox } from './useInfiniteCombobox-WcRgC9p6.js';
|
|
19
|
+
export { D as DateField } from './DateField-DXxPsRtf.js';
|
|
20
|
+
export { D as DateFieldRange } from './DateFieldRange-Xauviu1w.js';
|
|
21
|
+
export { D as DateFieldSingle } from './DateFieldSingle-yLnwpVzd.js';
|
|
21
22
|
export { D as DateFieldYearless } from './DateFieldYearless-Ba7HiTiI.js';
|
|
22
23
|
export { D as DaysOfTheWeek } from './DaysOfTheWeek-BYSYZySH.js';
|
|
23
24
|
export { D as Details, b as DetailsContent, a as DetailsSummary } from './Details-CF8DImjw.js';
|
|
24
25
|
export { D as Dialog, a as DialogCancelButton, b as DialogContent, c as DialogFooter, d as DialogHeader } from './Dialog-CgkrvrQu.js';
|
|
25
26
|
export { D as Divider } from './Divider-DJe8kLf2.js';
|
|
26
|
-
export { D as Dnd } from './index-
|
|
27
|
+
export { D as Dnd } from './index-V5Ez2gq_.js';
|
|
27
28
|
export { D as Drawer, a as DrawerCancelButton, d as DrawerContent, b as DrawerFooter, c as DrawerHeader } from './Drawer-CM4ZbAro.js';
|
|
28
29
|
export { E as EditCard } from './EditCard-WKzZ2XCz.js';
|
|
29
30
|
export { F as FieldLabel } from './FieldLabel-BsbTTyom.js';
|
|
30
31
|
export { F as FieldMessage } from './FieldMessage-B7uQ8vmr.js';
|
|
31
|
-
|
|
32
|
+
import { F as Flex } from './Flex-BdQMekvA.js';
|
|
32
33
|
export { G as Grid } from './Grid-MGUC698u.js';
|
|
33
|
-
|
|
34
|
+
import { I as Icon } from './Icon-D8SPKeO4.js';
|
|
34
35
|
export { I as InputMask } from './InputMask-_F139qFu.js';
|
|
35
36
|
export { L as Layout, a as LayoutElement, b as LayoutItem } from './Layout-CUUb2PVr.js';
|
|
36
37
|
export { L as Link, u as useLinkStyles } from './Link-eRsLWPaQ.js';
|
|
37
38
|
export { L as LinkButton } from './LinkButton-2lXfrVoU.js';
|
|
38
|
-
|
|
39
|
-
export {
|
|
39
|
+
import { L as Listbox } from './Listbox-CUhMbFm2.js';
|
|
40
|
+
export { a as ListboxOption, b as ListboxOptionGroup } from './Listbox-CUhMbFm2.js';
|
|
41
|
+
export { L as ListView, a as ListViewOption, b as ListViewOptionCell } from './ListView-pb3rIcze.js';
|
|
40
42
|
export { M as Menu, a as MenuItem } from './Menu-C8we5CHP.js';
|
|
41
43
|
export { N as NumberField } from './NumberField-CkZZrkYC.js';
|
|
42
44
|
export { Overflow, OverflowText } from './Overflow.js';
|
|
43
45
|
export { P as Page } from './Page-cKXkjMmd.js';
|
|
44
46
|
export { P as Pagination } from './Pagination-ta8a2cJN.js';
|
|
45
|
-
|
|
47
|
+
import { P as Popover } from './Popover-r26xMIfm.js';
|
|
48
|
+
export { a as PopoverButton, b as PopoverClose, c as PopoverContent, d as PopoverTrigger } from './Popover-r26xMIfm.js';
|
|
46
49
|
export { P as ProgressBar } from './ProgressBar-DXcXZEJ2.js';
|
|
47
50
|
export { R as Radio } from './Radio-C89VCMXd.js';
|
|
48
51
|
export { R as RadioGroup } from './RadioGroup-C_4buUtG.js';
|
|
49
|
-
export { S as SearchField } from './SearchField-
|
|
52
|
+
export { S as SearchField } from './SearchField-Bb0uObwG.js';
|
|
50
53
|
export { S as SegmentedControl, a as SegmentedControlSegment } from './SegmentedControl-CsjjV1Dz.js';
|
|
51
|
-
export { S as SelectCard, a as SelectCardElement, b as SelectCardGroup } from './SelectCard-
|
|
54
|
+
export { S as SelectCard, a as SelectCardElement, b as SelectCardGroup } from './SelectCard-BTYZg9TG.js';
|
|
52
55
|
export { S as SelectTrigger } from './SelectTrigger-f1hvRrSC.js';
|
|
53
56
|
export { S as SideNav, b as SideNavCollapsible, c as SideNavGroup, a as SideNavLink } from './SideNav-CBAzYyML.js';
|
|
54
57
|
export { Skeleton, SkeletonCircle, SkeletonPill, SkeletonRectangle, SkeletonText } from './Skeleton.js';
|
|
@@ -63,14 +66,18 @@ export { T as TextField } from './TextField-BiHxlzE3.js';
|
|
|
63
66
|
export { T as TimeField } from './TimeField-CmbErrsZ.js';
|
|
64
67
|
export { T as Toaster } from './Toaster-B7zUwJOt.js';
|
|
65
68
|
export { t as toast } from './Toaster-9cpG_tWR.js';
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
70
|
+
import { useContext, createContext, useId, useRef, useCallback, useEffect, forwardRef, useState, useMemo } from 'react';
|
|
71
|
+
import { c as cx } from './index-tZvMCc77.js';
|
|
72
|
+
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-DjD5IMh0.js';
|
|
73
|
+
import { u as useMergeRefs } from './useMergeRefs-Bde85AWI.js';
|
|
74
|
+
import { T as Tooltip } from './Tooltip-BI3Xs75X.js';
|
|
75
|
+
export { a as TooltipContent, b as TooltipTrigger } from './Tooltip-BI3Xs75X.js';
|
|
68
76
|
export { u as useAccessibleColor } from './useAccessibleColor-BYKjkGRg.js';
|
|
69
77
|
export { u as useBreakpoint } from './useBreakpoint-Cv5fnZxs.js';
|
|
70
|
-
export { u as useMergeRefs } from './useMergeRefs-Bde85AWI.js';
|
|
71
78
|
export { u as usePrefersColorScheme } from './usePrefersColorScheme-_hT7dK7_.js';
|
|
72
79
|
export { u as useSwipe } from './useSwipe-CULmVQEk.js';
|
|
73
|
-
|
|
80
|
+
import { useTrackingId } from './useTrackingId.js';
|
|
74
81
|
export { A as AnvilProvider, a as AnvilProviderContext } from './AnvilProvider-C_qRQnE6.js';
|
|
75
82
|
export { L as LocalizationProvider } from './LocalizationProvider-DEZyjW5d.js';
|
|
76
83
|
export { L as LocalizationContext, u as useLocalizationContext } from './LocalizationContext-UsmB5mnR.js';
|
|
@@ -79,6 +86,11 @@ export { T as ThemeProvider } from './ThemeProvider-Be3Pvtpz.js';
|
|
|
79
86
|
export { u as useTheme } from './useTheme-B4i6a3bM.js';
|
|
80
87
|
export { T as TrackingProvider } from './TrackingProvider-BtSjkmpM.js';
|
|
81
88
|
export { u as useTrackingContext } from './useTrackingContext-DRwDL8DE.js';
|
|
89
|
+
import { g as getKeyboardFocusableElements } from './getKeyboardFocusableElements-QqcABz0D.js';
|
|
90
|
+
import { u as useIntersectionObserver } from './useIntersectionObserver-BEmMDO3P.js';
|
|
91
|
+
import { S as SvgArrowDropDown } from './arrow_drop_down-ChAdBDux.js';
|
|
92
|
+
import { S as SvgMoreHoriz } from './more_horiz-DJgdQiy0.js';
|
|
93
|
+
import { S as SvgMoreVert } from './more_vert-C_lJSyxt.js';
|
|
82
94
|
|
|
83
95
|
const IANA_TIMEZONES = [
|
|
84
96
|
"Pacific/Kiritimati",
|
|
@@ -509,5 +521,725 @@ const IANA_TIMEZONES = [
|
|
|
509
521
|
"Pacific/Pago_Pago"
|
|
510
522
|
];
|
|
511
523
|
|
|
512
|
-
|
|
524
|
+
const OverflowItemContext = createContext({
|
|
525
|
+
isInOverflowMenu: false
|
|
526
|
+
});
|
|
527
|
+
const useOverFlowItemContext = () => useContext(OverflowItemContext);
|
|
528
|
+
|
|
529
|
+
const ToolbarOverflowContext = createContext({
|
|
530
|
+
overflowItems: [],
|
|
531
|
+
addItem: () => {
|
|
532
|
+
return;
|
|
533
|
+
},
|
|
534
|
+
removeItem: () => {
|
|
535
|
+
return;
|
|
536
|
+
},
|
|
537
|
+
toolbarRef: { current: null },
|
|
538
|
+
orderedIds: [],
|
|
539
|
+
overflow: "wrap"
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
function getToolbarElements(toolbarElement) {
|
|
543
|
+
const toolbarContent = toolbarElement.querySelector(
|
|
544
|
+
'[data-anv="toolbar-content"]'
|
|
545
|
+
);
|
|
546
|
+
const mainItems = getKeyboardFocusableElements(toolbarContent).filter(
|
|
547
|
+
(item) => {
|
|
548
|
+
const isVisible = !item.closest('[aria-hidden="true"]');
|
|
549
|
+
return isVisible;
|
|
550
|
+
}
|
|
551
|
+
);
|
|
552
|
+
const overflowTrigger = toolbarElement.querySelector(
|
|
553
|
+
'[data-anv="toolbar-overflow-trigger"]'
|
|
554
|
+
);
|
|
555
|
+
return overflowTrigger ? [...mainItems, overflowTrigger] : mainItems;
|
|
556
|
+
}
|
|
557
|
+
function updateToolbarItemsTabIndex(toolbarElement, activeItem) {
|
|
558
|
+
if (!toolbarElement) return;
|
|
559
|
+
const items = getToolbarElements(toolbarElement);
|
|
560
|
+
if (!items.length) return;
|
|
561
|
+
let activeIndex = 0;
|
|
562
|
+
if (typeof activeItem === "number") {
|
|
563
|
+
activeIndex = Math.max(0, Math.min(activeItem, items.length - 1));
|
|
564
|
+
} else if (activeItem instanceof Element) {
|
|
565
|
+
const foundIndex = items.indexOf(activeItem);
|
|
566
|
+
if (foundIndex !== -1) {
|
|
567
|
+
activeIndex = foundIndex;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
items.forEach((item, index) => {
|
|
571
|
+
item.setAttribute("tabindex", index === activeIndex ? "0" : "-1");
|
|
572
|
+
});
|
|
573
|
+
return items[activeIndex];
|
|
574
|
+
}
|
|
575
|
+
function handleToolbarKeyDown(event, toolbarElement) {
|
|
576
|
+
if (!toolbarElement || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
577
|
+
const items = getToolbarElements(toolbarElement);
|
|
578
|
+
if (!items.length) return;
|
|
579
|
+
const activeElement = event.target;
|
|
580
|
+
if (!toolbarElement.contains(activeElement)) return;
|
|
581
|
+
const activeItem = items.find(
|
|
582
|
+
(item) => item === activeElement || Array.from(item.children).some((child) => child === activeElement)
|
|
583
|
+
);
|
|
584
|
+
const activeIndex = activeItem ? items.indexOf(activeItem) : -1;
|
|
585
|
+
if (activeIndex === -1) return;
|
|
586
|
+
let nextIndex = activeIndex;
|
|
587
|
+
const isVertical = toolbarElement.getAttribute("aria-orientation") === "vertical";
|
|
588
|
+
switch (event.key) {
|
|
589
|
+
case "ArrowLeft":
|
|
590
|
+
case "ArrowUp":
|
|
591
|
+
event.preventDefault();
|
|
592
|
+
if (isVertical && event.key === "ArrowUp" || !isVertical && event.key === "ArrowLeft") {
|
|
593
|
+
nextIndex = activeIndex <= 0 ? items.length - 1 : activeIndex - 1;
|
|
594
|
+
}
|
|
595
|
+
break;
|
|
596
|
+
case "ArrowRight":
|
|
597
|
+
case "ArrowDown":
|
|
598
|
+
event.preventDefault();
|
|
599
|
+
if (isVertical && event.key === "ArrowDown" || !isVertical && event.key === "ArrowRight") {
|
|
600
|
+
nextIndex = activeIndex >= items.length - 1 ? 0 : activeIndex + 1;
|
|
601
|
+
}
|
|
602
|
+
break;
|
|
603
|
+
case "Home":
|
|
604
|
+
event.preventDefault();
|
|
605
|
+
nextIndex = 0;
|
|
606
|
+
break;
|
|
607
|
+
case "End":
|
|
608
|
+
event.preventDefault();
|
|
609
|
+
nextIndex = items.length - 1;
|
|
610
|
+
break;
|
|
611
|
+
default:
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
updateToolbarItemsTabIndex(toolbarElement, nextIndex);
|
|
615
|
+
items[nextIndex]?.focus();
|
|
616
|
+
}
|
|
617
|
+
const handleMenuKeyboardNavigation = (event) => {
|
|
618
|
+
const menuItems = Array.from(
|
|
619
|
+
event.currentTarget.querySelectorAll('[role="menuitem"]')
|
|
620
|
+
).map((menuItem) => {
|
|
621
|
+
return getKeyboardFocusableElements(menuItem)[0] || menuItem;
|
|
622
|
+
});
|
|
623
|
+
if (!menuItems.length) return;
|
|
624
|
+
const currentIndex = menuItems.indexOf(document.activeElement);
|
|
625
|
+
if (currentIndex === -1) return;
|
|
626
|
+
let nextIndex = currentIndex;
|
|
627
|
+
const isModifierKey = event.altKey || event.ctrlKey || event.metaKey;
|
|
628
|
+
if (isModifierKey) return;
|
|
629
|
+
switch (event.key) {
|
|
630
|
+
case "ArrowDown":
|
|
631
|
+
case "ArrowUp": {
|
|
632
|
+
event.preventDefault();
|
|
633
|
+
const direction = event.key === "ArrowDown" ? 1 : -1;
|
|
634
|
+
nextIndex = (currentIndex + direction + menuItems.length) % menuItems.length;
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
case "Home":
|
|
638
|
+
event.preventDefault();
|
|
639
|
+
nextIndex = 0;
|
|
640
|
+
break;
|
|
641
|
+
case "End":
|
|
642
|
+
event.preventDefault();
|
|
643
|
+
nextIndex = menuItems.length - 1;
|
|
644
|
+
break;
|
|
645
|
+
default:
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
menuItems[nextIndex]?.focus();
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
const toolbar = "_toolbar_7lbdr_13";
|
|
652
|
+
const styles = {
|
|
653
|
+
toolbar: toolbar,
|
|
654
|
+
"toolbar-content": "_toolbar-content_7lbdr_20",
|
|
655
|
+
"toolbar-overflow-content": "_toolbar-overflow-content_7lbdr_23",
|
|
656
|
+
"toolbar-button-item": "_toolbar-button-item_7lbdr_31",
|
|
657
|
+
"toolbar-item": "_toolbar-item_7lbdr_37",
|
|
658
|
+
"overflow-collapse": "_overflow-collapse_7lbdr_41",
|
|
659
|
+
"toolbar-button-toggle-item": "_toolbar-button-toggle-item_7lbdr_65",
|
|
660
|
+
"toolbar-overflow-trigger": "_toolbar-overflow-trigger_7lbdr_71"
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
const ToolbarItemWrapper = ({
|
|
664
|
+
item,
|
|
665
|
+
children
|
|
666
|
+
}) => {
|
|
667
|
+
const { addItem, removeItem, toolbarRef, overflow } = useContext(
|
|
668
|
+
ToolbarOverflowContext
|
|
669
|
+
);
|
|
670
|
+
const itemId = useId();
|
|
671
|
+
const elementRef = useRef(null);
|
|
672
|
+
const prevIntersectingRef = useRef(true);
|
|
673
|
+
const isCollapseMode = overflow === "collapse";
|
|
674
|
+
const handleVisibilityChange = useCallback(
|
|
675
|
+
(isVisible) => {
|
|
676
|
+
if (!isCollapseMode || prevIntersectingRef.current === isVisible) return;
|
|
677
|
+
const itemWithId = { ...item, id: itemId };
|
|
678
|
+
if (isVisible) {
|
|
679
|
+
removeItem(itemWithId);
|
|
680
|
+
} else {
|
|
681
|
+
addItem(itemWithId);
|
|
682
|
+
}
|
|
683
|
+
prevIntersectingRef.current = isVisible;
|
|
684
|
+
},
|
|
685
|
+
[isCollapseMode, item, itemId, addItem, removeItem]
|
|
686
|
+
);
|
|
687
|
+
const { isIntersecting, ref } = useIntersectionObserver({
|
|
688
|
+
root: isCollapseMode ? toolbarRef.current : null,
|
|
689
|
+
threshold: 1,
|
|
690
|
+
initialIsIntersecting: false,
|
|
691
|
+
onChange: handleVisibilityChange
|
|
692
|
+
});
|
|
693
|
+
const setRefCallback = useCallback(
|
|
694
|
+
(node) => {
|
|
695
|
+
elementRef.current = node;
|
|
696
|
+
if (isCollapseMode) {
|
|
697
|
+
ref(node);
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
[ref, isCollapseMode]
|
|
701
|
+
);
|
|
702
|
+
const handleFocusOrClick = useCallback(() => {
|
|
703
|
+
if (!toolbarRef.current || !elementRef.current) return;
|
|
704
|
+
const currentElement = elementRef.current.querySelector("button, a, input");
|
|
705
|
+
if (!currentElement) return;
|
|
706
|
+
updateToolbarItemsTabIndex(toolbarRef.current, currentElement);
|
|
707
|
+
}, [toolbarRef]);
|
|
708
|
+
useEffect(() => {
|
|
709
|
+
const interactiveEl = elementRef.current?.querySelector("button, a, input");
|
|
710
|
+
if (!interactiveEl) return;
|
|
711
|
+
interactiveEl.addEventListener("focus", handleFocusOrClick);
|
|
712
|
+
interactiveEl.addEventListener("click", handleFocusOrClick);
|
|
713
|
+
return () => {
|
|
714
|
+
interactiveEl.removeEventListener("focus", handleFocusOrClick);
|
|
715
|
+
interactiveEl.removeEventListener("click", handleFocusOrClick);
|
|
716
|
+
};
|
|
717
|
+
}, [handleFocusOrClick]);
|
|
718
|
+
useEffect(() => {
|
|
719
|
+
if (isCollapseMode) {
|
|
720
|
+
prevIntersectingRef.current = true;
|
|
721
|
+
}
|
|
722
|
+
}, [isCollapseMode]);
|
|
723
|
+
const isHidden = isCollapseMode && !isIntersecting;
|
|
724
|
+
return /* @__PURE__ */ jsx(
|
|
725
|
+
"div",
|
|
726
|
+
{
|
|
727
|
+
ref: setRefCallback,
|
|
728
|
+
className: styles["toolbar-item"],
|
|
729
|
+
style: { visibility: isHidden ? "hidden" : "visible" },
|
|
730
|
+
"aria-hidden": isHidden,
|
|
731
|
+
...{ inert: isHidden ? "" : void 0 },
|
|
732
|
+
"data-id": itemId,
|
|
733
|
+
"data-anv": "toolbar-item",
|
|
734
|
+
children
|
|
735
|
+
}
|
|
736
|
+
);
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
const ToolbarButton = forwardRef(
|
|
740
|
+
(props, _ref) => {
|
|
741
|
+
const { appearance = "ghost", className, children, ...rest } = props;
|
|
742
|
+
const { isInOverflowMenu = false } = useOverFlowItemContext?.() || {};
|
|
743
|
+
const trackingId = useTrackingId({
|
|
744
|
+
name: "ToolbarButton",
|
|
745
|
+
data: {
|
|
746
|
+
disabled: props.disabled,
|
|
747
|
+
"aria-label": props["aria-label"],
|
|
748
|
+
children: props.children
|
|
749
|
+
},
|
|
750
|
+
hasOverride: !!props["data-tracking-id"]
|
|
751
|
+
});
|
|
752
|
+
const buttonClassNames = cx(className, styles["toolbar-button-item"]);
|
|
753
|
+
const item = children ? /* @__PURE__ */ jsx(
|
|
754
|
+
Button,
|
|
755
|
+
{
|
|
756
|
+
"data-tracking-id": trackingId,
|
|
757
|
+
appearance,
|
|
758
|
+
size: "small",
|
|
759
|
+
"data-anv": "toolbar-button",
|
|
760
|
+
className: buttonClassNames,
|
|
761
|
+
...rest,
|
|
762
|
+
children
|
|
763
|
+
}
|
|
764
|
+
) : /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
765
|
+
/* @__PURE__ */ jsx(Tooltip.Trigger, { children: /* @__PURE__ */ jsx(
|
|
766
|
+
Button,
|
|
767
|
+
{
|
|
768
|
+
"data-tracking-id": trackingId,
|
|
769
|
+
appearance,
|
|
770
|
+
size: "small",
|
|
771
|
+
"data-anv": "toolbar-button",
|
|
772
|
+
className: buttonClassNames,
|
|
773
|
+
...rest
|
|
774
|
+
}
|
|
775
|
+
) }),
|
|
776
|
+
/* @__PURE__ */ jsx(Tooltip.Content, { children: rest["aria-label"] })
|
|
777
|
+
] });
|
|
778
|
+
if (isInOverflowMenu) {
|
|
779
|
+
return item;
|
|
780
|
+
}
|
|
781
|
+
return /* @__PURE__ */ jsx(ToolbarItemWrapper, { item: { itemProps: props, itemType: "button" }, children: item });
|
|
782
|
+
}
|
|
783
|
+
);
|
|
784
|
+
ToolbarButton.displayName = "ToolbarButton";
|
|
785
|
+
|
|
786
|
+
const ToolbarButtonToggle = forwardRef((props, _ref) => {
|
|
787
|
+
const { className, children, ...rest } = props;
|
|
788
|
+
const { isInOverflowMenu = false } = useOverFlowItemContext?.() || {};
|
|
789
|
+
const trackingId = useTrackingId({
|
|
790
|
+
name: "ToolbarButtonToggle",
|
|
791
|
+
data: {
|
|
792
|
+
checked: props.checked,
|
|
793
|
+
disabled: props.disabled,
|
|
794
|
+
"aria-label": props["aria-label"],
|
|
795
|
+
children: props.children
|
|
796
|
+
},
|
|
797
|
+
hasOverride: !!props["data-tracking-id"]
|
|
798
|
+
});
|
|
799
|
+
const buttonToggleClassNames = cx(
|
|
800
|
+
className,
|
|
801
|
+
styles["toolbar-button-item"],
|
|
802
|
+
styles["toolbar-button-toggle-item"]
|
|
803
|
+
);
|
|
804
|
+
const item = children ? /* @__PURE__ */ jsx(
|
|
805
|
+
ButtonToggle,
|
|
806
|
+
{
|
|
807
|
+
"data-tracking-id": trackingId,
|
|
808
|
+
size: "small",
|
|
809
|
+
"data-anv": "toolbar-button-toggle",
|
|
810
|
+
className: buttonToggleClassNames,
|
|
811
|
+
...rest,
|
|
812
|
+
children
|
|
813
|
+
}
|
|
814
|
+
) : /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
815
|
+
/* @__PURE__ */ jsx(Tooltip.Trigger, { children: /* @__PURE__ */ jsx(
|
|
816
|
+
ButtonToggle,
|
|
817
|
+
{
|
|
818
|
+
"data-tracking-id": trackingId,
|
|
819
|
+
size: "small",
|
|
820
|
+
"data-anv": "toolbar-button-toggle",
|
|
821
|
+
className: buttonToggleClassNames,
|
|
822
|
+
...rest
|
|
823
|
+
}
|
|
824
|
+
) }),
|
|
825
|
+
/* @__PURE__ */ jsx(Tooltip.Content, { children: rest["aria-label"] })
|
|
826
|
+
] });
|
|
827
|
+
if (isInOverflowMenu) {
|
|
828
|
+
return item;
|
|
829
|
+
}
|
|
830
|
+
return /* @__PURE__ */ jsx(ToolbarItemWrapper, { item: { itemProps: props, itemType: "buttonToggle" }, children: item });
|
|
831
|
+
});
|
|
832
|
+
ToolbarButtonToggle.displayName = "ToolbarButtonToggle";
|
|
833
|
+
|
|
834
|
+
const ToolbarButtonLink = forwardRef((props, _ref) => {
|
|
835
|
+
const { appearance = "ghost", className, children, ...rest } = props;
|
|
836
|
+
const { isInOverflowMenu = false } = useOverFlowItemContext?.() || {};
|
|
837
|
+
const trackingId = useTrackingId({
|
|
838
|
+
name: "ToolbarButtonLink",
|
|
839
|
+
data: {
|
|
840
|
+
href: props.href,
|
|
841
|
+
disabled: props.disabled,
|
|
842
|
+
"aria-label": props["aria-label"],
|
|
843
|
+
children: props.children,
|
|
844
|
+
target: props.target
|
|
845
|
+
},
|
|
846
|
+
hasOverride: !!props["data-tracking-id"]
|
|
847
|
+
});
|
|
848
|
+
const buttonLinkClassNames = cx(className, styles["toolbar-button-item"]);
|
|
849
|
+
const item = children ? /* @__PURE__ */ jsx(
|
|
850
|
+
ButtonLink,
|
|
851
|
+
{
|
|
852
|
+
"data-tracking-id": trackingId,
|
|
853
|
+
appearance,
|
|
854
|
+
size: "small",
|
|
855
|
+
"data-anv": "toolbar-button-link",
|
|
856
|
+
className: buttonLinkClassNames,
|
|
857
|
+
...rest,
|
|
858
|
+
children
|
|
859
|
+
}
|
|
860
|
+
) : /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
861
|
+
/* @__PURE__ */ jsx(Tooltip.Trigger, { children: /* @__PURE__ */ jsx(
|
|
862
|
+
ButtonLink,
|
|
863
|
+
{
|
|
864
|
+
"data-tracking-id": trackingId,
|
|
865
|
+
appearance,
|
|
866
|
+
size: "small",
|
|
867
|
+
"data-anv": "toolbar-button-link",
|
|
868
|
+
className: buttonLinkClassNames,
|
|
869
|
+
...rest
|
|
870
|
+
}
|
|
871
|
+
) }),
|
|
872
|
+
/* @__PURE__ */ jsx(Tooltip.Content, { children: rest["aria-label"] })
|
|
873
|
+
] });
|
|
874
|
+
if (isInOverflowMenu) {
|
|
875
|
+
return item;
|
|
876
|
+
}
|
|
877
|
+
return /* @__PURE__ */ jsx(ToolbarItemWrapper, { item: { itemProps: props, itemType: "buttonLink" }, children: item });
|
|
878
|
+
});
|
|
879
|
+
ToolbarButtonLink.displayName = "ToolbarButtonLink";
|
|
880
|
+
|
|
881
|
+
const ToolbarSelect = forwardRef(
|
|
882
|
+
(props, _ref) => {
|
|
883
|
+
const {
|
|
884
|
+
appearance = "ghost",
|
|
885
|
+
onChange,
|
|
886
|
+
selected: selectedItemId,
|
|
887
|
+
accessibleLabel,
|
|
888
|
+
className,
|
|
889
|
+
items,
|
|
890
|
+
...rest
|
|
891
|
+
} = props;
|
|
892
|
+
const selectId = useId();
|
|
893
|
+
const defaultId = items.length > 0 ? items[0].id : "";
|
|
894
|
+
const [internalSelectedId, setInternalSelectedId] = useState(defaultId);
|
|
895
|
+
const selectedId = selectedItemId ?? internalSelectedId;
|
|
896
|
+
const selectedItem = items.find((item2) => item2.id === selectedId) || items.find((item2) => item2.id === defaultId);
|
|
897
|
+
useEffect(() => {
|
|
898
|
+
if (!selectedItemId && items.length > 0 && !items.some((item2) => item2.id === internalSelectedId)) {
|
|
899
|
+
setInternalSelectedId(items[0].id);
|
|
900
|
+
}
|
|
901
|
+
}, [items, selectedItemId, internalSelectedId]);
|
|
902
|
+
const handleSelectionChange = (selected) => {
|
|
903
|
+
if (selected?.id) {
|
|
904
|
+
if (selectedItemId === void 0) {
|
|
905
|
+
setInternalSelectedId(selected.id);
|
|
906
|
+
}
|
|
907
|
+
onChange?.(selected.id);
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
const { isInOverflowMenu = false } = useOverFlowItemContext?.() || {};
|
|
911
|
+
const trackingId = useTrackingId({
|
|
912
|
+
name: "ToolbarSelect",
|
|
913
|
+
data: {
|
|
914
|
+
selected: props.selected,
|
|
915
|
+
disabled: props.disabled,
|
|
916
|
+
"aria-label": props["aria-label"],
|
|
917
|
+
items: props.items
|
|
918
|
+
},
|
|
919
|
+
hasOverride: !!props["data-tracking-id"]
|
|
920
|
+
});
|
|
921
|
+
const buttonClassNames = cx(className, styles["toolbar-button-item"]);
|
|
922
|
+
const item = /* @__PURE__ */ jsxs(Popover, { noPadding: true, children: [
|
|
923
|
+
/* @__PURE__ */ jsx(
|
|
924
|
+
Popover.Button,
|
|
925
|
+
{
|
|
926
|
+
"data-tracking-id": trackingId,
|
|
927
|
+
appearance,
|
|
928
|
+
size: "small",
|
|
929
|
+
icon: { after: SvgArrowDropDown },
|
|
930
|
+
className: buttonClassNames,
|
|
931
|
+
id: selectId,
|
|
932
|
+
"data-anv": "toolbar-select",
|
|
933
|
+
...rest,
|
|
934
|
+
children: selectedItem?.label
|
|
935
|
+
}
|
|
936
|
+
),
|
|
937
|
+
/* @__PURE__ */ jsx(
|
|
938
|
+
Popover.Content,
|
|
939
|
+
{
|
|
940
|
+
className: styles["toolbar-select-content"],
|
|
941
|
+
"aria-label": `${accessibleLabel} options`,
|
|
942
|
+
children: /* @__PURE__ */ jsx(
|
|
943
|
+
Listbox,
|
|
944
|
+
{
|
|
945
|
+
selected: selectedItem,
|
|
946
|
+
onSelectionChange: handleSelectionChange,
|
|
947
|
+
items,
|
|
948
|
+
"aria-labelledby": selectId,
|
|
949
|
+
children: ({ items: items2 }) => items2.map((item2) => /* @__PURE__ */ jsx(Listbox.Option, { item: item2, children: item2.label }, item2.label))
|
|
950
|
+
}
|
|
951
|
+
)
|
|
952
|
+
}
|
|
953
|
+
)
|
|
954
|
+
] });
|
|
955
|
+
if (isInOverflowMenu) {
|
|
956
|
+
return item;
|
|
957
|
+
}
|
|
958
|
+
return /* @__PURE__ */ jsx(ToolbarItemWrapper, { item: { itemProps: props, itemType: "select" }, children: item });
|
|
959
|
+
}
|
|
960
|
+
);
|
|
961
|
+
ToolbarSelect.displayName = "ToolbarSelect";
|
|
962
|
+
|
|
963
|
+
const OverflowItem = ({ itemType, itemProps }) => {
|
|
964
|
+
switch (itemType) {
|
|
965
|
+
case "button":
|
|
966
|
+
return /* @__PURE__ */ jsx(ToolbarButton, { ...itemProps });
|
|
967
|
+
case "buttonToggle":
|
|
968
|
+
return /* @__PURE__ */ jsx(ToolbarButtonToggle, { ...itemProps });
|
|
969
|
+
case "buttonLink":
|
|
970
|
+
return /* @__PURE__ */ jsx(ToolbarButtonLink, { ...itemProps });
|
|
971
|
+
case "select":
|
|
972
|
+
return /* @__PURE__ */ jsx(ToolbarSelect, { ...itemProps });
|
|
973
|
+
default:
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
const ToolbarOverflowMenu = ({
|
|
978
|
+
additionalItems,
|
|
979
|
+
direction
|
|
980
|
+
}) => {
|
|
981
|
+
const { overflowItems, orderedIds } = useContext(ToolbarOverflowContext);
|
|
982
|
+
const menuTriggerId = useId();
|
|
983
|
+
const orderedItems = useMemo(() => {
|
|
984
|
+
const allElements = orderedIds?.map((id) => {
|
|
985
|
+
return overflowItems.find((item) => item.id === id);
|
|
986
|
+
});
|
|
987
|
+
return allElements?.filter((item) => item !== void 0) || [];
|
|
988
|
+
}, [orderedIds, overflowItems]);
|
|
989
|
+
const popoverButtonClassNames = cx(
|
|
990
|
+
styles["toolbar-button-item"],
|
|
991
|
+
styles["toolbar-overflow-trigger"]
|
|
992
|
+
);
|
|
993
|
+
const overflowIcon = direction === "horizontal" ? SvgMoreHoriz : SvgMoreVert;
|
|
994
|
+
return /* @__PURE__ */ jsxs(Popover, { noPadding: true, children: [
|
|
995
|
+
/* @__PURE__ */ jsx(
|
|
996
|
+
Popover.Button,
|
|
997
|
+
{
|
|
998
|
+
size: "small",
|
|
999
|
+
appearance: "ghost",
|
|
1000
|
+
id: menuTriggerId,
|
|
1001
|
+
className: popoverButtonClassNames,
|
|
1002
|
+
"data-anv": "toolbar-overflow-trigger",
|
|
1003
|
+
"aria-label": "Additional toolbar options",
|
|
1004
|
+
children: /* @__PURE__ */ jsx(Icon, { svg: overflowIcon, size: "small" })
|
|
1005
|
+
}
|
|
1006
|
+
),
|
|
1007
|
+
/* @__PURE__ */ jsx(Popover.Content, { children: /* @__PURE__ */ jsx(OverflowItemContext.Provider, { value: { isInOverflowMenu: true }, children: /* @__PURE__ */ jsxs(
|
|
1008
|
+
"ul",
|
|
1009
|
+
{
|
|
1010
|
+
role: "menu",
|
|
1011
|
+
className: styles["toolbar-overflow-content"],
|
|
1012
|
+
"data-anv": "toolbar-overflow-menu",
|
|
1013
|
+
"aria-labelledby": menuTriggerId,
|
|
1014
|
+
onKeyDown: handleMenuKeyboardNavigation,
|
|
1015
|
+
children: [
|
|
1016
|
+
orderedItems.map((item) => {
|
|
1017
|
+
const { itemType, itemProps, id } = item;
|
|
1018
|
+
return /* @__PURE__ */ jsx(
|
|
1019
|
+
"li",
|
|
1020
|
+
{
|
|
1021
|
+
role: "menuitem",
|
|
1022
|
+
"data-anv": "toolbar-overflow-item",
|
|
1023
|
+
children: /* @__PURE__ */ jsx(
|
|
1024
|
+
OverflowItem,
|
|
1025
|
+
{
|
|
1026
|
+
itemType,
|
|
1027
|
+
itemProps,
|
|
1028
|
+
id
|
|
1029
|
+
}
|
|
1030
|
+
)
|
|
1031
|
+
},
|
|
1032
|
+
`${itemType}-${id}`
|
|
1033
|
+
);
|
|
1034
|
+
}),
|
|
1035
|
+
additionalItems?.map((item, index) => /* @__PURE__ */ jsx(
|
|
1036
|
+
"li",
|
|
1037
|
+
{
|
|
1038
|
+
role: "menuitem",
|
|
1039
|
+
"data-anv": "toolbar-overflow-item",
|
|
1040
|
+
children: item
|
|
1041
|
+
},
|
|
1042
|
+
`additional-item-${index}`
|
|
1043
|
+
))
|
|
1044
|
+
]
|
|
1045
|
+
}
|
|
1046
|
+
) }) })
|
|
1047
|
+
] });
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
const ToolbarElement = forwardRef(
|
|
1051
|
+
(props, ref) => {
|
|
1052
|
+
const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
|
|
1053
|
+
const {
|
|
1054
|
+
associatedContent,
|
|
1055
|
+
className,
|
|
1056
|
+
children,
|
|
1057
|
+
style,
|
|
1058
|
+
direction = "horizontal",
|
|
1059
|
+
overflow = "wrap",
|
|
1060
|
+
onKeyDown,
|
|
1061
|
+
additionalItems,
|
|
1062
|
+
...rest
|
|
1063
|
+
} = componentProps;
|
|
1064
|
+
const [overflowItems, setOverflowItems] = useState([]);
|
|
1065
|
+
const toolbarItemsRef = useRef(null);
|
|
1066
|
+
const toolbarRef = useRef(null);
|
|
1067
|
+
const [orderedIds, setOrderedIds] = useState([]);
|
|
1068
|
+
useEffect(() => {
|
|
1069
|
+
const newOrderedIds = Array.from(
|
|
1070
|
+
toolbarItemsRef.current?.querySelectorAll("[data-id]") || []
|
|
1071
|
+
).map((el) => {
|
|
1072
|
+
return el.getAttribute("data-id");
|
|
1073
|
+
});
|
|
1074
|
+
setOrderedIds(newOrderedIds);
|
|
1075
|
+
}, [children]);
|
|
1076
|
+
const addItem = useCallback((item) => {
|
|
1077
|
+
setOverflowItems((prev) => [...prev, item]);
|
|
1078
|
+
}, []);
|
|
1079
|
+
const removeItem = useCallback((item) => {
|
|
1080
|
+
setOverflowItems(
|
|
1081
|
+
(prev) => prev.filter((component) => component.id !== item.id)
|
|
1082
|
+
);
|
|
1083
|
+
}, []);
|
|
1084
|
+
useEffect(() => {
|
|
1085
|
+
if (toolbarRef.current) {
|
|
1086
|
+
updateToolbarItemsTabIndex(toolbarRef.current);
|
|
1087
|
+
}
|
|
1088
|
+
}, [children]);
|
|
1089
|
+
const handleKeyDown = useCallback(
|
|
1090
|
+
(event) => {
|
|
1091
|
+
if (toolbarRef.current) {
|
|
1092
|
+
handleToolbarKeyDown(event, toolbarRef.current);
|
|
1093
|
+
}
|
|
1094
|
+
onKeyDown?.(event);
|
|
1095
|
+
},
|
|
1096
|
+
[onKeyDown]
|
|
1097
|
+
);
|
|
1098
|
+
const showOverflowMenu = overflow === "collapse" && overflowItems.length > 0 || !!additionalItems;
|
|
1099
|
+
const value = useMemo(
|
|
1100
|
+
() => ({
|
|
1101
|
+
overflowItems,
|
|
1102
|
+
addItem,
|
|
1103
|
+
removeItem,
|
|
1104
|
+
toolbarRef,
|
|
1105
|
+
orderedIds,
|
|
1106
|
+
overflow
|
|
1107
|
+
}),
|
|
1108
|
+
[overflowItems, addItem, removeItem, toolbarRef, orderedIds, overflow]
|
|
1109
|
+
);
|
|
1110
|
+
const styleCombined = {
|
|
1111
|
+
...style,
|
|
1112
|
+
...layoutStyles
|
|
1113
|
+
};
|
|
1114
|
+
const toolbarClassNames = cx(styles["toolbar"], className);
|
|
1115
|
+
const toolbarContentClassNames = cx(styles["toolbar-content"], {
|
|
1116
|
+
[styles[`overflow-${overflow}`]]: overflow
|
|
1117
|
+
});
|
|
1118
|
+
return /* @__PURE__ */ jsx(ToolbarOverflowContext.Provider, { value, children: /* @__PURE__ */ jsxs(
|
|
1119
|
+
Flex,
|
|
1120
|
+
{
|
|
1121
|
+
direction: direction === "horizontal" ? "row" : "column",
|
|
1122
|
+
wrap: overflow === "wrap" ? "wrap" : "nowrap",
|
|
1123
|
+
alignItems: "center",
|
|
1124
|
+
className: toolbarClassNames,
|
|
1125
|
+
style: styleCombined,
|
|
1126
|
+
ref: useMergeRefs([toolbarRef, ref]),
|
|
1127
|
+
role: "toolbar",
|
|
1128
|
+
"data-anv": "toolbar",
|
|
1129
|
+
"aria-orientation": direction,
|
|
1130
|
+
"aria-label": `Toolbar for ${associatedContent}. Use arrow keys to navigate through toolbar controls.`,
|
|
1131
|
+
onKeyDown: handleKeyDown,
|
|
1132
|
+
...rest,
|
|
1133
|
+
children: [
|
|
1134
|
+
/* @__PURE__ */ jsx(
|
|
1135
|
+
Flex,
|
|
1136
|
+
{
|
|
1137
|
+
ref: useMergeRefs([toolbarItemsRef, ref]),
|
|
1138
|
+
className: toolbarContentClassNames,
|
|
1139
|
+
direction: direction === "horizontal" ? "row" : "column",
|
|
1140
|
+
wrap: overflow === "wrap" ? "wrap" : "nowrap",
|
|
1141
|
+
alignItems: "center",
|
|
1142
|
+
grow: 1,
|
|
1143
|
+
"data-anv": "toolbar-content",
|
|
1144
|
+
children
|
|
1145
|
+
}
|
|
1146
|
+
),
|
|
1147
|
+
showOverflowMenu && /* @__PURE__ */ jsx(
|
|
1148
|
+
ToolbarOverflowMenu,
|
|
1149
|
+
{
|
|
1150
|
+
direction,
|
|
1151
|
+
additionalItems
|
|
1152
|
+
}
|
|
1153
|
+
)
|
|
1154
|
+
]
|
|
1155
|
+
}
|
|
1156
|
+
) });
|
|
1157
|
+
}
|
|
1158
|
+
);
|
|
1159
|
+
ToolbarElement.displayName = "Toolbar";
|
|
1160
|
+
const Toolbar = Object.assign(ToolbarElement, {
|
|
1161
|
+
/**
|
|
1162
|
+
* ToolbarButton component for standard clickable actions within a toolbar with anvil2 tracking.
|
|
1163
|
+
*
|
|
1164
|
+
* Features:
|
|
1165
|
+
* - Designed specifically for toolbar integration
|
|
1166
|
+
* - Consistent styling with other toolbar items
|
|
1167
|
+
* - Automatic tooltip for icon-only buttons
|
|
1168
|
+
* - Overflow menu support
|
|
1169
|
+
* - Accessibility enforcement for aria-labels
|
|
1170
|
+
* - Small size optimized for toolbar layout
|
|
1171
|
+
* - Ghost and primary appearance options
|
|
1172
|
+
* - Automatic tracking ID generation for analytics
|
|
1173
|
+
*
|
|
1174
|
+
* @example
|
|
1175
|
+
* <Toolbar.Button icon={BoldIcon} aria-label="Bold text" />
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* <Toolbar.Button appearance="primary">
|
|
1179
|
+
* Save
|
|
1180
|
+
* </Toolbar.Button>
|
|
1181
|
+
*/
|
|
1182
|
+
Button: ToolbarButton,
|
|
1183
|
+
/**
|
|
1184
|
+
* ToolbarButtonToggle component for toggleable actions within a toolbar with anvil2 tracking.
|
|
1185
|
+
*
|
|
1186
|
+
* Features:
|
|
1187
|
+
* - Toggle state management
|
|
1188
|
+
* - Designed specifically for toolbar integration
|
|
1189
|
+
* - Consistent styling with other toolbar items
|
|
1190
|
+
* - Overflow menu support
|
|
1191
|
+
* - Accessibility enforcement for aria-labels
|
|
1192
|
+
* - Small size optimized for toolbar layout
|
|
1193
|
+
* - Ghost and primary appearance options
|
|
1194
|
+
* - Automatic tracking ID generation for analytics
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* <Toolbar.ButtonToggle icon={BoldIcon} aria-label="Bold" checked={isBold} />
|
|
1198
|
+
*/
|
|
1199
|
+
ButtonToggle: ToolbarButtonToggle,
|
|
1200
|
+
/**
|
|
1201
|
+
* ToolbarButtonLink component for link actions within a toolbar with anvil2 tracking.
|
|
1202
|
+
*
|
|
1203
|
+
* Features:
|
|
1204
|
+
* - Link functionality with href support
|
|
1205
|
+
* - Designed specifically for toolbar integration
|
|
1206
|
+
* - Consistent styling with other toolbar items
|
|
1207
|
+
* - Overflow menu support
|
|
1208
|
+
* - Accessibility enforcement for aria-labels
|
|
1209
|
+
* - Small size optimized for toolbar layout
|
|
1210
|
+
* - Ghost and primary appearance options
|
|
1211
|
+
* - Automatic tracking ID generation for analytics
|
|
1212
|
+
*
|
|
1213
|
+
* @example
|
|
1214
|
+
* <Toolbar.ButtonLink href="/help">
|
|
1215
|
+
* Help
|
|
1216
|
+
* </Toolbar.ButtonLink>
|
|
1217
|
+
*/
|
|
1218
|
+
ButtonLink: ToolbarButtonLink,
|
|
1219
|
+
/**
|
|
1220
|
+
* ToolbarSelect component provides a dropdown selector within a toolbar with anvil2 tracking.
|
|
1221
|
+
*
|
|
1222
|
+
* Features:
|
|
1223
|
+
* - Dropdown menu with selectable options
|
|
1224
|
+
* - Controlled and uncontrolled usage patterns
|
|
1225
|
+
* - Automatic overflow menu integration
|
|
1226
|
+
* - Accessibility support with proper ARIA labels
|
|
1227
|
+
* - Small size optimized for toolbar layout
|
|
1228
|
+
* - Ghost and primary appearance options
|
|
1229
|
+
* - Dropdown arrow icon indicator
|
|
1230
|
+
* - Listbox integration for keyboard navigation
|
|
1231
|
+
* - Automatic tracking ID generation for analytics
|
|
1232
|
+
*
|
|
1233
|
+
* @example
|
|
1234
|
+
* <Toolbar.Select
|
|
1235
|
+
* items={fontOptions}
|
|
1236
|
+
* selected="arial"
|
|
1237
|
+
* accessibleLabel="Font family"
|
|
1238
|
+
* onChange={(id) => setFont(id)}
|
|
1239
|
+
* />
|
|
1240
|
+
*/
|
|
1241
|
+
Select: ToolbarSelect
|
|
1242
|
+
});
|
|
1243
|
+
|
|
1244
|
+
export { Button, ButtonLink, ButtonToggle, Flex, IANA_TIMEZONES, Icon, Listbox, Popover, Toolbar, ToolbarButton, ToolbarButtonLink, ToolbarButtonToggle, ToolbarElement, ToolbarSelect, Tooltip, useMergeRefs, useTrackingId };
|
|
513
1245
|
//# sourceMappingURL=index.js.map
|