@linzjs/lui 21.24.3 → 21.24.5-0
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 +7 -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 +275 -47
- package/dist/index.js.map +1 -1
- package/dist/lui.css +1 -0
- package/dist/lui.css.map +1 -1
- package/dist/lui.esm.js +275 -47
- package/dist/lui.esm.js.map +1 -1
- package/dist/scss/Components/LuiSidePanel/LuiSidePanel.scss +1 -0
- 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,65 @@ 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
|
+
};
|
|
58677
58779
|
};
|
|
58678
|
-
|
|
58679
|
-
|
|
58680
|
-
|
|
58681
|
-
|
|
58780
|
+
var config = function (attr) { return ({
|
|
58781
|
+
attributeFilter: ["aria-value".concat(attr)],
|
|
58782
|
+
attributeOldValue: true
|
|
58783
|
+
}); };
|
|
58784
|
+
var minObserver = new MutationObserver(callback('min'));
|
|
58785
|
+
var maxObserver = new MutationObserver(callback('max'));
|
|
58786
|
+
var orientationObserver = new MutationObserver(function () { return setValueNow(); });
|
|
58787
|
+
minObserver.observe(separator.current, config('min'));
|
|
58788
|
+
maxObserver.observe(separator.current, config('max'));
|
|
58789
|
+
orientationObserver.observe(separator.current, {
|
|
58790
|
+
attributeFilter: ['aria-orientation']
|
|
58682
58791
|
});
|
|
58683
|
-
return function () {
|
|
58684
|
-
|
|
58792
|
+
return function () {
|
|
58793
|
+
minObserver.disconnect();
|
|
58794
|
+
maxObserver.disconnect();
|
|
58795
|
+
orientationObserver.disconnect();
|
|
58796
|
+
};
|
|
58797
|
+
}, [separator]);
|
|
58685
58798
|
};
|
|
58686
58799
|
/**
|
|
58687
58800
|
* Broadcasts changes if separator aria-valuenow was altered.
|
|
@@ -58705,12 +58818,49 @@ var useValueNowEffect = function (setValueNow, separator) {
|
|
|
58705
58818
|
/**
|
|
58706
58819
|
* Calls setValueNow when the separator attributes change.
|
|
58707
58820
|
*/
|
|
58708
|
-
var useValueSeparatorEffects = function (setValueNow, separator, ratio) {
|
|
58709
|
-
useRatioEffect(setValueNow, ratio);
|
|
58821
|
+
var useValueSeparatorEffects = function (setValueNow, separator, ratio, startAt) {
|
|
58822
|
+
useRatioEffect(setValueNow, separator, ratio, startAt);
|
|
58710
58823
|
useConfigEffect(setValueNow, separator);
|
|
58711
58824
|
useValueNowEffect(setValueNow, separator);
|
|
58712
58825
|
};
|
|
58713
58826
|
|
|
58827
|
+
/**
|
|
58828
|
+
* It will calculate the best grid arrangement, based on the min/max props passed to the Splitter.
|
|
58829
|
+
* All grid options work. The preference `1fr XXpx` over `(width - XXpx) 1fr` depends on the type of boundary
|
|
58830
|
+
* to avoid calculation of position when the window is being resized while trying to retain the collapsed state
|
|
58831
|
+
* on a min/max value fixed in pixels (e.g. 200px). Such calculation adds unnecessary lagging on the separator
|
|
58832
|
+
* to catch up. This function aims to avoid such lagging during resizing.
|
|
58833
|
+
* primary relates to top/left
|
|
58834
|
+
* secondary relates to right/bottom
|
|
58835
|
+
*/
|
|
58836
|
+
var getGridTemplate = function (separator) {
|
|
58837
|
+
var _a = getSeparatorAttributes({ separator: separator }), valueNow = _a.valueNow, gap = _a.thickness, boundary = _a.boundary, orientation = _a.orientation;
|
|
58838
|
+
var rect = separator.parentElement.getBoundingClientRect();
|
|
58839
|
+
var dimension = orientation === 'horizontal' ? 'height' : 'width';
|
|
58840
|
+
var seperatorAbsolutePx = (rect[dimension] / 100) * valueNow;
|
|
58841
|
+
var offset = gap / 2;
|
|
58842
|
+
if (boundary === 'keep-primary') {
|
|
58843
|
+
return {
|
|
58844
|
+
grid: "".concat(seperatorAbsolutePx - offset, "px 1fr"),
|
|
58845
|
+
primary: "".concat(seperatorAbsolutePx, "px"),
|
|
58846
|
+
secondary: ''
|
|
58847
|
+
};
|
|
58848
|
+
}
|
|
58849
|
+
if (boundary === 'keep-secondary') {
|
|
58850
|
+
return {
|
|
58851
|
+
grid: "1fr ".concat(rect[dimension] - seperatorAbsolutePx - offset, "px"),
|
|
58852
|
+
primary: '',
|
|
58853
|
+
secondary: "".concat(rect[dimension] - seperatorAbsolutePx, "px")
|
|
58854
|
+
};
|
|
58855
|
+
}
|
|
58856
|
+
var primary = "clamp(".concat(offset, "px, ").concat(valueNow, "%, calc(100% - ").concat(offset, "px))");
|
|
58857
|
+
return {
|
|
58858
|
+
grid: "min(calc(".concat(valueNow, "% - ").concat(gap / 2, "px), calc(100% - ").concat(gap, "px)) 1fr"),
|
|
58859
|
+
primary: primary,
|
|
58860
|
+
secondary: "calc(100% - ".concat(primary, ")")
|
|
58861
|
+
};
|
|
58862
|
+
};
|
|
58863
|
+
|
|
58714
58864
|
/**
|
|
58715
58865
|
* Ensures valueNow is set to a valid value within its allowed boundaries.
|
|
58716
58866
|
* If boundaries and/or initialRatio are not specified, they will be defaulted.
|
|
@@ -58718,19 +58868,24 @@ var useValueSeparatorEffects = function (setValueNow, separator, ratio) {
|
|
|
58718
58868
|
* This multiple calls are expected, and setValueNow will resize only once.
|
|
58719
58869
|
*/
|
|
58720
58870
|
var useValueSeparator = function (_a) {
|
|
58721
|
-
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized, _b = _a.boundaries,
|
|
58871
|
+
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized, _b = _a.boundaries, minProp = _b.min, maxProp = _b.max, startAt = _a.startAt;
|
|
58722
58872
|
var prev = useRef(null);
|
|
58723
|
-
var setValueNow = useCallback(function (val) {
|
|
58873
|
+
var setValueNow = useCallback(function (val, config) {
|
|
58874
|
+
var _a, _b;
|
|
58724
58875
|
var valueNow = getSeparatorAttributes({ ref: separator }).valueNow;
|
|
58876
|
+
// Prioritize min/max from callback, they are updated before the boundaries prop.
|
|
58877
|
+
var min = (_a = config === null || config === void 0 ? void 0 : config.min) !== null && _a !== void 0 ? _a : minProp;
|
|
58878
|
+
var max = (_b = config === null || config === void 0 ? void 0 : config.max) !== null && _b !== void 0 ? _b : maxProp;
|
|
58725
58879
|
var value = val !== null && val !== void 0 ? val : (valueNow || min + (max - min) / 2);
|
|
58726
58880
|
var newValue = clampSeparator({ value: value, max: max, min: min });
|
|
58881
|
+
var isCalculating = min === -Infinity || max === Infinity;
|
|
58727
58882
|
resize(separator, newValue);
|
|
58728
|
-
if (prev.current !== newValue) {
|
|
58883
|
+
if (prev.current !== newValue && !isCalculating) {
|
|
58729
58884
|
prev.current = newValue;
|
|
58730
58885
|
onResized === null || onResized === void 0 ? void 0 : onResized(newValue);
|
|
58731
58886
|
}
|
|
58732
|
-
}, [onResized,
|
|
58733
|
-
useValueSeparatorEffects(setValueNow, separator, ratio);
|
|
58887
|
+
}, [onResized, minProp, maxProp, prev]);
|
|
58888
|
+
useValueSeparatorEffects(setValueNow, separator, ratio, startAt);
|
|
58734
58889
|
return { setValueNow: setValueNow };
|
|
58735
58890
|
};
|
|
58736
58891
|
var resize = function (separator, value) {
|
|
@@ -58746,12 +58901,8 @@ var resize = function (separator, value) {
|
|
|
58746
58901
|
separator.current.setAttribute('aria-valuenow', newValue);
|
|
58747
58902
|
}
|
|
58748
58903
|
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");
|
|
58904
|
+
var _d = getGridTemplate(separator.current), grid = _d.grid, primary = _d.primary, secondary = _d.secondary;
|
|
58905
|
+
var gridTemplate = panels === 1 ? '1fr' : grid;
|
|
58755
58906
|
var splitter = (_b = separator.current) === null || _b === void 0 ? void 0 : _b.parentElement;
|
|
58756
58907
|
if (splitter) {
|
|
58757
58908
|
splitter.style.opacity = '1';
|
|
@@ -58759,25 +58910,29 @@ var resize = function (separator, value) {
|
|
|
58759
58910
|
splitter.style.columnGap = "".concat(gap, "px");
|
|
58760
58911
|
splitter.style.gridTemplateColumns = gridTemplate;
|
|
58761
58912
|
separator.current.style.width = "".concat(gap, "px");
|
|
58762
|
-
separator.current.style.left =
|
|
58913
|
+
separator.current.style.left = primary;
|
|
58914
|
+
separator.current.style.right = secondary;
|
|
58763
58915
|
separator.current.style.height = '100%';
|
|
58764
|
-
separator.current.style.transform =
|
|
58916
|
+
separator.current.style.transform = "translateX(".concat(primary && '-', "50%)");
|
|
58765
58917
|
separator.current.style.cursor = 'col-resize';
|
|
58766
58918
|
splitter.style.rowGap = '';
|
|
58767
58919
|
splitter.style.gridTemplateRows = '';
|
|
58768
58920
|
separator.current.style.top = '';
|
|
58921
|
+
separator.current.style.bottom = '';
|
|
58769
58922
|
}
|
|
58770
58923
|
else {
|
|
58771
58924
|
splitter.style.rowGap = "".concat(gap, "px");
|
|
58772
58925
|
splitter.style.gridTemplateRows = gridTemplate;
|
|
58773
58926
|
separator.current.style.height = "".concat(gap, "px");
|
|
58774
|
-
separator.current.style.top =
|
|
58927
|
+
separator.current.style.top = primary;
|
|
58928
|
+
separator.current.style.bottom = secondary;
|
|
58775
58929
|
separator.current.style.width = '100%';
|
|
58776
|
-
separator.current.style.transform =
|
|
58930
|
+
separator.current.style.transform = "translateY(".concat(primary && '-', "50%)");
|
|
58777
58931
|
separator.current.style.cursor = 'row-resize';
|
|
58778
58932
|
splitter.style.columnGap = '';
|
|
58779
58933
|
splitter.style.gridTemplateColumns = '';
|
|
58780
58934
|
separator.current.style.left = '';
|
|
58935
|
+
separator.current.style.right = '';
|
|
58781
58936
|
}
|
|
58782
58937
|
}
|
|
58783
58938
|
};
|
|
@@ -58861,6 +59016,62 @@ var getNewValueNow = function (_a, valueNow, pixelUnit) {
|
|
|
58861
59016
|
return valueNow;
|
|
58862
59017
|
};
|
|
58863
59018
|
|
|
59019
|
+
var isPxProps = function (_a) {
|
|
59020
|
+
var min = _a.min, max = _a.max;
|
|
59021
|
+
var isPercentage = typeof max === 'number' || typeof min === 'number';
|
|
59022
|
+
var isNull = min === undefined && max === undefined;
|
|
59023
|
+
return !isPercentage && !isNull;
|
|
59024
|
+
};
|
|
59025
|
+
/**
|
|
59026
|
+
* Maps min and max values if they are provided in 'XXXpx' format.
|
|
59027
|
+
*/
|
|
59028
|
+
var useBoundary = function (separator, boundaries) {
|
|
59029
|
+
var _a = useState({ min: -Infinity, max: Infinity }), mapped = _a[0], setMapped = _a[1];
|
|
59030
|
+
var isPx = isPxProps(boundaries);
|
|
59031
|
+
var min = boundaries.min, max = boundaries.max;
|
|
59032
|
+
useEffect(function () {
|
|
59033
|
+
var _a;
|
|
59034
|
+
var element = (_a = separator === null || separator === void 0 ? void 0 : separator.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
59035
|
+
var shouldMap = element && isPx;
|
|
59036
|
+
var observer = new ResizeObserver(function (_a) {
|
|
59037
|
+
var rect = _a[0].contentRect;
|
|
59038
|
+
var _b = getSeparatorAttributes({
|
|
59039
|
+
ref: separator
|
|
59040
|
+
}), thickness = _b.thickness, orientation = _b.orientation;
|
|
59041
|
+
var halfThickness = thickness / 2;
|
|
59042
|
+
var length = orientation === 'vertical' ? rect.width : rect.height;
|
|
59043
|
+
var parse = function (boundary) {
|
|
59044
|
+
if (typeof boundary === 'number') {
|
|
59045
|
+
return boundary;
|
|
59046
|
+
}
|
|
59047
|
+
var boundaryAsNumber = parseFloat(boundary);
|
|
59048
|
+
var offset = boundaryAsNumber > 0
|
|
59049
|
+
? boundaryAsNumber + halfThickness
|
|
59050
|
+
: length - Math.abs(boundaryAsNumber) - halfThickness;
|
|
59051
|
+
return (offset / length) * 100;
|
|
59052
|
+
};
|
|
59053
|
+
setMapped({ min: parse(min !== null && min !== void 0 ? min : 0), max: parse(max !== null && max !== void 0 ? max : 100) });
|
|
59054
|
+
});
|
|
59055
|
+
if (shouldMap) {
|
|
59056
|
+
observer.observe(element);
|
|
59057
|
+
}
|
|
59058
|
+
return function () {
|
|
59059
|
+
if (shouldMap) {
|
|
59060
|
+
observer.disconnect();
|
|
59061
|
+
}
|
|
59062
|
+
};
|
|
59063
|
+
}, [separator, max, min, isPx]);
|
|
59064
|
+
if (isPx) {
|
|
59065
|
+
return mapped;
|
|
59066
|
+
}
|
|
59067
|
+
else {
|
|
59068
|
+
return {
|
|
59069
|
+
min: Math.max(Number(min !== null && min !== void 0 ? min : 0), 0),
|
|
59070
|
+
max: Math.min(Number(max !== null && max !== void 0 ? max : 100), 100)
|
|
59071
|
+
};
|
|
59072
|
+
}
|
|
59073
|
+
};
|
|
59074
|
+
|
|
58864
59075
|
var canceEvent = function (e) {
|
|
58865
59076
|
if (e.currentTarget !== e.target) {
|
|
58866
59077
|
e.preventDefault();
|
|
@@ -58869,21 +59080,19 @@ var canceEvent = function (e) {
|
|
|
58869
59080
|
};
|
|
58870
59081
|
var Separator = forwardRef$1(function (_a, forwardRef) {
|
|
58871
59082
|
var _b;
|
|
58872
|
-
var parts = _a.parts, ratio = _a.ratio, onResized = _a.onResized, props = __rest(_a, ["parts", "ratio", "onResized"]);
|
|
59083
|
+
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
59084
|
var separator = useForkRef(forwardRef);
|
|
58874
|
-
var boundaries = {
|
|
58875
|
-
min: props['aria-valuemin'],
|
|
58876
|
-
max: props['aria-valuemax']
|
|
58877
|
-
};
|
|
59085
|
+
var boundaries = useBoundary(separator, { min: min, max: max });
|
|
58878
59086
|
var setValueNow = useValueSeparator({
|
|
58879
59087
|
ratio: ratio,
|
|
58880
59088
|
separator: separator,
|
|
58881
59089
|
onResized: onResized,
|
|
58882
|
-
boundaries: boundaries
|
|
59090
|
+
boundaries: boundaries,
|
|
59091
|
+
startAt: startAt
|
|
58883
59092
|
}).setValueNow;
|
|
58884
59093
|
useShowSeparator(separator);
|
|
58885
59094
|
var values = function () { return getSeparatorAttributes({ ref: separator }); };
|
|
58886
|
-
return (React__default.createElement("div", __assign({ ref: separator }, props, useMoveSeparator(separator, setValueNow), { onKeyDown: function (e) {
|
|
59095
|
+
return (React__default.createElement("div", __assign({ ref: separator, "aria-valuemin": boundaries.min, "aria-valuemax": boundaries.max }, props, useMoveSeparator(separator, setValueNow), { onKeyDown: function (e) {
|
|
58887
59096
|
var _a;
|
|
58888
59097
|
var newValueNow = keyDownHandler(e);
|
|
58889
59098
|
if (values().valueNow !== newValueNow) {
|
|
@@ -58933,12 +59142,31 @@ styleInject(css_248z);
|
|
|
58933
59142
|
*/
|
|
58934
59143
|
var Splitter = forwardRef$1(function (props, ref) {
|
|
58935
59144
|
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"]);
|
|
59145
|
+
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
59146
|
return (React__default.createElement("div", __assign({ ref: ref }, rest, { className: clsx('Splitter', rest === null || rest === void 0 ? void 0 : rest.className) }),
|
|
58938
59147
|
children,
|
|
58939
|
-
React__default.createElement(Separator, __assign({}, parts === null || parts === void 0 ? void 0 : parts.separator, { tabIndex: 0,
|
|
59148
|
+
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
59149
|
});
|
|
58941
|
-
Splitter.displayName = 'Splitter';
|
|
59150
|
+
Splitter.displayName = 'Splitter';
|
|
59151
|
+
var mapStartAt = function (props) {
|
|
59152
|
+
var _a;
|
|
59153
|
+
if (typeof props.ratio === 'number') {
|
|
59154
|
+
// Only consider startAt value when Splitter is uncontrolled (ratio is undefined)
|
|
59155
|
+
return undefined;
|
|
59156
|
+
}
|
|
59157
|
+
// Words describe better intent than numbers.
|
|
59158
|
+
// However, 0 & 100 are figurative numbers.
|
|
59159
|
+
// If there are boundaries, these will be respected.
|
|
59160
|
+
switch (props.startAt) {
|
|
59161
|
+
case '1st-collapsed':
|
|
59162
|
+
return 0;
|
|
59163
|
+
case '2nd-collapsed':
|
|
59164
|
+
return 100;
|
|
59165
|
+
default:
|
|
59166
|
+
// Can be started at any other number between 0 and 100.
|
|
59167
|
+
return (_a = props.startAt) !== null && _a !== void 0 ? _a : 50;
|
|
59168
|
+
}
|
|
59169
|
+
};
|
|
58942
59170
|
|
|
58943
59171
|
var getSeparator = function (splitter) {
|
|
58944
59172
|
var _a;
|