@vuu-ui/vuu-ui-controls 0.8.22-debug → 0.8.23-debug
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/cjs/index.js +2818 -1629
- package/cjs/index.js.map +4 -4
- package/esm/index.js +2592 -1374
- package/esm/index.js.map +4 -4
- package/index.css +220 -0
- package/index.css.map +3 -3
- package/package.json +7 -7
- package/types/calendar/internal/utils.d.ts +1 -2
- package/types/combo-box/ComboBox.d.ts +3 -1
- package/types/combo-box/useCombobox.d.ts +5 -5
- package/types/drag-drop/dragDropTypes.d.ts +12 -7
- package/types/drag-drop/drop-target-utils.d.ts +20 -28
- package/types/drag-drop/useDragDisplacers.d.ts +4 -2
- package/types/drag-drop/useDragDropCopy.d.ts +5 -1
- package/types/drag-drop/useDragDropIndicator.d.ts +1 -1
- package/types/drag-drop/useDragDropNaturalMovement.d.ts +1 -1
- package/types/dropdown/useDropdown.d.ts +1 -1
- package/types/editable/editable-utils.d.ts +1 -3
- package/types/editable/useEditableText.d.ts +1 -2
- package/types/index.d.ts +5 -0
- package/types/list/common-hooks/useCollapsibleGroups.d.ts +2 -2
- package/types/list/common-hooks/useKeyboardNavigation.d.ts +1 -1
- package/types/list/index.d.ts +0 -1
- package/types/list/listTypes.d.ts +3 -3
- package/types/list/useList.d.ts +1 -1
- package/types/list/useListHeight.d.ts +1 -3
- package/types/measured-container/MeasuredContainer.d.ts +15 -0
- package/types/measured-container/index.d.ts +2 -0
- package/types/measured-container/useMeasuredContainer.d.ts +22 -0
- package/types/measured-container/useResizeObserver.d.ts +15 -0
- package/types/overflow-container/OverflowContainer.d.ts +17 -0
- package/types/overflow-container/index.d.ts +2 -0
- package/types/overflow-container/overflow-utils.d.ts +49 -0
- package/types/overflow-container/useOverflowContainer.d.ts +20 -0
- package/types/split-button/SplitButton.d.ts +11 -0
- package/types/split-button/index.d.ts +1 -0
- package/types/split-button/useSplitButton.d.ts +289 -0
- package/types/tabstrip/useTabstrip.d.ts +1 -1
- package/types/toolbar/Toolbar.d.ts +21 -0
- package/types/toolbar/index.d.ts +1 -0
- package/types/toolbar/toolbar-dom-utils.d.ts +3 -0
- package/types/toolbar/useKeyboardNavigation.d.ts +32 -0
- package/types/toolbar/useSelection.d.ts +22 -0
- package/types/toolbar/useToolbar.d.ts +28 -0
- package/types/tree/Tree.d.ts +1 -1
- package/types/list/VirtualizedList.d.ts +0 -7
- package/types/list/useVirtualization.d.ts +0 -15
|
@@ -5,8 +5,9 @@ import { DropdownBaseProps } from "../dropdown";
|
|
|
5
5
|
import { ListProps } from "../list";
|
|
6
6
|
export interface ComboBoxProps<Item = string, S extends SelectionStrategy = "default"> extends Omit<DropdownBaseProps, "triggerComponent" | "onBlur" | "onChange" | "onFocus">, Pick<InputProps, "onBlur" | "onChange" | "onFocus" | "onSelect">, Omit<ComponentSelectionProps<Item, S>, "onSelect">, Pick<ListProps<Item, S>, "ListItem" | "itemToString" | "source" | "width"> {
|
|
7
7
|
InputProps?: InputProps;
|
|
8
|
-
ListProps?: Omit<ListProps<Item>, "ListItem" | "itemToString" | "source">;
|
|
8
|
+
ListProps?: Omit<ListProps<Item>, "ListItem" | "itemToString" | "source" | "onSelect" | "onSelectionChange">;
|
|
9
9
|
allowBackspaceClearsSelection?: boolean;
|
|
10
|
+
allowEnterCommitsText?: boolean;
|
|
10
11
|
allowFreeText?: boolean;
|
|
11
12
|
defaultValue?: string;
|
|
12
13
|
getFilterRegex?: (inputValue: string) => RegExp;
|
|
@@ -14,6 +15,7 @@ export interface ComboBoxProps<Item = string, S extends SelectionStrategy = "def
|
|
|
14
15
|
itemsToString?: (items: Item[]) => string;
|
|
15
16
|
onDeselect?: () => void;
|
|
16
17
|
onSetSelectedText?: (text: string) => void;
|
|
18
|
+
onListItemSelect?: ListProps<Item, S>["onSelect"];
|
|
17
19
|
disableFilter?: boolean;
|
|
18
20
|
value?: string;
|
|
19
21
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { InputProps } from "@salt-ds/core";
|
|
2
|
-
import {
|
|
2
|
+
import { RefCallback } from "react";
|
|
3
3
|
import { ComponentSelectionProps, MultiSelectionStrategy, SelectionStrategy } from "../common-hooks";
|
|
4
4
|
import { DropdownHookProps, DropdownHookResult, OpenChangeHandler } from "../dropdown";
|
|
5
5
|
import { ListHookProps, ListHookResult } from "../list";
|
|
6
6
|
import { ComboBoxProps } from "./ComboBox";
|
|
7
|
-
export interface ComboboxHookProps<Item = string, S extends SelectionStrategy = "default"> extends Partial<Omit<DropdownHookProps, "id" | "onKeyDown">>, Pick<InputProps, "onBlur" | "onChange" | "onFocus" | "onSelect">, Pick<ComboBoxProps<Item>, "allowBackspaceClearsSelection" | "allowFreeText" | "defaultValue" | "initialHighlightedIndex" | "itemsToString" | "onDeselect" | "onSetSelectedText" | "value">, Omit<ComponentSelectionProps<Item, S>, "onSelect">, Omit<ListHookProps<Item, S>, "containerRef" | "defaultSelected" | "onSelect" | "selected"> {
|
|
7
|
+
export interface ComboboxHookProps<Item = string, S extends SelectionStrategy = "default"> extends Partial<Omit<DropdownHookProps, "id" | "onKeyDown">>, Pick<InputProps, "onBlur" | "onChange" | "onFocus" | "onSelect">, Pick<ComboBoxProps<Item>, "allowBackspaceClearsSelection" | "allowEnterCommitsText" | "allowFreeText" | "defaultValue" | "initialHighlightedIndex" | "itemsToString" | "onDeselect" | "onSetSelectedText" | "onListItemSelect" | "value">, Omit<ComponentSelectionProps<Item, S>, "onSelect">, Omit<ListHookProps<Item, S>, "containerRef" | "defaultSelected" | "onSelect" | "selected"> {
|
|
8
8
|
InputProps?: InputProps;
|
|
9
9
|
ariaLabel?: string;
|
|
10
10
|
id: string;
|
|
11
11
|
itemCount: number;
|
|
12
12
|
itemToString?: (item: Item) => string;
|
|
13
|
-
listRef: RefObject<HTMLDivElement>;
|
|
14
13
|
}
|
|
15
14
|
export interface ComboboxHookResult<Item, S extends SelectionStrategy> extends Pick<ListHookResult<Item>, "focusVisible" | "highlightedIndex" | "listControlProps" | "listHandlers">, Partial<DropdownHookResult> {
|
|
16
|
-
|
|
15
|
+
InputProps: InputProps;
|
|
17
16
|
onOpenChange: OpenChangeHandler;
|
|
18
17
|
selected?: S extends MultiSelectionStrategy ? Item[] : Item | null;
|
|
18
|
+
setContainerRef: RefCallback<HTMLDivElement>;
|
|
19
19
|
}
|
|
20
|
-
export declare const useCombobox: <Item, S extends SelectionStrategy>({ allowBackspaceClearsSelection, allowFreeText, ariaLabel, collectionHook, defaultIsOpen, defaultSelected, defaultValue, onBlur, onFocus, onChange, onDeselect, onSelect, id, initialHighlightedIndex, isOpen: isOpenProp, itemCount, itemsToString, itemToString,
|
|
20
|
+
export declare const useCombobox: <Item, S extends SelectionStrategy>({ allowBackspaceClearsSelection, allowEnterCommitsText, allowFreeText, ariaLabel, collectionHook, defaultIsOpen, defaultSelected, defaultValue, onBlur, onFocus, onChange, onDeselect, onSelect, id, initialHighlightedIndex, isOpen: isOpenProp, itemCount, itemsToString, itemToString, onListItemSelect, onOpenChange, onSelectionChange, onSetSelectedText, selected: selectedProp, selectionKeys, selectionStrategy, value: valueProp, InputProps, }: ComboboxHookProps<Item, S>) => ComboboxHookResult<Item, S>;
|
|
@@ -47,8 +47,8 @@ export interface DragHookResult {
|
|
|
47
47
|
export interface InternalDragHookResult extends Omit<DragHookResult, "isDragging" | "isScrolling"> {
|
|
48
48
|
beginDrag: (dragElement: HTMLElement) => void;
|
|
49
49
|
drag: (dragPos: number, mouseMoveDirection: "fwd" | "bwd") => void;
|
|
50
|
-
drop: () =>
|
|
51
|
-
handleScrollStart?: () => void;
|
|
50
|
+
drop: () => DropOptions;
|
|
51
|
+
handleScrollStart?: (scrollDirection: "fwd" | "bwd") => void;
|
|
52
52
|
handleScrollStop?: (scrollDirection: "fwd" | "bwd", _scrollPos: number, atEnd: boolean) => void;
|
|
53
53
|
/**
|
|
54
54
|
* Draggable item has been dragged out of container. Remove any local drop
|
|
@@ -57,15 +57,16 @@ export interface InternalDragHookResult extends Omit<DragHookResult, "isDragging
|
|
|
57
57
|
releaseDrag?: () => void;
|
|
58
58
|
}
|
|
59
59
|
export interface DropOptions {
|
|
60
|
-
fromIndex
|
|
60
|
+
fromIndex: number;
|
|
61
61
|
toIndex: number;
|
|
62
62
|
isExternal?: boolean;
|
|
63
63
|
payload?: unknown;
|
|
64
64
|
}
|
|
65
65
|
export type DragStartHandler = (dragDropState: DragDropState) => void;
|
|
66
|
-
export type DropHandler = (
|
|
66
|
+
export type DropHandler = (options: DropOptions) => void;
|
|
67
67
|
export interface DragDropProps {
|
|
68
68
|
allowDragDrop?: boolean | dragStrategy;
|
|
69
|
+
containerRef: RefObject<HTMLElement>;
|
|
69
70
|
/** this is the className that will be assigned during drag to the dragged element */
|
|
70
71
|
draggableClassName: string;
|
|
71
72
|
extendedDropZone?: boolean;
|
|
@@ -73,16 +74,20 @@ export interface DragDropProps {
|
|
|
73
74
|
id?: string;
|
|
74
75
|
isDragSource?: boolean;
|
|
75
76
|
isDropTarget?: boolean;
|
|
77
|
+
itemQuery?: string;
|
|
76
78
|
onDragStart?: DragStartHandler;
|
|
77
79
|
onDrop: DropHandler;
|
|
78
80
|
onDropSettle?: (toIndex: number) => void;
|
|
79
81
|
orientation: orientationType;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
/**
|
|
83
|
+
* The scrolling container does not necessarily have to be a
|
|
84
|
+
* descendant of the container, it may be an ancestor element;
|
|
85
|
+
*/
|
|
86
|
+
scrollingContainerRef?: RefObject<HTMLElement>;
|
|
82
87
|
viewportRange?: ViewportRange;
|
|
83
88
|
}
|
|
84
89
|
export type DragDropHook = (props: DragDropProps) => DragHookResult;
|
|
85
|
-
export interface InternalDragDropProps extends Omit<DragDropProps, "draggableClassName" | "id"> {
|
|
90
|
+
export interface InternalDragDropProps extends Omit<DragDropProps, "draggableClassName" | "id" | "onDrop"> {
|
|
86
91
|
isDragSource?: boolean;
|
|
87
92
|
isDropTarget?: boolean;
|
|
88
93
|
selected?: unknown;
|
|
@@ -32,46 +32,37 @@ type Dimension = keyof Pick<DOMRect, "width" | "height">;
|
|
|
32
32
|
type ElementPosition = "x" | "y";
|
|
33
33
|
export declare const measureElementSizeAndPosition: (element: HTMLElement, dimension?: Dimension, includeAutoMargin?: boolean) => number[];
|
|
34
34
|
export declare const dimensions: (orientation: orientationType) => {
|
|
35
|
-
CLIENT_POS: "
|
|
36
|
-
CLIENT_SIZE: "
|
|
37
|
-
CONTRA: "width" | "height" | "left" | "right" | "
|
|
38
|
-
CONTRA_CLIENT_POS: "
|
|
35
|
+
CLIENT_POS: "clientX" | "clientY";
|
|
36
|
+
CLIENT_SIZE: "clientHeight" | "clientWidth" | "scrollHeight" | "scrollLeft" | "scrollTop" | "scrollWidth";
|
|
37
|
+
CONTRA: "width" | "height" | "left" | "right" | "bottom" | "top" | "x" | "y";
|
|
38
|
+
CONTRA_CLIENT_POS: "clientX" | "clientY";
|
|
39
39
|
CONTRA_END: "width" | "height";
|
|
40
40
|
CONTRA_POS: ElementPosition;
|
|
41
41
|
DIMENSION: "width" | "height";
|
|
42
|
-
END: "width" | "height" | "left" | "right" | "
|
|
42
|
+
END: "width" | "height" | "left" | "right" | "bottom" | "top" | "x" | "y";
|
|
43
43
|
POS: ElementPosition;
|
|
44
|
-
SCROLL_POS: "
|
|
45
|
-
SCROLL_SIZE: "
|
|
46
|
-
START: "width" | "height" | "left" | "right" | "
|
|
44
|
+
SCROLL_POS: "clientHeight" | "clientWidth" | "scrollHeight" | "scrollLeft" | "scrollTop" | "scrollWidth";
|
|
45
|
+
SCROLL_SIZE: "clientHeight" | "clientWidth" | "scrollHeight" | "scrollLeft" | "scrollTop" | "scrollWidth";
|
|
46
|
+
START: "width" | "height" | "left" | "right" | "bottom" | "top" | "x" | "y";
|
|
47
47
|
} | {
|
|
48
|
-
CLIENT_POS: "
|
|
49
|
-
CLIENT_SIZE: "
|
|
50
|
-
CONTRA: "width" | "height" | "left" | "right" | "
|
|
51
|
-
CONTRA_CLIENT_POS: "
|
|
48
|
+
CLIENT_POS: "clientX" | "clientY";
|
|
49
|
+
CLIENT_SIZE: "clientHeight" | "clientWidth" | "scrollHeight" | "scrollLeft" | "scrollTop" | "scrollWidth";
|
|
50
|
+
CONTRA: "width" | "height" | "left" | "right" | "bottom" | "top" | "x" | "y";
|
|
51
|
+
CONTRA_CLIENT_POS: "clientX" | "clientY";
|
|
52
52
|
CONTRA_END: "width" | "height";
|
|
53
53
|
CONTRA_POS: ElementPosition;
|
|
54
54
|
DIMENSION: "width" | "height";
|
|
55
|
-
END: "width" | "height" | "left" | "right" | "
|
|
55
|
+
END: "width" | "height" | "left" | "right" | "bottom" | "top" | "x" | "y";
|
|
56
56
|
POS: ElementPosition;
|
|
57
|
-
SCROLL_POS: "
|
|
58
|
-
SCROLL_SIZE: "
|
|
59
|
-
START: "width" | "height" | "left" | "right" | "
|
|
57
|
+
SCROLL_POS: "clientHeight" | "clientWidth" | "scrollHeight" | "scrollLeft" | "scrollTop" | "scrollWidth";
|
|
58
|
+
SCROLL_SIZE: "clientHeight" | "clientWidth" | "scrollHeight" | "scrollLeft" | "scrollTop" | "scrollWidth";
|
|
59
|
+
START: "width" | "height" | "left" | "right" | "bottom" | "top" | "x" | "y";
|
|
60
60
|
};
|
|
61
61
|
export declare const getItemById: (measuredItems: MeasuredDropTarget[], id: string) => MeasuredDropTarget | undefined;
|
|
62
62
|
export declare const removeDraggedItem: (measuredItems: MeasuredDropTarget[], index: number) => void;
|
|
63
63
|
export type dropZone = "start" | "end";
|
|
64
64
|
export declare const measureDropTargets: (container: HTMLElement, orientation: orientationType, itemQuery?: string, viewportRange?: ViewportRange, draggedItemId?: string) => MeasuredDropTarget[];
|
|
65
|
-
|
|
66
|
-
The index of the dropped item is its array offset within the
|
|
67
|
-
dropTargets. If there is no scrolling involved, this will be
|
|
68
|
-
the same as the 'absolute' index position. If the dropTargets have
|
|
69
|
-
been scrolled, though, we will only have a window of the full
|
|
70
|
-
dataset, corresponding to the current scroll viewport. In that case
|
|
71
|
-
we need to determine the offset and factor that into the 'absolute'
|
|
72
|
-
index.
|
|
73
|
-
*/
|
|
74
|
-
export declare const getIndexOfDraggedItem: (dropTargets: MeasuredDropTarget[], absoluteIndex?: boolean) => number;
|
|
65
|
+
export declare const getIndexOfDraggedItem: (dropTargets: MeasuredDropTarget[]) => number;
|
|
75
66
|
export declare const mutateDropTargetsSwitchDropTargetPosition: (dropTargets: MeasuredDropTarget[], direction: Direction) => void;
|
|
76
67
|
export declare const getNextDropTarget: (dropTargets: MeasuredDropTarget[], pos: number, draggedItemSize: number, mouseMoveDirection: Direction) => MeasuredDropTarget;
|
|
77
68
|
/**
|
|
@@ -81,6 +72,7 @@ export declare const getNextDropTarget: (dropTargets: MeasuredDropTarget[], pos:
|
|
|
81
72
|
*/
|
|
82
73
|
export declare function constrainRect(targetRect: Rect, constraintRect: Rect): Rect;
|
|
83
74
|
export declare const dropTargetsDebugString: (dropTargets: MeasuredDropTarget[]) => string;
|
|
84
|
-
export declare const
|
|
85
|
-
export declare const
|
|
75
|
+
export declare const getItemParentContainer: (container: HTMLElement | null, itemQuery: string) => HTMLElement | null;
|
|
76
|
+
export declare const getScrollableContainer: (container: HTMLElement | null, itemQuery: string) => HTMLElement | null;
|
|
77
|
+
export declare const isContainerScrollable: (scrollableContainer: HTMLElement | null, orientation: orientationType) => boolean;
|
|
86
78
|
export {};
|
|
@@ -2,9 +2,11 @@ import type { orientationType } from "@vuu-ui/vuu-utils";
|
|
|
2
2
|
import { Direction } from "./dragDropTypes";
|
|
3
3
|
import { MeasuredDropTarget } from "./drop-target-utils";
|
|
4
4
|
export type DragDisplacersHookResult = {
|
|
5
|
-
displaceItem: (dropTargets: MeasuredDropTarget[], dropTarget: MeasuredDropTarget, size: number, useTransition?: boolean, direction?: Direction | "static", orientation?: "horizontal" | "vertical") =>
|
|
6
|
-
displaceLastItem: (dropTargets: MeasuredDropTarget[], dropTarget: MeasuredDropTarget, size: number, useTransition?: boolean, direction?: Direction | "static", orientation?: "horizontal" | "vertical") =>
|
|
5
|
+
displaceItem: (dropTargets: MeasuredDropTarget[], dropTarget: MeasuredDropTarget, size: number, useTransition?: boolean, direction?: Direction | "static", orientation?: "horizontal" | "vertical") => number;
|
|
6
|
+
displaceLastItem: (dropTargets: MeasuredDropTarget[], dropTarget: MeasuredDropTarget, size: number, useTransition?: boolean, direction?: Direction | "static", orientation?: "horizontal" | "vertical") => number;
|
|
7
7
|
clearSpacers: (useAnimation?: boolean) => void;
|
|
8
|
+
/** Insert the sized spacer at start or end of collection */
|
|
9
|
+
setTerminalSpacer: (container: HTMLElement, position: "start" | "end", size: number) => void;
|
|
8
10
|
};
|
|
9
11
|
export type DragDisplacersHook = (orientation: orientationType) => DragDisplacersHookResult;
|
|
10
12
|
/**
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import { InternalDragDropProps, InternalDragHookResult } from "./dragDropTypes";
|
|
1
|
+
import type { InternalDragDropProps, InternalDragHookResult } from "./dragDropTypes";
|
|
2
|
+
export declare const NULL_DROP_OPTIONS: {
|
|
3
|
+
readonly fromIndex: -1;
|
|
4
|
+
readonly toIndex: -1;
|
|
5
|
+
};
|
|
2
6
|
export declare const useDragDropCopy: ({ selected, viewportRange, }: InternalDragDropProps) => InternalDragHookResult;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { InternalDragDropProps, InternalDragHookResult } from "./dragDropTypes";
|
|
2
|
-
export declare const useDragDropIndicator: ({
|
|
2
|
+
export declare const useDragDropIndicator: ({ orientation, containerRef, itemQuery, selected, viewportRange, }: InternalDragDropProps) => InternalDragHookResult;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { InternalDragDropProps, InternalDragHookResult } from "./dragDropTypes";
|
|
2
|
-
export declare const useDragDropNaturalMovement: ({
|
|
2
|
+
export declare const useDragDropNaturalMovement: ({ containerRef, orientation, itemQuery, selected, viewportRange, }: InternalDragDropProps) => InternalDragHookResult;
|
|
@@ -10,4 +10,4 @@ export interface DropdownListHookResult<Item> extends Partial<ListHookResult<Ite
|
|
|
10
10
|
onOpenChange: any;
|
|
11
11
|
triggerLabel?: string;
|
|
12
12
|
}
|
|
13
|
-
export declare const useDropdown: <Item, S extends SelectionStrategy>({ collectionHook, defaultHighlightedIndex: defaultHighlightedIndexProp, defaultIsOpen, defaultSelected, highlightedIndex: highlightedIndexProp, isOpen: isOpenProp, itemToString,
|
|
13
|
+
export declare const useDropdown: <Item, S extends SelectionStrategy>({ collectionHook, defaultHighlightedIndex: defaultHighlightedIndexProp, defaultIsOpen, defaultSelected, highlightedIndex: highlightedIndexProp, isOpen: isOpenProp, itemToString, onHighlight, onOpenChange, onSelectionChange, onSelect, selected, selectionStrategy, }: DropdownListHookProps<Item, S>) => DropdownListHookResult<Item>;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { EditValidationRule } from "@vuu-ui/vuu-table-types";
|
|
2
|
-
import { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
-
export type ClientSideValidationChecker = (value?: VuuRowDataItemType) => string | false | undefined;
|
|
1
|
+
import { ClientSideValidationChecker, EditValidationRule } from "@vuu-ui/vuu-table-types";
|
|
4
2
|
export declare const buildValidationChecker: (rules: EditValidationRule[]) => ClientSideValidationChecker;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DataItemCommitHandler } from "@vuu-ui/vuu-table-types";
|
|
1
|
+
import { ClientSideValidationChecker, DataItemCommitHandler } from "@vuu-ui/vuu-table-types";
|
|
2
2
|
import { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
3
3
|
import { FocusEventHandler, FormEventHandler, KeyboardEvent } from "react";
|
|
4
|
-
import { ClientSideValidationChecker } from "./editable-utils";
|
|
5
4
|
export declare const WarnCommit: () => Promise<true>;
|
|
6
5
|
export interface EditableTextHookProps<T extends VuuRowDataItemType = VuuRowDataItemType> {
|
|
7
6
|
clientSideEditValidationCheck?: ClientSideValidationChecker;
|
package/types/index.d.ts
CHANGED
|
@@ -12,8 +12,13 @@ export * from "./inputs";
|
|
|
12
12
|
export * from "./instrument-picker";
|
|
13
13
|
export * from "./instrument-search";
|
|
14
14
|
export * from "./list";
|
|
15
|
+
export * from "./measured-container";
|
|
16
|
+
export * from "./overflow-container";
|
|
15
17
|
export * from "./price-ticker";
|
|
18
|
+
export * from "./price-ticker";
|
|
19
|
+
export * from "./split-button";
|
|
16
20
|
export * from "./tabstrip";
|
|
21
|
+
export * from "./toolbar";
|
|
17
22
|
export * from "./tree";
|
|
18
23
|
export * from "./utils";
|
|
19
24
|
export * from "./vuu-input";
|
|
@@ -6,9 +6,9 @@ interface CollapsibleHookProps<Item> {
|
|
|
6
6
|
highlightedIdx: number;
|
|
7
7
|
onToggle?: (node: Item) => void;
|
|
8
8
|
}
|
|
9
|
-
interface CollapsibleHookResult
|
|
9
|
+
interface CollapsibleHookResult {
|
|
10
10
|
onClick?: ListHandlers["onClick"];
|
|
11
11
|
onKeyDown?: ListHandlers["onKeyDown"];
|
|
12
12
|
}
|
|
13
|
-
export declare const useCollapsibleGroups: <Item>({ collapsibleHeaders, collectionHook, highlightedIdx, onToggle, }: CollapsibleHookProps<Item>) => CollapsibleHookResult
|
|
13
|
+
export declare const useCollapsibleGroups: <Item>({ collapsibleHeaders, collectionHook, highlightedIdx, onToggle, }: CollapsibleHookProps<Item>) => CollapsibleHookResult;
|
|
14
14
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NavigationHookProps, NavigationHookResult } from "../../common-hooks";
|
|
2
2
|
export declare const LIST_FOCUS_VISIBLE = -2;
|
|
3
|
-
export declare const useKeyboardNavigation: ({ containerRef, defaultHighlightedIndex, disableHighlightOnFocus, highlightedIndex: highlightedIndexProp, itemCount, onHighlight, onKeyboardNavigation, restoreLastFocus, selected, viewportItemCount, }: NavigationHookProps) => NavigationHookResult;
|
|
3
|
+
export declare const useKeyboardNavigation: ({ containerRef, defaultHighlightedIndex, disableHighlightOnFocus, highlightedIndex: highlightedIndexProp, itemCount, onHighlight, onKeyboardNavigation, restoreLastFocus, selected, viewportItemCount: _, }: NavigationHookProps) => NavigationHookResult;
|
package/types/list/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FocusEventHandler, ForwardedRef, HTMLAttributes, KeyboardEvent, KeyboardEventHandler, MouseEventHandler, PropsWithChildren, Ref, RefObject } from "react";
|
|
1
|
+
import React, { FocusEventHandler, ForwardedRef, HTMLAttributes, KeyboardEvent, KeyboardEventHandler, MouseEventHandler, PropsWithChildren, Ref, RefCallback, RefObject } from "react";
|
|
2
2
|
import { ScrollingAPI, ViewportTrackingResult } from "./common-hooks";
|
|
3
3
|
import { CollectionHookResult, ComponentSelectionProps, ListHandlers, NavigationHookResult, SelectionHookResult, SelectionStrategy } from "../common-hooks";
|
|
4
4
|
import { DragHookResult, DragStartHandler, dragStrategy, DropHandler } from "../drag-drop";
|
|
@@ -173,7 +173,6 @@ export interface ListControlProps {
|
|
|
173
173
|
}
|
|
174
174
|
export interface ListHookProps<Item = string, S extends SelectionStrategy = "default"> extends Pick<ListProps<Item, S>, "allowDragDrop" | "collapsibleHeaders" | "disabled" | "id" | "onClick" | "onDragStart" | "onDrop" | "onHighlight" | "onMoveListItem" | "onSelect" | "onSelectionChange" | "restoreLastFocus" | "selectionKeys" | "selectionStrategy" | "stickyHeaders" | "tabToSelect"> {
|
|
175
175
|
collectionHook: CollectionHookResult<Item>;
|
|
176
|
-
containerRef: RefObject<HTMLElement>;
|
|
177
176
|
contentRef?: RefObject<HTMLElement>;
|
|
178
177
|
defaultHighlightedIndex?: number;
|
|
179
178
|
defaultSelected?: string[];
|
|
@@ -186,11 +185,12 @@ export interface ListHookProps<Item = string, S extends SelectionStrategy = "def
|
|
|
186
185
|
listHandlers?: ListHandlers;
|
|
187
186
|
onKeyboardNavigation?: (event: React.KeyboardEvent, currentIndex: number) => void;
|
|
188
187
|
onKeyDown?: (evt: KeyboardEvent) => void;
|
|
189
|
-
scrollContainerRef?: RefObject<HTMLElement>;
|
|
190
188
|
selected?: string[];
|
|
191
189
|
viewportRange?: ViewportRange;
|
|
192
190
|
}
|
|
193
191
|
export interface ListHookResult<Item> extends Partial<ViewportTrackingResult<Item>>, Pick<SelectionHookResult, "selected" | "setSelected">, Partial<Omit<NavigationHookResult, "listProps">>, Omit<DragHookResult, "isDragging" | "isScrolling"> {
|
|
192
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
193
|
+
setContainerRef: RefCallback<HTMLDivElement>;
|
|
194
194
|
keyboardNavigation: RefObject<boolean>;
|
|
195
195
|
listHandlers: ListHandlers;
|
|
196
196
|
listItemHeaderHandlers: Partial<ListHandlers>;
|
package/types/list/useList.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SelectionStrategy } from "../common-hooks";
|
|
2
2
|
import { ListHookProps, ListHookResult } from "./listTypes";
|
|
3
|
-
export declare const useList: <Item, S extends SelectionStrategy>({ allowDragDrop, collapsibleHeaders, collectionHook: dataHook,
|
|
3
|
+
export declare const useList: <Item, S extends SelectionStrategy>({ allowDragDrop, collapsibleHeaders, collectionHook: dataHook, contentRef, defaultHighlightedIndex, defaultSelected, disabled, disableAriaActiveDescendant, disableHighlightOnFocus, disableTypeToSelect, highlightedIndex: highlightedIndexProp, id, label, listHandlers: listHandlersProp, onClick: onClickProp, onDragStart, onDrop, onHighlight, onKeyboardNavigation, onKeyDown, onMoveListItem, onSelect, onSelectionChange, restoreLastFocus, selected, selectionStrategy, selectionKeys, stickyHeaders, tabToSelect, viewportRange, }: ListHookProps<Item, S>) => ListHookResult<Item>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { MeasuredSize } from "@vuu-ui/vuu-
|
|
2
|
-
import { RefObject } from "react";
|
|
1
|
+
import { MeasuredSize } from "@vuu-ui/vuu-ui-controls";
|
|
3
2
|
export interface ListHeightHookProps {
|
|
4
3
|
displayedItemCount: number;
|
|
5
4
|
getItemHeight?: (index: number) => number;
|
|
@@ -7,7 +6,6 @@ export interface ListHeightHookProps {
|
|
|
7
6
|
itemCount: number;
|
|
8
7
|
itemGapSize: number;
|
|
9
8
|
itemHeight?: number;
|
|
10
|
-
rootRef: RefObject<HTMLElement>;
|
|
11
9
|
size: MeasuredSize | undefined;
|
|
12
10
|
}
|
|
13
11
|
export interface HeightHookResult {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
import { MeasuredSize } from "./useMeasuredContainer";
|
|
3
|
+
import "./MeasuredContainer.css";
|
|
4
|
+
export interface MeasuredContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* A numeric value for height will result in a fixed height. To adapt to container
|
|
7
|
+
* use either a percentage height or 'auto'. Always use 'auto' when rendering
|
|
8
|
+
* within a column based flex container, together with a flex value (use the
|
|
9
|
+
* --vuuMeasuredContainer-flex CSS custom property))
|
|
10
|
+
*/
|
|
11
|
+
height?: number | string;
|
|
12
|
+
onResize?: (size: MeasuredSize) => void;
|
|
13
|
+
width?: number | string;
|
|
14
|
+
}
|
|
15
|
+
export declare const MeasuredContainer: import("react").ForwardRefExoticComponent<MeasuredContainerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CSSProperties, RefObject } from "react";
|
|
2
|
+
import { MeasuredContainerProps } from "./MeasuredContainer";
|
|
3
|
+
export interface ClientSize {
|
|
4
|
+
clientHeight: number;
|
|
5
|
+
clientWidth: number;
|
|
6
|
+
}
|
|
7
|
+
export interface MeasuredProps extends Pick<MeasuredContainerProps, "height" | "onResize" | "width"> {
|
|
8
|
+
defaultHeight?: number;
|
|
9
|
+
defaultWidth?: number;
|
|
10
|
+
}
|
|
11
|
+
export type CssSize = Pick<CSSProperties, "height" | "width">;
|
|
12
|
+
export interface MeasuredSize {
|
|
13
|
+
height: number;
|
|
14
|
+
width: number;
|
|
15
|
+
}
|
|
16
|
+
export interface MeasuredContainerHookResult {
|
|
17
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
18
|
+
cssSize: CssSize;
|
|
19
|
+
outerSize: CssSize;
|
|
20
|
+
innerSize?: MeasuredSize;
|
|
21
|
+
}
|
|
22
|
+
export declare const useMeasuredContainer: ({ defaultHeight, defaultWidth, height, onResize: onResizeProp, width, }: MeasuredProps) => MeasuredContainerHookResult;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
export declare const WidthHeight: string[];
|
|
3
|
+
export declare const WidthOnly: string[];
|
|
4
|
+
export type measurements<T = string | number> = {
|
|
5
|
+
height?: T;
|
|
6
|
+
clientHeight?: number;
|
|
7
|
+
clientWidth?: number;
|
|
8
|
+
contentHeight?: number;
|
|
9
|
+
contentWidth?: number;
|
|
10
|
+
scrollHeight?: number;
|
|
11
|
+
scrollWidth?: number;
|
|
12
|
+
width?: T;
|
|
13
|
+
};
|
|
14
|
+
export type ResizeHandler = (measurements: measurements<number>) => void;
|
|
15
|
+
export declare function useResizeObserver(ref: RefObject<Element | HTMLElement | null>, dimensions: readonly string[], onResize: ResizeHandler, reportInitialSize?: boolean): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PopupMenuProps } from "@vuu-ui/vuu-popups";
|
|
2
|
+
import { orientationType } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import React, { HTMLAttributes } from "react";
|
|
4
|
+
import { OverflowItem } from "./overflow-utils";
|
|
5
|
+
import "./OverflowContainer.css";
|
|
6
|
+
export interface OverflowContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
PopupMenuProps?: Partial<PopupMenuProps>;
|
|
8
|
+
allowDragDrop?: boolean;
|
|
9
|
+
debugId?: string;
|
|
10
|
+
height: number;
|
|
11
|
+
onMoveItem?: (fromIndex: number, toIndex: number) => void;
|
|
12
|
+
onSwitchWrappedItemIntoView?: (overflowItem: OverflowItem) => void;
|
|
13
|
+
orientation?: orientationType;
|
|
14
|
+
overflowIcon?: string;
|
|
15
|
+
overflowPosition?: "start" | "end" | number;
|
|
16
|
+
}
|
|
17
|
+
export declare const OverflowContainer: React.ForwardRefExoticComponent<OverflowContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { orientationType } from "@vuu-ui/vuu-utils";
|
|
2
|
+
export type OverflowItem = {
|
|
3
|
+
index: string;
|
|
4
|
+
label: string;
|
|
5
|
+
overflowPriority: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const isOverflowElement: (element: HTMLElement | null) => boolean;
|
|
8
|
+
export declare const sortByScreenOrder: (elements: HTMLElement[]) => HTMLElement[];
|
|
9
|
+
export declare const NO_WRAPPED_ITEMS: OverflowItem[];
|
|
10
|
+
/**
|
|
11
|
+
Identify wrapped items by comparing position of each item. Any item
|
|
12
|
+
not to the right of preceeding item has wrapped. Note: on-screen
|
|
13
|
+
position of items does not necessarily match document position, due
|
|
14
|
+
to use of css order. This is taken into account by sorting.
|
|
15
|
+
TODO support Vertical orientation
|
|
16
|
+
*/
|
|
17
|
+
export declare const getNonWrappedAndWrappedItems: (container: HTMLElement, orientation?: orientationType) => [OverflowItem[], OverflowItem[]];
|
|
18
|
+
export declare const applyOverflowClassToWrappedItems: (container: HTMLElement, overflowedItems: OverflowItem[], classBase?: string) => void;
|
|
19
|
+
export declare const overflowIndicatorHasWrappedButShouldNotHave: (wrappedItems: OverflowItem[]) => boolean;
|
|
20
|
+
export declare const highPriorityItemsHaveWrappedButShouldNotHave: (nonWrappedItems: OverflowItem[], wrappedItems: OverflowItem[]) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
An edge case that may occur when reducing width from unwrapped to
|
|
23
|
+
wrapped, or on first render.
|
|
24
|
+
We overflow one or more items. Then, when the overflowIndicator assumes
|
|
25
|
+
full width, it may itself overflow.
|
|
26
|
+
*/
|
|
27
|
+
export declare const correctForWrappedOverflowIndicator: (container: HTMLElement, overflowedItems: OverflowItem[]) => Promise<OverflowItem[]>;
|
|
28
|
+
/**
|
|
29
|
+
An edge case that may occur when reducing width from unwrapped to
|
|
30
|
+
wrapped, or on first render.
|
|
31
|
+
We overflow one or more items. Then, when the overflowIndicator assumes
|
|
32
|
+
full width, it may itself overflow.
|
|
33
|
+
*/
|
|
34
|
+
export declare const correctForWrappedHighPriorityItems: (container: HTMLElement, nonWrapped: OverflowItem[], wrapped: OverflowItem[]) => Promise<[OverflowItem[], OverflowItem[]]>;
|
|
35
|
+
export declare const markElementAsWrapped: (container: HTMLElement, item: OverflowItem) => void;
|
|
36
|
+
export declare const getElementsMarkedAsWrapped: (container: HTMLElement) => HTMLElement[];
|
|
37
|
+
export declare const unmarkItemsWhichAreNoLongerWrapped: (container: HTMLElement, wrappedItems: OverflowItem[]) => void;
|
|
38
|
+
/**
|
|
39
|
+
An edge case. If container has grown but we still have one
|
|
40
|
+
wrapped item - could the wrapped item return to the fold if the overflow
|
|
41
|
+
indicaor were removed ?
|
|
42
|
+
*/
|
|
43
|
+
export declare const removeOverflowIndicatorIfNoLongerNeeded: (container: HTMLElement) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* This is used both when an overflow menu is used to select an overflowed item
|
|
46
|
+
* and when a high priority item has overflowed, whilst lower priority items
|
|
47
|
+
* remain in view.
|
|
48
|
+
*/
|
|
49
|
+
export declare const switchWrappedItemIntoView: (container: HTMLElement, overflowItem: OverflowItem) => [OverflowItem[], OverflowItem[]];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MenuActionHandler, MenuBuilder } from "@vuu-ui/vuu-data-types";
|
|
3
|
+
import { OverflowItem } from "./overflow-utils";
|
|
4
|
+
import { OverflowContainerProps } from "./OverflowContainer";
|
|
5
|
+
export interface OverflowContainerHookProps extends Pick<OverflowContainerProps, "allowDragDrop" | "onMoveItem" | "orientation"> {
|
|
6
|
+
itemCount: number;
|
|
7
|
+
onSwitchWrappedItemIntoView?: (overflowItem: OverflowItem) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const useOverflowContainer: ({ allowDragDrop, itemCount, onMoveItem, onSwitchWrappedItemIntoView, orientation, }: OverflowContainerHookProps) => {
|
|
10
|
+
draggable?: JSX.Element | undefined;
|
|
11
|
+
dropIndicator?: JSX.Element | undefined;
|
|
12
|
+
draggedItemIndex?: number | undefined;
|
|
13
|
+
isDragging: boolean;
|
|
14
|
+
isScrolling: import("react").RefObject<boolean>;
|
|
15
|
+
revealOverflowedItems?: boolean | undefined;
|
|
16
|
+
menuActionHandler: MenuActionHandler;
|
|
17
|
+
menuBuilder: MenuBuilder<string, unknown>;
|
|
18
|
+
onItemMouseDown: import("react").MouseEventHandler<Element> | undefined;
|
|
19
|
+
rootRef: (el: HTMLDivElement | null) => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PopupMenuProps } from "@vuu-ui/vuu-popups";
|
|
2
|
+
import { ButtonProps } from "@salt-ds/core";
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
import "./SplitButton.css";
|
|
5
|
+
export interface SplitButtonProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
ButtonProps?: Partial<ButtonProps>;
|
|
7
|
+
PopupMenuProps?: Partial<PopupMenuProps>;
|
|
8
|
+
buttonText: string;
|
|
9
|
+
segmented?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const SplitButton: ({ ButtonProps: ButtonPropsProp, PopupMenuProps: PopupMenuPropsProp, buttonText, onClick, segmented, ...htmlAttributes }: SplitButtonProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SplitButton";
|