@linzjs/lui 21.25.0 → 21.26.1
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/CHANGELOG.md +14 -0
- package/dist/components/Splitter/Separator/Separator.d.ts +3 -0
- package/dist/components/Splitter/Splitter.d.ts +33 -19
- package/dist/components/Splitter/Stories/RangeAsPx.d.ts +9 -0
- package/dist/components/Splitter/Stories/Section.d.ts +5 -0
- package/dist/components/Splitter/helpers/dataBoundary.d.ts +18 -0
- package/dist/components/Splitter/helpers/getGridTemplate.d.ts +14 -0
- package/dist/components/Splitter/helpers/getSeparatorAttributes.d.ts +1 -0
- package/dist/components/Splitter/helpers/transition.d.ts +5 -0
- package/dist/components/Splitter/helpers/useBoundary.d.ts +13 -0
- package/dist/components/Splitter/helpers/useValueSeparator.d.ts +6 -2
- package/dist/components/Splitter/helpers/useValueSeparatorEffects.d.ts +4 -1
- package/dist/index.js +298 -47
- package/dist/index.js.map +1 -1
- package/dist/lui.esm.js +298 -47
- package/dist/lui.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/lui.esm.js
CHANGED
|
@@ -58421,6 +58421,56 @@ var useForkRef = function (forwardedRef) {
|
|
|
58421
58421
|
return forwardedRef || localRef;
|
|
58422
58422
|
};
|
|
58423
58423
|
|
|
58424
|
+
var attrBoundary = 'data-boundary';
|
|
58425
|
+
var dataBoundary = function (_a) {
|
|
58426
|
+
var min = _a.min, max = _a.max;
|
|
58427
|
+
if (typeof min === 'undefined' && typeof max !== 'undefined') {
|
|
58428
|
+
if (typeof max === 'string') {
|
|
58429
|
+
return parseInt(max) < 0 ? 'keep-secondary' : 'keep-primary';
|
|
58430
|
+
}
|
|
58431
|
+
}
|
|
58432
|
+
if (typeof max === 'undefined' && typeof min !== 'undefined') {
|
|
58433
|
+
if (typeof min === 'string') {
|
|
58434
|
+
return parseInt(min) < 0 ? 'keep-secondary' : 'keep-primary';
|
|
58435
|
+
}
|
|
58436
|
+
}
|
|
58437
|
+
if (typeof max === 'string' && typeof min === 'string') {
|
|
58438
|
+
if (parseInt(max) > 0 && parseInt(min) > 0) {
|
|
58439
|
+
return 'keep-primary';
|
|
58440
|
+
}
|
|
58441
|
+
if (parseInt(max) < 0 && parseInt(min) < 0) {
|
|
58442
|
+
return 'keep-secondary';
|
|
58443
|
+
}
|
|
58444
|
+
}
|
|
58445
|
+
return 'keep-both';
|
|
58446
|
+
};
|
|
58447
|
+
/**
|
|
58448
|
+
* Given boundaries passed as prop, it defines how the grid column/row template will be arranged.
|
|
58449
|
+
* and whether the separator will be positioned using right or left absolute values (top or bottom for horizontal).
|
|
58450
|
+
* It will use a data- attribute to store this prop derived information for later processing.
|
|
58451
|
+
*/
|
|
58452
|
+
var setDataBoundary = function (props) {
|
|
58453
|
+
var _a;
|
|
58454
|
+
return (_a = {},
|
|
58455
|
+
_a[attrBoundary] = dataBoundary(props),
|
|
58456
|
+
_a);
|
|
58457
|
+
};
|
|
58458
|
+
/**
|
|
58459
|
+
* Util to get what grid arrangement needs to be used to avoid jumps/flashes.
|
|
58460
|
+
* The return value is derived from the Splitter props, and stored in a data- attribute.
|
|
58461
|
+
*/
|
|
58462
|
+
var getDataBoundary = function (separator) {
|
|
58463
|
+
var boundaryType = separator === null || separator === void 0 ? void 0 : separator.getAttribute(attrBoundary);
|
|
58464
|
+
switch (boundaryType) {
|
|
58465
|
+
case 'keep-primary':
|
|
58466
|
+
case 'keep-secondary':
|
|
58467
|
+
case 'keep-both':
|
|
58468
|
+
return boundaryType;
|
|
58469
|
+
default:
|
|
58470
|
+
return undefined;
|
|
58471
|
+
}
|
|
58472
|
+
};
|
|
58473
|
+
|
|
58424
58474
|
/**
|
|
58425
58475
|
* Given a ref/element if finds the Separator and returns the most useful attributes
|
|
58426
58476
|
*/
|
|
@@ -58436,7 +58486,8 @@ var getValues = function (el) {
|
|
|
58436
58486
|
valueMin: parseValue(el === null || el === void 0 ? void 0 : el.getAttribute('aria-valuemin')),
|
|
58437
58487
|
valueMax: parseValue(el === null || el === void 0 ? void 0 : el.getAttribute('aria-valuemax')),
|
|
58438
58488
|
orientation: parseOrientation(el === null || el === void 0 ? void 0 : el.getAttribute('aria-orientation')),
|
|
58439
|
-
thickness: getSeparatorThickness(el)
|
|
58489
|
+
thickness: getSeparatorThickness(el),
|
|
58490
|
+
boundary: getDataBoundary(el)
|
|
58440
58491
|
};
|
|
58441
58492
|
};
|
|
58442
58493
|
var parseValue = function (val) {
|
|
@@ -58514,6 +58565,9 @@ var Control = forwardRef$1(function (props, forwardRef) {
|
|
|
58514
58565
|
useEffect(function () {
|
|
58515
58566
|
var callback = function () {
|
|
58516
58567
|
var control = ref.current;
|
|
58568
|
+
if (!control) {
|
|
58569
|
+
return;
|
|
58570
|
+
}
|
|
58517
58571
|
var _a = getButtonProps(ref, side), hide = _a.hide, offset = _a.offset, orientation = _a.orientation;
|
|
58518
58572
|
var vertical = orientation === 'vertical';
|
|
58519
58573
|
control.style.left = vertical ? "".concat(offset, "px") : '50%';
|
|
@@ -58526,7 +58580,14 @@ var Control = forwardRef$1(function (props, forwardRef) {
|
|
|
58526
58580
|
var separator = ref.current.closest('[role="separator"]');
|
|
58527
58581
|
callback();
|
|
58528
58582
|
var observer = new MutationObserver(callback);
|
|
58529
|
-
observer.observe(separator, {
|
|
58583
|
+
observer.observe(separator, {
|
|
58584
|
+
attributeFilter: [
|
|
58585
|
+
'aria-valuenow',
|
|
58586
|
+
'aria-valuemin',
|
|
58587
|
+
'aria-valuemax',
|
|
58588
|
+
'aria-orientation',
|
|
58589
|
+
]
|
|
58590
|
+
});
|
|
58530
58591
|
return function () { return observer.disconnect(); };
|
|
58531
58592
|
}, [ref, side]);
|
|
58532
58593
|
return (React__default.createElement(LuiButton, __assign({ ref: ref, level: "primary", type: "button" }, rest, { style: __assign(__assign({}, rest === null || rest === void 0 ? void 0 : rest.style), { width: squareButtonSide, height: squareButtonSide, borderRadius: '50%' }), className: clsx('Control', 'lui-button-icon-only', 'lui-box-shadow', rest === null || rest === void 0 ? void 0 : rest.className) }), (rest === null || rest === void 0 ? void 0 : rest.children) || React__default.createElement(ControlIcon, { parent: ref, side: side })));
|
|
@@ -58591,6 +58652,29 @@ var getSeparatorPosition = function (separatorRef, drag) {
|
|
|
58591
58652
|
return clampSeparator({ value: value });
|
|
58592
58653
|
};
|
|
58593
58654
|
|
|
58655
|
+
var transitionFactory = function (attrs, ms) {
|
|
58656
|
+
return attrs.map(function (key) { return "".concat(key, " ").concat(ms, "ms"); }).join(', ');
|
|
58657
|
+
};
|
|
58658
|
+
var barTransition = function (ms) {
|
|
58659
|
+
return transitionFactory(['left', 'top', 'right', 'bottom'], ms);
|
|
58660
|
+
};
|
|
58661
|
+
var gridTransition = function (ms) {
|
|
58662
|
+
return transitionFactory(['grid-template-columns', 'grid-template-rows'], ms);
|
|
58663
|
+
};
|
|
58664
|
+
var transition = function (separator) {
|
|
58665
|
+
var _a;
|
|
58666
|
+
var splitter = (_a = separator.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
58667
|
+
var delay = function (ms) {
|
|
58668
|
+
if (splitter) {
|
|
58669
|
+
separator.current.style.transition = barTransition(ms);
|
|
58670
|
+
splitter.style.transition = gridTransition(ms);
|
|
58671
|
+
}
|
|
58672
|
+
};
|
|
58673
|
+
var stop = function () { return delay(0); };
|
|
58674
|
+
var resume = function () { return delay(300); };
|
|
58675
|
+
return { stop: stop, resume: resume };
|
|
58676
|
+
};
|
|
58677
|
+
|
|
58594
58678
|
/**
|
|
58595
58679
|
* It captures window events to report a new position.
|
|
58596
58680
|
* Provides necessary handlers for separator.
|
|
@@ -58634,8 +58718,7 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58634
58718
|
var splitter = separator === null || separator === void 0 ? void 0 : separator.parentElement;
|
|
58635
58719
|
if (separator && splitter) {
|
|
58636
58720
|
if (animate === 'clear-transition') {
|
|
58637
|
-
|
|
58638
|
-
splitter.style.transition = '';
|
|
58721
|
+
transition(separatorRef).stop();
|
|
58639
58722
|
splitter.style.cursor =
|
|
58640
58723
|
separator.getAttribute('aria-orientation') === 'vertical'
|
|
58641
58724
|
? 'col-resize'
|
|
@@ -58643,9 +58726,7 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58643
58726
|
splitter.classList.add('resizing');
|
|
58644
58727
|
}
|
|
58645
58728
|
else {
|
|
58646
|
-
|
|
58647
|
-
splitter.style.transition =
|
|
58648
|
-
'grid-template-columns 300ms, grid-template-rows 300ms';
|
|
58729
|
+
transition(separatorRef).resume();
|
|
58649
58730
|
splitter.style.cursor = '';
|
|
58650
58731
|
splitter.classList.remove('resizing');
|
|
58651
58732
|
}
|
|
@@ -58655,33 +58736,84 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58655
58736
|
/**
|
|
58656
58737
|
* Moves separator as per ratio changes. Centers on first render if ratio is undefined.
|
|
58657
58738
|
*/
|
|
58658
|
-
var useRatioEffect = function (setValueNow, ratio) {
|
|
58739
|
+
var useRatioEffect = function (setValueNow, separator, ratio, startAt) {
|
|
58659
58740
|
var firstRun = useRef(true);
|
|
58741
|
+
var _a = getSeparatorAttributes({ ref: separator }), valueMax = _a.valueMax, valueMin = _a.valueMin;
|
|
58742
|
+
var isCalculating = valueMax === Infinity || valueMin === -Infinity;
|
|
58660
58743
|
useEffect(function () {
|
|
58661
|
-
if (firstRun.current || ratio !== undefined) {
|
|
58744
|
+
if (firstRun.current || ratio !== undefined || isCalculating) {
|
|
58662
58745
|
firstRun.current = false;
|
|
58663
58746
|
// If ratio is undefined, setValueNow will place the separator in the middle as a starting point.
|
|
58664
58747
|
// Whatever value is `the middle` will be determined by setValueNow
|
|
58665
|
-
setValueNow(ratio);
|
|
58748
|
+
setValueNow(ratio !== null && ratio !== void 0 ? ratio : startAt);
|
|
58666
58749
|
}
|
|
58667
|
-
}, [setValueNow, ratio, firstRun]);
|
|
58750
|
+
}, [setValueNow, ratio, firstRun, startAt]);
|
|
58668
58751
|
};
|
|
58669
58752
|
/**
|
|
58670
58753
|
* Re-arranges the splitter if the limits or orientation change.
|
|
58671
58754
|
*/
|
|
58672
58755
|
var useConfigEffect = function (setValueNow, separator) {
|
|
58756
|
+
var _a = useState(0), count = _a[0], setCount = _a[1];
|
|
58757
|
+
useEffect(function () { return transition(separator).resume(); }, [count]);
|
|
58673
58758
|
useEffect(function () {
|
|
58674
|
-
var callback = function () {
|
|
58675
|
-
|
|
58676
|
-
|
|
58759
|
+
var callback = function (attr) {
|
|
58760
|
+
return function (_a) {
|
|
58761
|
+
var record = _a[0];
|
|
58762
|
+
var target = record.target;
|
|
58763
|
+
var values = getSeparatorAttributes({ separator: target });
|
|
58764
|
+
var oldValue = Number(record.oldValue);
|
|
58765
|
+
var valueMax = values.valueMax, valueMin = values.valueMin, valueNow = values.valueNow;
|
|
58766
|
+
var newValue = attr === 'min' ? valueMin : valueMax;
|
|
58767
|
+
// Determine if separator was collapsed/expanded fully
|
|
58768
|
+
var wasInBoundary = oldValue === valueNow;
|
|
58769
|
+
// To remain collapsed/expanded, it is necessary to call setValueNow with the latest boundaries.
|
|
58770
|
+
// The useBoundaries hook haven't yet reflected the change, and it would cause an unwanted flash.
|
|
58771
|
+
// In such case, the newValueNow is moved along with the delimiter.
|
|
58772
|
+
var newValueNow = !wasInBoundary ? valueNow : newValue;
|
|
58773
|
+
if (wasInBoundary || valueMax < valueNow || valueMin > valueNow) {
|
|
58774
|
+
transition(separator).stop();
|
|
58775
|
+
setValueNow(newValueNow, { min: valueMin, max: valueMax });
|
|
58776
|
+
setCount(function (p) { return p + 1; });
|
|
58777
|
+
}
|
|
58778
|
+
else {
|
|
58779
|
+
var dim = values.orientation === 'vertical' ? 'width' : 'height';
|
|
58780
|
+
var gap = target.getBoundingClientRect()[dim];
|
|
58781
|
+
var offset = gap / 2;
|
|
58782
|
+
var splitterEl = target.parentElement;
|
|
58783
|
+
var primaryEl = splitterEl.childNodes[0];
|
|
58784
|
+
var splitterRect = splitterEl.getBoundingClientRect();
|
|
58785
|
+
var primaryRect = primaryEl.getBoundingClientRect();
|
|
58786
|
+
var container = splitterRect[dim];
|
|
58787
|
+
var primary = primaryRect[dim];
|
|
58788
|
+
var seconday = container - primary - gap;
|
|
58789
|
+
if (primary === 0 || seconday === 0) {
|
|
58790
|
+
return;
|
|
58791
|
+
}
|
|
58792
|
+
var newVal = ((primary + offset) / container) * 100;
|
|
58793
|
+
if (Math.abs(newVal - valueNow) >= 0.01) {
|
|
58794
|
+
setValueNow(newVal, { min: valueMin, max: valueMax });
|
|
58795
|
+
}
|
|
58796
|
+
}
|
|
58797
|
+
};
|
|
58677
58798
|
};
|
|
58678
|
-
|
|
58679
|
-
|
|
58680
|
-
|
|
58681
|
-
|
|
58799
|
+
var config = function (attr) { return ({
|
|
58800
|
+
attributeFilter: ["aria-value".concat(attr)],
|
|
58801
|
+
attributeOldValue: true
|
|
58802
|
+
}); };
|
|
58803
|
+
var minObserver = new MutationObserver(callback('min'));
|
|
58804
|
+
var maxObserver = new MutationObserver(callback('max'));
|
|
58805
|
+
var orientationObserver = new MutationObserver(function () { return setValueNow(); });
|
|
58806
|
+
minObserver.observe(separator.current, config('min'));
|
|
58807
|
+
maxObserver.observe(separator.current, config('max'));
|
|
58808
|
+
orientationObserver.observe(separator.current, {
|
|
58809
|
+
attributeFilter: ['aria-orientation']
|
|
58682
58810
|
});
|
|
58683
|
-
return function () {
|
|
58684
|
-
|
|
58811
|
+
return function () {
|
|
58812
|
+
minObserver.disconnect();
|
|
58813
|
+
maxObserver.disconnect();
|
|
58814
|
+
orientationObserver.disconnect();
|
|
58815
|
+
};
|
|
58816
|
+
}, [separator]);
|
|
58685
58817
|
};
|
|
58686
58818
|
/**
|
|
58687
58819
|
* Broadcasts changes if separator aria-valuenow was altered.
|
|
@@ -58705,12 +58837,53 @@ var useValueNowEffect = function (setValueNow, separator) {
|
|
|
58705
58837
|
/**
|
|
58706
58838
|
* Calls setValueNow when the separator attributes change.
|
|
58707
58839
|
*/
|
|
58708
|
-
var useValueSeparatorEffects = function (setValueNow, separator, ratio) {
|
|
58709
|
-
useRatioEffect(setValueNow, ratio);
|
|
58840
|
+
var useValueSeparatorEffects = function (setValueNow, separator, ratio, startAt) {
|
|
58841
|
+
useRatioEffect(setValueNow, separator, ratio, startAt);
|
|
58710
58842
|
useConfigEffect(setValueNow, separator);
|
|
58711
58843
|
useValueNowEffect(setValueNow, separator);
|
|
58712
58844
|
};
|
|
58713
58845
|
|
|
58846
|
+
/**
|
|
58847
|
+
* It will calculate the best grid arrangement, based on the min/max props passed to the Splitter.
|
|
58848
|
+
* All grid options work. The preference `1fr XXpx` over `(width - XXpx) 1fr` depends on the type of boundary
|
|
58849
|
+
* to avoid calculation of position when the window is being resized while trying to retain the collapsed state
|
|
58850
|
+
* on a min/max value fixed in pixels (e.g. 200px). Such calculation adds unnecessary lagging on the separator
|
|
58851
|
+
* to catch up. This function aims to avoid such lagging during resizing.
|
|
58852
|
+
* primary relates to top/left
|
|
58853
|
+
* secondary relates to right/bottom
|
|
58854
|
+
*/
|
|
58855
|
+
var getGridTemplate = function (separator) {
|
|
58856
|
+
var _a = getSeparatorAttributes({ separator: separator }), valueNow = _a.valueNow, gap = _a.thickness, boundary = _a.boundary, orientation = _a.orientation;
|
|
58857
|
+
var rect = separator.parentElement.getBoundingClientRect();
|
|
58858
|
+
var dimension = orientation === 'horizontal' ? 'height' : 'width';
|
|
58859
|
+
var seperatorAbsolutePx = (rect[dimension] / 100) * valueNow;
|
|
58860
|
+
var offset = gap / 2;
|
|
58861
|
+
var clamp = function (val, type) {
|
|
58862
|
+
return "clamp(".concat(offset, "px, ").concat(val).concat(type, ", calc(100% - ").concat(offset, "px))");
|
|
58863
|
+
};
|
|
58864
|
+
if (boundary === 'keep-primary') {
|
|
58865
|
+
var grid = Math.max(seperatorAbsolutePx - offset, 0);
|
|
58866
|
+
return {
|
|
58867
|
+
grid: "".concat(grid, "px 1fr"),
|
|
58868
|
+
primary: clamp(seperatorAbsolutePx, 'px'),
|
|
58869
|
+
secondary: ''
|
|
58870
|
+
};
|
|
58871
|
+
}
|
|
58872
|
+
if (boundary === 'keep-secondary') {
|
|
58873
|
+
var grid = Math.max(rect[dimension] - seperatorAbsolutePx - offset, 0);
|
|
58874
|
+
return {
|
|
58875
|
+
grid: "1fr ".concat(grid, "px"),
|
|
58876
|
+
primary: '',
|
|
58877
|
+
secondary: clamp(rect[dimension] - seperatorAbsolutePx, 'px')
|
|
58878
|
+
};
|
|
58879
|
+
}
|
|
58880
|
+
return {
|
|
58881
|
+
grid: "min(calc(".concat(valueNow, "% - ").concat(gap / 2, "px), calc(100% - ").concat(gap, "px)) 1fr"),
|
|
58882
|
+
primary: clamp(valueNow, '%'),
|
|
58883
|
+
secondary: "calc(100% - ".concat(clamp(valueNow, '%'), ")")
|
|
58884
|
+
};
|
|
58885
|
+
};
|
|
58886
|
+
|
|
58714
58887
|
/**
|
|
58715
58888
|
* Ensures valueNow is set to a valid value within its allowed boundaries.
|
|
58716
58889
|
* If boundaries and/or initialRatio are not specified, they will be defaulted.
|
|
@@ -58718,19 +58891,24 @@ var useValueSeparatorEffects = function (setValueNow, separator, ratio) {
|
|
|
58718
58891
|
* This multiple calls are expected, and setValueNow will resize only once.
|
|
58719
58892
|
*/
|
|
58720
58893
|
var useValueSeparator = function (_a) {
|
|
58721
|
-
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized, _b = _a.boundaries,
|
|
58894
|
+
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized, _b = _a.boundaries, minProp = _b.min, maxProp = _b.max, startAt = _a.startAt;
|
|
58722
58895
|
var prev = useRef(null);
|
|
58723
|
-
var setValueNow = useCallback(function (val) {
|
|
58896
|
+
var setValueNow = useCallback(function (val, config) {
|
|
58897
|
+
var _a, _b;
|
|
58724
58898
|
var valueNow = getSeparatorAttributes({ ref: separator }).valueNow;
|
|
58899
|
+
// Prioritize min/max from callback, they are updated before the boundaries prop.
|
|
58900
|
+
var min = (_a = config === null || config === void 0 ? void 0 : config.min) !== null && _a !== void 0 ? _a : minProp;
|
|
58901
|
+
var max = (_b = config === null || config === void 0 ? void 0 : config.max) !== null && _b !== void 0 ? _b : maxProp;
|
|
58725
58902
|
var value = val !== null && val !== void 0 ? val : (valueNow || min + (max - min) / 2);
|
|
58726
58903
|
var newValue = clampSeparator({ value: value, max: max, min: min });
|
|
58904
|
+
var isCalculating = min === -Infinity || max === Infinity;
|
|
58727
58905
|
resize(separator, newValue);
|
|
58728
|
-
if (prev.current !== newValue) {
|
|
58906
|
+
if (prev.current !== newValue && !isCalculating) {
|
|
58729
58907
|
prev.current = newValue;
|
|
58730
58908
|
onResized === null || onResized === void 0 ? void 0 : onResized(newValue);
|
|
58731
58909
|
}
|
|
58732
|
-
}, [onResized,
|
|
58733
|
-
useValueSeparatorEffects(setValueNow, separator, ratio);
|
|
58910
|
+
}, [onResized, minProp, maxProp, prev]);
|
|
58911
|
+
useValueSeparatorEffects(setValueNow, separator, ratio, startAt);
|
|
58734
58912
|
return { setValueNow: setValueNow };
|
|
58735
58913
|
};
|
|
58736
58914
|
var resize = function (separator, value) {
|
|
@@ -58746,12 +58924,8 @@ var resize = function (separator, value) {
|
|
|
58746
58924
|
separator.current.setAttribute('aria-valuenow', newValue);
|
|
58747
58925
|
}
|
|
58748
58926
|
var panels = (_a = separator.current.parentElement.childNodes.length) !== null && _a !== void 0 ? _a : 0;
|
|
58749
|
-
var
|
|
58750
|
-
var
|
|
58751
|
-
var absolute = "clamp(".concat(offset, "px, ").concat(valueNow, "%, calc(100% - ").concat(offset, "px))");
|
|
58752
|
-
var gridTemplate = panels === 1
|
|
58753
|
-
? '1fr'
|
|
58754
|
-
: "min(calc(".concat(valueNow, "% - ").concat(gap / 2, "px), calc(100% - ").concat(gap, "px)) 1fr");
|
|
58927
|
+
var _d = getGridTemplate(separator.current), grid = _d.grid, primary = _d.primary, secondary = _d.secondary;
|
|
58928
|
+
var gridTemplate = panels === 1 ? '1fr' : grid;
|
|
58755
58929
|
var splitter = (_b = separator.current) === null || _b === void 0 ? void 0 : _b.parentElement;
|
|
58756
58930
|
if (splitter) {
|
|
58757
58931
|
splitter.style.opacity = '1';
|
|
@@ -58759,25 +58933,29 @@ var resize = function (separator, value) {
|
|
|
58759
58933
|
splitter.style.columnGap = "".concat(gap, "px");
|
|
58760
58934
|
splitter.style.gridTemplateColumns = gridTemplate;
|
|
58761
58935
|
separator.current.style.width = "".concat(gap, "px");
|
|
58762
|
-
separator.current.style.left =
|
|
58936
|
+
separator.current.style.left = primary;
|
|
58937
|
+
separator.current.style.right = secondary;
|
|
58763
58938
|
separator.current.style.height = '100%';
|
|
58764
|
-
separator.current.style.transform =
|
|
58939
|
+
separator.current.style.transform = "translateX(".concat(primary && '-', "50%)");
|
|
58765
58940
|
separator.current.style.cursor = 'col-resize';
|
|
58766
58941
|
splitter.style.rowGap = '';
|
|
58767
58942
|
splitter.style.gridTemplateRows = '';
|
|
58768
58943
|
separator.current.style.top = '';
|
|
58944
|
+
separator.current.style.bottom = '';
|
|
58769
58945
|
}
|
|
58770
58946
|
else {
|
|
58771
58947
|
splitter.style.rowGap = "".concat(gap, "px");
|
|
58772
58948
|
splitter.style.gridTemplateRows = gridTemplate;
|
|
58773
58949
|
separator.current.style.height = "".concat(gap, "px");
|
|
58774
|
-
separator.current.style.top =
|
|
58950
|
+
separator.current.style.top = primary;
|
|
58951
|
+
separator.current.style.bottom = secondary;
|
|
58775
58952
|
separator.current.style.width = '100%';
|
|
58776
|
-
separator.current.style.transform =
|
|
58953
|
+
separator.current.style.transform = "translateY(".concat(primary && '-', "50%)");
|
|
58777
58954
|
separator.current.style.cursor = 'row-resize';
|
|
58778
58955
|
splitter.style.columnGap = '';
|
|
58779
58956
|
splitter.style.gridTemplateColumns = '';
|
|
58780
58957
|
separator.current.style.left = '';
|
|
58958
|
+
separator.current.style.right = '';
|
|
58781
58959
|
}
|
|
58782
58960
|
}
|
|
58783
58961
|
};
|
|
@@ -58861,6 +59039,62 @@ var getNewValueNow = function (_a, valueNow, pixelUnit) {
|
|
|
58861
59039
|
return valueNow;
|
|
58862
59040
|
};
|
|
58863
59041
|
|
|
59042
|
+
var isPxProps = function (_a) {
|
|
59043
|
+
var min = _a.min, max = _a.max;
|
|
59044
|
+
var isPercentage = typeof max === 'number' || typeof min === 'number';
|
|
59045
|
+
var isNull = min === undefined && max === undefined;
|
|
59046
|
+
return !isPercentage && !isNull;
|
|
59047
|
+
};
|
|
59048
|
+
/**
|
|
59049
|
+
* Maps min and max values if they are provided in 'XXXpx' format.
|
|
59050
|
+
*/
|
|
59051
|
+
var useBoundary = function (separator, boundaries) {
|
|
59052
|
+
var _a = useState({ min: -Infinity, max: Infinity }), mapped = _a[0], setMapped = _a[1];
|
|
59053
|
+
var isPx = isPxProps(boundaries);
|
|
59054
|
+
var min = boundaries.min, max = boundaries.max;
|
|
59055
|
+
useEffect(function () {
|
|
59056
|
+
var _a;
|
|
59057
|
+
var element = (_a = separator === null || separator === void 0 ? void 0 : separator.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
59058
|
+
var shouldMap = element && isPx;
|
|
59059
|
+
var observer = new ResizeObserver(function (_a) {
|
|
59060
|
+
var rect = _a[0].contentRect;
|
|
59061
|
+
var _b = getSeparatorAttributes({
|
|
59062
|
+
ref: separator
|
|
59063
|
+
}), thickness = _b.thickness, orientation = _b.orientation;
|
|
59064
|
+
var halfThickness = thickness / 2;
|
|
59065
|
+
var length = orientation === 'vertical' ? rect.width : rect.height;
|
|
59066
|
+
var parse = function (boundary) {
|
|
59067
|
+
if (typeof boundary === 'number') {
|
|
59068
|
+
return boundary;
|
|
59069
|
+
}
|
|
59070
|
+
var boundaryAsNumber = parseFloat(boundary);
|
|
59071
|
+
var offset = boundaryAsNumber > 0
|
|
59072
|
+
? boundaryAsNumber + halfThickness
|
|
59073
|
+
: length - Math.abs(boundaryAsNumber) - halfThickness;
|
|
59074
|
+
return (offset / length) * 100;
|
|
59075
|
+
};
|
|
59076
|
+
setMapped({ min: parse(min !== null && min !== void 0 ? min : 0), max: parse(max !== null && max !== void 0 ? max : 100) });
|
|
59077
|
+
});
|
|
59078
|
+
if (shouldMap) {
|
|
59079
|
+
observer.observe(element);
|
|
59080
|
+
}
|
|
59081
|
+
return function () {
|
|
59082
|
+
if (shouldMap) {
|
|
59083
|
+
observer.disconnect();
|
|
59084
|
+
}
|
|
59085
|
+
};
|
|
59086
|
+
}, [separator, max, min, isPx]);
|
|
59087
|
+
if (isPx) {
|
|
59088
|
+
return mapped;
|
|
59089
|
+
}
|
|
59090
|
+
else {
|
|
59091
|
+
return {
|
|
59092
|
+
min: Math.max(Number(min !== null && min !== void 0 ? min : 0), 0),
|
|
59093
|
+
max: Math.min(Number(max !== null && max !== void 0 ? max : 100), 100)
|
|
59094
|
+
};
|
|
59095
|
+
}
|
|
59096
|
+
};
|
|
59097
|
+
|
|
58864
59098
|
var canceEvent = function (e) {
|
|
58865
59099
|
if (e.currentTarget !== e.target) {
|
|
58866
59100
|
e.preventDefault();
|
|
@@ -58869,21 +59103,19 @@ var canceEvent = function (e) {
|
|
|
58869
59103
|
};
|
|
58870
59104
|
var Separator = forwardRef$1(function (_a, forwardRef) {
|
|
58871
59105
|
var _b;
|
|
58872
|
-
var parts = _a.parts, ratio = _a.ratio, onResized = _a.onResized, props = __rest(_a, ["parts", "ratio", "onResized"]);
|
|
59106
|
+
var parts = _a.parts, ratio = _a.ratio, onResized = _a.onResized, min = _a.min, max = _a.max, startAt = _a.startAt, props = __rest(_a, ["parts", "ratio", "onResized", "min", "max", "startAt"]);
|
|
58873
59107
|
var separator = useForkRef(forwardRef);
|
|
58874
|
-
var boundaries = {
|
|
58875
|
-
min: props['aria-valuemin'],
|
|
58876
|
-
max: props['aria-valuemax']
|
|
58877
|
-
};
|
|
59108
|
+
var boundaries = useBoundary(separator, { min: min, max: max });
|
|
58878
59109
|
var setValueNow = useValueSeparator({
|
|
58879
59110
|
ratio: ratio,
|
|
58880
59111
|
separator: separator,
|
|
58881
59112
|
onResized: onResized,
|
|
58882
|
-
boundaries: boundaries
|
|
59113
|
+
boundaries: boundaries,
|
|
59114
|
+
startAt: startAt
|
|
58883
59115
|
}).setValueNow;
|
|
58884
59116
|
useShowSeparator(separator);
|
|
58885
59117
|
var values = function () { return getSeparatorAttributes({ ref: separator }); };
|
|
58886
|
-
return (React__default.createElement("div", __assign({ ref: separator }, props, useMoveSeparator(separator, setValueNow), { onKeyDown: function (e) {
|
|
59118
|
+
return (React__default.createElement("div", __assign({ ref: separator, "aria-valuemin": boundaries.min, "aria-valuemax": boundaries.max }, props, useMoveSeparator(separator, setValueNow), { onKeyDown: function (e) {
|
|
58887
59119
|
var _a;
|
|
58888
59120
|
var newValueNow = keyDownHandler(e);
|
|
58889
59121
|
if (values().valueNow !== newValueNow) {
|
|
@@ -58933,12 +59165,31 @@ styleInject(css_248z);
|
|
|
58933
59165
|
*/
|
|
58934
59166
|
var Splitter = forwardRef$1(function (props, ref) {
|
|
58935
59167
|
if (props === void 0) { props = {}; }
|
|
58936
|
-
var parts = props.parts, ratio = props.ratio, onResized = props.onResized, min = props.min, max = props.max, children = props.children, _a = props.orientation, orientation = _a === void 0 ? 'vertical' : _a, rest = __rest(props, ["parts", "ratio", "onResized", "min", "max", "children", "orientation"]);
|
|
59168
|
+
var parts = props.parts, ratio = props.ratio, onResized = props.onResized, min = props.min, max = props.max, children = props.children, _a = props.orientation, orientation = _a === void 0 ? 'vertical' : _a, startAt = props.startAt, rest = __rest(props, ["parts", "ratio", "onResized", "min", "max", "children", "orientation", "startAt"]);
|
|
58937
59169
|
return (React__default.createElement("div", __assign({ ref: ref }, rest, { className: clsx('Splitter', rest === null || rest === void 0 ? void 0 : rest.className) }),
|
|
58938
59170
|
children,
|
|
58939
|
-
React__default.createElement(Separator, __assign({}, parts === null || parts === void 0 ? void 0 : parts.separator, { tabIndex: 0,
|
|
59171
|
+
React__default.createElement(Separator, __assign({}, parts === null || parts === void 0 ? void 0 : parts.separator, { tabIndex: 0, min: min, max: max, role: "separator", "aria-orientation": orientation, ratio: ratio, onResized: onResized, parts: parts === null || parts === void 0 ? void 0 : parts.controls, startAt: mapStartAt({ ratio: ratio, startAt: startAt }) }, setDataBoundary({ min: min, max: max })))));
|
|
58940
59172
|
});
|
|
58941
|
-
Splitter.displayName = 'Splitter';
|
|
59173
|
+
Splitter.displayName = 'Splitter';
|
|
59174
|
+
var mapStartAt = function (props) {
|
|
59175
|
+
var _a;
|
|
59176
|
+
if (typeof props.ratio === 'number') {
|
|
59177
|
+
// Only consider startAt value when Splitter is uncontrolled (ratio is undefined)
|
|
59178
|
+
return undefined;
|
|
59179
|
+
}
|
|
59180
|
+
// Words describe better intent than numbers.
|
|
59181
|
+
// However, 0 & 100 are figurative numbers.
|
|
59182
|
+
// If there are boundaries, these will be respected.
|
|
59183
|
+
switch (props.startAt) {
|
|
59184
|
+
case '1st-collapsed':
|
|
59185
|
+
return 0;
|
|
59186
|
+
case '2nd-collapsed':
|
|
59187
|
+
return 100;
|
|
59188
|
+
default:
|
|
59189
|
+
// Can be started at any other number between 0 and 100.
|
|
59190
|
+
return (_a = props.startAt) !== null && _a !== void 0 ? _a : 50;
|
|
59191
|
+
}
|
|
59192
|
+
};
|
|
58942
59193
|
|
|
58943
59194
|
var getSeparator = function (splitter) {
|
|
58944
59195
|
var _a;
|