@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,156 @@
|
|
|
1
|
+
import { isValidNumber, useResizeObserver } from "@vuu-ui/vuu-utils";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
const ClientWidthHeight = [
|
|
4
|
+
"clientHeight",
|
|
5
|
+
"clientWidth"
|
|
6
|
+
];
|
|
7
|
+
const WidthOnly = [
|
|
8
|
+
"clientWidth"
|
|
9
|
+
];
|
|
10
|
+
const HeightOnly = [
|
|
11
|
+
"clientHeight"
|
|
12
|
+
];
|
|
13
|
+
const NO_MEASUREMENT = [];
|
|
14
|
+
const NullClientSize = {
|
|
15
|
+
clientHeight: -1,
|
|
16
|
+
clientWidth: -1
|
|
17
|
+
};
|
|
18
|
+
const isNumber = (val)=>Number.isFinite(val);
|
|
19
|
+
const reduceSizeHeight = (size, value)=>{
|
|
20
|
+
if (0 === value) return size;
|
|
21
|
+
return {
|
|
22
|
+
height: size.height - value,
|
|
23
|
+
width: size.width
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const getInitialValue = (value, defaultValue)=>{
|
|
27
|
+
if (isValidNumber(value)) return `${value}px`;
|
|
28
|
+
if ("string" == typeof value) return value;
|
|
29
|
+
return defaultValue;
|
|
30
|
+
};
|
|
31
|
+
const getInitialCssSize = (height, width)=>({
|
|
32
|
+
height: getInitialValue(height, "100%"),
|
|
33
|
+
width: getInitialValue(width, "auto")
|
|
34
|
+
});
|
|
35
|
+
const getInitialInnerSize = (height, width)=>{
|
|
36
|
+
if (isValidNumber(height) && isValidNumber(width)) return {
|
|
37
|
+
height,
|
|
38
|
+
width
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const useMeasuredContainer = ({ defaultHeight = 0, defaultWidth = 0, height, onResize: onResizeProp, resizeStrategy = "responsive", width })=>{
|
|
42
|
+
const deferResize = "defer" === resizeStrategy;
|
|
43
|
+
const sizeRef = useRef(NullClientSize);
|
|
44
|
+
const resizeHandleRef = useRef(void 0);
|
|
45
|
+
const containerRef = useRef(null);
|
|
46
|
+
const [size, setSize] = useState({
|
|
47
|
+
css: getInitialCssSize(height, width),
|
|
48
|
+
inner: getInitialInnerSize(height, width),
|
|
49
|
+
outer: {
|
|
50
|
+
height: height ?? "100%",
|
|
51
|
+
width: width ?? "auto"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const fixedHeight = "number" == typeof height;
|
|
55
|
+
const fixedWidth = "number" == typeof width;
|
|
56
|
+
const dimensions = fixedHeight && fixedWidth ? NO_MEASUREMENT : fixedHeight ? WidthOnly : fixedWidth ? HeightOnly : ClientWidthHeight;
|
|
57
|
+
useMemo(()=>{
|
|
58
|
+
setSize((currentSize)=>{
|
|
59
|
+
const { inner, outer } = currentSize;
|
|
60
|
+
if (isValidNumber(height) && isValidNumber(width) && inner && outer) {
|
|
61
|
+
const { height: innerHeight, width: innerWidth } = inner;
|
|
62
|
+
const { height: outerHeight, width: outerWidth } = outer;
|
|
63
|
+
if (outerHeight !== height || outerWidth !== width) {
|
|
64
|
+
const heightDiff = isValidNumber(outerHeight) ? outerHeight - innerHeight : 0;
|
|
65
|
+
const widthDiff = isValidNumber(outerWidth) ? outerWidth - innerWidth : 0;
|
|
66
|
+
return {
|
|
67
|
+
...currentSize,
|
|
68
|
+
outer: {
|
|
69
|
+
height,
|
|
70
|
+
width
|
|
71
|
+
},
|
|
72
|
+
inner: {
|
|
73
|
+
height: height - heightDiff,
|
|
74
|
+
width: width - widthDiff
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return currentSize;
|
|
80
|
+
});
|
|
81
|
+
}, [
|
|
82
|
+
height,
|
|
83
|
+
width
|
|
84
|
+
]);
|
|
85
|
+
const handleResize = useCallback((clientWidth, clientHeight)=>{
|
|
86
|
+
const { css, inner, outer } = size;
|
|
87
|
+
let newState = size;
|
|
88
|
+
if (fixedHeight && isNumber(clientWidth) && Math.floor(clientWidth) !== inner?.width) newState = {
|
|
89
|
+
css,
|
|
90
|
+
outer,
|
|
91
|
+
inner: {
|
|
92
|
+
width: Math.floor(clientWidth) || defaultWidth,
|
|
93
|
+
height
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
else if (fixedWidth && isNumber(clientHeight) && Math.floor(clientHeight) !== inner?.height) newState = {
|
|
97
|
+
css,
|
|
98
|
+
outer,
|
|
99
|
+
inner: {
|
|
100
|
+
height: Math.floor(clientHeight) || defaultHeight,
|
|
101
|
+
width
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
else if (isNumber(clientHeight) && isNumber(clientWidth) && (clientWidth !== inner?.width || clientHeight !== inner?.height)) newState = {
|
|
105
|
+
css,
|
|
106
|
+
outer,
|
|
107
|
+
inner: {
|
|
108
|
+
width: Math.floor(clientWidth) || defaultWidth,
|
|
109
|
+
height: Math.floor(clientHeight) || defaultHeight
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
if (newState !== size) setSize(newState);
|
|
113
|
+
}, [
|
|
114
|
+
defaultHeight,
|
|
115
|
+
defaultWidth,
|
|
116
|
+
fixedHeight,
|
|
117
|
+
fixedWidth,
|
|
118
|
+
height,
|
|
119
|
+
size,
|
|
120
|
+
width
|
|
121
|
+
]);
|
|
122
|
+
const onResize = useCallback(({ clientHeight, clientWidth })=>{
|
|
123
|
+
if (deferResize) {
|
|
124
|
+
sizeRef.current.clientHeight = clientHeight;
|
|
125
|
+
sizeRef.current.clientWidth = clientWidth;
|
|
126
|
+
if (null !== resizeHandleRef.current) clearTimeout(resizeHandleRef.current);
|
|
127
|
+
resizeHandleRef.current = setTimeout(()=>{
|
|
128
|
+
handleResize(clientWidth, clientHeight);
|
|
129
|
+
}, 40);
|
|
130
|
+
} else handleResize(clientWidth, clientHeight);
|
|
131
|
+
}, [
|
|
132
|
+
deferResize,
|
|
133
|
+
handleResize
|
|
134
|
+
]);
|
|
135
|
+
useEffect(()=>{
|
|
136
|
+
if (size.inner) {
|
|
137
|
+
if (containerRef.current) {
|
|
138
|
+
if ("number" != typeof height || 0 === height) size.inner.height = containerRef.current.clientHeight;
|
|
139
|
+
size.inner.width = containerRef.current.clientWidth;
|
|
140
|
+
onResizeProp?.(size.inner);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, [
|
|
144
|
+
height,
|
|
145
|
+
onResizeProp,
|
|
146
|
+
size.inner
|
|
147
|
+
]);
|
|
148
|
+
useResizeObserver(containerRef, dimensions, onResize, true);
|
|
149
|
+
return {
|
|
150
|
+
containerRef,
|
|
151
|
+
cssSize: size.css,
|
|
152
|
+
outerSize: size.outer,
|
|
153
|
+
innerSize: size.inner
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export { reduceSizeHeight, useMeasuredContainer };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog, DialogActions, DialogCloseButton, DialogContent, DialogHeader } from "@salt-ds/core";
|
|
3
|
+
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
4
|
+
import { Prompt } from "../prompt/Prompt.js";
|
|
5
|
+
const useDialogHost = ()=>{
|
|
6
|
+
const [dialogState, setDialogState] = useState();
|
|
7
|
+
const [promptState, setPromptState] = useState();
|
|
8
|
+
const closePrompt = useCallback(()=>{
|
|
9
|
+
setPromptState(void 0);
|
|
10
|
+
}, []);
|
|
11
|
+
const closeDialog = useCallback(()=>{
|
|
12
|
+
setDialogState(void 0);
|
|
13
|
+
}, []);
|
|
14
|
+
const handleOpenChange = useCallback((open)=>{
|
|
15
|
+
if (true !== open) closeDialog();
|
|
16
|
+
}, [
|
|
17
|
+
closeDialog
|
|
18
|
+
]);
|
|
19
|
+
const dialog = dialogState ? /*#__PURE__*/ jsxs(Dialog, {
|
|
20
|
+
open: true,
|
|
21
|
+
onOpenChange: handleOpenChange,
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ jsx(DialogHeader, {
|
|
24
|
+
header: dialogState.title
|
|
25
|
+
}),
|
|
26
|
+
/*#__PURE__*/ jsx(DialogContent, {
|
|
27
|
+
children: dialogState.content
|
|
28
|
+
}),
|
|
29
|
+
true !== dialogState.hideCloseButton ? /*#__PURE__*/ jsx(DialogCloseButton, {
|
|
30
|
+
"data-embedded": true,
|
|
31
|
+
"data-icon": "close",
|
|
32
|
+
onClick: closeDialog
|
|
33
|
+
}) : null,
|
|
34
|
+
dialogState.actions ? /*#__PURE__*/ jsx(DialogActions, {
|
|
35
|
+
children: dialogState.actions
|
|
36
|
+
}) : null
|
|
37
|
+
]
|
|
38
|
+
}) : null;
|
|
39
|
+
const handleOpenChangePrompt = useCallback((open)=>{
|
|
40
|
+
if (true !== open) closePrompt();
|
|
41
|
+
promptState?.promptProps.onOpenChange?.(open);
|
|
42
|
+
}, [
|
|
43
|
+
closePrompt,
|
|
44
|
+
promptState
|
|
45
|
+
]);
|
|
46
|
+
const prompt = promptState ? /*#__PURE__*/ jsx(Prompt, {
|
|
47
|
+
...promptState.promptProps,
|
|
48
|
+
onClose: closePrompt,
|
|
49
|
+
onOpenChange: handleOpenChangePrompt,
|
|
50
|
+
open: true,
|
|
51
|
+
children: promptState.content
|
|
52
|
+
}) : null;
|
|
53
|
+
return {
|
|
54
|
+
dialog,
|
|
55
|
+
prompt,
|
|
56
|
+
setDialogState,
|
|
57
|
+
setPromptState
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const defaultShowDialog = ()=>{
|
|
61
|
+
console.warn("No DialogProvider in place");
|
|
62
|
+
};
|
|
63
|
+
const defaultCloseDialog = ()=>{
|
|
64
|
+
console.warn("No DialogProvider in place");
|
|
65
|
+
};
|
|
66
|
+
const defaultShowPrompt = ()=>{
|
|
67
|
+
console.warn("No DialogProvider in place");
|
|
68
|
+
};
|
|
69
|
+
const defaultClosePrompt = ()=>{
|
|
70
|
+
console.warn("No DialogProvider in place");
|
|
71
|
+
};
|
|
72
|
+
class DialogContextObject {
|
|
73
|
+
showDialog = defaultShowDialog;
|
|
74
|
+
closeDialog = defaultCloseDialog;
|
|
75
|
+
showPrompt = defaultShowPrompt;
|
|
76
|
+
closePrompt = defaultClosePrompt;
|
|
77
|
+
setDispatchers = (showDialog, closeDialog, showPrompt, closePrompt)=>{
|
|
78
|
+
this.showDialog = showDialog;
|
|
79
|
+
this.closeDialog = closeDialog;
|
|
80
|
+
this.showPrompt = showPrompt;
|
|
81
|
+
this.closePrompt = closePrompt;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const DialogContext = /*#__PURE__*/ createContext(new DialogContextObject());
|
|
85
|
+
const DialogHost = ({ context })=>{
|
|
86
|
+
const { dialog, setDialogState, prompt, setPromptState } = useDialogHost();
|
|
87
|
+
const showDialog = useCallback((dialogContent, title, actionButtons, hideCloseButton)=>{
|
|
88
|
+
setDialogState({
|
|
89
|
+
actions: actionButtons,
|
|
90
|
+
content: dialogContent,
|
|
91
|
+
title,
|
|
92
|
+
hideCloseButton
|
|
93
|
+
});
|
|
94
|
+
}, [
|
|
95
|
+
setDialogState
|
|
96
|
+
]);
|
|
97
|
+
const closeDialog = useCallback(()=>{
|
|
98
|
+
setDialogState(void 0);
|
|
99
|
+
}, [
|
|
100
|
+
setDialogState
|
|
101
|
+
]);
|
|
102
|
+
const showPrompt = useCallback((content, promptProps)=>{
|
|
103
|
+
setPromptState({
|
|
104
|
+
content,
|
|
105
|
+
promptProps
|
|
106
|
+
});
|
|
107
|
+
}, [
|
|
108
|
+
setPromptState
|
|
109
|
+
]);
|
|
110
|
+
const closePrompt = useCallback(()=>{
|
|
111
|
+
setPromptState(void 0);
|
|
112
|
+
}, [
|
|
113
|
+
setPromptState
|
|
114
|
+
]);
|
|
115
|
+
useMemo(()=>{
|
|
116
|
+
context.setDispatchers(showDialog, closeDialog, showPrompt, closePrompt);
|
|
117
|
+
}, [
|
|
118
|
+
closeDialog,
|
|
119
|
+
closePrompt,
|
|
120
|
+
context,
|
|
121
|
+
showDialog,
|
|
122
|
+
showPrompt
|
|
123
|
+
]);
|
|
124
|
+
return dialog ?? prompt;
|
|
125
|
+
};
|
|
126
|
+
const ModalProvider = ({ children })=>{
|
|
127
|
+
const context = useContext(DialogContext);
|
|
128
|
+
return /*#__PURE__*/ jsxs(DialogContext.Provider, {
|
|
129
|
+
value: context,
|
|
130
|
+
children: [
|
|
131
|
+
/*#__PURE__*/ jsx(DialogHost, {
|
|
132
|
+
context: context
|
|
133
|
+
}),
|
|
134
|
+
children
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const useModal = ()=>{
|
|
139
|
+
const { closeDialog, closePrompt, showDialog, showPrompt } = useContext(DialogContext);
|
|
140
|
+
return {
|
|
141
|
+
showDialog,
|
|
142
|
+
closeDialog,
|
|
143
|
+
showPrompt,
|
|
144
|
+
closePrompt
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export { ModalProvider, useModal };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
.vuuOverflowContainer {
|
|
3
|
+
--overflow-borderColor: var(--vuuOverflowContainer-borderColor, none);
|
|
4
|
+
--overflow-borderStyle: var(--vuuOverflowContainer-borderStyle, none);
|
|
5
|
+
--overflow-borderWidth: var(--vuuOverflowContainer-borderWidth, 0px);
|
|
6
|
+
--overflow-border-topWidth: var(--vuuOverflowContainer-borderTopWidth, var(--overflow-borderWidth));
|
|
7
|
+
--overflow-border-rightWidth: var(--vuuOverflowContainer-borderRightWidth, var(--overflow-borderWidth));
|
|
8
|
+
--overflow-border-bottomWidth: var(--vuuOverflowContainer-borderBottomWidth, var(--overflow-borderWidth));
|
|
9
|
+
--overflow-border-leftWidth: var(--vuuOverflowContainer-borderLeftWidth, var(--overflow-borderWidth));
|
|
10
|
+
--border: calc(var(--overflow-border-topWidth) + var(--overflow-border-bottomWidth));
|
|
11
|
+
--overflow-item-gap: var(--vuuOverflowContainer-gap, 2px);
|
|
12
|
+
--overflow-direction: row;
|
|
13
|
+
--overflow-height: var(--overflow-item-height);
|
|
14
|
+
background-color: var(--vuuOverflowContainer-background);
|
|
15
|
+
border-color: var(--overflow-borderColor);
|
|
16
|
+
border-style: var(--overflow-borderStyle);
|
|
17
|
+
border-top-width: var(--overflow-border-topWidth);
|
|
18
|
+
border-right-width: var(--overflow-border-rightWidth);
|
|
19
|
+
border-bottom-width: var(--overflow-border-bottomWidth);
|
|
20
|
+
border-left-width: var(--overflow-border-leftWidth);
|
|
21
|
+
height: var(--vuuOverflowContainer-height, var(--overflow-container-height));
|
|
22
|
+
width: var(--overflow-container-width);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.vuuOverflowContainer.vuuOrientation-horizontal {
|
|
26
|
+
--item-align: center;
|
|
27
|
+
--item-margin: 0 var(--overflow-item-gap) 0 var(--overflow-item-gap);
|
|
28
|
+
--overflow-container-height: calc(var(--salt-size-base) + var(--salt-spacing-100));
|
|
29
|
+
--overflow-container-width: var(--vuuOverflowContainer-width, auto);
|
|
30
|
+
--overflow-wrapper-height: var(--overflow-item-height);
|
|
31
|
+
--overflow-item-height: var(--vuuOverflowContainer-contentHeight, calc(var(--overflow-container-height) - var(--total-border-size)));
|
|
32
|
+
--overflow-item-width: auto;
|
|
33
|
+
--overflow-width: 0px;
|
|
34
|
+
--total-border-size: calc(var(--overflow-border-topWidth) + var(--overflow-border-bottomWidth));
|
|
35
|
+
min-width: var(--vuuOverflowContainer-minWidth, var(--overflow-container-height));
|
|
36
|
+
|
|
37
|
+
& .vuuOverflowContainer-wrapContainer-overflowed {
|
|
38
|
+
--overflow-left: auto;
|
|
39
|
+
--overflow-position: relative;
|
|
40
|
+
--overflow-width: auto;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.vuuOverflowContainer.vuuOrientation-vertical {
|
|
45
|
+
--item-align: stretch;
|
|
46
|
+
--overflow-container-height: 100%;
|
|
47
|
+
--overflow-container-width: var(--vuuOverflowContainer-width, calc(var(--salt-size-base) + var(--salt-spacing-100)));
|
|
48
|
+
--overflow-item-height: auto;
|
|
49
|
+
--overflow-item-width: calc(var(--overflow-container-width) - var(--total-border-size));
|
|
50
|
+
--overflow-wrapper-height: 100%;
|
|
51
|
+
--total-border-size: calc(var(--overflow-border-leftWidth) + var(--overflow-border-rightWidth));
|
|
52
|
+
--item-margin: var(--overflow-item-gap) 0 var(--overflow-item-gap) 0;
|
|
53
|
+
--overflow-direction: column;
|
|
54
|
+
--overflow-height: 0px;
|
|
55
|
+
--overflow-left: 0;
|
|
56
|
+
--overflow-top: 100%;
|
|
57
|
+
--overflow-width: auto;
|
|
58
|
+
|
|
59
|
+
& .vuuOverflowContainer-wrapContainer-overflowed {
|
|
60
|
+
--overflow-top: auto;
|
|
61
|
+
--overflow-position: relative;
|
|
62
|
+
--overflow-height: auto;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.vuuOverflowContainer-wrapContainer {
|
|
67
|
+
align-items: var(--item-align);
|
|
68
|
+
flex-direction: var(--overflow-direction);
|
|
69
|
+
height: var(--overflow-wrapper-height);
|
|
70
|
+
justify-content: var(--vuuOverflowContainer-justifyContent, flex-start);
|
|
71
|
+
flex-wrap: wrap;
|
|
72
|
+
width: 100%;
|
|
73
|
+
display: flex;
|
|
74
|
+
position: relative;
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.vuuOverflowContainer-wrapContainer-overflowed {
|
|
79
|
+
--overflow-order: 2;
|
|
80
|
+
--overflow-left: auto;
|
|
81
|
+
--overflow-position: relative;
|
|
82
|
+
--overflow-width: auto;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.vuuOverflowContainer.vuuOrientation-vertical.vuuOverflowContainer-wrapContainer-overflowed {
|
|
86
|
+
--overflow-height: auto;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.vuuOverflowContainer-item {
|
|
90
|
+
align-items: inherit;
|
|
91
|
+
height: var(--overflow-item-height);
|
|
92
|
+
margin: var(--item-margin);
|
|
93
|
+
width: var(--overflow-item-width);
|
|
94
|
+
order: 1;
|
|
95
|
+
display: flex;
|
|
96
|
+
position: relative;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.vuuOverflowContainer-item[data-align="right"] {
|
|
100
|
+
margin-left: auto;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.vuuOverflowContainer-item.wrapped {
|
|
104
|
+
--overflow-item-bg: #ccc;
|
|
105
|
+
visibility: hidden;
|
|
106
|
+
order: 3;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.vuuOverflowContainer-item.vuuDraggable-dragAway, .vuuOverflowContainer-item:has(.vuuDraggable-dragAway) {
|
|
110
|
+
display: none;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.vuuOverflowContainer-item.vuuDropTarget-settling {
|
|
114
|
+
visibility: hidden;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.vuuOverflowContainer-OverflowIndicator {
|
|
118
|
+
height: var(--overflow-height);
|
|
119
|
+
order: var(--overflow-order, 99);
|
|
120
|
+
width: var(--overflow-width);
|
|
121
|
+
background-color: #0000;
|
|
122
|
+
align-items: center;
|
|
123
|
+
display: flex;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.vuuDraggable-vuuOverflowContainer {
|
|
128
|
+
align-items: center;
|
|
129
|
+
height: 44px;
|
|
130
|
+
display: flex;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
`;
|
|
135
|
+
export default css;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PopupMenu } from "@vuu-ui/vuu-popups";
|
|
3
|
+
import { asReactElements, useId } from "@vuu-ui/vuu-utils";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
6
|
+
import { useWindow } from "@salt-ds/window";
|
|
7
|
+
import react, { forwardRef } from "react";
|
|
8
|
+
import { useOverflowContainer } from "./useOverflowContainer.js";
|
|
9
|
+
import OverflowContainer_0 from "./OverflowContainer.css";
|
|
10
|
+
const classBase = "vuuOverflowContainer";
|
|
11
|
+
const WrapContainer = /*#__PURE__*/ react.memo(({ PopupMenuProps, allowDragDrop, children, id, onMoveItem, onSwitchWrappedItemIntoView, orientation, overflowIcon })=>{
|
|
12
|
+
const childElements = asReactElements(children);
|
|
13
|
+
const { draggable, draggedItemIndex, menuActionHandler, menuBuilder, onItemMouseDown, rootRef } = useOverflowContainer({
|
|
14
|
+
allowDragDrop,
|
|
15
|
+
itemCount: childElements.length,
|
|
16
|
+
onMoveItem,
|
|
17
|
+
onSwitchWrappedItemIntoView,
|
|
18
|
+
orientation
|
|
19
|
+
});
|
|
20
|
+
const content = childElements.map((childEl, i)=>{
|
|
21
|
+
const { "data-align": align, "data-overflow-priority": overflowPriority = "0", id: itemId = `${id}-${i}`, label = `Item ${i + 1}` } = childEl.props;
|
|
22
|
+
return /*#__PURE__*/ jsx("div", {
|
|
23
|
+
className: clsx(`${classBase}-item`, {
|
|
24
|
+
"vuuDraggable-dragAway": draggedItemIndex === i
|
|
25
|
+
}),
|
|
26
|
+
"data-index": i,
|
|
27
|
+
"data-align": align,
|
|
28
|
+
"data-label": label,
|
|
29
|
+
"data-overflow-priority": overflowPriority,
|
|
30
|
+
id: `${itemId}-wrapper`,
|
|
31
|
+
onMouseDown: onItemMouseDown,
|
|
32
|
+
children: childEl
|
|
33
|
+
}, i);
|
|
34
|
+
});
|
|
35
|
+
const overflowIndicator = /*#__PURE__*/ jsx("div", {
|
|
36
|
+
className: `${classBase}-OverflowIndicator`,
|
|
37
|
+
"data-index": "overflow",
|
|
38
|
+
children: /*#__PURE__*/ jsx(PopupMenu, {
|
|
39
|
+
...PopupMenuProps,
|
|
40
|
+
"data-embedded": true,
|
|
41
|
+
icon: overflowIcon,
|
|
42
|
+
menuBuilder: menuBuilder,
|
|
43
|
+
menuActionHandler: menuActionHandler,
|
|
44
|
+
tabIndex: -1
|
|
45
|
+
})
|
|
46
|
+
}, "overflow");
|
|
47
|
+
content.push(overflowIndicator);
|
|
48
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
49
|
+
className: clsx(`${classBase}-wrapContainer`),
|
|
50
|
+
ref: rootRef,
|
|
51
|
+
children: [
|
|
52
|
+
content,
|
|
53
|
+
draggable
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
WrapContainer.displayName = "OverflowContainer.InnerContainer";
|
|
58
|
+
const OverflowContainer_OverflowContainer = /*#__PURE__*/ forwardRef(function({ PopupMenuProps, allowDragDrop = false, children, className, id: idProp, onMoveItem, onSwitchWrappedItemIntoView, orientation = "horizontal", overflowIcon, overflowPosition, ...htmlAttributes }, forwardedRef) {
|
|
59
|
+
const targetWindow = useWindow();
|
|
60
|
+
useComponentCssInjection({
|
|
61
|
+
testId: "vuu-overflow-container",
|
|
62
|
+
css: OverflowContainer_0,
|
|
63
|
+
window: targetWindow
|
|
64
|
+
});
|
|
65
|
+
const id = useId(idProp);
|
|
66
|
+
return /*#__PURE__*/ jsx("div", {
|
|
67
|
+
...htmlAttributes,
|
|
68
|
+
className: clsx(clsx(className, classBase, {
|
|
69
|
+
"vuuOrientation-horizontal": "horizontal" === orientation,
|
|
70
|
+
"vuuOrientation-vertical": "vertical" === orientation
|
|
71
|
+
})),
|
|
72
|
+
id: id,
|
|
73
|
+
ref: forwardedRef,
|
|
74
|
+
children: /*#__PURE__*/ jsx(WrapContainer, {
|
|
75
|
+
PopupMenuProps: PopupMenuProps,
|
|
76
|
+
allowDragDrop: allowDragDrop,
|
|
77
|
+
id: id,
|
|
78
|
+
orientation: orientation,
|
|
79
|
+
overflowIcon: overflowIcon,
|
|
80
|
+
overflowPosition: overflowPosition,
|
|
81
|
+
onMoveItem: onMoveItem,
|
|
82
|
+
onSwitchWrappedItemIntoView: onSwitchWrappedItemIntoView,
|
|
83
|
+
children: children
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
export { OverflowContainer_OverflowContainer as OverflowContainer };
|