@linzjs/lui 21.26.0 → 21.26.2

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [21.26.2](https://github.com/linz/lui/compare/v21.26.1...v21.26.2) (2024-04-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **Splitter:** calculation based on aria-valuenow ([#1111](https://github.com/linz/lui/issues/1111)) ([1b60dad](https://github.com/linz/lui/commit/1b60dad8bfe401d5d6ce30176ef2139e8c5a7626))
7
+
8
+ ## [21.26.1](https://github.com/linz/lui/compare/v21.26.0...v21.26.1) (2024-04-15)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **Splitter:** issue min/max @ 0px ([#1110](https://github.com/linz/lui/issues/1110)) ([500778b](https://github.com/linz/lui/commit/500778b07eeefdbf2a193819733a2541a3deb302))
14
+
1
15
  # [21.26.0](https://github.com/linz/lui/compare/v21.25.0...v21.26.0) (2024-04-11)
2
16
 
3
17
 
package/dist/index.js CHANGED
@@ -58762,6 +58762,15 @@ var animateSeparator = function (separatorRef, animate) {
58762
58762
  }
58763
58763
  };
58764
58764
 
58765
+ var useSetValueNow_static = function (setValueNow, separator) {
58766
+ var _a = React.useState(0), count = _a[0], setCount = _a[1];
58767
+ React.useEffect(function () { return transition(separator).resume(); }, [count]);
58768
+ return React.useCallback(function (val, config) {
58769
+ transition(separator).stop();
58770
+ setValueNow(val, config);
58771
+ setCount(function (p) { return p + 1; });
58772
+ }, [setValueNow]);
58773
+ };
58765
58774
  /**
58766
58775
  * Moves separator as per ratio changes. Centers on first render if ratio is undefined.
58767
58776
  */
@@ -58782,8 +58791,7 @@ var useRatioEffect = function (setValueNow, separator, ratio, startAt) {
58782
58791
  * Re-arranges the splitter if the limits or orientation change.
58783
58792
  */
58784
58793
  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]);
