@vuu-ui/vuu-layout 0.8.22-debug → 0.8.23-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +354 -1803
- package/cjs/index.js.map +4 -4
- package/esm/index.js +81 -1568
- package/esm/index.js.map +4 -4
- package/index.css +0 -151
- package/index.css.map +3 -3
- package/package.json +8 -8
- package/types/index.d.ts +0 -3
- package/types/utils/index.d.ts +0 -1
- package/types/utils/typeOf.d.ts +2 -1
- package/types/measured-container/MeasuredContainer.d.ts +0 -15
- package/types/measured-container/index.d.ts +0 -2
- package/types/measured-container/useMeasuredContainer.d.ts +0 -22
- package/types/measured-container/useResizeObserver.d.ts +0 -15
- package/types/overflow-container/OverflowContainer.d.ts +0 -17
- package/types/overflow-container/index.d.ts +0 -2
- package/types/overflow-container/overflow-utils.d.ts +0 -49
- package/types/overflow-container/useOverflowContainer.d.ts +0 -20
- package/types/toolbar/Toolbar.d.ts +0 -21
- package/types/toolbar/index.d.ts +0 -1
- package/types/toolbar/toolbar-dom-utils.d.ts +0 -3
- package/types/toolbar/useKeyboardNavigation.d.ts +0 -32
- package/types/toolbar/useSelection.d.ts +0 -22
- package/types/toolbar/useToolbar.d.ts +0 -28
- package/types/utils/react-utils.d.ts +0 -2
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 classBase11 = "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(classBase11, classNameProp, `${classBase11}-${orientation}`);
|
|
120
120
|
return /* @__PURE__ */ jsxs2("div", { className, id, style, children: [
|
|
121
121
|
drawers,
|
|
122
|
-
/* @__PURE__ */ jsx2("div", { className: `${
|
|
122
|
+
/* @__PURE__ */ jsx2("div", { className: `${classBase11}-content`, children: content })
|
|
123
123
|
] });
|
|
124
124
|
};
|
|
125
125
|
DockLayout.displayName = "DockLayout";
|
|
@@ -183,6 +183,7 @@ function typeOf(element) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
var isTypeOf = (element, type) => typeOf(element) === type;
|
|
186
|
+
var isLayoutJSON = (layout) => layout !== void 0 && "type" in layout;
|
|
186
187
|
|
|
187
188
|
// src/utils/pathUtils.ts
|
|
188
189
|
var removeFinalPathSegment = (path) => {
|
|
@@ -467,23 +468,6 @@ function setRef(ref, value) {
|
|
|
467
468
|
}
|
|
468
469
|
}
|
|
469
470
|
|
|
470
|
-
// src/utils/react-utils.ts
|
|
471
|
-
import { Children, isValidElement as isValidElement2 } from "react";
|
|
472
|
-
var EMPTY_ARRAY = [];
|
|
473
|
-
var asReactElements = (children) => {
|
|
474
|
-
const isArray = Array.isArray(children);
|
|
475
|
-
const count = isArray ? children.length : Children.count(children);
|
|
476
|
-
if (isArray && children.every(isValidElement2)) {
|
|
477
|
-
return children;
|
|
478
|
-
} else if (count === 1 && !isArray && isValidElement2(children)) {
|
|
479
|
-
return [children];
|
|
480
|
-
} else if (count > 1) {
|
|
481
|
-
return children;
|
|
482
|
-
} else {
|
|
483
|
-
return EMPTY_ARRAY;
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
|
|
487
471
|
// src/utils/styleUtils.ts
|
|
488
472
|
var expandFlex = (flex) => {
|
|
489
473
|
if (typeof flex !== "number") {
|
|
@@ -4222,7 +4206,7 @@ var getBreakPoints = (themeName) => {
|
|
|
4222
4206
|
};
|
|
4223
4207
|
|
|
4224
4208
|
// src/responsive/use-breakpoints.ts
|
|
4225
|
-
var
|
|
4209
|
+
var EMPTY_ARRAY = [];
|
|
4226
4210
|
var useBreakpoints = ({ breakPoints: breakPointsProp, smallerThan }, ref) => {
|
|
4227
4211
|
const [breakpointMatch, setBreakpointmatch] = useState4(
|
|
4228
4212
|
smallerThan ? false : "lg"
|
|
@@ -4263,7 +4247,7 @@ var useBreakpoints = ({ breakPoints: breakPointsProp, smallerThan }, ref) => {
|
|
|
4263
4247
|
);
|
|
4264
4248
|
useResizeObserver(
|
|
4265
4249
|
ref || bodyRef,
|
|
4266
|
-
breakPointsRef.current ? ["width"] :
|
|
4250
|
+
breakPointsRef.current ? ["width"] : EMPTY_ARRAY,
|
|
4267
4251
|
({ width: measuredWidth }) => {
|
|
4268
4252
|
const result = matchSizeAgainstBreakpoints(measuredWidth);
|
|
4269
4253
|
if (result !== sizeRef.current) {
|
|
@@ -5061,6 +5045,7 @@ FlexboxLayout.displayName = "Flexbox";
|
|
|
5061
5045
|
registerComponent("Flexbox", FlexboxLayout, "container");
|
|
5062
5046
|
|
|
5063
5047
|
// src/flexbox/FluidGrid.tsx
|
|
5048
|
+
import { asReactElements } from "@vuu-ui/vuu-utils";
|
|
5064
5049
|
import { useForkRef as useForkRef3 } from "@salt-ds/core";
|
|
5065
5050
|
import cx9 from "clsx";
|
|
5066
5051
|
import { forwardRef as forwardRef5, useMemo as useMemo6 } from "react";
|
|
@@ -5069,7 +5054,7 @@ import { forwardRef as forwardRef5, useMemo as useMemo6 } from "react";
|
|
|
5069
5054
|
import { getUniqueId as getUniqueId2 } from "@vuu-ui/vuu-utils";
|
|
5070
5055
|
import {
|
|
5071
5056
|
cloneElement as cloneElement4,
|
|
5072
|
-
isValidElement as
|
|
5057
|
+
isValidElement as isValidElement2,
|
|
5073
5058
|
useCallback as useCallback14,
|
|
5074
5059
|
useMemo as useMemo5,
|
|
5075
5060
|
useRef as useRef10
|
|
@@ -5088,7 +5073,7 @@ var useResponsiveSizing = ({
|
|
|
5088
5073
|
const isColumn = (style == null ? void 0 : style.flexDirection) === "column";
|
|
5089
5074
|
const dimension3 = isColumn ? "height" : "width";
|
|
5090
5075
|
const children = useMemo5(
|
|
5091
|
-
() => Array.isArray(childrenProp) ? childrenProp :
|
|
5076
|
+
() => Array.isArray(childrenProp) ? childrenProp : isValidElement2(childrenProp) ? [childrenProp] : [],
|
|
5092
5077
|
[childrenProp]
|
|
5093
5078
|
);
|
|
5094
5079
|
const buildContent2 = useCallback14(
|
|
@@ -5203,862 +5188,18 @@ var FluidGridLayout = function FluidGridLayout2(props) {
|
|
|
5203
5188
|
FluidGridLayout.displayName = "FluidGrid";
|
|
5204
5189
|
registerComponent("FluidGrid", FluidGridLayout, "container");
|
|
5205
5190
|
|
|
5206
|
-
// src/measured-container/MeasuredContainer.tsx
|
|
5207
|
-
import { forwardRef as forwardRef6 } from "react";
|
|
5208
|
-
|
|
5209
|
-
// src/measured-container/useMeasuredContainer.ts
|
|
5210
|
-
import { isValidNumber } from "@vuu-ui/vuu-utils";
|
|
5211
|
-
import {
|
|
5212
|
-
useCallback as useCallback16,
|
|
5213
|
-
useEffect as useEffect4,
|
|
5214
|
-
useMemo as useMemo7,
|
|
5215
|
-
useRef as useRef12,
|
|
5216
|
-
useState as useState9
|
|
5217
|
-
} from "react";
|
|
5218
|
-
|
|
5219
|
-
// src/measured-container/useResizeObserver.ts
|
|
5220
|
-
import { useCallback as useCallback15, useEffect as useEffect3, useRef as useRef11 } from "react";
|
|
5221
|
-
var observedMap2 = /* @__PURE__ */ new Map();
|
|
5222
|
-
var getTargetSize2 = (element, size, dimension3) => {
|
|
5223
|
-
switch (dimension3) {
|
|
5224
|
-
case "height":
|
|
5225
|
-
return size.height;
|
|
5226
|
-
case "clientHeight":
|
|
5227
|
-
return Math.floor(element.clientHeight);
|
|
5228
|
-
case "clientWidth":
|
|
5229
|
-
return Math.floor(element.clientWidth);
|
|
5230
|
-
case "contentHeight":
|
|
5231
|
-
return size.contentHeight;
|
|
5232
|
-
case "contentWidth":
|
|
5233
|
-
return size.contentWidth;
|
|
5234
|
-
case "scrollHeight":
|
|
5235
|
-
return Math.ceil(Math.floor(element.scrollHeight));
|
|
5236
|
-
case "scrollWidth":
|
|
5237
|
-
return Math.ceil(Math.floor(element.scrollWidth));
|
|
5238
|
-
case "width":
|
|
5239
|
-
return size.width;
|
|
5240
|
-
default:
|
|
5241
|
-
return 0;
|
|
5242
|
-
}
|
|
5243
|
-
};
|
|
5244
|
-
var resizeObserver2 = new ResizeObserver((entries) => {
|
|
5245
|
-
for (const entry of entries) {
|
|
5246
|
-
const { target, borderBoxSize, contentBoxSize } = entry;
|
|
5247
|
-
const observedTarget = observedMap2.get(target);
|
|
5248
|
-
if (observedTarget) {
|
|
5249
|
-
const [{ blockSize: height, inlineSize: width }] = borderBoxSize;
|
|
5250
|
-
const [{ blockSize: contentHeight, inlineSize: contentWidth }] = contentBoxSize;
|
|
5251
|
-
const { onResize, measurements } = observedTarget;
|
|
5252
|
-
let sizeChanged = false;
|
|
5253
|
-
for (const [dimension3, size] of Object.entries(measurements)) {
|
|
5254
|
-
const newSize = getTargetSize2(
|
|
5255
|
-
target,
|
|
5256
|
-
{ height, width, contentHeight, contentWidth },
|
|
5257
|
-
dimension3
|
|
5258
|
-
);
|
|
5259
|
-
if (newSize !== size) {
|
|
5260
|
-
sizeChanged = true;
|
|
5261
|
-
measurements[dimension3] = newSize;
|
|
5262
|
-
}
|
|
5263
|
-
}
|
|
5264
|
-
if (sizeChanged) {
|
|
5265
|
-
onResize && onResize(measurements);
|
|
5266
|
-
}
|
|
5267
|
-
}
|
|
5268
|
-
}
|
|
5269
|
-
});
|
|
5270
|
-
function useResizeObserver2(ref, dimensions, onResize, reportInitialSize = false) {
|
|
5271
|
-
const dimensionsRef = useRef11(dimensions);
|
|
5272
|
-
const measure = useCallback15((target) => {
|
|
5273
|
-
const { width, height } = target.getBoundingClientRect();
|
|
5274
|
-
const { clientWidth: contentWidth, clientHeight: contentHeight } = target;
|
|
5275
|
-
const flooredHeight = Math.floor(height);
|
|
5276
|
-
const flooredWidth = Math.floor(width);
|
|
5277
|
-
return dimensionsRef.current.reduce(
|
|
5278
|
-
(map, dim) => {
|
|
5279
|
-
map[dim] = getTargetSize2(
|
|
5280
|
-
target,
|
|
5281
|
-
{
|
|
5282
|
-
width: flooredWidth,
|
|
5283
|
-
height: flooredHeight,
|
|
5284
|
-
contentHeight,
|
|
5285
|
-
contentWidth
|
|
5286
|
-
},
|
|
5287
|
-
dim
|
|
5288
|
-
);
|
|
5289
|
-
return map;
|
|
5290
|
-
},
|
|
5291
|
-
{}
|
|
5292
|
-
);
|
|
5293
|
-
}, []);
|
|
5294
|
-
useEffect3(() => {
|
|
5295
|
-
const target = ref.current;
|
|
5296
|
-
async function registerObserver() {
|
|
5297
|
-
observedMap2.set(target, { measurements: {} });
|
|
5298
|
-
const observedTarget = observedMap2.get(target);
|
|
5299
|
-
if (observedTarget) {
|
|
5300
|
-
const measurements = measure(target);
|
|
5301
|
-
observedTarget.measurements = measurements;
|
|
5302
|
-
resizeObserver2.observe(target);
|
|
5303
|
-
if (reportInitialSize) {
|
|
5304
|
-
onResize(measurements);
|
|
5305
|
-
}
|
|
5306
|
-
} else {
|
|
5307
|
-
console.log(
|
|
5308
|
-
`%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation`,
|
|
5309
|
-
"font-weight:bold; color:red;"
|
|
5310
|
-
);
|
|
5311
|
-
}
|
|
5312
|
-
}
|
|
5313
|
-
if (target) {
|
|
5314
|
-
if (observedMap2.has(target)) {
|
|
5315
|
-
console.log(
|
|
5316
|
-
`useResizeObserver attemping to observe same element twice`,
|
|
5317
|
-
{
|
|
5318
|
-
target
|
|
5319
|
-
}
|
|
5320
|
-
);
|
|
5321
|
-
}
|
|
5322
|
-
registerObserver();
|
|
5323
|
-
}
|
|
5324
|
-
return () => {
|
|
5325
|
-
if (target && observedMap2.has(target)) {
|
|
5326
|
-
resizeObserver2.unobserve(target);
|
|
5327
|
-
observedMap2.delete(target);
|
|
5328
|
-
}
|
|
5329
|
-
};
|
|
5330
|
-
}, [measure, ref]);
|
|
5331
|
-
useEffect3(() => {
|
|
5332
|
-
const target = ref.current;
|
|
5333
|
-
const record = observedMap2.get(target);
|
|
5334
|
-
if (record) {
|
|
5335
|
-
if (dimensionsRef.current !== dimensions) {
|
|
5336
|
-
dimensionsRef.current = dimensions;
|
|
5337
|
-
const measurements = measure(target);
|
|
5338
|
-
record.measurements = measurements;
|
|
5339
|
-
}
|
|
5340
|
-
record.onResize = onResize;
|
|
5341
|
-
}
|
|
5342
|
-
}, [dimensions, measure, ref, onResize]);
|
|
5343
|
-
}
|
|
5344
|
-
|
|
5345
|
-
// src/measured-container/useMeasuredContainer.ts
|
|
5346
|
-
var ClientWidthHeight = ["clientHeight", "clientWidth"];
|
|
5347
|
-
var WidthOnly2 = ["clientWidth"];
|
|
5348
|
-
var HeightOnly2 = ["clientHeight"];
|
|
5349
|
-
var NO_MEASUREMENT2 = [];
|
|
5350
|
-
var isNumber = (val) => Number.isFinite(val);
|
|
5351
|
-
var FULL_SIZE = { height: "100%", width: "auto" };
|
|
5352
|
-
var getInitialCssSize = (height, width) => {
|
|
5353
|
-
if (isValidNumber(height) && isValidNumber(width)) {
|
|
5354
|
-
return {
|
|
5355
|
-
height: `${height}px`,
|
|
5356
|
-
width: `${width}px`
|
|
5357
|
-
};
|
|
5358
|
-
} else if (typeof height === "string" || typeof width === "string") {
|
|
5359
|
-
return {
|
|
5360
|
-
height: height != null ? height : "100%",
|
|
5361
|
-
width: width != null ? width : "auto"
|
|
5362
|
-
};
|
|
5363
|
-
} else {
|
|
5364
|
-
return FULL_SIZE;
|
|
5365
|
-
}
|
|
5366
|
-
};
|
|
5367
|
-
var getInitialInnerSize = (height, width) => {
|
|
5368
|
-
if (isValidNumber(height) && isValidNumber(width)) {
|
|
5369
|
-
return {
|
|
5370
|
-
height,
|
|
5371
|
-
width
|
|
5372
|
-
};
|
|
5373
|
-
}
|
|
5374
|
-
};
|
|
5375
|
-
var useMeasuredContainer = ({
|
|
5376
|
-
defaultHeight = 0,
|
|
5377
|
-
defaultWidth = 0,
|
|
5378
|
-
height,
|
|
5379
|
-
onResize: onResizeProp,
|
|
5380
|
-
width
|
|
5381
|
-
}) => {
|
|
5382
|
-
const containerRef = useRef12(null);
|
|
5383
|
-
const [size, setSize] = useState9({
|
|
5384
|
-
css: getInitialCssSize(height, width),
|
|
5385
|
-
inner: getInitialInnerSize(height, width),
|
|
5386
|
-
outer: {
|
|
5387
|
-
height: height != null ? height : "100%",
|
|
5388
|
-
width: width != null ? width : "auto"
|
|
5389
|
-
}
|
|
5390
|
-
});
|
|
5391
|
-
const fixedHeight = typeof height === "number";
|
|
5392
|
-
const fixedWidth = typeof width === "number";
|
|
5393
|
-
const dimensions = fixedHeight && fixedWidth ? NO_MEASUREMENT2 : fixedHeight ? WidthOnly2 : fixedWidth ? HeightOnly2 : ClientWidthHeight;
|
|
5394
|
-
useMemo7(() => {
|
|
5395
|
-
setSize((currentSize) => {
|
|
5396
|
-
const { inner, outer } = currentSize;
|
|
5397
|
-
if (isValidNumber(height) && isValidNumber(width) && inner && outer) {
|
|
5398
|
-
const { height: innerHeight, width: innerWidth } = inner;
|
|
5399
|
-
const { height: outerHeight, width: outerWidth } = outer;
|
|
5400
|
-
if (outerHeight !== height || outerWidth !== width) {
|
|
5401
|
-
const heightDiff = isValidNumber(outerHeight) ? outerHeight - innerHeight : 0;
|
|
5402
|
-
const widthDiff = isValidNumber(outerWidth) ? outerWidth - innerWidth : 0;
|
|
5403
|
-
return {
|
|
5404
|
-
...currentSize,
|
|
5405
|
-
outer: { height, width },
|
|
5406
|
-
inner: { height: height - heightDiff, width: width - widthDiff }
|
|
5407
|
-
};
|
|
5408
|
-
}
|
|
5409
|
-
}
|
|
5410
|
-
return currentSize;
|
|
5411
|
-
});
|
|
5412
|
-
}, [height, width]);
|
|
5413
|
-
const onResize = useCallback16(
|
|
5414
|
-
({ clientWidth, clientHeight }) => {
|
|
5415
|
-
const { css, inner, outer } = size;
|
|
5416
|
-
let newState = size;
|
|
5417
|
-
if (fixedHeight && isNumber(clientWidth) && Math.floor(clientWidth) !== (inner == null ? void 0 : inner.width)) {
|
|
5418
|
-
newState = {
|
|
5419
|
-
css,
|
|
5420
|
-
outer,
|
|
5421
|
-
inner: {
|
|
5422
|
-
width: Math.floor(clientWidth) || defaultWidth,
|
|
5423
|
-
height
|
|
5424
|
-
}
|
|
5425
|
-
};
|
|
5426
|
-
} else if (fixedWidth && isNumber(clientHeight) && Math.floor(clientHeight) !== (inner == null ? void 0 : inner.height)) {
|
|
5427
|
-
newState = {
|
|
5428
|
-
css,
|
|
5429
|
-
outer,
|
|
5430
|
-
inner: {
|
|
5431
|
-
height: Math.floor(clientHeight) || defaultHeight,
|
|
5432
|
-
width
|
|
5433
|
-
}
|
|
5434
|
-
};
|
|
5435
|
-
} else if (isNumber(clientHeight) && isNumber(clientWidth) && (clientWidth !== (inner == null ? void 0 : inner.width) || clientHeight !== (inner == null ? void 0 : inner.height))) {
|
|
5436
|
-
newState = {
|
|
5437
|
-
css,
|
|
5438
|
-
outer,
|
|
5439
|
-
inner: {
|
|
5440
|
-
width: Math.floor(clientWidth) || defaultWidth,
|
|
5441
|
-
height: Math.floor(clientHeight) || defaultHeight
|
|
5442
|
-
}
|
|
5443
|
-
};
|
|
5444
|
-
}
|
|
5445
|
-
if (newState !== size) {
|
|
5446
|
-
setSize(newState);
|
|
5447
|
-
}
|
|
5448
|
-
},
|
|
5449
|
-
[defaultHeight, defaultWidth, fixedHeight, fixedWidth, height, size, width]
|
|
5450
|
-
);
|
|
5451
|
-
useEffect4(() => {
|
|
5452
|
-
if (size.inner) {
|
|
5453
|
-
onResizeProp == null ? void 0 : onResizeProp(size.inner);
|
|
5454
|
-
}
|
|
5455
|
-
}, [onResizeProp, size.inner]);
|
|
5456
|
-
useResizeObserver2(containerRef, dimensions, onResize, true);
|
|
5457
|
-
return {
|
|
5458
|
-
containerRef,
|
|
5459
|
-
cssSize: size.css,
|
|
5460
|
-
outerSize: size.outer,
|
|
5461
|
-
innerSize: size.inner
|
|
5462
|
-
};
|
|
5463
|
-
};
|
|
5464
|
-
|
|
5465
|
-
// src/measured-container/MeasuredContainer.tsx
|
|
5466
|
-
import { useForkRef as useForkRef4 } from "@salt-ds/core";
|
|
5467
|
-
import cx10 from "clsx";
|
|
5468
|
-
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
5469
|
-
var baseClass = "vuuMeasuredContainer";
|
|
5470
|
-
var MeasuredContainer = forwardRef6(function MeasuredContainer2({
|
|
5471
|
-
children,
|
|
5472
|
-
className,
|
|
5473
|
-
height,
|
|
5474
|
-
onResize,
|
|
5475
|
-
style,
|
|
5476
|
-
width,
|
|
5477
|
-
...htmlAttributes
|
|
5478
|
-
}, forwardedRef) {
|
|
5479
|
-
const { containerRef, ...containerMeasurements } = useMeasuredContainer({
|
|
5480
|
-
height,
|
|
5481
|
-
onResize,
|
|
5482
|
-
width
|
|
5483
|
-
});
|
|
5484
|
-
const { cssSize, innerSize } = containerMeasurements;
|
|
5485
|
-
const unmeasured = innerSize === void 0;
|
|
5486
|
-
const getStyle3 = () => {
|
|
5487
|
-
return unmeasured ? {
|
|
5488
|
-
"--measured-css-height": `${cssSize.height}`,
|
|
5489
|
-
"--measured-css-width": `${cssSize.width}`
|
|
5490
|
-
} : {
|
|
5491
|
-
...style,
|
|
5492
|
-
"--measured-css-height": `${cssSize.height}`,
|
|
5493
|
-
"--measured-css-width": `${cssSize.width}`,
|
|
5494
|
-
"--measured-px-height": `${innerSize == null ? void 0 : innerSize.height}px`,
|
|
5495
|
-
"--measured-px-width": `${innerSize == null ? void 0 : innerSize.width}px`
|
|
5496
|
-
};
|
|
5497
|
-
};
|
|
5498
|
-
const forkedRef = useForkRef4(containerRef, forwardedRef);
|
|
5499
|
-
return unmeasured ? /* @__PURE__ */ jsx17(
|
|
5500
|
-
"div",
|
|
5501
|
-
{
|
|
5502
|
-
...htmlAttributes,
|
|
5503
|
-
className: cx10(baseClass, `${baseClass}-ummeasured`),
|
|
5504
|
-
style: getStyle3(),
|
|
5505
|
-
ref: containerRef
|
|
5506
|
-
}
|
|
5507
|
-
) : /* @__PURE__ */ jsx17(
|
|
5508
|
-
"div",
|
|
5509
|
-
{
|
|
5510
|
-
...htmlAttributes,
|
|
5511
|
-
className: cx10(baseClass, className),
|
|
5512
|
-
ref: forkedRef,
|
|
5513
|
-
style: getStyle3(),
|
|
5514
|
-
children
|
|
5515
|
-
}
|
|
5516
|
-
);
|
|
5517
|
-
});
|
|
5518
|
-
|
|
5519
|
-
// src/overflow-container/OverflowContainer.tsx
|
|
5520
|
-
import { PopupMenu } from "@vuu-ui/vuu-popups";
|
|
5521
|
-
import { useId as useId2 } from "@vuu-ui/vuu-utils";
|
|
5522
|
-
import cx11 from "clsx";
|
|
5523
|
-
import React15, {
|
|
5524
|
-
forwardRef as forwardRef7
|
|
5525
|
-
} from "react";
|
|
5526
|
-
|
|
5527
|
-
// src/overflow-container/useOverflowContainer.ts
|
|
5528
|
-
import { useDragDrop } from "@vuu-ui/vuu-ui-controls";
|
|
5529
|
-
import {
|
|
5530
|
-
isValidNumber as isValidNumber2,
|
|
5531
|
-
MEASURES,
|
|
5532
|
-
useLayoutEffectSkipFirst
|
|
5533
|
-
} from "@vuu-ui/vuu-utils";
|
|
5534
|
-
import { useCallback as useCallback17, useMemo as useMemo8, useRef as useRef13, useState as useState10 } from "react";
|
|
5535
|
-
|
|
5536
|
-
// src/overflow-container/overflow-utils.ts
|
|
5537
|
-
import { getElementByDataIndex } from "@vuu-ui/vuu-utils";
|
|
5538
|
-
var NON_WRAPPED_ITEM = ".vuuOverflowContainer-item:not(.wrapped)";
|
|
5539
|
-
var isOverflowElement = (element) => element !== null && element.dataset.index === "overflow" && element.parentElement !== null && element.parentElement.classList.contains(
|
|
5540
|
-
"vuuOverflowContainer-wrapContainer-overflowed"
|
|
5541
|
-
);
|
|
5542
|
-
var sortByScreenOrder = (elements) => elements.sort((e1, e2) => {
|
|
5543
|
-
const {
|
|
5544
|
-
dataset: { index: idx1 = "?" }
|
|
5545
|
-
} = e1;
|
|
5546
|
-
const {
|
|
5547
|
-
dataset: { index: idx2 = "?" }
|
|
5548
|
-
} = e2;
|
|
5549
|
-
const isOverflowed1 = e1.classList.contains("wrapped");
|
|
5550
|
-
const isOverflowed2 = e2.classList.contains("wrapped");
|
|
5551
|
-
const isOverflowedIndicator1 = idx1 === "overflow";
|
|
5552
|
-
const isOverflowedIndicator2 = idx2 === "overflow";
|
|
5553
|
-
if (isOverflowed1 && !isOverflowed2) {
|
|
5554
|
-
return 1;
|
|
5555
|
-
} else if (!isOverflowed1 && isOverflowed2) {
|
|
5556
|
-
return -1;
|
|
5557
|
-
}
|
|
5558
|
-
if (isOverflowedIndicator1) {
|
|
5559
|
-
return 1;
|
|
5560
|
-
} else if (isOverflowedIndicator2) {
|
|
5561
|
-
return -1;
|
|
5562
|
-
}
|
|
5563
|
-
return parseInt(idx1) > parseInt(idx2) ? 1 : -1;
|
|
5564
|
-
});
|
|
5565
|
-
var NO_WRAPPED_ITEMS = [];
|
|
5566
|
-
var getNonWrappedAndWrappedItems = (container, orientation = "horizontal") => {
|
|
5567
|
-
const nonWrappedItems = [];
|
|
5568
|
-
const wrappedItems = [];
|
|
5569
|
-
let currentPosition = -1;
|
|
5570
|
-
let overflowed = false;
|
|
5571
|
-
const sortedChildren = sortByScreenOrder(
|
|
5572
|
-
Array.from(container.children)
|
|
5573
|
-
);
|
|
5574
|
-
const positionAttribute = orientation === "vertical" ? "top" : "left";
|
|
5575
|
-
for (const child of sortedChildren) {
|
|
5576
|
-
const element = child;
|
|
5577
|
-
const {
|
|
5578
|
-
dataset: { index = "?", label = "?", overflowPriority = "0" }
|
|
5579
|
-
} = element;
|
|
5580
|
-
const { [positionAttribute]: position } = element.getBoundingClientRect();
|
|
5581
|
-
if (position <= currentPosition) {
|
|
5582
|
-
if (index === "overflow") {
|
|
5583
|
-
wrappedItems.push(nonWrappedItems.pop());
|
|
5584
|
-
} else {
|
|
5585
|
-
wrappedItems.push({ index, label, overflowPriority });
|
|
5586
|
-
}
|
|
5587
|
-
overflowed = true;
|
|
5588
|
-
} else if (overflowed) {
|
|
5589
|
-
wrappedItems.push({ index, label, overflowPriority });
|
|
5590
|
-
} else {
|
|
5591
|
-
nonWrappedItems.push({ index, label, overflowPriority });
|
|
5592
|
-
}
|
|
5593
|
-
currentPosition = position;
|
|
5594
|
-
}
|
|
5595
|
-
return [nonWrappedItems, wrappedItems];
|
|
5596
|
-
};
|
|
5597
|
-
var applyOverflowClassToWrappedItems = (container, overflowedItems, classBase13) => {
|
|
5598
|
-
let ignoreOverflow = false;
|
|
5599
|
-
const className = classBase13 ? `${classBase13}-overflowed` : "overflow";
|
|
5600
|
-
if (overflowedItems.find(({ index }) => index === "overflow")) {
|
|
5601
|
-
if (overflowedItems.length === 1) {
|
|
5602
|
-
ignoreOverflow = true;
|
|
5603
|
-
}
|
|
5604
|
-
}
|
|
5605
|
-
for (const element of container.children) {
|
|
5606
|
-
const {
|
|
5607
|
-
dataset: { index = "?" }
|
|
5608
|
-
} = element;
|
|
5609
|
-
if (overflowedItems.length === 0 || ignoreOverflow) {
|
|
5610
|
-
container.classList.remove(className);
|
|
5611
|
-
} else {
|
|
5612
|
-
container.classList.add(className);
|
|
5613
|
-
}
|
|
5614
|
-
if (index !== "overflow" && overflowedItems.find((item) => item.index === index)) {
|
|
5615
|
-
element.classList.add("wrapped");
|
|
5616
|
-
} else {
|
|
5617
|
-
element.classList.remove("wrapped");
|
|
5618
|
-
}
|
|
5619
|
-
}
|
|
5620
|
-
};
|
|
5621
|
-
var maxPriority = (priority, { overflowPriority }) => Math.max(priority, parseInt(overflowPriority));
|
|
5622
|
-
var minPriority = (priority, { overflowPriority }) => Math.min(priority, parseInt(overflowPriority));
|
|
5623
|
-
var overflowIndicatorHasWrappedButShouldNotHave = (wrappedItems) => {
|
|
5624
|
-
var _a;
|
|
5625
|
-
return wrappedItems.length > 1 && ((_a = wrappedItems.at(-1)) == null ? void 0 : _a.index) === "overflow";
|
|
5626
|
-
};
|
|
5627
|
-
var getHighestPriorityItem = (overflowItems) => {
|
|
5628
|
-
let [highestPriorityItem] = overflowItems;
|
|
5629
|
-
for (let i = 1; i < overflowItems.length; i++) {
|
|
5630
|
-
const item = overflowItems[i];
|
|
5631
|
-
if (parseInt(item.overflowPriority) > parseInt(highestPriorityItem.overflowPriority)) {
|
|
5632
|
-
highestPriorityItem = item;
|
|
5633
|
-
}
|
|
5634
|
-
}
|
|
5635
|
-
return highestPriorityItem;
|
|
5636
|
-
};
|
|
5637
|
-
var highPriorityItemsHaveWrappedButShouldNotHave = (nonWrappedItems, wrappedItems) => {
|
|
5638
|
-
var _a;
|
|
5639
|
-
const minNonwrappedPriority = nonWrappedItems.reduce(
|
|
5640
|
-
minPriority,
|
|
5641
|
-
Number.MAX_SAFE_INTEGER
|
|
5642
|
-
);
|
|
5643
|
-
const maxwrappedPriority = wrappedItems.reduce(maxPriority, 0);
|
|
5644
|
-
if (maxwrappedPriority > minNonwrappedPriority) {
|
|
5645
|
-
return true;
|
|
5646
|
-
} else {
|
|
5647
|
-
return wrappedItems.length > 1 && ((_a = wrappedItems.at(-1)) == null ? void 0 : _a.index) === "overflow";
|
|
5648
|
-
}
|
|
5649
|
-
};
|
|
5650
|
-
var correctForWrappedOverflowIndicator = (container, overflowedItems) => new Promise((resolve) => {
|
|
5651
|
-
requestAnimationFrame(() => {
|
|
5652
|
-
const [, o2] = getNonWrappedAndWrappedItems(container);
|
|
5653
|
-
const newlyOverflowed = getNewItems(overflowedItems, o2);
|
|
5654
|
-
newlyOverflowed.forEach((item) => markElementAsWrapped(container, item));
|
|
5655
|
-
resolve(o2);
|
|
5656
|
-
});
|
|
5657
|
-
});
|
|
5658
|
-
var correctForWrappedHighPriorityItems = (container, nonWrapped, wrapped) => new Promise((resolve) => {
|
|
5659
|
-
requestAnimationFrame(() => {
|
|
5660
|
-
const [, o2] = getNonWrappedAndWrappedItems(container);
|
|
5661
|
-
const highPriorityWrappedItem = getHighestPriorityItem(o2);
|
|
5662
|
-
if (highPriorityWrappedItem) {
|
|
5663
|
-
const [nonWrappedItems, wrappedItems] = switchWrappedItemIntoView(
|
|
5664
|
-
container,
|
|
5665
|
-
highPriorityWrappedItem
|
|
5666
|
-
);
|
|
5667
|
-
resolve([nonWrappedItems, wrappedItems]);
|
|
5668
|
-
} else {
|
|
5669
|
-
resolve([nonWrapped, wrapped]);
|
|
5670
|
-
}
|
|
5671
|
-
});
|
|
5672
|
-
});
|
|
5673
|
-
var markElementAsWrapped = (container, item) => {
|
|
5674
|
-
const el = getElementByDataIndex(container, item.index);
|
|
5675
|
-
if (el) {
|
|
5676
|
-
el.classList.add("wrapped");
|
|
5677
|
-
} else {
|
|
5678
|
-
throw Error(
|
|
5679
|
-
`markElementAsWrapped element item with index ${item.index} not found`
|
|
5680
|
-
);
|
|
5681
|
-
}
|
|
5682
|
-
};
|
|
5683
|
-
var getElementsMarkedAsWrapped = (container) => Array.from(container.querySelectorAll(".wrapped"));
|
|
5684
|
-
var getNewItems = (items1, items2) => {
|
|
5685
|
-
const newItems = [];
|
|
5686
|
-
for (const item of items2) {
|
|
5687
|
-
if (!items1.find(({ index }) => index === item.index)) {
|
|
5688
|
-
newItems.push(item);
|
|
5689
|
-
}
|
|
5690
|
-
}
|
|
5691
|
-
return newItems;
|
|
5692
|
-
};
|
|
5693
|
-
var unmarkItemsWhichAreNoLongerWrapped = (container, wrappedItems) => {
|
|
5694
|
-
const elementssMarkedAsWrapped = getElementsMarkedAsWrapped(container);
|
|
5695
|
-
elementssMarkedAsWrapped.forEach((el) => {
|
|
5696
|
-
const {
|
|
5697
|
-
dataset: { index = "?" }
|
|
5698
|
-
} = el;
|
|
5699
|
-
if (!wrappedItems.find((i) => i.index === index)) {
|
|
5700
|
-
el.classList.remove("wrapped");
|
|
5701
|
-
}
|
|
5702
|
-
});
|
|
5703
|
-
};
|
|
5704
|
-
var getOverflowIndicator = (container) => container.querySelector('[data-index="overflow"]');
|
|
5705
|
-
var getOverflowedItem = (container) => container.querySelector(".wrapped");
|
|
5706
|
-
var getElementWidth = (el) => parseInt(getComputedStyle(el).getPropertyValue("width"));
|
|
5707
|
-
var getAvailableSpace = (container, overflowIndicator) => {
|
|
5708
|
-
const { right: containerRight } = container.getBoundingClientRect();
|
|
5709
|
-
const paddingRight = parseInt(
|
|
5710
|
-
getComputedStyle(container).getPropertyValue("padding-right")
|
|
5711
|
-
);
|
|
5712
|
-
const { right: indicatorRight } = overflowIndicator.getBoundingClientRect();
|
|
5713
|
-
return containerRight - paddingRight - indicatorRight;
|
|
5714
|
-
};
|
|
5715
|
-
var removeOverflowIndicatorIfNoLongerNeeded = (container) => {
|
|
5716
|
-
const overflowIndicator = getOverflowIndicator(container);
|
|
5717
|
-
const availableSpace = getAvailableSpace(container, overflowIndicator);
|
|
5718
|
-
const indicatorWidth = getElementWidth(overflowIndicator);
|
|
5719
|
-
const overflowedItem = getOverflowedItem(container);
|
|
5720
|
-
const overflowWidth = getElementWidth(overflowedItem);
|
|
5721
|
-
if (overflowWidth <= availableSpace + indicatorWidth) {
|
|
5722
|
-
container.classList.remove("overflowed");
|
|
5723
|
-
overflowedItem.classList.remove("wrapped");
|
|
5724
|
-
return true;
|
|
5725
|
-
}
|
|
5726
|
-
return false;
|
|
5727
|
-
};
|
|
5728
|
-
var byPriorityDescending = (h1, h2) => {
|
|
5729
|
-
const {
|
|
5730
|
-
dataset: { index: i1 = "0", overflowPriority: p1 = "0" }
|
|
5731
|
-
} = h1;
|
|
5732
|
-
const {
|
|
5733
|
-
dataset: { index: i2 = "0", overflowPriority: p2 = "0" }
|
|
5734
|
-
} = h2;
|
|
5735
|
-
if (p1 > p2) {
|
|
5736
|
-
return -1;
|
|
5737
|
-
} else if (p1 < p2) {
|
|
5738
|
-
return 1;
|
|
5739
|
-
} else {
|
|
5740
|
-
return parseInt(i1) - parseInt(i2);
|
|
5741
|
-
}
|
|
5742
|
-
};
|
|
5743
|
-
var getNonwrappedItemsByPriority = (container) => Array.from(container.querySelectorAll(NON_WRAPPED_ITEM)).sort(
|
|
5744
|
-
byPriorityDescending
|
|
5745
|
-
);
|
|
5746
|
-
var switchWrappedItemIntoView = (container, overflowItem) => {
|
|
5747
|
-
const unwrappedItems = getNonwrappedItemsByPriority(container);
|
|
5748
|
-
const targetElement = getElementByDataIndex(
|
|
5749
|
-
container,
|
|
5750
|
-
overflowItem.index,
|
|
5751
|
-
true
|
|
5752
|
-
);
|
|
5753
|
-
let pos = -1;
|
|
5754
|
-
let unwrappedItem = unwrappedItems.at(pos);
|
|
5755
|
-
const itemWidth = getElementWidth(unwrappedItem);
|
|
5756
|
-
const targetWidth = getElementWidth(targetElement);
|
|
5757
|
-
const overflowIndicator = getOverflowIndicator(container);
|
|
5758
|
-
let availableSpace = getAvailableSpace(container, overflowIndicator) + itemWidth;
|
|
5759
|
-
if (availableSpace >= targetWidth) {
|
|
5760
|
-
switchWrapOnElements(targetElement, unwrappedItem);
|
|
5761
|
-
} else {
|
|
5762
|
-
const { left: lastLeft } = unwrappedItem.getBoundingClientRect();
|
|
5763
|
-
const baseAvailableSpace = availableSpace;
|
|
5764
|
-
const wrapTargets = [unwrappedItem];
|
|
5765
|
-
while (availableSpace < targetWidth) {
|
|
5766
|
-
pos -= 1;
|
|
5767
|
-
unwrappedItem = unwrappedItems.at(pos);
|
|
5768
|
-
wrapTargets.push(unwrappedItem);
|
|
5769
|
-
const { left: nextLeft } = unwrappedItem.getBoundingClientRect();
|
|
5770
|
-
const extraSpace = lastLeft - nextLeft;
|
|
5771
|
-
availableSpace = baseAvailableSpace + extraSpace;
|
|
5772
|
-
}
|
|
5773
|
-
targetElement == null ? void 0 : targetElement.classList.remove("wrapped");
|
|
5774
|
-
wrapTargets.forEach((item) => {
|
|
5775
|
-
item.classList.add("wrapped");
|
|
5776
|
-
});
|
|
5777
|
-
}
|
|
5778
|
-
const [nonWrappedItems, wrappedItems] = getNonWrappedAndWrappedItems(container);
|
|
5779
|
-
unmarkItemsWhichAreNoLongerWrapped(container, wrappedItems);
|
|
5780
|
-
return [nonWrappedItems, wrappedItems];
|
|
5781
|
-
};
|
|
5782
|
-
var switchWrapOnElements = (wrappedElement, nonWrappedElement) => {
|
|
5783
|
-
if (!wrappedElement || !nonWrappedElement) {
|
|
5784
|
-
throw Error("switchWrapOnElements, element undefined");
|
|
5785
|
-
}
|
|
5786
|
-
wrappedElement.classList.remove("wrapped");
|
|
5787
|
-
nonWrappedElement.classList.add("wrapped");
|
|
5788
|
-
};
|
|
5789
|
-
|
|
5790
|
-
// src/overflow-container/useOverflowContainer.ts
|
|
5791
|
-
var useOverflowContainer = ({
|
|
5792
|
-
allowDragDrop = false,
|
|
5793
|
-
itemCount,
|
|
5794
|
-
onMoveItem,
|
|
5795
|
-
onSwitchWrappedItemIntoView,
|
|
5796
|
-
orientation = "horizontal"
|
|
5797
|
-
}) => {
|
|
5798
|
-
const [container, setContainer] = useState10(null);
|
|
5799
|
-
const wrappedItemsRef = useRef13(NO_WRAPPED_ITEMS);
|
|
5800
|
-
const containerRef = useRef13(null);
|
|
5801
|
-
const setOverflowTabIndex = useCallback17((tabIndex) => {
|
|
5802
|
-
var _a;
|
|
5803
|
-
if (containerRef.current) {
|
|
5804
|
-
(_a = containerRef.current.querySelector(".vuuOverflowContainer-OverflowIndicator button")) == null ? void 0 : _a.setAttribute("tabindex", tabIndex);
|
|
5805
|
-
}
|
|
5806
|
-
}, []);
|
|
5807
|
-
const handleResize = useCallback17(async () => {
|
|
5808
|
-
if (container) {
|
|
5809
|
-
let [nonWrapped, wrapped] = getNonWrappedAndWrappedItems(
|
|
5810
|
-
container,
|
|
5811
|
-
orientation
|
|
5812
|
-
);
|
|
5813
|
-
applyOverflowClassToWrappedItems(
|
|
5814
|
-
container,
|
|
5815
|
-
wrapped,
|
|
5816
|
-
"vuuOverflowContainer-wrapContainer"
|
|
5817
|
-
);
|
|
5818
|
-
if (overflowIndicatorHasWrappedButShouldNotHave(wrapped)) {
|
|
5819
|
-
wrapped = await correctForWrappedOverflowIndicator(container, wrapped);
|
|
5820
|
-
}
|
|
5821
|
-
while (highPriorityItemsHaveWrappedButShouldNotHave(nonWrapped, wrapped)) {
|
|
5822
|
-
[nonWrapped, wrapped] = await correctForWrappedHighPriorityItems(
|
|
5823
|
-
container,
|
|
5824
|
-
nonWrapped,
|
|
5825
|
-
wrapped
|
|
5826
|
-
);
|
|
5827
|
-
}
|
|
5828
|
-
if (wrapped.length === 1) {
|
|
5829
|
-
if (removeOverflowIndicatorIfNoLongerNeeded(container)) {
|
|
5830
|
-
wrapped = NO_WRAPPED_ITEMS;
|
|
5831
|
-
}
|
|
5832
|
-
}
|
|
5833
|
-
if (wrappedItemsRef.current.length === 0 && wrapped.length > 0) {
|
|
5834
|
-
setOverflowTabIndex("0");
|
|
5835
|
-
} else if (wrappedItemsRef.current.length > 0 && wrapped.length === 0) {
|
|
5836
|
-
setOverflowTabIndex("-1");
|
|
5837
|
-
}
|
|
5838
|
-
wrappedItemsRef.current = wrapped;
|
|
5839
|
-
}
|
|
5840
|
-
}, [container, orientation, setOverflowTabIndex]);
|
|
5841
|
-
const hasOverflowItem = (opt) => typeof opt === "object" && opt !== null && "overflowItem" in opt;
|
|
5842
|
-
const [menuBuilder, menuActionHandler] = useMemo8(() => {
|
|
5843
|
-
return [
|
|
5844
|
-
() => {
|
|
5845
|
-
const { current: menuItems } = wrappedItemsRef;
|
|
5846
|
-
return menuItems.map((item) => {
|
|
5847
|
-
return {
|
|
5848
|
-
label: item.label,
|
|
5849
|
-
action: `activate-item-${item.index}`,
|
|
5850
|
-
options: { overflowItem: item }
|
|
5851
|
-
};
|
|
5852
|
-
});
|
|
5853
|
-
},
|
|
5854
|
-
// The menu items are our overflowed items, selecting one by default
|
|
5855
|
-
// brings it back onto the toolbar - TODO is this right ?
|
|
5856
|
-
({ options }) => {
|
|
5857
|
-
if (container && hasOverflowItem(options)) {
|
|
5858
|
-
const [, wrappedItems] = switchWrappedItemIntoView(
|
|
5859
|
-
container,
|
|
5860
|
-
options.overflowItem
|
|
5861
|
-
);
|
|
5862
|
-
wrappedItemsRef.current = wrappedItems;
|
|
5863
|
-
onSwitchWrappedItemIntoView == null ? void 0 : onSwitchWrappedItemIntoView(options.overflowItem);
|
|
5864
|
-
}
|
|
5865
|
-
return true;
|
|
5866
|
-
}
|
|
5867
|
-
];
|
|
5868
|
-
}, [container, onSwitchWrappedItemIntoView]);
|
|
5869
|
-
const resizeObserver3 = useMemo8(() => {
|
|
5870
|
-
const { sizeProp } = MEASURES[orientation];
|
|
5871
|
-
let currentSize = 0;
|
|
5872
|
-
return new ResizeObserver((entries) => {
|
|
5873
|
-
for (const entry of entries) {
|
|
5874
|
-
const { [sizeProp]: actualSize } = entry.contentRect;
|
|
5875
|
-
const size = Math.round(actualSize);
|
|
5876
|
-
if (isValidNumber2(size) && currentSize !== size) {
|
|
5877
|
-
currentSize = size;
|
|
5878
|
-
handleResize();
|
|
5879
|
-
}
|
|
5880
|
-
}
|
|
5881
|
-
});
|
|
5882
|
-
}, [handleResize, orientation]);
|
|
5883
|
-
useLayoutEffectSkipFirst(() => {
|
|
5884
|
-
handleResize();
|
|
5885
|
-
}, [handleResize, itemCount]);
|
|
5886
|
-
useMemo8(() => {
|
|
5887
|
-
if (container) {
|
|
5888
|
-
resizeObserver3.observe(container);
|
|
5889
|
-
}
|
|
5890
|
-
}, [container, resizeObserver3]);
|
|
5891
|
-
const callbackRef = useCallback17((el) => {
|
|
5892
|
-
setContainer(containerRef.current = el);
|
|
5893
|
-
}, []);
|
|
5894
|
-
const handleDrop = useCallback17(
|
|
5895
|
-
(fromIndex, toIndex) => {
|
|
5896
|
-
onMoveItem == null ? void 0 : onMoveItem(fromIndex, toIndex);
|
|
5897
|
-
},
|
|
5898
|
-
[onMoveItem]
|
|
5899
|
-
);
|
|
5900
|
-
const { onMouseDown: dragDropHookHandleMouseDown, ...dragDropHook } = useDragDrop({
|
|
5901
|
-
allowDragDrop,
|
|
5902
|
-
containerRef,
|
|
5903
|
-
// this is for useDragDropNext
|
|
5904
|
-
draggableClassName: `vuuOverflowContainer`,
|
|
5905
|
-
// extendedDropZone: overflowedItems.length > 0,
|
|
5906
|
-
onDrop: handleDrop,
|
|
5907
|
-
orientation: "horizontal",
|
|
5908
|
-
itemQuery: ".vuuOverflowContainer-item"
|
|
5909
|
-
});
|
|
5910
|
-
return {
|
|
5911
|
-
menuActionHandler,
|
|
5912
|
-
menuBuilder,
|
|
5913
|
-
onItemMouseDown: dragDropHookHandleMouseDown,
|
|
5914
|
-
rootRef: callbackRef,
|
|
5915
|
-
...dragDropHook
|
|
5916
|
-
};
|
|
5917
|
-
};
|
|
5918
|
-
|
|
5919
|
-
// src/overflow-container/OverflowContainer.tsx
|
|
5920
|
-
import { jsx as jsx18, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
5921
|
-
var classBase10 = "vuuOverflowContainer";
|
|
5922
|
-
var WrapContainer = React15.memo(
|
|
5923
|
-
({
|
|
5924
|
-
PopupMenuProps: PopupMenuProps2,
|
|
5925
|
-
allowDragDrop,
|
|
5926
|
-
children,
|
|
5927
|
-
className: classNameProp,
|
|
5928
|
-
height: heightProp,
|
|
5929
|
-
id,
|
|
5930
|
-
onMoveItem,
|
|
5931
|
-
onSwitchWrappedItemIntoView,
|
|
5932
|
-
orientation = "horizontal",
|
|
5933
|
-
overflowIcon,
|
|
5934
|
-
overflowPosition = "end"
|
|
5935
|
-
}) => {
|
|
5936
|
-
const childElements = asReactElements(children);
|
|
5937
|
-
const {
|
|
5938
|
-
draggable,
|
|
5939
|
-
draggedItemIndex,
|
|
5940
|
-
menuActionHandler,
|
|
5941
|
-
menuBuilder,
|
|
5942
|
-
onItemMouseDown,
|
|
5943
|
-
rootRef
|
|
5944
|
-
} = useOverflowContainer({
|
|
5945
|
-
allowDragDrop,
|
|
5946
|
-
itemCount: childElements.length,
|
|
5947
|
-
onMoveItem,
|
|
5948
|
-
onSwitchWrappedItemIntoView,
|
|
5949
|
-
orientation
|
|
5950
|
-
});
|
|
5951
|
-
const height = orientation === "vertical" ? "100%" : `${heightProp}px`;
|
|
5952
|
-
const style = {
|
|
5953
|
-
"--overflow-container-height": `${height}`
|
|
5954
|
-
};
|
|
5955
|
-
const className = cx11(`${classBase10}-wrapContainer`, classNameProp, {
|
|
5956
|
-
[`${classBase10}-horizontal`]: orientation === "horizontal",
|
|
5957
|
-
[`${classBase10}-vertical`]: orientation === "vertical"
|
|
5958
|
-
});
|
|
5959
|
-
const content = childElements.map((childEl, i) => {
|
|
5960
|
-
const {
|
|
5961
|
-
"data-align": align,
|
|
5962
|
-
"data-overflow-priority": overflowPriority = "0",
|
|
5963
|
-
id: itemId = `${id}-${i}`,
|
|
5964
|
-
label = `Item ${i + 1}`
|
|
5965
|
-
} = childEl.props;
|
|
5966
|
-
return /* @__PURE__ */ jsx18(
|
|
5967
|
-
"div",
|
|
5968
|
-
{
|
|
5969
|
-
className: cx11(`${classBase10}-item`, {
|
|
5970
|
-
"vuuDraggable-dragAway": draggedItemIndex === i
|
|
5971
|
-
}),
|
|
5972
|
-
"data-index": i,
|
|
5973
|
-
"data-align": align,
|
|
5974
|
-
"data-label": label,
|
|
5975
|
-
"data-overflow-priority": overflowPriority,
|
|
5976
|
-
id: `${itemId}-wrapper`,
|
|
5977
|
-
onMouseDown: onItemMouseDown,
|
|
5978
|
-
children: childEl
|
|
5979
|
-
},
|
|
5980
|
-
i
|
|
5981
|
-
);
|
|
5982
|
-
});
|
|
5983
|
-
const overflowIndicator = /* @__PURE__ */ jsx18(
|
|
5984
|
-
"div",
|
|
5985
|
-
{
|
|
5986
|
-
className: `${classBase10}-OverflowIndicator`,
|
|
5987
|
-
"data-index": "overflow",
|
|
5988
|
-
children: /* @__PURE__ */ jsx18(
|
|
5989
|
-
PopupMenu,
|
|
5990
|
-
{
|
|
5991
|
-
...PopupMenuProps2,
|
|
5992
|
-
icon: overflowIcon,
|
|
5993
|
-
menuBuilder,
|
|
5994
|
-
menuActionHandler,
|
|
5995
|
-
tabIndex: -1
|
|
5996
|
-
}
|
|
5997
|
-
)
|
|
5998
|
-
},
|
|
5999
|
-
"overflow"
|
|
6000
|
-
);
|
|
6001
|
-
content.push(overflowIndicator);
|
|
6002
|
-
return /* @__PURE__ */ jsxs5("div", { className, ref: rootRef, style, children: [
|
|
6003
|
-
content,
|
|
6004
|
-
draggable
|
|
6005
|
-
] });
|
|
6006
|
-
}
|
|
6007
|
-
);
|
|
6008
|
-
WrapContainer.displayName = "OverflowContainer.InnerContainer";
|
|
6009
|
-
var OverflowContainer = forwardRef7(function OverflowContainer2({
|
|
6010
|
-
PopupMenuProps: PopupMenuProps2,
|
|
6011
|
-
allowDragDrop = false,
|
|
6012
|
-
children,
|
|
6013
|
-
className,
|
|
6014
|
-
height = 44,
|
|
6015
|
-
id: idProp,
|
|
6016
|
-
onMoveItem,
|
|
6017
|
-
onSwitchWrappedItemIntoView,
|
|
6018
|
-
orientation,
|
|
6019
|
-
overflowIcon,
|
|
6020
|
-
overflowPosition,
|
|
6021
|
-
...htmlAttributes
|
|
6022
|
-
}, forwardedRef) {
|
|
6023
|
-
const id = useId2(idProp);
|
|
6024
|
-
return /* @__PURE__ */ jsx18(
|
|
6025
|
-
"div",
|
|
6026
|
-
{
|
|
6027
|
-
...htmlAttributes,
|
|
6028
|
-
className: cx11(cx11(className, classBase10)),
|
|
6029
|
-
id,
|
|
6030
|
-
ref: forwardedRef,
|
|
6031
|
-
children: /* @__PURE__ */ jsx18(
|
|
6032
|
-
WrapContainer,
|
|
6033
|
-
{
|
|
6034
|
-
PopupMenuProps: PopupMenuProps2,
|
|
6035
|
-
allowDragDrop,
|
|
6036
|
-
height,
|
|
6037
|
-
id,
|
|
6038
|
-
orientation,
|
|
6039
|
-
overflowIcon,
|
|
6040
|
-
overflowPosition,
|
|
6041
|
-
onMoveItem,
|
|
6042
|
-
onSwitchWrappedItemIntoView,
|
|
6043
|
-
children
|
|
6044
|
-
}
|
|
6045
|
-
)
|
|
6046
|
-
}
|
|
6047
|
-
);
|
|
6048
|
-
});
|
|
6049
|
-
|
|
6050
5191
|
// src/palette/Palette.tsx
|
|
6051
5192
|
import { uuid as uuid5 } from "@vuu-ui/vuu-utils";
|
|
6052
5193
|
import {
|
|
6053
5194
|
List,
|
|
6054
5195
|
ListItem
|
|
6055
5196
|
} from "@vuu-ui/vuu-ui-controls";
|
|
6056
|
-
import
|
|
5197
|
+
import cx10 from "clsx";
|
|
6057
5198
|
import {
|
|
6058
5199
|
cloneElement as cloneElement5,
|
|
6059
5200
|
memo
|
|
6060
5201
|
} from "react";
|
|
6061
|
-
import { jsx as
|
|
5202
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
6062
5203
|
var clonePaletteItem = (paletteItem) => {
|
|
6063
5204
|
const dolly = paletteItem.cloneNode(true);
|
|
6064
5205
|
dolly.id = "";
|
|
@@ -6075,10 +5216,10 @@ var PaletteItem = memo(
|
|
|
6075
5216
|
closeable,
|
|
6076
5217
|
...props
|
|
6077
5218
|
}) => {
|
|
6078
|
-
return /* @__PURE__ */
|
|
5219
|
+
return /* @__PURE__ */ jsx17(
|
|
6079
5220
|
ListItem,
|
|
6080
5221
|
{
|
|
6081
|
-
className:
|
|
5222
|
+
className: cx10("vuuPaletteItem", className),
|
|
6082
5223
|
"data-draggable": true,
|
|
6083
5224
|
"data-icon": "draggable",
|
|
6084
5225
|
...props
|
|
@@ -6097,7 +5238,7 @@ var Palette = ({
|
|
|
6097
5238
|
...props
|
|
6098
5239
|
}) => {
|
|
6099
5240
|
const dispatch = useLayoutProviderDispatch();
|
|
6100
|
-
const
|
|
5241
|
+
const classBase11 = "vuuPalette";
|
|
6101
5242
|
function handleMouseDown(evt) {
|
|
6102
5243
|
var _a, _b;
|
|
6103
5244
|
const target = evt.target;
|
|
@@ -6110,7 +5251,7 @@ var Palette = ({
|
|
|
6110
5251
|
const { height, left, top, width } = listItemElement.getBoundingClientRect();
|
|
6111
5252
|
const id = uuid5();
|
|
6112
5253
|
const identifiers = { id, key: id };
|
|
6113
|
-
const component = template ? payload : /* @__PURE__ */
|
|
5254
|
+
const component = template ? payload : /* @__PURE__ */ jsx17(
|
|
6114
5255
|
MemoView,
|
|
6115
5256
|
{
|
|
6116
5257
|
...ViewProps3,
|
|
@@ -6144,12 +5285,12 @@ var Palette = ({
|
|
|
6144
5285
|
type: "drag-start"
|
|
6145
5286
|
});
|
|
6146
5287
|
}
|
|
6147
|
-
return /* @__PURE__ */
|
|
5288
|
+
return /* @__PURE__ */ jsx17(
|
|
6148
5289
|
List,
|
|
6149
5290
|
{
|
|
6150
5291
|
...ListProps2,
|
|
6151
5292
|
...props,
|
|
6152
|
-
className:
|
|
5293
|
+
className: cx10(classBase11, className, `${classBase11}-${orientation}`),
|
|
6153
5294
|
itemHeight,
|
|
6154
5295
|
selected: null,
|
|
6155
5296
|
children: children.map(
|
|
@@ -6165,20 +5306,20 @@ registerComponent("Palette", Palette, "view");
|
|
|
6165
5306
|
|
|
6166
5307
|
// src/stack/Stack.tsx
|
|
6167
5308
|
import { Tab, Tabstrip } from "@vuu-ui/vuu-ui-controls";
|
|
6168
|
-
import { useId as
|
|
6169
|
-
import
|
|
6170
|
-
import
|
|
6171
|
-
forwardRef as
|
|
6172
|
-
useCallback as
|
|
6173
|
-
useRef as
|
|
5309
|
+
import { useId as useId2 } from "@vuu-ui/vuu-utils";
|
|
5310
|
+
import cx11 from "clsx";
|
|
5311
|
+
import React15, {
|
|
5312
|
+
forwardRef as forwardRef6,
|
|
5313
|
+
useCallback as useCallback15,
|
|
5314
|
+
useRef as useRef11
|
|
6174
5315
|
} from "react";
|
|
6175
|
-
import { jsx as
|
|
6176
|
-
var
|
|
5316
|
+
import { jsx as jsx18, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
5317
|
+
var classBase10 = "vuuTabs";
|
|
6177
5318
|
var getDefaultTabIcon = () => void 0;
|
|
6178
5319
|
var getChildElements = (children) => {
|
|
6179
5320
|
const elements = [];
|
|
6180
|
-
|
|
6181
|
-
if (
|
|
5321
|
+
React15.Children.forEach(children, (child) => {
|
|
5322
|
+
if (React15.isValidElement(child)) {
|
|
6182
5323
|
elements.push(child);
|
|
6183
5324
|
} else {
|
|
6184
5325
|
console.warn(`Stack has unexpected child element type`);
|
|
@@ -6191,7 +5332,7 @@ var DefaultTabstripProps = {
|
|
|
6191
5332
|
allowCloseTab: false,
|
|
6192
5333
|
allowRenameTab: false
|
|
6193
5334
|
};
|
|
6194
|
-
var Stack =
|
|
5335
|
+
var Stack = forwardRef6(function Stack2({
|
|
6195
5336
|
TabstripProps: TabstripProps2 = DefaultTabstripProps,
|
|
6196
5337
|
active = 0,
|
|
6197
5338
|
children,
|
|
@@ -6210,14 +5351,14 @@ var Stack = forwardRef8(function Stack2({
|
|
|
6210
5351
|
style
|
|
6211
5352
|
}, ref) {
|
|
6212
5353
|
var _a;
|
|
6213
|
-
const id =
|
|
6214
|
-
const tabLabels =
|
|
5354
|
+
const id = useId2(idProp);
|
|
5355
|
+
const tabLabels = useRef11([]);
|
|
6215
5356
|
const {
|
|
6216
5357
|
allowCloseTab,
|
|
6217
5358
|
allowRenameTab,
|
|
6218
5359
|
className: tabstripClassName
|
|
6219
5360
|
} = TabstripProps2;
|
|
6220
|
-
const handleExitEditMode =
|
|
5361
|
+
const handleExitEditMode = useCallback15(
|
|
6221
5362
|
(_oldText, newText, _allowDeactivation, tabIndex) => {
|
|
6222
5363
|
onTabEdit == null ? void 0 : onTabEdit(tabIndex, newText);
|
|
6223
5364
|
},
|
|
@@ -6225,7 +5366,7 @@ var Stack = forwardRef8(function Stack2({
|
|
|
6225
5366
|
);
|
|
6226
5367
|
const activeChild = () => {
|
|
6227
5368
|
var _a2;
|
|
6228
|
-
if (
|
|
5369
|
+
if (React15.isValidElement(children)) {
|
|
6229
5370
|
return children;
|
|
6230
5371
|
}
|
|
6231
5372
|
if (Array.isArray(children)) {
|
|
@@ -6241,7 +5382,7 @@ var Stack = forwardRef8(function Stack2({
|
|
|
6241
5382
|
} = child2.props;
|
|
6242
5383
|
const label = getTabLabel(child2, idx, tabLabels.current);
|
|
6243
5384
|
tabLabels.current.push(label);
|
|
6244
|
-
return /* @__PURE__ */
|
|
5385
|
+
return /* @__PURE__ */ jsx18(
|
|
6245
5386
|
Tab,
|
|
6246
5387
|
{
|
|
6247
5388
|
ariaControls: childId,
|
|
@@ -6259,24 +5400,24 @@ var Stack = forwardRef8(function Stack2({
|
|
|
6259
5400
|
const child = activeChild();
|
|
6260
5401
|
const isHorizontal = showTabs === "left" || showTabs === "right";
|
|
6261
5402
|
const tabstripOrientation = isHorizontal ? "vertical" : "horizontal";
|
|
6262
|
-
return /* @__PURE__ */
|
|
5403
|
+
return /* @__PURE__ */ jsxs5(
|
|
6263
5404
|
"div",
|
|
6264
5405
|
{
|
|
6265
|
-
className:
|
|
6266
|
-
[`${
|
|
5406
|
+
className: cx11(classBase10, classNameProp, {
|
|
5407
|
+
[`${classBase10}-horizontal`]: isHorizontal
|
|
6267
5408
|
}),
|
|
6268
5409
|
style,
|
|
6269
5410
|
id,
|
|
6270
5411
|
ref,
|
|
6271
5412
|
children: [
|
|
6272
|
-
showTabs ? /* @__PURE__ */
|
|
5413
|
+
showTabs ? /* @__PURE__ */ jsx18(
|
|
6273
5414
|
Tabstrip,
|
|
6274
5415
|
{
|
|
6275
5416
|
...TabstripProps2,
|
|
6276
5417
|
activeTabIndex: (_a = TabstripProps2 == null ? void 0 : TabstripProps2.activeTabIndex) != null ? _a : child === null ? -1 : active,
|
|
6277
5418
|
allowDragDrop: TabstripProps2.allowDragDrop !== false,
|
|
6278
5419
|
animateSelectionThumb: true,
|
|
6279
|
-
className:
|
|
5420
|
+
className: cx11("vuuTabHeader", tabstripClassName),
|
|
6280
5421
|
"aria-label": "data tabs",
|
|
6281
5422
|
keyBoardActivation,
|
|
6282
5423
|
onActiveChange: onTabSelectionChanged,
|
|
@@ -6288,11 +5429,11 @@ var Stack = forwardRef8(function Stack2({
|
|
|
6288
5429
|
children: renderTabs()
|
|
6289
5430
|
}
|
|
6290
5431
|
) : null,
|
|
6291
|
-
/* @__PURE__ */
|
|
5432
|
+
/* @__PURE__ */ jsx18(
|
|
6292
5433
|
"div",
|
|
6293
5434
|
{
|
|
6294
5435
|
"aria-labelledby": `${id}-${active}`,
|
|
6295
|
-
className: `${
|
|
5436
|
+
className: `${classBase10}-tabPanel`,
|
|
6296
5437
|
role: "tabpanel",
|
|
6297
5438
|
children: child
|
|
6298
5439
|
}
|
|
@@ -6304,10 +5445,10 @@ var Stack = forwardRef8(function Stack2({
|
|
|
6304
5445
|
Stack.displayName = "Stack";
|
|
6305
5446
|
|
|
6306
5447
|
// src/stack/StackLayout.tsx
|
|
6307
|
-
import { useId as
|
|
6308
|
-
import
|
|
6309
|
-
import { jsx as
|
|
6310
|
-
var defaultCreateNewChild = () => /* @__PURE__ */
|
|
5448
|
+
import { useId as useId3 } from "@vuu-ui/vuu-utils";
|
|
5449
|
+
import React16, { useCallback as useCallback16, useRef as useRef12 } from "react";
|
|
5450
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
5451
|
+
var defaultCreateNewChild = () => /* @__PURE__ */ jsx19(
|
|
6311
5452
|
Placeholder,
|
|
6312
5453
|
{
|
|
6313
5454
|
resizeable: true,
|
|
@@ -6316,7 +5457,7 @@ var defaultCreateNewChild = () => /* @__PURE__ */ jsx21(
|
|
|
6316
5457
|
);
|
|
6317
5458
|
var StackLayout = (props) => {
|
|
6318
5459
|
var _a;
|
|
6319
|
-
const ref =
|
|
5460
|
+
const ref = useRef12(null);
|
|
6320
5461
|
const dispatch = useLayoutProviderDispatch();
|
|
6321
5462
|
const { loadState } = usePersistentState();
|
|
6322
5463
|
const {
|
|
@@ -6327,7 +5468,7 @@ var StackLayout = (props) => {
|
|
|
6327
5468
|
...restProps
|
|
6328
5469
|
} = props;
|
|
6329
5470
|
const { children } = props;
|
|
6330
|
-
const id =
|
|
5471
|
+
const id = useId3(idProp);
|
|
6331
5472
|
const [dispatchViewAction] = useViewActionDispatcher(id, ref, path);
|
|
6332
5473
|
const createNewChildFromContext = useLayoutCreateNewChild();
|
|
6333
5474
|
const createNewChild = (_a = createNewChildProp != null ? createNewChildProp : createNewChildFromContext) != null ? _a : defaultCreateNewChild;
|
|
@@ -6337,7 +5478,7 @@ var StackLayout = (props) => {
|
|
|
6337
5478
|
onTabSelectionChanged == null ? void 0 : onTabSelectionChanged(nextIdx);
|
|
6338
5479
|
}
|
|
6339
5480
|
};
|
|
6340
|
-
const handleTabClose =
|
|
5481
|
+
const handleTabClose = useCallback16(
|
|
6341
5482
|
(tabIndex) => {
|
|
6342
5483
|
if (Array.isArray(children)) {
|
|
6343
5484
|
const {
|
|
@@ -6348,9 +5489,9 @@ var StackLayout = (props) => {
|
|
|
6348
5489
|
},
|
|
6349
5490
|
[children, dispatch]
|
|
6350
5491
|
);
|
|
6351
|
-
const handleTabAdd =
|
|
5492
|
+
const handleTabAdd = useCallback16(() => {
|
|
6352
5493
|
if (path) {
|
|
6353
|
-
const tabIndex =
|
|
5494
|
+
const tabIndex = React16.Children.count(children);
|
|
6354
5495
|
const component = createNewChild(tabIndex);
|
|
6355
5496
|
dispatch({
|
|
6356
5497
|
type: "add",
|
|
@@ -6359,7 +5500,7 @@ var StackLayout = (props) => {
|
|
|
6359
5500
|
});
|
|
6360
5501
|
}
|
|
6361
5502
|
}, [children, createNewChild, dispatch, path]);
|
|
6362
|
-
const handleMoveTab =
|
|
5503
|
+
const handleMoveTab = useCallback16(
|
|
6363
5504
|
(fromIndex, toIndex) => {
|
|
6364
5505
|
if (path) {
|
|
6365
5506
|
dispatch({
|
|
@@ -6394,7 +5535,7 @@ var StackLayout = (props) => {
|
|
|
6394
5535
|
return loadState(id2, "view-title") || title || // This will normally never be called as title is always assigned in layout model
|
|
6395
5536
|
getDefaultTabLabel(component, idx, existingLabels);
|
|
6396
5537
|
};
|
|
6397
|
-
return /* @__PURE__ */
|
|
5538
|
+
return /* @__PURE__ */ jsx19(
|
|
6398
5539
|
Stack,
|
|
6399
5540
|
{
|
|
6400
5541
|
...restProps,
|
|
@@ -6413,643 +5554,33 @@ var StackLayout = (props) => {
|
|
|
6413
5554
|
StackLayout.displayName = "Stack";
|
|
6414
5555
|
registerComponent("Stack", StackLayout, "container");
|
|
6415
5556
|
|
|
6416
|
-
// src/toolbar/Toolbar.tsx
|
|
6417
|
-
import {
|
|
6418
|
-
forwardCallbackProps
|
|
6419
|
-
} from "@vuu-ui/vuu-ui-controls";
|
|
6420
|
-
import { useId as useId5 } from "@vuu-ui/vuu-utils";
|
|
6421
|
-
import cx14 from "clsx";
|
|
6422
|
-
import React18, { useMemo as useMemo9, useRef as useRef18 } from "react";
|
|
6423
|
-
|
|
6424
|
-
// src/toolbar/useToolbar.ts
|
|
6425
|
-
import { isValidNumber as isValidNumber3 } from "@vuu-ui/vuu-utils";
|
|
6426
|
-
import {
|
|
6427
|
-
useCallback as useCallback22,
|
|
6428
|
-
useRef as useRef17
|
|
6429
|
-
} from "react";
|
|
6430
|
-
|
|
6431
|
-
// src/toolbar/useKeyboardNavigation.ts
|
|
6432
|
-
import { useControlled as useControlled2 } from "@salt-ds/core";
|
|
6433
|
-
import {
|
|
6434
|
-
dispatchMouseEvent,
|
|
6435
|
-
getClosest,
|
|
6436
|
-
getElementDataIndex as getElementDataIndex2,
|
|
6437
|
-
getFocusableElement
|
|
6438
|
-
} from "@vuu-ui/vuu-utils";
|
|
6439
|
-
import {
|
|
6440
|
-
useCallback as useCallback20,
|
|
6441
|
-
useRef as useRef16,
|
|
6442
|
-
useState as useState11
|
|
6443
|
-
} from "react";
|
|
6444
|
-
import {
|
|
6445
|
-
ArrowDown,
|
|
6446
|
-
ArrowUp,
|
|
6447
|
-
ArrowLeft,
|
|
6448
|
-
ArrowRight,
|
|
6449
|
-
Home,
|
|
6450
|
-
End
|
|
6451
|
-
} from "@vuu-ui/vuu-utils";
|
|
6452
|
-
|
|
6453
|
-
// src/toolbar/toolbar-dom-utils.ts
|
|
6454
|
-
import { getElementDataIndex } from "@vuu-ui/vuu-utils";
|
|
6455
|
-
var getIndexOfItem = (container, query) => {
|
|
6456
|
-
if (container) {
|
|
6457
|
-
const targetTab = container.querySelector(
|
|
6458
|
-
`[data-index]:has(${query})`
|
|
6459
|
-
);
|
|
6460
|
-
return getElementDataIndex(targetTab);
|
|
6461
|
-
}
|
|
6462
|
-
return -1;
|
|
6463
|
-
};
|
|
6464
|
-
var getIndexOfEditedItem = (container) => getIndexOfItem(container, ".vuuEditableLabel-editing");
|
|
6465
|
-
|
|
6466
|
-
// src/toolbar/useKeyboardNavigation.ts
|
|
6467
|
-
var navigation = {
|
|
6468
|
-
horizontal: {
|
|
6469
|
-
[Home]: "start",
|
|
6470
|
-
[End]: "end",
|
|
6471
|
-
[ArrowLeft]: "bwd",
|
|
6472
|
-
[ArrowRight]: "fwd"
|
|
6473
|
-
},
|
|
6474
|
-
vertical: {
|
|
6475
|
-
[Home]: "start",
|
|
6476
|
-
[End]: "end",
|
|
6477
|
-
[ArrowUp]: "bwd",
|
|
6478
|
-
[ArrowDown]: "fwd"
|
|
6479
|
-
}
|
|
6480
|
-
};
|
|
6481
|
-
var isOverflowIndicator = (el) => el !== null && el.dataset.index === "overflow";
|
|
6482
|
-
var itemIsNotFocusable = (container, direction, indexCount, nextIdx, hasOverflowedItem) => {
|
|
6483
|
-
if (container) {
|
|
6484
|
-
const withinRangeBwd = direction === "bwd" && nextIdx > 0;
|
|
6485
|
-
const withinRangeFwd = direction === "fwd" && nextIdx < indexCount;
|
|
6486
|
-
const withinRange = withinRangeBwd || withinRangeFwd;
|
|
6487
|
-
const nextElement = getElementByPosition(container, nextIdx, true);
|
|
6488
|
-
const isOverflowedItem = hasOverflowedItem && !isNonWrappedElement(nextElement);
|
|
6489
|
-
const isHiddenOverflowIndicator = !hasOverflowedItem && isOverflowIndicator(nextElement);
|
|
6490
|
-
hasOverflowedItem && !isNonWrappedElement(nextElement);
|
|
6491
|
-
return withinRange && (isOverflowedItem || isHiddenOverflowIndicator);
|
|
6492
|
-
} else {
|
|
6493
|
-
return false;
|
|
6494
|
-
}
|
|
6495
|
-
};
|
|
6496
|
-
var isNavigationKey = (key, orientation = "horizontal") => navigation[orientation][key] !== void 0;
|
|
6497
|
-
var isMenuActivationKey = (key) => key === ArrowDown;
|
|
6498
|
-
function nextItemIdx(count, direction, idx) {
|
|
6499
|
-
if (direction === "start") {
|
|
6500
|
-
return 0;
|
|
6501
|
-
} else if (direction === "end") {
|
|
6502
|
-
return count - 1;
|
|
6503
|
-
} else if (direction === "bwd") {
|
|
6504
|
-
if (idx > 0) {
|
|
6505
|
-
return idx - 1;
|
|
6506
|
-
} else {
|
|
6507
|
-
return idx;
|
|
6508
|
-
}
|
|
6509
|
-
} else {
|
|
6510
|
-
if (idx === null) {
|
|
6511
|
-
return 0;
|
|
6512
|
-
} else if (idx === count - 1) {
|
|
6513
|
-
return idx;
|
|
6514
|
-
} else {
|
|
6515
|
-
return idx + 1;
|
|
6516
|
-
}
|
|
6517
|
-
}
|
|
6518
|
-
}
|
|
6519
|
-
var isNonWrappedElement = (element) => element !== null && !element.classList.contains("wrapped");
|
|
6520
|
-
var getToolbarItems = (container) => Array.from(container.querySelectorAll("[data-index]"));
|
|
6521
|
-
var getIndexOfOverflowItem = (container) => {
|
|
6522
|
-
if (container === null) {
|
|
6523
|
-
return -1;
|
|
6524
|
-
} else {
|
|
6525
|
-
const targets = getToolbarItems(container);
|
|
6526
|
-
const indexValues = targets.map((el) => el.dataset.index);
|
|
6527
|
-
return indexValues.indexOf("overflow");
|
|
6528
|
-
}
|
|
6529
|
-
};
|
|
6530
|
-
var getElementByPosition = (container, index, includeOverflowInd = false) => {
|
|
6531
|
-
if (container !== null) {
|
|
6532
|
-
const targets = getToolbarItems(container);
|
|
6533
|
-
const target = targets[index];
|
|
6534
|
-
if (!includeOverflowInd && isOverflowIndicator(target)) {
|
|
6535
|
-
return null;
|
|
6536
|
-
} else {
|
|
6537
|
-
return target;
|
|
6538
|
-
}
|
|
6539
|
-
}
|
|
6540
|
-
return null;
|
|
6541
|
-
};
|
|
6542
|
-
var useKeyboardNavigation = ({
|
|
6543
|
-
containerRef,
|
|
6544
|
-
defaultHighlightedIdx = -1,
|
|
6545
|
-
highlightedIdx: highlightedIdxProp,
|
|
6546
|
-
onNavigateOutOfBounds,
|
|
6547
|
-
orientation
|
|
6548
|
-
}) => {
|
|
6549
|
-
const mouseClickPending = useRef16(false);
|
|
6550
|
-
const focusedRef = useRef16(-1);
|
|
6551
|
-
const [hasFocus, setHasFocus] = useState11(false);
|
|
6552
|
-
const [highlightedIdx, _setHighlightedIdx] = useControlled2({
|
|
6553
|
-
controlled: highlightedIdxProp,
|
|
6554
|
-
default: defaultHighlightedIdx,
|
|
6555
|
-
name: "UseKeyboardNavigation"
|
|
6556
|
-
});
|
|
6557
|
-
const setHighlightedIdx = useCallback20(
|
|
6558
|
-
(value) => {
|
|
6559
|
-
_setHighlightedIdx(focusedRef.current = value);
|
|
6560
|
-
},
|
|
6561
|
-
[_setHighlightedIdx]
|
|
6562
|
-
);
|
|
6563
|
-
const keyboardNavigation = useRef16(false);
|
|
6564
|
-
const focusItem = useCallback20(
|
|
6565
|
-
(itemIndex, immediateFocus = false, withKeyboard, delay = 70) => {
|
|
6566
|
-
console.log(`focus item ${itemIndex}`);
|
|
6567
|
-
setHighlightedIdx(itemIndex);
|
|
6568
|
-
if (withKeyboard === true && !keyboardNavigation.current) {
|
|
6569
|
-
keyboardNavigation.current = true;
|
|
6570
|
-
}
|
|
6571
|
-
const setFocus = () => {
|
|
6572
|
-
const element = getElementByPosition(
|
|
6573
|
-
containerRef.current,
|
|
6574
|
-
itemIndex,
|
|
6575
|
-
true
|
|
6576
|
-
);
|
|
6577
|
-
if (element) {
|
|
6578
|
-
const focussableElement = getFocusableElement(element);
|
|
6579
|
-
focussableElement == null ? void 0 : focussableElement.focus();
|
|
6580
|
-
}
|
|
6581
|
-
};
|
|
6582
|
-
if (immediateFocus) {
|
|
6583
|
-
setFocus();
|
|
6584
|
-
} else {
|
|
6585
|
-
setTimeout(setFocus, delay);
|
|
6586
|
-
}
|
|
6587
|
-
},
|
|
6588
|
-
[containerRef, setHighlightedIdx]
|
|
6589
|
-
);
|
|
6590
|
-
const onFocus = (e) => {
|
|
6591
|
-
if (focusedRef.current === -1) {
|
|
6592
|
-
if (e.target.tabIndex === 0) {
|
|
6593
|
-
const index = getElementDataIndex2(getClosest(e.target, "index"));
|
|
6594
|
-
setHighlightedIdx(index);
|
|
6595
|
-
} else if (e.target.tabIndex === -1) {
|
|
6596
|
-
} else {
|
|
6597
|
-
const index = getIndexOfEditedItem(containerRef.current);
|
|
6598
|
-
if (index !== -1) {
|
|
6599
|
-
requestAnimationFrame(() => {
|
|
6600
|
-
setHighlightedIdx(index);
|
|
6601
|
-
});
|
|
6602
|
-
}
|
|
6603
|
-
}
|
|
6604
|
-
}
|
|
6605
|
-
};
|
|
6606
|
-
const getIndexCount = useCallback20(
|
|
6607
|
-
() => {
|
|
6608
|
-
var _a, _b;
|
|
6609
|
-
return (_b = (_a = containerRef.current) == null ? void 0 : _a.querySelectorAll(`[data-index]`).length) != null ? _b : 0;
|
|
6610
|
-
},
|
|
6611
|
-
[containerRef]
|
|
6612
|
-
);
|
|
6613
|
-
const nextFocusableItemIdx = useCallback20(
|
|
6614
|
-
(direction = "fwd", idx) => {
|
|
6615
|
-
var _a;
|
|
6616
|
-
const indexCount = getIndexCount();
|
|
6617
|
-
const index = typeof idx === "number" ? idx : indexCount;
|
|
6618
|
-
let nextIdx = nextItemIdx(indexCount, direction, index);
|
|
6619
|
-
const nextDirection = direction === "start" ? "fwd" : direction === "end" ? "bwd" : direction;
|
|
6620
|
-
const hasOverflowedItem = ((_a = containerRef.current) == null ? void 0 : _a.querySelector(
|
|
6621
|
-
".vuuOverflowContainer-wrapContainer-overflowed"
|
|
6622
|
-
)) != null;
|
|
6623
|
-
while (itemIsNotFocusable(
|
|
6624
|
-
containerRef.current,
|
|
6625
|
-
nextDirection,
|
|
6626
|
-
indexCount,
|
|
6627
|
-
nextIdx,
|
|
6628
|
-
hasOverflowedItem
|
|
6629
|
-
)) {
|
|
6630
|
-
const newIdx = nextItemIdx(indexCount, nextDirection, nextIdx);
|
|
6631
|
-
if (newIdx === nextIdx) {
|
|
6632
|
-
return index;
|
|
6633
|
-
} else {
|
|
6634
|
-
nextIdx = newIdx;
|
|
6635
|
-
}
|
|
6636
|
-
}
|
|
6637
|
-
return nextIdx;
|
|
6638
|
-
},
|
|
6639
|
-
[containerRef, getIndexCount]
|
|
6640
|
-
);
|
|
6641
|
-
const navigateChildItems = useCallback20(
|
|
6642
|
-
(e) => {
|
|
6643
|
-
const direction = navigation[orientation][e.key];
|
|
6644
|
-
const nextIdx = nextFocusableItemIdx(direction, highlightedIdx);
|
|
6645
|
-
console.log(`highlightedIdx = ${highlightedIdx}, nextIdx = ${nextIdx} `);
|
|
6646
|
-
if (nextIdx !== highlightedIdx) {
|
|
6647
|
-
const immediateFocus = true;
|
|
6648
|
-
focusItem(nextIdx, immediateFocus);
|
|
6649
|
-
} else {
|
|
6650
|
-
onNavigateOutOfBounds == null ? void 0 : onNavigateOutOfBounds(direction === "bwd" ? "start" : "end");
|
|
6651
|
-
}
|
|
6652
|
-
},
|
|
6653
|
-
[
|
|
6654
|
-
orientation,
|
|
6655
|
-
nextFocusableItemIdx,
|
|
6656
|
-
highlightedIdx,
|
|
6657
|
-
focusItem,
|
|
6658
|
-
onNavigateOutOfBounds
|
|
6659
|
-
]
|
|
6660
|
-
);
|
|
6661
|
-
const highlightedItemHasMenu = useCallback20(() => {
|
|
6662
|
-
const el = getElementByPosition(containerRef.current, highlightedIdx);
|
|
6663
|
-
if (el) {
|
|
6664
|
-
return el.querySelector(".vuuPopupMenu") != null;
|
|
6665
|
-
}
|
|
6666
|
-
return false;
|
|
6667
|
-
}, [containerRef, highlightedIdx]);
|
|
6668
|
-
const highlightedItemInEditState = useCallback20(() => {
|
|
6669
|
-
const el = getElementByPosition(containerRef.current, highlightedIdx);
|
|
6670
|
-
if (el) {
|
|
6671
|
-
return el.querySelector(".vuuEditableLabel-input") != null;
|
|
6672
|
-
}
|
|
6673
|
-
return false;
|
|
6674
|
-
}, [containerRef, highlightedIdx]);
|
|
6675
|
-
const activateItemMenu = useCallback20(() => {
|
|
6676
|
-
const el = getElementByPosition(containerRef.current, highlightedIdx);
|
|
6677
|
-
const menuEl = el == null ? void 0 : el.querySelector(".vuuPopupMenu");
|
|
6678
|
-
if (menuEl) {
|
|
6679
|
-
dispatchMouseEvent(menuEl, "click");
|
|
6680
|
-
}
|
|
6681
|
-
return false;
|
|
6682
|
-
}, [containerRef, highlightedIdx]);
|
|
6683
|
-
const handleKeyDown = useCallback20(
|
|
6684
|
-
(e) => {
|
|
6685
|
-
if (getIndexCount() > 0 && isNavigationKey(e.key, orientation)) {
|
|
6686
|
-
e.preventDefault();
|
|
6687
|
-
if (keyboardNavigation.current) {
|
|
6688
|
-
navigateChildItems(e);
|
|
6689
|
-
} else {
|
|
6690
|
-
keyboardNavigation.current = true;
|
|
6691
|
-
navigateChildItems(e);
|
|
6692
|
-
}
|
|
6693
|
-
} else if (isMenuActivationKey(e.key) && highlightedItemHasMenu() && !highlightedItemInEditState()) {
|
|
6694
|
-
activateItemMenu();
|
|
6695
|
-
}
|
|
6696
|
-
},
|
|
6697
|
-
[
|
|
6698
|
-
activateItemMenu,
|
|
6699
|
-
getIndexCount,
|
|
6700
|
-
highlightedItemHasMenu,
|
|
6701
|
-
highlightedItemInEditState,
|
|
6702
|
-
navigateChildItems,
|
|
6703
|
-
orientation
|
|
6704
|
-
]
|
|
6705
|
-
);
|
|
6706
|
-
const handleItemClick = (_, itemIndex) => {
|
|
6707
|
-
setHighlightedIdx(itemIndex);
|
|
6708
|
-
};
|
|
6709
|
-
const handleFocus = useCallback20(() => {
|
|
6710
|
-
if (!hasFocus) {
|
|
6711
|
-
setHasFocus(true);
|
|
6712
|
-
if (!mouseClickPending.current) {
|
|
6713
|
-
keyboardNavigation.current = true;
|
|
6714
|
-
} else {
|
|
6715
|
-
mouseClickPending.current = false;
|
|
6716
|
-
}
|
|
6717
|
-
}
|
|
6718
|
-
}, [hasFocus]);
|
|
6719
|
-
const handleContainerMouseDown = useCallback20(() => {
|
|
6720
|
-
if (!hasFocus) {
|
|
6721
|
-
mouseClickPending.current = true;
|
|
6722
|
-
}
|
|
6723
|
-
keyboardNavigation.current = false;
|
|
6724
|
-
}, [hasFocus]);
|
|
6725
|
-
const handleOverflowMenuClose = useCallback20(
|
|
6726
|
-
(closeReason) => {
|
|
6727
|
-
if ((closeReason == null ? void 0 : closeReason.type) === "escape") {
|
|
6728
|
-
const index = getIndexOfOverflowItem(containerRef.current);
|
|
6729
|
-
if (index !== -1) {
|
|
6730
|
-
focusItem(index);
|
|
6731
|
-
}
|
|
6732
|
-
}
|
|
6733
|
-
},
|
|
6734
|
-
[containerRef, focusItem]
|
|
6735
|
-
);
|
|
6736
|
-
const containerProps = {
|
|
6737
|
-
onBlur: (e) => {
|
|
6738
|
-
const sourceTarget = e.target.closest(".vuuToolbar");
|
|
6739
|
-
const destTarget = e.relatedTarget;
|
|
6740
|
-
if (sourceTarget && !(sourceTarget == null ? void 0 : sourceTarget.contains(destTarget))) {
|
|
6741
|
-
setHighlightedIdx(-1);
|
|
6742
|
-
setHasFocus(false);
|
|
6743
|
-
}
|
|
6744
|
-
},
|
|
6745
|
-
onMouseDownCapture: handleContainerMouseDown,
|
|
6746
|
-
onFocus: handleFocus,
|
|
6747
|
-
onMouseLeave: () => {
|
|
6748
|
-
keyboardNavigation.current = true;
|
|
6749
|
-
setHighlightedIdx(-1);
|
|
6750
|
-
mouseClickPending.current = false;
|
|
6751
|
-
}
|
|
6752
|
-
};
|
|
6753
|
-
return {
|
|
6754
|
-
containerProps,
|
|
6755
|
-
focusVisible: keyboardNavigation.current ? highlightedIdx : -1,
|
|
6756
|
-
focusIsWithinComponent: hasFocus,
|
|
6757
|
-
highlightedIdx,
|
|
6758
|
-
focusableIdx: 0,
|
|
6759
|
-
focusItem,
|
|
6760
|
-
onClick: handleItemClick,
|
|
6761
|
-
onFocus,
|
|
6762
|
-
onKeyDown: handleKeyDown,
|
|
6763
|
-
onOverflowMenuClose: handleOverflowMenuClose,
|
|
6764
|
-
setHighlightedIdx
|
|
6765
|
-
};
|
|
6766
|
-
};
|
|
6767
|
-
|
|
6768
|
-
// src/toolbar/useSelection.ts
|
|
6769
|
-
import { isSelectableElement, getClosestIndexItem } from "@vuu-ui/vuu-utils";
|
|
6770
|
-
import {
|
|
6771
|
-
allowMultipleSelection,
|
|
6772
|
-
deselectionIsAllowed,
|
|
6773
|
-
selectionIsDisallowed,
|
|
6774
|
-
useControlled as useControlled3
|
|
6775
|
-
} from "@vuu-ui/vuu-ui-controls";
|
|
6776
|
-
import { useCallback as useCallback21 } from "react";
|
|
6777
|
-
var defaultSelectionKeys = ["Enter", " "];
|
|
6778
|
-
var NO_SELECTION_HANDLERS = {};
|
|
6779
|
-
var useSelection = ({
|
|
6780
|
-
containerRef,
|
|
6781
|
-
defaultSelected,
|
|
6782
|
-
highlightedIdx,
|
|
6783
|
-
itemQuery,
|
|
6784
|
-
onSelectionChange,
|
|
6785
|
-
selected: selectedProp,
|
|
6786
|
-
selectionStrategy
|
|
6787
|
-
}) => {
|
|
6788
|
-
const [selected, setSelected, isControlled] = useControlled3({
|
|
6789
|
-
controlled: selectedProp,
|
|
6790
|
-
default: defaultSelected != null ? defaultSelected : [],
|
|
6791
|
-
name: "useSelection",
|
|
6792
|
-
state: "selected"
|
|
6793
|
-
});
|
|
6794
|
-
const isSelectionEvent = useCallback21(
|
|
6795
|
-
(evt) => defaultSelectionKeys.includes(evt.key),
|
|
6796
|
-
[]
|
|
6797
|
-
);
|
|
6798
|
-
const selectItem = useCallback21(
|
|
6799
|
-
(itemIndex, specialKey = false) => {
|
|
6800
|
-
const newSelected = allowMultipleSelection(selectionStrategy, specialKey) ? selected.concat(itemIndex) : [itemIndex];
|
|
6801
|
-
setSelected(newSelected);
|
|
6802
|
-
onSelectionChange == null ? void 0 : onSelectionChange(newSelected);
|
|
6803
|
-
},
|
|
6804
|
-
[onSelectionChange, selected, selectionStrategy, setSelected]
|
|
6805
|
-
);
|
|
6806
|
-
const deselectItem = useCallback21(
|
|
6807
|
-
(itemIndex, specialKey = false) => {
|
|
6808
|
-
const newSelected = selectionStrategy === "deselectable" || selectionStrategy === "multiple-special-key" && !specialKey ? [] : selected.filter((index) => index !== itemIndex);
|
|
6809
|
-
setSelected(newSelected);
|
|
6810
|
-
onSelectionChange == null ? void 0 : onSelectionChange(newSelected);
|
|
6811
|
-
},
|
|
6812
|
-
[onSelectionChange, selected, selectionStrategy, setSelected]
|
|
6813
|
-
);
|
|
6814
|
-
const handleKeyDown = useCallback21(
|
|
6815
|
-
(e) => {
|
|
6816
|
-
if (isSelectionEvent(e) && isSelectableElement(e.target)) {
|
|
6817
|
-
if (!selected.includes(highlightedIdx)) {
|
|
6818
|
-
e.stopPropagation();
|
|
6819
|
-
e.preventDefault();
|
|
6820
|
-
selectItem(highlightedIdx, e.shiftKey);
|
|
6821
|
-
} else if (deselectionIsAllowed(selectionStrategy)) {
|
|
6822
|
-
e.stopPropagation();
|
|
6823
|
-
e.preventDefault();
|
|
6824
|
-
deselectItem(highlightedIdx, e.shiftKey);
|
|
6825
|
-
}
|
|
6826
|
-
}
|
|
6827
|
-
},
|
|
6828
|
-
[
|
|
6829
|
-
isSelectionEvent,
|
|
6830
|
-
selected,
|
|
6831
|
-
highlightedIdx,
|
|
6832
|
-
selectionStrategy,
|
|
6833
|
-
selectItem,
|
|
6834
|
-
deselectItem
|
|
6835
|
-
]
|
|
6836
|
-
);
|
|
6837
|
-
const handleClick = useCallback21(
|
|
6838
|
-
(e, itemIndex) => {
|
|
6839
|
-
const element = getClosestIndexItem(e.target);
|
|
6840
|
-
if (isSelectableElement(element)) {
|
|
6841
|
-
if (!selected.includes(itemIndex)) {
|
|
6842
|
-
selectItem(itemIndex, e.shiftKey);
|
|
6843
|
-
} else if (deselectionIsAllowed(selectionStrategy)) {
|
|
6844
|
-
deselectItem(itemIndex, e.shiftKey);
|
|
6845
|
-
}
|
|
6846
|
-
}
|
|
6847
|
-
},
|
|
6848
|
-
[deselectItem, selectItem, selected, selectionStrategy]
|
|
6849
|
-
);
|
|
6850
|
-
const itemHandlers = selectionIsDisallowed(selectionStrategy) ? NO_SELECTION_HANDLERS : {
|
|
6851
|
-
onClick: handleClick,
|
|
6852
|
-
onKeyDown: handleKeyDown
|
|
6853
|
-
};
|
|
6854
|
-
return {
|
|
6855
|
-
activateItem: selectItem,
|
|
6856
|
-
itemHandlers,
|
|
6857
|
-
isControlled,
|
|
6858
|
-
selected
|
|
6859
|
-
};
|
|
6860
|
-
};
|
|
6861
|
-
|
|
6862
|
-
// src/toolbar/useToolbar.ts
|
|
6863
|
-
var useToolbar = ({
|
|
6864
|
-
activeItemIndex: activeItemIndexProp,
|
|
6865
|
-
defaultActiveItemIndex,
|
|
6866
|
-
containerRef,
|
|
6867
|
-
itemQuery = "vuuToolbarItem",
|
|
6868
|
-
onActiveChange,
|
|
6869
|
-
onNavigateOutOfBounds,
|
|
6870
|
-
orientation,
|
|
6871
|
-
selectionStrategy
|
|
6872
|
-
}) => {
|
|
6873
|
-
const lastSelection = useRef17(activeItemIndexProp);
|
|
6874
|
-
const {
|
|
6875
|
-
focusItem: keyboardHookFocusItem,
|
|
6876
|
-
highlightedIdx,
|
|
6877
|
-
onClick: keyboardHookHandleClick,
|
|
6878
|
-
onKeyDown: keyboardHookHandleKeyDown,
|
|
6879
|
-
setHighlightedIdx: keyboardHookSetHighlightedIndex,
|
|
6880
|
-
...keyboardHook
|
|
6881
|
-
} = useKeyboardNavigation({
|
|
6882
|
-
containerRef,
|
|
6883
|
-
onNavigateOutOfBounds,
|
|
6884
|
-
orientation
|
|
6885
|
-
});
|
|
6886
|
-
const {
|
|
6887
|
-
activateItem: selectionHookActivateItem,
|
|
6888
|
-
itemHandlers: { onClick, onKeyDown },
|
|
6889
|
-
selected: selectionHookSelected
|
|
6890
|
-
} = useSelection({
|
|
6891
|
-
containerRef,
|
|
6892
|
-
defaultSelected: defaultActiveItemIndex,
|
|
6893
|
-
highlightedIdx,
|
|
6894
|
-
itemQuery,
|
|
6895
|
-
onSelectionChange: onActiveChange,
|
|
6896
|
-
selected: activeItemIndexProp,
|
|
6897
|
-
selectionStrategy
|
|
6898
|
-
});
|
|
6899
|
-
lastSelection.current = selectionHookSelected;
|
|
6900
|
-
const handleClick = useCallback22(
|
|
6901
|
-
(evt) => {
|
|
6902
|
-
var _a;
|
|
6903
|
-
const target = evt.target;
|
|
6904
|
-
const toolbarItem = target.closest("[data-index]");
|
|
6905
|
-
if (toolbarItem) {
|
|
6906
|
-
const index = parseInt((_a = toolbarItem.dataset.index) != null ? _a : "-1");
|
|
6907
|
-
if (index !== -1 && isValidNumber3(index)) {
|
|
6908
|
-
keyboardHookHandleClick(evt, index);
|
|
6909
|
-
onClick == null ? void 0 : onClick(evt, index);
|
|
6910
|
-
}
|
|
6911
|
-
}
|
|
6912
|
-
},
|
|
6913
|
-
[keyboardHookHandleClick, onClick]
|
|
6914
|
-
);
|
|
6915
|
-
const handleKeyDown = useCallback22(
|
|
6916
|
-
(evt) => {
|
|
6917
|
-
keyboardHookHandleKeyDown(evt);
|
|
6918
|
-
if (!evt.defaultPrevented) {
|
|
6919
|
-
onKeyDown == null ? void 0 : onKeyDown(evt);
|
|
6920
|
-
}
|
|
6921
|
-
},
|
|
6922
|
-
[keyboardHookHandleKeyDown, onKeyDown]
|
|
6923
|
-
);
|
|
6924
|
-
const onSwitchWrappedItemIntoView = useCallback22(
|
|
6925
|
-
(item) => {
|
|
6926
|
-
const index = parseInt(item.index);
|
|
6927
|
-
if (!isNaN(index)) {
|
|
6928
|
-
selectionHookActivateItem(index);
|
|
6929
|
-
keyboardHookFocusItem(index);
|
|
6930
|
-
}
|
|
6931
|
-
},
|
|
6932
|
-
[keyboardHookFocusItem, selectionHookActivateItem]
|
|
6933
|
-
);
|
|
6934
|
-
const itemProps = {
|
|
6935
|
-
onClick: handleClick,
|
|
6936
|
-
onFocus: keyboardHook.onFocus,
|
|
6937
|
-
onKeyDown: handleKeyDown
|
|
6938
|
-
};
|
|
6939
|
-
return {
|
|
6940
|
-
activeItemIndex: selectionHookSelected,
|
|
6941
|
-
focusableIdx: keyboardHook.focusableIdx,
|
|
6942
|
-
focusVisible: keyboardHook.focusVisible,
|
|
6943
|
-
containerProps: {
|
|
6944
|
-
PopupMenuProps: {
|
|
6945
|
-
onKeyDown: handleKeyDown,
|
|
6946
|
-
onMenuClose: keyboardHook.onOverflowMenuClose
|
|
6947
|
-
},
|
|
6948
|
-
...keyboardHook.containerProps,
|
|
6949
|
-
onSwitchWrappedItemIntoView
|
|
6950
|
-
},
|
|
6951
|
-
itemProps
|
|
6952
|
-
};
|
|
6953
|
-
};
|
|
6954
|
-
|
|
6955
|
-
// src/toolbar/Toolbar.tsx
|
|
6956
|
-
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
6957
|
-
var classBase12 = "vuuToolbar";
|
|
6958
|
-
var Toolbar = ({
|
|
6959
|
-
activeItemIndex: activeItemIndexProp,
|
|
6960
|
-
alignItems = "start",
|
|
6961
|
-
defaultActiveItemIndex,
|
|
6962
|
-
children,
|
|
6963
|
-
className,
|
|
6964
|
-
id: idProp,
|
|
6965
|
-
onActiveChange,
|
|
6966
|
-
onNavigateOutOfBounds,
|
|
6967
|
-
orientation = "horizontal",
|
|
6968
|
-
selectionStrategy = "none",
|
|
6969
|
-
showSeparators = false,
|
|
6970
|
-
...props
|
|
6971
|
-
}) => {
|
|
6972
|
-
const rootRef = useRef18(null);
|
|
6973
|
-
const {
|
|
6974
|
-
activeItemIndex,
|
|
6975
|
-
focusableIdx,
|
|
6976
|
-
focusVisible,
|
|
6977
|
-
itemProps,
|
|
6978
|
-
...toolbarHook
|
|
6979
|
-
} = useToolbar({
|
|
6980
|
-
activeItemIndex: activeItemIndexProp,
|
|
6981
|
-
defaultActiveItemIndex,
|
|
6982
|
-
containerRef: rootRef,
|
|
6983
|
-
onActiveChange,
|
|
6984
|
-
onNavigateOutOfBounds,
|
|
6985
|
-
orientation,
|
|
6986
|
-
selectionStrategy
|
|
6987
|
-
});
|
|
6988
|
-
const id = useId5(idProp);
|
|
6989
|
-
const items = useMemo9(
|
|
6990
|
-
() => asReactElements(children).map((child, index) => {
|
|
6991
|
-
const {
|
|
6992
|
-
id: itemId = `${id}-tab-${index}`,
|
|
6993
|
-
className: itemClassName,
|
|
6994
|
-
...ownProps
|
|
6995
|
-
} = child.props;
|
|
6996
|
-
const selected = activeItemIndex.includes(index);
|
|
6997
|
-
return React18.cloneElement(child, {
|
|
6998
|
-
...forwardCallbackProps(ownProps, itemProps),
|
|
6999
|
-
className: cx14("vuuToolbarItem", itemClassName),
|
|
7000
|
-
"data-overflow-priority": selected ? "1" : void 0,
|
|
7001
|
-
id: itemId,
|
|
7002
|
-
key: index,
|
|
7003
|
-
"aria-selected": selected,
|
|
7004
|
-
tabIndex: focusableIdx === index ? 0 : -1
|
|
7005
|
-
});
|
|
7006
|
-
}),
|
|
7007
|
-
[activeItemIndex, children, focusableIdx, id, itemProps]
|
|
7008
|
-
);
|
|
7009
|
-
return /* @__PURE__ */ jsx22(
|
|
7010
|
-
OverflowContainer,
|
|
7011
|
-
{
|
|
7012
|
-
...props,
|
|
7013
|
-
...toolbarHook.containerProps,
|
|
7014
|
-
className: cx14(className, classBase12, `${classBase12}-${orientation}`, {
|
|
7015
|
-
[`${classBase12}-alignCenter`]: alignItems === "center",
|
|
7016
|
-
[`${classBase12}-alignEnd`]: alignItems === "end",
|
|
7017
|
-
[`${classBase12}-withSeparators`]: showSeparators
|
|
7018
|
-
}),
|
|
7019
|
-
...props,
|
|
7020
|
-
ref: rootRef,
|
|
7021
|
-
children: items
|
|
7022
|
-
}
|
|
7023
|
-
);
|
|
7024
|
-
};
|
|
7025
|
-
|
|
7026
5557
|
// src/tools/config-wrapper/ConfigWrapper.tsx
|
|
7027
|
-
import
|
|
7028
|
-
import { jsx as
|
|
5558
|
+
import React17, { useState as useState9 } from "react";
|
|
5559
|
+
import { jsx as jsx20, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
7029
5560
|
var ConfigWrapper = ({ children }) => {
|
|
7030
5561
|
const designMode = false;
|
|
7031
|
-
const [layout, setLayout] =
|
|
7032
|
-
const [selectedComponent, setSelectedComponent] =
|
|
5562
|
+
const [layout, setLayout] = useState9(children);
|
|
5563
|
+
const [selectedComponent, setSelectedComponent] = useState9(children);
|
|
7033
5564
|
const handleSelection = (selectedPath) => {
|
|
7034
5565
|
const targetComponent = followPathToComponent(layout, selectedPath);
|
|
7035
5566
|
setSelectedComponent(targetComponent);
|
|
7036
5567
|
};
|
|
7037
5568
|
const handleChange = (property, value) => {
|
|
7038
5569
|
console.log(`change ${property} -> ${value}`);
|
|
7039
|
-
const newComponent =
|
|
5570
|
+
const newComponent = React17.cloneElement(selectedComponent, {
|
|
7040
5571
|
style: {
|
|
7041
5572
|
...selectedComponent.props.style,
|
|
7042
5573
|
[property]: value
|
|
7043
5574
|
}
|
|
7044
5575
|
});
|
|
7045
5576
|
setSelectedComponent(newComponent);
|
|
7046
|
-
setLayout(
|
|
5577
|
+
setLayout(React17.cloneElement(layout, {}, newComponent));
|
|
7047
5578
|
};
|
|
7048
|
-
return /* @__PURE__ */
|
|
5579
|
+
return /* @__PURE__ */ jsxs6("div", { "data-design-mode": `${designMode}`, children: [
|
|
7049
5580
|
layout,
|
|
7050
|
-
/* @__PURE__ */
|
|
7051
|
-
/* @__PURE__ */
|
|
7052
|
-
/* @__PURE__ */
|
|
5581
|
+
/* @__PURE__ */ jsx20("br", {}),
|
|
5582
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex" }, children: [
|
|
5583
|
+
/* @__PURE__ */ jsx20(
|
|
7053
5584
|
LayoutConfigurator,
|
|
7054
5585
|
{
|
|
7055
5586
|
height: 300,
|
|
@@ -7059,7 +5590,7 @@ var ConfigWrapper = ({ children }) => {
|
|
|
7059
5590
|
style: void 0
|
|
7060
5591
|
}
|
|
7061
5592
|
),
|
|
7062
|
-
/* @__PURE__ */
|
|
5593
|
+
/* @__PURE__ */ jsx20(
|
|
7063
5594
|
LayoutTreeViewer,
|
|
7064
5595
|
{
|
|
7065
5596
|
layout,
|
|
@@ -7073,7 +5604,7 @@ var ConfigWrapper = ({ children }) => {
|
|
|
7073
5604
|
|
|
7074
5605
|
// src/tools/devtools-box/layout-configurator.jsx
|
|
7075
5606
|
import { FormField, Input } from "@salt-ds/core";
|
|
7076
|
-
import { jsx as
|
|
5607
|
+
import { jsx as jsx21, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
7077
5608
|
var NO_STYLE2 = {};
|
|
7078
5609
|
var DIMENSIONS = {
|
|
7079
5610
|
margin: {
|
|
@@ -7096,10 +5627,10 @@ var DIMENSIONS = {
|
|
|
7096
5627
|
}
|
|
7097
5628
|
};
|
|
7098
5629
|
var LayoutBox = ({ feature, children, style, onChange }) => {
|
|
7099
|
-
return /* @__PURE__ */
|
|
7100
|
-
/* @__PURE__ */
|
|
7101
|
-
/* @__PURE__ */
|
|
7102
|
-
/* @__PURE__ */
|
|
5630
|
+
return /* @__PURE__ */ jsxs7("div", { className: `LayoutBox layout-${feature} layout-outer`, children: [
|
|
5631
|
+
/* @__PURE__ */ jsxs7("div", { className: `layout-top`, children: [
|
|
5632
|
+
/* @__PURE__ */ jsx21("span", { className: "layout-title", children: feature }),
|
|
5633
|
+
/* @__PURE__ */ jsx21(FormField, { className: "layout-input", style: { width: 30 }, children: /* @__PURE__ */ jsx21(
|
|
7103
5634
|
Input,
|
|
7104
5635
|
{
|
|
7105
5636
|
value: style.top,
|
|
@@ -7107,8 +5638,8 @@ var LayoutBox = ({ feature, children, style, onChange }) => {
|
|
|
7107
5638
|
}
|
|
7108
5639
|
) })
|
|
7109
5640
|
] }),
|
|
7110
|
-
/* @__PURE__ */
|
|
7111
|
-
/* @__PURE__ */
|
|
5641
|
+
/* @__PURE__ */ jsxs7("div", { className: `layout-inner`, children: [
|
|
5642
|
+
/* @__PURE__ */ jsx21("div", { className: `layout-left`, children: /* @__PURE__ */ jsx21(FormField, { className: "layout-input", style: { width: 30 }, children: /* @__PURE__ */ jsx21(
|
|
7112
5643
|
Input,
|
|
7113
5644
|
{
|
|
7114
5645
|
value: style.left,
|
|
@@ -7116,7 +5647,7 @@ var LayoutBox = ({ feature, children, style, onChange }) => {
|
|
|
7116
5647
|
}
|
|
7117
5648
|
) }) }),
|
|
7118
5649
|
children,
|
|
7119
|
-
/* @__PURE__ */
|
|
5650
|
+
/* @__PURE__ */ jsx21("div", { className: `layout-right`, children: /* @__PURE__ */ jsx21(FormField, { className: "layout-input", style: { width: 30 }, children: /* @__PURE__ */ jsx21(
|
|
7120
5651
|
Input,
|
|
7121
5652
|
{
|
|
7122
5653
|
value: style.right,
|
|
@@ -7124,7 +5655,7 @@ var LayoutBox = ({ feature, children, style, onChange }) => {
|
|
|
7124
5655
|
}
|
|
7125
5656
|
) }) })
|
|
7126
5657
|
] }),
|
|
7127
|
-
/* @__PURE__ */
|
|
5658
|
+
/* @__PURE__ */ jsx21("div", { className: `layout-bottom`, children: /* @__PURE__ */ jsx21(FormField, { className: "layout-input", style: { width: 30 }, children: /* @__PURE__ */ jsx21(
|
|
7128
5659
|
Input,
|
|
7129
5660
|
{
|
|
7130
5661
|
value: style.bottom,
|
|
@@ -7191,25 +5722,25 @@ var LayoutConfigurator = ({
|
|
|
7191
5722
|
paddingBottom: pb = 0,
|
|
7192
5723
|
paddingLeft: pl = 0
|
|
7193
5724
|
} = state;
|
|
7194
|
-
return /* @__PURE__ */
|
|
5725
|
+
return /* @__PURE__ */ jsx21("div", { className: "LayoutConfigurator", style: { width, height, ...style }, children: /* @__PURE__ */ jsx21(
|
|
7195
5726
|
LayoutBox,
|
|
7196
5727
|
{
|
|
7197
5728
|
feature: "margin",
|
|
7198
5729
|
style: { top: mt, right: mr, bottom: mb, left: ml },
|
|
7199
5730
|
onChange: handleChange,
|
|
7200
|
-
children: /* @__PURE__ */
|
|
5731
|
+
children: /* @__PURE__ */ jsx21(
|
|
7201
5732
|
LayoutBox,
|
|
7202
5733
|
{
|
|
7203
5734
|
feature: "border",
|
|
7204
5735
|
style: { top: bt, right: br, bottom: bb, left: bl },
|
|
7205
5736
|
onChange: handleChange,
|
|
7206
|
-
children: /* @__PURE__ */
|
|
5737
|
+
children: /* @__PURE__ */ jsx21(
|
|
7207
5738
|
LayoutBox,
|
|
7208
5739
|
{
|
|
7209
5740
|
feature: "padding",
|
|
7210
5741
|
style: { top: pt, right: pr, bottom: pb, left: pl },
|
|
7211
5742
|
onChange: handleChange,
|
|
7212
|
-
children: /* @__PURE__ */
|
|
5743
|
+
children: /* @__PURE__ */ jsx21("div", { className: "layout-content" })
|
|
7213
5744
|
}
|
|
7214
5745
|
)
|
|
7215
5746
|
}
|
|
@@ -7377,16 +5908,16 @@ function normalizeStyle(managedStyle = NO_STYLE2) {
|
|
|
7377
5908
|
}
|
|
7378
5909
|
|
|
7379
5910
|
// src/tools/devtools-tree/layout-tree-viewer.jsx
|
|
7380
|
-
import
|
|
7381
|
-
import
|
|
5911
|
+
import React18 from "react";
|
|
5912
|
+
import cx12 from "clsx";
|
|
7382
5913
|
import { Tree } from "@vuu-ui/vuu-ui-controls";
|
|
7383
|
-
import { jsx as
|
|
5914
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
7384
5915
|
var classBaseTree = "hwLayoutTreeViewer";
|
|
7385
5916
|
var toTreeJson = (component, path = "0") => {
|
|
7386
5917
|
return {
|
|
7387
5918
|
label: typeOf(component),
|
|
7388
5919
|
path,
|
|
7389
|
-
childNodes:
|
|
5920
|
+
childNodes: React18.Children.map(
|
|
7390
5921
|
component.props.children,
|
|
7391
5922
|
(child, i) => toTreeJson(child, path ? `${path}.${i}` : `${i}`)
|
|
7392
5923
|
)
|
|
@@ -7397,7 +5928,7 @@ var LayoutTreeViewer = ({ layout, onSelect, style }) => {
|
|
|
7397
5928
|
const handleSelection = (evt, [{ path }]) => {
|
|
7398
5929
|
onSelect(path);
|
|
7399
5930
|
};
|
|
7400
|
-
return /* @__PURE__ */
|
|
5931
|
+
return /* @__PURE__ */ jsx22("div", { className: cx12(classBaseTree), style, children: /* @__PURE__ */ jsx22(
|
|
7401
5932
|
Tree,
|
|
7402
5933
|
{
|
|
7403
5934
|
source: treeJson,
|
|
@@ -7431,16 +5962,12 @@ export {
|
|
|
7431
5962
|
LayoutProviderVersion,
|
|
7432
5963
|
LayoutTreeViewer,
|
|
7433
5964
|
MARGIN_STYLES,
|
|
7434
|
-
MeasuredContainer,
|
|
7435
|
-
NO_WRAPPED_ITEMS,
|
|
7436
|
-
OverflowContainer,
|
|
7437
5965
|
PADDING_STYLES,
|
|
7438
5966
|
Palette,
|
|
7439
5967
|
PaletteItem,
|
|
7440
5968
|
Placeholder,
|
|
7441
5969
|
Stack,
|
|
7442
5970
|
StackLayout,
|
|
7443
|
-
Toolbar,
|
|
7444
5971
|
MemoView as View,
|
|
7445
5972
|
ViewContext,
|
|
7446
5973
|
WidthHeight,
|
|
@@ -7448,13 +5975,9 @@ export {
|
|
|
7448
5975
|
XXXnormalizeStyles,
|
|
7449
5976
|
applyLayout,
|
|
7450
5977
|
applyLayoutProps,
|
|
7451
|
-
applyOverflowClassToWrappedItems,
|
|
7452
|
-
asReactElements,
|
|
7453
5978
|
componentToJson,
|
|
7454
5979
|
computeMenuPosition,
|
|
7455
5980
|
containerOf,
|
|
7456
|
-
correctForWrappedHighPriorityItems,
|
|
7457
|
-
correctForWrappedOverflowIndicator,
|
|
7458
5981
|
createFlexbox,
|
|
7459
5982
|
createPlaceHolder,
|
|
7460
5983
|
expandFlex,
|
|
@@ -7466,25 +5989,22 @@ export {
|
|
|
7466
5989
|
getChild,
|
|
7467
5990
|
getChildProp,
|
|
7468
5991
|
getDefaultTabLabel,
|
|
7469
|
-
getElementsMarkedAsWrapped,
|
|
7470
5992
|
getFlexDimensions,
|
|
7471
5993
|
getFlexOrIntrinsicStyle,
|
|
7472
5994
|
getFlexStyle,
|
|
7473
5995
|
getIntrinsicSize,
|
|
7474
5996
|
getManagedDimension,
|
|
7475
|
-
getNonWrappedAndWrappedItems,
|
|
7476
5997
|
getPersistentState,
|
|
7477
5998
|
getProp,
|
|
7478
5999
|
getProps,
|
|
7479
6000
|
hasPersistentState,
|
|
7480
6001
|
hasUnboundedFlexStyle,
|
|
7481
|
-
highPriorityItemsHaveWrappedButShouldNotHave,
|
|
7482
6002
|
identifyDropTarget,
|
|
7483
6003
|
isApplicationLevelChange,
|
|
7484
6004
|
isContainer,
|
|
7485
6005
|
isLayoutComponent,
|
|
6006
|
+
isLayoutJSON,
|
|
7486
6007
|
isLayoutLevelChange,
|
|
7487
|
-
isOverflowElement,
|
|
7488
6008
|
isResponsiveAttribute,
|
|
7489
6009
|
isTabstrip,
|
|
7490
6010
|
isTypeOf,
|
|
@@ -7493,14 +6013,11 @@ export {
|
|
|
7493
6013
|
layoutQuery,
|
|
7494
6014
|
layoutReducer,
|
|
7495
6015
|
layoutToJSON,
|
|
7496
|
-
markElementAsWrapped,
|
|
7497
6016
|
nextLeaf,
|
|
7498
6017
|
nextStep,
|
|
7499
|
-
overflowIndicatorHasWrappedButShouldNotHave,
|
|
7500
6018
|
previousLeaf,
|
|
7501
6019
|
processLayoutElement,
|
|
7502
6020
|
registerComponent,
|
|
7503
|
-
removeOverflowIndicatorIfNoLongerNeeded,
|
|
7504
6021
|
resetPath,
|
|
7505
6022
|
resizeObserver,
|
|
7506
6023
|
resolveJSONPath,
|
|
@@ -7508,15 +6025,11 @@ export {
|
|
|
7508
6025
|
serializeProps,
|
|
7509
6026
|
setPersistentState,
|
|
7510
6027
|
setRef,
|
|
7511
|
-
sortByScreenOrder,
|
|
7512
|
-
switchWrappedItemIntoView,
|
|
7513
6028
|
typeOf,
|
|
7514
|
-
unmarkItemsWhichAreNoLongerWrapped,
|
|
7515
6029
|
useBreakpoints,
|
|
7516
6030
|
useLayoutCreateNewChild,
|
|
7517
6031
|
useLayoutProviderDispatch,
|
|
7518
6032
|
useLayoutProviderVersion,
|
|
7519
|
-
useMeasuredContainer,
|
|
7520
6033
|
usePersistentState,
|
|
7521
6034
|
useResizeObserver,
|
|
7522
6035
|
useViewActionDispatcher,
|