@geomak/ui 7.4.1 → 7.4.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/dist/index.cjs CHANGED
@@ -4596,7 +4596,7 @@ function ScalableContainer({
4596
4596
  collapseIcon,
4597
4597
  togglePosition = "top-right",
4598
4598
  expandContainerRef,
4599
- expandRatio = 5,
4599
+ expandRatio = 3,
4600
4600
  className = ""
4601
4601
  }) {
4602
4602
  const containerRef = React30.useRef(null);
@@ -4606,6 +4606,15 @@ function ScalableContainer({
4606
4606
  const usePush = expandContainerRef != null;
4607
4607
  const grownRef = React30.useRef([]);
4608
4608
  const prevScaled = React30.useRef(isScaled);
4609
+ const kickResizeDuringTransition = () => {
4610
+ if (typeof window === "undefined") return;
4611
+ const kick = () => window.dispatchEvent(new Event("resize"));
4612
+ const interval = window.setInterval(kick, 80);
4613
+ window.setTimeout(() => {
4614
+ window.clearInterval(interval);
4615
+ kick();
4616
+ }, reduced ? 0 : 400);
4617
+ };
4609
4618
  const growAncestors = () => {
4610
4619
  const bound = expandContainerRef?.current;
4611
4620
  if (!bound || !containerRef.current) return;
@@ -4613,30 +4622,43 @@ function ScalableContainer({
4613
4622
  let el = containerRef.current.parentElement;
4614
4623
  while (el && el !== bound && bound.contains(el)) {
4615
4624
  const parent = el.parentElement;
4616
- if (parent && getComputedStyle(parent).display.includes("flex")) {
4625
+ const parentStyle = parent ? getComputedStyle(parent) : null;
4626
+ if (parent && parentStyle && parentStyle.display.includes("flex")) {
4617
4627
  grown.push({
4618
4628
  el,
4629
+ parent,
4619
4630
  prev: {
4620
4631
  flexGrow: el.style.flexGrow,
4621
4632
  flexBasis: el.style.flexBasis,
4622
- transition: el.style.transition
4633
+ height: el.style.height,
4634
+ transition: el.style.transition,
4635
+ parentFlexWrap: parent.style.flexWrap
4623
4636
  }
4624
4637
  });
4625
- const grow = `flex-grow ${reduced ? 0 : 0.32}s cubic-bezier(0.16, 1, 0.3, 1), flex-basis ${reduced ? 0 : 0.32}s cubic-bezier(0.16, 1, 0.3, 1)`;
4626
- el.style.transition = el.style.transition ? `${el.style.transition}, ${grow}` : grow;
4627
- el.style.flexBasis = "0%";
4628
- el.style.flexGrow = String(expandRatio);
4638
+ const t = (prop) => `${prop} ${reduced ? 0 : 0.32}s cubic-bezier(0.16, 1, 0.3, 1)`;
4639
+ const ours = `${t("flex-grow")}, ${t("flex-basis")}, ${t("height")}`;
4640
+ el.style.transition = el.style.transition ? `${el.style.transition}, ${ours}` : ours;
4641
+ if (parentStyle.flexDirection.startsWith("row")) {
4642
+ parent.style.flexWrap = "wrap";
4643
+ el.style.flexBasis = "100%";
4644
+ el.style.height = `${expandRatio / (expandRatio + 1) * 100}%`;
4645
+ } else {
4646
+ el.style.flexBasis = "0%";
4647
+ el.style.flexGrow = String(expandRatio);
4648
+ }
4629
4649
  }
4630
4650
  el = parent;
4631
4651
  }
4632
4652
  grownRef.current = grown;
4633
4653
  };
4634
4654
  const restoreAncestors = () => {
4635
- for (const { el, prev } of grownRef.current) {
4655
+ for (const { el, parent, prev } of grownRef.current) {
4636
4656
  el.style.flexGrow = prev.flexGrow;
4637
4657
  el.style.flexBasis = prev.flexBasis;
4658
+ el.style.height = prev.height;
4638
4659
  window.setTimeout(() => {
4639
4660
  el.style.transition = prev.transition;
4661
+ parent.style.flexWrap = prev.parentFlexWrap;
4640
4662
  }, reduced ? 0 : 360);
4641
4663
  }
4642
4664
  grownRef.current = [];
@@ -4646,12 +4668,15 @@ function ScalableContainer({
4646
4668
  prevScaled.current = isScaled;
4647
4669
  if (isScaled) growAncestors();
4648
4670
  else restoreAncestors();
4671
+ kickResizeDuringTransition();
4649
4672
  }, [isScaled, usePush]);
4650
4673
  React30.useEffect(() => () => {
4651
- for (const { el, prev } of grownRef.current) {
4674
+ for (const { el, parent, prev } of grownRef.current) {
4652
4675
  el.style.flexGrow = prev.flexGrow;
4653
4676
  el.style.flexBasis = prev.flexBasis;
4677
+ el.style.height = prev.height;
4654
4678
  el.style.transition = prev.transition;
4679
+ parent.style.flexWrap = prev.parentFlexWrap;
4655
4680
  }
4656
4681
  }, []);
4657
4682
  const onToggle = () => {
@@ -4670,6 +4695,10 @@ function ScalableContainer({
4670
4695
  framerMotion.motion.div,
4671
4696
  {
4672
4697
  ref: containerRef,
4698
+ style: {
4699
+ width: isScaled && !usePush ? expandedWidth : width,
4700
+ height: isScaled && !usePush ? expandedHeight : height
4701
+ },
4673
4702
  animate: {
4674
4703
  // Push mode keeps the container filling its (now growing)
4675
4704
  // wrapper — the wrapper's flex-grow does the work.