58794
+ var setValueNow_static = useSetValueNow_static(setValueNow, separator);
58787
58795
  React.useEffect(function () {
58788
58796
  var callback = function (attr) {
58789
58797
  return function (_a) {
@@ -58800,20 +58808,26 @@ var useConfigEffect = function (setValueNow, separator) {
58800
58808
  // In such case, the newValueNow is moved along with the delimiter.
58801
58809
  var newValueNow = !wasInBoundary ? valueNow : newValue;
58802
58810
  if (wasInBoundary || valueMax < valueNow || valueMin > valueNow) {
58803
- transition(separator).stop();
58804
- setValueNow(newValueNow, { min: valueMin, max: valueMax });
58805
- setCount(function (p) { return p + 1; });
58811
+ setValueNow_static(newValueNow, { min: valueMin, max: valueMax });
58806
58812
  }
58807
58813
  else {
58814
+ var threshold = 0.01;
58808
58815
  var dim = values.orientation === 'vertical' ? 'width' : 'height';
58809
- var offset = target.getBoundingClientRect()[dim] / 2;
58810
- var splitter = target.parentElement;
58811
- var primary = splitter.childNodes[0];
58812
- var splitterRect = splitter.getBoundingClientRect();
58813
- var primaryRect = primary.getBoundingClientRect();
58814
- var newVal = ((primaryRect[dim] + offset) / splitterRect[dim]) * 100;
58815
- if (Math.abs(newVal - valueNow) >= 0.01) {
58816
- setValueNow(newVal, { min: valueMin, max: valueMax });
58816
+ var abs = values.orientation === 'vertical' ? 'left' : 'top';
58817
+ var separatorRect = target.getBoundingClientRect();
58818
+ var gap = separatorRect[dim];
58819
+ var offset = gap / 2;
58820
+ var splitterEl = target.parentElement;
58821
+ var splitterRect = splitterEl.getBoundingClientRect();
58822
+ var container = splitterRect[dim];
58823
+ var primary = Math.max(separatorRect[abs] - splitterRect[abs], 0);
58824
+ var secondary = Math.max(container - primary - gap, 0);
58825
+ if (primary < threshold || secondary < threshold) {
58826
+ return;
58827
+ }
58828
+ var newVal = ((primary + offset) / container) * 100;
58829
+ if (Math.abs(newVal - valueNow) >= threshold) {
58830
+ setValueNow_static(newVal, { min: valueMin, max: valueMax });
58817
58831
  }
58818
58832
  }
58819
58833
  };
@@ -58880,25 +58894,29 @@ var getGridTemplate = function (separator) {
58880
58894
  var dimension = orientation === 'horizontal' ? 'height' : 'width';
58881
58895
  var seperatorAbsolutePx = (rect[dimension] / 100) * valueNow;
58882
58896
  var offset = gap / 2;
58897
+ var clamp = function (val, type) {
58898
+ return "clamp(".concat(offset, "px, ").concat(val).concat(type, ", calc(100% - ").concat(offset, "px))");
58899
+ };
58883
58900
  if (boundary === 'keep-primary') {
58901
+ var grid = Math.max(seperatorAbsolutePx - offset, 0);
58884
58902
  return {
58885
- grid: "".concat(seperatorAbsolutePx - offset, "px 1fr"),
58886
- primary: "".concat(seperatorAbsolutePx, "px"),
58903
+ grid: "".concat(grid, "px 1fr"),
58904
+ primary: clamp(seperatorAbsolutePx, 'px'),
58887
58905
  secondary: ''
58888
58906
  };
58889
58907
  }
58890
58908
  if (boundary === 'keep-secondary') {
58909
+ var grid = Math.max(rect[dimension] - seperatorAbsolutePx - offset, 0);
58891
58910
  return {
58892
- grid: "1fr ".concat(rect[dimension] - seperatorAbsolutePx - offset, "px"),
58911
+ grid: "1fr ".concat(grid, "px"),
58893
58912
  primary: '',
58894
- secondary: "".concat(rect[dimension] - seperatorAbsolutePx, "px")
58913
+ secondary: clamp(rect[dimension] - seperatorAbsolutePx, 'px')
58895
58914
  };
58896
58915
  }
58897
- var primary = "clamp(".concat(offset, "px, ").concat(valueNow, "%, calc(100% - ").concat(offset, "px))");
58898
58916
  return {
58899
58917
  grid: "min(calc(".concat(valueNow, "% - ").concat(gap / 2, "px), calc(100% - ").concat(gap, "px)) 1fr"),
58900
- primary: primary,
58901
- secondary: "calc(100% - ".concat(primary, ")")
58918
+ primary: clamp(valueNow, '%'),
58919
+ secondary: "calc(100% - ".concat(clamp(valueNow, '%'), ")")
58902
58920
  };
58903
58921
  };
58904
58922
 
@@ -59113,7 +59131,7 @@ var useBoundary = function (separator, boundaries) {
59113
59131
  }
59114
59132
  };
59115
59133
 
59116
- var canceEvent = function (e) {
59134
+ var cancelEvent = function (e) {
59117
59135
  if (e.currentTarget !== e.target) {
59118
59136
  e.preventDefault();
59119
59137
  e.stopPropagation();
@@ -59142,7 +59160,7 @@ var Separator = React.forwardRef(function (_a, forwardRef) {
59142
59160
  }
59143
59161
  (_a = props === null || props === void 0 ? void 0 : props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, e);
59144
59162
  }, className: clsx('Separator', props.className) }),
59145
- 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: canceEvent, onTouchStart: canceEvent }),
59163
+ 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 }),
59146
59164
  React__default["default"].createElement(Control, __assign({}, parts === null || parts === void 0 ? void 0 : parts.primary, { side: "primary", onClick: function (e) {
59147
59165
  var _a, _b;
59148
59166
  setValueNow(controlClickHandler(e, 'primary'));