@vuu-ui/vuu-ui-controls 2.1.19-beta.1 → 2.1.19-beta.2
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/package.json +12 -13
- package/src/calendar/Calendar.css.js +10 -0
- package/src/calendar/Calendar.js +70 -0
- package/src/calendar/index.js +4 -0
- package/src/calendar/internal/CalendarCarousel.css.js +19 -0
- package/src/calendar/internal/CalendarCarousel.js +73 -0
- package/src/calendar/internal/CalendarContext.js +9 -0
- package/src/calendar/internal/CalendarDay.css.js +116 -0
- package/src/calendar/internal/CalendarDay.js +64 -0
- package/src/calendar/internal/CalendarMonth.css.js +13 -0
- package/src/calendar/internal/CalendarMonth.js +43 -0
- package/src/calendar/internal/CalendarNavigation.css.js +24 -0
- package/src/calendar/internal/CalendarNavigation.js +185 -0
- package/src/calendar/internal/CalendarWeekHeader.css.js +23 -0
- package/src/calendar/internal/CalendarWeekHeader.js +31 -0
- package/src/calendar/internal/useFocusManagement.js +66 -0
- package/src/calendar/internal/utils.js +57 -0
- package/src/calendar/useCalendar.js +116 -0
- package/src/calendar/useCalendarDay.js +74 -0
- package/src/calendar/useSelection.js +202 -0
- package/src/column-picker/ColumnPicker.css.js +8 -0
- package/src/column-picker/ColumnPicker.js +108 -0
- package/src/column-picker/ColumnSearch.css.js +61 -0
- package/src/column-picker/ColumnSearch.js +66 -0
- package/src/column-picker/index.js +2 -0
- package/src/column-picker/moving-window.js +49 -0
- package/src/common-hooks/index.js +3 -0
- package/src/common-hooks/selectionTypes.js +8 -0
- package/src/common-hooks/use-resize-observer.js +122 -0
- package/src/common-hooks/useControlled.js +45 -0
- package/src/context-panel-provider/ContextPanelProvider.js +80 -0
- package/src/cycle-state-button/CycleStateButton.js +30 -0
- package/src/cycle-state-button/index.js +1 -0
- package/src/date-input/DateInput.css.js +195 -0
- package/src/date-input/DateInput.js +210 -0
- package/src/date-input/index.js +1 -0
- package/src/date-picker/DatePicker.js +137 -0
- package/src/date-picker/DatePickerContext.js +20 -0
- package/src/date-picker/DatePickerPanel.css.js +25 -0
- package/src/date-picker/DatePickerPanel.js +124 -0
- package/src/date-picker/index.js +1 -0
- package/src/drag-drop/DragDropProvider.js +123 -0
- package/src/drag-drop/DragDropState.js +25 -0
- package/src/drag-drop/Draggable.css.js +57 -0
- package/src/drag-drop/Draggable.js +77 -0
- package/src/drag-drop/DropIndicator.css.js +11 -0
- package/src/drag-drop/DropIndicator.js +28 -0
- package/src/drag-drop/dragDropTypes.js +3 -0
- package/src/drag-drop/drop-target-utils.js +199 -0
- package/src/drag-drop/index.js +6 -0
- package/src/drag-drop/useAutoScroll.js +53 -0
- package/src/drag-drop/useDragDisplacers.js +126 -0
- package/src/drag-drop/useDragDrop.js +435 -0
- package/src/drag-drop/useDragDropCopy.js +22 -0
- package/src/drag-drop/useDragDropIndicator.js +182 -0
- package/src/drag-drop/useDragDropNaturalMovement.js +205 -0
- package/src/drag-drop/useDropIndicator.js +21 -0
- package/src/drag-drop/useGlobalDragDrop.js +67 -0
- package/src/drag-drop/useTransition.js +11 -0
- package/src/editable/index.js +1 -0
- package/src/editable/useEditableText.js +199 -0
- package/src/editable-label/EditableLabel.css.js +81 -0
- package/src/editable-label/EditableLabel.js +125 -0
- package/src/editable-label/index.js +1 -0
- package/src/expando-input/ExpandoInput.css.js +67 -0
- package/src/expando-input/ExpandoInput.js +40 -0
- package/src/expando-input/index.js +1 -0
- package/src/highlighter/Highlighter.css.js +8 -0
- package/src/highlighter/Highlighter.js +27 -0
- package/src/highlighter/index.js +1 -0
- package/src/hover-overlay/HoverOverlay.js +92 -0
- package/src/icon-button/Icon.css.js +8 -0
- package/src/icon-button/Icon.js +26 -0
- package/src/icon-button/IconButton.css.js +10 -0
- package/src/icon-button/IconButton.js +28 -0
- package/src/icon-button/ToggleIconButton.css.js +47 -0
- package/src/icon-button/ToggleIconButton.js +26 -0
- package/src/icon-button/index.js +3 -0
- package/src/index.js +31 -0
- package/src/instrument-picker/SearchCell.css.js +17 -0
- package/src/instrument-picker/SearchCell.js +29 -0
- package/src/instrument-picker/TablePicker.css.js +23 -0
- package/src/instrument-picker/TablePicker.js +89 -0
- package/src/instrument-picker/index.js +1 -0
- package/src/instrument-picker/moving-window.js +49 -0
- package/src/instrument-picker/useDataSource.js +38 -0
- package/src/instrument-picker/useTablePicker.js +136 -0
- package/src/measured-container/MeasuredContainer.css.js +11 -0
- package/src/measured-container/MeasuredContainer.js +50 -0
- package/src/measured-container/index.js +2 -0
- package/src/measured-container/useMeasuredContainer.js +156 -0
- package/src/modal-provider/ModalProvider.js +147 -0
- package/src/overflow-container/OverflowContainer.css.js +135 -0
- package/src/overflow-container/OverflowContainer.js +87 -0
- package/src/overflow-container/index.js +2 -0
- package/src/overflow-container/overflow-utils.js +211 -0
- package/src/overflow-container/useOverflowContainer.js +108 -0
- package/src/price-ticker/PriceTicker.css.js +32 -0
- package/src/price-ticker/PriceTicker.js +51 -0
- package/src/price-ticker/index.js +1 -0
- package/src/prompt/Prompt.css.js +48 -0
- package/src/prompt/Prompt.js +112 -0
- package/src/sortable-list/SortableList.js +39 -0
- package/src/split-button/SplitButton.css.js +117 -0
- package/src/split-button/SplitButton.js +60 -0
- package/src/split-button/SplitStateButton.css.js +66 -0
- package/src/split-button/SplitStateButton.js +23 -0
- package/src/split-button/index.js +2 -0
- package/src/split-button/useSplitButton.js +61 -0
- package/src/table-search/SearchCell.css.js +20 -0
- package/src/table-search/SearchCell.js +26 -0
- package/src/table-search/TableSearch.css.js +27 -0
- package/src/table-search/TableSearch.js +81 -0
- package/src/table-search/index.js +1 -0
- package/src/table-search/moving-window.js +49 -0
- package/src/table-search/useTableSearch.js +30 -0
- package/src/tabs-next/TabBar.css.js +26 -0
- package/src/tabs-next/TabBar.js +27 -0
- package/src/tabs-next/TabListNext.css.js +36 -0
- package/src/tabs-next/TabListNext.js +94 -0
- package/src/tabs-next/TabNext.css.js +76 -0
- package/src/tabs-next/TabNext.js +91 -0
- package/src/tabs-next/TabNextAction.js +26 -0
- package/src/tabs-next/TabNextContext.js +14 -0
- package/src/tabs-next/TabNextPanel.css.js +17 -0
- package/src/tabs-next/TabNextPanel.js +69 -0
- package/src/tabs-next/TabNextTrigger.css.js +22 -0
- package/src/tabs-next/TabNextTrigger.js +66 -0
- package/src/tabs-next/TabOverflowList.css.js +77 -0
- package/src/tabs-next/TabOverflowList.js +115 -0
- package/src/tabs-next/TabsNext.js +149 -0
- package/src/tabs-next/TabsNextContext.js +28 -0
- package/src/tabs-next/hooks/useCollection.js +80 -0
- package/src/tabs-next/hooks/useFocusOutside.js +23 -0
- package/src/tabs-next/hooks/useOverflow.js +118 -0
- package/src/tabs-next/index.js +7 -0
- package/src/tabstrip/Tab.css.js +148 -0
- package/src/tabstrip/Tab.js +107 -0
- package/src/tabstrip/TabMenu.css.js +8 -0
- package/src/tabstrip/TabMenu.js +48 -0
- package/src/tabstrip/TabMenuOptions.js +14 -0
- package/src/tabstrip/TabsTypes.js +0 -0
- package/src/tabstrip/Tabstrip.css.js +121 -0
- package/src/tabstrip/Tabstrip.js +106 -0
- package/src/tabstrip/ThemeTabstrip.css.js +20 -0
- package/src/tabstrip/index.js +4 -0
- package/src/tabstrip/tabstrip-dom-utils.js +11 -0
- package/src/tabstrip/useAnimatedSelectionThumb.js +68 -0
- package/src/tabstrip/useKeyboardNavigation.js +191 -0
- package/src/tabstrip/useSelection.js +50 -0
- package/src/tabstrip/useTabstrip.js +181 -0
- package/src/time-input/MaskedInput.js +285 -0
- package/src/time-input/TimeInput.css.js +39 -0
- package/src/time-input/TimeInput.js +37 -0
- package/src/time-input/useTimeInput.js +82 -0
- package/src/toolbar/Toolbar.css.js +46 -0
- package/src/toolbar/Toolbar.js +62 -0
- package/src/toolbar/index.js +1 -0
- package/src/toolbar/toolbar-dom-utils.js +11 -0
- package/src/toolbar/useKeyboardNavigation.js +240 -0
- package/src/toolbar/useSelection.js +82 -0
- package/src/toolbar/useToolbar.js +73 -0
- package/src/utils/deprecated-types.js +0 -0
- package/src/utils/escapeRegExp.js +5 -0
- package/src/utils/forwardCallbackProps.js +15 -0
- package/src/utils/index.js +5 -0
- package/src/utils/isOverflowElement.js +2 -0
- package/src/utils/isPlainObject.js +2 -0
- package/src/vuu-date-picker/VuuDatePicker.js +92 -0
- package/src/vuu-date-picker/index.js +1 -0
- package/src/vuu-input/VuuInput.css.js +13 -0
- package/src/vuu-input/VuuInput.js +85 -0
- package/src/vuu-input/index.js +1 -0
- package/src/vuu-time-picker/TimeRangePicker.js +0 -0
- package/src/vuu-time-picker/VuuTimePicker.css.js +14 -0
- package/src/vuu-time-picker/VuuTimePicker.js +26 -0
- package/src/vuu-typeahead-input/VuuTypeaheadInput.css.js +49 -0
- package/src/vuu-typeahead-input/VuuTypeaheadInput.js +46 -0
- package/src/vuu-typeahead-input/index.js +1 -0
- package/src/vuu-typeahead-input/useVuuTypeaheadInput.js +140 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PopupMenu } from "@vuu-ui/vuu-popups";
|
|
3
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
4
|
+
import { useWindow } from "@salt-ds/window";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import { closeCommand, renameCommand } from "./TabMenuOptions.js";
|
|
8
|
+
import TabMenu from "./TabMenu.css";
|
|
9
|
+
const classBase = "vuuTabMenu";
|
|
10
|
+
const TabMenu_TabMenu = ({ allowClose, allowRename, controlledComponentId, controlledComponentTitle, location, onMenuAction, onMenuClose, index })=>{
|
|
11
|
+
const targetWindow = useWindow();
|
|
12
|
+
useComponentCssInjection({
|
|
13
|
+
testId: "vuu-tab-menu",
|
|
14
|
+
css: TabMenu,
|
|
15
|
+
window: targetWindow
|
|
16
|
+
});
|
|
17
|
+
const [menuBuilder, menuOptions] = useMemo(()=>[
|
|
18
|
+
(_location, options)=>{
|
|
19
|
+
const menuItems = [];
|
|
20
|
+
if (allowRename) menuItems.push(renameCommand(options));
|
|
21
|
+
if (allowClose) menuItems.push(closeCommand(options));
|
|
22
|
+
return menuItems;
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
controlledComponentId,
|
|
26
|
+
controlledComponentTitle,
|
|
27
|
+
tabIndex: index
|
|
28
|
+
}
|
|
29
|
+
], [
|
|
30
|
+
allowClose,
|
|
31
|
+
allowRename,
|
|
32
|
+
controlledComponentId,
|
|
33
|
+
controlledComponentTitle,
|
|
34
|
+
index
|
|
35
|
+
]);
|
|
36
|
+
return /*#__PURE__*/ jsx(PopupMenu, {
|
|
37
|
+
"aria-label": "context menu",
|
|
38
|
+
className: classBase,
|
|
39
|
+
"data-embedded": true,
|
|
40
|
+
menuBuilder: menuBuilder,
|
|
41
|
+
menuActionHandler: onMenuAction,
|
|
42
|
+
menuLocation: clsx("tab", location),
|
|
43
|
+
menuOptions: menuOptions,
|
|
44
|
+
onMenuClose: onMenuClose,
|
|
45
|
+
tabIndex: -1
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export { TabMenu_TabMenu as TabMenu };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const isTabMenuOptions = (options)=>"object" == typeof options && null !== options && "tabIndex" in options && "number" == typeof options.tabIndex;
|
|
2
|
+
const closeCommand = (options)=>({
|
|
3
|
+
label: "Close",
|
|
4
|
+
location: "tab",
|
|
5
|
+
id: "close-tab",
|
|
6
|
+
options
|
|
7
|
+
});
|
|
8
|
+
const renameCommand = (options)=>({
|
|
9
|
+
label: "Rename",
|
|
10
|
+
location: "tab",
|
|
11
|
+
id: "rename-tab",
|
|
12
|
+
options
|
|
13
|
+
});
|
|
14
|
+
export { closeCommand, isTabMenuOptions, renameCommand };
|
|
File without changes
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
.vuuTabstrip {
|
|
3
|
+
--vuuOverflowContainer-background: transparent;
|
|
4
|
+
--vuuOverflowContainer-borderColor: var(--salt-container-primary-borderColor);
|
|
5
|
+
--vuuOverflowContainer-width: var(--tabstrip-width);
|
|
6
|
+
--tabstrip-dragging-display: none;
|
|
7
|
+
--tabstrip-display: inline-flex;
|
|
8
|
+
--tabstrip-background: transparent;
|
|
9
|
+
align-self: var(--saltTabs-tabstrip-alignSelf, stretch);
|
|
10
|
+
font-size: var(--salt-text-fontSize);
|
|
11
|
+
font-weight: var(--vuuTabstrip-fontWeight, var(--salt-text-fontWeight));
|
|
12
|
+
min-width: 28px;
|
|
13
|
+
display: flex;
|
|
14
|
+
position: relative;
|
|
15
|
+
overflow: visible;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.vuuTabstrip.vuuOrientation-horizontal {
|
|
19
|
+
--vuuOverflowContainer-borderStyle: none none solid none;
|
|
20
|
+
--vuuOverflowContainer-borderBottomWidth: 1px;
|
|
21
|
+
--tabstrip-height: var(--vuuTabstrip-height, var(--overflow-wrapper-height, 28px));
|
|
22
|
+
--tabstrip-width: var(--vuuTabstrip-width, 100%);
|
|
23
|
+
--tab-height: var(--tabstrip-height);
|
|
24
|
+
--tab-width: auto;
|
|
25
|
+
--tab-thumb-height: 2px;
|
|
26
|
+
--tab-thumb-left: var(--tab-thumb-offset, 0);
|
|
27
|
+
--tab-thumb-top: auto;
|
|
28
|
+
--tab-thumb-width: var(--tab-thumb-size, 100%);
|
|
29
|
+
align-items: flex-start;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.vuuTabstrip.vuuOrientation-vertical {
|
|
33
|
+
--tabstrip-height: var(--vuuTabstrip-height, 100%);
|
|
34
|
+
--tabstrip-width: var(--vuuTabstrip-width, 100px);
|
|
35
|
+
--tab-height: 50px;
|
|
36
|
+
--tab-width: 100%;
|
|
37
|
+
--tab-thumb-height: 0;
|
|
38
|
+
--tab-thumb-left: 0;
|
|
39
|
+
--tab-thumb-top: var(--tab-thumb-offset, 0);
|
|
40
|
+
--tab-thumb-width: 2px;
|
|
41
|
+
align-self: flex-start;
|
|
42
|
+
display: inline-flex;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.vuuTabstrip-draggingTab .vuuTab {
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.vuuTabstrip-overflowMenu.vuuDropdown {
|
|
50
|
+
--saltIcon-margin: 2px 0 0 0px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.vuuTabstrip-overflowMenu-open {
|
|
54
|
+
--saltButton-background: var(--salt-actionable-subtle-background-active);
|
|
55
|
+
--saltButton-text-color: var(--salt-actionable-subtle-text-color-active);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.vuuTabstrip-overflowMenu-open .saltButton {
|
|
59
|
+
--saltIcon-color: var(--salt-actionable-subtle-foreground-active);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.vuuTabstrip-inner {
|
|
63
|
+
width: 100%;
|
|
64
|
+
line-height: var(--tabstrip-height);
|
|
65
|
+
flex-wrap: wrap;
|
|
66
|
+
flex: 0 auto;
|
|
67
|
+
justify-content: flex-start;
|
|
68
|
+
align-items: center;
|
|
69
|
+
display: flex;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.vuuTabstrip.vuuOrientation-vertical .vuuTabstrip-inner {
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
height: auto;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.vuuTabstrip-centered .vuuTabstrip-inner {
|
|
78
|
+
justify-content: center;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.vuuDraggable[class*="vuuTabstrip"] {
|
|
82
|
+
--tabstrip-display: flex;
|
|
83
|
+
--tabstrip-height: 100%;
|
|
84
|
+
--tabstrip-dragging-display: block;
|
|
85
|
+
--tabs-tab-background: var(--salt-navigable-primary-background-hover);
|
|
86
|
+
--tabs-tab-before-content: "";
|
|
87
|
+
--tabs-tab-before-background: var(--salt-navigable-indicator-hover);
|
|
88
|
+
--tabs-tab-before-height: var(--tab-activationIndicator-thumb-height);
|
|
89
|
+
--tabs-tab-before-inset: var(--tab-activationIndicator-inset);
|
|
90
|
+
--tabs-tab-before-width: var(--tab-activationIndicator-thumb-width);
|
|
91
|
+
--tabs-tab-cursor: var(--salt-draggable-grab-cursor-active);
|
|
92
|
+
--tabs-tab-position: static;
|
|
93
|
+
font-size: 12px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.vuuDraggable-tabstrip-horizontal {
|
|
97
|
+
--overflow-item-height: var(--tabstrip-height);
|
|
98
|
+
--tab-thumb-height: 2px;
|
|
99
|
+
--tab-thumb-left: 0px;
|
|
100
|
+
--tabstrip-display: inline-flex;
|
|
101
|
+
--tabstrip-height: 28px;
|
|
102
|
+
line-height: var(--tabstrip-height);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.vuuDraggable[class*="tabstrip"] .vuuTab[aria-selected="true"]:before {
|
|
106
|
+
--tabs-tab-before-background: var(--salt-navigable-indicator-active);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.vuuTabstrip-overflowMenu-dropTarget:after {
|
|
110
|
+
background: var(--salt-selectable-background-selected);
|
|
111
|
+
content: "";
|
|
112
|
+
height: 2px;
|
|
113
|
+
position: absolute;
|
|
114
|
+
bottom: 0;
|
|
115
|
+
left: 0;
|
|
116
|
+
right: 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
`;
|
|
121
|
+
export default css;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import react, { createElement, useMemo, useRef } from "react";
|
|
3
|
+
import { asReactElements, useId } from "@vuu-ui/vuu-utils";
|
|
4
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
5
|
+
import { useWindow } from "@salt-ds/window";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { useTabstrip } from "./useTabstrip.js";
|
|
8
|
+
import { IconButton } from "../icon-button/index.js";
|
|
9
|
+
import { OverflowContainer } from "../overflow-container/index.js";
|
|
10
|
+
import Tabstrip from "./Tabstrip.css";
|
|
11
|
+
const classBase = "vuuTabstrip";
|
|
12
|
+
const Tabstrip_Tabstrip = ({ activeTabIndex: activeTabIndexProp, allowAddTab, allowCloseTab, allowDragDrop = false, allowRenameTab = false, animateSelectionThumb = false, children, className: classNameProp, id: idProp, keyBoardActivation = "manual", location, onActiveChange, onAddTab, onCloseTab, onExitEditMode, onMoveTab, orientation = "horizontal", showTabMenuButton, style: styleProp, tabClassName, variant = "secondary", ...htmlAttributes })=>{
|
|
13
|
+
const targetWindow = useWindow();
|
|
14
|
+
useComponentCssInjection({
|
|
15
|
+
testId: "vuu-tabstrip",
|
|
16
|
+
css: Tabstrip,
|
|
17
|
+
window: targetWindow
|
|
18
|
+
});
|
|
19
|
+
const rootRef = useRef(null);
|
|
20
|
+
const { activeTabIndex, containerStyle, focusVisible, draggedItemIndex, onClickAddTab, interactedTabState, tabProps, ...tabstripHook } = useTabstrip({
|
|
21
|
+
activeTabIndex: activeTabIndexProp,
|
|
22
|
+
allowDragDrop,
|
|
23
|
+
animateSelectionThumb,
|
|
24
|
+
containerRef: rootRef,
|
|
25
|
+
keyBoardActivation,
|
|
26
|
+
onActiveChange,
|
|
27
|
+
onAddTab,
|
|
28
|
+
onCloseTab,
|
|
29
|
+
onExitEditMode,
|
|
30
|
+
onMoveTab,
|
|
31
|
+
orientation
|
|
32
|
+
});
|
|
33
|
+
const id = useId(idProp);
|
|
34
|
+
const className = clsx(classBase, classNameProp);
|
|
35
|
+
const style = styleProp || containerStyle ? {
|
|
36
|
+
...styleProp,
|
|
37
|
+
...containerStyle
|
|
38
|
+
} : void 0;
|
|
39
|
+
const tabs = useMemo(()=>asReactElements(children).map((child, index)=>{
|
|
40
|
+
const { id: tabId = `${id}-tab-${index}`, className, closeable = allowCloseTab, editable = allowRenameTab, location: tabLocation, showMenuButton = showTabMenuButton } = child.props;
|
|
41
|
+
const selected = index === activeTabIndex;
|
|
42
|
+
return /*#__PURE__*/ react.cloneElement(child, {
|
|
43
|
+
...tabProps,
|
|
44
|
+
...tabstripHook.navigationProps,
|
|
45
|
+
className: clsx(className, tabClassName),
|
|
46
|
+
closeable,
|
|
47
|
+
"data-overflow-priority": selected ? "1" : void 0,
|
|
48
|
+
dragging: draggedItemIndex === index,
|
|
49
|
+
editable,
|
|
50
|
+
editing: interactedTabState?.index === index,
|
|
51
|
+
focusVisible: focusVisible === index,
|
|
52
|
+
id: tabId,
|
|
53
|
+
index,
|
|
54
|
+
key: index,
|
|
55
|
+
location: clsx(location, tabLocation),
|
|
56
|
+
selected,
|
|
57
|
+
showMenuButton,
|
|
58
|
+
tabIndex: selected ? 0 : -1
|
|
59
|
+
});
|
|
60
|
+
}).concat(allowAddTab ? /*#__PURE__*/ createElement(IconButton, {
|
|
61
|
+
...tabstripHook.navigationProps,
|
|
62
|
+
"aria-label": "Create Tab",
|
|
63
|
+
className: `${classBase}-addTabButton`,
|
|
64
|
+
"data-embedded": true,
|
|
65
|
+
icon: "add",
|
|
66
|
+
"data-overflow-priority": "1",
|
|
67
|
+
key: "addButton",
|
|
68
|
+
onClick: onClickAddTab,
|
|
69
|
+
variant: "secondary",
|
|
70
|
+
tabIndex: -1
|
|
71
|
+
}) : []), [
|
|
72
|
+
children,
|
|
73
|
+
allowAddTab,
|
|
74
|
+
tabstripHook.navigationProps,
|
|
75
|
+
onClickAddTab,
|
|
76
|
+
id,
|
|
77
|
+
allowCloseTab,
|
|
78
|
+
allowRenameTab,
|
|
79
|
+
showTabMenuButton,
|
|
80
|
+
activeTabIndex,
|
|
81
|
+
tabProps,
|
|
82
|
+
tabClassName,
|
|
83
|
+
draggedItemIndex,
|
|
84
|
+
interactedTabState,
|
|
85
|
+
focusVisible,
|
|
86
|
+
location
|
|
87
|
+
]);
|
|
88
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ jsx(OverflowContainer, {
|
|
91
|
+
...htmlAttributes,
|
|
92
|
+
...tabstripHook.containerProps,
|
|
93
|
+
className: clsx(className, `${classBase}-${variant}`),
|
|
94
|
+
id: id,
|
|
95
|
+
orientation: orientation,
|
|
96
|
+
overflowIcon: "more-horiz",
|
|
97
|
+
ref: rootRef,
|
|
98
|
+
style: style,
|
|
99
|
+
role: "tablist",
|
|
100
|
+
children: tabs
|
|
101
|
+
}),
|
|
102
|
+
tabstripHook.draggable
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
export { Tabstrip_Tabstrip as Tabstrip };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
.salt-density-touch {
|
|
3
|
+
--toolbar-depth: calc(var(--salt-size-basis-unit) * 13);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.salt-density-low {
|
|
7
|
+
--toolbar-depth: calc(var(--salt-size-basis-unit) * 11);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.salt-density-medium {
|
|
11
|
+
--toolbar-depth: calc(var(--salt-size-basis-unit) * 9);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.salt-density-high {
|
|
15
|
+
--toolbar-depth: calc(var(--salt-size-basis-unit) * 7);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
`;
|
|
20
|
+
export default css;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getElementDataIndex } from "@vuu-ui/vuu-utils";
|
|
2
|
+
const getIndexOfItem = (container, query)=>{
|
|
3
|
+
if (container) {
|
|
4
|
+
const targetTab = container.querySelector(`[data-index]:has(${query})`);
|
|
5
|
+
return getElementDataIndex(targetTab);
|
|
6
|
+
}
|
|
7
|
+
return -1;
|
|
8
|
+
};
|
|
9
|
+
const getIndexOfSelectedTab = (container)=>getIndexOfItem(container, '[aria-selected="true"]');
|
|
10
|
+
const getIndexOfEditedItem = (container)=>getIndexOfItem(container, ".vuuEditableLabel-editing");
|
|
11
|
+
export { getIndexOfEditedItem, getIndexOfSelectedTab };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { MEASURES, isValidNumber } from "@vuu-ui/vuu-utils";
|
|
2
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
3
|
+
const useAnimatedSelectionThumb = (containerRef, activeTabIndex, orientation = "horizontal")=>{
|
|
4
|
+
const animationSuspendedRef = useRef(false);
|
|
5
|
+
const suspendAnimation = useCallback(()=>{
|
|
6
|
+
animationSuspendedRef.current = true;
|
|
7
|
+
}, []);
|
|
8
|
+
const resumeAnimation = useCallback(()=>{
|
|
9
|
+
animationSuspendedRef.current = false;
|
|
10
|
+
}, []);
|
|
11
|
+
const onTransitionEnd = useCallback(()=>{
|
|
12
|
+
containerRef.current?.style.setProperty("--tab-thumb-transition", "none");
|
|
13
|
+
containerRef.current?.removeEventListener("transitionend", onTransitionEnd);
|
|
14
|
+
}, [
|
|
15
|
+
containerRef
|
|
16
|
+
]);
|
|
17
|
+
const lastSelectedRef = useRef(-1);
|
|
18
|
+
return useMemo(()=>{
|
|
19
|
+
let offset = 0;
|
|
20
|
+
let size = 0;
|
|
21
|
+
if (-1 !== lastSelectedRef.current) {
|
|
22
|
+
const oldSelected = containerRef.current?.querySelector(".vuuTab-selected");
|
|
23
|
+
const newSelected = containerRef.current?.querySelector(`[data-index="${activeTabIndex}"] .vuuTab`);
|
|
24
|
+
const { positionProp, sizeProp } = MEASURES[orientation];
|
|
25
|
+
if (oldSelected && newSelected && !animationSuspendedRef.current) {
|
|
26
|
+
const { [positionProp]: oldPosition, [sizeProp]: oldSize } = oldSelected.getBoundingClientRect();
|
|
27
|
+
const { [positionProp]: newPosition } = newSelected.getBoundingClientRect();
|
|
28
|
+
if (isValidNumber(oldPosition) && isValidNumber(newPosition) && isValidNumber(oldSize)) {
|
|
29
|
+
offset = oldPosition - newPosition;
|
|
30
|
+
size = oldSize;
|
|
31
|
+
const speed = "horizontal" === orientation ? 1100 : 700;
|
|
32
|
+
const duration = Math.abs(offset / speed);
|
|
33
|
+
requestAnimationFrame(()=>{
|
|
34
|
+
containerRef.current?.style.setProperty("--tab-thumb-offset", "0px");
|
|
35
|
+
containerRef.current?.style.setProperty("--tab-thumb-size", "100%");
|
|
36
|
+
containerRef.current?.style.setProperty("--tab-thumb-transition", `all ${duration}s ease`);
|
|
37
|
+
containerRef.current?.addEventListener("transitionend", onTransitionEnd);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
lastSelectedRef.current = activeTabIndex;
|
|
43
|
+
if (animationSuspendedRef.current) return {
|
|
44
|
+
containerStyle: {
|
|
45
|
+
"--tab-thumb-offset": "0px",
|
|
46
|
+
"--tab-thumb-size": "100%"
|
|
47
|
+
},
|
|
48
|
+
resumeAnimation,
|
|
49
|
+
suspendAnimation
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
containerStyle: {
|
|
53
|
+
"--tab-thumb-offset": `${offset}px`,
|
|
54
|
+
"--tab-thumb-size": size ? `${size}px` : void 0
|
|
55
|
+
},
|
|
56
|
+
resumeAnimation,
|
|
57
|
+
suspendAnimation
|
|
58
|
+
};
|
|
59
|
+
}, [
|
|
60
|
+
activeTabIndex,
|
|
61
|
+
containerRef,
|
|
62
|
+
orientation,
|
|
63
|
+
onTransitionEnd,
|
|
64
|
+
resumeAnimation,
|
|
65
|
+
suspendAnimation
|
|
66
|
+
]);
|
|
67
|
+
};
|
|
68
|
+
export { useAnimatedSelectionThumb };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { useControlled } from "@salt-ds/core";
|
|
2
|
+
import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Home, dispatchMouseEvent, getElementByDataIndex, getFocusableElement } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import { useCallback, useRef, useState } from "react";
|
|
4
|
+
import { getIndexOfEditedItem } from "./tabstrip-dom-utils.js";
|
|
5
|
+
const navigation = {
|
|
6
|
+
horizontal: {
|
|
7
|
+
[Home]: "start",
|
|
8
|
+
[End]: "end",
|
|
9
|
+
[ArrowLeft]: "bwd",
|
|
10
|
+
[ArrowRight]: "fwd"
|
|
11
|
+
},
|
|
12
|
+
vertical: {
|
|
13
|
+
[Home]: "start",
|
|
14
|
+
[End]: "end",
|
|
15
|
+
[ArrowUp]: "bwd",
|
|
16
|
+
[ArrowDown]: "fwd"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const isNavigationKey = (key, orientation = "horizontal")=>void 0 !== navigation[orientation][key];
|
|
20
|
+
const isMenuActivationKey = (key)=>key === ArrowDown;
|
|
21
|
+
function nextItemIdx(count, direction, idx) {
|
|
22
|
+
if ("start" === direction) return 0;
|
|
23
|
+
if ("end" === direction) return count - 1;
|
|
24
|
+
if ("bwd" === direction) if (idx > 0) return idx - 1;
|
|
25
|
+
else return idx;
|
|
26
|
+
if (null === idx) return 0;
|
|
27
|
+
if (idx === count - 1) return idx;
|
|
28
|
+
else return idx + 1;
|
|
29
|
+
}
|
|
30
|
+
const isEditing = (element)=>null != element && element.classList.contains("vuuTab-editing");
|
|
31
|
+
const isNonWrappedElement = (element)=>null != element && !element.classList.contains("wrapped");
|
|
32
|
+
const useKeyboardNavigation = ({ containerRef, defaultHighlightedIdx = -1, highlightedIdx: highlightedIdxProp, keyBoardActivation, orientation, selectedIndex: selectedTabIndex = 0 })=>{
|
|
33
|
+
const manualActivation = "manual" === keyBoardActivation;
|
|
34
|
+
const mouseClickPending = useRef(false);
|
|
35
|
+
const focusedRef = useRef(-1);
|
|
36
|
+
const [hasFocus, setHasFocus] = useState(false);
|
|
37
|
+
const [, forceRefresh] = useState({});
|
|
38
|
+
const [highlightedIdx, _setHighlightedIdx] = useControlled({
|
|
39
|
+
controlled: highlightedIdxProp,
|
|
40
|
+
default: defaultHighlightedIdx,
|
|
41
|
+
name: "UseKeyboardNavigation"
|
|
42
|
+
});
|
|
43
|
+
const setHighlightedIdx = useCallback((value)=>{
|
|
44
|
+
_setHighlightedIdx(focusedRef.current = value);
|
|
45
|
+
}, [
|
|
46
|
+
_setHighlightedIdx
|
|
47
|
+
]);
|
|
48
|
+
const keyboardNavigation = useRef(false);
|
|
49
|
+
const focusTab = useCallback((tabIndex, immediateFocus = false, withKeyboard, delay = 70)=>{
|
|
50
|
+
setHighlightedIdx(tabIndex);
|
|
51
|
+
if (true === withKeyboard && !keyboardNavigation.current) keyboardNavigation.current = true;
|
|
52
|
+
const setFocus = ()=>{
|
|
53
|
+
if (-1 !== tabIndex) {
|
|
54
|
+
const element = getElementByDataIndex(containerRef.current, tabIndex);
|
|
55
|
+
if (element) {
|
|
56
|
+
const focusableElement = getFocusableElement(element);
|
|
57
|
+
if (!isEditing(focusableElement)) focusableElement?.focus();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
if (immediateFocus) setFocus();
|
|
62
|
+
else setTimeout(setFocus, delay);
|
|
63
|
+
}, [
|
|
64
|
+
containerRef,
|
|
65
|
+
setHighlightedIdx
|
|
66
|
+
]);
|
|
67
|
+
const onFocus = (e)=>{
|
|
68
|
+
if (-1 === focusedRef.current) if (-1 === e.target.tabIndex) ;
|
|
69
|
+
else {
|
|
70
|
+
const index = getIndexOfEditedItem(containerRef.current);
|
|
71
|
+
if (-1 !== index) requestAnimationFrame(()=>{
|
|
72
|
+
setHighlightedIdx(index);
|
|
73
|
+
});
|
|
74
|
+
else setTimeout(()=>{
|
|
75
|
+
if (-1 === focusedRef.current && null !== selectedTabIndex) setHighlightedIdx(selectedTabIndex);
|
|
76
|
+
}, 200);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const getIndexCount = useCallback(()=>containerRef.current?.querySelectorAll("[data-index]").length ?? 0, [
|
|
80
|
+
containerRef
|
|
81
|
+
]);
|
|
82
|
+
const nextFocusableItemIdx = useCallback((direction = "fwd", idx)=>{
|
|
83
|
+
const indexCount = getIndexCount();
|
|
84
|
+
const index = "number" == typeof idx ? idx : indexCount;
|
|
85
|
+
let nextIdx = nextItemIdx(indexCount, direction, index);
|
|
86
|
+
const nextDirection = "start" === direction ? "fwd" : "end" === direction ? "bwd" : direction;
|
|
87
|
+
while(("fwd" === nextDirection && nextIdx < indexCount || "bwd" === nextDirection && nextIdx > 0) && !isNonWrappedElement(getElementByDataIndex(containerRef.current, nextIdx))){
|
|
88
|
+
const newIdx = nextItemIdx(indexCount, nextDirection, nextIdx);
|
|
89
|
+
if (newIdx === nextIdx) break;
|
|
90
|
+
nextIdx = newIdx;
|
|
91
|
+
}
|
|
92
|
+
return nextIdx;
|
|
93
|
+
}, [
|
|
94
|
+
containerRef,
|
|
95
|
+
getIndexCount
|
|
96
|
+
]);
|
|
97
|
+
const navigateChildItems = useCallback((e, forceFocusVisible = false)=>{
|
|
98
|
+
const direction = navigation[orientation][e.key];
|
|
99
|
+
const nextIdx = nextFocusableItemIdx(direction, highlightedIdx);
|
|
100
|
+
if (nextIdx !== highlightedIdx) {
|
|
101
|
+
const immediateFocus = true;
|
|
102
|
+
if (manualActivation) focusTab(nextIdx, immediateFocus);
|
|
103
|
+
} else if (forceFocusVisible) forceRefresh({});
|
|
104
|
+
}, [
|
|
105
|
+
highlightedIdx,
|
|
106
|
+
manualActivation,
|
|
107
|
+
nextFocusableItemIdx,
|
|
108
|
+
focusTab,
|
|
109
|
+
orientation
|
|
110
|
+
]);
|
|
111
|
+
const highlightedTabHasMenu = useCallback(()=>{
|
|
112
|
+
const el = getElementByDataIndex(containerRef.current, highlightedIdx);
|
|
113
|
+
if (el) return null != el.querySelector(".vuuPopupMenu");
|
|
114
|
+
return false;
|
|
115
|
+
}, [
|
|
116
|
+
containerRef,
|
|
117
|
+
highlightedIdx
|
|
118
|
+
]);
|
|
119
|
+
const activateTabMenu = useCallback(()=>{
|
|
120
|
+
const el = getElementByDataIndex(containerRef.current, highlightedIdx);
|
|
121
|
+
const menuEl = el?.querySelector(".vuuPopupMenu");
|
|
122
|
+
if (menuEl) dispatchMouseEvent(menuEl, "click");
|
|
123
|
+
return false;
|
|
124
|
+
}, [
|
|
125
|
+
containerRef,
|
|
126
|
+
highlightedIdx
|
|
127
|
+
]);
|
|
128
|
+
const handleKeyDown = useCallback((e)=>{
|
|
129
|
+
if (getIndexCount() > 0 && isNavigationKey(e.key, orientation)) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
if (keyboardNavigation.current) navigateChildItems(e);
|
|
132
|
+
else {
|
|
133
|
+
keyboardNavigation.current = true;
|
|
134
|
+
navigateChildItems(e, true);
|
|
135
|
+
}
|
|
136
|
+
} else if (isMenuActivationKey(e.key) && highlightedTabHasMenu()) activateTabMenu();
|
|
137
|
+
}, [
|
|
138
|
+
activateTabMenu,
|
|
139
|
+
getIndexCount,
|
|
140
|
+
highlightedTabHasMenu,
|
|
141
|
+
navigateChildItems,
|
|
142
|
+
orientation
|
|
143
|
+
]);
|
|
144
|
+
const handleItemClick = (_, tabIndex)=>{
|
|
145
|
+
setHighlightedIdx(tabIndex);
|
|
146
|
+
};
|
|
147
|
+
const handleFocus = useCallback(()=>{
|
|
148
|
+
if (!hasFocus) {
|
|
149
|
+
setHasFocus(true);
|
|
150
|
+
if (mouseClickPending.current) mouseClickPending.current = false;
|
|
151
|
+
else keyboardNavigation.current = true;
|
|
152
|
+
}
|
|
153
|
+
}, [
|
|
154
|
+
hasFocus
|
|
155
|
+
]);
|
|
156
|
+
const handleContainerMouseDown = useCallback(()=>{
|
|
157
|
+
if (!hasFocus) mouseClickPending.current = true;
|
|
158
|
+
keyboardNavigation.current = false;
|
|
159
|
+
}, [
|
|
160
|
+
hasFocus
|
|
161
|
+
]);
|
|
162
|
+
const containerProps = {
|
|
163
|
+
onBlur: (e)=>{
|
|
164
|
+
const sourceTarget = e.target.closest(".vuuTabstrip");
|
|
165
|
+
const destTarget = e.relatedTarget;
|
|
166
|
+
if (sourceTarget && !sourceTarget?.contains(destTarget)) {
|
|
167
|
+
setHighlightedIdx(-1);
|
|
168
|
+
setHasFocus(false);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
onMouseDownCapture: handleContainerMouseDown,
|
|
172
|
+
onFocus: handleFocus,
|
|
173
|
+
onMouseLeave: ()=>{
|
|
174
|
+
keyboardNavigation.current = true;
|
|
175
|
+
setHighlightedIdx(-1);
|
|
176
|
+
mouseClickPending.current = false;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
return {
|
|
180
|
+
containerProps,
|
|
181
|
+
focusVisible: keyboardNavigation.current ? highlightedIdx : -1,
|
|
182
|
+
focusIsWithinComponent: hasFocus,
|
|
183
|
+
highlightedIdx,
|
|
184
|
+
focusTab,
|
|
185
|
+
onClick: handleItemClick,
|
|
186
|
+
onFocus,
|
|
187
|
+
onKeyDown: handleKeyDown,
|
|
188
|
+
setHighlightedIdx
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
export { useKeyboardNavigation };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useControlled } from "@salt-ds/core";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
const defaultSelectionKeys = [
|
|
4
|
+
"Enter",
|
|
5
|
+
" "
|
|
6
|
+
];
|
|
7
|
+
const isTabElement = (el)=>el && el.matches('[class*="vuuTab "]');
|
|
8
|
+
const useSelection = ({ defaultSelected, highlightedIdx, onSelectionChange, selected: selectedProp })=>{
|
|
9
|
+
const [selected, setSelected, isControlled] = useControlled({
|
|
10
|
+
controlled: selectedProp,
|
|
11
|
+
default: defaultSelected ?? 0,
|
|
12
|
+
name: "Tabstrip",
|
|
13
|
+
state: "value"
|
|
14
|
+
});
|
|
15
|
+
const isSelectionEvent = useCallback((evt)=>defaultSelectionKeys.includes(evt.key), []);
|
|
16
|
+
const selectItem = useCallback((tabIndex)=>{
|
|
17
|
+
setSelected(tabIndex);
|
|
18
|
+
onSelectionChange?.(tabIndex);
|
|
19
|
+
}, [
|
|
20
|
+
onSelectionChange,
|
|
21
|
+
setSelected
|
|
22
|
+
]);
|
|
23
|
+
const handleKeyDown = useCallback((e)=>{
|
|
24
|
+
const targetElement = e.target;
|
|
25
|
+
if (isSelectionEvent(e) && highlightedIdx !== selected && isTabElement(targetElement)) {
|
|
26
|
+
e.stopPropagation();
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
selectItem(highlightedIdx);
|
|
29
|
+
}
|
|
30
|
+
}, [
|
|
31
|
+
isSelectionEvent,
|
|
32
|
+
highlightedIdx,
|
|
33
|
+
selected,
|
|
34
|
+
selectItem
|
|
35
|
+
]);
|
|
36
|
+
const onClick = useCallback((e, tabIndex)=>{
|
|
37
|
+
if (tabIndex !== selected) selectItem(tabIndex);
|
|
38
|
+
}, [
|
|
39
|
+
selectItem,
|
|
40
|
+
selected
|
|
41
|
+
]);
|
|
42
|
+
return {
|
|
43
|
+
activateTab: selectItem,
|
|
44
|
+
isControlled,
|
|
45
|
+
onClick,
|
|
46
|
+
onKeyDown: handleKeyDown,
|
|
47
|
+
selected
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export { useSelection };
|