@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,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { Button } from "@salt-ds/core";
|
|
4
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
5
|
+
import { useWindow } from "@salt-ds/window";
|
|
6
|
+
import { Icon } from "./Icon.js";
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import IconButton_0 from "./IconButton.css";
|
|
9
|
+
const classBase = "vuuIconButton";
|
|
10
|
+
const IconButton_IconButton = /*#__PURE__*/ forwardRef(function({ "aria-label": ariaLabel, className, icon, size, ...buttonProps }, ref) {
|
|
11
|
+
const targetWindow = useWindow();
|
|
12
|
+
useComponentCssInjection({
|
|
13
|
+
testId: "vuu-icon-button",
|
|
14
|
+
css: IconButton_0,
|
|
15
|
+
window: targetWindow
|
|
16
|
+
});
|
|
17
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
18
|
+
...buttonProps,
|
|
19
|
+
className: clsx(classBase, className),
|
|
20
|
+
ref: ref,
|
|
21
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
22
|
+
"aria-label": ariaLabel,
|
|
23
|
+
name: icon,
|
|
24
|
+
size: size
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
export { IconButton_IconButton as IconButton };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
.vuuToggleIconButton {
|
|
3
|
+
&.saltButton {
|
|
4
|
+
&:active {
|
|
5
|
+
--saltButton-background-active: transparent;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&:hover {
|
|
9
|
+
--saltButton-background-hover: transparent;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
& .vuuIcon {
|
|
13
|
+
--vuu-icon-height: 18px;
|
|
14
|
+
--vuu-icon-left: -3px;
|
|
15
|
+
--vuu-icon-width: 18px;
|
|
16
|
+
|
|
17
|
+
&:after {
|
|
18
|
+
transition: transform .1s linear;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&[data-icon="triangle-down"]:after {
|
|
22
|
+
--vuu-icon-left: -1px;
|
|
23
|
+
--vuu-icon-top: -3px;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
border: none;
|
|
28
|
+
border-radius: 0;
|
|
29
|
+
width: 18px;
|
|
30
|
+
min-width: 18px;
|
|
31
|
+
height: 18px;
|
|
32
|
+
padding: 0;
|
|
33
|
+
left: 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.vuuTableGroupCell:hover {
|
|
38
|
+
& .vuuToggleIconButton {
|
|
39
|
+
& .vuuIcon:after {
|
|
40
|
+
--vuu-icon-color: var(--salt-palette-interact-cta-background-hover);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
`;
|
|
47
|
+
export default css;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
3
|
+
import { useWindow } from "@salt-ds/window";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
import { IconButton } from "./IconButton.js";
|
|
6
|
+
import ToggleIconButton from "./ToggleIconButton.css";
|
|
7
|
+
const classBase = "vuuToggleIconButton";
|
|
8
|
+
const ToggleIconButton_ToggleIconButton = ({ className, isExpanded, size = 7, ...props })=>{
|
|
9
|
+
const targetWindow = useWindow();
|
|
10
|
+
useComponentCssInjection({
|
|
11
|
+
testId: "vuu-toggle-icon-button",
|
|
12
|
+
css: ToggleIconButton,
|
|
13
|
+
window: targetWindow
|
|
14
|
+
});
|
|
15
|
+
const icon = isExpanded ? "triangle-down" : "triangle-right";
|
|
16
|
+
return /*#__PURE__*/ jsx(IconButton, {
|
|
17
|
+
...props,
|
|
18
|
+
appearance: "transparent",
|
|
19
|
+
className: clsx(classBase, className),
|
|
20
|
+
"data-embedded": true,
|
|
21
|
+
icon: icon,
|
|
22
|
+
sentiment: "neutral",
|
|
23
|
+
size: size
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export { ToggleIconButton_ToggleIconButton as ToggleIconButton };
|
package/src/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * from "./calendar/index.js";
|
|
2
|
+
export * from "./column-picker/index.js";
|
|
3
|
+
export * from "./common-hooks/index.js";
|
|
4
|
+
export * from "./cycle-state-button/index.js";
|
|
5
|
+
export * from "./date-input/index.js";
|
|
6
|
+
export * from "./date-picker/index.js";
|
|
7
|
+
export * from "./drag-drop/index.js";
|
|
8
|
+
export * from "./editable/index.js";
|
|
9
|
+
export * from "./editable-label/index.js";
|
|
10
|
+
export * from "./expando-input/index.js";
|
|
11
|
+
export * from "./icon-button/index.js";
|
|
12
|
+
export * from "./instrument-picker/index.js";
|
|
13
|
+
export * from "./measured-container/index.js";
|
|
14
|
+
export * from "./overflow-container/index.js";
|
|
15
|
+
export * from "./price-ticker/index.js";
|
|
16
|
+
export * from "./split-button/index.js";
|
|
17
|
+
export * from "./table-search/index.js";
|
|
18
|
+
export * from "./tabs-next/index.js";
|
|
19
|
+
export * from "./tabstrip/index.js";
|
|
20
|
+
export * from "./toolbar/index.js";
|
|
21
|
+
export * from "./utils/index.js";
|
|
22
|
+
export * from "./vuu-date-picker/index.js";
|
|
23
|
+
export * from "./vuu-input/index.js";
|
|
24
|
+
export * from "./vuu-typeahead-input/index.js";
|
|
25
|
+
export { ContextPanelProvider, useContextPanel, useHideContextPanel } from "./context-panel-provider/ContextPanelProvider.js";
|
|
26
|
+
export { HoverOverlay } from "./hover-overlay/HoverOverlay.js";
|
|
27
|
+
export { ModalProvider, useModal } from "./modal-provider/ModalProvider.js";
|
|
28
|
+
export { Prompt } from "./prompt/Prompt.js";
|
|
29
|
+
export { SortableList, SortableOption } from "./sortable-list/SortableList.js";
|
|
30
|
+
export { TimeInput } from "./time-input/TimeInput.js";
|
|
31
|
+
export { VuuTimePicker } from "./vuu-time-picker/VuuTimePicker.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
.vuuSearchCell {
|
|
3
|
+
--vuu-icon-left: 0;
|
|
4
|
+
--vuu-icon-size: 16px;
|
|
5
|
+
--vuu-icon-top: 0px;
|
|
6
|
+
color: var(--background-cell-color);
|
|
7
|
+
z-index: -1;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: 4px;
|
|
10
|
+
padding: 0 8px;
|
|
11
|
+
display: flex;
|
|
12
|
+
position: relative;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
`;
|
|
17
|
+
export default css;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
3
|
+
import { useWindow } from "@salt-ds/window";
|
|
4
|
+
import { registerComponent } from "@vuu-ui/vuu-utils";
|
|
5
|
+
import SearchCell from "./SearchCell.css";
|
|
6
|
+
const classBase = "vuuSearchCell";
|
|
7
|
+
const SearchCell_SearchCell = ({ column, dataRow })=>{
|
|
8
|
+
const targetWindow = useWindow();
|
|
9
|
+
useComponentCssInjection({
|
|
10
|
+
testId: "vuu-search-cell",
|
|
11
|
+
css: SearchCell,
|
|
12
|
+
window: targetWindow
|
|
13
|
+
});
|
|
14
|
+
const value = dataRow[column.name];
|
|
15
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
16
|
+
className: classBase,
|
|
17
|
+
tabIndex: -1,
|
|
18
|
+
children: [
|
|
19
|
+
/*#__PURE__*/ jsx("span", {
|
|
20
|
+
"data-icon": "draggable"
|
|
21
|
+
}),
|
|
22
|
+
value
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
registerComponent("search-cell", SearchCell_SearchCell, "cell-renderer", {
|
|
27
|
+
serverDataType: "private"
|
|
28
|
+
});
|
|
29
|
+
export { SearchCell_SearchCell as SearchCell };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
.vuuTablePicker {
|
|
3
|
+
height: var(--salt-size-base);
|
|
4
|
+
box-sizing: content-box;
|
|
5
|
+
border-radius: 6px;
|
|
6
|
+
padding: 1px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.vuuTablePicker-floating-table {
|
|
10
|
+
border: solid 1px var(--salt-container-secondary-borderColor);
|
|
11
|
+
padding: var(--salt-spacing-100) 0;
|
|
12
|
+
z-index: var(--salt-zIndex-popout);
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
overflow: auto;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[data-floating-ui-portal] [data-floating-ui-portal] .vuuTablePicker-floating-table {
|
|
18
|
+
z-index: calc(var(--salt-zIndex-modal) + var(--salt-zIndex-popout));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
`;
|
|
23
|
+
export default css;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Table } from "@vuu-ui/vuu-table";
|
|
3
|
+
import { Input, useFloatingComponent, useIdMemo } from "@salt-ds/core";
|
|
4
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
5
|
+
import { useWindow } from "@salt-ds/window";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { forwardRef, useMemo } from "react";
|
|
8
|
+
import { IconButton } from "../icon-button/index.js";
|
|
9
|
+
import TablePicker from "./TablePicker.css";
|
|
10
|
+
import { useTablePicker } from "./useTablePicker.js";
|
|
11
|
+
const classBase = "vuuTablePicker";
|
|
12
|
+
const TablePicker_FloatingTable = /*#__PURE__*/ forwardRef(function({ children, className, collapsed, open, ...props }, forwardedRef) {
|
|
13
|
+
const { Component: FloatingComponent } = useFloatingComponent();
|
|
14
|
+
return /*#__PURE__*/ jsx(FloatingComponent, {
|
|
15
|
+
className: clsx(`${classBase}-floating-table`, {
|
|
16
|
+
[`${classBase}-collapsed`]: collapsed
|
|
17
|
+
}, className),
|
|
18
|
+
role: "listbox",
|
|
19
|
+
open: open,
|
|
20
|
+
...props,
|
|
21
|
+
ref: forwardedRef,
|
|
22
|
+
children: children
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
const TablePicker_TablePicker = ({ TableProps, onSelect, rowToString, schema, searchColumns, ...htmlAttributes })=>{
|
|
26
|
+
const targetWindow = useWindow();
|
|
27
|
+
useComponentCssInjection({
|
|
28
|
+
testId: "vuu-table-picker",
|
|
29
|
+
css: TablePicker,
|
|
30
|
+
window: targetWindow
|
|
31
|
+
});
|
|
32
|
+
const tableId = useIdMemo();
|
|
33
|
+
const { containerRef, dataSource, highlightedIndex, floatingUIProps: { x, y, strategy, floating, reference }, inputProps, interactionPropGetters: { getFloatingProps, getReferenceProps }, onKeyDown, open, tableConfig, tableHandlers, tableRef, value, width } = useTablePicker({
|
|
34
|
+
TableProps,
|
|
35
|
+
rowToString,
|
|
36
|
+
onSelect,
|
|
37
|
+
schema,
|
|
38
|
+
searchColumns
|
|
39
|
+
});
|
|
40
|
+
const endAdornment = useMemo(()=>/*#__PURE__*/ jsx(IconButton, {
|
|
41
|
+
...getReferenceProps(),
|
|
42
|
+
appearance: "transparent",
|
|
43
|
+
"data-embedded": true,
|
|
44
|
+
ref: reference,
|
|
45
|
+
icon: "chevron-down",
|
|
46
|
+
onKeyDown: onKeyDown,
|
|
47
|
+
sentiment: "neutral"
|
|
48
|
+
}), [
|
|
49
|
+
getReferenceProps,
|
|
50
|
+
onKeyDown,
|
|
51
|
+
reference
|
|
52
|
+
]);
|
|
53
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
54
|
+
...htmlAttributes,
|
|
55
|
+
className: classBase,
|
|
56
|
+
ref: containerRef,
|
|
57
|
+
children: [
|
|
58
|
+
/*#__PURE__*/ jsx(Input, {
|
|
59
|
+
...inputProps,
|
|
60
|
+
bordered: true,
|
|
61
|
+
endAdornment: endAdornment,
|
|
62
|
+
value: value
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ jsx(TablePicker_FloatingTable, {
|
|
65
|
+
...getFloatingProps(),
|
|
66
|
+
collapsed: !open,
|
|
67
|
+
id: tableId,
|
|
68
|
+
open: open,
|
|
69
|
+
left: x + 3,
|
|
70
|
+
position: strategy,
|
|
71
|
+
ref: floating,
|
|
72
|
+
top: y + 3,
|
|
73
|
+
children: /*#__PURE__*/ jsx(Table, {
|
|
74
|
+
...tableHandlers,
|
|
75
|
+
config: tableConfig,
|
|
76
|
+
dataSource: dataSource,
|
|
77
|
+
highlightedIndex: highlightedIndex,
|
|
78
|
+
maxViewportRowLimit: 10,
|
|
79
|
+
navigationStyle: "row",
|
|
80
|
+
ref: tableRef,
|
|
81
|
+
selectionModel: "single",
|
|
82
|
+
showColumnHeaders: false,
|
|
83
|
+
width: width - 3
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
export { TablePicker_TablePicker as TablePicker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TablePicker.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { WindowRange, metadataKeys } from "@vuu-ui/vuu-utils";
|
|
2
|
+
const { SELECTED: SELECTED } = metadataKeys;
|
|
3
|
+
class MovingWindow {
|
|
4
|
+
data;
|
|
5
|
+
rowCount = 0;
|
|
6
|
+
range;
|
|
7
|
+
constructor({ from, to }){
|
|
8
|
+
this.range = new WindowRange(from, to);
|
|
9
|
+
this.data = new Array(to - from);
|
|
10
|
+
this.rowCount = 0;
|
|
11
|
+
}
|
|
12
|
+
setRowCount = (rowCount)=>{
|
|
13
|
+
if (rowCount < this.data.length) this.data.length = rowCount;
|
|
14
|
+
this.rowCount = rowCount;
|
|
15
|
+
};
|
|
16
|
+
add(data) {
|
|
17
|
+
const [index] = data;
|
|
18
|
+
if (this.isWithinRange(index)) {
|
|
19
|
+
const internalIndex = index - this.range.from;
|
|
20
|
+
this.data[internalIndex] = data;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
getAtIndex(index) {
|
|
24
|
+
return this.range.isWithin(index) && null != this.data[index - this.range.from] ? this.data[index - this.range.from] : void 0;
|
|
25
|
+
}
|
|
26
|
+
isWithinRange(index) {
|
|
27
|
+
return this.range.isWithin(index);
|
|
28
|
+
}
|
|
29
|
+
setRange({ from, to }) {
|
|
30
|
+
if (from !== this.range.from || to !== this.range.to) {
|
|
31
|
+
const [overlapFrom, overlapTo] = this.range.overlap(from, to);
|
|
32
|
+
const newData = new Array(Math.max(0, to - from));
|
|
33
|
+
for(let i = overlapFrom; i < overlapTo; i++){
|
|
34
|
+
const data = this.getAtIndex(i);
|
|
35
|
+
if (data) {
|
|
36
|
+
const index = i - from;
|
|
37
|
+
newData[index] = data;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this.data = newData;
|
|
41
|
+
this.range.from = from;
|
|
42
|
+
this.range.to = to;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
getSelectedRows() {
|
|
46
|
+
return this.data.filter((row)=>0 !== row[SELECTED]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export { MovingWindow };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { MovingWindow } from "./moving-window.js";
|
|
3
|
+
import { Range } from "@vuu-ui/vuu-utils";
|
|
4
|
+
const useDataSource = ({ dataSource })=>{
|
|
5
|
+
const [, forceUpdate] = useState(null);
|
|
6
|
+
const data = useRef([]);
|
|
7
|
+
const dataWindow = useMemo(()=>new MovingWindow({
|
|
8
|
+
from: 0,
|
|
9
|
+
to: 10
|
|
10
|
+
}), []);
|
|
11
|
+
const setData = useCallback((updates)=>{
|
|
12
|
+
console.table(updates);
|
|
13
|
+
for (const row of updates)dataWindow.add(row);
|
|
14
|
+
data.current = dataWindow.data;
|
|
15
|
+
forceUpdate({});
|
|
16
|
+
}, [
|
|
17
|
+
dataWindow
|
|
18
|
+
]);
|
|
19
|
+
const datasourceMessageHandler = useCallback((message)=>{
|
|
20
|
+
if ("subscribed" === message.type) ;
|
|
21
|
+
else if ("viewport-update" === message.type) {
|
|
22
|
+
if (message.rows) setData(message.rows);
|
|
23
|
+
} else console.log(`useDataSource unexpected message ${message.type}`);
|
|
24
|
+
}, [
|
|
25
|
+
setData
|
|
26
|
+
]);
|
|
27
|
+
useEffect(()=>{
|
|
28
|
+
console.log("subscribe to dataSource");
|
|
29
|
+
dataSource?.subscribe({
|
|
30
|
+
range: Range(0, 10)
|
|
31
|
+
}, datasourceMessageHandler);
|
|
32
|
+
}, [
|
|
33
|
+
dataSource,
|
|
34
|
+
datasourceMessageHandler
|
|
35
|
+
]);
|
|
36
|
+
return data.current;
|
|
37
|
+
};
|
|
38
|
+
export { useDataSource };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { flip, size, useClick, useDismiss, useInteractions } from "@floating-ui/react";
|
|
2
|
+
import { useFloatingUI } from "@salt-ds/core";
|
|
3
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { isStringColumn, toColumnName, useData } from "@vuu-ui/vuu-utils";
|
|
5
|
+
import { isNavigationKey, isRowSelectionKey, useControlledTableNavigation } from "@vuu-ui/vuu-table";
|
|
6
|
+
const defaultRowToString = (dataRow)=>Object.values(dataRow).join(" ");
|
|
7
|
+
const useTablePicker = ({ TableProps, onSelect, rowToString = defaultRowToString, schema, searchColumns = schema.columns.filter(isStringColumn).map(toColumnName) })=>{
|
|
8
|
+
const { VuuDataSource } = useData();
|
|
9
|
+
const [value, setValue] = useState("");
|
|
10
|
+
const [open, setOpen] = useState(false);
|
|
11
|
+
const widthRef = useRef(-1);
|
|
12
|
+
const tableColumns = TableProps?.config.columns;
|
|
13
|
+
const containerRef = useCallback((el)=>{
|
|
14
|
+
widthRef.current = el?.clientWidth ?? -1;
|
|
15
|
+
}, []);
|
|
16
|
+
const dataSource = useMemo(()=>{
|
|
17
|
+
const columns = tableColumns ?? schema.columns;
|
|
18
|
+
return new VuuDataSource({
|
|
19
|
+
columns: columns.map((c)=>c.name),
|
|
20
|
+
table: schema.table
|
|
21
|
+
});
|
|
22
|
+
}, [
|
|
23
|
+
tableColumns,
|
|
24
|
+
VuuDataSource,
|
|
25
|
+
schema
|
|
26
|
+
]);
|
|
27
|
+
const navigation = useControlledTableNavigation(-1, dataSource.size);
|
|
28
|
+
const baseFilterPattern = useMemo(()=>searchColumns.map((col)=>`${col} starts "__VALUE__"`).join(" or "), [
|
|
29
|
+
searchColumns
|
|
30
|
+
]);
|
|
31
|
+
const { context, elements, ...floatingUIProps } = useFloatingUI({
|
|
32
|
+
open,
|
|
33
|
+
onOpenChange: setOpen,
|
|
34
|
+
placement: "bottom-end",
|
|
35
|
+
strategy: "fixed",
|
|
36
|
+
middleware: [
|
|
37
|
+
size({
|
|
38
|
+
apply ({ rects, elements, availableHeight }) {
|
|
39
|
+
Object.assign(elements.floating.style, {
|
|
40
|
+
minWidth: `${rects.reference.width}px`,
|
|
41
|
+
maxHeight: `max(calc(${availableHeight}px - var(--salt-spacing-100)), calc((var(--salt-size-base) + var(--salt-spacing-100)) * 5))`
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
flip({
|
|
46
|
+
fallbackStrategy: "initialPlacement"
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
const interactionPropGetters = useInteractions([
|
|
51
|
+
useDismiss(context),
|
|
52
|
+
useClick(context, {
|
|
53
|
+
keyboardHandlers: false,
|
|
54
|
+
toggle: false
|
|
55
|
+
})
|
|
56
|
+
]);
|
|
57
|
+
const handleInputChange = useCallback((evt)=>{
|
|
58
|
+
const { value } = evt.target;
|
|
59
|
+
setValue(value);
|
|
60
|
+
console.log(`input changed ${value}`);
|
|
61
|
+
if (value && value.trim().length) {
|
|
62
|
+
const filter = baseFilterPattern.replaceAll("__VALUE__", value);
|
|
63
|
+
dataSource.filter = {
|
|
64
|
+
filter
|
|
65
|
+
};
|
|
66
|
+
} else dataSource.filter = {
|
|
67
|
+
filter: ""
|
|
68
|
+
};
|
|
69
|
+
}, [
|
|
70
|
+
baseFilterPattern,
|
|
71
|
+
dataSource
|
|
72
|
+
]);
|
|
73
|
+
const handleSelectRow = useCallback((dataRow)=>{
|
|
74
|
+
const value = null === dataRow ? "" : rowToString(dataRow);
|
|
75
|
+
setValue(value);
|
|
76
|
+
onSelect?.(dataRow);
|
|
77
|
+
requestAnimationFrame(()=>{
|
|
78
|
+
setOpen(false);
|
|
79
|
+
});
|
|
80
|
+
}, [
|
|
81
|
+
onSelect,
|
|
82
|
+
rowToString
|
|
83
|
+
]);
|
|
84
|
+
const handleKeyDown = useCallback((evt)=>{
|
|
85
|
+
if (open) {
|
|
86
|
+
if (isNavigationKey(evt.key, "row") || isRowSelectionKey(evt.key)) navigation.onKeyDown(evt);
|
|
87
|
+
} else if ("ArrowDown" === evt.key || "Enter" === evt.key) setOpen(true);
|
|
88
|
+
}, [
|
|
89
|
+
navigation,
|
|
90
|
+
open
|
|
91
|
+
]);
|
|
92
|
+
const inputProps = {
|
|
93
|
+
inputProps: {
|
|
94
|
+
autoComplete: "off",
|
|
95
|
+
onKeyDown: handleKeyDown
|
|
96
|
+
},
|
|
97
|
+
onChange: handleInputChange
|
|
98
|
+
};
|
|
99
|
+
const tableHandlers = {
|
|
100
|
+
onSelect: handleSelectRow
|
|
101
|
+
};
|
|
102
|
+
const tableConfig = useMemo(()=>{
|
|
103
|
+
const config = TableProps?.config;
|
|
104
|
+
if (!config) return {
|
|
105
|
+
columnLayout: "fit",
|
|
106
|
+
columns: schema.columns
|
|
107
|
+
};
|
|
108
|
+
{
|
|
109
|
+
const { columns = schema.columns, columnLayout = "fit", ...rest } = config;
|
|
110
|
+
return {
|
|
111
|
+
columns,
|
|
112
|
+
columnLayout,
|
|
113
|
+
...rest
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}, [
|
|
117
|
+
TableProps,
|
|
118
|
+
schema
|
|
119
|
+
]);
|
|
120
|
+
return {
|
|
121
|
+
containerRef,
|
|
122
|
+
dataSource,
|
|
123
|
+
highlightedIndex: navigation.highlightedIndexRef.current,
|
|
124
|
+
floatingUIProps,
|
|
125
|
+
inputProps,
|
|
126
|
+
interactionPropGetters,
|
|
127
|
+
onKeyDown: handleKeyDown,
|
|
128
|
+
open,
|
|
129
|
+
tableConfig,
|
|
130
|
+
tableHandlers,
|
|
131
|
+
tableRef: navigation.tableRef,
|
|
132
|
+
value,
|
|
133
|
+
width: widthRef.current
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
export { useTablePicker };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
3
|
+
import { useWindow } from "@salt-ds/window";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { useMeasuredContainer } from "./useMeasuredContainer.js";
|
|
6
|
+
import { useForkRef } from "@salt-ds/core";
|
|
7
|
+
import clsx from "clsx";
|
|
8
|
+
import MeasuredContainer_0 from "./MeasuredContainer.css";
|
|
9
|
+
const baseClass = "vuuMeasuredContainer";
|
|
10
|
+
const MeasuredContainer_MeasuredContainer = /*#__PURE__*/ forwardRef(function({ children, className, height, onResize, resizeStrategy, style, width, ...htmlAttributes }, forwardedRef) {
|
|
11
|
+
const targetWindow = useWindow();
|
|
12
|
+
useComponentCssInjection({
|
|
13
|
+
testId: "vuu-measured-container",
|
|
14
|
+
css: MeasuredContainer_0,
|
|
15
|
+
window: targetWindow
|
|
16
|
+
});
|
|
17
|
+
const { containerRef, ...containerMeasurements } = useMeasuredContainer({
|
|
18
|
+
height,
|
|
19
|
+
onResize,
|
|
20
|
+
resizeStrategy,
|
|
21
|
+
width
|
|
22
|
+
});
|
|
23
|
+
const { cssSize, innerSize } = containerMeasurements;
|
|
24
|
+
const unmeasured = void 0 === innerSize;
|
|
25
|
+
const getStyle = ()=>unmeasured ? {
|
|
26
|
+
...style,
|
|
27
|
+
"--measured-css-height": `${cssSize.height}`,
|
|
28
|
+
"--measured-css-width": `${cssSize.width}`
|
|
29
|
+
} : {
|
|
30
|
+
...style,
|
|
31
|
+
"--measured-css-height": `${cssSize.height}`,
|
|
32
|
+
"--measured-css-width": `${cssSize.width}`,
|
|
33
|
+
"--measured-px-height": `${innerSize?.height}px`,
|
|
34
|
+
"--measured-px-width": `${innerSize?.width}px`
|
|
35
|
+
};
|
|
36
|
+
const forkedRef = useForkRef(containerRef, forwardedRef);
|
|
37
|
+
return unmeasured ? /*#__PURE__*/ jsx("div", {
|
|
38
|
+
...htmlAttributes,
|
|
39
|
+
className: clsx(baseClass, `${baseClass}-ummeasured`),
|
|
40
|
+
style: getStyle(),
|
|
41
|
+
ref: containerRef
|
|
42
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
43
|
+
...htmlAttributes,
|
|
44
|
+
className: clsx(baseClass, className),
|
|
45
|
+
ref: forkedRef,
|
|
46
|
+
style: getStyle(),
|
|
47
|
+
children: children
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
export { MeasuredContainer_MeasuredContainer as MeasuredContainer };
|