@vuu-ui/vuu-layout 0.8.4-debug → 0.8.5-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 +3439 -507
- package/cjs/index.js.map +4 -4
- package/esm/index.js +3379 -404
- package/esm/index.js.map +4 -4
- package/index.css +418 -0
- package/index.css.map +3 -3
- package/package.json +3 -3
- package/types/flexbox/flexboxTypes.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/layout-reducer/layoutTypes.d.ts +8 -1
- package/types/layout-reducer/move-layout-element.d.ts +3 -0
- package/types/overflow-container/OverflowContainer.d.ts +10 -0
- package/types/overflow-container/index.d.ts +2 -0
- package/types/overflow-container/overflow-utils.d.ts +47 -0
- package/types/overflow-container/useOverflowContainer.d.ts +11 -0
- package/types/responsive/useResizeObserver.d.ts +1 -0
- package/types/stack/stackTypes.d.ts +3 -4
- package/types/utils/index.d.ts +1 -0
- package/types/utils/react-utils.d.ts +4 -0
package/esm/index.js
CHANGED
|
@@ -112,14 +112,14 @@ var isDrawer = (component) => component.type === Drawer_default;
|
|
|
112
112
|
var isVertical = ({ props: { position = "left" } }) => position.match(/top|bottom/);
|
|
113
113
|
var DockLayout = (props) => {
|
|
114
114
|
const { children, className: classNameProp, id, style } = props;
|
|
115
|
-
const
|
|
115
|
+
const classBase14 = "vuuDockLayout";
|
|
116
116
|
const [drawers, content] = partition(children, isDrawer);
|
|
117
117
|
const [verticalDrawers, horizontalDrawers] = partition(drawers, isVertical);
|
|
118
118
|
const orientation = verticalDrawers.length === 0 ? "horizontal" : horizontalDrawers.length === 0 ? "vertical" : "both";
|
|
119
|
-
const className = cx2(
|
|
119
|
+
const className = cx2(classBase14, classNameProp, `${classBase14}-${orientation}`);
|
|
120
120
|
return /* @__PURE__ */ jsxs2("div", { className, id, style, children: [
|
|
121
121
|
drawers,
|
|
122
|
-
/* @__PURE__ */ jsx2("div", { className: `${
|
|
122
|
+
/* @__PURE__ */ jsx2("div", { className: `${classBase14}-content`, children: content })
|
|
123
123
|
] });
|
|
124
124
|
};
|
|
125
125
|
DockLayout.displayName = "DockLayout";
|
|
@@ -417,6 +417,41 @@ function setRef(ref, value) {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
+
// src/utils/react-utils.ts
|
|
421
|
+
import {
|
|
422
|
+
Children,
|
|
423
|
+
isValidElement as isValidElement2,
|
|
424
|
+
useLayoutEffect,
|
|
425
|
+
useMemo,
|
|
426
|
+
useRef
|
|
427
|
+
} from "react";
|
|
428
|
+
var EMPTY_ARRAY = [];
|
|
429
|
+
var vuuComponentIdCount = 0;
|
|
430
|
+
var asReactElements = (children) => {
|
|
431
|
+
const isArray = Array.isArray(children);
|
|
432
|
+
const count = isArray ? children.length : Children.count(children);
|
|
433
|
+
if (isArray && children.every(isValidElement2)) {
|
|
434
|
+
return children;
|
|
435
|
+
} else if (count === 1 && !isArray && isValidElement2(children)) {
|
|
436
|
+
return [children];
|
|
437
|
+
} else if (count > 1) {
|
|
438
|
+
return children;
|
|
439
|
+
} else {
|
|
440
|
+
return EMPTY_ARRAY;
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
var useLayoutEffectSkipFirst = (func, deps) => {
|
|
444
|
+
const goodToGo = useRef(false);
|
|
445
|
+
useLayoutEffect(() => {
|
|
446
|
+
if (goodToGo.current) {
|
|
447
|
+
func();
|
|
448
|
+
} else {
|
|
449
|
+
goodToGo.current = true;
|
|
450
|
+
}
|
|
451
|
+
}, deps);
|
|
452
|
+
};
|
|
453
|
+
var useId = (id) => useMemo(() => id != null ? id : `vuu-${++vuuComponentIdCount}`, [id]);
|
|
454
|
+
|
|
420
455
|
// src/utils/styleUtils.ts
|
|
421
456
|
var expandFlex = (flex) => {
|
|
422
457
|
if (typeof flex !== "number") {
|
|
@@ -1036,11 +1071,11 @@ var DropTarget = class {
|
|
|
1036
1071
|
} else if (dragState && dragState.hasIntrinsicSize()) {
|
|
1037
1072
|
return this.getIntrinsicDropRect(dragState);
|
|
1038
1073
|
} else {
|
|
1039
|
-
const [l, t,
|
|
1074
|
+
const [l, t, r2, b] = this.getDropRectOutline(
|
|
1040
1075
|
lineWidth,
|
|
1041
1076
|
dragState
|
|
1042
1077
|
);
|
|
1043
|
-
return { l, t, r, b };
|
|
1078
|
+
return { l, t, r: r2, b };
|
|
1044
1079
|
}
|
|
1045
1080
|
}
|
|
1046
1081
|
getDropTabOutline(lineWidth, tab) {
|
|
@@ -1052,12 +1087,12 @@ var DropTarget = class {
|
|
|
1052
1087
|
const gap = Math.round(lineWidth / 2) + inset;
|
|
1053
1088
|
const t = Math.round(top);
|
|
1054
1089
|
const l = Math.round(left + gap);
|
|
1055
|
-
const
|
|
1090
|
+
const r2 = Math.round(right - gap);
|
|
1056
1091
|
const b = Math.round(bottom - gap);
|
|
1057
1092
|
const tabLeft = this.targetTabPos(tab);
|
|
1058
1093
|
const tabWidth = 60;
|
|
1059
1094
|
const tabHeight = ((_a = header == null ? void 0 : header.bottom) != null ? _a : 0) - ((_b = header == null ? void 0 : header.top) != null ? _b : 0);
|
|
1060
|
-
return { l, t, r, b, tabLeft, tabWidth, tabHeight };
|
|
1095
|
+
return { l, t, r: r2, b, tabLeft, tabWidth, tabHeight };
|
|
1061
1096
|
}
|
|
1062
1097
|
getIntrinsicDropRect(dragState) {
|
|
1063
1098
|
var _a, _b, _c, _d;
|
|
@@ -1080,14 +1115,14 @@ var DropTarget = class {
|
|
|
1080
1115
|
rect.bottom - height,
|
|
1081
1116
|
Math.max(rect.top, Math.round(pos.y - y.mousePct * height))
|
|
1082
1117
|
);
|
|
1083
|
-
const [l, t,
|
|
1118
|
+
const [l, t, r2, b] = this.dropRect = [
|
|
1084
1119
|
left,
|
|
1085
1120
|
top,
|
|
1086
1121
|
left + width,
|
|
1087
1122
|
top + height
|
|
1088
1123
|
];
|
|
1089
|
-
const guideLines = pos.position.EastOrWest ? [l, rect.top, l, rect.bottom,
|
|
1090
|
-
return { l, r, t, b, guideLines };
|
|
1124
|
+
const guideLines = pos.position.EastOrWest ? [l, rect.top, l, rect.bottom, r2, rect.top, r2, rect.bottom] : [rect.left, t, rect.right, t, rect.left, b, rect.right, b];
|
|
1125
|
+
return { l, r: r2, t, b, guideLines };
|
|
1091
1126
|
}
|
|
1092
1127
|
/**
|
|
1093
1128
|
* @returns [left, top, right, bottom]
|
|
@@ -1100,7 +1135,7 @@ var DropTarget = class {
|
|
|
1100
1135
|
const sizeHeight = (_b = intrinsicHeight != null ? intrinsicHeight : suggestedHeight) != null ? _b : 0;
|
|
1101
1136
|
const sizeWidth = (_c = intrinsicWidth != null ? intrinsicWidth : suggestedWidth) != null ? _c : 0;
|
|
1102
1137
|
this.dropRect = void 0;
|
|
1103
|
-
const { top: t, left: l, right:
|
|
1138
|
+
const { top: t, left: l, right: r2, bottom: b } = rect;
|
|
1104
1139
|
const inset = 0;
|
|
1105
1140
|
const gap = Math.round(lineWidth / 2) + inset;
|
|
1106
1141
|
switch (position) {
|
|
@@ -1108,25 +1143,25 @@ var DropTarget = class {
|
|
|
1108
1143
|
case Position.Header: {
|
|
1109
1144
|
const halfHeight = Math.round((b - t) / 2);
|
|
1110
1145
|
const height = sizeHeight ? Math.min(halfHeight, Math.round(sizeHeight)) : halfHeight;
|
|
1111
|
-
return sizeWidth && l + sizeWidth <
|
|
1146
|
+
return sizeWidth && l + sizeWidth < r2 ? [l + gap, t + gap, l + sizeWidth - gap, t + gap + height] : [l + gap, t + gap, r2 - gap, t + gap + height];
|
|
1112
1147
|
}
|
|
1113
1148
|
case Position.West: {
|
|
1114
|
-
const halfWidth = Math.round((
|
|
1149
|
+
const halfWidth = Math.round((r2 - l) / 2);
|
|
1115
1150
|
const width = sizeWidth ? Math.min(halfWidth, Math.round(sizeWidth)) : halfWidth;
|
|
1116
1151
|
return sizeHeight && t + sizeHeight < b ? [l + gap, t + gap, l - gap + width, t + sizeHeight + gap] : [l + gap, t + gap, l - gap + width, b - gap];
|
|
1117
1152
|
}
|
|
1118
1153
|
case Position.East: {
|
|
1119
|
-
const halfWidth = Math.round((
|
|
1154
|
+
const halfWidth = Math.round((r2 - l) / 2);
|
|
1120
1155
|
const width = sizeWidth ? Math.min(halfWidth, Math.round(sizeWidth)) : halfWidth;
|
|
1121
|
-
return sizeHeight && t + sizeHeight < b ? [
|
|
1156
|
+
return sizeHeight && t + sizeHeight < b ? [r2 - gap - width, t + gap, r2 - gap, t + sizeHeight + gap] : [r2 - gap - width, t + gap, r2 - gap, b - gap];
|
|
1122
1157
|
}
|
|
1123
1158
|
case Position.South: {
|
|
1124
1159
|
const halfHeight = Math.round((b - t) / 2);
|
|
1125
1160
|
const height = sizeHeight ? Math.min(halfHeight, Math.round(sizeHeight)) : halfHeight;
|
|
1126
|
-
return sizeWidth && l + sizeWidth <
|
|
1161
|
+
return sizeWidth && l + sizeWidth < r2 ? [l + gap, b - gap - height, l + sizeWidth - gap, b - gap] : [l + gap, b - gap - height, r2 - gap, b - gap];
|
|
1127
1162
|
}
|
|
1128
1163
|
case Position.Centre: {
|
|
1129
|
-
return [l + gap, t + gap,
|
|
1164
|
+
return [l + gap, t + gap, r2 - gap, b - gap];
|
|
1130
1165
|
}
|
|
1131
1166
|
default:
|
|
1132
1167
|
console.warn(`DropTarget does not recognize position ${position}`);
|
|
@@ -1443,8 +1478,8 @@ var DropTargetCanvas = class {
|
|
|
1443
1478
|
dragState
|
|
1444
1479
|
);
|
|
1445
1480
|
if (targetDropOutline) {
|
|
1446
|
-
const { l, t, r, b, tabLeft, tabWidth, tabHeight, guideLines } = targetDropOutline;
|
|
1447
|
-
const w =
|
|
1481
|
+
const { l, t, r: r2, b, tabLeft, tabWidth, tabHeight, guideLines } = targetDropOutline;
|
|
1482
|
+
const w = r2 - l;
|
|
1448
1483
|
const h = b - t;
|
|
1449
1484
|
if (this.currentPath) {
|
|
1450
1485
|
const path2 = document.getElementById("vuu-drop-outline");
|
|
@@ -1719,8 +1754,8 @@ import { forwardRef as forwardRef3 } from "react";
|
|
|
1719
1754
|
import { getUniqueId } from "@vuu-ui/vuu-utils";
|
|
1720
1755
|
import React5, {
|
|
1721
1756
|
useCallback as useCallback3,
|
|
1722
|
-
useMemo,
|
|
1723
|
-
useRef as
|
|
1757
|
+
useMemo as useMemo2,
|
|
1758
|
+
useRef as useRef3,
|
|
1724
1759
|
useState as useState2
|
|
1725
1760
|
} from "react";
|
|
1726
1761
|
|
|
@@ -1755,7 +1790,7 @@ registerComponent("Placeholder", Placeholder);
|
|
|
1755
1790
|
import cx5 from "classnames";
|
|
1756
1791
|
import React3, {
|
|
1757
1792
|
useCallback as useCallback2,
|
|
1758
|
-
useRef,
|
|
1793
|
+
useRef as useRef2,
|
|
1759
1794
|
useState
|
|
1760
1795
|
} from "react";
|
|
1761
1796
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
@@ -1767,9 +1802,9 @@ var Splitter = React3.memo(function Splitter2({
|
|
|
1767
1802
|
onDragStart,
|
|
1768
1803
|
style
|
|
1769
1804
|
}) {
|
|
1770
|
-
const ignoreClick =
|
|
1771
|
-
const rootRef =
|
|
1772
|
-
const lastPos =
|
|
1805
|
+
const ignoreClick = useRef2();
|
|
1806
|
+
const rootRef = useRef2(null);
|
|
1807
|
+
const lastPos = useRef2(0);
|
|
1773
1808
|
const [active, setActive] = useState(false);
|
|
1774
1809
|
const handleKeyDownDrag = useCallback2(
|
|
1775
1810
|
({ key, shiftKey }) => {
|
|
@@ -1799,7 +1834,7 @@ var Splitter = React3.memo(function Splitter2({
|
|
|
1799
1834
|
},
|
|
1800
1835
|
[column, handleKeyDownDrag, index, onDragStart]
|
|
1801
1836
|
);
|
|
1802
|
-
const keyDownHandlerRef =
|
|
1837
|
+
const keyDownHandlerRef = useRef2(handleKeyDownInitDrag);
|
|
1803
1838
|
const handleKeyDown = (evt) => keyDownHandlerRef.current(evt);
|
|
1804
1839
|
const handleMouseMove = useCallback2(
|
|
1805
1840
|
(e) => {
|
|
@@ -2102,7 +2137,7 @@ var findSplitterAndPlaceholderPositions = (childMeta) => {
|
|
|
2102
2137
|
const count = childMeta.length;
|
|
2103
2138
|
const allIntrinsic = childMeta.every(isIntrinsicallySized);
|
|
2104
2139
|
const splitterPositions = Array(count).fill(0);
|
|
2105
|
-
if (allIntrinsic) {
|
|
2140
|
+
if (allIntrinsic && count > 0) {
|
|
2106
2141
|
splitterPositions[0] = PLACEHOLDER;
|
|
2107
2142
|
splitterPositions[count - 1] = PLACEHOLDER;
|
|
2108
2143
|
}
|
|
@@ -2173,10 +2208,10 @@ var useSplitterResizing = ({
|
|
|
2173
2208
|
onSplitterMoved,
|
|
2174
2209
|
style
|
|
2175
2210
|
}) => {
|
|
2176
|
-
const rootRef =
|
|
2177
|
-
const metaRef =
|
|
2178
|
-
const contentRef =
|
|
2179
|
-
const assignedKeys =
|
|
2211
|
+
const rootRef = useRef3(null);
|
|
2212
|
+
const metaRef = useRef3();
|
|
2213
|
+
const contentRef = useRef3();
|
|
2214
|
+
const assignedKeys = useRef3([]);
|
|
2180
2215
|
const [, forceUpdate] = useState2({});
|
|
2181
2216
|
const setContent = (content) => {
|
|
2182
2217
|
contentRef.current = content;
|
|
@@ -2184,7 +2219,7 @@ var useSplitterResizing = ({
|
|
|
2184
2219
|
};
|
|
2185
2220
|
const isColumn = (style == null ? void 0 : style.flexDirection) === "column";
|
|
2186
2221
|
const dimension = isColumn ? "height" : "width";
|
|
2187
|
-
const children =
|
|
2222
|
+
const children = useMemo2(
|
|
2188
2223
|
() => Array.isArray(childrenProp) ? childrenProp : React5.isValidElement(childrenProp) ? [childrenProp] : [],
|
|
2189
2224
|
[childrenProp]
|
|
2190
2225
|
);
|
|
@@ -2260,7 +2295,7 @@ var useSplitterResizing = ({
|
|
|
2260
2295
|
},
|
|
2261
2296
|
[handleDrag, handleDragEnd, handleDragStart, isColumn]
|
|
2262
2297
|
);
|
|
2263
|
-
|
|
2298
|
+
useMemo2(() => {
|
|
2264
2299
|
const [content, meta] = buildContent(
|
|
2265
2300
|
children,
|
|
2266
2301
|
dimension,
|
|
@@ -2454,7 +2489,7 @@ import {
|
|
|
2454
2489
|
useCallback as useCallback6,
|
|
2455
2490
|
useContext,
|
|
2456
2491
|
useEffect,
|
|
2457
|
-
useRef as
|
|
2492
|
+
useRef as useRef5,
|
|
2458
2493
|
useState as useState3
|
|
2459
2494
|
} from "react";
|
|
2460
2495
|
|
|
@@ -2977,28 +3012,8 @@ function getStyledComponents(container, existingComponent, newComponent, targetR
|
|
|
2977
3012
|
}
|
|
2978
3013
|
}
|
|
2979
3014
|
|
|
2980
|
-
// src/layout-reducer/
|
|
2981
|
-
|
|
2982
|
-
ADD: "add",
|
|
2983
|
-
DRAG_START: "drag-start",
|
|
2984
|
-
DRAG_DROP: "drag-drop",
|
|
2985
|
-
LAYOUT_RESIZE: "layout-resize",
|
|
2986
|
-
MAXIMIZE: "maximize",
|
|
2987
|
-
MINIMIZE: "minimize",
|
|
2988
|
-
REMOVE: "remove",
|
|
2989
|
-
REPLACE: "replace",
|
|
2990
|
-
RESTORE: "restore",
|
|
2991
|
-
SAVE: "save",
|
|
2992
|
-
SET_PROP: "set-prop",
|
|
2993
|
-
SET_PROPS: "set-props",
|
|
2994
|
-
SET_TITLE: "set-title",
|
|
2995
|
-
SPLITTER_RESIZE: "splitter-resize",
|
|
2996
|
-
SWITCH_TAB: "switch-tab",
|
|
2997
|
-
TEAROUT: "tearout"
|
|
2998
|
-
};
|
|
2999
|
-
|
|
3000
|
-
// src/layout-reducer/remove-layout-element.ts
|
|
3001
|
-
import React9 from "react";
|
|
3015
|
+
// src/layout-reducer/move-layout-element.ts
|
|
3016
|
+
import { cloneElement as cloneElement2 } from "react";
|
|
3002
3017
|
|
|
3003
3018
|
// src/layout-reducer/replace-layout-element.ts
|
|
3004
3019
|
import React8 from "react";
|
|
@@ -3081,7 +3096,52 @@ function restore(child) {
|
|
|
3081
3096
|
});
|
|
3082
3097
|
}
|
|
3083
3098
|
|
|
3099
|
+
// src/layout-reducer/move-layout-element.ts
|
|
3100
|
+
function moveChild(layoutRoot, { fromIndex, path, toIndex }) {
|
|
3101
|
+
const target = followPath(layoutRoot, path, true);
|
|
3102
|
+
const { children } = getProps(target);
|
|
3103
|
+
const replacementChildren = moveChildWithinChildren(
|
|
3104
|
+
children,
|
|
3105
|
+
fromIndex,
|
|
3106
|
+
toIndex
|
|
3107
|
+
);
|
|
3108
|
+
const replacement = cloneElement2(target, void 0, replacementChildren);
|
|
3109
|
+
return swapChild(layoutRoot, target, replacement);
|
|
3110
|
+
}
|
|
3111
|
+
function moveChildWithinChildren(children, fromIndex, toIndex) {
|
|
3112
|
+
const newChildren = children.slice();
|
|
3113
|
+
const [child] = newChildren.splice(fromIndex, 1);
|
|
3114
|
+
if (toIndex === -1) {
|
|
3115
|
+
return newChildren.concat(child);
|
|
3116
|
+
} else {
|
|
3117
|
+
newChildren.splice(toIndex, 0, child);
|
|
3118
|
+
return newChildren;
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
|
|
3122
|
+
// src/layout-reducer/layoutTypes.ts
|
|
3123
|
+
var LayoutActionType = {
|
|
3124
|
+
ADD: "add",
|
|
3125
|
+
DRAG_START: "drag-start",
|
|
3126
|
+
DRAG_DROP: "drag-drop",
|
|
3127
|
+
LAYOUT_RESIZE: "layout-resize",
|
|
3128
|
+
MAXIMIZE: "maximize",
|
|
3129
|
+
MINIMIZE: "minimize",
|
|
3130
|
+
MOVE_CHILD: "move-child",
|
|
3131
|
+
REMOVE: "remove",
|
|
3132
|
+
REPLACE: "replace",
|
|
3133
|
+
RESTORE: "restore",
|
|
3134
|
+
SAVE: "save",
|
|
3135
|
+
SET_PROP: "set-prop",
|
|
3136
|
+
SET_PROPS: "set-props",
|
|
3137
|
+
SET_TITLE: "set-title",
|
|
3138
|
+
SPLITTER_RESIZE: "splitter-resize",
|
|
3139
|
+
SWITCH_TAB: "switch-tab",
|
|
3140
|
+
TEAROUT: "tearout"
|
|
3141
|
+
};
|
|
3142
|
+
|
|
3084
3143
|
// src/layout-reducer/remove-layout-element.ts
|
|
3144
|
+
import React9 from "react";
|
|
3085
3145
|
function removeChild(layoutRoot, { path }) {
|
|
3086
3146
|
const target = followPath(layoutRoot, path);
|
|
3087
3147
|
let targetParent = followPathToParent(layoutRoot, path);
|
|
@@ -3559,6 +3619,8 @@ var layoutReducer = (state, action) => {
|
|
|
3559
3619
|
return resizeFlexChild(state, action);
|
|
3560
3620
|
case LayoutActionType.SWITCH_TAB:
|
|
3561
3621
|
return switchTab(state, action);
|
|
3622
|
+
case LayoutActionType.MOVE_CHILD:
|
|
3623
|
+
return moveChild(state, action);
|
|
3562
3624
|
default:
|
|
3563
3625
|
return state;
|
|
3564
3626
|
}
|
|
@@ -3717,7 +3779,7 @@ var LayoutProviderContext = createContext({
|
|
|
3717
3779
|
});
|
|
3718
3780
|
|
|
3719
3781
|
// src/layout-provider/useLayoutDragDrop.ts
|
|
3720
|
-
import { useCallback as useCallback5, useRef as
|
|
3782
|
+
import { useCallback as useCallback5, useRef as useRef4 } from "react";
|
|
3721
3783
|
var NO_INSTRUCTIONS = {};
|
|
3722
3784
|
var NO_OFFSETS = [0, 0];
|
|
3723
3785
|
var getDragElement = (rect, id, dragElement) => {
|
|
@@ -3746,9 +3808,9 @@ var determineDragOffsets = (draggedElement) => {
|
|
|
3746
3808
|
}
|
|
3747
3809
|
};
|
|
3748
3810
|
var useLayoutDragDrop = (rootLayoutRef, dispatch) => {
|
|
3749
|
-
const dragActionRef =
|
|
3750
|
-
const dragOperationRef =
|
|
3751
|
-
const draggableHTMLElementRef =
|
|
3811
|
+
const dragActionRef = useRef4();
|
|
3812
|
+
const dragOperationRef = useRef4();
|
|
3813
|
+
const draggableHTMLElementRef = useRef4();
|
|
3752
3814
|
const handleDrag = useCallback5((x, y) => {
|
|
3753
3815
|
if (dragOperationRef.current && draggableHTMLElementRef.current) {
|
|
3754
3816
|
const {
|
|
@@ -3890,8 +3952,8 @@ var LayoutProviderVersion = () => {
|
|
|
3890
3952
|
};
|
|
3891
3953
|
var LayoutProvider = (props) => {
|
|
3892
3954
|
const { children, layout, onLayoutChange } = props;
|
|
3893
|
-
const state =
|
|
3894
|
-
const childrenRef =
|
|
3955
|
+
const state = useRef5(void 0);
|
|
3956
|
+
const childrenRef = useRef5(children);
|
|
3895
3957
|
const [, forceRefresh] = useState3(null);
|
|
3896
3958
|
const serializeState = useCallback6(
|
|
3897
3959
|
(source) => {
|
|
@@ -4012,13 +4074,13 @@ registerComponent("Flexbox", FlexboxLayout, "container");
|
|
|
4012
4074
|
// src/flexbox/FluidGrid.tsx
|
|
4013
4075
|
import { useForkRef as useForkRef2 } from "@salt-ds/core";
|
|
4014
4076
|
import cx7 from "classnames";
|
|
4015
|
-
import { forwardRef as forwardRef4 } from "react";
|
|
4077
|
+
import { forwardRef as forwardRef4, useMemo as useMemo4 } from "react";
|
|
4016
4078
|
|
|
4017
4079
|
// src/responsive/use-breakpoints.ts
|
|
4018
|
-
import { useCallback as useCallback9, useEffect as useEffect2, useRef as
|
|
4080
|
+
import { useCallback as useCallback9, useEffect as useEffect2, useRef as useRef7, useState as useState4 } from "react";
|
|
4019
4081
|
|
|
4020
4082
|
// src/responsive/useResizeObserver.ts
|
|
4021
|
-
import { useCallback as useCallback8, useLayoutEffect, useRef as
|
|
4083
|
+
import { useCallback as useCallback8, useLayoutEffect as useLayoutEffect2, useRef as useRef6 } from "react";
|
|
4022
4084
|
var WidthHeight = ["height", "width"];
|
|
4023
4085
|
var HeightOnly = ["height"];
|
|
4024
4086
|
var WidthOnly = ["width"];
|
|
@@ -4037,32 +4099,37 @@ var getTargetSize = (element, contentRect, dimension) => {
|
|
|
4037
4099
|
return 0;
|
|
4038
4100
|
}
|
|
4039
4101
|
};
|
|
4040
|
-
var resizeObserver = new ResizeObserver(
|
|
4041
|
-
|
|
4042
|
-
const
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
const
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4102
|
+
var resizeObserver = new ResizeObserver(
|
|
4103
|
+
(entries) => {
|
|
4104
|
+
for (const entry of entries) {
|
|
4105
|
+
const { target, contentRect } = entry;
|
|
4106
|
+
const observedTarget = observedMap.get(target);
|
|
4107
|
+
if (observedTarget) {
|
|
4108
|
+
const { onResize, measurements } = observedTarget;
|
|
4109
|
+
let sizeChanged = false;
|
|
4110
|
+
for (const [dimension, size] of Object.entries(measurements)) {
|
|
4111
|
+
const newSize = getTargetSize(
|
|
4112
|
+
target,
|
|
4113
|
+
contentRect,
|
|
4114
|
+
dimension
|
|
4115
|
+
);
|
|
4116
|
+
if (newSize !== size) {
|
|
4117
|
+
sizeChanged = true;
|
|
4118
|
+
measurements[dimension] = newSize;
|
|
4119
|
+
}
|
|
4120
|
+
}
|
|
4121
|
+
if (sizeChanged) {
|
|
4122
|
+
onResize && onResize(measurements);
|
|
4056
4123
|
}
|
|
4057
|
-
}
|
|
4058
|
-
if (sizeChanged) {
|
|
4059
|
-
onResize && onResize(measurements);
|
|
4060
4124
|
}
|
|
4061
4125
|
}
|
|
4062
4126
|
}
|
|
4063
|
-
|
|
4064
|
-
function useResizeObserver(ref,
|
|
4065
|
-
|
|
4127
|
+
);
|
|
4128
|
+
function useResizeObserver(ref, dimensions2, onResize, reportInitialSize = false) {
|
|
4129
|
+
console.log(`resizeObserver container`, {
|
|
4130
|
+
ref: ref.current
|
|
4131
|
+
});
|
|
4132
|
+
const dimensionsRef = useRef6(dimensions2);
|
|
4066
4133
|
const measure = useCallback8((target) => {
|
|
4067
4134
|
const rect = target.getBoundingClientRect();
|
|
4068
4135
|
return dimensionsRef.current.reduce(
|
|
@@ -4073,7 +4140,7 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
|
|
|
4073
4140
|
{}
|
|
4074
4141
|
);
|
|
4075
4142
|
}, []);
|
|
4076
|
-
|
|
4143
|
+
useLayoutEffect2(() => {
|
|
4077
4144
|
const target = ref.current;
|
|
4078
4145
|
let cleanedUp = false;
|
|
4079
4146
|
async function registerObserver() {
|
|
@@ -4111,18 +4178,18 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
|
|
|
4111
4178
|
}
|
|
4112
4179
|
};
|
|
4113
4180
|
}, [ref, measure, reportInitialSize, onResize]);
|
|
4114
|
-
|
|
4181
|
+
useLayoutEffect2(() => {
|
|
4115
4182
|
const target = ref.current;
|
|
4116
4183
|
const record = observedMap.get(target);
|
|
4117
4184
|
if (record) {
|
|
4118
|
-
if (dimensionsRef.current !==
|
|
4119
|
-
dimensionsRef.current =
|
|
4185
|
+
if (dimensionsRef.current !== dimensions2) {
|
|
4186
|
+
dimensionsRef.current = dimensions2;
|
|
4120
4187
|
const measurements = measure(target);
|
|
4121
4188
|
record.measurements = measurements;
|
|
4122
4189
|
}
|
|
4123
4190
|
record.onResize = onResize;
|
|
4124
4191
|
}
|
|
4125
|
-
}, [
|
|
4192
|
+
}, [dimensions2, measure, ref, onResize]);
|
|
4126
4193
|
}
|
|
4127
4194
|
|
|
4128
4195
|
// src/responsive/breakpoints.ts
|
|
@@ -4158,16 +4225,16 @@ var getBreakPoints = (themeName) => {
|
|
|
4158
4225
|
};
|
|
4159
4226
|
|
|
4160
4227
|
// src/responsive/use-breakpoints.ts
|
|
4161
|
-
var
|
|
4228
|
+
var EMPTY_ARRAY2 = [];
|
|
4162
4229
|
var useBreakpoints = ({ breakPoints: breakPointsProp, smallerThan }, ref) => {
|
|
4163
4230
|
const [breakpointMatch, setBreakpointmatch] = useState4(
|
|
4164
4231
|
smallerThan ? false : "lg"
|
|
4165
4232
|
);
|
|
4166
|
-
const bodyRef =
|
|
4167
|
-
const breakPointsRef =
|
|
4233
|
+
const bodyRef = useRef7(document.body);
|
|
4234
|
+
const breakPointsRef = useRef7(
|
|
4168
4235
|
breakPointsProp ? breakpointRamp(breakPointsProp) : getBreakPoints()
|
|
4169
4236
|
);
|
|
4170
|
-
const sizeRef =
|
|
4237
|
+
const sizeRef = useRef7("lg");
|
|
4171
4238
|
const stopFromMinWidth = useCallback9(
|
|
4172
4239
|
(w) => {
|
|
4173
4240
|
if (breakPointsRef.current) {
|
|
@@ -4199,7 +4266,7 @@ var useBreakpoints = ({ breakPoints: breakPointsProp, smallerThan }, ref) => {
|
|
|
4199
4266
|
);
|
|
4200
4267
|
useResizeObserver(
|
|
4201
4268
|
ref || bodyRef,
|
|
4202
|
-
breakPointsRef.current ? ["width"] :
|
|
4269
|
+
breakPointsRef.current ? ["width"] : EMPTY_ARRAY2,
|
|
4203
4270
|
({ width: measuredWidth }) => {
|
|
4204
4271
|
const result = matchSizeAgainstBreakpoints(measuredWidth);
|
|
4205
4272
|
if (result !== sizeRef.current) {
|
|
@@ -4265,11 +4332,11 @@ var extractResponsiveProps = (props) => {
|
|
|
4265
4332
|
// src/flexbox/useResponsiveSizing.ts
|
|
4266
4333
|
import { getUniqueId as getUniqueId2 } from "@vuu-ui/vuu-utils";
|
|
4267
4334
|
import {
|
|
4268
|
-
cloneElement as
|
|
4269
|
-
isValidElement as
|
|
4335
|
+
cloneElement as cloneElement3,
|
|
4336
|
+
isValidElement as isValidElement3,
|
|
4270
4337
|
useCallback as useCallback10,
|
|
4271
|
-
useMemo as
|
|
4272
|
-
useRef as
|
|
4338
|
+
useMemo as useMemo3,
|
|
4339
|
+
useRef as useRef8
|
|
4273
4340
|
} from "react";
|
|
4274
4341
|
var breakPoints = ["xs", "sm", "md", "lg", "xl"];
|
|
4275
4342
|
var DEFAULT_COLS = 12;
|
|
@@ -4278,14 +4345,14 @@ var useResponsiveSizing = ({
|
|
|
4278
4345
|
cols: colsProp,
|
|
4279
4346
|
style
|
|
4280
4347
|
}) => {
|
|
4281
|
-
const rootRef =
|
|
4282
|
-
const metaRef =
|
|
4283
|
-
const contentRef =
|
|
4348
|
+
const rootRef = useRef8(null);
|
|
4349
|
+
const metaRef = useRef8(null);
|
|
4350
|
+
const contentRef = useRef8();
|
|
4284
4351
|
const cols = colsProp != null ? colsProp : DEFAULT_COLS;
|
|
4285
4352
|
const isColumn = (style == null ? void 0 : style.flexDirection) === "column";
|
|
4286
4353
|
const dimension = isColumn ? "height" : "width";
|
|
4287
|
-
const children =
|
|
4288
|
-
() => Array.isArray(childrenProp) ? childrenProp :
|
|
4354
|
+
const children = useMemo3(
|
|
4355
|
+
() => Array.isArray(childrenProp) ? childrenProp : isValidElement3(childrenProp) ? [childrenProp] : [],
|
|
4289
4356
|
[childrenProp]
|
|
4290
4357
|
);
|
|
4291
4358
|
const buildContent2 = useCallback10(
|
|
@@ -4299,7 +4366,7 @@ var useResponsiveSizing = ({
|
|
|
4299
4366
|
style: { flex, ...rest }
|
|
4300
4367
|
} = child.props;
|
|
4301
4368
|
content.push(
|
|
4302
|
-
|
|
4369
|
+
cloneElement3(child, {
|
|
4303
4370
|
key: getUniqueId2(),
|
|
4304
4371
|
style: {
|
|
4305
4372
|
...rest,
|
|
@@ -4313,7 +4380,7 @@ var useResponsiveSizing = ({
|
|
|
4313
4380
|
},
|
|
4314
4381
|
[cols]
|
|
4315
4382
|
);
|
|
4316
|
-
|
|
4383
|
+
useMemo3(() => {
|
|
4317
4384
|
const [content, meta] = buildContent2(children, dimension);
|
|
4318
4385
|
metaRef.current = meta;
|
|
4319
4386
|
contentRef.current = content;
|
|
@@ -4331,7 +4398,7 @@ var classBase5 = "hwFluidGrid";
|
|
|
4331
4398
|
var FluidGrid = forwardRef4(function FluidGrid2(props, ref) {
|
|
4332
4399
|
const {
|
|
4333
4400
|
breakPoints: breakPoints2,
|
|
4334
|
-
children,
|
|
4401
|
+
children: childrenProp,
|
|
4335
4402
|
column,
|
|
4336
4403
|
cols: colsProp = 12,
|
|
4337
4404
|
className: classNameProp,
|
|
@@ -4348,6 +4415,9 @@ var FluidGrid = forwardRef4(function FluidGrid2(props, ref) {
|
|
|
4348
4415
|
style: styleProp,
|
|
4349
4416
|
...rest
|
|
4350
4417
|
} = props;
|
|
4418
|
+
const children = useMemo4(() => {
|
|
4419
|
+
return asReactElements(childrenProp);
|
|
4420
|
+
}, [childrenProp]);
|
|
4351
4421
|
const { cols, content, rootRef } = useResponsiveSizing({
|
|
4352
4422
|
children,
|
|
4353
4423
|
cols: colsProp,
|
|
@@ -4399,9 +4469,9 @@ registerComponent("FluidGrid", FluidGridLayout, "container");
|
|
|
4399
4469
|
|
|
4400
4470
|
// src/layout-header/Header.tsx
|
|
4401
4471
|
import classnames2 from "classnames";
|
|
4402
|
-
import
|
|
4403
|
-
useRef as
|
|
4404
|
-
useState as
|
|
4472
|
+
import React17, {
|
|
4473
|
+
useRef as useRef22,
|
|
4474
|
+
useState as useState11
|
|
4405
4475
|
} from "react";
|
|
4406
4476
|
|
|
4407
4477
|
// src/layout-view/useViewActionDispatcher.ts
|
|
@@ -4501,18 +4571,18 @@ var useViewActionDispatcher = (id, root, viewPath, dropTargets) => {
|
|
|
4501
4571
|
};
|
|
4502
4572
|
|
|
4503
4573
|
// src/layout-view/View.tsx
|
|
4504
|
-
import { useForkRef as useForkRef3, useIdMemo as
|
|
4574
|
+
import { useForkRef as useForkRef3, useIdMemo as useId2 } from "@salt-ds/core";
|
|
4505
4575
|
import cx8 from "classnames";
|
|
4506
4576
|
import React14, {
|
|
4507
4577
|
forwardRef as forwardRef5,
|
|
4508
4578
|
useCallback as useCallback14,
|
|
4509
|
-
useMemo as
|
|
4510
|
-
useRef as
|
|
4579
|
+
useMemo as useMemo6,
|
|
4580
|
+
useRef as useRef10,
|
|
4511
4581
|
useState as useState6
|
|
4512
4582
|
} from "react";
|
|
4513
4583
|
|
|
4514
4584
|
// src/layout-view/useView.tsx
|
|
4515
|
-
import { useCallback as useCallback12, useMemo as
|
|
4585
|
+
import { useCallback as useCallback12, useMemo as useMemo5 } from "react";
|
|
4516
4586
|
var useView = ({
|
|
4517
4587
|
id,
|
|
4518
4588
|
rootRef,
|
|
@@ -4534,7 +4604,7 @@ var useView = ({
|
|
|
4534
4604
|
path,
|
|
4535
4605
|
dropTargets
|
|
4536
4606
|
);
|
|
4537
|
-
const title =
|
|
4607
|
+
const title = useMemo5(
|
|
4538
4608
|
() => {
|
|
4539
4609
|
var _a;
|
|
4540
4610
|
return (_a = loadState("view-title")) != null ? _a : titleProp;
|
|
@@ -4549,7 +4619,7 @@ var useView = ({
|
|
|
4549
4619
|
},
|
|
4550
4620
|
[layoutDispatch, path]
|
|
4551
4621
|
);
|
|
4552
|
-
const restoredState =
|
|
4622
|
+
const restoredState = useMemo5(() => loadState(id), [id, loadState]);
|
|
4553
4623
|
const load = useCallback12(
|
|
4554
4624
|
(key) => loadState(id, key),
|
|
4555
4625
|
[id, loadState]
|
|
@@ -4600,7 +4670,7 @@ var useView = ({
|
|
|
4600
4670
|
|
|
4601
4671
|
// src/layout-view/useViewResize.ts
|
|
4602
4672
|
import { useResizeObserver as useResizeObserver2, WidthHeight as WidthHeight2 } from "@heswell/salt-lab";
|
|
4603
|
-
import { useCallback as useCallback13, useRef as
|
|
4673
|
+
import { useCallback as useCallback13, useRef as useRef9 } from "react";
|
|
4604
4674
|
var NO_MEASUREMENT = [];
|
|
4605
4675
|
var useViewResize = ({
|
|
4606
4676
|
mainRef,
|
|
@@ -4608,8 +4678,8 @@ var useViewResize = ({
|
|
|
4608
4678
|
rootRef
|
|
4609
4679
|
}) => {
|
|
4610
4680
|
const deferResize = resize === "defer";
|
|
4611
|
-
const mainSize =
|
|
4612
|
-
const resizeHandle =
|
|
4681
|
+
const mainSize = useRef9({});
|
|
4682
|
+
const resizeHandle = useRef9();
|
|
4613
4683
|
const setMainSize = useCallback13(() => {
|
|
4614
4684
|
if (mainRef.current) {
|
|
4615
4685
|
mainRef.current.style.height = mainSize.current.height + "px";
|
|
@@ -4682,9 +4752,9 @@ var View = forwardRef5(function View2(props, forwardedRef) {
|
|
|
4682
4752
|
title: titleProp,
|
|
4683
4753
|
...restProps
|
|
4684
4754
|
} = props;
|
|
4685
|
-
const id =
|
|
4686
|
-
const rootRef =
|
|
4687
|
-
const mainRef =
|
|
4755
|
+
const id = useId2(idProp);
|
|
4756
|
+
const rootRef = useRef10(null);
|
|
4757
|
+
const mainRef = useRef10(null);
|
|
4688
4758
|
const [componentProps, _setComponentProps] = useState6();
|
|
4689
4759
|
const {
|
|
4690
4760
|
contributions,
|
|
@@ -4718,7 +4788,7 @@ var View = forwardRef5(function View2(props, forwardedRef) {
|
|
|
4718
4788
|
}
|
|
4719
4789
|
return children;
|
|
4720
4790
|
};
|
|
4721
|
-
const viewContextValue =
|
|
4791
|
+
const viewContextValue = useMemo6(
|
|
4722
4792
|
() => ({
|
|
4723
4793
|
dispatch: dispatchViewAction,
|
|
4724
4794
|
id,
|
|
@@ -4788,165 +4858,3072 @@ registerComponent("View", MemoView, "view");
|
|
|
4788
4858
|
|
|
4789
4859
|
// src/layout-header/Header.tsx
|
|
4790
4860
|
import {
|
|
4791
|
-
EditableLabel,
|
|
4792
4861
|
Toolbar,
|
|
4793
4862
|
ToolbarButton,
|
|
4794
4863
|
ToolbarField,
|
|
4795
4864
|
Tooltray
|
|
4796
4865
|
} from "@heswell/salt-lab";
|
|
4797
4866
|
import { CloseIcon } from "@salt-ds/icons";
|
|
4798
|
-
|
|
4799
|
-
|
|
4867
|
+
|
|
4868
|
+
// ../../node_modules/clsx/dist/clsx.m.js
|
|
4869
|
+
function r(e) {
|
|
4870
|
+
var t, f, n = "";
|
|
4871
|
+
if ("string" == typeof e || "number" == typeof e)
|
|
4872
|
+
n += e;
|
|
4873
|
+
else if ("object" == typeof e)
|
|
4874
|
+
if (Array.isArray(e))
|
|
4875
|
+
for (t = 0; t < e.length; t++)
|
|
4876
|
+
e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
4877
|
+
else
|
|
4878
|
+
for (t in e)
|
|
4879
|
+
e[t] && (n && (n += " "), n += t);
|
|
4880
|
+
return n;
|
|
4881
|
+
}
|
|
4882
|
+
function clsx() {
|
|
4883
|
+
for (var e, t, f = 0, n = ""; f < arguments.length; )
|
|
4884
|
+
(e = arguments[f++]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
4885
|
+
return n;
|
|
4886
|
+
}
|
|
4887
|
+
|
|
4888
|
+
// ../vuu-ui-controls/src/editable-label/EditableLabel.tsx
|
|
4889
|
+
import {
|
|
4890
|
+
useCallback as useCallback15,
|
|
4891
|
+
useLayoutEffect as useLayoutEffect3,
|
|
4892
|
+
forwardRef as forwardRef6,
|
|
4893
|
+
useRef as useRef11
|
|
4894
|
+
} from "react";
|
|
4895
|
+
import { useControlled as useControlled2 } from "@salt-ds/core";
|
|
4896
|
+
import { Input } from "@heswell/salt-lab";
|
|
4897
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
4898
|
+
var classBase7 = "vuuEditableLabel";
|
|
4899
|
+
var EditableLabel = forwardRef6(function EditableLabel2({
|
|
4800
4900
|
className: classNameProp,
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
const
|
|
4811
|
-
const
|
|
4812
|
-
const
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4901
|
+
defaultEditing,
|
|
4902
|
+
defaultValue,
|
|
4903
|
+
editing: editingProp,
|
|
4904
|
+
onChange,
|
|
4905
|
+
onEnterEditMode,
|
|
4906
|
+
onExitEditMode,
|
|
4907
|
+
value: valueProp,
|
|
4908
|
+
...restProps
|
|
4909
|
+
}, forwardedRef) {
|
|
4910
|
+
const inputRef = useRef11(null);
|
|
4911
|
+
const editingRef = useRef11(false);
|
|
4912
|
+
const [value, setValue] = useControlled2({
|
|
4913
|
+
controlled: valueProp,
|
|
4914
|
+
default: defaultValue != null ? defaultValue : "",
|
|
4915
|
+
name: "EditableLabel",
|
|
4916
|
+
state: "value"
|
|
4917
|
+
});
|
|
4918
|
+
const [editing, _setEditing] = useControlled2({
|
|
4919
|
+
controlled: editingProp,
|
|
4920
|
+
default: defaultEditing != null ? defaultEditing : false,
|
|
4921
|
+
name: "EditableLabel",
|
|
4922
|
+
state: "editing"
|
|
4923
|
+
});
|
|
4924
|
+
const setEditing = useCallback15((value2) => {
|
|
4925
|
+
_setEditing(editingRef.current = value2);
|
|
4926
|
+
}, []);
|
|
4927
|
+
const initialValue = useRef11(value);
|
|
4928
|
+
useLayoutEffect3(() => {
|
|
4929
|
+
if (editing) {
|
|
4930
|
+
if (inputRef.current !== null) {
|
|
4931
|
+
inputRef.current.select();
|
|
4932
|
+
inputRef.current.focus();
|
|
4933
|
+
}
|
|
4934
|
+
}
|
|
4935
|
+
}, [editing, inputRef]);
|
|
4936
|
+
const enterEditMode = useCallback15(() => {
|
|
4937
|
+
setEditing(true);
|
|
4938
|
+
onEnterEditMode && onEnterEditMode();
|
|
4939
|
+
}, [onEnterEditMode, setEditing]);
|
|
4940
|
+
const exitEditMode = ({
|
|
4941
|
+
cancelEdit = false,
|
|
4942
|
+
allowDeactivation = false
|
|
4943
|
+
} = {}) => {
|
|
4944
|
+
setEditing(false);
|
|
4945
|
+
const originalValue = initialValue.current;
|
|
4946
|
+
if (originalValue !== value) {
|
|
4947
|
+
if (cancelEdit) {
|
|
4948
|
+
setValue(originalValue);
|
|
4949
|
+
} else {
|
|
4950
|
+
initialValue.current = value;
|
|
4951
|
+
}
|
|
4952
|
+
}
|
|
4953
|
+
onExitEditMode && onExitEditMode(originalValue, value, allowDeactivation, cancelEdit);
|
|
4818
4954
|
};
|
|
4819
|
-
const
|
|
4820
|
-
evt.
|
|
4955
|
+
const handleChange = (evt) => {
|
|
4956
|
+
const { value: value2 } = evt.target;
|
|
4957
|
+
setValue(value2);
|
|
4958
|
+
onChange && onChange(value2);
|
|
4821
4959
|
};
|
|
4822
|
-
const
|
|
4823
|
-
|
|
4824
|
-
classBase9,
|
|
4825
|
-
classNameProp,
|
|
4826
|
-
`${classBase9}-${orientation}`
|
|
4827
|
-
);
|
|
4828
|
-
const handleEnterEditMode = () => {
|
|
4829
|
-
setEditing(true);
|
|
4960
|
+
const handleDoubleClick = () => {
|
|
4961
|
+
enterEditMode();
|
|
4830
4962
|
};
|
|
4831
|
-
const
|
|
4832
|
-
if (
|
|
4833
|
-
|
|
4963
|
+
const handleBlur = () => {
|
|
4964
|
+
if (editingRef.current) {
|
|
4965
|
+
exitEditMode({ allowDeactivation: true });
|
|
4834
4966
|
}
|
|
4835
4967
|
};
|
|
4836
|
-
const
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
}
|
|
4845
|
-
if (allowDeactivation === false) {
|
|
4846
|
-
(_a = labelFieldRef.current) == null ? void 0 : _a.focus();
|
|
4968
|
+
const handleKeyDown = (evt) => {
|
|
4969
|
+
if (editing && evt.key === "Enter") {
|
|
4970
|
+
evt.stopPropagation();
|
|
4971
|
+
exitEditMode();
|
|
4972
|
+
} else if (evt.key === "ArrowRight" || evt.key === "ArrowLeft") {
|
|
4973
|
+
evt.stopPropagation();
|
|
4974
|
+
} else if (evt.key === "Escape") {
|
|
4975
|
+
exitEditMode({ cancelEdit: true });
|
|
4847
4976
|
}
|
|
4848
4977
|
};
|
|
4849
|
-
const
|
|
4850
|
-
|
|
4851
|
-
};
|
|
4852
|
-
const toolbarItems = [];
|
|
4853
|
-
const postTitleContributedItems = [];
|
|
4854
|
-
const actionButtons = [];
|
|
4855
|
-
contributions == null ? void 0 : contributions.forEach((contribution, i) => {
|
|
4856
|
-
switch (contribution.location) {
|
|
4857
|
-
case "pre-title":
|
|
4858
|
-
toolbarItems.push(React15.cloneElement(contribution.content, { key: i }));
|
|
4859
|
-
break;
|
|
4860
|
-
default:
|
|
4861
|
-
postTitleContributedItems.push(
|
|
4862
|
-
React15.cloneElement(contribution.content, { key: i })
|
|
4863
|
-
);
|
|
4864
|
-
}
|
|
4978
|
+
const className = clsx(classBase7, classNameProp, {
|
|
4979
|
+
[`${classBase7}-editing`]: editing
|
|
4865
4980
|
});
|
|
4866
|
-
title && toolbarItems.push(
|
|
4867
|
-
/* @__PURE__ */ jsx15(ToolbarField, { className: "vuuHeader-title", children: /* @__PURE__ */ jsx15(
|
|
4868
|
-
EditableLabel,
|
|
4869
|
-
{
|
|
4870
|
-
editing,
|
|
4871
|
-
value,
|
|
4872
|
-
onChange: setValue,
|
|
4873
|
-
onMouseDownCapture: handleTitleMouseDown,
|
|
4874
|
-
onEnterEditMode: handleEnterEditMode,
|
|
4875
|
-
onExitEditMode: handleExitEditMode,
|
|
4876
|
-
onKeyDown: handleTitleKeyDown,
|
|
4877
|
-
ref: labelFieldRef,
|
|
4878
|
-
tabIndex: 0
|
|
4879
|
-
},
|
|
4880
|
-
"title"
|
|
4881
|
-
) }, "title")
|
|
4882
|
-
);
|
|
4883
|
-
closeable && actionButtons.push(
|
|
4884
|
-
/* @__PURE__ */ jsxs4(
|
|
4885
|
-
ToolbarButton,
|
|
4886
|
-
{
|
|
4887
|
-
onClick: handleClose,
|
|
4888
|
-
onMouseDown: handleButtonMouseDown,
|
|
4889
|
-
children: [
|
|
4890
|
-
/* @__PURE__ */ jsx15(CloseIcon, {}),
|
|
4891
|
-
" Close"
|
|
4892
|
-
]
|
|
4893
|
-
},
|
|
4894
|
-
"close"
|
|
4895
|
-
)
|
|
4896
|
-
);
|
|
4897
|
-
postTitleContributedItems.length > 0 && toolbarItems.push(
|
|
4898
|
-
/* @__PURE__ */ jsx15(Tooltray, { "data-align-end": true, children: postTitleContributedItems }, "contributions")
|
|
4899
|
-
);
|
|
4900
|
-
actionButtons.length > 0 && toolbarItems.push(
|
|
4901
|
-
/* @__PURE__ */ jsx15(Tooltray, { "data-align-end": true, children: actionButtons }, "actions")
|
|
4902
|
-
);
|
|
4903
4981
|
return /* @__PURE__ */ jsx15(
|
|
4904
|
-
|
|
4982
|
+
"div",
|
|
4905
4983
|
{
|
|
4984
|
+
...restProps,
|
|
4906
4985
|
className,
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
children:
|
|
4986
|
+
onDoubleClick: handleDoubleClick,
|
|
4987
|
+
"data-text": value,
|
|
4988
|
+
ref: forwardedRef,
|
|
4989
|
+
children: editing ? /* @__PURE__ */ jsx15(
|
|
4990
|
+
Input,
|
|
4991
|
+
{
|
|
4992
|
+
inputProps: { className: `${classBase7}-input` },
|
|
4993
|
+
value,
|
|
4994
|
+
onBlur: handleBlur,
|
|
4995
|
+
onChange: handleChange,
|
|
4996
|
+
onKeyDown: handleKeyDown,
|
|
4997
|
+
ref: inputRef,
|
|
4998
|
+
style: { padding: 0 },
|
|
4999
|
+
textAlign: "left"
|
|
5000
|
+
}
|
|
5001
|
+
) : value
|
|
4911
5002
|
}
|
|
4912
5003
|
);
|
|
4913
|
-
};
|
|
5004
|
+
});
|
|
4914
5005
|
|
|
4915
|
-
// src/
|
|
4916
|
-
import {
|
|
4917
|
-
import { List, ListItem } from "@heswell/salt-lab";
|
|
5006
|
+
// ../vuu-ui-controls/src/tabstrip/Tabstrip.tsx
|
|
5007
|
+
import { Button as Button2 } from "@salt-ds/core";
|
|
4918
5008
|
import cx9 from "classnames";
|
|
5009
|
+
import React16, { useMemo as useMemo12, useRef as useRef20 } from "react";
|
|
5010
|
+
|
|
5011
|
+
// ../vuu-ui-controls/src/tabstrip/useTabstrip.ts
|
|
4919
5012
|
import {
|
|
4920
|
-
|
|
4921
|
-
|
|
5013
|
+
useCallback as useCallback27,
|
|
5014
|
+
useRef as useRef19
|
|
5015
|
+
} from "react";
|
|
5016
|
+
|
|
5017
|
+
// ../vuu-ui-controls/src/drag-drop/DragDropProvider.tsx
|
|
5018
|
+
import {
|
|
5019
|
+
createContext as createContext2,
|
|
5020
|
+
useCallback as useCallback16,
|
|
5021
|
+
useContext as useContext3,
|
|
5022
|
+
useMemo as useMemo7
|
|
4922
5023
|
} from "react";
|
|
4923
5024
|
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
4924
|
-
var
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
5025
|
+
var NO_DRAG_CONTEXT = {
|
|
5026
|
+
isDragSource: false,
|
|
5027
|
+
isDropTarget: false,
|
|
5028
|
+
register: () => void 0
|
|
5029
|
+
};
|
|
5030
|
+
var unconfiguredRegistrationCall = () => console.log(`have you forgotten to provide a DragDrop Provider ?`);
|
|
5031
|
+
var DragDropContext = createContext2({
|
|
5032
|
+
registerDragDropParty: unconfiguredRegistrationCall
|
|
5033
|
+
});
|
|
5034
|
+
var useDragDropProvider = (id) => {
|
|
5035
|
+
var _a, _b;
|
|
5036
|
+
const { dragSources, dropTargets, registerDragDropParty } = useContext3(DragDropContext);
|
|
5037
|
+
if (id) {
|
|
5038
|
+
const isDragSource = (_a = dragSources == null ? void 0 : dragSources.has(id)) != null ? _a : false;
|
|
5039
|
+
const isDropTarget = (_b = dropTargets == null ? void 0 : dropTargets.has(id)) != null ? _b : false;
|
|
5040
|
+
return {
|
|
5041
|
+
isDragSource,
|
|
5042
|
+
isDropTarget,
|
|
5043
|
+
register: registerDragDropParty
|
|
5044
|
+
};
|
|
5045
|
+
} else {
|
|
5046
|
+
return NO_DRAG_CONTEXT;
|
|
5047
|
+
}
|
|
5048
|
+
};
|
|
5049
|
+
|
|
5050
|
+
// ../vuu-ui-controls/src/drag-drop/useDragDropNaturalMovementNext.tsx
|
|
5051
|
+
import { useCallback as useCallback19, useMemo as useMemo9, useRef as useRef13, useState as useState7 } from "react";
|
|
5052
|
+
|
|
5053
|
+
// ../vuu-ui-controls/src/drag-drop/useDragDisplacers.ts
|
|
5054
|
+
import { useCallback as useCallback18, useMemo as useMemo8, useRef as useRef12 } from "react";
|
|
5055
|
+
|
|
5056
|
+
// ../vuu-ui-controls/src/drag-drop/drop-target-utils.ts
|
|
5057
|
+
var LEFT_RIGHT = ["left", "right"];
|
|
5058
|
+
var TOP_BOTTOM = ["top", "bottom"];
|
|
5059
|
+
var NOT_OVERFLOWED = ":not(.wrapped)";
|
|
5060
|
+
var NOT_HIDDEN = ':not([aria-hidden="true"])';
|
|
5061
|
+
var cloneElement4 = (element) => {
|
|
5062
|
+
const dolly = element.cloneNode(true);
|
|
5063
|
+
dolly.removeAttribute("id");
|
|
5064
|
+
dolly.dataset.index = "-1";
|
|
4928
5065
|
return dolly;
|
|
4929
5066
|
};
|
|
4930
|
-
var
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
...props
|
|
4946
|
-
}
|
|
4947
|
-
);
|
|
5067
|
+
var measureElementSizeAndPosition = (element, dimension = "width", includeAutoMargin = false) => {
|
|
5068
|
+
const pos = dimension === "width" ? "left" : "top";
|
|
5069
|
+
const { [dimension]: size, [pos]: position } = element.getBoundingClientRect();
|
|
5070
|
+
const { padEnd = false, padStart = false } = element.dataset;
|
|
5071
|
+
const style = getComputedStyle(element);
|
|
5072
|
+
const [start2, end] = dimension === "width" ? LEFT_RIGHT : TOP_BOTTOM;
|
|
5073
|
+
const marginStart = padStart && !includeAutoMargin ? 0 : parseInt(style.getPropertyValue(`margin-${start2}`), 10);
|
|
5074
|
+
const marginEnd = padEnd && !includeAutoMargin ? 0 : parseInt(style.getPropertyValue(`margin-${end}`), 10);
|
|
5075
|
+
let minWidth = size;
|
|
5076
|
+
const flexShrink = parseInt(style.getPropertyValue("flex-shrink"), 10);
|
|
5077
|
+
if (flexShrink > 0) {
|
|
5078
|
+
const flexBasis = parseInt(style.getPropertyValue("flex-basis"), 10);
|
|
5079
|
+
if (!isNaN(flexBasis) && flexBasis > 0) {
|
|
5080
|
+
minWidth = flexBasis;
|
|
5081
|
+
}
|
|
4948
5082
|
}
|
|
4949
|
-
|
|
5083
|
+
return [position, marginStart + minWidth + marginEnd];
|
|
5084
|
+
};
|
|
5085
|
+
var DIMENSIONS = {
|
|
5086
|
+
horizontal: {
|
|
5087
|
+
CLIENT_POS: "clientX",
|
|
5088
|
+
CLIENT_SIZE: "clientWidth",
|
|
5089
|
+
CONTRA: "top",
|
|
5090
|
+
CONTRA_CLIENT_POS: "clientY",
|
|
5091
|
+
CONTRA_END: "bottom",
|
|
5092
|
+
CONTRA_POS: "y",
|
|
5093
|
+
DIMENSION: "width",
|
|
5094
|
+
END: "right",
|
|
5095
|
+
POS: "x",
|
|
5096
|
+
SCROLL_POS: "scrollLeft",
|
|
5097
|
+
SCROLL_SIZE: "scrollWidth",
|
|
5098
|
+
START: "left"
|
|
5099
|
+
},
|
|
5100
|
+
vertical: {
|
|
5101
|
+
CLIENT_POS: "clientY",
|
|
5102
|
+
CLIENT_SIZE: "clientHeight",
|
|
5103
|
+
CONTRA: "left",
|
|
5104
|
+
CONTRA_CLIENT_POS: "clientX",
|
|
5105
|
+
CONTRA_END: "right",
|
|
5106
|
+
CONTRA_POS: "x",
|
|
5107
|
+
DIMENSION: "height",
|
|
5108
|
+
END: "bottom",
|
|
5109
|
+
POS: "y",
|
|
5110
|
+
SCROLL_POS: "scrollTop",
|
|
5111
|
+
SCROLL_SIZE: "scrollHeight",
|
|
5112
|
+
START: "top"
|
|
5113
|
+
}
|
|
5114
|
+
};
|
|
5115
|
+
var dimensions = (orientation) => DIMENSIONS[orientation];
|
|
5116
|
+
var getItemById = (measuredItems, id) => {
|
|
5117
|
+
const result = measuredItems.find((item) => item.id === id);
|
|
5118
|
+
if (result) {
|
|
5119
|
+
return result;
|
|
5120
|
+
}
|
|
5121
|
+
};
|
|
5122
|
+
var removeDraggedItem = (measuredItems, index) => {
|
|
5123
|
+
measuredItems.splice(index, 1);
|
|
5124
|
+
for (let i = index; i < measuredItems.length; i++) {
|
|
5125
|
+
measuredItems[i].currentIndex -= 1;
|
|
5126
|
+
}
|
|
5127
|
+
};
|
|
5128
|
+
var measureDropTargets = (container, orientation, itemQuery, viewportRange, draggedItemId) => {
|
|
5129
|
+
var _a;
|
|
5130
|
+
const dragThresholds = [];
|
|
5131
|
+
const { DIMENSION } = dimensions(orientation);
|
|
5132
|
+
const children = Array.from(
|
|
5133
|
+
itemQuery ? container.querySelectorAll(itemQuery) : container.children
|
|
5134
|
+
);
|
|
5135
|
+
const itemCount = children.length;
|
|
5136
|
+
const start2 = typeof (viewportRange == null ? void 0 : viewportRange.from) === "number" ? viewportRange.atEnd ? Math.max(0, viewportRange.from - 1) : viewportRange.from : 0;
|
|
5137
|
+
const end = typeof (viewportRange == null ? void 0 : viewportRange.to) === "number" ? Math.min(viewportRange.to + 2, itemCount - 1) : itemCount - 1;
|
|
5138
|
+
for (let index = start2; index <= end; index++) {
|
|
5139
|
+
const element = children[index];
|
|
5140
|
+
const [start3, size] = measureElementSizeAndPosition(element, DIMENSION);
|
|
5141
|
+
const isLast = index === itemCount - 1;
|
|
5142
|
+
const id = element.id;
|
|
5143
|
+
const dataIndex = parseInt((_a = element.dataset.index) != null ? _a : "-1");
|
|
5144
|
+
dragThresholds.push({
|
|
5145
|
+
currentIndex: index,
|
|
5146
|
+
dataIndex: isNaN(dataIndex) ? -1 : dataIndex,
|
|
5147
|
+
id,
|
|
5148
|
+
index,
|
|
5149
|
+
isDraggedItem: draggedItemId === id,
|
|
5150
|
+
isLast,
|
|
5151
|
+
isOverflowIndicator: element.dataset.index === "overflow",
|
|
5152
|
+
element,
|
|
5153
|
+
start: start3,
|
|
5154
|
+
end: start3 + size,
|
|
5155
|
+
size,
|
|
5156
|
+
mid: start3 + size / 2
|
|
5157
|
+
});
|
|
5158
|
+
}
|
|
5159
|
+
return dragThresholds;
|
|
5160
|
+
};
|
|
5161
|
+
var getIndexOfDraggedItem = (dropTargets) => dropTargets.findIndex((d) => d.isDraggedItem);
|
|
5162
|
+
var mutateDropTargetsSwitchDropTargetPosition = (dropTargets, direction) => {
|
|
5163
|
+
const indexOfDraggedItem = getIndexOfDraggedItem(dropTargets);
|
|
5164
|
+
const indexOfTarget = direction === "fwd" ? indexOfDraggedItem + 1 : indexOfDraggedItem - 1;
|
|
5165
|
+
if (indexOfTarget < 0 || indexOfTarget >= dropTargets.length) {
|
|
5166
|
+
throw Error("switchDropTargetPosition index out of range");
|
|
5167
|
+
}
|
|
5168
|
+
const draggedItem = dropTargets.at(indexOfDraggedItem);
|
|
5169
|
+
const targetItem = dropTargets.at(indexOfTarget);
|
|
5170
|
+
const diff = targetItem.size - draggedItem.size;
|
|
5171
|
+
if (direction === "fwd") {
|
|
5172
|
+
const draggedStart = targetItem.start + diff;
|
|
5173
|
+
const draggedEnd = targetItem.end;
|
|
5174
|
+
const newDraggedItem = {
|
|
5175
|
+
...draggedItem,
|
|
5176
|
+
start: draggedStart,
|
|
5177
|
+
mid: Math.floor(draggedStart + (draggedEnd - draggedStart) / 2),
|
|
5178
|
+
end: draggedEnd
|
|
5179
|
+
};
|
|
5180
|
+
const targetStart = draggedItem.start;
|
|
5181
|
+
const targetEnd = draggedItem.end + diff;
|
|
5182
|
+
const newTargetItem = {
|
|
5183
|
+
...targetItem,
|
|
5184
|
+
start: targetStart,
|
|
5185
|
+
mid: Math.floor(targetStart + (targetEnd - targetStart) / 2),
|
|
5186
|
+
end: targetEnd
|
|
5187
|
+
};
|
|
5188
|
+
dropTargets.splice(indexOfDraggedItem, 2, newTargetItem, newDraggedItem);
|
|
5189
|
+
} else {
|
|
5190
|
+
const draggedStart = targetItem.start;
|
|
5191
|
+
const draggedEnd = targetItem.end - diff;
|
|
5192
|
+
const newDraggedItem = {
|
|
5193
|
+
...draggedItem,
|
|
5194
|
+
start: draggedStart,
|
|
5195
|
+
mid: Math.floor(draggedStart + (draggedEnd - draggedStart) / 2),
|
|
5196
|
+
end: draggedEnd
|
|
5197
|
+
};
|
|
5198
|
+
const targetStart = draggedItem.start - diff;
|
|
5199
|
+
const targetEnd = draggedItem.end;
|
|
5200
|
+
const newTargetItem = {
|
|
5201
|
+
...targetItem,
|
|
5202
|
+
start: targetStart,
|
|
5203
|
+
mid: Math.floor(targetStart + (targetEnd - targetStart) / 2),
|
|
5204
|
+
end: targetEnd
|
|
5205
|
+
};
|
|
5206
|
+
dropTargets.splice(indexOfTarget, 2, newDraggedItem, newTargetItem);
|
|
5207
|
+
}
|
|
5208
|
+
};
|
|
5209
|
+
var getNextDropTarget = (dropTargets, pos, mouseMoveDirection) => {
|
|
5210
|
+
const len = dropTargets.length;
|
|
5211
|
+
const indexOfDraggedItem = getIndexOfDraggedItem(dropTargets);
|
|
5212
|
+
const draggedItem = dropTargets[indexOfDraggedItem];
|
|
5213
|
+
if (mouseMoveDirection === "fwd") {
|
|
5214
|
+
const leadingEdge = Math.round(pos + draggedItem.size);
|
|
5215
|
+
for (let index = len - 1; index >= 0; index--) {
|
|
5216
|
+
const dropTarget = dropTargets[index];
|
|
5217
|
+
if (leadingEdge > dropTarget.mid) {
|
|
5218
|
+
if (index < indexOfDraggedItem) {
|
|
5219
|
+
return draggedItem;
|
|
5220
|
+
} else {
|
|
5221
|
+
return dropTarget;
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
} else {
|
|
5226
|
+
const leadingEdge = Math.round(pos);
|
|
5227
|
+
for (let index = 0; index < len; index++) {
|
|
5228
|
+
const dropTarget = dropTargets[index];
|
|
5229
|
+
if (leadingEdge < dropTarget.mid) {
|
|
5230
|
+
if (index > indexOfDraggedItem) {
|
|
5231
|
+
return draggedItem;
|
|
5232
|
+
} else {
|
|
5233
|
+
return dropTarget;
|
|
5234
|
+
}
|
|
5235
|
+
}
|
|
5236
|
+
}
|
|
5237
|
+
}
|
|
5238
|
+
throw Error("no dropTraget identified");
|
|
5239
|
+
};
|
|
5240
|
+
function constrainRect(targetRect, constraintRect) {
|
|
5241
|
+
const { height, left, top, width } = targetRect;
|
|
5242
|
+
const { height: constrainedHeight, width: constrainedWidth } = constraintRect;
|
|
5243
|
+
return {
|
|
5244
|
+
height: Math.min(height, constrainedHeight),
|
|
5245
|
+
left,
|
|
5246
|
+
top,
|
|
5247
|
+
width: Math.min(width, constrainedWidth)
|
|
5248
|
+
};
|
|
5249
|
+
}
|
|
5250
|
+
|
|
5251
|
+
// ../vuu-ui-controls/src/drag-drop/Draggable.tsx
|
|
5252
|
+
import { useForkRef as useForkRef4 } from "@salt-ds/core";
|
|
5253
|
+
import {
|
|
5254
|
+
forwardRef as forwardRef7,
|
|
5255
|
+
useCallback as useCallback17
|
|
5256
|
+
} from "react";
|
|
5257
|
+
import { Portal } from "@vuu-ui/vuu-popups";
|
|
5258
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
5259
|
+
var makeClassNames = (classNames) => classNames.split(" ").map((className) => `vuuDraggable-${className}`);
|
|
5260
|
+
var Draggable2 = forwardRef7(function Draggable3({ wrapperClassName, element, onTransitionEnd, style, scale = 1 }, forwardedRef) {
|
|
5261
|
+
const callbackRef = useCallback17(
|
|
5262
|
+
(el) => {
|
|
5263
|
+
if (el) {
|
|
5264
|
+
el.innerHTML = "";
|
|
5265
|
+
el.appendChild(element);
|
|
5266
|
+
if (scale !== 1) {
|
|
5267
|
+
el.style.transform = `scale(${scale},${scale})`;
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
},
|
|
5271
|
+
[element, scale]
|
|
5272
|
+
);
|
|
5273
|
+
const forkedRef = useForkRef4(forwardedRef, callbackRef);
|
|
5274
|
+
return /* @__PURE__ */ jsx17(Portal, { children: /* @__PURE__ */ jsx17(
|
|
5275
|
+
"div",
|
|
5276
|
+
{
|
|
5277
|
+
className: clsx("vuuDraggable", ...makeClassNames(wrapperClassName)),
|
|
5278
|
+
ref: forkedRef,
|
|
5279
|
+
onTransitionEnd,
|
|
5280
|
+
style
|
|
5281
|
+
}
|
|
5282
|
+
) });
|
|
5283
|
+
});
|
|
5284
|
+
var createDragSpacer = (transitioning) => {
|
|
5285
|
+
const spacer = document.createElement("div");
|
|
5286
|
+
spacer.className = "vuuDraggable-spacer";
|
|
5287
|
+
if (transitioning) {
|
|
5288
|
+
spacer.addEventListener("transitionend", () => {
|
|
5289
|
+
transitioning.current = false;
|
|
5290
|
+
});
|
|
5291
|
+
}
|
|
5292
|
+
return spacer;
|
|
5293
|
+
};
|
|
5294
|
+
var createDropIndicatorPosition = () => {
|
|
5295
|
+
const spacer = document.createElement("div");
|
|
5296
|
+
spacer.className = "vuuDraggable-dropIndicatorPosition";
|
|
5297
|
+
return spacer;
|
|
5298
|
+
};
|
|
5299
|
+
var createDropIndicator = (transitioning) => {
|
|
5300
|
+
const spacer = document.createElement("div");
|
|
5301
|
+
spacer.className = "vuuDraggable-dropIndicator";
|
|
5302
|
+
if (transitioning) {
|
|
5303
|
+
spacer.addEventListener("transitionend", () => {
|
|
5304
|
+
transitioning.current = false;
|
|
5305
|
+
});
|
|
5306
|
+
}
|
|
5307
|
+
return spacer;
|
|
5308
|
+
};
|
|
5309
|
+
|
|
5310
|
+
// ../vuu-ui-controls/src/drag-drop/useDragDisplacers.ts
|
|
5311
|
+
var useDragDisplacers = () => {
|
|
5312
|
+
const animationFrame = useRef12(0);
|
|
5313
|
+
const transitioning = useRef12(false);
|
|
5314
|
+
const spacers = useMemo8(
|
|
5315
|
+
// We only need to listen for transition end on one of the spacers
|
|
5316
|
+
() => [createDragSpacer(transitioning), createDragSpacer()],
|
|
5317
|
+
[]
|
|
5318
|
+
);
|
|
5319
|
+
const clearSpacers = useCallback18(
|
|
5320
|
+
() => spacers.forEach((spacer) => spacer.remove()),
|
|
5321
|
+
[spacers]
|
|
5322
|
+
);
|
|
5323
|
+
const animateTransition = useCallback18(
|
|
5324
|
+
(size, propertyName = "width") => {
|
|
5325
|
+
const [spacer1, spacer2] = spacers;
|
|
5326
|
+
animationFrame.current = requestAnimationFrame(() => {
|
|
5327
|
+
transitioning.current = true;
|
|
5328
|
+
spacer1.style.cssText = `${propertyName}: 0px`;
|
|
5329
|
+
spacer2.style.cssText = `${propertyName}: ${size}px`;
|
|
5330
|
+
spacers[0] = spacer2;
|
|
5331
|
+
spacers[1] = spacer1;
|
|
5332
|
+
});
|
|
5333
|
+
},
|
|
5334
|
+
[spacers]
|
|
5335
|
+
);
|
|
5336
|
+
const cancelAnyPendingAnimation = useCallback18(() => {
|
|
5337
|
+
if (animationFrame.current) {
|
|
5338
|
+
cancelAnimationFrame(animationFrame.current);
|
|
5339
|
+
animationFrame.current = 0;
|
|
5340
|
+
}
|
|
5341
|
+
}, []);
|
|
5342
|
+
const clearDisplacedItem = useCallback18(() => {
|
|
5343
|
+
clearSpacers();
|
|
5344
|
+
}, [clearSpacers]);
|
|
5345
|
+
const displaceItem = useCallback18(
|
|
5346
|
+
(dropTargets, dropTarget, size, useTransition = false, direction = "static", orientation = "horizontal") => {
|
|
5347
|
+
if (dropTarget) {
|
|
5348
|
+
const propertyName = orientation === "horizontal" ? "width" : "height";
|
|
5349
|
+
const [spacer1, spacer2] = spacers;
|
|
5350
|
+
cancelAnyPendingAnimation();
|
|
5351
|
+
if (useTransition) {
|
|
5352
|
+
if (transitioning.current) {
|
|
5353
|
+
clearSpacers();
|
|
5354
|
+
spacer1.style.cssText = `${propertyName}: ${size}px`;
|
|
5355
|
+
spacer2.style.cssText = `${propertyName}: 0px`;
|
|
5356
|
+
if (direction === "fwd") {
|
|
5357
|
+
dropTarget.element.before(spacer1);
|
|
5358
|
+
dropTarget.element.after(spacer2);
|
|
5359
|
+
} else {
|
|
5360
|
+
dropTarget.element.after(spacer1);
|
|
5361
|
+
dropTarget.element.before(spacer2);
|
|
5362
|
+
}
|
|
5363
|
+
} else {
|
|
5364
|
+
if (direction === "fwd") {
|
|
5365
|
+
dropTarget.element.after(spacer2);
|
|
5366
|
+
} else {
|
|
5367
|
+
dropTarget.element.before(spacer2);
|
|
5368
|
+
}
|
|
5369
|
+
}
|
|
5370
|
+
animateTransition(size, propertyName);
|
|
5371
|
+
} else if (direction === "static") {
|
|
5372
|
+
spacer1.style.cssText = `${propertyName}: ${size}px`;
|
|
5373
|
+
dropTarget.element.before(spacer1);
|
|
5374
|
+
} else {
|
|
5375
|
+
throw Error(
|
|
5376
|
+
"useDragDisplacers currently only supports noTransition for static displacement"
|
|
5377
|
+
);
|
|
5378
|
+
}
|
|
5379
|
+
if (direction !== "static") {
|
|
5380
|
+
mutateDropTargetsSwitchDropTargetPosition(dropTargets, direction);
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
},
|
|
5384
|
+
[animateTransition, cancelAnyPendingAnimation, clearSpacers, spacers]
|
|
5385
|
+
);
|
|
5386
|
+
const displaceLastItem = useCallback18(
|
|
5387
|
+
(dropTargets, dropTarget, size, useTransition = false, direction = "static", orientation = "horizontal") => {
|
|
5388
|
+
const propertyName = orientation === "horizontal" ? "width" : "height";
|
|
5389
|
+
const [spacer1, spacer2] = spacers;
|
|
5390
|
+
cancelAnyPendingAnimation();
|
|
5391
|
+
if (useTransition) {
|
|
5392
|
+
if (transitioning.current) {
|
|
5393
|
+
clearSpacers();
|
|
5394
|
+
spacer1.style.cssText = `${propertyName}: ${size}px`;
|
|
5395
|
+
spacer2.style.cssText = `${propertyName}: 0px`;
|
|
5396
|
+
dropTarget.element.before(spacer1);
|
|
5397
|
+
dropTarget.element.after(spacer2);
|
|
5398
|
+
} else {
|
|
5399
|
+
if (direction === "fwd") {
|
|
5400
|
+
dropTarget.element.after(spacer2);
|
|
5401
|
+
} else {
|
|
5402
|
+
dropTarget.element.before(spacer2);
|
|
5403
|
+
}
|
|
5404
|
+
}
|
|
5405
|
+
animateTransition(size, propertyName);
|
|
5406
|
+
} else {
|
|
5407
|
+
spacer1.style.cssText = `${propertyName}: ${size}px`;
|
|
5408
|
+
dropTarget.element.after(spacer1);
|
|
5409
|
+
}
|
|
5410
|
+
if (direction !== "static") {
|
|
5411
|
+
mutateDropTargetsSwitchDropTargetPosition(dropTargets, direction);
|
|
5412
|
+
}
|
|
5413
|
+
},
|
|
5414
|
+
[animateTransition, cancelAnyPendingAnimation, clearSpacers, spacers]
|
|
5415
|
+
);
|
|
5416
|
+
return {
|
|
5417
|
+
clearDisplacedItem,
|
|
5418
|
+
displaceItem,
|
|
5419
|
+
displaceLastItem,
|
|
5420
|
+
clearSpacers
|
|
5421
|
+
};
|
|
5422
|
+
};
|
|
5423
|
+
|
|
5424
|
+
// ../vuu-ui-controls/src/drag-drop/useDragDropNaturalMovementNext.tsx
|
|
5425
|
+
var useDragDropNaturalMovement = ({
|
|
5426
|
+
draggableRef,
|
|
5427
|
+
onDrop,
|
|
5428
|
+
orientation = "horizontal",
|
|
5429
|
+
containerRef,
|
|
5430
|
+
itemQuery = "*",
|
|
5431
|
+
selected,
|
|
5432
|
+
viewportRange
|
|
5433
|
+
}) => {
|
|
5434
|
+
const dragDirectionRef = useRef13();
|
|
5435
|
+
const isScrollable = useRef13(false);
|
|
5436
|
+
const dragPosRef = useRef13(-1);
|
|
5437
|
+
const measuredDropTargets = useRef13([]);
|
|
5438
|
+
const overflowMenuShowingRef = useRef13(false);
|
|
5439
|
+
const [showOverflow, setShowOverflow] = useState7(false);
|
|
5440
|
+
const { clearDisplacedItem, clearSpacers, displaceItem, displaceLastItem } = useDragDisplacers();
|
|
5441
|
+
const draggedItemRef = useRef13();
|
|
5442
|
+
const fullItemQuery = `:is(${itemQuery}${NOT_OVERFLOWED}${NOT_HIDDEN},.vuuOverflowContainer-OverflowIndicator)`;
|
|
5443
|
+
const indexOf = (dropTarget) => measuredDropTargets.current.findIndex((d) => d.id === dropTarget.id);
|
|
5444
|
+
const rangeRef = useRef13();
|
|
5445
|
+
rangeRef.current = viewportRange;
|
|
5446
|
+
const handleScrollStart = useCallback19(() => {
|
|
5447
|
+
clearDisplacedItem();
|
|
5448
|
+
}, [clearDisplacedItem]);
|
|
5449
|
+
const handleScrollStop = useCallback19(
|
|
5450
|
+
(scrollDirection, _scrollPos, atEnd) => {
|
|
5451
|
+
const { current: container } = containerRef;
|
|
5452
|
+
const { current: draggedItem } = draggedItemRef;
|
|
5453
|
+
if (container && draggedItem) {
|
|
5454
|
+
measuredDropTargets.current = measureDropTargets(
|
|
5455
|
+
container,
|
|
5456
|
+
orientation,
|
|
5457
|
+
fullItemQuery,
|
|
5458
|
+
rangeRef.current
|
|
5459
|
+
);
|
|
5460
|
+
const { size } = draggedItem;
|
|
5461
|
+
const dragPos = dragPosRef.current;
|
|
5462
|
+
const midPos = dragPos + size / 2;
|
|
5463
|
+
const { current: dropTargets } = measuredDropTargets;
|
|
5464
|
+
const dropTarget = getNextDropTarget(dropTargets, midPos, "fwd");
|
|
5465
|
+
if (dropTarget) {
|
|
5466
|
+
const targetIndex = indexOf(dropTarget);
|
|
5467
|
+
const nextInsertPos = targetIndex;
|
|
5468
|
+
const nextDropTarget = dropTargets[nextInsertPos];
|
|
5469
|
+
if (atEnd && scrollDirection === "fwd") {
|
|
5470
|
+
displaceLastItem(
|
|
5471
|
+
dropTargets,
|
|
5472
|
+
dropTargets[dropTargets.length - 1],
|
|
5473
|
+
size,
|
|
5474
|
+
false,
|
|
5475
|
+
"static",
|
|
5476
|
+
orientation
|
|
5477
|
+
);
|
|
5478
|
+
} else {
|
|
5479
|
+
displaceItem(
|
|
5480
|
+
dropTargets,
|
|
5481
|
+
nextDropTarget,
|
|
5482
|
+
size,
|
|
5483
|
+
true,
|
|
5484
|
+
"static",
|
|
5485
|
+
orientation
|
|
5486
|
+
);
|
|
5487
|
+
}
|
|
5488
|
+
}
|
|
5489
|
+
}
|
|
5490
|
+
},
|
|
5491
|
+
[
|
|
5492
|
+
containerRef,
|
|
5493
|
+
displaceItem,
|
|
5494
|
+
displaceLastItem,
|
|
5495
|
+
fullItemQuery,
|
|
5496
|
+
orientation
|
|
5497
|
+
// setVizData,
|
|
5498
|
+
]
|
|
5499
|
+
);
|
|
5500
|
+
const beginDrag = useCallback19(
|
|
5501
|
+
(evt) => {
|
|
5502
|
+
const evtTarget = evt.target;
|
|
5503
|
+
const dragElement = evtTarget.closest(itemQuery);
|
|
5504
|
+
if (
|
|
5505
|
+
//TODO need a different check for selected
|
|
5506
|
+
dragElement.ariaSelected && Array.isArray(selected) && selected.length > 1
|
|
5507
|
+
) {
|
|
5508
|
+
console.log("its a selected element, and we have a multi select");
|
|
5509
|
+
}
|
|
5510
|
+
const { current: container } = containerRef;
|
|
5511
|
+
if (container && dragElement) {
|
|
5512
|
+
const { SCROLL_SIZE, CLIENT_SIZE } = dimensions(orientation);
|
|
5513
|
+
const { id: draggedItemId } = dragElement;
|
|
5514
|
+
const { [SCROLL_SIZE]: scrollSize, [CLIENT_SIZE]: clientSize } = container;
|
|
5515
|
+
isScrollable.current = scrollSize > clientSize;
|
|
5516
|
+
const dropTargets = measuredDropTargets.current = measureDropTargets(
|
|
5517
|
+
container,
|
|
5518
|
+
orientation,
|
|
5519
|
+
fullItemQuery,
|
|
5520
|
+
viewportRange,
|
|
5521
|
+
draggedItemId
|
|
5522
|
+
);
|
|
5523
|
+
console.log({ dropTargets });
|
|
5524
|
+
const indexOfDraggedItem = getIndexOfDraggedItem(dropTargets);
|
|
5525
|
+
const draggedItem = dropTargets[indexOfDraggedItem];
|
|
5526
|
+
if (draggedItem && container) {
|
|
5527
|
+
draggedItemRef.current = draggedItem;
|
|
5528
|
+
const displaceFunction = draggedItem.isLast ? displaceLastItem : displaceItem;
|
|
5529
|
+
displaceFunction(
|
|
5530
|
+
dropTargets,
|
|
5531
|
+
draggedItem,
|
|
5532
|
+
draggedItem.size,
|
|
5533
|
+
false,
|
|
5534
|
+
"static",
|
|
5535
|
+
orientation
|
|
5536
|
+
);
|
|
5537
|
+
}
|
|
5538
|
+
}
|
|
5539
|
+
},
|
|
5540
|
+
[
|
|
5541
|
+
containerRef,
|
|
5542
|
+
displaceItem,
|
|
5543
|
+
displaceLastItem,
|
|
5544
|
+
fullItemQuery,
|
|
5545
|
+
itemQuery,
|
|
5546
|
+
orientation,
|
|
5547
|
+
selected,
|
|
5548
|
+
// setVizData,
|
|
5549
|
+
viewportRange
|
|
5550
|
+
]
|
|
5551
|
+
);
|
|
5552
|
+
const [showPopup, hidePopup] = useMemo9(() => {
|
|
5553
|
+
let popupShowing = false;
|
|
5554
|
+
const show = (dropTarget) => {
|
|
5555
|
+
if (!popupShowing) {
|
|
5556
|
+
popupShowing = true;
|
|
5557
|
+
const button = dropTarget.element.querySelector(".vuuPopupMenu");
|
|
5558
|
+
if (button) {
|
|
5559
|
+
const evt = new MouseEvent("click", {
|
|
5560
|
+
view: window,
|
|
5561
|
+
bubbles: true,
|
|
5562
|
+
cancelable: true
|
|
5563
|
+
});
|
|
5564
|
+
button.dispatchEvent(evt);
|
|
5565
|
+
}
|
|
5566
|
+
}
|
|
5567
|
+
};
|
|
5568
|
+
const hide = (dropTarget) => {
|
|
5569
|
+
if (popupShowing) {
|
|
5570
|
+
popupShowing = false;
|
|
5571
|
+
const button = dropTarget.element.querySelector(".vuuPopupMenu");
|
|
5572
|
+
if (button) {
|
|
5573
|
+
const evt = new MouseEvent("click", {
|
|
5574
|
+
view: window,
|
|
5575
|
+
bubbles: true,
|
|
5576
|
+
cancelable: true
|
|
5577
|
+
});
|
|
5578
|
+
button.dispatchEvent(evt);
|
|
5579
|
+
}
|
|
5580
|
+
}
|
|
5581
|
+
};
|
|
5582
|
+
return [show, hide];
|
|
5583
|
+
}, []);
|
|
5584
|
+
const drag = useCallback19(
|
|
5585
|
+
(dragPos, mouseMoveDirection) => {
|
|
5586
|
+
const { current: draggedItem } = draggedItemRef;
|
|
5587
|
+
if (draggedItem) {
|
|
5588
|
+
if (draggableRef.current && containerRef.current) {
|
|
5589
|
+
dragPosRef.current = dragPos;
|
|
5590
|
+
const { current: dropTargets } = measuredDropTargets;
|
|
5591
|
+
const nextDropTarget = getNextDropTarget(
|
|
5592
|
+
dropTargets,
|
|
5593
|
+
dragPos,
|
|
5594
|
+
mouseMoveDirection
|
|
5595
|
+
);
|
|
5596
|
+
if (nextDropTarget && !nextDropTarget.isDraggedItem) {
|
|
5597
|
+
if (nextDropTarget.isOverflowIndicator) {
|
|
5598
|
+
setShowOverflow(overflowMenuShowingRef.current = true);
|
|
5599
|
+
showPopup(nextDropTarget);
|
|
5600
|
+
} else {
|
|
5601
|
+
const { size } = draggedItem;
|
|
5602
|
+
const targetIndex = indexOf(nextDropTarget);
|
|
5603
|
+
const displaceFunc = targetIndex === dropTargets.length - 1 ? displaceLastItem : displaceItem;
|
|
5604
|
+
displaceFunc(
|
|
5605
|
+
dropTargets,
|
|
5606
|
+
nextDropTarget,
|
|
5607
|
+
size,
|
|
5608
|
+
true,
|
|
5609
|
+
mouseMoveDirection,
|
|
5610
|
+
orientation
|
|
5611
|
+
);
|
|
5612
|
+
const overflowIndicator = dropTargets.at(
|
|
5613
|
+
-1
|
|
5614
|
+
);
|
|
5615
|
+
hidePopup(overflowIndicator);
|
|
5616
|
+
setShowOverflow(overflowMenuShowingRef.current = false);
|
|
5617
|
+
}
|
|
5618
|
+
}
|
|
5619
|
+
dragDirectionRef.current = mouseMoveDirection;
|
|
5620
|
+
}
|
|
5621
|
+
}
|
|
5622
|
+
},
|
|
5623
|
+
[
|
|
5624
|
+
containerRef,
|
|
5625
|
+
displaceItem,
|
|
5626
|
+
displaceLastItem,
|
|
5627
|
+
draggableRef,
|
|
5628
|
+
hidePopup,
|
|
5629
|
+
orientation,
|
|
5630
|
+
showPopup
|
|
5631
|
+
]
|
|
5632
|
+
);
|
|
5633
|
+
const drop = useCallback19(() => {
|
|
5634
|
+
var _a;
|
|
5635
|
+
clearSpacers();
|
|
5636
|
+
const { current: dropTargets } = measuredDropTargets;
|
|
5637
|
+
const indexOfDraggedItem = getIndexOfDraggedItem(dropTargets);
|
|
5638
|
+
const draggedItem = dropTargets[indexOfDraggedItem];
|
|
5639
|
+
if (draggedItem) {
|
|
5640
|
+
dragDirectionRef.current = void 0;
|
|
5641
|
+
if (overflowMenuShowingRef.current) {
|
|
5642
|
+
onDrop(draggedItem.index, -1);
|
|
5643
|
+
} else {
|
|
5644
|
+
onDrop(draggedItem.index, indexOfDraggedItem);
|
|
5645
|
+
}
|
|
5646
|
+
}
|
|
5647
|
+
setShowOverflow(false);
|
|
5648
|
+
if (containerRef.current) {
|
|
5649
|
+
const scrollTop = (_a = containerRef.current) == null ? void 0 : _a.scrollTop;
|
|
5650
|
+
if (indexOfDraggedItem < dropTargets.length) {
|
|
5651
|
+
containerRef.current.scrollTop = scrollTop;
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
}, [clearSpacers, containerRef, onDrop]);
|
|
5655
|
+
return {
|
|
5656
|
+
beginDrag,
|
|
5657
|
+
drag,
|
|
5658
|
+
drop,
|
|
5659
|
+
handleScrollStart,
|
|
5660
|
+
handleScrollStop,
|
|
5661
|
+
revealOverflowedItems: showOverflow
|
|
5662
|
+
};
|
|
5663
|
+
};
|
|
5664
|
+
|
|
5665
|
+
// ../vuu-ui-controls/src/drag-drop/useDragDropIndicator.tsx
|
|
5666
|
+
import { useCallback as useCallback21, useRef as useRef14, useState as useState8 } from "react";
|
|
5667
|
+
|
|
5668
|
+
// ../vuu-ui-controls/src/drag-drop/useDropIndicator.ts
|
|
5669
|
+
import { useCallback as useCallback20, useMemo as useMemo10 } from "react";
|
|
5670
|
+
var useDropIndicator = () => {
|
|
5671
|
+
const spacer = useMemo10(() => createDropIndicatorPosition(), []);
|
|
5672
|
+
const clearSpacer = useCallback20(() => spacer.remove(), [spacer]);
|
|
5673
|
+
const positionDropIndicator = useCallback20(
|
|
5674
|
+
(dropTarget, dropZone2 = "end") => {
|
|
5675
|
+
if (dropZone2 === "end") {
|
|
5676
|
+
dropTarget.element.after(spacer);
|
|
5677
|
+
} else {
|
|
5678
|
+
dropTarget.element.before(spacer);
|
|
5679
|
+
}
|
|
5680
|
+
return spacer;
|
|
5681
|
+
},
|
|
5682
|
+
[spacer]
|
|
5683
|
+
);
|
|
5684
|
+
return {
|
|
5685
|
+
positionDropIndicator,
|
|
5686
|
+
clearSpacer
|
|
5687
|
+
};
|
|
5688
|
+
};
|
|
5689
|
+
|
|
5690
|
+
// ../vuu-ui-controls/src/drag-drop/useDragDropIndicator.tsx
|
|
5691
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
5692
|
+
var NOT_OVERFLOWED2 = ':not([data-overflowed="true"])';
|
|
5693
|
+
var NOT_HIDDEN2 = ':not([aria-hidden="true"])';
|
|
5694
|
+
var useDragDropIndicator = ({
|
|
5695
|
+
draggableRef,
|
|
5696
|
+
onDrop,
|
|
5697
|
+
orientation = "horizontal",
|
|
5698
|
+
containerRef,
|
|
5699
|
+
itemQuery = "*",
|
|
5700
|
+
selected,
|
|
5701
|
+
viewportRange
|
|
5702
|
+
}) => {
|
|
5703
|
+
const dragDirectionRef = useRef14();
|
|
5704
|
+
const dropIndicatorRef = useRef14(null);
|
|
5705
|
+
const dropTargetRef = useRef14(null);
|
|
5706
|
+
const dropZoneRef = useRef14("");
|
|
5707
|
+
const isScrollable = useRef14(false);
|
|
5708
|
+
const dragPosRef = useRef14(-1);
|
|
5709
|
+
const measuredDropTargets = useRef14([]);
|
|
5710
|
+
const overflowMenuShowingRef = useRef14(false);
|
|
5711
|
+
const [showOverflow, setShowOverflow] = useState8(false);
|
|
5712
|
+
const [dropIndicator, setDropIndicator] = useState8();
|
|
5713
|
+
const { clearSpacer, positionDropIndicator } = useDropIndicator();
|
|
5714
|
+
const draggedItemRef = useRef14();
|
|
5715
|
+
const fullItemQuery = `:is(${itemQuery}${NOT_OVERFLOWED2}${NOT_HIDDEN2},[data-overflow-indicator])`;
|
|
5716
|
+
const indexOf = (dropTarget) => measuredDropTargets.current.findIndex((d) => d.id === dropTarget.id);
|
|
5717
|
+
const reposition = (dropTarget, distance, indexShift) => {
|
|
5718
|
+
dropTarget.start += distance;
|
|
5719
|
+
dropTarget.mid += distance;
|
|
5720
|
+
dropTarget.end += distance;
|
|
5721
|
+
if (typeof indexShift === "number") {
|
|
5722
|
+
dropTarget.currentIndex += indexShift;
|
|
5723
|
+
}
|
|
5724
|
+
};
|
|
5725
|
+
const rangeRef = useRef14();
|
|
5726
|
+
rangeRef.current = viewportRange;
|
|
5727
|
+
const handleScrollStart = useCallback21(() => {
|
|
5728
|
+
clearSpacer();
|
|
5729
|
+
}, [clearSpacer]);
|
|
5730
|
+
const handleScrollStop = useCallback21(
|
|
5731
|
+
(scrollDirection, _scrollPos, atEnd) => {
|
|
5732
|
+
const { current: container } = containerRef;
|
|
5733
|
+
const { current: draggedItem } = draggedItemRef;
|
|
5734
|
+
if (container && draggedItem) {
|
|
5735
|
+
measuredDropTargets.current = measureDropTargets(
|
|
5736
|
+
container,
|
|
5737
|
+
orientation,
|
|
5738
|
+
fullItemQuery,
|
|
5739
|
+
rangeRef.current
|
|
5740
|
+
);
|
|
5741
|
+
const { size } = draggedItem;
|
|
5742
|
+
const dragPos = dragPosRef.current;
|
|
5743
|
+
const midPos = dragPos + size / 2;
|
|
5744
|
+
const { current: dropTargets } = measuredDropTargets;
|
|
5745
|
+
const nextDropTarget = getNextDropTarget(dropTargets, midPos, "fwd");
|
|
5746
|
+
if (nextDropTarget) {
|
|
5747
|
+
if (atEnd && scrollDirection === "fwd") {
|
|
5748
|
+
positionDropIndicator(dropTargets[dropTargets.length - 1], "start");
|
|
5749
|
+
} else {
|
|
5750
|
+
positionDropIndicator(nextDropTarget, "start");
|
|
5751
|
+
}
|
|
5752
|
+
}
|
|
5753
|
+
}
|
|
5754
|
+
},
|
|
5755
|
+
[
|
|
5756
|
+
containerRef,
|
|
5757
|
+
positionDropIndicator,
|
|
5758
|
+
fullItemQuery,
|
|
5759
|
+
orientation
|
|
5760
|
+
// setVizData,
|
|
5761
|
+
]
|
|
5762
|
+
);
|
|
5763
|
+
const beginDrag = useCallback21(
|
|
5764
|
+
(evt) => {
|
|
5765
|
+
const evtTarget = evt.target;
|
|
5766
|
+
const dragElement = evtTarget.closest(itemQuery);
|
|
5767
|
+
if (dragElement.ariaSelected && Array.isArray(selected) && selected.length > 1) {
|
|
5768
|
+
console.log("its a selected element, and we have a multi select");
|
|
5769
|
+
}
|
|
5770
|
+
const { current: container } = containerRef;
|
|
5771
|
+
if (container && dragElement) {
|
|
5772
|
+
const { SCROLL_SIZE, CLIENT_SIZE } = dimensions(orientation);
|
|
5773
|
+
const { id: draggedItemId } = dragElement;
|
|
5774
|
+
const { [SCROLL_SIZE]: scrollSize, [CLIENT_SIZE]: clientSize } = container;
|
|
5775
|
+
isScrollable.current = scrollSize > clientSize;
|
|
5776
|
+
const dropTargets = measuredDropTargets.current = measureDropTargets(
|
|
5777
|
+
container,
|
|
5778
|
+
orientation,
|
|
5779
|
+
fullItemQuery,
|
|
5780
|
+
viewportRange
|
|
5781
|
+
);
|
|
5782
|
+
const draggedItem = getItemById(dropTargets, draggedItemId);
|
|
5783
|
+
if (draggedItem && container) {
|
|
5784
|
+
const targetIndex = indexOf(draggedItem);
|
|
5785
|
+
removeDraggedItem(dropTargets, targetIndex);
|
|
5786
|
+
draggedItemRef.current = draggedItem;
|
|
5787
|
+
const { current: range } = rangeRef;
|
|
5788
|
+
if (range == null ? void 0 : range.atEnd) {
|
|
5789
|
+
for (let i = 0; i < dropTargets.length; i++) {
|
|
5790
|
+
reposition(dropTargets[i], draggedItem.size);
|
|
5791
|
+
}
|
|
5792
|
+
}
|
|
5793
|
+
for (let i = targetIndex; i < dropTargets.length; i++) {
|
|
5794
|
+
reposition(dropTargets[i], -draggedItem.size, -1);
|
|
5795
|
+
}
|
|
5796
|
+
const [dropTarget, dropZone2] = draggedItem.isLast ? [dropTargets[dropTargets.length - 1], "end"] : [dropTargets[targetIndex], "start"];
|
|
5797
|
+
dropTargetRef.current = dropTarget;
|
|
5798
|
+
dropZoneRef.current = dropZone2;
|
|
5799
|
+
const dropIndicatorPosition = positionDropIndicator(
|
|
5800
|
+
dropTarget,
|
|
5801
|
+
dropZone2
|
|
5802
|
+
);
|
|
5803
|
+
const { top, left, width } = dropIndicatorPosition.getBoundingClientRect();
|
|
5804
|
+
const dropIndicatorRect = {
|
|
5805
|
+
top: draggedItem.isLast ? (range == null ? void 0 : range.atEnd) && !range.atStart ? top + draggedItem.size - 2 : top - 2 : top - draggedItem.size - 2,
|
|
5806
|
+
left,
|
|
5807
|
+
width,
|
|
5808
|
+
height: 2
|
|
5809
|
+
};
|
|
5810
|
+
setDropIndicator(
|
|
5811
|
+
/* @__PURE__ */ jsx18(
|
|
5812
|
+
Draggable2,
|
|
5813
|
+
{
|
|
5814
|
+
wrapperClassName: "dropIndicatorContainer",
|
|
5815
|
+
style: dropIndicatorRect,
|
|
5816
|
+
ref: dropIndicatorRef,
|
|
5817
|
+
element: createDropIndicator()
|
|
5818
|
+
}
|
|
5819
|
+
)
|
|
5820
|
+
);
|
|
5821
|
+
}
|
|
5822
|
+
}
|
|
5823
|
+
},
|
|
5824
|
+
[
|
|
5825
|
+
itemQuery,
|
|
5826
|
+
selected,
|
|
5827
|
+
containerRef,
|
|
5828
|
+
orientation,
|
|
5829
|
+
fullItemQuery,
|
|
5830
|
+
viewportRange,
|
|
5831
|
+
// setVizData,
|
|
5832
|
+
positionDropIndicator
|
|
5833
|
+
]
|
|
5834
|
+
);
|
|
5835
|
+
const drag = useCallback21(
|
|
5836
|
+
(dragPos, mouseMoveDirection) => {
|
|
5837
|
+
const { current: currentDropTarget } = dropTargetRef;
|
|
5838
|
+
const { current: draggedItem } = draggedItemRef;
|
|
5839
|
+
if (draggedItem) {
|
|
5840
|
+
if (draggableRef.current && containerRef.current) {
|
|
5841
|
+
const START = orientation === "horizontal" ? "left" : "top";
|
|
5842
|
+
dragPosRef.current = dragPos;
|
|
5843
|
+
const { current: dropTargets } = measuredDropTargets;
|
|
5844
|
+
const nextDropTarget = getNextDropTarget(
|
|
5845
|
+
dropTargets,
|
|
5846
|
+
dragPos,
|
|
5847
|
+
mouseMoveDirection
|
|
5848
|
+
);
|
|
5849
|
+
if (nextDropTarget && nextDropTarget.index !== (currentDropTarget == null ? void 0 : currentDropTarget.index)) {
|
|
5850
|
+
if (nextDropTarget.isOverflowIndicator) {
|
|
5851
|
+
setShowOverflow(overflowMenuShowingRef.current = true);
|
|
5852
|
+
} else if (dropIndicatorRef.current) {
|
|
5853
|
+
const targetIndex = indexOf(nextDropTarget);
|
|
5854
|
+
if (targetIndex === dropTargets.length - 1) {
|
|
5855
|
+
const dropTarget = dropTargets[dropTargets.length - 1];
|
|
5856
|
+
const dropIndicatorPosition = positionDropIndicator(
|
|
5857
|
+
dropTarget,
|
|
5858
|
+
"start"
|
|
5859
|
+
);
|
|
5860
|
+
const dropIndicatorRect = dropIndicatorPosition.getBoundingClientRect();
|
|
5861
|
+
dropIndicatorRef.current.style[START] = `${dropIndicatorRect.top}px`;
|
|
5862
|
+
} else {
|
|
5863
|
+
const dropIndicatorPosition = positionDropIndicator(
|
|
5864
|
+
nextDropTarget,
|
|
5865
|
+
"start"
|
|
5866
|
+
);
|
|
5867
|
+
const dropIndicatorRect = dropIndicatorPosition.getBoundingClientRect();
|
|
5868
|
+
dropIndicatorRef.current.style[START] = `${dropIndicatorRect.top}px`;
|
|
5869
|
+
}
|
|
5870
|
+
setShowOverflow(overflowMenuShowingRef.current = false);
|
|
5871
|
+
}
|
|
5872
|
+
dropTargetRef.current = nextDropTarget;
|
|
5873
|
+
dragDirectionRef.current = mouseMoveDirection;
|
|
5874
|
+
}
|
|
5875
|
+
}
|
|
5876
|
+
}
|
|
5877
|
+
},
|
|
5878
|
+
[draggableRef, containerRef, orientation, positionDropIndicator]
|
|
5879
|
+
);
|
|
5880
|
+
const drop = useCallback21(() => {
|
|
5881
|
+
clearSpacer();
|
|
5882
|
+
const { current: draggedItem } = draggedItemRef;
|
|
5883
|
+
const { current: dropTarget } = dropTargetRef;
|
|
5884
|
+
const { current: dropZone2 } = dropZoneRef;
|
|
5885
|
+
const { current: range } = rangeRef;
|
|
5886
|
+
if (draggedItem && range && dropTarget) {
|
|
5887
|
+
const { index: fromIndex } = draggedItem;
|
|
5888
|
+
const dropBefore = dropZone2 === "start";
|
|
5889
|
+
const {
|
|
5890
|
+
index: originalDropTargetIndex,
|
|
5891
|
+
currentIndex: currentDropTargetIndex
|
|
5892
|
+
} = dropTarget;
|
|
5893
|
+
dropTargetRef.current = null;
|
|
5894
|
+
dragDirectionRef.current = void 0;
|
|
5895
|
+
if (overflowMenuShowingRef.current) {
|
|
5896
|
+
onDrop(fromIndex, -1);
|
|
5897
|
+
} else {
|
|
5898
|
+
if (fromIndex < originalDropTargetIndex) {
|
|
5899
|
+
onDrop(
|
|
5900
|
+
fromIndex,
|
|
5901
|
+
dropBefore ? currentDropTargetIndex : currentDropTargetIndex + 1
|
|
5902
|
+
);
|
|
5903
|
+
} else {
|
|
5904
|
+
onDrop(
|
|
5905
|
+
fromIndex,
|
|
5906
|
+
dropBefore ? originalDropTargetIndex : originalDropTargetIndex + 1
|
|
5907
|
+
);
|
|
5908
|
+
}
|
|
5909
|
+
}
|
|
5910
|
+
setDropIndicator(void 0);
|
|
5911
|
+
}
|
|
5912
|
+
setShowOverflow(false);
|
|
5913
|
+
}, [clearSpacer, onDrop]);
|
|
5914
|
+
return {
|
|
5915
|
+
beginDrag,
|
|
5916
|
+
drag,
|
|
5917
|
+
drop,
|
|
5918
|
+
dropIndicator,
|
|
5919
|
+
handleScrollStart,
|
|
5920
|
+
handleScrollStop,
|
|
5921
|
+
revealOverflowedItems: showOverflow
|
|
5922
|
+
};
|
|
5923
|
+
};
|
|
5924
|
+
|
|
5925
|
+
// ../vuu-ui-controls/src/drag-drop/useDragDropNext.tsx
|
|
5926
|
+
import {
|
|
5927
|
+
useCallback as useCallback23,
|
|
5928
|
+
useLayoutEffect as useLayoutEffect4,
|
|
5929
|
+
useRef as useRef16,
|
|
5930
|
+
useState as useState9
|
|
5931
|
+
} from "react";
|
|
5932
|
+
|
|
5933
|
+
// ../vuu-ui-controls/src/drag-drop/useAutoScroll.ts
|
|
5934
|
+
import { useCallback as useCallback22, useRef as useRef15 } from "react";
|
|
5935
|
+
var useAutoScroll = ({
|
|
5936
|
+
containerRef,
|
|
5937
|
+
onScrollingStopped,
|
|
5938
|
+
orientation = "vertical"
|
|
5939
|
+
}) => {
|
|
5940
|
+
const scrollTimer = useRef15(null);
|
|
5941
|
+
const isScrolling = useRef15(false);
|
|
5942
|
+
const scrollPosRef = useRef15(0);
|
|
5943
|
+
const lastScrollDirectionRef = useRef15("fwd");
|
|
5944
|
+
const stopScrolling = useCallback22(
|
|
5945
|
+
(atEnd = false) => {
|
|
5946
|
+
console.log("[useAutoScroll] stopScrolling");
|
|
5947
|
+
if (scrollTimer.current !== null) {
|
|
5948
|
+
clearTimeout(scrollTimer.current);
|
|
5949
|
+
scrollTimer.current = null;
|
|
5950
|
+
}
|
|
5951
|
+
isScrolling.current = false;
|
|
5952
|
+
onScrollingStopped == null ? void 0 : onScrollingStopped(
|
|
5953
|
+
lastScrollDirectionRef.current,
|
|
5954
|
+
scrollPosRef.current,
|
|
5955
|
+
atEnd
|
|
5956
|
+
);
|
|
5957
|
+
},
|
|
5958
|
+
[onScrollingStopped]
|
|
5959
|
+
);
|
|
5960
|
+
const startScrolling = useCallback22(
|
|
5961
|
+
(direction, scrollRate, scrollUnit = 30) => {
|
|
5962
|
+
const { current: container } = containerRef;
|
|
5963
|
+
if (container) {
|
|
5964
|
+
const { SCROLL_POS, SCROLL_SIZE, CLIENT_SIZE } = dimensions(orientation);
|
|
5965
|
+
const {
|
|
5966
|
+
[SCROLL_POS]: scrollPos,
|
|
5967
|
+
[SCROLL_SIZE]: scrollSize,
|
|
5968
|
+
[CLIENT_SIZE]: clientSize
|
|
5969
|
+
} = container;
|
|
5970
|
+
const maxScroll = direction === "fwd" ? scrollSize - clientSize - scrollPos : scrollPos;
|
|
5971
|
+
const nextScroll = Math.min(maxScroll, scrollUnit);
|
|
5972
|
+
if (direction === "fwd") {
|
|
5973
|
+
lastScrollDirectionRef.current = "fwd";
|
|
5974
|
+
container[SCROLL_POS] = scrollPosRef.current = scrollPos + nextScroll;
|
|
5975
|
+
} else {
|
|
5976
|
+
lastScrollDirectionRef.current = "bwd";
|
|
5977
|
+
container[SCROLL_POS] = scrollPosRef.current = scrollPos - nextScroll;
|
|
5978
|
+
}
|
|
5979
|
+
if (nextScroll === maxScroll) {
|
|
5980
|
+
stopScrolling(true);
|
|
5981
|
+
} else {
|
|
5982
|
+
isScrolling.current = true;
|
|
5983
|
+
scrollTimer.current = window.setTimeout(() => {
|
|
5984
|
+
startScrolling(direction, scrollRate, scrollUnit);
|
|
5985
|
+
}, 100);
|
|
5986
|
+
}
|
|
5987
|
+
}
|
|
5988
|
+
},
|
|
5989
|
+
[containerRef, orientation, stopScrolling]
|
|
5990
|
+
);
|
|
5991
|
+
return {
|
|
5992
|
+
isScrolling,
|
|
5993
|
+
startScrolling,
|
|
5994
|
+
stopScrolling
|
|
5995
|
+
};
|
|
5996
|
+
};
|
|
5997
|
+
|
|
5998
|
+
// ../vuu-ui-controls/src/drag-drop/useDragDropNext.tsx
|
|
5999
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
6000
|
+
var NULL_DRAG_DROP_RESULT = {
|
|
6001
|
+
beginDrag: () => void 0,
|
|
6002
|
+
drag: () => void 0,
|
|
6003
|
+
draggableRef: { current: null },
|
|
6004
|
+
drop: () => void 0,
|
|
6005
|
+
isDragging: false,
|
|
6006
|
+
isScrolling: false,
|
|
6007
|
+
handleScrollStart: () => void 0,
|
|
6008
|
+
handleScrollStop: () => void 0,
|
|
6009
|
+
revealOverflowedItems: false
|
|
6010
|
+
};
|
|
6011
|
+
var UNBOUNDED = {
|
|
6012
|
+
start: 0,
|
|
6013
|
+
end: 1e3,
|
|
6014
|
+
contraStart: 0,
|
|
6015
|
+
contraEnd: 1e3
|
|
6016
|
+
};
|
|
6017
|
+
var noDragDrop = () => NULL_DRAG_DROP_RESULT;
|
|
6018
|
+
var dragThreshold = 3;
|
|
6019
|
+
var getDraggableElement = (el, query) => el.closest(query);
|
|
6020
|
+
var isOverflowElement = (element) => element.dataset.index === "overflow" && element.parentElement !== null && element.parentElement.classList.contains("overflowed");
|
|
6021
|
+
var getLastElement = (container, itemQuery) => {
|
|
6022
|
+
const fullItemQuery = `:is(${itemQuery}${NOT_OVERFLOWED},.vuuOverflowContainer-OverflowIndicator)`;
|
|
6023
|
+
const childElements = Array.from(container.querySelectorAll(fullItemQuery));
|
|
6024
|
+
const lastElement = childElements.pop();
|
|
6025
|
+
return [lastElement, isOverflowElement(lastElement)];
|
|
6026
|
+
};
|
|
6027
|
+
var useDragDropNext = ({
|
|
6028
|
+
allowDragDrop,
|
|
6029
|
+
containerRef,
|
|
6030
|
+
draggableClassName,
|
|
6031
|
+
itemQuery = "*",
|
|
6032
|
+
onDragStart,
|
|
6033
|
+
onDrop,
|
|
6034
|
+
onDropSettle,
|
|
6035
|
+
orientation,
|
|
6036
|
+
...dragDropProps
|
|
6037
|
+
}) => {
|
|
6038
|
+
const dragBoundaries = useRef16({
|
|
6039
|
+
start: 0,
|
|
6040
|
+
end: 0,
|
|
6041
|
+
contraStart: 0,
|
|
6042
|
+
contraEnd: 0
|
|
6043
|
+
});
|
|
6044
|
+
const [draggableStatus, setDraggableStatus] = useState9({
|
|
6045
|
+
draggable: void 0,
|
|
6046
|
+
draggedItemIndex: -1,
|
|
6047
|
+
isDragging: false
|
|
6048
|
+
});
|
|
6049
|
+
const draggableRef = useRef16(null);
|
|
6050
|
+
const dragElementRef = useRef16();
|
|
6051
|
+
const mouseDownTimer = useRef16(null);
|
|
6052
|
+
const isScrollableRef = useRef16(false);
|
|
6053
|
+
const mouseOffsetRef = useRef16({ x: 0, y: 0 });
|
|
6054
|
+
const mousePosRef = useRef16({ x: 0, y: 0 });
|
|
6055
|
+
const startPosRef = useRef16({ x: 0, y: 0 });
|
|
6056
|
+
const settlingItemRef = useRef16(null);
|
|
6057
|
+
const dropPosRef = useRef16(-1);
|
|
6058
|
+
const dropIndexRef = useRef16(-1);
|
|
6059
|
+
const handleScrollStopRef = useRef16();
|
|
6060
|
+
const { isDragSource, isDropTarget, register } = useDragDropProvider(
|
|
6061
|
+
dragDropProps.id
|
|
6062
|
+
);
|
|
6063
|
+
if (dragDropProps.id && (isDragSource || isDropTarget)) {
|
|
6064
|
+
register(dragDropProps.id);
|
|
6065
|
+
}
|
|
6066
|
+
const terminateDrag = useCallback23(() => {
|
|
6067
|
+
var _a;
|
|
6068
|
+
const { current: toIndex } = dropIndexRef;
|
|
6069
|
+
const droppedItem = (_a = containerRef.current) == null ? void 0 : _a.querySelector(
|
|
6070
|
+
`${itemQuery}[data-index="${toIndex}"]`
|
|
6071
|
+
);
|
|
6072
|
+
if (droppedItem) {
|
|
6073
|
+
droppedItem.classList.remove("vuuDropTarget-settling");
|
|
6074
|
+
}
|
|
6075
|
+
dropIndexRef.current = -1;
|
|
6076
|
+
onDropSettle == null ? void 0 : onDropSettle(toIndex);
|
|
6077
|
+
setDraggableStatus((status) => ({
|
|
6078
|
+
...status,
|
|
6079
|
+
draggable: void 0
|
|
6080
|
+
}));
|
|
6081
|
+
}, [containerRef, itemQuery, onDropSettle]);
|
|
6082
|
+
const getScrollDirection = useCallback23(
|
|
6083
|
+
(mousePos) => {
|
|
6084
|
+
if (containerRef.current) {
|
|
6085
|
+
const { POS, SCROLL_POS, SCROLL_SIZE, CLIENT_SIZE } = dimensions(orientation);
|
|
6086
|
+
const {
|
|
6087
|
+
[SCROLL_POS]: scrollPos,
|
|
6088
|
+
[SCROLL_SIZE]: scrollSize,
|
|
6089
|
+
[CLIENT_SIZE]: clientSize
|
|
6090
|
+
} = containerRef.current;
|
|
6091
|
+
const maxScroll = scrollSize - clientSize;
|
|
6092
|
+
const canScrollFwd = scrollPos < maxScroll;
|
|
6093
|
+
const viewportEnd = dragBoundaries.current.end;
|
|
6094
|
+
const bwd = scrollPos > 0 && mousePos - mouseOffsetRef.current[POS] <= dragBoundaries.current.start;
|
|
6095
|
+
const fwd = canScrollFwd && mousePos - mouseOffsetRef.current[POS] >= viewportEnd;
|
|
6096
|
+
return bwd ? "bwd" : fwd ? "fwd" : "";
|
|
6097
|
+
}
|
|
6098
|
+
},
|
|
6099
|
+
[containerRef, orientation]
|
|
6100
|
+
);
|
|
6101
|
+
const useDragDropHook = allowDragDrop === true || allowDragDrop === "natural-movement" ? useDragDropNaturalMovement : allowDragDrop === "drop-indicator" ? useDragDropIndicator : noDragDrop;
|
|
6102
|
+
const onScrollingStopped = useCallback23(
|
|
6103
|
+
(scrollDirection, scrollPos, atEnd) => {
|
|
6104
|
+
var _a;
|
|
6105
|
+
(_a = handleScrollStopRef.current) == null ? void 0 : _a.call(handleScrollStopRef, scrollDirection, scrollPos, atEnd);
|
|
6106
|
+
},
|
|
6107
|
+
[]
|
|
6108
|
+
);
|
|
6109
|
+
const { isScrolling, startScrolling, stopScrolling } = useAutoScroll({
|
|
6110
|
+
containerRef,
|
|
6111
|
+
onScrollingStopped,
|
|
6112
|
+
orientation
|
|
6113
|
+
});
|
|
6114
|
+
const handleDrop = useCallback23(
|
|
6115
|
+
(fromIndex, toIndex) => {
|
|
6116
|
+
dropPosRef.current = toIndex;
|
|
6117
|
+
onDrop == null ? void 0 : onDrop(fromIndex, toIndex);
|
|
6118
|
+
dropIndexRef.current = toIndex;
|
|
6119
|
+
},
|
|
6120
|
+
[onDrop]
|
|
6121
|
+
);
|
|
6122
|
+
const {
|
|
6123
|
+
beginDrag,
|
|
6124
|
+
drag,
|
|
6125
|
+
drop,
|
|
6126
|
+
handleScrollStart,
|
|
6127
|
+
handleScrollStop,
|
|
6128
|
+
...dragResult
|
|
6129
|
+
} = useDragDropHook({
|
|
6130
|
+
...dragDropProps,
|
|
6131
|
+
containerRef,
|
|
6132
|
+
draggableRef,
|
|
6133
|
+
isDragSource,
|
|
6134
|
+
isDropTarget,
|
|
6135
|
+
itemQuery,
|
|
6136
|
+
onDrop: handleDrop,
|
|
6137
|
+
orientation
|
|
6138
|
+
});
|
|
6139
|
+
handleScrollStopRef.current = handleScrollStop;
|
|
6140
|
+
const dragMouseMoveHandler = useCallback23(
|
|
6141
|
+
(evt) => {
|
|
6142
|
+
const { CLIENT_POS, CONTRA_CLIENT_POS, CONTRA_POS, POS } = dimensions(orientation);
|
|
6143
|
+
const { clientX, clientY } = evt;
|
|
6144
|
+
const { [CLIENT_POS]: clientPos, [CONTRA_CLIENT_POS]: clientContraPos } = evt;
|
|
6145
|
+
const lastClientPos = mousePosRef.current[POS];
|
|
6146
|
+
const lastClientContraPos = mousePosRef.current[CONTRA_POS];
|
|
6147
|
+
const dragDistance = Math.abs(lastClientPos - clientPos);
|
|
6148
|
+
const dragOutDistance = isDragSource ? Math.abs(lastClientContraPos - clientContraPos) : 0;
|
|
6149
|
+
if (dragOutDistance - dragDistance > 5) {
|
|
6150
|
+
dragBoundaries.current = UNBOUNDED;
|
|
6151
|
+
}
|
|
6152
|
+
mousePosRef.current.x = clientX;
|
|
6153
|
+
mousePosRef.current.y = clientY;
|
|
6154
|
+
if (dragBoundaries.current === UNBOUNDED && draggableRef.current) {
|
|
6155
|
+
const dragPosX = mousePosRef.current.x - mouseOffsetRef.current.x;
|
|
6156
|
+
const dragPosY = mousePosRef.current.y - mouseOffsetRef.current.y;
|
|
6157
|
+
draggableRef.current.style.top = `${dragPosY}px`;
|
|
6158
|
+
draggableRef.current.style.left = `${dragPosX}px`;
|
|
6159
|
+
} else if (dragDistance > 0 && draggableRef.current) {
|
|
6160
|
+
const mouseMoveDirection = lastClientPos < clientPos ? "fwd" : "bwd";
|
|
6161
|
+
const scrollDirection = getScrollDirection(clientPos);
|
|
6162
|
+
const dragPos = mousePosRef.current[POS] - mouseOffsetRef.current[POS];
|
|
6163
|
+
if (scrollDirection && isScrollableRef.current && !isScrolling.current) {
|
|
6164
|
+
handleScrollStart();
|
|
6165
|
+
startScrolling(scrollDirection, 1);
|
|
6166
|
+
} else if (!scrollDirection && isScrolling.current) {
|
|
6167
|
+
stopScrolling();
|
|
6168
|
+
}
|
|
6169
|
+
if (!isScrolling.current) {
|
|
6170
|
+
const renderDragPos = Math.round(
|
|
6171
|
+
Math.max(
|
|
6172
|
+
dragBoundaries.current.start,
|
|
6173
|
+
Math.min(dragBoundaries.current.end, dragPos)
|
|
6174
|
+
)
|
|
6175
|
+
);
|
|
6176
|
+
const START = orientation === "horizontal" ? "left" : "top";
|
|
6177
|
+
draggableRef.current.style[START] = `${renderDragPos}px`;
|
|
6178
|
+
drag(renderDragPos, mouseMoveDirection);
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
},
|
|
6182
|
+
[
|
|
6183
|
+
drag,
|
|
6184
|
+
draggableRef,
|
|
6185
|
+
getScrollDirection,
|
|
6186
|
+
handleScrollStart,
|
|
6187
|
+
isDragSource,
|
|
6188
|
+
isScrolling,
|
|
6189
|
+
orientation,
|
|
6190
|
+
startScrolling,
|
|
6191
|
+
stopScrolling
|
|
6192
|
+
]
|
|
6193
|
+
);
|
|
6194
|
+
const dragMouseUpHandler = useCallback23(() => {
|
|
6195
|
+
document.removeEventListener("mousemove", dragMouseMoveHandler, false);
|
|
6196
|
+
document.removeEventListener("mouseup", dragMouseUpHandler, false);
|
|
6197
|
+
settlingItemRef.current = draggableRef.current;
|
|
6198
|
+
drop();
|
|
6199
|
+
setDraggableStatus((status) => ({
|
|
6200
|
+
...status,
|
|
6201
|
+
draggedItemIndex: -1,
|
|
6202
|
+
isDragging: false
|
|
6203
|
+
}));
|
|
6204
|
+
dragElementRef.current = void 0;
|
|
6205
|
+
}, [dragMouseMoveHandler, draggableRef, drop]);
|
|
6206
|
+
const dragStart = useCallback23(
|
|
6207
|
+
(evt) => {
|
|
6208
|
+
const { clientX, clientY, target } = evt;
|
|
6209
|
+
const dragElement = getDraggableElement(target, itemQuery);
|
|
6210
|
+
const { current: container } = containerRef;
|
|
6211
|
+
if (container && dragElement) {
|
|
6212
|
+
const {
|
|
6213
|
+
CONTRA,
|
|
6214
|
+
CONTRA_END,
|
|
6215
|
+
DIMENSION,
|
|
6216
|
+
END,
|
|
6217
|
+
SCROLL_SIZE,
|
|
6218
|
+
CLIENT_SIZE,
|
|
6219
|
+
START
|
|
6220
|
+
} = dimensions(orientation);
|
|
6221
|
+
dragElementRef.current = dragElement;
|
|
6222
|
+
const { [SCROLL_SIZE]: scrollSize, [CLIENT_SIZE]: clientSize } = container;
|
|
6223
|
+
isScrollableRef.current = scrollSize > clientSize;
|
|
6224
|
+
const [lastElement, lastItemIsOverflowIndicator] = getLastElement(
|
|
6225
|
+
container,
|
|
6226
|
+
itemQuery
|
|
6227
|
+
);
|
|
6228
|
+
const containerRect = container.getBoundingClientRect();
|
|
6229
|
+
const draggableRect = dragElement.getBoundingClientRect();
|
|
6230
|
+
const draggableSize = draggableRect[DIMENSION];
|
|
6231
|
+
const { [START]: lastItemStart, [END]: lastItemEnd } = lastElement.getBoundingClientRect();
|
|
6232
|
+
mouseOffsetRef.current.x = clientX - draggableRect.left;
|
|
6233
|
+
mouseOffsetRef.current.y = clientY - draggableRect.top;
|
|
6234
|
+
dragBoundaries.current.start = containerRect[START];
|
|
6235
|
+
dragBoundaries.current.end = lastItemIsOverflowIndicator ? Math.max(lastItemStart, containerRect.right - draggableSize) : isScrollableRef.current ? containerRect[START] + containerRect[DIMENSION] - draggableSize : lastItemEnd - draggableSize;
|
|
6236
|
+
dragBoundaries.current.contraStart = containerRect[CONTRA];
|
|
6237
|
+
dragBoundaries.current.contraEnd = containerRect[CONTRA_END];
|
|
6238
|
+
beginDrag(evt);
|
|
6239
|
+
const {
|
|
6240
|
+
dataset: { index = "-1" }
|
|
6241
|
+
} = dragElement;
|
|
6242
|
+
setDraggableStatus({
|
|
6243
|
+
isDragging: true,
|
|
6244
|
+
draggable: /* @__PURE__ */ jsx19(
|
|
6245
|
+
Draggable2,
|
|
6246
|
+
{
|
|
6247
|
+
element: cloneElement4(dragElement),
|
|
6248
|
+
onTransitionEnd: terminateDrag,
|
|
6249
|
+
ref: draggableRef,
|
|
6250
|
+
style: constrainRect(draggableRect, containerRect),
|
|
6251
|
+
wrapperClassName: draggableClassName
|
|
6252
|
+
}
|
|
6253
|
+
),
|
|
6254
|
+
draggedItemIndex: parseInt(index)
|
|
6255
|
+
});
|
|
6256
|
+
onDragStart == null ? void 0 : onDragStart();
|
|
6257
|
+
document.addEventListener("mousemove", dragMouseMoveHandler, false);
|
|
6258
|
+
document.addEventListener("mouseup", dragMouseUpHandler, false);
|
|
6259
|
+
}
|
|
6260
|
+
},
|
|
6261
|
+
[
|
|
6262
|
+
beginDrag,
|
|
6263
|
+
containerRef,
|
|
6264
|
+
dragMouseMoveHandler,
|
|
6265
|
+
dragMouseUpHandler,
|
|
6266
|
+
draggableClassName,
|
|
6267
|
+
draggableRef,
|
|
6268
|
+
itemQuery,
|
|
6269
|
+
onDragStart,
|
|
6270
|
+
orientation,
|
|
6271
|
+
terminateDrag
|
|
6272
|
+
]
|
|
6273
|
+
);
|
|
6274
|
+
const preDragMouseMoveHandler = useCallback23(
|
|
6275
|
+
(evt) => {
|
|
6276
|
+
const { CLIENT_POS, POS } = dimensions(orientation);
|
|
6277
|
+
const { [CLIENT_POS]: clientPos } = evt;
|
|
6278
|
+
const mouseMoveDistance = Math.abs(clientPos - startPosRef.current[POS]);
|
|
6279
|
+
if (mouseMoveDistance > dragThreshold && containerRef.current) {
|
|
6280
|
+
if (mouseDownTimer.current) {
|
|
6281
|
+
window.clearTimeout(mouseDownTimer.current);
|
|
6282
|
+
mouseDownTimer.current = null;
|
|
6283
|
+
}
|
|
6284
|
+
document.removeEventListener("mousemove", preDragMouseMoveHandler);
|
|
6285
|
+
document.removeEventListener("mouseup", preDragMouseUpHandler, false);
|
|
6286
|
+
dragStart(evt);
|
|
6287
|
+
}
|
|
6288
|
+
},
|
|
6289
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6290
|
+
[containerRef, beginDrag, orientation]
|
|
6291
|
+
);
|
|
6292
|
+
const preDragMouseUpHandler = useCallback23(() => {
|
|
6293
|
+
if (mouseDownTimer.current) {
|
|
6294
|
+
window.clearTimeout(mouseDownTimer.current);
|
|
6295
|
+
mouseDownTimer.current = null;
|
|
6296
|
+
}
|
|
6297
|
+
document.removeEventListener("mousemove", preDragMouseMoveHandler, false);
|
|
6298
|
+
document.removeEventListener("mouseup", preDragMouseUpHandler, false);
|
|
6299
|
+
}, [preDragMouseMoveHandler]);
|
|
6300
|
+
const mouseDownHandler = useCallback23(
|
|
6301
|
+
(evt) => {
|
|
6302
|
+
console.log(`useDragDropNext onMouseDown`);
|
|
6303
|
+
const { current: container } = containerRef;
|
|
6304
|
+
if (container && !evt.defaultPrevented) {
|
|
6305
|
+
const { clientX, clientY } = evt;
|
|
6306
|
+
mousePosRef.current.x = startPosRef.current.x = clientX;
|
|
6307
|
+
mousePosRef.current.y = startPosRef.current.y = clientY;
|
|
6308
|
+
document.addEventListener("mousemove", preDragMouseMoveHandler, false);
|
|
6309
|
+
document.addEventListener("mouseup", preDragMouseUpHandler, false);
|
|
6310
|
+
evt.persist();
|
|
6311
|
+
mouseDownTimer.current = window.setTimeout(() => {
|
|
6312
|
+
document.removeEventListener(
|
|
6313
|
+
"mousemove",
|
|
6314
|
+
preDragMouseMoveHandler,
|
|
6315
|
+
false
|
|
6316
|
+
);
|
|
6317
|
+
document.removeEventListener("mouseup", preDragMouseUpHandler, false);
|
|
6318
|
+
dragStart(evt.nativeEvent);
|
|
6319
|
+
}, 500);
|
|
6320
|
+
}
|
|
6321
|
+
},
|
|
6322
|
+
[containerRef, dragStart, preDragMouseMoveHandler, preDragMouseUpHandler]
|
|
6323
|
+
);
|
|
6324
|
+
const { current: settlingItem } = settlingItemRef;
|
|
6325
|
+
useLayoutEffect4(() => {
|
|
6326
|
+
if (settlingItem && containerRef.current) {
|
|
6327
|
+
const dropPos = dropPosRef.current;
|
|
6328
|
+
const droppedItem = containerRef.current.querySelector(
|
|
6329
|
+
`${itemQuery}[data-index="${dropPos}"]`
|
|
6330
|
+
);
|
|
6331
|
+
if (droppedItem) {
|
|
6332
|
+
droppedItem.classList.add("vuuDropTarget-settling");
|
|
6333
|
+
requestAnimationFrame(() => {
|
|
6334
|
+
const { top: targetTop, left: targetLeft } = droppedItem.getBoundingClientRect();
|
|
6335
|
+
const { top: currentTop, left: currentLeft } = settlingItem.getBoundingClientRect();
|
|
6336
|
+
if (currentLeft !== targetLeft || currentTop !== targetTop) {
|
|
6337
|
+
settlingItem.classList.add("vuuDraggable-settling");
|
|
6338
|
+
settlingItem.style.top = `${targetTop}px`;
|
|
6339
|
+
settlingItem.style.left = `${targetLeft}px`;
|
|
6340
|
+
} else {
|
|
6341
|
+
terminateDrag();
|
|
6342
|
+
}
|
|
6343
|
+
});
|
|
6344
|
+
} else {
|
|
6345
|
+
console.log(`dont have the dropped item (at ${dropPos})`);
|
|
6346
|
+
}
|
|
6347
|
+
settlingItemRef.current = null;
|
|
6348
|
+
}
|
|
6349
|
+
}, [containerRef, itemQuery, settlingItem, terminateDrag]);
|
|
6350
|
+
return {
|
|
6351
|
+
...dragResult,
|
|
6352
|
+
...draggableStatus,
|
|
6353
|
+
isScrolling,
|
|
6354
|
+
onMouseDown: allowDragDrop ? mouseDownHandler : void 0
|
|
6355
|
+
};
|
|
6356
|
+
};
|
|
6357
|
+
|
|
6358
|
+
// ../vuu-ui-controls/src/tabstrip/TabMenuOptions.ts
|
|
6359
|
+
var isTabMenuOptions = (options) => typeof options === "object" && options !== null && "tabIndex" in options && typeof options.tabIndex === "number";
|
|
6360
|
+
var closeCommand = (options) => ({
|
|
6361
|
+
label: `Close`,
|
|
6362
|
+
location: "tab",
|
|
6363
|
+
action: `close-tab`,
|
|
6364
|
+
options
|
|
6365
|
+
});
|
|
6366
|
+
var renameCommand = (options) => ({
|
|
6367
|
+
label: `Rename`,
|
|
6368
|
+
location: "tab",
|
|
6369
|
+
action: `rename-tab`,
|
|
6370
|
+
options
|
|
6371
|
+
});
|
|
6372
|
+
|
|
6373
|
+
// ../vuu-ui-controls/src/tabstrip/tabstrip-dom-utils.ts
|
|
6374
|
+
var getElementIndex = (el) => {
|
|
6375
|
+
if (el) {
|
|
6376
|
+
const index = parseInt(el.dataset.index || "");
|
|
6377
|
+
if (!isNaN(index)) {
|
|
6378
|
+
return index;
|
|
6379
|
+
}
|
|
6380
|
+
}
|
|
6381
|
+
return -1;
|
|
6382
|
+
};
|
|
6383
|
+
var getIndexOfItem = (container, query) => {
|
|
6384
|
+
if (container) {
|
|
6385
|
+
const targetTab = container.querySelector(
|
|
6386
|
+
`[data-index]:has(${query})`
|
|
6387
|
+
);
|
|
6388
|
+
return getElementIndex(targetTab);
|
|
6389
|
+
}
|
|
6390
|
+
return -1;
|
|
6391
|
+
};
|
|
6392
|
+
var getIndexOfSelectedTab = (container) => getIndexOfItem(container, '[aria-selected="true"]');
|
|
6393
|
+
var getIndexOfEditedItem = (container) => getIndexOfItem(container, ".vuuEditableLabel-editing");
|
|
6394
|
+
|
|
6395
|
+
// ../vuu-ui-controls/src/tabstrip/useAnimatedSelectionThumb.ts
|
|
6396
|
+
import { useCallback as useCallback24, useMemo as useMemo11, useRef as useRef17 } from "react";
|
|
6397
|
+
var useAnimatedSelectionThumb = (containerRef, activeTabIndex) => {
|
|
6398
|
+
const animationSuspendedRef = useRef17(false);
|
|
6399
|
+
const suspendAnimation = useCallback24(() => {
|
|
6400
|
+
animationSuspendedRef.current = true;
|
|
6401
|
+
}, []);
|
|
6402
|
+
const resumeAnimation = useCallback24(() => {
|
|
6403
|
+
animationSuspendedRef.current = false;
|
|
6404
|
+
}, []);
|
|
6405
|
+
const onTransitionEnd = useCallback24(() => {
|
|
6406
|
+
var _a, _b;
|
|
6407
|
+
(_a = containerRef.current) == null ? void 0 : _a.style.setProperty("--tab-thumb-transition", "none");
|
|
6408
|
+
(_b = containerRef.current) == null ? void 0 : _b.removeEventListener("transitionend", onTransitionEnd);
|
|
6409
|
+
}, [containerRef]);
|
|
6410
|
+
const lastSelectedRef = useRef17(-1);
|
|
6411
|
+
return useMemo11(() => {
|
|
6412
|
+
var _a, _b;
|
|
6413
|
+
let offset = 0;
|
|
6414
|
+
let width = 0;
|
|
6415
|
+
if (lastSelectedRef.current !== -1) {
|
|
6416
|
+
const oldSelected = (_a = containerRef.current) == null ? void 0 : _a.querySelector(".vuuTab-selected");
|
|
6417
|
+
const newSelected = (_b = containerRef.current) == null ? void 0 : _b.querySelector(
|
|
6418
|
+
`[data-index="${activeTabIndex}"] .vuuTab`
|
|
6419
|
+
);
|
|
6420
|
+
if (oldSelected && newSelected && !animationSuspendedRef.current) {
|
|
6421
|
+
const { left: oldLeft, width: oldWidth } = oldSelected.getBoundingClientRect();
|
|
6422
|
+
const { left: newLeft } = newSelected.getBoundingClientRect();
|
|
6423
|
+
offset = oldLeft - newLeft;
|
|
6424
|
+
width = oldWidth;
|
|
6425
|
+
const duration = Math.abs(
|
|
6426
|
+
offset / 1100
|
|
6427
|
+
/* this is our speed */
|
|
6428
|
+
);
|
|
6429
|
+
requestAnimationFrame(() => {
|
|
6430
|
+
var _a2, _b2, _c, _d;
|
|
6431
|
+
(_a2 = containerRef.current) == null ? void 0 : _a2.style.setProperty("--tab-thumb-offset", "0px");
|
|
6432
|
+
(_b2 = containerRef.current) == null ? void 0 : _b2.style.setProperty("--tab-thumb-width", "100%");
|
|
6433
|
+
(_c = containerRef.current) == null ? void 0 : _c.style.setProperty(
|
|
6434
|
+
"--tab-thumb-transition",
|
|
6435
|
+
`all ${duration}s ease`
|
|
6436
|
+
);
|
|
6437
|
+
(_d = containerRef.current) == null ? void 0 : _d.addEventListener(
|
|
6438
|
+
"transitionend",
|
|
6439
|
+
onTransitionEnd
|
|
6440
|
+
);
|
|
6441
|
+
});
|
|
6442
|
+
}
|
|
6443
|
+
}
|
|
6444
|
+
lastSelectedRef.current = activeTabIndex;
|
|
6445
|
+
if (animationSuspendedRef.current) {
|
|
6446
|
+
return {
|
|
6447
|
+
containerStyle: {
|
|
6448
|
+
"--tab-thumb-offset": "0px",
|
|
6449
|
+
"--tab-thumb-width": "100%"
|
|
6450
|
+
},
|
|
6451
|
+
resumeAnimation,
|
|
6452
|
+
suspendAnimation
|
|
6453
|
+
};
|
|
6454
|
+
} else {
|
|
6455
|
+
return {
|
|
6456
|
+
containerStyle: {
|
|
6457
|
+
"--tab-thumb-offset": `${offset}px`,
|
|
6458
|
+
"--tab-thumb-width": width ? `${width}px` : void 0
|
|
6459
|
+
},
|
|
6460
|
+
resumeAnimation,
|
|
6461
|
+
suspendAnimation
|
|
6462
|
+
};
|
|
6463
|
+
}
|
|
6464
|
+
}, [
|
|
6465
|
+
activeTabIndex,
|
|
6466
|
+
resumeAnimation,
|
|
6467
|
+
suspendAnimation,
|
|
6468
|
+
containerRef,
|
|
6469
|
+
onTransitionEnd
|
|
6470
|
+
]);
|
|
6471
|
+
};
|
|
6472
|
+
|
|
6473
|
+
// ../vuu-ui-controls/src/tabstrip/useKeyboardNavigation.ts
|
|
6474
|
+
import { useControlled as useControlled3 } from "@salt-ds/core";
|
|
6475
|
+
import { getFocusableElement } from "@vuu-ui/vuu-utils";
|
|
6476
|
+
import {
|
|
6477
|
+
useCallback as useCallback25,
|
|
6478
|
+
useRef as useRef18,
|
|
6479
|
+
useState as useState10
|
|
6480
|
+
} from "react";
|
|
6481
|
+
import {
|
|
6482
|
+
ArrowDown,
|
|
6483
|
+
ArrowUp,
|
|
6484
|
+
ArrowLeft,
|
|
6485
|
+
ArrowRight,
|
|
6486
|
+
Home,
|
|
6487
|
+
End
|
|
6488
|
+
} from "@vuu-ui/vuu-utils";
|
|
6489
|
+
var navigation = {
|
|
6490
|
+
horizontal: {
|
|
6491
|
+
[Home]: "start",
|
|
6492
|
+
[End]: "end",
|
|
6493
|
+
[ArrowLeft]: "bwd",
|
|
6494
|
+
[ArrowRight]: "fwd"
|
|
6495
|
+
},
|
|
6496
|
+
vertical: {
|
|
6497
|
+
[Home]: "start",
|
|
6498
|
+
[End]: "end",
|
|
6499
|
+
[ArrowUp]: "bwd",
|
|
6500
|
+
[ArrowDown]: "fwd"
|
|
6501
|
+
}
|
|
6502
|
+
};
|
|
6503
|
+
var isNavigationKey = (key, orientation = "horizontal") => navigation[orientation][key] !== void 0;
|
|
6504
|
+
var isMenuActivationKey = (key) => key === ArrowDown;
|
|
6505
|
+
function nextItemIdx(count, direction, idx) {
|
|
6506
|
+
if (direction === "start") {
|
|
6507
|
+
return 0;
|
|
6508
|
+
} else if (direction === "end") {
|
|
6509
|
+
return count - 1;
|
|
6510
|
+
} else if (direction === "bwd") {
|
|
6511
|
+
if (idx > 0) {
|
|
6512
|
+
return idx - 1;
|
|
6513
|
+
} else {
|
|
6514
|
+
return idx;
|
|
6515
|
+
}
|
|
6516
|
+
} else {
|
|
6517
|
+
if (idx === null) {
|
|
6518
|
+
return 0;
|
|
6519
|
+
} else if (idx === count - 1) {
|
|
6520
|
+
return idx;
|
|
6521
|
+
} else {
|
|
6522
|
+
return idx + 1;
|
|
6523
|
+
}
|
|
6524
|
+
}
|
|
6525
|
+
}
|
|
6526
|
+
var isNonWrappedElement = (element) => element !== null && !element.classList.contains("wrapped");
|
|
6527
|
+
var getElementByPosition = (container, index) => container ? container.querySelector(`[data-index="${index}"]`) : null;
|
|
6528
|
+
var useKeyboardNavigation = ({
|
|
6529
|
+
containerRef,
|
|
6530
|
+
defaultHighlightedIdx = -1,
|
|
6531
|
+
highlightedIdx: highlightedIdxProp,
|
|
6532
|
+
keyBoardActivation,
|
|
6533
|
+
orientation,
|
|
6534
|
+
selectedIndex: selectedTabIndex = 0
|
|
6535
|
+
}) => {
|
|
6536
|
+
const manualActivation = keyBoardActivation === "manual";
|
|
6537
|
+
const mouseClickPending = useRef18(false);
|
|
6538
|
+
const focusedRef = useRef18(-1);
|
|
6539
|
+
const [hasFocus, setHasFocus] = useState10(false);
|
|
6540
|
+
const [, forceRefresh] = useState10({});
|
|
6541
|
+
const [highlightedIdx, _setHighlightedIdx] = useControlled3({
|
|
6542
|
+
controlled: highlightedIdxProp,
|
|
6543
|
+
default: defaultHighlightedIdx,
|
|
6544
|
+
name: "UseKeyboardNavigation"
|
|
6545
|
+
});
|
|
6546
|
+
const setHighlightedIdx = useCallback25(
|
|
6547
|
+
(value) => {
|
|
6548
|
+
_setHighlightedIdx(focusedRef.current = value);
|
|
6549
|
+
},
|
|
6550
|
+
[_setHighlightedIdx]
|
|
6551
|
+
);
|
|
6552
|
+
const keyboardNavigation = useRef18(false);
|
|
6553
|
+
const focusTab = useCallback25(
|
|
6554
|
+
(tabIndex, immediateFocus = false, withKeyboard, delay = 70) => {
|
|
6555
|
+
setHighlightedIdx(tabIndex);
|
|
6556
|
+
if (withKeyboard === true && !keyboardNavigation.current) {
|
|
6557
|
+
keyboardNavigation.current = true;
|
|
6558
|
+
}
|
|
6559
|
+
const setFocus = () => {
|
|
6560
|
+
const element = getElementByPosition(containerRef.current, tabIndex);
|
|
6561
|
+
if (element) {
|
|
6562
|
+
const focussableElement = getFocusableElement(element);
|
|
6563
|
+
focussableElement == null ? void 0 : focussableElement.focus();
|
|
6564
|
+
}
|
|
6565
|
+
};
|
|
6566
|
+
if (immediateFocus) {
|
|
6567
|
+
setFocus();
|
|
6568
|
+
} else {
|
|
6569
|
+
setTimeout(setFocus, delay);
|
|
6570
|
+
}
|
|
6571
|
+
},
|
|
6572
|
+
[containerRef, setHighlightedIdx]
|
|
6573
|
+
);
|
|
6574
|
+
const onFocus = (e) => {
|
|
6575
|
+
console.log("ONFOCUS");
|
|
6576
|
+
if (focusedRef.current === -1) {
|
|
6577
|
+
if (e.target.tabIndex === -1) {
|
|
6578
|
+
} else {
|
|
6579
|
+
const index = getIndexOfEditedItem(containerRef.current);
|
|
6580
|
+
if (index !== -1) {
|
|
6581
|
+
requestAnimationFrame(() => {
|
|
6582
|
+
setHighlightedIdx(index);
|
|
6583
|
+
});
|
|
6584
|
+
} else {
|
|
6585
|
+
setTimeout(() => {
|
|
6586
|
+
if (focusedRef.current === -1 && selectedTabIndex !== null) {
|
|
6587
|
+
setHighlightedIdx(selectedTabIndex);
|
|
6588
|
+
}
|
|
6589
|
+
}, 200);
|
|
6590
|
+
}
|
|
6591
|
+
}
|
|
6592
|
+
}
|
|
6593
|
+
};
|
|
6594
|
+
const getIndexCount = useCallback25(
|
|
6595
|
+
() => {
|
|
6596
|
+
var _a, _b;
|
|
6597
|
+
return (_b = (_a = containerRef.current) == null ? void 0 : _a.querySelectorAll(`[data-index]`).length) != null ? _b : 0;
|
|
6598
|
+
},
|
|
6599
|
+
[containerRef]
|
|
6600
|
+
);
|
|
6601
|
+
const nextFocusableItemIdx = useCallback25(
|
|
6602
|
+
(direction = "fwd", idx) => {
|
|
6603
|
+
const indexCount = getIndexCount();
|
|
6604
|
+
const index = typeof idx === "number" ? idx : indexCount;
|
|
6605
|
+
let nextIdx = nextItemIdx(indexCount, direction, index);
|
|
6606
|
+
const nextDirection = direction === "start" ? "fwd" : direction === "end" ? "bwd" : direction;
|
|
6607
|
+
while ((nextDirection === "fwd" && nextIdx < indexCount || nextDirection === "bwd" && nextIdx > 0) && !isNonWrappedElement(
|
|
6608
|
+
getElementByPosition(containerRef.current, nextIdx)
|
|
6609
|
+
)) {
|
|
6610
|
+
const newIdx = nextItemIdx(indexCount, nextDirection, nextIdx);
|
|
6611
|
+
if (newIdx === nextIdx) {
|
|
6612
|
+
break;
|
|
6613
|
+
} else {
|
|
6614
|
+
nextIdx = newIdx;
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
return nextIdx;
|
|
6618
|
+
},
|
|
6619
|
+
[containerRef, getIndexCount]
|
|
6620
|
+
);
|
|
6621
|
+
const navigateChildItems = useCallback25(
|
|
6622
|
+
(e, forceFocusVisible = false) => {
|
|
6623
|
+
const direction = navigation[orientation][e.key];
|
|
6624
|
+
const nextIdx = nextFocusableItemIdx(direction, highlightedIdx);
|
|
6625
|
+
if (nextIdx !== highlightedIdx) {
|
|
6626
|
+
const immediateFocus = true;
|
|
6627
|
+
if (manualActivation) {
|
|
6628
|
+
focusTab(nextIdx, immediateFocus);
|
|
6629
|
+
} else {
|
|
6630
|
+
}
|
|
6631
|
+
} else if (forceFocusVisible) {
|
|
6632
|
+
forceRefresh({});
|
|
6633
|
+
}
|
|
6634
|
+
},
|
|
6635
|
+
[
|
|
6636
|
+
highlightedIdx,
|
|
6637
|
+
manualActivation,
|
|
6638
|
+
nextFocusableItemIdx,
|
|
6639
|
+
focusTab,
|
|
6640
|
+
orientation
|
|
6641
|
+
]
|
|
6642
|
+
);
|
|
6643
|
+
const highlightedTabHasMenu = useCallback25(() => {
|
|
6644
|
+
const el = getElementByPosition(containerRef.current, highlightedIdx);
|
|
6645
|
+
if (el) {
|
|
6646
|
+
return el.querySelector(".vuuPopupMenu") != null;
|
|
6647
|
+
}
|
|
6648
|
+
return false;
|
|
6649
|
+
}, [containerRef, highlightedIdx]);
|
|
6650
|
+
const activateTabMenu = useCallback25(() => {
|
|
6651
|
+
const el = getElementByPosition(containerRef.current, highlightedIdx);
|
|
6652
|
+
const menuEl = el == null ? void 0 : el.querySelector(".vuuPopupMenu");
|
|
6653
|
+
if (menuEl) {
|
|
6654
|
+
const evt = new MouseEvent("click", {
|
|
6655
|
+
view: window,
|
|
6656
|
+
bubbles: true,
|
|
6657
|
+
cancelable: true
|
|
6658
|
+
});
|
|
6659
|
+
menuEl.dispatchEvent(evt);
|
|
6660
|
+
}
|
|
6661
|
+
return false;
|
|
6662
|
+
}, [containerRef, highlightedIdx]);
|
|
6663
|
+
const handleKeyDown = useCallback25(
|
|
6664
|
+
(e) => {
|
|
6665
|
+
if (getIndexCount() > 0 && isNavigationKey(e.key, orientation)) {
|
|
6666
|
+
e.preventDefault();
|
|
6667
|
+
if (keyboardNavigation.current) {
|
|
6668
|
+
navigateChildItems(e);
|
|
6669
|
+
} else {
|
|
6670
|
+
keyboardNavigation.current = true;
|
|
6671
|
+
navigateChildItems(e, true);
|
|
6672
|
+
}
|
|
6673
|
+
} else if (isMenuActivationKey(e.key) && highlightedTabHasMenu()) {
|
|
6674
|
+
activateTabMenu();
|
|
6675
|
+
}
|
|
6676
|
+
},
|
|
6677
|
+
[
|
|
6678
|
+
activateTabMenu,
|
|
6679
|
+
getIndexCount,
|
|
6680
|
+
highlightedTabHasMenu,
|
|
6681
|
+
navigateChildItems,
|
|
6682
|
+
orientation
|
|
6683
|
+
]
|
|
6684
|
+
);
|
|
6685
|
+
const handleItemClick = (_, tabIndex) => {
|
|
6686
|
+
setHighlightedIdx(tabIndex);
|
|
6687
|
+
};
|
|
6688
|
+
const handleFocus = useCallback25(() => {
|
|
6689
|
+
if (!hasFocus) {
|
|
6690
|
+
setHasFocus(true);
|
|
6691
|
+
if (!mouseClickPending.current) {
|
|
6692
|
+
keyboardNavigation.current = true;
|
|
6693
|
+
} else {
|
|
6694
|
+
mouseClickPending.current = false;
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
}, [hasFocus]);
|
|
6698
|
+
const handleContainerMouseDown = useCallback25(() => {
|
|
6699
|
+
if (!hasFocus) {
|
|
6700
|
+
mouseClickPending.current = true;
|
|
6701
|
+
}
|
|
6702
|
+
keyboardNavigation.current = false;
|
|
6703
|
+
}, [hasFocus]);
|
|
6704
|
+
const containerProps = {
|
|
6705
|
+
onBlur: (e) => {
|
|
6706
|
+
const sourceTarget = e.target.closest(".vuuTabstrip");
|
|
6707
|
+
const destTarget = e.relatedTarget;
|
|
6708
|
+
if (sourceTarget && !(sourceTarget == null ? void 0 : sourceTarget.contains(destTarget))) {
|
|
6709
|
+
setHighlightedIdx(-1);
|
|
6710
|
+
setHasFocus(false);
|
|
6711
|
+
}
|
|
6712
|
+
},
|
|
6713
|
+
onMouseDownCapture: handleContainerMouseDown,
|
|
6714
|
+
onFocus: handleFocus,
|
|
6715
|
+
onMouseLeave: () => {
|
|
6716
|
+
keyboardNavigation.current = true;
|
|
6717
|
+
setHighlightedIdx(-1);
|
|
6718
|
+
mouseClickPending.current = false;
|
|
6719
|
+
}
|
|
6720
|
+
};
|
|
6721
|
+
return {
|
|
6722
|
+
containerProps,
|
|
6723
|
+
focusVisible: keyboardNavigation.current ? highlightedIdx : -1,
|
|
6724
|
+
focusIsWithinComponent: hasFocus,
|
|
6725
|
+
highlightedIdx,
|
|
6726
|
+
focusTab,
|
|
6727
|
+
onClick: handleItemClick,
|
|
6728
|
+
onFocus,
|
|
6729
|
+
onKeyDown: handleKeyDown,
|
|
6730
|
+
setHighlightedIdx
|
|
6731
|
+
};
|
|
6732
|
+
};
|
|
6733
|
+
|
|
6734
|
+
// ../vuu-ui-controls/src/tabstrip/useSelection.ts
|
|
6735
|
+
import { useControlled as useControlled4 } from "@salt-ds/core";
|
|
6736
|
+
import { useCallback as useCallback26 } from "react";
|
|
6737
|
+
var defaultSelectionKeys = ["Enter", " "];
|
|
6738
|
+
var isTabElement = (el) => el && el.matches('[class*="vuuTab "]');
|
|
6739
|
+
var useSelection = ({
|
|
6740
|
+
defaultSelected,
|
|
6741
|
+
highlightedIdx,
|
|
6742
|
+
onSelectionChange,
|
|
6743
|
+
selected: selectedProp
|
|
6744
|
+
}) => {
|
|
6745
|
+
const [selected, setSelected, isControlled] = useControlled4({
|
|
6746
|
+
controlled: selectedProp,
|
|
6747
|
+
default: defaultSelected != null ? defaultSelected : 0,
|
|
6748
|
+
name: "Tabstrip",
|
|
6749
|
+
state: "value"
|
|
6750
|
+
});
|
|
6751
|
+
const isSelectionEvent = useCallback26(
|
|
6752
|
+
(evt) => defaultSelectionKeys.includes(evt.key),
|
|
6753
|
+
[]
|
|
6754
|
+
);
|
|
6755
|
+
const selectItem = useCallback26(
|
|
6756
|
+
(tabIndex) => {
|
|
6757
|
+
setSelected(tabIndex);
|
|
6758
|
+
onSelectionChange == null ? void 0 : onSelectionChange(tabIndex);
|
|
6759
|
+
},
|
|
6760
|
+
[onSelectionChange, setSelected]
|
|
6761
|
+
);
|
|
6762
|
+
const handleKeyDown = useCallback26(
|
|
6763
|
+
(e) => {
|
|
6764
|
+
const targetElement = e.target;
|
|
6765
|
+
if (isSelectionEvent(e) && highlightedIdx !== selected && isTabElement(targetElement)) {
|
|
6766
|
+
e.stopPropagation();
|
|
6767
|
+
e.preventDefault();
|
|
6768
|
+
selectItem(highlightedIdx);
|
|
6769
|
+
}
|
|
6770
|
+
},
|
|
6771
|
+
[isSelectionEvent, highlightedIdx, selected, selectItem]
|
|
6772
|
+
);
|
|
6773
|
+
const onClick = useCallback26(
|
|
6774
|
+
(e, tabIndex) => {
|
|
6775
|
+
if (tabIndex !== selected) {
|
|
6776
|
+
selectItem(tabIndex);
|
|
6777
|
+
}
|
|
6778
|
+
},
|
|
6779
|
+
[selectItem, selected]
|
|
6780
|
+
);
|
|
6781
|
+
return {
|
|
6782
|
+
activateTab: selectItem,
|
|
6783
|
+
isControlled,
|
|
6784
|
+
onClick,
|
|
6785
|
+
onKeyDown: handleKeyDown,
|
|
6786
|
+
selected
|
|
6787
|
+
};
|
|
6788
|
+
};
|
|
6789
|
+
|
|
6790
|
+
// ../vuu-ui-controls/src/tabstrip/useTabstrip.ts
|
|
6791
|
+
var editKeys = /* @__PURE__ */ new Set(["Enter", " "]);
|
|
6792
|
+
var isEditKey = (key) => editKeys.has(key);
|
|
6793
|
+
var getElementWithIndex = (container, index) => {
|
|
6794
|
+
if (container) {
|
|
6795
|
+
return container.querySelector(`[data-index="${index}"]`);
|
|
6796
|
+
} else {
|
|
6797
|
+
return null;
|
|
6798
|
+
}
|
|
6799
|
+
};
|
|
6800
|
+
var useTabstrip = ({
|
|
6801
|
+
activeTabIndex: activeTabIndexProp,
|
|
6802
|
+
allowDragDrop,
|
|
6803
|
+
animateSelectionThumb,
|
|
6804
|
+
containerRef,
|
|
6805
|
+
onActiveChange,
|
|
6806
|
+
onAddTab,
|
|
6807
|
+
onCloseTab,
|
|
6808
|
+
onExitEditMode,
|
|
6809
|
+
onMoveTab,
|
|
6810
|
+
orientation,
|
|
6811
|
+
keyBoardActivation
|
|
6812
|
+
}) => {
|
|
6813
|
+
const lastSelection = useRef19(activeTabIndexProp);
|
|
6814
|
+
const {
|
|
6815
|
+
focusTab: keyboardHookFocusTab,
|
|
6816
|
+
highlightedIdx,
|
|
6817
|
+
onClick: keyboardHookHandleClick,
|
|
6818
|
+
onKeyDown: keyboardHookHandleKeyDown,
|
|
6819
|
+
setHighlightedIdx: keyboardHookSetHighlightedIndex,
|
|
6820
|
+
...keyboardHook
|
|
6821
|
+
} = useKeyboardNavigation({
|
|
6822
|
+
containerRef,
|
|
6823
|
+
keyBoardActivation,
|
|
6824
|
+
orientation,
|
|
6825
|
+
selectedIndex: lastSelection.current
|
|
6826
|
+
});
|
|
6827
|
+
const {
|
|
6828
|
+
activateTab: selectionHookActivateTab,
|
|
6829
|
+
onClick: selectionHookHandleClick,
|
|
6830
|
+
onKeyDown: selectionHookHandleKeyDown,
|
|
6831
|
+
selected: selectionHookSelected
|
|
6832
|
+
} = useSelection({
|
|
6833
|
+
highlightedIdx,
|
|
6834
|
+
onSelectionChange: onActiveChange,
|
|
6835
|
+
selected: activeTabIndexProp
|
|
6836
|
+
});
|
|
6837
|
+
lastSelection.current = selectionHookSelected;
|
|
6838
|
+
const { containerStyle, resumeAnimation, suspendAnimation } = useAnimatedSelectionThumb(
|
|
6839
|
+
containerRef,
|
|
6840
|
+
animateSelectionThumb ? selectionHookSelected : -1
|
|
6841
|
+
);
|
|
6842
|
+
const handleDrop = useCallback27(
|
|
6843
|
+
(fromIndex, toIndex) => {
|
|
6844
|
+
const { current: selected } = lastSelection;
|
|
6845
|
+
console.log(
|
|
6846
|
+
`useTabstrip handleDrop ${fromIndex} - ${toIndex} ${selected}`
|
|
6847
|
+
);
|
|
6848
|
+
onMoveTab == null ? void 0 : onMoveTab(fromIndex, toIndex);
|
|
6849
|
+
let nextSelectedTab = -1;
|
|
6850
|
+
if (toIndex !== -1) {
|
|
6851
|
+
if (selected === fromIndex) {
|
|
6852
|
+
nextSelectedTab = toIndex;
|
|
6853
|
+
} else if (fromIndex > selected && toIndex <= selected) {
|
|
6854
|
+
nextSelectedTab = selected + 1;
|
|
6855
|
+
} else if (fromIndex < selected && toIndex >= selected) {
|
|
6856
|
+
nextSelectedTab = selected - 1;
|
|
6857
|
+
}
|
|
6858
|
+
if (nextSelectedTab !== -1) {
|
|
6859
|
+
suspendAnimation();
|
|
6860
|
+
selectionHookActivateTab(nextSelectedTab);
|
|
6861
|
+
requestAnimationFrame(resumeAnimation);
|
|
6862
|
+
}
|
|
6863
|
+
keyboardHookFocusTab(toIndex, false, false, 350);
|
|
6864
|
+
}
|
|
6865
|
+
},
|
|
6866
|
+
[
|
|
6867
|
+
keyboardHookFocusTab,
|
|
6868
|
+
onMoveTab,
|
|
6869
|
+
resumeAnimation,
|
|
6870
|
+
selectionHookActivateTab,
|
|
6871
|
+
suspendAnimation
|
|
6872
|
+
]
|
|
6873
|
+
);
|
|
6874
|
+
const { onMouseDown: dragDropHookHandleMouseDown, ...dragDropHook } = useDragDropNext({
|
|
6875
|
+
allowDragDrop,
|
|
6876
|
+
containerRef,
|
|
6877
|
+
// this is for useDragDropNext
|
|
6878
|
+
draggableClassName: `tabstrip-${orientation}`,
|
|
6879
|
+
// extendedDropZone: overflowedItems.length > 0,
|
|
6880
|
+
onDrop: handleDrop,
|
|
6881
|
+
orientation: "horizontal",
|
|
6882
|
+
itemQuery: ".vuuOverflowContainer-item"
|
|
6883
|
+
});
|
|
6884
|
+
const handleExitEditMode = useCallback27(
|
|
6885
|
+
(originalValue, editedValue, allowDeactivation, tabIndex) => {
|
|
6886
|
+
console.log(
|
|
6887
|
+
`handleExitEditMode ${originalValue} ${editedValue} ${allowDeactivation} ${tabIndex}`
|
|
6888
|
+
);
|
|
6889
|
+
onExitEditMode == null ? void 0 : onExitEditMode(originalValue, editedValue, allowDeactivation, tabIndex);
|
|
6890
|
+
if (!allowDeactivation) {
|
|
6891
|
+
keyboardHookFocusTab(tabIndex, false, true);
|
|
6892
|
+
}
|
|
6893
|
+
},
|
|
6894
|
+
[keyboardHookFocusTab, onExitEditMode]
|
|
6895
|
+
);
|
|
6896
|
+
const handleClick = useCallback27(
|
|
6897
|
+
(evt, tabIndex) => {
|
|
6898
|
+
keyboardHookHandleClick(evt, tabIndex);
|
|
6899
|
+
selectionHookHandleClick(evt, tabIndex);
|
|
6900
|
+
},
|
|
6901
|
+
// [dragDropHook.isDragging, keyboardHook, selectionHook]
|
|
6902
|
+
[keyboardHookHandleClick, selectionHookHandleClick]
|
|
6903
|
+
);
|
|
6904
|
+
const getEditableLabel = useCallback27(
|
|
6905
|
+
(tabIndex = highlightedIdx) => {
|
|
6906
|
+
const targetEl = getElementWithIndex(containerRef.current, tabIndex);
|
|
6907
|
+
if (targetEl) {
|
|
6908
|
+
return targetEl.querySelector(".vuuEditableLabel");
|
|
6909
|
+
}
|
|
6910
|
+
},
|
|
6911
|
+
[containerRef, highlightedIdx]
|
|
6912
|
+
);
|
|
6913
|
+
const tabInEditMode = useCallback27(
|
|
6914
|
+
(tabIndex = highlightedIdx) => {
|
|
6915
|
+
const editableLabel = getEditableLabel(tabIndex);
|
|
6916
|
+
if (editableLabel) {
|
|
6917
|
+
return editableLabel.classList.contains("vuuEditableLabel-editing");
|
|
6918
|
+
}
|
|
6919
|
+
return false;
|
|
6920
|
+
},
|
|
6921
|
+
[getEditableLabel, highlightedIdx]
|
|
6922
|
+
);
|
|
6923
|
+
const editTab = useCallback27(
|
|
6924
|
+
(tabIndex = highlightedIdx) => {
|
|
6925
|
+
const editableLabelEl = getEditableLabel(tabIndex);
|
|
6926
|
+
if (editableLabelEl) {
|
|
6927
|
+
const evt = new MouseEvent("dblclick", {
|
|
6928
|
+
view: window,
|
|
6929
|
+
bubbles: true,
|
|
6930
|
+
cancelable: true
|
|
6931
|
+
});
|
|
6932
|
+
editableLabelEl.dispatchEvent(evt);
|
|
6933
|
+
}
|
|
6934
|
+
},
|
|
6935
|
+
[getEditableLabel, highlightedIdx]
|
|
6936
|
+
);
|
|
6937
|
+
const handleKeyDown = useCallback27(
|
|
6938
|
+
(evt) => {
|
|
6939
|
+
keyboardHookHandleKeyDown(evt);
|
|
6940
|
+
if (!evt.defaultPrevented) {
|
|
6941
|
+
selectionHookHandleKeyDown(evt);
|
|
6942
|
+
}
|
|
6943
|
+
if (!evt.defaultPrevented && isEditKey(evt.key)) {
|
|
6944
|
+
editTab();
|
|
6945
|
+
}
|
|
6946
|
+
},
|
|
6947
|
+
[editTab, keyboardHookHandleKeyDown, selectionHookHandleKeyDown]
|
|
6948
|
+
);
|
|
6949
|
+
const handleCloseTabFromMenu = useCallback27(
|
|
6950
|
+
(tabIndex) => {
|
|
6951
|
+
const selectedTabIndex = getIndexOfSelectedTab(containerRef.current);
|
|
6952
|
+
const newActiveTabIndex = selectedTabIndex > tabIndex ? selectedTabIndex - 1 : selectedTabIndex === tabIndex ? 0 : selectedTabIndex;
|
|
6953
|
+
suspendAnimation();
|
|
6954
|
+
onCloseTab == null ? void 0 : onCloseTab(tabIndex, newActiveTabIndex);
|
|
6955
|
+
setTimeout(() => {
|
|
6956
|
+
resumeAnimation();
|
|
6957
|
+
}, 200);
|
|
6958
|
+
return true;
|
|
6959
|
+
},
|
|
6960
|
+
[containerRef, onCloseTab, resumeAnimation, suspendAnimation]
|
|
6961
|
+
);
|
|
6962
|
+
const handleRenameTabFromMenu = useCallback27(
|
|
6963
|
+
(tabIndex) => {
|
|
6964
|
+
editTab(tabIndex);
|
|
6965
|
+
return true;
|
|
6966
|
+
},
|
|
6967
|
+
[editTab]
|
|
6968
|
+
);
|
|
6969
|
+
const handleTabMenuAction = useCallback27(
|
|
6970
|
+
(action) => {
|
|
6971
|
+
if (isTabMenuOptions(action.options)) {
|
|
6972
|
+
switch (action.menuId) {
|
|
6973
|
+
case "close-tab":
|
|
6974
|
+
return handleCloseTabFromMenu(action.options.tabIndex);
|
|
6975
|
+
case "rename-tab":
|
|
6976
|
+
return handleRenameTabFromMenu(action.options.tabIndex);
|
|
6977
|
+
default:
|
|
6978
|
+
console.log(`tab menu action ${action.menuId}`);
|
|
6979
|
+
}
|
|
6980
|
+
}
|
|
6981
|
+
return false;
|
|
6982
|
+
},
|
|
6983
|
+
[handleCloseTabFromMenu, handleRenameTabFromMenu]
|
|
6984
|
+
);
|
|
6985
|
+
const handleTabMenuClose = useCallback27(() => {
|
|
6986
|
+
if (!tabInEditMode()) {
|
|
6987
|
+
keyboardHookFocusTab(highlightedIdx);
|
|
6988
|
+
} else {
|
|
6989
|
+
keyboardHookSetHighlightedIndex(highlightedIdx);
|
|
6990
|
+
}
|
|
6991
|
+
}, [
|
|
6992
|
+
highlightedIdx,
|
|
6993
|
+
keyboardHookFocusTab,
|
|
6994
|
+
keyboardHookSetHighlightedIndex,
|
|
6995
|
+
tabInEditMode
|
|
6996
|
+
]);
|
|
6997
|
+
const onSwitchWrappedItemIntoView = useCallback27(
|
|
6998
|
+
(item) => {
|
|
6999
|
+
const index = parseInt(item.index);
|
|
7000
|
+
if (!isNaN(index)) {
|
|
7001
|
+
selectionHookActivateTab(index);
|
|
7002
|
+
}
|
|
7003
|
+
},
|
|
7004
|
+
[selectionHookActivateTab]
|
|
7005
|
+
);
|
|
7006
|
+
const navigationProps = {
|
|
7007
|
+
onFocus: keyboardHook.onFocus,
|
|
7008
|
+
onKeyDown: handleKeyDown
|
|
7009
|
+
};
|
|
7010
|
+
const handleAddTabClick = useCallback27(() => {
|
|
7011
|
+
onAddTab == null ? void 0 : onAddTab();
|
|
7012
|
+
requestAnimationFrame(() => {
|
|
7013
|
+
const selectedTabIndex = getIndexOfSelectedTab(containerRef.current);
|
|
7014
|
+
if (selectedTabIndex !== -1) {
|
|
7015
|
+
keyboardHookFocusTab(selectedTabIndex);
|
|
7016
|
+
}
|
|
7017
|
+
});
|
|
7018
|
+
}, [containerRef, keyboardHookFocusTab, onAddTab]);
|
|
7019
|
+
const tabProps = {
|
|
7020
|
+
onClick: handleClick,
|
|
7021
|
+
onKeyDown: handleKeyDown,
|
|
7022
|
+
onExitEditMode: handleExitEditMode,
|
|
7023
|
+
onMenuAction: handleTabMenuAction,
|
|
7024
|
+
onMenuClose: handleTabMenuClose,
|
|
7025
|
+
onMouseDown: dragDropHookHandleMouseDown
|
|
7026
|
+
};
|
|
7027
|
+
return {
|
|
7028
|
+
activeTabIndex: selectionHookSelected,
|
|
7029
|
+
containerStyle,
|
|
7030
|
+
focusVisible: keyboardHook.focusVisible,
|
|
7031
|
+
containerProps: {
|
|
7032
|
+
...keyboardHook.containerProps,
|
|
7033
|
+
onSwitchWrappedItemIntoView
|
|
7034
|
+
},
|
|
7035
|
+
navigationProps,
|
|
7036
|
+
onClickAddTab: handleAddTabClick,
|
|
7037
|
+
tabProps,
|
|
7038
|
+
...dragDropHook
|
|
7039
|
+
};
|
|
7040
|
+
};
|
|
7041
|
+
|
|
7042
|
+
// ../vuu-ui-controls/src/tabstrip/Tabstrip.tsx
|
|
7043
|
+
import { Fragment, jsx as jsx20, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
7044
|
+
import { createElement } from "react";
|
|
7045
|
+
var classBase8 = "vuuTabstrip";
|
|
7046
|
+
var Tabstrip = ({
|
|
7047
|
+
activeTabIndex: activeTabIndexProp,
|
|
7048
|
+
allowAddTab,
|
|
7049
|
+
allowCloseTab,
|
|
7050
|
+
allowDragDrop = false,
|
|
7051
|
+
allowRenameTab = false,
|
|
7052
|
+
animateSelectionThumb = false,
|
|
7053
|
+
children,
|
|
7054
|
+
className: classNameProp,
|
|
7055
|
+
id: idProp,
|
|
7056
|
+
keyBoardActivation = "manual",
|
|
7057
|
+
location,
|
|
7058
|
+
onActiveChange,
|
|
7059
|
+
onAddTab,
|
|
7060
|
+
onCloseTab,
|
|
7061
|
+
onExitEditMode,
|
|
7062
|
+
onMoveTab,
|
|
7063
|
+
orientation = "horizontal",
|
|
7064
|
+
showTabMenuButton,
|
|
7065
|
+
style: styleProp,
|
|
7066
|
+
...htmlAttributes
|
|
7067
|
+
}) => {
|
|
7068
|
+
const rootRef = useRef20(null);
|
|
7069
|
+
const {
|
|
7070
|
+
activeTabIndex,
|
|
7071
|
+
focusVisible,
|
|
7072
|
+
containerStyle,
|
|
7073
|
+
draggedItemIndex,
|
|
7074
|
+
onClickAddTab,
|
|
7075
|
+
tabProps,
|
|
7076
|
+
...tabstripHook
|
|
7077
|
+
} = useTabstrip({
|
|
7078
|
+
activeTabIndex: activeTabIndexProp,
|
|
7079
|
+
allowDragDrop,
|
|
7080
|
+
animateSelectionThumb,
|
|
7081
|
+
containerRef: rootRef,
|
|
7082
|
+
keyBoardActivation,
|
|
7083
|
+
onActiveChange,
|
|
7084
|
+
onAddTab,
|
|
7085
|
+
onCloseTab,
|
|
7086
|
+
onExitEditMode,
|
|
7087
|
+
onMoveTab,
|
|
7088
|
+
orientation
|
|
7089
|
+
});
|
|
7090
|
+
const id = useId(idProp);
|
|
7091
|
+
const className = cx9(classBase8, `${classBase8}-${orientation}`, classNameProp);
|
|
7092
|
+
const style = styleProp || containerStyle ? {
|
|
7093
|
+
...styleProp,
|
|
7094
|
+
...containerStyle
|
|
7095
|
+
} : void 0;
|
|
7096
|
+
const tabs = useMemo12(
|
|
7097
|
+
() => asReactElements(children).map((child, index) => {
|
|
7098
|
+
const {
|
|
7099
|
+
id: tabId = `${id}-tab-${index}`,
|
|
7100
|
+
closeable = allowCloseTab,
|
|
7101
|
+
editable = allowRenameTab,
|
|
7102
|
+
showMenuButton = showTabMenuButton
|
|
7103
|
+
} = child.props;
|
|
7104
|
+
const selected = index === activeTabIndex;
|
|
7105
|
+
return React16.cloneElement(child, {
|
|
7106
|
+
...tabProps,
|
|
7107
|
+
...tabstripHook.navigationProps,
|
|
7108
|
+
closeable,
|
|
7109
|
+
"data-overflow-priority": selected ? "1" : void 0,
|
|
7110
|
+
dragging: draggedItemIndex === index,
|
|
7111
|
+
editable,
|
|
7112
|
+
focusVisible: focusVisible === index,
|
|
7113
|
+
id: tabId,
|
|
7114
|
+
index,
|
|
7115
|
+
location,
|
|
7116
|
+
selected,
|
|
7117
|
+
showMenuButton,
|
|
7118
|
+
tabIndex: selected ? 0 : -1
|
|
7119
|
+
});
|
|
7120
|
+
}).concat(
|
|
7121
|
+
allowAddTab ? /* @__PURE__ */ createElement(
|
|
7122
|
+
Button2,
|
|
7123
|
+
{
|
|
7124
|
+
...tabstripHook.navigationProps,
|
|
7125
|
+
"aria-label": "Create Tab",
|
|
7126
|
+
className: `${classBase8}-addTabButton`,
|
|
7127
|
+
"data-icon": "add",
|
|
7128
|
+
"data-overflow-priority": "1",
|
|
7129
|
+
key: "addButton",
|
|
7130
|
+
onClick: onClickAddTab,
|
|
7131
|
+
variant: "secondary",
|
|
7132
|
+
tabIndex: -1
|
|
7133
|
+
}
|
|
7134
|
+
) : []
|
|
7135
|
+
),
|
|
7136
|
+
[
|
|
7137
|
+
activeTabIndex,
|
|
7138
|
+
allowAddTab,
|
|
7139
|
+
allowCloseTab,
|
|
7140
|
+
allowRenameTab,
|
|
7141
|
+
children,
|
|
7142
|
+
focusVisible,
|
|
7143
|
+
id,
|
|
7144
|
+
location,
|
|
7145
|
+
onClickAddTab,
|
|
7146
|
+
showTabMenuButton,
|
|
7147
|
+
tabProps,
|
|
7148
|
+
draggedItemIndex,
|
|
7149
|
+
tabstripHook.navigationProps
|
|
7150
|
+
]
|
|
7151
|
+
);
|
|
7152
|
+
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
7153
|
+
/* @__PURE__ */ jsx20(
|
|
7154
|
+
OverflowContainer,
|
|
7155
|
+
{
|
|
7156
|
+
...htmlAttributes,
|
|
7157
|
+
...tabstripHook.containerProps,
|
|
7158
|
+
className,
|
|
7159
|
+
height: 28,
|
|
7160
|
+
id,
|
|
7161
|
+
overflowIcon: "more-horiz",
|
|
7162
|
+
ref: rootRef,
|
|
7163
|
+
style,
|
|
7164
|
+
children: tabs
|
|
7165
|
+
}
|
|
7166
|
+
),
|
|
7167
|
+
tabstripHook.draggable
|
|
7168
|
+
] });
|
|
7169
|
+
};
|
|
7170
|
+
|
|
7171
|
+
// ../vuu-ui-controls/src/tabstrip/Tab.tsx
|
|
7172
|
+
import { useForkRef as useForkRef5 } from "@salt-ds/core";
|
|
7173
|
+
import cx11 from "classnames";
|
|
7174
|
+
import {
|
|
7175
|
+
forwardRef as forwardRef8,
|
|
7176
|
+
useCallback as useCallback28,
|
|
7177
|
+
useRef as useRef21
|
|
7178
|
+
} from "react";
|
|
7179
|
+
|
|
7180
|
+
// ../vuu-ui-controls/src/tabstrip/TabMenu.tsx
|
|
7181
|
+
import { PopupMenu } from "@vuu-ui/vuu-popups";
|
|
7182
|
+
import { useMemo as useMemo13 } from "react";
|
|
7183
|
+
import cx10 from "classnames";
|
|
7184
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
7185
|
+
var classBase9 = "vuuTabMenu";
|
|
7186
|
+
var TabMenu = ({
|
|
7187
|
+
allowClose,
|
|
7188
|
+
allowRename,
|
|
7189
|
+
location,
|
|
7190
|
+
onMenuAction,
|
|
7191
|
+
onMenuClose,
|
|
7192
|
+
index
|
|
7193
|
+
}) => {
|
|
7194
|
+
const [menuBuilder, menuOptions] = useMemo13(
|
|
7195
|
+
() => [
|
|
7196
|
+
(_location, options) => {
|
|
7197
|
+
const menuItems = [];
|
|
7198
|
+
if (allowRename) {
|
|
7199
|
+
menuItems.push(renameCommand(options));
|
|
7200
|
+
}
|
|
7201
|
+
if (allowClose) {
|
|
7202
|
+
menuItems.push(closeCommand(options));
|
|
7203
|
+
}
|
|
7204
|
+
return menuItems;
|
|
7205
|
+
},
|
|
7206
|
+
{
|
|
7207
|
+
tabIndex: index
|
|
7208
|
+
}
|
|
7209
|
+
],
|
|
7210
|
+
[allowClose, allowRename, index]
|
|
7211
|
+
);
|
|
7212
|
+
return /* @__PURE__ */ jsx21(
|
|
7213
|
+
PopupMenu,
|
|
7214
|
+
{
|
|
7215
|
+
className: classBase9,
|
|
7216
|
+
menuBuilder,
|
|
7217
|
+
menuActionHandler: onMenuAction,
|
|
7218
|
+
menuLocation: cx10("tab", location),
|
|
7219
|
+
menuOptions,
|
|
7220
|
+
onMenuClose,
|
|
7221
|
+
tabIndex: -1
|
|
7222
|
+
}
|
|
7223
|
+
);
|
|
7224
|
+
};
|
|
7225
|
+
|
|
7226
|
+
// ../vuu-ui-controls/src/tabstrip/Tab.tsx
|
|
7227
|
+
import { jsx as jsx22, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
7228
|
+
var classBase10 = "vuuTab";
|
|
7229
|
+
var noop = () => void 0;
|
|
7230
|
+
var Tab = forwardRef8(function Tab2({
|
|
7231
|
+
ariaControls,
|
|
7232
|
+
children,
|
|
7233
|
+
className,
|
|
7234
|
+
closeable = false,
|
|
7235
|
+
dragging,
|
|
7236
|
+
editable = false,
|
|
7237
|
+
editing,
|
|
7238
|
+
focusVisible,
|
|
7239
|
+
index,
|
|
7240
|
+
label,
|
|
7241
|
+
location,
|
|
7242
|
+
onClick,
|
|
7243
|
+
onClose,
|
|
7244
|
+
onEnterEditMode = noop,
|
|
7245
|
+
onExitEditMode = noop,
|
|
7246
|
+
onFocus: onFocusProp,
|
|
7247
|
+
onKeyUp,
|
|
7248
|
+
onMenuAction,
|
|
7249
|
+
onMenuClose,
|
|
7250
|
+
orientation,
|
|
7251
|
+
selected,
|
|
7252
|
+
showMenuButton = closeable || editable,
|
|
7253
|
+
tabIndex,
|
|
7254
|
+
...props
|
|
7255
|
+
}, ref) {
|
|
7256
|
+
if (showMenuButton && typeof onMenuAction !== "function") {
|
|
7257
|
+
throw Error("Tab onMenuAction must be provided if showMenuButton is set");
|
|
7258
|
+
}
|
|
7259
|
+
const rootRef = useRef21(null);
|
|
7260
|
+
const editableRef = useRef21(null);
|
|
7261
|
+
const setForkRef = useForkRef5(ref, rootRef);
|
|
7262
|
+
const handleClick = useCallback28(
|
|
7263
|
+
(e) => {
|
|
7264
|
+
if (!editing) {
|
|
7265
|
+
e.preventDefault();
|
|
7266
|
+
onClick == null ? void 0 : onClick(e, index);
|
|
7267
|
+
}
|
|
7268
|
+
},
|
|
7269
|
+
[editing, index, onClick]
|
|
7270
|
+
);
|
|
7271
|
+
const handleOnExitEditMode = (originalValue = "", editedValue = "", allowDeactivation = true) => onExitEditMode(originalValue, editedValue, allowDeactivation, index);
|
|
7272
|
+
const handleKeyUp = (e) => {
|
|
7273
|
+
switch (e.key) {
|
|
7274
|
+
case "Backspace":
|
|
7275
|
+
case "Delete":
|
|
7276
|
+
if (closeable) {
|
|
7277
|
+
e.stopPropagation();
|
|
7278
|
+
onClose && onClose(index);
|
|
7279
|
+
}
|
|
7280
|
+
break;
|
|
7281
|
+
default:
|
|
7282
|
+
onKeyUp && onKeyUp(e, index);
|
|
7283
|
+
}
|
|
7284
|
+
};
|
|
7285
|
+
const getLabel = () => {
|
|
7286
|
+
if (editable) {
|
|
7287
|
+
return /* @__PURE__ */ jsx22(
|
|
7288
|
+
EditableLabel,
|
|
7289
|
+
{
|
|
7290
|
+
editing,
|
|
7291
|
+
defaultValue: label,
|
|
7292
|
+
onEnterEditMode,
|
|
7293
|
+
onExitEditMode: handleOnExitEditMode,
|
|
7294
|
+
ref: editableRef
|
|
7295
|
+
},
|
|
7296
|
+
label
|
|
7297
|
+
);
|
|
7298
|
+
} else {
|
|
7299
|
+
return label;
|
|
7300
|
+
}
|
|
7301
|
+
};
|
|
7302
|
+
const handleFocus = (evt) => {
|
|
7303
|
+
if (editableRef.current) {
|
|
7304
|
+
const editable2 = editableRef.current;
|
|
7305
|
+
const input = editable2.querySelector(
|
|
7306
|
+
".vuuEditableLabel-input"
|
|
7307
|
+
);
|
|
7308
|
+
input == null ? void 0 : input.focus();
|
|
7309
|
+
}
|
|
7310
|
+
onFocusProp == null ? void 0 : onFocusProp(evt);
|
|
7311
|
+
};
|
|
7312
|
+
return /* @__PURE__ */ jsxs5(
|
|
7313
|
+
"div",
|
|
7314
|
+
{
|
|
7315
|
+
...props,
|
|
7316
|
+
"aria-controls": ariaControls,
|
|
7317
|
+
"aria-selected": selected,
|
|
7318
|
+
className: cx11(classBase10, {
|
|
7319
|
+
[`${classBase10}-closeable`]: closeable,
|
|
7320
|
+
"vuuDraggable-dragAway": dragging,
|
|
7321
|
+
[`${classBase10}-editing`]: editing,
|
|
7322
|
+
[`${classBase10}-selected`]: selected || void 0,
|
|
7323
|
+
[`${classBase10}-vertical`]: orientation === "vertical",
|
|
7324
|
+
[`saltFocusVisible`]: focusVisible
|
|
7325
|
+
}),
|
|
7326
|
+
onClick: handleClick,
|
|
7327
|
+
onFocus: handleFocus,
|
|
7328
|
+
onKeyUp: handleKeyUp,
|
|
7329
|
+
ref: setForkRef,
|
|
7330
|
+
role: "tab",
|
|
7331
|
+
tabIndex,
|
|
7332
|
+
children: [
|
|
7333
|
+
/* @__PURE__ */ jsx22("div", { className: `${classBase10}-main`, children: /* @__PURE__ */ jsx22(
|
|
7334
|
+
"span",
|
|
7335
|
+
{
|
|
7336
|
+
className: `${classBase10}-text`,
|
|
7337
|
+
"data-text": editable ? void 0 : label,
|
|
7338
|
+
children: children != null ? children : getLabel()
|
|
7339
|
+
}
|
|
7340
|
+
) }),
|
|
7341
|
+
showMenuButton ? /* @__PURE__ */ jsx22(
|
|
7342
|
+
TabMenu,
|
|
7343
|
+
{
|
|
7344
|
+
allowClose: closeable,
|
|
7345
|
+
allowRename: editable,
|
|
7346
|
+
location,
|
|
7347
|
+
onMenuAction,
|
|
7348
|
+
onMenuClose,
|
|
7349
|
+
index
|
|
7350
|
+
}
|
|
7351
|
+
) : null
|
|
7352
|
+
]
|
|
7353
|
+
}
|
|
7354
|
+
);
|
|
7355
|
+
});
|
|
7356
|
+
|
|
7357
|
+
// src/layout-header/Header.tsx
|
|
7358
|
+
import { jsx as jsx23, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
7359
|
+
var Header = ({
|
|
7360
|
+
className: classNameProp,
|
|
7361
|
+
contributions,
|
|
7362
|
+
collapsed,
|
|
7363
|
+
closeable,
|
|
7364
|
+
onEditTitle,
|
|
7365
|
+
orientation: orientationProp = "horizontal",
|
|
7366
|
+
style,
|
|
7367
|
+
title = "Untitled"
|
|
7368
|
+
}) => {
|
|
7369
|
+
const labelFieldRef = useRef22(null);
|
|
7370
|
+
const [value, setValue] = useState11(title);
|
|
7371
|
+
const [editing, setEditing] = useState11(false);
|
|
7372
|
+
const viewDispatch = useViewDispatch();
|
|
7373
|
+
const handleClose = (evt) => viewDispatch == null ? void 0 : viewDispatch({ type: "remove" }, evt);
|
|
7374
|
+
const classBase14 = "vuuHeader";
|
|
7375
|
+
const handleTitleMouseDown = () => {
|
|
7376
|
+
var _a;
|
|
7377
|
+
(_a = labelFieldRef.current) == null ? void 0 : _a.focus();
|
|
7378
|
+
};
|
|
7379
|
+
const handleButtonMouseDown = (evt) => {
|
|
7380
|
+
evt.stopPropagation();
|
|
7381
|
+
};
|
|
7382
|
+
const orientation = collapsed || orientationProp;
|
|
7383
|
+
const className = classnames2(
|
|
7384
|
+
classBase14,
|
|
7385
|
+
classNameProp,
|
|
7386
|
+
`${classBase14}-${orientation}`
|
|
7387
|
+
);
|
|
7388
|
+
const handleEnterEditMode = () => {
|
|
7389
|
+
setEditing(true);
|
|
7390
|
+
};
|
|
7391
|
+
const handleTitleKeyDown = (evt) => {
|
|
7392
|
+
if (evt.key === "Enter") {
|
|
7393
|
+
setEditing(true);
|
|
7394
|
+
}
|
|
7395
|
+
};
|
|
7396
|
+
const handleExitEditMode = (originalValue = "", finalValue = "", allowDeactivation = true, editCancelled = false) => {
|
|
7397
|
+
var _a;
|
|
7398
|
+
setEditing(false);
|
|
7399
|
+
if (editCancelled) {
|
|
7400
|
+
setValue(originalValue);
|
|
7401
|
+
} else if (finalValue !== originalValue) {
|
|
7402
|
+
setValue(finalValue);
|
|
7403
|
+
onEditTitle == null ? void 0 : onEditTitle(finalValue);
|
|
7404
|
+
}
|
|
7405
|
+
if (allowDeactivation === false) {
|
|
7406
|
+
(_a = labelFieldRef.current) == null ? void 0 : _a.focus();
|
|
7407
|
+
}
|
|
7408
|
+
};
|
|
7409
|
+
const handleMouseDown = (e) => {
|
|
7410
|
+
viewDispatch == null ? void 0 : viewDispatch({ type: "mousedown" }, e);
|
|
7411
|
+
};
|
|
7412
|
+
const toolbarItems = [];
|
|
7413
|
+
const postTitleContributedItems = [];
|
|
7414
|
+
const actionButtons = [];
|
|
7415
|
+
contributions == null ? void 0 : contributions.forEach((contribution, i) => {
|
|
7416
|
+
switch (contribution.location) {
|
|
7417
|
+
case "pre-title":
|
|
7418
|
+
toolbarItems.push(React17.cloneElement(contribution.content, { key: i }));
|
|
7419
|
+
break;
|
|
7420
|
+
default:
|
|
7421
|
+
postTitleContributedItems.push(
|
|
7422
|
+
React17.cloneElement(contribution.content, { key: i })
|
|
7423
|
+
);
|
|
7424
|
+
}
|
|
7425
|
+
});
|
|
7426
|
+
title && toolbarItems.push(
|
|
7427
|
+
/* @__PURE__ */ jsx23(ToolbarField, { className: "vuuHeader-title", children: /* @__PURE__ */ jsx23(
|
|
7428
|
+
EditableLabel,
|
|
7429
|
+
{
|
|
7430
|
+
editing,
|
|
7431
|
+
value,
|
|
7432
|
+
onChange: setValue,
|
|
7433
|
+
onMouseDownCapture: handleTitleMouseDown,
|
|
7434
|
+
onEnterEditMode: handleEnterEditMode,
|
|
7435
|
+
onExitEditMode: handleExitEditMode,
|
|
7436
|
+
onKeyDown: handleTitleKeyDown,
|
|
7437
|
+
ref: labelFieldRef,
|
|
7438
|
+
tabIndex: 0
|
|
7439
|
+
},
|
|
7440
|
+
"title"
|
|
7441
|
+
) }, "title")
|
|
7442
|
+
);
|
|
7443
|
+
closeable && actionButtons.push(
|
|
7444
|
+
/* @__PURE__ */ jsxs6(
|
|
7445
|
+
ToolbarButton,
|
|
7446
|
+
{
|
|
7447
|
+
onClick: handleClose,
|
|
7448
|
+
onMouseDown: handleButtonMouseDown,
|
|
7449
|
+
children: [
|
|
7450
|
+
/* @__PURE__ */ jsx23(CloseIcon, {}),
|
|
7451
|
+
" Close"
|
|
7452
|
+
]
|
|
7453
|
+
},
|
|
7454
|
+
"close"
|
|
7455
|
+
)
|
|
7456
|
+
);
|
|
7457
|
+
postTitleContributedItems.length > 0 && toolbarItems.push(
|
|
7458
|
+
/* @__PURE__ */ jsx23(Tooltray, { "data-align-end": true, children: postTitleContributedItems }, "contributions")
|
|
7459
|
+
);
|
|
7460
|
+
actionButtons.length > 0 && toolbarItems.push(
|
|
7461
|
+
/* @__PURE__ */ jsx23(Tooltray, { "data-align-end": true, children: actionButtons }, "actions")
|
|
7462
|
+
);
|
|
7463
|
+
return /* @__PURE__ */ jsx23(
|
|
7464
|
+
Toolbar,
|
|
7465
|
+
{
|
|
7466
|
+
className,
|
|
7467
|
+
orientation: orientationProp,
|
|
7468
|
+
style,
|
|
7469
|
+
onMouseDown: handleMouseDown,
|
|
7470
|
+
children: toolbarItems
|
|
7471
|
+
}
|
|
7472
|
+
);
|
|
7473
|
+
};
|
|
7474
|
+
|
|
7475
|
+
// src/overflow-container/OverflowContainer.tsx
|
|
7476
|
+
import React18, {
|
|
7477
|
+
forwardRef as forwardRef9
|
|
7478
|
+
} from "react";
|
|
7479
|
+
import cx12 from "classnames";
|
|
7480
|
+
import { PopupMenu as PopupMenu2 } from "@vuu-ui/vuu-popups";
|
|
7481
|
+
|
|
7482
|
+
// src/overflow-container/useOverflowContainer.ts
|
|
7483
|
+
import { useCallback as useCallback29, useMemo as useMemo14, useRef as useRef23, useState as useState12 } from "react";
|
|
7484
|
+
|
|
7485
|
+
// src/overflow-container/overflow-utils.ts
|
|
7486
|
+
var NON_WRAPPED_ITEM = ".vuuOverflowContainer-item:not(.wrapped)";
|
|
7487
|
+
var sortByScreenOrder = (elements) => elements.sort((e1, e2) => {
|
|
7488
|
+
const {
|
|
7489
|
+
dataset: { index: idx1 = "?" }
|
|
7490
|
+
} = e1;
|
|
7491
|
+
const {
|
|
7492
|
+
dataset: { index: idx2 = "?" }
|
|
7493
|
+
} = e2;
|
|
7494
|
+
const isOverflowed1 = e1.classList.contains("wrapped");
|
|
7495
|
+
const isOverflowed2 = e2.classList.contains("wrapped");
|
|
7496
|
+
const isOverflowedIndicator1 = idx1 === "overflow";
|
|
7497
|
+
const isOverflowedIndicator2 = idx2 === "overflow";
|
|
7498
|
+
if (isOverflowed1 && !isOverflowed2) {
|
|
7499
|
+
return 1;
|
|
7500
|
+
} else if (!isOverflowed1 && isOverflowed2) {
|
|
7501
|
+
return -1;
|
|
7502
|
+
}
|
|
7503
|
+
if (isOverflowedIndicator1) {
|
|
7504
|
+
return 1;
|
|
7505
|
+
} else if (isOverflowedIndicator2) {
|
|
7506
|
+
return -1;
|
|
7507
|
+
}
|
|
7508
|
+
return parseInt(idx1) > parseInt(idx2) ? 1 : -1;
|
|
7509
|
+
});
|
|
7510
|
+
var NO_WRAPPED_ITEMS = [];
|
|
7511
|
+
var getNonWrappedAndWrappedItems = (container) => {
|
|
7512
|
+
const nonWrappedItems = [];
|
|
7513
|
+
const wrappedItems = [];
|
|
7514
|
+
let currentLeft = -1;
|
|
7515
|
+
let overflowed = false;
|
|
7516
|
+
const sortedChildren = sortByScreenOrder(
|
|
7517
|
+
Array.from(container.children)
|
|
7518
|
+
);
|
|
7519
|
+
for (const child of sortedChildren) {
|
|
7520
|
+
const element = child;
|
|
7521
|
+
const {
|
|
7522
|
+
dataset: { index = "?", label = "?", overflowPriority = "0" }
|
|
7523
|
+
} = element;
|
|
7524
|
+
const { left } = element.getBoundingClientRect();
|
|
7525
|
+
if (left <= currentLeft) {
|
|
7526
|
+
if (index === "overflow") {
|
|
7527
|
+
wrappedItems.push(nonWrappedItems.pop());
|
|
7528
|
+
} else {
|
|
7529
|
+
wrappedItems.push({ index, label, overflowPriority });
|
|
7530
|
+
}
|
|
7531
|
+
overflowed = true;
|
|
7532
|
+
} else if (overflowed) {
|
|
7533
|
+
wrappedItems.push({ index, label, overflowPriority });
|
|
7534
|
+
} else {
|
|
7535
|
+
nonWrappedItems.push({ index, label, overflowPriority });
|
|
7536
|
+
}
|
|
7537
|
+
currentLeft = left;
|
|
7538
|
+
}
|
|
7539
|
+
return [nonWrappedItems, wrappedItems];
|
|
7540
|
+
};
|
|
7541
|
+
var applyOverflowClassToWrappedItems = (container, overflowedItems) => {
|
|
7542
|
+
let ignoreOverflow = false;
|
|
7543
|
+
if (overflowedItems.find(({ index }) => index === "overflow")) {
|
|
7544
|
+
if (overflowedItems.length === 1) {
|
|
7545
|
+
ignoreOverflow = true;
|
|
7546
|
+
}
|
|
7547
|
+
}
|
|
7548
|
+
for (const element of container.children) {
|
|
7549
|
+
const {
|
|
7550
|
+
dataset: { index = "?" }
|
|
7551
|
+
} = element;
|
|
7552
|
+
if (overflowedItems.length === 0 || ignoreOverflow) {
|
|
7553
|
+
container.classList.remove("overflowed");
|
|
7554
|
+
} else {
|
|
7555
|
+
container.classList.add("overflowed");
|
|
7556
|
+
}
|
|
7557
|
+
if (index !== "overflow" && overflowedItems.find((item) => item.index === index)) {
|
|
7558
|
+
element.classList.add("wrapped");
|
|
7559
|
+
} else {
|
|
7560
|
+
element.classList.remove("wrapped");
|
|
7561
|
+
}
|
|
7562
|
+
}
|
|
7563
|
+
};
|
|
7564
|
+
var maxPriority = (priority, { overflowPriority }) => Math.max(priority, parseInt(overflowPriority));
|
|
7565
|
+
var minPriority = (priority, { overflowPriority }) => Math.min(priority, parseInt(overflowPriority));
|
|
7566
|
+
var overflowIndicatorHasWrappedButShouldNotHave = (wrappedItems) => {
|
|
7567
|
+
var _a;
|
|
7568
|
+
return wrappedItems.length > 1 && ((_a = wrappedItems.at(-1)) == null ? void 0 : _a.index) === "overflow";
|
|
7569
|
+
};
|
|
7570
|
+
var getHighestPriorityItem = (overflowItems) => {
|
|
7571
|
+
let [highestPriorityItem] = overflowItems;
|
|
7572
|
+
for (let i = 1; i < overflowItems.length; i++) {
|
|
7573
|
+
const item = overflowItems[i];
|
|
7574
|
+
if (parseInt(item.overflowPriority) > parseInt(highestPriorityItem.overflowPriority)) {
|
|
7575
|
+
highestPriorityItem = item;
|
|
7576
|
+
}
|
|
7577
|
+
}
|
|
7578
|
+
return highestPriorityItem;
|
|
7579
|
+
};
|
|
7580
|
+
var highPriorityItemsHaveWrappedButShouldNotHave = (nonWrappedItems, wrappedItems) => {
|
|
7581
|
+
var _a;
|
|
7582
|
+
const minNonwrappedPriority = nonWrappedItems.reduce(
|
|
7583
|
+
minPriority,
|
|
7584
|
+
Number.MAX_SAFE_INTEGER
|
|
7585
|
+
);
|
|
7586
|
+
const maxwrappedPriority = wrappedItems.reduce(maxPriority, 0);
|
|
7587
|
+
if (maxwrappedPriority > minNonwrappedPriority) {
|
|
7588
|
+
return true;
|
|
7589
|
+
} else {
|
|
7590
|
+
return wrappedItems.length > 1 && ((_a = wrappedItems.at(-1)) == null ? void 0 : _a.index) === "overflow";
|
|
7591
|
+
}
|
|
7592
|
+
};
|
|
7593
|
+
var correctForWrappedOverflowIndicator = (container, overflowedItems) => new Promise((resolve) => {
|
|
7594
|
+
requestAnimationFrame(() => {
|
|
7595
|
+
const [, o2] = getNonWrappedAndWrappedItems(container);
|
|
7596
|
+
const newlyOverflowed = getNewItems(overflowedItems, o2);
|
|
7597
|
+
newlyOverflowed.forEach((item) => markElementAsWrapped(container, item));
|
|
7598
|
+
resolve(o2);
|
|
7599
|
+
});
|
|
7600
|
+
});
|
|
7601
|
+
var correctForWrappedHighPriorityItems = (container, nonWrapped, wrapped) => new Promise((resolve) => {
|
|
7602
|
+
requestAnimationFrame(() => {
|
|
7603
|
+
const [, o2] = getNonWrappedAndWrappedItems(container);
|
|
7604
|
+
const highPriorityWrappedItem = getHighestPriorityItem(o2);
|
|
7605
|
+
if (highPriorityWrappedItem) {
|
|
7606
|
+
const [nonWrappedItems, wrappedItems] = switchWrappedItemIntoView(
|
|
7607
|
+
container,
|
|
7608
|
+
highPriorityWrappedItem
|
|
7609
|
+
);
|
|
7610
|
+
resolve([nonWrappedItems, wrappedItems]);
|
|
7611
|
+
} else {
|
|
7612
|
+
resolve([nonWrapped, wrapped]);
|
|
7613
|
+
}
|
|
7614
|
+
});
|
|
7615
|
+
});
|
|
7616
|
+
var getElementByIndex = (container, item) => container.querySelector(`[data-index="${item.index}"]`);
|
|
7617
|
+
var markElementAsWrapped = (container, item) => {
|
|
7618
|
+
const el = getElementByIndex(container, item);
|
|
7619
|
+
if (el) {
|
|
7620
|
+
el.classList.add("wrapped");
|
|
7621
|
+
} else {
|
|
7622
|
+
throw Error(
|
|
7623
|
+
`markElementAsWrapped element item with index ${item.index} not found`
|
|
7624
|
+
);
|
|
7625
|
+
}
|
|
7626
|
+
};
|
|
7627
|
+
var getElementsMarkedAsWrapped = (container) => Array.from(container.querySelectorAll(".wrapped"));
|
|
7628
|
+
var getNewItems = (items1, items2) => {
|
|
7629
|
+
const newItems = [];
|
|
7630
|
+
for (const item of items2) {
|
|
7631
|
+
if (!items1.find(({ index }) => index === item.index)) {
|
|
7632
|
+
newItems.push(item);
|
|
7633
|
+
}
|
|
7634
|
+
}
|
|
7635
|
+
return newItems;
|
|
7636
|
+
};
|
|
7637
|
+
var unmarkItemsWhichAreNoLongerWrapped = (container, wrappedItems) => {
|
|
7638
|
+
const elementssMarkedAsWrapped = getElementsMarkedAsWrapped(container);
|
|
7639
|
+
elementssMarkedAsWrapped.forEach((el) => {
|
|
7640
|
+
const {
|
|
7641
|
+
dataset: { index = "?" }
|
|
7642
|
+
} = el;
|
|
7643
|
+
if (!wrappedItems.find((i) => i.index === index)) {
|
|
7644
|
+
el.classList.remove("wrapped");
|
|
7645
|
+
}
|
|
7646
|
+
});
|
|
7647
|
+
};
|
|
7648
|
+
var getOverflowIndicator = (container) => container.querySelector('[data-index="overflow"]');
|
|
7649
|
+
var getOverflowedItem = (container) => container.querySelector(".wrapped");
|
|
7650
|
+
var getElementWidth = (el) => parseInt(getComputedStyle(el).getPropertyValue("width"));
|
|
7651
|
+
var getAvailableSpace = (container, overflowIndicator) => {
|
|
7652
|
+
const { right: containerRight } = container.getBoundingClientRect();
|
|
7653
|
+
const paddingRight = parseInt(
|
|
7654
|
+
getComputedStyle(container).getPropertyValue("padding-right")
|
|
7655
|
+
);
|
|
7656
|
+
const { right: indicatorRight } = overflowIndicator.getBoundingClientRect();
|
|
7657
|
+
return containerRight - paddingRight - indicatorRight;
|
|
7658
|
+
};
|
|
7659
|
+
var removeOverflowIndicatorIfNoLongerNeeded = (container) => {
|
|
7660
|
+
const overflowIndicator = getOverflowIndicator(container);
|
|
7661
|
+
const availableSpace = getAvailableSpace(container, overflowIndicator);
|
|
7662
|
+
const indicatorWidth = getElementWidth(overflowIndicator);
|
|
7663
|
+
const overflowedItem = getOverflowedItem(container);
|
|
7664
|
+
const overflowWidth = getElementWidth(overflowedItem);
|
|
7665
|
+
if (overflowWidth <= availableSpace + indicatorWidth) {
|
|
7666
|
+
container.classList.remove("overflowed");
|
|
7667
|
+
overflowedItem.classList.remove("wrapped");
|
|
7668
|
+
return true;
|
|
7669
|
+
}
|
|
7670
|
+
return false;
|
|
7671
|
+
};
|
|
7672
|
+
var byPriorityDescending = (h1, h2) => {
|
|
7673
|
+
const {
|
|
7674
|
+
dataset: { index: i1 = "0", overflowPriority: p1 = "0" }
|
|
7675
|
+
} = h1;
|
|
7676
|
+
const {
|
|
7677
|
+
dataset: { index: i2 = "0", overflowPriority: p2 = "0" }
|
|
7678
|
+
} = h2;
|
|
7679
|
+
if (p1 > p2) {
|
|
7680
|
+
return -1;
|
|
7681
|
+
} else if (p1 < p2) {
|
|
7682
|
+
return 1;
|
|
7683
|
+
} else {
|
|
7684
|
+
return parseInt(i1) - parseInt(i2);
|
|
7685
|
+
}
|
|
7686
|
+
};
|
|
7687
|
+
var getNonwrappedItemsByPriority = (container) => Array.from(container.querySelectorAll(NON_WRAPPED_ITEM)).sort(
|
|
7688
|
+
byPriorityDescending
|
|
7689
|
+
);
|
|
7690
|
+
var switchWrappedItemIntoView = (container, overflowItem) => {
|
|
7691
|
+
const unwrappedItems = getNonwrappedItemsByPriority(container);
|
|
7692
|
+
const targetElement = getElementByIndex(container, overflowItem);
|
|
7693
|
+
let pos = -1;
|
|
7694
|
+
let unwrappedItem = unwrappedItems.at(pos);
|
|
7695
|
+
const itemWidth = getElementWidth(unwrappedItem);
|
|
7696
|
+
const targetWidth = getElementWidth(targetElement);
|
|
7697
|
+
const overflowIndicator = getOverflowIndicator(container);
|
|
7698
|
+
let availableSpace = getAvailableSpace(container, overflowIndicator) + itemWidth;
|
|
7699
|
+
if (availableSpace >= targetWidth) {
|
|
7700
|
+
switchWrapOnElements(targetElement, unwrappedItem);
|
|
7701
|
+
} else {
|
|
7702
|
+
const { left: lastLeft } = unwrappedItem.getBoundingClientRect();
|
|
7703
|
+
const baseAvailableSpace = availableSpace;
|
|
7704
|
+
const wrapTargets = [unwrappedItem];
|
|
7705
|
+
while (availableSpace < targetWidth) {
|
|
7706
|
+
pos -= 1;
|
|
7707
|
+
unwrappedItem = unwrappedItems.at(pos);
|
|
7708
|
+
wrapTargets.push(unwrappedItem);
|
|
7709
|
+
const { left: nextLeft } = unwrappedItem.getBoundingClientRect();
|
|
7710
|
+
const extraSpace = lastLeft - nextLeft;
|
|
7711
|
+
availableSpace = baseAvailableSpace + extraSpace;
|
|
7712
|
+
}
|
|
7713
|
+
targetElement == null ? void 0 : targetElement.classList.remove("wrapped");
|
|
7714
|
+
wrapTargets.forEach((item) => {
|
|
7715
|
+
item.classList.add("wrapped");
|
|
7716
|
+
});
|
|
7717
|
+
}
|
|
7718
|
+
const [nonWrappedItems, wrappedItems] = getNonWrappedAndWrappedItems(container);
|
|
7719
|
+
unmarkItemsWhichAreNoLongerWrapped(container, wrappedItems);
|
|
7720
|
+
return [nonWrappedItems, wrappedItems];
|
|
7721
|
+
};
|
|
7722
|
+
var switchWrapOnElements = (wrappedElement, nonWrappedElement) => {
|
|
7723
|
+
if (!wrappedElement || !nonWrappedElement) {
|
|
7724
|
+
throw Error("switchWrapOnElements, element undefined");
|
|
7725
|
+
}
|
|
7726
|
+
wrappedElement.classList.remove("wrapped");
|
|
7727
|
+
nonWrappedElement.classList.add("wrapped");
|
|
7728
|
+
};
|
|
7729
|
+
|
|
7730
|
+
// src/overflow-container/useOverflowContainer.ts
|
|
7731
|
+
var useOverflowContainer = ({
|
|
7732
|
+
itemCount,
|
|
7733
|
+
onSwitchWrappedItemIntoView
|
|
7734
|
+
}) => {
|
|
7735
|
+
const [container, setContainer] = useState12(null);
|
|
7736
|
+
const wrappedItemsRef = useRef23(NO_WRAPPED_ITEMS);
|
|
7737
|
+
const handleResize = useCallback29(async () => {
|
|
7738
|
+
if (container) {
|
|
7739
|
+
let [nonWrapped, wrapped] = getNonWrappedAndWrappedItems(container);
|
|
7740
|
+
applyOverflowClassToWrappedItems(container, wrapped);
|
|
7741
|
+
if (overflowIndicatorHasWrappedButShouldNotHave(wrapped)) {
|
|
7742
|
+
wrapped = await correctForWrappedOverflowIndicator(container, wrapped);
|
|
7743
|
+
}
|
|
7744
|
+
while (highPriorityItemsHaveWrappedButShouldNotHave(nonWrapped, wrapped)) {
|
|
7745
|
+
[nonWrapped, wrapped] = await correctForWrappedHighPriorityItems(
|
|
7746
|
+
container,
|
|
7747
|
+
nonWrapped,
|
|
7748
|
+
wrapped
|
|
7749
|
+
);
|
|
7750
|
+
}
|
|
7751
|
+
if (wrapped.length === 1) {
|
|
7752
|
+
if (removeOverflowIndicatorIfNoLongerNeeded(container)) {
|
|
7753
|
+
wrapped = NO_WRAPPED_ITEMS;
|
|
7754
|
+
}
|
|
7755
|
+
}
|
|
7756
|
+
wrappedItemsRef.current = wrapped;
|
|
7757
|
+
}
|
|
7758
|
+
}, [container]);
|
|
7759
|
+
const hasOverflowItem = (opt) => typeof opt === "object" && opt !== null && "overflowItem" in opt;
|
|
7760
|
+
const [menuBuilder, menuActionHandler] = useMemo14(() => {
|
|
7761
|
+
return [
|
|
7762
|
+
() => {
|
|
7763
|
+
const { current: menuItems } = wrappedItemsRef;
|
|
7764
|
+
return menuItems.map((item) => {
|
|
7765
|
+
return {
|
|
7766
|
+
label: item.label,
|
|
7767
|
+
action: `activate-item-${item.index}`,
|
|
7768
|
+
options: { overflowItem: item }
|
|
7769
|
+
};
|
|
7770
|
+
});
|
|
7771
|
+
},
|
|
7772
|
+
({ options }) => {
|
|
7773
|
+
if (container && hasOverflowItem(options)) {
|
|
7774
|
+
const [, wrappedItems] = switchWrappedItemIntoView(
|
|
7775
|
+
container,
|
|
7776
|
+
options.overflowItem
|
|
7777
|
+
);
|
|
7778
|
+
wrappedItemsRef.current = wrappedItems;
|
|
7779
|
+
onSwitchWrappedItemIntoView == null ? void 0 : onSwitchWrappedItemIntoView(options.overflowItem);
|
|
7780
|
+
}
|
|
7781
|
+
return true;
|
|
7782
|
+
}
|
|
7783
|
+
];
|
|
7784
|
+
}, [container, onSwitchWrappedItemIntoView]);
|
|
7785
|
+
const resizeObserver2 = useMemo14(() => {
|
|
7786
|
+
let currentWidth = 0;
|
|
7787
|
+
return new ResizeObserver((entries) => {
|
|
7788
|
+
for (const entry of entries) {
|
|
7789
|
+
const { width } = entry.contentRect;
|
|
7790
|
+
if (currentWidth !== width) {
|
|
7791
|
+
currentWidth = width;
|
|
7792
|
+
handleResize();
|
|
7793
|
+
}
|
|
7794
|
+
}
|
|
7795
|
+
});
|
|
7796
|
+
}, [handleResize]);
|
|
7797
|
+
useLayoutEffectSkipFirst(() => {
|
|
7798
|
+
handleResize();
|
|
7799
|
+
}, [handleResize, itemCount]);
|
|
7800
|
+
useMemo14(() => {
|
|
7801
|
+
if (container) {
|
|
7802
|
+
resizeObserver2.observe(container);
|
|
7803
|
+
}
|
|
7804
|
+
}, [container, resizeObserver2]);
|
|
7805
|
+
const callbackRef = useCallback29((el) => {
|
|
7806
|
+
setContainer(el);
|
|
7807
|
+
}, []);
|
|
7808
|
+
return {
|
|
7809
|
+
menuActionHandler,
|
|
7810
|
+
menuBuilder,
|
|
7811
|
+
rootRef: callbackRef
|
|
7812
|
+
};
|
|
7813
|
+
};
|
|
7814
|
+
|
|
7815
|
+
// src/overflow-container/OverflowContainer.tsx
|
|
7816
|
+
import { jsx as jsx24, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
7817
|
+
var classBase11 = "vuuOverflowContainer";
|
|
7818
|
+
var WrapContainer = React18.memo(
|
|
7819
|
+
({
|
|
7820
|
+
children,
|
|
7821
|
+
height,
|
|
7822
|
+
onSwitchWrappedItemIntoView,
|
|
7823
|
+
overflowIcon
|
|
7824
|
+
}) => {
|
|
7825
|
+
const childElements = asReactElements(children);
|
|
7826
|
+
const { menuActionHandler, menuBuilder, rootRef } = useOverflowContainer({
|
|
7827
|
+
itemCount: childElements.length,
|
|
7828
|
+
onSwitchWrappedItemIntoView
|
|
7829
|
+
});
|
|
7830
|
+
const style = {
|
|
7831
|
+
"--overflow-container-height": `${height}px`
|
|
7832
|
+
};
|
|
7833
|
+
return /* @__PURE__ */ jsxs7("div", { className: `${classBase11}-wrapContainer`, ref: rootRef, style, children: [
|
|
7834
|
+
childElements.map((childEl, i) => {
|
|
7835
|
+
const {
|
|
7836
|
+
"data-overflow-priority": overflowPriority = "0",
|
|
7837
|
+
id: itemId,
|
|
7838
|
+
label = `Item ${i + 1}`
|
|
7839
|
+
} = childEl.props;
|
|
7840
|
+
return /* @__PURE__ */ jsx24(
|
|
7841
|
+
"div",
|
|
7842
|
+
{
|
|
7843
|
+
className: cx12(`${classBase11}-item`),
|
|
7844
|
+
"data-index": i,
|
|
7845
|
+
"data-label": label,
|
|
7846
|
+
"data-overflow-priority": overflowPriority,
|
|
7847
|
+
id: `${itemId}-wrapper`,
|
|
7848
|
+
children: childEl
|
|
7849
|
+
},
|
|
7850
|
+
i
|
|
7851
|
+
);
|
|
7852
|
+
}),
|
|
7853
|
+
/* @__PURE__ */ jsx24("div", { className: `${classBase11}-OverflowIndicator`, "data-index": "overflow", children: /* @__PURE__ */ jsx24(
|
|
7854
|
+
PopupMenu2,
|
|
7855
|
+
{
|
|
7856
|
+
icon: overflowIcon,
|
|
7857
|
+
menuBuilder,
|
|
7858
|
+
menuActionHandler
|
|
7859
|
+
}
|
|
7860
|
+
) })
|
|
7861
|
+
] });
|
|
7862
|
+
}
|
|
7863
|
+
);
|
|
7864
|
+
WrapContainer.displayName = "OverflowContainer.InnerContainer";
|
|
7865
|
+
var OverflowContainer = forwardRef9(function OverflowContainer2({
|
|
7866
|
+
children,
|
|
7867
|
+
className,
|
|
7868
|
+
height = 44,
|
|
7869
|
+
onSwitchWrappedItemIntoView,
|
|
7870
|
+
overflowIcon,
|
|
7871
|
+
...htmlAttributes
|
|
7872
|
+
}, forwardedRef) {
|
|
7873
|
+
return /* @__PURE__ */ jsx24(
|
|
7874
|
+
"div",
|
|
7875
|
+
{
|
|
7876
|
+
...htmlAttributes,
|
|
7877
|
+
className: cx12(cx12(classBase11, className)),
|
|
7878
|
+
ref: forwardedRef,
|
|
7879
|
+
children: /* @__PURE__ */ jsx24(
|
|
7880
|
+
WrapContainer,
|
|
7881
|
+
{
|
|
7882
|
+
height,
|
|
7883
|
+
overflowIcon,
|
|
7884
|
+
onSwitchWrappedItemIntoView,
|
|
7885
|
+
children
|
|
7886
|
+
}
|
|
7887
|
+
)
|
|
7888
|
+
}
|
|
7889
|
+
);
|
|
7890
|
+
});
|
|
7891
|
+
|
|
7892
|
+
// src/palette/Palette.tsx
|
|
7893
|
+
import { uuid as uuid5 } from "@vuu-ui/vuu-utils";
|
|
7894
|
+
import { List, ListItem } from "@heswell/salt-lab";
|
|
7895
|
+
import cx13 from "classnames";
|
|
7896
|
+
import {
|
|
7897
|
+
cloneElement as cloneElement5,
|
|
7898
|
+
memo
|
|
7899
|
+
} from "react";
|
|
7900
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
7901
|
+
var clonePaletteItem = (paletteItem) => {
|
|
7902
|
+
const dolly = paletteItem.cloneNode(true);
|
|
7903
|
+
dolly.id = "";
|
|
7904
|
+
delete dolly.dataset.idx;
|
|
7905
|
+
return dolly;
|
|
7906
|
+
};
|
|
7907
|
+
var PaletteItem = memo(
|
|
7908
|
+
({
|
|
7909
|
+
className,
|
|
7910
|
+
children: component,
|
|
7911
|
+
idx,
|
|
7912
|
+
resizeable,
|
|
7913
|
+
header,
|
|
7914
|
+
closeable,
|
|
7915
|
+
...props
|
|
7916
|
+
}) => {
|
|
7917
|
+
return /* @__PURE__ */ jsx25(
|
|
7918
|
+
ListItem,
|
|
7919
|
+
{
|
|
7920
|
+
className: cx13("vuuPaletteItem", className),
|
|
7921
|
+
"data-draggable": true,
|
|
7922
|
+
...props
|
|
7923
|
+
}
|
|
7924
|
+
);
|
|
7925
|
+
}
|
|
7926
|
+
);
|
|
4950
7927
|
PaletteItem.displayName = "PaletteItem";
|
|
4951
7928
|
var Palette = ({
|
|
4952
7929
|
children,
|
|
@@ -4956,7 +7933,7 @@ var Palette = ({
|
|
|
4956
7933
|
...props
|
|
4957
7934
|
}) => {
|
|
4958
7935
|
const dispatch = useLayoutProviderDispatch();
|
|
4959
|
-
const
|
|
7936
|
+
const classBase14 = "vuuPalette";
|
|
4960
7937
|
function handleMouseDown(evt) {
|
|
4961
7938
|
var _a;
|
|
4962
7939
|
const target = evt.target;
|
|
@@ -4975,7 +7952,7 @@ var Palette = ({
|
|
|
4975
7952
|
const { height, left, top, width } = listItemElement.getBoundingClientRect();
|
|
4976
7953
|
const id = uuid5();
|
|
4977
7954
|
const identifiers = { id, key: id };
|
|
4978
|
-
const component = template ? payload : /* @__PURE__ */
|
|
7955
|
+
const component = template ? payload : /* @__PURE__ */ jsx25(MemoView, { ...ViewProps2, ...identifiers, ...props2, title: props2.label, children: payload });
|
|
4979
7956
|
dispatch({
|
|
4980
7957
|
dragRect: {
|
|
4981
7958
|
left,
|
|
@@ -4998,16 +7975,16 @@ var Palette = ({
|
|
|
4998
7975
|
type: "drag-start"
|
|
4999
7976
|
});
|
|
5000
7977
|
}
|
|
5001
|
-
return /* @__PURE__ */
|
|
7978
|
+
return /* @__PURE__ */ jsx25(
|
|
5002
7979
|
List,
|
|
5003
7980
|
{
|
|
5004
7981
|
...props,
|
|
5005
7982
|
borderless: true,
|
|
5006
|
-
className:
|
|
7983
|
+
className: cx13(classBase14, className, `${classBase14}-${orientation}`),
|
|
5007
7984
|
maxHeight: 800,
|
|
5008
7985
|
selected: null,
|
|
5009
7986
|
children: children.map(
|
|
5010
|
-
(child, idx) => child.type === PaletteItem ?
|
|
7987
|
+
(child, idx) => child.type === PaletteItem ? cloneElement5(child, {
|
|
5011
7988
|
key: idx,
|
|
5012
7989
|
onMouseDown: handleMouseDown
|
|
5013
7990
|
}) : child
|
|
@@ -5020,9 +7997,9 @@ registerComponent("Palette", Palette, "view");
|
|
|
5020
7997
|
// src/palette/PaletteSalt.tsx
|
|
5021
7998
|
import { uuid as uuid6 } from "@vuu-ui/vuu-utils";
|
|
5022
7999
|
import { List as List2, ListItem as ListItem2 } from "@heswell/salt-lab";
|
|
5023
|
-
import
|
|
5024
|
-
import { jsx as
|
|
5025
|
-
var
|
|
8000
|
+
import cx14 from "classnames";
|
|
8001
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
8002
|
+
var classBase12 = "vuuPalette";
|
|
5026
8003
|
var PaletteListItem = (props) => {
|
|
5027
8004
|
const { children, ViewProps: ViewProps2, label, onMouseDown, template, ...restProps } = props;
|
|
5028
8005
|
const dispatch = useLayoutProviderDispatch();
|
|
@@ -5030,7 +8007,7 @@ var PaletteListItem = (props) => {
|
|
|
5030
8007
|
const { left, top, width } = evt.currentTarget.getBoundingClientRect();
|
|
5031
8008
|
const id = uuid6();
|
|
5032
8009
|
const identifiers = { id, key: id };
|
|
5033
|
-
const component = template ? children : /* @__PURE__ */
|
|
8010
|
+
const component = template ? children : /* @__PURE__ */ jsx26(MemoView, { ...identifiers, ...ViewProps2, title: props.label, children });
|
|
5034
8011
|
dispatch({
|
|
5035
8012
|
type: "drag-start",
|
|
5036
8013
|
evt: evt.nativeEvent,
|
|
@@ -5052,14 +8029,14 @@ var PaletteListItem = (props) => {
|
|
|
5052
8029
|
}
|
|
5053
8030
|
});
|
|
5054
8031
|
};
|
|
5055
|
-
return /* @__PURE__ */
|
|
8032
|
+
return /* @__PURE__ */ jsx26(ListItem2, { onMouseDown: handleMouseDown, ...restProps, children: label });
|
|
5056
8033
|
};
|
|
5057
8034
|
var PaletteSalt = ({ className, ...props }) => {
|
|
5058
|
-
return /* @__PURE__ */
|
|
8035
|
+
return /* @__PURE__ */ jsx26(
|
|
5059
8036
|
List2,
|
|
5060
8037
|
{
|
|
5061
8038
|
...props,
|
|
5062
|
-
className:
|
|
8039
|
+
className: cx14(classBase12, className),
|
|
5063
8040
|
height: "100%",
|
|
5064
8041
|
selectionStrategy: "none"
|
|
5065
8042
|
}
|
|
@@ -5068,15 +8045,13 @@ var PaletteSalt = ({ className, ...props }) => {
|
|
|
5068
8045
|
registerComponent("PaletteSalt", PaletteSalt, "view");
|
|
5069
8046
|
|
|
5070
8047
|
// src/stack/Stack.tsx
|
|
5071
|
-
import
|
|
5072
|
-
import {
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
forwardRef as forwardRef6,
|
|
5076
|
-
useCallback as useCallback15
|
|
8048
|
+
import cx15 from "classnames";
|
|
8049
|
+
import React19, {
|
|
8050
|
+
forwardRef as forwardRef10,
|
|
8051
|
+
useCallback as useCallback30
|
|
5077
8052
|
} from "react";
|
|
5078
|
-
import { jsx as
|
|
5079
|
-
var
|
|
8053
|
+
import { jsx as jsx27, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
8054
|
+
var classBase13 = "Tabs";
|
|
5080
8055
|
var getDefaultTabIcon = () => void 0;
|
|
5081
8056
|
var getDefaultTabLabel = (component, tabIndex) => {
|
|
5082
8057
|
var _a, _b;
|
|
@@ -5084,8 +8059,8 @@ var getDefaultTabLabel = (component, tabIndex) => {
|
|
|
5084
8059
|
};
|
|
5085
8060
|
var getChildElements = (children) => {
|
|
5086
8061
|
const elements = [];
|
|
5087
|
-
|
|
5088
|
-
if (
|
|
8062
|
+
React19.Children.forEach(children, (child) => {
|
|
8063
|
+
if (React19.isValidElement(child)) {
|
|
5089
8064
|
elements.push(child);
|
|
5090
8065
|
} else {
|
|
5091
8066
|
console.warn(`Stack has unexpected child element type`);
|
|
@@ -5093,50 +8068,33 @@ var getChildElements = (children) => {
|
|
|
5093
8068
|
});
|
|
5094
8069
|
return elements;
|
|
5095
8070
|
};
|
|
5096
|
-
var
|
|
8071
|
+
var DefaultTabstripProps = {
|
|
8072
|
+
allowAddTab: false,
|
|
8073
|
+
allowCloseTab: false,
|
|
8074
|
+
allowRenameTab: false
|
|
8075
|
+
};
|
|
8076
|
+
var Stack = forwardRef10(function Stack2({
|
|
5097
8077
|
active = 0,
|
|
5098
8078
|
children,
|
|
5099
8079
|
className: classNameProp,
|
|
5100
|
-
enableAddTab,
|
|
5101
|
-
enableCloseTabs,
|
|
5102
8080
|
getTabIcon = getDefaultTabIcon,
|
|
5103
8081
|
getTabLabel = getDefaultTabLabel,
|
|
5104
8082
|
id: idProp,
|
|
5105
8083
|
keyBoardActivation = "manual",
|
|
5106
|
-
onMouseDown,
|
|
5107
|
-
|
|
8084
|
+
// onMouseDown,
|
|
8085
|
+
onAddTab,
|
|
8086
|
+
onMoveTab,
|
|
5108
8087
|
onTabClose,
|
|
5109
8088
|
onTabEdit,
|
|
5110
8089
|
onTabSelectionChanged,
|
|
5111
|
-
showTabs,
|
|
8090
|
+
showTabs = true,
|
|
5112
8091
|
style,
|
|
5113
|
-
TabstripProps
|
|
8092
|
+
TabstripProps: TabstripProps2 = DefaultTabstripProps
|
|
5114
8093
|
}, ref) {
|
|
5115
8094
|
var _a;
|
|
5116
|
-
const id =
|
|
5117
|
-
const
|
|
5118
|
-
|
|
5119
|
-
};
|
|
5120
|
-
const handleTabClose = (tabIndex) => {
|
|
5121
|
-
onTabClose == null ? void 0 : onTabClose(tabIndex);
|
|
5122
|
-
};
|
|
5123
|
-
const handleAddTab = () => {
|
|
5124
|
-
onTabAdd == null ? void 0 : onTabAdd(React16.Children.count(children));
|
|
5125
|
-
};
|
|
5126
|
-
const handleMouseDown = (e) => {
|
|
5127
|
-
var _a2;
|
|
5128
|
-
const target = e.target;
|
|
5129
|
-
const tabElement = target.closest('[role^="tab"]');
|
|
5130
|
-
const role = tabElement == null ? void 0 : tabElement.getAttribute("role");
|
|
5131
|
-
if (role === "tab") {
|
|
5132
|
-
const tabIndex = parseInt((_a2 = tabElement.dataset.idx) != null ? _a2 : "-1");
|
|
5133
|
-
if (tabIndex === -1) {
|
|
5134
|
-
throw Error("Stack: mousedown on tab with unknown index");
|
|
5135
|
-
}
|
|
5136
|
-
onMouseDown == null ? void 0 : onMouseDown(e, tabIndex);
|
|
5137
|
-
}
|
|
5138
|
-
};
|
|
5139
|
-
const handleExitEditMode = useCallback15(
|
|
8095
|
+
const id = useId(idProp);
|
|
8096
|
+
const { allowCloseTab, allowRenameTab } = TabstripProps2;
|
|
8097
|
+
const handleExitEditMode = useCallback30(
|
|
5140
8098
|
(_oldText, newText, _allowDeactivation, tabIndex) => {
|
|
5141
8099
|
onTabEdit == null ? void 0 : onTabEdit(tabIndex, newText);
|
|
5142
8100
|
},
|
|
@@ -5144,7 +8102,7 @@ var Stack = forwardRef6(function Stack2({
|
|
|
5144
8102
|
);
|
|
5145
8103
|
const activeChild = () => {
|
|
5146
8104
|
var _a2;
|
|
5147
|
-
if (
|
|
8105
|
+
if (React19.isValidElement(children)) {
|
|
5148
8106
|
return children;
|
|
5149
8107
|
}
|
|
5150
8108
|
if (Array.isArray(children)) {
|
|
@@ -5154,63 +8112,47 @@ var Stack = forwardRef6(function Stack2({
|
|
|
5154
8112
|
};
|
|
5155
8113
|
const renderTabs = () => getChildElements(children).map((child2, idx) => {
|
|
5156
8114
|
const rootId = `${id}-${idx}`;
|
|
5157
|
-
const { closeable, id: childId } = child2.props;
|
|
5158
|
-
return /* @__PURE__ */
|
|
8115
|
+
const { closeable = allowCloseTab, id: childId } = child2.props;
|
|
8116
|
+
return /* @__PURE__ */ jsx27(
|
|
5159
8117
|
Tab,
|
|
5160
8118
|
{
|
|
5161
8119
|
ariaControls: `${rootId}-tab`,
|
|
5162
8120
|
"data-icon": getTabIcon(child2, idx),
|
|
5163
|
-
draggable: true,
|
|
5164
8121
|
id: rootId,
|
|
8122
|
+
index: idx,
|
|
5165
8123
|
label: getTabLabel(child2, idx),
|
|
5166
|
-
closeable
|
|
5167
|
-
editable:
|
|
8124
|
+
closeable,
|
|
8125
|
+
editable: allowRenameTab
|
|
5168
8126
|
},
|
|
5169
8127
|
childId != null ? childId : idx
|
|
5170
8128
|
);
|
|
5171
8129
|
});
|
|
5172
8130
|
const child = activeChild();
|
|
5173
|
-
return /* @__PURE__ */
|
|
8131
|
+
return /* @__PURE__ */ jsxs8(
|
|
5174
8132
|
"div",
|
|
5175
8133
|
{
|
|
5176
|
-
className:
|
|
5177
|
-
[`${
|
|
8134
|
+
className: cx15(classBase13, classNameProp, {
|
|
8135
|
+
[`${classBase13}-horizontal`]: (TabstripProps2 == null ? void 0 : TabstripProps2.orientation) === "vertical"
|
|
5178
8136
|
}),
|
|
5179
8137
|
style,
|
|
5180
8138
|
id,
|
|
5181
8139
|
ref,
|
|
5182
8140
|
children: [
|
|
5183
|
-
showTabs ? /* @__PURE__ */
|
|
5184
|
-
|
|
8141
|
+
showTabs ? /* @__PURE__ */ jsx27(
|
|
8142
|
+
Tabstrip,
|
|
5185
8143
|
{
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
...TabstripProps,
|
|
5199
|
-
activeTabIndex: (_a = TabstripProps == null ? void 0 : TabstripProps.activeTabIndex) != null ? _a : child === null ? -1 : active,
|
|
5200
|
-
enableRenameTab: (TabstripProps == null ? void 0 : TabstripProps.enableRenameTab) !== false,
|
|
5201
|
-
enableAddTab,
|
|
5202
|
-
enableCloseTab: enableCloseTabs,
|
|
5203
|
-
keyBoardActivation,
|
|
5204
|
-
onActiveChange: handleTabSelection,
|
|
5205
|
-
onAddTab: handleAddTab,
|
|
5206
|
-
onCloseTab: handleTabClose,
|
|
5207
|
-
onExitEditMode: handleExitEditMode,
|
|
5208
|
-
onMouseDown: handleMouseDown,
|
|
5209
|
-
children: renderTabs()
|
|
5210
|
-
}
|
|
5211
|
-
)
|
|
5212
|
-
}
|
|
5213
|
-
)
|
|
8144
|
+
...TabstripProps2,
|
|
8145
|
+
activeTabIndex: (_a = TabstripProps2 == null ? void 0 : TabstripProps2.activeTabIndex) != null ? _a : child === null ? -1 : active,
|
|
8146
|
+
allowDragDrop: TabstripProps2.allowDragDrop !== false,
|
|
8147
|
+
animateSelectionThumb: true,
|
|
8148
|
+
className: "vuuTabHeader",
|
|
8149
|
+
keyBoardActivation,
|
|
8150
|
+
onActiveChange: onTabSelectionChanged,
|
|
8151
|
+
onAddTab,
|
|
8152
|
+
onCloseTab: onTabClose,
|
|
8153
|
+
onExitEditMode: handleExitEditMode,
|
|
8154
|
+
onMoveTab,
|
|
8155
|
+
children: renderTabs()
|
|
5214
8156
|
}
|
|
5215
8157
|
) : null,
|
|
5216
8158
|
child
|
|
@@ -5222,9 +8164,9 @@ Stack.displayName = "Stack";
|
|
|
5222
8164
|
|
|
5223
8165
|
// src/stack/StackLayout.tsx
|
|
5224
8166
|
import { useIdMemo as useId3 } from "@salt-ds/core";
|
|
5225
|
-
import
|
|
5226
|
-
import { jsx as
|
|
5227
|
-
var defaultCreateNewChild = (index) => /* @__PURE__ */
|
|
8167
|
+
import React20, { useCallback as useCallback31, useRef as useRef24 } from "react";
|
|
8168
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
8169
|
+
var defaultCreateNewChild = (index) => /* @__PURE__ */ jsx28(
|
|
5228
8170
|
MemoView,
|
|
5229
8171
|
{
|
|
5230
8172
|
resizeable: true,
|
|
@@ -5232,11 +8174,11 @@ var defaultCreateNewChild = (index) => /* @__PURE__ */ jsx19(
|
|
|
5232
8174
|
style: { flexGrow: 1, flexShrink: 0, flexBasis: 0 },
|
|
5233
8175
|
header: true,
|
|
5234
8176
|
closeable: true,
|
|
5235
|
-
children: /* @__PURE__ */
|
|
8177
|
+
children: /* @__PURE__ */ jsx28(Component_default, { style: { flex: 1 } })
|
|
5236
8178
|
}
|
|
5237
8179
|
);
|
|
5238
8180
|
var StackLayout = (props) => {
|
|
5239
|
-
const ref =
|
|
8181
|
+
const ref = useRef24(null);
|
|
5240
8182
|
const dispatch = useLayoutProviderDispatch();
|
|
5241
8183
|
const { loadState } = usePersistentState();
|
|
5242
8184
|
const {
|
|
@@ -5250,32 +8192,46 @@ var StackLayout = (props) => {
|
|
|
5250
8192
|
const id = useId3(idProp);
|
|
5251
8193
|
const [dispatchViewAction] = useViewActionDispatcher(id, ref, path);
|
|
5252
8194
|
const handleTabSelection = (nextIdx) => {
|
|
5253
|
-
console.log(`StackLayout handleTabSelection nextTab = ${nextIdx}`);
|
|
5254
8195
|
if (path) {
|
|
5255
8196
|
dispatch({ type: "switch-tab", path, nextIdx });
|
|
5256
8197
|
onTabSelectionChanged == null ? void 0 : onTabSelectionChanged(nextIdx);
|
|
5257
8198
|
}
|
|
5258
8199
|
};
|
|
5259
|
-
const handleTabClose = (
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
8200
|
+
const handleTabClose = useCallback31(
|
|
8201
|
+
(tabIndex) => {
|
|
8202
|
+
if (Array.isArray(children)) {
|
|
8203
|
+
const {
|
|
8204
|
+
props: { "data-path": dataPath, path: path2 = dataPath }
|
|
8205
|
+
} = children[tabIndex];
|
|
8206
|
+
dispatch({ type: "remove", path: path2 });
|
|
8207
|
+
}
|
|
8208
|
+
},
|
|
8209
|
+
[children, dispatch]
|
|
8210
|
+
);
|
|
8211
|
+
const handleTabAdd = useCallback31(() => {
|
|
5268
8212
|
if (path) {
|
|
5269
|
-
|
|
8213
|
+
const tabIndex = React20.Children.count(children);
|
|
5270
8214
|
const component = createNewChild(tabIndex);
|
|
5271
|
-
console.log({ component });
|
|
5272
8215
|
dispatch({
|
|
5273
8216
|
type: "add",
|
|
5274
8217
|
path,
|
|
5275
8218
|
component
|
|
5276
8219
|
});
|
|
5277
8220
|
}
|
|
5278
|
-
};
|
|
8221
|
+
}, [children, createNewChild, dispatch, path]);
|
|
8222
|
+
const handleMoveTab = useCallback31(
|
|
8223
|
+
(fromIndex, toIndex) => {
|
|
8224
|
+
if (path) {
|
|
8225
|
+
dispatch({
|
|
8226
|
+
fromIndex,
|
|
8227
|
+
toIndex,
|
|
8228
|
+
path,
|
|
8229
|
+
type: "move-child"
|
|
8230
|
+
});
|
|
8231
|
+
}
|
|
8232
|
+
},
|
|
8233
|
+
[dispatch, path]
|
|
8234
|
+
);
|
|
5279
8235
|
const handleMouseDown = async (e, index) => {
|
|
5280
8236
|
let readyToDrag;
|
|
5281
8237
|
const preDragActivity = async () => new Promise((resolve) => {
|
|
@@ -5297,14 +8253,15 @@ var StackLayout = (props) => {
|
|
|
5297
8253
|
const { id: id2, title } = component.props;
|
|
5298
8254
|
return loadState(id2, "view-title") || title || `Tab ${idx + 1}`;
|
|
5299
8255
|
};
|
|
5300
|
-
return /* @__PURE__ */
|
|
8256
|
+
return /* @__PURE__ */ jsx28(
|
|
5301
8257
|
Stack,
|
|
5302
8258
|
{
|
|
5303
8259
|
...restProps,
|
|
5304
8260
|
id,
|
|
5305
8261
|
getTabLabel,
|
|
5306
8262
|
onMouseDown: handleMouseDown,
|
|
5307
|
-
|
|
8263
|
+
onMoveTab: handleMoveTab,
|
|
8264
|
+
onAddTab: handleTabAdd,
|
|
5308
8265
|
onTabClose: handleTabClose,
|
|
5309
8266
|
onTabEdit: handleTabEdit,
|
|
5310
8267
|
onTabSelectionChanged: handleTabSelection,
|
|
@@ -5316,32 +8273,32 @@ StackLayout.displayName = "Stack";
|
|
|
5316
8273
|
registerComponent("Stack", StackLayout, "container");
|
|
5317
8274
|
|
|
5318
8275
|
// src/tools/config-wrapper/ConfigWrapper.tsx
|
|
5319
|
-
import
|
|
5320
|
-
import { jsx as
|
|
8276
|
+
import React21, { useState as useState13 } from "react";
|
|
8277
|
+
import { jsx as jsx29, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
5321
8278
|
var ConfigWrapper = ({ children }) => {
|
|
5322
8279
|
const designMode = false;
|
|
5323
|
-
const [layout, setLayout] =
|
|
5324
|
-
const [selectedComponent, setSelectedComponent] =
|
|
8280
|
+
const [layout, setLayout] = useState13(children);
|
|
8281
|
+
const [selectedComponent, setSelectedComponent] = useState13(children);
|
|
5325
8282
|
const handleSelection = (selectedPath) => {
|
|
5326
8283
|
const targetComponent = followPathToComponent(layout, selectedPath);
|
|
5327
8284
|
setSelectedComponent(targetComponent);
|
|
5328
8285
|
};
|
|
5329
8286
|
const handleChange = (property, value) => {
|
|
5330
8287
|
console.log(`change ${property} -> ${value}`);
|
|
5331
|
-
const newComponent =
|
|
8288
|
+
const newComponent = React21.cloneElement(selectedComponent, {
|
|
5332
8289
|
style: {
|
|
5333
8290
|
...selectedComponent.props.style,
|
|
5334
8291
|
[property]: value
|
|
5335
8292
|
}
|
|
5336
8293
|
});
|
|
5337
8294
|
setSelectedComponent(newComponent);
|
|
5338
|
-
setLayout(
|
|
8295
|
+
setLayout(React21.cloneElement(layout, {}, newComponent));
|
|
5339
8296
|
};
|
|
5340
|
-
return /* @__PURE__ */
|
|
8297
|
+
return /* @__PURE__ */ jsxs9("div", { "data-design-mode": `${designMode}`, children: [
|
|
5341
8298
|
layout,
|
|
5342
|
-
/* @__PURE__ */
|
|
5343
|
-
/* @__PURE__ */
|
|
5344
|
-
/* @__PURE__ */
|
|
8299
|
+
/* @__PURE__ */ jsx29("br", {}),
|
|
8300
|
+
/* @__PURE__ */ jsxs9("div", { style: { display: "flex" }, children: [
|
|
8301
|
+
/* @__PURE__ */ jsx29(
|
|
5345
8302
|
LayoutConfigurator,
|
|
5346
8303
|
{
|
|
5347
8304
|
height: 300,
|
|
@@ -5351,7 +8308,7 @@ var ConfigWrapper = ({ children }) => {
|
|
|
5351
8308
|
style: void 0
|
|
5352
8309
|
}
|
|
5353
8310
|
),
|
|
5354
|
-
/* @__PURE__ */
|
|
8311
|
+
/* @__PURE__ */ jsx29(
|
|
5355
8312
|
LayoutTreeViewer,
|
|
5356
8313
|
{
|
|
5357
8314
|
layout,
|
|
@@ -5364,10 +8321,10 @@ var ConfigWrapper = ({ children }) => {
|
|
|
5364
8321
|
};
|
|
5365
8322
|
|
|
5366
8323
|
// src/tools/devtools-box/layout-configurator.jsx
|
|
5367
|
-
import { FormField, Input } from "@heswell/salt-lab";
|
|
5368
|
-
import { jsx as
|
|
8324
|
+
import { FormField, Input as Input2 } from "@heswell/salt-lab";
|
|
8325
|
+
import { jsx as jsx30, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5369
8326
|
var NO_STYLE2 = {};
|
|
5370
|
-
var
|
|
8327
|
+
var DIMENSIONS2 = {
|
|
5371
8328
|
margin: {
|
|
5372
8329
|
top: "marginTop",
|
|
5373
8330
|
right: "marginRight",
|
|
@@ -5388,36 +8345,36 @@ var DIMENSIONS = {
|
|
|
5388
8345
|
}
|
|
5389
8346
|
};
|
|
5390
8347
|
var LayoutBox = ({ feature, children, style, onChange }) => {
|
|
5391
|
-
return /* @__PURE__ */
|
|
5392
|
-
/* @__PURE__ */
|
|
5393
|
-
/* @__PURE__ */
|
|
5394
|
-
/* @__PURE__ */
|
|
5395
|
-
|
|
8348
|
+
return /* @__PURE__ */ jsxs10("div", { className: `LayoutBox layout-${feature} layout-outer`, children: [
|
|
8349
|
+
/* @__PURE__ */ jsxs10("div", { className: `layout-top`, children: [
|
|
8350
|
+
/* @__PURE__ */ jsx30("span", { className: "layout-title", children: feature }),
|
|
8351
|
+
/* @__PURE__ */ jsx30(FormField, { className: "layout-input", style: { width: 30 }, children: /* @__PURE__ */ jsx30(
|
|
8352
|
+
Input2,
|
|
5396
8353
|
{
|
|
5397
8354
|
value: style.top,
|
|
5398
8355
|
onChange: (evt, value) => onChange(feature, "top", value)
|
|
5399
8356
|
}
|
|
5400
8357
|
) })
|
|
5401
8358
|
] }),
|
|
5402
|
-
/* @__PURE__ */
|
|
5403
|
-
/* @__PURE__ */
|
|
5404
|
-
|
|
8359
|
+
/* @__PURE__ */ jsxs10("div", { className: `layout-inner`, children: [
|
|
8360
|
+
/* @__PURE__ */ jsx30("div", { className: `layout-left`, children: /* @__PURE__ */ jsx30(FormField, { className: "layout-input", style: { width: 30 }, children: /* @__PURE__ */ jsx30(
|
|
8361
|
+
Input2,
|
|
5405
8362
|
{
|
|
5406
8363
|
value: style.left,
|
|
5407
8364
|
onChange: (evt, value) => onChange(feature, "left", value)
|
|
5408
8365
|
}
|
|
5409
8366
|
) }) }),
|
|
5410
8367
|
children,
|
|
5411
|
-
/* @__PURE__ */
|
|
5412
|
-
|
|
8368
|
+
/* @__PURE__ */ jsx30("div", { className: `layout-right`, children: /* @__PURE__ */ jsx30(FormField, { className: "layout-input", style: { width: 30 }, children: /* @__PURE__ */ jsx30(
|
|
8369
|
+
Input2,
|
|
5413
8370
|
{
|
|
5414
8371
|
value: style.right,
|
|
5415
8372
|
onChange: (evt, value) => onChange(feature, "right", value)
|
|
5416
8373
|
}
|
|
5417
8374
|
) }) })
|
|
5418
8375
|
] }),
|
|
5419
|
-
/* @__PURE__ */
|
|
5420
|
-
|
|
8376
|
+
/* @__PURE__ */ jsx30("div", { className: `layout-bottom`, children: /* @__PURE__ */ jsx30(FormField, { className: "layout-input", style: { width: 30 }, children: /* @__PURE__ */ jsx30(
|
|
8377
|
+
Input2,
|
|
5421
8378
|
{
|
|
5422
8379
|
value: style.bottom,
|
|
5423
8380
|
onChange: (evt, value) => onChange(feature, "bottom", value)
|
|
@@ -5462,7 +8419,7 @@ var LayoutConfigurator = ({
|
|
|
5462
8419
|
const state = normalizeStyle(managedStyle);
|
|
5463
8420
|
const handleChange = (feature, dimension, strValue) => {
|
|
5464
8421
|
const value = parseInt(strValue || "0", 10);
|
|
5465
|
-
const property =
|
|
8422
|
+
const property = DIMENSIONS2[feature][dimension];
|
|
5466
8423
|
onChange(property, value);
|
|
5467
8424
|
};
|
|
5468
8425
|
const {
|
|
@@ -5483,25 +8440,25 @@ var LayoutConfigurator = ({
|
|
|
5483
8440
|
paddingBottom: pb = 0,
|
|
5484
8441
|
paddingLeft: pl = 0
|
|
5485
8442
|
} = state;
|
|
5486
|
-
return /* @__PURE__ */
|
|
8443
|
+
return /* @__PURE__ */ jsx30("div", { className: "LayoutConfigurator", style: { width, height, ...style }, children: /* @__PURE__ */ jsx30(
|
|
5487
8444
|
LayoutBox,
|
|
5488
8445
|
{
|
|
5489
8446
|
feature: "margin",
|
|
5490
8447
|
style: { top: mt, right: mr, bottom: mb, left: ml },
|
|
5491
8448
|
onChange: handleChange,
|
|
5492
|
-
children: /* @__PURE__ */
|
|
8449
|
+
children: /* @__PURE__ */ jsx30(
|
|
5493
8450
|
LayoutBox,
|
|
5494
8451
|
{
|
|
5495
8452
|
feature: "border",
|
|
5496
8453
|
style: { top: bt, right: br, bottom: bb, left: bl },
|
|
5497
8454
|
onChange: handleChange,
|
|
5498
|
-
children: /* @__PURE__ */
|
|
8455
|
+
children: /* @__PURE__ */ jsx30(
|
|
5499
8456
|
LayoutBox,
|
|
5500
8457
|
{
|
|
5501
8458
|
feature: "padding",
|
|
5502
8459
|
style: { top: pt, right: pr, bottom: pb, left: pl },
|
|
5503
8460
|
onChange: handleChange,
|
|
5504
|
-
children: /* @__PURE__ */
|
|
8461
|
+
children: /* @__PURE__ */ jsx30("div", { className: "layout-content" })
|
|
5505
8462
|
}
|
|
5506
8463
|
)
|
|
5507
8464
|
}
|
|
@@ -5669,16 +8626,16 @@ function normalizeStyle(managedStyle = NO_STYLE2) {
|
|
|
5669
8626
|
}
|
|
5670
8627
|
|
|
5671
8628
|
// src/tools/devtools-tree/layout-tree-viewer.jsx
|
|
5672
|
-
import
|
|
5673
|
-
import
|
|
8629
|
+
import React22 from "react";
|
|
8630
|
+
import cx16 from "classnames";
|
|
5674
8631
|
import { Tree } from "@heswell/salt-lab";
|
|
5675
|
-
import { jsx as
|
|
8632
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
5676
8633
|
var classBaseTree = "hwLayoutTreeViewer";
|
|
5677
8634
|
var toTreeJson = (component, path = "0") => {
|
|
5678
8635
|
return {
|
|
5679
8636
|
label: typeOf(component),
|
|
5680
8637
|
path,
|
|
5681
|
-
childNodes:
|
|
8638
|
+
childNodes: React22.Children.map(
|
|
5682
8639
|
component.props.children,
|
|
5683
8640
|
(child, i) => toTreeJson(child, path ? `${path}.${i}` : `${i}`)
|
|
5684
8641
|
)
|
|
@@ -5689,7 +8646,7 @@ var LayoutTreeViewer = ({ layout, onSelect, style }) => {
|
|
|
5689
8646
|
const handleSelection = (evt, [{ path }]) => {
|
|
5690
8647
|
onSelect(path);
|
|
5691
8648
|
};
|
|
5692
|
-
return /* @__PURE__ */
|
|
8649
|
+
return /* @__PURE__ */ jsx31("div", { className: cx16(classBaseTree), style, children: /* @__PURE__ */ jsx31(
|
|
5693
8650
|
Tree,
|
|
5694
8651
|
{
|
|
5695
8652
|
source: treeJson,
|
|
@@ -5722,6 +8679,8 @@ export {
|
|
|
5722
8679
|
LayoutProviderVersion,
|
|
5723
8680
|
LayoutTreeViewer,
|
|
5724
8681
|
MARGIN_STYLES,
|
|
8682
|
+
NO_WRAPPED_ITEMS,
|
|
8683
|
+
OverflowContainer,
|
|
5725
8684
|
PADDING_STYLES,
|
|
5726
8685
|
Palette,
|
|
5727
8686
|
PaletteItem,
|
|
@@ -5735,8 +8694,12 @@ export {
|
|
|
5735
8694
|
WidthHeight,
|
|
5736
8695
|
WidthOnly,
|
|
5737
8696
|
XXXnormalizeStyles,
|
|
8697
|
+
applyOverflowClassToWrappedItems,
|
|
8698
|
+
asReactElements,
|
|
5738
8699
|
computeMenuPosition,
|
|
5739
8700
|
containerOf,
|
|
8701
|
+
correctForWrappedHighPriorityItems,
|
|
8702
|
+
correctForWrappedOverflowIndicator,
|
|
5740
8703
|
expandFlex,
|
|
5741
8704
|
extractResponsiveProps,
|
|
5742
8705
|
findTarget,
|
|
@@ -5745,10 +8708,13 @@ export {
|
|
|
5745
8708
|
followPathToParent,
|
|
5746
8709
|
getChild,
|
|
5747
8710
|
getChildProp,
|
|
8711
|
+
getElementsMarkedAsWrapped,
|
|
8712
|
+
getNonWrappedAndWrappedItems,
|
|
5748
8713
|
getPersistentState,
|
|
5749
8714
|
getProp,
|
|
5750
8715
|
getProps,
|
|
5751
8716
|
hasPersistentState,
|
|
8717
|
+
highPriorityItemsHaveWrappedButShouldNotHave,
|
|
5752
8718
|
identifyDropTarget,
|
|
5753
8719
|
isContainer,
|
|
5754
8720
|
isLayoutComponent,
|
|
@@ -5757,15 +8723,24 @@ export {
|
|
|
5757
8723
|
isTabstrip,
|
|
5758
8724
|
isTypeOf,
|
|
5759
8725
|
isView,
|
|
8726
|
+
markElementAsWrapped,
|
|
5760
8727
|
nextLeaf,
|
|
5761
8728
|
nextStep,
|
|
8729
|
+
overflowIndicatorHasWrappedButShouldNotHave,
|
|
5762
8730
|
previousLeaf,
|
|
5763
8731
|
registerComponent,
|
|
8732
|
+
removeOverflowIndicatorIfNoLongerNeeded,
|
|
5764
8733
|
resetPath,
|
|
8734
|
+
resizeObserver,
|
|
5765
8735
|
setPersistentState,
|
|
5766
8736
|
setRef,
|
|
8737
|
+
sortByScreenOrder,
|
|
8738
|
+
switchWrappedItemIntoView,
|
|
5767
8739
|
typeOf,
|
|
8740
|
+
unmarkItemsWhichAreNoLongerWrapped,
|
|
5768
8741
|
useBreakpoints,
|
|
8742
|
+
useId,
|
|
8743
|
+
useLayoutEffectSkipFirst,
|
|
5769
8744
|
useLayoutProviderDispatch,
|
|
5770
8745
|
useLayoutProviderVersion,
|
|
5771
8746
|
usePersistentState,
|