@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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [21.25.0](https://github.com/linz/lui/compare/v21.24.4...v21.25.0) (2024-04-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* select now now longer has line-height set. This was causing the attached issues with "g" ([#1109](https://github.com/linz/lui/issues/1109)) ([54b8238](https://github.com/linz/lui/commit/54b8238de24a7733f9462cbf6bd4f028be8e5e88))
|
|
7
|
+
|
|
1
8
|
## [21.24.4](https://github.com/linz/lui/compare/v21.24.3...v21.24.4) (2024-03-15)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -6,8 +6,5 @@ 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
|
-
startAt?: number | undefined;
|
|
12
9
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
13
10
|
export {};
|
|
@@ -1,44 +1,30 @@
|
|
|
1
1
|
import React, { ComponentPropsWithRef } from 'react';
|
|
2
|
-
import { HTMLAttributes } from 'react';
|
|
3
2
|
import './Splitter.scss';
|
|
4
3
|
import { LuiButton } from '../LuiButton/LuiButton';
|
|
5
4
|
declare type ButtonProps = Omit<ComponentPropsWithRef<typeof LuiButton>, 'children'> & {
|
|
6
5
|
children?: React.ReactNode;
|
|
7
6
|
};
|
|
8
|
-
declare type BoundaryPx = {
|
|
9
|
-
min?: `${number}px`;
|
|
10
|
-
max?: `${number}px`;
|
|
11
|
-
};
|
|
12
|
-
declare type BoundaryNum = {
|
|
13
|
-
min?: number;
|
|
14
|
-
max?: number;
|
|
15
|
-
};
|
|
16
|
-
declare type BoundaryProps = BoundaryPx | BoundaryNum;
|
|
17
|
-
declare type Start = number | '1st-collapsed' | '2nd-collapsed';
|
|
18
|
-
declare type Controlled = {
|
|
19
|
-
ratio?: number;
|
|
20
|
-
startAt?: never;
|
|
21
|
-
};
|
|
22
|
-
declare type Uncontrolled = {
|
|
23
|
-
ratio?: never;
|
|
24
|
-
startAt?: Start;
|
|
25
|
-
};
|
|
26
|
-
declare type RatioProps = Controlled | Uncontrolled;
|
|
27
|
-
declare type Props = {
|
|
28
|
-
onResized?: (ratio: number) => void;
|
|
29
|
-
orientation?: 'horizontal' | 'vertical';
|
|
30
|
-
parts?: {
|
|
31
|
-
separator?: ComponentPropsWithRef<'div'>;
|
|
32
|
-
controls?: {
|
|
33
|
-
container?: ComponentPropsWithRef<'span'>;
|
|
34
|
-
primary?: ButtonProps;
|
|
35
|
-
secondary?: ButtonProps;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
} & HTMLAttributes<HTMLDivElement> & RatioProps & BoundaryProps;
|
|
39
7
|
/**
|
|
40
8
|
* Container that appends a separator when the children count equals 2.
|
|
41
9
|
* It looks at HTML nodes, not React components
|
|
42
10
|
*/
|
|
43
|
-
export declare const Splitter: React.ForwardRefExoticComponent<
|
|
11
|
+
export declare const Splitter: React.ForwardRefExoticComponent<{
|
|
12
|
+
ratio?: number | undefined;
|
|
13
|
+
min?: number | undefined;
|
|
14
|
+
max?: number | undefined;
|
|
15
|
+
onResized?: ((ratio: number) => void) | undefined;
|
|
16
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
17
|
+
parts?: {
|
|
18
|
+
separator?: (Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
19
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
20
|
+
}) | undefined;
|
|
21
|
+
controls?: {
|
|
22
|
+
container?: (Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
23
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
24
|
+
}) | undefined;
|
|
25
|
+
primary?: ButtonProps | undefined;
|
|
26
|
+
secondary?: ButtonProps | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
} & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
44
30
|
export {};
|
|
@@ -5,7 +5,7 @@ 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, boundaries: { min
|
|
8
|
+
export declare const useValueSeparator: ({ separator, ratio, onResized, boundaries: { min, max }, }: {
|
|
9
9
|
ratio?: number | undefined;
|
|
10
10
|
onResized?: ((newVal: number) => void) | undefined;
|
|
11
11
|
separator: RefObject<HTMLDivElement>;
|
|
@@ -13,10 +13,6 @@ export declare const useValueSeparator: ({ separator, ratio, onResized, boundari
|
|
|
13
13
|
min: number;
|
|
14
14
|
max: number;
|
|
15
15
|
};
|
|
16
|
-
startAt?: number | undefined;
|
|
17
16
|
}) => {
|
|
18
|
-
setValueNow: (val?: number
|
|
19
|
-
min?: number | undefined;
|
|
20
|
-
max?: number | undefined;
|
|
21
|
-
} | undefined) => void;
|
|
17
|
+
setValueNow: (val?: number) => void;
|
|
22
18
|
};
|
|
@@ -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) => void;
|
package/dist/index.js
CHANGED
|
@@ -58450,56 +58450,6 @@ var useForkRef = function (forwardedRef) {
|
|
|
58450
58450
|
return forwardedRef || localRef;
|
|
58451
58451
|
};
|
|
58452
58452
|
|
|
58453
|
-
var attrBoundary = 'data-boundary';
|
|
58454
|
-
var dataBoundary = function (_a) {
|
|
58455
|
-
var min = _a.min, max = _a.max;
|
|
58456
|
-
if (typeof min === 'undefined' && typeof max !== 'undefined') {
|
|
58457
|
-
if (typeof max === 'string') {
|
|
58458
|
-
return parseInt(max) < 0 ? 'keep-secondary' : 'keep-primary';
|
|
58459
|
-
}
|
|
58460
|
-
}
|
|
58461
|
-
if (typeof max === 'undefined' && typeof min !== 'undefined') {
|
|
58462
|
-
if (typeof min === 'string') {
|
|
58463
|
-
return parseInt(min) < 0 ? 'keep-secondary' : 'keep-primary';
|
|
58464
|
-
}
|
|
58465
|
-
}
|
|
58466
|
-
if (typeof max === 'string' && typeof min === 'string') {
|
|
58467
|
-
if (parseInt(max) > 0 && parseInt(min) > 0) {
|
|
58468
|
-
return 'keep-primary';
|
|
58469
|
-
}
|
|
58470
|
-
if (parseInt(max) < 0 && parseInt(min) < 0) {
|
|
58471
|
-
return 'keep-secondary';
|
|
58472
|
-
}
|
|
58473
|
-
}
|
|
58474
|
-
return 'keep-both';
|
|
58475
|
-
};
|
|
58476
|
-
/**
|
|
58477
|
-
* Given boundaries passed as prop, it defines how the grid column/row template will be arranged.
|
|
58478
|
-
* and whether the separator will be positioned using right or left absolute values (top or bottom for horizontal).
|
|
58479
|
-
* It will use a data- attribute to store this prop derived information for later processing.
|
|
58480
|
-
*/
|
|
58481
|
-
var setDataBoundary = function (props) {
|
|
58482
|
-
var _a;
|
|
58483
|
-
return (_a = {},
|
|
58484
|
-
_a[attrBoundary] = dataBoundary(props),
|
|
58485
|
-
_a);
|
|
58486
|
-
};
|
|
58487
|
-
/**
|
|
58488
|
-
* Util to get what grid arrangement needs to be used to avoid jumps/flashes.
|
|
58489
|
-
* The return value is derived from the Splitter props, and stored in a data- attribute.
|
|
58490
|
-
*/
|
|
58491
|
-
var getDataBoundary = function (separator) {
|
|
58492
|
-
var boundaryType = separator === null || separator === void 0 ? void 0 : separator.getAttribute(attrBoundary);
|
|
58493
|
-
switch (boundaryType) {
|
|
58494
|
-
case 'keep-primary':
|
|
58495
|
-
case 'keep-secondary':
|
|
58496
|
-
case 'keep-both':
|
|
58497
|
-
return boundaryType;
|
|
58498
|
-
default:
|
|
58499
|
-
return undefined;
|
|
58500
|
-
}
|
|
58501
|
-
};
|
|
58502
|
-
|
|
58503
58453
|
/**
|
|
58504
58454
|
* Given a ref/element if finds the Separator and returns the most useful attributes
|
|
58505
58455
|
*/
|
|
@@ -58515,8 +58465,7 @@ var getValues = function (el) {
|
|
|
58515
58465
|
valueMin: parseValue(el === null || el === void 0 ? void 0 : el.getAttribute('aria-valuemin')),
|
|
58516
58466
|
valueMax: parseValue(el === null || el === void 0 ? void 0 : el.getAttribute('aria-valuemax')),
|
|
58517
58467
|
orientation: parseOrientation(el === null || el === void 0 ? void 0 : el.getAttribute('aria-orientation')),
|
|
58518
|
-
thickness: getSeparatorThickness(el)
|
|
58519
|
-
boundary: getDataBoundary(el)
|
|
58468
|
+
thickness: getSeparatorThickness(el)
|
|
58520
58469
|
};
|
|
58521
58470
|
};
|
|
58522
58471
|
var parseValue = function (val) {
|
|
@@ -58594,9 +58543,6 @@ var Control = React.forwardRef(function (props, forwardRef) {
|
|
|
58594
58543
|
React.useEffect(function () {
|
|
58595
58544
|
var callback = function () {
|
|
58596
58545
|
var control = ref.current;
|
|
58597
|
-
if (!control) {
|
|
58598
|
-
return;
|
|
58599
|
-
}
|
|
58600
58546
|
var _a = getButtonProps(ref, side), hide = _a.hide, offset = _a.offset, orientation = _a.orientation;
|
|
58601
58547
|
var vertical = orientation === 'vertical';
|
|
58602
58548
|
control.style.left = vertical ? "".concat(offset, "px") : '50%';
|
|
@@ -58609,14 +58555,7 @@ var Control = React.forwardRef(function (props, forwardRef) {
|
|
|
58609
58555
|
var separator = ref.current.closest('[role="separator"]');
|
|
58610
58556
|
callback();
|
|
58611
58557
|
var observer = new MutationObserver(callback);
|
|
58612
|
-
observer.observe(separator, {
|
|
58613
|
-
attributeFilter: [
|
|
58614
|
-
'aria-valuenow',
|
|
58615
|
-
'aria-valuemin',
|
|
58616
|
-
'aria-valuemax',
|
|
58617
|
-
'aria-orientation',
|
|
58618
|
-
]
|
|
58619
|
-
});
|
|
58558
|
+
observer.observe(separator, { attributeFilter: ['aria-valuenow'] });
|
|
58620
58559
|
return function () { return observer.disconnect(); };
|
|
58621
58560
|
}, [ref, side]);
|
|
58622
58561
|
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 })));
|
|
@@ -58681,29 +58620,6 @@ var getSeparatorPosition = function (separatorRef, drag) {
|
|
|
58681
58620
|
return clampSeparator({ value: value });
|
|
58682
58621
|
};
|
|
58683
58622
|
|
|
58684
|
-
var transitionFactory = function (attrs, ms) {
|
|
58685
|
-
return attrs.map(function (key) { return "".concat(key, " ").concat(ms, "ms"); }).join(', ');
|
|
58686
|
-
};
|
|
58687
|
-
var barTransition = function (ms) {
|
|
58688
|
-
return transitionFactory(['left', 'top', 'right', 'bottom'], ms);
|
|
58689
|
-
};
|
|
58690
|
-
var gridTransition = function (ms) {
|
|
58691
|
-
return transitionFactory(['grid-template-columns', 'grid-template-rows'], ms);
|
|
58692
|
-
};
|
|
58693
|
-
var transition = function (separator) {
|
|
58694
|
-
var _a;
|
|
58695
|
-
var splitter = (_a = separator.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
58696
|
-
var delay = function (ms) {
|
|
58697
|
-
if (splitter) {
|
|
58698
|
-
separator.current.style.transition = barTransition(ms);
|
|
58699
|
-
splitter.style.transition = gridTransition(ms);
|
|
58700
|
-
}
|
|
58701
|
-
};
|
|
58702
|
-
var stop = function () { return delay(0); };
|
|
58703
|
-
var resume = function () { return delay(300); };
|
|
58704
|
-
return { stop: stop, resume: resume };
|
|
58705
|
-
};
|
|
58706
|
-
|
|
58707
58623
|
/**
|
|
58708
58624
|
* It captures window events to report a new position.
|
|
58709
58625
|
* Provides necessary handlers for separator.
|
|
@@ -58747,7 +58663,8 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58747
58663
|
var splitter = separator === null || separator === void 0 ? void 0 : separator.parentElement;
|
|
58748
58664
|
if (separator && splitter) {
|
|
58749
58665
|
if (animate === 'clear-transition') {
|
|
58750
|
-
transition
|
|
58666
|
+
separator.style.transition = '';
|
|
58667
|
+
splitter.style.transition = '';
|
|
58751
58668
|
splitter.style.cursor =
|
|
58752
58669
|
separator.getAttribute('aria-orientation') === 'vertical'
|
|
58753
58670
|
? 'col-resize'
|
|
@@ -58755,7 +58672,9 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58755
58672
|
splitter.classList.add('resizing');
|
|
58756
58673
|
}
|
|
58757
58674
|
else {
|
|
58758
|
-
transition
|
|
58675
|
+
separator.style.transition = 'left 300ms, top 300ms';
|
|
58676
|
+
splitter.style.transition =
|
|
58677
|
+
'grid-template-columns 300ms, grid-template-rows 300ms';
|
|
58759
58678
|
splitter.style.cursor = '';
|
|
58760
58679
|
splitter.classList.remove('resizing');
|
|
58761
58680
|
}
|
|
@@ -58765,65 +58684,33 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58765
58684
|
/**
|
|
58766
58685
|
* Moves separator as per ratio changes. Centers on first render if ratio is undefined.
|
|
58767
58686
|
*/
|
|
58768
|
-
var useRatioEffect = function (setValueNow,
|
|
58687
|
+
var useRatioEffect = function (setValueNow, ratio) {
|
|
58769
58688
|
var firstRun = React.useRef(true);
|
|
58770
|
-
var _a = getSeparatorAttributes({ ref: separator }), valueMax = _a.valueMax, valueMin = _a.valueMin;
|
|
58771
|
-
var isCalculating = valueMax === Infinity || valueMin === -Infinity;
|
|
58772
58689
|
React.useEffect(function () {
|
|
58773
|
-
if (firstRun.current || ratio !== undefined
|
|
58690
|
+
if (firstRun.current || ratio !== undefined) {
|
|
58774
58691
|
firstRun.current = false;
|
|
58775
58692
|
// If ratio is undefined, setValueNow will place the separator in the middle as a starting point.
|
|
58776
58693
|
// Whatever value is `the middle` will be determined by setValueNow
|
|
58777
|
-
setValueNow(ratio
|
|
58694
|
+
setValueNow(ratio);
|
|
58778
58695
|
}
|
|
58779
|
-
}, [setValueNow, ratio, firstRun
|
|
58696
|
+
}, [setValueNow, ratio, firstRun]);
|
|
58780
58697
|
};
|
|
58781
58698
|
/**
|
|
58782
58699
|
* Re-arranges the splitter if the limits or orientation change.
|
|
58783
58700
|
*/
|
|
58784
58701
|
var useConfigEffect = function (setValueNow, separator) {
|
|
58785
|
-
var _a = React.useState(0), count = _a[0], setCount = _a[1];
|
|
58786
|
-
React.useEffect(function () { return transition(separator).resume(); }, [count]);
|
|
58787
58702
|
React.useEffect(function () {
|
|
58788
|
-
var callback = function (
|
|
58789
|
-
|
|
58790
|
-
|
|
58791
|
-
var target = record.target;
|
|
58792
|
-
var values = getSeparatorAttributes({ separator: target });
|
|
58793
|
-
var oldValue = Number(record.oldValue);
|
|
58794
|
-
var valueMax = values.valueMax, valueMin = values.valueMin, valueNow = values.valueNow;
|
|
58795
|
-
var newValue = attr === 'min' ? valueMin : valueMax;
|
|
58796
|
-
// Determine if separator was collapsed/expanded fully
|
|
58797
|
-
var wasInBoundary = oldValue === valueNow;
|
|
58798
|
-
// To remain collapsed/expanded, it is necessary to call setValueNow with the latest boundaries.
|
|
58799
|
-
// The useBoundaries hook haven't yet reflected the change, and it would cause an unwanted flash.
|
|
58800
|
-
// In such case, the newValueNow is moved along with the delimiter.
|
|
58801
|
-
var newValueNow = !wasInBoundary ? valueNow : newValue;
|
|
58802
|
-
if (wasInBoundary || valueMax < valueNow || valueMin > valueNow) {
|
|
58803
|
-
transition(separator).stop();
|
|
58804
|
-
setValueNow(newValueNow, { min: valueMin, max: valueMax });
|
|
58805
|
-
setCount(function (p) { return p + 1; });
|
|
58806
|
-
}
|
|
58807
|
-
};
|
|
58703
|
+
var callback = function () {
|
|
58704
|
+
var value = getSeparatorAttributes({ ref: separator }).valueNow;
|
|
58705
|
+
setValueNow(value);
|
|
58808
58706
|
};
|
|
58809
|
-
|
|
58810
|
-
|
|
58811
|
-
|
|
58812
|
-
|
|
58813
|
-
var minObserver = new MutationObserver(callback('min'));
|
|
58814
|
-
var maxObserver = new MutationObserver(callback('max'));
|
|
58815
|
-
var orientationObserver = new MutationObserver(function () { return setValueNow(); });
|
|
58816
|
-
minObserver.observe(separator.current, config('min'));
|
|
58817
|
-
maxObserver.observe(separator.current, config('max'));
|
|
58818
|
-
orientationObserver.observe(separator.current, {
|
|
58819
|
-
attributeFilter: ['aria-orientation']
|
|
58707
|
+
callback();
|
|
58708
|
+
var observer = new MutationObserver(callback);
|
|
58709
|
+
observer.observe(separator.current, {
|
|
58710
|
+
attributeFilter: ['aria-orientation', 'aria-valuemin', 'aria-valuemax']
|
|
58820
58711
|
});
|
|
58821
|
-
return function () {
|
|
58822
|
-
|
|
58823
|
-
maxObserver.disconnect();
|
|
58824
|
-
orientationObserver.disconnect();
|
|
58825
|
-
};
|
|
58826
|
-
}, [separator]);
|
|
58712
|
+
return function () { return observer.disconnect(); };
|
|
58713
|
+
}, [separator, setValueNow]);
|
|
58827
58714
|
};
|
|
58828
58715
|
/**
|
|
58829
58716
|
* Broadcasts changes if separator aria-valuenow was altered.
|
|
@@ -58847,49 +58734,12 @@ var useValueNowEffect = function (setValueNow, separator) {
|
|
|
58847
58734
|
/**
|
|
58848
58735
|
* Calls setValueNow when the separator attributes change.
|
|
58849
58736
|
*/
|
|
58850
|
-
var useValueSeparatorEffects = function (setValueNow, separator, ratio
|
|
58851
|
-
useRatioEffect(setValueNow,
|
|
58737
|
+
var useValueSeparatorEffects = function (setValueNow, separator, ratio) {
|
|
58738
|
+
useRatioEffect(setValueNow, ratio);
|
|
58852
58739
|
useConfigEffect(setValueNow, separator);
|
|
58853
58740
|
useValueNowEffect(setValueNow, separator);
|
|
58854
58741
|
};
|
|
58855
58742
|
|
|
58856
|
-
/**
|
|
58857
|
-
* It will calculate the best grid arrangement, based on the min/max props passed to the Splitter.
|
|
58858
|
-
* All grid options work. The preference `1fr XXpx` over `(width - XXpx) 1fr` depends on the type of boundary
|
|
58859
|
-
* to avoid calculation of position when the window is being resized while trying to retain the collapsed state
|
|
58860
|
-
* on a min/max value fixed in pixels (e.g. 200px). Such calculation adds unnecessary lagging on the separator
|
|
58861
|
-
* to catch up. This function aims to avoid such lagging during resizing.
|
|
58862
|
-
* primary relates to top/left
|
|
58863
|
-
* secondary relates to right/bottom
|
|
58864
|
-
*/
|
|
58865
|
-
var getGridTemplate = function (separator) {
|
|
58866
|
-
var _a = getSeparatorAttributes({ separator: separator }), valueNow = _a.valueNow, gap = _a.thickness, boundary = _a.boundary, orientation = _a.orientation;
|
|
58867
|
-
var rect = separator.parentElement.getBoundingClientRect();
|
|
58868
|
-
var dimension = orientation === 'horizontal' ? 'height' : 'width';
|
|
58869
|
-
var seperatorAbsolutePx = (rect[dimension] / 100) * valueNow;
|
|
58870
|
-
var offset = gap / 2;
|
|
58871
|
-
if (boundary === 'keep-primary') {
|
|
58872
|
-
return {
|
|
58873
|
-
grid: "".concat(seperatorAbsolutePx - offset, "px 1fr"),
|
|
58874
|
-
primary: "".concat(seperatorAbsolutePx, "px"),
|
|
58875
|
-
secondary: ''
|
|
58876
|
-
};
|
|
58877
|
-
}
|
|
58878
|
-
if (boundary === 'keep-secondary') {
|
|
58879
|
-
return {
|
|
58880
|
-
grid: "1fr ".concat(rect[dimension] - seperatorAbsolutePx - offset, "px"),
|
|
58881
|
-
primary: '',
|
|
58882
|
-
secondary: "".concat(rect[dimension] - seperatorAbsolutePx, "px")
|
|
58883
|
-
};
|
|
58884
|
-
}
|
|
58885
|
-
var primary = "clamp(".concat(offset, "px, ").concat(valueNow, "%, calc(100% - ").concat(offset, "px))");
|
|
58886
|
-
return {
|
|
58887
|
-
grid: "min(calc(".concat(valueNow, "% - ").concat(gap / 2, "px), calc(100% - ").concat(gap, "px)) 1fr"),
|
|
58888
|
-
primary: primary,
|
|
58889
|
-
secondary: "calc(100% - ".concat(primary, ")")
|
|
58890
|
-
};
|
|
58891
|
-
};
|
|
58892
|
-
|
|
58893
58743
|
/**
|
|
58894
58744
|
* Ensures valueNow is set to a valid value within its allowed boundaries.
|
|
58895
58745
|
* If boundaries and/or initialRatio are not specified, they will be defaulted.
|
|
@@ -58897,24 +58747,19 @@ var getGridTemplate = function (separator) {
|
|
|
58897
58747
|
* This multiple calls are expected, and setValueNow will resize only once.
|
|
58898
58748
|
*/
|
|
58899
58749
|
var useValueSeparator = function (_a) {
|
|
58900
|
-
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized, _b = _a.boundaries,
|
|
58750
|
+
var separator = _a.separator, ratio = _a.ratio, onResized = _a.onResized, _b = _a.boundaries, min = _b.min, max = _b.max;
|
|
58901
58751
|
var prev = React.useRef(null);
|
|
58902
|
-
var setValueNow = React.useCallback(function (val
|
|
58903
|
-
var _a, _b;
|
|
58752
|
+
var setValueNow = React.useCallback(function (val) {
|
|
58904
58753
|
var valueNow = getSeparatorAttributes({ ref: separator }).valueNow;
|
|
58905
|
-
// Prioritize min/max from callback, they are updated before the boundaries prop.
|
|
58906
|
-
var min = (_a = config === null || config === void 0 ? void 0 : config.min) !== null && _a !== void 0 ? _a : minProp;
|
|
58907
|
-
var max = (_b = config === null || config === void 0 ? void 0 : config.max) !== null && _b !== void 0 ? _b : maxProp;
|
|
58908
58754
|
var value = val !== null && val !== void 0 ? val : (valueNow || min + (max - min) / 2);
|
|
58909
58755
|
var newValue = clampSeparator({ value: value, max: max, min: min });
|
|
58910
|
-
var isCalculating = min === -Infinity || max === Infinity;
|
|
58911
58756
|
resize(separator, newValue);
|
|
58912
|
-
if (prev.current !== newValue
|
|
58757
|
+
if (prev.current !== newValue) {
|
|
58913
58758
|
prev.current = newValue;
|
|
58914
58759
|
onResized === null || onResized === void 0 ? void 0 : onResized(newValue);
|
|
58915
58760
|
}
|
|
58916
|
-
}, [onResized,
|
|
58917
|
-
useValueSeparatorEffects(setValueNow, separator, ratio
|
|
58761
|
+
}, [onResized, min, max, prev]);
|
|
58762
|
+
useValueSeparatorEffects(setValueNow, separator, ratio);
|
|
58918
58763
|
return { setValueNow: setValueNow };
|
|
58919
58764
|
};
|
|
58920
58765
|
var resize = function (separator, value) {
|
|
@@ -58930,8 +58775,12 @@ var resize = function (separator, value) {
|
|
|
58930
58775
|
separator.current.setAttribute('aria-valuenow', newValue);
|
|
58931
58776
|
}
|
|
58932
58777
|
var panels = (_a = separator.current.parentElement.childNodes.length) !== null && _a !== void 0 ? _a : 0;
|
|
58933
|
-
var
|
|
58934
|
-
var
|
|
58778
|
+
var valueNow = Number(separator.current.getAttribute('aria-valuenow'));
|
|
58779
|
+
var offset = gap / 2;
|
|
58780
|
+
var absolute = "clamp(".concat(offset, "px, ").concat(valueNow, "%, calc(100% - ").concat(offset, "px))");
|
|
58781
|
+
var gridTemplate = panels === 1
|
|
58782
|
+
? '1fr'
|
|
58783
|
+
: "min(calc(".concat(valueNow, "% - ").concat(gap / 2, "px), calc(100% - ").concat(gap, "px)) 1fr");
|
|
58935
58784
|
var splitter = (_b = separator.current) === null || _b === void 0 ? void 0 : _b.parentElement;
|
|
58936
58785
|
if (splitter) {
|
|
58937
58786
|
splitter.style.opacity = '1';
|
|
@@ -58939,29 +58788,25 @@ var resize = function (separator, value) {
|
|
|
58939
58788
|
splitter.style.columnGap = "".concat(gap, "px");
|
|
58940
58789
|
splitter.style.gridTemplateColumns = gridTemplate;
|
|
58941
58790
|
separator.current.style.width = "".concat(gap, "px");
|
|
58942
|
-
separator.current.style.left =
|
|
58943
|
-
separator.current.style.right = secondary;
|
|
58791
|
+
separator.current.style.left = absolute;
|
|
58944
58792
|
separator.current.style.height = '100%';
|
|
58945
|
-
separator.current.style.transform =
|
|
58793
|
+
separator.current.style.transform = 'translateX(-50%)';
|
|
58946
58794
|
separator.current.style.cursor = 'col-resize';
|
|
58947
58795
|
splitter.style.rowGap = '';
|
|
58948
58796
|
splitter.style.gridTemplateRows = '';
|
|
58949
58797
|
separator.current.style.top = '';
|
|
58950
|
-
separator.current.style.bottom = '';
|
|
58951
58798
|
}
|
|
58952
58799
|
else {
|
|
58953
58800
|
splitter.style.rowGap = "".concat(gap, "px");
|
|
58954
58801
|
splitter.style.gridTemplateRows = gridTemplate;
|
|
58955
58802
|
separator.current.style.height = "".concat(gap, "px");
|
|
58956
|
-
separator.current.style.top =
|
|
58957
|
-
separator.current.style.bottom = secondary;
|
|
58803
|
+
separator.current.style.top = absolute;
|
|
58958
58804
|
separator.current.style.width = '100%';
|
|
58959
|
-
separator.current.style.transform =
|
|
58805
|
+
separator.current.style.transform = 'translateY(-50%)';
|
|
58960
58806
|
separator.current.style.cursor = 'row-resize';
|
|
58961
58807
|
splitter.style.columnGap = '';
|
|
58962
58808
|
splitter.style.gridTemplateColumns = '';
|
|
58963
58809
|
separator.current.style.left = '';
|
|
58964
|
-
separator.current.style.right = '';
|
|
58965
58810
|
}
|
|
58966
58811
|
}
|
|
58967
58812
|
};
|
|
@@ -59045,62 +58890,6 @@ var getNewValueNow = function (_a, valueNow, pixelUnit) {
|
|
|
59045
58890
|
return valueNow;
|
|
59046
58891
|
};
|
|
59047
58892
|
|
|
59048
|
-
var isPxProps = function (_a) {
|
|
59049
|
-
var min = _a.min, max = _a.max;
|
|
59050
|
-
var isPercentage = typeof max === 'number' || typeof min === 'number';
|
|
59051
|
-
var isNull = min === undefined && max === undefined;
|
|
59052
|
-
return !isPercentage && !isNull;
|
|
59053
|
-
};
|
|
59054
|
-
/**
|
|
59055
|
-
* Maps min and max values if they are provided in 'XXXpx' format.
|
|
59056
|
-
*/
|
|
59057
|
-
var useBoundary = function (separator, boundaries) {
|
|
59058
|
-
var _a = React.useState({ min: -Infinity, max: Infinity }), mapped = _a[0], setMapped = _a[1];
|
|
59059
|
-
var isPx = isPxProps(boundaries);
|
|
59060
|
-
var min = boundaries.min, max = boundaries.max;
|
|
59061
|
-
React.useEffect(function () {
|
|
59062
|
-
var _a;
|
|
59063
|
-
var element = (_a = separator === null || separator === void 0 ? void 0 : separator.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
59064
|
-
var shouldMap = element && isPx;
|
|
59065
|
-
var observer = new ResizeObserver(function (_a) {
|
|
59066
|
-
var rect = _a[0].contentRect;
|
|
59067
|
-
var _b = getSeparatorAttributes({
|
|
59068
|
-
ref: separator
|
|
59069
|
-
}), thickness = _b.thickness, orientation = _b.orientation;
|
|
59070
|
-
var halfThickness = thickness / 2;
|
|
59071
|
-
var length = orientation === 'vertical' ? rect.width : rect.height;
|
|
59072
|
-
var parse = function (boundary) {
|
|
59073
|
-
if (typeof boundary === 'number') {
|
|
59074
|
-
return boundary;
|
|
59075
|
-
}
|
|
59076
|
-
var boundaryAsNumber = parseFloat(boundary);
|
|
59077
|
-
var offset = boundaryAsNumber > 0
|
|
59078
|
-
? boundaryAsNumber + halfThickness
|
|
59079
|
-
: length - Math.abs(boundaryAsNumber) - halfThickness;
|
|
59080
|
-
return (offset / length) * 100;
|
|
59081
|
-
};
|
|
59082
|
-
setMapped({ min: parse(min !== null && min !== void 0 ? min : 0), max: parse(max !== null && max !== void 0 ? max : 100) });
|
|
59083
|
-
});
|
|
59084
|
-
if (shouldMap) {
|
|
59085
|
-
observer.observe(element);
|
|
59086
|
-
}
|
|
59087
|
-
return function () {
|
|
59088
|
-
if (shouldMap) {
|
|
59089
|
-
observer.disconnect();
|
|
59090
|
-
}
|
|
59091
|
-
};
|
|
59092
|
-
}, [separator, max, min, isPx]);
|
|
59093
|
-
if (isPx) {
|
|
59094
|
-
return mapped;
|
|
59095
|
-
}
|
|
59096
|
-
else {
|
|
59097
|
-
return {
|
|
59098
|
-
min: Math.max(Number(min !== null && min !== void 0 ? min : 0), 0),
|
|
59099
|
-
max: Math.min(Number(max !== null && max !== void 0 ? max : 100), 100)
|
|
59100
|
-
};
|
|
59101
|
-
}
|
|
59102
|
-
};
|
|
59103
|
-
|
|
59104
58893
|
var canceEvent = function (e) {
|
|
59105
58894
|
if (e.currentTarget !== e.target) {
|
|
59106
58895
|
e.preventDefault();
|
|
@@ -59109,19 +58898,21 @@ var canceEvent = function (e) {
|
|
|
59109
58898
|
};
|
|
59110
58899
|
var Separator = React.forwardRef(function (_a, forwardRef) {
|
|
59111
58900
|
var _b;
|
|
59112
|
-
var parts = _a.parts, ratio = _a.ratio, onResized = _a.onResized,
|
|
58901
|
+
var parts = _a.parts, ratio = _a.ratio, onResized = _a.onResized, props = __rest(_a, ["parts", "ratio", "onResized"]);
|
|
59113
58902
|
var separator = useForkRef(forwardRef);
|
|
59114
|
-
var boundaries =
|
|
58903
|
+
var boundaries = {
|
|
58904
|
+
min: props['aria-valuemin'],
|
|
58905
|
+
max: props['aria-valuemax']
|
|
58906
|
+
};
|
|
59115
58907
|
var setValueNow = useValueSeparator({
|
|
59116
58908
|
ratio: ratio,
|
|
59117
58909
|
separator: separator,
|
|
59118
58910
|
onResized: onResized,
|
|
59119
|
-
boundaries: boundaries
|
|
59120
|
-
startAt: startAt
|
|
58911
|
+
boundaries: boundaries
|
|
59121
58912
|
}).setValueNow;
|
|
59122
58913
|
useShowSeparator(separator);
|
|
59123
58914
|
var values = function () { return getSeparatorAttributes({ ref: separator }); };
|
|
59124
|
-
return (React__default["default"].createElement("div", __assign({ ref: separator
|
|
58915
|
+
return (React__default["default"].createElement("div", __assign({ ref: separator }, props, useMoveSeparator(separator, setValueNow), { onKeyDown: function (e) {
|
|
59125
58916
|
var _a;
|
|
59126
58917
|
var newValueNow = keyDownHandler(e);
|
|
59127
58918
|
if (values().valueNow !== newValueNow) {
|
|
@@ -59171,31 +58962,12 @@ styleInject(css_248z);
|
|
|
59171
58962
|
*/
|
|
59172
58963
|
var Splitter = React.forwardRef(function (props, ref) {
|
|
59173
58964
|
if (props === void 0) { props = {}; }
|
|
59174
|
-
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,
|
|
58965
|
+
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"]);
|
|
59175
58966
|
return (React__default["default"].createElement("div", __assign({ ref: ref }, rest, { className: clsx('Splitter', rest === null || rest === void 0 ? void 0 : rest.className) }),
|
|
59176
58967
|
children,
|
|
59177
|
-
React__default["default"].createElement(Separator, __assign({}, parts === null || parts === void 0 ? void 0 : parts.separator, { tabIndex: 0, min:
|
|
58968
|
+
React__default["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 }))));
|
|
59178
58969
|
});
|
|
59179
|
-
Splitter.displayName = 'Splitter';
|
|
59180
|
-
var mapStartAt = function (props) {
|
|
59181
|
-
var _a;
|
|
59182
|
-
if (typeof props.ratio === 'number') {
|
|
59183
|
-
// Only consider startAt value when Splitter is uncontrolled (ratio is undefined)
|
|
59184
|
-
return undefined;
|
|
59185
|
-
}
|
|
59186
|
-
// Words describe better intent than numbers.
|
|
59187
|
-
// However, 0 & 100 are figurative numbers.
|
|
59188
|
-
// If there are boundaries, these will be respected.
|
|
59189
|
-
switch (props.startAt) {
|
|
59190
|
-
case '1st-collapsed':
|
|
59191
|
-
return 0;
|
|
59192
|
-
case '2nd-collapsed':
|
|
59193
|
-
return 100;
|
|
59194
|
-
default:
|
|
59195
|
-
// Can be started at any other number between 0 and 100.
|
|
59196
|
-
return (_a = props.startAt) !== null && _a !== void 0 ? _a : 50;
|
|
59197
|
-
}
|
|
59198
|
-
};
|
|
58970
|
+
Splitter.displayName = 'Splitter';
|
|
59199
58971
|
|
|
59200
58972
|
var getSeparator = function (splitter) {
|
|
59201
58973
|
var _a;
|