@linzjs/lui 21.24.5-0 → 21.25.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 +0 -3
- package/dist/components/Splitter/Splitter.d.ts +19 -33
- package/dist/components/Splitter/helpers/getSeparatorAttributes.d.ts +0 -1
- package/dist/components/Splitter/helpers/useValueSeparator.d.ts +2 -6
- package/dist/components/Splitter/helpers/useValueSeparatorEffects.d.ts +1 -4
- package/dist/index.js +47 -275
- package/dist/index.js.map +1 -1
- package/dist/lui.css +8 -1
- package/dist/lui.css.map +1 -1
- package/dist/lui.esm.js +47 -275
- package/dist/lui.esm.js.map +1 -1
- package/dist/scss/Vendor/naturalize.scss +8 -1
- package/package.json +1 -1
- package/dist/components/Splitter/Stories/RangeAsPx.d.ts +0 -9
- package/dist/components/Splitter/Stories/Section.d.ts +0 -5
- package/dist/components/Splitter/helpers/dataBoundary.d.ts +0 -18
- package/dist/components/Splitter/helpers/getGridTemplate.d.ts +0 -14
- package/dist/components/Splitter/helpers/transition.d.ts +0 -5
- package/dist/components/Splitter/helpers/useBoundary.d.ts +0 -13
package/dist/lui.esm.js
CHANGED
|
@@ -58421,56 +58421,6 @@ 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
|
-
|
|
58474
58424
|
/**
|
|
58475
58425
|
* Given a ref/element if finds the Separator and returns the most useful attributes
|
|
58476
58426
|
*/
|
|
@@ -58486,8 +58436,7 @@ var getValues = function (el) {
|
|
|
58486
58436
|
valueMin: parseValue(el === null || el === void 0 ? void 0 : el.getAttribute('aria-valuemin')),
|
|
58487
58437
|
valueMax: parseValue(el === null || el === void 0 ? void 0 : el.getAttribute('aria-valuemax')),
|
|
58488
58438
|
orientation: parseOrientation(el === null || el === void 0 ? void 0 : el.getAttribute('aria-orientation')),
|
|
58489
|
-
thickness: getSeparatorThickness(el)
|
|
58490
|
-
boundary: getDataBoundary(el)
|
|
58439
|
+
thickness: getSeparatorThickness(el)
|
|
58491
58440
|
};
|
|
58492
58441
|
};
|
|
58493
58442
|
var parseValue = function (val) {
|
|
@@ -58565,9 +58514,6 @@ var Control = forwardRef$1(function (props, forwardRef) {
|
|
|
58565
58514
|
useEffect(function () {
|
|
58566
58515
|
var callback = function () {
|
|
58567
58516
|
var control = ref.current;
|
|
58568
|
-
if (!control) {
|
|
58569
|
-
return;
|
|
58570
|
-
}
|
|
58571
58517
|
var _a = getButtonProps(ref, side), hide = _a.hide, offset = _a.offset, orientation = _a.orientation;
|
|
58572
58518
|
var vertical = orientation === 'vertical';
|
|
58573
58519
|
control.style.left = vertical ? "".concat(offset, "px") : '50%';
|
|
@@ -58580,14 +58526,7 @@ var Control = forwardRef$1(function (props, forwardRef) {
|
|
|
58580
58526
|
var separator = ref.current.closest('[role="separator"]');
|
|
58581
58527
|
callback();
|
|
58582
58528
|
var observer = new MutationObserver(callback);
|
|
58583
|
-
observer.observe(separator, {
|
|
58584
|
-
attributeFilter: [
|
|
58585
|
-
'aria-valuenow',
|
|
58586
|
-
'aria-valuemin',
|
|
58587
|
-
'aria-valuemax',
|
|
58588
|
-
'aria-orientation',
|
|
58589
|
-
]
|
|
58590
|
-
});
|
|
58529
|
+
observer.observe(separator, { attributeFilter: ['aria-valuenow'] });
|
|
58591
58530
|
return function () { return observer.disconnect(); };
|
|
58592
58531
|
}, [ref, side]);
|
|
58593
58532
|
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 })));
|
|
@@ -58652,29 +58591,6 @@ var getSeparatorPosition = function (separatorRef, drag) {
|
|
|
58652
58591
|
return clampSeparator({ value: value });
|
|
58653
58592
|
};
|
|
58654
58593
|
|
|
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
|
-
|
|
58678
58594
|
/**
|
|
58679
58595
|
* It captures window events to report a new position.
|
|
58680
58596
|
* Provides necessary handlers for separator.
|
|
@@ -58718,7 +58634,8 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58718
58634
|
var splitter = separator === null || separator === void 0 ? void 0 : separator.parentElement;
|
|
58719
58635
|
if (separator && splitter) {
|
|
58720
58636
|
if (animate === 'clear-transition') {
|
|
58721
|
-
transition
|
|
58637
|
+
separator.style.transition = '';
|
|
58638
|
+
splitter.style.transition = '';
|
|
58722
58639
|
splitter.style.cursor =
|
|
58723
58640
|
separator.getAttribute('aria-orientation') === 'vertical'
|
|
58724
58641
|
? 'col-resize'
|
|
@@ -58726,7 +58643,9 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58726
58643
|
splitter.classList.add('resizing');
|
|
58727
58644
|
}
|
|
58728
58645
|
else {
|
|
58729
|
-
transition
|
|
58646
|
+
separator.style.transition = 'left 300ms, top 300ms';
|
|
58647
|
+
splitter.style.transition =
|
|
58648
|
+
'grid-template-columns 300ms, grid-template-rows 300ms';
|
|
58730
58649
|
splitter.style.cursor = '';
|
|
58731
58650
|
splitter.classList.remove('resizing');
|
|
58732
58651
|
}
|
|
@@ -58736,65 +58655,33 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58736
58655
|
/**
|
|
58737
58656
|
* Moves separator as per ratio changes. Centers on first render if ratio is undefined.
|
|
58738
58657
|
*/
|
|
58739
|
-
var useRatioEffect = function (setValueNow,
|
|
58658
|
+
var useRatioEffect = function (setValueNow, ratio) {
|
|
58740
58659
|
var firstRun = useRef(true);
|
|
58741
|
-
var _a = getSeparatorAttributes({ ref: separator }), valueMax = _a.valueMax, valueMin = _a.valueMin;
|
|
58742
|
-
var isCalculating = valueMax === Infinity || valueMin === -Infinity;
|
|
58743
58660
|
useEffect(function () {
|
|
58744
|
-
if (firstRun.current || ratio !== undefined
|
|
58661
|
+
if (firstRun.current || ratio !== undefined) {
|
|
58745
58662
|
firstRun.current = false;
|
|
58746
58663
|
// If ratio is undefined, setValueNow will place the separator in the middle as a starting point.
|
|
58747
58664
|
// Whatever value is `the middle` will be determined by setValueNow
|
|
58748
|
-
setValueNow(ratio
|
|
58665
|
+
setValueNow(ratio);
|
|
58749
58666
|
}
|
|
58750
|
-
}, [setValueNow, ratio, firstRun
|
|
58667
|
+
}, [setValueNow, ratio, firstRun]);
|
|
58751
58668
|
};
|
|
58752
58669
|
/**
|
|
58753
58670
|
* Re-arranges the splitter if the limits or orientation change.
|
|
58754
58671
|
*/
|
|
58755
58672
|
var useConfigEffect = function (setValueNow, separator) {
|
|
58756
|
-
var _a = useState(0), count = _a[0], setCount = _a[1];
|
|
58757
|
-
useEffect(function () { return transition(separator).resume(); }, [count]);
|
|
58758
58673
|
useEffect(function () {
|
|
58759
|
-
var callback = function (
|
|
58760
|
-
|
|
58761
|
-
|
|
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
|
-
};
|
|
58674
|
+
var callback = function () {
|
|
58675
|
+
var value = getSeparatorAttributes({ ref: separator }).valueNow;
|
|
58676
|
+
setValueNow(value);
|
|
58779
58677
|
};
|
|
58780
|
-
|
|
58781
|
-
|
|
58782
|
-
|
|
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']
|
|
58678
|
+
callback();
|
|
58679
|
+
var observer = new MutationObserver(callback);
|
|
58680
|
+
observer.observe(separator.current, {
|
|
58681
|
+
attributeFilter: ['aria-orientation', 'aria-valuemin', 'aria-valuemax']
|
|
58791
58682
|
});
|
|
58792
|
-
return function () {
|
|
58793
|
-
|
|
58794
|
-
maxObserver.disconnect();
|
|
58795
|
-
orientationObserver.disconnect();
|
|
58796
|
-
};
|
|
58797
|
-
}, [separator]);
|
|
58683
|
+
return function () { return observer.disconnect(); };
|
|
58684
|
+
}, [separator, setValueNow]);
|
|
58798
58685
|
};
|
|
58799
58686
|
/**
|
|
58800
58687
|
* Broadcasts changes if separator aria-valuenow was altered.
|
|
@@ -58818,49 +58705,12 @@ var useValueNowEffect = function (setValueNow, separator) {
|
|
|
58818
58705
|
/**
|
|
58819
58706
|
* Calls setValueNow when the separator attributes change.
|
|
58820
58707
|
*/
|
|
58821
|
-
var useValueSeparatorEffects = function (setValueNow, separator, ratio
|
|
58822
|
-
useRatioEffect(setValueNow,
|
|
58708
|
+
var useValueSeparatorEffects = function (setValueNow, separator, ratio) {
|
|
58709
|
+
useRatioEffect(setValueNow, ratio);
|
|
58823
58710
|
useConfigEffect(setValueNow, separator);
|
|
58824
58711
|
useValueNowEffect(setValueNow, separator);
|
|
58825
58712
|
};
|
|
58826
58713
|
|
|
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
|
-
|
|
58864
58714
|
/**
|
|
58865
58715
|
* Ensures valueNow is set to a valid value within its allowed boundaries.
|
|
58866
58716
|
* If boundaries and/or initialRatio are not specified, they will be defaulted.
|
|
@@ -58868,24 +58718,19 @@ var getGridTemplate = function (separator) {
|
|
|
58868
58718
|
* This multiple calls are expected, and setValueNow will resize only once.
|
|
58869
58719
|
*/
|
|
58870
58720
|
var useValueSeparator = function (_a) {
|
|
58871
|
-
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized, _b = _a.boundaries,
|
|
58721
|
+
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized, _b = _a.boundaries, min = _b.min, max = _b.max;
|
|
58872
58722
|
var prev = useRef(null);
|
|
58873
|
-
var setValueNow = useCallback(function (val
|
|
58874
|
-
var _a, _b;
|
|
58723
|
+
var setValueNow = useCallback(function (val) {
|
|
58875
58724
|
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;
|
|
58879
58725
|
var value = val !== null && val !== void 0 ? val : (valueNow || min + (max - min) / 2);
|
|
58880
58726
|
var newValue = clampSeparator({ value: value, max: max, min: min });
|
|
58881
|
-
var isCalculating = min === -Infinity || max === Infinity;
|
|
58882
58727
|
resize(separator, newValue);
|
|
58883
|
-
if (prev.current !== newValue
|
|
58728
|
+
if (prev.current !== newValue) {
|
|
58884
58729
|
prev.current = newValue;
|
|
58885
58730
|
onResized === null || onResized === void 0 ? void 0 : onResized(newValue);
|
|
58886
58731
|
}
|
|
58887
|
-
}, [onResized,
|
|
58888
|
-
useValueSeparatorEffects(setValueNow, separator, ratio
|
|
58732
|
+
}, [onResized, min, max, prev]);
|
|
58733
|
+
useValueSeparatorEffects(setValueNow, separator, ratio);
|
|
58889
58734
|
return { setValueNow: setValueNow };
|
|
58890
58735
|
};
|
|
58891
58736
|
var resize = function (separator, value) {
|
|
@@ -58901,8 +58746,12 @@ var resize = function (separator, value) {
|
|
|
58901
58746
|
separator.current.setAttribute('aria-valuenow', newValue);
|
|
58902
58747
|
}
|
|
58903
58748
|
var panels = (_a = separator.current.parentElement.childNodes.length) !== null && _a !== void 0 ? _a : 0;
|
|
58904
|
-
var
|
|
58905
|
-
var
|
|
58749
|
+
var valueNow = Number(separator.current.getAttribute('aria-valuenow'));
|
|
58750
|
+
var offset = gap / 2;
|
|
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");
|
|
58906
58755
|
var splitter = (_b = separator.current) === null || _b === void 0 ? void 0 : _b.parentElement;
|
|
58907
58756
|
if (splitter) {
|
|
58908
58757
|
splitter.style.opacity = '1';
|
|
@@ -58910,29 +58759,25 @@ var resize = function (separator, value) {
|
|
|
58910
58759
|
splitter.style.columnGap = "".concat(gap, "px");
|
|
58911
58760
|
splitter.style.gridTemplateColumns = gridTemplate;
|
|
58912
58761
|
separator.current.style.width = "".concat(gap, "px");
|
|
58913
|
-
separator.current.style.left =
|
|
58914
|
-
separator.current.style.right = secondary;
|
|
58762
|
+
separator.current.style.left = absolute;
|
|
58915
58763
|
separator.current.style.height = '100%';
|
|
58916
|
-
separator.current.style.transform =
|
|
58764
|
+
separator.current.style.transform = 'translateX(-50%)';
|
|
58917
58765
|
separator.current.style.cursor = 'col-resize';
|
|
58918
58766
|
splitter.style.rowGap = '';
|
|
58919
58767
|
splitter.style.gridTemplateRows = '';
|
|
58920
58768
|
separator.current.style.top = '';
|
|
58921
|
-
separator.current.style.bottom = '';
|
|
58922
58769
|
}
|
|
58923
58770
|
else {
|
|
58924
58771
|
splitter.style.rowGap = "".concat(gap, "px");
|
|
58925
58772
|
splitter.style.gridTemplateRows = gridTemplate;
|
|
58926
58773
|
separator.current.style.height = "".concat(gap, "px");
|
|
58927
|
-
separator.current.style.top =
|
|
58928
|
-
separator.current.style.bottom = secondary;
|
|
58774
|
+
separator.current.style.top = absolute;
|
|
58929
58775
|
separator.current.style.width = '100%';
|
|
58930
|
-
separator.current.style.transform =
|
|
58776
|
+
separator.current.style.transform = 'translateY(-50%)';
|
|
58931
58777
|
separator.current.style.cursor = 'row-resize';
|
|
58932
58778
|
splitter.style.columnGap = '';
|
|
58933
58779
|
splitter.style.gridTemplateColumns = '';
|
|
58934
58780
|
separator.current.style.left = '';
|
|
58935
|
-
separator.current.style.right = '';
|
|
58936
58781
|
}
|
|
58937
58782
|
}
|
|
58938
58783
|
};
|
|
@@ -59016,62 +58861,6 @@ var getNewValueNow = function (_a, valueNow, pixelUnit) {
|
|
|
59016
58861
|
return valueNow;
|
|
59017
58862
|
};
|
|
59018
58863
|
|
|
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
|
-
|
|
59075
58864
|
var canceEvent = function (e) {
|
|
59076
58865
|
if (e.currentTarget !== e.target) {
|
|
59077
58866
|
e.preventDefault();
|
|
@@ -59080,19 +58869,21 @@ var canceEvent = function (e) {
|
|
|
59080
58869
|
};
|
|
59081
58870
|
var Separator = forwardRef$1(function (_a, forwardRef) {
|
|
59082
58871
|
var _b;
|
|
59083
|
-
var parts = _a.parts, ratio = _a.ratio, onResized = _a.onResized,
|
|
58872
|
+
var parts = _a.parts, ratio = _a.ratio, onResized = _a.onResized, props = __rest(_a, ["parts", "ratio", "onResized"]);
|
|
59084
58873
|
var separator = useForkRef(forwardRef);
|
|
59085
|
-
var boundaries =
|
|
58874
|
+
var boundaries = {
|
|
58875
|
+
min: props['aria-valuemin'],
|
|
58876
|
+
max: props['aria-valuemax']
|
|
58877
|
+
};
|
|
59086
58878
|
var setValueNow = useValueSeparator({
|
|
59087
58879
|
ratio: ratio,
|
|
59088
58880
|
separator: separator,
|
|
59089
58881
|
onResized: onResized,
|
|
59090
|
-
boundaries: boundaries
|
|
59091
|
-
startAt: startAt
|
|
58882
|
+
boundaries: boundaries
|
|
59092
58883
|
}).setValueNow;
|
|
59093
58884
|
useShowSeparator(separator);
|
|
59094
58885
|
var values = function () { return getSeparatorAttributes({ ref: separator }); };
|
|
59095
|
-
return (React__default.createElement("div", __assign({ ref: separator
|
|
58886
|
+
return (React__default.createElement("div", __assign({ ref: separator }, props, useMoveSeparator(separator, setValueNow), { onKeyDown: function (e) {
|
|
59096
58887
|
var _a;
|
|
59097
58888
|
var newValueNow = keyDownHandler(e);
|
|
59098
58889
|
if (values().valueNow !== newValueNow) {
|
|
@@ -59142,31 +58933,12 @@ styleInject(css_248z);
|
|
|
59142
58933
|
*/
|
|
59143
58934
|
var Splitter = forwardRef$1(function (props, ref) {
|
|
59144
58935
|
if (props === void 0) { props = {}; }
|
|
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,
|
|
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"]);
|
|
59146
58937
|
return (React__default.createElement("div", __assign({ ref: ref }, rest, { className: clsx('Splitter', rest === null || rest === void 0 ? void 0 : rest.className) }),
|
|
59147
58938
|
children,
|
|
59148
|
-
React__default.createElement(Separator, __assign({}, parts === null || parts === void 0 ? void 0 : parts.separator, { tabIndex: 0, min:
|
|
58939
|
+
React__default.createElement(Separator, __assign({}, parts === null || parts === void 0 ? void 0 : parts.separator, { tabIndex: 0, "aria-valuemin": Math.max(min !== null && min !== void 0 ? min : 0, 0), "aria-valuemax": Math.min(max !== null && max !== void 0 ? max : 100, 100), role: "separator", "aria-orientation": orientation, ratio: ratio, onResized: onResized, parts: parts === null || parts === void 0 ? void 0 : parts.controls }))));
|
|
59149
58940
|
});
|
|
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
|
-
};
|
|
58941
|
+
Splitter.displayName = 'Splitter';
|
|
59170
58942
|
|
|
59171
58943
|
var getSeparator = function (splitter) {
|
|
59172
58944
|
var _a;
|