@linzjs/lui 21.39.1 → 21.39.2-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/dist/components/Splitter/Separator/Separator.d.ts +0 -2
- package/dist/components/Splitter/helpers/getSeparatorAttributes.d.ts +2 -1
- package/dist/components/Splitter/helpers/useValueSeparator.d.ts +2 -9
- package/dist/components/Splitter/helpers/useValueSeparatorEffects.d.ts +1 -4
- package/dist/index.js +184 -224
- package/dist/index.js.map +1 -1
- package/dist/lui.esm.js +184 -224
- package/dist/lui.esm.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/Splitter/helpers/useBoundary.d.ts +0 -13
|
@@ -6,8 +6,6 @@ export declare const Separator: React.ForwardRefExoticComponent<Pick<React.Detai
|
|
|
6
6
|
parts?: Parts;
|
|
7
7
|
ratio?: number | undefined;
|
|
8
8
|
onResized?: ((val: number) => void) | undefined;
|
|
9
|
-
min?: number | `${number}px` | undefined;
|
|
10
|
-
max?: number | `${number}px` | undefined;
|
|
11
9
|
startAt?: number | undefined;
|
|
12
10
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
13
11
|
export {};
|
|
@@ -17,10 +17,11 @@ declare type Props = {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const getSeparatorAttributes: (props: Props) => {
|
|
19
19
|
valueNow: number;
|
|
20
|
-
valueMin: number;
|
|
21
20
|
valueMax: number;
|
|
21
|
+
valueMin: number;
|
|
22
22
|
orientation: "horizontal" | "vertical" | undefined;
|
|
23
23
|
thickness: number;
|
|
24
24
|
boundary: ("keep-secondary" | "keep-primary" | "keep-both") | undefined;
|
|
25
|
+
sticky: "primary" | "secondary" | undefined;
|
|
25
26
|
};
|
|
26
27
|
export {};
|
|
@@ -5,18 +5,11 @@ import { RefObject } from 'react';
|
|
|
5
5
|
* It's possible that multiple events trigger setValueNow simultaneosly with the same value.
|
|
6
6
|
* This multiple calls are expected, and setValueNow will resize only once.
|
|
7
7
|
*/
|
|
8
|
-
export declare const useValueSeparator: ({ separator, ratio, onResized,
|
|
8
|
+
export declare const useValueSeparator: ({ separator, ratio, onResized, startAt, }: {
|
|
9
9
|
ratio?: number | undefined;
|
|
10
10
|
onResized?: ((newVal: number) => void) | undefined;
|
|
11
11
|
separator: RefObject<HTMLDivElement>;
|
|
12
|
-
boundaries: {
|
|
13
|
-
min: number;
|
|
14
|
-
max: number;
|
|
15
|
-
};
|
|
16
12
|
startAt?: number | undefined;
|
|
17
13
|
}) => {
|
|
18
|
-
setValueNow: (val?: number
|
|
19
|
-
min?: number | undefined;
|
|
20
|
-
max?: number | undefined;
|
|
21
|
-
} | undefined) => void;
|
|
14
|
+
setValueNow: (val?: number) => void;
|
|
22
15
|
};
|
|
@@ -2,7 +2,4 @@ import { RefObject } from 'react';
|
|
|
2
2
|
/**
|
|
3
3
|
* Calls setValueNow when the separator attributes change.
|
|
4
4
|
*/
|
|
5
|
-
export declare const useValueSeparatorEffects: (setValueNow: (val?: number,
|
|
6
|
-
min?: number;
|
|
7
|
-
max?: number;
|
|
8
|
-
}) => void, separator: RefObject<HTMLDivElement>, ratio?: number, startAt?: number) => void;
|
|
5
|
+
export declare const useValueSeparatorEffects: (setValueNow: (val?: number) => void, separator: RefObject<HTMLDivElement>, ratio?: number, startAt?: number) => void;
|
package/dist/index.js
CHANGED
|
@@ -58566,14 +58566,45 @@ var getSeparatorAttributes = function (props) {
|
|
|
58566
58566
|
? (_a = props.child) === null || _a === void 0 ? void 0 : _a.closest('[role="separator"]')
|
|
58567
58567
|
: (_b = props.separator) !== null && _b !== void 0 ? _b : (_c = props.ref) === null || _c === void 0 ? void 0 : _c.current));
|
|
58568
58568
|
};
|
|
58569
|
+
var getBoundary = function (length, px, offset) {
|
|
58570
|
+
var asNumber = parseFloat(px);
|
|
58571
|
+
var absolute = Math.abs(asNumber) + offset;
|
|
58572
|
+
var percentage = absolute / length;
|
|
58573
|
+
if (asNumber > 0) {
|
|
58574
|
+
return percentage * 100;
|
|
58575
|
+
}
|
|
58576
|
+
else {
|
|
58577
|
+
return (1 - percentage) * 100;
|
|
58578
|
+
}
|
|
58579
|
+
};
|
|
58569
58580
|
var getValues = function (el) {
|
|
58581
|
+
var _a, _b, _c, _d;
|
|
58582
|
+
var valueMin = parseValue((_a = el === null || el === void 0 ? void 0 : el.getAttribute('aria-valuemin')) !== null && _a !== void 0 ? _a : '0');
|
|
58583
|
+
var valueMax = parseValue((_b = el === null || el === void 0 ? void 0 : el.getAttribute('aria-valuemax')) !== null && _b !== void 0 ? _b : '100');
|
|
58584
|
+
var thickness = getSeparatorThickness(el);
|
|
58585
|
+
var minPx = el === null || el === void 0 ? void 0 : el.getAttribute('data-minpx');
|
|
58586
|
+
var maxPx = el === null || el === void 0 ? void 0 : el.getAttribute('data-maxpx');
|
|
58587
|
+
var orientation = parseOrientation(el === null || el === void 0 ? void 0 : el.getAttribute('aria-orientation'));
|
|
58588
|
+
var rect = (_c = el === null || el === void 0 ? void 0 : el.parentElement) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
|
|
58589
|
+
var dimension = orientation === 'horizontal' ? 'height' : 'width';
|
|
58590
|
+
var length = (_d = rect === null || rect === void 0 ? void 0 : rect[dimension]) !== null && _d !== void 0 ? _d : 0;
|
|
58591
|
+
if (minPx === null || minPx === void 0 ? void 0 : minPx.endsWith('px')) {
|
|
58592
|
+
var boundaryMin = getBoundary(length, minPx, thickness / 2);
|
|
58593
|
+
valueMin = Math.max(valueMin, boundaryMin);
|
|
58594
|
+
}
|
|
58595
|
+
if (maxPx === null || maxPx === void 0 ? void 0 : maxPx.endsWith('px')) {
|
|
58596
|
+
var boundaryMax = getBoundary(length, maxPx, thickness / 2);
|
|
58597
|
+
valueMax = Math.min(valueMax, boundaryMax);
|
|
58598
|
+
}
|
|
58599
|
+
var sticky = el === null || el === void 0 ? void 0 : el.getAttribute('data-sticky');
|
|
58570
58600
|
return {
|
|
58571
58601
|
valueNow: parseValue(el === null || el === void 0 ? void 0 : el.getAttribute('aria-valuenow')),
|
|
58572
|
-
|
|
58573
|
-
|
|
58574
|
-
orientation:
|
|
58575
|
-
thickness:
|
|
58576
|
-
boundary: getDataBoundary(el)
|
|
58602
|
+
valueMax: valueMax,
|
|
58603
|
+
valueMin: valueMin,
|
|
58604
|
+
orientation: orientation,
|
|
58605
|
+
thickness: thickness,
|
|
58606
|
+
boundary: getDataBoundary(el),
|
|
58607
|
+
sticky: sticky
|
|
58577
58608
|
};
|
|
58578
58609
|
};
|
|
58579
58610
|
var parseValue = function (val) {
|
|
@@ -58665,8 +58696,8 @@ var Control = React.forwardRef(function (props, forwardRef) {
|
|
|
58665
58696
|
};
|
|
58666
58697
|
var separator = ref.current.closest('[role="separator"]');
|
|
58667
58698
|
callback();
|
|
58668
|
-
var
|
|
58669
|
-
|
|
58699
|
+
var attributes = new MutationObserver(callback);
|
|
58700
|
+
attributes.observe(separator, {
|
|
58670
58701
|
attributeFilter: [
|
|
58671
58702
|
'aria-valuenow',
|
|
58672
58703
|
'aria-valuemin',
|
|
@@ -58674,7 +58705,12 @@ var Control = React.forwardRef(function (props, forwardRef) {
|
|
|
58674
58705
|
'aria-orientation',
|
|
58675
58706
|
]
|
|
58676
58707
|
});
|
|
58677
|
-
|
|
58708
|
+
var resize = new ResizeObserver(callback);
|
|
58709
|
+
resize.observe(separator.parentElement);
|
|
58710
|
+
return function () {
|
|
58711
|
+
attributes.disconnect();
|
|
58712
|
+
resize.disconnect();
|
|
58713
|
+
};
|
|
58678
58714
|
}, [ref, side]);
|
|
58679
58715
|
return (React__default["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["default"].createElement(ControlIcon, { parent: ref, side: side })));
|
|
58680
58716
|
});
|
|
@@ -58738,6 +58774,34 @@ var getSeparatorPosition = function (separatorRef, drag) {
|
|
|
58738
58774
|
return clampSeparator({ value: value });
|
|
58739
58775
|
};
|
|
58740
58776
|
|
|
58777
|
+
var transitionFactory = function (attrs, ms) {
|
|
58778
|
+
return attrs.map(function (key) { return "".concat(key, " ").concat(ms, "ms"); }).join(', ');
|
|
58779
|
+
};
|
|
58780
|
+
var barTransition = function (ms) {
|
|
58781
|
+
return transitionFactory(['left', 'top', 'right', 'bottom'], ms);
|
|
58782
|
+
};
|
|
58783
|
+
var gridTransition = function (ms) {
|
|
58784
|
+
return transitionFactory(['grid-template-columns', 'grid-template-rows'], ms);
|
|
58785
|
+
};
|
|
58786
|
+
var transition = function (props) {
|
|
58787
|
+
var _a;
|
|
58788
|
+
var separator = Object.hasOwn(props, 'current')
|
|
58789
|
+
? props
|
|
58790
|
+
: { current: props };
|
|
58791
|
+
var splitter = (_a = separator.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
58792
|
+
var delay = function (ms) {
|
|
58793
|
+
if (splitter) {
|
|
58794
|
+
separator.current.style.transition = barTransition(ms);
|
|
58795
|
+
splitter.style.transition = gridTransition(ms);
|
|
58796
|
+
}
|
|
58797
|
+
};
|
|
58798
|
+
var stop = function () { return delay(0); };
|
|
58799
|
+
var resume = function () {
|
|
58800
|
+
return delay((splitter === null || splitter === void 0 ? void 0 : splitter.classList.contains('resizing')) ? 0 : 300);
|
|
58801
|
+
};
|
|
58802
|
+
return { stop: stop, resume: resume };
|
|
58803
|
+
};
|
|
58804
|
+
|
|
58741
58805
|
/**
|
|
58742
58806
|
* It captures window events to report a new position.
|
|
58743
58807
|
* Provides necessary handlers for separator.
|
|
@@ -58786,54 +58850,64 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58786
58850
|
? 'col-resize'
|
|
58787
58851
|
: 'row-resize';
|
|
58788
58852
|
splitter.classList.add('resizing');
|
|
58853
|
+
transition(separator).stop();
|
|
58789
58854
|
}
|
|
58790
58855
|
else {
|
|
58791
58856
|
splitter.style.cursor = '';
|
|
58792
58857
|
splitter.classList.remove('resizing');
|
|
58858
|
+
transition(separator).resume();
|
|
58793
58859
|
}
|
|
58794
58860
|
}
|
|
58795
58861
|
};
|
|
58796
58862
|
|
|
58797
|
-
|
|
58798
|
-
|
|
58799
|
-
|
|
58800
|
-
|
|
58801
|
-
|
|
58802
|
-
|
|
58803
|
-
|
|
58804
|
-
|
|
58805
|
-
|
|
58806
|
-
var
|
|
58807
|
-
var _a;
|
|
58808
|
-
var
|
|
58809
|
-
|
|
58810
|
-
|
|
58811
|
-
var
|
|
58812
|
-
var
|
|
58813
|
-
|
|
58814
|
-
separator.current.style.transition = barTransition(ms);
|
|
58815
|
-
splitter.style.transition = gridTransition(ms);
|
|
58816
|
-
}
|
|
58863
|
+
/**
|
|
58864
|
+
* It will calculate the best grid arrangement, based on the min/max props passed to the Splitter.
|
|
58865
|
+
* All grid options work. The preference `1fr XXpx` over `(width - XXpx) 1fr` depends on the type of boundary
|
|
58866
|
+
* to avoid calculation of position when the window is being resized while trying to retain the collapsed state
|
|
58867
|
+
* on a min/max value fixed in pixels (e.g. 200px). Such calculation adds unnecessary lagging on the separator
|
|
58868
|
+
* to catch up. This function aims to avoid such lagging during resizing.
|
|
58869
|
+
* primary relates to top/left
|
|
58870
|
+
* secondary relates to right/bottom
|
|
58871
|
+
*/
|
|
58872
|
+
var getGridTemplate = function (separator) {
|
|
58873
|
+
var _a = getSeparatorAttributes({ separator: separator }), valueNow = _a.valueNow, gap = _a.thickness, boundary = _a.boundary, orientation = _a.orientation;
|
|
58874
|
+
var rect = separator.parentElement.getBoundingClientRect();
|
|
58875
|
+
var dimension = orientation === 'horizontal' ? 'height' : 'width';
|
|
58876
|
+
var seperatorAbsolutePx = (rect[dimension] / 100) * valueNow;
|
|
58877
|
+
var offset = gap / 2;
|
|
58878
|
+
var clamp = function (val, type) {
|
|
58879
|
+
return "clamp(".concat(offset, "px, ").concat(val).concat(type, ", calc(100% - ").concat(offset, "px))");
|
|
58817
58880
|
};
|
|
58818
|
-
|
|
58819
|
-
|
|
58820
|
-
return
|
|
58881
|
+
if (boundary === 'keep-primary') {
|
|
58882
|
+
var grid = Math.max(seperatorAbsolutePx - offset, 0);
|
|
58883
|
+
return {
|
|
58884
|
+
grid: "".concat(grid, "px 1fr"),
|
|
58885
|
+
primary: clamp(seperatorAbsolutePx, 'px'),
|
|
58886
|
+
secondary: ''
|
|
58887
|
+
};
|
|
58888
|
+
}
|
|
58889
|
+
if (boundary === 'keep-secondary') {
|
|
58890
|
+
var grid = Math.max(rect[dimension] - seperatorAbsolutePx - offset, 0);
|
|
58891
|
+
return {
|
|
58892
|
+
grid: "1fr ".concat(grid, "px"),
|
|
58893
|
+
primary: '',
|
|
58894
|
+
secondary: clamp(rect[dimension] - seperatorAbsolutePx, 'px')
|
|
58895
|
+
};
|
|
58896
|
+
}
|
|
58897
|
+
return {
|
|
58898
|
+
grid: "min(calc(".concat(valueNow, "% - ").concat(gap / 2, "px), calc(100% - ").concat(gap, "px)) 1fr"),
|
|
58899
|
+
primary: clamp(valueNow, '%'),
|
|
58900
|
+
secondary: "calc(100% - ".concat(clamp(valueNow, '%'), ")")
|
|
58821
58901
|
};
|
|
58822
|
-
return { stop: stop, resume: resume };
|
|
58823
58902
|
};
|
|
58824
58903
|
|
|
58825
58904
|
/**
|
|
58826
58905
|
* Moves separator as per ratio changes. Centers on first render if ratio is undefined.
|
|
58827
58906
|
*/
|
|
58828
|
-
var useRatioEffect = function (setValueNow,
|
|
58907
|
+
var useRatioEffect = function (setValueNow, ratio, startAt) {
|
|
58829
58908
|
var firstRun = React.useRef(true);
|
|
58830
|
-
var _a = getSeparatorAttributes({ ref: separator }), valueMax = _a.valueMax, valueMin = _a.valueMin;
|
|
58831
|
-
var isCalculating = valueMax === Infinity || valueMin === -Infinity;
|
|
58832
58909
|
React.useEffect(function () {
|
|
58833
|
-
if (
|
|
58834
|
-
transition(separator).resume();
|
|
58835
|
-
}
|
|
58836
|
-
if (firstRun.current || ratio !== undefined || isCalculating) {
|
|
58910
|
+
if (firstRun.current || ratio !== undefined) {
|
|
58837
58911
|
firstRun.current = false;
|
|
58838
58912
|
// If ratio is undefined, setValueNow will place the separator in the middle as a starting point.
|
|
58839
58913
|
// Whatever value is `the middle` will be determined by setValueNow
|
|
@@ -58846,63 +58920,17 @@ var useRatioEffect = function (setValueNow, separator, ratio, startAt) {
|
|
|
58846
58920
|
*/
|
|
58847
58921
|
var useConfigEffect = function (setValueNow, separator) {
|
|
58848
58922
|
React.useEffect(function () {
|
|
58849
|
-
var callback = function (
|
|
58850
|
-
|
|
58851
|
-
|
|
58852
|
-
var target = record.target;
|
|
58853
|
-
var values = getSeparatorAttributes({ separator: target });
|
|
58854
|
-
var oldValue = Number(record.oldValue);
|
|
58855
|
-
var valueMax = values.valueMax, valueMin = values.valueMin, valueNow = values.valueNow;
|
|
58856
|
-
var newValue = attr === 'min' ? valueMin : valueMax;
|
|
58857
|
-
// Determine if separator was collapsed/expanded fully
|
|
58858
|
-
var wasInBoundary = oldValue === valueNow;
|
|
58859
|
-
// To remain collapsed/expanded, it is necessary to call setValueNow with the latest boundaries.
|
|
58860
|
-
// The useBoundaries hook haven't yet reflected the change, and it would cause an unwanted flash.
|
|
58861
|
-
// In such case, the newValueNow is moved along with the delimiter.
|
|
58862
|
-
var newValueNow = !wasInBoundary ? valueNow : newValue;
|
|
58863
|
-
if (wasInBoundary || valueMax < valueNow || valueMin > valueNow) {
|
|
58864
|
-
setValueNow(newValueNow, { min: valueMin, max: valueMax });
|
|
58865
|
-
}
|
|
58866
|
-
else {
|
|
58867
|
-
var threshold = 0.01;
|
|
58868
|
-
var dim = values.orientation === 'vertical' ? 'width' : 'height';
|
|
58869
|
-
var abs = values.orientation === 'vertical' ? 'left' : 'top';
|
|
58870
|
-
var separatorRect = target.getBoundingClientRect();
|
|
58871
|
-
var gap = separatorRect[dim];
|
|
58872
|
-
var offset = gap / 2;
|
|
58873
|
-
var splitterEl = target.parentElement;
|
|
58874
|
-
var splitterRect = splitterEl.getBoundingClientRect();
|
|
58875
|
-
var container = splitterRect[dim];
|
|
58876
|
-
var primary = Math.max(separatorRect[abs] - splitterRect[abs], 0);
|
|
58877
|
-
var secondary = Math.max(container - primary - gap, 0);
|
|
58878
|
-
if (primary < threshold || secondary < threshold) {
|
|
58879
|
-
return;
|
|
58880
|
-
}
|
|
58881
|
-
var newVal = ((primary + offset) / container) * 100;
|
|
58882
|
-
if (Math.abs(newVal - valueNow) >= threshold) {
|
|
58883
|
-
setValueNow(newVal, { min: valueMin, max: valueMax });
|
|
58884
|
-
}
|
|
58885
|
-
}
|
|
58886
|
-
};
|
|
58923
|
+
var callback = function () {
|
|
58924
|
+
var value = getSeparatorAttributes({ ref: separator }).valueNow;
|
|
58925
|
+
setValueNow(value);
|
|
58887
58926
|
};
|
|
58888
|
-
|
|
58889
|
-
|
|
58890
|
-
|
|
58891
|
-
|
|
58892
|
-
var minObserver = new MutationObserver(callback('min'));
|
|
58893
|
-
var maxObserver = new MutationObserver(callback('max'));
|
|
58894
|
-
var orientationObserver = new MutationObserver(function () { return setValueNow(); });
|
|
58895
|
-
minObserver.observe(separator.current, config('min'));
|
|
58896
|
-
maxObserver.observe(separator.current, config('max'));
|
|
58897
|
-
orientationObserver.observe(separator.current, {
|
|
58898
|
-
attributeFilter: ['aria-orientation']
|
|
58927
|
+
callback();
|
|
58928
|
+
var observer = new MutationObserver(callback);
|
|
58929
|
+
observer.observe(separator.current, {
|
|
58930
|
+
attributeFilter: ['aria-orientation', 'aria-valuemin', 'aria-valuemax']
|
|
58899
58931
|
});
|
|
58900
|
-
return function () {
|
|
58901
|
-
|
|
58902
|
-
maxObserver.disconnect();
|
|
58903
|
-
orientationObserver.disconnect();
|
|
58904
|
-
};
|
|
58905
|
-
}, [separator]);
|
|
58932
|
+
return function () { return observer.disconnect(); };
|
|
58933
|
+
}, [separator, setValueNow]);
|
|
58906
58934
|
};
|
|
58907
58935
|
/**
|
|
58908
58936
|
* Broadcasts changes if separator aria-valuenow was altered.
|
|
@@ -58910,73 +58938,64 @@ var useConfigEffect = function (setValueNow, separator) {
|
|
|
58910
58938
|
var useValueNowEffect = function (setValueNow, separator) {
|
|
58911
58939
|
React.useEffect(function () {
|
|
58912
58940
|
var observer = new MutationObserver(function (_a) {
|
|
58913
|
-
var
|
|
58941
|
+
var target = _a[0].target;
|
|
58914
58942
|
var el = target;
|
|
58915
58943
|
var splitter = target.parentElement;
|
|
58916
58944
|
var newValueNow = Number(el.getAttribute('aria-valuenow'));
|
|
58917
58945
|
if (!splitter.classList.contains('resizing')) {
|
|
58918
|
-
|
|
58919
|
-
transition(separator).resume();
|
|
58920
|
-
setValueNow(newValueNow);
|
|
58921
|
-
}
|
|
58946
|
+
setValueNow(newValueNow);
|
|
58922
58947
|
}
|
|
58923
58948
|
});
|
|
58924
58949
|
var attributeFilter = ['aria-valuenow'];
|
|
58925
|
-
observer.observe(separator.current, {
|
|
58926
|
-
attributeFilter: attributeFilter,
|
|
58927
|
-
attributeOldValue: true
|
|
58928
|
-
});
|
|
58950
|
+
observer.observe(separator.current, { attributeFilter: attributeFilter });
|
|
58929
58951
|
return function () { return observer.disconnect(); };
|
|
58930
58952
|
}, [separator, setValueNow]);
|
|
58931
58953
|
};
|
|
58954
|
+
/**
|
|
58955
|
+
* Makes sure that separator is within boundaries
|
|
58956
|
+
*/
|
|
58957
|
+
var useResizeEffect = function (setValueNow, separator) {
|
|
58958
|
+
var length = React.useRef();
|
|
58959
|
+
var _a = React.useState(0), count = _a[0], setCount = _a[1];
|
|
58960
|
+
React.useEffect(function () {
|
|
58961
|
+
var element = separator.current.parentElement;
|
|
58962
|
+
var observer = new ResizeObserver(function (_a) {
|
|
58963
|
+
var contentBoxSize = _a[0].contentBoxSize;
|
|
58964
|
+
var _b = contentBoxSize[0], inlineSize = _b.inlineSize, blockSize = _b.blockSize;
|
|
58965
|
+
var attributes = getSeparatorAttributes({ ref: separator });
|
|
58966
|
+
var orientation = attributes.orientation, valueNow = attributes.valueNow, sticky = attributes.sticky;
|
|
58967
|
+
var newValue = valueNow;
|
|
58968
|
+
var newLength = orientation === 'vertical' ? inlineSize : blockSize;
|
|
58969
|
+
if (newLength !== length.current) {
|
|
58970
|
+
if (length.current) {
|
|
58971
|
+
transition(separator).stop();
|
|
58972
|
+
if (sticky === 'primary') {
|
|
58973
|
+
newValue = 0;
|
|
58974
|
+
}
|
|
58975
|
+
if (sticky === 'secondary') {
|
|
58976
|
+
newValue = 100;
|
|
58977
|
+
}
|
|
58978
|
+
setValueNow(newValue);
|
|
58979
|
+
setCount(function (p) { return p + 1; });
|
|
58980
|
+
}
|
|
58981
|
+
length.current = newLength;
|
|
58982
|
+
}
|
|
58983
|
+
});
|
|
58984
|
+
observer.observe(element);
|
|
58985
|
+
return function () { return observer.disconnect(); };
|
|
58986
|
+
}, [separator, setValueNow, length]);
|
|
58987
|
+
React.useEffect(function () {
|
|
58988
|
+
transition(separator).resume();
|
|
58989
|
+
}, [count]);
|
|
58990
|
+
};
|
|
58932
58991
|
/**
|
|
58933
58992
|
* Calls setValueNow when the separator attributes change.
|
|
58934
58993
|
*/
|
|
58935
58994
|
var useValueSeparatorEffects = function (setValueNow, separator, ratio, startAt) {
|
|
58936
|
-
useRatioEffect(setValueNow,
|
|
58995
|
+
useRatioEffect(setValueNow, ratio, startAt);
|
|
58937
58996
|
useConfigEffect(setValueNow, separator);
|
|
58938
58997
|
useValueNowEffect(setValueNow, separator);
|
|
58939
|
-
|
|
58940
|
-
|
|
58941
|
-
/**
|
|
58942
|
-
* It will calculate the best grid arrangement, based on the min/max props passed to the Splitter.
|
|
58943
|
-
* All grid options work. The preference `1fr XXpx` over `(width - XXpx) 1fr` depends on the type of boundary
|
|
58944
|
-
* to avoid calculation of position when the window is being resized while trying to retain the collapsed state
|
|
58945
|
-
* on a min/max value fixed in pixels (e.g. 200px). Such calculation adds unnecessary lagging on the separator
|
|
58946
|
-
* to catch up. This function aims to avoid such lagging during resizing.
|
|
58947
|
-
* primary relates to top/left
|
|
58948
|
-
* secondary relates to right/bottom
|
|
58949
|
-
*/
|
|
58950
|
-
var getGridTemplate = function (separator) {
|
|
58951
|
-
var _a = getSeparatorAttributes({ separator: separator }), valueNow = _a.valueNow, gap = _a.thickness, boundary = _a.boundary, orientation = _a.orientation;
|
|
58952
|
-
var rect = separator.parentElement.getBoundingClientRect();
|
|
58953
|
-
var dimension = orientation === 'horizontal' ? 'height' : 'width';
|
|
58954
|
-
var seperatorAbsolutePx = (rect[dimension] / 100) * valueNow;
|
|
58955
|
-
var offset = gap / 2;
|
|
58956
|
-
var clamp = function (val, type) {
|
|
58957
|
-
return "clamp(".concat(offset, "px, ").concat(val).concat(type, ", calc(100% - ").concat(offset, "px))");
|
|
58958
|
-
};
|
|
58959
|
-
if (boundary === 'keep-primary') {
|
|
58960
|
-
var grid = Math.max(seperatorAbsolutePx - offset, 0);
|
|
58961
|
-
return {
|
|
58962
|
-
grid: "".concat(grid, "px 1fr"),
|
|
58963
|
-
primary: clamp(seperatorAbsolutePx, 'px'),
|
|
58964
|
-
secondary: ''
|
|
58965
|
-
};
|
|
58966
|
-
}
|
|
58967
|
-
if (boundary === 'keep-secondary') {
|
|
58968
|
-
var grid = Math.max(rect[dimension] - seperatorAbsolutePx - offset, 0);
|
|
58969
|
-
return {
|
|
58970
|
-
grid: "1fr ".concat(grid, "px"),
|
|
58971
|
-
primary: '',
|
|
58972
|
-
secondary: clamp(rect[dimension] - seperatorAbsolutePx, 'px')
|
|
58973
|
-
};
|
|
58974
|
-
}
|
|
58975
|
-
return {
|
|
58976
|
-
grid: "min(calc(".concat(valueNow, "% - ").concat(gap / 2, "px), calc(100% - ").concat(gap, "px)) 1fr"),
|
|
58977
|
-
primary: clamp(valueNow, '%'),
|
|
58978
|
-
secondary: "calc(100% - ".concat(clamp(valueNow, '%'), ")")
|
|
58979
|
-
};
|
|
58998
|
+
useResizeEffect(setValueNow, separator);
|
|
58980
58999
|
};
|
|
58981
59000
|
|
|
58982
59001
|
/**
|
|
@@ -58986,23 +59005,29 @@ var getGridTemplate = function (separator) {
|
|
|
58986
59005
|
* This multiple calls are expected, and setValueNow will resize only once.
|
|
58987
59006
|
*/
|
|
58988
59007
|
var useValueSeparator = function (_a) {
|
|
58989
|
-
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized,
|
|
59008
|
+
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized, startAt = _a.startAt;
|
|
58990
59009
|
var prev = React.useRef(null);
|
|
58991
|
-
var setValueNow = React.useCallback(function (val
|
|
58992
|
-
var _a, _b;
|
|
58993
|
-
var
|
|
58994
|
-
|
|
58995
|
-
var min = (_a = config === null || config === void 0 ? void 0 : config.min) !== null && _a !== void 0 ? _a : minProp;
|
|
58996
|
-
var max = (_b = config === null || config === void 0 ? void 0 : config.max) !== null && _b !== void 0 ? _b : maxProp;
|
|
59010
|
+
var setValueNow = React.useCallback(function (val) {
|
|
59011
|
+
var _a, _b, _c;
|
|
59012
|
+
var attributes = getSeparatorAttributes({ ref: separator });
|
|
59013
|
+
var valueNow = attributes.valueNow, max = attributes.valueMax, min = attributes.valueMin;
|
|
58997
59014
|
var value = val !== null && val !== void 0 ? val : (valueNow || min + (max - min) / 2);
|
|
58998
59015
|
var newValue = clampSeparator({ value: value, max: max, min: min });
|
|
58999
|
-
var isCalculating = min === -Infinity || max === Infinity;
|
|
59000
59016
|
resize(separator, newValue);
|
|
59001
|
-
if (prev.current !== newValue
|
|
59017
|
+
if (prev.current !== newValue) {
|
|
59018
|
+
if (newValue === min) {
|
|
59019
|
+
(_a = separator.current) === null || _a === void 0 ? void 0 : _a.setAttribute('data-sticky', 'primary');
|
|
59020
|
+
}
|
|
59021
|
+
else if (newValue === max) {
|
|
59022
|
+
(_b = separator.current) === null || _b === void 0 ? void 0 : _b.setAttribute('data-sticky', 'secondary');
|
|
59023
|
+
}
|
|
59024
|
+
else {
|
|
59025
|
+
(_c = separator.current) === null || _c === void 0 ? void 0 : _c.removeAttribute('data-sticky');
|
|
59026
|
+
}
|
|
59002
59027
|
prev.current = newValue;
|
|
59003
59028
|
onResized === null || onResized === void 0 ? void 0 : onResized(newValue);
|
|
59004
59029
|
}
|
|
59005
|
-
}, [onResized,
|
|
59030
|
+
}, [onResized, prev]);
|
|
59006
59031
|
useValueSeparatorEffects(setValueNow, separator, ratio, startAt);
|
|
59007
59032
|
return { setValueNow: setValueNow };
|
|
59008
59033
|
};
|
|
@@ -59134,62 +59159,6 @@ var getNewValueNow = function (_a, valueNow, pixelUnit) {
|
|
|
59134
59159
|
return valueNow;
|
|
59135
59160
|
};
|
|
59136
59161
|
|
|
59137
|
-
var isPxProps = function (_a) {
|
|
59138
|
-
var min = _a.min, max = _a.max;
|
|
59139
|
-
var isPercentage = typeof max === 'number' || typeof min === 'number';
|
|
59140
|
-
var isNull = min === undefined && max === undefined;
|
|
59141
|
-
return !isPercentage && !isNull;
|
|
59142
|
-
};
|
|
59143
|
-
/**
|
|
59144
|
-
* Maps min and max values if they are provided in 'XXXpx' format.
|
|
59145
|
-
*/
|
|
59146
|
-
var useBoundary = function (separator, boundaries) {
|
|
59147
|
-
var _a = React.useState({ min: -Infinity, max: Infinity }), mapped = _a[0], setMapped = _a[1];
|
|
59148
|
-
var isPx = isPxProps(boundaries);
|
|
59149
|
-
var min = boundaries.min, max = boundaries.max;
|
|
59150
|
-
React.useEffect(function () {
|
|
59151
|
-
var _a;
|
|
59152
|
-
var element = (_a = separator === null || separator === void 0 ? void 0 : separator.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
59153
|
-
var shouldMap = element && isPx;
|
|
59154
|
-
var observer = new ResizeObserver(function (_a) {
|
|
59155
|
-
var rect = _a[0].contentRect;
|
|
59156
|
-
var _b = getSeparatorAttributes({
|
|
59157
|
-
ref: separator
|
|
59158
|
-
}), thickness = _b.thickness, orientation = _b.orientation;
|
|
59159
|
-
var halfThickness = thickness / 2;
|
|
59160
|
-
var length = orientation === 'vertical' ? rect.width : rect.height;
|
|
59161
|
-
var parse = function (boundary) {
|
|
59162
|
-
if (typeof boundary === 'number') {
|
|
59163
|
-
return boundary;
|
|
59164
|
-
}
|
|
59165
|
-
var boundaryAsNumber = parseFloat(boundary);
|
|
59166
|
-
var offset = boundaryAsNumber > 0
|
|
59167
|
-
? boundaryAsNumber + halfThickness
|
|
59168
|
-
: length - Math.abs(boundaryAsNumber) - halfThickness;
|
|
59169
|
-
return (offset / length) * 100;
|
|
59170
|
-
};
|
|
59171
|
-
setMapped({ min: parse(min !== null && min !== void 0 ? min : 0), max: parse(max !== null && max !== void 0 ? max : 100) });
|
|
59172
|
-
});
|
|
59173
|
-
if (shouldMap) {
|
|
59174
|
-
observer.observe(element);
|
|
59175
|
-
}
|
|
59176
|
-
return function () {
|
|
59177
|
-
if (shouldMap) {
|
|
59178
|
-
observer.disconnect();
|
|
59179
|
-
}
|
|
59180
|
-
};
|
|
59181
|
-
}, [separator, max, min, isPx]);
|
|
59182
|
-
if (isPx) {
|
|
59183
|
-
return mapped;
|
|
59184
|
-
}
|
|
59185
|
-
else {
|
|
59186
|
-
return {
|
|
59187
|
-
min: Math.max(Number(min !== null && min !== void 0 ? min : 0), 0),
|
|
59188
|
-
max: Math.min(Number(max !== null && max !== void 0 ? max : 100), 100)
|
|
59189
|
-
};
|
|
59190
|
-
}
|
|
59191
|
-
};
|
|
59192
|
-
|
|
59193
59162
|
var cancelEvent = function (e) {
|
|
59194
59163
|
if (e.currentTarget !== e.target) {
|
|
59195
59164
|
e.preventDefault();
|
|
@@ -59198,42 +59167,33 @@ var cancelEvent = function (e) {
|
|
|
59198
59167
|
};
|
|
59199
59168
|
var Separator = React.forwardRef(function (_a, forwardRef) {
|
|
59200
59169
|
var _b;
|
|
59201
|
-
var parts = _a.parts, ratio = _a.ratio, onResized = _a.onResized,
|
|
59170
|
+
var parts = _a.parts, ratio = _a.ratio, onResized = _a.onResized, startAt = _a.startAt, props = __rest(_a, ["parts", "ratio", "onResized", "startAt"]);
|
|
59202
59171
|
var separator = useForkRef(forwardRef);
|
|
59203
|
-
var boundaries = useBoundary(separator, { min: min, max: max });
|
|
59204
59172
|
var setValueNow = useValueSeparator({
|
|
59205
59173
|
ratio: ratio,
|
|
59206
59174
|
separator: separator,
|
|
59207
59175
|
onResized: onResized,
|
|
59208
|
-
boundaries: boundaries,
|
|
59209
59176
|
startAt: startAt
|
|
59210
59177
|
}).setValueNow;
|
|
59211
59178
|
useShowSeparator(separator);
|
|
59212
59179
|
var values = function () { return getSeparatorAttributes({ ref: separator }); };
|
|
59213
|
-
return (React__default["default"].createElement("div", __assign({ ref: separator
|
|
59180
|
+
return (React__default["default"].createElement("div", __assign({ ref: separator }, props, useMoveSeparator(separator, setValueNow), { onKeyDown: function (e) {
|
|
59214
59181
|
var _a;
|
|
59215
59182
|
var newValueNow = keyDownHandler(e);
|
|
59216
59183
|
if (values().valueNow !== newValueNow) {
|
|
59217
|
-
transition(separator).resume();
|
|
59218
59184
|
setValueNow(newValueNow);
|
|
59219
59185
|
e.preventDefault();
|
|
59220
59186
|
}
|
|
59221
59187
|
(_a = props === null || props === void 0 ? void 0 : props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
59222
|
-
}, className: clsx('Separator', props.className)
|
|
59223
|
-
var _a;
|
|
59224
|
-
transition(separator).stop();
|
|
59225
|
-
(_a = props.onTransitionEnd) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
59226
|
-
} }),
|
|
59188
|
+
}, className: clsx('Separator', props.className) }),
|
|
59227
59189
|
React__default["default"].createElement("span", __assign({}, parts === null || parts === void 0 ? void 0 : parts.container, { className: clsx('Separator-arrows', (_b = parts === null || parts === void 0 ? void 0 : parts.container) === null || _b === void 0 ? void 0 : _b.className), onMouseDown: cancelEvent, onTouchStart: cancelEvent }),
|
|
59228
59190
|
React__default["default"].createElement(Control, __assign({}, parts === null || parts === void 0 ? void 0 : parts.primary, { side: "primary", onClick: function (e) {
|
|
59229
59191
|
var _a, _b;
|
|
59230
|
-
transition(separator).resume();
|
|
59231
59192
|
setValueNow(controlClickHandler(e, 'primary'));
|
|
59232
59193
|
(_b = (_a = parts === null || parts === void 0 ? void 0 : parts.primary) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
59233
59194
|
} })),
|
|
59234
59195
|
React__default["default"].createElement(Control, __assign({}, parts === null || parts === void 0 ? void 0 : parts.secondary, { side: "secondary", onClick: function (e) {
|
|
59235
59196
|
var _a, _b;
|
|
59236
|
-
transition(separator).resume();
|
|
59237
59197
|
setValueNow(controlClickHandler(e, 'secondary'));
|
|
59238
59198
|
(_b = (_a = parts === null || parts === void 0 ? void 0 : parts.secondary) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
59239
59199
|
} })))));
|
|
@@ -59270,7 +59230,7 @@ var Splitter = React.forwardRef(function (props, ref) {
|
|
|
59270
59230
|
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"]);
|
|
59271
59231
|
return (React__default["default"].createElement("div", __assign({ ref: ref }, rest, { className: clsx('Splitter', rest === null || rest === void 0 ? void 0 : rest.className) }),
|
|
59272
59232
|
children,
|
|
59273
|
-
React__default["default"].createElement(Separator, __assign({}, parts === null || parts === void 0 ? void 0 : parts.separator, { tabIndex: 0, min:
|
|
59233
|
+
React__default["default"].createElement(Separator, __assign({}, parts === null || parts === void 0 ? void 0 : parts.separator, { tabIndex: 0, "data-minpx": typeof min === 'string' ? min : undefined, "data-maxpx": typeof max === 'string' ? max : undefined, "aria-valuemin": typeof min === 'number' ? Math.max(min, 0) : 0, "aria-valuemax": typeof max === 'number' ? Math.min(max, 100) : 100, 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 })))));
|
|
59274
59234
|
});
|
|
59275
59235
|
Splitter.displayName = 'Splitter';
|
|
59276
59236
|
var mapStartAt = function (props) {
|