@linzjs/lui 21.26.1 → 21.26.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/components/Splitter/helpers/transition.d.ts +1 -1
- package/dist/index.js +59 -43
- package/dist/index.js.map +1 -1
- package/dist/lui.esm.js +59 -43
- package/dist/lui.esm.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [21.26.3](https://github.com/linz/lui/compare/v21.26.2...v21.26.3) (2024-04-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **Splitter:** make transition be triggered manually ([#1112](https://github.com/linz/lui/issues/1112)) ([f07a612](https://github.com/linz/lui/commit/f07a612e9c28d8f88186d3d038b1a3334c7cb065))
|
|
7
|
+
|
|
8
|
+
## [21.26.2](https://github.com/linz/lui/compare/v21.26.1...v21.26.2) (2024-04-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **Splitter:** calculation based on aria-valuenow ([#1111](https://github.com/linz/lui/issues/1111)) ([1b60dad](https://github.com/linz/lui/commit/1b60dad8bfe401d5d6ce30176ef2139e8c5a7626))
|
|
14
|
+
|
|
1
15
|
## [21.26.1](https://github.com/linz/lui/compare/v21.26.0...v21.26.1) (2024-04-15)
|
|
2
16
|
|
|
3
17
|
|
package/dist/index.js
CHANGED
|
@@ -58439,7 +58439,7 @@ var LuiPagination = function (_a) {
|
|
|
58439
58439
|
React__default["default"].createElement("div", { className: "pagination" }, renderPaginationNumbers())))));
|
|
58440
58440
|
};
|
|
58441
58441
|
|
|
58442
|
-
var css_248z$2 = "/**\n @deprecated\n */\n/**\n @deprecated\n */\n/**\n @deprecated\n */\n.Separator {\n background-color: #eaeaea;\n position: absolute;\n display: flex;\n justify-content: space-around;\n transition-property: background-color;\n transition-delay: 750ms;\n transition-duration:
|
|
58442
|
+
var css_248z$2 = "/**\n @deprecated\n */\n/**\n @deprecated\n */\n/**\n @deprecated\n */\n.Separator {\n background-color: #eaeaea;\n position: absolute;\n display: flex;\n justify-content: space-around;\n transition-property: background-color;\n transition-delay: 750ms;\n transition-duration: 0ms;\n}\n.Separator-arrows {\n align-self: center;\n position: relative;\n opacity: 0;\n transition-property: opacity;\n transition-delay: 750ms;\n transition-duration: 0ms;\n}\n.Separator:focus-within, .Separator:hover, .Separator:focus, .Separator:active {\n background-color: #73c8e1;\n transition-delay: 0ms;\n transition-duration: 0ms;\n}\n.Separator:focus-within .Separator-arrows, .Separator:hover .Separator-arrows, .Separator:focus .Separator-arrows, .Separator:active .Separator-arrows {\n opacity: 1;\n transition-delay: 0ms;\n transition-duration: 0ms;\n display: inline-block;\n}";
|
|
58443
58443
|
styleInject(css_248z$2);
|
|
58444
58444
|
|
|
58445
58445
|
var css_248z$1 = ".Control {\n transition: opacity 0.2s ease;\n position: absolute;\n margin-left: 0 !important;\n display: flex;\n justify-content: space-around;\n align-items: center;\n}";
|
|
@@ -58681,29 +58681,6 @@ var getSeparatorPosition = function (separatorRef, drag) {
|
|
|
58681
58681
|
return clampSeparator({ value: value });
|
|
58682
58682
|
};
|
|
58683
58683
|
|
|
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
58684
|
/**
|
|
58708
58685
|
* It captures window events to report a new position.
|
|
58709
58686
|
* Provides necessary handlers for separator.
|
|
@@ -58747,7 +58724,6 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58747
58724
|
var splitter = separator === null || separator === void 0 ? void 0 : separator.parentElement;
|
|
58748
58725
|
if (separator && splitter) {
|
|
58749
58726
|
if (animate === 'clear-transition') {
|
|
58750
|
-
transition(separatorRef).stop();
|
|
58751
58727
|
splitter.style.cursor =
|
|
58752
58728
|
separator.getAttribute('aria-orientation') === 'vertical'
|
|
58753
58729
|
? 'col-resize'
|
|
@@ -58755,13 +58731,40 @@ var animateSeparator = function (separatorRef, animate) {
|
|
|
58755
58731
|
splitter.classList.add('resizing');
|
|
58756
58732
|
}
|
|
58757
58733
|
else {
|
|
58758
|
-
transition(separatorRef).resume();
|
|
58759
58734
|
splitter.style.cursor = '';
|
|
58760
58735
|
splitter.classList.remove('resizing');
|
|
58761
58736
|
}
|
|
58762
58737
|
}
|
|
58763
58738
|
};
|
|
58764
58739
|
|
|
58740
|
+
var transitionFactory = function (attrs, ms) {
|
|
58741
|
+
return attrs.map(function (key) { return "".concat(key, " ").concat(ms, "ms"); }).join(', ');
|
|
58742
|
+
};
|
|
58743
|
+
var barTransition = function (ms) {
|
|
58744
|
+
return transitionFactory(['left', 'top', 'right', 'bottom'], ms);
|
|
58745
|
+
};
|
|
58746
|
+
var gridTransition = function (ms) {
|
|
58747
|
+
return transitionFactory(['grid-template-columns', 'grid-template-rows'], ms);
|
|
58748
|
+
};
|
|
58749
|
+
var transition = function (props) {
|
|
58750
|
+
var _a;
|
|
58751
|
+
var separator = Object.hasOwn(props, 'current')
|
|
58752
|
+
? props
|
|
58753
|
+
: { current: props };
|
|
58754
|
+
var splitter = (_a = separator.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
58755
|
+
var delay = function (ms) {
|
|
58756
|
+
if (splitter) {
|
|
58757
|
+
separator.current.style.transition = barTransition(ms);
|
|
58758
|
+
splitter.style.transition = gridTransition(ms);
|
|
58759
|
+
}
|
|
58760
|
+
};
|
|
58761
|
+
var stop = function () { return delay(0); };
|
|
58762
|
+
var resume = function () {
|
|
58763
|
+
return delay((splitter === null || splitter === void 0 ? void 0 : splitter.classList.contains('resizing')) ? 0 : 300);
|
|
58764
|
+
};
|
|
58765
|
+
return { stop: stop, resume: resume };
|
|
58766
|
+
};
|
|
58767
|
+
|
|
58765
58768
|
/**
|
|
58766
58769
|
* Moves separator as per ratio changes. Centers on first render if ratio is undefined.
|
|
58767
58770
|
*/
|
|
@@ -58770,6 +58773,9 @@ var useRatioEffect = function (setValueNow, separator, ratio, startAt) {
|
|
|
58770
58773
|
var _a = getSeparatorAttributes({ ref: separator }), valueMax = _a.valueMax, valueMin = _a.valueMin;
|
|
58771
58774
|
var isCalculating = valueMax === Infinity || valueMin === -Infinity;
|
|
58772
58775
|
React.useEffect(function () {
|
|
58776
|
+
if (!firstRun.current && ratio !== undefined && !isCalculating) {
|
|
58777
|
+
transition(separator).resume();
|
|
58778
|
+
}
|
|
58773
58779
|
if (firstRun.current || ratio !== undefined || isCalculating) {
|
|
58774
58780
|
firstRun.current = false;
|
|
58775
58781
|
// If ratio is undefined, setValueNow will place the separator in the middle as a starting point.
|
|
@@ -58782,8 +58788,6 @@ var useRatioEffect = function (setValueNow, separator, ratio, startAt) {
|
|
|
58782
58788
|
* Re-arranges the splitter if the limits or orientation change.
|
|
58783
58789
|
*/
|
|
58784
58790
|
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
58791
|
React.useEffect(function () {
|
|
58788
58792
|
var callback = function (attr) {
|
|
58789
58793
|
return function (_a) {
|
|
@@ -58800,26 +58804,25 @@ var useConfigEffect = function (setValueNow, separator) {
|
|
|
58800
58804
|
// In such case, the newValueNow is moved along with the delimiter.
|
|
58801
58805
|
var newValueNow = !wasInBoundary ? valueNow : newValue;
|
|
58802
58806
|
if (wasInBoundary || valueMax < valueNow || valueMin > valueNow) {
|
|
58803
|
-
transition(separator).stop();
|
|
58804
58807
|
setValueNow(newValueNow, { min: valueMin, max: valueMax });
|
|
58805
|
-
setCount(function (p) { return p + 1; });
|
|
58806
58808
|
}
|
|
58807
58809
|
else {
|
|
58810
|
+
var threshold = 0.01;
|
|
58808
58811
|
var dim = values.orientation === 'vertical' ? 'width' : 'height';
|
|
58809
|
-
var
|
|
58812
|
+
var abs = values.orientation === 'vertical' ? 'left' : 'top';
|
|
58813
|
+
var separatorRect = target.getBoundingClientRect();
|
|
58814
|
+
var gap = separatorRect[dim];
|
|
58810
58815
|
var offset = gap / 2;
|
|
58811
58816
|
var splitterEl = target.parentElement;
|
|
58812
|
-
var primaryEl = splitterEl.childNodes[0];
|
|
58813
58817
|
var splitterRect = splitterEl.getBoundingClientRect();
|
|
58814
|
-
var primaryRect = primaryEl.getBoundingClientRect();
|
|
58815
58818
|
var container = splitterRect[dim];
|
|
58816
|
-
var primary =
|
|
58817
|
-
var
|
|
58818
|
-
if (primary
|
|
58819
|
+
var primary = Math.max(separatorRect[abs] - splitterRect[abs], 0);
|
|
58820
|
+
var secondary = Math.max(container - primary - gap, 0);
|
|
58821
|
+
if (primary < threshold || secondary < threshold) {
|
|
58819
58822
|
return;
|
|
58820
58823
|
}
|
|
58821
58824
|
var newVal = ((primary + offset) / container) * 100;
|
|
58822
|
-
if (Math.abs(newVal - valueNow) >=
|
|
58825
|
+
if (Math.abs(newVal - valueNow) >= threshold) {
|
|
58823
58826
|
setValueNow(newVal, { min: valueMin, max: valueMax });
|
|
58824
58827
|
}
|
|
58825
58828
|
}
|
|
@@ -58850,16 +58853,22 @@ var useConfigEffect = function (setValueNow, separator) {
|
|
|
58850
58853
|
var useValueNowEffect = function (setValueNow, separator) {
|
|
58851
58854
|
React.useEffect(function () {
|
|
58852
58855
|
var observer = new MutationObserver(function (_a) {
|
|
58853
|
-
var
|
|
58856
|
+
var _b = _a[0], target = _b.target, oldValue = _b.oldValue;
|
|
58854
58857
|
var el = target;
|
|
58855
58858
|
var splitter = target.parentElement;
|
|
58856
58859
|
var newValueNow = Number(el.getAttribute('aria-valuenow'));
|
|
58857
58860
|
if (!splitter.classList.contains('resizing')) {
|
|
58858
|
-
|
|
58861
|
+
if (Number(oldValue) !== newValueNow) {
|
|
58862
|
+
transition(separator).resume();
|
|
58863
|
+
setValueNow(newValueNow);
|
|
58864
|
+
}
|
|
58859
58865
|
}
|
|
58860
58866
|
});
|
|
58861
58867
|
var attributeFilter = ['aria-valuenow'];
|
|
58862
|
-
observer.observe(separator.current, {
|
|
58868
|
+
observer.observe(separator.current, {
|
|
58869
|
+
attributeFilter: attributeFilter,
|
|
58870
|
+
attributeOldValue: true
|
|
58871
|
+
});
|
|
58863
58872
|
return function () { return observer.disconnect(); };
|
|
58864
58873
|
}, [separator, setValueNow]);
|
|
58865
58874
|
};
|
|
@@ -59124,7 +59133,7 @@ var useBoundary = function (separator, boundaries) {
|
|
|
59124
59133
|
}
|
|
59125
59134
|
};
|
|
59126
59135
|
|
|
59127
|
-
var
|
|
59136
|
+
var cancelEvent = function (e) {
|
|
59128
59137
|
if (e.currentTarget !== e.target) {
|
|
59129
59138
|
e.preventDefault();
|
|
59130
59139
|
e.stopPropagation();
|
|
@@ -59148,19 +59157,26 @@ var Separator = React.forwardRef(function (_a, forwardRef) {
|
|
|
59148
59157
|
var _a;
|
|
59149
59158
|
var newValueNow = keyDownHandler(e);
|
|
59150
59159
|
if (values().valueNow !== newValueNow) {
|
|
59160
|
+
transition(separator).resume();
|
|
59151
59161
|
setValueNow(newValueNow);
|
|
59152
59162
|
e.preventDefault();
|
|
59153
59163
|
}
|
|
59154
59164
|
(_a = props === null || props === void 0 ? void 0 : props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
59155
|
-
}, className: clsx('Separator', props.className)
|
|
59156
|
-
|
|
59165
|
+
}, className: clsx('Separator', props.className), onTransitionEnd: function (e) {
|
|
59166
|
+
var _a;
|
|
59167
|
+
transition(separator).stop();
|
|
59168
|
+
(_a = props.onTransitionEnd) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
59169
|
+
} }),
|
|
59170
|
+
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 }),
|
|
59157
59171
|
React__default["default"].createElement(Control, __assign({}, parts === null || parts === void 0 ? void 0 : parts.primary, { side: "primary", onClick: function (e) {
|
|
59158
59172
|
var _a, _b;
|
|
59173
|
+
transition(separator).resume();
|
|
59159
59174
|
setValueNow(controlClickHandler(e, 'primary'));
|
|
59160
59175
|
(_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);
|
|
59161
59176
|
} })),
|
|
59162
59177
|
React__default["default"].createElement(Control, __assign({}, parts === null || parts === void 0 ? void 0 : parts.secondary, { side: "secondary", onClick: function (e) {
|
|
59163
59178
|
var _a, _b;
|
|
59179
|
+
transition(separator).resume();
|
|
59164
59180
|
setValueNow(controlClickHandler(e, 'secondary'));
|
|
59165
59181
|
(_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);
|
|
59166
59182
|
} })))));
|